manpagez: man pages & more
info mathgl
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 mglGraphAB class

#cindex mglDraw

Generally this class is a bit less abstract class than mglGraph class (see section MathGL core). It provide many protected methods for handling intermediate data from mglGraph methods and require a few methods to be defined by derived class. The developers of derived classes should look on file ‘mgl_ab.h’ and comments inside it or contact me.

Here I just show new public methods for class mglGraphAB. There are functions returning the created picture (bitmap), its width and height. You may display it by yourself in any graphical library (see also, Widget classes) or save in file (see also, Export to file).

Method on mglGraphAB: const unsigned char * GetBits ()

Gets RGB bitmap of the current state of the image. Format of each element of bits is: {red, green, blue}. Number of elements is Width*Height. Position of element {i,j} is [3*i + 3*Width*j].

Method on mglGraphAB: const unsigned char * GetRGBA ()

Gets RGBA bitmap of the current state of the image. Format of each element of bits is: {red, green, blue, alpha}. Number of elements is Width*Height. Position of element {i,j} is [4*i + 4*Width*j].

Method on mglGraphAB: int GetWidth ()

Gets width of the image.

Method on mglGraphAB: int GetHeight ()

Gets height of the image.

Class mglGraphAB is the base class for “widget classes”. So there are set of functions for handling window behavior. Most of them are applicable only for “window” classes (like mglGraphFLTK and so on, see section Widget classes). In all other classes these functions just do nothing. You should provide the corresponding interface in derived “widget” classes for user convenience.

Method on mglGraphAB: void Window (int argc, char **argv, int (*draw)(mglGraph *gr, void *p), const char *title, void *par=NULL, void (*reload)(int next, void *p)=NULL)

This function creates a window for plotting. Parameters argc, argv contain OS specific information and should be the same as in function main(int argc,char **argv). Parameter draw sets a pointer (this is the name of function) to drawing function. 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. Parameter title sets the title of the window. Parameter par contains pointer to data for the plotting function draw.

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.

IMPORTANT!!! You need to add a call of Rotate() (see section Transformation matrix) function for having possibility of plot rotation. If plot should be unrotated by default just add Rotate(0,0) in drawing function.

Method on mglGraphAB: void Window (int argc, char **argv, mglDraw *draw, const char *title)

This function is mostly the same as previous one. The only difference is that the drawing function and function for data reloading are specified as methods on a class inherited from class mglDraw. This class is defined in #include <mgl/mgl_data.h> and have only 2 methods:

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

You should inherit yours class from mglDraw and reimplement one or both functions for using this function.

Method on mglGraphAB: void ToggleAlpha ()

Switch on/off transparency but do not overwrite switches in user drawing function.

Method on mglGraphAB: void ToggleLight ()

Switch on/off lighting but do not overwrite switches in user drawing function.

Method on mglGraphAB: void ToggleZoom ()

Switch on/off zooming by mouse as region selection.

Method on mglGraphAB: void ToggleRotate ()

Switch on/off rotation by mouse. Usually, left button is used for rotation, middle button for shift, right button for zoom/perspective.

Method on mglGraphAB: void ToggleNo ()

Switch off all zooming and rotation and restore initial state.

Method on mglGraphAB: void Update ()

Update window contents.

Method on mglGraphAB: void ReLoad (bool o)

Reload user data and update picture.

Method on mglGraphAB: void Adjust ()

Adjust size of bitmap to window size.

Method on mglGraphAB: void NextFrame ()

Show next frame if one.

Method on mglGraphAB: void PrevFrame ()

Show previous frame if one.

Method on mglGraphAB: void Animation ()

Run/stop slideshow (animation) of frames

Widget option of mglGraphAB: bool AutoClf

Clear canvas between drawing. You may switch it off for accumulate previous drawing (for example some points or parts of a picture).

Widget option of mglGraphAB: float Delay

Delay for animation in seconds. Default value is 1 sec.

Method on mglGraphAB: mglPoint CalcXYZ (int xs, int ys)

Calculate 3D coordinate {x,y,z} for screen point {xs,ys}. At this moment it ignore perspective and transformation formulas (curvilinear coordinates). The calculation are done for the last used InPlot (see section Transformation matrix).

Widget option of mglGraphAB: float ShowMousePos

Switch to show or not in the widget the last mouse click position.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2026
Individual documents may contain additional copyright information.