Imported Upstream version 2~rc2+svn358
authorDimitrios Eftaxiopoulos <eftaxi12@otenet.gr>
Thu, 8 Mar 2012 16:55:48 +0000 (18:55 +0200)
committerDimitrios Eftaxiopoulos <eftaxi12@otenet.gr>
Thu, 8 Mar 2012 16:55:48 +0000 (18:55 +0200)
36 files changed:
CMakeLists.txt
examples/full_test.cpp
include/mgl/base.h
include/mgl/base_cf.h
include/mgl/canvas_cf.h
include/mgl/define.h
include/mgl/mgl.h
include/mgl/parser.h
include/mgl/qt.h
lang/CMakeLists.txt
src/axis.cpp
src/base.cpp
src/base_cf.cpp
src/canvas.cpp
src/cont.cpp
src/data.cpp
src/parser.cpp
src/pixel.cpp
texinfo/CMakeLists.txt
texinfo/concept_en.texi
texinfo/example_en.texi
texinfo/mathgl_en.texi
texinfo/other_en.texi
texinfo/overview_en.texi
texinfo/parse_en.texi [new file with mode: 0644]
texinfo/parse_ru.texi [new file with mode: 0644]
todo.txt
udav/CMakeLists.txt
udav/qmglcanvas.cpp [deleted file]
udav/qmglcanvas.h [deleted file]
udav/style_dlg.cpp
udav/udav_wnd.cpp
utils/mglconv.cpp
utils/mglview.cpp
widgets/fltk.cpp
widgets/qt.cpp

index eb74cbda31bb198352b2a8c50e7a2ff8e043ef5c..9f1c281df42b8a8c9f3fc74bfba262d0b6ca6a00 100644 (file)
@@ -310,6 +310,6 @@ add_subdirectory( utils )
 add_subdirectory( examples )
 add_subdirectory( include )
 add_subdirectory( udav )
-add_subdirectory( mgllab )
+#add_subdirectory( mgllab )
 add_subdirectory( texinfo )
 add_subdirectory( lang )
index d0d7081492dabb2ebfcf5c1f2e0a782d26b4d28b..06eabbbf44dd1d88a420583f9316b7f0d5fdd35c 100644 (file)
@@ -44,125 +44,15 @@ int mini = 0;
 int big  = 0;\r
 int srnd = 0;\r
 //-----------------------------------------------------------------------------\r
+void smgl_colorbar(mglGraph *gr);\r
+void smgl_combined(mglGraph *gr);\r
+void save(mglGraph *gr,const char *name,const char *suf);\r
 void test(mglGraph *gr)\r
 {\r
-       gr->SubPlot(2,2,0);\r
-       float d,x1,x2,x0,y=0.95;\r
-       d=0.3, x0=0.2, x1=0.5, x2=0.6;\r
-       gr->Line(mglPoint(x0,1-0*d),mglPoint(x1,1-0*d),"k-");   gr->Puts(mglPoint(x2,y-0*d),"Solid '-'",":rL");\r
-       gr->Line(mglPoint(x0,1-1*d),mglPoint(x1,1-1*d),"k|");   gr->Puts(mglPoint(x2,y-1*d),"Long Dash '|'",":rL");\r
-       gr->Line(mglPoint(x0,1-2*d),mglPoint(x1,1-2*d),"k;");   gr->Puts(mglPoint(x2,y-2*d),"Dash ';'",":rL");\r
-       gr->Line(mglPoint(x0,1-3*d),mglPoint(x1,1-3*d),"k=");   gr->Puts(mglPoint(x2,y-3*d),"Small dash '='",":rL");\r
-       gr->Line(mglPoint(x0,1-4*d),mglPoint(x1,1-4*d),"kj");   gr->Puts(mglPoint(x2,y-4*d),"Dash-dot 'j'",":rL");\r
-       gr->Line(mglPoint(x0,1-5*d),mglPoint(x1,1-5*d),"ki");   gr->Puts(mglPoint(x2,y-5*d),"Small dash-dot 'i'",":rL");\r
-       gr->Line(mglPoint(x0,1-6*d),mglPoint(x1,1-6*d),"k:");   gr->Puts(mglPoint(x2,y-6*d),"Dots ':'",":rL");\r
-       gr->Line(mglPoint(x0,1-7*d),mglPoint(x1,1-7*d),"k ");   gr->Puts(mglPoint(x2,y-7*d),"None ' '",":rL");\r
-\r
-       d=0.25; x1=-1; x0=-0.8; y = -0.05;\r
-       gr->Mark(mglPoint(x1,5*d),".");         gr->Puts(mglPoint(x0,y+5*d),"'.'",":rL");\r
-       gr->Mark(mglPoint(x1,4*d),"+");         gr->Puts(mglPoint(x0,y+4*d),"'+'",":rL");\r
-       gr->Mark(mglPoint(x1,3*d),"x");         gr->Puts(mglPoint(x0,y+3*d),"'x'",":rL");\r
-       gr->Mark(mglPoint(x1,2*d),"*");         gr->Puts(mglPoint(x0,y+2*d),"'*'",":rL");\r
-       gr->Mark(mglPoint(x1,d),"s");           gr->Puts(mglPoint(x0,y+d),"'s'",":rL");\r
-       gr->Mark(mglPoint(x1,0),"d");           gr->Puts(mglPoint(x0,y),"'d'",":rL");\r
-       gr->Mark(mglPoint(x1,-d,0),"o");        gr->Puts(mglPoint(x0,y-d),"'o'",":rL");\r
-       gr->Mark(mglPoint(x1,-2*d,0),"^");      gr->Puts(mglPoint(x0,y-2*d),"'\\^'",":rL");\r
-       gr->Mark(mglPoint(x1,-3*d,0),"v");      gr->Puts(mglPoint(x0,y-3*d),"'v'",":rL");\r
-       gr->Mark(mglPoint(x1,-4*d,0),"<");      gr->Puts(mglPoint(x0,y-4*d),"'<'",":rL");\r
-       gr->Mark(mglPoint(x1,-5*d,0),">");      gr->Puts(mglPoint(x0,y-5*d),"'>'",":rL");\r
-\r
-       d=0.25; x1=-0.5; x0=-0.3;       y = -0.05;\r
-       gr->Mark(mglPoint(x1,5*d),"#.");        gr->Puts(mglPoint(x0,y+5*d),"'\\#.'",":rL");\r
-       gr->Mark(mglPoint(x1,4*d),"#+");        gr->Puts(mglPoint(x0,y+4*d),"'\\#+'",":rL");\r
-       gr->Mark(mglPoint(x1,3*d),"#x");        gr->Puts(mglPoint(x0,y+3*d),"'\\#x'",":rL");\r
-       gr->Mark(mglPoint(x1,2*d),"#*");        gr->Puts(mglPoint(x0,y+2*d),"'\\#*'",":rL");\r
-       gr->Mark(mglPoint(x1,d),"#s");          gr->Puts(mglPoint(x0,y+d),"'\\#s'",":rL");\r
-       gr->Mark(mglPoint(x1,0),"#d");          gr->Puts(mglPoint(x0,y),"'\\#d'",":rL");\r
-       gr->Mark(mglPoint(x1,-d,0),"#o");       gr->Puts(mglPoint(x0,y-d),"'\\#o'",":rL");\r
-       gr->Mark(mglPoint(x1,-2*d,0),"#^");     gr->Puts(mglPoint(x0,y-2*d),"'\\#\\^'",":rL");\r
-       gr->Mark(mglPoint(x1,-3*d,0),"#v");     gr->Puts(mglPoint(x0,y-3*d),"'\\#v'",":rL");\r
-       gr->Mark(mglPoint(x1,-4*d,0),"#<");     gr->Puts(mglPoint(x0,y-4*d),"'\\#<'",":rL");\r
-       gr->Mark(mglPoint(x1,-5*d,0),"#>");     gr->Puts(mglPoint(x0,y-5*d),"'\\#>'",":rL");\r
-\r
-       gr->SubPlot(2,2,1);\r
-       float a=0.1,b=0.4,c=0.5;\r
-       gr->Line(mglPoint(a,1),mglPoint(b,1),"k-A");            gr->Puts(mglPoint(c,1),"Style 'A' or 'A\\_'",":rL");\r
-       gr->Line(mglPoint(a,0.8),mglPoint(b,0.8),"k-V");        gr->Puts(mglPoint(c,0.8),"Style 'V' or 'V\\_'",":rL");\r
-       gr->Line(mglPoint(a,0.6),mglPoint(b,0.6),"k-K");        gr->Puts(mglPoint(c,0.6),"Style 'K' or 'K\\_'",":rL");\r
-       gr->Line(mglPoint(a,0.4),mglPoint(b,0.4),"k-I");        gr->Puts(mglPoint(c,0.4),"Style 'I' or 'I\\_'",":rL");\r
-       gr->Line(mglPoint(a,0.2),mglPoint(b,0.2),"k-D");        gr->Puts(mglPoint(c,0.2),"Style 'D' or 'D\\_'",":rL");\r
-       gr->Line(mglPoint(a,0),mglPoint(b,0),"k-S");            gr->Puts(mglPoint(c,0),"Style 'S' or 'S\\_'",":rL");\r
-       gr->Line(mglPoint(a,-0.2),mglPoint(b,-0.2),"k-O");      gr->Puts(mglPoint(c,-0.2),"Style 'O' or 'O\\_'",":rL");\r
-       gr->Line(mglPoint(a,-0.4),mglPoint(b,-0.4),"k-T");      gr->Puts(mglPoint(c,-0.4),"Style 'T' or 'T\\_'",":rL");\r
-       gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"k-_");      gr->Puts(mglPoint(c,-0.6),"Style '\\_' or none",":rL");\r
-       gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-AS");     gr->Puts(mglPoint(c,-0.8),"Style 'AS'",":rL");\r
-       gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-_A");         gr->Puts(mglPoint(c,-1),"Style '\\_A'",":rL");\r
-\r
-       a=-1;   b=-0.7; c=-0.6;\r
-       gr->Line(mglPoint(a,1),mglPoint(b,1),"kAA");            gr->Puts(mglPoint(c,1),"Style 'AA'",":rL");\r
-       gr->Line(mglPoint(a,0.8),mglPoint(b,0.8),"kVV");        gr->Puts(mglPoint(c,0.8),"Style 'VV'",":rL");\r
-       gr->Line(mglPoint(a,0.6),mglPoint(b,0.6),"kKK");        gr->Puts(mglPoint(c,0.6),"Style 'KK'",":rL");\r
-       gr->Line(mglPoint(a,0.4),mglPoint(b,0.4),"kII");        gr->Puts(mglPoint(c,0.4),"Style 'II'",":rL");\r
-       gr->Line(mglPoint(a,0.2),mglPoint(b,0.2),"kDD");        gr->Puts(mglPoint(c,0.2),"Style 'DD'",":rL");\r
-       gr->Line(mglPoint(a,0),mglPoint(b,0),"kSS");            gr->Puts(mglPoint(c,0),"Style 'SS'",":rL");\r
-       gr->Line(mglPoint(a,-0.2),mglPoint(b,-0.2),"kOO");      gr->Puts(mglPoint(c,-0.2),"Style 'OO'",":rL");\r
-       gr->Line(mglPoint(a,-0.4),mglPoint(b,-0.4),"kTT");      gr->Puts(mglPoint(c,-0.4),"Style 'TT'",":rL");\r
-       gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"k-__");     gr->Puts(mglPoint(c,-0.6),"Style '\\_\\_'",":rL");\r
-       gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-VA");     gr->Puts(mglPoint(c,-0.8),"Style 'VA'",":rL");\r
-       gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-AV");         gr->Puts(mglPoint(c,-1),"Style 'AV'",":rL");\r
-\r
-       gr->SubPlot(2,2,2);\r
-       //#LENUQ\r
-       gr->FaceZ(mglPoint(-1,  -1), 0.4, 0.3, "L#");   gr->Puts(mglPoint(-0.8,-0.9), "L", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.6,-1), 0.4, 0.3, "E#");   gr->Puts(mglPoint(-0.4,-0.9), "E", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.2,-1), 0.4, 0.3, "N#");   gr->Puts(mglPoint(0,  -0.9), "N", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.2, -1), 0.4, 0.3, "U#");   gr->Puts(mglPoint(0.4,-0.9), "U", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.6, -1), 0.4, 0.3, "Q#");   gr->Puts(mglPoint(0.8,-0.9), "Q", "w:C", -1.4);\r
-       //#lenuq\r
-       gr->FaceZ(mglPoint(-1,  -0.7), 0.4, 0.3, "l#"); gr->Puts(mglPoint(-0.8,-0.6), "l", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.6,-0.7), 0.4, 0.3, "e#"); gr->Puts(mglPoint(-0.4,-0.6), "e", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.2,-0.7), 0.4, 0.3, "n#"); gr->Puts(mglPoint(0,  -0.6), "n", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.2, -0.7), 0.4, 0.3, "u#"); gr->Puts(mglPoint(0.4,-0.6), "u", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.6, -0.7), 0.4, 0.3, "q#"); gr->Puts(mglPoint(0.8,-0.6), "q", "k:C", -1.4);\r
-       //#CMYkP\r
-       gr->FaceZ(mglPoint(-1,  -0.4), 0.4, 0.3, "C#"); gr->Puts(mglPoint(-0.8,-0.3), "C", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.6,-0.4), 0.4, 0.3, "M#"); gr->Puts(mglPoint(-0.4,-0.3), "M", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.2,-0.4), 0.4, 0.3, "Y#"); gr->Puts(mglPoint(0,  -0.3), "Y", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.2, -0.4), 0.4, 0.3, "k#"); gr->Puts(mglPoint(0.4,-0.3), "k", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.6, -0.4), 0.4, 0.3, "P#"); gr->Puts(mglPoint(0.8,-0.3), "P", "w:C", -1.4);\r
-       //#cmywp\r
-       gr->FaceZ(mglPoint(-1,  -0.1), 0.4, 0.3, "c#"); gr->Puts(mglPoint(-0.8, 0), "c", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.6,-0.1), 0.4, 0.3, "m#"); gr->Puts(mglPoint(-0.4, 0), "m", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.2,-0.1), 0.4, 0.3, "y#"); gr->Puts(mglPoint(0,   0), "y", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.2, -0.1), 0.4, 0.3, "w#"); gr->Puts(mglPoint(0.4, 0), "w", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.6, -0.1), 0.4, 0.3, "p#"); gr->Puts(mglPoint(0.8, 0), "p", "k:C", -1.4);\r
-       //#BGRHW\r
-       gr->FaceZ(mglPoint(-1,  0.2), 0.4, 0.3, "B#");  gr->Puts(mglPoint(-0.8, 0.3), "B", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.6,0.2), 0.4, 0.3, "G#");  gr->Puts(mglPoint(-0.4, 0.3), "G", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.2,0.2), 0.4, 0.3, "R#");  gr->Puts(mglPoint(0,   0.3), "R", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.2, 0.2), 0.4, 0.3, "H#");  gr->Puts(mglPoint(0.4, 0.3), "H", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.6, 0.2), 0.4, 0.3, "W#");  gr->Puts(mglPoint(0.8, 0.3), "W", "w:C", -1.4);\r
-       //#bgrhw\r
-       gr->FaceZ(mglPoint(-1,  0.5), 0.4, 0.3, "b#");  gr->Puts(mglPoint(-0.8, 0.6), "b", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.6,0.5), 0.4, 0.3, "g#");  gr->Puts(mglPoint(-0.4, 0.6), "g", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.2,0.5), 0.4, 0.3, "r#");  gr->Puts(mglPoint(0,   0.6), "r", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.2, 0.5), 0.4, 0.3, "h#");  gr->Puts(mglPoint(0.4, 0.6), "h", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.6, 0.5), 0.4, 0.3, "w#");  gr->Puts(mglPoint(0.8, 0.6), "w", "k:C", -1.4);\r
-       //#brighted\r
-       gr->FaceZ(mglPoint(-1,  0.8), 0.4, 0.3, "{r1}#");       gr->Puts(mglPoint(-0.8, 0.9), "\\{r1\\}", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.6,0.8), 0.4, 0.3, "{r3}#");       gr->Puts(mglPoint(-0.4, 0.9), "\\{r3\\}", "w:C", -1.4);\r
-       gr->FaceZ(mglPoint(-0.2,0.8), 0.4, 0.3, "{r5}#");       gr->Puts(mglPoint(0,   0.9), "\\{r5\\}", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.2, 0.8), 0.4, 0.3, "{r7}#");       gr->Puts(mglPoint(0.4, 0.9), "\\{r7\\}", "k:C", -1.4);\r
-       gr->FaceZ(mglPoint(0.6, 0.8), 0.4, 0.3, "{r9}#");       gr->Puts(mglPoint(0.8, 0.9), "\\{r9\\}", "k:C", -1.4);\r
-\r
-       gr->SubPlot(2,2,3);\r
-       char stl[3]="r1", txt[4]="'1'";\r
-       for(int i=0;i<10;i++)\r
-       {\r
-               txt[1]=stl[1]='0'+i;\r
-               gr->Line(mglPoint(-1,0.2*i-1),mglPoint(1,0.2*i-1),stl);\r
-               gr->Puts(mglPoint(1.05,0.2*i-1),txt,":L");\r
-       }\r
+       gr->DefaultPlotParam(); gr->Clf();\r
+       smgl_colorbar(gr);      save(gr, "colorbar", "");\r
+       gr->DefaultPlotParam(); gr->Clf();\r
+       smgl_combined(gr);      save(gr, "combined", "");\r
        return;\r
 \r
        mglParse par;\r
index bc7b77f1a49a0765eee0eda8811ef43a1d0bcdbb..6104428e1ed8b03b074e4e69168ef06586ee989c 100644 (file)
@@ -175,6 +175,7 @@ public:
        mglPoint Max;           ///< Upper edge of bounding box for graphics.\r
        std::string Mess;       ///< Buffer for receiving messages\r
        int ObjId;                      ///< object id for mglPrim\r
+       int HighId;                     ///< object id to be highlited\r
        std::vector<mglGroup> Grp;      ///< List of groups with names -- need for export\r
        std::string PlotId;     ///< Id of plot for saving filename (in GLUT window for example)\r
 \r
@@ -269,8 +270,8 @@ public:
        virtual void StartAutoGroup (const char *)=0;\r
        void StartGroup(const char *name, int id);\r
        virtual void EndGroup()=0;      //      {       LoadState();    }\r
-       /// Highlight next group\r
-       inline void Highlight() {       set(MGL_HIGHLIGHT);     }\r
+       /// Highlight group\r
+       inline void Highlight(int id)   {       HighId=id;      }\r
 \r
        /// Set FontSize by size in pt and picture DPI (default is 16 pt for dpi=72)\r
        virtual void SetFontSizePT(float pt, int dpi=72){       FontSize = pt*27.f/dpi; }\r
index b00492a78af92f3082aa79c4513e662deacfa097..d3383d2fb92ca20c27a74407bce8dc01b029d08d 100644 (file)
@@ -31,7 +31,7 @@ const char *mgl_get_mess(HMGL gr);
 long mgl_use_graph(HMGL gr, int inc);\r
 void mgl_start_group(HMGL gr, const char *);\r
 void mgl_end_group(HMGL gr);\r
-void mgl_highlight(HMGL gr);\r
+void mgl_highlight(HMGL gr, int id);\r
 \r
 void mgl_set_palette(HMGL gr, const char *colors);\r
 void mgl_set_alpha_default(HMGL graph, float alpha);\r
@@ -75,7 +75,7 @@ void mgl_set_warn_(uintptr_t *gr, int *code, const char *text,int);
 long mgl_use_graph_(uintptr_t *gr, int *inc);\r
 void mgl_start_group_(uintptr_t *gr, const char *,int);\r
 void mgl_end_group_(uintptr_t *gr);\r
-void mgl_highlight_(uintptr_t *gr);\r
+void mgl_highlight_(uintptr_t *gr, int *id);\r
 \r
 void mgl_set_palette_(uintptr_t *gr, const char *colors, int);\r
 void mgl_set_pal_color_(uintptr_t *graph, int *n, float *r, float *g, float *b);\r
index 41ca369bbe1ab929873c879e614e96af9611ffa4..3e807f3508547e55a1a3e43525d580445122d053 100644 (file)
@@ -311,8 +311,8 @@ void mgl_del_var(HMPR p, const char *name);
 int mgl_parse(HMGL gr, HMPR p, const char *str, int pos);\r
 int mgl_parsew(HMGL gr, HMPR p, const wchar_t *str, int pos);\r
 void mgl_parse_file(HMGL gr, HMPR p, FILE *fp, int print);\r
-void mgl_parse_text(HMGL gr, HMPR p, const char *str, void (*error)(const char *mes, void *par), int high, void *par);\r
-void mgl_parsew_text(HMGL gr, HMPR p, const wchar_t *str, void (*error)(const char *mes, void *par), int high, void *par);\r
+void mgl_parse_text(HMGL gr, HMPR p, const char *str);\r
+void mgl_parsew_text(HMGL gr, HMPR p, const wchar_t *str);\r
 void mgl_restore_once(HMPR p);\r
 void mgl_parser_allow_setsize(HMPR p, int a);\r
 void mgl_parser_stop(HMPR p);\r
index 247cb4026f4b0567f4599760896fe2d99863fccc..dff47c797b6d198998382cfc58e1959b9076ca5b 100644 (file)
@@ -170,7 +170,7 @@ enum{       // Codes for warnings/messages
 #define MGL_AUTO_CLF           0x000800        ///< Clear canvas between drawing\r
 #define MGL_SHOW_POS           0x001000        ///< Switch to show or not mouse click position\r
 #define MGL_CLF_ON_UPD         0x002000        ///< Clear plot before Update()\r
-#define MGL_HIGHLIGHT          0x004000        ///< Highlight plot\r
+//#define MGL_HIGHLIGHT                0x004000        ///< Highlight plot\r
 #define MGL_DIFFUSIVE          0x008000        ///< Use diffusive light instead of specular\r
 #define MGL_USEDRWDAT          0x010000        ///< Use DrwDat to remember all data of frames\r
 #define MGL_REDUCEACC          0x020000        ///< Reduce accuracy of points (to reduc size of output files)\r
index 56611b6670a2c73b0193170aa7446d28292feaba..ef33e2146d185ef1772bb97d7a1b488ab78e82ea 100644 (file)
@@ -258,7 +258,7 @@ public:
        /// End group of objects\r
        inline void EndGroup()  {       mgl_end_group(gr);      }\r
        /// Highlight next group\r
-       inline void Highlight() {       mgl_highlight(gr);      }\r
+       inline void Highlight(int id)   {       mgl_highlight(gr, id);  }\r
 \r
        /// Show currently produced image\r
        inline void ShowImage(const char *viewer, bool keep=0)\r
@@ -1105,10 +1105,10 @@ public:
        {       return mgl_parse(gr->Self(), pr, str, pos);     }\r
        inline int Parse(mglGraph *gr, const wchar_t *str, int pos)\r
        {       return mgl_parsew(gr->Self(), pr, str, pos);    }\r
-       inline void Execute(mglGraph *gr, const char *str, void (*error)(const char *mes, void *par)=NULL, int high=-1, void *par=NULL)\r
-       {       mgl_parse_text(gr->Self(), pr, str, error, high, par);  }\r
-       inline void Execute(mglGraph *gr, const wchar_t *str, void (*error)(const char *mes, void *par)=NULL, int high=-1, void *par=NULL)\r
-       {       mgl_parsew_text(gr->Self(), pr, str, error, high, par); }\r
+       inline void Execute(mglGraph *gr, const char *str)\r
+       {       mgl_parse_text(gr->Self(), pr, str);    }\r
+       inline void Execute(mglGraph *gr, const wchar_t *str)\r
+       {       mgl_parsew_text(gr->Self(), pr, str);   }\r
        inline void Execute(mglGraph *gr, FILE *fp, bool print=false)\r
        {       mgl_parse_file(gr->Self(), pr, fp, print);      }\r
        inline int CmdType(const char *name)\r
index 9ec33a672c8ddbebae2e07a1f92c7778a1337168..fae19c6d3d74f90e8ebd2406ccd5130df1cb27d0 100644 (file)
@@ -135,17 +135,17 @@ public:
        {       mglGraph GR(gr);        Execute(&GR,fp,print);  }\r
        void Execute(mglGraph *gr, FILE *fp, bool print=false);\r
        /// Execute MGL script from array of lines\r
-       inline void Execute(HMGL gr, int num, const wchar_t **text, void (*error)(const char *mes, void *par)=NULL, int high=-1, void *par=NULL)\r
-       {       mglGraph GR(gr);        Execute(&GR,num,text,error,high);       }\r
-       void Execute(mglGraph *gr, int num, const wchar_t **text, void (*error)(const char *mes, void *par)=NULL, int high=-1, void *par=NULL);\r
+       inline void Execute(HMGL gr, int num, const wchar_t **text)\r
+       {       mglGraph GR(gr);        Execute(&GR,num,text);  }\r
+       void Execute(mglGraph *gr, int num, const wchar_t **text);\r
        /// Execute MGL script text with '\n' separated lines\r
-       inline void Execute(HMGL gr, const wchar_t *text, void (*error)(const char *mes, void *par)=NULL, int high=-1, void *par=NULL)\r
-       {       mglGraph GR(gr);        Execute(&GR,text,error,high);   }\r
-       void Execute(mglGraph *gr, const wchar_t *text, void (*error)(const char *mes, void *par)=NULL, int high=-1, void *par=NULL);\r
+       inline void Execute(HMGL gr, const wchar_t *text)\r
+       {       mglGraph GR(gr);        Execute(&GR,text);      }\r
+       void Execute(mglGraph *gr, const wchar_t *text);\r
        /// Execute MGL script text with '\n' separated lines\r
-       inline void Execute(HMGL gr, const char *text, void (*error)(const char *mes, void *par)=NULL, int high=-1, void *par=NULL)\r
-       {       mglGraph GR(gr);        Execute(&GR,text,error,high);   }\r
-       void Execute(mglGraph *gr, const char *text, void (*error)(const char *mes, void *par)=NULL, int high=-1, void *par=NULL);\r
+       inline void Execute(HMGL gr, const char *text)\r
+       {       mglGraph GR(gr);        Execute(&GR,text);      }\r
+       void Execute(mglGraph *gr, const char *text);\r
        /// Scan for functions (use NULL for reset)\r
        void ScanFunc(const wchar_t *line);\r
        /// Check if name is function and return its address (or 0 if no)\r
index 40d9d2513bfdafd45eaa4ddbe872d31d65c1ddc2..b54d574d7a51134e48f4245606768d3df5798f52 100644 (file)
@@ -204,7 +204,7 @@ struct mglDrawScript : public mglDraw
        long line;              ///< Line which will be highlited\r
        mglDrawScript(HMPR p)   {       par=p;  line=-1;        }\r
        int Draw(mglGraph *gr)\r
-       {       mgl_parse_text(gr->Self(),par,text.toAscii(),NULL,line,NULL);   return 0;       }\r
+       {       gr->Highlight(line+1);  mgl_parse_text(gr->Self(),par,text.toAscii());  return 0;       }\r
 };\r
 //-----------------------------------------------------------------------------\r
 /// Convert bitmap from mglCanvasW to QPixmap\r
index 24dd94edd59024c8050d4b3dac0a3adf68b6df6d..e150326eef4feb6e94821fcf2bcd52775ad2f380 100644 (file)
@@ -1,27 +1,24 @@
 if(use_python)
-#      INCLUDE(${SWIG_USE_FILE})
+       INCLUDE(${SWIG_USE_FILE})
        INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
        INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
-       SET(CMAKE_SWIG_FLAGS "")
-
-#      SET_SOURCE_FILES_PROPERTIES(mgl.i PROPERTIES CPLUSPLUS ON)
-# #    SET_SOURCE_FILES_PROPERTIES(example.i PROPERTIES SWIG_FLAGS "-includeall")
-#      SWIG_ADD_MODULE(mathgl python mgl.i ../include/mgl/type.h ../include/mgl/data.h ../include/mgl/mgl.h)
-#      SWIG_LINK_LIBRARIES(mathgl ${PYTHON_LIBRARIES})
+       SET(CMAKE_SWIG_FLAGS "-c++")
+       SET_SOURCE_FILES_PROPERTIES(mgl.i PROPERTIES CPLUSPLUS ON)
+#      SET_SOURCE_FILES_PROPERTIES(example.i PROPERTIES SWIG_FLAGS "-includeall")
+       SWIG_ADD_MODULE(mathgl python mgl.i ../include/mgl/type.h ../include/mgl/data.h ../include/mgl/mgl.h)
+       SWIG_LINK_LIBRARIES(mathgl ${PYTHON_LIBRARIES})
 
 #      INSTALL_FILES(/lib/python2.7/dist-packages/ mathgl)
 
-       add_custom_command(OUTPUT mgl_python.cpp mathgl.py
-               COMMAND ${SWIG_EXECUTABLE} -python -c++ -I${CMAKE_SOURCE_DIR}/include -o mgl_python.cpp ${CMAKE_SOURCE_DIR}/lang/mgl.i
-               MAIN_DEPENDENCY mgl.i
-               IMPLICIT_DEPENDS CXX ../include/mgl/type.h ../include/mgl/data.h ../include/mgl/mgl.h
- #             WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/lang
-       )
-       add_custom_target(_mathgl.so ALL
-               COMMAND CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR} ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/setup.py build
- #             COMMAND CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR} ${PYTHON_EXECUTABLE}
-               DEPENDS ${CMAKE_BINARY_DIR}/lang/mathgl.py ${CMAKE_BINARY_DIR}/lang/mgl_python.cpp
-               WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
-       )
-       install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/setup.py install --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )")
+#      add_custom_command(OUTPUT mgl_python.cpp mathgl.py
+#              COMMAND ${SWIG_EXECUTABLE} -python -c++ -I${CMAKE_SOURCE_DIR}/include -o mgl_python.cpp ${CMAKE_SOURCE_DIR}/lang/mgl.i
+#              MAIN_DEPENDENCY mgl.i
+#              IMPLICIT_DEPENDS CXX ../include/mgl/type.h ../include/mgl/data.h ../include/mgl/mgl.h
+#      )
+#      add_custom_target(_mathgl.so ALL
+#              COMMAND CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR} ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/setup.py build
+#              DEPENDS ${CMAKE_BINARY_DIR}/lang/mathgl.py ${CMAKE_BINARY_DIR}/lang/mgl_python.cpp
+#              WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+#      )
+#      install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/setup.py install --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )")
 endif(use_python)
index 8aa4e211db4a5ff148d7b6757b44f44b8b0efff4..0e31b9c755be0369844277c69b9e22ccbe1193a6 100644 (file)
 #define islog(a, b) (((a)>0 && (b)>10*(a)) || ((b)<0 && (a)<10*(b)))
 #define sign(a)        ((a)<0 ? -1:1)
 //-----------------------------------------------------------------------------
-#ifdef WIN32   // NOTE: this is not thread safe!
+/*#ifdef WIN32 // NOTE: this is not thread safe!
 inline struct tm* localtime_r (const time_t *clock, struct tm *result)
 {      if (!clock || !result) return NULL;
        memcpy(result,localtime(clock),sizeof(*result));
        return result;  }
-#endif
+#endif*/
 //-----------------------------------------------------------------------------
 long mgl_have_color(const char *stl)
 {
@@ -567,6 +567,8 @@ void mglCanvas::DrawLabels(mglAxis &aa)
                {       ax=qq.u*cos(tet) - qq.v*sin(tet);       ay=qq.v*cos(tet) + qq.u*sin(tet);       }
                qq.u = ax;      qq.v = ay;
 
+               if(!get(MGL_ENABLE_RTEXT))      pos[2] = nn.x<0 || (nn.x==0 && nn.y<0) ? 'L':'R';
+
                if(aa.ch=='c' && aa.txt[i].text[0]==' ')        qq.u = qq.v = NAN;
                if(!get(MGL_DISABLE_SCALE))     pos[0]=(qq.u*nn.y-qq.v*nn.x>0) ? 'T':'t';
                if(aa.ch=='T' && pos[0]=='T')   pos[0]='t';
index dfde8df3a6f761b23cfd9c0c0026c27a6c648394..3d79ec8fbc866330c391ac0a4e34fa500279f05a 100644 (file)
@@ -57,7 +57,7 @@ mglBase::mglBase()
        pthread_mutex_init(&mutexPnt,0);\r
        pthread_mutex_init(&mutexTxt,0);\r
 #endif\r
-       fnt=0;  *FontDef==0;\r
+       fnt=0;  *FontDef=0;\r
        fx=fy=fz=fa=fc=0;\r
 \r
        InUse = 1;\r
index 15f37d4fa7eca8d3776b16351a26bbef460882d9..64d37a5a7928820d059ca09f7ce9e3318364ba1b 100644 (file)
@@ -36,7 +36,7 @@ void mgl_set_alpha_default(HMGL gr, float alpha)      {       gr->SetAlphaDef(alpha); }
 void mgl_set_light_dif(HMGL gr, int enable)            {       gr->SetDifLight(enable);        }\r
 //-----------------------------------------------------------------------------\r
 void mgl_set_rdc_acc(HMGL gr, int reduce)      {       gr->SetReduceAcc(reduce);       }\r
-void mgl_highlight(HMGL gr)                    {       gr->Highlight();        }\r
+void mgl_highlight(HMGL gr, int id)                    {       gr->Highlight(id);      }\r
 void mgl_set_cut(HMGL gr, int cut)     {       gr->SetCut(cut);        }\r
 void mgl_set_cut_box(HMGL gr, float x1,float y1,float z1,float x2,float y2,float z2)\r
 {      gr->SetCutBox(x1,y1,z1,x2,y2,z2);       }\r
@@ -73,7 +73,7 @@ void mgl_set_bar_width(HMGL gr, float width)  {       gr->SetBarWidth(width); }
 //-----------------------------------------------------------------------------\r
 void mgl_set_rdc_acc_(uintptr_t *gr, int *reduce)\r
 {      _GR_->SetReduceAcc(*reduce);    }\r
-void mgl_highlight_(uintptr_t *gr)     {       _GR_->Highlight();      }\r
+void mgl_highlight_(uintptr_t *gr, int *id)    {       _GR_->Highlight(*id);   }\r
 void mgl_set_origin_(uintptr_t *gr, float *x0, float *y0, float *z0)\r
 {      _GR_->SetOrigin(*x0,*y0,*z0);   }\r
 int mgl_get_warn_(uintptr_t *gr)       {       return _GR_->GetWarn(); }\r
index 5653cdc0809b98f71089be28907e481a786cb9a2..b5121aa6d95c3f0ad69ae1dfad1aed2850b4aa0f 100644 (file)
@@ -72,7 +72,7 @@ void mglCanvas::add_prim(mglPrim &a)
 {\r
        if(a.n1>=0)\r
        {       a.z = Pnt[a.n1].z;      // this is a bit less accurate but simpler for transformation\r
-               a.id = ObjId;   MGL_PUSH(Prm,a,mutexPrm);       clr(MGL_FINISHED);      }\r
+               a.id = ObjId;   MGL_PUSH(Prm,a,mutexPrm);       }\r
 }\r
 //-----------------------------------------------------------------------------\r
 void mglCanvas::DefaultPlotParam()\r
@@ -90,7 +90,7 @@ int Depth;                    ///< Depth of the image
 int CurFrameId;                ///< Number of automaticle created frames\r
 GifFileType *gif;*/\r
        SetTickRotate(true);    SetTickSkip(true);\r
-       SetWarn(mglWarnNone);   ObjId = 0;\r
+       SetWarn(mglWarnNone);   ObjId = -1;\r
        SetFunc(0,0);   Stop=false;     CutOff(0);      Ternary(0);\r
        SetRanges(mglPoint(-1,-1,-1,-1), mglPoint(1,1,1,1));\r
        SetBarWidth(0.7);       SetMarkSize(1); SetArrowSize(1);\r
@@ -780,5 +780,5 @@ void mglCanvas::StartAutoGroup (const char *lbl)
        MGL_PUSH(Grp,mglGroup(lbl,ObjId),mutexGrp);\r
 }\r
 //-----------------------------------------------------------------------------\r
-void mglCanvas::EndGroup()     {       LoadState();    clr(MGL_HIGHLIGHT);     }\r
+void mglCanvas::EndGroup()     {       LoadState();    }\r
 //-----------------------------------------------------------------------------\r
index db9fd12fa7bb673817bd91c659b8273658c5d0ea..d9ce5fe118f76e60b1d2f4d39d26f2bb8bf25732 100644 (file)
@@ -904,6 +904,9 @@ void mgl_get_slice(_mgl_slice &s, HCDT x, HCDT y, HCDT z, HCDT a, char dir, floa
        s.x.Create(nx,ny);      s.y.Create(nx,ny);\r
        s.z.Create(nx,ny);      s.a.Create(nx,ny);\r
        p = long(d);    d -= p;\r
+       if(dir=='x' && p>=n-1)  {       d+=p-n+2;       p=n-2;  }\r
+       if(dir=='y' && p>=m-1)  {       d+=p-m+2.;      p=m-2;  }\r
+       if(dir=='z' && p>=l-1)  {       d+=p-l+2;       p=l-2;  }\r
        float v;\r
 \r
        if(both)\r
index 0ca22be9c50033a25fd80e70d39db0a8e73f41d5..b485f8282994978c6f41446d857e62870e459fa2 100644 (file)
@@ -29,14 +29,33 @@ void mglFillP(long x, const mreal *a,long nx,mreal _p[4]);
 void mglFillP5(long x,long y, const mreal *a,long nx,long ny,mreal _p[6][6]);\r
 void mglFillP5(long x, const mreal *a,long nx,mreal _p[6]);\r
 //-----------------------------------------------------------------------------\r
+#ifdef HAVE_PTHREAD\r
+#ifdef WIN32\r
+#include <windows.h>\r
+#include <process.h>\r
+#elif defined(__APPLE__) || defined (__FreeBSD__)\r
+#include <sys/sysctl.h>\r
+#elif defined(unix) || defined(__unix) || defined(__unix__)\r
+#include <sys/sysinfo.h>\r
+#endif\r
 void mglSetNumThr(int n)\r
 {\r
-#ifdef HAVE_PTHREAD\r
-       mglNumThr = n>0 ? n : sysconf(_SC_NPROCESSORS_CONF);\r
+#ifdef WIN32\r
+       SYSTEM_INFO systemInfo;\r
+       GetSystemInfo(&systemInfo);\r
+       mglNumThr = n>0 ? n : systemInfo.dwNumberOfProcessors;\r
+#elif defined (__APPLE__) || defined(__FreeBSD__)\r
+       int numProcessors = 1;\r
+       size_t size = sizeof(numProcessors);\r
+       sysctlbyname("hw.ncpu", &numProcessors, &size, NULL, 0);\r
+       mglNumThr = n>0 ? n : numProcessors;\r
 #else\r
-       mglNumThr = 1;\r
+       mglNumThr = n>0 ? n : get_nprocs_conf();\r
 #endif\r
 }\r
+#else\r
+void mglSetNumThr(int) {       mglNumThr = 1;  }\r
+#endif\r
 //-----------------------------------------------------------------------------\r
 void mglStartThread(void *(*func)(void *), void (*post)(mglThreadD *,mreal *), long n, mreal *a,\r
        const mreal *b, const mreal *c, const long *p, void *v, const mreal *d, const mreal *e, char *s)\r
index 5d93adec4a60e9abdc6995247c4161563bc0f731..6bf7d21b8d8e6d45ae2e5e65d6a071d03ecd5270 100644 (file)
@@ -892,18 +892,17 @@ int mglParser::FlowExec(mglGraph *, const wchar_t *com, long m, mglArg *a)
        return n+1;
 }
 //-----------------------------------------------------------------------------
-void mgl_error_print(const char *mess, void *)
-{      if(mess && *mess)       printf("%s\n",mess);    }
 #include <string>
 void mglParser::Execute(mglGraph *gr, FILE *fp, bool print)
 {
        if(gr==0 || fp==0)      return;
        std::wstring str;
        while(!feof(fp))        str.push_back(fgetwc(fp));
-       Execute(gr,str.c_str(),print?mgl_error_print:NULL);
+       Execute(gr,str.c_str());
+       if(print)       printf("%s\n",gr->Message());
 }
 //-----------------------------------------------------------------------------
-void mglParser::Execute(mglGraph *gr, int n, const wchar_t **text, void (*error)(const char *mes, void *par), int high, void *par)
+void mglParser::Execute(mglGraph *gr, int n, const wchar_t **text)
 {
        if(n<1 || text==0)      return;
        long i, r;
@@ -913,7 +912,6 @@ void mglParser::Execute(mglGraph *gr, int n, const wchar_t **text, void (*error)
        for(i=0;i<n;i++)
        {
                gr->SetWarn(-1, NULL);
-               if(i==high)     gr->Highlight();
                gr->SetObjId(i+1);
                r = Parse(gr,text[i],i+1);
                if(r<0) {       i = -r-2;       continue;       }
@@ -925,11 +923,9 @@ void mglParser::Execute(mglGraph *gr, int n, const wchar_t **text, void (*error)
                else *buf=0;
                if(*buf)        gr->SetWarn(-2,buf);
        }
-       const char *mess=gr->Message();
-       if(error && mess && *mess)      error(mess,par);
 }
 //-----------------------------------------------------------------------------
-void mglParser::Execute(mglGraph *gr, const wchar_t *text, void (*error)(const char *mes, void *par), int high, void *par)
+void mglParser::Execute(mglGraph *gr, const wchar_t *text)
 {
        unsigned s = wcslen(text)+1;
        wchar_t *wcs = new wchar_t[s];
@@ -955,16 +951,16 @@ void mglParser::Execute(mglGraph *gr, const wchar_t *text, void (*error)(const c
 
                }
        }
-       Execute(gr, n, str, error, high, par);
+       Execute(gr, n, str);
        delete []wcs;   free(str);
 }
 //-----------------------------------------------------------------------------
-void mglParser::Execute(mglGraph *gr, const char *text, void (*error)(const char *mes, void *par), int high, void *par)
+void mglParser::Execute(mglGraph *gr, const char *text)
 {
        unsigned s = strlen(text)+1;
        wchar_t *wcs = new wchar_t[s];
        mbstowcs(wcs,text,s);
-       Execute(gr, wcs, error, high, par);
+       Execute(gr, wcs);
        delete []wcs;
 }
 //-----------------------------------------------------------------------------
@@ -1022,10 +1018,10 @@ int mgl_parse(HMGL gr, HMPR p, const char *str, int pos)
 {      return p->Parse(gr, str, pos);  }
 int mgl_parsew(HMGL gr, HMPR p, const wchar_t *str, int pos)
 {      return p->Parse(gr, str, pos);  }
-void mgl_parse_text(HMGL gr, HMPR p, const char *str, void (*error)(const char *mes, void *par), int high, void *par)
-{      p->Execute(gr, str, error, high, par);  }
-void mgl_parsew_text(HMGL gr, HMPR p, const wchar_t *str, void (*error)(const char *mes, void *par), int high, void *par)
-{      p->Execute(gr, str, error, high, par);  }
+void mgl_parse_text(HMGL gr, HMPR p, const char *str)
+{      p->Execute(gr, str);    }
+void mgl_parsew_text(HMGL gr, HMPR p, const wchar_t *str)
+{      p->Execute(gr, str);    }
 void mgl_parse_file(HMGL gr, HMPR p, FILE *fp, int print)
 {      p->Execute(gr,fp,print);        }
 void mgl_restore_once(HMPR p)  {       p->RestoreOnce();       }
index 0e6dbb9c844bdc97c280ad5db479238c2470a823..8bc59e9c0a85f1d2a4453d06402f6f5097963e84 100644 (file)
@@ -276,7 +276,8 @@ void mglCanvas::pxl_primdr(unsigned long id, unsigned long n, const void *)
        mglPrim p;\r
        for(i=0;i<n;i++)\r
        {\r
-               p=Prm[i];       PDef=p.n3;      pPos=p.s;       PenWidth=p.w;\r
+               p=Prm[i];       PDef=p.n3;      pPos=p.s;\r
+               ObjId = p.id;   PenWidth=p.w;\r
                switch(p.type)\r
                {\r
                case 0: mark_draw(p.n1,p.n4,p.s,&d);    break;\r
@@ -286,7 +287,7 @@ void mglCanvas::pxl_primdr(unsigned long id, unsigned long n, const void *)
                case 4: glyph_draw(&p,&d);      break;\r
                }\r
        }\r
-       PDef=pdef;      pPos=ss;        PenWidth=ww;\r
+       PDef=pdef;      pPos=ss;        PenWidth=ww;    ObjId=-1;\r
 }\r
 //-----------------------------------------------------------------------------\r
 void mglCanvas::pxl_combine(unsigned long id, unsigned long n, const void *)\r
@@ -517,7 +518,7 @@ unsigned char* mglCanvas::col2int(const mglPnt &p,unsigned char *r)
        else\r
        {       b0=p.r; b1=p.g; b2=p.b; }\r
        // try to highlight faces\r
-       if(get(MGL_HIGHLIGHT))  {       b0*=0.7;        b1*=0.7;        b2*=0.7;        }\r
+       if(ObjId==HighId)       {       b0*=0.7;        b1*=0.7;        b2*=0.7;        }\r
        r[0] = (unsigned char)(255*b0);\r
        r[1] = (unsigned char)(255*b1);\r
        r[2] = (unsigned char)(255*b2);\r
@@ -693,7 +694,7 @@ void mglCanvas::line_draw(long k1, long k2, mglDrawReg *dr)
        long y1,x1,y2,x2;\r
 \r
        float pw=PenWidth*sqrt(font_factor/400), dxu,dxv,dyu,dyv,dd,dpw=3;\r
-       if(get(MGL_HIGHLIGHT))  {       pw *= 2;        dpw=2;  }\r
+       if(ObjId==HighId)       {       pw *= 2;        dpw=2;  }\r
        const mglPnt &p1=Pnt[k1], &p2=Pnt[k2];\r
        mglPnt d=p2-p1, p;\r
        bool hor = fabs(d.x)>fabs(d.y);\r
@@ -782,7 +783,7 @@ void mglCanvas::pnt_draw(long k, mglDrawReg *dr)
 {\r
        register long i,j,s,x,y;\r
        register float v,pw=2*PenWidth*sqrt(font_factor/400),dpw=3;\r
-       if(get(MGL_HIGHLIGHT))  {       pw *= 2;        dpw=2;  }\r
+       if(ObjId==HighId)       {       pw *= 2;        dpw=2;  }\r
        const mglPnt &p=Pnt[k];\r
        unsigned char cs[4], cc;        col2int(p,cs);  cc = cs[3];\r
        if(cc==0)       return;\r
index 9ee13e52eb4a86922ae5bf1e4da01f66eaadd990..dd3f86f71ff6563891611ecaf1b3d115bc3c6403 100644 (file)
@@ -12,22 +12,20 @@ if(use_doc)
 #      set_source_files_properties(${CMAKE_BINARY_DIR}/examples/mgl_example PROPERTIES GENERATED 1)
 #      ADD_CUSTOM_TARGET(gen_all_png DEPENDS ${CMAKE_SOURCE_DIR}/texinfo/png/all.png)
 #      ADD_DEPENDENCIES(gen_all_png mgl_example)
-       set(list_texi_files_en mathgl_en.texi mgl_en.texi overview_en.texi example_en.texi ex_mgl_en.texi
-               core_en.texi widget_en.texi data_en.texi other_en.texi samples_en.texi appendix_en.texi fdl.texi)
-       set(list_texi_files_ru mathgl_ru.texi mgl_ru.texi overview_ru.texi example_ru.texi ex_mgl_ru.texi
-               core_ru.texi widget_ru.texi data_ru.texi other_ru.texi samples_ru.texi appendix_ru.texi fdl.texi)
+       set(list_texi_files_en mathgl_en.texi mgl_en.texi overview_en.texi example_en.texi ex_mgl_en.texi parse_en.texi core_en.texi widget_en.texi data_en.texi other_en.texi samples_en.texi appendix_en.texi fdl.texi)
+       set(list_texi_files_ru mathgl_ru.texi mgl_ru.texi overview_ru.texi example_ru.texi ex_mgl_ru.texi parse_ru.texi core_ru.texi widget_ru.texi data_ru.texi other_ru.texi samples_ru.texi appendix_ru.texi fdl.texi)
 
        add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/texinfo/mathgl_en.info
-               COMMAND ${findth} --split=chapter mathgl_en.texi -o mathgl_en
-               COMMAND ${findth} --split=chapter mgl_en.texi -o mgl_en
+               COMMAND ${findth} --split=section mathgl_en.texi -o mathgl_en
+               COMMAND ${findth} --split=section mgl_en.texi -o mgl_en
                COMMAND ${findmi} --no-validate mathgl_en.texi
                DEPENDS ${CMAKE_SOURCE_DIR}/texinfo/png/all.png
                DEPENDS ${list_texi_files_en}
                WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/texinfo
        )
        add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/texinfo/mathgl_ru.info
-               COMMAND ${findth} --split=chapter mathgl_ru.texi -o mathgl_ru
-               COMMAND ${findth} --split=chapter mgl_ru.texi -o mgl_ru
+               COMMAND ${findth} --split=section mathgl_ru.texi -o mathgl_ru
+               COMMAND ${findth} --split=section mgl_ru.texi -o mgl_ru
                COMMAND ${findmi} --no-validate mathgl_ru.texi
                DEPENDS ${CMAKE_SOURCE_DIR}/texinfo/png/all.png
                DEPENDS ${list_texi_files_ru}
index c6e4f0d5919bd24f15eb93d541e86905d1258aed..ba123d148d1afd8ac6bcbc82cb0ed395ceed5508 100644 (file)
@@ -1,3 +1,37 @@
+@chapter Overview
+
+The set of MathGL features is rather rich -- just the number of basic graphics types
+is larger than 50. Also there are functions for data handling, plot setup and so on. In spite of it I tried to keep a similar style in function names and in the order of arguments. Mostly it is
+used for different drawing functions.
+
+There are six most general (base) concepts:
+@enumerate
+@item
+@strong{Any picture is created in memory first.} The internal (memory) representation can be different: bitmap picture (for @code{SetQuality(MGL_DRAW_LMEM)}) or the list of vector primitives (default). After that the user may decide what he/she want: save to file, display on the screen, run animation, do additional editing and so on. This approach assures a high portability of the program -- the source code will produce exactly the same picture in @emph{any} OS. Another big positive consequence is the ability to create the picture in the console program (using command line, without creating a window)!
+@item
+@strong{Every plot settings (style of lines, font, color scheme) are specified by a string.} It provides convenience for user/programmer -- short string with parameters is more comprehensible than a large set of parameters. Also it provides portability -- the strings are the same in any OS so that it is not necessary to think about argument types.
+@item
+@strong{All functions have ``simplified'' and ``advanced'' forms.} It is done for user's convenience. One needs to specify only one data array in the ``simplified'' form in order to see the result. But one may set parametric dependence of coordinates and produce rather complex curves and surfaces in the ``advanced'' form. In both cases the order of function arguments is the same: first data arrays, second the string with style, and later string with options for additional plot tuning.
+@item
+@strong{All data arrays for plotting are encapsulated in mglData(A) class.} This reduces the number of errors while working with memory and provides a uniform interface for data of different types (float, double and so on) or for formula plotting.
+@item
+@strong{All plots are vector plots.} The MathGL library is intended for handling scientific data which have vector nature (lines, faces, matrices and so on). As a result, vector representation is used in all cases! In addition, the vector representation allows one to scale the plot easily -- change the canvas size by a factor of 2, and the picture will be proportionally scaled.
+@item
+@strong{New drawing never clears things drawn already.} This, in some sense, unexpected, idea allows to create a lot of ``combined'' graphics. For example, to make a surface with contour lines one needs to call the function for surface plotting and the function for contour lines plotting (in any order). Thus the special functions for making this ``combined'' plots (as it is done in Matlab and some other plotting systems) are superfluous. Many more examples of such plots can be found in section @ref{Hints} and in home site (@uref{http://mathgl.sf.net/index.html}).
+@end enumerate
+
+In addition to the general concepts I want to comment on some non-trivial or less commonly used general ideas -- plot positioning, axis specification and curvilinear coordinates, styles for lines, text and color scheme.
+
+@menu
+* Coordinate axes::
+* Line styles::
+* Color scheme::
+* Font styles::
+* Textual formulas::
+* Command options::
+* Interfaces::
+@end menu
+
 @c ------------------------------------------------------------------
 @node Coordinate axes, Line styles, , General concepts
 @subsection Coordinate axes
@@ -181,7 +215,7 @@ There is no difference between lower or upper case in formulas. If argument valu
 
 
 @c ------------------------------------------------------------------
-@node  Command options, , Textual formulas, General concepts
+@node  Command options, Interfaces, Textual formulas, General concepts
 @section Command options
 
 Command options allow the easy setup of the plot by changing of global settings only for this plot. Each option is separated from the previous text by symbol @samp{;}. Options work so that them remember the current settings, change settings as it being set in the option, execute command and return the original settings back. So, the options usage for data handling commands or for graphics setup commands is useless.
@@ -235,3 +269,217 @@ Adds string 'txt' to internal legend accumulator. The style of described line an
 @deffn {MGL option} value @code{val}
 Set the value to be used as additional numeric parameter in plotting command.
 @end deffn
+
+
+
+@node Interfaces, , Command options, General concepts
+@section Interfaces
+
+The MathGL library has interfaces for a set of languages. Most of them are based on the C interface via SWIG tool. There are Python, Java, Octave, Lisp, C#, Guile, Lua, Modula 3, Ocaml, Perl, PHP, Pike, R, Ruby, and Tcl interfaces. Also there is a Fortran interface which has a similar set of functions, but slightly different types of arguments (integers instead of pointers). These functions are marked as [C function].
+@c ++++++++++
+Some of the languages listed above support classes (like C++ or Python). For them, a special wrapper was written.
+@c ++++++++++
+Finally, a special command language MGL was written for a faster access to plotting functions. Corresponding scripts can be executed separately (by UDAV, mgl2png, mgl2eps and so on)
+@ifclear UDAV
+ or from the C/C++/Python/... code (@pxref{mglParse class}).
+@end ifclear
+
+@ifclear UDAV
+@menu
+* C interface::
+* Python interface::
+* MGL interface::
+@end menu
+
+@node C interface, Python interface, , Interfaces
+@subsection C/Fortran interface
+
+The C interface is a base for many other interfaces. It contains the pure C functions for most of the methods of MathGL classes. In distinction to C++ classes, C functions must have an argument HMGL (for graphics) and/or HMDT (for data arrays), which specifies the object for drawing or manipulating (changing). So, firstly, the user has to create this object by the function @code{mgl_create_*()} and has to delete it after the use by function @code{mgl_delete_*()}.
+
+All C functions are described in the header file @code{#include <mgl/mgl_c.h>} and use variables of the following types:
+@itemize
+@item
+@code{HMGL} --- Pointer to class @code{mglGraph} (@pxref{MathGL core}).
+@item
+@code{HMDT} --- Pointer to class @code{mglData} (@pxref{Data processing}).
+@item
+@code{HMPR} --- Pointer to class @code{mglParse} (@pxref{mglParse class}).
+@end itemize
+These variables contain identifiers for graphics drawing objects and for the data objects.
+
+Fortran functions/subroutines have the same names as C functions. However, there is a difference. Variable of type @code{HMGL, HMDT} must be an integer with sufficient size (@code{integer*4} in the 32-bit operating system or @code{integer*8} in the 64-bit operating system). All C functions are subroutines in Fortran, which are called by operator @code{call}. The exceptions are functions, which return variables of types @code{HMGL} or @code{HMDT}. These functions should be declared as integer in Fortran code. Also, one should keep in mind that strings in Fortran are denoted by @code{'} symbol, not the @code{"} symbol.
+
+@node Python interface, MGL interface, C interface, Interfaces
+@subsection C++/Python interface
+
+MathGL provides the interface to a set of languages via SWIG library. Some of these languages support classes. The typical example is Python -- which is named in this chapter's title. Exactly the same classes are used for high-level C++ API. Its feature is using only inline member-functions what make high-level API to be independent on compiler even for binary build.
+
+There are 2 classes in:
+@itemize
+@item @code{mglGraph}
+-- provide most plotting functions (@pxref{MathGL core}).
+@item @code{mglData}
+-- provide base data processing (@pxref{Data processing}). It have an additional feature to access data values. You can use a construct like this: @code{dat[i]=sth;} or @code{sth=dat[i]} where flat representation of data is used (i.e., @var{i} can be in range 0...nx*nx*nz-1). You can also import NumPy arrays as input arguments in Python: @code{mgl_dat = mglData(numpy_dat);}.
+@c @item @code{mglParse} -- practically the same as C++ class @code{MathGL provides the interface to a set of languages via SWIG library. Some of these languages support classes. The typical example is Python -- which is denoted in the chapter title.
+@end itemize
+
+
+To use Python classes just execute @samp{import mathgl}. The simplest example will be:
+@verbatim
+import mathgl
+a=mathgl.mglGraph()
+a.Box()
+a.WritePNG("test.png")
+@end verbatim
+Alternatively you can import all classes from @code{mathgl} module and easily access MathGL classes like this:
+@verbatim
+from mathgl import *
+a=mglGraph()
+a.Box()
+a.WritePNG("test.png")
+@end verbatim
+This becomes useful if you create many @code{mglData} objects, for example.
+
+
+@node MGL interface, , Python interface, Interfaces
+@end ifclear
+@subsection MGL interface
+
+MathGL library supports the simplest scripts for data handling and plotting. These scripts can be used independently (with the help of UDAV, mglconv, mglview programs and others, @pxref{Utilities}) or in the frame of the library using.
+
+MGL script language is rather simple. Each string is a command. First word of string is the name of command. Other words are command arguments. Command may have up to 1000 arguments (at least for now). Words are separated from each other by space or tabulation symbol. The upper or lower case of words is sufficient, i.e. variables @var{a} and @var{A} are different variables. Symbol @samp{#} starts the comment (all characters after # will be ignored). The exception is situation when @samp{#} is a part of some string. Also options can be specified after symbol @samp{;} (@pxref{Command options}). Symbol @samp{:} starts new command (like new line character) if it is not placed inside a string or inside brackets.
+
+If string contain references to external parameters (substrings @samp{$0}, @samp{$1} ... @samp{$9}) or definitions (substrings @samp{$a}, @samp{$b} ... @samp{$z}) then before execution the values of parameter/definition will be substituted instead of reference. It allows to use the same MGL script for different parameters (filenames, paths, condition and so on).
+
+Argument can be a string, a variable name or a number.
+@itemize @bullet
+@item
+The string is any symbols between ordinary marks @samp{'}.
+
+@item
+Usually variable have a name which is arbitrary combination of symbols (except spaces and @samp{'}) started from a letter and with length less than 64. A temporary array can be used as variable:
+@itemize @bullet
+@item
+sub-arrays (like in @ref{subdata} command) as command argument. For example, @code{a(1)} or @code{a(1,:)} or @code{a(1,:,:)} is second row, @code{a(:,2)} or @code{a(:,2,:)} is third column, @code{a(:,:,0)} is first slice and so on. Also you can extract a part of array from m-th to n-th element by code @code{a(m:n,:,:)} or just @code{a(m:n)}.
+
+@item
+any column combinations defined by formulas, like @code{a('n*w^2/exp(t)')} if names for data columns was specified (by @ref{idset} command or in the file at string started with @code{##}).
+
+@item
+any expression (without spaces) of existed variables produce temporary variable. For example, @samp{sqrt(dat(:,5)+1)} will produce temporary variable with data values equal to @code{tmp[i,j] = sqrt(dat[i,5,j]+1)}.
+
+@item
+temporary variable of higher dimensions by help of []. For example, @samp{[1,2,3]} will produce a temporary vector of 3 elements @{1, 2, 3@}; @samp{[[11,12],[21,22]]} will produce matrix 2*2 and so on. Here you can join even an arrays of the same dimensions by construction like @samp{[v1,v2,...,vn]}.
+
+@item
+result of code for making new data (@pxref{Make another data}) inside @{@}. For example, @samp{@{sum dat 'x'@}} produce temporary variable which contain result of summation of @var{dat} along direction 'x'. This is the same array @var{tmp} as produced by command @samp{sum tmp dat 'x'}. You can use nested constructions, like @samp{@{sum @{max dat 'z'@} 'x'@}}.
+@end itemize
+Temporary variables can not be used as 1st argument for commands which create (return) the data (like @samp{new}, @samp{read}, @samp{hist} and so on).
+
+@item
+Special names @code{nan=#QNAN, pi=3.1415926..., on=1, off=0, :=-1} are treated as number if they were not redefined by user. Variables with suffixes are treated as numbers (@pxref{Data information}). Names defined by @ref{define} command are treated as number. Also results of formulas with sizes 1x1x1 are treated as number (for example, @samp{pi/dat.nx}).
+@end itemize
+Before the first using all variables must be defined with the help of commands, like, @ref{new}, @ref{var}, @ref{list}, @ref{copy}, @ref{read}, @ref{hist}, @ref{sum} and so on (see sections @ref{Data constructor}, @ref{Data filling} and @ref{Make another data}).
+
+Command may have several set of possible arguments (for example, @code{plot ydat} and @code{plot xdat ydat}). All command arguments for a selected set must be specified. However, some arguments can have default values. These argument are printed in [], like @code{plot ydat ['stl'='' zval=nan]}. At this, the record @code{[arg1 arg2 arg3 ...]} means @code{[arg1 [arg2 [arg3 ...]]]}, i.e. you can omit only tailing arguments if you agree with its default values. For example, @code{plot ydat '' 1} or @code{plot ydat ''} is correct, but @code{plot ydat 1} is incorrect (argument @code{'stl'} is missed).
+
+Below I show commands to control program flow, like, conditions, cycles, define script arguments and so on. Other commands can be found in chapters @ref{MathGL core} and @ref{Data processing}.
+
+@cindex chdir
+@anchor{chdir}
+@deftypefn {MGL command} {} chdir 'path'
+Changes the current directory to @var{path}.
+@end deftypefn
+
+@cindex define
+@anchor{define}
+@deftypefn {MGL command} {} define $N smth
+Sets @var{N}-th script argument to @var{smth}. Note, that @var{smth} is used as is (with @samp{'} symbols if present). Here @var{N} is digit (0...9) or alpha (a...z).
+@end deftypefn
+@deftypefn {MGL command} {} define name smth
+Create scalar variable @code{name} which have the numeric value of @code{smth}. Later you can use this variable as usual number. Here @var{N} is digit (0...9) or alpha (a...z).
+@end deftypefn
+@cindex defchr
+@anchor{defchr}
+@deftypefn {MGL command} {} defchr $N smth
+Sets @var{N}-th script argument to character with value evaluated from @var{smth}. Here @var{N} is digit (0...9) or alpha (a...z).
+@end deftypefn
+@cindex defnum
+@anchor{defnum}
+@deftypefn {MGL command} {} defnum $N smth
+Sets @var{N}-th script argument to number with value evaluated from @var{smth}. Here @var{N} is digit (0...9) or alpha (a...z).
+@end deftypefn
+@cindex defpal
+@anchor{defpal}
+@deftypefn {MGL command} {} defpal $N smth
+Sets @var{N}-th script argument to palette character at position evaluated from @var{smth}. Here @var{N} is digit (0...9) or alpha (a...z).
+@end deftypefn
+
+@cindex call
+@anchor{call}
+@deftypefn {MGL command} {} call 'fname' [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]
+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
+@anchor{return}
+@deftypefn {MGL command} {} return
+Return from the function. See also @ref{func}.
+@end deftypefn
+
+
+@cindex if
+@anchor{if}
+@deftypefn {MGL command} {} if dat 'cond'
+Starts block which will be executed if @var{dat} satisfy to @var{cond}.
+@end deftypefn
+@deftypefn {MGL command} {} if @code{val}
+Starts block which will be executed if @code{val} is nonzero.
+@end deftypefn
+@cindex elseif
+@anchor{elseif}
+@deftypefn {MGL command} {} elseif dat 'cond'
+Starts block which will be executed if previous @code{if} or @code{elseif} is false and @var{dat} satisfy to @var{cond}.
+@end deftypefn
+@deftypefn {MGL command} {} elseif @code{val}
+Starts block which will be executed if previous @code{if} or @code{elseif} is false and @code{val} is nonzero.
+@end deftypefn
+@cindex else
+@anchor{else}
+@deftypefn {MGL command} {} else
+Starts block which will be executed if previous @code{if} or @code{elseif} is false.
+@end deftypefn
+@cindex endif
+@anchor{endif}
+@deftypefn {MGL command} {} endif
+Finishes @code{if/elseif/else} block.
+@end deftypefn
+
+@cindex for
+@anchor{for}
+@deftypefn {MGL command} {} for $N @code{v1 v2 [dv=1]}
+Starts cycle with $@var{N}-th argument changing from @var{v1} to @var{v2} with the step @var{dv}. Here @var{N} is digit (0...9) or alpha (a...z).
+@end deftypefn
+@deftypefn {MGL command} {} for $N dat
+Starts cycle with $@var{N}-th argument changing for @var{dat} values. Here @var{N} is digit (0...9) or alpha (a...z).
+@end deftypefn
+@cindex next
+@anchor{next}
+@deftypefn {MGL command} {} next
+Finishes @code{for} cycle.
+@end deftypefn
+
+@cindex once
+@anchor{once}
+@deftypefn {MGL command} {} once @code{val}
+The code between @code{once on} and @code{once off} will be executed only once. Useful for large data manipulation in programs like UDAV.
+@end deftypefn
+@cindex stop
+@anchor{stop}
+@deftypefn {MGL command} {} stop
+Terminate execution.
+@end deftypefn
index 5df4f8e8ca3713727fc7ac8051f40b0d7b48fd9f..6d1b062a2caac788447e82c6aaa7ebeb3be08c72 100644 (file)
@@ -1,7 +1,7 @@
 @c ------------------------------------------------------------------
 @chapter MathGL examples
 
-This chapter contain information about basic and advanced MathGL, hints and samples for all types of graphics. I recommend you read first 2 sections one after another and at least look on ``Hints'' section. Also I recommend you to look at @ref{General concepts} and @ref{FAQ}. Sample code for some of these examples can be found in @uref{http://mathgl.sf.net/pictures.html} and in @ref{Samples}.
+This chapter contain information about basic and advanced MathGL, hints and samples for all types of graphics. I recommend you read first 2 sections one after another and at least look on @ref{Hints} section. Also I recommend you to look at @ref{General concepts} and @ref{FAQ}.
 
 @menu
 * Basic usage::                 
@@ -11,6 +11,7 @@ This chapter contain information about basic and advanced MathGL, hints and samp
 * C/Fortran interface::         
 * MathGL and PyQt::
 * Hints::
+* FAQ::
 @end menu
 
 @c ------------------------------------------------------------------
@@ -1355,3 +1356,132 @@ One can easily create stereo image in MathGL. Stereo image can be produced by ma
     // draw the same here
 @end verbatim
 
+@node FAQ, , Hints, Examples
+@section FAQ
+
+@table @strong
+@item The plot does not appear
+Check that points of the plot lie  inside the bounding box and resize the bounding box using @code{Axis()} function. Check that the data have correct dimensions for selected type of plot. Be sure that  @code{Finish()} is called after the plotting functions (or be sure that the plot is saved to a file). Sometimes the light reflection from flat surfaces (like, @code{Dens()}) can look as if the plot were absent.
+
+@item I can not find some special kind of plot.
+Most ``new'' types of plots can be created by using the existing drawing functions. For example, the surface of curve rotation can be created by a special function @code{Torus()}, or as a parametrically specified surface by @code{Surf()}. See also, @ref{Hints}. If you can not find a specific type of plot, please e-mail me and this plot will appear in the next version of MathGL library.
+
+@item Should I know some graphical libraries (like OpenGL) before using the MathGL library?
+No. The MathGL library is self-contained and does not require the knowledge of external libraries.
+
+@item In which language is the library written? For which languages does it have an interface?
+The core of the MathGL library is written in C++. But there are interfaces for: pure C, Fortran, Pascal, Forth, and its own command language MGL. Also there is a large set of interpreted languages, which are supported (Python, Java,  ALLEGROCL, CHICKEN, Lisp, CFFI, C#, Guile, Lua, Modula 3, Mzscheme, Ocaml, Octave, Perl, PHP, Pike, R, Ruby, Tcl). These interfaces are written using SWIG (both pure C functions and classes) but only the interface for Python and Octave is included in the autoconf/automake script. The reason is that I don't know any other interpreted languages :(. Note that most other languages can use (link to) the pure C functions.
+
+@item How can I use MathGL with Fortran?
+You can use MathGL as is with @code{gfortran} because it uses by default the AT&T notation for external functions. For other compilers (like Visual Fortran) you have to switch on the AT&T notation manually. The AT&T notation requires that the symbol @samp{_} is added at the end of each function name, function argument(s) is passed by pointers and the string length(s) is passed at the end of the argument list. For example:
+
+@emph{C function} -- @code{void mgl_fplot(HMGL graph, const char *fy, const char *stl, int n);}
+
+@emph{AT&T function} -- @code{void mgl_fplot_(uintptr_t *graph, const char *fy, const char *stl, int *n, int ly, int ls);}
+
+@item I have a class Foo and a drawing method Foo::draw(mglGraph *gr). How I can use it in FLTK or GLUT window?
+The member-functions of classes have a hidden parameter (the pointer to a class instance) in C++. So, their direct usage is impossible. The solution is to write an interface function:
+@example
+int foo_draw(mglGraph *gr, void *par)
+@{   ((Foo *)foo)->draw(gr);    @}
+@end example
+and to use it in the call of @code{Window()} function:
+@example
+gr->Window(argc,argv,foo_draw,"Title",this);
+@end example
+
+Alternatively you can inherit your class from @code{mglDraw} class and use the functions like @code{gr->Window(argc, argv, foo, "Title");}.
+
+@item How can I print in Russian/Spanish/Arabic/Japanese, and so on?
+The standard way is to use Unicode encoding for the text output. But the MathGL library also has interface for 8-bit (char *) strings with internal conversion to Unicode. This conversion depends on the current locale OS. You may change it by @code{setlocale()} function. For example, for Russian text in CP1251 encoding you may use @code{setlocale(LC_CTYPE, "ru_RU.cp1251");} (under MS Windows the name of locale may differ -- @code{setlocale(LC_CTYPE, "russian_russia.1251")}). I strongly recommend not to use the constant @code{LC_ALL} in the conversion. Since it also changes the number format, it may lead to mistakes in formula writing and reading of the text in data files. For example, the program will await a @samp{,} as a decimal point but the user will enter @samp{.}.
+
+@item How can I exclude a point or a region of plot from the drawing?
+There are 3 general ways. First, the point with @code{NAN} value as one of the coordinates will never be plotted. Second, special variables @var{CutMin}, @var{CutMax} or function @code{CutOff}() define the condition when the points should be omitted (@pxref{Cutting}). Last, you may change the transparency of a part of the plot by the help of functions @code{SurfA()}, @code{Surf3A()} (@pxref{Dual plotting}). In this last case the transparency is switched on smoothly.
+
+@item I use VisualStudio, CBuilder or some other compiler (not MinGW/gcc). How can I link the MathGL library?
+In version 2.0, the recomended class @code{mglGraph} (header file @code{#include <mgl/mgl.h>}) contains only @code{inline} functions and is acceptable for any compiler with the same binary files. However, if you plan to access low-level features (i.e. classes mglBase, mglCanvas and so on) then you have to recompile MathGL by yours compiler.
+
+@c @strong{Finally!} Please @emph{do not} ask me Windows-specific questions. I do not use Windows. I know nothing about Visual Basic, Visual C++, CBuiled or .NET. Please find the appropriate Usenet discussion group and ask your question there.
+
+@item How I can build MathGL under Windows?
+The simplest way is using the combination CMake+MinGW. Also you need some extra libraries like GSL, PNG, JPEG and so on. All of them can be found at @url{http://gnuwin32.sourceforge.net/packages.html}. After installing all components, just run CMake configurator and make the MathGL itself.
+
+@item How I can create FLTK/GLUT/Qt window in parallel with calculation?
+You should create a separate thread for processing window messages. The cross-platform way is using the @code{pthread} library. You can update the data by calling @code{mglGraphFLTK::Update()} function. The code can look like this:
+@verbatim
+//-----------------------------------------------------------------------------
+#include <mgl/window.h>
+#include <pthread.h>
+
+mglPoint pnt;  // some global variable for changable data
+//-----------------------------------------------------------------------------
+int sample(mglGraph *gr)
+{
+  gr->Box();  gr->Line(mglPoint(),pnt,"Ar2"); // just draw a vector
+  return 0;
+}
+//-----------------------------------------------------------------------------
+void *mgl_fltk_tmp(void *)      {       mglFlRun();     return 0;       }
+int main (int argc, char ** argv)
+{
+  mglWindow gr(0,sample,"test");  // create window
+  static pthread_t tmp;
+  pthread_create(&tmp, 0, mgl_fltk_tmp, 0);
+  pthread_detach(tmp);    // run window handling in the separate thread
+  for(int i=0;i<10;i++)   // do calculation
+  {
+    sleep(1);             // which can be very long
+    pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1);
+    gr.Update();          // update window
+  }
+  return 0;   // finish calculations and close the window
+}
+//-----------------------------------------------------------------------------
+@end verbatim
+If you just need a static image with current results of calculation then you can set @code{NULL} as plotting function and call @code{Update()} when you want to update the image. This way is also usefult for Fortran users.
+@verbatim
+//-----------------------------------------------------------------------------
+#include <mgl/window.h>
+//-----------------------------------------------------------------------------
+int sample(mglGraph *gr)
+{
+  gr->Box();  gr->Line(mglPoint(),pnt,"Ar2"); // just draw a vector
+  return 0;
+}
+//-----------------------------------------------------------------------------
+void *mgl_fltk_tmp(void *)      {       mglFlRun();     return 0;       }
+int main (int argc, char ** argv)
+{
+  mglWindow gr(0,NULL,"test");  // create window
+  for(int i=0;i<10;i++)   // do calculation
+  {
+    sleep(1);             // which can be very long
+    pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1);
+    sample(&gr);          // draw picture
+    gr.Update();          // update window
+  }
+  return 0;   // finish calculations and close the window
+}
+//-----------------------------------------------------------------------------
+@end verbatim
+
+
+@item How many people write this library?
+Most of the library was written by one person. This is a result of nearly a year of work (mostly in the evening and on holidays): I spent half a year to write the kernel and half a year to a year on extending, improving the library and writing documentation. This process continues now :). The autoconf/automake script was written mostly by D.Kulagin, and the export to IDTF was written mostly by M.Vidassov.
+
+@item How can I display a bitmap on the figure?
+You can import data into a @code{mglData} instance and display it by @code{Dens()} function. For example, for black-and-white bitmap you can use the code: @code{mglData bmp; bmp.Import("fname.png","wk"); gr->Dens(bmp,"wk");}.
+
+@item How can I use MathGL in Qt, FLTK, wxWidgets etc.?
+There are special classes (widgets) for these libraries: QMathGL for Qt, Fl_MathGL for FLTK and so on. If you don't find the appropriate class then you can create your own widget that displays a bitmap using mglCanvas::GetBits().
+
+@item How can I create U3D file (make 3D in PDF)?
+There are 2 steps: first you should create IDTF file, and later convert it to U3D. You can use @uref{http://sourceforge.net/project/showfiles.php?group_id=152187&package_id=300628, U3D tools} for converting IDTF file to U3D. It needs @uref{http://libharu.org, libharu} 2.1.0 or later. For installation use @code{./bootstrap, ./configure, make, sudo make install}. It provides  IDTFConverter program for converting text files *.idtf to binary files *.u3d. The latter can be included into PDF.
+
+@item How I can change the font family?
+First, you should download new font files from @uref{http://mathgl.sourceforge.net/download.html, here} or from @uref{http://sourceforge.net/project/showfiles.php?group_id=152187&package_id=267177, here}. Next, you should load the font files into mglGraph class instance @var{gr} by the following command: @code{gr->LoadFont(fontname,path);}. Here @var{fontname} is the base font name like @samp{STIX} and @var{path} sets the location of font files. Use @code{gr->RestoreFont();} to start using the default font.
+
+@item How can I draw tick out of a bounding box?
+Just set a negative value in @var{SetTickLen}. For example, use @code{gr->SetTickLen(-0.1);}.
+
+@end table
index d8a7d8cb0aa0d0fbb69c704d766c6ee4765600dc..20189d89d9005aba4c6100634cb19d7c6cbca4f8 100644 (file)
@@ -68,11 +68,12 @@ supports it in developing GNU and promoting software freedom.''
 @menu
 * Overview::
 * Examples::
+* General concepts::
 * MathGL core::
 * Widget classes::
 * Data processing::
+* MGL scripts::
 * Other classes::
-* Samples::
 * TeX-like symbols::
 * Copying This Manual::
 * Index::
@@ -89,25 +90,28 @@ supports it in developing GNU and promoting software freedom.''
 @node Overview, Examples, , Top
 @include overview_en.texi
 
-@node Examples, MathGL core, Overview, Top
+@node Examples, General concepts, Overview, Top
 @include example_en.texi
 
-@node MathGL core, Widget classes, Examples, Top
+@node General concepts, MathGL core, Examples, Top
+@include concept_en.texi
+
+@node MathGL core, Widget classes, General concepts, Top
 @include core_en.texi
 
 @node Widget classes, Data handling, MathGL core, Top
 @include widget_en.texi
 
-@node Data processing, Other classes, Widget classes, Top
+@node Data processing, MGL scripts, Widget classes, Top
 @include data_en.texi
 
-@node Other classes, Samples, Data handling, Top
-@include other_en.texi
+@node MGL scripts, Other classes, Data processing, Top
+@include parse_en.texi
 
-@node Samples, TeX-like symbols, Other classes, Top
-@include samples_en.texi
+@node Other classes, TeX-like symbols, MGL scripts, Top
+@include other_en.texi
 
-@node TeX-like symbols, Copying This Manual, Samples, Top
+@node TeX-like symbols, Copying This Manual, Other classes, Top
 @appendix TeX-like symbols
 @include appendix_en.texi
 
index eb221cc3db8b009db38b14482033a032009300a1..00136bdbc2186daeffcbb0eaba77493a5a64774f 100644 (file)
@@ -3,7 +3,6 @@
 @chapter Other classes
 
 @menu
-* mglParse class::              
 * mglFormula class::            
 * mglColor class::              
 * mglPoint class::              
 * mglArg class::                
 @end menu
 
-@c ------------------------------------------------------------------
-@node mglParse class, mglFormula class, , Other classes
-@section mglParse class
-@cindex mglParse
-
-Class for parsing and executing MGL script. This class is defined in @code{#include <mgl/mgl.h>}.
-
-Class mglParse is the interpreter for MGL scripts (@pxref{MGL interface}). The main function of mglParse class is @code{Parse()}. Exactly this function parses and executes the script string-by-string. Also there are two subservient functions for the finding and creation of a variable. These functions can be useful for displaying values of variables (arrays) in some external program (in window, for example). The variable @var{DataList} contains full list of variables in script. Flag @var{AllowSetSize} allows one to prevent changing the size of the  picture inside the script (forbids the MGL command @code{setsize}). 
-
-@c Note an important feature -- if user defines function @var{func} in variable then it will be called before the destroying of this variable (@pxref{mglVar class}).
-
-@deftypefn {Constructor on @code{mglParse}} @code{} mglParse (@code{bool} setsize=@code{false})
-@deftypefnx {C function} @code{HMPR} mgl_create_parser ()
-Constructor initializes all values with zero and set @var{AllowSetSize} value.
-@end deftypefn
-
-@deftypefn {Destructor on @code{mglParse}} @code{} ~mglParse ()
-@deftypefnx {C function} @code{void} mgl_delete_parser (@code{HMPR} p)
-Destructor delete parser
-@end deftypefn
-
-@deftypefn {Method on @code{mglParse}} @code{int} Parse (@code{mglGraph *}gr, @code{const char *}str, @code{long} pos=@code{0})
-@deftypefnx {Method on @code{mglParse}} @code{int} Parse (@code{mglGraph *}gr, @code{const wchar_t *}str, @code{long} pos=@code{0})
-@deftypefnx {C function} @code{int} mgl_parse (@code{HMGL} gr, @code{HMPR} p, @code{const char *}str, @code{int} pos)
-@deftypefnx {C function} @code{int} mgl_parsew (@code{HMGL} gr, @code{HMPR} p, @code{const wchar_t *}str, @code{int} pos)
-Main function in the class. It parses the string @var{str} and executes it by  using @var{gr} as a graphics plotter. Returns the value depending on an error presence in the string @var{str}: 0 -- no error, 1 -- wrong command argument(s), 2 -- unknown command, 3 -- string is too long. Optional argument @var{pos} allows to save the string position in the document (or file) for using @code{for|next} command.
-@end deftypefn
-
-@deftypefn {Method on @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{FILE *}fp, @code{bool} print=@code{false})
-@deftypefnx {C function} @code{int} mgl_parsew (@code{HMGL} gr, @code{HMPR} p, @code{FILE *}fp, @code{int} print)
-Function parse and execute line-by-line MGL script in file @var{fp}. If @var{print}=@code{true} then all warnings and information will be printed in stdout.
-@end deftypefn
-
-@deftypefn {Method on @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{const char *}text, @code{void (*} error @code{)(int line, int kind, char *mes)=NULL})
-@deftypefnx{Method on @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{const wchar_t *}text, @code{void (*} error @code{)(int line, int kind, char *mes)=NULL})
-@deftypefnx {C function} @code{void} mgl_parse_text (@code{HMGL} gr, @code{HMPR} p, @code{const char *}text, @code{void (*} error @code{)(int line, int kind, char *mes)})
-@deftypefnx {C function} @code{void} mgl_parsew_text (@code{HMGL} gr, @code{HMPR} p, @code{const wchar_t *}text, @code{void (*} error @code{)(int line, int kind, char *mes)})
-Function parse and execute line-by-line MGL script in array @var{text}. Lines are separated by newline symbol @samp{\n} as usual. If @var{error} is not @code{NULL} then this function will be called for all warnings, information and other messages.
-@end deftypefn
-
-@deftypefn {Method on @code{mglParse}} @code{bool} AddParam (@code{int} n, @code{const char *}str, @code{bool} isstr=@code{true})
-@deftypefnx {Method on @code{mglParse} (C++)} @code{bool} AddParam (@code{int} n, @code{const wchar_t *}str, @code{bool} isstr=@code{true})
-@deftypefnx {C function} @code{void} mgl_add_param (@code{HMPR} p, @code{int} id, @code{const char *}val)
-@deftypefnx {C function} @code{void} mgl_add_paramw (@code{HMPR} p, @code{int} id, @code{const wchar_t *}val)
-Function set the value of @var{n}-th parameter as string @var{str} (@var{n}=0, 1 ... 9). It return @code{true} for success.
-@end deftypefn
-
-@deftypefn {Method on @code{mglParse}} @code{mglData *} FindVar (@code{const char *}name)
-@deftypefnx {C function} @code{HMDT} mgl_find_var  (@code{HMPR} p, @code{const char *}name)
-Function returns the pointer to variable with name @var{name} or zero if variable is absent. Use this function to put external data array to the script or get the data from the script. You must @strong{not delete} obtained data arrays!
-@end deftypefn
-@deftypefn {Method on @code{mglParse}} @code{mglData *} AddVar (@code{const char *}name)
-@deftypefnx {C function} @code{HMDT} mgl_add_var (@code{HMPR} p, @code{const char *}name)
-Function returns the pointer to variable with name @var{name}. If variable is absent then new variable is created with name @var{name}. Use this function to put external data array to the script or get the data from the script. You must @strong{not delete} obtained data arrays!
-@end deftypefn
-
-@deftypefn{Method on @code{mglParse} (C++)} @code{void} DeleteVar (@code{const char *}name)
-@deftypefnx {C function} @code{void} mgl_del_var (@code{HMPR} p, @code{const char *}name)
-Function delete the variable specified by its name or by its pointer.
-@end deftypefn
-
-@deftypefn {Method on @code{mglParse}} @code{void} RestoreOnce ()
-@deftypefnx {C function} @code{void} mgl_restore_once (@code{HMPR} p)
-Restore Once flag.
-@end deftypefn
-
-@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.
-@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.
-@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.
-@end deftypefn
 
 @c ------------------------------------------------------------------
-@node mglFormula class, mglColor class, mglParse class, Other classes
+@node mglFormula class, mglColor class, , Other classes
 @section mglFormula class
 @cindex mglFormula
 
index 02f67aa11835da3e5542ffcaa05ec300a8e9a252..369e4f5a81c3a12015b2fc7624e86231032e9f81 100644 (file)
@@ -15,24 +15,23 @@ a library with large and growing set of graphics.
 @end itemize
 
 @menu
-* Why have I written MathGL?::
+* What is MathGL?::
 * MathGL features::
 * Installation and usage::
-* General concepts::
-* FAQ::
-* Interfaces::
+* Quick guide::
+* Changes from v.1::
 * Utilities::
 * Thanks::
 @end menu
 
-@node Why have I written MathGL?, MathGL features, , Overview
-@section Why have I written MathGL?
+@node What is MathGL?, MathGL features, , Overview
+@section What is MathGL?
 
-A code for making high-quality scientific graphics under Linux and Windows. A  code for the fast handling and plotting of large data arrays. A code for working in window and console regimes and for easy including into another program. A code with large and renewal set of graphics. Exactly such a code I was looking for in the last years. Exactly such a code I tried to realize in MathGL library.
+A code for making high-quality scientific graphics under Linux and Windows. A  code for the fast handling and plotting of large data arrays. A code for working in window and console regimes and for easy including into another program. A code with large and renewal set of graphics. Exactly such a code I tried to put in MathGL library.
 
 At this version (@value{VERSION}) MathGL has more than 50 general types of graphics for 1d, 2d and 3d data arrays. It can export graphics to bitmap and vector (EPS or SVG) files. It has OpenGL interface and can be used from console programs. It has functions for data handling and script MGL language for simplification of data plotting. It also has several types of transparency and smoothed lighting, vector fonts and TeX-like symbol parsing, arbitrary curvilinear coordinate system and many other useful things (see pictures section at @uref{http://mathgl.sf.net/, homepage}). Finally it is platform-independent and free (under GPL v.2.0 or later license).
 
-@node MathGL features, Installation and usage, Why have I written MathGL?, Overview
+@node MathGL features, Installation and usage, What is MathGL?, Overview
 @section MathGL features
 
 MathGL can plot a wide range of graphics. It includes:
@@ -63,7 +62,7 @@ Special class mglData is used for data encapsulation (@pxref{Data processing}).
 
 There is fast evaluation of a textual mathematical expression (@pxref{Textual formulas}). It is based on string precompilation to tree-like code at the creation of class instance. At evaluation stage code performs only fast tree-walk and returns the value of the expression. In addition to changing data values, textual formulas are also used for drawing in @emph{arbitrary} curvilinear coordinates. A set of such curvilinear coordinates is limited only by user's imagination rather than a fixed list like: polar, parabolic, spherical, and so on.
 
-@node Installation and usage, General concepts, MathGL features, Overview
+@node Installation and usage, Quick guide, MathGL features, Overview
 @section Installation and usage
 
 MathGL can be installed in 4 different ways.
@@ -85,386 +84,19 @@ Install precompiled versions from standard packages (RPM, deb, DevPak and so on,
 
 To compile your own program, you need to specify the linker option @code{-lmgl} for a compilation in the console program or with external (non-MathGL) window library. If you want to use FLTK or GLUT windows then you need to add the option @code{-lmgl-fltk} or @code{-lmgl-glut}. Fortran users also should add C++ library by the option @code{-lstdc++}.
 
-@node General concepts, FAQ, Installation and usage, Overview
-@section General concepts
 
-The set of MathGL features is rather rich -- just the number of basic graphics types
-is larger than 50. Also there are functions for data handling, plot setup and so on. In spite of it I tried to keep a similar style in function names and in the order of arguments. Mostly it is
-used for different drawing functions.
-
-There are six most general (base) concepts:
-@enumerate
-@item
-@strong{Any picture is created in memory first.} The internal (memory) representation can be different: bitmap picture (for @code{SetQuality(MGL_DRAW_LMEM)}) or the list of vector primitives (default). After that the user may decide what he/she want: save to file, display on the screen, run animation, do additional editing and so on. This approach assures a high portability of the program -- the source code will produce exactly the same picture in @emph{any} OS. Another big positive consequence is the ability to create the picture in the console program (using command line, without creating a window)!
-@item
-@strong{Every plot settings (style of lines, font, color scheme) are specified by a string.} It provides convenience for user/programmer -- short string with parameters is more comprehensible than a large set of parameters. Also it provides portability -- the strings are the same in any OS so that it is not necessary to think about argument types.
-@item
-@strong{All functions have ``simplified'' and ``advanced'' forms.} It is done for user's convenience. One needs to specify only one data array in the ``simplified'' form in order to see the result. But one may set parametric dependence of coordinates and produce rather complex curves and surfaces in the ``advanced'' form. In both cases the order of function arguments is the same: first data arrays, second the string with style, and later string with options for additional plot tuning.
-@item
-@strong{All data arrays for plotting are encapsulated in mglData(A) class.} This reduces the number of errors while working with memory and provides a uniform interface for data of different types (float, double and so on) or for formula plotting.
-@item
-@strong{All plots are vector plots.} The MathGL library is intended for handling scientific data which have vector nature (lines, faces, matrices and so on). As a result, vector representation is used in all cases! In addition, the vector representation allows one to scale the plot easily -- change the canvas size by a factor of 2, and the picture will be proportionally scaled.
-@item
-@strong{New drawing never clears things drawn already.} This, in some sense, unexpected, idea allows to create a lot of ``combined'' graphics. For example, to make a surface with contour lines one needs to call the function for surface plotting and the function for contour lines plotting (in any order). Thus the special functions for making this ``combined'' plots (as it is done in Matlab and some other plotting systems) are superfluous. Many more examples of such plots can be found in section @ref{Hints} and in home site (@uref{http://mathgl.sf.net/index.html}).
-@end enumerate
-
-In addition to the general concepts I want to comment on some non-trivial or less commonly used general ideas -- plot positioning, axis specification and curvilinear coordinates, styles for lines, text and color scheme.
-
-@menu
-* Coordinate axes::
-* Line styles::
-* Color scheme::
-* Font styles::
-* Textual formulas::
-* Command options::
-@end menu
-
-@include concept_en.texi
-
-@node FAQ, Interfaces, General concepts, Overview
-@section FAQ
-
-@table @strong
-@item The plot does not appear
-Check that points of the plot lie  inside the bounding box and resize the bounding box using @code{Axis()} function. Check that the data have correct dimensions for selected type of plot. Be sure that  @code{Finish()} is called after the plotting functions (or be sure that the plot is saved to a file). Sometimes the light reflection from flat surfaces (like, @code{Dens()}) can look as if the plot were absent.
-
-@item I can not find some special kind of plot.
-Most ``new'' types of plots can be created by using the existing drawing functions. For example, the surface of curve rotation can be created by a special function @code{Torus()}, or as a parametrically specified surface by @code{Surf()}. See also, @ref{Hints} and @ref{Examples} of MathGL. If you can not find a specific type of plot, please e-mail me and this plot will appear in the next version of MathGL library.
-
-@item Should I know some graphical libraries (like OpenGL) before using the MathGL library?
-No. The MathGL library is self-contained and does not require the knowledge of external libraries.
-
-@item In which language is the library written? For which languages does it have an interface?
-The core of the MathGL library is written in C++. But there are interfaces for: pure C, Fortran, Pascal, Forth, and its own command language MGL. Also there is a large set of interpreted languages, which are supported (Python, Java,  ALLEGROCL, CHICKEN, Lisp, CFFI, C#, Guile, Lua, Modula 3, Mzscheme, Ocaml, Octave, Perl, PHP, Pike, R, Ruby, Tcl). These interfaces are written using SWIG (both pure C functions and classes) but only the interface for Python and Octave is included in the autoconf/automake script. The reason is that I don't know any other interpreted languages :(. Note that most other languages can use (link to) the pure C functions.
-
-@item How can I use MathGL with Fortran?
-You can use MathGL as is with @code{gfortran} because it uses by default the AT&T notation for external functions. For other compilers (like Visual Fortran) you have to switch on the AT&T notation manually. The AT&T notation requires that the symbol @samp{_} is added at the end of each function name, function argument(s) is passed by pointers and the string length(s) is passed at the end of the argument list. For example:
-
-@emph{C function} -- @code{void mgl_fplot(HMGL graph, const char *fy, const char *stl, int n);}
-
-@emph{AT&T function} -- @code{void mgl_fplot_(uintptr_t *graph, const char *fy, const char *stl, int *n, int ly, int ls);}
-
-@item I have a class Foo and a drawing method Foo::draw(mglGraph *gr). How I can use it in FLTK or GLUT window?
-The member-functions of classes have a hidden parameter (the pointer to a class instance) in C++. So, their direct usage is impossible. The solution is to write an interface function:
-@example
-int foo_draw(mglGraph *gr, void *par)
-@{   ((Foo *)foo)->draw(gr);    @}
-@end example
-and to use it in the call of @code{Window()} function:
-@example
-gr->Window(argc,argv,foo_draw,"Title",this);
-@end example
-
-Alternatively you can inherit your class from @code{mglDraw} class and use the functions like @code{gr->Window(argc, argv, foo, "Title");}.
-
-@item How can I print in Russian/Spanish/Arabic/Japanese, and so on?
-The standard way is to use Unicode encoding for the text output. But the MathGL library also has interface for 8-bit (char *) strings with internal conversion to Unicode. This conversion depends on the current locale OS. You may change it by @code{setlocale()} function. For example, for Russian text in CP1251 encoding you may use @code{setlocale(LC_CTYPE, "ru_RU.cp1251");} (under MS Windows the name of locale may differ -- @code{setlocale(LC_CTYPE, "russian_russia.1251")}). I strongly recommend not to use the constant @code{LC_ALL} in the conversion. Since it also changes the number format, it may lead to mistakes in formula writing and reading of the text in data files. For example, the program will await a @samp{,} as a decimal point but the user will enter @samp{.}.
-
-@item How can I exclude a point or a region of plot from the drawing?
-There are 3 general ways. First, the point with @code{NAN} value as one of the coordinates will never be plotted. Second, special variables @var{CutMin}, @var{CutMax} or function @code{CutOff}() define the condition when the points should be omitted (@pxref{Cutting}). Last, you may change the transparency of a part of the plot by the help of functions @code{SurfA()}, @code{Surf3A()} (@pxref{Dual plotting}). In this last case the transparency is switched on smoothly.
-
-@item I use VisualStudio, CBuilder or some other compiler (not MinGW/gcc). How can I link the MathGL library?
-In version 2.0, the recomended class @code{mglGraph} (header file @code{#include <mgl/mgl.h>}) contains only @code{inline} functions and is acceptable for any compiler with the same binary files. However, if you plan to access low-level features (i.e. classes mglBase, mglCanvas and so on) then you have to recompile MathGL by yours compiler.
-
-@c @strong{Finally!} Please @emph{do not} ask me Windows-specific questions. I do not use Windows. I know nothing about Visual Basic, Visual C++, CBuiled or .NET. Please find the appropriate Usenet discussion group and ask your question there.
-
-@item How I can build MathGL under Windows?
-The simplest way is using the combination CMake+MinGW. Also you need some extra libraries like GSL, PNG, JPEG and so on. All of them can be found at @url{http://gnuwin32.sourceforge.net/packages.html}. After installing all components, just run CMake configurator and make the MathGL itself.
-
-@item How I can create FLTK/GLUT/Qt window in parallel with calculation?
-You should create a separate thread for processing window messages. The cross-platform way is using the @code{pthread} library. You can update the data by calling @code{mglGraphFLTK::Update()} function. The code can look like this:
-@verbatim
-//-----------------------------------------------------------------------------
-#include <mgl/window.h>
-#include <pthread.h>
-
-mglPoint pnt;  // some global variable for changable data
-//-----------------------------------------------------------------------------
-int sample(mglGraph *gr)
-{
-  gr->Box();  gr->Line(mglPoint(),pnt,"Ar2"); // just draw a vector
-  return 0;
-}
-//-----------------------------------------------------------------------------
-void *mgl_fltk_tmp(void *)      {       mglFlRun();     return 0;       }
-int main (int argc, char ** argv)
-{
-  mglWindow gr(0,sample,"test");  // create window
-  static pthread_t tmp;
-  pthread_create(&tmp, 0, mgl_fltk_tmp, 0);
-  pthread_detach(tmp);    // run window handling in the separate thread
-  for(int i=0;i<10;i++)   // do calculation
-  {
-    sleep(1);             // which can be very long
-    pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1);
-    gr.Update();          // update window
-  }
-  return 0;   // finish calculations and close the window
-}
-//-----------------------------------------------------------------------------
-@end verbatim
-If you just need a static image with current results of calculation then you can set @code{NULL} as plotting function and call @code{Update()} when you want to update the image. This way is also usefult for Fortran users.
-@verbatim
-//-----------------------------------------------------------------------------
-#include <mgl/window.h>
-//-----------------------------------------------------------------------------
-int sample(mglGraph *gr)
-{
-  gr->Box();  gr->Line(mglPoint(),pnt,"Ar2"); // just draw a vector
-  return 0;
-}
-//-----------------------------------------------------------------------------
-void *mgl_fltk_tmp(void *)      {       mglFlRun();     return 0;       }
-int main (int argc, char ** argv)
-{
-  mglWindow gr(0,NULL,"test");  // create window
-  for(int i=0;i<10;i++)   // do calculation
-  {
-    sleep(1);             // which can be very long
-    pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1);
-    sample(&gr);          // draw picture
-    gr.Update();          // update window
-  }
-  return 0;   // finish calculations and close the window
-}
-//-----------------------------------------------------------------------------
-@end verbatim
-
-
-@item How many people write this library?
-Most of the library was written by one person. This is a result of nearly a year of work (mostly in the evening and on holidays): I spent half a year to write the kernel and half a year to a year on extending, improving the library and writing documentation. This process continues now :). The autoconf/automake script was written mostly by D.Kulagin, and the export to IDTF was written mostly by M.Vidassov.
-
-@item How can I display a bitmap on the figure?
-You can import data into a @code{mglData} instance and display it by @code{Dens()} function. For example, for black-and-white bitmap you can use the code: @code{mglData bmp; bmp.Import("fname.png","wk"); gr->Dens(bmp,"wk");}.
-
-@item How can I use MathGL in Qt, FLTK, wxWidgets etc.?
-There are special classes (widgets) for these libraries: QMathGL for Qt, Fl_MathGL for FLTK and so on. If you don't find the appropriate class then you can create your own widget that displays a bitmap using mglCanvas::GetBits().
-
-@item How can I create U3D file (make 3D in PDF)?
-There are 2 steps: first you should create IDTF file, and later convert it to U3D. You can use @uref{http://sourceforge.net/project/showfiles.php?group_id=152187&package_id=300628, U3D tools} for converting IDTF file to U3D. It needs @uref{http://libharu.org, libharu} 2.1.0 or later. For installation use @code{./bootstrap, ./configure, make, sudo make install}. It provides  IDTFConverter program for converting text files *.idtf to binary files *.u3d. The latter can be included into PDF.
-
-@item How I can change the font family?
-First, you should download new font files from @uref{http://mathgl.sourceforge.net/download.html, here} or from @uref{http://sourceforge.net/project/showfiles.php?group_id=152187&package_id=267177, here}. Next, you should load the font files into mglGraph class instance @var{gr} by the following command: @code{gr->LoadFont(fontname,path);}. Here @var{fontname} is the base font name like @samp{STIX} and @var{path} sets the location of font files. Use @code{gr->RestoreFont();} to start using the default font.
-
-@item How can I draw tick out of a bounding box?
-Just set a negative value in @var{SetTickLen}. For example, use @code{gr->SetTickLen(-0.1);}.
-
-@end table
-
-@node Interfaces, Utilities, FAQ, Overview
-@section Interfaces
-
-The MathGL library has interfaces for a set of languages. Most of them are based on the C interface via SWIG tool. There are Python, Java, Octave, Lisp, C#, Guile, Lua, Modula 3, Ocaml, Perl, PHP, Pike, R, Ruby, and Tcl interfaces. Also there is a Fortran interface which has a similar set of functions, but slightly different types of arguments (integers instead of pointers). These functions are marked as [C function].
-@c ++++++++++
-Some of the languages listed above support classes (like C++ or Python). For them, a special wrapper was written.
-@c ++++++++++
-Finally, a special command language MGL was written for a faster access to plotting functions. Corresponding scripts can be executed separately (by UDAV, mgl2png, mgl2eps and so on)
-@ifclear UDAV
- or from the C/C++/Python/... code (@pxref{mglParse class}).
-@end ifclear
-
-@ifclear UDAV
-@menu
-* C interface::
-* Python interface::
-* MGL interface::
-@end menu
-
-@node C interface, Python interface, , Interfaces
-@subsection C/Fortran interface
-
-The C interface is a base for many other interfaces. It contains the pure C functions for most of the methods of MathGL classes. In distinction to C++ classes, C functions must have an argument HMGL (for graphics) and/or HMDT (for data arrays), which specifies the object for drawing or manipulating (changing). So, firstly, the user has to create this object by the function @code{mgl_create_*()} and has to delete it after the use by function @code{mgl_delete_*()}.
-
-All C functions are described in the header file @code{#include <mgl/mgl_c.h>} and use variables of the following types:
-@itemize
-@item
-@code{HMGL} --- Pointer to class @code{mglGraph} (@pxref{MathGL core}).
-@item
-@code{HMDT} --- Pointer to class @code{mglData} (@pxref{Data processing}).
-@item
-@code{HMPR} --- Pointer to class @code{mglParse} (@pxref{mglParse class}).
-@end itemize
-These variables contain identifiers for graphics drawing objects and for the data objects.
-
-Fortran functions/subroutines have the same names as C functions. However, there is a difference. Variable of type @code{HMGL, HMDT} must be an integer with sufficient size (@code{integer*4} in the 32-bit operating system or @code{integer*8} in the 64-bit operating system). All C functions are subroutines in Fortran, which are called by operator @code{call}. The exceptions are functions, which return variables of types @code{HMGL} or @code{HMDT}. These functions should be declared as integer in Fortran code. Also, one should keep in mind that strings in Fortran are denoted by @code{'} symbol, not the @code{"} symbol.
-
-@node Python interface, MGL interface, C interface, Interfaces
-@subsection C++/Python interface
-
-MathGL provides the interface to a set of languages via SWIG library. Some of these languages support classes. The typical example is Python -- which is named in this chapter's title. Exactly the same classes are used for high-level C++ API. Its feature is using only inline member-functions what make high-level API to be independent on compiler even for binary build.
-
-There are 2 classes in:
-@itemize
-@item @code{mglGraph}
--- provide most plotting functions (@pxref{MathGL core}).
-@item @code{mglData}
--- provide base data processing (@pxref{Data processing}). It have an additional feature to access data values. You can use a construct like this: @code{dat[i]=sth;} or @code{sth=dat[i]} where flat representation of data is used (i.e., @var{i} can be in range 0...nx*nx*nz-1). You can also import NumPy arrays as input arguments in Python: @code{mgl_dat = mglData(numpy_dat);}.
-@c @item @code{mglParse} -- practically the same as C++ class @code{MathGL provides the interface to a set of languages via SWIG library. Some of these languages support classes. The typical example is Python -- which is denoted in the chapter title.
-@end itemize
-
-
-To use Python classes just execute @samp{import mathgl}. The simplest example will be:
-@verbatim
-import mathgl
-a=mathgl.mglGraph()
-a.Box()
-a.WritePNG("test.png")
-@end verbatim
-Alternatively you can import all classes from @code{mathgl} module and easily access MathGL classes like this:
-@verbatim
-from mathgl import *
-a=mglGraph()
-a.Box()
-a.WritePNG("test.png")
-@end verbatim
-This becomes useful if you create many @code{mglData} objects, for example.
-
-
-@node MGL interface, , Python interface, Interfaces
-@end ifclear
-@subsection MGL interface
-
-MathGL library supports the simplest scripts for data handling and plotting. These scripts can be used independently (with the help of UDAV, mglconv, mglview programs and others, @pxref{Utilities}) or in the frame of the library using.
-
-MGL script language is rather simple. Each string is a command. First word of string is the name of command. Other words are command arguments. Command may have up to 1000 arguments (at least for now). Words are separated from each other by space or tabulation symbol. The upper or lower case of words is sufficient, i.e. variables @var{a} and @var{A} are different variables. Symbol @samp{#} starts the comment (all characters after # will be ignored). The exception is situation when @samp{#} is a part of some string. Also options can be specified after symbol @samp{;} (@pxref{Command options}). Symbol @samp{:} starts new command (like new line character) if it is not placed inside a string or inside brackets.
-
-If string contain references to external parameters (substrings @samp{$0}, @samp{$1} ... @samp{$9}) or definitions (substrings @samp{$a}, @samp{$b} ... @samp{$z}) then before execution the values of parameter/definition will be substituted instead of reference. It allows to use the same MGL script for different parameters (filenames, paths, condition and so on).
-
-Argument can be a string, a variable name or a number.
-@itemize @bullet
-@item
-The string is any symbols between ordinary marks @samp{'}.
-
-@item
-Usually variable have a name which is arbitrary combination of symbols (except spaces and @samp{'}) started from a letter and with length less than 64. A temporary array can be used as variable:
-@itemize @bullet
-@item
-sub-arrays (like in @ref{subdata} command) as command argument. For example, @code{a(1)} or @code{a(1,:)} or @code{a(1,:,:)} is second row, @code{a(:,2)} or @code{a(:,2,:)} is third column, @code{a(:,:,0)} is first slice and so on. Also you can extract a part of array from m-th to n-th element by code @code{a(m:n,:,:)} or just @code{a(m:n)}.
-
-@item
-any column combinations defined by formulas, like @code{a('n*w^2/exp(t)')} if names for data columns was specified (by @ref{idset} command or in the file at string started with @code{##}).
-
-@item
-any expression (without spaces) of existed variables produce temporary variable. For example, @samp{sqrt(dat(:,5)+1)} will produce temporary variable with data values equal to @code{tmp[i,j] = sqrt(dat[i,5,j]+1)}.
+@c ------------------------------------------------------------------
+@node  Quick guide, Changes from v.1, Installation and usage, Overview
+@section Quick guide
+@c ------------------------------------------------------------------
+@node  Changes from v.1, Utilities, Quick guide, Overview
+@section Changes from v.1.*
 
-@item
-temporary variable of higher dimensions by help of []. For example, @samp{[1,2,3]} will produce a temporary vector of 3 elements @{1, 2, 3@}; @samp{[[11,12],[21,22]]} will produce matrix 2*2 and so on. Here you can join even an arrays of the same dimensions by construction like @samp{[v1,v2,...,vn]}.
 
-@item
-result of code for making new data (@pxref{Make another data}) inside @{@}. For example, @samp{@{sum dat 'x'@}} produce temporary variable which contain result of summation of @var{dat} along direction 'x'. This is the same array @var{tmp} as produced by command @samp{sum tmp dat 'x'}. You can use nested constructions, like @samp{@{sum @{max dat 'z'@} 'x'@}}.
-@end itemize
-Temporary variables can not be used as 1st argument for commands which create (return) the data (like @samp{new}, @samp{read}, @samp{hist} and so on).
 
-@item
-Special names @code{nan=#QNAN, pi=3.1415926..., on=1, off=0, :=-1} are treated as number if they were not redefined by user. Variables with suffixes are treated as numbers (@pxref{Data information}). Names defined by @ref{define} command are treated as number. Also results of formulas with sizes 1x1x1 are treated as number (for example, @samp{pi/dat.nx}).
-@end itemize
-Before the first using all variables must be defined with the help of commands, like, @ref{new}, @ref{var}, @ref{list}, @ref{copy}, @ref{read}, @ref{hist}, @ref{sum} and so on (see sections @ref{Data constructor}, @ref{Data filling} and @ref{Make another data}).
-
-Command may have several set of possible arguments (for example, @code{plot ydat} and @code{plot xdat ydat}). All command arguments for a selected set must be specified. However, some arguments can have default values. These argument are printed in [], like @code{plot ydat ['stl'='' zval=nan]}. At this, the record @code{[arg1 arg2 arg3 ...]} means @code{[arg1 [arg2 [arg3 ...]]]}, i.e. you can omit only tailing arguments if you agree with its default values. For example, @code{plot ydat '' 1} or @code{plot ydat ''} is correct, but @code{plot ydat 1} is incorrect (argument @code{'stl'} is missed).
-
-Below I show commands to control program flow, like, conditions, cycles, define script arguments and so on. Other commands can be found in chapters @ref{MathGL core} and @ref{Data processing}.
-
-@cindex chdir
-@anchor{chdir}
-@deftypefn {MGL command} {} chdir 'path'
-Changes the current directory to @var{path}.
-@end deftypefn
-
-@cindex define
-@anchor{define}
-@deftypefn {MGL command} {} define $N smth
-Sets @var{N}-th script argument to @var{smth}. Note, that @var{smth} is used as is (with @samp{'} symbols if present). Here @var{N} is digit (0...9) or alpha (a...z).
-@end deftypefn
-@deftypefn {MGL command} {} define name smth
-Create scalar variable @code{name} which have the numeric value of @code{smth}. Later you can use this variable as usual number. Here @var{N} is digit (0...9) or alpha (a...z).
-@end deftypefn
-@cindex defchr
-@anchor{defchr}
-@deftypefn {MGL command} {} defchr $N smth
-Sets @var{N}-th script argument to character with value evaluated from @var{smth}. Here @var{N} is digit (0...9) or alpha (a...z).
-@end deftypefn
-@cindex defnum
-@anchor{defnum}
-@deftypefn {MGL command} {} defnum $N smth
-Sets @var{N}-th script argument to number with value evaluated from @var{smth}. Here @var{N} is digit (0...9) or alpha (a...z).
-@end deftypefn
-@cindex defpal
-@anchor{defpal}
-@deftypefn {MGL command} {} defpal $N smth
-Sets @var{N}-th script argument to palette character at position evaluated from @var{smth}. Here @var{N} is digit (0...9) or alpha (a...z).
-@end deftypefn
-
-@cindex call
-@anchor{call}
-@deftypefn {MGL command} {} call 'fname' [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]
-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
-@anchor{return}
-@deftypefn {MGL command} {} return
-Return from the function. See also @ref{func}.
-@end deftypefn
-
-
-@cindex if
-@anchor{if}
-@deftypefn {MGL command} {} if dat 'cond'
-Starts block which will be executed if @var{dat} satisfy to @var{cond}.
-@end deftypefn
-@deftypefn {MGL command} {} if @code{val}
-Starts block which will be executed if @code{val} is nonzero.
-@end deftypefn
-@cindex elseif
-@anchor{elseif}
-@deftypefn {MGL command} {} elseif dat 'cond'
-Starts block which will be executed if previous @code{if} or @code{elseif} is false and @var{dat} satisfy to @var{cond}.
-@end deftypefn
-@deftypefn {MGL command} {} elseif @code{val}
-Starts block which will be executed if previous @code{if} or @code{elseif} is false and @code{val} is nonzero.
-@end deftypefn
-@cindex else
-@anchor{else}
-@deftypefn {MGL command} {} else
-Starts block which will be executed if previous @code{if} or @code{elseif} is false.
-@end deftypefn
-@cindex endif
-@anchor{endif}
-@deftypefn {MGL command} {} endif
-Finishes @code{if/elseif/else} block.
-@end deftypefn
-
-@cindex for
-@anchor{for}
-@deftypefn {MGL command} {} for $N @code{v1 v2 [dv=1]}
-Starts cycle with $@var{N}-th argument changing from @var{v1} to @var{v2} with the step @var{dv}. Here @var{N} is digit (0...9) or alpha (a...z).
-@end deftypefn
-@deftypefn {MGL command} {} for $N dat
-Starts cycle with $@var{N}-th argument changing for @var{dat} values. Here @var{N} is digit (0...9) or alpha (a...z).
-@end deftypefn
-@cindex next
-@anchor{next}
-@deftypefn {MGL command} {} next
-Finishes @code{for} cycle.
-@end deftypefn
-
-@cindex once
-@anchor{once}
-@deftypefn {MGL command} {} once @code{val}
-The code between @code{once on} and @code{once off} will be executed only once. Useful for large data manipulation in programs like UDAV.
-@end deftypefn
-@cindex stop
-@anchor{stop}
-@deftypefn {MGL command} {} stop
-Terminate execution.
-@end deftypefn
 
 @c ------------------------------------------------------------------
-@node  Utilities, Thanks, Interfaces, Overview
+@node  Utilities, Thanks, Changes from v.1, Overview
 @section Utilities for parsing MGL
 
 MathGL library provides several tools for parsing MGL scripts. There is tools saving it to bitmap or vectorial images (@code{mgl2conv}). Tool @code{mglview} show MGL script and allow to rotate and setup the image. Also you can translate MGL script to C++ file by help of @code{mgl2cpp} tool.
diff --git a/texinfo/parse_en.texi b/texinfo/parse_en.texi
new file mode 100644 (file)
index 0000000..c9e53a0
--- /dev/null
@@ -0,0 +1,89 @@
+
+@c ------------------------------------------------------------------
+@chapter MGL scripts
+
+@menu
+* mglParse class::
+@end menu
+
+@c ------------------------------------------------------------------
+@node mglParse class, , , MGL scripts
+@section mglParse class
+@cindex mglParse
+
+Class for parsing and executing MGL script. This class is defined in @code{#include <mgl/mgl.h>}.
+
+Class mglParse is the interpreter for MGL scripts (@pxref{MGL interface}). The main function of mglParse class is @code{Parse()}. Exactly this function parses and executes the script string-by-string. Also there are two subservient functions for the finding and creation of a variable. These functions can be useful for displaying values of variables (arrays) in some external program (in window, for example). The variable @var{DataList} contains full list of variables in script. Flag @var{AllowSetSize} allows one to prevent changing the size of the  picture inside the script (forbids the MGL command @code{setsize}).
+
+@c Note an important feature -- if user defines function @var{func} in variable then it will be called before the destroying of this variable (@pxref{mglVar class}).
+
+@deftypefn {Constructor on @code{mglParse}} @code{} mglParse (@code{bool} setsize=@code{false})
+@deftypefnx {C function} @code{HMPR} mgl_create_parser ()
+Constructor initializes all values with zero and set @var{AllowSetSize} value.
+@end deftypefn
+
+@deftypefn {Destructor on @code{mglParse}} @code{} ~mglParse ()
+@deftypefnx {C function} @code{void} mgl_delete_parser (@code{HMPR} p)
+Destructor delete parser
+@end deftypefn
+
+@deftypefn {Method on @code{mglParse}} @code{int} Parse (@code{mglGraph *}gr, @code{const char *}str, @code{long} pos=@code{0})
+@deftypefnx {Method on @code{mglParse}} @code{int} Parse (@code{mglGraph *}gr, @code{const wchar_t *}str, @code{long} pos=@code{0})
+@deftypefnx {C function} @code{int} mgl_parse (@code{HMGL} gr, @code{HMPR} p, @code{const char *}str, @code{int} pos)
+@deftypefnx {C function} @code{int} mgl_parsew (@code{HMGL} gr, @code{HMPR} p, @code{const wchar_t *}str, @code{int} pos)
+Main function in the class. It parses the string @var{str} and executes it by  using @var{gr} as a graphics plotter. Returns the value depending on an error presence in the string @var{str}: 0 -- no error, 1 -- wrong command argument(s), 2 -- unknown command, 3 -- string is too long. Optional argument @var{pos} allows to save the string position in the document (or file) for using @code{for|next} command.
+@end deftypefn
+
+@deftypefn {Method on @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{FILE *}fp, @code{bool} print=@code{false})
+@deftypefnx {C function} @code{int} mgl_parsew (@code{HMGL} gr, @code{HMPR} p, @code{FILE *}fp, @code{int} print)
+Function parse and execute line-by-line MGL script in file @var{fp}. If @var{print}=@code{true} then all warnings and information will be printed in stdout.
+@end deftypefn
+
+@deftypefn {Method on @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{const char *}text, @code{void (*} error @code{)(int line, int kind, char *mes)=NULL})
+@deftypefnx{Method on @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{const wchar_t *}text, @code{void (*} error @code{)(int line, int kind, char *mes)=NULL})
+@deftypefnx {C function} @code{void} mgl_parse_text (@code{HMGL} gr, @code{HMPR} p, @code{const char *}text, @code{void (*} error @code{)(int line, int kind, char *mes)})
+@deftypefnx {C function} @code{void} mgl_parsew_text (@code{HMGL} gr, @code{HMPR} p, @code{const wchar_t *}text, @code{void (*} error @code{)(int line, int kind, char *mes)})
+Function parse and execute line-by-line MGL script in array @var{text}. Lines are separated by newline symbol @samp{\n} as usual. If @var{error} is not @code{NULL} then this function will be called for all warnings, information and other messages.
+@end deftypefn
+
+@deftypefn {Method on @code{mglParse}} @code{bool} AddParam (@code{int} n, @code{const char *}str, @code{bool} isstr=@code{true})
+@deftypefnx {Method on @code{mglParse} (C++)} @code{bool} AddParam (@code{int} n, @code{const wchar_t *}str, @code{bool} isstr=@code{true})
+@deftypefnx {C function} @code{void} mgl_add_param (@code{HMPR} p, @code{int} id, @code{const char *}val)
+@deftypefnx {C function} @code{void} mgl_add_paramw (@code{HMPR} p, @code{int} id, @code{const wchar_t *}val)
+Function set the value of @var{n}-th parameter as string @var{str} (@var{n}=0, 1 ... 9). It return @code{true} for success.
+@end deftypefn
+
+@deftypefn {Method on @code{mglParse}} @code{mglData *} FindVar (@code{const char *}name)
+@deftypefnx {C function} @code{HMDT} mgl_find_var  (@code{HMPR} p, @code{const char *}name)
+Function returns the pointer to variable with name @var{name} or zero if variable is absent. Use this function to put external data array to the script or get the data from the script. You must @strong{not delete} obtained data arrays!
+@end deftypefn
+@deftypefn {Method on @code{mglParse}} @code{mglData *} AddVar (@code{const char *}name)
+@deftypefnx {C function} @code{HMDT} mgl_add_var (@code{HMPR} p, @code{const char *}name)
+Function returns the pointer to variable with name @var{name}. If variable is absent then new variable is created with name @var{name}. Use this function to put external data array to the script or get the data from the script. You must @strong{not delete} obtained data arrays!
+@end deftypefn
+
+@deftypefn{Method on @code{mglParse} (C++)} @code{void} DeleteVar (@code{const char *}name)
+@deftypefnx {C function} @code{void} mgl_del_var (@code{HMPR} p, @code{const char *}name)
+Function delete the variable specified by its name or by its pointer.
+@end deftypefn
+
+@deftypefn {Method on @code{mglParse}} @code{void} RestoreOnce ()
+@deftypefnx {C function} @code{void} mgl_restore_once (@code{HMPR} p)
+Restore Once flag.
+@end deftypefn
+
+@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.
+@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.
+@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.
+@end deftypefn
diff --git a/texinfo/parse_ru.texi b/texinfo/parse_ru.texi
new file mode 100644 (file)
index 0000000..c9e53a0
--- /dev/null
@@ -0,0 +1,89 @@
+
+@c ------------------------------------------------------------------
+@chapter MGL scripts
+
+@menu
+* mglParse class::
+@end menu
+
+@c ------------------------------------------------------------------
+@node mglParse class, , , MGL scripts
+@section mglParse class
+@cindex mglParse
+
+Class for parsing and executing MGL script. This class is defined in @code{#include <mgl/mgl.h>}.
+
+Class mglParse is the interpreter for MGL scripts (@pxref{MGL interface}). The main function of mglParse class is @code{Parse()}. Exactly this function parses and executes the script string-by-string. Also there are two subservient functions for the finding and creation of a variable. These functions can be useful for displaying values of variables (arrays) in some external program (in window, for example). The variable @var{DataList} contains full list of variables in script. Flag @var{AllowSetSize} allows one to prevent changing the size of the  picture inside the script (forbids the MGL command @code{setsize}).
+
+@c Note an important feature -- if user defines function @var{func} in variable then it will be called before the destroying of this variable (@pxref{mglVar class}).
+
+@deftypefn {Constructor on @code{mglParse}} @code{} mglParse (@code{bool} setsize=@code{false})
+@deftypefnx {C function} @code{HMPR} mgl_create_parser ()
+Constructor initializes all values with zero and set @var{AllowSetSize} value.
+@end deftypefn
+
+@deftypefn {Destructor on @code{mglParse}} @code{} ~mglParse ()
+@deftypefnx {C function} @code{void} mgl_delete_parser (@code{HMPR} p)
+Destructor delete parser
+@end deftypefn
+
+@deftypefn {Method on @code{mglParse}} @code{int} Parse (@code{mglGraph *}gr, @code{const char *}str, @code{long} pos=@code{0})
+@deftypefnx {Method on @code{mglParse}} @code{int} Parse (@code{mglGraph *}gr, @code{const wchar_t *}str, @code{long} pos=@code{0})
+@deftypefnx {C function} @code{int} mgl_parse (@code{HMGL} gr, @code{HMPR} p, @code{const char *}str, @code{int} pos)
+@deftypefnx {C function} @code{int} mgl_parsew (@code{HMGL} gr, @code{HMPR} p, @code{const wchar_t *}str, @code{int} pos)
+Main function in the class. It parses the string @var{str} and executes it by  using @var{gr} as a graphics plotter. Returns the value depending on an error presence in the string @var{str}: 0 -- no error, 1 -- wrong command argument(s), 2 -- unknown command, 3 -- string is too long. Optional argument @var{pos} allows to save the string position in the document (or file) for using @code{for|next} command.
+@end deftypefn
+
+@deftypefn {Method on @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{FILE *}fp, @code{bool} print=@code{false})
+@deftypefnx {C function} @code{int} mgl_parsew (@code{HMGL} gr, @code{HMPR} p, @code{FILE *}fp, @code{int} print)
+Function parse and execute line-by-line MGL script in file @var{fp}. If @var{print}=@code{true} then all warnings and information will be printed in stdout.
+@end deftypefn
+
+@deftypefn {Method on @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{const char *}text, @code{void (*} error @code{)(int line, int kind, char *mes)=NULL})
+@deftypefnx{Method on @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{const wchar_t *}text, @code{void (*} error @code{)(int line, int kind, char *mes)=NULL})
+@deftypefnx {C function} @code{void} mgl_parse_text (@code{HMGL} gr, @code{HMPR} p, @code{const char *}text, @code{void (*} error @code{)(int line, int kind, char *mes)})
+@deftypefnx {C function} @code{void} mgl_parsew_text (@code{HMGL} gr, @code{HMPR} p, @code{const wchar_t *}text, @code{void (*} error @code{)(int line, int kind, char *mes)})
+Function parse and execute line-by-line MGL script in array @var{text}. Lines are separated by newline symbol @samp{\n} as usual. If @var{error} is not @code{NULL} then this function will be called for all warnings, information and other messages.
+@end deftypefn
+
+@deftypefn {Method on @code{mglParse}} @code{bool} AddParam (@code{int} n, @code{const char *}str, @code{bool} isstr=@code{true})
+@deftypefnx {Method on @code{mglParse} (C++)} @code{bool} AddParam (@code{int} n, @code{const wchar_t *}str, @code{bool} isstr=@code{true})
+@deftypefnx {C function} @code{void} mgl_add_param (@code{HMPR} p, @code{int} id, @code{const char *}val)
+@deftypefnx {C function} @code{void} mgl_add_paramw (@code{HMPR} p, @code{int} id, @code{const wchar_t *}val)
+Function set the value of @var{n}-th parameter as string @var{str} (@var{n}=0, 1 ... 9). It return @code{true} for success.
+@end deftypefn
+
+@deftypefn {Method on @code{mglParse}} @code{mglData *} FindVar (@code{const char *}name)
+@deftypefnx {C function} @code{HMDT} mgl_find_var  (@code{HMPR} p, @code{const char *}name)
+Function returns the pointer to variable with name @var{name} or zero if variable is absent. Use this function to put external data array to the script or get the data from the script. You must @strong{not delete} obtained data arrays!
+@end deftypefn
+@deftypefn {Method on @code{mglParse}} @code{mglData *} AddVar (@code{const char *}name)
+@deftypefnx {C function} @code{HMDT} mgl_add_var (@code{HMPR} p, @code{const char *}name)
+Function returns the pointer to variable with name @var{name}. If variable is absent then new variable is created with name @var{name}. Use this function to put external data array to the script or get the data from the script. You must @strong{not delete} obtained data arrays!
+@end deftypefn
+
+@deftypefn{Method on @code{mglParse} (C++)} @code{void} DeleteVar (@code{const char *}name)
+@deftypefnx {C function} @code{void} mgl_del_var (@code{HMPR} p, @code{const char *}name)
+Function delete the variable specified by its name or by its pointer.
+@end deftypefn
+
+@deftypefn {Method on @code{mglParse}} @code{void} RestoreOnce ()
+@deftypefnx {C function} @code{void} mgl_restore_once (@code{HMPR} p)
+Restore Once flag.
+@end deftypefn
+
+@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.
+@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.
+@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.
+@end deftypefn
index 22e0c1adfd9c159e962bbb9df7eb7f7366f65b44..7b547c4743f5c45164775be9f5db13d056a36330 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -1,21 +1,13 @@
 ============= TEST =============
+
 1. MGL testing system
 2. test pthread for windows
-3. Check highlight -- UDAV: set proper pos, correct dbl-click, dbl-click on messages
-4. Check export to MGLD/TeX/OBJ/XGL/X3D/STL.
-5. check 'rotatetext off', 'fgets'
-6. font loading in udav
-7. add XInitThreads() from #include <X11/Xlib.h> into all GUI
-8, Fl::awake() for Update()?!? + similar for Qt
-
-6. Check fontsize maximum ?!?
-7. curved text (in new sample) look not so good
-8. emulate fog in EPS/SVG
-9. line segment losses in EPS ???
+3. Check export to MGLD/TeX/OBJ/XGL/X3D/STL.
+4. add XInitThreads() from #include <X11/Xlib.h> into all GUI
+5, Fl::lock() for Update()?!? + similar for Qt
 
 ============= NEW  =============
 
-1. ReadHDF5 -- add string argument for handling lowest dimension (like complex numbers): "sum" - sum, "arg" - arg, "0...9" read slice 0...9, "abs" - sqrt(sum []^2)
 2. Export to X3D and VRML
 3. Sample for TriPlot (piramid) and QuadPlot (cube)
 
 14. Axis -- projection (ternary + quaternary)
 15. Examples of animation, u3d, x3d, js and so on
 
+16. Check fontsize maximum ?!?
+17. curved text (in new sample) look not so good
+18. emulate fog in EPS/SVG
+19. line segment losses in EPS ???
+
+20. ReadHDF5 -- add string argument for handling lowest dimension (like complex numbers): "sum" - sum, "arg" - arg, "0...9" read slice 0...9, "abs" - sqrt(sum []^2)
+
 ============= UDAV =============
 
 01. Dialog for data input
@@ -129,3 +128,85 @@ Remove other setting if data name is changed.
 
 1. утилиты (mgl2png и пр.) вылетают, если в коментариях русские буквы
 
+========= Docs structure =======
+
+       1. Overview
+               1.1 What is MathGL?
+               1.2 Installation and usage
+               1.3 Quick start
+               1.4 Changes from v.1.*
+               1.5 Utilities
+               1.6 Thanks
+
+       2. Examples
+               2.1 Basic usage (window; file; memory; QMathGL; Fl_MathGL; PyQt)
+               2.2 Advanced usage (subplots; axis; curv.coor; text)
+               2.3 Animation (win.stat; win.update; gif; jpeg/mpeg)
+               2.4 Data handling
+               2.5 1D data plotting
+               2.6 2D data plotting
+               2.7 3D data plotting
+               2.8 Dual data plotting
+               2.9 Multi-threading
+               2.10 Hints
+               2.11 FAQ
+
+       3 General concepts (class-diagram)
+               3.1 Coordinate axes
+               3.2 Line styles
+               3.3 Color scheme
+               3.4 Font styles
+               3.5 Textual formulas
+               3.6 Command options
+               3.7 Interfaces (c++/python; c/fortran; mgl)
+
+       3. MathGL core
+               3.1 Create and delete objects
+               3.2 Graphics setup
+               3.3 Axis settings
+               3.4 Transformation matrix
+               3.5 Export picture
+               3.6 Primitives drawing
+               3.7 Text printing
+               3.8 Axis and Colorbar
+               3.9 Legend
+               3.10 1D plotting
+               3.11 2D plotting
+               3.12 3D plotting
+               3.13 Dual plotting
+               3.14 Vector fields
+               3.15 Other plotting
+               3.16 Nonlinear fitting
+               3.17 Data manipulation
+
+       4. Widget classes
+               4.1 mglWindow class
+               4.2 Fl_MathGL class
+               4.3 QMathGL class
+
+       5. Data processing
+               5.1 Public variables
+               5.2 Data constructor
+               5.3 Data resizing
+               5.4 Data filling
+               5.5 File I/O
+               5.6 Make another data
+               5.7 Data changing
+               5.8 Interpolation
+               5.9 Data information
+               5.10 Operators
+               5.11 Global functions
+
+       6 MGL scripts
+               6.1 MGL definition
+               6.2 mglParse class
+               6.3 Program flow commands
+
+       7. Other classes (c++ only)
+               7.1 mglBase class
+               7.2 mglDataA class
+               7.3 mglCanvas class
+               7.4 mglFormula class
+               7.5 mglColor class
+               7.6 mglPoint class
+               7.7 mglFont class (format)
index 6114126bc215eb58153f52e36eb6e5a1ec519925..43912ffbc4f3d92f4f1a73139a40e7b64bdfc671 100644 (file)
@@ -3,13 +3,13 @@ if(use_qt)
 
 #set(mgl_wnd_src window.cpp)
 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 qmglcanvas.cpp text_pnl.cpp calc_dlg.cpp hint_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)
 
 set(udav_moc_hdr anim_dlg.h files_dlg.h info_dlg.h opt_dlg.h qmglsyntax.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
-       prop_dlg.h style_dlg.h dat_pnl.h open_dlg.h qmglcanvas.h textedit.h hint_dlg.h)
+       prop_dlg.h style_dlg.h dat_pnl.h open_dlg.h textedit.h hint_dlg.h)
 
 set(udav_rc udav.qrc)
 
diff --git a/udav/qmglcanvas.cpp b/udav/qmglcanvas.cpp
deleted file mode 100644 (file)
index 9958469..0000000
+++ /dev/null
@@ -1,412 +0,0 @@
-/***************************************************************************\r
- *   Copyright (C) 2008 by Alexey Balakin                                  *\r
- *   mathgl.abalakin@gmail.com                                             *\r
- *                                                                         *\r
- *   This program is free software; you can redistribute it and/or modify  *\r
- *   it under the terms of the GNU General Public License as published by  *\r
- *   the Free Software Foundation; either version 2 of the License, or     *\r
- *   (at your option) any later version.                                   *\r
- *                                                                         *\r
- *   This program is distributed in the hope that it will be useful,       *\r
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *\r
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *\r
- *   GNU General Public License for more details.                          *\r
- *                                                                         *\r
- *   You should have received a copy of the GNU General Public License     *\r
- *   along with this program; if not, write to the                         *\r
- *   Free Software Foundation, Inc.,                                       *\r
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *\r
- ***************************************************************************/\r
-\r
-#include <QApplication>\r
-#include <QMouseEvent>\r
-#include <QMessageBox>\r
-#include <QMenu>\r
-#include <QClipboard>\r
-#include <QTextEdit>\r
-#include <QPainter>\r
-#include <QCursor>\r
-#include <QImage>\r
-#include <QFileInfo>\r
-#include <QProcess>\r
-#include <QStringList>\r
-#include <stdio.h>\r
-#include <mgl/parser.h>\r
-//#include <mgl/mgl_idtf.h> //TODO: Add later\r
-#include "qmglcanvas.h"\r
-extern mglParser parser;\r
-extern bool mglAutoPure;\r
-//-----------------------------------------------------------------------------\r
-QMGLCanvas::QMGLCanvas(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)\r
-{\r
-       autoResize = false;\r
-       textMGL = warnMGL = 0;  appName = tr("UDAV");\r
-       popup = 0;      grBuf = 0;      phi = tet = per = 0;\r
-       alpha = light = rotate = grid = false;\r
-       graph = new mglGraph;\r
-       resize(graph->GetWidth(), graph->GetHeight());\r
-       convertFromGraph(pic, graph, &grBuf);\r
-       thr = new MGLThread();  thr->cnv = this;\r
-}\r
-//-----------------------------------------------------------------------------\r
-QMGLCanvas::~QMGLCanvas()\r
-{      delete thr;     delete graph;   if(grBuf)       delete []grBuf; }\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::paintEvent(QPaintEvent *)\r
-{\r
-       QPainter paint;\r
-       paint.begin(this);\r
-       paint.drawPixmap(0,0,pic);\r
-       if(grid)\r
-       {\r
-               int i, h=pic.height(), w=pic.width();\r
-               paint.setPen(QColor(192,192,192));\r
-               for(i=1;i<10;i++)\r
-               {\r
-                       paint.drawText(0,i*h/10,QString::number(1-i*0.1));\r
-                       paint.drawLine(0,i*h/10,w,i*h/10);\r
-                       paint.drawText(i*w/10,h,QString::number(i*0.1));\r
-                       paint.drawLine(i*w/10,0,i*w/10,h);\r
-               }\r
-       }\r
-       paint.end();\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::resizeEvent(QResizeEvent *ev)\r
-{\r
-       if(autoResize && ev->size().width()>0 && ev->size().height()>0)\r
-       {       graph->SetSize(ev->size().width(), ev->size().height());        execute();      repaint();      }\r
-       else    resize(graph->GetWidth(), graph->GetHeight());\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::setPer(int p)\r
-{\r
-       if(per!=p && p>=0 && p<100)\r
-       {       per = 100*p;    emit perChanged(p);     execute();      }\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::imgSize(int w, int h)\r
-{      if(w<=0 || h<=0)        return;\r
-       graph->SetSize(w,h);    execute();      }\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::setPhi(int p)\r
-{      if(phi!=p)      {       phi = p;        emit phiChanged(p);     execute();      }       }\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::setTet(int t)\r
-{      if(tet!=t)      {       tet = t;        emit tetChanged(t);     execute();      }       }\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::setGrid(bool a)\r
-{      if(grid!=a)             {       grid = a;       emit gridChanged(a);    execute();      }       }\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::setAlpha(bool a)\r
-{      if(alpha!=a)    {       alpha = a;      emit alphaChanged(a);   execute();      }       }\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::setLight(bool l)\r
-{      if(light!=l)    {       light = l;      emit lightChanged(l);   execute();      }       }\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::setRotate(bool r)\r
-{\r
-       if(rotate!=r)\r
-       {\r
-               rotate=r;\r
-               emit rotateChanged(r);\r
-               execute();\r
-       }\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::restore()\r
-{\r
-       setPhi(0);      setTet(0);      setPer(0);      rotate=false;\r
-       emit rotateChanged(false);\r
-       execute();\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::execute(mglGraph *gr, int line)\r
-{\r
-       if(!textMGL && autoResize)      {       run(defText, false, gr);        return; }\r
-       else if(!textMGL)       return;\r
-       run(textMGL->toPlainText(), true, gr, line);\r
-       if(pic.size()!=size())  setSize(pic.width(), pic.height());\r
-       emit refreshData();\r
-}\r
-//-----------------------------------------------------------------------------\r
-QString QMGLCanvas::run(const QString &text, bool showm, mglGraph *gr, int line)\r
-{\r
-       defText = text;\r
-       if(gr==0)       gr=graph;\r
-       if(gr==0)       return QString(tr("Not initialized!"));\r
-       gr->DefaultPlotParam();\r
-       gr->Alpha(alpha);       gr->Light(light);\r
-       gr->View(tet,phi);      gr->SetOrigin(NAN,NAN,NAN);\r
-       gr->Perspective(per);\r
-//     gr->DrawFace = !(rotate && mglAutoPure);\r
-       if(text.count("rotate ")==0 && text.count("rotate\t")==0)       gr->Rotate(0,0);\r
-       parser.Stop = false;\r
-       parser.AllowSetSize = true;\r
-       showMessage = showm;\r
-\r
-       if(warnMGL && !warnMGL->toPlainText().isEmpty())        warnMGL->clear();\r
-       // At least now I don't want use setup script ! So I skip this code\r
-       if(!isHidden()) QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));\r
-       if(!thr->isRunning())\r
-       {\r
-               thr->gr = gr;   thr->text = text;\r
-               thr->line = line;       thr->start();\r
-       }\r
-       if(rotate)      thr->wait();\r
-       else    while(thr->isRunning()) qApp->processEvents();\r
-       if(warnMGL)     warnMGL->setText(thr->warn);\r
-       if(!isHidden()) QApplication::restoreOverrideCursor();\r
-       if(gr==graph)\r
-       {       convertFromGraph(pic, graph, &grBuf);   repaint();      }\r
-       return QString(gr->Message());\r
-}\r
-//-----------------------------------------------------------------------------\r
-void MGLThread::run()\r
-{\r
-       gr->DefaultPlotParam();\r
-       wchar_t *str = new wchar_t[text.length()+2];\r
-       text.toWCharArray(str);\r
-       setlocale(LC_ALL, "C");\r
-       parser.Execute(gr,str,NULL,line);\r
-       setlocale(LC_ALL, "");\r
-       const char *mess=gr->Message();\r
-       warn = mess?mess:"";    delete []str;\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::mouseDoubleClickEvent(QMouseEvent *ev)\r
-{\r
-       int oi = graph->GetObjId(ev->x(),ev->y())-1;\r
-       emit objChanged(oi);\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::mousePressEvent(QMouseEvent *ev)\r
-{\r
-       if(!rotate && ev->button()&Qt::LeftButton)\r
-       {\r
-               mglPoint p = graph->CalcXYZ(ev->x(), ev->y());\r
-               clickPos.sprintf("x=%g, y=%g, z=%g  --  Xabs=%.3g, Yabs=%.3g",\r
-                                       p.x,p.y,p.z,double(ev->x())/graph->GetWidth(),\r
-                                       1-double(ev->y())/graph->GetHeight());\r
-               emit posChanged(clickPos);\r
-       }\r
-       xe=x0=ev->x();  ye=y0=ev->y();\r
-       ev->accept();\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::mouseReleaseEvent(QMouseEvent *ev)\r
-{\r
-       if(ev->button()&Qt::RightButton && popup && !rotate)    // popup menu\r
-               popup->popup(QCursor::pos());\r
-       ev->accept();\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::mouseMoveEvent(QMouseEvent *ev)\r
-{\r
-       xe=ev->x();     ye=ev->y();\r
-       if(rotate)\r
-       {\r
-               if(ev->buttons()&Qt::LeftButton)        // rotate\r
-               {\r
-                       float ff = 240/sqrt(float(width()*height()));\r
-                       phi += int((x0-xe)*ff);\r
-                       tet += int((y0-ye)*ff);\r
-                       if(phi>180)     phi-=360;               if(phi<-180)    phi+=360;\r
-                       if(tet>180)     tet-=360;               if(tet<-180)    tet+=360;\r
-                       emit tetChanged(int(tet));              emit phiChanged(int(phi));\r
-                       execute();\r
-               }\r
-/*             if(ev->buttons()&Qt::RightButton)       // zoom and perspective\r
-               {\r
-                       float ff = 2.*(y0-ye)/width(), gg = 0.5*(xe-x0)/height();\r
-                       float cx = (x1+x2)/2, cy = (y1+y2)/2;\r
-                       x1 = cx+(x1-cx)*exp(-ff);       x2 = cx+(x2-cx)*exp(-ff);\r
-                       y1 = cy+(y1-cy)*exp(-ff);       y2 = cy+(y2-cy)*exp(-ff);\r
-                       per = per + gg;\r
-                       if(per<0)       per = 0;        if(per>=1)      per = 0.9999;\r
-                       if(gg)  emit perChanged(int(per));\r
-                       execute();\r
-               }\r
-               if(ev->buttons()&Qt::MidButton) // shift\r
-               {\r
-                       float ff = 1./sqrt(float(width()*height()));\r
-                       float dx = (x0-xe)*ff*(x2-x1), dy = (y0-ye)*ff*(y2-y1);\r
-                       x1 += dx;       x2 += dx;       y1 -= dy;       y2 -= dy;\r
-               }*/\r
-               x0 = xe;        y0 = ye;\r
-//             execute();\r
-       }\r
-       ev->accept();\r
-}\r
-//-----------------------------------------------------------------------------\r
-QString setExtension(QString &fname, const char *ext)\r
-{\r
-       QString oname;\r
-       if(fname.right(4)==".mgl")\r
-               oname = fname.left(fname.length()-3)+ext;\r
-       else\r
-               oname = fname+"."+QString(ext);\r
-       return oname;\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::startGIF(int animDelay, QString fname)\r
-{      if(fname.isEmpty())     fname = scriptName;\r
-       if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename. Please save script first."),QMessageBox::Ok,0,0);\r
-       else\r
-       {\r
-               graph->StartGIF(setExtension(fname,"gif").toAscii(), animDelay);\r
-               graph->ResetFrames();\r
-       }\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::closeGIF()            {       graph->CloseGIF();      }\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::exportGIF(QString fname)\r
-{      if(fname.isEmpty())     fname = scriptName;\r
-       if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename. Please save script first."),QMessageBox::Ok,0,0);\r
-       else    graph->WriteGIF(setExtension(fname,"gif").toAscii(), appName.toAscii());\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::exportPNG(QString fname)\r
-{      if(fname.isEmpty())     fname = scriptName;\r
-       if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename. Please save script first."),QMessageBox::Ok,0,0);\r
-       else    graph->WritePNG(setExtension(fname,"png").toAscii(), appName.toAscii());\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::exportPNGs(QString fname)\r
-{      if(fname.isEmpty())     fname = scriptName;\r
-       if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename. Please save script first."),QMessageBox::Ok,0,0);\r
-       else    graph->WritePNG(setExtension(fname,"png").toAscii(), appName.toAscii(), false);\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::exportJPG(QString fname)\r
-{      if(fname.isEmpty())     fname = scriptName;\r
-       if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename. Please save script first."),QMessageBox::Ok,0,0);\r
-       else    graph->WriteJPEG(setExtension(fname,"jpg").toAscii(), appName.toAscii());\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::exportBPS(QString fname)\r
-{\r
-       if(fname.isEmpty())     fname = scriptName;\r
-       if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename. Please save script first."),QMessageBox::Ok,0,0);\r
-       else\r
-       {\r
-               setlocale(LC_ALL, "C");\r
-                               graph->WriteBPS(setExtension(fname,"eps.gz").toAscii(), appName.toAscii());\r
-               setlocale(LC_ALL, "");\r
-       }\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::exportEPS(QString fname)\r
-{\r
-       if(fname.isEmpty())     fname = scriptName;\r
-       if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename. Please save script first."),QMessageBox::Ok,0,0);\r
-       else\r
-               {\r
-                               setlocale(LC_ALL, "C");\r
-                               graph->WriteEPS(setExtension(fname,"eps.gz").toAscii(), appName.toAscii());\r
-                               setlocale(LC_ALL, "");\r
-               }\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::exportSVG(QString fname)\r
-{\r
-       if(fname.isEmpty())     fname = scriptName;\r
-       if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename. Please save script first."),QMessageBox::Ok,0,0);\r
-       else\r
-               {\r
-                               setlocale(LC_ALL, "C");\r
-                               graph->WriteSVG(setExtension(fname,"svgz").toAscii(), appName.toAscii());\r
-                               setlocale(LC_ALL, "");\r
-               }\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::exportIDTF(QString fname)\r
-{\r
-       if(fname.isEmpty())     fname = scriptName;\r
-       if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename. Please save script first."),QMessageBox::Ok,0,0);\r
-       else\r
-       {\r
-/*             mglGraphIDTF *ps = new mglGraphIDTF;\r
-               ps->SetFont(graph->GetFont());\r
-               execute(ps);\r
-               setlocale(LC_ALL, "C");\r
-               ps->WriteIDTF(setExtension(fname,"idtf").toAscii(), appName.toAscii());\r
-               setlocale(LC_ALL, "");\r
-                               delete ps;*/\r
-       }\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::exportCPP(QString fname)\r
-{\r
-       if(fname.isEmpty())     fname = scriptName;\r
-       if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename. Please save script first."),QMessageBox::Ok,0,0);\r
-       else\r
-       {\r
-/*             wchar_t out[1024];\r
-               FILE *fp = fopen(setExtension(fname,"cpp").toAscii(),"wt");\r
-               mglGraphPS *ps = new mglGraphPS(graph->GetWidth(), graph->GetHeight());\r
-               int i, r, n = textMGL->toPlainText().count('\n')+1;\r
-               wchar_t *str = new wchar_t[textMGL->toPlainText().length()+2];\r
-               QString cur;\r
-               fwprintf(fp,L"int draw_func(mglGraph *gr, void *)\n{\n");\r
-               fwprintf(fp,L"\tstatic bool once = false;\n");\r
-               for(i=0;i<n;i++)\r
-               {\r
-                       cur = textMGL->toPlainText().section('\n',i,i);\r
-                       r = cur.toWCharArray(str);      str[r] = 0;\r
-                       out[0] = 0;             r = 0;\r
-                       setlocale(LC_ALL, "C");\r
-                       parser.Export(out,ps,str);\r
-                       setlocale(LC_ALL, "");\r
-                       fwprintf(fp,L"\t//%ls\n",str);\r
-                       if(*out)\r
-                       {\r
-                               if(*(parser.op1))       fwprintf(fp,L"%ls\n",parser.op1);\r
-                               fwprintf(fp,L"\t%ls\n",out);\r
-                               if(*(parser.op2))       fwprintf(fp,L"%ls\n",parser.op2);\r
-                       }\r
-               }\r
-               fwprintf(fp,L"\treturn 0;\n}\n");\r
-               fclose(fp);\r
-               delete []str;\r
-                               delete ps;*/\r
-       }\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::reload()      {       parser.RestoreOnce();   execute();      }\r
-//-----------------------------------------------------------------------------\r
-//void QMGLCanvas::stop()              {       parser.Stop = true;     }\r
-void QMGLCanvas::stop()                {       thr->terminate();       }\r
-//-----------------------------------------------------------------------------\r
-void convertFromGraph(QPixmap &pic, mglGraph *gr, uchar **buf)\r
-{\r
-       register long w=gr->GetWidth(), h=gr->GetHeight();\r
-       if(*buf)        delete [](*buf);\r
-       *buf = new uchar[4*w*h];\r
-       gr->GetBGRN(*buf,4*w*h);\r
-       QImage img(*buf, w, h, QImage::Format_RGB32);\r
-       pic = QPixmap::fromImage(img);\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::copy()\r
-{      QApplication::clipboard()->setPixmap(pic, QClipboard::Clipboard);       }\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::copyClickCoor()\r
-{      QApplication::clipboard()->setText(clickPos);   }\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::setMGLFont(QString path)\r
-{\r
-       if(path.isEmpty())      graph->RestoreFont();\r
-       else\r
-       {\r
-               QFileInfo fi(path);\r
-               graph->LoadFont(fi.baseName().toAscii(), fi.path().toAscii());\r
-       }\r
-       execute();\r
-}\r
-//-----------------------------------------------------------------------------\r
-void QMGLCanvas::setSize(int w, int h)\r
-{      if(w<=0 || h<=0)        return;\r
-       graph->SetSize(w,h);    resize(w, h);   execute();      }\r
-//-----------------------------------------------------------------------------\r
diff --git a/udav/qmglcanvas.h b/udav/qmglcanvas.h
deleted file mode 100644 (file)
index b6c7597..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Alexey Balakin                                  *
- *   mathgl.abalakin@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 2 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, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-#ifndef QMGLCANVAS_H
-#define QMGLCANVAS_H
-//-----------------------------------------------------------------------------
-#include <qwidget.h>
-#include <QPixmap>
-#include <QThread>
-#include <mgl/mgl.h>
-class QTextEdit;
-class QMenu;
-class QMGLCanvas;
-/// Class for making picture in separate thread
-class MGLThread : public QThread
-{
-friend class QMGLCanvas;
-Q_OBJECT
-protected:
-       QMGLCanvas *cnv;
-       mglGraph *gr;
-       QString warn;   ///< gr->Message after execution
-       QString text;   ///< text for parsing
-       int line;               ///< line to highlite
-//     QString mes;
-       void run();
-};
-//-----------------------------------------------------------------------------
-/// Class for displaying the result of MGL script parsing
-class QMGLCanvas : public QWidget
-{
-friend class MGLThread;
-Q_OBJECT
-public:
-       bool autoResize;                ///< Allow auto resizing (default is false)
-       QString appName;                ///< Application name for message boxes
-       QTextEdit *textMGL;             ///< Editor with MGL script body
-       QTextEdit *warnMGL;             ///< Buffer for messages and warnings
-       QString scriptName;             ///< Default script name which used for exporting
-       mglGraph *graph;                ///< Built-in mglGraph-er instance (used by default)
-
-       QMGLCanvas(QWidget *parent = 0, Qt::WindowFlags f = 0);
-       ~QMGLCanvas();
-       double getRatio()       {       return double(graph->GetWidth())/graph->GetHeight();    };
-       void setPopup(QMenu *p) {       popup = p;      };
-       void setSize(int w, int h);
-       /// Execute script from string
-       QString run(const QString &text, bool showm=true, mglGraph *gr=0, int line=-1);
-       const QPixmap &getPic() {       return pic;     };      ///< Pixmap for drawing
-signals:
-       void refreshData();
-public slots:
-       void execute(mglGraph *gr=0, int line=-1);      ///< Execute script (and update picture)
-       void copy();                    ///< copy graphics to clipboard
-       void copyClickCoor();   ///< copy click coordinates to clipboard
-       void stop();                    ///< Stop execution
-       void setPer(int p);             ///< Set perspective value
-       void setPhi(int p);             ///< Set Phi-angle value
-       void setTet(int t);             ///< Set Theta-angle value
-       void setGrid(bool a);   ///< Switch on/off grid of absolute coor
-       void setAlpha(bool a);  ///< Switch on/off transparency
-       void setLight(bool l);  ///< Switch on/off lightning
-       void setRotate(bool r); ///< Switch on/off mouse rotation
-       void imgSize(int w, int h);     ///< Set image size
-       void restore();                 ///< Restore zoom and rotation to default values
-       void reload();                  ///< Reload data and execute script
-       void exportPNG(QString fname="");       ///< export to PNG file
-       void exportPNGs(QString fname="");      ///< export to PNG file (no transparency)
-       void exportJPG(QString fname="");       ///< export to JPEG file
-       void exportGIF(QString fname="");       ///< export to GIF file
-       void exportBPS(QString fname="");       ///< export to bitmap EPS file
-       void exportEPS(QString fname="");       ///< export to vector EPS file
-       void exportSVG(QString fname="");       ///< export to SVG file
-       void exportCPP(QString fname="");       ///< export to CPP file
-       void exportIDTF(QString fname="");      ///< export to IDTF file
-       void setMGLFont(QString path);          ///< restore/load font for graphics
-       void startGIF(int animDelay=500, QString fname="");
-       void closeGIF();
-signals:
-       void phiChanged(int);
-       void tetChanged(int);
-       void perChanged(int);
-       void gridChanged(bool);
-       void alphaChanged(bool);
-       void lightChanged(bool);
-       void rotateChanged(bool);
-       void posChanged(QString message);       ///< user click to show mouse position
-       void objChanged(int objId);                     ///< User double-click to select object/line
-protected:
-       void paintEvent(QPaintEvent *);
-       void resizeEvent(QResizeEvent *);
-       void mousePressEvent(QMouseEvent *);
-       void mouseReleaseEvent(QMouseEvent *);
-       void mouseMoveEvent(QMouseEvent *);
-       void mouseDoubleClickEvent(QMouseEvent *);
-
-       MGLThread *thr;         ///< Thread for making picture
-       QPixmap pic;            ///< Pixmap for drawing (changed by update)
-       double tet, phi;        ///< Rotation angles
-       double per;                     ///< Value of perspective ( must be in [0,1) )
-       bool grid;                      ///< Grid state
-       bool alpha;                     ///< Transparency state
-       bool light;                     ///< Lightning state
-       bool rotate;            ///< Mouse rotation state
-       bool showMessage;       ///< Flag for showing messages (enabled by each execute())
-       QMenu *popup;           ///< Pointer to pop-up menu
-       QString clickPos;       ///< Position of last mouse click
-private:
-       int x0, y0, xe, ye;             ///< Temporary variables for mouse
-       uchar *grBuf;
-       QString defText;                ///< Default text for execution
-};
-//-----------------------------------------------------------------------------
-/// Convert bitmap from mglGraph to QPixmap
-void convertFromGraph(QPixmap &pic, mglGraph *gr, uchar **buf);
-//-----------------------------------------------------------------------------
-#endif
-//-----------------------------------------------------------------------------
index c090088fa87b7a68b2a7356d5d6d8858caf4938b..af595d4e754a1c63a0c4d2027eabf4b9a529c780 100644 (file)
@@ -361,3 +361,13 @@ void StyleDialog::updatePic()
        pic->setPixmap(p);\r
 }\r
 //-----------------------------------------------------------------------------\r
+void convertFromGraph(QPixmap &pic, mglGraph *gr, uchar **buf)\r
+{\r
+       register long w=gr->GetWidth(), h=gr->GetHeight();\r
+       if(*buf)        delete [](*buf);\r
+       *buf = new uchar[4*w*h];\r
+       gr->GetBGRN(*buf,4*w*h);\r
+       QImage img(*buf, w, h, QImage::Format_RGB32);\r
+       pic = QPixmap::fromImage(img);\r
+}\r
+//-----------------------------------------------------------------------------\r
index e12c8bd1e45580454b49f8de3e1ade4d576eb1a5..239fb26e2f3f5520a81a40db8559c6ced9effb0a 100644 (file)
@@ -164,6 +164,7 @@ MainWindow::MainWindow(QWidget *wp) : QMainWindow(wp)
        addDockWidget(Qt::BottomDockWidgetArea, messWnd);
        messWnd->resize(size().width(), 0);     new MessSyntax(mess);
        connect(mess,SIGNAL(cursorPositionChanged()),this,SLOT(messClicked()));
+       connect(mess,SIGNAL(selectionChanged()),this,SLOT(messClicked()));
 
        calcWnd = new QDockWidget(tr("Calculator"),this);
 
@@ -423,13 +424,12 @@ void MainWindow::messClicked()
        for(;p>=0;p--)
        {
                q = m.section('\n',p,p);
-               if(q.contains("In line "))
+               if(q.contains("in line "))
                {
-                       QString s = q.mid(8).section(' ',0,0);
-                       int n = s.toInt();      if(n<0) return;
+                       QString s = q.section(' ',-1);
+                       int n = s.toInt()-1;    if(n<0) return;
                        edit->moveCursor(QTextCursor::Start);
                        for(int i=0;i<n;i++)    edit->moveCursor(QTextCursor::NextBlock);
-                       edit->setFocus();
                }
        }
        edit->setFocus();
@@ -437,8 +437,10 @@ void MainWindow::messClicked()
 //-----------------------------------------------------------------------------
 void MainWindow::warnChanged()
 {
-       if(mess->toPlainText().isEmpty())       return;
-       messWnd->show();        ainfo->setChecked(true);
+       if(mess->toPlainText().isEmpty())
+       {       messWnd->hide();        ainfo->setChecked(false);       }
+       else
+       {       messWnd->show();        ainfo->setChecked(true);        }
 }
 //-----------------------------------------------------------------------------
 void MainWindow::about()
index 69b990fb6606e43329e65e102ee8b8ff71b0557b..96b063f059b603902a4c33c10defe7ebd300ec11 100644 (file)
@@ -83,7 +83,8 @@ int main(int narg, char **arg)
                {\r
                        gr.NewFrame();\r
                        p.AddParam(0,var[i].c_str());\r
-                       p.Execute(&gr,str.c_str(),mgl_error_print);\r
+                       p.Execute(&gr,str.c_str());\r
+                       printf("%s\n",gr.Message());\r
                        gr.EndFrame();\r
                        sprintf(buf,"%s-%ld",fname,i);\r
                        if(!gif)        gr.WriteFrame(buf);\r
@@ -92,7 +93,8 @@ int main(int narg, char **arg)
        }\r
        else\r
        {\r
-               p.Execute(&gr,str.c_str(),mgl_error_print);\r
+               p.Execute(&gr,str.c_str());\r
+               printf("%s\n",gr.Message());\r
                gr.WriteFrame(fname);\r
        }\r
        printf("Write output to %s\n",fname);\r
index b2a37a0cffe682217aaf64d41359ff25a72c5d42..f4c73cb9411bd4667bc1217c29fd4428664c81eb 100644 (file)
@@ -31,7 +31,8 @@ void mgl_ask_qt(const wchar_t *quest, wchar_t *res);
 //-----------------------------------------------------------------------------
 int show(mglGraph *gr)
 {
-       p.Execute(gr,str.c_str(),mgl_error_print);
+       p.Execute(gr,str.c_str());
+       printf("%s\n",gr->Message());
        return 0;
 }
 //-----------------------------------------------------------------------------
index c26499b3a51217d137a0482fdce20c2619534ae2..462a6dbda2b77bd82f7418bc73347d1dd22804cc 100644 (file)
@@ -288,11 +288,11 @@ void mgl_wire_cb(Fl_Widget*, void* v)
 //-------------------------------------------------------------------------
 void mgl_alpha_cb(Fl_Widget*, void* v) // alpha?xpm_a2:xpm_a1
 {      if(v)   ((Fl_MGLView*)v)->toggle_alpha();       }
-void mglCanvasFL::ToggleAlpha()        {       mgl->toggle_alpha();    }
+void mglCanvasFL::ToggleAlpha()        {       Fl::lock();     mgl->toggle_alpha();    Fl::unlock();   }
 //-----------------------------------------------------------------------------
 void mgl_light_cb(Fl_Widget*, void* v) // light?xpm_l2:xpm_l1
 {      if(v)   ((Fl_MGLView*)v)->toggle_light();       }
-void mglCanvasFL::ToggleLight()        {       mgl->toggle_light();    }
+void mglCanvasFL::ToggleLight()        {       Fl::lock();     mgl->toggle_light();    Fl::unlock();   }
 //-----------------------------------------------------------------------------
 void mgl_norm_cb(Fl_Widget*, void* v)
 {
@@ -301,21 +301,21 @@ void mgl_norm_cb(Fl_Widget*, void* v)
        e->FMGL->tet_val->value(0);     e->FMGL->phi_val->value(0);
        e->update();
 }
-void mglCanvasFL::ToggleNo()   {       mgl_norm_cb(0,mgl);     }
+void mglCanvasFL::ToggleNo()   {       Fl::lock();     mgl_norm_cb(0,mgl);     Fl::unlock();   }
 //-----------------------------------------------------------------------------
 void mgl_zoom_cb(Fl_Widget*, void* v)
 {
        Fl_MGLView *e = (Fl_MGLView*)v; if(!e)  return;
        e->setoff_rotate();     e->toggle_zoom();
 }
-void mglCanvasFL::ToggleZoom() {       mgl_zoom_cb(0,mgl);     }
+void mglCanvasFL::ToggleZoom() {       Fl::lock();     mgl_zoom_cb(0,mgl);     Fl::unlock();   }
 //-----------------------------------------------------------------------------
 void mgl_rotate_cb(Fl_Widget*, void* v)
 {
        Fl_MGLView *e = (Fl_MGLView*)v; if(!e)  return;
        e->setoff_zoom();       e->toggle_rotate();
 }
-void mglCanvasFL::ToggleRotate()       {       mgl_rotate_cb(0,mgl);   }
+void mglCanvasFL::ToggleRotate()       {       Fl::lock();     mgl_rotate_cb(0,mgl);   Fl::unlock();   }
 //-----------------------------------------------------------------------------
 void Fl_MGLView::update()
 {
@@ -325,7 +325,7 @@ void Fl_MGLView::update()
 }
 void mgl_draw_cb(Fl_Widget*, void* v)
 {      if(v)   ((Fl_MGLView*)v)->update();     }
-void mglCanvasFL::Update()             {       mgl->update();  }
+void mglCanvasFL::Update()             {       Fl::lock();     mgl->update();  Fl::unlock();   }
 //-----------------------------------------------------------------------------
 void mgl_export_png_cb(Fl_Widget*, void* v)
 {
@@ -431,7 +431,7 @@ void mgl_adjust_cb(Fl_Widget*, void*v)
        mgl_set_size(e->FMGL->get_graph(), e->scroll->w(), e->scroll->h());
        e->FMGL->size(e->scroll->w(), e->scroll->h());  e->update();
 }
-void mglCanvasFL::Adjust()     {       mgl_adjust_cb(0,mgl);   }
+void mglCanvasFL::Adjust()     {       Fl::lock();     mgl_adjust_cb(0,mgl);   Fl::unlock();   }
 //-----------------------------------------------------------------------------
 void mgl_oncemore_cb(Fl_Widget*, void*v)
 {      Fl_MGLView *e = (Fl_MGLView*)v; if(e && e->reload)      e->reload(e->par);      }
@@ -459,7 +459,7 @@ void mgl_sshow_cb(Fl_Widget *, void *v)
        e->toggle_sshow();
        if(e->is_sshow())       Fl::add_timeout(e->delay(e->par), mgl_time_cb, v);
 }
-void mglCanvasFL::Animation()  {       mgl_sshow_cb(0,mgl);    }
+void mglCanvasFL::Animation()  {       Fl::lock();     mgl_sshow_cb(0,mgl);    Fl::unlock();   }
 void mgl_no_cb(Fl_Widget *, void *)    {}
 //-----------------------------------------------------------------------------
 Fl_Menu_Item pop_graph[15] = {
@@ -615,6 +615,7 @@ float mgl_fl_delay(void *v) {       return ((mglCanvasW*)v)->GetDelay();    }       ///< Callba
 //-----------------------------------------------------------------------------
 void mglCanvasFL::Window(int argc, char **argv, int (*draw)(mglBase *gr, void *p), const char *title, void *par, void (*reload)(void *p), bool maximize)
 {
+       Fl::lock();
        SetDrawFunc(draw, par, reload);
        if(Wnd) {       Wnd->label(title);      Wnd->show();    return; }
 
index 06265215f42699c9e64f1480742fac5649f05357..9fc5d02237ad3433f173e66a25fe0118f41fc562 100644 (file)
@@ -206,11 +206,7 @@ void QMathGL::update()
                emit refreshData();
 
                QString buf = gr->Mess.c_str();
-               if(!buf.isEmpty())
-               {
-                       emit showWarn(buf);
-//                     QMessageBox::warning(this, appName, buf);
-               }
+               emit showWarn(buf);
                mousePos="";
        }
        refresh();