Next: , Previous: , Up: Top   [Contents][Index]


6 Widget classes

There are set of “window” classes for making a window with MathGL graphics: mglWindow, mglFLTK, mglQT and mglGLUT for whole window, Fl_MathGL and QMathGL as widgets. All these classes allow user to show, rotate, export, and change view of the plot using keyboard. Most of them (except mglGLUT) also have toolbar and menu for simplifying plot manipulation. All window classes have mostly the same set of functions derived from mglWnd class.

For drawing you can use: NULL pointer if you’ll update plot manually, global callback function of type int draw(HMGL gr, void *p) or int draw(mglGraph *gr), or instance of class derived from mglDraw class. Basically, this class have 2 main virtual methods:

class mglDraw
{
public:
    virtual int Draw(mglGraph *) { return 0; };
    virtual void Reload() {};
};

You should inherit yours class from mglDraw and re-implement one or both functions for drawing.

The window can be constructed using one of following classes (see Using MathGL window for examples).

Constructor on mglFLTK: mglFLTK (const char *title="MathGL")
Constructor on mglFLTK: mglFLTK (int (*draw)(HMGL gr, void *p), const char *title="MathGL", void *par=NULL, void (*reload)(HMGL gr, void *p)=0)
Constructor on mglFLTK: mglFLTK (int (*draw)(mglGraph *gr), const char *title="MathGL")
Constructor on mglFLTK: mglFLTK (mglDraw *draw, const char *title="MathGL")
C function: HMGL mgl_create_graph_fltk (int (*draw)(HMGL gr, void *p), const char *title, void *par, void (*reload)(HMGL gr, void *p))

Creates a FLTK-based window for plotting. Parameter draw sets a pointer to drawing function (this is the name of function) or instance of mglDraw class. There is support of a list of plots (frames). So as one can prepare a set of frames at first and redraw it fast later (but it requires more memory). Function should return positive number of frames for the list or zero if it will plot directly. Note, that draw can be NULL for displaying static bitmaps only (no animation or slides). Parameter title sets the title of the window. Parameter par contains pointer to data for the plotting function draw. FLTK-based windows is a bit faster than Qt ones, and provide better support of multi-threading.

Method on mglFLTK: int RunThr ()
C function: int mgl_fltk_thr ()

Run main loop for event handling in separate thread. Note, right now it work for FLTK windows only.

Constructor on mglQT: mglQT (const char *title="MathGL")
Constructor on mglQT: mglQT (int (*draw)(HMGL gr, void *p), const char *title="MathGL", void *par=NULL, void (*reload)(HMGL gr, void *p)=0)
Constructor on mglQT: mglQT (int (*draw)(mglGraph *gr), const char *title="MathGL")
Constructor on mglQT: mglQT (mglDraw *draw, const char *title="MathGL")
C function: HMGL mgl_create_graph_qt (int (*draw)(HMGL gr, void *p), const char *title, void *par, void (*reload)(HMGL gr, void *p))

Creates a FLTK-based window for plotting. Parameter draw sets a pointer to drawing function (this is the name of function) or instance of mglDraw class. There is support of a list of plots (frames). So as one can prepare a set of frames at first and redraw it fast later (but it requires more memory). Function should return positive number of frames for the list or zero if it will plot directly. Note, that draw can be NULL for displaying static bitmaps only (no animation or slides). Parameter title sets the title of the window. Parameter par contains pointer to data for the plotting function draw.

Constructor on mglGLUT: mglGLUT (const char *title="MathGL")
Constructor on mglGLUT: mglGLUT (int (*draw)(HMGL gr, void *p), const char *title="MathGL", void *par=NULL, void (*reload)(HMGL gr, void *p)=0)
Constructor on mglGLUT: mglGLUT (int (*draw)(mglGraph *gr), const char *title="MathGL")
Constructor on mglGLUT: mglGLUT (mglDraw *draw, const char *title="MathGL")
C function: HMGL mgl_create_graph_glut (int (*draw)(HMGL gr, void *p), const char *title, void *par, void (*reload)(HMGL gr, void *p))

Creates a GLUT-based window for plotting. Parameter draw sets a pointer to drawing function (this is the name of function) or instance of mglDraw class. There is support of a list of plots (frames). So as one can prepare a set of frames at first and redraw it fast later (but it requires more memory). Function should return positive number of frames for the list or zero if it will plot directly. Note, that draw can be NULL for displaying static bitmaps only (no animation or slides). Parameter title sets the title of the window. Parameter par contains pointer to data for the plotting function draw. GLUT-based windows are fastest one but there is no toolbar, and plot have some issues due to OpenGL limitations.

There are some keys handles for manipulating by the plot: ’a’, ’d’, ’w’, ’s’ for the rotating; ’,’, ’.’ for viewing of the previous or next frames in the list; ’r’ for the switching of transparency; ’f’ for the switching of lightning; ’x’ for hiding (closing) the window.





Next: , Previous: , Up: Top   [Contents][Index]