[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7. Other classes


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.1 mglParse class

Class for parsing and executing MGL script. This class is defined in #include <mgl/mgl_parse.h>.

Class mglParse is the interpreter for MGL scripts (see section MGL interface). The main function of mglParse class is Parse(). Exactly this function parses and executes the script string-by-string. Also there are two subservient functions for the finding and creation of a variable. These functions can be useful for displaying values of variables (arrays) in some external program (in window, for example). The variable DataList contains full list of variables in script. Flag AllowSetSize allows one to prevent changing the size of the picture inside the script (forbids the MGL command setsize).

Note an important feature – if user defines function func in variable then it will be called before the destroying of this variable (see section mglVar class).

Method on mglParse: mglParse (bool setsize=false)

Constructor initializes all values with zero and set AllowSetSize value.

Method on mglParse: int Parse (mglGraph *gr, const char *str, long pos=0)
Method on mglParse: int Parse (mglGraph *gr, const wchar_t *str, long pos=0)

Main function in the class. It parses the string str and executes it by using gr as a graphics plotter. Returns the value depending on an error presence in the string str: 0 – no error, 1 – wrong command argument(s), 2 – unknown command, 3 – string is too long. Optional argument pos allows to save the string position in the document (or file) for using for|next command.

Method on mglParse: int Export (wchar_t cpp_out[1024], mglGraph *gr, const wchar_t *str)

Function parses the string str, executes it by using gr as a graphics plotter and exports it to C++ code. Returns the value depending on an error presence in the string str: 0 – no error, 1 – wrong command argument(s), 2 – unknown command, 3 – string is too long. Output C++ text will be placed in out variable. If string str have options (defined after ’;’ symbol) then the corresponding C++ texts are placed in variables op1, op2.

Method on mglParse: void Execute (mglGraph *gr, FILE *fp, bool print=false)

Function parse and execute line-by-line MGL script in file fp. If print=true then all warnings and information will be printed in stdout. Also this function support the for|next MGL commands.

Method on mglParse: void Execute (mglGraph *gr, int num, const wchar_t **text, void (* error )(int line, int kind)=NULL)

Function parse and execute line-by-line MGL script in array text. If error is not NULL then this function will be called for all warnings, information and other messages. Also this function support the for|next MGL commands.

Method on mglParse: void Execute (mglGraph *gr, const char *text, void (* error )(int line, int kind)=NULL)
Method on mglParse: void Execute (mglGraph *gr, const wchar_t *text, void (* error )(int line, int kind)=NULL)

Function parse and execute line-by-line MGL script in string text. Lines are separated by ‘\n’ symbol as usual. If error is not NULL then this function will be called for all warnings, information and other messages. Also this function support the for|next MGL commands.

Method on mglParse: bool AddParam (int n, const char *str, bool isstr=true)
Method on mglParse: bool AddParam (int n, const wchar_t *str, bool isstr=true)

Function set the value of n-th parameter as string str (n=0, 1 ... 9). It return true for success.

Method on mglParse: mglVar * FindVar (const char *name)
Method on mglParse: mglVar * FindVar (const wchar_t *name)

Function returns the pointer to variable with name name or zero if variable is absent. Use this function to put external data array to the script or get the data from the script.

Method on mglParse: mglVar * AddVar (const char *name)
Method on mglParse: mglVar * AddVar (const wchar_t *name)

Function returns the pointer to variable with name name. If variable is absent then new variable is created with name name. Use this function to put external data array to the script or get the data from the script.

Method on mglParse: void DeleteVar (mglVar *v)
Method on mglParse: void DeleteVar (const char *name)
Method on mglParse: void DeleteVar (const wchar_t *name)

Function delete the variable specified by its name or by its pointer.

Method on mglParse: inline void RestoreOnce ()

Restore Once flag.

Method on mglParse: void AddCommand (mglCommand *cmd, int num=0)

Add num commands cmd to the defined MGL commands list. Parameter cmd is array of mglCommand structures. If parameter num=0 then it will be determined automatically. At this, array cmd must have last element with name=L""

Option of mglParse: mglVar * DataList

List of variables defined in script.

Option of mglParse: bool AllowSetSize

Flag which allows/forbids the command setsize in scripts.

Option of mglParse: bool Stop

Flag which interrupt script execution.

Option of mglParse: mglCommand * Cmd

Table (array) of recognizable MGL commands (can be changed by user). Items in the table MUST be sorted by name field !!! Last items must have empty name (i.e. L"").

Option of mglParse: wchar_t * op1

These strings contain command options and should be placed before the command. These variables are used for MGL->C++ (or other language) conversion.

Option of mglParse: wchar_t * op2

These strings contain command options and should be placed after the command. These variables are used for MGL->C++ (or other language) conversion.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2 mglFormula class

Class for evaluating of formula specified by the string. This class is defined in #include <mgl/mgl_eval.h>.

It is the fast variant of formula evaluation. At creation it will be recognized and compiled to tree-like internal code. At evaluation stage only fast calculations are performed. There is no difference between lower or upper case in formulas. If argument value lie outside the range of function definition then function returns NaN.

There are a lot of functions and operators available. The operators are: ‘+’ – addition, ‘-’ – subtraction, ‘*’ – multiplication, ‘/’ – division, ‘^’ – integer power. Also there are logical “operators”: ‘<’ – true if x<y, ‘>’ – true if x>y, ‘=’ – true if x=y, ‘&’ – true if x and y both nonzero, ‘|’ – true if x or y nonzero. These logical operators have lowest priority and return 1 if true or 0 if false.

The basic functions are: ‘sqrt(x)’ – square root of x, ‘pow(x,y)’ power x in y, ‘ln(x)’ – natural logarithm of x, ‘lg(x)’ – decimal logarithm of x, ‘log(a,x)’ – logarithm base a of x, ‘abs(x)’ – absolute value of x, ‘sign(x)’ – sign of x, ‘mod(x,y)’ – x modulo y, ‘step(x)’ – step function, ‘rnd’ – random number, ‘pi’ – number \pi=3.1415926....

Trigonometric functions are: ‘sin(x)’, ‘cos(x)’, ‘tan(x)’ (or ‘tg(x)’). Inverse trigonometric functions are: ‘asin(x)’, ‘acos(x)’, ‘atan(x)’. Hyperbolic functions are: ‘sinh(x)’ (or ‘sh(x)’), ‘cosh(x)’ (or ‘ch(x)’), ‘tanh(x)’ (or ‘th(x)’). Inverse hyperbolic functions are: ‘asinh(x)’, ‘acosh(x)’, ‘atanh(x)’.

There are a set of special functions: ‘gamma(x)’ – Gamma function \Gamma(x) = \int_0^\infty dt t^x-1 \exp(-t) , ‘psi(x)’ – digamma function \psi(x) = \Gamma’(x)/\Gamma(x) for x!=0, ‘ai(x)’ – Airy function Ai(x), ‘bi(x)’ – Airy function Bi(x), ‘cl(x)’ – Clausen function, ‘li2(x)’ (or ‘dilog(x)’) – dilogarithm Li_2(x) = - \Re \int_0^x ds \log(1-s)/s, ‘sinc(x)’ – compute sinc(x) = \sin(\pi x) / (\pi x) for any value of x, ‘zeta(x)’ – Riemann zeta function \zeta(s) = \sum_k=1^\infty k^-s for arbitrary s!=1, ‘eta(x)’ – eta function \eta(s) = (1-2^1-s) \zeta(s) for arbitrary s, ‘lp(l,x)’ – Legendre polynomial P_l(x), (|x|<=1, l>=0), ‘w0(x)’ – principal branch of the Lambert W function, ‘w1(x)’ – principal branch of the Lambert W function. Function W(x) is defined to be solution of the equation W \exp(W) = x.

The exponent integrals are: ‘ci(x)’ – Cosine integral Ci(x) = \int_0^x dt \cos(t)/t, ‘si(x)’ – Sine integral Si(x) = \int_0^x dt \sin(t)/t, ‘erf(x)’ – error function erf(x) = (2/\sqrt(\pi)) \int_0^x dt \exp(-t^2), ‘ei(x)’ – exponential integral Ei(x) := - PV(\int_-x^\infty dt \exp(-t)/t) (where PV denotes the principal value of the integral), ‘e1(x)’ – exponential integral E_1(x) := Re \int_1^\infty dt \exp(-xt)/t , ‘e2(x)’ – exponential integral E_2(x) := Re \int_1^\infty dt \exp(-xt)/t^2, ‘ei3(x)’ – exponential integral Ei_3(x) = \int_0^x dt \exp(-t^3) for x>=0.

Bessel functions are: ‘j(nu,x)’ – regular cylindrical Bessel function of fractional order nu, ‘y(nu,x)’ – irregular cylindrical Bessel function of fractional order nu, ‘i(nu,x)’ – regular modified Bessel function of fractional order nu, ‘k(nu,x)’ – irregular modified Bessel function of fractional order nu.

Elliptic integrals are: ‘ee(k)’ – complete elliptic integral is denoted by E(k) = E(\pi/2, k), ‘ek(k)’ – complete elliptic integral is denoted by K(k) = F(\pi/2, k), ‘e(phi,k)’ – elliptic integral E(\phi,k) = \int_0^\phi dt \sqrt((1 - k^2 \sin^2(t))), ‘f(phi,k)’ – elliptic integral F(\phi,k) = \int_0^\phi dt 1/\sqrt((1 - k^2 \sin^2(t))).

Jacobi elliptic functions are: ‘sn(u,m)’, ‘cn(u,m)’, ‘dn(u,m)’, ‘sc(u,m)’, ‘sd(u,m)’, ‘ns(u,m)’, ‘cs(u,m)’, ‘cd(u,m)’, ‘nc(u,m)’, ‘ds(u,m)’, ‘dc(u,m)’, ‘nd(u,m)’.

Note, some of these functions are unavailable if NO\_GSL is defined during compilation of MathGL library.

Method on mglFormula: mglFormula (const char *str)

Parses the formula str and creates formula-tree. Constructor recursively parses the formula and creates a tree-like structure containing functions and operators for fast further evaluating by Calc() or CalcD() functions.

Method on mglFormula: float Calc (float x, float y=0, float z=0, float u=0)

Evaluates the formula for 'x','r'=x, 'y','n'=y, 'z','t'=z, 'a','u'=u. Error code (if one) can be obtained from function GetError().

Method on mglFormula: float Calc (float x, float y, float z, float u, float v, float w)

Evaluates the formula for 'x'=x, 'y'=y, 'z'=z, 'u'=u, 'v'=v, 'w'=w. Error code (if one) can be obtained from function GetError().

Method on mglFormula: float Calc (float var['z'-'a'+1])

Evaluates the formula for variables in array var[’z’-’a’]. Error code (if one) can be obtained from function GetError().

Method on mglFormula: float CalcD (float var['z'-'a'+1], char diff)

Evaluates the formula derivation respect to diff for variables in array var[’z’-’a’]. Error code (if one) can be obtained from function GetError().

Method on mglFormula: int GetError ()

Returns error code: 0 means no error; ERR_LOG means error in logarithm or power functions; ERR_ARC means error in inverse functions (like asin); ERR_SQRT means error in sqrt function.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.3 mglFont class

Class for working with font: load, get metrics, parse and draw strings. This class is defined in #include <mgl/mgl_font.h>.

The class is based on loading and drawing of vector Hershey font. There are two styles of specifying of the font type and aligning: by integer parameters or by string.

The string can be any combination of characters: ‘rbiLCRwou’. The font types are: ‘r’ – roman font, ‘i’ – italic style, ‘b’ – bold style. By default roman font (that is ‘’ or ‘r’) is used. The align types are: ‘L’ – align left (default), ‘C’ – align center, ‘R’ – align right. Additional font effects are: ‘w’ – wire, ‘o’ – over-lined, ‘u’ – underlined.

The over way of font and alignment setting is the using of the integer constant. Integer font Id can be one of predefined constants: MGL_FONT_ITAL, MGL_FONT_BOLD, MGL_FONT_BOLD_ITAL = MGL_FONT_ITAL+MGL_FONT_BOLD. Default font is MGL_FONT_ROMAN. Also there are flags MGL_FONT_ULINE, MGL_FONT_OLINE, MGL_FONT_WIRE for additional font effects. Align parameter controls the text alignment: 0 – align left, 1 – align center, 2 – align right.

Parsing of the string to special (TeX-like) commands will be done if variable parse is true (it’s default). There are commands for the font style changing inside the string (for example, use \b for bold font): \a or \overline – over-lined, \b or \textbf – bold, \i or \textit – italic, \r or \textrm – roman (disable bold and italic attributes), \u or \underline – underlined, \w or \wire – wired, \big – bigger size, @ – smaller size. The lower and upper indexes are specified by ‘_’ and ‘^’ symbols. At this the changed font style is applied only on next symbol or symbols in braces {}. The text in braces {} are treated as single symbol that allow one to print the index of index. For example, compare the strings ‘sin (x^{2^3})’ and ‘sin (x^2^3)’. You may also change text color inside string by command #? or by \color? where ‘?’ is symbolic id of the color (see section mglColor class). For example, words ‘Blue’ and ‘red’ will be colored in the string ‘#b{Blue} and \colorr{red} text’.

The most of commands for special TeX or AMSTeX symbols, the commands for font style changing (\textrm, \textbf, \textit, \overline, \underline), accents (\hat, \tilde, \dot, \ddot, \acute, \check, \grave, \bar, \breve) and roots (\sqrt, \sqrt3, \sqrt4) are recognized. The full list contain approximately 2000 commands. Note that first space symbol after the command is ignored, but second one is printed as normal symbol (space). For example, the following strings produce the same result \tilde a: ‘\tilde{a}’; ‘\tilde a’; ‘\tilde{}a’.

The Greek letters are recognizable special symbols: α – \alpha, β – \beta, γ – \gamma, δ – \delta, ε – \epsilon, η – \eta, ι – \iota, χ – \chi, κ – \kappa, λ – \lambda, μ – \mu, ν – \nu, o – \o, ω – \omega, ϕ – \phi, π – \pi, ψ – \psi, ρ – \rho, σ – \sigma, θ – \theta, τ – \tau, υ – \upsilon, ξ – \xi, ζ – \zeta, ς – \varsigma, ɛ – \varepsilon, ϑ – \vartheta, φ – \varphi, ϰ – \varkappa; A – \Alpha, B – \Beta, Γ – \Gamma, Δ – \Delta, E – \Epsilon, H – \Eta, I – \Iota, C – \Chi, K – \Kappa, Λ – \Lambda, M – \Mu, N – \Nu, O – \O, Ω – \Omega, Φ – \Phi, Π – \Pi, Ψ – \Psi, R – \Rho, Σ – \Sigma, Θ – \Theta, T – \Tau, Υ – \Upsilon, Ξ – \Xi, Z – \Zeta.

The small part of most common special TeX symbols are: ∠ – \angle, ⋅ – \cdot, ♣ – \clubsuit, ✓ – \checkmark, ∪ – \cup, ∩ – \cap, ♢ – \diamondsuit, ◇ – \diamond, ÷ – \div, ↓ – \downarrow, † – \dag, ‡ – \ddag, ≡ – \equiv, ∃ – \exists, ⌢ – \frown, ♭ – \flat, ≥ – \ge, ≥ – \geq, ≧ – \geqq, ← – \gets, ♡ – \heartsuit, ∞ – \infty, ∫ – \int, \Int, ℑ – \Im, ♢ – \lozenge, ⟨ – \langle, ≤ – \le, ≤ – \leq, ≦ – \leqq, ← – \leftarrow, ∓ – \mp, ∇ – \nabla, ≠ – \ne, ≠ – \neq, ♮ – \natural, ∮ – \oint, ⊙ – \odot, ⊕ – \oplus, ∂ – \partial, ∥ – \parallel, ⊥ –\perp, ± – \pm, ∝ – \propto, ∏ – \prod, ℜ – \Re, → – \rightarrow, ⟩ – \rangle, ♠ – \spadesuit, ~ – \sim, ⌣ – \smile, ⊂ – \subset, ⊃ – \supset, √ – \sqrt or \surd, § – \S, ♯ – \sharp, ∑ – \sum, × – \times, → – \to, ∴ – \therefore, ↑ – \uparrow, ℘ – \wp.

Method on mglFont: mglFont (const char *name=MGL_DEF_FONT_NAME, const char *path=NULL)

Initialize the font and load data from file name (default name is "STIX" for Linux and MacOS) or if name=NULL limited data from memory (default for Windows).

Method on mglFont: bool Load (const char * base, const char *path=NULL)

Load font from file path/base into the memory. The font may contain 4 files: base.vfm, base_b.vfm, base_i.vfm, base_bi.vfm. Appendix contain detailed description of font format.

Method on mglFont: void Restore ()

Restore default font.

Method on mglFont: void (mglFont * fnt)

Copy data from other font instance.

Method on mglFont: void Clear ()

Clear memory by deleting the loaded font.

Method on mglFont: inline unsigned GetNumGlyph ()

Return the number of glyphs in the font.

Method on mglFont: inline bool Ready ()

Return true if font is loaded and ready for use.

Method on mglFont: float Height (int font)

Gets height of text for font specified by integer constant.

Method on mglFont: float Puts (const char *str, int font=0, int align=0)

Prints 8-bit text string for font specified by integer constant.

Method on mglFont: float Width (const char *str, int font=0)

Gets width of 8-bit text string for font specified by integer constant.

Method on mglFont: float Puts (const wchar_t *str, int font=0, int align=0)

Prints Unicode text string for font specified by integer constant.

Method on mglFont: float Width (const wchar_t *str, int font=0)

Gets width of Unicode text string for font specified by integer constant.

Method on mglFont: float Height (const char *how)

Gets height of text for font specified by string.

Method on mglFont: float Puts (const char *str, const char *how)

Prints 8-bit text string for font specified by string.

Method on mglFont: float Width (const char *str, const char *how)

Gets width of 8-bit text string for font specified by string.

Method on mglFont: float Puts (const wchar_t *str, const char *how)

Prints Unicode text string for font specified by string.

Method on mglFont: float Width (const wchar_t *str, const char *how)

Gets width of Unicode text string for font specified by string.

Parameter of mglFont: mglGraph * gr

Instance of mglGraph class which is used for character drawing.

Parameter of mglFont: bool parse

Flag for switching on/off the parsing of TeX commands. Default value is true.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.3.1 Format of font files

Starting from v.1.6 the MathGL library uses new font files. The font is defined in 4 files with suffixes ‘*.vfm’, ‘*_b.vfm’, ‘*_i.vfm’, ‘*_bi.vfm’. These files are text files containing the data for roman font, bold font, italic font and bold italic font. The files (or some symbols in the files) for bold, italic or bold italic fonts can be absent. In this case the roman glyph will be used for them. By analogy, if the bold italic font is absent but the bold font is present then bold glyph will be used for bold italic. You may create these font files by yourself from *.ttf, *.otf files with the help of program font_tools. This program can be found at MathGL home site.

The format of font files (*.vfm – vector font for MathGL) is the following.

  1. First string contains human readable comment and is always ignored.
  2. Second string contains 3 numbers, delimited by space or tabulation. The order of numbers is the following: numg – the number of glyphs in the file (integer), fact – the factor for glyph sizing (float), size – the size of buffer for glyph description (integer).
  3. After it numg-th strings with glyphs description are placed. Each string contains 6 positive numbers, delimited by space of tabulation. The order of numbers is the following: Unicode glyph ID, glyph width, number of lines in glyph, position of lines coordinates in the buffer (length is 2*number of lines), number of triangles in glyph, position of triangles coordinates in the buffer (length is 6*number of triangles).
  4. The end of file contains the buffer with point coordinates at lines or triangles vertexes. The size of buffer (the number of integer) is size.

Note: the closing contour line is done automatically (so the last segment may be absent). For starting new contour use a point with coordinates {0x3fff, 0x3fff}.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.4 mglColor class

Structure for working with colors. This structure is defined in #include <mgl/mgl.h>.

There are two ways to set the color in MathGL. First one is using of float values of red, green and blue channels for precise color definition. The second way is the using of character id. There are a set of characters specifying frequently used colors. Normally capital letter gives more dark color than lowercase one. The full list of characters is: ‘k’ – black, ‘r’ – red, ‘R’ – dark red, ‘g’ – green, ‘G’ – dark green, ‘b’ – blue, ‘B’ – dark blue, ‘c’ – cyan, ‘C’ – dark cyan, ‘m’ – magenta, ‘M’ – dark magenta, ‘y’ – yellow, ‘Y’ – dark yellow (gold), ‘h’ – gray, ‘H’ – dark gray, ‘w’ – white, ‘W’ – bright gray, ‘l’ – green-blue, ‘L’ – dark green-blue, ‘e’ – green-yellow, ‘E’ – dark green-yellow, ‘n’ – sky-blue, ‘N’ – dark sky-blue, ‘u’ – blue-violet, ‘U’ – dark blue-violet, ‘p’ – purple, ‘P’ – dark purple, ‘q’ – orange, ‘Q’ – dark orange (brown).

Also you may use “lighted” colors in color scheme specification (not in line style!). The “lighted” color contain 2 symbols: first one is usual symbol for color specification, second one is digit for its brightness. The digit can be in range ‘1’...‘9’. At this ‘5’ correspond to normal color, ‘1’ is very dark version of the color (practically black), ‘9’ is very bright version of the color (practically white).

png/colors

Colors and its ids.

Parameter of mglVar: float r, g, b

Reg, green and blue component of color.

Method on mglColor: mglColor (float R, float G, float B)

Constructor sets the color by float values of Red, Green and Blue channels.

Method on mglColor: mglColor (char c='k')

Constructor sets the color from character id. The black color is used by default.

Method on mglColor: void Set (float R, float G, float B)

Sets color from values of Red, Green and Blue channels. This values should be in interval [0,1].

Method on mglColor: void Set (mglColor c, float bright=1)

Sets color as “lighted” version of color c.

Method on mglColor: void Set (char p)

Sets color from symbolic id.

Method on mglColor: bool Valid ()

Checks correctness of the color.

Method on mglColor: float Norm ()

Gets maximal of spectral component.

Method on mglColor: bool operator== (const mglColor &c)

Compare with another color

Library Function: inline mglColor operator+ (const mglColor &a, const mglColor &b)

Adds colors by its RGB values.

Library Function: inline mglColor operator- (const mglColor &a, const mglColor &b)

Subtracts colors by its RGB values.

Library Function: inline mglColor operator* (const mglColor &a, float b)

Multiplies color by number.

Library Function: inline mglColor operator* (float a, const mglColor &b)

Multiplies color by number.

Library Function: inline mglColor operator/ (const mglColor &a, float b)

Divide color by number.

Library Function: inline mglColor operator! (const mglColor &a)

Return inverted color.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.5 mglPoint class

Structure describes point in space. This structure is defined in #include <mgl/mgl.h>

Parameter of mglVar: float x, y, z

Point coordinates. By default all values are zero.

Library Function: inline mglPoint operator+ (const mglPoint &a, const mglPoint &b)

Point of summation (summation of vectors).

Library Function: inline mglPoint operator- (const mglPoint &a, const mglPoint &b)

Point of difference (difference of vectors).

Library Function: inline mglPoint operator* (float a, const mglPoint &b)

Multiplies (scale) points by number.

Library Function: inline mglPoint operator* (const mglPoint &a, float b)

Multiplies (scale) points by number.

Library Function: inline mglPoint operator/ (const mglPoint &a, float b)

Multiplies (scale) points by number 1/b.

Library Function: inline float operator- (const mglPoint &a, const mglPoint &b)

Scalar product of vectors.

Library Function: inline mglPoint operator^ (const mglPoint &a, const mglPoint &b)

Cross-product of vectors.

Library Function: inline mglPoint operator& (const mglPoint &a, const mglPoint &b)

The part of a which is perpendicular to vector b.

Library Function: inline mglPoint operator| (const mglPoint &a, const mglPoint &b)

The part of a which is parallel to vector b.

Library Function: inline mglPoint operator! (const mglPoint &a)

Return vector perpendicular to vector a.

Library Function: inline bool Norm (const mglPoint &a)

Return the norm |a|^2 of vector a.

Library Function: inline bool operator== (const mglPoint &a, const mglPoint &b)

Return true if points are the same.

Library Function: inline bool operator!= (const mglPoint &a, const mglPoint &b)

Return true if points are different.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.6 mglVar class

Structure describes variable of type mglData and its name in MGL script. This structure is used by mglParse and is defined in #include <mgl/mgl_parse.h>.

Parameter of mglVar: mglData d

Data itself

Parameter of mglVar: wchar_t s[256]

Data name

Parameter of mglVar: void * o

Pointer to external object for function func.

Parameter of mglVar: mglVar * next

Pointer to next instance in list

Parameter of mglVar: mglVar * prev

Pointer to prev instance in list

Parameter of mglVar: bool temp

Flag for temporar variable. Temporal variables will be destroyed after script execution.

Parameter of mglVar: void (* func )(void *)

Callback function for destroying non-temporal variable.

Method on mglGraphAB: void MoveAfter (mglVar *var)

Move variable after var and copy func from var (if func is not 0)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.7 mglCommand class

Structure describes MGL command, its name, short description, executable and export functions. The structure is used by mglParse and is defined in #include <mgl/mgl_parse.h>.

Parameter of mglCommand: const wchar_t * name

Name of command.

Parameter of mglCommand: const wchar_t * desc

Short command description (can be NULL).

Parameter of mglCommand: const wchar_t * form

Format of command arguments (can be NULL).

Parameter of mglCommand: int (* exec )(mglGraph *gr, long n, mglArg *a, int k[10])const wchar_t *

Function for executing (plotting) the command using grapher gr and having n-th arguments a. Function must return 0 if all is OK; or 1 if arguments are wrong.

Parameter of mglCommand: void (* save )(wchar_t out[1024], long n, mglArg *a, int k[10])const wchar_t *

Function for exporting in C++ (can be NULL).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.8 mglArg class

Structure describes arguments of functions in the stucture mglCommand. It is defined in #include <mgl/mgl_parse.h>.

Parameter of mglArg: int type

Type of argument: 0-data, 1-string, 2-number.

Parameter of mglArg: mglData * d

Pointer to data (used if type=0).

Parameter of mglArg: wchar_t w[2048]

String with parameters (used if type=1 or if type=0 as variable name).

Parameter of mglArg: char s[2048]

String with parameters (used if type=1).

Parameter of mglArg: float v

Numerical value (used if type==2)


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Build Daemon user on September 11, 2010 using texi2html 1.82.