| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
3.8.2 C++/Python interface
MathGL provides the interface to a set of languages via SWIG library. Some of these languages support classes. The typical example is Python – which is named in this chapter’s title. Exactly the same classes are used for high-level C++ API. Its feature is using only inline member-functions what make high-level API to be independent on compiler even for binary build.
There are 3 main classes in:
-
mglGraph– provide most plotting functions (see MathGL core). -
mglData– provide base data processing (see Data processing). It have an additional feature to access data values. You can use a construct like this:dat[i]=sth;orsth=dat[i]where flat representation of data is used (i.e., i can be in range 0...nx*nx*nz-1). You can also import NumPy arrays as input arguments in Python:mgl_dat = mglData(numpy_dat);. -
mglParse– provide functions for parsing MGL scripts (see MGL scripts).
To use Python classes just execute ‘import mathgl’. The simplest example will be:
import mathgl
a=mathgl.mglGraph()
a.Box()
a.WritePNG("test.png")
Alternatively you can import all classes from mathgl module and easily access MathGL classes like this:
from mathgl import *
a=mglGraph()
a.Box()
a.WritePNG("test.png")
This becomes useful if you create many mglData objects, for example.
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 21, 2014 using texi2html 5.0.
