[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
2.1.5 Using QMathGL
MathGL have several interface widgets for different widget libraries. There are QMathGL for Qt, Fl_MathGL for FLTK. These classes provide control which display MathGL graphics. Unfortunately there is no uniform interface for widget classes because all libraries have slightly different set of functions, features and so on. However the usage of MathGL widgets is rather simple. Let me show it on the example of QMathGL.
First of all you have to define the drawing function or inherit a class from mglDraw
class. After it just create a window and setup QMathGL instance as any other Qt widget:
#include <QApplication> #include <QMainWindow> #include <QScrollArea> #include <mgl2/qmathgl.h> int main(int argc,char **argv) { QApplication a(argc,argv); QMainWindow *Wnd = new QMainWindow; Wnd->resize(810,610); // for fill up the QMGL, menu and toolbars Wnd->setWindowTitle("QMathGL sample"); // here I allow to scroll QMathGL -- the case // then user want to prepare huge picture QScrollArea *scroll = new QScrollArea(Wnd); // Create and setup QMathGL QMathGL *QMGL = new QMathGL(Wnd); //QMGL->setPopup(popup); // if you want to setup popup menu for QMGL QMGL->setDraw(sample); // or use QMGL->setDraw(foo); for instance of class Foo:public mglDraw QMGL->update(); // continue other setup (menu, toolbar and so on) scroll->setWidget(QMGL); Wnd->setCentralWidget(scroll); Wnd->show(); return a.exec(); }
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 21, 2014 using texi2html 5.0.