8.3 Специальные комментарии

There are number of special comments for MGL script, which set some global behavior (like, animation, dialog for parameters and so on). All these special comments starts with double sign ##. Let consider them.

##c v1 v2 [dv=1]

Sets the parameter for animation loop relative to variable $0. Here v1 and v2 are initial and final values, dv is the increment.

##a val

Adds the parameter val to the list of animation relative to variable $0. You can use it several times (one parameter per line) or combine it with animation loop ##c.

##d $I kind|label|par1|par2|...

Creates custom dialog for changing plot properties. Each line adds one widget to the dialog. Here $I is id ($0,$1...$9,$a,$b...$z), label is the label of widget, kind is the kind of the widget:

  • ’e’ for editor or input line (parameter is initial value) ,
  • ’v’ for spinner or counter (parameters are "ini|min|max|step|big_step"),
  • ’s’ for slider (parameters are "ini|min|max|step"),
  • ’b’ for check box (parameter is "ini"; also understand "on"=1),
  • ’c’ for choice (parameters are possible choices).

Now, it work in FLTK-based mgllab and mglview only.

You can make custom dialog in C/C++ code too by using one of following functions.

Method on mglWnd: void MakeDialog (const char *ids, char const * const *args, const char *title)
Method on mglWnd: void MakeDialog (const std::string &ids, const std::vector<std::string> &args, const char *title)
C function: void mgl_wnd_make_dialog (HMGL gr, const char *ids, char const * const *args, const char *title)

Makes custom dialog for parameters ids of element properties defined by args.

At this you need to provide callback function for setting up properties. You can do it by overloading Param() function of mglDraw class or set it manually.

Method on mglDraw: void Param (char id, const char * val)
Method on mglWnd: void SetPropFunc (void (*prop)(char id, const char *val, void *p), void *par=NULL)
C function: void mgl_wnd_set_prop (void (*prop)(char id, const char *val, void *p), void *par)

Set callback function for properties setup.