MML Annotations
MML Annotations
Overview
Nokia recently released a Math Markup Language (MML) Solution which provides an easy to use MML Widget. We can use this widget to provide a MML annotation in VisIt that will allow users to overlay complex mathematical formulas in movies.
Below is a simple proof of concept that shows how to create a QtMmlWidget and render its contents into a QImage. The example
app saves the QImage to a file, but the image data could easily be converted to a vtk image and become an annotation.
#include <QtCore>
#include <QtGui>
#include <qtmmlwidget.h>
#include <iostream>
int main( int argc, char ** argv )
{
if(argc < 3)
{
std::cout << "usage: qtmmlrender [input.mml] [output_image.png]" <<end;
exit(-1);
}
QApplication app(argc,argv);
// Create the widget but don't show it
QtMmlWidget *mmlw = new QtMmlWidget();
// Open the mml source file.
QFile ifile(argv[1]);
if (!ifile.open(QIODevice::ReadOnly))
{/* Handle Error. */}
QTextStream istream(&ifile);
QString mml_text = istream.readAll();
ifile.close();
QString emsg;
int eline;
int ecol;
if!(mmlw->setContent(mml_text, &emsg, &eline,&ecol))
{/* Handle Error. */}
// Set transparent background
mmlw->setAttribute(Qt::WA_NoSystemBackground);
// Create image to render into
QImage img(mmlw->size(),QImage::Format_ARGB32);
// Render into QImage
mmlw->render(&img);
// For this example save to file, however we could convert
// the data to a vtk image for rendering as an annotation.
img.save(argv[2]);
}
If you want the complete source code, contact Cyrus @ he will give you a tarball.
Before attempting to build this project make sure:
- You have a working build of Qt4
- To obtain and build the qtmmlwidget solution
- To modify qtmmlrender.pro to provide the correct path to the qtmmlwidget.pri file.
To build & run:
qmake make qtmmlrender example.mml example.png
The output should look like the following: