set(CMAKE_VERBOSE_MAKEFILE ON)
#set(MathGL_VERSION_MAJOR 2)
#set(MathGL_VERSION_MINOR 2.2)
-set(MathGL_SOVERSION 7.3.0)
+set(MathGL_SOVERSION 7.4.0)
MACRO(MGL_DEPENDENT_OPTION option doc default depends1 force1 depends2 force2)
option(enable-openmp "Enable OpenMP support" ON)
option(enable-lgpl "Enable only LGPL part of MathGL")
option(enable-mgl2 "Use names 'libmgl2-*' instead of 'libmgl-*'")
-#option(enable-ltdl "Enable loading modules support")
+option(enable-ltdl "Enable loading modules support")
CMAKE_DEPENDENT_OPTION(enable-doc-site "Enable HTML documentation for website" OFF "NOT enable-all-docs" ON)
CMAKE_DEPENDENT_OPTION(enable-doc-html "Enable HTML documentation" OFF "NOT enable-all-docs" ON)
CMAKE_DEPENDENT_OPTION(enable-doc-info "Enable INFO documentation" OFF "NOT enable-all-docs" ON)
CMAKE_DEPENDENT_OPTION(enable-doc-prc "Enable PDF samples for HTML docs" OFF "NOT enable-all-docs" ON)
CMAKE_DEPENDENT_OPTION(enable-doc-json "Enable JSON samples for HTML docs" OFF "NOT enable-all-docs" ON)
option(enable-texi2html "Use texi2html (obsolete package) instead of texi2any" OFF)
+CMAKE_DEPENDENT_OPTION(enable-mgltex "Enable installation of mgltex package (MGL scripts in LATEX document)" OFF "NOT enable-lgpl" OFF)
CMAKE_DEPENDENT_OPTION(enable-zlib "Enable zlib support" ON "NOT enable-all" ON)
CMAKE_DEPENDENT_OPTION(enable-png "Enable png support" ON "NOT enable-all" ON)
if(UNIX AND enable-rvalue)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif(UNIX AND enable-rvalue)
-
+
# MSVC does not require any special flags
if(enable-qt4 OR enable-qt5)
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
if(WORDS_BIGENDIAN)
- ADD_DEFINITIONS("-DWORDS_BIGENDIAN")
+ ADD_DEFINITIONS(-DWORDS_BIGENDIAN)
endif(WORDS_BIGENDIAN)
CHECK_FUNCTION_EXISTS(sin MGL_SIN)
endif(MGL_SIN_M)
endif(NOT MGL_SIN)
if(HAVE_MEMRCHR)
- ADD_DEFINITIONS("-DHAVE_MEMRCHR")
+ ADD_DEFINITIONS(-DHAVE_MEMRCHR)
endif(HAVE_MEMRCHR)
include(CheckCXXSourceCompiles)
set(MGL_HAVE_GSL 0)
endif(enable-gsl)
-#if(enable-all OR enable-ltdl)
-# set(MGL_HAVE_LTDL 1)
-# find_library(LTDL_LIB ltdl)
-# find_path(LTDL_INCLUDE_DIR ltdl.h)
-# if(NOT LTDL_LIB OR NOT LTDL_INCLUDE_DIR)
-# message(SEND_ERROR "${LTDL_LIB}")
-# message(SEND_ERROR "${LTDL_INCLUDE_DIR}")
-# message(SEND_ERROR "Couldn't find LTDL library.")
-# endif(NOT LTDL_LIB OR NOT LTDL_INCLUDE_DIR)
-#else(enable-all OR enable-ltdl)
-# set(MGL_HAVE_LTDL 0)
-#endif(enable-all OR enable-ltdl)
+if(enable-all OR enable-ltdl)
+ set(MGL_HAVE_LTDL 1)
+ find_library(LTDL_LIB ltdl)
+ find_path(LTDL_INCLUDE_DIR ltdl.h)
+ if(NOT LTDL_LIB OR NOT LTDL_INCLUDE_DIR)
+ message(SEND_ERROR "${LTDL_LIB}")
+ message(SEND_ERROR "${LTDL_INCLUDE_DIR}")
+ message(SEND_ERROR "Couldn't find LTDL library.")
+ endif(NOT LTDL_LIB OR NOT LTDL_INCLUDE_DIR)
+else(enable-all OR enable-ltdl)
+ set(MGL_HAVE_LTDL 0)
+endif(enable-all OR enable-ltdl)
if(enable-hdf4)
set(MGL_HAVE_HDF4 1)
endif(MGL_HAVE_DOC_HTML OR MGL_HAVE_DOC_SITE OR MGL_HAVE_DOC_INFO OR MGL_HAVE_DOC_PDF_RU OR MGL_HAVE_DOC_PDF_EN )
endif(NOT MSVC AND NOT BORLAND)
+
+if(enable-mgltex)
+ add_subdirectory( mgltex )
+endif(enable-mgltex)
+2.3.1 Released 20 October 2014
+
+* Add MGL command 'load' for loading MGL commands from external DLL (or .so) module.
+* Add Logo() function to draw bitmap (logo), which is stretched along whole axis range
+* Add MGL command 'reset' which restore default settings and clear image (i.e. call DefaultPlotParam()).
+* Change y coordinate at x-z projection.
+* Improve projection of 'unrotatable' objects (like legend, title, ...).
+* Add projection (Ternary&8) which is the same as usual (Ternary&4) but don't print text on projections
+* Improve orientation of axis ticks and labels.
+* Add mglWnd::SetDrawFunc().
+* Add mgl_set_global_warn() and mgl_get_global_warn() for set/get messages of global scope.
+* Make copying private of mglGraph and derived.
+* Add virtual destructors.
+* Add some static functions for mglGraph.
+* Add option "-n" to mglconv to disable automatic saving of the image.
+* Add option "-s" to mglview and mglconv to run setup script before the main one.
+* Become compatible with giflib 5.1.
+* Add light scaling at MGLD import.
+* Add scaling of frames at Adjust().
+* Possible bugfix for 32bit gcc.
+* Update docs.
+
+
2.3 Released 7 August 2014
* Add background image, which allow in particular semi-transparent background color. Correspondingly add function Rasterize() for saving current image as background, and function LoadBackground() for loading background image from PNG or JPEG file.
target_link_libraries(mgl_qt_example mgl-qt4)
endif(enable-qt5)
endif(enable-qt)
+
+if(MGL_HAVE_LTDL)
+ include_directories(${LTDL_INCLUDE_DIR})
+ add_library(mgl_module MODULE mgl_module.cpp)
+ target_link_libraries(mgl_module mgl) # for compatibility with win32
+endif(MGL_HAVE_LTDL)
+
void save(mglGraph *gr,const char *name,const char *suf);\r
void test(mglGraph *gr)\r
{\r
- gr->Rotate(40,60); gr->Fog(1); gr->Box(); return;\r
+// gr->Rotate(40,60); gr->Fog(1); gr->Box(); return;\r
mglParse par;\r
- par.Execute(gr,"subplot 1 1 0:#rotate 40 60\nperspective 0.9:box:axis\n");\r
+ par.Execute(gr,"load '/home/balakin/mathgl-code/mathgl-2x/build/examples/libmgl_module.so':baxis\n");\r
// par.Execute(gr,"subplot 1 1 0:#rotate 40 60\nperspective 1.22:box:axis\n");\r
return;\r
}\r
printf("Global:%s\n",mglGlobalMess.c_str());\r
delete gr; return 0;\r
}\r
- else if(dotest==2)\r
+ else if(dotest==2) // NOTE mgl_gen_fnt[###][6] have to be updated if new glyphs will be added to built-in font\r
+\r
{ mgl_create_cpp_font(gr->Self(), L"!-~,¡-ÿ,̀-̏,Α-ω,ϑ,ϕ,ϖ,ϰ,ϱ,ϵ,А-я,ℏ,ℑ,ℓ,ℜ,←-↙,∀-∯,≠-≯,⟂");\r
delete gr; return 0; }\r
else if(dotest==4)\r
--- /dev/null
+#include "mgl2/mgl.h"
+#include "mgl2/base.h"
+#include "mgl2/parser.h"
+//-----------------------------------------------------------------------------
+int test1(mglGraph *gr, long , mglArg *a, const char *k, const char *)
+{
+ int res=0;
+ if(!strcmp(k,"")) { gr->Box(); gr->Axis(); }
+ else if(!strcmp(k,"s")) { gr->Box(); gr->Axis(a[0].s.c_str()); }
+ else res = 1; return res;
+}
+//-----------------------------------------------------------------------------
+int test2(mglGraph *gr, long , mglArg *a, const char *k, const char *)
+{
+ int res=0;
+ if(!strcmp(k,"nnnns"))
+ {
+ gr->FaceZ(mglPoint(a[0].v-a[2].v/2,a[1].v-a[3].v/2),a[2].v,a[3].v,"r");
+ gr->Putsw(mglPoint(a[0].v,a[1].v),a[4].w.c_str());
+ }
+ else if(!strcmp(k,"nnnnss"))
+ {
+ gr->FaceZ(mglPoint(a[0].v-a[2].v/2,a[1].v-a[3].v/2),a[2].v,a[3].v,a[5].s.c_str());
+ gr->Putsw(mglPoint(a[0].v,a[1].v),a[4].w.c_str());
+ }
+ else res = 1; return res;
+}
+//-----------------------------------------------------------------------------
+mglCommand mgl_cmd_extra[] = {
+ {"baxis","Box + axis","baxis ['stl'='']", test1, 12},
+ {"trect","Box + text","trect x0 y0 dx dy 'text' ['stl'='']", test2, 13},
+ {"",0,0,0,0}};
+//-----------------------------------------------------------------------------
#define MGL_HAVE_C99_COMPLEX ${MGL_HAVE_C99_COMPLEX}
#endif
+#define MGL_HAVE_LTDL ${MGL_HAVE_LTDL}
#define MGL_HAVE_RVAL ${MGL_HAVE_RVAL}
#define MGL_HAVE_ZLIB ${MGL_HAVE_ZLIB}
#define MGL_HAVE_PNG ${MGL_HAVE_PNG}
// { return j>0 ? (j<GetNy()-1 ? (v(i,j+1,k)-v(i,j-1,k))/2 : v(i,j,k)-v(i,j-1,k)) : v(i,1,k)-v(i,0,k); }
virtual mreal dvz(long i,long j=0,long k=0) const = 0;
// { return k>0 ? (k<GetNz()-1 ? (v(i,j,k+1)-v(i,j,k-1))/2 : v(i,j,k)-v(i,j,k-1)) : v(i,j,1)-v(i,j,0); }
-
+
// Now some common function which applicable for most of data types
/// Save whole data array (for ns=-1) or only ns-th slice to text file
virtual void Save(const char *fname,long ns=-1) const
inline void PrintInfo(FILE *fp) const
{ if(fp) { fprintf(fp,"%s",mgl_data_info(this)); fflush(fp); } }
/// Get maximal value of the data
- mreal Maximal() const { return mgl_data_max(this); }
+ virtual mreal Maximal() const { return mgl_data_max(this); }
/// Get minimal value of the data
- mreal Minimal() const { return mgl_data_min(this); }
+ virtual mreal Minimal() const { return mgl_data_min(this); }
/// Get maximal value of the data which is less than 0
inline mreal MaximalNeg() const { return mgl_data_neg_max(this); }
/// Get minimal value of the data which is larger than 0
{ return AddPnt(&B,p,c,n,a,scl); }\r
long AddPnt(const mglMatrix *M, mglPoint p, mreal c=-1, mglPoint n=mglPoint(NAN), mreal a=-1, int scl=1);\r
long CopyNtoC(long k, mreal c);\r
- long CopyProj(long from, mglPoint p, mglPoint n);\r
+ long CopyProj(long from, mglPoint p, mglPoint n, short sub=0);\r
+ void SetRGBA(long k, const mglColor &c)\r
+ { mglPnt &p=Pnt[k]; p.r = c.r; p.g = c.g; p.b = c.b; p.a = c.a; }\r
virtual void Reserve(long n); ///< Allocate n-cells for Pnt and return current position\r
/// Set to reduce accuracy of points (to reduce size of output files)\r
inline void SetReduceAcc(bool val) { set(val, MGL_REDUCEACC); }\r
extern "C" {\r
#endif\r
\r
-/// Check if MathGL version is valid\r
+/// Check if MathGL version is valid (return 0) or not (return 1)\r
int MGL_EXPORT mgl_check_version(const char *ver);\r
int MGL_EXPORT mgl_check_version_(const char *ver, int);\r
/// Suppress printing warnings to stderr\r
/// Set warning code ant fill message\r
void MGL_EXPORT mgl_set_warn(HMGL gr, int code, const char *text);\r
void MGL_EXPORT mgl_set_warn_(uintptr_t *gr, int *code, const char *text,int);\r
-/// Set buffer for warning messages\r
+/// Get text of warning message(s)\r
MGL_EXPORT_PURE const char *mgl_get_mess(HMGL gr);\r
int MGL_EXPORT mgl_get_mess_(uintptr_t *gr, char *out, int len);\r
\r
void MGL_EXPORT mgl_set_coor(HMGL gr, int how);\r
void MGL_EXPORT mgl_set_coor_(uintptr_t *gr, int *how);\r
/// Set to draw Ternary axis (triangle like axis, grid and so on)\r
-void MGL_EXPORT mgl_set_ternary(HMGL gr, int enable);\r
-void MGL_EXPORT mgl_set_ternary_(uintptr_t *gr, int *enable);\r
+void MGL_EXPORT mgl_set_ternary(HMGL gr, int kind);\r
+void MGL_EXPORT mgl_set_ternary_(uintptr_t *gr, int *kind);\r
\r
/// Set to use or not tick labels rotation\r
void MGL_EXPORT mgl_set_tick_rotate(HMGL gr, int enable);\r
char pos; ///< Text position ('t' by default, or 'T' for opposite)\r
mreal sh; ///< Extra shift of ticks and axis labels\r
bool inv; ///< Inverse automatic origin position\r
+ mreal angl; ///< Manual for ticks rotation (if not NAN)\r
};\r
//-----------------------------------------------------------------------------\r
/// Structure for light source\r
/// Prepare labels for ticks\r
void LabelTicks(mglAxis &aa);\r
/// Draw axis\r
- void DrawAxis(mglAxis &aa, bool text=true, char arr=0,const char *stl="",const char *opt="");\r
+ void DrawAxis(mglAxis &aa, bool text=true, char arr=0,const char *stl="",mreal angl=NAN);\r
/// Draw axis grid lines\r
void DrawGrid(mglAxis &aa, bool at_tick=false);\r
/// Update axis ranges\r
void MGL_EXPORT mgl_add_tick(HMGL gr, char dir, double val, const char *lbl);\r
void MGL_EXPORT mgl_add_tick_(uintptr_t *gr, const char *dir, mreal *val, const char *lbl,int,int);\r
void MGL_EXPORT mgl_add_tickw(HMGL gr, char dir, double val, const wchar_t *lbl);\r
-/// Tune ticks \r
+/// Tune ticks\r
void MGL_EXPORT mgl_tune_ticks(HMGL gr, int tune, double fact_pos);\r
void MGL_EXPORT mgl_tune_ticks_(uintptr_t *gr, int *tune, mreal *fact_pos);\r
/// Set templates for ticks\r
/// Callback function for mouse click\r
void MGL_EXPORT mgl_set_click_func(HMGL gr, void (*func)(void *p));\r
\r
+/// Set callback functions for drawing and data reloading\r
+void MGL_EXPORT mgl_wnd_set_func(HMGL gr, int (*draw)(HMGL gr, void *p), void *par, void (*reload)(void *p));\r
/// Set delay for animation in seconds\r
void MGL_EXPORT mgl_wnd_set_delay(HMGL gr, double dt);\r
void MGL_EXPORT mgl_wnd_set_delay_(uintptr_t *gr, mreal *dt);\r
void MGL_EXPORT mgl_parser_del_all(HMPR p);\r
void MGL_EXPORT mgl_parser_del_all_(uintptr_t *p);\r
\r
+/// Load new commands from external dynamic Library (must have "const mglCommand *mgl_cmd_extra" variable)\r
+void MGL_EXPORT mgl_parser_load(HMPR pr, const char *dll_name);\r
+void MGL_EXPORT mgl_parser_load_(uintptr_t *pr, const char *dll_name,int);\r
+\r
/// Parse and draw single line of the MGL script\r
int MGL_EXPORT mgl_parse_line(HMGL gr, HMPR p, const char *str, int pos);\r
int MGL_EXPORT mgl_parse_line_(uintptr_t* gr, uintptr_t* p, const char *str, int *pos, int);\r
/// Allow reading/saving files\r
void MGL_EXPORT mgl_parser_allow_file_io(HMPR p, int a);\r
void MGL_EXPORT mgl_parser_allow_file_io_(uintptr_t* p, int *a);\r
+/// Allow loading commands from external libraries\r
+void MGL_EXPORT mgl_parser_allow_dll_call(HMPR p, int a);\r
+void MGL_EXPORT mgl_parser_allow_dll_call_(uintptr_t* p, int *a);\r
/// Set flag to stop script parsing\r
void MGL_EXPORT mgl_parser_stop(HMPR p);\r
void MGL_EXPORT mgl_parser_stop_(uintptr_t* p);\r
inline void Fill(HMGL gr, const char *eq, const mglDataA &vdat, const mglDataA &wdat,const char *opt="")\r
{ mgl_data_fill_eq(gr,this,eq,&vdat,&wdat,opt); }\r
/// Equidistantly fill the data to range [x1,x2] in direction dir\r
- inline void Fill(mreal x1,mreal x2=NaN,char dir='x')\r
+ inline void Fill(mreal x1,mreal x2=mglNaN,char dir='x')\r
{ mgl_data_fill(this,x1,x2,dir); }\r
/// Fill the data by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in range [p1,p2] using global spline\r
inline void RefillGS(const mglDataA &xdat, const mglDataA &vdat, mreal x1, mreal x2,long sl=-1)\r
inline void Envelop(char dir='x')\r
{ mgl_data_envelop(this,dir); }\r
/// Remove phase jump\r
- inline void Sew(const char *dirs="xyz", mreal da=2*Pi)\r
+ inline void Sew(const char *dirs="xyz", mreal da=2*mglPi)\r
{ mgl_data_sew(this,dirs,da); }\r
/// Smooth the data on specified direction or directions\r
inline void Smooth(const char *dirs="xyz",mreal delta=0)\r
long nz; ///< number of points in 3d dimensions ('z' dimension)\r
mreal di, dj, dk, a0;\r
public:\r
- mglDataV(long xx=1,long yy=1,long zz=1,mreal x1=0,mreal x2=NaN,char dir='x'):nx(xx),ny(yy),nz(zz)\r
+ mglDataV(long xx=1,long yy=1,long zz=1,mreal x1=0,mreal x2=mglNaN,char dir='x'):nx(xx),ny(yy),nz(zz)\r
{ Fill(x1,x2,dir); }\r
mglDataV(const mglDataV &d):nx(d.nx),ny(d.ny),nz(d.nz),di(d.di),dj(d.dj),dk(d.dk),a0(d.a0) {}\r
#if MGL_HAVE_RVAL\r
/// For going throw all elements\r
inline void All() { di=dj=dk=1; a0=0; }\r
/// Equidistantly fill the data to range [x1,x2] in direction dir\r
- inline void Fill(mreal x1,mreal x2=NaN,char dir='x')\r
+ inline void Fill(mreal x1,mreal x2=mglNaN,char dir='x')\r
{\r
di=dj=dk=0; a0=x1;\r
if(mgl_isnum(x2))\r
inline void Fill(mglBase *gr, const char *eq, const mglDataA &vdat, const mglDataA &wdat,const char *opt="")\r
{ mgl_datac_fill_eq(gr,this,eq,&vdat,&wdat,opt); }\r
/// Equidistantly fill the data to range [x1,x2] in direction dir\r
- inline void Fill(dual x1,dual x2=NaN,char dir='x')\r
+ inline void Fill(dual x1,dual x2=mglNaN,char dir='x')\r
{ mgl_datac_fill(this,x1,x2,dir); }\r
\r
/// Put value to data element(s)\r
#define MGL_LOCAL_PURE MGL_NO_EXPORT MGL_FUNC_PURE\r
\r
#if MGL_HAVE_RVAL // C++11 don't support register keyword\r
+#if (!defined(_MSC_VER)) || (defined(_MSC_VER) && (_MSC_VER < 1310))\r
#define register\r
#endif\r
+#endif\r
\r
#if MGL_HAVE_OMP\r
#include <omp.h>\r
\r
#endif\r
\r
-#define MGL_VER2 3.0 // minor version of MathGL 2.* (like 1.3 for v.2.1.3)\r
+#define MGL_VER2 3.1 // minor version of MathGL 2.* (like 1.3 for v.2.1.3)\r
//-----------------------------------------------------------------------------\r
#ifdef WIN32 //_MSC_VER needs this before math.h\r
#define _USE_MATH_DEFINES\r
void MGL_EXPORT mgl_wcstombs(char *dst, const wchar_t *src, int size);\r
/// Clear internal data for speeding up FFT and Hankel transforms\r
void MGL_EXPORT mgl_clear_fft();\r
+/// Set global warning message\r
+void MGL_EXPORT mgl_set_global_warn(const char *text);\r
+void MGL_EXPORT mgl_set_global_warn_(const char *text,int);\r
+/// Get text of global warning message(s)\r
+MGL_EXPORT_PURE const char *mgl_get_global_warn();\r
+int MGL_EXPORT mgl_get_global_warn_(char *out, int len);\r
#ifdef __cplusplus\r
}\r
#endif\r
HMDT MGL_EXPORT mgl_hist_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *opt);\r
\r
void MGL_EXPORT mgl_puts_fit(HMGL gr, double x, double y, double z, const char *prefix, const char *font, double size);\r
+mreal MGL_EXPORT mgl_get_fit_chi();\r
//-----------------------------------------------------------------------------\r
uintptr_t MGL_EXPORT mgl_fit_1_(uintptr_t* gr, uintptr_t* y, const char *eq, const char *vars, uintptr_t *ini, const char *opt,int, int l, int n);\r
uintptr_t MGL_EXPORT mgl_fit_2_(uintptr_t* gr, uintptr_t* z, const char *eq, const char *vars, uintptr_t *ini, const char *opt,int, int l, int n);\r
uintptr_t MGL_EXPORT mgl_hist_xyz_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* z, uintptr_t* a, const char *opt,int);\r
\r
void MGL_EXPORT mgl_puts_fit_(uintptr_t* gr, mreal *x, mreal *y, mreal *z, const char *prefix, const char *font, mreal *size, int l, int n);\r
+mreal MGL_EXPORT mgl_get_fit_chi_();\r
//-----------------------------------------------------------------------------\r
#ifdef __cplusplus\r
}\r
/// Wrapper class for windows displaying graphics\r
class MGL_EXPORT mglFLTK : public mglWnd\r
{\r
+ mglFLTK(const mglFLTK &t) {} // copying is not allowed\r
+ const mglFLTK &operator=(const mglFLTK &t) { return t; }\r
public:\r
mglFLTK(const char *title="MathGL") : mglWnd()\r
{ gr = mgl_create_graph_fltk(0,title,0,0); }\r
mglFLTK(mglDraw *draw, const char *title="MathGL") : mglWnd()\r
{ gr = mgl_create_graph_fltk(draw?mgl_draw_class:0,title,draw,mgl_reload_class);\r
mgl_set_click_func(gr, mgl_click_class); }\r
+ virtual ~mglFLTK() {}\r
int Run() { return mgl_fltk_run(); } ///< Run main loop for event handling\r
int RunThr() { return mgl_fltk_thr(); } ///< Run main loop for event handling in separate thread\r
};\r
\r
const Fl_Menu_Item *popup; ///< pointer to popup menu items\r
Fl_Widget *wpar; ///< widget for popup menu\r
- void *vpar; ///< parameter for popup menu\r
- mreal tet,phi; ///< rotation angles\r
+ void *vpar; ///< parameter for popup menu\r
+ mreal tet,phi; ///< rotation angles\r
bool rotate; ///< flag for handle mouse\r
- bool zoom; ///< flag for zoom by mouse\r
+ bool zoom; ///< flag for zoom by mouse\r
bool wire;\r
- mreal x1,x2,y1,y2; ///< zoom region\r
- int flag; ///< bitwise flag for general state (1-Alpha, 2-Light)\r
+ mreal x1,x2,y1,y2; ///< zoom region\r
+ int flag; ///< bitwise flag for general state (1-Alpha, 2-Light)\r
int x0,y0,xe,ye; ///< mouse position\r
char pos[128];\r
\r
virtual void draw(); ///< quick drawing function\r
- int handle(int code); ///< handle mouse events\r
+ int handle(int code); ///< handle mouse events\r
void resize(int x, int y, int w, int h); ///< resize control\r
};\r
//-----------------------------------------------------------------------------\r
//-----------------------------------------------------------------------------\r
class MGL_EXPORT mglGLUT: public mglGraph\r
{\r
+ mglGLUT(const mglGLUT &t) {} // copying is not allowed\r
+ const mglGLUT &operator=(const mglGLUT &t) { return t; }\r
public:\r
mglGLUT(int (*draw)(HMGL gr, void *p), const char *title="MathGL", void *par=0, void (*load)(void *p)=0) : mglGraph(-1)\r
{ gr = mgl_create_graph_glut(draw,title,par,load); }\r
{ gr = mgl_create_graph_glut(draw?mgl_draw_graph:0,title,(void*)draw,0); }\r
mglGLUT(mglDraw *draw=0, const char *title="MathGL") : mglGraph(-1)\r
{ gr = mgl_create_graph_glut(draw?mgl_draw_class:0,title,draw,mgl_reload_class); }\r
+ virtual ~mglGLUT() {}\r
\r
inline void ToggleAlpha() ///< Switch on/off transparency (do not overwrite user settings)\r
{ mgl_glut_toggle_alpha(gr); }\r
#ifdef __cplusplus\r
#include "mgl2/data.h"\r
#include "mgl2/datac.h"\r
+#include <sys/stat.h>\r
//-----------------------------------------------------------------------------\r
/// Wrapper class for all graphics\r
class MGL_EXPORT mglGraph\r
{\r
+ mglGraph(const mglGraph &t) {} // copying is not allowed\r
+ const mglGraph &operator=(const mglGraph &t) { return t; }\r
protected:\r
HMGL gr;\r
public:\r
- inline mglGraph(int kind=0, int width=600, int height=400)\r
+ mglGraph(int kind=0, int width=600, int height=400)\r
{\r
if(kind==-1) gr=NULL;\r
#if MGL_HAVE_OPENGL\r
#else\r
else if(kind==1)\r
{ gr=mgl_create_graph(width, height);\r
- mglGlobalMess += "OpenGL support was disabled. Please, enable it and rebuild MathGL.\n"; }\r
+ SetGlobalWarn("OpenGL support was disabled. Please, enable it and rebuild MathGL."); }\r
#endif\r
else gr=mgl_create_graph(width, height);\r
}\r
- inline mglGraph(const mglGraph &graph)\r
- { gr = graph.gr; mgl_use_graph(gr,1); }\r
- inline mglGraph(HMGL graph)\r
+ mglGraph(HMGL graph)\r
{ gr = graph; mgl_use_graph(gr,1); }\r
virtual ~mglGraph()\r
{ if(mgl_use_graph(gr,-1)<1) mgl_delete_graph(gr); }\r
inline void RestoreFont() { mgl_restore_font(gr); }\r
/// Set to use or not text rotation\r
inline void SetRotatedText(bool rotated) { mgl_set_rotated_text(gr, rotated); }\r
+ /// Set default font for all new HMGL and mglGraph objects\r
+ static inline void SetDefFont(const char *name, const char *path=NULL) { mgl_def_font(name,path); }\r
\r
/// Set default palette\r
inline void SetPalette(const char *colors) { mgl_set_palette(gr, colors); }\r
inline int GetWarn() { return mgl_get_warn(gr);}\r
/// Set warning code ant fill message\r
inline void SetWarn(int code, const char *info) { mgl_set_warn(gr,code,info); }\r
- /// Set buffer for warning messages\r
+ /// Get text of warning message(s)\r
inline const char *Message() { return mgl_get_mess(gr); }\r
+ /// Set global warning message\r
+ static inline void SetGlobalWarn(const char *text) { mgl_set_global_warn(text); }\r
+ /// Get text of global warning message(s)\r
+ static inline const char *GlobalWarn() { return mgl_get_global_warn(); }\r
+ /// Suppress printing warnings to stderr\r
+ static inline void SuppressWarn(bool on) { mgl_suppress_warn(on); }\r
+ /// Check if MathGL version is valid (return false) or not (return true)\r
+ static inline bool CheckVersion(const char *ver) { return mgl_check_version(ver); }\r
\r
/// Set axis range scaling -- simplified way to shift/zoom axis range -- need to replot whole image!\r
inline void ZoomAxis(mglPoint p1=mglPoint(0,0,0,0), mglPoint p2=mglPoint(1,1,1,1))\r
/// Set axis origin\r
inline void SetOrigin(mglPoint p)\r
{ mgl_set_origin(gr, p.x, p.y, p.z); }\r
- inline void SetOrigin(double x0, double y0, double z0=NaN)\r
+ inline void SetOrigin(double x0, double y0, double z0=mglNaN)\r
{ mgl_set_origin(gr, x0, y0, z0); }\r
\r
/// Set the transformation formulas for coordinate\r
inline void AddTick(char dir, double val, const wchar_t *lbl)\r
{ mgl_add_tickw(gr,dir,val,lbl); }\r
/// Set the ticks parameters and string for its factor\r
- inline void SetTicks(char dir, double d=0, int ns=0, double org=NaN, const char *factor="")\r
+ inline void SetTicks(char dir, double d=0, int ns=0, double org=mglNaN, const char *factor="")\r
{ mgl_set_ticks_fact(gr, dir, d, ns, org, factor); }\r
inline void SetTicks(char dir, double d, int ns, double org, const wchar_t *factor)\r
{ mgl_set_ticks_factw(gr, dir, d, ns, org, factor); }\r
/// Draws the arc around axis 'z' with center at p0 and starting from p1, by color stl and angle a (in degrees)\r
inline void Arc(mglPoint p0, mglPoint p1, double a, const char *stl="r")\r
{ mgl_arc_ext(gr, p0.x,p0.y,p0.z, 0,0,1, p1.x,p1.y,p0.z, a,stl); }\r
+ /// Draws bitmap (logo) which is stretched along whole axis range\r
+ inline void Logo(long w, long h, const unsigned char *rgba, bool smooth=false, const char *opt="")\r
+ { mgl_logo(gr, w, h, rgba, smooth, opt); }\r
+ inline void Logo(const char *fname, bool smooth=false, const char *opt="")\r
+ { mgl_logo_file(gr, fname, smooth, opt); }\r
\r
/// Print text in position p with specified font\r
inline void Putsw(mglPoint p,const wchar_t *text,const char *font=":C",double size=-1)\r
{ mgl_pipe_3d(gr, &ax, &ay, &az, sch, r0, opt); }\r
\r
/// Draw density plot for data at x = sVal\r
- inline void DensX(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void DensX(const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_dens_x(gr, &a, stl, sVal, opt); }\r
/// Draw density plot for data at y = sVal\r
- inline void DensY(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void DensY(const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_dens_y(gr, &a, stl, sVal, opt); }\r
/// Draw density plot for data at z = sVal\r
- inline void DensZ(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void DensZ(const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_dens_z(gr, &a, stl, sVal, opt); }\r
/// Draw contour lines for data at x = sVal\r
- inline void ContX(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void ContX(const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_cont_x(gr, &a, stl, sVal, opt); }\r
- inline void ContX(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void ContX(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_cont_x_val(gr, &v, &a, stl, sVal, opt); }\r
/// Draw contour lines for data at y = sVal\r
- inline void ContY(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void ContY(const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_cont_y(gr, &a, stl, sVal, opt); }\r
- inline void ContY(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void ContY(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_cont_y_val(gr, &v, &a, stl, sVal, opt); }\r
/// Draw contour lines for data at z = sVal\r
- inline void ContZ(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void ContZ(const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_cont_z(gr, &a, stl, sVal, opt); }\r
- inline void ContZ(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void ContZ(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_cont_z_val(gr, &v, &a, stl, sVal, opt); }\r
/// Draw solid contours for data at x = sVal\r
- inline void ContFX(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void ContFX(const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_contf_x(gr, &a, stl, sVal, opt); }\r
- inline void ContFX(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void ContFX(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_contf_x_val(gr, &v, &a, stl, sVal, opt); }\r
/// Draw solid contours for data at y = sVal\r
- inline void ContFY(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void ContFY(const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_contf_y(gr, &a, stl, sVal, opt); }\r
- inline void ContFY(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void ContFY(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_contf_y_val(gr, &v, &a, stl, sVal, opt); }\r
/// Draw solid contours for data at z = sVal\r
- inline void ContFZ(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void ContFZ(const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_contf_z(gr, &a, stl, sVal, opt); }\r
- inline void ContFZ(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="")\r
+ inline void ContFZ(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=mglNaN, const char *opt="")\r
{ mgl_contf_z_val(gr, &v, &a, stl, sVal, opt); }\r
\r
/// Draw curve for formula with x in x-axis range\r
inline void PutsFit(mglPoint p, const char *prefix=0, const char *font="", double size=-1)\r
{ mgl_puts_fit(gr, p.x, p.y, p.z, prefix, font, size); }\r
/// Get last fitted formula\r
- inline const char *GetFit()\r
+ inline const char *GetFit() const\r
{ return mgl_get_fit(gr); }\r
+ /// Get chi for last fitted formula\r
+ static inline mreal GetFitChi()\r
+ { return mgl_get_fit_chi(); }\r
\r
/// Solve PDE with x,y,z in range [Min, Max]\r
inline mglData PDE(const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, double dz=0.1, double k0=100, const char *opt="")\r
mglParse(mglParse &p) { pr = p.pr; mgl_use_parser(pr,1); }\r
mglParse(bool setsize=false)\r
{ pr=mgl_create_parser(); mgl_parser_allow_setsize(pr, setsize); }\r
- virtual ~mglParse() { if(mgl_use_parser(pr,-1)<1) mgl_delete_parser(pr); }\r
+ virtual ~mglParse()\r
+ {\r
+#pragma omp critical\r
+ if(mgl_use_parser(pr,-1)<1) mgl_delete_parser(pr);\r
+ }\r
/// Get pointer to internal mglParser object\r
inline HMPR Self() { return pr; }\r
/// Parse and draw single line of the MGL script\r
/// Get number of defined commands\r
inline long GetCmdNum()\r
{ return mgl_parser_cmd_num(pr); }\r
+ /// Load new commands from external dynamic Library (must have "const mglCommand *mgl_cmd_extra" variable)\r
+ inline void LoadDLL(const char *fname)\r
+ { mgl_parser_load(pr, fname); }\r
\r
/// Set value for parameter $N\r
inline void AddParam(int id, const char *str)\r
inline void AllowSetSize(bool allow) { mgl_parser_allow_setsize(pr, allow); }\r
/// Allow reading/saving files\r
inline void AllowFileIO(bool allow) { mgl_parser_allow_file_io(pr, allow); }\r
+ /// Allow loading commands from external libraries\r
+ inline void AllowDllCall(bool allow) { mgl_parser_allow_dll_call(pr, allow); }\r
/// Set flag to stop script parsing\r
inline void Stop() { mgl_parser_stop(pr); }\r
\r
/// Wrapper class for all graphics\r
class MGL_EXPORT mglGraphMPI:public mglGraph\r
{\r
+ mglGraphMPI(const mglGraphMPI &t) {} // copying is not allowed\r
+ const mglGraphMPI &operator=(const mglGraphMPI &t) { return t; }\r
public:\r
inline mglGraphMPI(int kind=0, int width=600, int height=400):mglGraph(kind,width,height){}\r
- inline mglGraphMPI(const mglGraph &graph):mglGraph(graph){}\r
inline mglGraphMPI(HMGL graph):mglGraph(graph){}\r
virtual ~mglGraphMPI(){}\r
\r
#ifdef __cplusplus\r
#include "mgl2/mgl.h"\r
#include <string>\r
+#if MGL_HAVE_LTDL\r
+#include <ltdl.h>\r
+#endif\r
//-----------------------------------------------------------------------------\r
/// Structure for the command argument.\r
struct mglArg\r
{\r
friend void mgl_export(wchar_t *out, const wchar_t *in, int type);\r
public:\r
+#if MGL_HAVE_LTDL\r
+ std::vector<lt_dlhandle> DllOpened; ///< Opened external DLL (keep )\r
+#endif\r
std::vector<mglDataA*> DataList; ///< List with data and its names\r
std::vector<mglNum*> NumList; ///< List with numbers and its names\r
+ bool AllowDllCall; ///< Allow calls from external dynamic libraries\r
bool AllowSetSize; ///< Allow using setsize command\r
bool AllowFileIO; ///< Allow reading/saving files\r
bool Stop; ///< Stop command was. Flag prevent further execution\r
void MGL_EXPORT mgl_table_(uintptr_t *gr, mreal *x, mreal *y, uintptr_t *val, const char *text, const char *fnt, const char *opt,int,int,int);\r
void MGL_EXPORT mgl_tablew(HMGL gr, double x, double y, HCDT val, const wchar_t *text, const char *fnt, const char *opt);\r
\r
+/// Draws bitmap (logo) which is stretched along whole axis range\r
+void MGL_EXPORT mgl_logo(HMGL gr, long w, long h, const unsigned char *rgba, int smooth, const char *opt);\r
+void MGL_EXPORT mgl_logo_file(HMGL gr, const char *fname, int smooth, const char *opt);\r
+void MGL_EXPORT mgl_logo_file_(uintptr_t *gr, const char *fname, int *smooth, const char *opt,int l,int n);\r
+\r
#ifdef __cplusplus\r
}\r
#endif\r
/// Wrapper class for windows displaying graphics\r
class MGL_EXPORT mglQT : public mglWnd\r
{\r
+ mglQT(const mglQT &t) {} // copying is not allowed\r
+ const mglQT &operator=(const mglQT &t) { return t; }\r
public:\r
mglQT(const char *title="MathGL") : mglWnd()\r
{ gr = mgl_create_graph_qt(0,title,0,0); }\r
mglQT(mglDraw *draw, const char *title="MathGL") : mglWnd()\r
{ gr = mgl_create_graph_qt(draw?mgl_draw_class:0,title,draw,mgl_reload_class);\r
mgl_set_click_func(gr, mgl_click_class); }\r
+ virtual ~mglQT() {}\r
int Run() { return mgl_qt_run(); } ///< Run main loop for event handling\r
};\r
//-----------------------------------------------------------------------------\r
#include "mgl2/define.h"
//-----------------------------------------------------------------------------
-const mreal Pi = M_PI;
-const mreal NaN = NAN;
-const mreal Inf = INFINITY;
+const mreal mglPi = M_PI;
+const mreal mglNaN = NAN;
+const mreal mglInf = INFINITY;
const mreal mgl_min_a = 1./256;
//-----------------------------------------------------------------------------
#define MGL_SET_XYZ(p,xx,yy,zz) {p.x=(xx);p.y=(yy);p.z=(zz);}
\r
#include "mgl2/qt.h"\r
#include "mgl2/fltk.h"\r
-#include "mgl2/wx.h"\r
+//#include "mgl2/wx.h"\r
//-----------------------------------------------------------------------------\r
/// Wrapper class for all windows displaying graphics\r
class MGL_EXPORT mglWindow : public mglWnd\r
{\r
+ mglWindow(const mglWindow &t) {} // copying is not allowed\r
+ const mglWindow &operator=(const mglWindow &t) { return t; }\r
int wnd; ///< Type of window\r
public:\r
mglWindow(const char *title="MathGL") : mglWnd()\r
/// Abstract class for windows displaying graphics\r
class MGL_EXPORT mglWnd : public mglGraph\r
{\r
+ mglWnd(const mglWnd &t) {} // copying is not allowed\r
+ const mglWnd &operator=(const mglWnd &t) { return t; }\r
public:\r
mglWnd() : mglGraph(-1) {}\r
- virtual int Run()=0; ///< Run main loop for event handling\r
+ virtual ~mglWnd() {}\r
+ virtual int Run()=0; ///< Run main loop for event handling\r
\r
inline void ToggleAlpha() ///< Switch on/off transparency (do not overwrite user settings)\r
{ mgl_wnd_toggle_alpha(gr); }\r
{ mgl_wnd_prev_frame(gr); }\r
inline void Animation() ///< Run slideshow (animation) of frames\r
{ mgl_wnd_animation(gr); }\r
- void SetClickFunc(void (*func)(void *p)) ///< Callback function for mouse click\r
+ inline void SetClickFunc(void (*func)(void *p)) ///< Callback function for mouse click\r
{ mgl_set_click_func(gr,func); }\r
+ /// Set callback functions for drawing and data reloading\r
+ inline void SetDrawFunc(int (*draw)(mglBase *gr, void *p), void *par=NULL, void (*reload)(void *p)=NULL)\r
+ { mgl_wnd_set_func(gr,draw,par,reload); }\r
+ inline void SetDrawFunc(int (*draw)(mglGraph *gr))\r
+ { mgl_wnd_set_func(gr,draw?mgl_draw_graph:0,(void*)draw,0); }\r
+ inline void SetDrawFunc(mglDraw *draw)\r
+ { mgl_wnd_set_func(gr,draw?mgl_draw_class:0,draw,mgl_reload_class);\r
+ mgl_set_click_func(gr, mgl_click_class); }\r
\r
inline void SetDelay(double dt) ///< Set delay for animation in seconds\r
{ mgl_wnd_set_delay(gr, dt); }\r
endif(enable-qt5)
add_executable(MglForJsTestBench ${json_src} ${json_moc_src} ${json_ui_src})
if(enable-qt5)
- add_definitions( -DMGL_USE_QT5)
+ target_compile_definitions(MglForJsTestBench PUBLIC MGL_USE_QT5)
target_link_libraries(MglForJsTestBench mgl-qt5)
qt5_use_modules(MglForJsTestBench Core Widgets Gui Network WebKit WebKitWidgets PrintSupport)
else(enable-qt5)
../include/mgl2/type.h
../include/mgl2/data.h
../include/mgl2/mgl.h
+mgl.i
+data.i
+type.i
)
set(mgl_clean_files "")
#include "mgl2/type.h"
#include "mgl2/data.h"
#include "mgl2/mgl.h"
+const double Pi = M_PI;
+const double NaN = NAN;
+const double Inf = INFINITY;
%}
#if MGL_USE_DOUBLE
/// Wrapper class for all graphics
class mglGraph
{
+ mglGraph(const mglGraph &t) {} // copying is not allowed
+ const mglGraph &operator=(const mglGraph &t) { return t; }
protected:
HMGL gr;
public:
#endif
else gr=mgl_create_graph(width, height);
}
- inline mglGraph(const mglGraph &graph)
- { gr = graph.gr; mgl_use_graph(gr,1); }
inline mglGraph(HMGL graph)
{ gr = graph; mgl_use_graph(gr,1); }
virtual ~mglGraph()
//-----------------------------------------------------------------------------
const mreal Pi = M_PI;
const mreal NaN = NAN;
+const mreal Inf = INFINITY;
const mreal mgl_min_a = 1./256;
//-----------------------------------------------------------------------------
/// Class for point in 3D space
--- /dev/null
+find_program(findpdflatex pdflatex)
+if(NOT findpdflatex)
+ message(SEND_ERROR "Couldn't find pdflatex needed for LATEX example building.")
+endif(NOT findpdflatex)
+find_program(findkpsewhich kpsewhich)
+if(NOT findkpsewhich)
+ message(SEND_ERROR "Couldn't find kpsewhich needed for LATEX example install.")
+endif(NOT findkpsewhich)
+find_program(findmktexlsr mktexlsr)
+if(NOT findmktexlsr)
+ message(SEND_ERROR "Couldn't find mktexlsr needed for LATEX example install.")
+endif(NOT findmktexlsr)
+execute_process(
+ COMMAND ${findkpsewhich} -var-value=TEXMFLOCAL
+ OUTPUT_VARIABLE TEXMFLOCALDIR
+ RESULT_VARIABLE TEXMFLOCAL_ERR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+if(NOT TEXMFLOCALDIR)
+ message(SEND_ERROR "Couldn't find TEXMFLOCAL directory.")
+endif(NOT TEXMFLOCALDIR)
+
+set(extramgl Axis_projection Vectorial)
+
+add_custom_command(OUTPUT scripts
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${MathGL_BINARY_DIR}/mgltex/scripts
+ COMMAND ${CMAKE_COMMAND} -E copy ${MathGL_SOURCE_DIR}/mgltex/sample.tex ${MathGL_BINARY_DIR}/mgltex/
+ COMMAND ${CMAKE_COMMAND} -E copy ${MathGL_SOURCE_DIR}/mgltex/mgltex.sty ${MathGL_BINARY_DIR}/mgltex/
+ COMMAND ${findpdflatex} -draftmode sample.tex
+)
+foreach(mglscr ${extramgl})
+ list(APPEND mglpng scripts/${mglscr}.png)
+ add_custom_command(OUTPUT scripts/${mglscr}.png
+ COMMAND mglconv -o ${mglscr}.png ${mglscr}.mgl
+ DEPENDS mglconv scripts
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/mgltex/scripts/
+ )
+endforeach(mglscr)
+
+add_custom_command(OUTPUT scripts/sample.png
+ COMMAND mglconv -o scripts/sample.png scripts/sample.mgl
+ DEPENDS mglconv scripts
+)
+
+add_custom_command(OUTPUT sample.pdf
+ COMMAND ${findpdflatex} sample.tex
+ DEPENDS mgltex.sty sample.tex ${mglpng} scripts/sample.png)
+add_custom_target(pdf ALL DEPENDS sample.pdf)
+
+get_directory_property(mglconv_clean ADDITIONAL_MAKE_CLEAN_FILES)
+set(mglconv_clean ${mglconv_clean} scripts sample.sty sample.tex sample.aux sample.log)
+set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${mglconv_clean}")
+
+install(FILES mgltex.sty DESTINATION ${TEXMFLOCALDIR}/tex/latex/mgltex/)
+install(FILES sample.tex mgltex.pdf ${MathGL_BINARY_DIR}/mgltex/sample.pdf DESTINATION ${TEXMFLOCALDIR}/doc/latex/mgltex/)
+install(CODE "execute_process(COMMAND ${findmktexlsr} ${TEXMFLOCALDIR})")
--- /dev/null
+% \iffalse meta-comment
+%
+% Copyright (C) 2014 by Diego Sejas <diego.mathematician@gmail.com>
+%
+% This program is free software: you can redistribute it and/or modify it
+% under the terms of the GNU General Public License as published by the
+% Free Software Foundation, either version 3 of the License, or (at your
+% option) any later version.
+%
+% This program is distributed in the hope that it will be useful, but
+% WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+% Public License for more details.
+%
+% You should have received a copy of the GNU General Public License along
+% with this program. If not, see <http://www.gnu.org/licenses/>.
+%
+% \fi
+%
+% \iffalse
+%<package>\def\mgl@name{mgltex}
+%<package>\def\mgl@date{2014/09/16}
+%<package>\def\mgl@version{1.0}
+%<package>\def\mgl@description{Embed MGL code into LaTeX documents}
+%<package>
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{\mgl@name}[\mgl@date\space v.\mgl@version\space\mgl@description]
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{mgltex}
+\def\linefill#1{%
+ \leavevmode\leaders\hrule height #1\hfill\kern0em%
+}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{mgltex.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{0}
+%
+% \CharacterTable
+% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+% \changes{v1.0}{2014/09/27}{Initial version}
+%
+% \GetFileInfo{mgltex.sty}
+%
+% \DoNotIndex{}
+%
+% \title{The \textsf{\mglTeX} package\thanks{This document corresponds to \textsf{\mglTeX}~\fileversion, dated \filedate.}}
+% \author{Diego Sejas Viscarra\\\texttt{diego.mathematician@gmail.com}}
+%
+% \maketitle
+%
+% \begin{abstract}
+% \noindent
+% \end{abstract}
+%
+% \section{Introduction}
+% MathGL is a fast and efficient library by Alexey Balakin for the creation of high-quality publication-ready scientific graphics. It implements more than $50$ different types of graphics for 1d, 2d and 3d large sets of data. It supports exporting images to bitmap formats (PNG, JPEG, BMP, etc.), or vector formats (EPS, \TeX, SVG, etc.), or 3d image formats (STL, OBJ, XYZ, etc.), and even its own 3d format, MGLD. MathGL also defines its own vector font specification format, and supports UTF-16 encoding with \TeX-like symbol parsing. It supports various kinds of transparency and lighting, textual formula evaluation, arbitrary curvilinear coordinate systems, loading of subroutines from .dll or .so libraries, and many other useful features.
+%
+% MathGL has interfaces for a wide variety of programming languages, such as C/C++, Fortran, Python, Octave, Pascal, Forth, and many others, but it also defines its own scripting language, called \emph{MGL}, which can be used to generate graphics independently of any programming language. The \textsf{\mglTeX} package adds support to embed MGL code inside \LaTeX{} documents, which is automatically extracted and executed, and the resulting images are included in the document.
+%
+% Besides the obvious advantage of having available all the useful features of MathGL, \textsf{\mglTeX} facilitates the maintenance of your document, since both code for text and code for graphics are contained in a single file.
+%
+% \section{Usage}
+% \noindent The simplest way to load \textsf{\mglTeX} to a \LaTeX{} document is to write the command
+% \begin{center}
+% |\usepackage{mgltex}|
+% \end{center}
+% in the preamble. Alternatively, one can pass a number of options to the package by means of the syntax
+% \begin{center}
+% |\usepackage|\oarg{options list}|{mgltex}|,
+% \end{center}
+% where \meta{options list} is a comma-separated list that can contains one or more of the following options:
+% \begin{itemize}
+% \item |draft|: The generated images won't be included in the document. This option is useful when fast compilation of the document is needed.
+% \item |final|: This overrides the |draft| option.
+% \item |png|, |jpg|, |jpeg|: To export images to the corresponding bitmap format.
+% \item |eps|, |epsz|: To export to uncompressed/compressed EPS format as primitives.
+% \item |bps|, |bpsz|: To export to uncompressed/compressed EPS format as bitmap.
+% \item |pdf|: To export to 3D PDF format.
+% \end{itemize}
+% It must be noted that the options that specify the format to save the images are exclusive, in the sense that if one specifies more than one format, only the last one will be used.
+%
+% The are two ways to compile a document with \textsf{\mglTeX}: The first way is to run
+% \begin{center}
+% |latex --shell-escape |\meta{document}
+% \end{center}
+% twice, since the first run will extract the MGL code, execute it and include some of the resulting graphics, while the second run will include the remaining graphics; the second way is to run |latex |\meta{document} to extract the MGL code, then execute the generated scripts with the program |mglconv| (which comes with MathGL), and execute |latex |\meta{document} once more to include the graphics.
+%
+% \subsection{Environments for MGL code embedding}
+% \DescribeEnv{mgl}\noindent The main environment defined by \textsf{\mglTeX} is |mgl|. It extracts its contents to a general script, called \meta{document}.mgl, where \meta{document} stands for the name of the \LaTeX{} file being compiled; this script is compiled, and the corresponding image is included. Its syntax is:
+% \begin{center}
+% \begin{tabular}{l}
+% \hline\\[-0.75em]
+% |\begin{mgl}|\oarg{key-val list}\\[0.5em]
+% \hss\meta{MGL code}\hss\\[0.5em]
+% |\end{mgl}|\\[0.25em]
+% \hline
+% \end{tabular}
+% \end{center}
+% Here, \meta{key-val list} accepts the same optional arguments as the |\includegraphics| command from the \textsf{graphicx} package, plus an additional one, |imgext|, which can be used to specify the extension to save the graphic. The \meta{MGL code} doesn't need to contain any specific instruction to create the image, since \textsf{\mglTeX} takes care of that.
+%
+% \DescribeEnv{mgladdon} This environment adds its contents to the general script \meta{document}.mgl, but it doesn't produce any image. It doesn't require any kind of arguments.
+% \begin{center}
+% \begin{tabular}{l}
+% \hline\\[-0.75em]
+% |\begin{mgladdon}|\\[0.5em]
+% \hss\meta{MGL code}\hss\\[0.5em]
+% |\end{mgladdon}|\\[0.25em]
+% \hline
+% \end{tabular}
+% \end{center}
+%
+% \DescribeEnv{mglcode} This is the same as the |mgl| environment, but the corresponding code is written \emph{verbatim} to a separate script, whose name is specified as mandatory argument. It accepts the same optional arguments as |mgl|.
+% \begin{center}
+% \begin{tabular}{l}
+% \hline\\[-0.75em]
+% |\begin{mglcode}|\oarg{key-val list}\marg{script\_name}\\[0.5em]
+% \hss\meta{MGL code}\hss\\[0.5em]
+% |\end{mglcode}|\\[0.25em]
+% \hline
+% \end{tabular}
+% \end{center}
+%
+% \DescribeEnv{mglscript} The code within |mglscript| is written verbatim to a script whose name is specified as mandatory argument, but no image is produced. It is useful for creation of MGL scripts which can be later post-processed by another package, like \textsf{listings}.
+% \begin{center}
+% \begin{tabular}{l}
+% \hline\\[-0.75em]
+% |\begin{mglscript}|\marg{script\_name}\\[0.5em]
+% \hss\meta{MGL code}\hss\\[0.5em]
+% |\end{mglscript}|\\[0.25em]
+% \hline
+% \end{tabular}
+% \end{center}
+%
+% \DescribeEnv{mglfunc} This is used to define MGL functions within the general script \meta{document}.mgl. It takes one mandatory argument, which is the name of the function, plus one optional argument, which specifies the number of arguments of the function. The environment needs to contain only the body of the function, since the lines ``func \meta{function\_name} \meta{number of arguments}'' and ``return'' are appended automatically at the beginning and the end, respectively. The resulting code is written at the end of the general script, after the |stop| command, which is also written automatically.
+% \begin{center}
+% \begin{tabular}{l}
+% \hline\\[-0.75em]
+% |\begin{mglfunc}|\oarg{number of arguments}\marg{function\_name}\\[0.5em]
+% \hss\meta{MGL function body}\hss\\[0.5em]
+% |\end{mglfunc}|\\[0.25em]
+% \hline
+% \end{tabular}
+% \end{center}
+%
+% \subsection{Fast creation of graphics}
+% \noindent\textsf{\mglTeX} defines a convenient way to work with many graphics that have exactly the same settings (for example, same angles of rotation, same type of grid, etc.): instead of writing repetitive code every time it's needed, it can be stored in memory with the |mglplotsettings| environment, and then can be used when needed with the |\mglplot| command.
+%
+% \DescribeEnv{mglplotsettings} This environment stores its contents in memory for later use. It accepts one mandatory argument, which is a keyword (name) to be associated to the corresponding block of code, so different blocks of code can be stored with different names.
+% \begin{center}
+% \begin{tabular}{l}
+% \hline\\[-0.75em]
+% |\begin{mglplotsettings}|\marg{keyword}\\[0.5em]
+% \hss\meta{MGL code}\hss\\[0.5em]
+% |\end{mglplotsettings}|\\[0.25em]
+% \hline
+% \end{tabular}
+% \end{center}
+%
+% \DescribeMacro{\mglplot} This command is used for fast generation of graphics with default settings, and can be used in parallel with the |mglplotsettings| environment. It accepts one mandatory argument which consists of MGL instructions, separated by the symbol ``:'', which can span through various text lines. It also accepts the same optional arguments as the |mgl| environment, plus an additional one, called |settings|, which can be used to specify a keyword used in a |mglplotsettings| environment. If the |settings| option is specified, the code in the mandatory argument will be appended to the block of code of the corresponding |mglplotsettings| environment.
+% \begin{center}
+% \begin{tabular}{l}
+% \hline\\[-0.75em]
+% |\mglplot|\oarg{key-val list}\marg{MGL code}\\[0.25em]
+% \hline
+% \end{tabular}
+% \end{center}
+%
+% \subsection{Verbatim-like environments}
+% \DescribeEnv{mglblock}\noindent It writes its contents \emph{verbatim} to a file, whose name is given as mandatory argument, and then it also typesets its contents on the \LaTeX{} document, numbering each line of code.
+% \begin{center}
+% \begin{tabular}{l}
+% \hline\\[-0.75em]
+% |\begin{mglblock}|\marg{script\_name}\\[0.5em]
+% \hss\meta{MGL code}\hss\\[0.5em]
+% |\end{mglblock}|\\[0.25em]
+% \hline
+% \end{tabular}
+% \end{center}
+%
+% \DescribeEnv{mglverbatim} It typesets its contents to the \LaTeX{} document, numbering each line of code.
+% \begin{center}
+% \begin{tabular}{l}
+% \hline\\[-0.75em]
+% |\begin{mglverbatim}|\\[0.5em]
+% \hss\meta{MGL code}\hss\\[0.5em]
+% |\end{mglverbatim}|\\[0.25em]
+% \hline
+% \end{tabular}
+% \end{center}
+%
+% \subsection{Working with external scripts}
+% \noindent In case of having MGL scripts in their own files, \textsf{\mglTeX} can work with them without needing to transcript them to the \LaTeX{} document.
+%
+% \DescribeMacro{\mglgraphics} This command takes one mandatory argument, which is the name of an external MGL script, which will be automatically executed, and the resulting image will be included. The same optional arguments as the |mgl| environment are accepted.
+% \begin{center}
+% \begin{tabular}{l}
+% \hline\\[-0.75em]
+% |\mglgraphics|\oarg{key-val list}\marg{script\_name}\\[0.25em]
+% \hline
+% \end{tabular}
+% \end{center}
+%
+% \DescribeMacro{\mglinclude} This command takes one mandatory argument, which is the name of an external MGL script, which will be automatically transcript \emph{verbatim} on the \LaTeX{} document, and each line of code will be numerated.
+% \begin{center}
+% \begin{tabular}{l}
+% \hline\\[-0.75em]
+% |\mglinclude|\marg{script\_name}\\[0.25em]
+% \hline
+% \end{tabular}
+% \end{center}
+%
+% \subsection{Additional commands}
+% \DescribeMacro{\mgldir}\noindent This command can be used to specify where \textsf{\mglTeX} should create the MGL scripts and corresponding images. This is useful, for example, to avoid a lot of scripts and images from polluting the current directory.
+% \begin{center}
+% \begin{tabular}{l}
+% \hline\\[-0.75em]
+% |\mgldir|\marg{directory}\\[0.25em]
+% \hline
+% \end{tabular}
+% \end{center}
+% This command must be used in the preamble of the document, since the first MGL script is created at the moment of the |\begin{document}| command; trying to use it somewhere else will issue an error. On the other hand, it is the responsibility of the user to create the \meta{directory}, since \textsf{\mglTeX} won't do it automatically.
+%
+% \DescribeMacro{\mglTeX} This command just pretty-prints the name of the package.
+% \begin{center}
+% \begin{tabular}{l}
+% \hline\\[-0.75em]
+% |\mglTeX|\\[0.25em]
+% \hline
+% \end{tabular}
+% \end{center}
+%
+% \subsection{Behavior of \textsf{\mglTeX}}
+% \noindent As a convenient feature, the environments |mglcode|, |mglscript| and |mglblock| will automatically check if they are being used to create different scripts with the same name, in which case \textsf{\mglTeX} will issue a warning; however, if one of these environments overwrite an external script (not embedded in the document), it won't be noticed. Likewise, the user will be warned if the environment |mglfunc| is being used to create different MGL functions with the same name.
+%
+% When \textsf{\mglTeX} is unable to find a graphic that is supposed to include, instead of producing an error, it will warn the user about it, and will display a box in the corresponding position of the document, like the following one:
+% \begin{center}
+% \framebox[10em]{
+% \centering
+% \bfseries\Huge
+% \vbox{MGL\\image\\not\\found}
+% }
+% \end{center}
+% Notice that the first time \LaTeX{} is executed, many of these boxes will appear in the document because the graphics from the MGL scripts are created, but not all are included (until \LaTeX{} is run for the second time).
+%
+% \StopEventually{}
+% \section{Implementation}
+% \begin{macrocode}
+
+\RequirePackage{keyval}
+\RequirePackage{graphicx}
+
+\DeclareOption{draft}{%
+ \PassOptionsToPackage{\CurrentOption}{graphicx}%
+}
+\DeclareOption{final}{%
+ \PassOptionsToPackage{\CurrentOption}{graphicx}%
+}
+
+\DeclareGraphicsExtensions{.png,.eps,.jpg,.jpeg,.bps,.pdf,.epsz,.eps.gz,.bpsz,.bps.gz,.gif}
+%\DeclareGraphicsExtensions{.png,.eps,.jpg,.jpeg,.bps,.pdf,.gif}
+%\DeclareGraphicsRule{*}{eps}{*}{}
+%\DeclareGraphicsRule{.eps.gz}{eps}{.eps.bb}{`gunzip -c #1}% gzipped EPS
+%\DeclareGraphicsRule{.epsz}{eps}{.eps.bb}{`gunzip -c #1}% gzipped EPS
+%\DeclareGraphicsRule{.bps.gz}{eps}{.bps.bb}{`gunzip -c #1}% gzipped EPS
+%\DeclareGraphicsRule{.bpsz}{eps}{.bps.bb}{`gunzip -c #1}% gzipped EPS
+
+\DeclareOption{jpg}{\def\mgl@image@ext{.jpg}}
+\DeclareOption{jpeg}{\def\mgl@image@ext{.jpeg}}
+\DeclareOption{pdf}{\def\mgl@image@ext{.pdf}}
+\DeclareOption{png}{\def\mgl@image@ext{.png}}
+\DeclareOption{eps}{\def\mgl@image@ext{.eps}}
+\DeclareOption{epsz}{\def\mgl@image@ext{.eps.gz}}
+\DeclareOption{bps}{\def\mgl@image@ext{.bps}}
+\DeclareOption{bpsz}{\def\mgl@image@ext{.bps.gz}}
+\DeclareOption{gif}{\def\mgl@image@ext{.gif}}
+
+\DeclareOption{tex}{\def\mgl@image@ext{.tex}}
+%\DeclareOption{svg}{\def\mgl@image@ext{.svg}}
+%\DeclareOption{svgz}{\def\mgl@image@ext{.svgz}}
+%\DeclareOption{bmp}{\def\mgl@image@ext{.bmp}}
+%\DeclareOption{tga}{\def\mgl@image@ext{.tga}}
+%\DeclareOption{mgld}{\def\mgl@image@ext{.mgld}}
+%\DeclareOption{json}{\def\mgl@image@ext{.json}}
+%\DeclareOption{jsonz}{\def\mgl@image@ext{.jsonz}}
+%\DeclareOption{obj}{\def\mgl@image@ext{.obj}}
+%\DeclareOption{xyz}{\def\mgl@image@ext{.xyz}}
+%\DeclareOption{stl}{\def\mgl@image@ext{.stl}}
+%\DeclareOption{off}{\def\mgl@image@ext{.off}}
+%\DeclareOption{prc}{\def\mgl@image@ext{.prc}}
+
+\ExecuteOptions{final,eps}
+\ProcessOptions*
+
+\define@key{mgl@keys}{bb}{\g@addto@macro{\graph@keys}{bb=#1,}}
+\define@key{mgl@keys}{bbllx}{\g@addto@macro{\graph@keys}{bbllx=#1,}}
+\define@key{mgl@keys}{bblly}{\g@addto@macro{\graph@keys}{bblly=#1,}}
+\define@key{mgl@keys}{bburx}{\g@addto@macro{\graph@keys}{bburx=#1,}}
+\define@key{mgl@keys}{bbury}{\g@addto@macro{\graph@keys}{bbury=#1,}}
+\define@key{mgl@keys}{natwidth}{\g@addto@macro{\graph@keys}{natwidth=#1,}}
+\define@key{mgl@keys}{natheight}{\g@addto@macro{\graph@keys}{natheight=#1,}}
+\define@key{mgl@keys}{hiresbb}{\g@addto@macro{\graph@keys}{hiresbb=#1,}}
+\define@key{mgl@keys}{viewport}{\g@addto@macro{\graph@keys}{viewport=#1,}}
+\define@key{mgl@keys}{trim}{\g@addto@macro{\graph@keys}{trim=#1,}}
+\define@key{mgl@keys}{angle}{\g@addto@macro{\graph@keys}{angle=#1,}}
+\define@key{mgl@keys}{origin}{\g@addto@macro{\graph@keys}{origin=#1,}}
+\define@key{mgl@keys}{width}{\g@addto@macro{\graph@keys}{width=#1,}}
+\define@key{mgl@keys}{height}{\g@addto@macro{\graph@keys}{height=#1,}}
+\define@key{mgl@keys}{totalheight}{\g@addto@macro{\graph@keys}{totalheight=#1,}}
+\define@key{mgl@keys}{keepaspectratio}{\g@addto@macro{\graph@keys}{keepaspectratio=#1,}}
+\define@key{mgl@keys}{scale}{\g@addto@macro{\graph@keys}{scale=#1,}}
+\define@key{mgl@keys}{clip}[true]{\g@addto@macro{\graph@keys}{clip=#1,}}
+\define@key{mgl@keys}{draft}[false]{\g@addto@macro{\graph@keys}{draft=#1,}}
+\define@key{mgl@keys}{type}{\g@addto@macro{\graph@keys}{type=#1,}}
+\define@key{mgl@keys}{ext}{\g@addto@macro{\graph@keys}{ext=#1,}}
+\define@key{mgl@keys}{read}{\g@addto@macro{\graph@keys}{read=#1,}}
+\define@key{mgl@keys}{command}{\g@addto@macro{\graph@keys}{command=#1,}}
+\define@key{mgl@keys}{imgext}{\def\mgl@image@ext{.#1}}
+
+\define@key{mglplot@keys}{bb}{\g@addto@macro{\graph@keys}{bb=#1,}}
+\define@key{mglplot@keys}{bbllx}{\g@addto@macro{\graph@keys}{bbllx=#1,}}
+\define@key{mglplot@keys}{bblly}{\g@addto@macro{\graph@keys}{bblly=#1,}}
+\define@key{mglplot@keys}{bburx}{\g@addto@macro{\graph@keys}{bburx=#1,}}
+\define@key{mglplot@keys}{bbury}{\g@addto@macro{\graph@keys}{bbury=#1,}}
+\define@key{mglplot@keys}{natwidth}{\g@addto@macro{\graph@keys}{natwidth=#1,}}
+\define@key{mglplot@keys}{natheight}{\g@addto@macro{\graph@keys}{natheight=#1,}}
+\define@key{mglplot@keys}{hiresbb}{\g@addto@macro{\graph@keys}{hiresbb=#1,}}
+\define@key{mglplot@keys}{viewport}{\g@addto@macro{\graph@keys}{viewport=#1,}}
+\define@key{mglplot@keys}{trim}{\g@addto@macro{\graph@keys}{trim=#1,}}
+\define@key{mglplot@keys}{angle}{\g@addto@macro{\graph@keys}{angle=#1,}}
+\define@key{mglplot@keys}{origin}{\g@addto@macro{\graph@keys}{origin=#1,}}
+\define@key{mglplot@keys}{width}{\g@addto@macro{\graph@keys}{width=#1,}}
+\define@key{mglplot@keys}{height}{\g@addto@macro{\graph@keys}{height=#1,}}
+\define@key{mglplot@keys}{totalheight}{\g@addto@macro{\graph@keys}{totalheight=#1,}}
+\define@key{mglplot@keys}{keepaspectratio}{\g@addto@macro{\graph@keys}{keepaspectratio=#1,}}
+\define@key{mglplot@keys}{scale}{\g@addto@macro{\graph@keys}{scale=#1,}}
+\define@key{mglplot@keys}{clip}[true]{\g@addto@macro{\graph@keys}{clip=#1,}}
+\define@key{mglplot@keys}{draft}[false]{\g@addto@macro{\graph@keys}{draft=#1,}}
+\define@key{mglplot@keys}{type}{\g@addto@macro{\graph@keys}{type=#1,}}
+\define@key{mglplot@keys}{ext}{\g@addto@macro{\graph@keys}{ext=#1,}}
+\define@key{mglplot@keys}{read}{\g@addto@macro{\graph@keys}{read=#1,}}
+\define@key{mglplot@keys}{command}{\g@addto@macro{\graph@keys}{command=#1,}}
+\define@key{mglplot@keys}{outext}{\def\mglplot@output@ext{.#1}}
+\define@key{mglplot@keys}{settings}{\def\mglplot@settings{#1}}
+
+\def\mgl@dir{}
+\def\mgldir#1{%
+ \def\mgl@dir{#1}%
+}
+\@onlypreamble\mgldir
+
+\newwrite\mgl@script
+\AtBeginDocument{%
+ \immediate\openout\mgl@script="\mgl@dir\jobname.mgl"%
+}
+\AtEndDocument{%
+ \immediate\write\mgl@script{}%
+ \immediate\write\mgl@script{stop}%
+ \mgl@func%
+ \immediate\closeout\mgl@script%
+ \immediate\write18{mglconv -n "\mgl@dir\jobname.mgl"}%
+}
+
+\def\mglplotsettings@defined{}
+\newcommand\mglplotsettings[1][generic]{%
+ \test@mglplotsettings@defined{#1}%
+ \expandafter\def\csname mgl@setup@#1\endcsname{\immediate\write\mgl@script{}}%
+ \g@addto@macro{\mglplotsettings@defined}{#1,}%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \catcode`\ =10%
+ \expandafter\mglplotsettings@write@line%
+}
+\def\test@mglplotsettings@defined#1{%
+ \def\this@setup{#1}%
+ \@for\mglplotsettings@name:=\mglplotsettings@defined\do{%
+ \ifx\this@mglplotsettings\mglplotsettings@name%
+ \PackageWarning{\mgl@name}{Redefining "#1" setup for \noexpand\mglplot}%
+ \fi%
+ }%
+}
+\begingroup%
+ \catcode`\^^M\active%
+ \gdef\mglplotsettings@write@line#1^^M{%
+ \def\next@action{%
+ \expandafter\g@addto@macro\csname mgl@setup@\this@setup\endcsname{\immediate\write\mgl@script{#1}}%
+ \mglplotsettings@write@line%
+ }%
+ \test@end@mglplotsettings{#1}%
+ \next@action%
+ }%
+\endgroup
+\begingroup%
+ \escapechar=-1 \relax%
+ \xdef\end@mglplotsettings{\string\\end\string\{mglplotsettings\string\}}%
+\endgroup
+\def\test@end@mglplotsettings#1{%
+ \edef\this@line{#1}%
+ \ifx\this@line\end@mglplotsettings%
+ \def\next@action{\end{mglplotsettings}}%
+ \fi%
+}
+\def\endmglplotsettings{}
+
+\def\TeX@ext{.tex}
+\newcounter{mgl@image@no}
+
+\def\mglplot{%
+ \@ifnextchar[{\@mglplot}{\@mglplot[]}%
+}
+\def\@mglplot[#1]{%
+ \def\mglplot@settings{generic}%
+ \def\graph@keys{}%
+ \setkeys{mglplot@keys}{#1}%
+ \stepcounter{mgl@image@no}%
+ \ifx\csname mgl@setup@\mglplot@settings\endcsname\@undefined%
+ \PackageError{\mgl@name}{Setup "\mglplot@settings" undefined}{}%
+ \else%
+ \csname mgl@setup@\mglplot@settings\endcsname%
+ \fi%
+ \@@mglplot%
+}
+\long\def\@@mglplot#1{%
+ \immediate\write\mgl@script{\detokenize{#1}}%
+ \immediate\write\mgl@script{write '\mgl@dir\jobname-mgl-\arabic{mgl@image@no}\mgl@image@ext'}%
+ \immediate\write\mgl@script{reset}%
+ \mgl@include@image{\mgl@dir\jobname-mgl-\arabic{mgl@image@no}}%
+}
+
+\newcommand\mgl[1][]{%
+ \def\graph@keys{}%
+ \setkeys{mgl@keys}{#1}%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \catcode`\ =10%
+ \mgl@write@line%
+}
+\begingroup%
+ \escapechar=-1 \relax%
+ \xdef\end@mgl{\string\\end\string\{mgl\string\}}%
+\endgroup
+\begingroup%
+ \catcode`\^^M\active%
+ \gdef\mgl@write@line#1^^M{%
+ \def\next@action{%
+ \immediate\write\mgl@script{#1}%
+ \mgl@write@line%
+ }%
+ \test@end@mgl{#1}%
+ \next@action%
+ }%
+\endgroup
+\def\test@end@mgl#1{%
+ \edef\this@line{#1}%
+ \ifx\this@line\end@mgl%
+ \def\next@action{\end{mgl}}%
+ \fi%
+}
+\def\endmgl{%
+ \stepcounter{mgl@image@no}%
+ \immediate\write\mgl@script{write '\mgl@dir\jobname-mgl-\arabic{mgl@image@no}\mgl@image@ext'}%
+ \immediate\write\mgl@script{reset}%
+ \mgl@include@image{\mgl@dir\jobname-mgl-\arabic{mgl@image@no}}%
+}
+\def\mgl@include@image#1{%
+ \ifx\mgl@image@ext\TeX@ext%
+ \IfFileExists{#1.tex}{%
+ \include{#1}%
+ }{%
+ \mgl@img@not@found{#1}%
+ }%
+ \else%
+ \def\next@action{\mgl@img@not@found{#1}}%
+ \@for\img@ext:=\Gin@extensions\do{%
+ \IfFileExists{#1\img@ext}{%
+ \def\next@action{%
+ \expandafter\includegraphics\expandafter[\graph@keys]{#1}%
+ }%
+ }{}%
+ }%
+ \next@action%
+ \fi%
+}
+\def\mgl@img@not@found#1{%
+ \PackageWarning{\mgl@name}{MGL image "#1" not found}%
+ \framebox[10em]{%
+ \centering%
+ \bfseries\Huge%
+ \vbox{MGL\\image\\not\\found}%
+ }%
+}
+
+\bgroup%
+ \escapechar=-1\relax%
+ \xdef\end@mgladdon{\string\\end\string\{mgladdon\string\}}%
+\egroup%
+\newenvironment{mgladdon}{%
+ \def\test@end@mgl##1{%
+ \edef\this@line{##1}%
+ \ifx\this@line\end@mgladdon%
+ \def\next@action{\end{mgladdon}}%
+ \fi%
+ }%
+ \mgl[]%
+}{}
+
+\def\mgl@script@written{}
+\newwrite\mgl@out@stream
+\newcommand\mglcode[2][]{%
+ \def\graph@keys{}%
+ \setkeys{mgl@keys}{#1}%
+ \test@mgl@script@written{#2}%
+ \xdef\mgl@script@written{\mgl@script@written#2,}%
+ \def\this@script{#2}%
+ \immediate\openout\mgl@out@stream=\mgl@dir\this@script.mgl%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \obeyspaces%
+ \mglcode@write@line%
+}
+\def\test@mgl@script@written#1{%
+ \edef\this@script{#1}%
+ \@for\mgl@script@name:=\mgl@script@written\do{%
+ \ifx\this@script\mgl@script@name%
+ \PackageWarning{\mgl@name}{Overwriting MGL script "\this@script.mgl"}%
+ \fi%
+ }%
+}
+\def\mglcode@write@line#1{%
+ \let\next@action\mglcode@write@line%
+ \expandafter\if#1\^^M%
+ \immediate\write\mgl@out@stream{\the\mgl@line}%
+ \mgl@line{}%
+ \mgl@word{}%
+ \else\expandafter\if#1\space%
+ \mgl@word{}%
+ \mgl@line\expandafter{\the\mgl@line#1}%
+ \else%
+ \mgl@word\expandafter{\the\mgl@word#1}%
+ \mgl@line\expandafter{\the\mgl@line#1}%
+ \test@end@mglcode{\the\mgl@word}%
+ \fi\fi%
+ \next@action%
+}
+\begingroup%
+ \escapechar=-1\relax%
+ \xdef\end@mglcode{\string\\end\string\{mglcode\string\}}%
+\endgroup%
+\def\test@end@mglcode#1{%
+ \edef\this@word{#1}%
+ \ifx\this@word\end@mglcode%
+ \def\next@action{\end{mglcode}}%
+ \fi%
+}
+\def\endmglcode{%
+ \immediate\closeout\mgl@out@stream%
+ \immediate\write18{mglconv "\mgl@dir\this@script.mgl" -o "\mgl@dir\this@script\mgl@image@ext"}%
+ \mgl@include@image{\mgl@dir\this@script}%
+}
+
+\bgroup%
+ \escapechar=-1\relax%
+ \xdef\end@mglscript{\string\\end\string\{mglscript\string\}}%
+\egroup%
+\newenvironment{mglscript}[1]{%
+ \def\test@end@mglcode##1{%
+ \edef\this@word{##1}%
+ \ifx\this@word\end@mglscript%
+ \def\next@action{\end{mglscript}}%
+ \fi%
+ }%
+ \mglcode{#1}%
+}{%
+ \immediate\closeout\mgl@out@stream%
+}
+
+\def\mglfunc@defined{}
+\def\mgl@func{}
+\newcommand\mglfunc[2][0]{%
+ \test@mglfunc@defined{#2}%
+ \g@addto@macro{\mglfunc@defined}{#2,}%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \catcode`\ =10%
+ \g@addto@macro{\mgl@func}{\immediate\write\mgl@script{}}%
+ \g@addto@macro{\mgl@func}{\immediate\write\mgl@script{func '#2' #1}}%
+ \expandafter\mglfunc@ignore@line%
+}
+\def\test@mglfunc@defined#1{%
+ \def\this@func{#1}%
+ \@for\mglfunc@name:=\mglfunc@defined\do{%
+ \ifx\this@func\mglfunc@name%
+ \PackageWarning{\mgl@name}{MGL function "#1" has multiple definitions}%
+ \fi%
+ }%
+}
+\begingroup%
+ \catcode`\^^M\active%
+ \gdef\mglfunc@ignore@line#1^^M{%
+ \expandafter\mglfunc@write@line%
+ }
+ \gdef\mglfunc@write@line#1^^M{%
+ \def\next@action{%
+ \g@addto@macro{\mgl@func}{\immediate\write\mgl@script{#1}}%
+ \mglfunc@write@line%
+ }%
+ \test@end@mglfunc{#1}%
+ \next@action%
+ }%
+\endgroup
+\begingroup%
+ \escapechar=-1 \relax%
+ \xdef\end@mglfunc{\string\\end\string\{mglfunc\string\}}%
+\endgroup
+\def\test@end@mglfunc#1{%
+ \edef\this@line{#1}%
+ \ifx\this@line\end@mglfunc%
+ \def\next@action{\end{mglfunc}}%
+ \fi%
+}
+\def\endmglfunc{%
+ \g@addto@macro{\mgl@func}{\immediate\write\mgl@script{return}}%
+}
+
+\def\mglblock#1{%
+ \test@mgl@script@written{#1}%
+ \xdef\mgl@script@written{\mgl@script@written#1,}%
+ \def\this@script{#1}%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \obeyspaces%
+ \immediate\openout\mgl@out@stream="\mgl@dir\this@script.mgl"%
+ \mglblock@ignore@line%
+}
+\def\mglblock@ignore@line#1{%
+ \mglblock@write@line%
+}
+\def\mglblock@write@line#1{%
+ \let\next@action\mglblock@write@line%
+ \expandafter\if#1\^^M%
+ \immediate\write\mgl@out@stream{\the\mgl@line}%
+ \mgl@line{}%
+ \mgl@word{}%
+ \else\expandafter\if#1\space%
+ \mgl@word{}%
+ \mgl@line\expandafter{\the\mgl@line#1}%
+ \else%
+ \mgl@word\expandafter{\the\mgl@word#1}%
+ \mgl@line\expandafter{\the\mgl@line#1}%
+ \test@end@mglblock{\the\mgl@word}%
+ \fi\fi%
+ \next@action%
+}
+\begingroup%
+ \escapechar=-1\relax%
+ \xdef\end@mglblock{\string\\end\string\{mglblock\string\}}%
+\endgroup%
+\def\test@end@mglblock#1{%
+ \edef\this@word{#1}%
+ \ifx\this@word\end@mglblock%
+ \def\next@action{\end{mglblock}}%
+ \fi%
+}
+\newread\mgl@in@stream
+\def\endmglblock{%
+ \immediate\closeout\mgl@out@stream%
+ \immediate\openin\mgl@in@stream="\mgl@dir\this@script.mgl"%
+ \begingroup%
+ \list{\itshape\footnotesize\arabic{mgl@verb@line@no}.}{}%
+ \setlength{\labelsep}{1em}%
+ \itemsep\z@skip%
+ \leftskip\z@skip\rightskip\z@skip%
+ \verbatim@font%
+ \parindent\z@\parfillskip\@flushglue\parskip\z@skip%
+ \@vobeyspaces%
+ \mglblock@read@line%
+}
+\def\mglblock@read@line{%
+ \stepcounter{mgl@verb@line@no}%
+ \read\mgl@in@stream to \this@line%
+ \ifeof\mgl@in@stream%
+ \def\next@action{%
+ \immediate\closein\mgl@in@stream%
+ \endlist%
+ \endgroup%
+ }%
+ \else%
+ \def\next@action{%
+ \item\mbox{\this@line}%
+ \mglblock@read@line%
+ }%
+ \fi%
+ \next@action%
+}
+
+\newcounter{mgl@verb@line@no}
+\def\mglverbatim{%
+ \setcounter{mgl@verb@line@no}{0}%
+ \list{\itshape\footnotesize\arabic{mgl@verb@line@no}.}{}%
+ \setlength{\labelsep}{1em}%
+ \itemsep\z@skip%
+ \leftskip\z@skip\rightskip\z@skip%
+ \verbatim@font%
+ \parindent\z@\parfillskip\@flushglue\parskip\z@skip%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \obeyspaces%
+ \mglverbatim@ignore@line%
+}
+\def\mglverbatim@ignore@line#1{%
+ \mglverbatim@write@line%
+}
+\newtoks\mgl@word
+\newtoks\mgl@line
+\def\mglverbatim@write@line#1{%
+ \let\next@action\mglverbatim@write@line%
+ \expandafter\if#1\^^M%
+ \stepcounter{mgl@verb@line@no}%
+ \item\mbox{\the\mgl@line}%
+ \mgl@line{}%
+ \mgl@word{}%
+ \else\expandafter\if#1\space%
+ \mgl@word{}%
+ \mgl@line\expandafter{\the\mgl@line#1}%
+ \else%
+ \mgl@word\expandafter{\the\mgl@word#1}%
+ \mgl@line\expandafter{\the\mgl@line#1}%
+ \test@end@mglverbatim{\the\mgl@word}%
+ \fi\fi%
+ \next@action%
+}
+\begingroup%
+ \escapechar=-1\relax%
+ \xdef\end@mglverbatim{\string\\end\string\{mglverbatim\string\}}%
+\endgroup%
+\def\test@end@mglverbatim#1{%
+ \edef\this@word{#1}%
+ \ifx\this@word\end@mglverbatim%
+ \def\next@action{\end{mglverbatim}}%
+ \fi%
+}
+\def\endmglverbatim{\endlist}
+
+\newcommand\mglgraphics[2][]{%
+ \def\graph@keys{}%
+ \setkeys{mgl@keys}{#1}%
+ \immediate\write18{mglconv "\mgl@dir#2.mgl" -o "\mgl@dir#2\mgl@image@ext"}
+ \mgl@include@image{\mgl@dir#2}%
+}
+
+\def\mglinclude#1{%
+ \setcounter{mgl@verb@line@no}{0}%
+ \immediate\openin\mgl@in@stream="\mgl@dir#1.mgl"%
+ \begingroup%
+ \list{\itshape\footnotesize\arabic{mgl@verb@line@no}.}{}%
+ \setlength{\labelsep}{1em}%
+ \itemsep\z@skip%
+ \leftskip\z@skip\rightskip\z@skip%
+ \verbatim@font%
+ \parindent\z@\parfillskip\@flushglue\parskip\z@skip%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \@vobeyspaces%
+ \mglblock@read@line%
+}
+
+\def\mglTeX{mgl\TeX}
+% \end{macrocode}
+% \Finale
\ No newline at end of file
--- /dev/null
+%%
+%% Copyright (C) 2014 by Diego Sejas <diego.mathematician@gmail.com>
+%%
+%% This program is free software: you can redistribute it and/or modify it
+%% under the terms of the GNU General Public License as published by the
+%% Free Software Foundation, either version 3 of the License, or (at your
+%% option) any later version.
+%%
+%% This program is distributed in the hope that it will be useful, but
+%% WITHOUT ANY WARRANTY; without even the implied warranty of
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+%% Public License for more details.
+%%
+%% You should have received a copy of the GNU General Public License along
+%% with this program. If not, see <http://www.gnu.org/licenses/>.
+%%
+
+\input docstrip.tex
+\keepsilent
+
+\usedir{tex/latex/mgltex}
+
+\preamble
+
+This is a generated file.
+
+Copyright (C) 2014 by Diego Sejas <diego.mathematician@gmail.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program. If not, see <http://www.gnu.org/licenses/>.
+
+\endpreamble
+
+\generate{\file{mgltex.sty}{\from{mgltex.dtx}{package}}}
+
+\obeyspaces
+\Msg{**********************************************************}
+\Msg{* *}
+\Msg{* To finish the installation you have to move the *}
+\Msg{* following file into a directory searched by TeX: *}
+\Msg{* *}
+\Msg{* mgltex.sty *}
+\Msg{* *}
+\Msg{* To produce the documentation run the file mgltex.dtx *}
+\Msg{* through LaTeX. *}
+\Msg{* *}
+\Msg{* Happy TeXing! *}
+\Msg{* *}
+\Msg{**********************************************************}
+
+\endbatchfile
\ No newline at end of file
--- /dev/null
+%%
+%% This is file `mgltex.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% mgltex.dtx (with options: `package')
+%%
+%% This is a generated file.
+%%
+%% Copyright (C) 2014 by Diego Sejas <diego.mathematician@gmail.com>
+%%
+%% This program is free software: you can redistribute it and/or modify it
+%% under the terms of the GNU General Public License as published by the
+%% Free Software Foundation, either version 3 of the License, or (at your
+%% option) any later version.
+%%
+%% This program is distributed in the hope that it will be useful, but
+%% WITHOUT ANY WARRANTY; without even the implied warranty of
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+%% Public License for more details.
+%%
+%% You should have received a copy of the GNU General Public License along
+%% with this program. If not, see <http://www.gnu.org/licenses/>.
+%%
+\def\mgl@name{mgltex}
+\def\mgl@date{2014/09/16}
+\def\mgl@version{1.0}
+\def\mgl@description{Embed MGL code into LaTeX documents}
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{\mgl@name}[\mgl@date\space v.\mgl@version\space\mgl@description]
+
+\RequirePackage{keyval}
+\RequirePackage{graphicx}
+
+\DeclareOption{draft}{%
+ \PassOptionsToPackage{\CurrentOption}{graphicx}%
+}
+\DeclareOption{final}{%
+ \PassOptionsToPackage{\CurrentOption}{graphicx}%
+}
+
+\DeclareGraphicsExtensions{.png,.eps,.jpg,.jpeg,.bps,.pdf,.epsz,.eps.gz,.bpsz,.bps.gz,.gif}
+
+\DeclareOption{jpg}{\def\mgl@image@ext{.jpg}}
+\DeclareOption{jpeg}{\def\mgl@image@ext{.jpeg}}
+\DeclareOption{pdf}{\def\mgl@image@ext{.pdf}}
+\DeclareOption{png}{\def\mgl@image@ext{.png}}
+\DeclareOption{eps}{\def\mgl@image@ext{.eps}}
+\DeclareOption{epsz}{\def\mgl@image@ext{.eps.gz}}
+\DeclareOption{bps}{\def\mgl@image@ext{.bps}}
+\DeclareOption{bpsz}{\def\mgl@image@ext{.bps.gz}}
+\DeclareOption{gif}{\def\mgl@image@ext{.gif}}
+
+\DeclareOption{tex}{\def\mgl@image@ext{.tex}}
+
+\ExecuteOptions{final,eps}
+\ProcessOptions*
+
+\define@key{mgl@keys}{bb}{\g@addto@macro{\graph@keys}{bb=#1,}}
+\define@key{mgl@keys}{bbllx}{\g@addto@macro{\graph@keys}{bbllx=#1,}}
+\define@key{mgl@keys}{bblly}{\g@addto@macro{\graph@keys}{bblly=#1,}}
+\define@key{mgl@keys}{bburx}{\g@addto@macro{\graph@keys}{bburx=#1,}}
+\define@key{mgl@keys}{bbury}{\g@addto@macro{\graph@keys}{bbury=#1,}}
+\define@key{mgl@keys}{natwidth}{\g@addto@macro{\graph@keys}{natwidth=#1,}}
+\define@key{mgl@keys}{natheight}{\g@addto@macro{\graph@keys}{natheight=#1,}}
+\define@key{mgl@keys}{hiresbb}{\g@addto@macro{\graph@keys}{hiresbb=#1,}}
+\define@key{mgl@keys}{viewport}{\g@addto@macro{\graph@keys}{viewport=#1,}}
+\define@key{mgl@keys}{trim}{\g@addto@macro{\graph@keys}{trim=#1,}}
+\define@key{mgl@keys}{angle}{\g@addto@macro{\graph@keys}{angle=#1,}}
+\define@key{mgl@keys}{origin}{\g@addto@macro{\graph@keys}{origin=#1,}}
+\define@key{mgl@keys}{width}{\g@addto@macro{\graph@keys}{width=#1,}}
+\define@key{mgl@keys}{height}{\g@addto@macro{\graph@keys}{height=#1,}}
+\define@key{mgl@keys}{totalheight}{\g@addto@macro{\graph@keys}{totalheight=#1,}}
+\define@key{mgl@keys}{keepaspectratio}{\g@addto@macro{\graph@keys}{keepaspectratio=#1,}}
+\define@key{mgl@keys}{scale}{\g@addto@macro{\graph@keys}{scale=#1,}}
+\define@key{mgl@keys}{clip}[true]{\g@addto@macro{\graph@keys}{clip=#1,}}
+\define@key{mgl@keys}{draft}[false]{\g@addto@macro{\graph@keys}{draft=#1,}}
+\define@key{mgl@keys}{type}{\g@addto@macro{\graph@keys}{type=#1,}}
+\define@key{mgl@keys}{ext}{\g@addto@macro{\graph@keys}{ext=#1,}}
+\define@key{mgl@keys}{read}{\g@addto@macro{\graph@keys}{read=#1,}}
+\define@key{mgl@keys}{command}{\g@addto@macro{\graph@keys}{command=#1,}}
+\define@key{mgl@keys}{imgext}{\def\mgl@image@ext{.#1}}
+
+\define@key{mglplot@keys}{bb}{\g@addto@macro{\graph@keys}{bb=#1,}}
+\define@key{mglplot@keys}{bbllx}{\g@addto@macro{\graph@keys}{bbllx=#1,}}
+\define@key{mglplot@keys}{bblly}{\g@addto@macro{\graph@keys}{bblly=#1,}}
+\define@key{mglplot@keys}{bburx}{\g@addto@macro{\graph@keys}{bburx=#1,}}
+\define@key{mglplot@keys}{bbury}{\g@addto@macro{\graph@keys}{bbury=#1,}}
+\define@key{mglplot@keys}{natwidth}{\g@addto@macro{\graph@keys}{natwidth=#1,}}
+\define@key{mglplot@keys}{natheight}{\g@addto@macro{\graph@keys}{natheight=#1,}}
+\define@key{mglplot@keys}{hiresbb}{\g@addto@macro{\graph@keys}{hiresbb=#1,}}
+\define@key{mglplot@keys}{viewport}{\g@addto@macro{\graph@keys}{viewport=#1,}}
+\define@key{mglplot@keys}{trim}{\g@addto@macro{\graph@keys}{trim=#1,}}
+\define@key{mglplot@keys}{angle}{\g@addto@macro{\graph@keys}{angle=#1,}}
+\define@key{mglplot@keys}{origin}{\g@addto@macro{\graph@keys}{origin=#1,}}
+\define@key{mglplot@keys}{width}{\g@addto@macro{\graph@keys}{width=#1,}}
+\define@key{mglplot@keys}{height}{\g@addto@macro{\graph@keys}{height=#1,}}
+\define@key{mglplot@keys}{totalheight}{\g@addto@macro{\graph@keys}{totalheight=#1,}}
+\define@key{mglplot@keys}{keepaspectratio}{\g@addto@macro{\graph@keys}{keepaspectratio=#1,}}
+\define@key{mglplot@keys}{scale}{\g@addto@macro{\graph@keys}{scale=#1,}}
+\define@key{mglplot@keys}{clip}[true]{\g@addto@macro{\graph@keys}{clip=#1,}}
+\define@key{mglplot@keys}{draft}[false]{\g@addto@macro{\graph@keys}{draft=#1,}}
+\define@key{mglplot@keys}{type}{\g@addto@macro{\graph@keys}{type=#1,}}
+\define@key{mglplot@keys}{ext}{\g@addto@macro{\graph@keys}{ext=#1,}}
+\define@key{mglplot@keys}{read}{\g@addto@macro{\graph@keys}{read=#1,}}
+\define@key{mglplot@keys}{command}{\g@addto@macro{\graph@keys}{command=#1,}}
+\define@key{mglplot@keys}{outext}{\def\mglplot@output@ext{.#1}}
+\define@key{mglplot@keys}{settings}{\def\mglplot@settings{#1}}
+
+\def\mgl@dir{}
+\def\mgldir#1{%
+ \def\mgl@dir{#1}%
+}
+\@onlypreamble\mgldir
+
+\newwrite\mgl@script
+\AtBeginDocument{%
+ \immediate\openout\mgl@script="\mgl@dir\jobname.mgl"%
+}
+\AtEndDocument{%
+ \immediate\write\mgl@script{}%
+ \immediate\write\mgl@script{stop}%
+ \mgl@func%
+ \immediate\closeout\mgl@script%
+ \immediate\write18{mglconv -n "\mgl@dir\jobname.mgl"}%
+}
+
+\def\mglplotsettings@defined{}
+\newcommand\mglplotsettings[1][generic]{%
+ \test@mglplotsettings@defined{#1}%
+ \expandafter\def\csname mgl@setup@#1\endcsname{\immediate\write\mgl@script{}}%
+ \g@addto@macro{\mglplotsettings@defined}{#1,}%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \catcode`\ =10%
+ \expandafter\mglplotsettings@write@line%
+}
+\def\test@mglplotsettings@defined#1{%
+ \def\this@setup{#1}%
+ \@for\mglplotsettings@name:=\mglplotsettings@defined\do{%
+ \ifx\this@mglplotsettings\mglplotsettings@name%
+ \PackageWarning{\mgl@name}{Redefining "#1" setup for \noexpand\mglplot}%
+ \fi%
+ }%
+}
+\begingroup%
+ \catcode`\^^M\active%
+ \gdef\mglplotsettings@write@line#1^^M{%
+ \def\next@action{%
+ \expandafter\g@addto@macro\csname mgl@setup@\this@setup\endcsname{\immediate\write\mgl@script{#1}}%
+ \mglplotsettings@write@line%
+ }%
+ \test@end@mglplotsettings{#1}%
+ \next@action%
+ }%
+\endgroup
+\begingroup%
+ \escapechar=-1 \relax%
+ \xdef\end@mglplotsettings{\string\\end\string\{mglplotsettings\string\}}%
+\endgroup
+\def\test@end@mglplotsettings#1{%
+ \edef\this@line{#1}%
+ \ifx\this@line\end@mglplotsettings%
+ \def\next@action{\end{mglplotsettings}}%
+ \fi%
+}
+\def\endmglplotsettings{}
+
+\def\TeX@ext{.tex}
+\newcounter{mgl@image@no}
+
+\def\mglplot{%
+ \@ifnextchar[{\@mglplot}{\@mglplot[]}%
+}
+\def\@mglplot[#1]{%
+ \def\mglplot@settings{generic}%
+ \def\graph@keys{}%
+ \setkeys{mglplot@keys}{#1}%
+ \stepcounter{mgl@image@no}%
+ \ifx\csname mgl@setup@\mglplot@settings\endcsname\@undefined%
+ \PackageError{\mgl@name}{Setup "\mglplot@settings" undefined}{}%
+ \else%
+ \csname mgl@setup@\mglplot@settings\endcsname%
+ \fi%
+ \@@mglplot%
+}
+\long\def\@@mglplot#1{%
+ \immediate\write\mgl@script{\detokenize{#1}}%
+ \immediate\write\mgl@script{write '\mgl@dir\jobname-mgl-\arabic{mgl@image@no}\mgl@image@ext'}%
+ \immediate\write\mgl@script{reset}%
+ \mgl@include@image{\mgl@dir\jobname-mgl-\arabic{mgl@image@no}}%
+}
+
+\newcommand\mgl[1][]{%
+ \def\graph@keys{}%
+ \setkeys{mgl@keys}{#1}%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \catcode`\ =10%
+ \mgl@write@line%
+}
+\begingroup%
+ \escapechar=-1 \relax%
+ \xdef\end@mgl{\string\\end\string\{mgl\string\}}%
+\endgroup
+\begingroup%
+ \catcode`\^^M\active%
+ \gdef\mgl@write@line#1^^M{%
+ \def\next@action{%
+ \immediate\write\mgl@script{#1}%
+ \mgl@write@line%
+ }%
+ \test@end@mgl{#1}%
+ \next@action%
+ }%
+\endgroup
+\def\test@end@mgl#1{%
+ \edef\this@line{#1}%
+ \ifx\this@line\end@mgl%
+ \def\next@action{\end{mgl}}%
+ \fi%
+}
+\def\endmgl{%
+ \stepcounter{mgl@image@no}%
+ \immediate\write\mgl@script{write '\mgl@dir\jobname-mgl-\arabic{mgl@image@no}\mgl@image@ext'}%
+ \immediate\write\mgl@script{reset}%
+ \mgl@include@image{\mgl@dir\jobname-mgl-\arabic{mgl@image@no}}%
+}
+\def\mgl@include@image#1{%
+ \ifx\mgl@image@ext\TeX@ext%
+ \IfFileExists{#1.tex}{%
+ \include{#1}%
+ }{%
+ \mgl@img@not@found{#1}%
+ }%
+ \else%
+ \def\next@action{\mgl@img@not@found{#1}}%
+ \@for\img@ext:=\Gin@extensions\do{%
+ \IfFileExists{#1\img@ext}{%
+ \def\next@action{%
+ \expandafter\includegraphics\expandafter[\graph@keys]{#1}%
+ }%
+ }{}%
+ }%
+ \next@action%
+ \fi%
+}
+\def\mgl@img@not@found#1{%
+ \PackageWarning{\mgl@name}{MGL image "#1" not found}%
+ \framebox[10em]{%
+ \centering%
+ \bfseries\Huge%
+ \vbox{MGL\\image\\not\\found}%
+ }%
+}
+
+\bgroup%
+ \escapechar=-1\relax%
+ \xdef\end@mgladdon{\string\\end\string\{mgladdon\string\}}%
+\egroup%
+\newenvironment{mgladdon}{%
+ \def\test@end@mgl##1{%
+ \edef\this@line{##1}%
+ \ifx\this@line\end@mgladdon%
+ \def\next@action{\end{mgladdon}}%
+ \fi%
+ }%
+ \mgl[]%
+}{}
+
+\def\mgl@script@written{}
+\newwrite\mgl@out@stream
+\newcommand\mglcode[2][]{%
+ \def\graph@keys{}%
+ \setkeys{mgl@keys}{#1}%
+ \test@mgl@script@written{#2}%
+ \xdef\mgl@script@written{\mgl@script@written#2,}%
+ \def\this@script{#2}%
+ \immediate\openout\mgl@out@stream=\mgl@dir\this@script.mgl%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \obeyspaces%
+ \mglcode@write@line%
+}
+\def\test@mgl@script@written#1{%
+ \edef\this@script{#1}%
+ \@for\mgl@script@name:=\mgl@script@written\do{%
+ \ifx\this@script\mgl@script@name%
+ \PackageWarning{\mgl@name}{Overwriting MGL script "\this@script.mgl"}%
+ \fi%
+ }%
+}
+\def\mglcode@write@line#1{%
+ \let\next@action\mglcode@write@line%
+ \expandafter\if#1\^^M%
+ \immediate\write\mgl@out@stream{\the\mgl@line}%
+ \mgl@line{}%
+ \mgl@word{}%
+ \else\expandafter\if#1\space%
+ \mgl@word{}%
+ \mgl@line\expandafter{\the\mgl@line#1}%
+ \else%
+ \mgl@word\expandafter{\the\mgl@word#1}%
+ \mgl@line\expandafter{\the\mgl@line#1}%
+ \test@end@mglcode{\the\mgl@word}%
+ \fi\fi%
+ \next@action%
+}
+\begingroup%
+ \escapechar=-1\relax%
+ \xdef\end@mglcode{\string\\end\string\{mglcode\string\}}%
+\endgroup%
+\def\test@end@mglcode#1{%
+ \edef\this@word{#1}%
+ \ifx\this@word\end@mglcode%
+ \def\next@action{\end{mglcode}}%
+ \fi%
+}
+\def\endmglcode{%
+ \immediate\closeout\mgl@out@stream%
+ \immediate\write18{mglconv "\mgl@dir\this@script.mgl" -o "\mgl@dir\this@script\mgl@image@ext"}%
+ \mgl@include@image{\mgl@dir\this@script}%
+}
+
+\bgroup%
+ \escapechar=-1\relax%
+ \xdef\end@mglscript{\string\\end\string\{mglscript\string\}}%
+\egroup%
+\newenvironment{mglscript}[1]{%
+ \def\test@end@mglcode##1{%
+ \edef\this@word{##1}%
+ \ifx\this@word\end@mglscript%
+ \def\next@action{\end{mglscript}}%
+ \fi%
+ }%
+ \mglcode{#1}%
+}{%
+ \immediate\closeout\mgl@out@stream%
+}
+
+\def\mglfunc@defined{}
+\def\mgl@func{}
+\newcommand\mglfunc[2][0]{%
+ \test@mglfunc@defined{#2}%
+ \g@addto@macro{\mglfunc@defined}{#2,}%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \catcode`\ =10%
+ \g@addto@macro{\mgl@func}{\immediate\write\mgl@script{}}%
+ \g@addto@macro{\mgl@func}{\immediate\write\mgl@script{func '#2' #1}}%
+ \expandafter\mglfunc@ignore@line%
+}
+\def\test@mglfunc@defined#1{%
+ \def\this@func{#1}%
+ \@for\mglfunc@name:=\mglfunc@defined\do{%
+ \ifx\this@func\mglfunc@name%
+ \PackageWarning{\mgl@name}{MGL function "#1" has multiple definitions}%
+ \fi%
+ }%
+}
+\begingroup%
+ \catcode`\^^M\active%
+ \gdef\mglfunc@ignore@line#1^^M{%
+ \expandafter\mglfunc@write@line%
+ }
+ \gdef\mglfunc@write@line#1^^M{%
+ \def\next@action{%
+ \g@addto@macro{\mgl@func}{\immediate\write\mgl@script{#1}}%
+ \mglfunc@write@line%
+ }%
+ \test@end@mglfunc{#1}%
+ \next@action%
+ }%
+\endgroup
+\begingroup%
+ \escapechar=-1 \relax%
+ \xdef\end@mglfunc{\string\\end\string\{mglfunc\string\}}%
+\endgroup
+\def\test@end@mglfunc#1{%
+ \edef\this@line{#1}%
+ \ifx\this@line\end@mglfunc%
+ \def\next@action{\end{mglfunc}}%
+ \fi%
+}
+\def\endmglfunc{%
+ \g@addto@macro{\mgl@func}{\immediate\write\mgl@script{return}}%
+}
+
+\def\mglblock#1{%
+ \test@mgl@script@written{#1}%
+ \xdef\mgl@script@written{\mgl@script@written#1,}%
+ \def\this@script{#1}%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \obeyspaces%
+ \immediate\openout\mgl@out@stream="\mgl@dir\this@script.mgl"%
+ \mglblock@ignore@line%
+}
+\def\mglblock@ignore@line#1{%
+ \mglblock@write@line%
+}
+\def\mglblock@write@line#1{%
+ \let\next@action\mglblock@write@line%
+ \expandafter\if#1\^^M%
+ \immediate\write\mgl@out@stream{\the\mgl@line}%
+ \mgl@line{}%
+ \mgl@word{}%
+ \else\expandafter\if#1\space%
+ \mgl@word{}%
+ \mgl@line\expandafter{\the\mgl@line#1}%
+ \else%
+ \mgl@word\expandafter{\the\mgl@word#1}%
+ \mgl@line\expandafter{\the\mgl@line#1}%
+ \test@end@mglblock{\the\mgl@word}%
+ \fi\fi%
+ \next@action%
+}
+\begingroup%
+ \escapechar=-1\relax%
+ \xdef\end@mglblock{\string\\end\string\{mglblock\string\}}%
+\endgroup%
+\def\test@end@mglblock#1{%
+ \edef\this@word{#1}%
+ \ifx\this@word\end@mglblock%
+ \def\next@action{\end{mglblock}}%
+ \fi%
+}
+\newread\mgl@in@stream
+\def\endmglblock{%
+ \immediate\closeout\mgl@out@stream%
+ \immediate\openin\mgl@in@stream="\mgl@dir\this@script.mgl"%
+ \begingroup%
+ \list{\itshape\footnotesize\arabic{mgl@verb@line@no}.}{}%
+ \setlength{\labelsep}{1em}%
+ \itemsep\z@skip%
+ \leftskip\z@skip\rightskip\z@skip%
+ \verbatim@font%
+ \parindent\z@\parfillskip\@flushglue\parskip\z@skip%
+ \@vobeyspaces%
+ \mglblock@read@line%
+}
+\def\mglblock@read@line{%
+ \stepcounter{mgl@verb@line@no}%
+ \read\mgl@in@stream to \this@line%
+ \ifeof\mgl@in@stream%
+ \def\next@action{%
+ \immediate\closein\mgl@in@stream%
+ \endlist%
+ \endgroup%
+ }%
+ \else%
+ \def\next@action{%
+ \item\mbox{\this@line}%
+ \mglblock@read@line%
+ }%
+ \fi%
+ \next@action%
+}
+
+\newcounter{mgl@verb@line@no}
+\def\mglverbatim{%
+ \setcounter{mgl@verb@line@no}{0}%
+ \list{\itshape\footnotesize\arabic{mgl@verb@line@no}.}{}%
+ \setlength{\labelsep}{1em}%
+ \itemsep\z@skip%
+ \leftskip\z@skip\rightskip\z@skip%
+ \verbatim@font%
+ \parindent\z@\parfillskip\@flushglue\parskip\z@skip%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \obeyspaces%
+ \mglverbatim@ignore@line%
+}
+\def\mglverbatim@ignore@line#1{%
+ \mglverbatim@write@line%
+}
+\newtoks\mgl@word
+\newtoks\mgl@line
+\def\mglverbatim@write@line#1{%
+ \let\next@action\mglverbatim@write@line%
+ \expandafter\if#1\^^M%
+ \stepcounter{mgl@verb@line@no}%
+ \item\mbox{\the\mgl@line}%
+ \mgl@line{}%
+ \mgl@word{}%
+ \else\expandafter\if#1\space%
+ \mgl@word{}%
+ \mgl@line\expandafter{\the\mgl@line#1}%
+ \else%
+ \mgl@word\expandafter{\the\mgl@word#1}%
+ \mgl@line\expandafter{\the\mgl@line#1}%
+ \test@end@mglverbatim{\the\mgl@word}%
+ \fi\fi%
+ \next@action%
+}
+\begingroup%
+ \escapechar=-1\relax%
+ \xdef\end@mglverbatim{\string\\end\string\{mglverbatim\string\}}%
+\endgroup%
+\def\test@end@mglverbatim#1{%
+ \edef\this@word{#1}%
+ \ifx\this@word\end@mglverbatim%
+ \def\next@action{\end{mglverbatim}}%
+ \fi%
+}
+\def\endmglverbatim{\endlist}
+
+\newcommand\mglgraphics[2][]{%
+ \def\graph@keys{}%
+ \setkeys{mgl@keys}{#1}%
+ \immediate\write18{mglconv "\mgl@dir#2.mgl" -o "\mgl@dir#2\mgl@image@ext"}
+ \mgl@include@image{\mgl@dir#2}%
+}
+
+\def\mglinclude#1{%
+ \setcounter{mgl@verb@line@no}{0}%
+ \immediate\openin\mgl@in@stream="\mgl@dir#1.mgl"%
+ \begingroup%
+ \list{\itshape\footnotesize\arabic{mgl@verb@line@no}.}{}%
+ \setlength{\labelsep}{1em}%
+ \itemsep\z@skip%
+ \leftskip\z@skip\rightskip\z@skip%
+ \verbatim@font%
+ \parindent\z@\parfillskip\@flushglue\parskip\z@skip%
+ \let\do\@makeother \dospecials%
+ \endlinechar`\^^M \catcode`\^^M\active%
+ \@vobeyspaces%
+ \mglblock@read@line%
+}
+
+\def\mglTeX{mgl\TeX}
+\endinput
+%%
+%% End of file `mgltex.sty'.
--- /dev/null
+\documentclass[12pt]{article}
+
+\usepackage[png]{mgltex}
+
+\title{\mglTeX{} package example}
+\author{Diego Sejas Viscarra, Alexey Balakin}
+\date{\today}
+\mgldir{scripts/}
+
+\begin{document}
+
+\maketitle
+
+
+LaTeX package \texttt{mgltex} (was made by Diego Sejas Viscarra) allow one to make figures directly from MGL script located in LaTeX file.
+
+For using this package you need to specify \texttt{--shell-escape} option for \emph{latex/pdflatex} or manually run \emph{mglconv} tool with produced MGL scripts for generation of images. Don't forgot to run \emph{latex/pdflatex} second time to insert generated images into the output document.
+
+The package may have following options: \texttt{draft}, \texttt{final} -- the same as in the \emph{graphicx} package; \texttt{jpg}, \texttt{jpeg}, \texttt{png} -- for export to JPEG/PNG images; \texttt{eps}, \texttt{epsz} -- for export to uncompressed/compressed EPS format as primitives; \texttt{bps}, \texttt{bpsz} -- for export to uncompressed/compressed EPS format as bitmap (don't work with \emph{pdflatex}), \texttt{pdf} -- for export to 3D PDF.
+
+The package defines the following environments:
+\begin{description}
+\item[mgl]
+ It writes its contents to a general script which has the same name as the LaTeX document, but its extension is \emph{.mgl}. The code in this environment is compiled and the image produced is included. It takes exactly the same optional arguments as the \texttt{\textbackslash{}includegraphics} command, plus an additional argument \emph{imgext}, which specifies the extension to save the image.
+\item[mgladdon]
+ It adds its contents to the general script, without producing any image. It useful to set some global properties (like size of the images) at beginning of the document.
+\item[mglcode]
+ Is exactly the same as \texttt{mgl}, but it writes its contents verbatim to its own file, whose name is specified as a mandatory argument.
+\item[mglscript]
+ Is exactly the same as \texttt{mglcode}, but it doesn't produce any image, nor accepts optional arguments. It is useful, for example, to create a MGL script, which can later be post processed by another package like "listings".
+\item[mglblock]
+ It writes its contents verbatim to a file, specified as a mandatory argument, and to the LaTeX document, and numerates each line of code.
+
+% This last three environments will test if the user is overwriting some file, and will issue a warning in that case.
+\item[mglverbatim]
+ Exactly the same as \texttt{mglblock}, but it doesn't write to a file. This environment doesn't have arguments.
+\item[mglfunc]
+ Is used to define MGL functions. It takes one mandatory argument, which is the name of the function, plus one additional argument, which specifies the number of arguments of the function. The environment needs to contain only the body of the function, since the first and last lines are appended automatically, and the resulting code is written at the end of the general script, which is also written automatically. The warning is produced if 2 or more function with the same name is defined.
+\item[mglplotsettings]
+ If many scripts with the same code are to be written, the repetitive code can be written inside this environment only once, then this code will be used automatically every time the \texttt{\textbackslash{}mglplot} command is used (see below). It takes one optional argument, which is a name to be associated to the corresponding contents of the environment; this name can be passed to the \texttt{\textbackslash{}mglplot} command to use the corresponding block of code automatically (see below).
+\end{description}
+
+The package also defines the following commands:
+\begin{description}
+\item[\textbackslash{}mglplot]
+ It takes one mandatory argument, which is MGL instructions separated by the symbol ':' this argument can be more than one line long. It takes the same optional arguments as the \texttt{mgl} environment, plus an additional argument \emph{settings}, which indicates the name associated to a block of code inside a \texttt{mglplotsettings} environment. The code inside the mandatory argument will be appended to the block of code specified, and the resulting code will be written to the general script.
+\item[\textbackslash{}mglgraphics]
+ This command takes the same optional arguments as the \texttt{mgl} environment, and one mandatory argument, which is the name of a MGL script. This command will compile the corresponding script and include the resulting image. It is useful when you have a script outside the LaTeX document, and you want to include the image, but you don't want to type the script again.
+\item[\textbackslash{}mglinclude]
+ This is like \texttt{\textbackslash{}mglgraphics} but, instead of creating/including the corresponding image, it writes the contents of the MGL script to the LaTeX document, and numerates the lines.
+\item[\textbackslash{}mgldir]
+ This command can be used in the preamble of the document to specify a directory where LaTeX will save the MGL scripts and generate the corresponding images. This directory is also where \texttt{\textbackslash{}mglgraphics} and \texttt{\textbackslash{}mglinclude} will look for scripts.
+\item[\textbackslash{}mglTeX]
+ It just pretty prints the name of the package ''\mglTeX''.
+\end{description}
+
+
+An example of usage of \texttt{mgl} and \texttt{mglfunc} environments would be:
+\begin{verbatim}
+\begin{mglfunc}{prepare2d}
+ new a 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
+ new b 50 40 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
+\end{mglfunc}
+
+\begin{figure}[!ht]
+ \centering
+ \begin{mgl}[width=0.85\textwidth,height=7.5cm]
+ fog 0.5
+ call 'prepare2d'
+ subplot 2 2 0:title 'Surf plot (default)':rotate 50 60:light on:box:surf a
+
+ subplot 2 2 1:title '"\#" style; meshnum 10':rotate 50 60:box
+ surf a '#'; meshnum 10
+
+ subplot 2 2 2 : title 'Mesh plot' : rotate 50 60 : box
+ mesh a
+
+ new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)'
+ new y 50 40 '0.8*cos(pi*x)*sin(pi*(y+1)/2)'
+ new z 50 40 '0.8*cos(pi*(y+1)/2)'
+ subplot 2 2 3 : title 'parametric form' : rotate 50 60 : box
+ surf x y z 'BbwrR'
+ \end{mgl}
+\end{figure}
+\end{verbatim}
+Note, that \texttt{mglfunc} environment(s) can be located at any position (at the beginning, at the end, or somewhere else) of LaTeX document.
+\begin{mglfunc}{prepare2d}
+ new a 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
+ new b 50 40 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
+\end{mglfunc}
+
+\begin{figure}[!ht]
+ \centering
+ \begin{mgl}[width=0.85\textwidth,height=7.5cm]
+ fog 0.5
+ call 'prepare2d'
+ subplot 2 2 0 : title 'Surf plot (default)' : rotate 50 60 : light on : box : surf a
+
+ subplot 2 2 1 : title '"\#" style; meshnum 10' : rotate 50 60 : box
+ surf a '#'; meshnum 10
+
+ subplot 2 2 2 : title 'Mesh plot' : rotate 50 60 : box
+ mesh a
+
+ new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)'
+ new y 50 40 '0.8*cos(pi*x)*sin(pi*(y+1)/2)'
+ new z 50 40 '0.8*cos(pi*(y+1)/2)'
+ subplot 2 2 3 : title 'parametric form' : rotate 50 60 : box
+ surf x y z 'BbwrR'
+ \end{mgl}
+\end{figure}
+
+Following example show the usage of \texttt{mglscript} environment
+\begin{verbatim}
+\begin{mglscript}{Vectorial}
+call 'prepare2v'
+subplot 3 2 0 '' : title 'lolo' : box
+vect a b
+subplot 3 2 1 '' : title '"." style; "=" style' : box
+vect a b '.='
+subplot 3 2 2 '' : title '"f" style' : box
+vect a b 'f'
+subplot 3 2 3 '' : title '">" style' : box
+vect a b '>'
+subplot 3 2 4 '' : title '"<" style' : box
+vect a b '<'
+call 'prepare3v'
+subplot 3 2 5 : title '3d variant' : rotate 50 60 : box
+vect ex ey ez
+
+stop
+
+func 'prepare2v'
+ new a 20 30 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
+ new b 20 30 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
+return
+
+func 'prepare3v'
+ define $1 pow(x*x+y*y+(z-0.3)*(z-0.3)+0.03,1.5)
+ define $2 pow(x*x+y*y+(z+0.3)*(z+0.3)+0.03,1.5)
+ new ex 10 10 10 '0.2*x/$1-0.2*x/$2'
+ new ey 10 10 10 '0.2*y/$1-0.2*y/$2'
+ new ez 10 10 10 '0.2*(z-0.3)/$1-0.2*(z+0.3)/$2'
+return
+\end{mglscript}
+\end{verbatim}
+
+\begin{mglscript}{Vectorial}
+call 'prepare2v'
+subplot 3 2 0 '' : title 'lolo' : box
+vect a b
+subplot 3 2 1 '' : title '"." style; "=" style' : box
+vect a b '.='
+subplot 3 2 2 '' : title '"f" style' : box
+vect a b 'f'
+subplot 3 2 3 '' : title '">" style' : box
+vect a b '>'
+subplot 3 2 4 '' : title '"<" style' : box
+vect a b '<'
+call 'prepare3v'
+subplot 3 2 5 : title '3d variant' : rotate 50 60 : box
+vect ex ey ez
+
+stop
+
+func 'prepare2v'
+ new a 20 30 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
+ new b 20 30 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
+return
+
+func 'prepare3v'
+ define $1 pow(x*x+y*y+(z-0.3)*(z-0.3)+0.03,1.5)
+ define $2 pow(x*x+y*y+(z+0.3)*(z+0.3)+0.03,1.5)
+ new ex 10 10 10 '0.2*x/$1-0.2*x/$2'
+ new ey 10 10 10 '0.2*y/$1-0.2*y/$2'
+ new ez 10 10 10 '0.2*(z-0.3)/$1-0.2*(z+0.3)/$2'
+return
+\end{mglscript}
+
+You should use \texttt{\textbackslash{}mglgraphics} command to display its contents
+\begin{verbatim}
+\begin{figure}[!ht]
+ \centering
+ \mglgraphics[width=40em,height=20em]{Vectorial}
+ \caption{A beautiful example}
+\end{figure}
+\end{verbatim}
+
+\begin{figure}[!ht]
+ \centering
+ \mglgraphics[width=40em,height=20em]{Vectorial}
+ \caption{A beautiful example}
+\end{figure}
+
+Alternatively, you can display the contents of the script in parallel to saving to a file, if you are using \texttt{mglblock} environment
+\begin{verbatim}
+\begin{mglblock}{Axis_projection}
+ ranges 0 1 0 1 0 1
+ new x 50 '0.25*(1+cos(2*pi*x))'
+ new y 50 '0.25*(1+sin(2*pi*x))'
+ new z 50 'x'
+ new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'
+ new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx
+ light on
+
+ title 'Projection sample':ternary 4:rotate 50 60
+ box:axis:grid
+ plot x y z 'r2':surf a '#'
+ xlabel 'X':ylabel 'Y':zlabel 'Z'
+\end{mglblock}
+\begin{figure}[!ht]
+ \centering
+ \mglgraphics[scale=0.5]{Axis_projection}
+ \caption{The image from Axis\_projection.mgl script}
+\end{figure}
+\end{verbatim}
+
+\begin{mglblock}{Axis_projection}
+ ranges 0 1 0 1 0 1
+ new x 50 '0.25*(1+cos(2*pi*x))'
+ new y 50 '0.25*(1+sin(2*pi*x))'
+ new z 50 'x'
+ new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'
+ new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx
+ light on
+
+ title 'Projection sample':ternary 4:rotate 50 60
+ box:axis:grid
+ plot x y z 'r2':surf a '#'
+ xlabel 'X':ylabel 'Y':zlabel 'Z'
+\end{mglblock}
+\begin{figure}[!ht]
+ \centering
+ \mglgraphics[scale=0.5]{Axis_projection}
+ \caption{The image from Axis\_projection.mgl script}
+\end{figure}
+
+Finally, you can just show MGL script itself
+\begin{verbatim}
+\begin{mglverbatim}
+ ranges 0 1 0 1 0 1
+ new x 50 '0.25*(1+cos(2*pi*x))'
+ new y 50 '0.25*(1+sin(2*pi*x))'
+ new z 50 'x'
+ new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'
+ new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx
+ light on
+
+ title 'Projection sample':ternary 4:rotate 50 60
+ box:axis:grid
+ plot x y z 'r2':surf a '#'
+ xlabel 'X':ylabel 'Y':zlabel 'Z'
+\end{mglverbatim}
+\end{verbatim}
+
+\begin{mglverbatim}
+ ranges 0 1 0 1 0 1
+ new x 50 '0.25*(1+cos(2*pi*x))'
+ new y 50 '0.25*(1+sin(2*pi*x))'
+ new z 50 'x'
+ new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'
+ new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx
+ light on
+
+ title 'Projection sample':ternary 4:rotate 50 60
+ box:axis:grid
+ plot x y z 'r2':surf a '#'
+ xlabel 'X':ylabel 'Y':zlabel 'Z'
+\end{mglverbatim}
+
+
+An example of usage of \texttt{\textbackslash{}mglplot} command would be:
+\begin{verbatim}
+\begin{mglplotsettings}
+ box '@{W9}' : axis
+\end{mglplotsettings}
+\begin{mglplotsettings}[2d]
+ box : axis
+ grid 'xy' ';k'
+\end{mglplotsettings}
+\begin{mglplotsettings}[3d]
+ rotate 50 60
+ box : axis : grid 'xyz' ';k'
+\end{mglplotsettings}
+\begin{figure}[!ht]
+ \centering
+ \mglplot[scale=0.5]{new a 200 'sin(pi*x)':plot a '2B'}
+\end{figure}
+\begin{figure}[!ht]
+ \centering
+ \mglplot[scale=0.5,settings=2d]{
+ fplot 'sin(pi*x)' '2B' :
+ fplot 'cos(pi*x^2)' '2R'
+ }
+\end{figure}
+\begin{figure}[!ht]
+ \centering
+ \mglplot[width=0.5 \textwidth, settings=3d]
+ {fsurf 'sin(pi*x)+cos(pi*y)'}
+\end{figure}
+\end{verbatim}
+
+\begin{mglplotsettings}
+ box '@{W9}' : axis
+\end{mglplotsettings}
+\begin{mglplotsettings}[2d]
+ box : axis
+ grid 'xy' ';k'
+\end{mglplotsettings}
+\begin{mglplotsettings}[3d]
+ rotate 50 60
+ box : axis : grid 'xyz' ';k'
+\end{mglplotsettings}
+\begin{figure}[!ht]
+ \centering
+ \mglplot[scale=0.5]{new a 200 'sin(pi*x)':plot a '2B'}
+\end{figure}
+\begin{figure}[!ht]
+ \centering
+ \mglplot[scale=0.5,settings=2d]{
+ fplot 'sin(pi*x)' '2B' :
+ fplot 'cos(pi*x^2)' '2R'
+ }
+\end{figure}
+\begin{figure}[!ht]
+ \centering
+ \mglplot[width=0.5 \textwidth, settings=3d]
+ {fsurf 'sin(pi*x)+cos(pi*y)'}
+\end{figure}
+
+As an additional feature, when an image is not found or cannot be included, instead of issuing an error, \texttt{mgltex} prints a box with the word \emph{'MGL image not found'} in the LaTeX document.
+\begin{figure}[!ht]
+ \centering
+ \mglgraphics{xyz}
+\end{figure}
+
+The last sample is displaying the content of the MGL file using \texttt{\textbackslash{}mglinclude} command:
+\mglinclude{Vectorial}
+
+\end{document}
\ No newline at end of file
set(mgl_src
addon.cpp axis.cpp base_cf.cpp base.cpp canvas_cf.cpp canvas.cpp cont.cpp crust.cpp
complex.cpp complex_ex.cpp complex_io.cpp fft.cpp data_gr.cpp
- data.cpp data_io.cpp data_ex.cpp data_png.cpp def_font.cpp
+ data.cpp data_io.cpp data_ex.cpp data_png.cpp
export_2d.cpp export_3d.cpp eval.cpp evalp.cpp exec.cpp export.cpp
fit.cpp font.cpp obj.cpp other.cpp parser.cpp pde.cpp pixel.cpp
plot.cpp prim.cpp surf.cpp tex_table.cpp vect.cpp volume.cpp evalc.cpp
add_library(mgl-static STATIC ${mgl_src} ${mgl_hdr})
set_target_properties(mgl PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(mgl-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
-set_target_properties(mgl-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE)
+target_compile_definitions(mgl-static PUBLIC MGL_STATIC_DEFINE)
generate_export_header(mgl EXPORT_FILE_NAME ../include/mgl2/dllexport.h)
if(enable-mgl2)
include_directories(${HDF4_INCLUDE_DIR})
endif(MGL_HAVE_HDF4)
+if(MGL_HAVE_LTDL)
+ target_link_libraries(mgl ${LTDL_LIB} )
+ include_directories(${LTDL_INCLUDE_DIR})
+endif(MGL_HAVE_LTDL)
+
if(MGL_HAVE_GSL)
target_link_libraries(mgl ${GSL_LIB} ${GSL_CBLAS_LIB} )
include_directories(${GSL_INCLUDE_DIR})
set_target_properties(mgl-mpi PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS")
set_target_properties(mgl-mpi-static PROPERTIES OUTPUT_NAME "mgl-mpi")
set_target_properties(mgl-mpi-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
- set_target_properties(mgl-mpi-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE)
+ target_compile_definitions(mgl-mpi-static PUBLIC MGL_STATIC_DEFINE)
if(enable-mgl2)
set_target_properties(mgl-mpi PROPERTIES OUTPUT_NAME "mgl2-mpi")
register mreal dd = i+di;
dd = 1./(sqrt(dd*dd+1.)+dd); // corrections for "axiality"
register mreal gg = 1+dd*dd;
- d[i] = a[i*step] + adt*( b[i-1]*((gg-dd)/k) -
- b[i]*(2*gg/k) + b[i+1]*((gg+dd)/k) );
+ d[i] = a[i*step] + adt*( b[i-1]*((gg-dd)/k) - b[i]*(2*gg/k) + b[i+1]*((gg+dd)/k) );
}
memcpy(b,d,n*sizeof(dual));
switch(Border)
if(strchr(dir,ar[i])) { arr=ar[i]; break; }
if(!mglchrs(dir,"xXyYzZ")) dir="xyz";
- SaveState(opt);
+ mreal angl = SaveState(opt);
AdjustTicks(dir,mglchr(stl,'a'),Tstl);
LoadState();
ax.inv = ay.inv = az.inv = false;
if(strchr(dir,'X') || strchr(dir,'x'))
- { ax.inv = inv; DrawAxis(ax, text, arr, stl, opt); }
+ { ax.inv = inv; DrawAxis(ax, text, arr, stl, angl); }
if(strchr(dir,'Z') || strchr(dir,'z'))
- { az.inv = inv; DrawAxis(az, text, arr, stl, opt); }
+ { az.inv = inv; DrawAxis(az, text, arr, stl, angl); }
if((TernAxis&3))
{
mglAxis ty(ay); ty.pos='t'; ty.ch='T';
ty.dir = mglPoint(-1,1); ty.org = mglPoint(1,0,ay.org.z);
- DrawAxis(ty, text, arr, stl, opt); ty.ch='t';
+ DrawAxis(ty, text, arr, stl, angl); ty.ch='t';
ty.dir = mglPoint(0,-1); ty.org = mglPoint(0,1,ay.org.z);
- DrawAxis(ty, text, arr, stl, opt);
+ DrawAxis(ty, text, arr, stl, angl);
}
else if(strchr(dir,'Y') || strchr(dir,'y'))
- { ay.inv = inv; DrawAxis(ay, text, arr, stl, opt); }
+ { ay.inv = inv; DrawAxis(ay, text, arr, stl, angl); }
set(ret, MGL_ENABLE_RTEXT);
}
//-----------------------------------------------------------------------------
-void mglCanvas::DrawAxis(mglAxis &aa, bool text, char arr,const char *stl,const char *opt)
+void mglCanvas::DrawAxis(mglAxis &aa, bool text, char arr,const char *stl,mreal angl)
{
- SaveState(opt);
+ aa.angl = angl;
if(strchr("xyz",aa.ch))
aa.org = mglPoint(GetOrgX(aa.ch,aa.inv), GetOrgY(aa.ch,aa.inv), GetOrgZ(aa.ch,aa.inv));
if(aa.ch=='x') aa.v0 = aa.org.x;
{
w[i] = TextWidth(aa.txt[i].text.c_str(),FontDef,-1);
kk[i] = AddPnt(M, o+d*aa.txt[i].val,-1,d,0,7);
+ if(kk[i]>=0)
+ {
+ mglPnt &pp = Pnt[kk[i]];
+ if(pp.u<0 || (pp.u==0 && pp.v<0))
+ { pp.u=-pp.u; pp.v=-pp.v; pp.w=-pp.w; }
+ }
}
for(l=0,c=INFINITY,i=0;i<n-1;i++)
if(v>0 && l < vv/v) l = vv/v;
if(c>v) c = v;
}
- if(get(MGL_ENABLE_RTEXT) && get(MGL_TICKS_ROTATE) && l>1 && c>0) // try rotate first
+ if(mgl_isnum(aa.angl)) // manual rotation
+ {
+ tet = aa.angl*M_PI/180;
+ mreal s = sin(tet);
+ if(s>0)
+ { pos[2]=(aa.ch=='c' && !inv)?'R':'L'; l=0.99*h/s/c;
+ for(i=0;i<n;i++) w[i]=l*c; }
+ else if(s<0)
+ { pos[2]=(aa.ch=='c' && !inv)?'L':'R'; l=-0.99*h/s/c;
+ for(i=0;i<n;i++) w[i]=l*c; }
+ }
+ else if(get(MGL_ENABLE_RTEXT) && get(MGL_TICKS_ROTATE) && l>1 && c>0) // try rotate first
{ tet = c>1.1*h ? asin(1.1*h/c) : M_PI/2; pos[2]=(aa.ch=='c' && !inv)?'R':'L';
l=0.99*h/sin(tet)/c; for(i=0;i<n;i++) w[i]=l*c; }
// TODO: do clever points exclusion (i.e. longest and so on)
mreal v0 = mgl_isnan(aa.o) ? aa.v0 : aa.o;
if(aa.v2>aa.v1) v0 = v0 - aa.ds*floor((v0-aa.v1)/aa.ds+1e-3);
else v0 = v0 - aa.ds*floor((v0-aa.v2)/aa.ds+1e-3);
+ fflush(stdout); // somehow this help to bypass bug in GCC 32bit
if(v0+aa.ds!=v0 && aa.v2+aa.ds!=aa.v2)
for(mreal v=v0;(v-aa.v2)*(v-aa.v1)<=0;v+=aa.ds)
mgl_drw_grid(this, v, d, oa, ob, da1, db1, da2, db2);
if(pos<-0.2) ff[1]='L'; if(pos>0.2) ff[1]='R';
strncpy(font,FontDef,63); strcat(font,ff);
long kk = AddPnt(&B, p,-1,q,0,7); ff[1]=0;
+ if(kk>=0)
+ {
+ mglPnt &pp = Pnt[kk];
+ if(pp.u<0 || (pp.u==0 && pp.v<0))
+ { pp.u=-pp.u; pp.v=-pp.v; pp.w=-pp.w; }
+ }
ff[0] = GetLabelPos(t, kk, *aa); strcat(font,ff);
text_plot(kk,text,font,-1.4,0.35+shift);
}
SetPenPal(AxisStl);
// bool out = fabs(x)>1 && fabs(y)>1;
bool inv = where!=3 && where!=0;
- ac.ns = where;
+ ac.ns = where; ac.angl=NAN;
if(text) DrawLabels(ac,inv,&M); // NOTE ns isn't used for colorbar
clr(MGL_DISABLE_SCALE); EndGroup();
}
l += 2*f->GetNl(0,ch);\r
n += 6*f->GetNt(0,ch);\r
}\r
- printf("unsigned mgl_numg=%lu, mgl_cur=%lu;\n",(unsigned long)s.size(),l+n);\r
+ printf("const long mgl_numg=%lu, mgl_cur=%lu;\n",(unsigned long)s.size(),l+n);\r
printf("float mgl_fact=%g;\n",f->GetFact(0)/mgl_fgen);\r
printf("long mgl_gen_fnt[%lu][6] = {\n", (unsigned long)s.size());\r
for(i=m=0;i<s.size();i++) // first write symbols descriptions\r
mglBase::~mglBase()\r
{\r
ClearEq(); ClearPrmInd(); delete fnt;\r
+ Pnt.set_mutex(0); Prm.set_mutex(0);\r
+ Sub.set_mutex(0); Txt.set_mutex(0);\r
#if MGL_HAVE_OMP\r
omp_destroy_lock(&lockClf);\r
#endif\r
{k=Pnt.size(); MGL_PUSH(Pnt,p,mutexPnt);} return k;\r
}\r
//-----------------------------------------------------------------------------\r
-long mglBase::CopyProj(long from, mglPoint p, mglPoint n)\r
+long mglBase::CopyProj(long from, mglPoint p, mglPoint n, short sub)\r
{\r
if(from<0) return -1;\r
- mglPnt q=Pnt[from];\r
+ mglPnt q=Pnt[from]; q.sub = sub;\r
q.x=q.xx=p.x; q.y=q.yy=p.y; q.z=q.zz=p.z;\r
q.u = n.x; q.v = n.y; q.w = n.z;\r
long k;\r
//-----------------------------------------------------------------------------\r
void mglBase::Reserve(long n)\r
{\r
- if(TernAxis&4) n*=4;\r
+ if(TernAxis&12) n*=4;\r
#pragma omp critical(pnt)\r
Pnt.reserve(n);\r
#pragma omp critical(prm)\r
int MGL_EXPORT_PURE mgl_get_warn(HMGL gr) { return gr->GetWarn(); }\r
void MGL_EXPORT mgl_set_warn(HMGL gr, int code, const char *txt)\r
{ gr->SetWarn(code,txt); }\r
+extern bool mglPrintWarn;\r
+void MGL_EXPORT mgl_set_global_warn(const char *txt)\r
+{\r
+ if(txt && *txt)\r
+ {\r
+ mglGlobalMess += txt; mglGlobalMess += '\n';\r
+ if(mglPrintWarn) fprintf(stderr,"Global message - %s\n",txt);\r
+ }\r
+}\r
+void MGL_EXPORT mgl_set_global_warn_(const char *txt, int l)\r
+{ char *s=new char[l+1]; memcpy(s,txt,l); s[l]=0; mgl_set_global_warn(s); delete []s; }\r
+MGL_EXPORT_PURE const char *mgl_get_global_warn() { return mglGlobalMess.c_str(); }\r
+int MGL_EXPORT mgl_get_global_warn_(char *out, int len)\r
+{\r
+ const char *res = mgl_get_global_warn();\r
+ if(out) strncpy(out,res,len);\r
+ return strlen(res);\r
+}\r
+//-----------------------------------------------------------------------------\r
void MGL_EXPORT mgl_set_origin(HMGL gr, double x0, double y0, double z0)\r
{ gr->SetOrigin(x0,y0,z0); }\r
void MGL_EXPORT mgl_set_palette(HMGL gr, const char *colors)\r
pthread_mutex_lock(&mutexAct);\r
#endif\r
\r
-#pragma omp critical(txt)\r
+#pragma omp critical\r
{\r
StartAutoGroup(NULL);\r
Sub.clear(); Leg.clear(); Grp.clear(); Act.clear();\r
size = size?fabs(size):1;\r
size *= MarkSize*0.35*font_factor;\r
if(type=='.') size = fabs(PenWidth)*sqrt(font_factor/400);\r
- if(TernAxis&4) for(int i=0;i<4;i++)\r
+ if(TernAxis&12) for(int i=0;i<4;i++)\r
{ p = ProjScale(i, pp); MGL_MARK_PLOT }\r
else { MGL_MARK_PLOT }\r
}\r
if(p1>p2) { long kk=p1; p1=p2; p2=kk; } // rearrange start/end for proper dashing\r
long pp1=p1,pp2=p2;\r
mreal pw = fabs(PenWidth)*sqrt(font_factor/400);\r
- if(TernAxis&4) for(int i=0;i<4;i++)\r
+ if(TernAxis&12) for(int i=0;i<4;i++)\r
{ p1 = ProjScale(i, pp1); p2 = ProjScale(i, pp2);\r
MGL_LINE_PLOT }\r
else { MGL_LINE_PLOT }\r
if(p1<0 || p2<0 || p3<0 || mgl_isnan(Pnt[p1].x) || mgl_isnan(Pnt[p2].x) || mgl_isnan(Pnt[p3].x)) return;\r
long pp1=p1,pp2=p2,pp3=p3;\r
mreal pw = fabs(PenWidth)*sqrt(font_factor/400);\r
- if(TernAxis&4) for(int i=0;i<4;i++)\r
+ if(TernAxis&12) for(int i=0;i<4;i++)\r
{ p1 = ProjScale(i, pp1); p2 = ProjScale(i, pp2);\r
p3 = ProjScale(i, pp3); MGL_TRIG_PLOT }\r
else { MGL_TRIG_PLOT }\r
if(p4<0 || mgl_isnan(Pnt[p4].x)) { trig_plot(p1,p2,p3); return; }\r
long pp1=p1,pp2=p2,pp3=p3,pp4=p4;\r
mreal pw = fabs(PenWidth)*sqrt(font_factor/400);\r
- if(TernAxis&4) for(int i=0;i<4;i++)\r
+ if(TernAxis&12) for(int i=0;i<4;i++)\r
{ p1 = ProjScale(i, pp1); p2 = ProjScale(i, pp2);\r
p3 = ProjScale(i, pp3); p4 = ProjScale(i, pp4);\r
MGL_QUAD_PLOT }\r
TernAxis = TernAxis|4;\r
return res;\r
}\r
+ else if(TernAxis&8) // text at projections\r
+ {\r
+ mreal res;\r
+ TernAxis = TernAxis&(~8);\r
+// for(int i=0;i<4;i++)\r
+ res = text_plot(ProjScale(3,p,true),text,font,size/2,sh,col,rot);\r
+ TernAxis = TernAxis|8;\r
+ return res;\r
+ }\r
+\r
\r
mglPnt q=Pnt[p];\r
mreal ll = q.u*q.u+q.v*q.v;\r
// parse -nan numbers\r
if(!strcmp(sf,"-nan")) memcpy(sf,"nan",4);\r
\r
- \r
+\r
// clear exp format\r
int st = se[0]=='-'?1:0;\r
if(plus || se[3+st+dig]=='-') // first remove zeros after 'e'\r
//-----------------------------------------------------------------------------\r
#if !MGL_HAVE_PNG\r
void MGL_EXPORT mgl_write_prc(HMGL gr, const char *fname,const char *descr, int make_pdf)\r
-{ mglGlobalMess += "PNG support was disabled. Please, enable it and rebuild MathGL.\n"; }\r
+{ mgl_set_global_warn("PNG support was disabled. Please, enable it and rebuild MathGL."); }\r
void MGL_EXPORT mgl_write_prc_(uintptr_t *graph, const char *fname,const char *descr, int *make_pdf,int lf,int ld)\r
-{ mglGlobalMess += "PNG support was disabled. Please, enable it and rebuild MathGL.\n"; }\r
+{ mgl_set_global_warn("PNG support was disabled. Please, enable it and rebuild MathGL."); }\r
#endif\r
//-----------------------------------------------------------------------------\r
void MGL_EXPORT mgl_finish(HMGL gr)\r
long nx=d->nx, ny=d->ny, nz=d->nz;\r
if(xx>=nx || yy>=ny || zz>=nz) return;\r
dual *a=d->a;\r
+ if(xx>=0 && yy>=0 && zz>=0) a[xx+nx*(yy+zz*ny)] = val;\r
if(xx<0 && yy<0 && zz<0)\r
#pragma omp parallel for\r
for(long i=0;i<nx*ny*nz;i++) a[i] = val;\r
else if(yy<0)\r
#pragma omp parallel for\r
for(long i=0;i<ny;i++) a[xx+nx*(i+zz*ny)] = val;\r
- else if(zz<0)\r
+ else //if(zz<0)\r
#pragma omp parallel for\r
for(long i=0;i<nz;i++) a[xx+nx*(yy+i*ny)] = val;\r
- else a[xx+nx*(yy+zz*ny)] = val;\r
}\r
//-----------------------------------------------------------------------------\r
void MGL_EXPORT mgl_datac_put_dat(HADT d, HCDT v, long xx, long yy, long zz)\r
//-----------------------------------------------------------------------------\r
#else\r
void MGL_EXPORT mgl_datac_save_hdf(HCDT ,const char *,const char *,int )\r
-{ mglGlobalMess += "HDF5 support was disabled. Please, enable it and rebuild MathGL.\n"; }\r
+{ mgl_set_global_warn("HDF5 support was disabled. Please, enable it and rebuild MathGL."); }\r
int MGL_EXPORT mgl_datac_read_hdf(HADT ,const char *,const char *)\r
-{ mglGlobalMess += "HDF5 support was disabled. Please, enable it and rebuild MathGL.\n"; return false;}\r
+{ mgl_set_global_warn("HDF5 support was disabled. Please, enable it and rebuild MathGL."); return false;}\r
#endif\r
//-----------------------------------------------------------------------------\r
int MGL_EXPORT mgl_datac_read_hdf_(uintptr_t *d, const char *fname, const char *data,int l,int n)\r
\r
std::vector<Triad> triads;\r
if(de_duplicate(pts, out))\r
- mglGlobalMess += "There are duplicated points for triangulation.\n";\r
+ mgl_set_global_warn("There are duplicated points for triangulation.");\r
s_hull_pro(pts, triads);\r
long m = triads.size();\r
nums=new mglData(3,m);\r
register long nx=d->nx, ny=d->ny, nz=d->nz;\r
if(xx>=nx || yy>=ny || zz>=nz) return;\r
mreal *a=d->a;\r
+ if(xx>=0 && yy>=0 && zz>=0) a[xx+nx*(yy+zz*ny)] = val;\r
if(xx<0 && yy<0 && zz<0)\r
#pragma omp parallel for\r
for(long i=0;i<nx*ny*nz;i++) a[i] = val;\r
else if(yy<0)\r
#pragma omp parallel for\r
for(long i=0;i<ny;i++) a[xx+nx*(i+zz*ny)] = val;\r
- else if(zz<0)\r
+ else //if(zz<0)\r
#pragma omp parallel for\r
for(long i=0;i<nz;i++) a[xx+nx*(yy+i*ny)] = val;\r
- else a[xx+nx*(yy+zz*ny)] = val;\r
}\r
//-----------------------------------------------------------------------------\r
void MGL_EXPORT mgl_data_put_dat(HMDT d, HCDT v, long xx, long yy, long zz)\r
}\r
#else\r
int MGL_EXPORT mgl_data_read_hdf4(HMDT ,const char *,const char *)\r
-{ mglGlobalMess += "HDF4 support was disabled. Please, enable it and rebuild MathGL.\n"; return false; }\r
+{ mgl_set_global_warn("HDF4 support was disabled. Please, enable it and rebuild MathGL."); return false; }\r
#endif\r
//-----------------------------------------------------------------------------\r
#if MGL_HAVE_HDF5\r
}\r
#else\r
void MGL_EXPORT mgl_data_save_hdf(HCDT ,const char *,const char *,int )\r
-{ mglGlobalMess += "HDF5 support was disabled. Please, enable it and rebuild MathGL.\n"; }\r
+{ mgl_set_global_warn("HDF5 support was disabled. Please, enable it and rebuild MathGL."); }\r
int MGL_EXPORT mgl_datas_hdf(const char *, char *, long )\r
-{ mglGlobalMess += "HDF5 support was disabled. Please, enable it and rebuild MathGL.\n"; return 0;}\r
+{ mgl_set_global_warn("HDF5 support was disabled. Please, enable it and rebuild MathGL."); return 0;}\r
int MGL_EXPORT mgl_data_read_hdf(HMDT ,const char *,const char *)\r
-{ mglGlobalMess += "HDF5 support was disabled. Please, enable it and rebuild MathGL.\n"; return false;}\r
+{ mgl_set_global_warn("HDF5 support was disabled. Please, enable it and rebuild MathGL."); return false;}\r
#endif\r
//-----------------------------------------------------------------------------\r
int MGL_EXPORT mgl_data_read_hdf_(uintptr_t *d, const char *fname, const char *data,int l,int n)\r
return c;\r
}\r
//-----------------------------------------------------------------------------\r
-bool MGL_NO_EXPORT mgl_read_image(unsigned char *g, int w, int h, const char *fname)\r
+bool MGL_NO_EXPORT mgl_read_image(unsigned char **g, int &w, int &h, const char *fname)\r
{\r
const char *ext = fname+strlen(fname)-1; // rindex(fname,'.');\r
while(*ext!='.' && ext!=fname) ext--;\r
long wi=png_get_image_width(png_ptr, info_ptr);\r
long hi=png_get_image_height(png_ptr, info_ptr);\r
int type = png_get_color_type(png_ptr, info_ptr);\r
- if(w<wi) wi=w;\r
- if(h>hi) h=hi;\r
+ if(*g)\r
+ {\r
+ if(wi>w) wi = w;\r
+ if(hi>h) hi = h;\r
+ }\r
+ else { w = wi; h = hi; *g = new unsigned char[4*w*h]; }\r
if(type==PNG_COLOR_TYPE_RGB_ALPHA)\r
#pragma omp parallel for\r
- for(long i=0;i<h;i++) memcpy(g+4*w*i,rows[i],4*wi);\r
+ for(long i=0;i<hi;i++) memcpy(*g+4*w*i,rows[i],4*wi);\r
else if(type==PNG_COLOR_TYPE_RGB)\r
#pragma omp parallel for collapse(2)\r
- for(long i=0;i<h;i++) for(long j=0;j<wi;j++)\r
- memcpy(g+4*(w*i+j),rows[i]+3*j,3);\r
+ for(long i=0;i<hi;i++) for(long j=0;j<wi;j++)\r
+ memcpy(*g+4*(w*i+j),rows[i]+3*j,3);\r
else if(type==PNG_COLOR_TYPE_GRAY)\r
#pragma omp parallel for collapse(2)\r
- for(long i=0;i<h;i++) for(long j=0;j<wi;j++)\r
- g[4*(w*i+j)] = g[4*(w*i+j)+1] = g[4*(w*i+j)+2] = rows[i][j];\r
+ for(long i=0;i<hi;i++) for(long j=0;j<wi;j++)\r
+ (*g)[4*(w*i+j)] = (*g)[4*(w*i+j)+1] = (*g)[4*(w*i+j)+2] = rows[i][j];\r
else if(type==PNG_COLOR_TYPE_GRAY_ALPHA)\r
#pragma omp parallel for collapse(2)\r
- for(long i=0;i<h;i++) for(long j=0;j<wi;j++)\r
+ for(long i=0;i<hi;i++) for(long j=0;j<wi;j++)\r
{\r
- g[4*(w*i+j)] = g[4*(w*i+j)+1] = g[4*(w*i+j)+2] = rows[i][2*j];\r
- g[4*(w*i+j)+3] = rows[i][2*j+1];\r
+ (*g)[4*(w*i+j)] = (*g)[4*(w*i+j)+1] = (*g)[4*(w*i+j)+2] = rows[i][2*j];\r
+ (*g)[4*(w*i+j)+3] = rows[i][2*j+1];\r
}\r
png_destroy_read_struct(&png_ptr, &info_ptr,&end_info);\r
fclose(fp);\r
#else\r
- mglGlobalMess += "PNG support was disabled. Please, enable it and rebuild MathGL.\n";\r
+ mgl_set_global_warn("PNG support was disabled. Please, enable it and rebuild MathGL.");\r
#endif\r
}\r
else if(!strcmp(ext,".jpg") || !strcmp(ext,".jpeg"))\r
long hi = info.output_height;\r
int channels = info.num_components; // == 4 for RGBA else for RGB\r
unsigned char *buf = new unsigned char[(channels==4?4:3)*wi];\r
- if(hi>h) hi = h;\r
- if(wi>w) wi = w;\r
+ if(*g)\r
+ {\r
+ if(hi>h) hi = h;\r
+ if(wi>w) wi = w;\r
+ }\r
+ else { w = wi; h = hi; *g = new unsigned char[4*w*h]; }\r
for(long i=0;i<hi;i++)\r
{\r
jpeg_read_scanlines(&info, &buf, 1);\r
if(channels==4)\r
- memcpy(g+4*i*w,buf,4*wi);\r
+ memcpy(*g+4*i*w,buf,4*wi);\r
else\r
#pragma omp parallel for\r
for(long j=0;j<wi;j++)\r
- memcpy(g+4*i*w+4*j,buf+3*j,3);\r
+ memcpy(*g+4*i*w+4*j,buf+3*j,3);\r
}\r
delete []buf;\r
#else\r
- mglGlobalMess += "JPEG support was disabled. Please, enable it and rebuild MathGL.\n";\r
+ mgl_set_global_warn("JPEG support was disabled. Please, enable it and rebuild MathGL.");\r
#endif\r
}\r
return true;\r
//-----------------------------------------------------------------------------\r
void MGL_EXPORT mgl_data_import(HMDT d, const char *fname, const char *scheme,mreal v1,mreal v2)\r
{\r
-#if MGL_HAVE_PNG\r
if(v1>=v2) return;\r
+ unsigned char *g = 0;\r
+ int w=0, h=0;\r
+ if(!mgl_read_image(&g,w,h,fname)) return;\r
long num=0;\r
- FILE *fp = fopen(fname, "rb");\r
- if (!fp) return;\r
- png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);\r
- if (!png_ptr) { fclose(fp); return; }\r
- png_infop info_ptr = png_create_info_struct(png_ptr);\r
- if (!info_ptr)\r
- { png_destroy_read_struct(&png_ptr,0,0); fclose(fp); return; }\r
- png_infop end_info = png_create_info_struct(png_ptr);\r
- if (!end_info)\r
- { png_destroy_read_struct(&png_ptr,&info_ptr,0); fclose(fp); return; }\r
-\r
- png_init_io(png_ptr, fp);\r
- png_read_png(png_ptr, info_ptr,\r
- PNG_TRANSFORM_STRIP_ALPHA|PNG_TRANSFORM_PACKING|\r
- PNG_TRANSFORM_STRIP_16|PNG_TRANSFORM_EXPAND,0);\r
- unsigned char **rows = png_get_rows(png_ptr, info_ptr);\r
unsigned char *c = mgl_create_scheme(scheme,num);\r
if(num>1)\r
{\r
- long w=png_get_image_width(png_ptr, info_ptr);\r
- long h=png_get_image_height(png_ptr, info_ptr);\r
d->Create(w,h,1);\r
#pragma omp parallel for collapse(2)\r
- for(long i=0;i<d->ny;i++) for(long j=0;j<d->nx;j++)\r
+ for(long i=0;i<h;i++) for(long j=0;j<w;j++)\r
{\r
size_t pos=0,mval=256;\r
for(long k=0;k<num;k++)\r
{\r
- size_t val = mgl_col_dif(c+3*k,rows[d->ny-i-1]+3*j,true);\r
+ size_t val = mgl_col_dif(c+3*k,g+4*w*(d->ny-i-1)+4*j,true);\r
if(val==0) { pos=k; break; }\r
if(val<mval) { pos=k; mval=val; }\r
}\r
d->a[j+d->nx*i] = v1 + pos*(v2-v1)/num;\r
}\r
}\r
- png_destroy_read_struct(&png_ptr, &info_ptr,&end_info);\r
- fclose(fp); delete []c;\r
-#else\r
- mglGlobalMess += "PNG support was disabled. Please, enable it and rebuild MathGL.\n";\r
-#endif\r
+ delete []g;\r
+ delete []c;\r
}\r
//-----------------------------------------------------------------------------\r
+int MGL_NO_EXPORT mgl_png_save(const char *fname, int w, int h, unsigned char **p);\r
+int MGL_NO_EXPORT mgl_bmp_save(const char *fname, int w, int h, unsigned char **p);\r
+int MGL_NO_EXPORT mgl_tga_save(const char *fname, int w, int h, unsigned char **p);\r
+int MGL_NO_EXPORT mgl_jpeg_save(const char *fname, int w, int h, unsigned char **p);\r
+int MGL_NO_EXPORT mgl_bps_save(const char *fname, int w, int h, unsigned char **p);\r
void MGL_EXPORT mgl_data_export(HCDT dd, const char *fname, const char *scheme,mreal v1,mreal v2,long ns)\r
{\r
-#if MGL_HAVE_PNG\r
long nx=dd->GetNx(), ny=dd->GetNy(), nz=dd->GetNz();\r
if(v1>v2) return;\r
if(ns<0 || ns>=nz) ns=0;\r
\r
unsigned char **p = new unsigned char*[ny];\r
unsigned char *d = new unsigned char[3*nx*ny];\r
-#pragma omp parallel for\r
+ #pragma omp parallel for\r
for(long i=0;i<ny;i++) p[i] = d+3*nx*(ny-1-i);\r
-#pragma omp parallel for collapse(2)\r
+ #pragma omp parallel for collapse(2)\r
for(long i=0;i<ny;i++) for(long j=0;j<nx;j++)\r
{\r
register long k = long(num*(dd->v(j,i,ns)-v1)/(v2-v1));\r
}\r
delete []c;\r
\r
- FILE *fp = fopen(fname, "wb");\r
- if (!fp) { delete []p; delete []d; return; }\r
- png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);\r
- if (!png_ptr) { delete []p; delete []d; fclose(fp); return; }\r
- png_infop info_ptr = png_create_info_struct(png_ptr);\r
- if (!info_ptr)\r
- { png_destroy_write_struct(&png_ptr,0); delete []p; delete []d; fclose(fp); return; }\r
- png_init_io(png_ptr, fp);\r
- png_set_filter(png_ptr, 0, PNG_ALL_FILTERS);\r
- png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);\r
- png_set_IHDR(png_ptr, info_ptr, nx, ny, 8, PNG_COLOR_TYPE_RGB,\r
- PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);\r
- png_set_rows(png_ptr, info_ptr, p);\r
- png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, 0);\r
- png_write_end(png_ptr, info_ptr);\r
- png_destroy_write_struct(&png_ptr, &info_ptr);\r
- fclose(fp); delete []p; delete []d;\r
-#else\r
- mglGlobalMess += "PNG support was disabled. Please, enable it and rebuild MathGL.\n";\r
-#endif\r
+ int len=strlen(fname);\r
+ if(!strcmp(fname+len-4,".jpg") || !strcmp(fname+len-5,".jpeg")) mgl_jpeg_save(fname, nx,ny,p);\r
+ if(!strcmp(fname+len-4,".bmp")) mgl_bmp_save(fname, nx,ny,p);\r
+ if(!strcmp(fname+len-4,".png")) mgl_png_save(fname, nx,ny,p);\r
+ if(!strcmp(fname+len-4,".eps") || !strcmp(fname+len-4,".bps")) mgl_bps_save(fname, nx,ny,p);\r
}\r
//-----------------------------------------------------------------------------\r
void MGL_EXPORT mgl_data_export_(uintptr_t *d, const char *fname, const char *scheme,mreal *v1,mreal *v2,int *ns,int l,int n)\r
-{\r
- char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0;\r
+{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0;\r
char *f=new char[n+1]; memcpy(f,scheme,n); f[n]=0;\r
- mgl_data_export(_DT_,s,f,*v1,*v2,*ns);\r
- delete []s; delete []f;\r
-}\r
+ mgl_data_export(_DT_,s,f,*v1,*v2,*ns); delete []s; delete []f; }\r
void MGL_EXPORT mgl_data_import_(uintptr_t *d, const char *fname, const char *scheme,mreal *v1,mreal *v2,int l,int n)\r
-{\r
- char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0;\r
+{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0;\r
char *f=new char[n+1]; memcpy(f,scheme,n); f[n]=0;\r
- mgl_data_import(_DT_,s,f,*v1,*v2);\r
- delete []s; delete []f;\r
-}\r
+ mgl_data_import(_DT_,s,f,*v1,*v2); delete []s; delete []f; }\r
//-----------------------------------------------------------------------------\r
-#include "mgl2/define.h"
-unsigned MGL_EXPORT mgl_numg=411, mgl_cur=243136;
-float MGL_EXPORT mgl_fact=35.7143;
-long MGL_EXPORT mgl_gen_fnt[411][6] = {
+const long mgl_numg=411, mgl_cur=243136;
+const float mgl_fact=35.7143;
+long mgl_gen_fnt[411][6] = {
{0x21,166,41,0,39,164},
{0x22,204,43,398,38,570},
{0x23,250,33,798,32,930},
{0x226f,342,20,242874,19,242954},
{0x27c2,346,8,243068,6,243100}
};
-short MGL_EXPORT mgl_buf_fnt[243136] = {
+short mgl_buf_fnt[243136] = {
88,88,94,88,117,278,117,282,118,286,118,297,117,311,113,322,108,331,101,336,92,338,81,336,74,331,69,323,66,312,65,300,65,289,66,284,66,278,16383,16383,118,21,116,30,113,37,107,43,100,47,92,49,83,47,76,43,70,37,66,30,65,22,66,13,70,6,75,0,82,-2,91,-3,100,-2,107,0,113,6,116,13,118,21,150,215,154,243,158,268,162,289,165,306,166,318,165,324,162,330,157,334,151,337,145,338,138,337,132,334,127,330,124,324,123,316,124,307,126,291,129,270,134,244,139,215,16383,16383,65,215,70,243,75,268,78,289,80,306,81,318,80,324,77,330,73,334,67,337,60,338,53,337,47,334,42,330,40,324,39,316,39,307,42,291,45,270,
107,43,107,0,113,37,113,37,107,0,113,6,113,37,113,6,116,30,116,30,113,6,116,13,116,30,116,13,118,21,65,22,66,13,66,30,66,30,66,13,70,6,66,30,70,6,70,37,70,37,70,6,75,0,70,37,75,0,76,43,76,43,75,0,82,-2,76,43,82,-2,83,47,83,47,82,-2,91,-3,83,47,91,-3,92,49,92,49,91,-3,100,-2,92,49,100,-2,100,47,100,47,100,-2,107,0,100,47,107,0,107,43,118,297,117,311,117,278,118,297,117,278,117,282,118,297,117,282,118,286,118,297,118,286,118,290,118,297,118,290,118,294,117,278,117,311,113,322,117,278,113,322,108,331,117,278,108,331,101,336,117,278,101,336,94,88,92,338,81,336,88,88,92,338,88,88,94,88,92,338,94,88,101,336,66,284,66,278,69,323,69,323,66,278,88,88,69,323,88,88,74,331,74,331,88,88,81,336,66,312,65,300,65,297,66,312,65,297,65,293,66,312,65,293,65,289,66,312,65,289,66,284,66,312,66,284,69,323,
150,215,154,243,158,268,162,289,165,306,166,318,165,324,162,330,157,334,151,337,145,338,138,337,132,334,127,330,124,324,123,316,124,307,126,291,129,270,134,244,139,215,16383,16383,65,215,70,243,75,268,78,289,80,306,81,318,80,324,77,330,73,334,67,337,60,338,53,337,47,334,42,330,40,324,39,316,39,307,42,291,45,270,50,244,55,215,248,203,248,230,200,230,214,331,185,331,171,230,104,230,119,331,90,331,75,230,17,230,17,203,71,203,60,136,3,136,3,108,56,108,40,0,69,0,85,108,152,108,137,0,166,0,181,108,235,108,235,136,185,136,195,203,16383,16383,166,203,156,136,89,136,100,203,132,319,154,314,172,304,186,291,197,273,205,250,213,250,213,305,202,314,189,321,
Left=Right=0;\r
Res=0; Kod=0;\r
if(!string) { Kod = EQ_NUM; Res = 0; return; }\r
-//printf("%s\n",string); fflush(stdout);\r
char *str = new char[strlen(string)+1];\r
strcpy(str,string);\r
long n,len;\r
else res = 1; return res;
}
//-----------------------------------------------------------------------------
+int MGL_NO_EXPORT mgls_reset(mglGraph *gr, long , mglArg *, const char *k, const char *)
+{
+ int res=0;
+ if(!strcmp(k,"")) gr->DefaultPlotParam();
+ else res = 1; return res;
+}
+//-----------------------------------------------------------------------------
int MGL_NO_EXPORT mgls_chart(mglGraph *gr, long , mglArg *a, const char *k, const char *opt)
{
int res=0;
else res = 1; gr->Self()->LoadState(); return res;
}
//-----------------------------------------------------------------------------
+int MGL_NO_EXPORT mgls_logo(mglGraph *gr, long , mglArg *a, const char *k, const char *opt)
+{
+ int res=0;
+ if(!strcmp(k,"s")) gr->Logo(a[0].s.c_str(),false,opt);
+ else if(!strcmp(k,"sn")) gr->Logo(a[0].s.c_str(),iint(a[1].v),opt);
+ else res = 1; return res;
+}
+//-----------------------------------------------------------------------------
int MGL_NO_EXPORT mgls_resize(mglGraph *, long , mglArg *a, const char *k, const char *)
{
int res=0;
{"legendmarks","Set number of marks in the legend","legendmarks val", mgls_legendmarks ,15},
{"light","Setup light","light [val] | val num | num xpos ypos zpos ['fmt' br]", mgls_light ,2},
{"line","Draw line","line x1 y1 x2 y2 ['fmt']|x1 y1 z1 x2 y2 z2 ['fmt']", mgls_line ,13},
- {"list","Creates new variable from list of numbers or data","list Var v1 ...|Var D1 ...", 0, 6},
+ {"list","Creates new variable from list of numbers or data","list Var v1 ...|Var D1 ...", 0, 4},
+ {"load","Load commands from external DLL","load 'fname'", 0, 6},
{"loadfont","Load fontfaces","loadfont ['face']", mgls_loadfont ,15},
+ {"logo","Draw bitmap (logo) along axis range","logo 'fname' [smooth]", mgls_logo ,13},
{"map","Draw mapping plot","map Udat Vdat ['fmt']|Xdat Ydat Udat Vdat ['fmt']", mgls_map ,10},
{"mark","Draw mark plot for 1D data","mark Ydat Rdat ['fmt']|Xdat Ydat Rdat ['fmt']|Xdat Ydat Zdat Rdat ['fmt']", mgls_mark ,7},
{"marksize","Set size of markers","marksize val", mgls_marksize ,2},
{"rect","Draw rectangle","rect x1 y1 x2 y2 ['fmt']|x1 y1 z1 x2 y2 z2 ['fmt']", mgls_rect ,13},
{"refill","Fill data by interpolation of Vdat","refill Dat Xdat Vdat [sl] | Dat Xdat Ydat Vdat [sl] | Dat Xdat Ydat Zdat Vdat", mgls_refill ,3},
{"region","Draw filled region (ribbon) between 2 curves","region Ydat1 Ydat2 ['fmt']|Xdat Ydat1 Ydat2 ['fmt']||Xdat1 Ydat1 Xdat2 Ydat2 ['fmt']|Xdat1 Ydat1 Zdat1 Xdat2 Ydat2 Zdat2 ['fmt']", mgls_region ,7},
+ {"reset","Reset settings and clear picture","reset", mgls_reset ,12},
{"resize","Resize data","resize Res Dat mx [my mz]", mgls_resize ,4},
{"return","Return from function","return", 0, 6},
{"rhomb","Draw rhombus","rhomb x1 y1 x2 y2 r ['fmt']|x1 y1 z1 x2 y2 z2 r ['fmt']", mgls_rhomb ,13},
if(fl) fclose(fp);
return 0;
#else
- mglGlobalMess += "PNG support was disabled. Please, enable it and rebuild MathGL.\n";
+ mgl_set_global_warn("PNG support was disabled. Please, enable it and rebuild MathGL.");
return 1;
#endif
}
if(fl) fclose(fp);
return 0;
#else
- mglGlobalMess += "PNG support was disabled. Please, enable it and rebuild MathGL.\n";
+ mgl_set_global_warn("PNG support was disabled. Please, enable it and rebuild MathGL.");
return 1;
#endif
}
if(fl) fclose(fp);
return 0;
#else
- mglGlobalMess += "JPEG support was disabled. Please, enable it and rebuild MathGL.\n";
+ mgl_set_global_warn("JPEG support was disabled. Please, enable it and rebuild MathGL.");
return 1;
#endif
}
void *fp;
if(!strcmp(fname,"-")) fp = stdout; // allow to write in stdout
- else fp = gz ? (void*)gzopen(fname,"wt") : (void*)fopen(fname,"wt");
+ else
+ {
+ fp = gz ? (void*)gzopen(fname,"wt") : (void*)fopen(fname,"wt");
+ if(gz)
+ {
+ unsigned len = strlen(fname), pos=0;
+ char *buf = new char[len+4];
+ memcpy(buf,fname,len);
+ if(buf[len-3]=='.') pos = len-2;
+ else if(buf[len-2]=='.') pos = len-1;
+ else { buf[len-1]='.'; pos = len; }
+ if(pos) { buf[pos]=buf[pos+1]='b'; buf[pos+2]=0; }
+ FILE *fb = fopen(buf,"w");
+ fprintf(fb, "%%%%BoundingBox: 0 0 %d %d\n", w, h);
+ fclose(fb);
+ }
+ }
mgl_printf(fp, gz, "%%!PS-Adobe-3.0 EPSF-3.0\n%%%%BoundingBox: 0 0 %d %d\n",w,h);
mgl_printf(fp, gz, "%%%%Created by MathGL library\n%%%%Title: %s\n", fname);
mgl_printf(fp, gz, "%%%%CreationDate: %s\n",ctime(&now));
mgl_printf(fp, gz, "%d %d 8 [1 0 0 1 0 0] {currentfile %d string readhexstring pop} false 3 colorimage\n",
- w,h,1+w*h/40);
- for(j=h-1;j>=0;j--) for(i=0;i<w;i++)
+ w,h,w*h/40);
+ for(long j=0;j<h;j++) for(long i=0;i<w;i++)
{
- if((i+w*(h-j-1))%40==0 && i+j>0) mgl_printf(fp, gz, "\n");
- mgl_printf(fp, gz, "%02x%02x%02x",p[j][3*i],p[j][3*i+1],p[j][3*i+2]);
+ if((i+w*j)%40==0 && i+j>0) mgl_printf(fp, gz, "\n");
+ register long jj=h-1-j;
+ mgl_printf(fp, gz, "%02x%02x%02x",p[jj][3*i],p[jj][3*i+1],p[jj][3*i+2]);
}
mgl_printf(fp, gz, "\n\nshowpage\n%%%%EOF\n");
if(strcmp(fname,"-")) { if(gz) gzclose((gzFile)fp); else fclose((FILE *)fp); }
line[m] = i+6*(j+6*k);
}
EGifPutLine(fg, line, w*h);
+#if GIFLIB_MAJOR>5 || (GIFLIB_MAJOR==5 && GIFLIB_MINOR>0)
+ EGifCloseFile(fg,0);
+#else
EGifCloseFile(fg);
+#endif
delete []line; return 0;
#else
- mglGlobalMess += "GIF support was disabled. Please, enable it and rebuild MathGL.\n";
+ mgl_set_global_warn("GIF support was disabled. Please, enable it and rebuild MathGL.");
return 1;
#endif
}
void mglCanvas::StartGIF(const char *fname, int ms)
{
#if MGL_HAVE_GIF
- if(gif) EGifCloseFile(gif);
std::string fn=fname;
if(fn.empty()) { fn=PlotId+".gif"; fname = fn.c_str(); }
+#if GIFLIB_MAJOR>5 || (GIFLIB_MAJOR==5 && GIFLIB_MINOR>0)
+ if(gif) EGifCloseFile(gif,0);
+#else
+ if(gif) EGifCloseFile(gif);
+#endif
#if GIFLIB_MAJOR>=5
gif = EGifOpenFileName(fname, 0, 0);
EGifSetGifVersion(gif,true);
EGifPutExtension(gif,0xf9,4,ext2);
#endif
#else
- mglGlobalMess += "GIF support was disabled. Please, enable it and rebuild MathGL.\n";
+ mgl_set_global_warn("GIF support was disabled. Please, enable it and rebuild MathGL.");
#endif
}
//-----------------------------------------------------------------------------
void mglCanvas::CloseGIF()
{
#if MGL_HAVE_GIF
+#if GIFLIB_MAJOR>5 || (GIFLIB_MAJOR==5 && GIFLIB_MINOR>0)
+ if(gif) EGifCloseFile(gif,0);
+#else
if(gif) EGifCloseFile(gif);
+#endif
#else
- mglGlobalMess += "GIF support was disabled. Please, enable it and rebuild MathGL.\n";
+ mgl_set_global_warn("GIF support was disabled. Please, enable it and rebuild MathGL.");
#endif
gif = 0;
}
EGifPutLine(gif, line, n);
delete []line; free(l);
if(f) free(f);
-//#else
-// mglGlobalMess += "GIF support was disabled. Please, enable it and rebuild MathGL.\n";
#endif
}
//-----------------------------------------------------------------------------
if(!strcmp(fname+len-4,".png")) mgl_write_png(gr,fname,descr);
if(!strcmp(fname+len-4,".eps")) mgl_write_eps(gr,fname,descr);
if(!strcmp(fname+len-5,".epsz")) mgl_write_eps(gr,fname,descr);
+ if(!strcmp(fname+len-7,".eps.gz")) mgl_write_eps(gr,fname,descr);
if(!strcmp(fname+len-4,".bps")) mgl_write_bps(gr,fname,descr);
if(!strcmp(fname+len-5,".bpsz")) mgl_write_bps(gr,fname,descr);
+ if(!strcmp(fname+len-7,".bps.gz")) mgl_write_bps(gr,fname,descr);
if(!strcmp(fname+len-4,".svg")) mgl_write_svg(gr,fname,descr);
if(!strcmp(fname+len-5,".svgz")) mgl_write_svg(gr,fname,descr);
+ if(!strcmp(fname+len-7,".svg.gz")) mgl_write_svg(gr,fname,descr);
if(!strcmp(fname+len-4,".gif")) mgl_write_gif(gr,fname,descr);
if(!strcmp(fname+len-4,".bmp")) mgl_write_bmp(gr,fname,descr);
if(!strcmp(fname+len-4,".tga")) mgl_write_tga(gr,fname,descr);
if(!strcmp(fname,"-")) fp = stdout; // allow to write in stdout
else fp = gz ? (void*)gzopen(fname,"wt") : (void*)fopen(fname,"wt");
if(!fp) { gr->SetWarn(mglWarnOpen,fname); return; }
- const std::string loc = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C");
int w = _Gr_->GetWidth(), h = _Gr_->GetHeight();
+
+ if(gz)
+ {
+ unsigned len = strlen(fname), pos=0;
+ char *buf = new char[len+4];
+ memcpy(buf,fname,len);
+ if(buf[len-3]=='.') pos = len-2;
+ else if(buf[len-2]=='.') pos = len-1;
+ else { buf[len-1]='.'; pos = len; }
+ if(pos) { buf[pos]=buf[pos+1]='b'; buf[pos+2]=0; }
+ FILE *fb = fopen(buf,"w");
+ fprintf(fb, "%%%%BoundingBox: 0 0 %d %d\n", w, h);
+ fclose(fb);
+ }
+
+ const std::string loc = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C");
mgl_printf(fp, gz, "%%!PS-Adobe-3.0 EPSF-3.0\n%%%%BoundingBox: 0 0 %d %d\n", w, h);
mgl_printf(fp, gz, "%%%%Created by MathGL library\n%%%%Title: %s\n",descr ? descr : fname);
mgl_printf(fp, gz, "%%%%CreationDate: %s\n",ctime(&now));
const std::string loc = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C");\r
if(!add) { Clf(); Txt.clear(); }\r
else { ClfZB(); npnt=Pnt.size(); nglf=Glf.size(); }\r
+ LightScale(&B);\r
#if MGL_HAVE_PTHREAD\r
pthread_mutex_lock(&mutexGlf);\r
pthread_mutex_lock(&mutexPnt);\r
//-----------------------------------------------------------------------------\r
int mglFitPnts=100; ///< Number of output points in fitting\r
char mglFitRes[1024]; ///< Last fitted formula\r
+mreal mglFitChi=NAN; ///< Chi value for last fitted formula\r
+//-----------------------------------------------------------------------------\r
+mreal MGL_EXPORT mgl_get_fit_chi() { return mglFitChi; }\r
+mreal MGL_EXPORT mgl_get_fit_chi_() { return mglFitChi; }\r
//-----------------------------------------------------------------------------\r
void MGL_EXPORT mgl_puts_fit(HMGL gr, double x, double y, double z, const char *pre, const char *font, double size)\r
{\r
mglData res = mglFormulaCalc(fd->eq, list);\r
#pragma omp parallel for\r
for(long i=0;i<fd->n;i++)\r
- gsl_vector_set (f, i, (res.a[i] - fd->a[i])/fd->s[i]);\r
+ {\r
+ mreal aa = fd->a[i], ss = fd->s[i];\r
+ if(mgl_isnum(aa) && ss==ss && ss!=0)\r
+ gsl_vector_set (f, i, (res.a[i] - aa)/ss);\r
+ else gsl_vector_set (f, i, 0);\r
+ }\r
delete []var;\r
return GSL_SUCCESS;\r
}\r
var[j].Fill(gsl_vector_get(x,j));\r
#pragma omp parallel for\r
for(long i=0;i<fd->n;i++)\r
- gsl_matrix_set (J, i, j, dif.a[i]/fd->s[i]);\r
+ {\r
+ mreal aa = fd->a[i], ss = fd->s[i];\r
+ if(mgl_isnum(aa) && ss==ss && ss!=0)\r
+ gsl_matrix_set (J, i, j, dif.a[i]/ss);\r
+ else gsl_matrix_set (J, i, j, 0);\r
+ }\r
}\r
delete []var;\r
return GSL_SUCCESS;\r
mglData res = mglFormulaCalc(fd->eq, list);\r
#pragma omp parallel for\r
for(long i=0;i<fd->n;i++)\r
- gsl_vector_set (f, i, (res.a[i] - fd->a[i])/fd->s[i]);\r
+ {\r
+ mreal aa = fd->a[i], ss = fd->s[i];\r
+ if(mgl_isnum(aa) && ss==ss && ss!=0)\r
+ gsl_vector_set (f, i, (res.a[i] - aa)/ss);\r
+ else gsl_vector_set (f, i, 0);\r
+ }\r
const mreal eps = 1e-5;\r
for(long j=0;j<fd->m;j++)\r
{\r
var[j].Fill(gsl_vector_get(x,j));\r
#pragma omp parallel for\r
for(long i=0;i<fd->n;i++)\r
- gsl_matrix_set (J, i, j, dif.a[i]/fd->s[i]);\r
+ {\r
+ mreal aa = fd->a[i], ss = fd->s[i];\r
+ if(mgl_isnum(aa) && ss==ss && ss!=0)\r
+ gsl_matrix_set (J, i, j, dif.a[i]/ss);\r
+ else gsl_matrix_set (J, i, j, 0);\r
+ }\r
}\r
delete []var;\r
return GSL_SUCCESS;\r
void mglPrepareFitEq(mglBase *gr,mreal chi, const char *eq, const char *var, mreal *par)\r
{\r
char buf[32]="";\r
+ mglFitChi = chi;\r
snprintf(mglFitRes,1024,"chi=%g",chi);\r
size_t i,k,len=strlen(var);\r
for(i=0;i<len;i++)\r
{ gr->SetWarn(mglWarnNull,"Fit[S]"); return 0; }\r
\r
mglData x(xx), y(yy), s(ss); x.s=L"x";\r
+ long mm = yy->GetNy()*yy->GetNz();\r
+#pragma omp parallel for\r
+ for(long i=0;i<m;i++) if(mgl_isnan(x.a[i]))\r
+ for(long j=0;j<mm;j++) y.a[i+m*j] = NAN;\r
mglFitData fd;\r
fd.n = m; fd.x = &x; fd.y = 0;\r
fd.z = 0; fd.a = y.a; fd.s = s.a;\r
{ gr->SetWarn(mglWarnNull,"Fit[S]"); return 0; }\r
\r
mglData x(m, n), y(m, n), z(zz), s(ss); x.s=L"x"; y.s=L"y";\r
+ long nz = zz->GetNz(), mm = n*m;\r
#pragma omp parallel for collapse(2)\r
for(long i=0;i<m;i++) for(long j=0;j<n;j++)\r
{\r
- x.a[i+m*j] = GetX(xx,i,j,0).x;\r
- y.a[i+m*j] = GetY(yy,i,j,0).x;\r
+ register long i0 = i+m*j;\r
+ x.a[i0] = GetX(xx,i,j,0).x;\r
+ y.a[i0] = GetY(yy,i,j,0).x;\r
+ if(mgl_isnan(x.a[i0]) || mgl_isnan(y.a[i0]))\r
+ for(long k=0;k<nz;k++) z.a[i0+mm*k] = NAN;\r
}\r
mglFitData fd;\r
fd.n = m*n; fd.x = &x; fd.y = &y;\r
\r
mglData in(fd.m), *fit=new mglData(nn, nn, zz->GetNz());\r
mreal res = -1;\r
- for(long i=0;i<zz->GetNz();i++)\r
+ for(long i=0;i<nz;i++)\r
{\r
if(ini && ini->nx>=fd.m) in.Set(ini->a,fd.m);\r
else in.Fill(0.,0);\r
x.a[i0] = GetX(xx,i,j,k).x;\r
y.a[i0] = GetY(yy,i,j,k).x;\r
z.a[i0] = GetZ(zz,i,j,k).x;\r
+ if(mgl_isnan(x.a[i0]) || mgl_isnan(y.a[i0]) || mgl_isnan(z.a[i0])) a.a[i0] = NAN;\r
}\r
mglFitData fd;\r
fd.n = m*n*l; fd.x = &x; fd.y = &y;\r
\r
#include "mgl2/base.h"\r
#include "mgl2/font.h"\r
+#include "def_font.cpp"\r
//-----------------------------------------------------------------------------\r
-extern unsigned mgl_numg, mgl_cur;\r
-extern float mgl_fact;\r
-extern long mgl_gen_fnt[516][6];\r
-extern short mgl_buf_fnt[246080];\r
extern mglTeXsymb mgl_tex_symb[];\r
extern long mgl_tex_num;\r
//mglFont mglDefFont("nofont");\r
void mglFont::main_copy()\r
{\r
#pragma omp parallel for\r
- for(size_t i=0;i<glyphs.size();i++)\r
+ for(long i=0;i<long(glyphs.size());i++)\r
{\r
mglGlyphDescr &g = glyphs[i];\r
g.numl[1] = g.numl[2] = g.numl[3] = g.numl[0];\r
return true;\r
}\r
//-----------------------------------------------------------------------------\r
-//extern std::string mglGlobalMess; ///< Buffer for receiving global messages\r
bool mglFont::Load(const char *base, const char *path)\r
{\r
// base = 0;\r
path = buf; buf[i]=0; base = buf+i+1;\r
}\r
}\r
- Clear(); // first clear old\r
+ Clear(); // first clear old\r
\r
snprintf(str,256,"%s%c%s.vfm",path,sep,base?base:"");\r
std::vector<short> norm, bold, ital, both;\r
if(!(base && *base) || !read_main(str,norm))\r
{\r
-// mglGlobalMess += "Load built-in font.\n";\r
read_def(); setlocale(LC_NUMERIC,loc.c_str());\r
if(buf) delete []buf; return true;\r
}\r
for(long i=0;i<GetNumGlyph();i++) if(glyphs[i].ln[1]<0)\r
{ glyphs[i].ln[1] = cur-1-glyphs[i].ln[1]; glyphs[i].tr[1] = cur-1-glyphs[i].tr[1]; }\r
#pragma omp parallel for\r
- for(size_t i=0;i<ex_b.size();i++) if(ex_b[i].ln[1]<0)\r
+ for(long i=0;i<long(ex_b.size());i++) if(ex_b[i].ln[1]<0)\r
{\r
mglGlyphDescr &g = ex_b[i];\r
g.ln[0] = g.ln[1] = g.ln[2] = g.ln[3] = cur-1-g.ln[1];\r
for(long i=0;i<GetNumGlyph();i++) if(glyphs[i].ln[2]<0)\r
{ glyphs[i].ln[2] = cur-1-glyphs[i].ln[2]; glyphs[i].tr[2] = cur-1-glyphs[i].tr[2]; }\r
#pragma omp parallel for\r
- for(size_t i=0;i<ex_i.size();i++) if(ex_i[i].ln[2]<0)\r
+ for(long i=0;i<long(ex_i.size());i++) if(ex_i[i].ln[2]<0)\r
{\r
mglGlyphDescr &g = ex_i[i];\r
g.ln[0] = g.ln[1] = g.ln[2] = g.ln[3] = cur-1-g.ln[2];\r
for(long i=0;i<GetNumGlyph();i++) if(glyphs[i].ln[3]<0)\r
{ glyphs[i].ln[3] = cur-1-glyphs[i].ln[3]; glyphs[i].tr[3] = cur-1-glyphs[i].tr[3]; }\r
#pragma omp parallel for\r
- for(size_t i=0;i<ex_bi.size();i++) if(ex_bi[i].ln[3]<0)\r
+ for(long i=0;i<long(ex_bi.size());i++) if(ex_bi[i].ln[3]<0)\r
{\r
mglGlyphDescr &g = ex_bi[i];\r
g.ln[0] = g.ln[1] = g.ln[2] = g.ln[3] = cur-1-g.ln[3];\r
Load(MGL_DEF_FONT_NAME,0);\r
}\r
}\r
-mglFont::~mglFont() { Clear(); }\r
+mglFont::~mglFont() { if(Buf) delete []Buf; }\r
void mglFont::Restore() { Copy(&mglDefFont); }\r
//-----------------------------------------------------------------------------\r
void mglFont::Clear()\r
{\r
-#pragma omp critical(font)\r
+//#pragma omp critical(font)\r
{ if(Buf) delete []Buf; Buf=0; glyphs.clear(); }\r
}\r
//-----------------------------------------------------------------------------\r
for(long i=0;i<40;i++) par[i]=L"";
Cmd = mgls_base_cmd;
- AllowSetSize=setsize; AllowFileIO=true;
+ AllowSetSize=setsize; AllowFileIO=true; AllowDllCall=true;
Once = true;
fval = new mglData[40];
+#if MGL_HAVE_LTDL
+ lt_dlinit();
+#endif
}
//-----------------------------------------------------------------------------
mglParser::~mglParser()
{
DeleteAll(); delete []fval;
- if(Cmd && Cmd!=mgls_base_cmd) delete []Cmd;
+#if MGL_HAVE_LTDL
+ lt_dlexit();
+#endif
}
//-----------------------------------------------------------------------------
void mglParser::DeleteAll()
for(size_t i=0;i<NumList.size();i++)
if(NumList[i]) delete NumList[i];
NumList.clear();
+ if(Cmd && Cmd!=mgls_base_cmd)
+ { delete []Cmd; Cmd = mgls_base_cmd; }
+#if MGL_HAVE_LTDL
+ for(size_t i=0;i<DllOpened.size();i++)
+ lt_dlclose(DllOpened[i]);
+ DllOpened.clear();
+#endif
}
//-----------------------------------------------------------------------------
void mglParser::AddParam(int n, const char *str)
n = FlowExec(gr, arg[0].c_str(),k-1,a);
if(n) { delete []a; return n-1; }
if(skip()) { delete []a; return 0; }
+ if(!arg[0].compare(L"load"))
+ {
+ int n = a[0].type==1?0:1;
+ a[0].s.assign(a[0].w.begin(),a[0].w.end());
+ if(!n) mgl_parser_load(this,a[0].s.c_str());
+ delete []a; return n;
+ }
if(!arg[0].compare(L"define"))
{
if(k==3)
void MGL_EXPORT mgl_parser_stop(HMPR p) { p->Stop = true; }
void MGL_EXPORT mgl_parser_allow_setsize(HMPR p, int a) { p->AllowSetSize= a; }
void MGL_EXPORT mgl_parser_allow_file_io(HMPR p, int a) { p->AllowFileIO = a; }
+void MGL_EXPORT mgl_parser_allow_dll_call(HMPR p, int a){ p->AllowDllCall = a; }
//-----------------------------------------------------------------------------
#define _PR_ ((mglParser *)(*p))
uintptr_t MGL_EXPORT mgl_create_parser_() { return uintptr_t(new mglParser); }
void MGL_EXPORT mgl_parser_restore_once_(uintptr_t* p) { _PR_->RestoreOnce(); }
void MGL_EXPORT mgl_parser_allow_setsize_(uintptr_t* p, int *a) { _PR_->AllowSetSize= *a; }
void MGL_EXPORT mgl_parser_allow_file_io_(uintptr_t* p, int *a) { _PR_->AllowFileIO = *a; }
+void MGL_EXPORT mgl_parser_allow_dll_call_(uintptr_t* p, int *a){ _PR_->AllowDllCall= *a; }
void MGL_EXPORT mgl_parser_stop_(uintptr_t* p) { _PR_->Stop = true; }
//-----------------------------------------------------------------------------
long MGL_EXPORT mgl_use_parser(HMPR pr, int inc)
void MGL_EXPORT mgl_parser_del_all(HMPR p) { p->DeleteAll(); }
void MGL_EXPORT mgl_parser_del_all_(uintptr_t *p) { _PR_->DeleteAll(); }
//---------------------------------------------------------------------------
+void MGL_EXPORT mgl_parser_load(HMPR pr, const char *so_name)
+{
+ if(!pr->AllowDllCall) return;
+#if MGL_HAVE_LTDL
+ lt_dlhandle so = lt_dlopen(so_name);
+ if(!so) return;
+ const mglCommand *cmd = (const mglCommand *)lt_dlsym(so,"mgl_cmd_extra");
+ if(!cmd) return;
+
+ int i, mp, mc, exist=true;
+ // determine the number of symbols
+ for(i=0;pr->Cmd[i].name[0];i++){}; mp = i;
+ for(i=0;cmd[i].name[0];i++)
+ if(!pr->FindCommand(cmd[i].name)) exist=false;
+ if(exist) { lt_dlclose(so); return; } // all commands already presents
+ else pr->DllOpened.push_back(so);
+ mc = i;
+ mglCommand *buf = new mglCommand[mp+mc+1];
+ memcpy(buf, pr->Cmd, mp*sizeof(mglCommand));
+ memcpy(buf+mp, cmd, (mc+1)*sizeof(mglCommand));
+ qsort(buf, mp+mc, sizeof(mglCommand), mgl_cmd_cmp);
+ if(pr->Cmd!=mgls_base_cmd) delete []pr->Cmd;
+ pr->Cmd = buf;
+#endif
+}
+void MGL_EXPORT mgl_parser_load_(uintptr_t *p, const char *dll_name,int l)
+{ char *s=new char[l+1]; memcpy(s,dll_name,l); s[l]=0;
+ mgl_parser_load(_PR_, s); delete []s; }
+//---------------------------------------------------------------------------
for(long i=0;i<s;i++) memcpy(GB+4*i,BDef,4);\r
InPlot(0,1,0,1,false);\r
if(clf || (Quality&4)) Clf();\r
- else\r
+ else // NOTE: no scaling for text (a bit complicated)\r
{\r
+ long n = long(Pnt.size());\r
#pragma omp parallel for\r
- for(long i=0;i<long(Pnt.size());i++)\r
+ for(long i=0;i<n;i++)\r
{\r
mglPnt &q = Pnt[i];\r
q.x*=dx; q.y*=dy; q.z*=dz;\r
q.xx*=dx; q.yy*=dy; q.zz*=dz;\r
- q.u*=dx; q.v*=dy; q.w*=dz;\r
+ if(mgl_isnum(q.w))\r
+ { q.u*=dx; q.v*=dy; q.w*=dz; }\r
+ }\r
+ for(size_t k=0;k<DrwDat.size();k++) // scale frames too\r
+ {\r
+ mglStack<mglPnt> &pnt = DrwDat[k].Pnt;\r
+ n = long(pnt.size());\r
+#pragma omp parallel for\r
+ for(long i=0;i<n;i++)\r
+ {\r
+ mglPnt &q = pnt[i];\r
+ q.x*=dx; q.y*=dy; q.z*=dz;\r
+ q.xx*=dx; q.yy*=dy; q.zz*=dz;\r
+ if(mgl_isnum(q.w))\r
+ { q.u*=dx; q.v*=dy; q.w*=dz; }\r
+ }\r
}\r
ClfZB(); Finish();\r
}\r
//-----------------------------------------------------------------------------\r
long mglCanvas::ProjScale(int nf, long id, bool text)\r
{\r
- mglPoint pp = GetPntP(id), nn = GetPntN(id), q, p, n, u;\r
+ const mglPnt &pi = Pnt[id];\r
+ mglPoint pp = mglPoint(pi.x,pi.y,pi.z), nn = mglPoint(pi.u,pi.v,pi.w), p, n;\r
if(mgl_isnan(pp.x)) return -1;\r
- q = RestorePnt(pp)/(2*B.pf);\r
- u = RestorePnt(nn,true); u.Normalize();\r
mreal w=B1.b[0]/2, h=B1.b[4]/2, d=B1.b[8]/2, xx=B1.x-w/2, yy=B1.y-h/2;\r
- if(nf==0)\r
- { p.x = xx + q.x*w; p.y = yy + q.y*h; p.z = B1.z + q.z*d; n = u; }\r
- else if(nf==1)\r
- { p.x = xx + q.x*w; p.y = yy+h + q.z*h; p.z = B1.z + q.y*d; n = mglPoint(u.x,u.z,u.y); }\r
- else if(nf==2)\r
- { p.x = xx+w + q.z*w; p.y = yy + q.y*h; p.z = B1.z+ q.x*d; n = mglPoint(u.z,u.y,u.x); }\r
+ if(!pi.sub)\r
+ {\r
+ mglPoint q = RestorePnt(pp)/(2*B.pf);\r
+ mglPoint u = RestorePnt(nn,true); u.Normalize();\r
+ if(nf==0)\r
+ { p.x = xx + q.x*w; p.y = yy + q.y*h; p.z = B1.z + q.z*d; n = u; }\r
+ else if(nf==1)\r
+ { p.x = xx + q.x*w; p.y = yy+h + q.z*h; p.z = B1.z - q.y*d; n = mglPoint(u.x,u.z,-u.y); }\r
+ else if(nf==2)\r
+ { p.x = xx+w + q.z*w; p.y = yy + q.y*h; p.z = B1.z - q.x*d; n = mglPoint(u.z,u.y,-u.x); }\r
+ else\r
+ {\r
+ const mreal *b=B.b; n = nn;\r
+ p.x = xx+w + q.x*b[0]/2 + q.y*b[1]/2 + q.z*b[2]/2;\r
+ p.y = yy+h + q.x*b[3]/2 + q.y*b[4]/2 + q.z*b[5]/2;\r
+ p.z = B.z + q.x*b[6]/2 + q.y*b[7]/2 + q.z*b[8]/2;\r
+ }\r
+ }\r
else\r
{\r
- const mreal *b=B.b; n = nn;\r
- p.x = xx+w + q.x*b[0]/2 + q.y*b[1]/2 + q.z*b[2]/2;\r
- p.y = yy+h + q.x*b[3]/2 + q.y*b[4]/2 + q.z*b[5]/2;\r
- p.z = B.z + q.x*b[6]/2 + q.y*b[7]/2 + q.z*b[8]/2;\r
+ p.x = pi.x/2 + w*(nf/2);\r
+ p.y = pi.y/2 + h*(nf%2);\r
+ p.z = pi.z; n=nn;\r
}\r
- return CopyProj(id,p,text?n:nn);\r
+ return CopyProj(id,p,text?n:nn,pi.sub);\r
}\r
//-----------------------------------------------------------------------------\r
void mglCanvas::LightScale(const mglMatrix *M)\r
memcpy(GB,G4,4*Width*Height);\r
}\r
//-----------------------------------------------------------------------------\r
-bool MGL_NO_EXPORT mgl_read_image(unsigned char *g, int w, int h, const char *fname);\r
+bool MGL_NO_EXPORT mgl_read_image(unsigned char **g, int &w, int &h, const char *fname);\r
void mglCanvas::LoadBackground(const char *fname, double alpha)\r
{\r
- mgl_read_image(GB,Width,Height,fname);\r
+ mgl_read_image(&GB,Width,Height,fname);\r
if(alpha<1 && alpha>0)\r
#pragma omp parallel for\r
for(long i=0;i<Width*Height;i++) GB[4*i+3] = (unsigned char)(GB[4*i+3]*alpha);\r
s = sqrt(s);\r
register float qu = d3.x*yy - d3.y*xx + dd + s;\r
register float qv = d3.y*xx - d3.x*yy + dd + s;\r
- register float u = 2.f*(d2.y*xx - d2.x*yy)/qu; \r
+ register float u = 2.f*(d2.y*xx - d2.x*yy)/qu;\r
register float v = 2.f*(d1.x*yy - d1.y*xx)/qv;\r
if(u*(1.f-u)<0.f || v*(1.f-v)<0.f) // first root bad\r
{\r
FILE *fp=fopen(tname,"wt");\r
fputs("Can not produce PDF file, MathGL compiled without PDF output support\n", fp);\r
fclose(fp);\r
- mglGlobalMess += "PDF support was disabled. Please, enable it and rebuild MathGL.\n";\r
+ mgl_set_global_warn("PDF support was disabled. Please, enable it and rebuild MathGL.");\r
#endif // MGL_HAVE_PDF\r
}\r
delete []tname;\r
mgl_tablew(_GR_, *x, *y, _DA_(val),s,f, o);\r
delete []o; delete []s; delete []f; }\r
//-----------------------------------------------------------------------------\r
+//\r
+// Logo series\r
+//\r
+//-----------------------------------------------------------------------------\r
+void MGL_EXPORT mgl_logo(HMGL gr, long w, long h, const unsigned char *rgba, int smooth, const char *opt)\r
+{\r
+ if(w<1 || h<1 || !rgba) { gr->SetWarn(mglWarnLow,"Logo"); return; }\r
+ static int cgid=1; gr->StartGroup("Logo",cgid++);\r
+ mreal z = gr->SaveState(opt);\r
+ if(mgl_isnan(z)) z = gr->Min.z;\r
+ mreal x1 = gr->Min.x, y1 = gr->Min.y, dx, dy;\r
+ if(!smooth || w<2 || h<2)\r
+ {\r
+ dx = (gr->Max.x-x1)/w; dy = (gr->Max.y-y1)/h;\r
+ gr->Reserve(4*(w+1)*(h+1));\r
+ for(long j=0;j<h;j++) for(long i=0;i<w;i++)\r
+ {\r
+ long i0 = 4*(w-1-i+w*j), k1,k2,k3,k4;\r
+ mglColor c(rgba[i0]/255.,rgba[i0+1]/255.,rgba[i0+2]/255.);\r
+ k1 = gr->AddPnt(mglPoint(x1+dx*i,y1+dy*j,z),0); gr->SetRGBA(k1,c);\r
+ k2 = gr->AddPnt(mglPoint(x1+dx*(i+1),y1+dy*j,z),0); gr->SetRGBA(k2,c);\r
+ k3 = gr->AddPnt(mglPoint(x1+dx*i,y1+dy*(j+1),z),0); gr->SetRGBA(k3,c);\r
+ k4 = gr->AddPnt(mglPoint(x1+dx*(i+1),y1+dy*(j+1),z),0); gr->SetRGBA(k4,c);\r
+ gr->quad_plot(k1,k2,k3,k4);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ dx = (gr->Max.x-x1)/(w-1); dy = (gr->Max.y-y1)/(h-1);\r
+ gr->Reserve(w*h);\r
+ long *pos = new long[w*h];\r
+ for(long j=0;j<h;j++) for(long i=0;i<w;i++)\r
+ {\r
+ long i0 = 4*(w-1-i+w*j), i1 = i+w*j;\r
+ pos[i1] = gr->AddPnt(mglPoint(x1+dx*i,y1+dy*j,z),0);\r
+ gr->SetRGBA(pos[i1],mglColor(rgba[i0]/255.,rgba[i0+1]/255.,rgba[i0+2]/255.));\r
+ }\r
+ for(long j=0;j<h-1;j++) for(long i=0;i<w-1;i++)\r
+ {\r
+ long i1 = i+w*j;\r
+ gr->quad_plot(pos[i1],pos[i1+1],pos[i1+w],pos[i1+1+w]);\r
+ }\r
+ delete []pos;\r
+ }\r
+ gr->EndGroup();\r
+}\r
+//-----------------------------------------------------------------------------\r
+bool MGL_NO_EXPORT mgl_read_image(unsigned char **g, int &w, int &h, const char *fname);\r
+void MGL_EXPORT mgl_logo_file(HMGL gr, const char *fname, int smooth, const char *opt)\r
+{\r
+ unsigned char *g = 0;\r
+ int w=0, h=0;\r
+ if(!mgl_read_image(&g,w,h,fname)) return;\r
+ mgl_logo(gr,w,h,g,smooth,opt);\r
+ delete []g;\r
+}\r
+//-----------------------------------------------------------------------------\r
+void MGL_EXPORT mgl_logo_file_(uintptr_t *gr, const char *fname, int *smooth, const char *opt,int l,int n)\r
+{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0;\r
+ char *f=new char[n+1]; memcpy(f,opt,n); f[n]=0;\r
+ mgl_logo_file(_GR_,s,*smooth,f); delete []s; delete []f; }\r
+//-----------------------------------------------------------------------------\r
const std::string loc = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C");\r
// use frames for quickly redrawing while adding/changing primitives\r
if(mgl_is_frames(this)) NewFrame();\r
- \r
+\r
int n = DrawFunc ? DrawFunc(this,FuncPar) : 0;\r
if(n<NumFig && n>=0) NumFig = n;\r
- \r
+\r
if(mgl_is_frames(this)) EndFrame();\r
setlocale(LC_NUMERIC, loc.c_str());\r
Update();\r
}\r
}\r
//-----------------------------------------------------------------------------\r
+void MGL_EXPORT mgl_wnd_set_func(HMGL gr, int (*draw)(HMGL gr, void *p), void *par, void (*reload)(void *p))\r
+{ mglCanvasWnd *g = dynamic_cast<mglCanvasWnd *>(gr); if(g) g->SetDrawFunc(draw, par, reload); }\r
void MGL_EXPORT mgl_wnd_toggle_alpha(HMGL gr)\r
{ mglCanvasWnd *g = dynamic_cast<mglCanvasWnd *>(gr); if(g) g->ToggleAlpha(); }\r
void MGL_EXPORT mgl_wnd_toggle_light(HMGL gr)\r
@item
@strong{Все функции имеют ``упрощенный'' и ``продвинутый'' варианты.} Сделано опять из-за удобства. В ``упрощенном'' варианте для построения графика нужны только один-два массив(а) данных, которые автоматически равнораспределяются в заданном диапазоне осей координат. В ``продвинутой'' версии можно не только указать явно диапазон построения графика, но и задать его параметрически. Последнее позволяет легко строить довольно сложные кривые и поверхности. В обоих вариантах функций порядок аргументов стандартен: сначала идут массивы данных, потом необязательный строковый параметр стиля графика, а далее строка опций для более точной настройки графика.
@item
-@strong{Все данные передаются через экземпляры класса mglData(A).} Такой подход позволяет избежать ошибок при работе с памятью и единообразно передавать данные разных типов (mreal, double, данные из файла, заполненных пользователем и пр.) в функции рисования.
+@strong{Все данные передаются через экземпляры класса mglData(A).} Такой подход позволяет избежать ошибок при работе с памятью и единообразно передавать данные разных типов (float, double, данные из файла, заполненных пользователем и пр.) в функции рисования.
@item
@strong{Все элементы рисунков векторные.} Изначально библиотека MathGL была ориентированна на работу с научными данными, которые по своей природе векторные (линии, грани, матрицы и т.д.). Поэтому векторность используется во всех рисунках! Причем иногда даже в ущерб производительности (например, при выводе шрифтов). Помимо всего прочего, векторность позволяет легко масштабировать рисунок -- измените размер картинки в 2 раза, и рисунок пропорционально растянется.
@item
@anchor{version}
@deftypefn {MGL command} {} version 'ver'
@ifclear UDAV
+@deftypefnx {Method on @code{mglGraph}} @code{bool} CheckVersion (@code{const char *}ver) static
@deftypefnx {C function} @code{int} mgl_check_version (@code{const char *}ver)
@end ifclear
Return nonzero if MathGL version is appropriate for required by @var{ver}, i.e. if major version is the same and minor version is greater or equal to one in @var{ver}.
Functions and variables in this group influences on overall graphics appearance. So all of them should be placed @emph{before} any actual plotting function calls.
+@anchor{reset}
+@deftypefn {MGL command} {} reset
@ifclear UDAV
-@deftypefn {Method on @code{mglGraph}} @code{void} DefaultPlotParam ()
+@deftypefnx {Method on @code{mglGraph}} @code{void} DefaultPlotParam ()
@deftypefnx {C function} @code{void} mgl_set_def_param (@code{HMGL} gr)
-Restore initial values for all of parameters.
-@end deftypefn
@end ifclear
+Restore initial values for all of parameters and clear the image.
+@end deftypefn
@menu
* Transparency::
Restore font data to default typeface.
@end deftypefn
-@deftypefn {C function} @code{void} mgl_def_font (@code{const char *}name, @code{const char *}path)
+@deftypefn {Method on @code{mglGraph}} @code{void} SetDefFont (@code{const char *}name, @code{const char *}path=@code{""}) static
+@deftypefnx {C function} @code{void} mgl_def_font (@code{const char *}name, @code{const char *}path)
Load default font typeface (for all newly created HMGL/mglGraph objects) from @var{path}/@var{name}.
@end deftypefn
@end table
@end deftypefn
-@deftypefn {C function} @code{void} mgl_suppress_warn (@code{int} state)
+@deftypefn {Method on @code{mglGraph}} @code{void} SuppressWarn (@code{bool} state) static
+@deftypefnx {C function} @code{void} mgl_suppress_warn (@code{int} state)
Disable printing warnings to @code{stderr} if @var{state} is nonzero.
@end deftypefn
+@deftypefn {Method on @code{mglGraph}} @code{void} SetGlobalWarn (@code{const char *}info) static
+@deftypefnx {C function} @code{void} mgl_set_global_warn (@code{const char *}info)
+Set warning message @var{info} for global scope.
+@end deftypefn
+
+@deftypefn {Method on @code{mglGraph}} @code{const char *} GlobalWarn () static
+@deftypefnx {C function} @code{const char *} mgl_get_global_warn ()
+Get warning message(s) for global scope.
+@end deftypefn
+
@end ifclear
Correspondingly, Quaternary plot is plot for 4 dependent coordinates @var{a}, @var{b}, @var{c} and @var{d} so that @var{a}+@var{b}+@var{c}+@var{d}=1. MathGL uses only 3 independent coordinates @var{a}=x, @var{b}=y and @var{d}=z since it is enough to plot everything.
-Projections can be obtained by adding value @code{4} to @var{tern} argument. So, that @var{tern}=@code{4} will draw projections in Cartesian coordinates, @var{tern}=@code{5} will draw projections in Ternary coordinates, @var{tern}=@code{6} will draw projections in Quaternary coordinates.
+Projections can be obtained by adding value @code{4} to @var{tern} argument. So, that @var{tern}=@code{4} will draw projections in Cartesian coordinates, @var{tern}=@code{5} will draw projections in Ternary coordinates, @var{tern}=@code{6} will draw projections in Quaternary coordinates. If you add @code{8} instead of @code{4} then all text labels will not be printed on projections.
Use @code{Ternary(0)} for returning to usual axis. @sref{Ternary axis} @sref{Axis projection}
@end deftypefn
@end itemize
@end deftypefn
+
+@anchor{logo}
+@deftypefn {MGL command} {} logo 'fname' [smooth=off]
+@ifclear UDAV
+@deftypefnx {Method on @code{mglGraph}} @code{void} Logo (@code{const char *}fname, @code{bool} smooth=@code{false}, @code{const char *}opt=@code{""})
+@deftypefnx {Method on @code{mglGraph}} @code{void} Logo (@code{long} w, @code{long} h, @code{const unsigned char *}rgba, @code{bool} smooth=@code{false}, @code{const char *}opt=@code{""})
+@deftypefnx {C function only} @code{void} mgl_logo (@code{HMGL} gr, @code{long} w, @code{long} h, @code{const unsigned char *}rgba, @code{bool} smooth, @code{const char *}opt)
+@deftypefnx {C function} @code{void} mgl_logo_file (@code{HMGL} gr, @code{const char *}fname, @code{bool} smooth, @code{const char *}opt)
+@end ifclear
+Draw bitmap (logo) along whole axis range, which can be changed by @ref{Command options}. Bitmap can be loaded from file or specified as RGBA values for pixels. Parameter @var{smooth} set to draw bitmap without or with color interpolation.
+@end deftypefn
+
@c ##################################################################
@external{}
@node Text printing, Axis and Colorbar, Primitives, MathGL core
@deftypefnx {Fortran subroutine} @code{} mgl_get_fit (@code{long} gr, @code{char *}out, @code{int} len)
Get last fitted formula with found coefficients (as numbers).
@end deftypefn
+
+@deftypefn {Method on @code{mglGraph}} @code{mreal} GetFitChi ()
+@deftypefnx {C function only} @code{mreal} mgl_get_fit_chi ()
+Get \chi for last fitted formula.
+@end deftypefn
@end ifclear
Некоторые возможности MathGL доступны только в новых версиях библиотеки. Для проверки текущей версии MathGL можно использовать следующую функцию.
@anchor{version}
-@deftypefn {MGL command} {} version 'ver'
+@deftypefn {Команда MGL} {} version 'ver'
@ifclear UDAV
-@deftypefnx {C function} @code{int} mgl_check_version (@code{const char *}ver)
+@deftypefnx {Метод класса @code{mglGraph}} @code{bool} CheckVersion (@code{const char *}ver) static
+@deftypefnx {Функция С} @code{int} mgl_check_version (@code{const char *}ver)
@end ifclear
Возвращает ненулевое значение если версия MathGL подходит для требуемой в @var{ver}, т.е. если номер основной версии совпадает и "подверсия" больше или равна указанной в @var{ver}.
@end deftypefn
Функции и переменные в этой группе влияют на вид всего рисунка. Соответственно они должны располагаться @emph{перед} вызовом функций непосредственно рисующих графики.
+@anchor{reset}
+@deftypefn {Команда MGL} {} reset
@ifclear UDAV
-@deftypefn {Метод класса @code{mglGraph}} @code{void} DefaultPlotParam ()
+@deftypefnx {Метод класса @code{mglGraph}} @code{void} DefaultPlotParam ()
@deftypefnx {Функция С} @code{void} mgl_set_def_param (@code{HMGL} gr)
-Устанавливает все настройки по умолчанию.
-@end deftypefn
@end ifclear
+Устанавливает все настройки по умолчанию и очищает рисунок.
+@end deftypefn
@menu
* Transparency::
Восстанавливает начертание шрифта по умолчанию.
@end deftypefn
-@deftypefn {Функция С} @code{void} mgl_def_font (@code{const char *}name, @code{const char *}path)
+@deftypefn {Метод класса @code{mglGraph}} @code{void} SetDefFont (@code{const char *}name, @code{const char *}path=@code{""}) static
+@deftypefnx {Функция С} @code{void} mgl_def_font (@code{const char *}name, @code{const char *}path)
Загружает начертание шрифта по умолчанию (для всех вновь создаваемых HMGL/mglGraph объектов) из файла @var{path}/@var{name}.
@end deftypefn
@end table
@end deftypefn
-@deftypefn {Функция С} @code{void} mgl_suppress_warn (@code{int} state)
+@deftypefn {Метод класса @code{mglGraph}} @code{void} SuppressWarn (@code{bool} state) static
+@deftypefnx {Функция С} @code{void} mgl_suppress_warn (@code{int} state)
Выключает вывод предупреждений в @code{stderr} если @var{state} не ноль.
@end deftypefn
+@deftypefn {Метод класса @code{mglGraph}} @code{void} SetGlobalWarn (@code{const char *}info) static
+@deftypefnx {Функция С} @code{void} mgl_set_global_warn (@code{const char *}info)
+Задает предупреждение @var{info}, не привязанное к конкретному объекту рисования.
+@end deftypefn
+
+@deftypefn {Метод класса @code{mglGraph}} @code{const char *} GlobalWarn () static
+@deftypefnx {Функция С} @code{const char *} mgl_get_global_warn ()
+Возвращает предупреждения, не привязанные к конкретному объекту рисования.
+@end deftypefn
+
@end ifclear
@cindex SetEventFunc
@deftypefn {Метод класса @code{mglGraph}} @code{void} Stop (@code{bool} stop=@code{true})
-@deftypefnx {C function only} @code{void} mgl_ask_stop (@code{HMGL} gr, @code{int} stop)
+@deftypefnx {Функция С only} @code{void} mgl_ask_stop (@code{HMGL} gr, @code{int} stop)
Просит остановить рисование если @var{stop} не ноль, иначе сбрасывает флаг остановки.
@end deftypefn
@deftypefn {Метод класса @code{mglGraph}} @code{bool} NeedStop ()
-@deftypefnx {C function only} @code{void} mgl_need_stop (@code{HMGL} gr)
+@deftypefnx {Функция С only} @code{void} mgl_need_stop (@code{HMGL} gr)
Возвращает @code{true} если рисование должно быть остановлено. Также запускает обработку всех отложенных событий в GUI. Пользователь должен вызывать эту функцию время от времени внутри долгих вычислений для плавности отклика GUI.
@end deftypefn
@deftypefn {Метод класса @code{mglGraph}} @code{bool} SetEventFunc (@code{void (*}func@code{)(void *)}, @code{void *}par=@code{NULL})
-@deftypefnx {C function only} @code{void} mgl_set_event_func (@code{HMGL} gr, @code{void (*}func@code{)(void *)}, @code{void *}par)
+@deftypefnx {Функция С only} @code{void} mgl_set_event_func (@code{HMGL} gr, @code{void (*}func@code{)(void *)}, @code{void *}par)
Задает функцию, которая будет вызвана для обработки событий в GUI библиотеке.
@end deftypefn
Соответственно Quaternary координаты -- 4 зависимые координаты @var{a}, @var{b}, @var{c} и @var{d}, такие что @var{a}+@var{b}+@var{c}+@var{d}=1. MathGL использует только 2 независимые координаты @var{a}=x, @var{b}=y и @var{d}=z поскольку их достаточно для построения всех графиков.
-Проекции строятся если к переменной @var{tern} добавить число @code{4}. Так что @var{tern}=@code{4} нарисует проекции в декартовых координатах, @var{tern}=@code{5} нарисует проекции в треугольных координатах, @var{tern}=@code{6} нарисует проекции в пирамидальных координатах.
+Проекции строятся если к переменной @var{tern} добавить число @code{4}. Так что @var{tern}=@code{4} нарисует проекции в декартовых координатах, @var{tern}=@code{5} нарисует проекции в треугольных координатах, @var{tern}=@code{6} нарисует проекции в пирамидальных координатах. Если добавить @code{8} вместо @code{4}, то текст не будет выводиться на проекциях.
Используйте @code{Ternary(0)} для возвращения к привычным координатам. @sref{Ternary axis} @sref{Axis projection}
@end deftypefn
@end deftypefn
@anchor{arc}
-@deftypefn {MGL command} {} arc @code{x0 y0 x1 y1 a} ['col'='r']
-@deftypefnx {MGL command} {} arc @code{x0 y0 z0 x1 y1 a} ['col'='r']
-@deftypefnx {MGL command} {} arc @code{x0 y0 z0 xa ya za x1 y1 z1 a} ['col'='r']
+@deftypefn {Команда MGL} {} arc @code{x0 y0 x1 y1 a} ['col'='r']
+@deftypefnx {Команда MGL} {} arc @code{x0 y0 z0 x1 y1 a} ['col'='r']
+@deftypefnx {Команда MGL} {} arc @code{x0 y0 z0 xa ya za x1 y1 z1 a} ['col'='r']
@ifclear UDAV
@deftypefnx {Метод класса @code{mglGraph}} @code{void} Arc (@code{mglPoint} p0, @code{mglPoint} p1, @code{mreal} a, @code{const char *}col=@code{"r"})
@deftypefnx {Метод класса @code{mglGraph}} @code{void} Arc (@code{mglPoint} p0, @code{mglPoint} pa, @code{mglPoint} p1, @code{mreal} a, @code{const char *}col=@code{"r"})
-@deftypefnx {C function} @code{void} mgl_arc (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} x1, @code{mreal} y1, @code{mreal} a, @code{const char *}col)
-@deftypefnx {C function} @code{void} mgl_arc_ext (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} xa, @code{mreal} ya, @code{mreal} za, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} a, @code{const char *}col)
+@deftypefnx {Функция С} @code{void} mgl_arc (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} x1, @code{mreal} y1, @code{mreal} a, @code{const char *}col)
+@deftypefnx {Функция С} @code{void} mgl_arc_ext (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} xa, @code{mreal} ya, @code{mreal} za, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} a, @code{const char *}col)
@end ifclear
Рисует дугу вокруг оси @var{pa} (по умолчанию вокруг оси z @var{pa}=@{0,0,1@}) с центром в @var{p0}, начиная с точки @var{p1}. Параметр @var{a} задает угол дуги в градусах. Строка @var{col} задает цвет дуги и тип стрелок на краях.
@end deftypefn
@anchor{polygon}
-@deftypefn {MGL command} {} polygon @code{x0 y0 x1 y1 num} ['col'='r']
-@deftypefnx {MGL command} {} polygon @code{x0 y0 z0 x1 y1 z1 num} ['col'='r']
+@deftypefn {Команда MGL} {} polygon @code{x0 y0 x1 y1 num} ['col'='r']
+@deftypefnx {Команда MGL} {} polygon @code{x0 y0 z0 x1 y1 z1 num} ['col'='r']
@ifclear UDAV
@deftypefnx {Метод класса @code{mglGraph}} @code{void} Polygon (@code{mglPoint} p0, @code{mglPoint} p1, @code{int} num, @code{const char *}col=@code{"r"})
-@deftypefnx {C function} @code{void} mgl_polygon (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{int} num, @code{const char *}col)
+@deftypefnx {Функция С} @code{void} mgl_polygon (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{int} num, @code{const char *}col)
@end ifclear
Рисует правильный @var{num}-угольник с центром в @var{p0} с первой вершиной в @var{p1} цветом @var{col}. Если @var{col} содержит: @samp{#} то рисуется только граница, @samp{@@} то рисуется граница (вторым цветом из @var{col} или черными).
@c Если @var{col} содержит 3 цвета, то используется градиентная заливка.
@end deftypefn
+@anchor{logo}
+@deftypefn {Команда MGL} {} logo 'fname' [smooth=off]
+@ifclear UDAV
+@deftypefnx {Метод класса @code{mglGraph}} @code{void} Logo (@code{const char *}fname, @code{bool} smooth=@code{false}, @code{const char *}opt=@code{""})
+@deftypefnx {Метод класса @code{mglGraph}} @code{void} Logo (@code{long} w, @code{long} h, @code{const unsigned char *}rgba, @code{bool} smooth=@code{false}, @code{const char *}opt=@code{""})
+@deftypefnx {Функция С} @code{void} mgl_logo (@code{HMGL} gr, @code{long} w, @code{long} h, @code{const unsigned char *}rgba, @code{bool} smooth, @code{const char *}opt)
+@deftypefnx {Функция С} @code{void} mgl_logo_file (@code{HMGL} gr, @code{const char *}fname, @code{bool} smooth, @code{const char *}opt)
+@end ifclear
+Draw bitmap (logo) along whole axis range, which can be changed by @ref{Command options}. Bitmap can be loaded from file or specified as RGBA values for pixels. Parameter @var{smooth} set to draw bitmap without or with color interpolation.
+@end deftypefn
+
@c ##################################################################
@external{}
@node Text printing, Axis and Colorbar, Primitives, MathGL core
@deftypefnx {Fortran процедура} @code{} mgl_get_fit (@code{long} gr, @code{char *}out, @code{int} len)
Возвращает последнюю подобранную формулу с найденными коэффициентами.
@end deftypefn
+
+@deftypefn {Метод класса @code{mglGraph}} @code{mreal} GetFitChi ()
+@deftypefnx {Функция С} @code{mreal} mgl_get_fit_chi ()
+Возвращает величину \chi для последней подобранной формулы.
+@end deftypefn
@end ifclear
gr.FPlot("sin(pi*x)");
gr.WriteFrame("test.png");
@end verbatim
-in Octave will be as (you need first install MathGL package by command @code{octave:1> pkg install /usr/share/mathgl/octave/mathgl.tar.gz} from @code{sudo octave})
+in Octave will be as (you need first execute @code{mathgl;} in newer Octave versions)
+@c (install MathGL package by command @code{octave:1> pkg install /usr/share/mathgl/octave/mathgl.tar.gz} from @code{sudo octave})
@verbatim
gr = mglGraph();
gr.FPlot("sin(pi*x)");
gr.FPlot("sin(pi*x)");
gr.WriteFrame("test.png");
@end verbatim
-в Octave он будет почти тем же
+в Octave он будет почти тем же (в новых версиях надо предварительно выполнить @code{mathgl;})
@verbatim
gr = mglGraph();
gr.FPlot("sin(pi*x)");
@menu
* MGL definition::
* Program flow commands::
+* LaTeX package::
@ifclear UDAV
* mglParse class::
@end ifclear
@c ------------------------------------------------------------------
@external{}
-@ifclear UDAV
-@node Program flow commands, mglParse class, MGL definition, MGL scripts
-@end ifclear
-@ifset UDAV
-@node Program flow commands, , MGL definition, MGL scripts
-@end ifset
+@node Program flow commands, LaTeX package, MGL definition, MGL scripts
@section Program flow commands
@nav{}
@cindex call
@anchor{call}
-@deftypefn {MGL command} {} call 'fname' [ARG1 ARG2 ... ARG9]
+@deftypefn {MGL command} {} call 'funcname' [ARG1 ARG2 ... ARG9]
Executes function @var{fname} (or script if function is not found). Optional arguments will be passed to functions. See also @ref{func}.
@end deftypefn
@cindex func
@anchor{func}
-@deftypefn {MGL command} {} func 'fname' [narg=0]
+@deftypefn {MGL command} {} func 'funcname' [narg=0]
Define the function @var{fname} and number of required arguments. The arguments will be placed in script parameters $1, $2, ... $9. Note, you should stop script execution before function definition(s) by command @ref{stop}. See also @ref{return}.
@end deftypefn
@cindex return
Return from the function. See also @ref{func}.
@end deftypefn
+@cindex load
+@anchor{load}
+@deftypefn {MGL command} {} load 'filename'
+Load additional MGL command from external module (DLL or .so), located in file @var{filename}. This module have to contain array with name @code{mgl_cmd_extra} of type @code{mglCommand}, which describe provided commands.
+@end deftypefn
+
@cindex if
@anchor{if}
Terminate execution.
@end deftypefn
+
+
+@c ------------------------------------------------------------------
+@external{}
+@ifclear UDAV
+@node LaTeX package, mglParse class, Program flow commands, MGL scripts
+@end ifclear
+@ifset UDAV
+@node LaTeX package, , Program flow commands, MGL scripts
+@end ifset
+@section LaTeX package
+@nav{}
+
+There is LaTeX package @code{mgltex} (was made by Diego Sejas Viscarra) which allow one to make figures directly from MGL script located in LaTeX file.
+
+For using this package you need to specify @code{--shell-escape} option for @emph{latex/pdflatex} or manually run @emph{mglconv} tool with produced MGL scripts for generation of images. Don't forgot to run @emph{latex/pdflatex} second time to insert generated images into the output document.
+
+The package may have following options: @code{draft}, @code{final} -- the same as in the @emph{graphicx} package; @code{jpg}, @code{jpeg}, @code{png} -- for export to JPEG/PNG images; @code{eps}, @code{epsz} -- for export to uncompressed/compressed EPS format as primitives; @code{bps}, @code{bpsz} -- for export to uncompressed/compressed EPS format as bitmap, @code{pdf} -- for export to 3D PDF.
+
+The package defines the following environments:
+@table @samp
+@item mgl
+ It writes its contents to a general script which has the same name as the LaTeX document, but its extension is @emph{.mgl}. The code in this environment is compiled and the image produced is included. It takes exactly the same optional arguments as the @code{\includegraphics} command, plus an additional argument @var{imgext}, which specifies the extension to save the image.
+
+An example of usage of @samp{mgl} environment would be:
+@verbatim
+\begin{mglfunc}{prepare2d}
+ new a 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
+ new b 50 40 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
+\end{mglfunc}
+
+\begin{figure}[!ht]
+ \centering
+ \begin{mgl}[width=0.85\textwidth,height=7.5cm]
+ fog 0.5
+ call 'prepare2d'
+ subplot 2 2 0 : title 'Surf plot (default)' : rotate 50 60 : light on : box : surf a
+
+ subplot 2 2 1 : title '"\#" style; meshnum 10' : rotate 50 60 : box
+ surf a '#'; meshnum 10
+
+ subplot 2 2 2 : title 'Mesh plot' : rotate 50 60 : box
+ mesh a
+
+ new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)'
+ new y 50 40 '0.8*cos(pi*x)*sin(pi*(y+1)/2)'
+ new z 50 40 '0.8*cos(pi*(y+1)/2)'
+ subplot 2 2 3 : title 'parametric form' : rotate 50 60 : box
+ surf x y z 'BbwrR'
+ \end{mgl}
+\end{figure}
+@end verbatim
+
+@item mgladdon
+ It adds its contents to the general script, without producing any image.
+@item mglcode
+ Is exactly the same as @samp{mgl}, but it writes its contents verbatim to its own file, whose name is specified as a mandatory argument.
+@item mglscript
+ Is exactly the same as @samp{mglcode}, but it doesn't produce any image, nor accepts optional arguments. It is useful, for example, to create a MGL script, which can later be post processed by another package like "listings".
+@item mglblock
+ It writes its contents verbatim to a file, specified as a mandatory argument, and to the LaTeX document, and numerates each line of code.
+
+@c This last three environments will test if the user is overwriting some file, and will issue a warning in that case.
+@item mglverbatim
+ Exactly the same as @samp{mglblock}, but it doesn't write to a file. This environment doesn't have arguments.
+@item mglfunc
+ Is used to define MGL functions. It takes one mandatory argument, which is the name of the function, plus one additional argument, which specifies the number of arguments of the function. The environment needs to contain only the body of the function, since the first and last lines are appended automatically, and the resulting code is written at the end of the general script, after the @ref{stop} command, which is also written automatically. The warning is produced if 2 or more function with the same name is defined.
+@item mglsetup
+ If many scripts with the same code are to be written, the repetitive code can be written inside this environment only once, then this code will be used automatically every time the @samp{\mglplot} command is used (see below). It takes one optional argument, which is a name to be associated to the corresponding contents of the environment; this name can be passed to the @samp{\mglplot} command to use the corresponding block of code automatically (see below).
+@end table
+
+The package also defines the following commands:
+@table @samp
+@item \mglplot
+ It takes one mandatory argument, which is MGL instructions separated by the symbol @samp{:} this argument can be more than one line long. It takes the same optional arguments as the @samp{mgl} environment, plus an additional argument @var{setup}, which indicates the name associated to a block of code inside a @samp{mglsetup} environment. The code inside the mandatory argument will be appended to the block of code specified, and the resulting code will be written to the general script.
+
+An example of usage of @samp{\mglplot} command would be:
+@verbatim
+\begin{mglsetup}
+ box '@{W9}' : axis
+\end{mglsetup}
+\begin{mglsetup}[2d]
+ box : axis
+ grid 'xy' ';k'
+\end{mglsetup}
+\begin{mglsetup}[3d]
+ rotate 50 60
+ box : axis : grid 'xyz' ';k'
+\end{mglsetup}
+\begin{figure}[!ht]
+ \centering
+ \mglplot[scale=0.5]{new a 200 'sin(pi*x)' : plot a '2B'}
+\end{figure}
+\begin{figure}[!ht]
+ \centering
+ \mglplot[scale=0.5,setup=2d]{
+ fplot 'sin(pi*x)' '2B' :
+ fplot 'cos(pi*x^2)' '2R'
+ }
+\end{figure}
+\begin{figure}[!ht]
+ \centering
+ \mglplot[setup=3d]{fsurf 'sin(pi*x)+cos(pi*y)'}
+\end{figure}
+@end verbatim
+
+@item \mglgraphics
+ This command takes the same optional arguments as the @samp{mgl} environment, and one mandatory argument, which is the name of a MGL script. This command will compile the corresponding script and include the resulting image. It is useful when you have a script outside the LaTeX document, and you want to include the image, but you don't want to type the script again.
+@item \mglinclude
+ This is like @samp{\mglgraphics} but, instead of creating/including the corresponding image, it writes the contents of the MGL script to the LaTeX document, and numerates the lines.
+@item \mgldir
+ This command can be used in the preamble of the document to specify a directory where LaTeX will save the MGL scripts and generate the corresponding images. This directory is also where @samp{\mglgraphics} and @samp{\mglinclude} will look for scripts.
+@item \mglTeX
+ It just pretty prints the name of the package.
+@end table
+
+As an additional feature, when an image is not found or cannot be included, instead of issuing an error, @code{mgltex} prints a box with the word @samp{MGL image not found} in the LaTeX document.
+
+
+
@ifclear UDAV
@c ------------------------------------------------------------------
@external{}
-@node mglParse class, , Program flow commands, MGL scripts
+@node mglParse class, , LaTeX package, MGL scripts
@section mglParse class
@nav{}
@cindex mglParse
@deftypefn{Method on @code{mglParse} (C++)} @code{void} DeleteAll ()
@deftypefnx {C function} @code{void} mgl_parser_del_all (@code{HMPR} p)
-Function delete all variables in this parser.
+Function delete all variables and reset list of commands to default one in this parser.
@end deftypefn
@deftypefn {Method on @code{mglParse}} @code{void} RestoreOnce ()
@deftypefn {Method on @code{mglParse}} @code{void} AllowSetSize (@code{bool} a)
@deftypefnx {C function} @code{void} mgl_parser_allow_setsize (@code{HMPR} p, @code{int} a)
-Allow to parse 'setsize' command or not.
+Allow to parse @ref{setsize} command or not.
@end deftypefn
@deftypefn {Method on @code{mglParse}} @code{void} AllowFileIO (@code{bool} a)
Allow reading/saving files or not.
@end deftypefn
+@deftypefn {Method on @code{mglParse}} @code{void} AllowDllCall (@code{bool} a)
+@deftypefnx {C function} @code{void} mgl_parser_allow_dll_call (@code{HMPR} p, @code{int} a)
+Allow to parse @ref{load} command or not.
+@end deftypefn
+
@deftypefn {Method on @code{mglParse}} @code{void} Stop ()
@deftypefnx {C function} @code{void} mgl_parser_stop (@code{HMPR} p)
Sends stop signal which terminate execution at next command.
@menu
* MGL definition::
* Program flow commands::
+* LaTeX package::
@ifclear UDAV
* mglParse class::
@end ifclear
@c ------------------------------------------------------------------
@external{}
-@ifclear UDAV
-@node Program flow commands, mglParse class, MGL definition, MGL scripts
-@end ifclear
-@ifset UDAV
-@node Program flow commands, , MGL definition, MGL scripts
-@end ifset
+@node Program flow commands, LaTeX package, MGL definition, MGL scripts
@section Управление ходом выполнения
@nav{}
Возвращается из подпрограммы. См. также @ref{func}.
@end deftypefn
+@cindex load
+@anchor{load}
+@deftypefn {MGL command} {} load 'filename'
+Загружает дополнительные команды MGL из внешней динамической библиотеки @var{filename}. Данная библиотека должна содержать массив с именем @code{mgl_cmd_extra} типа @code{mglCommand}, который содержит описание новых комманд.
+@end deftypefn
+
@cindex if
@anchor{if}
Останавливает выполнение скрипта.
@end deftypefn
+
+@c TODO Translate it!
+
+@c ------------------------------------------------------------------
+@external{}
+@ifclear UDAV
+@node LaTeX package, mglParse class, Program flow commands, MGL scripts
+@end ifclear
+@ifset UDAV
+@node LaTeX package, , Program flow commands, MGL scripts
+@end ifset
+@section LaTeX package
+@nav{}
+
+There is LaTeX package @code{mgltex} (was made by Diego Sejas Viscarra) which allow one to make figures directly from MGL script located in LaTeX file.
+
+For using this package you need to specify @code{--shell-escape} option for @emph{latex/pdflatex} or manually run @emph{mglconv} tool for produced MGL scripts for generation of images. Don't forgot to run @emph{latex/pdflatex} second time to insert generated images into the output document.
+
+The package may have following options: @code{draft}, @code{final} -- the same as in the @emph{graphicx} package; @code{jpg}, @code{jpeg}, @code{png} -- for export to JPEG/PNG images; @code{eps}, @code{epsz} -- for export to uncompressed/compressed EPS format as primitives; @code{bps}, @code{bpsz} -- for export to uncompressed/compressed EPS format as bitmap, @code{pdf} -- for export to 3D PDF.
+
+The package defines the following environments:
+@table @samp
+@item mgl
+ It writes its contents to a general script which has the same name as the LaTeX document, but its extension is @emph{.mgl}. The code in this environment is compiled and the image produced is included. It takes exactly the same optional arguments as the @code{\includegraphics} command, plus an additional argument @var{imgext}, which specifies the extension to save the image.
+
+An example of usage of @samp{mgl} environment would be:
+@verbatim
+\begin{mglfunc}{prepare2d}
+ new a 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
+ new b 50 40 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
+\end{mglfunc}
+
+\begin{figure}[!ht]
+ \centering
+ \begin{mgl}[width=0.85\textwidth,height=7.5cm]
+ fog 0.5
+ call 'prepare2d'
+ subplot 2 2 0 : title 'Surf plot (default)' : rotate 50 60 : light on : box : surf a
+
+ subplot 2 2 1 : title '"\#" style; meshnum 10' : rotate 50 60 : box
+ surf a '#'; meshnum 10
+
+ subplot 2 2 2 : title 'Mesh plot' : rotate 50 60 : box
+ mesh a
+
+ new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)'
+ new y 50 40 '0.8*cos(pi*x)*sin(pi*(y+1)/2)'
+ new z 50 40 '0.8*cos(pi*(y+1)/2)'
+ subplot 2 2 3 : title 'parametric form' : rotate 50 60 : box
+ surf x y z 'BbwrR'
+ \end{mgl}
+\end{figure}
+@end verbatim
+
+@item mgladdon
+ It adds its contents to the general script, without producing any image.
+@item mglcode
+ Is exactly the same as @samp{mgl}, but it writes its contents verbatim to its own file, whose name is specified as a mandatory argument.
+@item mglscript
+ Is exactly the same as @samp{mglcode}, but it doesn't produce any image, nor accepts optional arguments. It is useful, for example, to create a MGL script, which can later be post processed by another package like "listings".
+@item mglblock
+ It writes its contents verbatim to a file, specified as a mandatory argument, and to the LaTeX document, and numerates each line of code.
+
+@c This last three environments will test if the user is overwriting some file, and will issue a warning in that case.
+@item mglverbatim
+ Exactly the same as @samp{mglblock}, but it doesn't write to a file. This environment doesn't have arguments.
+@item mglfunc
+ Is used to define MGL functions. It takes one mandatory argument, which is the name of the function, plus one additional argument, which specifies the number of arguments of the function. The environment needs to contain only the body of the function, since the first and last lines are appended automatically, and the resulting code is written at the end of the general script, after the @ref{stop} command, which is also written automatically. The warning is produced if 2 or more function with the same name is defined.
+@item mglsetup
+ If many scripts with the same code are to be written, the repetitive code can be written inside this environment only once, then this code will be used automatically every time the @samp{\mglplot} command is used (see below). It takes one optional argument, which is a name to be associated to the corresponding contents of the environment; this name can be passed to the @samp{\mglplot} command to use the corresponding block of code automatically (see below).
+@end table
+
+The package also defines the following commands:
+@table @samp
+@item \mglplot
+ It takes one mandatory argument, which is MGL instructions separated by the symbol @samp{:} this argument can be more than one line long. It takes the same optional arguments as the @samp{mgl} environment, plus an additional argument @var{setup}, which indicates the name associated to a block of code inside a @samp{mglsetup} environment. The code inside the mandatory argument will be appended to the block of code specified, and the resulting code will be written to the general script.
+
+An example of usage of @samp{\mglplot} command would be:
+@verbatim
+\begin{mglsetup}
+ box '@{W9}' : axis
+\end{mglsetup}
+\begin{mglsetup}[2d]
+ box : axis
+ grid 'xy' ';k'
+\end{mglsetup}
+\begin{mglsetup}[3d]
+ rotate 50 60
+ box : axis : grid 'xyz' ';k'
+\end{mglsetup}
+\begin{figure}[!ht]
+ \centering
+ \mglplot[scale=0.5]{new a 200 'sin(pi*x)' : plot a '2B'}
+\end{figure}
+\begin{figure}[!ht]
+ \centering
+ \mglplot[scale=0.5,setup=2d]{
+ fplot 'sin(pi*x)' '2B' :
+ fplot 'cos(pi*x^2)' '2R'
+ }
+\end{figure}
+\begin{figure}[!ht]
+ \centering
+ \mglplot[setup=3d]{fsurf 'sin(pi*x)+cos(pi*y)'}
+\end{figure}
+@end verbatim
+
+@item \mglgraphics
+ This command takes the same optional arguments as the @samp{mgl} environment, and one mandatory argument, which is the name of a MGL script. This command will compile the corresponding script and include the resulting image. It is useful when you have a script outside the LaTeX document, and you want to include the image, but you don't want to type the script again.
+@item \mglinclude
+ This is like @samp{\mglgraphics} but, instead of creating/including the corresponding image, it writes the contents of the MGL script to the LaTeX document, and numerates the lines.
+@item \mgldir
+ This command can be used in the preamble of the document to specify a directory where LaTeX will save the MGL scripts and generate the corresponding images. This directory is also where @samp{\mglgraphics} and @samp{\mglinclude} will look for scripts.
+@item \mglTeX
+ It just pretty prints the name of the package.
+@end table
+
+As an additional feature, when an image is not found or cannot be included, instead of issuing an error, @code{mgltex} prints a box with the word @samp{MGL image not found} in the LaTeX document.
+
+
+
@ifclear UDAV
@c ------------------------------------------------------------------
@external{}
-@node mglParse class, , Program flow commands, MGL scripts
+@node mglParse class, , LaTeX package, MGL scripts
@section mglParse class
@nav{}
@cindex mglParse
@deftypefn{Метод класса @code{mglParse} (C++)} @code{void} DeleteAll ()
@deftypefnx {Функция С} @code{void} mgl_parser_del_all (@code{HMPR} p)
-Удаляет все переменные в данном классе.
+УдалÑ\8fеÑ\82 вÑ\81е пеÑ\80еменнÑ\8bе и Ñ\81бÑ\80аÑ\81Ñ\8bваеÑ\82 Ñ\81пиÑ\81ок команд к Ñ\81пиÑ\81кÑ\83 по Ñ\83молÑ\87аниÑ\8e в данном клаÑ\81Ñ\81е.
@end deftypefn
@deftypefn {Метод класса @code{mglParse}} @code{void} RestoreOnce ()
@deftypefn {Метод класса @code{mglParse}} @code{void} AllowSetSize (@code{bool} a)
@deftypefnx {Функция С} @code{void} mgl_parser_allow_setsize (@code{HMPR} p, @code{int} a)
-Разрешает/запрещает команду 'setsize'.
+Разрешает/запрещает команду @ref{setsize}.
@end deftypefn
@deftypefn {Метод класса @code{mglParse}} @code{void} AllowFileIO (@code{bool} a)
Разрешает/запрещает команды чтения файлов.
@end deftypefn
+@deftypefn {Метод класса @code{mglParse}} @code{void} AllowDllCall (@code{bool} a)
+@deftypefnx {Функция С} @code{void} mgl_parser_allow_dll_call (@code{HMPR} p, @code{int} a)
+Разрешает/запрещает команду @ref{load}.
+@end deftypefn
+
@deftypefn {Метод класса @code{mglParse}} @code{void} Stop ()
@deftypefnx {Функция С} @code{void} mgl_parser_stop (@code{HMPR} p)
Посылает сигнал завершения выполнения для следующей команды.
@set VERSION 2.3
-@set MINVER @c .2
+@set MINVER .1
@strong{Latest news}
@itemize
+@item @emph{20 October 2014.}
+New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are @ref{LaTeX package}, command to load external DLL file (@ref{load}), new primitive (@ref{logo}), improvements for projections, manual rotation angle in @ref{axis} and other minor improvements, which denoted @ref{News, here}.
@item @emph{7 August 2014.}
New version (v.@value{VERSION}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are many major improvements for both MathGL core and for UDAV, which denoted @ref{News, here}.
-@comment New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are extend of 'region' plot, improve export to TeX, add missing Fortran functions, bugfixes, and other improvements, which denoted @ref{News, here}. Note, this release looks as bug free, but next release (v.2.3) will introduce a set of improvements which may not so stable at first time.
-@item @emph{11 November 2013.}
-New version (v.2.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are speeding up, new plot kinds and data handling functions, new plot styles, masks for bitmap output, wx-widget, Lua interface, and many other improvements, which denoted @ref{News, here}.
@end itemize
There is detailed @ref{News, news list}. Sourceforge project page @uref{http://sourceforge.net/projects/mathgl/, here}.
@nav{}
@itemize
+
+@item @strong{20 October 2014.}
+New version (v.2.3.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor improvements and bugfixes:
+@itemize @bullet
+@item Add @ref{LaTeX package} @emph{mglTeX} (author Diego Sejas Viscarra) for making figures directly from MGL script located in LaTeX file.
+@item Add MGL command @ref{load} for loading MGL commands from external DLL (or .so) module.
+@item Add @ref{logo} function to draw bitmap (logo), which is stretched along whole axis range.
+@item Add MGL command @ref{reset} which restore default settings and clear image (i.e. call @code{DefaultPlotParam()}).
+@item Add option @code{value} to @ref{axis} function, which allow to set rotation angle for tick labels.
+@item Change y coordinate at x-z projection.
+@item Improve projection of 'unrotatable' objects (like @ref{legend}, @ref{title}, ...).
+@item Add projection (@ref{ternary}&8) which is the same as usual (@ref{ternary}&4) but don't print text on projections
+@item Improve orientation of axis ticks and labels.
+@item Add mglWnd::SetDrawFunc().
+@item Add mgl_set_global_warn() and mgl_get_global_warn() for set/get messages of global scope.
+@item Make copying private of mglGraph and derived.
+@item Add virtual destructors.
+@item Add some static functions for mglGraph.
+@item Add option @samp{-n} to mglconv to disable automatic saving of the image.
+@item Add option @samp{-s} to mglview and mglconv to run setup script before the main one.
+@item Become compatible with giflib 5.1.
+@item Add light scaling at MGLD import.
+@item Add scaling of frames at Adjust().
+@item Possible bugfix for 32bit gcc.
+@item Update documentation and make other minor bugfixes and compatibility changes.
+@end itemize
+
@item @strong{7 August 2014.}
New version (v.2.3) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are major improvements and speeding up of core MathGL and UDAV.
@itemize @bullet
@end itemize
-@item @strong{19 March 2014.}
-New version (v.2.2.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes for MS VisualStudio 2010 and early.
-@itemize @bullet
-@item Compatibility changes for MS VisualStudio 2010 and early.
-@item Function SetRange(v1,v2) ignore NAN values now.
-@item Add enable-json-sample for building json-samples on demand only.
-@item Update documentation.
-@end itemize
-
-@item @strong{10 March 2014.}
-New version (v.2.2.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor improvements and bugfixes:
-@itemize @bullet
-@item Add mgl_region_3d() to draw region (or ribbon) between 2 curves. Correspondingly extend mglGraph::Region() function and MGL command 'region'.
-@item Allow LGPL for MathGL widgets.
-@item Improve export to TeX.
-@item Add missing functions to Fortran interface.
-@item Bugfix for legend with enabled lighting.
-@item Minor bugfixes and memory leaks.
-@end itemize
-
-@item @strong{22 January 2014.}
-New version (v.2.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor improvements and bugfixes:
-@itemize @bullet
-@item Add Qt5 support.
-@item Add Pascal interface.
-@item Improve JavaScript interface.
-@item Add function mglGraph::AddRange(char dir, mreal v1, mreal v2) and extend corresponding MGL commands '[xyzc]range'.
-@item Add 'hypot(x,y)' function for known functions in formula parsing.
-@item Add style '~' to disable colorbar or axis labels. NOTE, axis style '_' is obsolete and should be replaced by '~'.
-@item Change Aspect() if Ax=NAN. Now, Ay and Az set the ratio to optimal aspect (not exact value as previously).
-@item Disable changes by View(),Zoom(),Perspective() for position of Title(), Legend(), Colorbar().
-@item Partial support of perspective in CalcXYZ().
-@item Speed up PDE solving.
-@item Add complex versions of PDE, QO2d, QO3d.
-@item Correct filled background for Box() in curved coordinates.
-@item Allow nx=1 for Stem and Error.
-@item Bugfix for drawing single axis.
-@item Bugfix for missing options parsing for some of MGL commands.
-@item Bugfix for .pmin suffix in MGL. Add mglData::MaximalNeg() and mglData::MinimalPos() functions. Add .nmin and .nmax suffixes.
-@item Bugfix for colorbar labels.
-@item Force using python 2.7 by default due to bug in Ubuntu. Debian sid works well with python 3.* too.
-@item Other minor bugfixes and memory leaks.
-@end itemize
-
-@item @strong{11 November 2013.}
-New version (v.2.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor bugfixes and improvements:
-@itemize @bullet
-@item Add OpenMP calls mostly everywhere (can work as replacement of pthreads - a bit faster since more loops is parallelized).
-@item Greatly speed up consequent FFT and Hankel transforms. Add mgl_clear_fft() function for manual clearing of saved FFT/Hankel data.
-@item Add @ref{ohlc} plot for drawing Open-High-Low-Close diagram
-@item Add wxMathGL widget. See @ref{wxMathGL class}.
-@item Add interface for Lua v.5.1.
-@item Add @ref{mask} for face drawing if one of symbols @samp{-+=;oOsS~<>jdD*^} is specified in color scheme. This work only for export in bitmap images.
-@item Add @ref{quality}=8 for dots drawing (extremely fast).
-@item Add styles '4','6','8' for @ref{cone} and @ref{cones} to produce square, hex-, octo-prism.
-@item Add style 't' for @ref{cones} to produce tubes (cylinders).
-@item Add style '^' for @ref{legend} to left/right align legend if its coordinates are right/left from the center
-@item Add style '<', '^', '>' for aligning/centering boxes in @ref{bars}, @ref{barh}, @ref{boxplot}, @ref{cones}. Also this plots become centered by default if nx sizes are the same for all data.
-@item Add @ref{dots} function which set independently both color and transparency of dots.
-@item Improve automatic axis position. Add style '^' for inverse automatic axis position.
-@item Improve tick labeling. Add style @ref{tuneticks}&4 for zero filling of tick labels.
-@item Add @ref{refill} for filling by interpolation of parametrically dependent data
-@item Add transparency for @ref{area} and @ref{region} plots.
-@item Add mgl_clf_chr() function and extend @ref{clf} command.
-@item Fourier now perform true inverse Fourier transform (instead of backward one).
-@item Improve/change lighting from local sources. Add @ref{diffuse} function.
-@item C functions now return NULL if HMDT data cannot be created for given input argument(s).
-@item Enable line width for @ref{mesh} and @ref{fall} plots.
-@item Replace +INF and -INF by NAN in textual formula output.
-@item Add manual compression of JSON.
-@item Define WORDS_BIGENDIAN and HAVE_MEMRCHR (thanks to Dinar Valeev).
-@item Bugfix for cleaning unused points.
-@item Fix 'setsize' command at UDAV starting.
-@item Rewrite MGL parsing by using std::wstring for avoiding possible bugs of wcs*() functions.
-@item Minor bugfixes.
-@item Update docs.
-@end itemize
-
+@item @strong{19 March 2014.}Version 2.2.2.1 was released.
+@item @strong{10 March 2014.} Version 2.2.2 was released.
+@item @strong{22 January 2014.} Version 2.2.1 was released.
+@item @strong{11 November 2013.} Version 2.2 was released.
@item @strong{8 May 2013.} Version 2.1.3.1 was released.
@item @strong{2 May 2013.} Version 2.1.3 was released.
@item @strong{28 January 2013.} Version 2.1.2 was released.
@strong{Latest news}
@itemize
+@item @emph{20 October 2014.}
+New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are @ref{LaTeX package}, command to load external DLL file (@ref{load}), new primitive (@ref{logo}), improvements for projections, manual rotation angle in @ref{axis} and other minor improvements, which denoted @ref{News, here}.
@item @emph{7 August 2014.}
New version (v.@value{VERSION}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are many major improvements for both MathGL core and for UDAV, which denoted @ref{News, here}.
-@comment New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are extend of 'region' plot, improve export to TeX, add missing Fortran functions, bugfixes, and other improvements, which denoted @ref{News, here}. Note, this release looks as bug free, but next release (v.2.3) will introduce a set of improvements which may not so stable at first time.
-@item @emph{11 November 2013.}
-New version (v.2.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are speeding up, new plot kinds and data handling functions, new plot styles, masks for bitmap output, wx-widget, Lua interface, and many other improvements, which denoted @ref{News, here}.
@end itemize
There is detailed @ref{News, news list}. Sourceforge project page @uref{http://sourceforge.net/projects/mathgl/, here}.
@nav{}
@itemize
+
+@item @strong{20 October 2014.}
+New version (v.2.3.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor improvements and bugfixes:
+@itemize @bullet
+@item Add @ref{LaTeX package} @emph{mglTeX} (author Diego Sejas Viscarra) for making figures directly from MGL script located in LaTeX file.
+@item Add MGL command @ref{load} for loading MGL commands from external DLL (or .so) module.
+@item Add @ref{logo} function to draw bitmap (logo), which is stretched along whole axis range.
+@item Add MGL command @ref{reset} which restore default settings and clear image (i.e. call @code{DefaultPlotParam()}).
+@item Add option @code{value} to @ref{axis} function, which allow to set rotation angle for tick labels.
+@item Change y coordinate at x-z projection.
+@item Improve projection of 'unrotatable' objects (like @ref{legend}, @ref{title}, ...).
+@item Add projection (@ref{ternary}&8) which is the same as usual (@ref{ternary}&4) but don't print text on projections
+@item Improve orientation of axis ticks and labels.
+@item Add mglWnd::SetDrawFunc().
+@item Add mgl_set_global_warn() and mgl_get_global_warn() for set/get messages of global scope.
+@item Make copying private of mglGraph and derived.
+@item Add virtual destructors.
+@item Add some static functions for mglGraph.
+@item Add option @samp{-n} to mglconv to disable automatic saving of the image.
+@item Add option @samp{-s} to mglview and mglconv to run setup script before the main one.
+@item Become compatible with giflib 5.1.
+@item Add light scaling at MGLD import.
+@item Add scaling of frames at Adjust().
+@item Possible bugfix for 32bit gcc.
+@item Update documentation and make other minor bugfixes and compatibility changes.
+@end itemize
+
@item @strong{7 August 2014.}
New version (v.2.3) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are major improvements and speeding up of core MathGL and UDAV.
@itemize @bullet
@item Add background image, which allow in particular semi-transparent background color. Correspondingly add function @ref{rasterize} for saving current image as background, and function @ref{background} for loading background image from PNG or JPEG file.
@item Add primitives to draw @ref{polygon} and angle @ref{arc}.
@item Allow arbitrary factor for axis ticks (like, @code{gr->SetTicks('x',M_PI,0,NAN,"\\pi");} or @code{@ref{xtick} pi '\pi'}).
-@item Add function mglGraph::AddTick() for adding manual tick to the list of existed ones.
+@item Add function @code{AddTick()} for adding manual tick to the list of existed ones.
@item Add new styles and symbols:
@itemize
@end itemize
-@item @strong{19 March 2014.}
-New version (v.2.2.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes for MS VisualStudio 2010 and early.
-@itemize @bullet
-@item Compatibility changes for MS VisualStudio 2010 and early.
-@item Function SetRange(v1,v2) ignore NAN values now.
-@item Add enable-json-sample for building json-samples on demand only.
-@item Update documentation.
-@end itemize
-
-@item @strong{10 March 2014.}
-New version (v.2.2.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor improvements and bugfixes:
-@itemize @bullet
-@item Add mgl_region_3d() to draw region (or ribbon) between 2 curves. Correspondingly extend mglGraph::Region() function and MGL command 'region'.
-@item Allow LGPL for MathGL widgets.
-@item Improve export to TeX.
-@item Add missing functions to Fortran interface.
-@item Bugfix for legend with enabled lighting.
-@item Minor bugfixes and memory leaks.
-@end itemize
-
-@item @strong{22 January 2014.}
-New version (v.2.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor improvements and bugfixes:
-@itemize @bullet
-@item Add Qt5 support.
-@item Add Pascal interface.
-@item Improve JavaScript interface.
-@item Add function mglGraph::AddRange(char dir, mreal v1, mreal v2) and extend corresponding MGL commands '[xyzc]range'.
-@item Add 'hypot(x,y)' function for known functions in formula parsing.
-@item Add style '~' to disable colorbar or axis labels. NOTE, axis style '_' is obsolete and should be replaced by '~'.
-@item Change Aspect() if Ax=NAN. Now, Ay and Az set the ratio to optimal aspect (not exact value as previously).
-@item Disable changes by View(),Zoom(),Perspective() for position of Title(), Legend(), Colorbar().
-@item Partial support of perspective in CalcXYZ().
-@item Speed up PDE solving.
-@item Add complex versions of PDE, QO2d, QO3d.
-@item Correct filled background for Box() in curved coordinates.
-@item Allow nx=1 for Stem and Error.
-@item Bugfix for drawing single axis.
-@item Bugfix for missing options parsing for some of MGL commands.
-@item Bugfix for .pmin suffix in MGL. Add mglData::MaximalNeg() and mglData::MinimalPos() functions. Add .nmin and .nmax suffixes.
-@item Bugfix for colorbar labels.
-@item Force using python 2.7 by default due to bug in Ubuntu. Debian sid works well with python 3.* too.
-@item Other minor bugfixes and memory leaks.
-@end itemize
-
-@item @strong{11 November 2013.}
-New version (v.2.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor bugfixes and improvements:
-@itemize @bullet
-@item Add OpenMP calls mostly everywhere (can work as replacement of pthreads - a bit faster since more loops is parallelized).
-@item Greatly speed up consequent FFT and Hankel transforms. Add mgl_clear_fft() function for manual clearing of saved FFT/Hankel data.
-@item Add @ref{ohlc} plot for drawing Open-High-Low-Close diagram
-@item Add wxMathGL widget. See @ref{wxMathGL class}.
-@item Add interface for Lua v.5.1.
-@item Add @ref{mask} for face drawing if one of symbols @samp{-+=;oOsS~<>jdD*^} is specified in color scheme. This work only for export in bitmap images.
-@item Add @ref{quality}=8 for dots drawing (extremely fast).
-@item Add styles '4','6','8' for @ref{cone} and @ref{cones} to produce square, hex-, octo-prism.
-@item Add style 't' for @ref{cones} to produce tubes (cylinders).
-@item Add style '^' for @ref{legend} to left/right align legend if its coordinates are right/left from the center
-@item Add style '<', '^', '>' for aligning/centering boxes in @ref{bars}, @ref{barh}, @ref{boxplot}, @ref{cones}. Also this plots become centered by default if nx sizes are the same for all data.
-@item Add @ref{dots} function which set independently both color and transparency of dots.
-@item Improve automatic axis position. Add style '^' for inverse automatic axis position.
-@item Improve tick labeling. Add style @ref{tuneticks}&4 for zero filling of tick labels.
-@item Add @ref{refill} for filling by interpolation of parametrically dependent data
-@item Add transparency for @ref{area} and @ref{region} plots.
-@item Add mgl_clf_chr() function and extend @ref{clf} command.
-@item Fourier now perform true inverse Fourier transform (instead of backward one).
-@item Improve/change lighting from local sources. Add @ref{diffuse} function.
-@item C functions now return NULL if HMDT data cannot be created for given input argument(s).
-@item Enable line width for @ref{mesh} and @ref{fall} plots.
-@item Replace +INF and -INF by NAN in textual formula output.
-@item Add manual compression of JSON.
-@item Define WORDS_BIGENDIAN and HAVE_MEMRCHR (thanks to Dinar Valeev).
-@item Bugfix for cleaning unused points.
-@item Fix 'setsize' command at UDAV starting.
-@item Rewrite MGL parsing by using std::wstring for avoiding possible bugs of wcs*() functions.
-@item Minor bugfixes.
-@item Update docs.
-@end itemize
-
+@item @strong{19 March 2014.}Version 2.2.2.1 was released.
+@item @strong{10 March 2014.} Version 2.2.2 was released.
+@item @strong{22 January 2014.} Version 2.2.1 was released.
+@item @strong{11 November 2013.} Version 2.2 was released.
@item @strong{8 May 2013.} Version 2.1.3.1 was released.
@item @strong{2 May 2013.} Version 2.1.3 was released.
@item @strong{28 January 2013.} Version 2.1.2 was released.
@cindex window
@cindex widgets
-There are set of ``window'' classes for making a window with MathGL graphics: @code{mglWindow} and @code{mglGLUT} for whole window, @code{Fl_MathGL} and @code{QMathGL} as widgets. All these classes allow user to show, rotate, export, and change view of the plot using keyboard. Most of them (except @code{mglGLUT}) also have toolbar and menu for simplifying plot manipulation. All window classes have mostly the same set of functions.
+There are set of ``window'' classes for making a window with MathGL graphics: @code{mglWindow}, @code{mglFLTK}, @code{mglQT} and @code{mglGLUT} for whole window, @code{Fl_MathGL} and @code{QMathGL} as widgets. All these classes allow user to show, rotate, export, and change view of the plot using keyboard. Most of them (except @code{mglGLUT}) also have toolbar and menu for simplifying plot manipulation. All window classes have mostly the same set of functions.
For drawing you can use: @code{NULL} pointer if you'll update plot manually, global callback function of type @code{int draw(@code{HMGL} gr, @code{void *}p)} or @code{int draw(@code{mglGraph *}gr)}, or instance of class derived from @code{mglDraw} class. This class is defined in @code{#include <mgl2/window.h>} and have only 2 methods:
@verbatim
Run main loop for event handling. Usually it should be called in a separate thread or as last function call in @code{main()}.
@end deftypefn
+@deftypefn {Method on @code{mglWindow}} @code{void} SetDrawFunc (@code{int} (*draw)(@code{HMGL} gr, @code{void *}p), @code{void *}par=@code{NULL}, @code{void} (*reload)(@code{void *}p)=@code{NULL})
+@deftypefnx {Method on @code{mglWindow}} @code{void} SetDrawFunc (@code{int} (*draw)(@code{mglGraph *}gr))
+@deftypefnx {Method on @code{mglWindow}} @code{void} SetDrawFunc (@code{mglDraw *}obj)
+@deftypefnx {C function} @code{void} mgl_wnd_set_func (@code{HMGL} gr, @code{int} (*draw)(@code{HMGL} gr, @code{void *}p), @code{void *}par, @code{void} (*reload)(@code{void *}p))
+Set callback functions for drawing (@var{draw}) and data reloading (@var{reload}), or instance @var{obj} of a class derived from @code{mglDraw}.
+@end deftypefn
+
@deftypefn {Method on @code{mglWindow}} @code{void} SetClickFunc (@code{void} (*func)(@code{HMGL} gr, @code{void *}p))
@deftypefnx {C function} @code{void} mgl_set_click_func (@code{void} (*func)(@code{HMGL} gr, @code{void *}p))
-Set callback function @code{func} which will be called on mouse click.
+Set callback function @var{func} which will be called on mouse click.
@end deftypefn
@deftypefn {Method on @code{mglWindow}} @code{void} ToggleAlpha ()
Запускает цикл обработки сообщений. Обычно эта функция должна вызываться в отдельном потоке или последней функцией в @code{main()}.
@end deftypefn
+@deftypefn {Метод класса @code{mglWindow}} @code{void} SetDrawFunc (@code{int} (*draw)(@code{HMGL} gr, @code{void *}p), @code{void *}par=@code{NULL}, @code{void} (*reload)(@code{void *}p)=@code{NULL})
+@deftypefnx {Метод класса @code{mglWindow}} @code{void} SetDrawFunc (@code{int} (*draw)(@code{mglGraph *}gr))
+@deftypefnx {Метод класса @code{mglWindow}} @code{void} SetDrawFunc (@code{mglDraw *}obj)
+@deftypefnx {Функция С} @code{void} mgl_wnd_set_func (@code{HMGL} gr, @code{int} (*draw)(@code{HMGL} gr, @code{void *}p), @code{void *}par, @code{void} (*reload)(@code{void *}p))
+Устанавливает функцию, которая будет вызвана при перерисовке (@var{draw}) и при повторной загрузке данных (@var{reload}), или объект @var{obj} класса, производного от @code{mglDraw}.
+@end deftypefn
+
@deftypefn {Метод класса @code{mglWindow}} @code{void} SetClickFunc (@code{void} (*func)(@code{HMGL} gr, @code{void *}p))
@deftypefnx {Функция С} @code{void} mgl_set_click_func (@code{void} (*func)(@code{HMGL} gr, @code{void *}p))
Устанавливает функцию, которая будет вызвана при щелчке мышью.
B. как делать анимацию (кадры) для мышиной версии ... список кадров, кнопки добавить в кадры + вставить из кадра
16. Docs about mgl_datac_diffr
17. Extend QO + extra docs
+18. Import OBJ ???
+19. Simplified triangle filling for Quality=1 ?!?
+20. Extend 'ask' by adding multiple questions simultaneously (+ set/get default values from file ???)
+21. Occasional seg.fault in mgl_qt_example at exit
ZZ. Update *.i for new functions {before release!!!}
4. Check centered curved text (see text2)
5. Export to X3D
-
6. New tests:
c. Tests for mglDataC arrays (as separate flag)
e. Test for Crop, Momentum, NormSl, Sew, DiffParam, Envelope, STFA for all directions "xyz"; Clean, Last, First, Find, Spline3, FindAny, Insert, Delete, Put, SetId/Column, Squeeze, Extend, Trace, Combine, new Max/Min/Momentum, FillSample, Hist, operators, Sort, Roots, Jacobian
u. Test FlowP + 3d
+7. Improve z-order for rapidly oscillating surfaces
+10. Manual rotation angle for axis ticks (as "value" option?!)
+11. Export to XPM (like GIF)
+13. Title and perspective
+
============= DOCUMENTATION =============
A. Paper about MathGL!!!
set(udav_src anim_dlg.cpp find_dlg.cpp mem_pnl.cpp prop_dlg.cpp textedit.cpp args_dlg.cpp
help_pnl.cpp newcmd_dlg.cpp text_pnl.cpp calc_dlg.cpp hint_dlg.cpp
open_dlg.cpp qmglsyntax.cpp udav_wnd.cpp dat_pnl.cpp info_dlg.cpp opt_dlg.cpp setup_dlg.cpp
- files_dlg.cpp plot_pnl.cpp style_dlg.cpp data_dlg.cpp tree_pnl.cpp subplot_dlg.cpp )
+ files_dlg.cpp plot_pnl.cpp style_dlg.cpp data_dlg.cpp subplot_dlg.cpp )
set(udav_moc_hdr anim_dlg.h files_dlg.h info_dlg.h opt_dlg.h text_pnl.h args_dlg.h
find_dlg.h mem_pnl.h plot_pnl.h setup_dlg.h udav_wnd.h calc_dlg.h help_pnl.h newcmd_dlg.h
// mgl addon
//
//-----------------------------------------------------------------------------
-/*mglCommand udav_base_cmd[] = {
- {L"fplot",L"Plot curve by formula",L"fplot 'func' ['stl'='' num=100]", mgls_fplot, mglc_fplot},
- {L"fsurf",L"Plot surface by formula",L"fsurf 'func' ['stl'='' numx=100 numy=100]", mgls_fsurf, mglc_fsurf},
- {L"fgets",L"Print string from file",L"fgets x y {z} 'fname' [pos=0 'stl'='' size=-1.4]", mgls_fgets, mglc_fgets},
-{L"",0,0,0,0}};
-//-----------------------------------------------------------------------------
-void udavAddCommands(const mglCommand *cmd) // NOTE it work but I don't how I can use it
-{
- int i, mp, mc;
- // determine the number of symbols
- for(i=0;parser.Cmd[i].name[0];i++){}; mp = i;
- for(i=0;cmd[i].name[0];i++){}; mc = i;
- mglCommand *buf = new mglCommand[mp+mc+1];
- memcpy(buf, parser.Cmd, mp*sizeof(mglCommand));
- memcpy(buf+mp, cmd, (mc+1)*sizeof(mglCommand));
- qsort(buf, mp+mc, sizeof(mglCommand), mgl_cmd_cmp);
-#pragma omp critical(cmd_parser)
- if(parser.Cmd!=mgls_base_cmd) delete []parser.Cmd;
- parser.Cmd = buf;
-}*/
-//-----------------------------------------------------------------------------
void udavLoadDefCommands() {} //{ udavAddCommands(udav_base_cmd); }
//-----------------------------------------------------------------------------
//
mglParse p(true);\r
char ch, buf[2048], iname[256]="", oname[256]="";\r
std::vector<std::wstring> var;\r
+ std::wstring str;\r
+ bool none=false;\r
\r
while(1)\r
{\r
- ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:ho:L:C:A:");\r
+ ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:hno:L:C:A:s:");\r
if(ch>='1' && ch<='9') p.AddParam(ch-'0', optarg);\r
+ else if(ch=='s')\r
+ {\r
+ setlocale(LC_CTYPE, "");\r
+ FILE *fp = fopen(optarg,"r");\r
+ if(fp)\r
+ {\r
+ wchar_t ch;\r
+ while((ch=fgetwc(fp))!=WEOF) str.push_back(ch);\r
+ fclose(fp); str += L"\n";\r
+ }\r
+ }\r
+ else if(ch=='n') none = true;\r
else if(ch=='L') setlocale(LC_CTYPE, optarg);\r
else if(ch=='A')\r
{\r
"\t... ...\n"\r
"\t-9 str set str as argument $9 for script\n"\r
"\t-L loc set locale to loc\n"\r
+ "\t-s opt set MGL script for setting up the plot\n"\r
"\t-o name set output file name\n"\r
- "\t- get script from standard input\n"\r
+ "\t-n no manual output (script should save results by itself)\n"\r
"\t-A val add animation value val\n"\r
"\t-C n1:n2:dn add animation value in range [n1,n2] with step dn\n"\r
"\t-C n1:n2 add animation value in range [n1,n2] with step 1\n"\r
}\r
if(ch=='h') return 0;\r
if(*oname==0) { strncpy(oname,*iname?iname:"out",250); strcat(oname,".png"); }\r
- \r
+ else none = false;\r
+\r
mgl_ask_func = mgl_ask_gets;\r
// prepare for animation\r
- std::wstring str;\r
setlocale(LC_CTYPE, "");\r
FILE *fp = *iname?fopen(iname,"r"):stdin;\r
+ if(!fp) { printf("No file for MGL script\n"); return 0; }\r
wchar_t cw;\r
while((cw=fgetwc(fp))!=WEOF) str.push_back(cw);\r
// while(!feof(fp)) str.push_back(fgetwc(fp));\r
{\r
p.Execute(&gr,str.c_str());\r
printf("%s\n",gr.Message());\r
- gr.WriteFrame(oname);\r
+ if(!none) gr.WriteFrame(oname);\r
}\r
if(!mglGlobalMess.empty()) printf("%s",mglGlobalMess.c_str());\r
- printf("Write output to %s\n",oname);\r
+ if(!none || gif) printf("Write output to %s\n",oname);\r
return 0;\r
}\r
//-----------------------------------------------------------------------------\r
#include "mgl2/mgl.h"
#include "mgl2/qt.h"
//-----------------------------------------------------------------------------
-std::wstring str;
+std::wstring str, opt;
mglParse p(true);
void mgl_error_print(const char *Message, void *par);
void mgl_ask_fltk(const wchar_t *quest, wchar_t *res);
mgl_suppress_warn(true);
while(1)
{
- ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:ho:L:");
+ ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:hL:s:");
if(ch>='1' && ch<='9') p.AddParam(ch-'0', optarg);
+ else if(ch=='s')
+ {
+ setlocale(LC_CTYPE, "");
+ FILE *fp = fopen(optarg,"r");
+ if(fp)
+ {
+ wchar_t ch;
+ while((ch=fgetwc(fp))!=WEOF) opt.push_back(ch);
+ fclose(fp);
+ }
+ }
else if(ch=='L') setlocale(LC_CTYPE, optarg);
else if(ch=='h' || (ch==-1 && optind>=argc))
{
- printf("mglconv convert mgl script to bitmap png file.\nCurrent version is 2.%g\n",MGL_VER2);
+ printf("mglview show plot from MGL script or MGLD file.\nCurrent version is 2.%g\n",MGL_VER2);
printf("Usage:\tmglview [parameter(s)] scriptfile\n");
printf(
"\t-1 str set str as argument $1 for script\n"
"\t... ...\n"
"\t-9 str set str as argument $9 for script\n"
+ "\t-s opt set MGL script for setting up the plot\n"
"\t-L loc set locale to loc\n"
"\t- get script from standard input\n"
"\t-h print this message\n" );
bool mgld=(*iname && iname[strlen(iname)-1]=='d');
if(!mgld)
{
+ str = opt + L"\n";
setlocale(LC_CTYPE, "");
FILE *fp = *iname?fopen(iname,"r"):stdin;
if(fp)
while((ch=fgetwc(fp))!=WEOF) str.push_back(ch);
fclose(fp);
}
+ else { printf("No file for MGL script\n"); return 0; }
}
mgl_ask_func = mgl_ask_gets;
{
gr.Setup(false);
gr.NewFrame(); setlocale(LC_NUMERIC, "C");
- gr.ImportMGLD(iname);
+ if(!opt.empty())
+ {
+ p.Execute(&gr,opt.c_str());
+ printf("Setup script: %s\n",gr.Message());
+ gr.ImportMGLD(iname,true);
+ }
+ else gr.ImportMGLD(iname);
setlocale(LC_NUMERIC, ""); gr.EndFrame();
gr.Update();
}
if(!mglGlobalMess.empty()) printf("%s",mglGlobalMess.c_str());
- gr.Run();
- return 0;
+ return gr.Run();
}
//-----------------------------------------------------------------------------
set_target_properties(mgl-fltk PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(mgl-fltk PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS")
set_target_properties(mgl-fltk-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
- set_target_properties(mgl-fltk-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE)
+ target_compile_definitions(mgl-fltk-static PUBLIC MGL_STATIC_DEFINE)
target_link_libraries(mgl-fltk mgl ${FLTK_LIBRARIES})
if(enable-mgl2)
set_target_properties(mgl-glut PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(mgl-glut PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS")
set_target_properties(mgl-glut-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
- set_target_properties(mgl-glut-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE)
+ target_compile_definitions(mgl-glut-static PUBLIC MGL_STATIC_DEFINE)
target_link_libraries(mgl-glut mgl)
target_link_libraries(mgl-glut ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES})
set_target_properties(mgl-wx PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(mgl-wx PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS")
set_target_properties(mgl-wx-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
- set_target_properties(mgl-wx-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE)
+ target_compile_definitions(mgl-wx-static PUBLIC MGL_STATIC_DEFINE)
target_link_libraries(mgl-wx mgl)
target_link_libraries(mgl-wx ${wxWidgets_LIBRARIES})
Fl_MGLView *mgl; ///< Pointer to MGL widget with buttons
mglCanvasFL();
- ~mglCanvasFL();
+ virtual ~mglCanvasFL();
/// Create a window for plotting. Now implemeted only for GLUT.
void Window(int argc, char **argv, int (*draw)(mglBase *gr, void *p), const char *title,
//-----------------------------------------------------------------------------
Fl_MGLView::Fl_MGLView(int xx, int yy, int ww, int hh, const char *lbl) : Fl_Window(xx,yy,ww,hh,lbl)
{
+ Fl_Button *o;
grid = alpha = light = sshow = 0; menu = 0;
next = prev = reload = NULL; delay = NULL;
- Fl_Button *o;
- Fl_Group *g = new Fl_Group(0,30,435,30);
-
+ Fl_Group *g = new Fl_Group(0,0,435,30);
alpha_bt = new Fl_Button(0, 1, 25, 25); alpha_bt->type(FL_TOGGLE_BUTTON);
alpha_bt->image(xpm_a1); alpha_bt->callback(mgl_alpha_cb,this);
alpha_bt->tooltip(mgl_gettext("Switch on/off transparency in the picture"));
-// alpha_bt->box(FL_PLASTIC_UP_BOX); alpha_bt->down_box(FL_PLASTIC_DOWN_BOX);
light_bt = new Fl_Button(25, 1, 25, 25); light_bt->type(FL_TOGGLE_BUTTON);
light_bt->image(xpm_l1); light_bt->callback(mgl_light_cb,this);
light_bt->tooltip(mgl_gettext("Switch on/off lightning in the picture"));
-// light_bt->box(FL_PLASTIC_UP_BOX); light_bt->down_box(FL_PLASTIC_DOWN_BOX);
grid_bt = new Fl_Button(50, 1, 25, 25); grid_bt->type(FL_TOGGLE_BUTTON);
grid_bt->image(xpm_wire); grid_bt->callback(mgl_grid_cb,this);
grid_bt->tooltip(mgl_gettext("Switch on/off grid drawing"));
- // grid_bt->box(FL_PLASTIC_UP_BOX); grid_bt->down_box(FL_PLASTIC_DOWN_BOX);
rotate_bt = new Fl_Button(80, 1, 25, 25);rotate_bt->type(FL_TOGGLE_BUTTON);
rotate_bt->image(xpm_r1); rotate_bt->callback(mgl_rotate_cb,this);
rotate_bt->tooltip(mgl_gettext("Rotate picture by holding left mouse button"));
-// rotate_bt->box(FL_PLASTIC_UP_BOX); rotate_bt->down_box(FL_PLASTIC_DOWN_BOX);
zoom_bt = new Fl_Button(105, 1, 25, 25); zoom_bt->type(FL_TOGGLE_BUTTON);
zoom_bt->image(xpm_z1); zoom_bt->callback(mgl_zoom_cb,this);
zoom_bt->tooltip(mgl_gettext("Zoom in selected region of the picture"));
-// zoom_bt->box(FL_PLASTIC_UP_BOX); zoom_bt->down_box(FL_PLASTIC_DOWN_BOX);
o = new Fl_Button(130, 1, 25, 25); o->tooltip(mgl_gettext("Return picture to normal zoom"));
o->image(new Fl_Pixmap(zoom_out_xpm)); o->callback(mgl_norm_cb,this);
-// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX);
-
o = new Fl_Button(160, 1, 25, 25); o->tooltip(mgl_gettext("Stop drawing"));
o->image(new Fl_Pixmap(stop_xpm)); o->callback(mgl_stop_cb,this);
-
o = new Fl_Button(160, 1, 25, 25); o->tooltip(mgl_gettext("Refresh the picture"));
o->image(new Fl_Pixmap(ok_xpm)); o->callback(mgl_draw_cb,this);
-// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX);
Fl_Counter *tet, *phi;
tet = new Fl_Counter(195, 1, 90, 25, 0); tet->callback(mgl_draw_cb,this);
tet->tooltip(mgl_gettext("Theta angle (tilt z-axis)"));
phi->lstep(10); phi->step(1); phi->range(-180,180);
phi->tooltip(mgl_gettext("Phi angle (rotate in x*y plane)"));
-// tet->box(FL_PLASTIC_UP_BOX); phi->box(FL_PLASTIC_UP_BOX);
g->end(); g->resizable(0);
- g = new Fl_Group(0,30,30,260);
+ g = new Fl_Group(0,0,30,260);
o = new Fl_Button(1, 30, 25, 25); o->tooltip(mgl_gettext("Shift the picture up"));
o->image(new Fl_Pixmap(up_1_xpm)); o->callback(mgl_su_cb,this);
// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX);
o = new Fl_Button(1, 55, 25, 25); o->tooltip(mgl_gettext("Shift the picture left"));
o->image(new Fl_Pixmap(left_1_xpm)); o->callback(mgl_sl_cb,this);
-// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX);
o = new Fl_Button(1, 80, 25, 25); o->tooltip(mgl_gettext("Zoom in the picture"));
o->image(new Fl_Pixmap(zoom_1_xpm)); o->callback(mgl_sz_cb,this);
-// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX);
o = new Fl_Button(1, 105, 25, 25); o->tooltip(mgl_gettext("Zoom out the picture"));
o->image(new Fl_Pixmap(norm_1_xpm)); o->callback(mgl_so_cb,this);
-// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX);
o = new Fl_Button(1, 130, 25, 25); o->tooltip(mgl_gettext("Shift the picture right"));
o->image(new Fl_Pixmap(right_1_xpm)); o->callback(mgl_sr_cb,this);
-// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX);
o = new Fl_Button(1, 155, 25, 25); o->tooltip(mgl_gettext("Shift the picture down"));
o->image(new Fl_Pixmap(down_1_xpm)); o->callback(mgl_sd_cb,this);
-// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX);
o = new Fl_Button(1, 185, 25, 25); o->tooltip(mgl_gettext("Show previous frame in slideshow"));
o->image(new Fl_Pixmap(prev_sl_xpm)); o->callback(mgl_sprev_cb,this);
-// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX);
anim_bt = new Fl_Button(1, 210, 25, 25); anim_bt->type(FL_TOGGLE_BUTTON);
anim_bt->image(xpm_s1); anim_bt->callback(mgl_sshow_cb,this);
anim_bt->tooltip(mgl_gettext("Run/Stop slideshow (graphics animation)"));
-// anim_bt->box(FL_PLASTIC_UP_BOX); anim_bt->down_box(FL_PLASTIC_DOWN_BOX);
o = new Fl_Button(1, 235, 25, 25); o->tooltip(mgl_gettext("Show next frame in slideshow"));
o->image(new Fl_Pixmap(next_sl_xpm)); o->callback(mgl_snext_cb,this);
-// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX);
-
g->end(); g->resizable(0);
scroll = new Fl_Scroll(30, 30, 800, 600);
FMGL->tet_val = tet;
FMGL->phi_val = phi;
FMGL->set_popup(pop_graph,FMGL,this);
- scroll->end();
- resizable(scroll); end();
+ scroll->end(); resizable(scroll); end();
}
Fl_MGLView::~Fl_MGLView() {}
//-----------------------------------------------------------------------------
#define MGL_MAX_LINES (INT_MAX-1000)
#if !defined(WIN32) && !defined(__APPLE__)
#include <X11/Xlib.h>
-#include <qt5/QtCore/QTimer>
#endif
//-----------------------------------------------------------------------------
/// Base class for windows containing MathGL graphics
QMainWindow *Wnd; ///< Pointer to window
mglCanvasQT();
+ virtual ~mglCanvasQT() { if(Wnd) delete Wnd; }
/// Create a window for plotting. Now implemeted only for GLUT.
void Window(int argc, char **argv, int (*draw)(mglBase *gr, void *p),const char *title,
//-----------------------------------------------------------------------------
QMathGL::~QMathGL()
{
+ timer->stop(); timerRefr->stop();
if(mgl_use_graph(gr,-1)<1) mgl_delete_graph(gr);
if(grBuf) delete []grBuf;
if(draw) delete draw;
// must be placed before ANY window creation
XInitThreads();
#endif
- QApplication *a;
- if(!argv)
- {
- static char tmp[2][1];
- tmp[0][0]=tmp[1][0]=0;
- static int aa=1;
- a = new QApplication(aa, (char **)tmp);
- }
- else a = new QApplication(argc, argv);
+// static char buf=0, *tmp=&buf;
+// if(!argv) { argc = 1; argv = &tmp; }
+ if(!argv) argc = 0;
+ QApplication *a = new QApplication(argc, argv);
a->connect(a, SIGNAL(lastWindowClosed()), a, SLOT(quit()));
}
set_target_properties(mgl-${mglqt} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(mgl-${mglqt} PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS")
set_target_properties(mgl-${mglqt}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
- set_target_properties(mgl-${mglqt}-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE)
+ target_compile_definitions(mgl-${mglqt}-static PUBLIC MGL_STATIC_DEFINE)
target_link_libraries(mgl-${mglqt} mgl)
target_link_libraries(mgl-${mglqt} ${QT_LIBRARIES})
set_target_properties(mgl-wnd PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(mgl-wnd PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS")
set_target_properties(mgl-wnd-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
- set_target_properties(mgl-wnd-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE)
-
+ target_compile_definitions(mgl-wnd-static PUBLIC MGL_STATIC_DEFINE)
if(enable-mgl2)
set_target_properties(mgl-wnd PROPERTIES OUTPUT_NAME "mgl2-wnd")
set_target_properties(mgl-wnd-static PROPERTIES OUTPUT_NAME "mgl2-wnd")
set_target_properties(mgl-${mglqt} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(mgl-${mglqt} PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS")
set_target_properties(mgl-${mglqt}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
- set_target_properties(mgl-${mglqt}-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE)
+ target_compile_definitions(mgl-${mglqt}-static PUBLIC MGL_STATIC_DEFINE)
target_link_libraries(mgl-${mglqt} mgl)
qt5_use_modules(mgl-${mglqt} Core Widgets Gui PrintSupport)
qt5_use_modules(mgl-${mglqt}-static Core Widgets Gui PrintSupport)
set_target_properties(mgl-wnd PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(mgl-wnd PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS")
set_target_properties(mgl-wnd-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
- set_target_properties(mgl-wnd-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE)
-
+ target_compile_definitions(mgl-wnd-static PUBLIC MGL_STATIC_DEFINE)
if(enable-mgl2)
set_target_properties(mgl-wnd PROPERTIES OUTPUT_NAME "mgl2-wnd")
set_target_properties(mgl-wnd-static PROPERTIES OUTPUT_NAME "mgl2-wnd")