| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Functions in this group save or give access to produced picture. So, usually they should be called after plotting is done.
w hmglGraph: void SetSize (int width, int height)void mgl_set_size (HMGL gr, int width, int height)Sets size of picture in pixels. This function must be called before any other plotting because it completely remove picture contents.
val=2]mglGraph: void SetQuality (int val=MGL_DRAW_NORM)void mgl_set_quality (HMGL gr, int val)Sets quality of the plot depending on value val: MGL_DRAW_WIRE=0 – no face drawing (fastest), MGL_DRAW_FAST=1 – no color interpolation (fast), MGL_DRAW_NORM=2 – high quality (normal), MGL_DRAW_HIGH=3 – high quality with 3d primitives (arrows and marks). If MGL_DRAW_LMEM=0x4 is set then direct bitmap drawing is used (low memory usage).
mglGraph: int GetQuality ()int mgl_get_quality (HMGL gr)Gets quality of the plot: MGL_DRAW_WIRE=0 – no face drawing (fastest), MGL_DRAW_FAST=1 – no color interpolation (fast), MGL_DRAW_NORM=2 – high quality (normal), MGL_DRAW_HIGH=3 – high quality with 3d primitives (arrows and marks). If MGL_DRAW_LMEM=0x4 is set then direct bitmap drawing is used (low memory usage).
mglGraph: void StartGroup (const char *name)void mgl_start_group (HMGL gr, const char *name)Starts group definition. Groups contain objects and other groups, they are used to select a part of a model to zoom to or to make invizible or to make semitransparent and so on.
mglGraph: void EndGroup ()void mgl_end_group (HMGL gr)Ends group definition.
| 4.5.1 Export to file | ||
| 4.5.2 Frames/Animation | ||
| 4.5.3 Bitmap in memory | ||
| 4.5.4 Parallelization |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These functions export current view to a graphic file. The filename fname should have appropriate extension. Parameter descr gives the short description of the picture. Just now the transparency is supported in PNG, SVG, OBJ and PRC files.
mglGraph: void WriteFrame (const char *fname="", const char *descr="")void mgl_write_frame (HMGL gr, const char *fname, const char *descr)Exports current frame to a file fname which type is determined by the extension. Parameter descr adds description to file (can be ""). If fname="" then the file ‘frame####.jpg’ is used, where ‘####’ is current frame id and name ‘frame’ is defined by plotid class property.
mglGraph: void WritePNG (const char *fname, const char *descr="", int compr="", bool alpha=true)void mgl_write_png (HMGL gr, const char *fname, const char *descr)void mgl_write_png_solid (HMGL gr, const char *fname, const char *descr)Exports current frame to PNG file. Parameter fname specifies the file name, descr adds description to file, alpha gives the transparency type. By default there are no description added and semitransparent image used. This function does nothing if HAVE_PNG isn’t defined during compilation of MathGL library.
mglGraph: void WriteJPEG (const char *fname, const char *descr="")void mgl_write_jpg (HMGL gr, const char *fname, const char *descr)Exports current frame to JPEG file. Parameter fname specifies the file name, descr adds description to file. By default there is no description added. This function does nothing if HAVE_JPEG isn’t defined during compilation of MathGL library.
mglGraph: void WriteGIF (const char *fname, const char *descr="")void mgl_write_gif (HMGL gr, const char *fname, const char *descr)Exports current frame to GIF file. Parameter fname specifies the file name, descr adds description to file. By default there is no description added. This function does nothing if HAVE_GIF isn’t defined during compilation of MathGL library.
mglGraph: void WriteBMP (const char *fname, const char *descr="")void mgl_write_bmp (HMGL gr, const char *fname, const char *descr)Exports current frame to BMP file. Parameter fname specifies the file name, descr adds description to file. There is no compression used.
mglGraph: void WriteTGA (const char *fname, const char *descr="")void mgl_write_tga (HMGL gr, const char *fname, const char *descr)Exports current frame to TGA file. Parameter fname specifies the file name, descr adds description to file. There is no compression used.
mglGraph: void WriteEPS (const char *fname, const char *descr="")void mgl_write_eps (HMGL gr, const char *fname, const char *descr)Exports current frame to EPS file using vector representation. So it is not recommended for the export of large data plot. It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file. By default there is no description added. If file name is terminated by ‘z’ (for example, ‘fname.eps.gz’) then file will be compressed in gzip format.
mglGraph: void WriteBPS (const char *fname, const char *descr="")void mgl_write_eps (HMGL gr, const char *fname, const char *descr)Exports current frame to EPS file using bitmap representation. Parameter fname specifies the file name, descr adds description to file. By default there is no description added. If file name is terminated by ‘z’ (for example, ‘fname.eps.gz’) then file will be compressed in gzip format.
mglGraph: void WriteSVG (const char *fname, const char *descr="")void mgl_write_svg (HMGL gr, const char *fname, const char *descr)Exports current frame to SVG (Scalable Vector Graphics) file using vector representation. In difference of EPS format, SVG format support transparency that allows to correctly draw semitransparent plot (like surfa, surf3a or cloud). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name). If file name is terminated by ‘z’ (for example, ‘fname.svgz’) then file will be compressed in gzip format.
mglGraph: void WriteTEX (const char *fname, const char *descr="")void mgl_write_tex (HMGL gr, const char *fname, const char *descr)Exports current frame to LaTeX (package Tikz/PGF) file using vector representation. Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name). Note, there is no text scaling now (for example, in subplots), what may produce miss-aligned labels.
mglGraph: void WritePRC (const char *fname, const char *descr="", bool make_pdf=true)void mgl_write_prc (HMGL gr, const char *fname, const char *descr, int make_pdf)Exports current frame to PRC file using vector representation (see http://en.wikipedia.org/wiki/PRC_%28file_format%29). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name). If parameter make_pdf=true and PDF was enabled at MathGL configure then corresponding PDF file with 3D image will be created.
mglGraph: void WriteOBJ (const char *fname, const char *descr="")void mgl_write_obj (HMGL gr, const char *fname, const char *descr)Exports current frame to OBJ/MTL file using vector representation (see OBJ format for details). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name).
mglGraph: void WriteXYZ (const char *fname, const char *descr="")void mgl_write_xyz (HMGL gr, const char *fname, const char *descr)Exports current frame to XYZ/XYZL/XYZF files using vector representation (see XYZ format for details). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name).
mglGraph: void WriteSTL (const char *fname, const char *descr="")void mgl_write_stl (HMGL gr, const char *fname, const char *descr)Exports current frame to STL file using vector representation (see STL format for details). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name.
mglGraph: void WriteOFF (const char *fname, const char *descr="", bool colored=false)void mgl_write_off (HMGL gr, const char *fname, const char *descr, bool colored)Exports current frame to OFF file using vector representation (see OFF format for details). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name).
mglGraph: void ShowImage (const char *viewer, bool nowait=false)void mgl_show_image (const char *viewer, int nowait)Displays the current picture using external program viewer for viewing. The function save the picture to temporary file and call viewer to display it. If nowait=true then the function return immediately (it will not wait while window will be closed).
mglGraph: void WriteJSON (const char *fname, const char *descr="")void mgl_write_json (HMGL gr, const char *fname, const char *descr)Exports current frame to textual file using JSON format. Later this file can be used for faster loading and viewing by JavaScript script. Parameter fname specifies the file name, descr adds description to file.
mglGraph: void ExportMGLD (const char *fname, const char *descr="")void mgl_export_mgld (HMGL gr, const char *fname, const char *descr)Exports points and primitives in file using MGLD format. Later this file can be used for faster loading and viewing by mglview utility. Parameter fname specifies the file name, descr adds description to file (default is file name).
mglGraph: void ImportMGLD (const char *fname, bool add=false)void mgl_import_mgld (HMGL gr, const char *fname, int add)Imports points and primitives in file using MGLD format. Later this file can be used for faster loading and viewing by mglview utility. Parameter fname specifies the file name, add sets to append or replace primitives to existed ones.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These functions provide ability to create several pictures simultaneously. For most of cases it is useless but for widget classes (see Widget classes) they can provide a way to show animation. Also you can write several frames into animated GIF file.
mglGraph: void NewFrame ()void mgl_new_frame (HMGL gr)Creates new frame. Function returns current frame id. This is not thread safe function in OpenGL mode! Use direct list creation in multi-threading drawing. The function EndFrame() must be call after the finishing of the frame drawing for each call of this function.
mglGraph: void EndFrame ()void mgl_end_frame (HMGL gr)Finishes the frame drawing.
mglGraph: int GetNumFrame ()int mgl_get_num_frame (HMGL gr)Gets the number of created frames.
mglGraph: void SetFrame (int i)void mgl_set_frame (HMGL gr, int i)Finishes the frame drawing and sets drawing data to frame i, which should be in range [0, GetNumFrame()-1]. This function is similar to EndFrame() but don’t add frame to the GIF image.
mglGraph: void GetFrame (int i)void mgl_get_frame (HMGL gr, int i)Replaces drawing data by one from frame i. Function work if MGL_VECT_FRAME is set on (by default).
mglGraph: void ShowFrame (int i)void mgl_show_frame (HMGL gr, int i)Appends drawing data from frame i to current one. Function work if MGL_VECT_FRAME is set on (by default).
mglGraph: void DelFrame (int i)void mgl_del_frame (HMGL gr, int i)Deletes drawing data for frame i and shift all later frame indexes. Function work if MGL_VECT_FRAME is set on (by default). Do nothing in OpenGL mode.
mglGraph: void ResetFrames ()void mgl_reset_frames (HMGL gr)Reset frames counter (start it from zero).
mglGraph: void StartGIF (const char *fname, int ms=100)void mgl_start_gif (HMGL gr, const char *fname, int ms)Start writing frames into animated GIF file fname. Parameter ms set the delay between frames in milliseconds. You should not change the picture size during writing the cinema. Use CloseGIF() to finalize writing. Note, that this function is disabled in OpenGL mode.
mglGraph: void CloseGIF ()void mgl_close_gif (HMGL gr)Finish writing animated GIF and close connected pointers.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These functions return 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).
mglGraph: const unsigned char * GetRGB ()mglGraph: void GetRGB (char *buf, int size)mglGraph: void GetBGRN (char *buf, int size)const unsigned char * mgl_get_rgb (HMGL gr)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] (or is [4*i + 4*Width*j] for GetBGRN()). You have to provide the proper size of the buffer, buf, i.e. the code for Python should look like
from mathgl import * gr = mglGraph(); bits='\t'; bits=bits.expandtabs(4*gr.GetWidth()*gr.GetHeight()); gr.GetBGRN(bits, len(bits));
mglGraph: const unsigned char * GetRGBA ()mglGraph: void GetRGBA (char *buf, int size)const unsigned char * mgl_get_rgba (HMGL gr)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].
mglGraph: int GetWidth ()mglGraph: int GetHeight ()int mgl_get_width (HMGL gr)int mgl_get_height (HMGL gr)Gets width and height of the image.
mglGraph: mglPoint CalcXYZ (int xs, int ys)void mgl_calc_xyz (HMGL gr, int xs, int ys, mreal *x, mreal *y, mreal *z)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 Subplots and rotation).
mglGraph: mglPoint CalcScr (mglPoint p)void mgl_calc_scr (HMGL gr, mreal x, mreal y, mreal z, int *xs, int *ys)Calculate screen point {xs,ys} for 3D coordinate {x,y,z}. The calculation are done for the last used InPlot (see Subplots and rotation).
mglGraph: void SetObjId (int id)void mgl_set_obj_id (HMGL gr, int id)Set the numeric id for object or subplot/inplot.
mglGraph: int GetObjId (int xs, int ys)int mgl_get_obj_id (HMGL gr, int xs, int ys)Get the numeric id for most upper object at pixel {xs, ys} of the picture.
mglGraph: int GetSplId (int xs, int ys)int mgl_get_spl_id (HMGL gr, int xs, int ys)Get the numeric id for most subplot/inplot at pixel {xs, ys} of the picture.
mglGraph: void Highlight (int id)void mgl_highlight (HMGL gr, int id)Highlight the object with given id.
mglGraph: long IsActive (int xs, int ys, int d=1)long mgl_is_active (HMGL gr, int xs, int ys, int d)Checks if point {xs, ys} is close to one of active point (i.e. mglBase::Act) with accuracy d and return its index or -1 if not found. Active points are special points which characterize primitives (like edges and so on). This function for advanced users only.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Many of things MathGL do in parallel by default (if MathGL was built with pthread). However, there is function which set the number of threads to be used.
int mgl_set_num_thr (int n)Set the number of threads to be used by MathGL. If n<1 then the number of threads is set as maximal number of processors (cores). If n=1 then single thread will be used (this is default if pthread was disabled).
Another option is combining bitmap image (taking into account Z-ordering) from different instances of mglGraph. This method is most appropriate for computer clusters when the data size is so large that it exceed the memory of single computer node.
mglGraph: int Combine (const mglGraph *g)int mgl_combine_gr (HMGL gr, HMGL g)Combine drawing from instance g with gr (or with this) taking into account Z-ordering of pixels. The width and height of both instances must be the same.
mglGraph: int MPI_Send (int id)int mgl_mpi_send (HMGL gr, int id)Send graphical information from node id using MPI. The width and height in both nodes must be the same.
mglGraph: int MPI_Recv (int id)int mgl_mpi_send (HMGL gr, int id)Receive graphical information from node id using MPI. The width and height in both nodes must be the same.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated by Build Daemon user on December 22, 2013 using texi2html 1.82.