New upstream version 2.3.5.1
authorDimitrios Eftaxiopoulos <eftaxi12@otenet.gr>
Tue, 24 Jan 2017 16:20:36 +0000 (18:20 +0200)
committerDimitrios Eftaxiopoulos <eftaxi12@otenet.gr>
Tue, 24 Jan 2017 16:20:36 +0000 (18:20 +0200)
169 files changed:
CMakeLists.txt
ChangeLog.txt
addons/getopt/CMakeLists.txt [new file with mode: 0644]
addons/getopt/getopt.c [new file with mode: 0644]
addons/getopt/getopt.h [new file with mode: 0644]
cmake-qt4.txt
cmake-qt5.txt
examples/CMakeLists.txt
examples/FractInt.ifs [new file with mode: 0644]
examples/fltk_example.cpp
examples/full_test.cpp
examples/glut_example.cpp
examples/qgl_example.cpp
examples/qt_example.cpp
examples/samples.cpp
examples/wnd_samples.cpp
examples/wx_example.cpp
fonts/CMakeLists.txt
fonts/make_bin.cpp
include/mgl2/Fl_MathGL.h
include/mgl2/abstract.h
include/mgl2/addon.h
include/mgl2/base.h
include/mgl2/base_cf.h
include/mgl2/canvas.h
include/mgl2/canvas_cf.h
include/mgl2/canvas_wnd.h
include/mgl2/cont.h
include/mgl2/data.h
include/mgl2/data_cf.h
include/mgl2/datac.h
include/mgl2/datac_cf.h
include/mgl2/define.h
include/mgl2/eval.h
include/mgl2/evalc.h
include/mgl2/fit.h
include/mgl2/fltk.h
include/mgl2/font.h
include/mgl2/glut.h
include/mgl2/mgl.h
include/mgl2/mgl_cf.h
include/mgl2/mpi.h
include/mgl2/opengl.h
include/mgl2/other.h
include/mgl2/parser.h
include/mgl2/pde.h
include/mgl2/plot.h
include/mgl2/prim.h
include/mgl2/qmathgl.h
include/mgl2/qt.h
include/mgl2/surf.h
include/mgl2/thread.h
include/mgl2/type.h
include/mgl2/vect.h
include/mgl2/volume.h
include/mgl2/window.h
include/mgl2/wnd.h
include/mgl2/wx.h
json/Backend.cpp
json/Backend.hpp
json/CMakeLists.txt
lang/mgl.i
make_release [deleted file]
mgltex/Recompilation_decision.eps
mgltex/Recompilation_decision.pdf
mgltex/Recompilation_decision.svg
mgltex/mgltex.dtx
mgltex/mgltex.ins
mgltex/mgltex.pdf
mgltex/sample.tex
src/CMakeLists.txt
src/addon.cpp
src/axis.cpp
src/base.cpp
src/base_cf.cpp
src/canvas.cpp
src/canvas_cf.cpp
src/complex.cpp
src/complex_ex.cpp
src/complex_io.cpp
src/cont.cpp
src/crust.cpp
src/data.cpp
src/data_ex.cpp
src/data_gr.cpp
src/data_io.cpp
src/data_png.cpp
src/eval.cpp
src/evalc.cpp
src/evalp.cpp
src/exec.cpp
src/export.cpp
src/export_2d.cpp
src/export_3d.cpp
src/fft.cpp
src/fit.cpp
src/font.cpp
src/fractal.cpp [new file with mode: 0644]
src/obj.cpp
src/other.cpp
src/parser.cpp
src/pde.cpp
src/pixel.cpp
src/plot.cpp
src/prc.cpp
src/prc/PRC.h
src/prim.cpp
src/s_hull/s_hull_pro.h
src/surf.cpp
src/tex_table.cc
src/vect.cpp
src/volume.cpp
src/window.cpp
texinfo/concept_en.texi
texinfo/concept_ru.texi
texinfo/core_en.texi
texinfo/core_ru.texi
texinfo/data_en.texi
texinfo/data_ru.texi
texinfo/ex_mgl_en.texi
texinfo/ex_mgl_ru.texi
texinfo/example_en.texi
texinfo/example_ru.texi
texinfo/formats_en.texi
texinfo/formats_ru.texi
texinfo/parse_en.texi
texinfo/parse_ru.texi
texinfo/symbols_en.texi
texinfo/symbols_ru.texi
texinfo/version.texi.in
texinfo/version_hist.txt
texinfo/web_en.texi
texinfo/web_ru.texi
texinfo/widget_en.texi
texinfo/widget_ru.texi
todo.txt
udav/CMakeLists.txt
udav/anim_dlg.h
udav/dat_pnl.cpp
udav/data_dlg.cpp
udav/files_dlg.h
udav/find_dlg.h
udav/help_pnl.h
udav/hint_dlg.cpp
udav/hint_dlg.h
udav/info_dlg.cpp
udav/mem_pnl.cpp
udav/newcmd_dlg.cpp
udav/open_dlg.cpp
udav/opt_dlg.h
udav/setup_dlg.h
udav/style_dlg.cpp
udav/subplot_dlg.cpp
udav/text_pnl.cpp
udav/textedit.cpp
udav/textedit.h
udav/udav_wnd.cpp
utils/CMakeLists.txt
utils/make_pas.cpp
utils/mglcgi.cpp
utils/mglconv.cpp
utils/mglview.cpp
widgets/CMakeLists.txt
widgets/fltk.cpp
widgets/glut.cpp
widgets/qt.cpp
widgets/qt4/CMakeLists.txt
widgets/qt5/CMakeLists.txt
widgets/wx.cpp

index 744680e5fd4af42151228cc6d9d0b1c8b72b12a5..df67e618be1e9f3d7cd2cc9b08b26c304992a311 100644 (file)
@@ -1,10 +1,12 @@
-cmake_minimum_required(VERSION 2.8.9)
+cmake_minimum_required(VERSION 2.8.12)
 if(POLICY CMP0043)
     cmake_policy(SET CMP0043 OLD)
 endif()
 
 project( MathGL )
 
+set(MGL_DEP_LIBS)
+
 if(NOT CMAKE_BUILD_TYPE)
        set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are:
                None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
@@ -12,8 +14,8 @@ endif(NOT CMAKE_BUILD_TYPE)
 
 set(CMAKE_VERBOSE_MAKEFILE ON)
 set(MathGL_VERSION_MAJOR 2)
-set(MathGL_VERSION_MINOR 3.4)
-set(MathGL_SOVERSION 7.4.1)
+set(MathGL_VERSION_MINOR 3.5)
+set(MathGL_SOVERSION 7.4.3)
 
 function(mgl_add_lib mgl_tmp_lib)
        if(${mgl_tmp_lib} MATCHES mgl)
@@ -28,16 +30,29 @@ function(mgl_add_lib mgl_tmp_lib)
        add_library(${mgllib} SHARED ${mgl_src_lst})
        add_library(${mgllib}-static STATIC ${mgl_src_lst})
        set_target_properties(${mgllib} PROPERTIES SOVERSION ${MathGL_SOVERSION})
-       set_target_properties(${mgllib} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
        set_target_properties(${mgllib} PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS")
-       set_target_properties(${mgllib}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+       set_target_properties(${mgllib} PROPERTIES C_VISIBILITY_PRESET hidden)
+       set_target_properties(${mgllib} PROPERTIES CXX_VISIBILITY_PRESET hidden)
+       set_target_properties(${mgllib} PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
        target_compile_definitions(${mgllib}-static PUBLIC MGL_STATIC_DEFINE)
-
+       if(MSVC)
+          set(mgl_lib_static "-static")
+           if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+               set(mgl_lib_end "d")
+          else(CMAKE_BUILD_TYPE STREQUAL "Debug")
+               set(mgl_lib_end)
+           endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
+       elseif(MSVC)
+          set(mgl_lib_static)
+           set_target_properties(${mgllib} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+          set_target_properties(${mgllib}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+       endif(MSVC)
        if(enable-mgl2)
-               set_target_properties(${mgllib} PROPERTIES OUTPUT_NAME "${mgllib2}")
-               set_target_properties(${mgllib}-static PROPERTIES OUTPUT_NAME "${mgllib2}")
+               set_target_properties(${mgllib} PROPERTIES OUTPUT_NAME "${mgllib2}${mgl_lib_end}")
+               set_target_properties(${mgllib}-static PROPERTIES OUTPUT_NAME "${mgllib2}${mgl_lib_static}${mgl_lib_end}")
        else(enable-mgl2)
-               set_target_properties(${mgllib}-static PROPERTIES OUTPUT_NAME "${mgllib}")
+               set_target_properties(${mgllib} PROPERTIES OUTPUT_NAME "${mgllib}${mgl_lib_end}")
+               set_target_properties(${mgllib}-static PROPERTIES OUTPUT_NAME "${mgllib}${mgl_lib_static}${mgl_lib_end}")
        endif(enable-mgl2)
 
        install(
@@ -136,17 +151,30 @@ CMAKE_DEPENDENT_OPTION(enable-glut "Enable glut support" OFF "NOT enable-all-wid
 CMAKE_DEPENDENT_OPTION(enable-fltk "Enable fltk widget" OFF "NOT enable-all-widgets" ON)
 CMAKE_DEPENDENT_OPTION(enable-wx "Enable wxWidget widget" OFF "NOT enable-all-widgets" ON)
 CMAKE_DEPENDENT_OPTION(enable-qt4 "Enable Qt4 widget" OFF "NOT enable-all-widgets" ON)
+CMAKE_DEPENDENT_OPTION(enable-qt4asqt "Set Qt4 as default libmgl-qt" OFF "enable-qt4" OFF)
 CMAKE_DEPENDENT_OPTION(enable-qt5 "Enable Qt5 widget" OFF "NOT enable-all-widgets" ON)
-CMAKE_DEPENDENT_OPTION(enable-qt5asqt "Set Qt5 as default libmgl-qt" ON "enable-qt5" OFF)
+CMAKE_DEPENDENT_OPTION(enable-qt5asqt "Set Qt5 as default libmgl-qt" OFF "enable-qt5" OFF)
 
-if(UNIX AND enable-rvalue)
-       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
-endif(UNIX AND enable-rvalue)
-
-# MSVC does not require any special flags
+# msvc fwprintf print char* for the specifier of "%s" format
+if(MSVC AND MSVC_VERSION GREATER 1899)
+       SET(CMAKE_CXX_FLAGS "/EHsc -D_CRT_STDIO_ISO_WIDE_SPECIFIERS ${CMAKE_CXX_FLAGS}")
+       SET(CMAKE_C_FLAGS "-D_CRT_STDIO_ISO_WIDE_SPECIFIERS ${CMAKE_C_FLAGS}")
+endif(MSVC AND MSVC_VERSION GREATER 1899)
 
 if(enable-qt4 OR enable-qt5)
-set(QT_ENABLED ON)
+       set(QT_ENABLED ON)
+       if(enable-qt4asqt AND enable-qt5asqt)
+               message(SEND_ERROR "You cannot make Qt4 and Qt5 as qt at the same time.")
+       endif(enable-qt4asqt AND enable-qt5asqt)
+       if(enable-qt4 AND NOT enable-qt5)
+               set(enable-qt4asqt TRUE)
+       endif(enable-qt4 AND NOT enable-qt5)
+       if(enable-qt5 AND NOT enable-qt4)
+               set(enable-qt5asqt TRUE)
+       endif(enable-qt5 AND NOT enable-qt4)
+#      if(NOT enable-opengl)
+#              message(SEND_ERROR "You cannot build MathGL with Qt4 or Qt5 without OpenGL enabled.")
+#      endif(NOT enable-opengl)
 endif(enable-qt4 OR enable-qt5)
 
 CMAKE_DEPENDENT_OPTION(enable-json-sample "Enable JSON sample" ON "QT_ENABLED" OFF)
@@ -183,16 +211,18 @@ endif(WORDS_BIGENDIAN)
 CHECK_FUNCTION_EXISTS(sin MGL_SIN)
 CHECK_FUNCTION_EXISTS(memrchr HAVE_MEMRCHR)
 if(NOT MGL_SIN)
-        cmake_push_check_state()
-        set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
-        CHECK_FUNCTION_EXISTS(sin MGL_SIN_M)
-        cmake_pop_check_state()
-        if(MGL_SIN_M)
-                set(M_LIB m)
-        elseif(MGL_SIN_M)
-                message(SEND_ERROR "Math library not found")
-        endif(MGL_SIN_M)
+       cmake_push_check_state()
+       set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
+       CHECK_FUNCTION_EXISTS(sin MGL_SIN_M)
+       cmake_pop_check_state()
+       if(MGL_SIN_M)
+               set(M_LIB m)
+       elseif(MGL_SIN_M)
+               message(SEND_ERROR "Math library not found")
+       endif(MGL_SIN_M)
 endif(NOT MGL_SIN)
+set(MGL_DEP_LIBS ${M_LIB} ${MGL_DEP_LIBS})
+
 if(HAVE_MEMRCHR)
        ADD_DEFINITIONS(-DHAVE_MEMRCHR)
 endif(HAVE_MEMRCHR)
@@ -201,7 +231,7 @@ include(CheckTypeSize)
 check_type_size("long" SIZEOF_LONG)
 
 include(CheckCXXSourceCompiles)
-unset(MGL_HAVE_C99_COMPLEX)
+#unset(MGL_HAVE_C99_COMPLEX)
 CHECK_CXX_SOURCE_COMPILES(
 "#include <complex>
 #include <complex.h>
@@ -214,7 +244,7 @@ if(NOT MGL_HAVE_C99_COMPLEX)
        set(MGL_HAVE_C99_COMPLEX 0)
 endif(NOT MGL_HAVE_C99_COMPLEX)
 
-unset(MGL_HAVE_NAN_INF)
+#unset(MGL_HAVE_NAN_INF)
 CHECK_CXX_SOURCE_COMPILES(
 "#include <math.h>
 int main(){double a=NAN, b=INFINITY;return 0;}" MGL_HAVE_NAN_INF)
@@ -222,7 +252,7 @@ if(NOT MGL_HAVE_NAN_INF)
        set(MGL_HAVE_NAN_INF 0)
 endif(NOT MGL_HAVE_NAN_INF)
 
-unset(MGL_HAVE_ATTRIBUTE)
+#unset(MGL_HAVE_ATTRIBUTE)
 CHECK_CXX_SOURCE_COMPILES(
 "int __attribute__((pure)) test1() {return 0;}
 int __attribute__((const)) test2(int x) {return x*x;}
@@ -231,7 +261,7 @@ if(NOT MGL_HAVE_ATTRIBUTE)
        set(MGL_HAVE_ATTRIBUTE 0)
 endif(NOT MGL_HAVE_ATTRIBUTE)
 
-unset(MGL_HAVE_TYPEOF)
+unset(MGL_HAVE_TYPEOF CACHE)
 CHECK_CXX_SOURCE_COMPILES(
 "#define mgl_isnum(a)  ({typeof (a) _a = (a); _a==_a;})
 int main(){bool a=mgl_isnum(1);return 0;}" MGL_HAVE_TYPEOF)
@@ -239,13 +269,30 @@ if(NOT MGL_HAVE_TYPEOF)
        set(MGL_HAVE_TYPEOF 0)
 endif(NOT MGL_HAVE_TYPEOF)
 
-unset(MGL_HAVE_RVAL)
-CHECK_CXX_SOURCE_COMPILES(
-"struct test { test() {} test(test&& a){} };
-int main() { test t;   return 0; }" MGL_HAVE_RVAL)
-if(NOT MGL_HAVE_RVAL)
+if(NOT MSVC AND enable-rvalue)
+       SET(CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}")
+       unset(MGL_HAVE_RVAL CACHE)
+       CHECK_CXX_SOURCE_COMPILES(
+       "struct test { test() {} test(test&& a){} };
+       int main() { test t;    return 0; }" MGL_HAVE_RVAL)
+       if(NOT MGL_HAVE_RVAL)
+               message(SEND_ERROR "Couldn't enable rvalue.")
+#              set(MGL_HAVE_RVAL 0)
+       endif(NOT MGL_HAVE_RVAL)
+else(NOT MSVC AND enable-rvalue)
        set(MGL_HAVE_RVAL 0)
-endif(NOT MGL_HAVE_RVAL)
+endif(NOT MSVC AND enable-rvalue)
+
+
+
+CHECK_CXX_SOURCE_COMPILES(
+"#include <getopt.h>
+int main(int argc, char *args[]) {
+int ch = getopt(argc, args, \"1:2:3:4:5:6:7:8:9:hno:L:C:A:s:S:q:\"); return 0; }" MGL_HAVE_GETOPT)
+if(NOT MGL_HAVE_GETOPT)
+       include_directories(${MathGL_SOURCE_DIR}/addons/getopt)
+       set(getopt_lib-static getopt-static)
+endif(NOT MGL_HAVE_GETOPT)
 
 if(enable-double)
        set(MGL_USE_DOUBLE 1)
@@ -281,24 +328,22 @@ else(enable-mpi)
        set(MGL_HAVE_MPI 0)
 endif(enable-mpi)
 
-if(enable-pthread)
-       set(MGL_HAVE_PTHREAD 1)
-       include(FindThreads)
-       if(NOT CMAKE_USE_PTHREADS_INIT)
-               message(SEND_ERROR "Couldn't find POSIX threads library.")
-       endif(NOT CMAKE_USE_PTHREADS_INIT)
-else(enable-pthread)
-       set(MGL_HAVE_PTHREAD 0)
-endif(enable-pthread)
 
 if(enable-pthr-widget OR enable-pthread)
+       if(enable-pthread)
+               set(MGL_HAVE_PTHREAD 1)
+       else(enable-pthread)
+               set(MGL_HAVE_PTHREAD 0)
+       endif(enable-pthread)
        set(MGL_HAVE_PTHR_WIDGET 1)
        include(FindThreads)
        if(NOT CMAKE_USE_PTHREADS_INIT)
                message(SEND_ERROR "Couldn't find POSIX threads library.")
        endif(NOT CMAKE_USE_PTHREADS_INIT)
+       set(MGL_DEP_LIBS ${CMAKE_THREAD_LIBS_INIT} ${MGL_DEP_LIBS})
 else(enable-pthr-widget OR enable-pthread)
        set(MGL_HAVE_PTHR_WIDGET 0)
+       set(MGL_HAVE_PTHREAD 0)
 endif(enable-pthr-widget OR enable-pthread)
 
 if(enable-gsl)
@@ -318,6 +363,8 @@ if(enable-gsl)
                int main(){gsl_multifit_fdfsolver *s=0;gsl_matrix *J = 0;
                gsl_multifit_fdfsolver_jac(s, J);}" MGL_HAVE_GSL2)
        endif(NOT GSL_LIB OR NOT GSL_CBLAS_LIB OR NOT GSL_INCLUDE_DIR)
+       set(MGL_DEP_LIBS ${GSL_LIB} ${GSL_CBLAS_LIB} ${MGL_DEP_LIBS})
+       include_directories(${GSL_INCLUDE_DIR})
 else(enable-gsl)
        set(MGL_HAVE_GSL 0)
 endif(enable-gsl)
@@ -331,6 +378,8 @@ if(enable-all OR enable-ltdl)
                message(SEND_ERROR "${LTDL_INCLUDE_DIR}")
                message(SEND_ERROR "Couldn't find LTDL library.")
        endif(NOT LTDL_LIB OR NOT LTDL_INCLUDE_DIR)
+       set(MGL_DEP_LIBS ${LTDL_LIB} ${MGL_DEP_LIBS})
+       include_directories(${LTDL_INCLUDE_DIR})
 else(enable-all OR enable-ltdl)
        set(MGL_HAVE_LTDL 0)
 endif(enable-all OR enable-ltdl)
@@ -346,6 +395,8 @@ if(enable-hdf4)
                message(SEND_ERROR "${HDF4_INCLUDE_DIR}")
                message(SEND_ERROR "Couldn't find HDF4 libraries.")
        endif(NOT HDF4_LIB OR NOT HDF4MF_LIB OR NOT HDF4_INCLUDE_DIR)
+       set(MGL_DEP_LIBS ${HDF4MF_LIB} ${HDF4_LIB} ${MGL_DEP_LIBS})
+       include_directories(${HDF4_INCLUDE_DIR})
 else(enable-hdf4)
        set(MGL_HAVE_HDF4 0)
 endif(enable-hdf4)
@@ -359,6 +410,8 @@ if(enable-hdf5)
                        message(SEND_ERROR "Couldn't find HDF5 library.")
                endif(NOT HDF5_FOUND)
        endif(NOT HDF5_FOUND)
+       set(MGL_DEP_LIBS ${HDF5_LIBRARIES} ${HDF5_C_SHARED_LIBRARY} ${MGL_DEP_LIBS})
+       include_directories(${HDF5_INCLUDE_DIR})
 else(enable-hdf5)
        set(MGL_HAVE_HDF5 0)
 endif(enable-hdf5)
@@ -369,6 +422,8 @@ if(enable-jpeg)
        if(NOT JPEG_FOUND)
                message(SEND_ERROR "Couldn't find JPEG library.")
        endif(NOT JPEG_FOUND)
+       set(MGL_DEP_LIBS ${JPEG_LIBRARIES} ${MGL_DEP_LIBS})
+       include_directories(${JPEG_INCLUDE_DIR})
 else(enable-jpeg)
        set(MGL_HAVE_JPEG 0)
 endif(enable-jpeg)
@@ -380,6 +435,8 @@ if(enable-zlib)
        if(NOT ZLIB_FOUND)
                message(SEND_ERROR "Couldn't find ZLib library.")
        endif(NOT ZLIB_FOUND)
+       set(MGL_DEP_LIBS ${ZLIB_LIBRARIES} ${MGL_DEP_LIBS})
+       include_directories(${ZLIB_INCLUDE_DIR})
 else(enable-zlib)
        set(MGL_HAVE_ZLIB 0)
 endif(enable-zlib)
@@ -393,6 +450,8 @@ if(enable-png)
        if(NOT PNG_FOUND)
                message(SEND_ERROR "Couldn't find PNG library.")
        endif(NOT PNG_FOUND)
+       set(MGL_DEP_LIBS ${PNG_LIBRARIES} ${MGL_DEP_LIBS})
+       include_directories(${PNG_INCLUDE_DIR})
 else(enable-png)
        set(MGL_HAVE_PNG 0)
 endif(enable-png)
@@ -411,6 +470,8 @@ if(enable-pdf)
        if(NOT HPDF_INCLUDE_DIR)
                message(SEND_ERROR "Couldn't find headers of 3d-enabled version of libhpdf.")
        endif(NOT HPDF_INCLUDE_DIR)
+       include_directories(${HPDF_INCLUDE_DIR})
+       set(MGL_DEP_LIBS ${HPDF_LIB} ${MGL_DEP_LIBS})
 else(enable-pdf)
        set(MGL_HAVE_PDF 0)
 endif(enable-pdf)
@@ -421,6 +482,8 @@ if(enable-gif)
        if(NOT GIF_FOUND)
                message(SEND_ERROR "Couldn't find GIF library.")
        endif(NOT GIF_FOUND)
+       set(MGL_DEP_LIBS ${GIF_LIBRARIES} ${MGL_DEP_LIBS})
+       include_directories(${GIF_INCLUDE_DIR})
 else(enable-gif)
        set(MGL_HAVE_GIF 0)
 endif(enable-gif)
@@ -431,6 +494,8 @@ if(enable-opengl)
        if(NOT OPENGL_FOUND)
                message(SEND_ERROR "Couldn't find OpenGL libraries.")
        endif(NOT OPENGL_FOUND)
+       set(MGL_DEP_LIBS ${OPENGL_LIBRARIES} ${MGL_DEP_LIBS})
+       include_directories(${OPENGL_INCLUDE_DIR} )
 else(enable-opengl)
        set(MGL_HAVE_OPENGL 0)
 endif(enable-opengl)
@@ -557,6 +622,10 @@ if(WIN32)
        add_definitions(-DWIN32)
 endif(WIN32)
 
+if(NOT MGL_HAVE_GETOPT)
+       add_subdirectory( addons/getopt )
+endif(NOT MGL_HAVE_GETOPT)
+
 add_subdirectory( src )
 add_subdirectory( widgets )
 add_subdirectory( include )
@@ -566,17 +635,15 @@ if(NOT enable-lgpl)
        if(enable-python OR enable-lua OR enable-octave)
                add_subdirectory( lang )
        endif(enable-python OR enable-lua OR enable-octave)
-       if(NOT MSVC AND NOT BORLAND)
-               add_subdirectory( utils )
-       endif(NOT MSVC AND NOT BORLAND)
+add_subdirectory( utils )
+add_subdirectory( examples )
        if(NOT WIN32)
                add_subdirectory( fonts )
        endif(NOT WIN32)
-#      add_subdirectory( mgllab )
+#      add_subdirectory( mgllab )
 endif(NOT enable-lgpl)
 
 if(NOT MSVC AND NOT BORLAND)
-       add_subdirectory( examples )
 
        if(MGL_HAVE_DOC_HTML OR MGL_HAVE_DOC_SITE OR MGL_HAVE_DOC_INFO OR MGL_HAVE_DOC_PDF_RU OR MGL_HAVE_DOC_PDF_EN )
                add_subdirectory( texinfo )
index c481c3d1cbd79b19f2dc9dc1307245b1bc77b165..c47c1765d0cc6600c81fdf16a2a9c37861ac2d22 100644 (file)
@@ -1,3 +1,66 @@
+2.3.5.1 Released 2 June 2016
+
+* INCOMPATIBLE: library libmgl-qt is removed. You need to use libmgl-qt4 or libmgl-qt5 explicitly now.
+* Compatibility changes for latest MS VisualStudio.
+* Bugfixes.
+
+2.3.5 Released 16 May 2016
+
+* Greatly update mgltex (by Diego Sejas Viscarra)
+       o \MGL@codes: Bugfix: category code for tabulators is changed too
+       o \MGL@quality: 9 is accepted as quality value now
+       o \MGL@scale: Now accepts any positive value
+       o \MGL@test@switch: New command to verify and validate switching arguments
+       o \mglTeX: Add a small negative space in the logo, between the "mgl" and "TEX"
+       o \mglTeX: Declared now as robust command
+       o \mglcomments: Now accepts arguments 0 (equivalent to off) and 1 (equivalent to on), besides the usual off and on
+       o \mglgraphics: New command options: gray, mglscale, quality, variant
+       o \mglname: Now writes the MGL code line setsize 600 400 to the main script
+       o \mglplot: Added \bgroup and \egroup in order to keep changes private
+       o New command options: gray, mglscale, quality, variant
+       o \mglsettings: Added options gray and variant
+       o Now calls the \mglswitch and \mglcomments commands for the switch and comments options, respectively
+       o \mglswitch: Now accepts arguments 0 (equivalent to off) and 1 (equivalent to on), besides the usual off and on
+       o mglTeX now depends on the ifpdf package
+       o Change definition of \mglcommentname from MGL comment to mglTEX comment
+       o Introduce the concept of global, local and private settings in the documentation
+       o New commands: \mglgray (to activate/deactivate) gray-scale mode locally, and \mglvariant (to set variant of arguments in MGL scripts locally)
+       o New package option 9q for setting quality to 9 (for testing purposes of the author)
+       o New package options 0v, 1v, 2v to select variant of arguments in MGL scripts
+       o New package options gray, color to activate/deactivate gray-scale mode for graphics
+       o Remove the \MGL@setkeys command, since it isn’t needed as first thought
+       o Rename \MGL@document@scripts to \MGL@doc@scripts
+       o Rename \MGL@script@name to \MGL@script
+       o Rename command \MGL@graph@ext to \MGL@imgext
+       o Rename command \mglcommonscriptname to mglsetupscriptname
+       o Rename environment mglcommon to mglsetupscript (mglcommon is still available, but deprecated)
+       o Rename family MGL@keys as MGL@gr@keys for consistency
+       o Reorganize and update documentation
+       o Some minor bugfixes
+       o The MGL code line "setsize 600 400" is now automatically written to the main script in order for the scaling options and commands to work
+       o mgl: New environment options: gray, mglscale, quality, variant
+       o mglcode: New environment options: gray, mglscale, quality, variant
+* Add MGL command 'variant' to select proper variant of arguments (like "var1?var2?var3?...") in MGL commands.
+* Remove limitation of maximal number (was 1000) of arguments for MGL commands. This is actual for 'list' command.
+* Add mglWnd::Widget() for accessing widget which is used for drawing.
+* Add Gray() for producing gray-scaled image.
+* Add MGL command 'setsizescl' for scaling all further 'setsize'.
+* Add Shear() for shearing plot.
+* Add ShearPlot() for placing plots side-by-side with some shearing.
+* Add mglData::Limit() for limit maximal absolute value of data.
+* Add mglTridMat() for tridiagonal matrix algorithm.
+* Add MGL command 'diffract' for single step diffraction calculation.
+* Add 'ifsfile' for reading IFS fractal parameters from *.ifs file.
+* Add style '*' for 2d versions of Pipe() and Flow() to draw threads from points inside axis range.
+* Add "norm()" to the list of known functions
+* Compatibility changes for MS VisualStudio, MacOS, Win64.
+* Bugfix for legend export into EPS and SVG.
+* Bugfix for importing data from std::vector.
+* Improve Surf3*() drawing.
+* Force NAN if divided by 0 in formulas.
+* Option "-S" of mglconv now perform scaling in any cases
+
+
 2.3.4 Released 13 February 2016
 
 * Add mglData::Pulse() for determining pulse parameters.
diff --git a/addons/getopt/CMakeLists.txt b/addons/getopt/CMakeLists.txt
new file mode 100644 (file)
index 0000000..679b761
--- /dev/null
@@ -0,0 +1,2 @@
+add_library(getopt-static STATIC getopt.c getopt.h)
+target_compile_definitions(getopt-static PUBLIC MGL_STATIC_DEFINE)
diff --git a/addons/getopt/getopt.c b/addons/getopt/getopt.c
new file mode 100644 (file)
index 0000000..dd4f2c5
--- /dev/null
@@ -0,0 +1,973 @@
+/* Getopt for Microsoft C\r
+This code is a modification of the Free Software Foundation, Inc.\r
+Getopt library for parsing command line argument the purpose was\r
+to provide a Microsoft Visual C friendly derivative. This code\r
+provides functionality for both Unicode and Multibyte builds.\r
+\r
+Date: 02/03/2011 - Ludvik Jerabek - Initial Release\r
+Version: 1.0\r
+Comment: Supports getopt, getopt_long, and getopt_long_only\r
+and POSIXLY_CORRECT environment flag\r
+License: LGPL\r
+\r
+Revisions:\r
+\r
+02/03/2011 - Ludvik Jerabek - Initial Release\r
+02/20/2011 - Ludvik Jerabek - Fixed compiler warnings at Level 4\r
+07/05/2011 - Ludvik Jerabek - Added no_argument, required_argument, optional_argument defs\r
+08/03/2011 - Ludvik Jerabek - Fixed non-argument runtime bug which caused runtime exception\r
+08/09/2011 - Ludvik Jerabek - Added code to export functions for DLL and LIB\r
+02/15/2012 - Ludvik Jerabek - Fixed _GETOPT_THROW definition missing in implementation file\r
+08/01/2012 - Ludvik Jerabek - Created separate functions for char and wchar_t characters so single dll can do both unicode and ansi\r
+10/15/2012 - Ludvik Jerabek - Modified to match latest GNU features\r
+06/19/2015 - Ludvik Jerabek - Fixed maximum option limitation caused by option_a (255) and option_w (65535) structure val variable\r
+\r
+**DISCLAIMER**\r
+THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,\r
+EITHER EXPRESS OR IMPLIED, INCLUDING, BUT Not LIMITED TO, THE\r
+IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\r
+PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE\r
+EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT\r
+APPLY TO YOU. IN NO EVENT WILL I BE LIABLE TO ANY PARTY FOR ANY\r
+DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES FOR ANY\r
+USE OF THIS MATERIAL INCLUDING, WITHOUT LIMITATION, ANY LOST\r
+PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON\r
+YOUR INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN If WE ARE\r
+EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r
+*/\r
+#define _CRT_SECURE_NO_WARNINGS\r
+#include <stdlib.h>\r
+#include <stdio.h>\r
+#include <malloc.h>\r
+#include "getopt.h"\r
+\r
+#ifdef __cplusplus\r
+       #define _GETOPT_THROW throw()\r
+#else\r
+       #define _GETOPT_THROW\r
+#endif\r
+\r
+int optind = 1;\r
+int opterr = 1;\r
+int optopt = '?';\r
+enum ENUM_ORDERING { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER };\r
+\r
+//\r
+//\r
+//             Ansi structures and functions follow\r
+// \r
+//\r
+\r
+static struct _getopt_data_a\r
+{\r
+       int optind;\r
+       int opterr;\r
+       int optopt;\r
+       char *optarg;\r
+       int __initialized;\r
+       char *__nextchar;\r
+       enum ENUM_ORDERING __ordering;\r
+       int __posixly_correct;\r
+       int __first_nonopt;\r
+       int __last_nonopt;\r
+} getopt_data_a;\r
+char *optarg_a;\r
+\r
+static void exchange_a(char **argv, struct _getopt_data_a *d)\r
+{\r
+       int bottom = d->__first_nonopt;\r
+       int middle = d->__last_nonopt;\r
+       int top = d->optind;\r
+       char *tem;\r
+       while (top > middle && middle > bottom)\r
+       {\r
+               if (top - middle > middle - bottom)\r
+               {\r
+                       int len = middle - bottom;\r
+                       register int i;\r
+                       for (i = 0; i < len; i++)\r
+                       {\r
+                               tem = argv[bottom + i];\r
+                               argv[bottom + i] = argv[top - (middle - bottom) + i];\r
+                               argv[top - (middle - bottom) + i] = tem;\r
+                       }\r
+                       top -= len;\r
+               }\r
+               else\r
+               {\r
+                       int len = top - middle;\r
+                       register int i;\r
+                       for (i = 0; i < len; i++)\r
+                       {\r
+                               tem = argv[bottom + i];\r
+                               argv[bottom + i] = argv[middle + i];\r
+                               argv[middle + i] = tem;\r
+                       }\r
+                       bottom += len;\r
+               }\r
+       }\r
+       d->__first_nonopt += (d->optind - d->__last_nonopt);\r
+       d->__last_nonopt = d->optind;\r
+}\r
+static const char *_getopt_initialize_a (const char *optstring, struct _getopt_data_a *d, int posixly_correct)\r
+{\r
+       d->__first_nonopt = d->__last_nonopt = d->optind;\r
+       d->__nextchar = NULL;\r
+       d->__posixly_correct = posixly_correct | !!getenv("POSIXLY_CORRECT");\r
+       if (optstring[0] == '-')\r
+       {\r
+               d->__ordering = RETURN_IN_ORDER;\r
+               ++optstring;\r
+       }\r
+       else if (optstring[0] == '+')\r
+       {\r
+               d->__ordering = REQUIRE_ORDER;\r
+               ++optstring;\r
+       }\r
+       else if (d->__posixly_correct)\r
+               d->__ordering = REQUIRE_ORDER;\r
+       else\r
+               d->__ordering = PERMUTE;\r
+       return optstring;\r
+}\r
+int _getopt_internal_r_a (int argc, char *const *argv, const char *optstring, const struct option_a *longopts, int *longind, int long_only, struct _getopt_data_a *d, int posixly_correct)\r
+{\r
+       int print_errors = d->opterr;\r
+       if (argc < 1)\r
+               return -1;\r
+       d->optarg = NULL;\r
+       if (d->optind == 0 || !d->__initialized)\r
+       {\r
+               if (d->optind == 0)\r
+                       d->optind = 1;\r
+               optstring = _getopt_initialize_a (optstring, d, posixly_correct);\r
+               d->__initialized = 1;\r
+       }\r
+       else if (optstring[0] == '-' || optstring[0] == '+')\r
+               optstring++;\r
+       if (optstring[0] == ':')\r
+               print_errors = 0;\r
+       if (d->__nextchar == NULL || *d->__nextchar == '\0')\r
+       {\r
+               if (d->__last_nonopt > d->optind)\r
+                       d->__last_nonopt = d->optind;\r
+               if (d->__first_nonopt > d->optind)\r
+                       d->__first_nonopt = d->optind;\r
+               if (d->__ordering == PERMUTE)\r
+               {\r
+                       if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind)\r
+                               exchange_a ((char **) argv, d);\r
+                       else if (d->__last_nonopt != d->optind)\r
+                               d->__first_nonopt = d->optind;\r
+                       while (d->optind < argc && (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0'))\r
+                               d->optind++;\r
+                       d->__last_nonopt = d->optind;\r
+               }\r
+               if (d->optind != argc && !strcmp(argv[d->optind], "--"))\r
+               {\r
+                       d->optind++;\r
+                       if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind)\r
+                               exchange_a((char **) argv, d);\r
+                       else if (d->__first_nonopt == d->__last_nonopt)\r
+                               d->__first_nonopt = d->optind;\r
+                       d->__last_nonopt = argc;\r
+                       d->optind = argc;\r
+               }\r
+               if (d->optind == argc)\r
+               {\r
+                       if (d->__first_nonopt != d->__last_nonopt)\r
+                               d->optind = d->__first_nonopt;\r
+                       return -1;\r
+               }\r
+               if ((argv[d->optind][0] != '-' || argv[d->optind][1] == '\0'))\r
+               {\r
+                       if (d->__ordering == REQUIRE_ORDER)\r
+                               return -1;\r
+                       d->optarg = argv[d->optind++];\r
+                       return 1;\r
+               }\r
+               d->__nextchar = (argv[d->optind] + 1 + (longopts != NULL && argv[d->optind][1] == '-'));\r
+       }\r
+       if (longopts != NULL && (argv[d->optind][1] == '-' || (long_only && (argv[d->optind][2] || !strchr(optstring, argv[d->optind][1])))))\r
+       {\r
+               char *nameend;\r
+               unsigned int namelen;\r
+               const struct option_a *p;\r
+               const struct option_a *pfound = NULL;\r
+               struct option_list\r
+               {\r
+                       const struct option_a *p;\r
+                       struct option_list *next;\r
+               } *ambig_list = NULL;\r
+               int exact = 0;\r
+               int indfound = -1;\r
+               int option_index;\r
+               for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++);\r
+               namelen = (unsigned int)(nameend - d->__nextchar);\r
+               for (p = longopts, option_index = 0; p->name; p++, option_index++)\r
+                       if (!strncmp(p->name, d->__nextchar, namelen))\r
+                       {\r
+                               if (namelen == (unsigned int)strlen(p->name))\r
+                               {\r
+                                       pfound = p;\r
+                                       indfound = option_index;\r
+                                       exact = 1;\r
+                                       break;\r
+                               }\r
+                               else if (pfound == NULL)\r
+                               {\r
+                                       pfound = p;\r
+                                       indfound = option_index;\r
+                               }\r
+                               else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val)\r
+                               {\r
+                                       struct option_list *newp = (struct option_list*)alloca(sizeof(*newp));\r
+                                       newp->p = p;\r
+                                       newp->next = ambig_list;\r
+                                       ambig_list = newp;\r
+                               }\r
+                       }\r
+                       if (ambig_list != NULL && !exact)\r
+                       {\r
+                               if (print_errors)\r
+                               {\r
+                                       struct option_list first;\r
+                                       first.p = pfound;\r
+                                       first.next = ambig_list;\r
+                                       ambig_list = &first;\r
+                                       fprintf (stderr, "%s: option '%s' is ambiguous; possibilities:", argv[0], argv[d->optind]);\r
+                                       do\r
+                                       {\r
+                                               fprintf (stderr, " '--%s'", ambig_list->p->name);\r
+                                               ambig_list = ambig_list->next;\r
+                                       }\r
+                                       while (ambig_list != NULL);\r
+                                       fputc ('\n', stderr);\r
+                               }\r
+                               d->__nextchar += strlen(d->__nextchar);\r
+                               d->optind++;\r
+                               d->optopt = 0;\r
+                               return '?';\r
+                       }\r
+                       if (pfound != NULL)\r
+                       {\r
+                               option_index = indfound;\r
+                               d->optind++;\r
+                               if (*nameend)\r
+                               {\r
+                                       if (pfound->has_arg)\r
+                                               d->optarg = nameend + 1;\r
+                                       else\r
+                                       {\r
+                                               if (print_errors)\r
+                                               {\r
+                                                       if (argv[d->optind - 1][1] == '-')\r
+                                                       {\r
+                                                               fprintf(stderr, "%s: option '--%s' doesn't allow an argument\n",argv[0], pfound->name);\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               fprintf(stderr, "%s: option '%c%s' doesn't allow an argument\n",argv[0], argv[d->optind - 1][0],pfound->name);\r
+                                                       }\r
+                                               }\r
+                                               d->__nextchar += strlen(d->__nextchar);\r
+                                               d->optopt = pfound->val;\r
+                                               return '?';\r
+                                       }\r
+                               }\r
+                               else if (pfound->has_arg == 1)\r
+                               {\r
+                                       if (d->optind < argc)\r
+                                               d->optarg = argv[d->optind++];\r
+                                       else\r
+                                       {\r
+                                               if (print_errors)\r
+                                               {\r
+                                                       fprintf(stderr,"%s: option '--%s' requires an argument\n",argv[0], pfound->name);\r
+                                               }\r
+                                               d->__nextchar += strlen(d->__nextchar);\r
+                                               d->optopt = pfound->val;\r
+                                               return optstring[0] == ':' ? ':' : '?';\r
+                                       }\r
+                               }\r
+                               d->__nextchar += strlen(d->__nextchar);\r
+                               if (longind != NULL)\r
+                                       *longind = option_index;\r
+                               if (pfound->flag)\r
+                               {\r
+                                       *(pfound->flag) = pfound->val;\r
+                                       return 0;\r
+                               }\r
+                               return pfound->val;\r
+                       }\r
+                       if (!long_only || argv[d->optind][1] == '-' || strchr(optstring, *d->__nextchar) == NULL)\r
+                       {\r
+                               if (print_errors)\r
+                               {\r
+                                       if (argv[d->optind][1] == '-')\r
+                                       {\r
+                                               fprintf(stderr, "%s: unrecognized option '--%s'\n",argv[0], d->__nextchar);\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               fprintf(stderr, "%s: unrecognized option '%c%s'\n",argv[0], argv[d->optind][0], d->__nextchar);\r
+                                       }\r
+                               }\r
+                               d->__nextchar = (char *)"";\r
+                               d->optind++;\r
+                               d->optopt = 0;\r
+                               return '?';\r
+                       }\r
+       }\r
+       {\r
+               char c = *d->__nextchar++;\r
+               char *temp = (char*)strchr(optstring, c);\r
+               if (*d->__nextchar == '\0')\r
+                       ++d->optind;\r
+               if (temp == NULL || c == ':' || c == ';')\r
+               {\r
+                       if (print_errors)\r
+                       {\r
+                               fprintf(stderr, "%s: invalid option -- '%c'\n", argv[0], c);\r
+                       }\r
+                       d->optopt = c;\r
+                       return '?';\r
+               }\r
+               if (temp[0] == 'W' && temp[1] == ';')\r
+               {\r
+                       char *nameend;\r
+                       const struct option_a *p;\r
+                       const struct option_a *pfound = NULL;\r
+                       int exact = 0;\r
+                       int ambig = 0;\r
+                       int indfound = 0;\r
+                       int option_index;\r
+                       if (longopts == NULL)\r
+                               goto no_longs;\r
+                       if (*d->__nextchar != '\0')\r
+                       {\r
+                               d->optarg = d->__nextchar;\r
+                               d->optind++;\r
+                       }\r
+                       else if (d->optind == argc)\r
+                       {\r
+                               if (print_errors)\r
+                               {\r
+                                       fprintf(stderr,"%s: option requires an argument -- '%c'\n",argv[0], c);\r
+                               }\r
+                               d->optopt = c;\r
+                               if (optstring[0] == ':')\r
+                                       c = ':';\r
+                               else\r
+                                       c = '?';\r
+                               return c;\r
+                       }\r
+                       else\r
+                               d->optarg = argv[d->optind++];\r
+                       for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '='; nameend++);\r
+                       for (p = longopts, option_index = 0; p->name; p++, option_index++)\r
+                               if (!strncmp(p->name, d->__nextchar, nameend - d->__nextchar))\r
+                               {\r
+                                       if ((unsigned int) (nameend - d->__nextchar) == strlen(p->name))\r
+                                       {\r
+                                               pfound = p;\r
+                                               indfound = option_index;\r
+                                               exact = 1;\r
+                                               break;\r
+                                       }\r
+                                       else if (pfound == NULL)\r
+                                       {\r
+                                               pfound = p;\r
+                                               indfound = option_index;\r
+                                       }\r
+                                       else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val)\r
+                                               ambig = 1;\r
+                               }\r
+                               if (ambig && !exact)\r
+                               {\r
+                                       if (print_errors)\r
+                                       {\r
+                                               fprintf(stderr, "%s: option '-W %s' is ambiguous\n",argv[0], d->optarg);\r
+                                       }\r
+                                       d->__nextchar += strlen(d->__nextchar);\r
+                                       d->optind++;\r
+                                       return '?';\r
+                               }\r
+                               if (pfound != NULL)\r
+                               {\r
+                                       option_index = indfound;\r
+                                       if (*nameend)\r
+                                       {\r
+                                               if (pfound->has_arg)\r
+                                                       d->optarg = nameend + 1;\r
+                                               else\r
+                                               {\r
+                                                       if (print_errors)\r
+                                                       {\r
+                                                               fprintf(stderr, "%s: option '-W %s' doesn't allow an argument\n",argv[0], pfound->name);\r
+                                                       }\r
+                                                       d->__nextchar += strlen(d->__nextchar);\r
+                                                       return '?';\r
+                                               }\r
+                                       }\r
+                                       else if (pfound->has_arg == 1)\r
+                                       {\r
+                                               if (d->optind < argc)\r
+                                                       d->optarg = argv[d->optind++];\r
+                                               else\r
+                                               {\r
+                                                       if (print_errors)\r
+                                                       {\r
+                                                               fprintf(stderr, "%s: option '-W %s' requires an argument\n",argv[0], pfound->name);\r
+                                                       }\r
+                                                       d->__nextchar += strlen(d->__nextchar);\r
+                                                       return optstring[0] == ':' ? ':' : '?';\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                               d->optarg = NULL;\r
+                                       d->__nextchar += strlen(d->__nextchar);\r
+                                       if (longind != NULL)\r
+                                               *longind = option_index;\r
+                                       if (pfound->flag)\r
+                                       {\r
+                                               *(pfound->flag) = pfound->val;\r
+                                               return 0;\r
+                                       }\r
+                                       return pfound->val;\r
+                               }\r
+no_longs:\r
+                               d->__nextchar = NULL;\r
+                               return 'W';\r
+               }\r
+               if (temp[1] == ':')\r
+               {\r
+                       if (temp[2] == ':')\r
+                       {\r
+                               if (*d->__nextchar != '\0')\r
+                               {\r
+                                       d->optarg = d->__nextchar;\r
+                                       d->optind++;\r
+                               }\r
+                               else\r
+                                       d->optarg = NULL;\r
+                               d->__nextchar = NULL;\r
+                       }\r
+                       else\r
+                       {\r
+                               if (*d->__nextchar != '\0')\r
+                               {\r
+                                       d->optarg = d->__nextchar;\r
+                                       d->optind++;\r
+                               }\r
+                               else if (d->optind == argc)\r
+                               {\r
+                                       if (print_errors)\r
+                                       {\r
+                                               fprintf(stderr,"%s: option requires an argument -- '%c'\n",argv[0], c);\r
+                                       }\r
+                                       d->optopt = c;\r
+                                       if (optstring[0] == ':')\r
+                                               c = ':';\r
+                                       else\r
+                                               c = '?';\r
+                               }\r
+                               else\r
+                                       d->optarg = argv[d->optind++];\r
+                               d->__nextchar = NULL;\r
+                       }\r
+               }\r
+               return c;\r
+       }\r
+}\r
+int _getopt_internal_a (int argc, char *const *argv, const char *optstring, const struct option_a *longopts, int *longind, int long_only, int posixly_correct)\r
+{\r
+       int result;\r
+       getopt_data_a.optind = optind;\r
+       getopt_data_a.opterr = opterr;\r
+       result = _getopt_internal_r_a (argc, argv, optstring, longopts,longind, long_only, &getopt_data_a,posixly_correct);\r
+       optind = getopt_data_a.optind;\r
+       optarg_a = getopt_data_a.optarg;\r
+       optopt = getopt_data_a.optopt;\r
+       return result;\r
+}\r
+int getopt_a (int argc, char *const *argv, const char *optstring) _GETOPT_THROW\r
+{\r
+       return _getopt_internal_a (argc, argv, optstring, (const struct option_a *) 0, (int *) 0, 0, 0);\r
+}\r
+int getopt_long_a (int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW\r
+{\r
+       return _getopt_internal_a (argc, argv, options, long_options, opt_index, 0, 0);\r
+}\r
+int getopt_long_only_a (int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW\r
+{\r
+       return _getopt_internal_a (argc, argv, options, long_options, opt_index, 1, 0);\r
+}\r
+int _getopt_long_r_a (int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index, struct _getopt_data_a *d)\r
+{\r
+       return _getopt_internal_r_a (argc, argv, options, long_options, opt_index,0, d, 0);\r
+}\r
+int _getopt_long_only_r_a (int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index, struct _getopt_data_a *d)\r
+{\r
+       return _getopt_internal_r_a (argc, argv, options, long_options, opt_index, 1, d, 0);\r
+}\r
+\r
+//\r
+//\r
+//     Unicode Structures and Functions\r
+// \r
+//\r
+\r
+static struct _getopt_data_w\r
+{\r
+       int optind;\r
+       int opterr;\r
+       int optopt;\r
+       wchar_t *optarg;\r
+       int __initialized;\r
+       wchar_t *__nextchar;\r
+       enum ENUM_ORDERING __ordering;\r
+       int __posixly_correct;\r
+       int __first_nonopt;\r
+       int __last_nonopt;\r
+} getopt_data_w;\r
+wchar_t *optarg_w;\r
+\r
+static void exchange_w(wchar_t **argv, struct _getopt_data_w *d)\r
+{\r
+       int bottom = d->__first_nonopt;\r
+       int middle = d->__last_nonopt;\r
+       int top = d->optind;\r
+       wchar_t *tem;\r
+       while (top > middle && middle > bottom)\r
+       {\r
+               if (top - middle > middle - bottom)\r
+               {\r
+                       int len = middle - bottom;\r
+                       register int i;\r
+                       for (i = 0; i < len; i++)\r
+                       {\r
+                               tem = argv[bottom + i];\r
+                               argv[bottom + i] = argv[top - (middle - bottom) + i];\r
+                               argv[top - (middle - bottom) + i] = tem;\r
+                       }\r
+                       top -= len;\r
+               }\r
+               else\r
+               {\r
+                       int len = top - middle;\r
+                       register int i;\r
+                       for (i = 0; i < len; i++)\r
+                       {\r
+                               tem = argv[bottom + i];\r
+                               argv[bottom + i] = argv[middle + i];\r
+                               argv[middle + i] = tem;\r
+                       }\r
+                       bottom += len;\r
+               }\r
+       }\r
+       d->__first_nonopt += (d->optind - d->__last_nonopt);\r
+       d->__last_nonopt = d->optind;\r
+}\r
+static const wchar_t *_getopt_initialize_w (const wchar_t *optstring, struct _getopt_data_w *d, int posixly_correct)\r
+{\r
+       d->__first_nonopt = d->__last_nonopt = d->optind;\r
+       d->__nextchar = NULL;\r
+       d->__posixly_correct = posixly_correct | !!_wgetenv(L"POSIXLY_CORRECT");\r
+       if (optstring[0] == L'-')\r
+       {\r
+               d->__ordering = RETURN_IN_ORDER;\r
+               ++optstring;\r
+       }\r
+       else if (optstring[0] == L'+')\r
+       {\r
+               d->__ordering = REQUIRE_ORDER;\r
+               ++optstring;\r
+       }\r
+       else if (d->__posixly_correct)\r
+               d->__ordering = REQUIRE_ORDER;\r
+       else\r
+               d->__ordering = PERMUTE;\r
+       return optstring;\r
+}\r
+int _getopt_internal_r_w (int argc, wchar_t *const *argv, const wchar_t *optstring, const struct option_w *longopts, int *longind, int long_only, struct _getopt_data_w *d, int posixly_correct)\r
+{\r
+       int print_errors = d->opterr;\r
+       if (argc < 1)\r
+               return -1;\r
+       d->optarg = NULL;\r
+       if (d->optind == 0 || !d->__initialized)\r
+       {\r
+               if (d->optind == 0)\r
+                       d->optind = 1;\r
+               optstring = _getopt_initialize_w (optstring, d, posixly_correct);\r
+               d->__initialized = 1;\r
+       }\r
+       else if (optstring[0] == L'-' || optstring[0] == L'+')\r
+               optstring++;\r
+       if (optstring[0] == L':')\r
+               print_errors = 0;\r
+       if (d->__nextchar == NULL || *d->__nextchar == L'\0')\r
+       {\r
+               if (d->__last_nonopt > d->optind)\r
+                       d->__last_nonopt = d->optind;\r
+               if (d->__first_nonopt > d->optind)\r
+                       d->__first_nonopt = d->optind;\r
+               if (d->__ordering == PERMUTE)\r
+               {\r
+                       if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind)\r
+                               exchange_w((wchar_t **) argv, d);\r
+                       else if (d->__last_nonopt != d->optind)\r
+                               d->__first_nonopt = d->optind;\r
+                       while (d->optind < argc && (argv[d->optind][0] != L'-' || argv[d->optind][1] == L'\0'))\r
+                               d->optind++;\r
+                       d->__last_nonopt = d->optind;\r
+               }\r
+               if (d->optind != argc && !wcscmp(argv[d->optind], L"--"))\r
+               {\r
+                       d->optind++;\r
+                       if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind)\r
+                               exchange_w((wchar_t **) argv, d);\r
+                       else if (d->__first_nonopt == d->__last_nonopt)\r
+                               d->__first_nonopt = d->optind;\r
+                       d->__last_nonopt = argc;\r
+                       d->optind = argc;\r
+               }\r
+               if (d->optind == argc)\r
+               {\r
+                       if (d->__first_nonopt != d->__last_nonopt)\r
+                               d->optind = d->__first_nonopt;\r
+                       return -1;\r
+               }\r
+               if ((argv[d->optind][0] != L'-' || argv[d->optind][1] == L'\0'))\r
+               {\r
+                       if (d->__ordering == REQUIRE_ORDER)\r
+                               return -1;\r
+                       d->optarg = argv[d->optind++];\r
+                       return 1;\r
+               }\r
+               d->__nextchar = (argv[d->optind] + 1 + (longopts != NULL && argv[d->optind][1] == L'-'));\r
+       }\r
+       if (longopts != NULL && (argv[d->optind][1] == L'-' || (long_only && (argv[d->optind][2] || !wcschr(optstring, argv[d->optind][1])))))\r
+       {\r
+               wchar_t *nameend;\r
+               unsigned int namelen;\r
+               const struct option_w *p;\r
+               const struct option_w *pfound = NULL;\r
+               struct option_list\r
+               {\r
+                       const struct option_w *p;\r
+                       struct option_list *next;\r
+               } *ambig_list = NULL;\r
+               int exact = 0;\r
+               int indfound = -1;\r
+               int option_index;\r
+               for (nameend = d->__nextchar; *nameend && *nameend != L'='; nameend++);\r
+               namelen = (unsigned int)(nameend - d->__nextchar);\r
+               for (p = longopts, option_index = 0; p->name; p++, option_index++)\r
+                       if (!wcsncmp(p->name, d->__nextchar, namelen))\r
+                       {\r
+                               if (namelen == (unsigned int)wcslen(p->name))\r
+                               {\r
+                                       pfound = p;\r
+                                       indfound = option_index;\r
+                                       exact = 1;\r
+                                       break;\r
+                               }\r
+                               else if (pfound == NULL)\r
+                               {\r
+                                       pfound = p;\r
+                                       indfound = option_index;\r
+                               }\r
+                               else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val)\r
+                               {\r
+                                       struct option_list *newp = (struct option_list*)alloca(sizeof(*newp));\r
+                                       newp->p = p;\r
+                                       newp->next = ambig_list;\r
+                                       ambig_list = newp;\r
+                               }\r
+                       }\r
+                       if (ambig_list != NULL && !exact)\r
+                       {\r
+                               if (print_errors)\r
+                               {                                               \r
+                                       struct option_list first;\r
+                                       first.p = pfound;\r
+                                       first.next = ambig_list;\r
+                                       ambig_list = &first;\r
+                                       fwprintf(stderr, L"%ls: option '%ls' is ambiguous; possibilities:", argv[0], argv[d->optind]);\r
+                                       do\r
+                                       {\r
+                                               fwprintf (stderr, L" '--%ls'", ambig_list->p->name);\r
+                                               ambig_list = ambig_list->next;\r
+                                       }\r
+                                       while (ambig_list != NULL);\r
+                                       fputwc (L'\n', stderr);\r
+                               }\r
+                               d->__nextchar += wcslen(d->__nextchar);\r
+                               d->optind++;\r
+                               d->optopt = 0;\r
+                               return L'?';\r
+                       }\r
+                       if (pfound != NULL)\r
+                       {\r
+                               option_index = indfound;\r
+                               d->optind++;\r
+                               if (*nameend)\r
+                               {\r
+                                       if (pfound->has_arg)\r
+                                               d->optarg = nameend + 1;\r
+                                       else\r
+                                       {\r
+                                               if (print_errors)\r
+                                               {\r
+                                                       if (argv[d->optind - 1][1] == L'-')\r
+                                                       {\r
+                                                               fwprintf(stderr, L"%ls: option '--%ls' doesn't allow an argument\n",argv[0], pfound->name);\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               fwprintf(stderr, L"%ls: option '%c%ls' doesn't allow an argument\n",argv[0], argv[d->optind - 1][0],pfound->name);\r
+                                                       }\r
+                                               }\r
+                                               d->__nextchar += wcslen(d->__nextchar);\r
+                                               d->optopt = pfound->val;\r
+                                               return L'?';\r
+                                       }\r
+                               }\r
+                               else if (pfound->has_arg == 1)\r
+                               {\r
+                                       if (d->optind < argc)\r
+                                               d->optarg = argv[d->optind++];\r
+                                       else\r
+                                       {\r
+                                               if (print_errors)\r
+                                               {\r
+                                                       fwprintf(stderr,L"%ls: option '--%ls' requires an argument\n",argv[0], pfound->name);\r
+                                               }\r
+                                               d->__nextchar += wcslen(d->__nextchar);\r
+                                               d->optopt = pfound->val;\r
+                                               return optstring[0] == L':' ? L':' : L'?';\r
+                                       }\r
+                               }\r
+                               d->__nextchar += wcslen(d->__nextchar);\r
+                               if (longind != NULL)\r
+                                       *longind = option_index;\r
+                               if (pfound->flag)\r
+                               {\r
+                                       *(pfound->flag) = pfound->val;\r
+                                       return 0;\r
+                               }\r
+                               return pfound->val;\r
+                       }\r
+                       if (!long_only || argv[d->optind][1] == L'-' || wcschr(optstring, *d->__nextchar) == NULL)\r
+                       {\r
+                               if (print_errors)\r
+                               {\r
+                                       if (argv[d->optind][1] == L'-')\r
+                                       {\r
+                                               fwprintf(stderr, L"%ls: unrecognized option '--%ls'\n",argv[0], d->__nextchar);\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               fwprintf(stderr, L"%ls: unrecognized option '%c%ls'\n",argv[0], argv[d->optind][0], d->__nextchar);\r
+                                       }\r
+                               }\r
+                               d->__nextchar = (wchar_t *)L"";\r
+                               d->optind++;\r
+                               d->optopt = 0;\r
+                               return L'?';\r
+                       }\r
+       }\r
+       {\r
+               wchar_t c = *d->__nextchar++;\r
+               wchar_t *temp = (wchar_t*)wcschr(optstring, c);\r
+               if (*d->__nextchar == L'\0')\r
+                       ++d->optind;\r
+               if (temp == NULL || c == L':' || c == L';')\r
+               {\r
+                       if (print_errors)\r
+                       {\r
+                               fwprintf(stderr, L"%ls: invalid option -- '%c'\n", argv[0], c);\r
+                       }\r
+                       d->optopt = c;\r
+                       return L'?';\r
+               }\r
+               if (temp[0] == L'W' && temp[1] == L';')\r
+               {\r
+                       wchar_t *nameend;\r
+                       const struct option_w *p;\r
+                       const struct option_w *pfound = NULL;\r
+                       int exact = 0;\r
+                       int ambig = 0;\r
+                       int indfound = 0;\r
+                       int option_index;\r
+                       if (longopts == NULL)\r
+                               goto no_longs;\r
+                       if (*d->__nextchar != L'\0')\r
+                       {\r
+                               d->optarg = d->__nextchar;\r
+                               d->optind++;\r
+                       }\r
+                       else if (d->optind == argc)\r
+                       {\r
+                               if (print_errors)\r
+                               {\r
+                                       fwprintf(stderr,L"%ls: option requires an argument -- '%c'\n",argv[0], c);\r
+                               }\r
+                               d->optopt = c;\r
+                               if (optstring[0] == L':')\r
+                                       c = L':';\r
+                               else\r
+                                       c = L'?';\r
+                               return c;\r
+                       }\r
+                       else\r
+                               d->optarg = argv[d->optind++];\r
+                       for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != L'='; nameend++);\r
+                       for (p = longopts, option_index = 0; p->name; p++, option_index++)\r
+                               if (!wcsncmp(p->name, d->__nextchar, nameend - d->__nextchar))\r
+                               {\r
+                                       if ((unsigned int) (nameend - d->__nextchar) == wcslen(p->name))\r
+                                       {\r
+                                               pfound = p;\r
+                                               indfound = option_index;\r
+                                               exact = 1;\r
+                                               break;\r
+                                       }\r
+                                       else if (pfound == NULL)\r
+                                       {\r
+                                               pfound = p;\r
+                                               indfound = option_index;\r
+                                       }\r
+                                       else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val)\r
+                                               ambig = 1;\r
+                               }\r
+                               if (ambig && !exact)\r
+                               {\r
+                                       if (print_errors)\r
+                                       {\r
+                                               fwprintf(stderr, L"%ls: option '-W %ls' is ambiguous\n",argv[0], d->optarg);\r
+                                       }\r
+                                       d->__nextchar += wcslen(d->__nextchar);\r
+                                       d->optind++;\r
+                                       return L'?';\r
+                               }\r
+                               if (pfound != NULL)\r
+                               {\r
+                                       option_index = indfound;\r
+                                       if (*nameend)\r
+                                       {\r
+                                               if (pfound->has_arg)\r
+                                                       d->optarg = nameend + 1;\r
+                                               else\r
+                                               {\r
+                                                       if (print_errors)\r
+                                                       {\r
+                                                               fwprintf(stderr, L"%ls: option '-W %ls' doesn't allow an argument\n",argv[0], pfound->name);\r
+                                                       }\r
+                                                       d->__nextchar += wcslen(d->__nextchar);\r
+                                                       return L'?';\r
+                                               }\r
+                                       }\r
+                                       else if (pfound->has_arg == 1)\r
+                                       {\r
+                                               if (d->optind < argc)\r
+                                                       d->optarg = argv[d->optind++];\r
+                                               else\r
+                                               {\r
+                                                       if (print_errors)\r
+                                                       {\r
+                                                               fwprintf(stderr, L"%ls: option '-W %ls' requires an argument\n",argv[0], pfound->name);\r
+                                                       }\r
+                                                       d->__nextchar += wcslen(d->__nextchar);\r
+                                                       return optstring[0] == L':' ? L':' : L'?';\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                               d->optarg = NULL;\r
+                                       d->__nextchar += wcslen(d->__nextchar);\r
+                                       if (longind != NULL)\r
+                                               *longind = option_index;\r
+                                       if (pfound->flag)\r
+                                       {\r
+                                               *(pfound->flag) = pfound->val;\r
+                                               return 0;\r
+                                       }\r
+                                       return pfound->val;\r
+                               }\r
+no_longs:\r
+                               d->__nextchar = NULL;\r
+                               return L'W';\r
+               }\r
+               if (temp[1] == L':')\r
+               {\r
+                       if (temp[2] == L':')\r
+                       {\r
+                               if (*d->__nextchar != L'\0')\r
+                               {\r
+                                       d->optarg = d->__nextchar;\r
+                                       d->optind++;\r
+                               }\r
+                               else\r
+                                       d->optarg = NULL;\r
+                               d->__nextchar = NULL;\r
+                       }\r
+                       else\r
+                       {\r
+                               if (*d->__nextchar != L'\0')\r
+                               {\r
+                                       d->optarg = d->__nextchar;\r
+                                       d->optind++;\r
+                               }\r
+                               else if (d->optind == argc)\r
+                               {\r
+                                       if (print_errors)\r
+                                       {\r
+                                               fwprintf(stderr,L"%ls: option requires an argument -- '%c'\n",argv[0], c);\r
+                                       }\r
+                                       d->optopt = c;\r
+                                       if (optstring[0] == L':')\r
+                                               c = L':';\r
+                                       else\r
+                                               c = L'?';\r
+                               }\r
+                               else\r
+                                       d->optarg = argv[d->optind++];\r
+                               d->__nextchar = NULL;\r
+                       }\r
+               }\r
+               return c;\r
+       }\r
+}\r
+int _getopt_internal_w (int argc, wchar_t *const *argv, const wchar_t *optstring, const struct option_w *longopts, int *longind, int long_only, int posixly_correct)\r
+{\r
+       int result;\r
+       getopt_data_w.optind = optind;\r
+       getopt_data_w.opterr = opterr;\r
+       result = _getopt_internal_r_w (argc, argv, optstring, longopts,longind, long_only, &getopt_data_w,posixly_correct);\r
+       optind = getopt_data_w.optind;\r
+       optarg_w = getopt_data_w.optarg;\r
+       optopt = getopt_data_w.optopt;\r
+       return result;\r
+}\r
+int getopt_w (int argc, wchar_t *const *argv, const wchar_t *optstring) _GETOPT_THROW\r
+{\r
+       return _getopt_internal_w (argc, argv, optstring, (const struct option_w *) 0, (int *) 0, 0, 0);\r
+}\r
+int getopt_long_w (int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW\r
+{\r
+       return _getopt_internal_w (argc, argv, options, long_options, opt_index, 0, 0);\r
+}\r
+int getopt_long_only_w (int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW\r
+{\r
+       return _getopt_internal_w (argc, argv, options, long_options, opt_index, 1, 0);\r
+}\r
+int _getopt_long_r_w (int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index, struct _getopt_data_w *d)\r
+{\r
+       return _getopt_internal_r_w (argc, argv, options, long_options, opt_index,0, d, 0);\r
+}\r
+int _getopt_long_only_r_w (int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index, struct _getopt_data_w *d)\r
+{\r
+       return _getopt_internal_r_w (argc, argv, options, long_options, opt_index, 1, d, 0);\r
+}
\ No newline at end of file
diff --git a/addons/getopt/getopt.h b/addons/getopt/getopt.h
new file mode 100644 (file)
index 0000000..9b52559
--- /dev/null
@@ -0,0 +1,121 @@
+/* Getopt for Microsoft C\r
+This code is a modification of the Free Software Foundation, Inc.\r
+Getopt library for parsing command line argument the purpose was\r
+to provide a Microsoft Visual C friendly derivative. This code\r
+provides functionality for both Unicode and Multibyte builds.\r
+\r
+Date: 02/03/2011 - Ludvik Jerabek - Initial Release\r
+Version: 1.0\r
+Comment: Supports getopt, getopt_long, and getopt_long_only\r
+and POSIXLY_CORRECT environment flag\r
+License: LGPL\r
+\r
+Revisions:\r
+\r
+02/03/2011 - Ludvik Jerabek - Initial Release\r
+02/20/2011 - Ludvik Jerabek - Fixed compiler warnings at Level 4\r
+07/05/2011 - Ludvik Jerabek - Added no_argument, required_argument, optional_argument defs\r
+08/03/2011 - Ludvik Jerabek - Fixed non-argument runtime bug which caused runtime exception\r
+08/09/2011 - Ludvik Jerabek - Added code to export functions for DLL and LIB\r
+02/15/2012 - Ludvik Jerabek - Fixed _GETOPT_THROW definition missing in implementation file\r
+08/01/2012 - Ludvik Jerabek - Created separate functions for char and wchar_t characters so single dll can do both unicode and ansi\r
+10/15/2012 - Ludvik Jerabek - Modified to match latest GNU features\r
+06/19/2015 - Ludvik Jerabek - Fixed maximum option limitation caused by option_a (255) and option_w (65535) structure val variable\r
+\r
+**DISCLAIMER**\r
+THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,\r
+EITHER EXPRESS OR IMPLIED, INCLUDING, BUT Not LIMITED TO, THE\r
+IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\r
+PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE\r
+EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT\r
+APPLY TO YOU. IN NO EVENT WILL I BE LIABLE TO ANY PARTY FOR ANY\r
+DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES FOR ANY\r
+USE OF THIS MATERIAL INCLUDING, WITHOUT LIMITATION, ANY LOST\r
+PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON\r
+YOUR INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN If WE ARE\r
+EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r
+*/\r
+#ifndef __GETOPT_H_\r
+       #define __GETOPT_H_\r
+       #include <mgl2/dllexport.h>\r
+       #define _GETOPT_API MGL_EXPORT\r
+\r
+       // Change behavior for C\C++\r
+       #ifdef __cplusplus\r
+               #define _BEGIN_EXTERN_C extern "C" {\r
+               #define _END_EXTERN_C }\r
+               #define _GETOPT_THROW throw()\r
+       #else\r
+               #define _BEGIN_EXTERN_C\r
+               #define _END_EXTERN_C\r
+               #define _GETOPT_THROW\r
+       #endif\r
+\r
+       // Standard GNU options\r
+       #define null_argument           0       /*Argument Null*/\r
+       #define no_argument                     0       /*Argument Switch Only*/\r
+       #define required_argument       1       /*Argument Required*/\r
+       #define optional_argument       2       /*Argument Optional*/   \r
+\r
+       // Shorter Options\r
+       #define ARG_NULL        0       /*Argument Null*/\r
+       #define ARG_NONE        0       /*Argument Switch Only*/\r
+       #define ARG_REQ         1       /*Argument Required*/\r
+       #define ARG_OPT         2       /*Argument Optional*/\r
+\r
+       #include <string.h>\r
+       #include <wchar.h>\r
+\r
+_BEGIN_EXTERN_C\r
+\r
+       extern _GETOPT_API int optind;\r
+       extern _GETOPT_API int opterr;\r
+       extern _GETOPT_API int optopt;\r
+\r
+       // Ansi\r
+       struct option_a\r
+       {\r
+               const char* name;\r
+               int has_arg;\r
+               int *flag;\r
+               int val;\r
+       };\r
+       extern _GETOPT_API char *optarg_a;\r
+       extern _GETOPT_API int getopt_a(int argc, char *const *argv, const char *optstring) _GETOPT_THROW;\r
+       extern _GETOPT_API int getopt_long_a(int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW;\r
+       extern _GETOPT_API int getopt_long_only_a(int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW;\r
+\r
+       // Unicode\r
+       struct option_w\r
+       {\r
+               const wchar_t* name;\r
+               int has_arg;\r
+               int *flag;\r
+               int val;\r
+       };\r
+       extern _GETOPT_API wchar_t *optarg_w;\r
+       extern _GETOPT_API int getopt_w(int argc, wchar_t *const *argv, const wchar_t *optstring) _GETOPT_THROW;\r
+       extern _GETOPT_API int getopt_long_w(int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW;\r
+       extern _GETOPT_API int getopt_long_only_w(int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW;   \r
+       \r
+_END_EXTERN_C\r
+\r
+       #undef _BEGIN_EXTERN_C\r
+       #undef _END_EXTERN_C\r
+       #undef _GETOPT_THROW\r
+       #undef _GETOPT_API\r
+\r
+       #ifdef _UNICODE\r
+               #define getopt getopt_w\r
+               #define getopt_long getopt_long_w\r
+               #define getopt_long_only getopt_long_only_w\r
+               #define option option_w\r
+               #define optarg optarg_w\r
+       #else\r
+               #define getopt getopt_a\r
+               #define getopt_long getopt_long_a\r
+               #define getopt_long_only getopt_long_only_a\r
+               #define option option_a\r
+               #define optarg optarg_a\r
+       #endif\r
+#endif  // __GETOPT_H_\r
index 4208b52932853fce2ccba97595cf7cace28c2886..7e661ea047552c39340091e3cd48fe68c4b9736c 100644 (file)
@@ -1,14 +1,20 @@
 set(MGL_HAVE_QT4 1)
+set(MGL_QT4_LIBS)
 if(enable-json-sample)
-set(MGL_QT4_LIBS Core Gui Network WebKit OpenGL)
-FIND_PACKAGE(Qt4 4.8 REQUIRED QtCore QtGui QtNetwork QtWebKit QtOpenGL)
+set(MGL_QT4_LIBS_FIND QtCore QtGui QtNetwork QtWebKit QtOpenGL)
 else(enable-json-sample)
-set(MGL_QT4_LIBS Core Gui OpenGL)
-FIND_PACKAGE(Qt4 4.8 REQUIRED QtCore QtGui QtOpenGL)
+set(MGL_QT4_LIBS_FIND QtCore QtGui QtOpenGL)
 endif(enable-json-sample)
+
+FIND_PACKAGE(Qt4 4.8 REQUIRED ${MGL_QT4_LIBS_FIND})
+
 if(NOT QT4_FOUND)
        message(SEND_ERROR "Couldn't find Qt4 library.")
 endif(NOT QT4_FOUND)
 
 set(CMAKE_AUTOMOC ON)
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+foreach(mgl_qt4_lib ${MGL_QT4_LIBS_FIND})
+        set(MGL_QT4_LIBS ${MGL_QT4_LIBS} Qt4::${mgl_qt4_lib})
+endforeach(mgl_qt4_lib)
index ff447f7cd850e08fe3b413a6c2b560d27f616ad7..4b7f0b9cb201ffbf6f713bfc6e95b7a640ec055f 100644 (file)
@@ -1,37 +1,18 @@
 set(MGL_HAVE_QT5 1)
-find_package(Qt5Core REQUIRED)
-find_package(Qt5Widgets REQUIRED)
-find_package(Qt5Gui REQUIRED)
-find_package(Qt5PrintSupport REQUIRED)
-find_package(Qt5OpenGL REQUIRED)
-if(NOT Qt5OpenGL_FOUND)
-       message(SEND_ERROR "Couldn't find Qt5 OpenGL library.")
-endif(NOT Qt5OpenGL_FOUND)
-if(NOT Qt5Core_FOUND)
-       message(SEND_ERROR "Couldn't find Qt5 Core library.")
-endif(NOT Qt5Core_FOUND)
-if(NOT Qt5Gui_FOUND)
-       message(SEND_ERROR "Couldn't find Qt5 Gui library.")
-endif(NOT Qt5Gui_FOUND)
-if(NOT Qt5PrintSupport_FOUND)
-       message(SEND_ERROR "Couldn't find Qt5 PrintSupport library.")
-endif(NOT Qt5PrintSupport_FOUND)
-set(MGL_QT5_LIBS Core Gui Widgets PrintSupport OpenGL)
+
+set(MGL_QT5_LIBS_FIND Core Gui Widgets PrintSupport OpenGL)
+
 if(enable-json-sample)
-find_package(Qt5Network REQUIRED)
-find_package(Qt5WebKit REQUIRED)
-find_package(Qt5WebKitWidgets REQUIRED)
-if(NOT Qt5Network_FOUND)
-       message(SEND_ERROR "Couldn't find Qt5 Network library.")
-endif(NOT Qt5Network_FOUND)
-if(NOT Qt5WebKit_FOUND)
-       message(SEND_ERROR "Couldn't find Qt5 WebKit library.")
-endif(NOT Qt5WebKit_FOUND)
-if(NOT Qt5WebKitWidgets_FOUND)
-       message(SEND_ERROR "Couldn't find Qt5 WebKitWidgets library.")
-endif(NOT Qt5WebKitWidgets_FOUND)
-set(MGL_QT5_LIBS ${MGL_QT5_LIBS} Network WebKit WebKitWidgets)
+    set(MGL_QT5_LIBS_FIND ${MGL_QT5_LIBS_FIND} Network WebKit WebKitWidgets)
 endif(enable-json-sample)
 
+foreach(mgl_qt5_lib ${MGL_QT5_LIBS_FIND})
+       set(MGL_QT5_LIBS ${MGL_QT5_LIBS} Qt5::${mgl_qt5_lib})
+       find_package(Qt5${mgl_qt5_lib} REQUIRED)
+       if(NOT Qt5${mgl_qt5_lib}_FOUND)
+               message(SEND_ERROR "Couldn't find Qt5 ${mgl_qt5_lib} library.")
+       endif(NOT Qt5${mgl_qt5_lib}_FOUND)
+endforeach(mgl_qt5_lib)
+
 set(CMAKE_AUTOMOC ON)
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
index 75a04658ace469cc1bf179c4dbb10469b12a2368..d216bef86be2f742eb727fafea67130cc7f5ea5e 100644 (file)
@@ -1,9 +1,5 @@
-if(MGL_HAVE_GSL)
-       include_directories(${GSL_INCLUDE_DIR})
-endif(MGL_HAVE_GSL)
-
 add_executable(mgl_example wnd_samples.cpp full_test.cpp samples.cpp)
-target_link_libraries(mgl_example mgl)
+target_link_libraries(mgl_example mgl-static ${getopt_lib-static})
 
 if(MGL_HAVE_FLTK)
        include_directories(${FLTK_INCLUDE_DIR})
@@ -31,19 +27,18 @@ if(QT_ENABLED)
                include(../cmake-qt4.txt)
                target_link_libraries(mgl_qt_example mgl-qt4)
        endif(enable-qt5)
-       add_executable(mgl_qgl_example wnd_samples.cpp qgl_example.cpp)
-       if(enable-qt5)
-               target_link_libraries(mgl_qgl_example mgl)
-               qt5_use_modules(mgl_qgl_example ${MGL_QT5_LIBS})
-       else(enable-qt5)
-               target_link_libraries(mgl_qgl_example mgl)
-               qt4_use_modules(mgl_qgl_example ${MGL_QT4_LIBS})
-       endif(enable-qt5)
-
+       
+       if(MGL_HAVE_OPENGL)
+               add_executable(mgl_qgl_example wnd_samples.cpp qgl_example.cpp)
+               if(enable-qt5)
+                       target_link_libraries(mgl_qgl_example mgl ${MGL_QT5_LIBS})
+               else(enable-qt5)
+                       target_link_libraries(mgl_qgl_example mgl ${MGL_QT4_LIBS})
+               endif(enable-qt5)
+       endif(MGL_HAVE_OPENGL)
 endif(QT_ENABLED)
 
 if(MGL_HAVE_LTDL)
-       include_directories(${LTDL_INCLUDE_DIR})
        add_library(mgl_module MODULE mgl_module.cpp)
        target_link_libraries(mgl_module mgl)   # for compatibility with win32
 endif(MGL_HAVE_LTDL)
diff --git a/examples/FractInt.ifs b/examples/FractInt.ifs
new file mode 100644 (file)
index 0000000..5503b66
--- /dev/null
@@ -0,0 +1,158 @@
+\r
+ binary\r
+ { ; comment allowed here\r
+  ; and here\r
+  .5  .0 .0 .5 -2.563477 -0.000003 .333333   ; also comment allowed here\r
+  .5  .0 .0 .5  2.436544 -0.000003 .333333\r
+  .0 -.5 .5 .0  4.873085  7.563492 .333333\r
+  }\r
+\r
+coral{.307692 -.531469 -.461538 -.293706  5.401953 8.655175 .40 ; also comment\r
+  .307692 -.076923  .153846 -.447552 -1.295248 4.152990 .15\r
+  .000000  .545455  .692308 -.195804 -4.893637 7.269794 .45\r
+  }\r
+\r
+crystal {\r
+  .696970 -.481061 -.393939 -.662879 2.147003 10.310288 .747826\r
+  .090909 -.443182  .515152 -.094697 4.286558  2.925762 .252174\r
+  }\r
+\r
+dragon {\r
+  .824074 .281482 -.212346  .864198 -1.882290 -0.110607 .787473\r
+  .088272 .520988 -.463889 -.377778  0.785360  8.095795 .212527\r
+  }\r
+\r
+fern {0  0    0  .16 0   0 .01\r
+   .85  .04 -.04 .85 0 1.6 .85\r
+   .2  -.26  .23 .22 0 1.6 .07\r
+  -.15  .28  .26 .24 0 .44 .07\r
+  }\r
+\r
+3dfern (3D) {\r
+   .00  .00 0 .0 .18 .0 0  0.0 0.00 0 0.0 0 .01\r
+   .85  .00 0 .0 .85 .1 0 -0.1 0.85 0 1.6 0 .85\r
+   .20 -.20 0 .2 .20 .0 0  0.0 0.30 0 0.8 0 .07\r
+  -.20  .20 0 .2 .20 .0 0  0.0 0.30 0 0.8 0 .07\r
+  }\r
+\r
+floor {\r
+  .0 -.5  .5 .0 -1.732366 3.366182 .333333\r
+  .5  .0  .0 .5 -0.027891 5.014877 .333333\r
+  .0  .5 -.5 .0  1.620804 3.310401 .333333\r
+  }\r
+\r
+koch3 {\r
+  .307692 -.000000  .000000  .294118  4.119164 1.604278 .151515\r
+  .192308 -.205882  .653846  .088235 -0.688840 5.978916 .253788\r
+  .192308  .205882 -.653846  .088235  0.668580 5.962514 .253788\r
+  .307692 -.000000  .000000  .294118 -4.136530 1.604278 .151515\r
+  .384615 -.000000  .000000 -.294118 -0.007718 2.941176 .189394\r
+  }\r
+\r
+spiral {   \r
+   .787879 -.424242 .242424 .859848  1.758647 1.408065 .895652\r
+  -.121212  .257576 .151515 .053030 -6.721654 1.377236 .052174\r
+   .181818 -.136364 .090909 .181818  6.086107 1.568035 .052174\r
+  }\r
+\r
+swirl5 {\r
+   .745455 -.459091  .406061  .887121 1.460279 0.691072 .912675\r
+  -.424242 -.065152 -.175758 -.218182 3.809567 6.741476 .087325\r
+  }\r
+\r
+tree {\r
+    0  0   0  .5   0   0  .05\r
+  .42 -.42  .42 .42  0  .2  .4\r
+  .42  .42 -.42 .42  0  .2  .4\r
+   .1  0   0  .1   0  .2  .15\r
+  }\r
+\r
+triangle {\r
+  .5  0  0  .5  0  0  .33\r
+  .5  0  0  .5  0  1  .33\r
+  .5  0  0  .5  1  1  .34\r
+  }\r
+\r
+zigzag2 {\r
+  -.632407 -.614815 -.545370 .659259 3.840822 1.282321 .888128\r
+  -.036111  .444444  .210185 .037037 2.071081 8.330552 .111872\r
+  }\r
+\r
+\r
+3dTetrahedron (3D) { ; by Alex Matulich\r
+  0.50  0  0  0  0.50  0  0  0  0.50  0.00  0.00  1.00  0.25\r
+  0.50  0  0  0  0.50  0  0  0  0.50  0.00  0.87 -0.50  0.25\r
+  0.50  0  0  0  0.50  0  0  0  0.50 -0.87 -0.50 -0.50  0.25\r
+  0.50  0  0  0  0.50  0  0  0  0.50  0.87 -0.50 -0.50  0.25\r
+}\r
+3d5Tetrahedron (3D) { ; by Alex Matulich\r
+  0.44  0  0  0  0.44  0  0  0  0.44  0.00  0.00  1.00  0.20\r
+  0.44  0  0  0  0.44  0  0  0  0.44  0.00  0.87 -0.50  0.20\r
+  0.44  0  0  0  0.44  0  0  0  0.44 -0.87 -0.50 -0.50  0.20\r
+  0.44  0  0  0  0.44  0  0  0  0.44  0.87 -0.50 -0.50  0.20\r
+  0.44  0  0  0  0.44  0  0  0  0.44  0.00  0.00  0.00  0.20\r
+}\r
+3dHexahedron (3D) { ; by Alex Matulich\r
+  0.44  0  0  0  0.44  0  0  0  0.44  0.00  0.00  0.90  0.20\r
+  0.44  0  0  0  0.44  0  0  0  0.44  0.87 -0.50  0.00  0.20\r
+  0.44  0  0  0  0.44  0  0  0  0.44 -0.87 -0.50  0.00  0.20\r
+  0.44  0  0  0  0.44  0  0  0  0.44  0.00  1.00  0.00  0.20\r
+  0.44  0  0  0  0.44  0  0  0  0.44  0.00  0.00 -0.90  0.20\r
+}\r
+3dCube (3d) { ; by Alex Matulich\r
+  0.35  0  0  0  0.35  0  0  0  0.35  1.00  1.00  1.00  0.12\r
+  0.35  0  0  0  0.35  0  0  0  0.35  1.00  1.00 -1.00  0.13\r
+  0.35  0  0  0  0.35  0  0  0  0.35  1.00 -1.00  1.00  0.12\r
+  0.35  0  0  0  0.35  0  0  0  0.35  1.00 -1.00 -1.00  0.13\r
+  0.35  0  0  0  0.35  0  0  0  0.35 -1.00  1.00  1.00  0.12\r
+  0.35  0  0  0  0.35  0  0  0  0.35 -1.00  1.00 -1.00  0.13\r
+  0.35  0  0  0  0.35  0  0  0  0.35 -1.00 -1.00  1.00  0.12\r
+  0.35  0  0  0  0.35  0  0  0  0.35 -1.00 -1.00 -1.00  0.13\r
+}\r
+3dOctahedron (3D) { ; by Alex Matulich\r
+  0.40  0  0  0  0.40  0  0  0  0.40  0.00  0.00  1.00  0.17\r
+  0.40  0  0  0  0.40  0  0  0  0.40  1.00  0.00  0.00  0.16\r
+  0.40  0  0  0  0.40  0  0  0  0.40  0.00  1.00  0.00  0.17\r
+  0.40  0  0  0  0.40  0  0  0  0.40 -1.00  0.00  0.00  0.17\r
+  0.40  0  0  0  0.40  0  0  0  0.40  0.00 -1.00  0.00  0.16\r
+  0.40  0  0  0  0.40  0  0  0  0.40  0.00  0.00 -1.00  0.17\r
+}\r
+3dDuodecahedron (3D) { ; by Alex Matulich\r
+  0.28  0  0  0  0.28  0  0  0  0.28  0.00  0.00  0.96  0.09\r
+  0.28  0  0  0  0.28  0  0  0  0.28  0.00  0.85  0.43  0.08\r
+  0.28  0  0  0  0.28  0  0  0  0.28  0.81  0.26  0.43  0.08\r
+  0.28  0  0  0  0.28  0  0  0  0.28 -0.81  0.26  0.43  0.09\r
+  0.28  0  0  0  0.28  0  0  0  0.28  0.50 -0.69  0.43  0.08\r
+  0.28  0  0  0  0.28  0  0  0  0.28 -0.50 -0.69  0.43  0.08\r
+  0.28  0  0  0  0.28  0  0  0  0.28  0.50  0.69 -0.43  0.09\r
+  0.28  0  0  0  0.28  0  0  0  0.28 -0.50  0.69 -0.43  0.08\r
+  0.28  0  0  0  0.28  0  0  0  0.28  0.81 -0.26 -0.43  0.08\r
+  0.28  0  0  0  0.28  0  0  0  0.28 -0.81 -0.26 -0.43  0.09\r
+  0.28  0  0  0  0.28  0  0  0  0.28  0.00 -0.85 -0.43  0.08\r
+  0.28  0  0  0  0.28  0  0  0  0.28  0.00  0.00 -0.96  0.08\r
+}\r
+\r
+fractint { ; by Pieter Branderhorst\r
+  0.00 -0.11  0.22  0.00 -6.25 4.84 0.06\r
+  0.11  0.02  0.00  0.11 -6.30 5.99 0.03\r
+  0.06  0.02  0.00  0.10 -6.25 4.51 0.02\r
+  0.00 -0.11  0.22  0.00 -4.34 4.84 0.06\r
+  0.08  0.00  0.00  0.11 -4.50 5.99 0.02\r
+  0.00  0.11 -0.08  0.00 -4.30 6.15 0.02\r
+ -0.09  0.00 -0.01 -0.13 -4.15 5.94 0.02\r
+  0.06  0.11 -0.13  0.00 -4.69 4.15 0.04\r
+  0.03 -0.11  0.23  0.11 -2.26 4.43 0.07\r
+  0.03  0.11 -0.25  0.00 -2.57 4.99 0.07\r
+  0.06  0.00  0.00  0.11 -2.40 4.46 0.02\r
+  0.00  0.11 -0.19  0.00 -1.62 4.99 0.06\r
+  0.09 -0.01  0.00  0.10 -0.58 2.96 0.03\r
+ -0.09  0.00  0.00 -0.11 -0.65 7.10 0.03\r
+  0.12  0.00 -0.00  0.11  1.24 6.00 0.03\r
+  0.00  0.11 -0.22  0.00  0.68 4.80 0.06\r
+ -0.12  0.00  0.00 -0.13  6.17 7.18 0.03\r
+  0.00 -0.11  0.22  0.00  6.78 4.84 0.06\r
+  0.00  0.08 -0.25  0.02  2.21 4.95 0.07\r
+  0.00 -0.11  0.22  0.00  4.10 4.84 0.06\r
+  0.00 -0.11  0.22  0.00  5.25 5.23 0.06\r
+  0.08  0.11 -0.25  0.00  3.57 4.99 0.08\r
+  }\r
index 6595211e2d4a97b7ece33a73a9ae8e3dd37898f9..61d39c9885099fb9780a07b1c24314cf0e10837a 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * fltk_example.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\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
@@ -125,20 +125,22 @@ int main(int argc,char **argv)
        else    printf("You may specify argument '1', '2', '3', 'd' for viewing examples of 1d, 2d, 3d, dual plotting,\nor 'm' for multi-threading sample.\n");\r
        switch(key)\r
        {\r
-       case '0':       gr = new mglFLTK((mglDraw *)NULL,"1D plots");   break;\r
+       case '0':       gr = new mglFLTK((mglDraw *)NULL,"1D plots");\r
+                               gr->Rotate(40,60);      gr->Box();      gr->Light(true);\r
+                               gr->FSurf("sin(4*pi*x*y)");     gr->Update();   break;\r
        case '1':       gr = new mglFLTK(sample_1,"1D plots");  break;\r
        case '2':       gr = new mglFLTK(sample_2,"2D plots");  break;\r
        case '3':       gr = new mglFLTK(sample_3,"3D plots");  break;\r
        case 'd':       gr = new mglFLTK(sample_d,"Dual plots");break;\r
        case 't':       gr = new mglFLTK(test_wnd,"Testing");   break;\r
+       case 'f':       gr = new mglFLTK("Frame drawing");\r
+                               gr->NewFrame(); gr->Box();      gr->EndFrame(); break;\r
 #if MGL_HAVE_PTHR_WIDGET\r
        case 'm':       gr = new mglFLTK(&dr,"Multi-threading test");\r
        dr.SetWnd(gr);  dr.Run();       break;\r
 #endif\r
        default:        gr = new mglFLTK(sample,"Drop and waves");      break;\r
        }\r
-       if(key=='0')\r
-       {       gr->Rotate(40,60);      gr->Box();      gr->Light(true);        gr->FSurf("sin(4*pi*x*y)");     gr->Update();   }\r
        gr->Run();      return 0;\r
 }\r
 #endif\r
index acf86123008d93b2a839d623914afc6315bc1e07..538dfba3224b9595c897f8e6b4f26f28ee50661d 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * full_test.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\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
 #include <time.h>\r
 #include <locale.h>\r
 #include <time.h>\r
-#if !defined(_MSC_VER) && !defined(__BORLANDC__)\r
 #include <getopt.h>\r
-#endif\r
 \r
 #include "mgl2/mgl.h"\r
 #include "mgl2/font.h"\r
 #include "mgl2/eval.h"\r
 //-----------------------------------------------------------------------------\r
-void mgl_create_cpp_font(HMGL gr, const wchar_t *how);\r
+void MGL_EXPORT mgl_create_cpp_font(HMGL gr, const wchar_t *how);\r
+long MGL_EXPORT mgl_check_tex_table();\r
 //-----------------------------------------------------------------------------\r
 struct mglSample       /// Structure for list of samples\r
 {\r
@@ -75,7 +74,6 @@ void test(mglGraph *gr)
        return;\r
 }\r
 //-----------------------------------------------------------------------------\r
-#if !defined(_MSC_VER) && !defined(__BORLANDC__)\r
 static struct option longopts[] =\r
 {\r
        { "big",        no_argument,    &big,           1 },\r
@@ -156,7 +154,6 @@ void usage()
                "--fexport      - test most of output formats\n"\r
        );\r
 }\r
-#endif\r
 //-----------------------------------------------------------------------------\r
 void save(mglGraph *gr,const char *name,const char *suf="")\r
 {\r
@@ -389,15 +386,6 @@ void smgl_fexport(mglGraph *gr)    // test file export
        gr->ImportMGLD("fexport.mgld");\r
 }\r
 //-----------------------------------------------------------------------------\r
-extern mglTeXsymb mgl_tex_symb[];\r
-extern long mgl_tex_num;\r
-int MGL_LOCAL_PURE mgl_tex_symb_cmp(const void *a, const void *b)\r
-{\r
-       const mglTeXsymb *aa = (const mglTeXsymb *)a;\r
-       const mglTeXsymb *bb = (const mglTeXsymb *)b;\r
-       return wcscmp(aa->tex, bb->tex);\r
-}\r
-//-----------------------------------------------------------------------------\r
 int main(int argc,char **argv)\r
 {\r
        mgl_suppress_warn(true);\r
@@ -407,7 +395,6 @@ int main(int argc,char **argv)
        time_t st,en;   time(&st);\r
        mglGraph *gr = NULL;\r
        mglSample *s=samp;\r
-#if !defined(_MSC_VER) && !defined(__BORLANDC__)\r
        while(( ch = getopt_long_only(argc, argv, "", longopts, NULL)) != -1)\r
                switch(ch)\r
                {\r
@@ -426,7 +413,6 @@ int main(int argc,char **argv)
                        case '?':\r
                        default:        usage();        return 0;\r
                }\r
-#endif\r
 \r
        if(dotest==1)   printf("Global (before):%s\n",mglGlobalMess.c_str());\r
        gr = new mglGraph;\r
@@ -498,14 +484,7 @@ int main(int argc,char **argv)
        {       smgl_fexport(gr);       delete gr;      return 0;       }\r
        else if(dotest==5)\r
        {\r
-               long i=0;       while(mgl_tex_symb[i].tex[0])   i++;\r
-               if(mgl_tex_num!=i)      printf("real=%lu, set=%ld\n",i,mgl_tex_num);\r
-               for(long i=0;mgl_tex_symb[i].tex[0];i++)\r
-               {\r
-                               mglTeXsymb tst, *rts;   tst.tex = mgl_tex_symb[i].tex;\r
-                               rts = (mglTeXsymb *) bsearch(&tst, mgl_tex_symb, mgl_tex_num, sizeof(mglTeXsymb), mgl_tex_symb_cmp);\r
-                               if(!rts)        printf("Bad '%ls' at %lu\n",mgl_tex_symb[i].tex,i);\r
-               }\r
+               mgl_check_tex_table();\r
                delete gr;      return 0;\r
        }\r
 \r
index 1ae89b67bf1fbb6614a814ce15e254c224191bca..c92158324cbcb55545da72fe571f38af777292aa 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * glut_example.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\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
index c606a3a78068e34cc88166162f13dfefa38e5e7e..77fa94bf5250bda8709c03a155e33bec35311970 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * qt_example.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   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  *
@@ -19,6 +19,7 @@
  ***************************************************************************/
 #include "qgl_example.h"
 #include <QApplication>
+//#include <GL/gl.h>
 //-----------------------------------------------------------------------------
 int main(int argc, char *argv[])
 {
index 1b7a3b0c08e9cce089b50f28ee1afaba788afc89..7d5e4ab0cb88baf64c1a42872bba5fc35ce8effd 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * qt_example.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\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
@@ -139,20 +139,22 @@ int main(int argc,char **argv)
        else    printf("You may specify argument '1', '2', '3', 'd' for viewing examples of 1d, 2d, 3d, dual plotting,\nor 'm' for multi-threading sample.\n");\r
        switch(key)\r
        {\r
-       case '0':       gr = new mglQT((mglDraw *)NULL,"1D plots");     break;\r
+       case '0':       gr = new mglQT((mglDraw *)NULL,"1D plots");\r
+                               gr->Rotate(40,60);      gr->Box();      gr->Light(true);\r
+                               gr->FSurf("sin(4*pi*x*y)");     gr->Update();   break;\r
        case '1':       gr = new mglQT(sample_1,"1D plots");    break;\r
        case '2':       gr = new mglQT(sample_2,"2D plots");    break;\r
        case '3':       gr = new mglQT(sample_3,"3D plots");    break;\r
        case 'd':       gr = new mglQT(sample_d,"Dual plots");  break;\r
-       case 't':       gr = new mglQT(test_wnd,"Testing");     break;\r
+       case 't':       gr = new mglQT(test_wnd,"Testing");             break;\r
+       case 'f':       gr = new mglQT("Frame drawing");\r
+                               gr->NewFrame(); gr->Box();      gr->EndFrame(); break;\r
 #if MGL_HAVE_PTHR_WIDGET\r
        case 'm':       gr = new mglQT(&dr,"Multi-threading test");\r
        dr.SetWnd(gr);  dr.Run();       break;\r
 #endif\r
        default:        gr = new mglQT(sample,"Drop and waves");        break;\r
        }\r
-       if(key=='0')\r
-       {       gr->Rotate(40,60);      gr->Box();      gr->Light(true);        gr->FSurf("sin(4*pi*x*y)");     gr->Update();   }\r
        gr->Run();      return 0;\r
 }\r
 #endif\r
index 437990d2e1ace07008bca8dd6d0e14c520d22328..243f59a2782f0f18e1f8ae5612c3dd69c805afaf 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * samples.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   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  *
@@ -105,7 +105,7 @@ void smgl_refill(mglGraph *gr)
 //-----------------------------------------------------------------------------
 const char *mmgl_indirect="subplot 1 1 0 '':title 'SubData vs Evaluate'\n"
 "new in 9 'x^3/1.1':plot in 'ko ':box\nnew arg 99 '4*x+4'\n"
-"evaluate e in arg:plot e 'b.'; legend 'Evaluate'\n"
+"evaluate e in arg off:plot e 'b.'; legend 'Evaluate'\n"
 "subdata s in arg:plot s 'r.';legend 'SubData'\nlegend 2";
 void smgl_indirect(mglGraph *gr)
 {
@@ -113,7 +113,7 @@ void smgl_indirect(mglGraph *gr)
        mglData in(9), arg(99), e, s;
        gr->Fill(in,"x^3/1.1"); gr->Fill(arg,"4*x+4");
        gr->Plot(in,"ko ");             gr->Box();
-       e = in.Evaluate(arg);   gr->Plot(e,"b.","legend 'Evaluate'");
+       e = in.Evaluate(arg,false);     gr->Plot(e,"b.","legend 'Evaluate'");
        s = in.SubData(arg);    gr->Plot(s,"r.","legend 'SubData'");
        gr->Legend(2);
 }
@@ -1979,9 +1979,11 @@ void smgl_cones(mglGraph *gr)
        gr->Rotate(50,60);      gr->Box();      gr->Cones(ys,"4");
 }
 //-----------------------------------------------------------------------------
-const char *mmgl_aspect="subplot 2 2 0:box:text -1 1.1 'Just box' ':L'\ninplot 0.2 0.5 0.7 1 off:box:text 0 1.2 'InPlot example'\n"
-"subplot 2 2 1:title 'Rotate only':rotate 50 60:box\nsubplot 2 2 2:title 'Rotate and Aspect':rotate 50 60:aspect 1 1 2:box\n"
-"subplot 2 2 3:title 'Aspect in other direction':rotate 50 60:aspect 1 2 2:box";
+const char *mmgl_aspect="subplot 2 2 0:box:text -1 1.1 'Just box' ':L'\n"
+"inplot 0.2 0.5 0.7 1 off:box:text 0 1.2 'InPlot example'\n"
+"subplot 2 2 1:title 'Rotate only':rotate 50 60:box\n"
+"subplot 2 2 2:title 'Rotate and Aspect':rotate 50 60:aspect 1 1 2:box\n"
+"subplot 2 2 3:title 'Shear':box 'c':shear 0.2 0.1:box";
 void smgl_aspect(mglGraph *gr) // transformation
 {
        gr->SubPlot(2,2,0);     gr->Box();
@@ -1992,18 +1994,20 @@ void smgl_aspect(mglGraph *gr)  // transformation
        gr->Rotate(50,60);      gr->Box();
        gr->SubPlot(2,2,2);     gr->Title("Rotate and Aspect");
        gr->Rotate(50,60);      gr->Aspect(1,1,2);      gr->Box();
-       gr->SubPlot(2,2,3);     gr->Title("Aspect in other direction");
-       gr->Rotate(50,60);      gr->Aspect(1,2,2);      gr->Box();
+       gr->SubPlot(2,2,3);     gr->Title("Shear");
+       gr->Box("c");           gr->Shear(0.2,0.1);     gr->Box();
 }
 //-----------------------------------------------------------------------------
-const char *mmgl_inplot="subplot 3 2 0:title 'StickPlot'\nstickplot 3 0 20 30:box 'r':text 0 0 '0' 'r'\n"
-"stickplot 3 1 20 30:box 'g':text 0 0 '1' 'g'\nstickplot 3 2 20 30:box 'b':text 0 0 '2' 'b'\n"
+const char *mmgl_inplot="subplot 3 2 0:title 'StickPlot'\nstickplot 3 0 20 30:box 'r':text 0 0 '0' 'r'\n"
+"stickplot 3 1 20 30:box 'g':text 0 0 0 '1' 'g'\nstickplot 3 2 20 30:box 'b':text 0 9 0 '2' 'b'\n"
 "subplot 3 2 3 '':title 'ColumnPlot'\ncolumnplot 3 0:box 'r':text 0 0 '0' 'r'\n"
 "columnplot 3 1:box 'g':text 0 0 '1' 'g'\ncolumnplot 3 2:box 'b':text 0 0 '2' 'b'\n"
 "subplot 3 2 4 '':title 'GridPlot'\ngridplot 2 2 0:box 'r':text 0 0 '0' 'r'\n"
 "gridplot 2 2 1:box 'g':text 0 0 '1' 'g'\ngridplot 2 2 2:box 'b':text 0 0 '2' 'b'\n"
 "gridplot 2 2 3:box 'm':text 0 0 '3' 'm'\nsubplot 3 2 5 '':title 'InPlot':box\n"
-"inplot 0.4 1 0.6 1 on:box 'r'\nmultiplot 3 2 1 2 1 '':title 'MultiPlot':box";
+"inplot 0.4 1 0.6 1 on:box 'r'\nmultiplot 3 2 1 2 1 '':title 'MultiPlot and ShearPlot':box\n"
+"shearplot 3 0 0.2 0.1:box 'r':text 0 0 '0' 'r'\nshearplot 3 1 0.2 0.1:box 'g':text 0 0 '1' 'g'\n"
+"shearplot 3 2 0.2 0.1:box 'b':text 0 0 '2' 'b'";
 void smgl_inplot(mglGraph *gr)
 {
        gr->SubPlot(3,2,0);     gr->Title("StickPlot");
@@ -2021,7 +2025,10 @@ void smgl_inplot(mglGraph *gr)
        gr->GridPlot(2, 2, 3);  gr->Box("m");   gr->Puts(mglPoint(0),"3","m");
        gr->SubPlot(3,2,5,"");  gr->Title("InPlot");    gr->Box();
        gr->InPlot(0.4, 1, 0.6, 1, true);       gr->Box("r");
-       gr->MultiPlot(3,2,1, 2, 1,"");  gr->Title("MultiPlot"); gr->Box();
+       gr->MultiPlot(3,2,1, 2, 1,"");  gr->Title("MultiPlot and ShearPlot");   gr->Box();
+       gr->ShearPlot(3, 0, 0.2, 0.1);  gr->Box("r");   gr->Puts(mglPoint(0),"0","r");
+       gr->ShearPlot(3, 1, 0.2, 0.1);  gr->Box("g");   gr->Puts(mglPoint(0),"1","g");
+       gr->ShearPlot(3, 2, 0.2, 0.1);  gr->Box("b");   gr->Puts(mglPoint(0),"2","b");
 }
 //-----------------------------------------------------------------------------
 const char *mmgl_combined="call 'prepare2v'\ncall 'prepare3d'\nnew v 10:fill v -0.5 1:copy d sqrt(a^2+b^2)\n"
index 8506f40409916765437f4f864a807a2ef3d67aa7..bea8abe976c63d24b83846fadea0097a807c0cf6 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * wnd_sample.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\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
index 2c064ff6ee6904546adf599a3e0e31b998c1052c..34b1c722f7669bad220b57c18195d46fc77c91bd 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * wx_example.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\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
index 28ea013689fb14de82d70761a16effc02f66b1a3..f24af56e28b931ab76551264bda719591c710822 100644 (file)
@@ -1,6 +1,5 @@
-
 add_executable(make_bin make_bin.cpp)
-target_link_libraries(make_bin mgl)
+target_link_libraries(make_bin mgl-static ${getopt_lib-static})
 
 set(MGL_FONTS STIX adventor  bonum  cursor  heroscn  heros  pagella  schola  termes)
 set(MGL_FONTS_BIN )
index bb4aadad9459b6982a0f637493331a0d65714a37..600745f0ec5b6066ae8b6f3d4f504d0439c1b371 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * make_bin.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   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  *
index 387a347bf92a89fcce6ebd67fc9b3267d450a1ba..372bae2c7d338aea0f0665dcc832fc53bd11bc08 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * Fl_MathGL.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 48cc733a1fc05ea1ca02e292b6dd95d46ebd6c00..861aeb127f1845731e2a771300008f2a5ed7f11f 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * abstract.h is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
@@ -23,7 +23,6 @@
 #include "mgl2/define.h"
 //-----------------------------------------------------------------------------
 #ifdef __cplusplus
-#include <string>
 #include "mgl2/type.h"
 #define MGL_TO_WCS(str,code)   if(str && *str){size_t s=mbstowcs(0,str,0); wchar_t *wcs=new wchar_t[s+1]; mbstowcs(wcs,str,s); wcs[s]=0; code; delete []wcs;}else{const wchar_t *wcs=L""; code;}
 //-----------------------------------------------------------------------------
@@ -135,6 +134,10 @@ mreal MGL_EXPORT mgl_data_linear_(uintptr_t *dat, mreal *x,mreal *y,mreal *z);
 mreal MGL_EXPORT mgl_data_linear_ext(HCDT dat, mreal x,mreal y,mreal z, mreal *dx,mreal *dy,mreal *dz);
 mreal MGL_EXPORT mgl_data_linear_ext_(uintptr_t *dat, mreal *x,mreal *y,mreal *z, mreal *dx,mreal *dy,mreal *dz);
 
+/// Internal function for (un-)locking mutex in mglStack
+void MGL_EXPORT mgl_mutex_lock(void *);
+void MGL_EXPORT mgl_mutex_unlock(void *);
+
 //-----------------------------------------------------------------------------
 /// Callback function for asking user a question. Result shouldn't exceed 1024.
 extern MGL_EXPORT void (*mgl_ask_func)(const wchar_t *quest, wchar_t *res);
@@ -152,7 +155,7 @@ public:
 
        mglDataA()      {       temp=false;     func=0; o=0;    }
        virtual ~mglDataA()     {       if(func)        func(o);        }
-       virtual void set_v(mreal val, long i,long j=0,long k=0) {}
+       virtual void set_v(mreal /*val*/, long /*i*/,long /*j*/=0,long /*k*/=0) {}
        /// Get the interpolated value and its derivatives in given data cell without border checking
        virtual mreal valueD(mreal x,mreal y=0,mreal z=0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const =0;
        /// Get the interpolated value in given data cell without border checking
@@ -164,7 +167,10 @@ public:
        inline mreal linearD(mreal x,mreal y=0,mreal z=0,mreal *dx=0,mreal *dy=0,mreal *dz=0)   const
        {       return mgl_data_linear_ext(this,x,y,z,dx,dy,dz);        }
        virtual mreal v(long i,long j=0,long k=0) const = 0;
-       virtual mreal vthr(long i) const = 0;
+       virtual mreal vthr(long i) const
+       {       return v(i%GetNx(), (i/GetNx())%GetNy(), i/(GetNx()*GetNy()));  }
+       virtual dual vc(long i,long j=0,long k=0) const {       return v(i,j,k);        }
+       virtual dual vcthr(long i) const        {       return vthr(i); }
        virtual long GetNx() const = 0;
        virtual long GetNy() const = 0;
        virtual long GetNz() const = 0;
@@ -236,6 +242,34 @@ public:
        /// Find if any nonzero value of formula
        inline bool FindAny(const char *cond) const
        {       return mgl_data_find_any(this,cond);    }
+
+       /// Interpolate by cubic spline the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1]
+       inline mreal Spline(mreal x,mreal y=0,mreal z=0) const
+       {       return value(x,y,z);    }
+       /// Interpolate by cubic spline the data to given point x,\a y,\a z which normalized in range [0, 1]
+       inline mreal Spline1(mreal x,mreal y=0,mreal z=0) const
+       {       return value(x*(GetNx()-1),y*(GetNy()-1),z*(GetNz()-1));        }
+       /// Interpolate by cubic spline the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1]
+       inline mreal Spline(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const
+       {       return valueD(x,y,z, &(dif.x),&(dif.y), &(dif.z));      }
+       /// Interpolate by cubic spline the data and return its derivatives at given point x,\a y,\a z which normalized in range [0, 1]
+       inline mreal Spline1(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const
+       {       mreal res=valueD(x*(GetNx()-1),y*(GetNy()-1),z*(GetNz()-1), &(dif.x),&(dif.y), &(dif.z));
+               dif.x*=GetNx()>1?GetNx()-1:1;   dif.y*=GetNy()>1?GetNy()-1:1;   dif.z*=GetNz()>1?GetNz()-1:1;   return res;     }
+
+       /// Interpolate by linear function the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1]
+       inline mreal Linear(mreal x,mreal y=0,mreal z=0)        const
+       {       return mgl_data_linear_ext(this,x,y,z,0,0,0);   }
+       /// Interpolate by line the data to given point x,\a y,\a z which normalized in range [0, 1]
+       inline mreal Linear1(mreal x,mreal y=0,mreal z=0) const
+       {       return mgl_data_linear_ext(this,x*(GetNx()-1),y*(GetNy()-1),z*(GetNz()-1),0,0,0);       }
+       /// Interpolate by linear function the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1]
+       inline mreal Linear(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const
+       {       return mgl_data_linear_ext(this,x,y,z, &(dif.x),&(dif.y), &(dif.z));    }
+       /// Interpolate by line the data and return its derivatives at given point x,\a y,\a z which normalized in range [0, 1]
+       inline mreal Linear1(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const
+       {       mreal res=mgl_data_linear_ext(this,x*(GetNx()-1),y*(GetNy()-1),z*(GetNz()-1), &(dif.x),&(dif.y), &(dif.z));
+               dif.x*=GetNx()>1?GetNx()-1:1;   dif.y*=GetNy()>1?GetNy()-1:1;   dif.z*=GetNz()>1?GetNz()-1:1;   return res;     }
 };
 //-----------------------------------------------------------------------------
 /// Structure for color ID
index 801054c22b2c22f72a771204f25c9070d026871b..2e9d98f6f0e12ca09127dcc10b4af700746ac73a 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * addon.h is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
index 8ef2c3f97f959aff197f2ba0a64756fdeee8688d..a455625c14c9cf4a1bf3cba95930a0da9771427d 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * base.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -23,8 +23,6 @@
 #include "mgl2/abstract.h"\r
 \r
 #ifdef __cplusplus\r
-#include <vector>\r
-#include <string>\r
 \r
 #if (MGL_HAVE_PTHREAD|MGL_HAVE_PTHR_WIDGET)\r
 #include <pthread.h>\r
@@ -35,9 +33,6 @@
 #else\r
 #define MGL_PUSH(a,v,m)        a.push_back(v);\r
 #endif\r
-#if MGL_HAVE_OMP\r
-#include <omp.h>\r
-#endif\r
 //-----------------------------------------------------------------------------\r
 inline mreal mgl_d(mreal v,mreal v1,mreal v2) { return v2!=v1?(v-v1)/(v2-v1):NAN; }\r
 //-----------------------------------------------------------------------------\r
@@ -59,11 +54,11 @@ public:
        mglStack(const mglStack<T> &st)\r
        {       np=st.np;       dat = (T**)malloc(np*sizeof(T*));\r
                pb=st.pb;       m=n=0;  reserve(st.n);\r
-               for(size_t i=0;i<m;i++) memcpy(dat[i],st.dat[i],(1L<<pb)*sizeof(T));\r
+               for(size_t i=0;i<m;i++) memcpy(dat[i],st.dat[i],((size_t)1<<pb)*sizeof(T));\r
                n=st.n;         mutex = 0;      }\r
        mglStack(size_t Pbuf=10)\r
        {       np=16;  pb=Pbuf;        dat = (T**)malloc(np*sizeof(T*));\r
-               dat[0] = new T[1L<<pb]; n=0;    m=1;    mutex = 0;      }\r
+               dat[0] = new T[(size_t)1<<pb];  n=0;    m=1;    mutex = 0;      }\r
        ~mglStack()     {       clear();        delete [](dat[0]);      free(dat);      }\r
        inline void set_mutex(void *m)  {       mutex = m;      }\r
        void reserve(size_t num)\r
@@ -74,30 +69,16 @@ public:
                        num = 1+ (num>>pb);\r
                        if(num>np)\r
                        {       dat = (T**)realloc(dat, num*sizeof(T*));        np=num; }\r
-                       for(size_t i=m;i<num;i++)       dat[i] = new T[1L<<pb];\r
+                       for(size_t i=m;i<num;i++)       dat[i] = new T[(size_t)1<<pb];\r
                        m = num;\r
                }\r
        }\r
        void clear()\r
        {\r
-               if(mutex)\r
-               {\r
-#if MGL_HAVE_PTHREAD\r
-                       pthread_mutex_lock((pthread_mutex_t *)mutex);\r
-#elif MGL_HAVE_OMP\r
-                       omp_set_lock((omp_lock_t *)mutex);\r
-#endif\r
-               }\r
+               if(mutex)       mgl_mutex_lock(mutex);\r
                for(size_t i=0;i<m;i++) delete [](dat[i]);\r
-               dat[0] = new T[1L<<pb]; n=0;    m=1;\r
-               if(mutex)\r
-               {\r
-#if MGL_HAVE_PTHREAD\r
-                       pthread_mutex_unlock((pthread_mutex_t *)mutex);\r
-#elif MGL_HAVE_OMP\r
-                       omp_unset_lock((omp_lock_t *)mutex);\r
-#endif\r
-               }\r
+               dat[0] = new T[(size_t)1<<pb];  n=0;    m=1;\r
+               if(mutex)       mgl_mutex_unlock(mutex);\r
        }\r
        T &operator[](size_t i) {       register size_t d=i>>pb;        return dat[d][i-(d<<pb)];       }\r
        const T &operator[](size_t i)   const   {       register size_t d=i>>pb;        return dat[d][i-(d<<pb)];       }\r
@@ -111,7 +92,7 @@ public:
        const mglStack<T> &operator=(const mglStack<T> &st)\r
        {\r
                pb=st.pb;       clear();        reserve(st.n);\r
-               for(size_t i=0;i<st.m && i<m;i++)       memcpy(dat[i],st.dat[i],(1L<<pb)*sizeof(T));\r
+               for(size_t i=0;i<st.m && i<m;i++)       memcpy(dat[i],st.dat[i],((size_t)1<<pb)*sizeof(T));\r
                n = st.n;       return st;\r
        }\r
 };\r
@@ -278,22 +259,25 @@ struct MGL_EXPORT mglGlyph
 /// Structure for texture (color scheme + palette) representation\r
 struct MGL_EXPORT mglTexture\r
 {\r
-       mglColor col[MGL_TEXTURE_COLOURS];      ///< Colors itself\r
+       mglColor *col;  ///< Colors itself\r
        long n;                         ///< Number of initial colors along u\r
 \r
        char Sch[260];          ///< Color scheme used\r
        int Smooth;                     ///< Type of texture (smoothing and so on)\r
        mreal Alpha;                    ///< Transparency\r
 \r
-       mglTexture():n(0),Smooth(0),Alpha(1)    {}\r
+       mglTexture():n(0),Smooth(0),Alpha(1)\r
+       {       col = new mglColor[MGL_TEXTURE_COLOURS];        }\r
        mglTexture(const char *cols, int smooth=0,mreal alpha=1):n(0)\r
-       {       Set(cols,smooth,alpha); }\r
+       {       col = new mglColor[MGL_TEXTURE_COLOURS];        Set(cols,smooth,alpha); }\r
        mglTexture(const mglTexture &aa) : n(aa.n),Smooth(aa.Smooth),Alpha(aa.Alpha)\r
-       {       memcpy(col,aa.col,MGL_TEXTURE_COLOURS*sizeof(mglColor));        memcpy(Sch,aa.Sch,260); }\r
+       {       col = new mglColor[MGL_TEXTURE_COLOURS];        memcpy(Sch,aa.Sch,260);\r
+               memcpy(col,aa.col,MGL_TEXTURE_COLOURS*sizeof(mglColor));        }\r
 #if MGL_HAVE_RVAL\r
        mglTexture(mglTexture &&aa) : n(aa.n),Smooth(aa.Smooth),Alpha(aa.Alpha)\r
-       {       memcpy(col,aa.col,MGL_TEXTURE_COLOURS*sizeof(mglColor));        memcpy(Sch,aa.Sch,260); }\r
+       {       col = aa.col;   memcpy(Sch,aa.Sch,260); aa.col=0;       }\r
 #endif\r
+       ~mglTexture()   {       if(col) delete []col;   }\r
        void Clear()    {       n=0;    }\r
        void Set(const char *cols, int smooth=0,mreal alpha=1);\r
        void Set(HCDT val, const char *cols);\r
@@ -323,6 +307,18 @@ struct MGL_EXPORT mglActivePos
        int n;          ///< position of active point in command (object id)\r
 };\r
 //-----------------------------------------------------------------------------\r
+#if defined(_MSC_VER)\r
+template class MGL_EXPORT mglStack<mglPnt>;\r
+template class MGL_EXPORT mglStack<mglPrim>;\r
+template class MGL_EXPORT std::vector<mglGroup>;\r
+template class MGL_EXPORT std::vector<mglText>;\r
+template class MGL_EXPORT std::vector<mglTexture>;\r
+template class MGL_EXPORT std::vector<mglGlyph>;\r
+template class MGL_EXPORT std::vector<mglBlock>;\r
+template class MGL_EXPORT std::vector<mglMatrix>;\r
+template class MGL_EXPORT mglStack<mglActivePos>;\r
+#endif\r
+//-----------------------------------------------------------------------------\r
 /// Base class for canvas which handle all basic drawing\r
 class MGL_EXPORT mglBase\r
 {\r
@@ -336,7 +332,7 @@ public:
        std::string Mess;       ///< Buffer for receiving messages\r
        int ObjId;                      ///< object id for mglPrim\r
        int HighId;                     ///< object id to be highlited\r
-       mglStack<mglGroup> Grp;         ///< List of groups with names -- need for export\r
+       std::vector<mglGroup> Grp;      ///< List of groups with names -- need for export\r
        mglStack<mglActivePos> Act;     ///< Position of active points\r
        std::string PlotId;     ///< Id of plot for saving filename (in GLUT window for example)\r
 \r
@@ -605,14 +601,12 @@ protected:
        std::vector<mglText> Ptx;       ///< Text labels for mglPrim\r
        std::vector<mglText> Leg;       ///< Text labels for legend\r
        std::vector<mglGlyph> Glf;      ///< Glyphs data\r
-       mglStack<mglTexture> Txt;       ///< Pointer to textures\r
+       std::vector<mglTexture> Txt;    ///< Pointer to textures\r
 #if MGL_HAVE_PTHREAD\r
        pthread_mutex_t mutexPnt, mutexTxt, mutexLeg, mutexGlf, mutexAct, mutexDrw;\r
        pthread_mutex_t mutexSub, mutexPrm, mutexPtx, mutexStk, mutexGrp, mutexClf;\r
 #endif\r
-#if MGL_HAVE_OMP\r
-       omp_lock_t lockClf;\r
-#endif\r
+       void *lockClf;          ///< pointer to mutex for mglStack\r
 \r
        int TernAxis;           ///< Flag that Ternary axis is used\r
        unsigned PDef;          ///< Pen bit mask\r
index 786afa48280bed78a6e38681dc82f7467a455a9a..9bcb77190827cddbd546349a38cfbd5b5f9fca4c 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * base_cf.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 924147ce0bb6c6748da354a13791b552555b2d29..d8c1db61577ece0e72d9a25d0d365b8d01c42253 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * canvas.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -99,8 +99,11 @@ struct MGL_EXPORT mglDrawDat
        std::vector<mglBlock> Sub;      ///< InPlot regions\r
        std::vector<mglText> Ptx;       ///< Text labels for mglPrim\r
        std::vector<mglGlyph> Glf;      ///< Glyphs data\r
-       mglStack<mglTexture> Txt;       ///< Pointer to textures\r
+       std::vector<mglTexture> Txt;    ///< Pointer to textures\r
 };\r
+#if defined(_MSC_VER)\r
+template class MGL_EXPORT std::vector<mglDrawDat>;\r
+#endif\r
 //-----------------------------------------------------------------------------\r
 union mglRGBA  {       uint32_t c; unsigned char r[4]; };\r
 //-----------------------------------------------------------------------------\r
@@ -143,6 +146,8 @@ using mglBase::Light;
 \r
        /// Put further plotting in cell of stick rotated on angles tet, phi\r
        void StickPlot(int num, int i, mreal tet, mreal phi);\r
+       /// Put further plotting in cell of stick sheared on sx, sy\r
+       void ShearPlot(int num, int i, mreal sx, mreal sy, mreal xd, mreal yd);\r
        /// Put further plotting in some region of whole frame surface.\r
        inline void InPlot(mreal x1,mreal x2,mreal y1,mreal y2,bool rel=true)\r
        {       InPlot(B,x1,x2,y1,y2,rel);      }\r
@@ -153,6 +158,8 @@ using mglBase::Light;
        void Title(const wchar_t *title,const char *stl="#",mreal size=-2);\r
        /// Set aspect ratio for further plotting.\r
        void Aspect(mreal Ax,mreal Ay,mreal Az);\r
+       /// Shear a further plotting.\r
+       void Shear(mreal Sx,mreal Sy);\r
        /// Rotate a further plotting.\r
        void Rotate(mreal TetX,mreal TetZ,mreal TetY=0);\r
        /// Rotate a further plotting around vector {x,y,z}.\r
index e648164e1110bef267d6b92c2b7f7b25676bd5f7..91fddea2cb8b45b1c005589419719e152ebb2ed9 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * canvas_cf.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -388,6 +388,9 @@ void MGL_EXPORT mgl_set_transp_type_(uintptr_t *gr, int *kind);
 /// Set the transparency on/off.\r
 void MGL_EXPORT mgl_set_alpha(HMGL gr, int enable);\r
 void MGL_EXPORT mgl_set_alpha_(uintptr_t *gr, int *enable);\r
+/// Set the gray-scale mode on/off.\r
+void MGL_EXPORT mgl_set_gray(HMGL gr, int enable);\r
+void MGL_EXPORT mgl_set_gray_(uintptr_t *gr, int *enable);\r
 /// Set the fog distance or switch it off (if d=0).\r
 void MGL_EXPORT mgl_set_fog(HMGL gr, double d, double dz);\r
 void MGL_EXPORT mgl_set_fog_(uintptr_t *gr, mreal *dist, mreal *dz);\r
@@ -479,6 +482,9 @@ void MGL_EXPORT mgl_gridplot_(uintptr_t *gr, int *nx, int *ny, int *m, mreal *d)
 /// Put further plotting in cell of stick rotated on angles tet, phi.\r
 void MGL_EXPORT mgl_stickplot(HMGL gr, int num, int ind, double tet, double phi);\r
 void MGL_EXPORT mgl_stickplot_(uintptr_t *gr, int *num, int *i, mreal *tet, mreal *phi);\r
+/// Put further plotting in cell of stick sheared on sx, sy.\r
+void MGL_EXPORT mgl_shearplot(HMGL gr, int num, int ind, double sx, double sy, double xd, double yd);\r
+void MGL_EXPORT mgl_shearplot_(uintptr_t *gr, int *num, int *i, mreal *sy, mreal *sx, mreal *xd, mreal *yd);\r
 /// Add title for current subplot/inplot.\r
 /** Style '#' draw box around the title. */\r
 void MGL_EXPORT mgl_title(HMGL gr, const char *title, const char *stl, double size);\r
@@ -491,6 +497,9 @@ void MGL_EXPORT mgl_set_plotfactor_(uintptr_t *gr, mreal *val);
 /// Set aspect ratio for further plotting.\r
 void MGL_EXPORT mgl_aspect(HMGL gr, double Ax,double Ay,double Az);\r
 void MGL_EXPORT mgl_aspect_(uintptr_t *gr, mreal *Ax, mreal *Ay, mreal *Az);\r
+/// Set aspect ratio for further plotting.\r
+void MGL_EXPORT mgl_shear(HMGL gr, double Sx,double Sz);\r
+void MGL_EXPORT mgl_shear_(uintptr_t *gr, mreal *Sx, mreal *Sy);\r
 /// Rotate a further plotting.\r
 void MGL_EXPORT mgl_rotate(HMGL gr, double TetX,double TetZ,double TetY);\r
 void MGL_EXPORT mgl_rotate_(uintptr_t *gr, mreal *TetX, mreal *TetZ, mreal *TetY);\r
@@ -641,6 +650,9 @@ void MGL_EXPORT mgl_parser_allow_dll_call_(uintptr_t* p, int *a);
 /// Set flag to stop script parsing\r
 void MGL_EXPORT mgl_parser_stop(HMPR p);\r
 void MGL_EXPORT mgl_parser_stop_(uintptr_t* p);\r
+/// Set variant of argument(s) separated by '?' to be used\r
+void MGL_EXPORT mgl_parser_variant(HMPR p, int var);\r
+void MGL_EXPORT mgl_parser_variant_(uintptr_t* p, int *var);\r
 \r
 /// Return type of command: 0 - not found, 1 - data plot, 2 - other plot,\r
 ///            3 - setup, 4 - data handle, 5 - data create, 6 - subplot, 7 - program\r
index b157d6dbe75bbb53f2f023afdd466950b011b01d..19091edaccadcdbef3c166c260e62167a587be40 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * canvas_wnd.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index a0367df30acca1300d84812027f4261037450e9d..bd3b91c201ae1f0c2af4a9188beecc98e66a5f50 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * cont.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 834ca26b0d87fc938bcef49a9ab1100d93e0ed40..462ec83483d2eb33a803bb4e5e279a961518ea85 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * data.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -23,8 +23,6 @@
 #include "mgl2/data_cf.h"\r
 #include "mgl2/pde.h"\r
 //-----------------------------------------------------------------------------\r
-#include <vector>\r
-#include <string>\r
 #include <stdarg.h>\r
 //-----------------------------------------------------------------------------\r
 mreal MGL_EXPORT mglLinear(const mreal *a, long nx, long ny, long nz, mreal x, mreal y, mreal z);\r
@@ -135,9 +133,9 @@ using mglDataA::Momentum;
        {       if(d.size()>0)  {       Create(d.size());       for(long i=0;i<nx;i++)  a[i] = d[i];    }\r
                else    Create(1);      }\r
        inline void Set(const std::vector<float> &d)\r
-       {       if(d.size()>0)  Set(&(a[0]),d.size());  else    Create(1);      }\r
+       {       if(d.size()>0)  Set(&(d[0]),d.size());  else    Create(1);      }\r
        inline void Set(const std::vector<double> &d)\r
-       {       if(d.size()>0)  Set(&(a[0]),d.size());  else    Create(1);      }\r
+       {       if(d.size()>0)  Set(&(d[0]),d.size());  else    Create(1);      }\r
        /// Allocate memory and set data from variable argument list of double values\r
        inline void SetList(long n, ...)\r
        {\r
@@ -364,6 +362,9 @@ using mglDataA::Momentum;
        /// Normalize the data to range [v1,v2] slice by slice\r
        inline void NormSl(mreal v1=0,mreal v2=1,char dir='z',bool keep_en=true,bool sym=false)\r
        {       mgl_data_norm_slice(this,v1,v2,dir,keep_en,sym);        }\r
+       /// Limit the data to be inside [-v,v], keeping the original sign\r
+       inline void Limit(mreal v)\r
+       {       mgl_data_limit(this, v);        }\r
 \r
        /// Apply Hankel transform\r
        inline void Hankel(const char *dir)     {       mgl_data_hankel(this,dir);      }\r
@@ -392,34 +393,6 @@ using mglDataA::Momentum;
        inline mglData Solve(mreal val, char dir, const mglData &i0, bool norm=true) const\r
        {       return mglData(true,mgl_data_solve(this, val, dir, &i0, norm)); }\r
 \r
-       /// Interpolate by cubic spline the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1]\r
-       inline mreal Spline(mreal x,mreal y=0,mreal z=0) const\r
-       {       return value(x,y,z);    }\r
-       /// Interpolate by cubic spline the data to given point x,\a y,\a z which normalized in range [0, 1]\r
-       inline mreal Spline1(mreal x,mreal y=0,mreal z=0) const\r
-       {       return value(x*(nx-1),y*(ny-1),z*(nz-1));       }\r
-       /// Interpolate by linear function the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1]\r
-       inline mreal Linear(mreal x,mreal y=0,mreal z=0)        const\r
-       {       return mgl_data_linear_ext(this,x,y,z,0,0,0);   }\r
-       /// Interpolate by line the data to given point x,\a y,\a z which normalized in range [0, 1]\r
-       inline mreal Linear1(mreal x,mreal y=0,mreal z=0) const\r
-       {       return mgl_data_linear_ext(this,x*(nx-1),y*(ny-1),z*(nz-1),0,0,0);      }\r
-\r
-       /// Interpolate by cubic spline the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1]\r
-       inline mreal Spline(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const\r
-       {       return valueD(x,y,z, &(dif.x),&(dif.y), &(dif.z));      }\r
-       /// Interpolate by cubic spline the data and return its derivatives at given point x,\a y,\a z which normalized in range [0, 1]\r
-       inline mreal Spline1(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const\r
-       {       mreal res=valueD(x*(nx-1),y*(ny-1),z*(nz-1), &(dif.x),&(dif.y), &(dif.z));\r
-               dif.x*=nx>1?nx-1:1;     dif.y*=ny>1?ny-1:1;     dif.z*=nz>1?nz-1:1;     return res;     }\r
-       /// Interpolate by linear function the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1]\r
-       inline mreal Linear(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const\r
-       {       return mgl_data_linear_ext(this,x,y,z, &(dif.x),&(dif.y), &(dif.z));    }\r
-       /// Interpolate by line the data and return its derivatives at given point x,\a y,\a z which normalized in range [0, 1]\r
-       inline mreal Linear1(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const\r
-       {       mreal res=mgl_data_linear_ext(this,x*(nx-1),y*(ny-1),z*(nz-1), &(dif.x),&(dif.y), &(dif.z));\r
-               dif.x*=nx>1?nx-1:1;     dif.y*=ny>1?ny-1:1;     dif.z*=nz>1?nz-1:1;     return res;     }\r
-\r
        /// Copy data from other mglData variable\r
        inline const mglDataA &operator=(const mglDataA &d)\r
        {       if(this!=&d)    mgl_data_set(this,&d);  return d;       }\r
@@ -542,6 +515,16 @@ inline mglData mglRay(const char *ham, mglPoint r0, mglPoint p0, mreal dt=0.1, m
 /// Saves result of ODE solving (|u|^2) for "Hamiltonian" ham with initial conditions ini\r
 inline mglData mglODE(const char *df, const char *var, const mglDataA &ini, mreal dt=0.1, mreal tmax=10)\r
 {      return mglData(true, mgl_ode_solve_str(df,var, &ini, dt, tmax));        }\r
+//-----------------------------------------------------------------------------\r
+/// Get array as solution of tridiagonal system of equations a[i]*x[i-1]+b[i]*x[i]+c[i]*x[i+1]=d[i]\r
+/** String \a how may contain:\r
+ * 'x', 'y', 'z' for solving along x-,y-,z-directions, or\r
+ * 'h' for solving along hexagonal direction at x-y plain (need nx=ny),\r
+ * 'c' for using periodical boundary conditions,\r
+ * 'd' for diffraction/diffuse calculation. */\r
+inline mglData mglTridMat(const mglDataA &A, const mglDataA &B, const mglDataA &C, const mglDataA &D, const char *how)\r
+{      return mglData(true, mgl_data_tridmat(&A, &B, &C, &D, how));    }\r
+//-----------------------------------------------------------------------------\r
 /// Calculate Jacobian determinant for D{x(u,v), y(u,v)} = dx/du*dy/dv-dx/dv*dy/du\r
 inline mglData mglJacobian(const mglDataA &x, const mglDataA &y)\r
 {      return mglData(true, mgl_jacobian_2d(&x, &y));  }\r
@@ -559,6 +542,16 @@ inline mglData mglIFS2d(const mglDataA &A, long n, long skip=20)
 /// Get array which is n-th points {x[i],y[i],z[i]} for iterated function system (fractal) generated by A\r
 inline mglData mglIFS3d(const mglDataA &A, long n, long skip=20)\r
 {      return mglData(true,mgl_data_ifs_3d(&A,n,skip));        }\r
+/// Get array which is n-th points {x[i],y[i],z[i]} for iterated function system (fractal) defined in *.ifs file 'fname' and named as 'name'\r
+inline mglData mglIFSfile(const char *fname, const char *name, long n, long skip=20)\r
+{      return mglData(true,mgl_data_ifs_file(fname,name,n,skip));      }\r
+/// Get array which is n-th pairs {x[i],y[i]} for flame fractal generated by A with functions F\r
+/// Get array which is n-th pairs {x[i],y[i]} for Flame fractal generated by A with functions F\r
+/** NOTE: A.nx must be >= 7 and F.nx >= 2 and F.nz=A.ny.\r
+ * F[0,i,j] denote function id. F[1,i,j] give function weight, F(2:5,i,j) provide function parameters.\r
+ * Resulting point is {xnew,ynew} = sum_i F[1,i,j]*F[0,i,j]{IFS2d(A[j]){x,y}}. */\r
+inline mglData mglFlame2d(const mglDataA &A, const mglDataA &F, long n, long skip=20)\r
+{      return mglData(true,mgl_data_flame_2d(&A,&F,n,skip));   }\r
 //-----------------------------------------------------------------------------\r
 /// Get sub-array of the data with given fixed indexes\r
 inline mglData mglSubData(const mglDataA &dat, long xx, long yy=-1, long zz=-1)\r
@@ -882,10 +875,10 @@ public:
        {       ind = i;        s = name;       }\r
 \r
        /// Get the interpolated value and its derivatives in given data cell without border checking\r
-       mreal valueD(mreal x,mreal y=0,mreal z=0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const\r
+       mreal valueD(mreal x,mreal y=0,mreal =0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const\r
        {       if(dz)  *dz=0;  return dat.valueD(ind,x,y,0,dx,dy);     }\r
        /// Get the interpolated value in given data cell without border checking\r
-       mreal value(mreal x,mreal y=0,mreal z=0) const\r
+       mreal value(mreal x,mreal y=0,mreal =0) const\r
        {       return dat.value(ind,x,y);      }\r
        /// Get the value in given cell of the data without border checking\r
        mreal v(long i,long j=0,long =0) const\r
@@ -929,10 +922,10 @@ public:
        {       ind = i;        s = name;       }\r
 \r
        /// Get the interpolated value and its derivatives in given data cell without border checking\r
-       mreal valueD(mreal x,mreal y=0,mreal z=0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const\r
+       mreal valueD(mreal x,mreal =0,mreal =0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const\r
        {       if(dy)  *dy=0;  if(dz)  *dz=0;  return dat.valueD(x,ind,0,dx);  }\r
        /// Get the interpolated value in given data cell without border checking\r
-       mreal value(mreal x,mreal y=0,mreal z=0) const\r
+       mreal value(mreal x,mreal =0,mreal =0) const\r
        {       return dat.value(x,ind,0);      }\r
        /// Get the value in given cell of the data without border checking\r
        mreal v(long i,long =0,long =0) const\r
@@ -940,9 +933,9 @@ public:
        mreal vthr(long i) const\r
        {       return dat.vthr(i+dat.GetNx()*ind);     }\r
        // add for speeding up !!!\r
-       mreal dvx(long i,long j=0,long =0) const\r
+       mreal dvx(long i,long =0,long =0) const\r
        {       return  dat.dvx(i,ind,0);       }\r
-       mreal dvy(long i,long j=0,long =0) const\r
+       mreal dvy(long ,long =0,long =0) const\r
        {       return 0;       }\r
        mreal dvz(long ,long =0,long =0) const\r
        {       return 0;       }\r
@@ -967,21 +960,21 @@ public:
        const std::vector<mreal> &operator=(const std::vector<mreal> &st)       {       dat = st;       return st;      }\r
 \r
        /// Get the interpolated value and its derivatives in given data cell without border checking\r
-       mreal valueD(mreal x,mreal y=0,mreal z=0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const\r
+       mreal valueD(mreal x,mreal =0,mreal =0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const\r
        {       return mglSpline3(dat.data(),dat.size(),1,1,x,0,0,dx,dy,dz);    }\r
        /// Get the interpolated value in given data cell without border checking\r
-       mreal value(mreal x,mreal y=0,mreal z=0) const\r
+       mreal value(mreal x,mreal =0,mreal =0) const\r
        {       return mglSpline3s(dat.data(),dat.size(),1,1,x,0,0);    }\r
 \r
-       mreal v(long i,long j=0,long k=0) const         {       return dat[i];  }\r
+       mreal v(long i,long =0,long =0) const           {       return dat[i];  }\r
        mreal vthr(long i) const        {       return dat[i];  };\r
        long GetNx() const      {       return dat.size();      }\r
        long GetNy() const      {       return 1;       }\r
        long GetNz() const      {       return 1;       }\r
-       mreal dvx(long i,long j=0,long k=0) const\r
+       mreal dvx(long i,long =0,long =0) const\r
        {       return i>0? (i<long(dat.size()-1)? (dat[i+1]-dat[i-1])/2:dat[i]-dat[i-1]) : dat[i+1]-dat[i];    }\r
-       mreal dvy(long i,long j=0,long k=0) const       {       return 1;       }\r
-       mreal dvz(long i,long j=0,long k=0) const       {       return 1;       }\r
+       mreal dvy(long ,long =0,long =0) const  {       return 1;       }\r
+       mreal dvz(long ,long =0,long =0) const  {       return 1;       }\r
 };\r
 //-----------------------------------------------------------------------------\r
 #endif\r
index b7ae601dad5fd92675fb197b043deb6417e1562f..05e5f3b193f1e83e89b4f5d58275a064f855f6e7 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * data_cf.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -133,11 +133,14 @@ void MGL_EXPORT mgl_data_create_(uintptr_t *dat, int *nx,int *ny,int *nz);
 void MGL_EXPORT mgl_data_transpose(HMDT dat, const char *dim);\r
 void MGL_EXPORT mgl_data_transpose_(uintptr_t *dat, const char *dim,int);\r
 /// Normalize the data to range [v1,v2]\r
-void MGL_EXPORT mgl_data_norm(HMDT dat, mreal v1,mreal v2,long sym,long dim);\r
+void MGL_EXPORT mgl_data_norm(HMDT dat, mreal v1,mreal v2,int sym,long dim);\r
 void MGL_EXPORT mgl_data_norm_(uintptr_t *dat, mreal *v1,mreal *v2,int *sym,int *dim);\r
 /// Normalize the data to range [v1,v2] slice by slice\r
 void MGL_EXPORT mgl_data_norm_slice(HMDT dat, mreal v1,mreal v2,char dir,long keep_en,long sym);\r
 void MGL_EXPORT mgl_data_norm_slice_(uintptr_t *dat, mreal *v1,mreal *v2,char *dir,int *keep_en,int *sym,int l);\r
+/// Limit the data to be inside [-v,v], keeping the original sign\r
+void MGL_EXPORT mgl_data_limit(HMDT dat, mreal v);\r
+void MGL_EXPORT mgl_data_limit_(uintptr_t *dat, mreal *v);\r
 /// Get sub-array of the data with given fixed indexes\r
 HMDT MGL_EXPORT mgl_data_subdata(HCDT dat, long xx,long yy,long zz);\r
 uintptr_t MGL_EXPORT mgl_data_subdata_(uintptr_t *dat, int *xx,int *yy,int *zz);\r
@@ -201,6 +204,39 @@ uintptr_t MGL_EXPORT mgl_data_ifs_2d_(uintptr_t *A, long *n, long *skip);
 /** NOTE: A.nx must be >= 13. */\r
 HMDT MGL_EXPORT mgl_data_ifs_3d(HCDT A, long n, long skip);\r
 uintptr_t MGL_EXPORT mgl_data_ifs_3d_(uintptr_t *A, long *n, long *skip);\r
+/// Get array which is n-th points {x[i],y[i],z[i]} for iterated function system (fractal) defined in *.ifs file 'fname' and named as 'name'\r
+HMDT MGL_EXPORT mgl_data_ifs_file(const char *fname, const char *name, long n, long skip);\r
+uintptr_t mgl_data_ifs_file_(const char *fname, const char *name, long *n, long *skip,int l,int m);\r
+/// Codes for flame fractal functions\r
+enum {\r
+       mglFlameLinear=0,               mglFlameSin,                    mglFlameSphere,         mglFlameSwirl,          mglFlameHorseshoe,\r
+       mglFlamePolar,                  mglFlameHandkerchief,   mglFlameHeart,          mglFlameDisk,           mglFlameSpiral,\r
+       mglFlameHyperbolic,             mglFlameDiamond,                mglFlameEx,                     mglFlameJulia,          mglFlameBent,\r
+       mglFlameWaves,                  mglFlameFishEye,                mglFlamePopcorn,        mglFlameExponent,       mglFlamePower,\r
+       mglFlameCos,                    mglFlameRings,                  mglFlameFan,            mglFlameBlob,           mglFlamePdj,\r
+       mglFlameFan2,                   mglFlameRings2,                 mglFlameEyefish,        mglFlameBubble,         mglFlameCylinder,\r
+       mglFlamePerspective,    mglFlameNoise,                  mglFlameJuliaN,         mglFlameJuliaScope,     mglFlameBlur,\r
+       mglFlameGaussian,               mglFlameRadialBlur,             mglFlamePie,            mglFlameNgon,           mglFlameCurl,\r
+       mglFlameRectangles,             mglFlameArch,                   mglFlameTangent,        mglFlameSquare,         mglFlameRays,\r
+       mglFlameBlade,                  mglFlameSecant,                 mglFlameTwintrian,      mglFlameCross,          mglFlameLAST\r
+};\r
+/// Get array which is n-th pairs {x[i],y[i]} for Flame fractal generated by A with functions F\r
+/** NOTE: A.nx must be >= 7 and F.nx >= 2 and F.nz=A.ny.\r
+ * F[0,i,j] denote function id. F[1,i,j] give function weight. F(2:5,i,j) provide function parameters.\r
+ * Resulting point is {xnew,ynew} = sum_i F[1,i,j]*F[0,i,j]{IFS2d(A[j]){x,y}}. */\r
+HMDT MGL_EXPORT mgl_data_flame_2d(HCDT A, HCDT F, long n, long skip);\r
+uintptr_t MGL_EXPORT mgl_data_flame_2d_(uintptr_t *A, uintptr_t *F, long *n, long *skip);\r
+\r
+\r
+/// Get array as solution of tridiagonal matrix solution a[i]*x[i-1]+b[i]*x[i]+c[i]*x[i+1]=d[i]\r
+/** String \a how may contain:\r
+ * 'x', 'y', 'z' for solving along x-,y-,z-directions, or\r
+ * 'h' for solving along hexagonal direction at x-y plain (need nx=ny),\r
+ * 'c' for using periodical boundary conditions,\r
+ * 'd' for diffraction/diffuse calculation.\r
+ * NOTE: It work for flat data model only (i.e. for a[i,j]==a[i+nx*j]) */\r
+HMDT MGL_EXPORT mgl_data_tridmat(HCDT A, HCDT B, HCDT C, HCDT D, const char *how);\r
+uintptr_t MGL_EXPORT mgl_data_tridmat_(uintptr_t *A, uintptr_t *B, uintptr_t *C, uintptr_t *D, const char *how, int);\r
 \r
 /// Returns pointer to data element [i,j,k]\r
 MGL_EXPORT mreal *mgl_data_value(HMDT dat, long i,long j,long k);\r
index c3687fa64836401b34d95de8db2081aa97e5b54f..39670ccd483ce4012afb68c29d8def7d7658d3ff 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * datac.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -354,6 +354,9 @@ using mglDataA::Momentum;
         *  By default quadratic averaging over 5 points is used. */\r
        inline void Smooth(const char *dirs="xyz",mreal delta=0)\r
        {       mgl_datac_smooth(this,dirs,delta);      }\r
+       /// Limit the data to be inside [-v,v], keeping the original sign\r
+       inline void Limit(mreal v)\r
+       {       mgl_datac_limit(this, v);       }\r
 \r
        /// Hankel transform\r
        inline void Hankel(const char *dir)     {       mgl_datac_hankel(this,dir);     }\r
@@ -445,6 +448,9 @@ using mglDataA::Momentum;
        /// Set the value in given cell of the data\r
        void set_v(mreal val, long i,long j=0,long k=0) {       mgl_datac_set_value(this,val,i,j,k);    }\r
 #endif\r
+       /// Get the complex value in given cell of the data\r
+       dual vc(long i,long j=0,long k=0) const {       return a[i+nx*(j+ny*k)];        }\r
+       dual vcthr(long i) const        {       return a[i];    }\r
        /// Get the interpolated value and its derivatives in given data cell without border checking\r
        mreal valueD(mreal x,mreal y=0,mreal z=0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const\r
        {       dual aa,ax,ay,az;       mreal res;\r
@@ -482,6 +488,15 @@ inline mglDataC mglQO3dc(const char *ham, const mglDataA &ini_re, const mglDataA
 inline mglDataC mglQO3dc(const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mglData &xx, mglData &yy, mglData &zz, mreal r=1, mreal k0=100)\r
 {      return mglDataC(true, mgl_qo3d_solve_c(ham, &ini_re, &ini_im, &ray, r, k0, &xx, &yy, &zz));     }\r
 //-----------------------------------------------------------------------------\r
+/// Get array as solution of tridiagonal system of equations a[i]*x[i-1]+b[i]*x[i]+c[i]*x[i+1]=d[i]\r
+/** String \a how may contain:\r
+ * 'x', 'y', 'z' for solving along x-,y-,z-directions, or\r
+ * 'h' for solving along hexagonal direction at x-y plain (need nx=ny),\r
+ * 'c' for using periodical boundary conditions,\r
+ * 'd' for diffraction/diffuse calculation. */\r
+inline mglDataC mglTridMatC(const mglDataA &A, const mglDataA &B, const mglDataA &C, const mglDataC &D, const char *how)\r
+{      return mglDataC(true, mgl_datac_tridmat(&A, &B, &C, &D, how));  }\r
+//-----------------------------------------------------------------------------\r
 /// Get sub-array of the data with given fixed indexes\r
 inline mglDataC mglSubDataC(const mglDataA &dat, long xx, long yy=-1, long zz=-1)\r
 {      return mglDataC(true,mgl_datac_subdata(&dat,xx,yy,zz)); }\r
index 1383e84e21979777a3a8b1c3d1d5e4a06e34c873..b6f5ad2f059a445d771825cd5854c12798f7db37 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * data_cf.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -88,6 +88,16 @@ mdual MGL_EXPORT mgl_datac_get_value_(uintptr_t *d, int *i, int *j, int *k);
 void MGL_EXPORT mgl_datac_set_values(HADT dat, const char *val, long nx, long ny, long nz);\r
 void MGL_EXPORT mgl_datac_set_values_(uintptr_t *d, const char *val, int *nx, int *ny, int *nz, int l);\r
 \r
+/// Get array as solution of tridiagonal matrix solution a[i]*x[i-1]+b[i]*x[i]+c[i]*x[i+1]=d[i]\r
+/** String \a how may contain:\r
+ * 'x', 'y', 'z' for solving along x-,y-,z-directions, or\r
+ * 'h' for solving along hexagonal direction at x-y plain (need nx=ny),\r
+ * 'c' for using periodical boundary conditions,\r
+ * 'd' for diffraction/diffuse calculation.\r
+ * NOTE: It work for flat data model only (i.e. for a[i,j]==a[i+nx*j]) */\r
+HADT MGL_EXPORT mgl_datac_tridmat(HCDT A, HCDT B, HCDT C, HCDT D, const char *how);\r
+uintptr_t MGL_EXPORT mgl_datac_tridmat_(uintptr_t *A, uintptr_t *B, uintptr_t *C, uintptr_t *D, const char *how, int);\r
+\r
 /// Returns pointer to internal data array\r
 MGL_EXPORT dual *mgl_datac_data(HADT dat);\r
 /// Returns pointer to data element [i,j,k]\r
@@ -196,6 +206,10 @@ void MGL_EXPORT mgl_datac_modify_(uintptr_t *dat, const char *eq,int *dim,int);
 void MGL_EXPORT mgl_datac_modify_vw(HADT dat, const char *eq,HCDT vdat,HCDT wdat);\r
 void MGL_EXPORT mgl_datac_modify_vw_(uintptr_t *dat, const char *eq, uintptr_t *vdat, uintptr_t *wdat,int);\r
 \r
+/// Limit the data to be inside [-v,v], keeping the original sign\r
+void MGL_EXPORT mgl_datac_limit(HADT dat, mreal v);\r
+void MGL_EXPORT mgl_datac_limit_(uintptr_t *dat, mreal *v);\r
+\r
 /// Put value to data element(s)\r
 void MGL_EXPORT mgl_datac_put_val(HADT dat, dual val, long i, long j, long k);\r
 void MGL_EXPORT mgl_datac_put_val_(uintptr_t *dat, dual *val, int *i, int *j, int *k);\r
index ada4ce50aafd39c38a50f681415a8032d0af84b4..8a753852e792046e602d714eb82017cc9d760cf9 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * define.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
 #ifndef _MGL_DEFINE_H_\r
 #define _MGL_DEFINE_H_\r
 //-----------------------------------------------------------------------------\r
+// Disable warnings for MSVC:\r
+// 4190 - C-linkage of std::complex,\r
+// 4996 - deprecated abi functions\r
+// 4786 - disable warnings on 255 char debug symbols\r
+// 4231 - disable warnings on extern before template instantiation\r
+// 4800        - "int,uint32_t,etc" forcing value to bool 'true' or 'false' (performance warning)\r
+// 4244 - conversion from 'mreal,double' to 'float', possible loss of data\r
+// 4267        - conversion from 'size_t' to 'long,int,etc', possible loss of data\r
+// 4305        - truncation from 'double' to 'float'\r
+#if defined(_MSC_VER)\r
+#pragma warning(disable: 4996 4190 4786 4231 4800 4244 4267 4305)\r
+#endif\r
+\r
 #include "mgl2/config.h"\r
 #ifndef SWIG\r
 \r
 #endif\r
 \r
 #include "mgl2/dllexport.h"\r
+#if defined(_MSC_VER)\r
+#define MGL_OBSOLETE   MGL_NO_EXPORT\r
+#else\r
+#define MGL_OBSOLETE   MGL_EXPORT\r
+#endif\r
+\r
 #if MGL_HAVE_ATTRIBUTE\r
 #define MGL_FUNC_CONST __attribute__((const))\r
 #define MGL_FUNC_PURE  __attribute__((pure))\r
@@ -92,8 +111,8 @@ typedef unsigned long uintptr_t;
 #include <wchar.h>\r
 \r
 #if defined(_MSC_VER)\r
-#if (_MSC_VER<=1800)\r
 #define collapse(a)    // MSVS don't support OpenMP 3.*\r
+#if (_MSC_VER<=1800)\r
 #define strtoull _strtoui64\r
 //#define hypot        _hypot\r
 #define getcwd _getcwd\r
@@ -267,6 +286,7 @@ extern uint64_t mgl_mask_val[16];
 #define MGL_PREFERVC           0x040000        ///< Prefer vertex color instead of texture if output format supports\r
 #define MGL_ONESIDED           0x080000        ///< Render only front side of surfaces if output format supports (for debugging)\r
 #define MGL_NO_ORIGIN          0x100000        ///< Don't draw tick labels at axis origin\r
+#define MGL_GRAY_MODE          0x100000        ///< Convert all colors to gray ones\r
 //-----------------------------------------------------------------------------\r
 #if MGL_HAVE_C99_COMPLEX\r
 #include <complex.h>\r
@@ -282,10 +302,26 @@ const mdual mgl_I=_Complex_I;
 #define mgl_abs(x)     cabs(x)\r
 #endif\r
 #ifdef __cplusplus\r
+#include <string>\r
+#include <vector>\r
+#if defined(_MSC_VER)\r
+template class MGL_EXPORT std::allocator<char>;\r
+template class MGL_EXPORT std::allocator<wchar_t>;\r
+template struct MGL_EXPORT std::char_traits<char>;\r
+template struct MGL_EXPORT std::char_traits<wchar_t>;\r
+template class MGL_EXPORT std::basic_string< char, std::char_traits<char>, std::allocator<char> >;\r
+template class MGL_EXPORT std::basic_string< wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >;\r
+template class MGL_EXPORT std::vector<long>;\r
+template class MGL_EXPORT std::vector<mreal>;\r
+#endif\r
 //-----------------------------------------------------------------------------\r
 extern float mgl_cos[360];     ///< contain cosine with step 1 degree\r
 //-----------------------------------------------------------------------------\r
 #include <complex>\r
+#if defined(_MSC_VER)\r
+template class MGL_EXPORT std::complex<float>;\r
+template class MGL_EXPORT std::complex<double>;\r
+#endif\r
 typedef std::complex<mreal> dual;\r
 typedef std::complex<double> ddual;\r
 #if !MGL_HAVE_C99_COMPLEX\r
index 9043ccf4ece58987947d3fe45e35e6a7aa57a884..920c0c707d2c7f7d529ea89e2e89c099a18870e0 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * eval.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 202ca81badaa07db24838e40321e323b5ba5dfae..36dbeef5323ab993a4348c102bcd4bc1b4aefd3b 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * evalc.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 82e3144b753276ee706e301eee6efd0c81edd911..5f6f2e20bc200b5fc3bd1cc17292825cc0419b09 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * fit.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 129ac08e5b0712b82c66cda80917df6355e051f9..9d4a223362cb145a8af36a9f2f99030d970fddf3 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * fltk.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -35,6 +35,8 @@ int MGL_EXPORT mgl_fltk_run_();
 int MGL_EXPORT mgl_fltk_thr();\r
 /// Callback function for asking user.\r
 void MGL_EXPORT mgl_ask_fltk(const wchar_t *quest, wchar_t *res);\r
+/// Return pointer to widget (Fl_MGLView*) used for plotting\r
+MGL_EXPORT void *mgl_fltk_widget(HMGL gr);\r
 #ifdef __cplusplus\r
 }\r
 //-----------------------------------------------------------------------------\r
@@ -43,7 +45,7 @@ void MGL_EXPORT mgl_ask_fltk(const wchar_t *quest, wchar_t *res);
 /// Wrapper class for windows displaying graphics\r
 class MGL_EXPORT mglFLTK : public mglWnd\r
 {\r
-       mglFLTK(const mglFLTK &t) {}    // copying is not allowed\r
+       mglFLTK(const mglFLTK &) {}     // copying is not allowed\r
        const mglFLTK &operator=(const mglFLTK &t)      {       return t;       }\r
 public:\r
        mglFLTK(const char *title="MathGL") : mglWnd()\r
@@ -61,6 +63,8 @@ public:
     virtual ~mglFLTK() {}\r
        int Run()       {       return mgl_fltk_run();  }       ///< Run main loop for event handling\r
        int RunThr()    {       return mgl_fltk_thr();  }       ///< Run main loop for event handling in separate thread\r
+       /// Return pointer to widget (Fl_MGLView*) used for plotting\r
+       void *Widget()  {       return mgl_fltk_widget(gr);     }\r
 };\r
 //-----------------------------------------------------------------------------\r
 #endif\r
index 3bb937cc3c96e13ff46c35ee7379fbe3eb088da0..8c0abdb5cfb618bf1b8a4fd9392eb6d27fc31cc5 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * font.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -22,7 +22,6 @@
 #define _MGL_FONT_H_\r
 \r
 #include "mgl2/define.h"\r
-#include <vector>\r
 //-----------------------------------------------------------------------------\r
 #define MGL_FONT_BOLD          0x01000000      // This value is used binary\r
 #define MGL_FONT_ITAL          0x02000000      // This value is used binary\r
@@ -50,6 +49,9 @@ struct mglGlyphDescr
 };\r
 inline bool operator<(const mglGlyphDescr &a,const mglGlyphDescr &b)   {       return a.id<b.id;       }\r
 inline bool operator>(const mglGlyphDescr &a,const mglGlyphDescr &b)   {       return a.id>b.id;       }\r
+#if defined(_MSC_VER)\r
+template class MGL_EXPORT std::vector<mglGlyphDescr>;\r
+#endif\r
 //-----------------------------------------------------------------------------\r
 struct MGL_EXPORT mglTeXsymb   {       unsigned kod;   const wchar_t *tex;     };\r
 const float mgl_fgen = 4*14;\r
index 11fb0d50a77bff6327286bb219f6cee01f15b0bc..83c345ced8eb0afd6e18e6e5ce3c47d5d64cf1f3 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * glut.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -51,7 +51,7 @@ void MGL_EXPORT mgl_glut_animation(HMGL gr);
 //-----------------------------------------------------------------------------\r
 class MGL_EXPORT mglGLUT: public mglGraph\r
 {\r
-       mglGLUT(const mglGLUT &t) {}    // copying is not allowed\r
+       mglGLUT(const mglGLUT &) {}     // copying is not allowed\r
        const mglGLUT &operator=(const mglGLUT &t)      {       return t;       }\r
 public:\r
        mglGLUT(int (*draw)(HMGL gr, void *p), const char *title="MathGL", void *par=0, void (*load)(void *p)=0) : mglGraph(-1)\r
index 993596a7fabd2cca4b5fe1070522a27faebdddd2..023cd849b7ce5c43ef00000c9ad169c669c141ef 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * mgl.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\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
@@ -29,7 +29,7 @@
 /// Wrapper class for all graphics\r
 class MGL_EXPORT mglGraph\r
 {\r
-       mglGraph(const mglGraph &t) {}  // copying is not allowed\r
+       mglGraph(const mglGraph &) {}   // copying is not allowed\r
        const mglGraph &operator=(const mglGraph &t)    {       return t;       }\r
 protected:\r
        HMGL gr;\r
@@ -69,6 +69,8 @@ public:
 \r
        /// Set the transparency on/off.\r
        inline void Alpha(bool enable)                  {       mgl_set_alpha(gr, enable);      }\r
+       /// Set the gray-scale mode on/off.\r
+       inline void Gray(bool enable)                   {       mgl_set_gray(gr, enable);       }\r
        /// Set default value of alpha-channel\r
        inline void SetAlphaDef(double alpha)   {       mgl_set_alpha_default(gr, alpha);       }\r
        /// Set the transparency type (0 - usual, 1 - glass, 2 - lamp)\r
@@ -304,6 +306,9 @@ public:
        /// Put further plotting in cell of stick rotated on angles tet, phi\r
        inline void StickPlot(int num, int i, double tet, double phi)\r
        {       mgl_stickplot(gr,num,i,tet,phi);        }\r
+       /// Put further plotting in cell of stick sheared on sx, sy.\r
+       inline void ShearPlot(int num, int i, mreal sx, mreal sy, mreal xd=1, mreal yd=0)\r
+       {       mgl_shearplot(gr,num,i,sx,sy,xd,yd);    }\r
 \r
        /// Set factor of plot size\r
        inline void SetPlotFactor(double val)\r
@@ -324,6 +329,9 @@ public:
        /// Set aspect ratio for further plotting.\r
        inline void Aspect(double Ax,double Ay,double Az=1)\r
        {       mgl_aspect(gr, Ax, Ay, Az);             }\r
+       /// Shear a further plotting.\r
+       inline void Shear(double Sx,double Sy)\r
+       {       mgl_shear(gr, Sx, Sy);          }\r
        /// Rotate a further plotting.\r
        inline void Rotate(double TetX,double TetZ=0,double TetY=0)\r
        {       mgl_rotate(gr, TetX, TetZ, TetY);       }\r
@@ -2204,7 +2212,10 @@ public:
        inline void AllowDllCall(bool allow)    {       mgl_parser_allow_dll_call(pr, allow);   }\r
        /// Set flag to stop script parsing\r
        inline void Stop()      {       mgl_parser_stop(pr);    }\r
-\r
+       /// Set variant of argument(s) separated by '?' to be used in further commands\r
+       inline void SetVariant(int var=0)\r
+       {       mgl_parser_variant(pr, var);    }\r
+       \r
        /// Return result of formula evaluation\r
        inline mglData Calc(const char *formula)\r
        {       return mglData(true,mgl_parser_calc(pr,formula));       }\r
index a0d0080f5d25cc1cdabf55c8d9ace9edbaffd67f..66d3f16f35d37bd99d019b35a19d21a65130449a 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * mgl_cf.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 79aacb0796a34f00c56f452943853f361f725762..1ad2145e942bba5aa0bf5ab6532b8f31d96c1f06 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * mpi.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\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
index beae2f6f5f66443ad9cd57a02afff2b9ac6dc487..a1b1354c3c52436087744d83dcee9fa9d1b596b4 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * opengl.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 4d1675cc8acceee234a45a56e2f3002ddcdd1541..c299ba7b731741d08ec6b8fb6660592638dd9821 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * other.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index f952074c2f090e7a3d84dbdaf6df74bc9bb8b001..fe21f8099ce384cf6c08406e80e2cc3d91904ec0 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * parser.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -22,7 +22,6 @@
 \r
 #ifdef __cplusplus\r
 #include "mgl2/mgl.h"\r
-#include <string>\r
 #if MGL_HAVE_LTDL\r
 #include <ltdl.h>\r
 #endif\r
@@ -161,6 +160,8 @@ public:
        void DeleteVar(const wchar_t *name);\r
        /// Delete all data variables\r
        void DeleteAll();\r
+       /// Set variant of argument(s) separated by '?' to be used\r
+       inline void SetVariant(int var=0)       {       Variant = var<=0?0:var; }\r
 private:\r
 //     long parlen;            ///< Length of parameter strings\r
        std::wstring par[40];   ///< Parameter for substituting instead of $1, ..., $9\r
@@ -176,6 +177,7 @@ private:
        int for_stack[40];      ///< The order of for-variables\r
        int for_addr;           ///< Flag for saving address in variable (for_addr-1)\r
        bool for_br;            ///< Break is switched on (skip all comands until 'next')\r
+       unsigned Variant;       ///< Select variant of argument(s) separated by '?'\r
 \r
        /// Parse command\r
        int Exec(mglGraph *gr, const wchar_t *com, long n, mglArg *a, const std::wstring &var, const wchar_t *opt);\r
index f358ce7488f91247a4a327a9d08bdee0383e6e26..d47656933e704e1dfc16a3c7622e40212a56bc69 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * pde.h is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
index fe7a59d65d4a04573d2039698245715ad2c1f4d1..90312dfb95766166fedde201ffacd9d7a7d03b2e 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * plot.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index d6959b0ba97b396a467e63202f544f013494e098..43abeaaa94dd96cc7d86decc4cafa64de7a03bf0 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * prim.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 79ed1574890b7133ec2d8fed9c851186fa5d98bb..de39072e5afac5d2f4236967fc3681b9ee07b94d 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * qmathgl.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
 #ifndef _MGL_QMATHGL_H_\r
 #define _MGL_QMATHGL_H_\r
 //-----------------------------------------------------------------------------\r
-#include <string>\r
+#include <mgl2/wnd.h>\r
 #include <QWidget>\r
 #include <QPixmap>\r
-#include <mgl2/wnd.h>\r
 //-----------------------------------------------------------------------------\r
 class QTextEdit;\r
 class QMenu;\r
@@ -233,7 +232,16 @@ public:
        mglDrawScript(HMPR p):mglDraw() {       par=p;  line=-1;        }\r
        virtual ~mglDrawScript() {}\r
        int Draw(mglGraph *gr)\r
-       {       gr->Highlight(line+1);  mgl_parse_textw(gr->Self(),par,text.toStdWString().c_str());    return 0;       }\r
+       {\r
+               wchar_t *wtext;\r
+               wtext = new wchar_t[text.size()+1];\r
+               text.toWCharArray(wtext);\r
+               wtext[text.size()] = 0;\r
+               gr->Highlight(line + 1);\r
+               mgl_parse_textw(gr->Self(), par, wtext);\r
+               delete[] wtext;\r
+               return 0;\r
+       }\r
 };\r
 //-----------------------------------------------------------------------------\r
 /// Convert bitmap from mglCanvasWnd to QPixmap\r
index 58ef70d1768de575886bb5b9990c4d0d381cd42c..09bc0dc75693731c706868c8b677907d5a4249ce 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * qt.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -30,6 +30,8 @@ uintptr_t MGL_EXPORT mgl_create_graph_qt_(const char *title, int);
 /// Run main Qt loop for event handling.\r
 int MGL_EXPORT mgl_qt_run();\r
 int MGL_EXPORT mgl_qt_run_();\r
+/// Return pointer to widget (QMathGL*) used for plotting\r
+MGL_EXPORT void *mgl_qt_widget(HMGL gr);\r
 #ifdef __cplusplus\r
 }\r
 //-----------------------------------------------------------------------------\r
@@ -38,7 +40,7 @@ int MGL_EXPORT mgl_qt_run_();
 /// Wrapper class for windows displaying graphics\r
 class MGL_EXPORT mglQT : public mglWnd\r
 {\r
-       mglQT(const mglQT &t) {}        // copying is not allowed\r
+       mglQT(const mglQT &) {} // copying is not allowed\r
        const mglQT &operator=(const mglQT &t)  {       return t;       }\r
 public:\r
        mglQT(const char *title="MathGL") : mglWnd()\r
@@ -52,6 +54,8 @@ public:
                mgl_set_click_func(gr, mgl_click_class);        }\r
        virtual ~mglQT() {}\r
        int Run()       {       return mgl_qt_run();    }       ///< Run main loop for event handling\r
+       /// Return pointer to widget (QMathGL*) used for plotting\r
+       void *Widget()  {       return mgl_qt_widget(gr);       }\r
 };\r
 //-----------------------------------------------------------------------------\r
 void MGL_EXPORT mgl_ask_qt(const wchar_t *quest, wchar_t *res);\r
index 43f35b45f9eb1947ddb43a4054643161ef8cc9b0..b2903193dd6e7a29a8128e5da60224cf67941b73 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * surf.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index f8c3db52d0c6d408d51fdbc46c8d3815e71e437c..537c9b0bc478f8593e042a432d81f8bfe1e53a0c 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * thread.h is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
index d441ec13bd4f87afd8789cfe7ea851f4bedd5c73..6d639c0f301ca041fe6ba857b674a03d102992b6 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * type.h is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
index 388c0e077c851a2821db6f8b25cfa1d3b489fa74..120fd300b03758699108a7e83eefca311c2e6f02 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * vect.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index d5ee4bc695993a64a77d29480361dd0107222c48..c5efca9835e7df45f7065311acd1f1c6b7ceb105 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * volume.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 00d52948d4970e7f438fc0b673ec7b833c208920..d20f3484fe18b3487dce7756fbb6dd718d84ce75 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * window.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index ad496e72e0a5b12d00d2ae70c2bff0925f42c3d7..8cadd9c255c4052e097594a2a670ed3a8c54fb66 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * wnd.h is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -56,7 +56,7 @@ public:
        pthread_t thr;\r
        bool running;\r
        pthread_mutex_t mutex;\r
-       \r
+\r
 #else\r
        mglDraw() {}\r
        virtual ~mglDraw() {}\r
@@ -74,12 +74,14 @@ void MGL_EXPORT mgl_reload_class(void *p);
 /// Abstract class for windows displaying graphics\r
 class MGL_EXPORT mglWnd : public mglGraph\r
 {\r
-       mglWnd(const mglWnd &t) {}      // copying is not allowed\r
+       mglWnd(const mglWnd &) {}       // copying is not allowed\r
        const mglWnd &operator=(const mglWnd &t)        {       return t;       }\r
 public:\r
        mglWnd() : mglGraph(-1) {}\r
        virtual ~mglWnd() {     mgl_use_graph(gr,-255); }\r
        virtual int Run()=0;            ///< Run main loop for event handling\r
+       /// Return pointer to widget used for plotting\r
+       virtual void *Widget()  {       return NULL;    }\r
 \r
        inline void ToggleAlpha()       ///< Switch on/off transparency (do not overwrite user settings)\r
        {       mgl_wnd_toggle_alpha(gr);       }\r
index 911fda4a8be899a6074204f21f3b4d16b97dec2c..6e1d05181eb77c57d57cd9ed51d23c6f46560604 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * wx.h.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 32fa3f07cdae98301ab83f162338092cd4877b31..89f9e5b4d0a568852762d879cf1ab76735f1a917 100644 (file)
@@ -11,13 +11,18 @@ QString Backend::show(const QString& text) const
 {
        qDebug() << __FUNCTION__;
        const char *tmp = tmpnam(0);
+       wchar_t *wtext;
        mglGraph gr;
        gr.SetFaceNum(200);
        mglParse pr;
        pr.AllowSetSize(true);
        setlocale(LC_CTYPE, "");
        setlocale(LC_NUMERIC, "C");
-       pr.Execute(&gr,text.toStdWString().c_str());
+       wtext = new wchar_t[text.size()+1];
+       text.toWCharArray(wtext);
+       wtext[text.size()] = 0;
+       pr.Execute(&gr,wtext);
+       delete[] wtext;
        gr.WriteJSON(tmp);
        setlocale(LC_NUMERIC, "");
 
@@ -32,13 +37,18 @@ QString Backend::show(const QString& text) const
 //-----------------------------------------------------------------------------
 QString Backend::coor(const QString& xy, const QString& text) const
 {
+       wchar_t *wtext;
        qDebug() << __FUNCTION__;
        mglGraph gr;
        mglParse pr;
        pr.AllowSetSize(true);
        setlocale(LC_CTYPE, "");
        setlocale(LC_NUMERIC, "C");
-       pr.Execute(&gr,text.toStdWString().c_str());
+       wtext = new wchar_t[text.size()+1];
+       text.toWCharArray(wtext);
+       wtext[text.size()] = 0;
+       pr.Execute(&gr,wtext);
+       delete[] wtext;
        gr.Finish();
 
        int x = (int)xy.section(" ",0,0).toDouble();
@@ -54,6 +64,7 @@ QString Backend::geometry(const QString& mgl) const
 {
        qDebug() << __FUNCTION__;
        const char *tmp = tmpnam(0);
+       wchar_t *wmgl;
        mglGraph gr;
 #if 0
        gr.SetFaceNum(200);
@@ -62,7 +73,11 @@ QString Backend::geometry(const QString& mgl) const
        pr.AllowSetSize(true);
        setlocale(LC_CTYPE, "");
        setlocale(LC_NUMERIC, "C");
-       pr.Execute(&gr,mgl.toStdWString().c_str());
+       wmgl = new wchar_t[mgl.size()+1];
+       mgl.toWCharArray(wmgl);
+       wmgl[mgl.size()] = 0;
+       pr.Execute(&gr,wmgl);
+       delete[] wmgl;
        gr.WriteJSON(tmp);
        setlocale(LC_NUMERIC, "");
 
index 33081d65c68d7ca6289c20a671206873b8ec4b5d..3ebb08e97c7104422aebdeba771b1687f723b7ce 100644 (file)
@@ -2,6 +2,9 @@
 
 #include <QObject>
 #include <QStringList>
+#if defined(_MSC_VER)
+#include <mgl2/define.h>
+#endif
 
 class Backend : public QObject
 {
index 5979d6ca14c7ffbc71d3d3a8223fc5ef693c1260..63733a1416f8c2c708942ae32241f29c835583cb 100644 (file)
@@ -14,11 +14,9 @@ endif(enable-qt5)
 add_executable(MglForJsTestBench ${json_src} ${json_moc_hdr} ${json_ui_src})
 if(enable-qt5)
        target_compile_definitions(MglForJsTestBench PUBLIC MGL_USE_QT5)
-       target_link_libraries(MglForJsTestBench mgl-qt5)
-       qt5_use_modules(MglForJsTestBench ${MGL_QT5_LIBS})
+       target_link_libraries(MglForJsTestBench mgl-qt5 ${MGL_QT5_LIBS})
 else(enable-qt5)
-       target_link_libraries(MglForJsTestBench mgl-qt)
-       qt4_use_modules(MglForJsTestBench ${MGL_QT4_LIBS})
+       target_link_libraries(MglForJsTestBench mgl-qt4 ${MGL_QT4_LIBS})
 endif(enable-qt5)
 
 endif(enable-json-sample)
index d050ccc2f58bbe17d0d83372ef028d3826afee34..8fef5356735873a28f2d82976ea5fe87e4548093 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * mgl.h is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   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  *
diff --git a/make_release b/make_release
deleted file mode 100755 (executable)
index 2fe9fe3..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/bash
-# Make releases
-
-VER=2.3.4
-LVER=${VER}.LGPL
-BIN=MathGL
-LBIN=MathGL-LGPL
-SRC=/home/balakin/mathgl-code/mathgl-2x
-BSRC=${SRC}/build
-
-mkdir mathgl-${VER}-mingw.i686
-mkdir mathgl-${VER}-mingw.i686/bin/
-cp -p ${BIN}/bin/* mathgl-${VER}-mingw.i686/bin/
-mkdir mathgl-${VER}-mingw.i686/lib/
-cp -p ${BIN}/lib/* mathgl-${VER}-mingw.i686/lib/
-mkdir mathgl-${VER}-mingw.i686/include/
-mkdir mathgl-${VER}-mingw.i686/include/mgl2/
-cp -p ${BIN}/include/mgl2/* mathgl-${VER}-mingw.i686/include/mgl2/
-cp -p ${SRC}/ChangeLog.txt mathgl-${VER}-mingw.i686/
-cp -p ${SRC}/FindMathGL2.cmake mathgl-${VER}-mingw.i686/mathgl2-config.cmake
-7z a mathgl-${VER}-mingw.i686.7z mathgl-${VER}-mingw.i686/
-rm -R mathgl-${VER}-mingw.i686
-
-mkdir mathgl-${LVER}-mingw.i686
-mkdir mathgl-${LVER}-mingw.i686/bin/
-cp -p ${LBIN}/bin/* mathgl-${LVER}-mingw.i686/bin/
-mkdir mathgl-${VER}-mingw.i686/lib/
-cp -p ${LBIN}/lib/* mathgl-${LVER}-mingw.i686/lib/
-mkdir mathgl-${LVER}-mingw.i686/include/
-mkdir mathgl-${LVER}-mingw.i686/include/mgl2/
-cp -p ${LBIN}/include/mgl2/* mathgl-${LVER}-mingw.i686/include/mgl2/
-cp -p ${SRC}/ChangeLog.txt mathgl-${LVER}-mingw.i686/
-cp -p ${SRC}/FindMathGL2.cmake mathgl-${LVER}-mingw.i686/mathgl2-config.cmake
-7z a mathgl-${LVER}-mingw.i686.7z mathgl-${LVER}-mingw.i686/
-rm -R mathgl-${LVER}-mingw.i686
-
-mkdir mgl_scripts-${VER}
-cp -pR ${BIN}/extra/* mgl_scripts-${VER}/
-cp -p ${BIN}/bin/* mgl_scripts-${VER}/
-cp -p ${BIN}/share/mathgl/mgl.cgi.exe mgl_scripts-${VER}/
-cp -p ${BIN}/share/udav/*.qm mgl_scripts-${VER}/
-cp -p ${BSRC}/texinfo/mgl_??.html mgl_scripts-${VER}/
-cp -p ${SRC}/ChangeLog.txt mgl_scripts-${VER}/
-7z a mgl_scripts-${VER}.7z mgl_scripts-${VER}/
-rm -R mgl_scripts-${VER}
-
-cp -p ${BSRC}/texinfo/mathgl_en.pdf mathgl-${VER}.eng.pdf
-cp -p ${BSRC}/texinfo/mgl_en.pdf mgl-${VER}.eng.pdf
-cp -p ${SRC}/ChangeLog.txt ChangeLog-${VER}.txt
-7z a mathgl-doc-html-${VER}.7z ${BSRC}/texinfo/m*html ${BSRC}/texinfo/png/
-
-svn checkout svn://svn.code.sf.net/p/mathgl/code/mathgl-2x/ mathgl-${VER}
-cd mathgl-${VER}
-./clean-svn
-cd ..
-tar -zcf mathgl-${VER}.tar.gz mathgl-${VER}/
-rm -R mathgl-${VER}
index b08705841ba5b212e9b0cc0e28040e6b29f2e567..c454a177e6f9a6f5652583c0c60444f258c75a5b 100644 (file)
@@ -1,6 +1,6 @@
 %!PS-Adobe-3.0 EPSF-3.0
 %%Creator: cairo 1.13.1 (http://cairographics.org)
-%%CreationDate: Sat Nov  7 08:28:35 2015
+%%CreationDate: Sat Nov  7 15:28:00 2015
 %%Pages: 1
 %%DocumentData: Clean7Bit
 %%LanguageLevel: 3
 ET
 Q q
 0 g
-2.4 w
+2.15895 w
 0 J
 0 j
 [] 0.0 d
 4 M q 1 0 0 -1 0 790.399963 cm
-316.762 33.48 m 316.762 86.008 l S Q
+316.762 37.789 m 316.762 80.293 l S Q
+321.988 721.4 m 316.781 707.248 l 311.578 721.4 l 314.652 719.138 318.855
+ 719.15 321.988 721.4 c h
+321.988 721.4 m f*
+0.809606 w
+1 j
+q 0 1 1 0 0 790.399963 cm
+-69 321.988 m -83.152 316.781 l -69 311.578 l -71.262 314.652 -71.25 318.855
+ -69 321.988 c h
+-69 321.988 m S Q
+2.15579 w
+0 j
 q 1 0 0 -1 0 790.399963 cm
-316.762 147.812 m 316.762 199.551 l S Q
+316.762 152.66 m 316.762 194.406 l S Q
+321.98 607.271 m 316.781 593.138 l 311.586 607.271 l 314.652 605.013 318.852
+ 605.029 321.98 607.271 c h
+321.98 607.271 m f*
+0.808421 w
+1 j
+q 0 1 1 0 0 790.399963 cm
+-183.129 321.98 m -197.262 316.781 l -183.129 311.586 l -185.387 314.652
+ -185.371 318.852 -183.129 321.98 c h
+-183.129 321.98 m S Q
+2.295753 w
+0 j
 q 1 0 0 -1 0 790.399963 cm
-256.559 257.719 m 139.379 257.719 l 139.379 365.215 l S Q
+252.547 257.68 m 139.148 257.68 l 139.148 359.32 l S Q
+144.703 443.091 m 139.172 428.041 l 133.637 443.091 l 136.902 440.685 141.375
+ 440.701 144.703 443.091 c h
+144.703 443.091 m f*
+0.860907 w
+1 j
+q 0 1 1 0 0 790.399963 cm
+-347.309 144.703 m -362.359 139.172 l -347.309 133.637 l -349.715 136.902
+ -349.699 141.375 -347.309 144.703 c h
+-347.309 144.703 m S Q
+2.324777 w
+0 j
 q 1 0 0 -1 0 790.399963 cm
-378.305 257.715 m 495.484 257.715 l 495.484 365.211 l S Q
+381.137 257.691 m 495.648 257.691 l 495.648 360.906 l S Q
+501.273 441.658 m 495.668 426.416 l 490.066 441.658 l 493.375 439.22 497.902
+ 439.236 501.273 441.658 c h
+501.273 441.658 m f*
+0.871792 w
+1 j
+q 0 1 1 0 0 790.399963 cm
+-348.742 501.273 m -363.984 495.668 l -348.742 490.066 l -351.18 493.375
+ -351.164 497.902 -348.742 501.273 c h
+-348.742 501.273 m S Q
+2.290224 w
+0 j
 q 1 0 0 -1 0 790.399963 cm
-225.398 398.059 m 316.828 397.484 l 316.828 474.172 l S Q
+228.438 397.988 m 317.062 397.453 l 317.062 469.492 l S Q
+322.605 332.888 m 317.086 317.873 l 311.562 332.888 l 314.824 330.49 319.281
+ 330.502 322.605 332.888 c h
+322.605 332.888 m f*
+0.858834 w
+1 j
+q 0 1 1 0 0 790.399963 cm
+-457.512 322.605 m -472.527 317.086 l -457.512 311.562 l -459.91 314.824
+ -459.898 319.281 -457.512 322.605 c h
+-457.512 322.605 m S Q
+2.300242 w
+0 j
 q 1 0 0 -1 0 790.399963 cm
-377.992 533.152 m 495.168 533.152 l 495.168 640.648 l S Q
+379.918 533.141 m 495.336 533.141 l 495.336 633.395 l S Q
+500.902 169.041 m 495.359 153.962 l 489.812 169.041 l 493.086 166.63 497.566
+ 166.646 500.902 169.041 c h
+500.902 169.041 m f*
+0.862591 w
+1 j
+q 0 1 1 0 0 790.399963 cm
+-621.359 500.902 m -636.438 495.359 l -621.359 489.812 l -623.77 493.086
+ -623.754 497.566 -621.359 500.902 c h
+-621.359 500.902 m S Q
+2.29295 w
+0 j
 q 1 0 0 -1 0 790.399963 cm
-255.668 532.582 m 138.488 532.582 l 138.488 640.078 l S Q
+252.285 532.551 m 138.273 532.551 l 138.273 633.395 l S Q
+143.824 168.998 m 138.297 153.966 l 132.77 168.998 l 136.031 166.595 140.496
+ 166.611 143.824 168.998 c h
+143.824 168.998 m f*
+0.859856 w
+1 j
+q 0 1 1 0 0 790.399963 cm
+-621.402 143.824 m -636.434 138.297 l -621.402 132.77 l -623.805 136.031
+ -623.789 140.496 -621.402 143.824 c h
+-621.402 143.824 m S Q
+2.335361 w
+0 j
 q 1 0 0 -1 0 790.399963 cm
-255.688 674.629 m 373.973 674.629 l S Q
+258.828 674.629 m 370.828 674.629 l S Q
+2.348876 w
 q 1 0 0 -1 0 790.399963 cm
-316.828 674.629 m 316.828 752.344 l S Q
+316.828 674.629 m 316.828 749.066 l S Q
+322.512 53.619 m 316.852 38.22 l 311.188 53.619 l 314.531 51.162 319.105
+ 51.173 322.512 53.619 c h
+322.512 53.619 m f*
+0.880828 w
+1 j
+q 0 1 1 0 0 790.399963 cm
+-736.781 322.512 m -752.18 316.852 l -736.781 311.187 l -739.238 314.531
+ -739.227 319.105 -736.781 322.512 c h
+-736.781 322.512 m S Q
+2.4 w
+0 j
 q 1 0 0 -1 0 790.399963 cm
 495.113 422.059 m 495.113 451.77 l 332.828 451.199 l 332.828 451.199 317.516
  429.449 301.457 451.18 c 138.828 451.484 l 138.543 532.629 l S Q
index cff8a1366f06637813738663ec827c692d01a292..a6a33bfe9457f86771536fd6785e2ef2b1fea87f 100644 (file)
Binary files a/mgltex/Recompilation_decision.pdf and b/mgltex/Recompilation_decision.pdf differ
index deabd7d5d7a145c95cee245ccabe599e67ad420a..79163b903647150d761957636463a9861e6ddaa3 100644 (file)
    sodipodi:docname="Recompilation_decision.svg">
   <defs
      id="defs4">
+    <marker
+       inkscape:isstock="true"
+       style="overflow:visible"
+       id="marker5654"
+       refX="0"
+       refY="0"
+       orient="auto"
+       inkscape:stockid="Arrow2Mend">
+      <path
+         inkscape:connector-curvature="0"
+         transform="scale(-0.6,-0.6)"
+         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+         style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+         id="path5656" />
+    </marker>
+    <marker
+       inkscape:stockid="Arrow2Mend"
+       orient="auto"
+       refY="0"
+       refX="0"
+       id="marker5452"
+       style="overflow:visible"
+       inkscape:isstock="true"
+       inkscape:collect="always">
+      <path
+         id="path5454"
+         style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+         transform="scale(-0.6,-0.6)"
+         inkscape:connector-curvature="0" />
+    </marker>
+    <marker
+       inkscape:isstock="true"
+       style="overflow:visible"
+       id="marker5256"
+       refX="0"
+       refY="0"
+       orient="auto"
+       inkscape:stockid="Arrow2Mend"
+       inkscape:collect="always">
+      <path
+         inkscape:connector-curvature="0"
+         transform="scale(-0.6,-0.6)"
+         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+         style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+         id="path5258" />
+    </marker>
+    <marker
+       inkscape:stockid="Arrow2Mend"
+       orient="auto"
+       refY="0"
+       refX="0"
+       id="marker5066"
+       style="overflow:visible"
+       inkscape:isstock="true"
+       inkscape:collect="always">
+      <path
+         id="path5068"
+         style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+         transform="scale(-0.6,-0.6)"
+         inkscape:connector-curvature="0" />
+    </marker>
+    <marker
+       inkscape:isstock="true"
+       style="overflow:visible"
+       id="marker4882"
+       refX="0"
+       refY="0"
+       orient="auto"
+       inkscape:stockid="Arrow2Mend"
+       inkscape:collect="always">
+      <path
+         inkscape:connector-curvature="0"
+         transform="scale(-0.6,-0.6)"
+         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+         style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+         id="path4884" />
+    </marker>
+    <marker
+       inkscape:stockid="Arrow2Mend"
+       orient="auto"
+       refY="0"
+       refX="0"
+       id="marker4704"
+       style="overflow:visible"
+       inkscape:isstock="true"
+       inkscape:collect="always">
+      <path
+         id="path4706"
+         style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+         transform="scale(-0.6,-0.6)"
+         inkscape:connector-curvature="0" />
+    </marker>
+    <marker
+       inkscape:isstock="true"
+       style="overflow:visible"
+       id="marker4532"
+       refX="0"
+       refY="0"
+       orient="auto"
+       inkscape:stockid="Arrow2Mend"
+       inkscape:collect="always">
+      <path
+         inkscape:connector-curvature="0"
+         transform="scale(-0.6,-0.6)"
+         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
+         style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
+         id="path4534" />
+    </marker>
     <marker
        inkscape:stockid="Arrow2Mend"
        orient="auto"
        refX="0"
        id="marker5662"
        style="overflow:visible"
-       inkscape:isstock="true">
+       inkscape:isstock="true"
+       inkscape:collect="always">
       <path
          id="path5664"
          style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
      showgrid="true"
      inkscape:current-layer="svg2"
      inkscape:document-units="px"
-     inkscape:cy="496.39986"
-     inkscape:cx="327.57307"
+     inkscape:cy="482.82902"
+     inkscape:cx="440.18293"
      inkscape:zoom="0.70000001"
      inkscape:pageshadow="2"
      inkscape:pageopacity="0.0"
         <dc:format>image/svg+xml</dc:format>
         <dc:type
            rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-        <dc:title></dc:title>
+        <dc:title />
       </cc:Work>
     </rdf:RDF>
   </metadata>
      inkscape:groupmode="layer"
      id="layer1"
      transform="translate(56.035869,-48.362179)" />
-  <rect
-     style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5398)"
-     id="rect15298"
-     width="100"
-     height="39.999996"
-     x="346.03613"
-     y="3.9999998"
-     ry="19.999998" />
-  <text
-     xml:space="preserve"
-     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-     x="395.46545"
-     y="33.285709"
-     id="text15304"
-     sodipodi:linespacing="100%"><tspan
-       sodipodi:role="line"
-       id="tspan15306"
+  <g
+     id="g7122">
+    <rect
+       ry="19.999998"
+       y="3.9999998"
+       x="346.03613"
+       height="39.999996"
+       width="100"
+       id="rect15298"
+       style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5398)" />
+    <text
+       sodipodi:linespacing="100%"
+       id="text15304"
+       y="33.285709"
        x="395.46545"
-       y="33.285709">Start</tspan></text>
-  <rect
-     style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:2.93979216;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5374)"
-     id="rect15308"
-     width="290.06018"
-     height="74.345917"
-     x="251.006"
-     y="110.82932"
-     ry="3.7605369e-06" />
-  <text
-     xml:space="preserve"
-     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-     x="397.49304"
-     y="142.28799"
-     id="text15310"
-     sodipodi:linespacing="100%"><tspan
-       sodipodi:role="line"
-       id="tspan15312"
-       x="397.49304"
-       y="142.28799">Find</tspan><tspan
-       sodipodi:role="line"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="33.285709"
+         x="395.46545"
+         id="tspan15306"
+         sodipodi:role="line">Start</tspan></text>
+  </g>
+  <g
+     id="g7127">
+    <rect
+       ry="3.7605369e-06"
+       y="110.82932"
+       x="251.006"
+       height="74.345917"
+       width="290.06018"
+       id="rect15308"
+       style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:2.93979216;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5374)" />
+    <text
+       sodipodi:linespacing="100%"
+       id="text15310"
+       y="142.28799"
        x="397.49304"
-       y="169.78799"
-       id="tspan15314">\MGL@@@&lt;script&gt;</tspan></text>
-  <rect
-     style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:2.61052561;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5350)"
-     id="rect15316"
-     width="104.42103"
-     height="104.421"
-     x="-37.940403"
-     y="434.159"
-     ry="0"
-     transform="matrix(0.73605839,-0.67691805,0.73605839,0.67691805,27.536121,2.4999998)" />
-  <text
-     xml:space="preserve"
-     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-     x="396.24426"
-     y="309.45212"
-     id="text15372"
-     sodipodi:linespacing="100%"><tspan
-       sodipodi:role="line"
-       id="tspan15374"
-       x="396.24426"
-       y="309.45212">Is it</tspan><tspan
-       sodipodi:role="line"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="142.28799"
+         x="397.49304"
+         id="tspan15312"
+         sodipodi:role="line">Find</tspan><tspan
+         id="tspan15314"
+         y="169.78799"
+         x="397.49304"
+         sodipodi:role="line">\MGL@@@&lt;script&gt;</tspan></text>
+  </g>
+  <g
+     id="g7133">
+    <rect
+       transform="matrix(0.73605839,-0.67691805,0.73605839,0.67691805,27.536121,2.4999998)"
+       ry="0"
+       y="434.159"
+       x="-37.940403"
+       height="104.421"
+       width="104.42103"
+       id="rect15316"
+       style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:2.61052561;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5350)" />
+    <text
+       sodipodi:linespacing="100%"
+       id="text15372"
+       y="309.45212"
        x="396.24426"
-       y="336.95212"
-       id="tspan15376">defined?</tspan></text>
-  <rect
-     style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:2.46426511;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5326)"
-     id="rect15308-5"
-     width="214.82143"
-     height="70.535728"
-     x="66.625397"
-     y="458.73218"
-     ry="3.5678115e-06" />
-  <text
-     xml:space="preserve"
-     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-     x="173.32182"
-     y="487.595"
-     id="text15310-7"
-     sodipodi:linespacing="100%"><tspan
-       sodipodi:role="line"
-       id="tspan15402"
-       x="173.32182"
-       y="487.595">Compare</tspan><tspan
-       sodipodi:role="line"
-       id="tspan15404"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="309.45212"
+         x="396.24426"
+         id="tspan15374"
+         sodipodi:role="line">Is it</tspan><tspan
+         id="tspan15376"
+         y="336.95212"
+         x="396.24426"
+         sodipodi:role="line">defined?</tspan></text>
+  </g>
+  <g
+     id="g7149">
+    <rect
+       ry="3.5678115e-06"
+       y="458.73218"
+       x="66.625397"
+       height="70.535728"
+       width="214.82143"
+       id="rect15308-5"
+       style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:2.46426511;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5326)" />
+    <text
+       sodipodi:linespacing="100%"
+       id="text15310-7"
+       y="487.595"
        x="173.32182"
-       y="515.09497">script vs. code</tspan></text>
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="487.595"
+         x="173.32182"
+         id="tspan15402"
+         sodipodi:role="line">Compare</tspan><tspan
+         y="515.09497"
+         x="173.32182"
+         id="tspan15404"
+         sodipodi:role="line">script vs. code</tspan></text>
+  </g>
   <rect
      style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:2.6016953;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5302)"
      id="rect15308-5-1"
      x="483.47986"
      y="461.65802"
      ry="3.2718219e-06" />
-  <text
-     xml:space="preserve"
-     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-     x="615.10748"
-     y="487.8367"
-     id="text15310-7-8"
-     sodipodi:linespacing="100%"><tspan
-       sodipodi:role="line"
-       id="tspan15430"
-       x="615.10748"
-       y="487.8367">Rewrite/recompile</tspan><tspan
-       sodipodi:role="line"
-       id="tspan15432"
+  <g
+     id="g7155">
+    <text
+       sodipodi:linespacing="100%"
+       id="text15310-7-8"
+       y="487.8367"
        x="615.10748"
-       y="515.33667">script</tspan></text>
-  <rect
-     style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:2.93979216;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5230)"
-     id="rect15308-58"
-     width="290.06018"
-     height="74.345917"
-     x="469.00604"
-     y="802.82477"
-     ry="3.7605369e-06" />
-  <text
-     xml:space="preserve"
-     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-     x="615.46466"
-     y="833.83441"
-     id="text15310-2"
-     sodipodi:linespacing="100%"><tspan
-       sodipodi:role="line"
-       id="tspan15538"
-       x="615.46466"
-       y="833.83441">Undefine</tspan><tspan
-       sodipodi:role="line"
-       id="tspan15540"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="487.8367"
+         x="615.10748"
+         id="tspan15430"
+         sodipodi:role="line">Rewrite/recompile</tspan><tspan
+         y="515.33667"
+         x="615.10748"
+         id="tspan15432"
+         sodipodi:role="line">script</tspan></text>
+  </g>
+  <g
+     id="g7177">
+    <rect
+       ry="3.7605369e-06"
+       y="802.82477"
+       x="469.00604"
+       height="74.345917"
+       width="290.06018"
+       id="rect15308-58"
+       style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:2.93979216;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5230)" />
+    <text
+       sodipodi:linespacing="100%"
+       id="text15310-2"
+       y="833.83441"
        x="615.46466"
-       y="861.33441">\MGL@@@&lt;script&gt;</tspan></text>
-  <rect
-     style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:2.93979216;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5254)"
-     id="rect15308-7"
-     width="290.06018"
-     height="74.345917"
-     x="29.006018"
-     y="802.82477"
-     ry="3.7605369e-06" />
-  <text
-     xml:space="preserve"
-     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-     x="175.46468"
-     y="833.83441"
-     id="text15310-4"
-     sodipodi:linespacing="100%"><tspan
-       sodipodi:role="line"
-       id="tspan15534"
-       x="175.46468"
-       y="833.83441">Define</tspan><tspan
-       sodipodi:role="line"
-       id="tspan15536"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="833.83441"
+         x="615.46466"
+         id="tspan15538"
+         sodipodi:role="line">Undefine</tspan><tspan
+         y="861.33441"
+         x="615.46466"
+         id="tspan15540"
+         sodipodi:role="line">\MGL@@@&lt;script&gt;</tspan></text>
+  </g>
+  <g
+     id="g7183">
+    <rect
+       ry="3.7605369e-06"
+       y="802.82477"
+       x="29.006018"
+       height="74.345917"
+       width="290.06018"
+       id="rect15308-7"
+       style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:2.93979216;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5254)" />
+    <text
+       sodipodi:linespacing="100%"
+       id="text15310-4"
+       y="833.83441"
        x="175.46468"
-       y="861.33441">\MGL@@@&lt;script&gt;</tspan></text>
-  <rect
-     style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5206)"
-     id="rect15298-0"
-     width="100"
-     height="39.999996"
-     x="346.03613"
-     y="944"
-     ry="19.999998" />
-  <text
-     xml:space="preserve"
-     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-     x="395.93542"
-     y="973.28571"
-     id="text15304-3"
-     sodipodi:linespacing="100%"><tspan
-       sodipodi:role="line"
-       id="tspan15563"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="833.83441"
+         x="175.46468"
+         id="tspan15534"
+         sodipodi:role="line">Define</tspan><tspan
+         y="861.33441"
+         x="175.46468"
+         id="tspan15536"
+         sodipodi:role="line">\MGL@@@&lt;script&gt;</tspan></text>
+  </g>
+  <g
+     id="g7189">
+    <rect
+       ry="19.999998"
+       y="944"
+       x="346.03613"
+       height="39.999996"
+       width="100"
+       id="rect15298-0"
+       style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5206)" />
+    <text
+       sodipodi:linespacing="100%"
+       id="text15304-3"
+       y="973.28571"
        x="395.93542"
-       y="973.28571">End</tspan></text>
-  <rect
-     style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:2.61052561;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5278)"
-     id="rect15316-5"
-     width="104.42103"
-     height="104.421"
-     x="-291.92599"
-     y="688.14459"
-     ry="0"
-     transform="matrix(0.73605839,-0.67691805,0.73605839,0.67691805,27.536121,2.4999998)" />
-  <text
-     xml:space="preserve"
-     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-     x="396.24426"
-     y="638.30701"
-     id="text15372-1"
-     sodipodi:linespacing="100%"><tspan
-       sodipodi:role="line"
-       id="tspan4665"
-       x="396.24426"
-       y="638.30701">Are</tspan><tspan
-       sodipodi:role="line"
-       id="tspan4667"
-       x="396.24426"
-       y="665.80701">they</tspan><tspan
-       sodipodi:role="line"
-       id="tspan4669"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="973.28571"
+         x="395.93542"
+         id="tspan15563"
+         sodipodi:role="line">End</tspan></text>
+  </g>
+  <g
+     id="g7160">
+    <rect
+       transform="matrix(0.73605839,-0.67691805,0.73605839,0.67691805,27.536121,2.4999998)"
+       ry="0"
+       y="688.14459"
+       x="-291.92599"
+       height="104.421"
+       width="104.42103"
+       id="rect15316-5"
+       style="fill:#ff9b58;fill-opacity:1;stroke:#000000;stroke-width:2.61052561;stroke-linecap:butt;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter5278)" />
+    <text
+       sodipodi:linespacing="100%"
+       id="text15372-1"
+       y="638.30701"
        x="396.24426"
-       y="693.30701">equal?</tspan></text>
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       xml:space="preserve"><tspan
+         y="638.30701"
+         x="396.24426"
+         id="tspan4665"
+         sodipodi:role="line">Are</tspan><tspan
+         y="665.80701"
+         x="396.24426"
+         id="tspan4667"
+         sodipodi:role="line">they</tspan><tspan
+         y="693.30701"
+         x="396.24426"
+         id="tspan4669"
+         sodipodi:role="line">equal?</tspan></text>
+  </g>
   <path
-     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:"
-     d="m 395.9522,41.850038 0,65.659912"
+     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.69868755;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker5662)"
+     d="m 395.9522,47.234559 0,53.132841"
      id="path9635"
      inkscape:connector-curvature="0"
      sodipodi:nodetypes="cc" />
   <path
-     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:"
-     d="m 395.9522,184.76632 0,64.67006"
+     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.69473767;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker5654)"
+     d="m 395.9522,190.82724 0,52.17876"
      id="path9668"
      inkscape:connector-curvature="0"
      sodipodi:nodetypes="cc" />
   <path
-     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:"
-     d="m 320.69584,322.14706 -146.47212,0 0,134.37059"
+     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.86969066;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker4704)"
+     d="m 315.68408,322.10132 -141.74819,0 0,127.04843"
      id="path9880"
      inkscape:connector-curvature="0"
      sodipodi:nodetypes="ccc" />
   <path
-     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:"
-     d="m 472.88165,322.14453 146.47212,0 0,134.37059"
+     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.90597177;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker4532)"
+     d="m 476.42192,322.11395 143.13726,0 0,129.01695"
      id="path9880-8"
      inkscape:connector-curvature="0"
      sodipodi:nodetypes="ccc" />
   <path
-     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:"
-     d="m 281.75015,497.57146 114.28572,-0.71429 0,95.85714"
+     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.86277986;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker4882)"
+     d="m 285.54764,497.48577 110.78038,-0.67102 0,90.05069"
      id="path11097"
      inkscape:connector-curvature="0"
      sodipodi:nodetypes="ccc" />
   <path
-     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:"
-     d="m 472.48848,666.43983 146.47212,0 0,134.37059"
+     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.87530303;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker5066)"
+     d="m 474.89723,666.42636 144.27202,0 0,125.31464"
      id="path9880-87"
      inkscape:connector-curvature="0"
      sodipodi:nodetypes="ccc" />
   <path
-     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:"
-     d="m 319.58325,665.72555 -146.47211,0 0,134.37059"
+     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.86618733;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker5256)"
+     d="m 315.35785,665.6901 -142.51657,0 0,126.05511"
      id="path9880-4"
      inkscape:connector-curvature="0"
      sodipodi:nodetypes="ccc" />
   <path
-     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:"
-     d="m 319.6073,843.28574 147.85714,0"
+     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.91920161;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+     d="m 323.53587,843.28574 140,0"
      id="path12272"
      inkscape:connector-curvature="0" />
   <path
-     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:"
-     d="m 396.03587,843.28574 0,97.14286"
+     style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.93609476;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker5452)"
+     d="m 396.03587,843.28574 0,93.04832"
      id="path12293"
      inkscape:connector-curvature="0" />
   <path
      id="path12941"
      inkscape:connector-curvature="0"
      sodipodi:nodetypes="cccccc" />
-  <rect
-     style="fill:#ffe3d0;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
-     id="rect5520"
-     width="71.428574"
-     height="40"
-     x="214.67897"
-     y="301.21429"
-     ry="20" />
-  <text
-     xml:space="preserve"
-     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
-     x="227.53612"
-     y="329.78571"
-     id="text5522"
-     sodipodi:linespacing="100%"><tspan
-       sodipodi:role="line"
-       id="tspan5524"
+  <g
+     id="g7144">
+    <rect
+       ry="20"
+       y="301.21429"
+       x="214.67897"
+       height="40"
+       width="71.428574"
+       id="rect5520"
+       style="fill:#ffe3d0;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="100%"
+       id="text5522"
+       y="329.78571"
        x="227.53612"
-       y="329.78571">Yes</tspan></text>
-  <rect
-     style="fill:#ffe3d0;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
-     id="rect5520-4"
-     width="71.428574"
-     height="40"
-     x="213.2504"
-     y="644.64282"
-     ry="20" />
-  <text
-     xml:space="preserve"
-     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
-     x="226.10754"
-     y="673.21423"
-     id="text5522-9"
-     sodipodi:linespacing="100%"><tspan
-       sodipodi:role="line"
-       id="tspan5524-4"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+       xml:space="preserve"><tspan
+         y="329.78571"
+         x="227.53612"
+         id="tspan5524"
+         sodipodi:role="line">Yes</tspan></text>
+  </g>
+  <g
+     id="g7172">
+    <rect
+       ry="20"
+       y="644.64282"
+       x="213.2504"
+       height="40"
+       width="71.428574"
+       id="rect5520-4"
+       style="fill:#ffe3d0;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="100%"
+       id="text5522-9"
+       y="673.21423"
        x="226.10754"
-       y="673.21423">Yes</tspan></text>
-  <rect
-     style="fill:#ffe3d0;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
-     id="rect5520-7"
-     width="71.428574"
-     height="40"
-     x="507.5361"
-     y="644.07141"
-     ry="20" />
-  <text
-     xml:space="preserve"
-     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
-     x="524.67896"
-     y="674.07141"
-     id="text5522-6"
-     sodipodi:linespacing="100%"><tspan
-       sodipodi:role="line"
-       id="tspan5586"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+       xml:space="preserve"><tspan
+         y="673.21423"
+         x="226.10754"
+         id="tspan5524-4"
+         sodipodi:role="line">Yes</tspan></text>
+  </g>
+  <g
+     id="g7167">
+    <rect
+       ry="20"
+       y="644.07141"
+       x="507.5361"
+       height="40"
+       width="71.428574"
+       id="rect5520-7"
+       style="fill:#ffe3d0;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="100%"
+       id="text5522-6"
+       y="674.07141"
        x="524.67896"
-       y="674.07141">No</tspan></text>
-  <rect
-     style="fill:#ffe3d0;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
-     id="rect5520-7-3"
-     width="71.428574"
-     height="40"
-     x="506.10754"
-     y="301.21426"
-     ry="20" />
-  <text
-     xml:space="preserve"
-     style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
-     x="523.25037"
-     y="331.21423"
-     id="text5522-6-9"
-     sodipodi:linespacing="100%"><tspan
-       sodipodi:role="line"
-       id="tspan5586-2"
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+       xml:space="preserve"><tspan
+         y="674.07141"
+         x="524.67896"
+         id="tspan5586"
+         sodipodi:role="line">No</tspan></text>
+  </g>
+  <g
+     id="g7139">
+    <rect
+       ry="20"
+       y="301.21426"
+       x="506.10754"
+       height="40"
+       width="71.428574"
+       id="rect5520-7-3"
+       style="fill:#ffe3d0;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+    <text
+       sodipodi:linespacing="100%"
+       id="text5522-6-9"
+       y="331.21423"
        x="523.25037"
-       y="331.21423">No</tspan></text>
+       style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+       xml:space="preserve"><tspan
+         y="331.21423"
+         x="523.25037"
+         id="tspan5586-2"
+         sodipodi:role="line">No</tspan></text>
+  </g>
 </svg>
index 959e117fe833b13cc68aeaba21943691a9f69545..d50fa825424da3466e34fff950551576237fc8fa 100644 (file)
 %
 %<package>
 %<package>\NeedsTeXFormat{LaTeX2e}
-%<package>\ProvidesPackage{mgltex}[2016/01/28 v4.1 Embed MGL scripts into LaTeX documents]
+%<package>\ProvidesPackage{mgltex}[2016/04/26 v4.2 Embed MGL scripts into LaTeX documents]
 %<package>
 %
 %<*driver>
 \documentclass[10pt]{ltxdoc}
 \usepackage{color}
+\usepackage{mgltex}
+\DeclareRobustCommand\mglTeX{mgl\kern-0.04em\TeX}% Otherwise, incompatibility with \CharacterTable
 \IfFileExists{hyperref.sty}{%
-       \usepackage[hidelinks=true]{hyperref}%
+  \usepackage[hidelinks]{hyperref}%
 }{}
-\usepackage{mgltex}
-\def\mglTeX{mgl\TeX} % Otherwise, incompatibility with \CharacterTable
 \EnableCrossrefs
 \CodelineIndex
 \RecordChanges
 %   \makeatother
 % \egroup
 %
-% \changes{v1.0}{2014/09/27}{Initial version}
-% \changes{v2.0}{2014/11/23}{Possible bugfix by adding \texttt{\textbackslash expandafter} to commands to ignore/write lines of MGL code}
-% \changes{v2.0}{2014/11/23}{Add environment \texttt{mglsignature} that adds a commentary every MGL script}
-% \changes{v2.0}{2014/11/23}{Eliminate line ignoring commands to create more elegant scripts, due to the a new command that adds comments to the scripts}
-% \changes{v2.0}{2014/11/23}{Move the MGL \emph{stop} command from the \texttt{\textbackslash{}AtEndDocument} command to the \texttt{\textbackslash{}mgl@func} buffer}
-% \changes{v3.0}{/2015/03/29}{Add detection of changes in MGL scripts to speed up compilation time (only changed scripts are recompiled)}
-% \changes{v3.0}{/2015/03/29}{Add command \texttt{\textbackslash mgldir}, \texttt{\textbackslash mglscriptsdir}, \texttt{\textbackslash mglgraphicsdir} and \texttt{\textbackslash mglbackupsdir} to specify a main directory for \textsf{\mglTeX} and directories for the creation of scripts, graphics and backups}
-% \changes{v3.0}{/2015/03/29}{Add the \texttt{\textbackslash mglquality} command to specify a default quality}
-% \changes{v3.0}{/2015/03/29}{Add the \texttt{\textbackslash mglwidth} and \texttt{\textbackslash mglheight} commands to specify the default size of the images produced}
-% \changes{v3.0}{/2015/03/29}{Add the \texttt{\textbackslash mglsettings} command to configure behavior of the package}
-% \changes{v3.0}{/2015/03/29}{Improve environment \texttt{mglsignature} by adding the possibility of using \LaTeX{} commands inside it}
-% \changes{v4.0}{/2015/08/17}{Completely rewrite of \textsf{\mglTeX}}
-% \changes{v4.0}{/2015/08/17}{\textsf{\mglTeX} now depends of the \textsf{verbatim} package}
-% \changes{v4.0}{/2015/08/17}{All environments write their contents \emph{verbatim}}
-% \changes{v4.0}{/2015/08/17}{Add package options \texttt{0q}, \ldots, \texttt{8q} to specify quality}
-% \changes{v4.0}{/2015/08/17}{Add the \texttt{\textbackslash mglpaths} command to add directories to the search paths for MGL scripts}
-% \changes{v4.0}{/2015/08/17}{Add the \texttt{\textbackslash mglname} command to force clousure of the current main script, its compilation, and the opening of a new main script}
-% \changes{v4.0}{/2015/08/17}{Add the option \texttt{label} to the \texttt{mgl} environment in order to override the automatic naming of the script and corresponding image}
-% \changes{v4.0}{/2015/08/17}{Add the option \texttt{label} to the \texttt{mglverbatim} environment to name the verbatim code}
-% \changes{v4.0}{/2015/08/17}{Add the option \texttt{separator} to the command \texttt{\textbackslash mglplot} to brake the code into different physical text lines}
-% \changes{v4.0}{/2015/08/17}{Add the option \texttt{path} to the commands \texttt{\textbackslash mglgraphics} and \texttt{\textbackslash mglinclude} to force a path to search MGL scripts}
-% \changes{v4.0}{/2015/08/17}{Make verbatim-like environments and \texttt{\textbackslash mglinclude} command more visually elegant}
-% \changes{v4.0}{/2015/08/17}{Numbering in verbatim-like environments is optional now}
-% \changes{v4.0}{/2015/08/17}{Add the command \texttt{\textbackslash listofmglscripts} to create a list of all MGL scripts included verbatim in the document}
-% \changes{v4.0}{/2015/08/17}{Add the command \texttt{\textbackslash mglTeXwVer} that prints the name of the package with its version in a coherent manner, and separated by an unbreakable space}
-% \changes{v4.0}{/2015/08/17}{Verbatim-like environments and the \texttt{\textbackslash mglinclude} command have starred versions wich prevent the command \texttt{\textbackslash listofmglscripts} to list them}
-% \changes{v4.0}{/2015/08/17}{Remove \texttt{mglsignature} environment for being considered useless, and to avoid interference with the detection of changes in MGL scripts, to speed up script writing and to make the package less resource-consuming}
-% \changes{v4.0}{/2015/08/17}{Remove the \texttt{\textbackslash mglwidth} and \texttt{\textbackslash mglheight} commands for being considered useless}
-% \changes{v4.0}{/2015/08/17}{Remove the \texttt{\textbackslash MGL@setkeys} command, since it isn't needed as first thought}
-% \changes{v4.0}{/2015/08/17}{Many improvements, including, but not limited to, speed up, increased coherence and cleanness of the code, less resource consumption}
-% \changes{v4.0}{/2015/08/17}{Many bugfixes}
-%
-% \changes{v4.1}{/2016/01/28}{Add the command \texttt{\textbackslash mglimgext} to specify locally the extension to save the generated graphics}
-% \changes{v4.1}{/2016/01/28}{Add the command \texttt{\textbackslash mglswitch}, which replaces \texttt{\textbackslash mgltexon} and \texttt{\textbackslash mgltexoff}}
-% \changes{v4.1}{/2016/01/28}{Rename the commands \texttt{\textbackslash mgltexon} as \texttt{\textbackslash MGL@switch@on} and \texttt{\textbackslash mgltexoff} as \texttt{\textbackslash MGL@switch@off} in order to avoid the user from unpurposely overwriting them}
-% \changes{v4.1}{/2016/01/28}{The command \texttt{\textbackslash mglcomments} has been reimplemented to accept one mandatory argument: \texttt{\textbackslash mglcomments\{on\}} replaces the old \texttt{\textbackslash mglcomments}, while \texttt{\textbackslash mglcomments\{off\}} replaces the old \texttt{\textbackslash mglnocomments}}
-% \changes{v4.1}{/2016/01/28}{Remove the command \texttt{\textbackslash mglnocomments} (rendered useless by the new implementation of \texttt{\textbackslash mglcomments})}
-% \changes{v4.1}{/2016/01/28}{Remove the command \texttt{\textbackslash mglTeXwVer} (rendered useless by the implementation of the starred version of \texttt{\textbackslash mglTeX})}
-% \changes{v4.1}{/2016/01/28}{Restore the command \texttt{\textbackslash mglsettings}, which was unintentionally deleted in version~4.0}
-% \changes{v4.1}{/2016/01/28}{Expand the key-val list family for the command \texttt{\textbackslash mglsettings}}
-% \changes{v4.1}{/2016/01/28}{Reimplement the \texttt{\textbackslash @MGL@comments@} switch}
-% \changes{v4.1}{/2016/01/28}{A starred version of the command \texttt{\textbackslash mglTeX} has been implemented, which prints the version of the package besides its name}
+%      \def\doccommand#1{\texttt{\textbackslash#1}}
+%
+% \changes{\textbf{v1.0 ------------}}{2014/09/27}{Initial version}
+%
+%
+% \changes{\textbf{v2.0 ------------}}{2014/11/23}{Possible bugfix by adding \doccommand{expandafter} to commands to ignore/write lines of MGL code}
+% \changes{\textbf{v2.0 ------------}}{2014/11/23}{Add environment \texttt{mglsignature} that adds a comment to every MGL script}
+% \changes{\textbf{v2.0 ------------}}{2014/11/23}{Eliminate line ignoring commands to create more elegant scripts, due to the a new command that adds comments to the scripts}
+% \changes{\textbf{v2.0 ------------}}{2014/11/23}{Move the MGL \emph{stop} command from the \texttt{\textbackslash{}AtEndDocument} command to the \doccommand{mgl@func} buffer}
+%
+%
+% \changes{\textbf{v3.0 ------------}}{2015/03/29}{Add detection of changes in MGL scripts to speed up compilation time (only changed scripts are recompiled)}
+% \changes{\textbf{v3.0 ------------}}{2015/03/29}{Add command \doccommand{mgldir}, \doccommand{mglscriptsdir}, \doccommand{mglgraphicsdir} and \doccommand{mglbackupsdir} to specify a main directory for \textsf{\mglTeX} and directories for the creation of scripts, graphics and backups}
+% \changes{\textbf{v3.0 ------------}}{2015/03/29}{Add the \doccommand{mglquality} command to specify a default quality}
+% \changes{\textbf{v3.0 ------------}}{2015/03/29}{Add the \doccommand{mglwidth} and \doccommand{mglheight} commands to specify the default size of the images produced}
+% \changes{\textbf{v3.0 ------------}}{2015/03/29}{Add the \doccommand{mglsettings} command to configure behavior of the package}
+% \changes{\textbf{v3.0 ------------}}{2015/03/29}{Improve environment \texttt{mglsignature} by adding the possibility of using \LaTeX{} commands inside it}
+%
+%
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Complete rewrite of \textsf{\mglTeX}}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{\textsf{\mglTeX} now depends of the \textsf{verbatim} package}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{All environments write their contents \emph{verbatim}}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add package options \texttt{0q}, \ldots, \texttt{8q} to specify quality}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the \doccommand{mglpaths} command to add directories to the search paths for MGL scripts}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the \doccommand{mglname} command to force clousure of the current main script, its compilation, and the opening of a new main script}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the option \texttt{label} to the \texttt{mgl} environment in order to override the automatic naming of the script and corresponding image}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the option \texttt{label} to the \texttt{mglverbatim} environment to name the verbatim code}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the option \texttt{separator} to the command \doccommand{mglplot} to brake the code into different physical text lines}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the option \texttt{path} to the commands \doccommand{mglgraphics} and \doccommand{mglinclude} to force a path to search MGL scripts}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Verbatim-like environments and \doccommand{mglinclude} command are more visually elegant now}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Numbering in verbatim-like environments is optional now}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the command \doccommand{listofmglscripts} to create a list of all MGL scripts included verbatim in the document}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the command \doccommand{mglTeXwVer} that prints the name of the package with its version in a coherent manner, and separated by an unbreakable space}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Verbatim-like environments and the \doccommand{mglinclude} command have starred versions wich prevent the command \doccommand{listofmglscripts} to list them}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Remove \texttt{mglsignature} environment for being considered useless, and to avoid interference with the detection of changes in MGL scripts, to speed up script writing and to make the package less resource-consuming}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Remove the \doccommand{mglwidth} and \doccommand{mglheight} commands for being considered useless}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Many improvements, including, but not limited to, speed up, increased coherence and cleanness of the code, less resource consumption}
+% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Many bugfixes}
+%
+%
+% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Add the command \doccommand{mglimgext} to specify locally the extension to save the generated graphics}
+% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Add the command \doccommand{mglswitch}, which replaces \doccommand{mgltexon} and \doccommand{mgltexoff}}
+% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Rename the commands \doccommand{mgltexon} as \doccommand{MGL@switch@on} and \doccommand{mgltexoff} as \doccommand{MGL@switch@off} in order to avoid the user from unpurposely overwriting them}
+% \changes{\textbf{v4.1 ------------}}{2016/01/28}{The command \doccommand{mglcomments} has been reimplemented to accept one mandatory argument: \doccommand{mglcomments\{on\}} replaces the old \doccommand{mglcomments}, while \doccommand{mglcomments\{off\}} replaces the old \doccommand{mglnocomments}}
+% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Remove the command \doccommand{mglnocomments} (rendered useless by the new implementation of \doccommand{mglcomments})}
+% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Remove the command \doccommand{mglTeXwVer} (rendered useless by the implementation of the starred version of \doccommand{mglTeX})}
+% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Restore the command \doccommand{mglsettings}, which was unintentionally deleted in version~4.0}
+% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Expand the key-val list family for the command \doccommand{mglsettings}}
+% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Reimplement the \doccommand{@MGL@comments@} switch}
+% \changes{\textbf{v4.1 ------------}}{2016/01/28}{A starred version of the command \doccommand{mglTeX} has been implemented, which prints the version of the package besides its name}
+%
+%
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New package options \texttt{gray}, \texttt{color} to activate/deactivate gray-scale mode for graphics}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New package options \texttt{0v}, \texttt{1v}, \texttt{2v} to select variant of arguments in MGL scripts}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New package option \texttt{9q} for setting quality to \texttt{9} (for testing purposes of the author)}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New commands: \doccommand{mglgray} (to activate/deactivate) gray-scale mode locally, and \doccommand{mglvariant} (to set variant of arguments in MGL scripts locally)}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Rename environment \texttt{mglcommon} to \texttt{mglsetupscript} (\texttt{mglcommon} is still available, but deprecated)}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Rename command \doccommand{mglcommonscriptname} to \texttt{mglsetupscriptname}}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Rename command \doccommand{MGL@graph@ext} to \doccommand{MGL@imgext}}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Rename family \texttt{MGL@keys} as \texttt{MGL@gr@keys} for consistency}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Reorganize and update documentation}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{\mglTeX{} now depends on the \texttt{ifpdf} package}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{The MGL code line \texttt{setsize~600~400} is now automatically written to the main script in order for the scaling options and commands to work}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Remove the \doccommand{MGL@setkeys} command, since it isn't needed as first thought}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Some minor bugfixes}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Change definition of \doccommand{mglcommentname} from \emph{MGL comment} to \emph{\mglTeX{} comment}}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Rename \doccommand{MGL@document@scripts} to \doccommand{MGL@doc@scripts}}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Rename \doccommand{MGL@script@name} tp \doccommand{MGL@script}}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Introduce the concept of \emph{global}, \emph{local} and \emph{private} settings in the documentation}
 %
 % \GetFileInfo{mgltex.sty}
 %
 % \DoNotIndex{\@flushglue,\@for,\@ifnextchar,\@makeother,\{,\},\ ,\AtBeginDocument,\AtEndDocument,\centering}
 % \DoNotIndex{\closein,\closeout,\csname,\endcsname,\CurrentOption,\DeclareGraphicsExtensions,\define@key,\DeclareOption}
 % \DoNotIndex{\detokenize,\do,\dospecials,\endlinechar,\endlist,\escapechar,\ExecuteOptions,\expandafter,\footnotesize}
-% \DoNotIndex{\framebox,\Gin@extensions,\Huge,\ifeof,\IfFileExists,\ifx,\immediate,\include,\includegraphics,\item,\itemsep}
+% \DoNotIndex{\framebox,\Huge,\ifeof,\IfFileExists,\ifx,\immediate,\include,\includegraphics,\item,\itemsep}
 % \DoNotIndex{\itshape,\jobname,\labelsep,\leftskip,\let,\long,\mbox,\newcounter,\newread,\newtoks,\newwrite,\noexpand}
 % \DoNotIndex{\obeyspaces,\openin,\openout,\PackageError,\PackageWarning,\parfillskip,\parindent,\parskip}
 % \DoNotIndex{\PassOptionsToPackage,\ProcessOptions,\read,\relax,\RequirePackage,\rightskip,\setcounter,\setkeys,\setlength}
 % \DoNotIndex{\endcenter,\everypar,\fbox,\fboxrule,\frenchspacing,\g@addto@macro,\global,\hb@xt@,\hbadness,\hfil,\hfill}
 % \DoNotIndex{\hrule,\hskip,\hss,\if@minipage,\if@tempswa,\ifhmode,\ifnum,\interlinepenalty,\itemindent,\kern,\l@chapter}
 % \DoNotIndex{\l@section,\large,\leavevmode,\MakeUppercase,\newdimen,\nobreak,\nopagebreak,\normalfont,\null,\numberline}
-% \DoNotIndex{\p@,\par,\unpenalty,\usecounter,\@ifstar,\^}
+% \DoNotIndex{\p@,\par,\unpenalty,\usecounter,\@ifstar,\^,\iffalse,\iftrue,\ifpdf}
 %
 % \title{The \textsf{\mglTeX} package\thanks{This document corresponds to \textsf{\mglTeX}~\fileversion, dated \filedate.}}
 % \author{Diego Sejas Viscarra\\\texttt{dsejas.mathematics@gmail.com}}
 % \begin{abstract}
 % \noindent MathGL is a fast and efficient library by Alexey Balakin for the creation of high-quality publication-ready scientific graphics. Although it defines interfaces for many programming languages, it also implements its own scripting language, called \emph{MGL}, which can be used independently. With the package \textsf{\mglTeX}, MGL scripts can be embedded within any \LaTeX{} document, and the corresponding images are automatically created and included.
 %
-% This manual documents the use of the commands and environments of~\textsf{\mglTeX}.
+% This manual documents the usage of the commands and environments of~\textsf{\mglTeX}.
 % \end{abstract}
 %
 % \tableofcontents
 %
 % \section{Introduction}
-% MathGL is a fast and efficient library by Alexey Balakin for the creation of high-quality publication-ready scientific graphics. It implements more than $50$ different types of graphics for 1d, 2d and 3d large sets of data. It supports exporting images to bitmap formats (PNG, JPEG, BMP, etc.), or vector formats (EPS, \TeX, SVG, etc.), or 3d image formats (STL, OBJ, XYZ, etc.), and even its own native 3d format, MGLD. MathGL also defines its own vector font specification format, and supports UTF-16 encoding with \TeX-like symbol parsing. It supports various kinds of transparency and lighting, textual formula evaluation, arbitrary curvilinear coordinate systems, loading of subroutines from .dll or .so libraries, and many other useful features.
+% \noindent MathGL is a fast and efficient library by Alexey Balakin for the creation of high-quality publication-ready scientific graphics. It implements more than $50$ different types of graphics for 1d, 2d and 3d large sets of data. It supports exporting images to bitmap formats (PNG, JPEG, BMP, etc.), or vector formats (EPS, \TeX, SVG, etc.), or 3d image formats (STL, OBJ, XYZ, etc.), and even its own native 3d format, MGLD. MathGL also defines its own vector font specification format, and supports UTF-16 encoding with \TeX-like symbol parsing. It supports various kinds of transparency and lighting, textual formula evaluation, arbitrary curvilinear coordinate systems, loading of subroutines from .dll or .so libraries, and many other useful features.
 %
 % MathGL has interfaces for a wide variety of programming languages, such as C/C++, Fortran, Python, Octave, Pascal, Forth, and many others, but it also defines its own scripting language, called \emph{MGL}, which can be used to generate graphics independently of any programming language. The \textsf{\mglTeX} package adds support to embed MGL code inside \LaTeX{} documents, which is automatically extracted and executed, and the resulting images are included in the document.
 %
 % \begin{enumerate}
 %   \item Any meta-variable that contain the word \emph{directory} indicates the name of a directory, in the form of an absolute or relative path, ending with the slash (``/'') character.
 %   \item Any meta-variable that contain the word \emph{subdirectory} indicates a relative path ending with the slash (``/'') character.
-%   \item \meta{$x_1\vert x_2\vert\ldots\vert x_n$} indicates that any of the values $x_1$, $x_2$, \ldots, $x_n$ can be placed there.
+%   \item \meta{$x_1\vert x_2\vert\ldots\vert x_n$} indicates that any of the values $x_1$, $x_2$, \ldots, $x_n$ can be placed there. A special case is \meta{$x_1\vert x_2\vert\ldots$}, where no upper limit is set.
+%   \item The possible values of a meta-variable could also be indicated by a property. For example \meta{$x:x>0$} indicates that any positive value can be used in that location.
 %   \item A meta-variable of the form \meta{list of something} or \meta{something list} indicate a comma-separated list of values of type $\meta{something}$; if only one value is used, no comma is needed.
-% \item A meta-variable with underscores (``\_'') in its description indicate that spaces should not be used in that location.
+% \item A meta-variable with underscores (``|_|'') in its description indicate that spaces should not be used in that location.
 % \item \meta{key-val list} refers to a list of \meta{key}=\meta{value} pairs of options, where \meta{key} is a keyword name for an option and \meta{value} is a value assigned to it.
 % \end{enumerate}
 %
-% As is conventional for \LaTeX{} packages, the commands and environments of \textsf{\mglTeX{}} accept optional commands inside brackets and mandatory arguments inside curly braces.
+% As is conventional for \LaTeX{} packages, the environments and commands defined by \textsf{\mglTeX} accept optional commands inside brackets ("|[|" and "|]|"), and mandatory arguments inside curly braces ("|{|" and "|}|").
+%
+% While reading the following, it must be noted that most of \textsf{\mglTeX} settings have three modes: global, local and private. A setting is \emph{global} if it applies to the whole document, it is \emph{local} if it applies to the document from one point onwards, and it is \emph{private} if it applies only to a particular MGL script. Global settings are set thorugh package options or with the command |\mglsettings| (explained later), local settings have associated commands (subsection \ref{local setts}), and private settings are specified as optional arguments for environments and commands. An example of this would be the package option |4q|, the command |\mglquality{4}|, and the optional argument for environments and commands |quality=4|, to set the quality for graphics to |4| in the three different modes, respectively.
 %
 % \section{Usage}
 % \noindent The simplest way to load \textsf{\mglTeX} to a \LaTeX{} document is to write the command
 % \end{center}
 % where \meta{options list} can contain one or more of the following options:
 % \begin{itemize}
-%   \item |draft|: The generated images won't be included in the document. This option is useful when fast compilation of the document is needed.
-%   \item |final|: Overrides the |draft| option.
-%   \item |on|: To rewrite, recompile and include the changed MGL scripts and/or corresponding graphics.
-%   \item |off|: To avoid creation, compilation and/or inclusion of the MGL scripts and corresponding images.
-%   \item |comments|: To allow the contents of the |mglcomment| environments to be shown in the \LaTeX{} document.
-%   \item |nocomments|: To avoid showing the contents of the |mglcomment| environments in the \LaTeX{} document.
-%   \item |1x|, \ldots, |9x|: To specify the scale for the creation of graphics (|1x| is normal scaling, |2x| is twice as bigger, etc).
-%   \item |0q|, \ldots, |8q|: To specify the quality for the creation of graphics. An info message indicating the characteristics of the chosen quality is printed in the .log file according to the following table:
+%   \item \textbf{draft:} The generated images won't be included in the document. This option is useful when fast compilation of the document is needed.
+%   \item \textbf{final:} Overrides the |draft| option.
+%   \item \textbf{on:} To rewrite, recompile and include the changed MGL scripts and/or corresponding graphics.
+%   \item \textbf{off:} To avoid creation, compilation and/or inclusion of the MGL scripts and corresponding images.
+%   \item \textbf{comments:} To allow the contents of the |mglcomment| environments to be shown in the \LaTeX{} document.
+%   \item \textbf{nocomments:} To avoid showing the contents of the |mglcomment| environments in the \LaTeX{} document.
+%   \item \textbf{gray:} To create the MGL graphics in gray-scale mode.
+%   \item \textbf{color:} To create the MGL graphics in color mode.
+%   \item \textbf{1x, \ldots, 9x:} To specify the scale for the creation of graphics (|1x| is normal scaling, |2x| is twice as bigger, etc).
+%   \item \textbf{0q, \ldots, 9q:} To specify the quality for the creation of graphics. An info message indicating the characteristics of the chosen quality is printed in the .log file according to the following table:
 % \begin{center}
 %   \DeleteShortVerb{\|}
 %   \begin{tabular}{|c|l|}
 %     \hline
 %     $8$ & Draw dots instead of primitives (extremely fast)\\
 %     \hline
+%     $9$ & No drawing (for testing purposes)\\
+%     \hline
 %   \end{tabular}
 %   \MakeShortVerb{\|}
 % \end{center}
-%   \item |png|, |jpg|, |jpeg|: To export images to a bitmap format.
-%   \item |eps|, |epsz|: To export to uncompressed/compressed vectorial EPS format.
-%   \item |bps|, |bpsz|: To export to uncompressed/compressed bitmap EPS format.
-%   \item |pdf|: To export to 3D PDF format.
-%   \item |tex|: To export to \LaTeX{}/\emph{tikz} document.
+%   \item \textbf{0v, 1v, 2v:} To set the default variant of arguments for the MGL commands.
+%   \item \textbf{png, jpg, jpeg:} To export images to a bitmap format.
+%   \item \textbf{eps, epsz:} To export to uncompressed/compressed vectorial EPS format.
+%   \item \textbf{bps, bpsz:} To export to uncompressed/compressed bitmap EPS format.
+%   \item \textbf{pdf:} To export to 3D PDF format.
+%   \item \textbf{tex:} To export to \LaTeX{}/\emph{tikz} document.
 % \end{itemize}
 % If two or more mutually exclusive options are specified, only the last one will be used by \textsf{\mglTeX}. For example, if one specifies the options |0q|, |3q| and |8q|---in that order---, then the quality will be set to $8$.
 %
 % \end{quote}
 %
 % \subsection{Environments for MGL code embedding}
-% \DescribeEnv{mgl}\noindent The main environment defined by \textsf{\mglTeX} is |mgl|. It extracts its contents to a main script, called \meta{main\_script\_name}.mgl, where \meta{main\_script\_name} stands for a name specified by the user with the |\mglname| command (see below), or the name of the \LaTeX{} document being executed otherwise; this script is compiled, and the corresponding image is included.
+% \DescribeEnv{mgl}\noindent The main environment defined by \textsf{\mglTeX} is |mgl|. It extracts its contents to a main script, called \meta{main\_script\_name}.mgl, where \meta{main\_script\_name} stands for a name specified by the user with the |\mglname| command (explained later), or the name of the \LaTeX{} document being executed otherwise; this script is compiled, and the corresponding image is included.
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
 %     \hline
 %   \end{tabular}
 % \end{center}
-% Here, \meta{key-val list} can have the same optional arguments as the |\includegraphics| command from the \textsf{graphicx} package, plus two additional ones, |imgext|, which can be used to specify the extension to save the graphic, and |label|, which can be used to indicate a name for the corresponding graphic (otherwise, an automatic naming will be applied). The \meta{MGL code} doesn't need to contain any specific instruction to create the image since \textsf{\mglTeX} takes care of that.
+% Here, \meta{key-val list} can have the following optional arguments:
+% \begin{itemize}
+%   \item \textbf{bb, bbllx, bblly, bburx, bbury, natwidth, natheight, hiresbb, viewport, trim, angle, origin, width, height, totalheight, keepaspectratio, scale, clip, draft, type, ext, read, command:} These are the same options of the |\includegraphics| command from the \textsf{graphicx} package.
+%   \item \textbf{gray:} Can be used to activate (|gray=on| or |gray=1|) or deactivate (|gray=off| or |gray=0|) gray-scale mode privately (only for the current graphic).
+%   \item \textbf{mglscale:} Any positive value for this option is used to physically scale the resulting image file, i.g., |mglscale=2| will create an image file twice as bigger.
+%   \item \textbf{quality:} Sets the quality of the current graphic. Valid values are integers between |0| and |9|.
+%   \item \textbf{variant:} Sets the variant of argument for the commands in the current script.
+%   \item \textbf{imgext:} Can be used to set the extension for the current image.
+%   \item \textbf{label:} Can be used to indicate a name for the corresponding graphic (otherwise, an automatic naming will be applied)
+% \end{itemize}
 %
-% \DescribeEnv{mgladdon} This environment adds its contents to the document's main script, but it doesn't produce any image. It doesn't require any kind of arguments. It is useful to add ``complementary code'', like loading of dynamic libraries, set default size for the graphics, etc.
+% \DescribeEnv{mgladdon} This environment adds its contents to the document's main script, but it doesn't produce any image. It doesn't require any kind of arguments. It is useful to add ``complementary code'', like instructions to load dynamic libraries, set default size for the graphics, etc.
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
 %   \end{tabular}
 % \end{center}
 %
-% \DescribeEnv{mglcode} It has the same function as the |mgl| environment, but the corresponding code is written to a separate script, whose name is specified as mandatory argument. It accepts the same optional arguments as |mgl|, except, of course, the |label| option.
+% \DescribeEnv{mglcode} It has the same function as the |mgl| environment, but the corresponding code is written to a separate script, whose name is specified as mandatory argument. It accepts the following optional arguments:
+% \begin{itemize}
+%   \item \textbf{bb, bbllx, bblly, bburx, bbury, natwidth, natheight, hiresbb, viewport, trim, angle, origin, width, height, totalheight, keepaspectratio, scale, clip, draft, type, ext, read, command:} These are the same options of the |\includegraphics| command from the \textsf{graphicx} package.
+%   \item \textbf{gray:} Can be used to activate (|gray=on| or |gray=1|) or deactivate (|gray=off| or |gray=0|) gray-scale mode privately (only for the current graphic).
+%   \item \textbf{mglscale:} Any positive value for this option is used to physically scale the resulting image file, i.g., |mglscale=2| will create an image file twice as bigger.
+%   \item \textbf{quality:} Sets the quality of the current graphic. Valid values are integers between |0| and |9|.
+%   \item \textbf{variant:} Sets the variant of argument for the commands in the current script.
+%   \item \textbf{imgext:} Can be used to set the extension for the current image.
+% \end{itemize}
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
 %   \end{tabular}
 % \end{center}
 %
-% \DescribeEnv{mglcommon} This is used to create a common ``setup'' script to define constants, parameters, etc. that will be available to the others.
+% \DescribeEnv{mglsetupscript} This is used to create a common ``setup'' script to define constants, parameters, etc. that will be available to the others.
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
-%     |\begin{mglcommon}|\\[0.5em]
+%     |\begin{mglsetupscript}|\\[0.5em]
 %       \hss\meta{MGL code}\hss\\[0.5em]
-%     |\end{mglcommon}|\\[0.25em]
+%     |\end{mglsetupscript}|\\[0.25em]
 %     \hline
 %   \end{tabular}
 % \end{center}
 %
 % For example, one could write
 % \begin{quote}
-%   |\begin{mglcommon}|\\
+%   |\begin{mglsetupscript}|\\
 %   |define gravity 9.81 # [m/s^2]|\\
-%   |\end{mglcommon}|
+%   |\end{mglsetupscript}|
 % \end{quote}
 % to make the constant \emph{gravity} available to every script.
 %
+% \DescribeEnv{mglcommon} This is a synomyn for the |mglsetupscript| environment. It is and will always be kept in \textsf{\mglTeX} for backwards compatibility with older versions of the package, but its use is \emph{deprecated}.
+% \begin{center}
+%   \begin{tabular}{l}
+%     \hline\\[-0.75em]
+%     |\begin{mglcommon}|\\[0.5em]
+%       \hss\meta{MGL code}\hss\\[0.5em]
+%     |\end{mglcommon}|\\[0.25em]
+%     \hline
+%   \end{tabular}
+% \end{center}
+%
 % \subsection{Fast creation of graphics}
 % \noindent\textsf{\mglTeX} defines a convenient way to work with many graphics that have exactly the same settings (same rotation angles, same type of grid, same lighting, etc.): instead of writing repetitive code every time it's needed, it can be stored inside a |mglsetup| environment, and then can be used when needed with the |\mglplot| command.
 %
 %   \end{tabular}
 % \end{center}
 %
-% \DescribeMacro{\mglplot} This command is used for fast generation of graphics with default settings, and can be used in parallel with the |mglsetup| environment. It accepts one mandatory argument which consists of MGL instructions, separated by the symbol ``:'', and can span through various text lines. It accepts the same optional arguments as the |mgl| environment, plus two additional ones, called |setup| and |separator|. The |setup| option specifies a keyword associated to a |mglsetup| block, which will be executed before the code in the mandatory argument. The |separator| option specifies a text symbol that will break the code in the mandatory argument into a new physical line in the main script every time is encountered.
+% \DescribeMacro{\mglplot} This command is used for fast generation of graphics with default settings, and can be used in parallel with the |mglsetup| environment. It accepts one mandatory argument which consists of MGL instructions, separated by the symbol ``:'', and can span through various text lines. It accepts the following optional arguments:
+% \begin{itemize}
+%   \item \textbf{bb, bbllx, bblly, bburx, bbury, natwidth, natheight, hiresbb, viewport, trim, angle, origin, width, height, totalheight, keepaspectratio, scale, clip, draft, type, ext, read, command:} These are the same options of the |\includegraphics| command from the \textsf{graphicx} package.
+%   \item \textbf{gray:} Can be used to activate (|gray=on| or |gray=1|) or deactivate (|gray=off| or |gray=0|) gray-scale mode privately (only for the current graphic).
+%   \item \textbf{mglscale:} Any positive value for this option is used to physically scale the resulting image file, e.g., |mglscale=2| will create an image file twice as bigger.
+%   \item \textbf{quality:} Sets the quality of the current graphic. Valid values are integers between |0| and |9|.
+%   \item \textbf{variant:} Sets the variant of argument for the commands in the current script.
+%   \item \textbf{imgext:} Can be used to set the extension for the current image.
+%   \item \textbf{label:} Can be used to indicate a name for the corresponding graphic (otherwise, an automatic naming will be applied)
+%   \item \textbf{setup:} Specifies a keyword associated to a |mglsetup| block, which will be executed before the code in the mandatory argument.
+%   \item \textbf{separator:} Specifies a text symbol that will break the code in the mandatory argument into a new physical line in the main script every time is encountered.
+% \end{itemize}
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
 % \end{center}
 %
 % \subsection{Verbatim-like environments}
-% \noindent The main purpose of these environments is to typeset their contents to the \LaTeX{} document, elegantly separated from the rest of the text. They have two versions: an unstarred version which can be listed later with the |\listofmglscripts| command (see below), and a starred version which won't be listed.
+% \noindent The main purpose of these environments is to typeset their contents to the \LaTeX{} document, elegantly separated from the rest of the text. They have two versions: an unstarred version which can be listed later with the |\listofmglscripts| command (explained later), and a starred version which won't be listed.
 %
-% Although these environments are intended to mimic the behavior of the |verbatim| environment from \LaTeX{}, there is an important difference, namely, long lines will be broken when the page margin is reached. This intended behavior is set because a language like MGL can easily have very long lines of code, like textual formulas, vectors input as lists of values, etc. Of course, no hyphenation will be performed, but the code will be indented in the second, third, etc. continuation lines by an amount specified by |\mglbreakindent| (see below).
+% Although these environments are intended to mimic the behavior of the |verbatim| environment from \LaTeX{}, there is an important difference, namely, long lines will be broken when the page margin is reached. This intended behavior is set because a language like MGL can easily have very long lines of code, like textual formulas, vectors input as lists of values, etc. Of course, no hyphenation will be performed, but the code will be indented in the second, third, etc. continuation lines by an amount specified by |\mglbreakindent| (explained later).
 %
-% \DescribeEnv{mglblock}\DescribeEnv{mglblock*} Besides typesetting its contents to the document, |mglblock| creates a script whose name is specified as mandatory argument. It also accepts one optional argument, called |lineno|, whose default value is |true|, used to activate (|lineno=true|) or deactivate (|lineno=false|) line numbering inside the environment. The default behavior is to number each line of code.
+% \DescribeEnv{mglblock}\DescribeEnv{mglblock*} Besides typesetting its contents to the document, |mglblock| creates a script whose name is specified as mandatory argument. It accepts one optional argument:
+% \begin{itemize}
+%   \item \textbf{lineno:} Used to activate (|lineno=true| or simply |lineno|) or deactivate (|lineno=false|) line numbering inside the environment.
+% \end{itemize}
+% By default, each line of code is numbered.
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
 % \begin{quote}
 %   \makeatletter
 %   \MGL@set@script@name{example_script}%
-%   \refstepcounter{MGL@verb@script@no}%
-%   \addcontentsline{lms}{MGL@script}{\protect\numberline{\theMGL@verb@script@no.}{\ttfamily\protect\detokenize{\MGL@script@name.mgl}}}%
+%   \refstepcounter{MGL@verb@no}%
+%   \addcontentsline{lms}{MGL@script}{\protect\numberline{\theMGL@verb@no.}{\ttfamily\protect\detokenize{\MGL@script.mgl}}}%
 %   \setcounter{MGL@line@no}{0}%
 %   \list{\mgllinenostyle\arabic{MGL@line@no}.}{}%
 %   \MGL@set@pseudo@verb@env
 %   \fboxrule=\mgllinethickness%
-%   \item[\MGL@line@sep]\fbox{\bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script@name.mgl}}\hskip\labelsep\MGL@line@sep\par\par%
+%   \item[\MGL@line@sep]\fbox{\bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script.mgl}}\hskip\labelsep\MGL@line@sep\par\par%
 %   \stepcounter{MGL@line@no}%
 %   \item new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)'
 %   \stepcounter{MGL@line@no}%
 %   \endlist%
 % \end{quote}
 %
-% \DescribeEnv{mglverbatim}\DescribeEnv{mglverbatim*} This environment only typesets its contents to the \LaTeX{} document without creating any script. It accepts the |lineno| option, with default value |true|, plus an one called |label|, intended to specify a name associated to the corresponding code. The default behavior is to number each line of code.
+% \DescribeEnv{mglverbatim}\DescribeEnv{mglverbatim*} This environment only typesets its contents to the \LaTeX{} document without creating any script. It accepts two optional arguments
+% \begin{itemize}
+%   \item \textbf{lineno:} Used to activate (|lineno=true| or simply |lineno|) or deactivate (|lineno=false|) line numbering inside the environment.
+%   \item \textbf{label:} Used to specify a name associated to the corresponding code.
+% \end{itemize}
+% The default behavior is to number each line of code.
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
 %   \fboxrule=\mgllinethickness%
 %   \MGL@set@script@name{\mglverbatimname}%
 %   \item[\MGL@line@sep]\hskip-\labelsep\MGL@line@sep%
-%   \refstepcounter{MGL@verb@script@no}%
-%   \addcontentsline{lms}{MGL@script}{\protect\numberline{\theMGL@verb@script@no.}{\ttfamily\protect\detokenize{\MGL@script@name}}}%
+%   \refstepcounter{MGL@verb@no}%
+%   \addcontentsline{lms}{MGL@script}{\protect\numberline{\theMGL@verb@no.}{\ttfamily\protect\detokenize{\MGL@script}}}%
 %   \stepcounter{MGL@line@no}%
 %   \item new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)'
 %   \stepcounter{MGL@line@no}%
 % \end{quote}
 % \noindent If a |label| is specified, the output will look exactly as that of the |mglblock| environment.
 %
-% \DescribeEnv{mglcomment} This environment is used to embed commentaries in the \LaTeX{} document. The commentary won't be visible in the case of the user passing the option |nocomments| to the package, but it will be typeset \emph{verbatim} to the document if the user passes the option |comments|.
+% \DescribeEnv{mglcomment} This environment is used to embed comments. The comment won't be visible in the case of the user passing the option |nocomments| to the package, but it will be typeset \emph{verbatim} to the document if the user passes the option |comments|.
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
 %     |\begin{mglcomment}|\\[0.5em]
-%       \hss\meta{Commentary}\hss\\[0.5em]
+%       \hss\meta{Comment}\hss\\[0.5em]
 %     |\end{mglcomment}|\\[0.25em]
 %     \hline
 %   \end{tabular}
 % \end{center}
-% If the user requests visible commentaries, this will result in the appearance of something like the following in the \LaTeX{} document:
+% If the user requests visible comments, this will result in the appearance of something like the following in the \LaTeX{} document:
 % \begin{quote}
 %   \makeatletter
 %   \list{}{}%
 %   \MGL@set@pseudo@verb@env
 %   \item\hskip-\labelsep<\MGL@dash@sep\mglcommentname\MGL@dash@sep>%
-%   \item This is a MGL commentary
+%   \item This is a mglTeX comment
 %   \item\hskip-\labelsep<\MGL@dash@sep\mglcommentname\MGL@dash@sep>%
 %   \endlist%
 % \end{quote}
 %
 % \subsection{Working with external scripts}
-% \noindent External scripts exist in their own files, independently of the \LaTeX{} document ---for example, a script sent by a colleague, a script created before the actual writing of the \LaTeX{} document, etc. \textsf{\mglTeX} provides convenient ways to deal with external scripts, as if they were embedded. It must be noted, however, that the package works on the suposition that these scripts are in their final version, so no change detection is performed on them. If a external script is changed, the corresponding graphic must be manually deleted in oreder to force recompilation.
+% \noindent \textsf{\mglTeX} provides convenient ways to deal with external scripts (scripts that exist in their own files, independently of the \LaTeX{} document, like scripts sent by a colleague or created before the actual writing of the \LaTeX{} document, etc). It must be noted, however, that the package works on the suposition that these scripts are in their final version, so no change detection is performed on them. If a external script is changed, the corresponding graphic must be manually deleted in oreder to force recompilation.
+%
+% \DescribeMacro{\mglgraphics} This command takes the name of an external MGL script as mandatory argument, which will be automatically executed, and the resulting image will be included. The same optional arguments accepted by this command are:
+% \begin{itemize}
+%   \item \textbf{bb, bbllx, bblly, bburx, bbury, natwidth, natheight, hiresbb, viewport, trim, angle, origin, width, height, totalheight, keepaspectratio, clip, draft, type, ext, read, command:} These are the same options of the |\includegraphics| command from the \textsf{graphicx} package.
+%   \item \textbf{gray:} Can be used to activate (|gray=on| or |gray=1|) or deactivate (|gray=off| or |gray=0|) gray-scale mode privately (only for the current graphic).
+%   \item \textbf{mglscale:} Any positive value for this option is used to physically scale the resulting image file, i.g., |mglscale=2| will create an image file twice as bigger.
+%   \item \textbf{quality:} Sets the quality of the current graphic. Valid values are integers between |0| and |9|.
+%   \item \textbf{variant:} Sets the variant of argument for the commands in the current script.
+%   \item \textbf{imgext:} Can be used to set the extension for the current image.
+%   \item \textbf{path:} Can be used to specify the location of the script.
+% \end{itemize}
 %
-% \DescribeMacro{\mglinclude}\DescribeMacro{\mglinclude*} This command is the equivalent of the |mglverbatim| environment for external scripts. It takes one mandatory argument, which is the name of a MGL script, which will be automatically transcript \emph{verbatim} on the \LaTeX{} document. It accepts the same optional arguments as the |\mglgraphics| command, plus the |lineno| option to activate/deactivate line numbering. There are unstarred version of this command will be listed if |\listofmglscripts| is used, while the starred version won't.
+% \DescribeMacro{\mglinclude}\DescribeMacro{\mglinclude*} This command is the equivalent of the |mglverbatim| environment for external scripts. It takes one mandatory argument, which is the name of a MGL script, which will be automatically transcript \emph{verbatim} on the \LaTeX{} document. It accepts the following optional arguments:
+% \begin{itemize}
+%   \item \textbf{lineno:} Used to activate (|lineno=true| or simply |lineno|) or deactivate (|lineno=false|) line numbering inside the environment.
+%   \item \textbf{path:} Can be used to specify the location of the script.
+% \end{itemize}
+% The unstarred version of this command will be listed if |\listofmglscripts| is used (explained later), while the starred version won't.
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
-%     |\mglinclude|\marg{script\_name}\oarg{key-val list}\\[0.25em]
+%     |\mglinclude|\oarg{key-val list}\marg{script\_name}\\[0.25em]
 %     \hline
 %   \end{tabular}
 % \end{center}
 %   \end{tabular}
 % \end{center}
 %
-% \DescribeMacro{\mglgraphics} This takes one mandatory argument, which is the name of an external MGL script, which will be automatically executed, and the resulting image will be included. The same optional arguments as the |\includegraphics| command are accepted, plus the |imgext| option to specify the extension of the resulting graphic, and an additional option, |path|, which can be used to specify the location of the script.
+% \subsection{Additional commands}
+% \DescribeMacro{\listofmglscripts}\noindent Opens a new section or chapter---depending on the \LaTeX{} class used---, where all the scripts that have been transcript in the document with the unstarred versions of the |mglblock| and |mglverbatim| environments, and the |\mglinclude| command, are listed. In case a |mglverbatim| is used, but no |label| is specified, the default name to display is specified by the |\mglverbatimname| macro (explained later), otherwise, the corresponding label is typeset.
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
-%     |\mglgraphics|\oarg{key-val list}\marg{script\_name}\\[0.25em]
+%     |\listofmglscripts|\\[0.25em]
 %     \hline
 %   \end{tabular}
 % \end{center}
+% The output is like this:
+% \begin{center}
+%   \begin{minipage}{0.9\textwidth}
+%     \listofmglscripts
+%   \end{minipage}
+% \end{center}
 %
-% \subsection{Additional commands}
-% \DescribeMacro{\mglname}\noindent This command can be used in the preamble of the document to indicate the name of the main script, passed as mandatory argument. If used after the |\begin{document}| command, it will force the closure of the current main script, create the corresponding graphics, and start a new script with the specified name.
+% \DescribeMacro{\mglTeX}\DescribeMacro{\mglTeX*} This command just pretty-prints the name of the package, i.e., the logo:
+% \begin{center}
+%   \Huge\mglTeX
+% \end{center}
+% The starred version will also print the version in a coherent manner.
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
-%     |\mglname|\marg{main\_script\_name}\\[0.25em]
+%     |\mglTeX|\\[0.25em]
+%     \hline
+%   \end{tabular}
+% \end{center}
+% \begin{center}
+%   \begin{tabular}{l}
+%     \hline\\[-0.75em]
+%     |\mglTeX*|\\[0.25em]
 %     \hline
 %   \end{tabular}
 % \end{center}
 %
-% The use of this command is encouraged when writing large documents, like books or thesis, to create a main script per document block (section, chapter, part, etc.). Since the |mgl| environment and the |\mglplot| command use an internal counter to automatically name scripts, unless the |label| option is used; if a new script is added this way to the document, it will alter the original numbering, causing \textsf{\mglTeX} to recompile the scripts from that point on (for more details, read subsection \ref{subsection: recompilation decision}). If the |\mglname| command is used, only the scripts of the current document block will be recompiled.
+% In an environment where the typesetting of the logo is impossible (a text editor, for instance), it can (and should) be replaced by ``mglTeX''.
 %
-% \DescribeMacro{\mglimgext} Can be used to specify the extension to save graphics. Its effect is local, meaning that the new quality will be applied from the point this command is used~on.
+% \subsection{Local settings commands}\label{local setts}
+% \noindent These commands are intended to be equivalent to the package options, but with a local-only effect, meaning that the new settings are applied from the point these commands are used onward.
+%
+% \DescribeMacro{\mglswitch} This command is equivalent to the package options |on| and |off|, depending on the argument passed.
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
-%     |\mglimgext|\marg{image extension}\\[0.25em]
+%     |\mglswitch{|\meta{off\,$\vert$on\,$\vert$0\,$\vert$1}|}|\\[0.25em]
+%     \hline
+%   \end{tabular}
+% \end{center}
+%
+% Observe that |\mglswitch{on}| and |\mglswitch{off}| can be used to save time when writing a document, wrapping a section with them, avoiding recompilation of the corresponding scripts.
+%
+% \DescribeMacro{\mglcomments} This command is equivalent to the package options |comments| and |nocomments|, depending on the argument passed.
+% \begin{center}
+%   \begin{tabular}{l}
+%     \hline\\[-0.75em]
+%     |\mglcomments{|\meta{off\,$\vert$on\,$\vert$0\,$\vert$1}|}|\\[0.25em]
+%     \hline
+%   \end{tabular}
+% \end{center}
+%
+% \DescribeMacro{\mglgray} It is equivalent to the package options |gray| and |color|, depending on the argument passed.
+% \begin{center}
+%   \begin{tabular}{l}
+%     \hline\\[-0.75em]
+%     |\mglgray{|\meta{off\,$\vert$on\,$\vert$0\,$\vert$1}|}|\\[0.25em]
+%     \hline
+%   \end{tabular}
+% \end{center}
+%
+% \DescribeMacro{\mglscale} Can be used to specify the default scaling for the creation of MGL graphics (1 is normal scaling, 2 is twice as bigger, etc.).
+% \begin{center}
+%   \begin{tabular}{l}
+%     \hline\\[-0.75em]
+%     |\mglscale|\marg{$x:x>0$}\\[0.25em]
 %     \hline
 %   \end{tabular}
 % \end{center}
 %     \hline
 %     $8$ & Draw dots instead of primitives (extremely fast)\\
 %     \hline
+%     $9$ & No drawing (for testing purposes)\\
+%     \hline
 %   \end{tabular}
 %   \MakeShortVerb{\|}
 % \end{center}
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
-%     |\mglquality|\marg{0$\vert$1$\vert$\ldots$\vert$8}\\[0.25em]
+%     |\mglquality|\marg{0\,$\vert$1\,$\vert$\ldots\,$\vert$9}\\[0.25em]
 %     \hline
 %   \end{tabular}
 % \end{center}
 %
-% \DescribeMacro{\mglscale} Can be used to specify the default scaling for the creation of MGL graphics (1 is normal scaling, 2 is twice as bigger, etc.). Its effect is local, meaning that the new scaling will be applied from the point this command is used on. Any non negative value can be specified.
+% \DescribeMacro{\mglvariant} It is useful to set the default variant of arguments for MGL commands.
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
-%     |\mglscale|\marg{1$\vert$2$\vert$\ldots$\vert$9}\\[0.25em]
+%     |\mglvariant|\marg{0\,$\vert$1\,$\vert$\ldots}\\[0.25em]
 %     \hline
 %   \end{tabular}
 % \end{center}
 %
-% \DescribeMacro{\mglswitch} This command is equivalent to the package options |on| and |off|, depending on the argument passed, but it's effect is local.
+% \DescribeMacro{\mglimgext} Can be used to specify the extension to save graphics.
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
-%     |\mglswitch{|\meta{on$\vert$off}|}|\\[0.25em]
+%     |\mglimgext|\marg{image extension}\\[0.25em]
 %     \hline
 %   \end{tabular}
 % \end{center}
 %
-% Observe that |\mglswitch{on}| and |\mglswitch{off}| can be used to save time when writing a document, wrapping a section with them, avoiding recompilation of the corresponding scripts.
-%
-% \DescribeMacro{\mglcomments} This command is equivalent to the package options |comments| and |nocomments|, depending on the argument passed, but its effect is local.
+% \DescribeMacro{\mglname}\noindent If used in the preamble of the document this commands just sets the name of the. If used after the |\begin{document}| command, it will force the closure of the current main script, create the corresponding graphics, and start a new main script with the specified name.
 % \begin{center}
 %   \begin{tabular}{l}
 %     \hline\\[-0.75em]
-%     |\mglcomments{|\meta{on$\vert$off$\vert$true$\vert$false}|}|\\[0.25em]
+%     |\mglname|\marg{main\_script\_name}\\[0.25em]
 %     \hline
 %   \end{tabular}
 % \end{center}
 %
-% \DescribeMacro{\listofmglscripts} Opens a new section or chapter---depending on the \LaTeX{} class used---, where all the scripts that have been transcript in the document with the unstarred versions of the |mglblock| and |mglverbatim| environments, and the |\mglinclude| command, are listed. In case a |mglverbatim| is used, but no |label| is specified, the default name to display is specified by the |\mglverbatimname| macro (see below), otherwise, the corresponding label is typeset.
-% \begin{center}
-%   \begin{tabular}{l}
-%     \hline\\[-0.75em]
-%     |\listofmglscripts|\\[0.25em]
-%     \hline
-%   \end{tabular}
-% \end{center}
-% The output is like this:
-% \begin{center}
-%   \begin{minipage}{0.9\textwidth}
-%     \listofmglscripts
-%   \end{minipage}
-% \end{center}
-%
-% \DescribeMacro{\mglTeX}\DescribeMacro{\mglTeX*} This command just pretty-prints the name of the package; if followed by an asterisk, it will also print the version, separated with an unbreakable space.
-% \begin{center}
-%   \begin{tabular}{l}
-%     \hline\\[-0.75em]
-%     |\mglTeX|\\[0.25em]
-%     \hline
-%   \end{tabular}
-% \end{center}
-% \begin{center}
-%   \begin{tabular}{l}
-%     \hline\\[-0.75em]
-%     |\mglTeX*|\\[0.25em]
-%     \hline
-%   \end{tabular}
-% \end{center}
+% The use of this command is encouraged when writing large documents, like books or thesis, to create a main script per document block (section, chapter, part, etc.). Since the |mgl| environment and the |\mglplot| command use an internal counter to automatically name scripts, unless the |label| option is used; if a new script is added this way to the document, it will alter the original numbering, causing \textsf{\mglTeX} to recompile the scripts from that point on (for more details, read subsection \ref{subsection: recompilation decision}). If the |\mglname| command is used, only the scripts of the current document block will be recompiled.
 %
-% \subsection{Advanced setup commands}
+% \subsection{Advanced settings commands}
 % \noindent Although \textsf{\mglTeX} is completely functional without any further set up, there are some parameters of its behavior that could be useful to modify. The following commands must be used in the preamble of the document only, since the first MGL script is created at the moment of the |\begin{document}| command, and otherwise they could create weird errors during compilation; trying to use them somewhere else will produce an error. 
 %
 % \DescribeMacro{\mgldir} This command can be used to specify the main working directory for \textsf{\mglTeX}. Inside it, the scripts, backup files and graphics will be created, or can be separated inside subdirectories. This is useful, for example, to avoid many scripts and graphics from polluting the directory where the \LaTeX{} document is.
 % \end{center}
 % This command can be used many times or can be used to specify many paths at once. In the case of using it many times, each call will add the new directory or directories to the list of searching paths.
 %
-% \DescribeMacro{mglsettings} This command has been added for the confort of the user, since it handles all of the basic and advanced settings of \textsf{\mglTeX}, as an alternative to some package options and commands. It takes one mandatory argument which should be a list of \meta{key}=\meta{value} pairs, according to the following table:
+% \DescribeMacro{\mglsettings} This command has been added for the confort of the user, since it handles all of the basic and advanced settings of \textsf{\mglTeX}, as an alternative to some package options and commands. It takes one mandatory argument which should be a list of \meta{key}=\meta{value} pairs, according to the following table:
 % \begin{center}
 %   \DeleteShortVerb{\|}
 %   \begin{tabular}{|l|l|l|}
 %     \hline
 %     paths & \meta{directory list} & Paths to external scripts\\
 %     \hline
-%     quality & \meta{0$\vert$1$\vert$\ldots$\vert$8} & Quality for creation of graphics\\
+%     switch & \meta{off\,$\vert$on\,$\vert$0\,$\vert$1} & Turn off/on \mglTeX\\
 %     \hline
-%     scale & \meta{1$\vert$2$\vert$\ldots$\vert$9} & Scale for creation of graphics\\
+%     comments & \meta{off\,$\vert$on\,$\vert$0\,$\vert$1} & Turn off/on comments\\
+%     \hline
+%     gray & \meta{off\,$\vert$on\,$\vert$0\,$\vert$1} & Turn off/on gray-scale mode\\
+%     \hline
+%     mglscale & \meta{$x:x>0$} & Scale for creation of graphics\\
+%     \hline
+%     quality & \meta{0\,$\vert$1\,$\vert$\ldots\,$\vert$9} & Quality for creation of graphics\\
+%     \hline
+%     variant & \meta{0\,$\vert$1\,$\vert$\ldots} & Variant of arguments for MGL commands\\
 %     \hline
 %     imgext & \meta{image extension} & Extension for creation of graphics\\
 %     \hline
 % \end{center}
 %
 % \subsection{User-definable macros}
-% \noindent There are macros that the user is allowed to modify in order to customize some aspects of the behavior of \textsf{\mglTeX}. For example, if writing in spanish, french or russian, the user would like to modify the name of the common script, the words typeset in the separator lines of MGL commentaries, the name of the list of MGL scripts, etc.
+% \noindent There are macros that the user is allowed to modify in order to customize some aspects of the behavior of \textsf{\mglTeX}. For example, if writing in spanish, french or russian, the user would like to modify the name of the common script, the words typeset in the separator lines of mglTeX comments, the name of the list of MGL scripts, etc.
 %
-% \DescribeMacro{\mglcommonscriptname} It is the name for the common script that takes the contents of the |mglcommon| environment. The default name is defined by
+% \DescribeMacro{\mglsetupscriptname} It is the name for the common setup script that takes the contents of the |mglseuptscipt| or |mglcommon| environments. The default name is defined by
 % \begin{quote}
-%   |\def\mglcommonscriptname{MGL_common_script}|
+%   |\def\mglsetupscriptname{MGL_setup_script}|
 % \end{quote}
 %
-% \DescribeMacro{\mglcommentname} This macro expands to the words typeset before and after a MGL commentary, in the middle of the separator lines. The default words are set by
+% \DescribeMacro{\mglcommentname} This macro expands to the words typeset before and after a \textsf{\mglTeX} comment, in the middle of the separator lines. The default words are set by
 % \begin{quote}
-%   |\def\mglcommentname{MGL commentary}|
+%   |\def\mglcommentname{\mglTeX{} comment}|
 % \end{quote}
 %
 % \DescribeMacro{\listofmglscriptsname} This is the name of the section/chapter created by the command |\listofmglscripts|. The default is set by
 % \StopEventually{\PrintChanges\PrintIndex}
 %
 % \section{Implementation}
-% \noindent This section documents the complete implementation of \textsf{\mglTeX}. It's main purpose is to facilitate the understanding and maintanance of the package's code. For the following, we use ``|@|'' in the name of macros the user should not modify; the prefix ``|MGL|'' is used to simulate a namespace, so the macros from \textsf{\mglTeX} won't interfere with the ones from other packages.
+% \noindent This section documents the complete code of \textsf{\mglTeX}. It's main purpose is to facilitate the understanding and maintanance of the package's code. For the following, we use ``|@|'' in the name of macros the user should not modify; the prefix ``|MGL|'' is used to simulate a namespace, so the macros from \textsf{\mglTeX} won't interfere with the ones from other packages.
 %
-% \subsection{Initialization}
+% \subsection{Initialization}\label{Init}
 % \noindent We first define some macros that will serve different purposes on different parts of the package.
+% \begin{macro}{\MGL@off}\begin{macro}{\MGL@on}\begin{macro}{\MGL@zero}\begin{macro}{\MGL@one}
+% These are used in the command |\MGL@test@switch| (explained later) to determine whether the user has passed one of the options |off|, |on|, |0| or |1| to a command.
+%    \begin{macrocode}
+\def\MGL@off{off}
+\def\MGL@on{on}
+\def\MGL@zero{0}
+\def\MGL@one{1}
+%    \end{macrocode}
+% \end{macro}\end{macro}\end{macro}\end{macro}
+% \begin{macro}{\MGL@test@switch}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New command to verify and validate switching arguments}
+% It is called by a command to test whether the user has passed the option |off|, |on|, |0| (equivalent to |off|) or |1| (equivalent to |on|); if the option is correct, it is replaced by its equivalent, otherwise, a warning is issued. It takes two arguments: the first one is the option to test, the second one is the name of the command calling this macro.
+%    \begin{macrocode}
+\def\MGL@test@switch#1#2{%
+  \def\MGL@temp@a{#1}%
+  \ifx\MGL@temp@a\MGL@on%
+  \else\ifx\MGL@temp@a\MGL@off%
+  \else\ifx\MGL@temp@a\MGL@one%
+    \def\MGL@temp@a{on}%
+  \else\ifx\MGL@temp@a\MGL@zero%
+    \def\MGL@temp@a{off}%
+  \else%
+    \PackageWarning{mgltex}{%
+      Unrecognizable option "#1" passed to command \protect#2%
+    }%
+  \fi\fi\fi\fi%
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\MGL@TeX@ext}
-% Is used to determine whether the user has chosen to save graphics in \LaTeX/Tikz format.
+% Is used in the command |\MGL@includegraphics| (explained later) to determine whether the user has chosen to save graphics in \LaTeX/Tikz format.
 %    \begin{macrocode}
 \def\MGL@TeX@ext{.tex}
 %    \end{macrocode}
 % \end{macro}
 %
-% The macros |\MGL@switch@on| and |\MGL@switch@off| are called when the package options |on| and |off| are passed, respectively.
+% The macros |\MGL@switch@on| and |\MGL@switch@off| are called when the package options |on| and |off| are passed, respectively, or when the commands |\mglswitch{on}| and |\mglswitch{off}| are used, respectively.
 % \begin{macro}{\MGL@switch@on}
 % (Re)defines the commands to open, read, write and close scripts, and the command that includes MGL graphics.
 %    \begin{macrocode}
 %    \begin{macrocode}
   \def\MGL@includegraphics{%
 %    \end{macrocode}
-% First checks if the image exists. Note the |\MGL@dir| and |\MGL@graphics@dir| macros are set by the user with the |\mgldir| and |\mglgraphicsdir| commands, respectively, while |\MGL@script@name| stores the name of the script ---and thus the image--- executed, and |\MGL@graph@ext| is the extension chosen by the user to save the graphics.
+% First checks if the image exists. Note the |\MGL@dir| and |\MGL@graphics@dir| macros are set by the user with the |\mgldir| and |\mglgraphicsdir| commands, respectively, while |\MGL@script| stores the name of the script ---and thus the image--- executed, and |\MGL@imgext| is the extension chosen by the user to save the graphics.
 %    \begin{macrocode}
-    \IfFileExists{\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext}{%
+    \IfFileExists{\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext}{%
 %    \end{macrocode}
 % If the chosen extension is |.tex|, a \LaTeX/Tikz file has been created, which has to be simply included in the document; it will be automatically compiled by \LaTeX{}. (Observe we use the |\MGL@TeX@ext| macro defined above.)
 %    \begin{macrocode}
-      \ifx\MGL@graph@ext\MGL@TeX@ext%
-        \include{\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext}%
+      \ifx\MGL@imgext\MGL@TeX@ext%
+        \include{\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext}%
 %    \end{macrocode}
 % If the chosen extension is not |.tex|, a normal visual image has been created, so the |\includegraphics| command is invoked to deal with it. The options for this command (like |scale|, |angle|, etc.) are stored in the |\MGL@graph@keys| macro, which is defined by every environment or command that creates and compiles MGL scripts, according to the optional arguments the user has passed.
 %    \begin{macrocode}
       \else%
         \expandafter\includegraphics\expandafter[\MGL@graph@keys]{%
-          \MGL@dir\MGL@graphics@dir\MGL@script@name%
+          \MGL@dir\MGL@graphics@dir\MGL@script%
         }%
       \fi%
     }{%
 %    \end{macrocode}
 % If the requested image doesn't exist, the issue a warning message for the user, and print a warning framed box (``\textbf{MGL image not found}'') in the place the image should occupy.
 %    \begin{macrocode}
-      \PackageWarning{mgltex}{MGL image "\MGL@script@name" not found}%
+      \PackageWarning{mgltex}{MGL image "\MGL@script" not found}%
       \fbox{%
         \centering%
         \bfseries\Huge%
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@MGL@comments@on}\begin{macro}{\@MGL@comments@off}
-% We will need a boolean switch to activate/deactivate commentaries later.
+% \begin{macro}{\@MGL@comments@off}\begin{macro}{\@MGL@comments@on}
+% We will need a boolean switch to activate/deactivate comments later.
 %    \begin{macrocode}
 
+\def\@MGL@comments@off{\let\if@MGL@comments@\iffalse}
 \def\@MGL@comments@on{\let\if@MGL@comments@\iftrue}
-\def\@MGL@comments@off{\let\if@mglcomments@\iffalse}
 %    \end{macrocode}
 % \end{macro}\end{macro}
 %
+% \begin{macro}{\MGL@gray}\begin{macro}{\MGL@gray@off}\begin{macro}{\MGL@gray@on}
+% The commands |\MGL@gray@off| and |\MGL@gray@on| simply set the value of |\MGL@gray| to $0$ and $1$, respectively; this value will be used later through the |-g| command line option from |mglconv|.
+%    \begin{macrocode}
+
+\def\MGL@gray@off{\def\MGL@gray{0}}
+\def\MGL@gray@on{\def\MGL@gray{1}}
+%    \end{macrocode}
+% \end{macro}\end{macro}\end{macro}
+% \begin{macro}{\mglgray}
+% Depending on the option passed by the user, it calls |\@MGL@gray@on| or |\@MGL@gray@off|.
+%    \begin{macrocode}
+\def\mglgray#1{%
+  \MGL@test@switch{#1}{\mglgray}%
+  \csname @MGL@gray@\MGL@temp@a\endcsname%
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\mglscale}\begin{macro}{\MGL@scale}
-% |\mglscale| sets the value of the |\MGL@scale| macro, which is used later to specify the default scaling for graphics. It only accepts integer values from $1$ to $9$, otherwise it issues a warning and restarts the scaling to $1$. In order to be able to check the validity of the value passed by the user, we first set the |\MGL@scale| macro to that value and test it with the |\ifcase| conditional; if the value is valid, we do nothing, but if it is invalid, we issue a warning and overwrite |\MGL@scale| to $1$.
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Now accepts any positive value}
+% |\mglscale| sets the value of the |\MGL@scale| macro, which is used later to specify the default scaling for graphics. It only accepts positive values, otherwise it issues a warning and restarts the scaling to $1$. In order to be able to check the validity of the value passed by the user, we first set the |\MGL@scale| macro to that value and test it with the |\ifdim| conditional.\footnote{We can't use \doccommand{ifnum} here because it only accepts integer values.} Since this conditional tests dimensions only, the value passed by the user is multiplied by |\p@| (value |1pt|), so it can be compared with |\z@| (value |0pt|).
 %    \begin{macrocode}
 
 \def\mglscale#1{
-  \def\MGL@scale{#1}%
-  \ifcase\MGL@scale\or\or\or\or\or\or\or\or\else%
+  \ifdim#1\p@>\z@%
+    \def\MGL@scale{#1}%
+  \else%
     \PackageWarning{mgltex}{%
-      Scaling value of \MGL@scale\space not allowed; using default (1)%
+      Scaling value of #1\space not allowed; using default (1)%
     }%
     \def\MGL@scale{1}%
   \fi%
 % \end{macro}\end{macro}
 %
 % \begin{macro}{\mglquality}\begin{macro}{\MGL@quality}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{\texttt{9} is accepted as quality value now}
 % |\mglquality| sets the value of the |\MGL@quality| macro, which is used later to specify the default quality for graphics. It only accepts integer values from $0$ to $8$ (the only ones defined by |MathGL|), otherwise it issues a warning and restarts to $2$ (the default for |MathGL|). In order to be able to check the validity of the value passed by the user, we first set the |\MGL@quality| macro to that value and test it with the |\ifcase| conditional; if the value is valid, we print an info message to the |.log| file about the characteristics of the chosen quality, but if it is invalid, we issue a warning and overwrite |\MGL@scale| to $2$.
-% \end{macro}\end{macro}
 %    \begin{macrocode}
 
 \def\mglquality#1{%
     }%
   \or%
     \PackageInfo{mgltex}{%
-      Quality 4: No face drawing, direct bitmap drawing (low memory usage)%
+      Quality 4: No face drawing, direct bitmap drawing
+      (low memory usage)%
     }%
   \or%
     \PackageInfo{mgltex}{%
-      Quality 5: No color interpolation, direct bitmap drawing (low memory usage)%
+      Quality 5: No color interpolation, direct bitmap drawing
+      (low memory usage)%
     }%
   \or%
     \PackageInfo{mgltex}{%
     }%
   \or%
     \PackageInfo{mgltex}{%
-      Quality 7: High quality with 3d primitives, direct bitmap drawing (not implemented yet)%
+      Quality 7: High quality with 3d primitives, direct bitmap drawing %
+      (not implemented yet)%
     }%
   \or%
     \PackageInfo{mgltex}{%
       Quality 8: Draw dots instead of primitives (extremely fast)%
     }%
+  \or%
+    \PackageInfo{mgltex}{%
+      Quality 9: No drawing (for testing purposes)%
+    }%
   \else%
     \PackageWarning{mgltex}{%
       Quality #1 not available; using default (2)%
   \fi%
 }
 %    \end{macrocode}
+% \end{macro}\end{macro}
+%
+% \begin{macro}{\mglvariant}\begin{macro}{\MGL@variant}
+% |\mglvariant| sets the value of the |\MGL@variant| macro, which is passed later to |mglconv| thorugh its |-v| command line option. It only accepts non-negative integer, otherwise it issues a warning and restarts to $0$ (the default for |MathGL|). In order to be able to check the validity of the value passed by the user, we use the |\ifnum| conditional; if the value is invalid we issue a warning and overwrite |\MGL@variant| to $0$.
+%    \begin{macrocode}
+
+\def\mglvariant#1{%
+  \def\MGL@variant{#1}%
+  \ifnum\MGL@variant<0%
+    \PackageWarning{mgltex}{%
+      Variant #1 not allowed; using default (0)%
+    }%
+    \def\MGL@variant{0}%
+  \fi%
+}
+%    \end{macrocode}
+% \end{macro}\end{macro}
 %
 % Now we declare the options |final| and |draft|, which are simply passed to the \textsf{graphicx} package.
 %    \begin{macrocode}
   \PassOptionsToPackage{\CurrentOption}{graphicx}%
 }
 %    \end{macrocode}
-% Now we can declare the package options |on| and |off| so that they execute |\MGL@switch@on| and |\MGL@switch@off|, respectively.
+%
+% The rest of the package options just call an adequate command or set an adequate value for a macro.
 %    \begin{macrocode}
+
 \DeclareOption{on}{\MGL@switch@on}
 \DeclareOption{off}{\MGL@switch@off}
-%    \end{macrocode}
-% Now, the options call the respective commands.
-%    \begin{macrocode}
+
 \DeclareOption{nocomments}{\@MGL@comments@off}
 \DeclareOption{comments}{\@MGL@comments@on}
-%    \end{macrocode}
-% The pacakage options |1x|, \ldots, |9x| just call |\mglscale| with the appropiate value.
-%    \begin{macrocode}
-\DeclareOption{1x}{\mglscale{1}}
-\DeclareOption{2x}{\mglscale{2}}
-\DeclareOption{3x}{\mglscale{3}}
-\DeclareOption{4x}{\mglscale{4}}
-\DeclareOption{5x}{\mglscale{5}}
-\DeclareOption{6x}{\mglscale{6}}
-\DeclareOption{7x}{\mglscale{7}}
-\DeclareOption{8x}{\mglscale{8}}
-\DeclareOption{9x}{\mglscale{9}}
-%    \end{macrocode}
-% The package options |0q|, \ldots, |8q| just call |\mglquality| with the appropiate value.
-%    \begin{macrocode}
-\DeclareOption{0q}{\mglquality{0}}
-\DeclareOption{1q}{\mglquality{1}}
-\DeclareOption{2q}{\mglquality{2}}
-\DeclareOption{3q}{\mglquality{3}}
-\DeclareOption{4q}{\mglquality{4}}
-\DeclareOption{5q}{\mglquality{5}}
-\DeclareOption{6q}{\mglquality{6}}
-\DeclareOption{7q}{\mglquality{7}}
-\DeclareOption{8q}{\mglquality{8}}
+
+\DeclareOption{gray}{\MGL@gray@on}
+\DeclareOption{color}{\MGL@gray@off}
+
+\DeclareOption{1x}{\def\MGL@scale{1}}
+\DeclareOption{2x}{\def\MGL@scale{2}}
+\DeclareOption{3x}{\def\MGL@scale{3}}
+\DeclareOption{4x}{\def\MGL@scale{4}}
+\DeclareOption{5x}{\def\MGL@scale{5}}
+\DeclareOption{6x}{\def\MGL@scale{6}}
+\DeclareOption{7x}{\def\MGL@scale{7}}
+\DeclareOption{8x}{\def\MGL@scale{8}}
+\DeclareOption{9x}{\def\MGL@scale{9}}
+
+\DeclareOption{0q}{\def\MGL@quality{0}}
+\DeclareOption{1q}{\def\MGL@quality{1}}
+\DeclareOption{2q}{\def\MGL@quality{2}}
+\DeclareOption{3q}{\def\MGL@quality{3}}
+\DeclareOption{4q}{\def\MGL@quality{4}}
+\DeclareOption{5q}{\def\MGL@quality{5}}
+\DeclareOption{6q}{\def\MGL@quality{6}}
+\DeclareOption{7q}{\def\MGL@quality{7}}
+\DeclareOption{8q}{\def\MGL@quality{8}}
+\DeclareOption{9q}{\def\MGL@quality{9}}
+
+\DeclareOption{0v}{\def\MGL@variant{0}}
+\DeclareOption{1v}{\def\MGL@variant{1}}
+\DeclareOption{2v}{\def\MGL@variant{2}}
 %    \end{macrocode}
 %
-% \begin{macro}{\MGL@graph@ext}
-% The following options set the default graphics extension, which is stored in the |\MGL@graph@ext| macro for later use.
+% \begin{macro}{\MGL@imgext}
+% The following options set the default graphics extension, which is stored in the |\MGL@imgext| macro for later use.
 %    \begin{macrocode}
 
-\DeclareOption{eps}{\def\MGL@graph@ext{.eps}}
-\DeclareOption{epsz}{\def\MGL@graph@ext{.epsz}}
-\DeclareOption{epsgz}{\def\MGL@graph@ext{.eps.gz}}
-\DeclareOption{bps}{\def\MGL@graph@ext{.bps}}
-\DeclareOption{bpsz}{\def\MGL@graph@ext{.bpsz}}
-\DeclareOption{bpsgz}{\def\MGL@graph@ext{.bps.gz}}
-\DeclareOption{pdf}{\def\MGL@graph@ext{.pdf}}
-\DeclareOption{png}{\def\MGL@graph@ext{.png}}
-\DeclareOption{jpg}{\def\MGL@graph@ext{.jpg}}
-\DeclareOption{jpeg}{\def\MGL@graph@ext{.jpeg}}
-\DeclareOption{gif}{\def\MGL@graph@ext{.gif}}
-\DeclareOption{tex}{\def\MGL@graph@ext{.tex}}
+\DeclareOption{eps}{\def\MGL@imgext{.eps}}
+\DeclareOption{epsz}{\def\MGL@imgext{.epsz}}
+\DeclareOption{epsgz}{\def\MGL@imgext{.eps.gz}}
+\DeclareOption{bps}{\def\MGL@imgext{.bps}}
+\DeclareOption{bpsz}{\def\MGL@imgext{.bpsz}}
+\DeclareOption{bpsgz}{\def\MGL@imgext{.bps.gz}}
+\DeclareOption{pdf}{\def\MGL@imgext{.pdf}}
+\DeclareOption{png}{\def\MGL@imgext{.png}}
+\DeclareOption{jpg}{\def\MGL@imgext{.jpg}}
+\DeclareOption{jpeg}{\def\MGL@imgext{.jpeg}}
+\DeclareOption{gif}{\def\MGL@imgext{.gif}}
+\DeclareOption{tex}{\def\MGL@imgext{.tex}}
 %    \end{macrocode}
 % \end{macro}
 %
 % We now declare the default package options, and, finally, process the options the user specifies in the order they are introduced.
 %    \begin{macrocode}
 
-\ExecuteOptions{final,on,nocomments,1x,2q,eps}
+\ExecuteOptions{final,on,nocomments,color,1x,2q,0v,eps}
 \ProcessOptions*
 %    \end{macrocode}
 %
-% \textsf{\mglTeX} requires the \textsf{keyval} package to define \meta{key}=\meta{value} options for the environments and commands; the \textsf{graphicx} package apports the facilities for inclusion of graphics, and the \textsf{verbatim} package is used as engine for the environments.
-%    \begin{macrocode}
-
-\RequirePackage{keyval}
-\RequirePackage{graphicx}
-\RequirePackage{verbatim}
-%    \end{macrocode}
-%
-% \begin{macro}{\MGL@graph@keys}
-% The main family of \meta{key}=\meta{value} pairs is defined. These pairs are common to every environment or command that produces graphics. Most of the \meta{key}'s are redefinitions of the optional arguments for the |\includegraphics| commands, so they are stored inside the |\MGL@graph@keys| macro, which is later passed to that command as optional argument by |\MGL@includegraphics|.
-%    \begin{macrocode}
-
-\define@key{MGL@keys}{bb}{\g@addto@macro\MGL@graph@keys{bb=#1,}}
-\define@key{MGL@keys}{bbllx}{\g@addto@macro\MGL@graph@keys{bbllx=#1,}}
-\define@key{MGL@keys}{bblly}{\g@addto@macro\MGL@graph@keys{bblly=#1,}}
-\define@key{MGL@keys}{bburx}{\g@addto@macro\MGL@graph@keys{bburx=#1,}}
-\define@key{MGL@keys}{bbury}{\g@addto@macro\MGL@graph@keys{bbury=#1,}}
-\define@key{MGL@keys}{natwidth}{\g@addto@macro\MGL@graph@keys{natwidth=#1,}}
-\define@key{MGL@keys}{natheight}{\g@addto@macro\MGL@graph@keys{natheight=#1,}}
-\define@key{MGL@keys}{hiresbb}{\g@addto@macro\MGL@graph@keys{hiresbb=#1,}}
-\define@key{MGL@keys}{viewport}{\g@addto@macro\MGL@graph@keys{viewport=#1,}}
-\define@key{MGL@keys}{trim}{\g@addto@macro\MGL@graph@keys{trim=#1,}}
-\define@key{MGL@keys}{angle}{\g@addto@macro\MGL@graph@keys{angle=#1,}}
-\define@key{MGL@keys}{origin}{\g@addto@macro\MGL@graph@keys{origin=#1,}}
-\define@key{MGL@keys}{width}{\g@addto@macro\MGL@graph@keys{width=#1,}}
-\define@key{MGL@keys}{height}{\g@addto@macro\MGL@graph@keys{height=#1,}}
-\define@key{MGL@keys}{totalheight}{\g@addto@macro\MGL@graph@keys{totalheight=#1,}}
-\define@key{MGL@keys}{keepaspectratio}[true]{%
-  \g@addto@macro\MGL@graph@keys{keepaspectratio=#1,}%
-}
-\define@key{MGL@keys}{scale}{\g@addto@macro\MGL@graph@keys{scale=#1,}}
-\define@key{MGL@keys}{clip}[true]{\g@addto@macro\MGL@graph@keys{clip=#1,}}
-\define@key{MGL@keys}{draft}[true]{\g@addto@macro\MGL@graph@keys{draft=#1,}}
-\define@key{MGL@keys}{type}{\g@addto@macro\MGL@graph@keys{type=#1,}}
-\define@key{MGL@keys}{ext}{\g@addto@macro\MGL@graph@keys{ext=#1,}}
-\define@key{MGL@keys}{read}{\g@addto@macro\MGL@graph@keys{read=#1,}}
-\define@key{MGL@keys}{command}{\g@addto@macro\MGL@graph@keys{command=#1,}}
-%    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\MGL@graph@ext}
-% Stores the default extension for the creation of the graphics.
-%    \begin{macrocode}
-\define@key{MGL@keys}{imgext}{\def\MGL@graph@ext{.#1}}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@MGL@lineno@}
-% The only \meta{key}=\meta{value} pair needed for verbatim-like environments and commands is the one for the |lineno| option, which sets the value of the |\@MGL@lineno@| boolean macro.
-%    \begin{macrocode}
-
-\newif\if@MGL@lineno@
-\define@key{MGL@verb@keys}{lineno}[true]{\csname @MGL@lineno@#1\endcsname}
-%    \end{macrocode}
-% \end{macro}
-%
 % \begin{macro}{\MGL@dir}
 % This is the \textsf{\mglTeX} main working directory. By default, it is defined to empty, so it points to the path of the \LaTeX{} document.
 %    \begin{macrocode}
 \def\MGL@paths{\MGL@dir\MGL@scripts@dir,\MGL@dir\MGL@backups@dir}
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{\mglsettings}
-% First, we define a \meta{key}=\meta{value} family, |MGL@sett@keys|, for the |\mglsettings| command.
-%    \begin{macrocode}
-\define@key{MGL@sett@keys}{dir}{\def\MGL@dir{#1}}
-\define@key{MGL@sett@keys}{scriptsdir}{\def\MGL@scripts@dir{#1}}
-\define@key{MGL@sett@keys}{graphicsdir}{\def\MGL@graphics@dir{#1}}
-\define@key{MGL@sett@keys}{backupsdir}{\def\MGL@backups@dir{#1}}
-\define@key{MGL@sett@keys}{paths}{\g@addto@macro\MGL@paths{,#1}}
-\define@key{MGL@sett@keys}{quality}{\mglquality{#1}}
-\define@key{MGL@sett@keys}{scale}{\mglscale{#1}}
-\define@key{MGL@sett@keys}{imgext}{\def\MGL@graph@ext{.#1}}
-%    \end{macrocode}
-% The command receives and executes the \meta{key}=\meta{value} pairs for |MGL@sett@keys|. This is an only-preamble command.
-%    \begin{macrocode}
-\def\mglsettings#1{\setkeys{MGL@sett@keys}{#1}}
-\@onlypreamble\mglsettings
-%    \end{macrocode}
-% \end{macro}
 %
 % \begin{macro}{\MGL@main@script@name}
 % \noindent This macro stores the name of the of the document's main script. It is initialized to the name of the \LaTeX{} document.
 \newcounter{MGL@line@no}
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{MGL@verb@script@no}
+% \begin{macro}{MGL@verb@no}
 % The counter used to numerate verbatim-written scripts with the |\listofmglscripts| command.
 %    \begin{macrocode}
-\newcounter{MGL@verb@script@no}
+\newcounter{MGL@verb@no}
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\@MGL@list@script@}
 \def\l@MGL@script{\@dottedtocline{1}{0em}{1.5em}}
 %    \end{macrocode}
 % \end{macro}
-% Finally, the supported graphic formats are declared, and the |\verbatim@finish| command from the \textsf{verbatim} package is disabled to avoid it from writing a blank line at the end of every script (see subsection~\ref{subsection: warning}).
+%
+% \textsf{\mglTeX} requires the \textsf{keyval} package to define \meta{key}=\meta{value} options for the environments and commands; the \textsf{graphicx} package apports the facilities for inclusion of graphics; the \textsf{ifpdf} package is used to determine whether the user is compiling to |pdf| or not when indicating the default graphics extensionsthe \textsf{verbatim} package is used as engine for the environments.
+%    \begin{macrocode}
+
+\RequirePackage{keyval}
+\RequirePackage{graphicx}
+\RequirePackage{ifpdf}
+\RequirePackage{verbatim}
+%    \end{macrocode}
+%
+% The supported graphic extensions are declared. These extensions depend on whether we are compiling to |pdf| or not, so the |\ifpdf| conditional from the homonym package is used.
+%    \begin{macrocode}
+\ifpdf%
+  \DeclareGraphicsExtensions{%
+    .pdf,.png,.jpg,.jpeg,.gif%
+  }%
+\else%
+  \DeclareGraphicsExtensions{%
+    .eps,.epsz,.eps.gz,.bps,.bpsz,.bps.gz%
+  }%
+\fi%
+%    \end{macrocode}
+% Finally, the |\verbatim@finish| command from the \textsf{verbatim} package is disabled to avoid it from writing a blank line at the end of every script (see subsection~\ref{subsection: warning}).
 %    \begin{macrocode}
-\DeclareGraphicsExtensions{%
-  .eps,.epsz,.eps.gz,.bps,.bpsz,.bps.gz,.pdf,.png,.jpg,.jpeg,.gif%
-}
 \let\verbatim@finish\relax
 %    \end{macrocode}
 %
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\MGL@graph@keys}
+% The main family of \meta{key}=\meta{value} pairs is defined. These pairs are common to every environment or command that produces graphics. Most of the \meta{key}'s are redefinitions of the optional arguments for the |\includegraphics| commands, so they are stored inside the |\MGL@graph@keys| macro, which is later passed to that command as optional argument by |\MGL@includegraphics|.
+%    \begin{macrocode}
+
+\define@key{MGL@gr@keys}{bb}{%
+  \g@addto@macro\MGL@graph@keys{bb=#1,}%
+}
+\define@key{MGL@gr@keys}{bbllx}{%
+  \g@addto@macro\MGL@graph@keys{bbllx=#1,}%
+}
+\define@key{MGL@gr@keys}{bblly}{%
+  \g@addto@macro\MGL@graph@keys{bblly=#1,}%
+}
+\define@key{MGL@gr@keys}{bburx}{%
+  \g@addto@macro\MGL@graph@keys{bburx=#1,}%
+}
+\define@key{MGL@gr@keys}{bbury}{%
+  \g@addto@macro\MGL@graph@keys{bbury=#1,}%
+}
+\define@key{MGL@gr@keys}{natwidth}{%
+  \g@addto@macro\MGL@graph@keys{natwidth=#1,}%
+}
+\define@key{MGL@gr@keys}{natheight}{%
+  \g@addto@macro\MGL@graph@keys{natheight=#1,}%
+}
+\define@key{MGL@gr@keys}{hiresbb}{%
+  \g@addto@macro\MGL@graph@keys{hiresbb=#1,}%
+}
+\define@key{MGL@gr@keys}{viewport}{%
+  \g@addto@macro\MGL@graph@keys{viewport=#1,}%
+}
+\define@key{MGL@gr@keys}{trim}{%
+  \g@addto@macro\MGL@graph@keys{trim=#1,}%
+}
+\define@key{MGL@gr@keys}{angle}{%
+  \g@addto@macro\MGL@graph@keys{angle=#1,}%
+}
+\define@key{MGL@gr@keys}{origin}{%
+  \g@addto@macro\MGL@graph@keys{origin=#1,}%
+}
+\define@key{MGL@gr@keys}{width}{%
+  \g@addto@macro\MGL@graph@keys{width=#1,}%
+}
+\define@key{MGL@gr@keys}{height}{%
+  \g@addto@macro\MGL@graph@keys{height=#1,}%
+}
+\define@key{MGL@gr@keys}{totalheight}{%
+  \g@addto@macro\MGL@graph@keys{totalheight=#1,}%
+}
+\define@key{MGL@gr@keys}{keepaspectratio}[true]{%
+  \g@addto@macro\MGL@graph@keys{keepaspectratio=#1,}%
+}
+\define@key{MGL@gr@keys}{scale}{%
+  \g@addto@macro\MGL@graph@keys{scale=#1,}%
+}
+\define@key{MGL@gr@keys}{clip}[true]{%
+  \g@addto@macro\MGL@graph@keys{clip=#1,}%
+}
+\define@key{MGL@gr@keys}{draft}[true]{%
+  \g@addto@macro\MGL@graph@keys{draft=#1,}%
+}
+\define@key{MGL@gr@keys}{type}{%
+  \g@addto@macro\MGL@graph@keys{type=#1,}%
+}
+\define@key{MGL@gr@keys}{ext}{%
+  \g@addto@macro\MGL@graph@keys{ext=#1,}%
+}
+\define@key{MGL@gr@keys}{read}{%
+  \g@addto@macro\MGL@graph@keys{read=#1,}%
+}
+\define@key{MGL@gr@keys}{command}{%
+  \g@addto@macro\MGL@graph@keys{command=#1,}%
+}
+%    \end{macrocode}
+% \end{macro}
+% The following four \meta{key}=\meta{value} pairs call the adequate \textsf{\mglTeX} command.
+%    \begin{macrocode}
+\define@key{MGL@gr@keys}{gray}[0]{\mglgray{#1}}
+\define@key{MGL@gr@keys}{mglscale}{\mglscale{#1}}
+\define@key{MGL@gr@keys}{quality}{\mglquality{#1}}
+\define@key{MGL@gr@keys}{variant}{\mglvariant{#1}}
+%    \end{macrocode}
+% \begin{macro}{\MGL@imgext}
+% |\MGL@imgext| stores the default extension for the creation of the graphics.
+%    \begin{macrocode}
+\define@key{MGL@gr@keys}{imgext}{\def\MGL@imgext{.#1}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@MGL@lineno@}
+% The only \meta{key}=\meta{value} pair needed for verbatim-like environments and commands is the one for the |lineno| option, which sets the value of the |\@MGL@lineno@| boolean macro.
+%    \begin{macrocode}
+
+\newif\if@MGL@lineno@
+\define@key{MGL@verb@keys}{lineno}[true]{\csname @MGL@lineno@#1\endcsname}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\MGL@codes}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Bugfix: category code for tabulators is changed too}
 % This macro changes the category codes of all special characters (like |\|, |$|, etc.) to $12$ (other), so they don't have any special meaning and can be processed as normal text. The exception is the new line character (|^^M|), which is kept active for compatibility with the \textsf{verbatim} package.
 %    \begin{macrocode}
 
 \def\MGL@codes{%
   \let\do\@makeother\dospecials%
+  \catcode`\^^I=12%
   \catcode`\^^M\active%
 }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\MGL@document@scripts}
+% \begin{macro}{\MGL@doc@scripts}
 % A macro to store the names of the scripts created or compiled in the document.
 %    \begin{macrocode}
 
-\def\MGL@document@scripts{}
+\def\MGL@doc@scripts{}
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{\MGL@set@script@name}\begin{macro}{\MGL@script@name}
-% |\MGL@set@script@name| receives the name of a script without extension as argument, defines |\MGL@script@name| as that name, and checks if it has already been created or compiled, by comparing it with the names already stored in |\MGL@document@scripts|; if it's there already, warns the user. Finally, adds the name of the script to |\MGL@document@scripts|.
+% \begin{macro}{\MGL@set@script@name}\begin{macro}{\MGL@script}
+% |\MGL@set@script@name| receives the name of a script without extension as argument, defines |\MGL@script| as that name, and checks if it has already been created or compiled, by comparing it with the names already stored in |\MGL@doc@scripts|; if it's there already, warns the user. Finally, adds the name of the script to |\MGL@doc@scripts|.
 %    \begin{macrocode}
 \def\MGL@set@script@name#1{%
-  \edef\MGL@script@name{#1}%
-  \@for\MGL@temp@a:=\MGL@document@scripts\do{%
-    \ifx\MGL@temp@a\MGL@script@name%
-      \PackageWarning{mgltex}{Multiple MGL scripts named "\MGL@script@name.mgl"}%
+  \edef\MGL@script{#1}%
+  \@for\MGL@temp@a:=\MGL@doc@scripts\do{%
+    \ifx\MGL@temp@a\MGL@script%
+      \PackageWarning{mgltex}{Multiple MGL scripts named "\MGL@script.mgl"}%
     \fi%
   }%
-  \g@addto@macro\MGL@document@scripts{\MGL@script@name,}%
+  \g@addto@macro\MGL@doc@scripts{\MGL@script,}%
 }
 %    \end{macrocode}
 % \end{macro}\end{macro}
 % \end{macro}
 %
 % \begin{macro}{\MGL@process@script}
-% It checks whether the ``switch'' |\MGL@@@\MGL@script@name| is undefined, in which case executes its first argument. If the switch is defined, it checks if the corresponding image has been created; if so, it executes its second argument; otherwise, the first one.
+% It checks whether the ``switch'' |\MGL@@@\MGL@script| is undefined, in which case executes its first argument. If the switch is defined, it checks if the corresponding image has been created; if so, it executes its second argument; otherwise, the first one.
 %    \begin{macrocode}
 
 \def\MGL@process@script#1#2{%
-  \@ifundefined{MGL@@@\MGL@script@name}{%
+  \@ifundefined{MGL@@@\MGL@script}{%
     #1%
   }{%
-    \IfFileExists{\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext}{%
+    \IfFileExists{\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext}{%
       #2%
     }{%
       #1%
 \def\MGL@compare@code#1{%
 %    \end{macrocode}
 % \begin{macro}{\MGL@next}
-% This macro is called at the end of environments that use the |\MGL@compare@code| macro, and performs the ending actions of the comparision process, which are closing the |\MGL@in@stream| and writing the |\MGL@unchanged{\MGL@script@name}| to the |.aux| file. If during the comparison process a difference in the code is found, |\MGL@next| is redefined to only close the |\MGL@in@stream|.
+% This macro is called at the end of environments that use the |\MGL@compare@code| macro, and performs the ending actions of the comparision process, which are closing the |\MGL@in@stream| and writing the |\MGL@unchanged{\MGL@script}| to the |.aux| file. If during the comparison process a difference in the code is found, |\MGL@next| is redefined to only close the |\MGL@in@stream|.
 %    \begin{macrocode}
   \def\MGL@next{%
     \MGL@closein\MGL@in@stream%
-    \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script@name}}%
+    \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script}}%
   }%
 %    \end{macrocode}
 % \end{macro}
 % \noindent For the following, we agree that if a macro is required by an environment, and it hasn't been already defined, it will be defined between the commands that start and end such environment; also the command's name will have the environment's name as prefix.
 %
 % \begin{environment}{mgl}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New environment options: \texttt{gray}, \texttt{mglscale}, \texttt{quality}, \texttt{variant}}
 % This environment has to transcript its contents to the document's main script, and create a backup of the code simultaneously; the backup is used to detect changes in following compilations.
 % \begin{macro}{\mgl}
 % The command that starts the |mgl| environment. It is called by the |\begin{mgl}| command.
 %    \end{macrocode}
 % We define an additional \meta{key}=\meta{value} pair in the main family of pairs, corresponding to the |label| option for this environment. This definition is local because we don't want to be valid outside the environment.
 %    \begin{macrocode}
-  \define@key{MGL@keys}{label}{\def\MGL@script@name{##1}}%
+  \define@key{MGL@gr@keys}{label}{\def\MGL@script{##1}}%
 %    \end{macrocode}
 % The list of comma-separated options is processed.
 %    \begin{macrocode}
-  \MGL@setkeys{MGL@keys}{#1}%
+  \MGL@setkeys{MGL@gr@keys}{#1}%
 %    \end{macrocode}
 % If the user hasn't used the |label| option, the automatic naming mechanism is called. Note that |\MGL@main@script@name| is set using the |\mglname| command.
 %    \begin{macrocode}
-  \@ifundefined{MGL@script@name}{%
+  \@ifundefined{MGL@script}{%
     \stepcounter{MGL@script@no}%
-    \edef\MGL@script@name{\MGL@main@script@name-MGL-\arabic{MGL@script@no}}%
+    \edef\MGL@script{\MGL@main@script@name-MGL-\arabic{MGL@script@no}}%
   }{}%
 %    \end{macrocode}
 % We use the |\MGL@set@script@name| to test whether the given name has already been used.
 %    \begin{macrocode}
-  \MGL@set@script@name{\MGL@script@name}%
+  \MGL@set@script@name{\MGL@script}%
 %    \end{macrocode}
 % |\MGL@codes| is used to change the codes of special characters.
 %    \begin{macrocode}
   \MGL@process@script{%
     \MGL@write@script%
   }{%
-    \MGL@compare@code{\MGL@dir\MGL@backups@dir\MGL@script@name.mgl}%
+    \MGL@compare@code{\MGL@dir\MGL@backups@dir\MGL@script.mgl}%
   }%
 }
 %    \end{macrocode}
 \def\MGL@write@script{%
 %    \end{macrocode}
 % \begin{macro}{\MGL@next}
-% It contains the actions to perform immediately after the end of |\MGL@write@script|. They are close the output stream; write in the main script the commands to save the image, and to reset the initial values for all MGL parameters and clear the image; finally, write |\MGL@unchanged{\MGL@script@name}| in the |.aux| file.
+% It contains the actions to perform immediately after the end of |\MGL@write@script|. They are close the output stream; write in the main script the commands to save the image, and to reset the initial values for all MGL parameters and clear the image; finally, write |\MGL@unchanged{\MGL@script}| in the |.aux| file.
 %    \begin{macrocode}
   \def\MGL@next{%
     \MGL@closeout\MGL@out@stream%
     \MGL@write\MGL@main@stream{%
-      write '\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext'^^J%
+      write '\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext'^^J%
       ^^Jreset^^J%
     }%
-    \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script@name}}%
+    \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script}}%
   }%
 %    \end{macrocode}
 % \end{macro}
     \MGL@write\MGL@out@stream{\the\verbatim@line}%
   }%
 %    \end{macrocode}
-% Before writing the MGL code of the environment, we set the default quality.
+% Before writing the MGL code of the environment, we set the default gray/color mode, mglscale, quality and variant.
 %    \begin{macrocode}
-  \MGL@write\MGL@main@stream{quality \MGL@quality}%
+  \MGL@write\MGL@main@stream{%
+    gray \MGL@gray^^J%
+    setsizescl \MGL@scale^^J%
+    quality \MGL@quality^^J%
+    variant \MGL@variant%
+  }%
 %    \end{macrocode}
 % We open the backup file in the output stream.
 %    \begin{macrocode}
-  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@backups@dir\MGL@script@name.mgl}%
+  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@backups@dir\MGL@script.mgl}%
 %    \end{macrocode}
 % The transcription process starts by calling the |\verbatim@start| command.
 %    \begin{macrocode}
 %    \end{macrocode}
 % The backup file is opened for writing.
 %    \begin{macrocode}
-  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@backups@dir\MGL@script@name.mgl}%
+  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@backups@dir\MGL@script.mgl}%
 %    \end{macrocode}
 % The head of the function is written.
 %    \begin{macrocode}
-  \MGL@write\MGL@out@stream{func '\MGL@script@name' #1}%
+  \MGL@write\MGL@out@stream{func '\MGL@script' #1}%
 %    \end{macrocode}
 % The writing process is started.
 %    \begin{macrocode}
 % \end{environment}
 %
 % \begin{environment}{mglcode}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New environment options: \texttt{gray}, \texttt{mglscale}, \texttt{quality}, \texttt{variant}}
 % This environment also checks for changes on the code, but, since it writes to its own script, there is no need to create a backup file (the check is performed using the script itself).
 % \begin{macro}{\mglcode}
 % It starts the |mglcode| environment. Its anatomy is similar to that of the |\mgl| command.
 %    \begin{macrocode}
 
 \newcommand\mglcode[2][]{%
-  \MGL@setkeys{MGL@keys}{#1}%
+  \MGL@setkeys{MGL@gr@keys}{#1}%
   \MGL@set@script@name{#2}%
   \MGL@codes%
   \MGL@process@script{%
     \mglcode@write@script%
   }{%
-    \MGL@compare@code{\MGL@dir\MGL@scripts@dir\MGL@script@name.mgl}%
+    \MGL@compare@code{\MGL@dir\MGL@scripts@dir\MGL@script.mgl}%
   }%
 }
 %    \end{macrocode}
 %    \begin{macrocode}
     \MGL@closeout\MGL@out@stream%
 %    \end{macrocode}
-% The |\MGL@unchanged{\MGL@script@name}| command is written to the |.aux| file.
+% The |\MGL@unchanged{\MGL@script}| command is written to the |.aux| file.
 %    \begin{macrocode}
-    \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script@name}}%
+    \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script}}%
 %    \end{macrocode}
 % The script compilation instruction is written to the terminal.
 %    \begin{macrocode}
     \MGL@write{18}{%
-      mglconv -q \MGL@quality\space -S \MGL@scale\space%
-      -s "\MGL@dir\MGL@scripts@dir\mglcommonscriptname.mgl"\space%
-      -o "\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext"\space%
-      "\MGL@dir\MGL@scripts@dir\MGL@script@name.mgl"%
+      mglconv -q \MGL@quality\space -g \MGL@gray\space%
+      -S \MGL@scale\space -v \MGL@variant\space%
+      -s "\MGL@dir\MGL@scripts@dir\mglsetupscriptname.mgl"\space%
+      -o "\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext"\space%
+      "\MGL@dir\MGL@scripts@dir\MGL@script.mgl"%
     }%
   }%
 %    \end{macrocode}
 %    \end{macrocode}
 % The script is opened for writing in the output stream.
 %    \begin{macrocode}
-  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script@name.mgl}%
+  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script.mgl}%
 %    \end{macrocode}
 % The writing process is started by calling the |\verbatim@start| command.
 %    \begin{macrocode}
   \MGL@set@script@name{#1}%
   \MGL@codes%
   \def\verbatim@processline{\MGL@write\MGL@out@stream{\the\verbatim@line}}%
-  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script@name.mgl}%
+  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script.mgl}%
   \verbatim@start%
 }
 %    \end{macrocode}
 % \end{macro}
 % \end{environment}
 %
-% \begin{environment}{mglcommon}
-% This environment doesn't require any backup file nor any scanning for changes. Although the user sets the name of the script by redifining |\mglcommonscriptname|, it is necessary to perform a check of the name, just in case a name has been inadvertedly repeated.
-% \begin{macro}{\mglcommon}
-% Starts the |mglcommon| environment.
+% \begin{environment}{mglsetupscript}\begin{environment}{mglcommon}
+% This environment doesn't require any backup file nor any scanning for changes. Although the user sets the name of the script by redifining |\mglsetupscriptname|, it is necessary to perform a check of the name, just in case a name has been inadvertedly repeated.
+% \begin{macro}{\mglsetupscript}
+% Starts the |mglsetupscript| environment.
 %    \begin{macrocode}
 
-\def\mglcommon{%
+\def\mglsetupscript{%
   \@bsphack%
-  \MGL@set@script@name{\mglcommonscriptname}%
+  \MGL@set@script@name{\mglsetupscriptname}%
   \MGL@codes%
   \def\verbatim@processline{\MGL@write\MGL@out@stream{\the\verbatim@line}}%
-  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script@name.mgl}%
+  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script.mgl}%
   \verbatim@start%
 }
 %    \end{macrocode}
 % It is declared to be an only-preamble command, so it can't be used after the |\begin{document}| instruction.
 %    \begin{macrocode}
+\@onlypreamble\mglsetupscript
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\mglcommon}
+% This macro is defined to be a synonym for |\mglcommon| (to keep backwards compatibility).
+%    \begin{macrocode}
+\let\mglcommon\mglsetupscript
 \@onlypreamble\mglcommon
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{\endmglcommon}
-% It ends the |mglcommon| environment.
+% \begin{macro}{\endmglsetupscript}
+% It ends the |mglsetupscript| environment.
 %    \begin{macrocode}
-\def\endmglcommon{%
+\def\endmglsetupscript{%
   \MGL@closeout\MGL@out@stream%
   \@esphack%
 }
 %    \end{macrocode}
 % \end{macro}
-% \end{environment}
+% \begin{macro}{\endmglcommon}
+% It is defined to be a synonym for |\endmglsetupscript|.
+%    \begin{macrocode}
+\let\endmglcommon\endmglsetupscript
+%    \end{macrocode}
+% \end{macro}
+% \end{environment}\end{environment}
 %
 % \subsection{Fast creation of graphics}
 % \begin{environment}{mglsetup}
 % This environment is meant to contain code that is executed just before the instruction of a |\mglplot| command, producing always the same ouput. Instead of writing a new chunk of code for that purpose, |mglsetup| is defined as a special case of the |mglfunc| environment, with the exception that the MGL function obtained this way doesn't accept any argument ---thus producing always the same output.
 % \begin{macro}{\mglsetup}
-% It is defined as an alias for |\mglfunc|, but only the name of the MGL function is passed to it, forcing the assumption that the number of arguments for the function is zero.
+% It is defined as an alias for |\mglfunc|, but only the name of the MGL function is passed to it, forcing the assumption that its number of arguments is zero.
 %    \begin{macrocode}
 
 \def\mglsetup#1{\mglfunc{#1}}%
 % \end{environment}
 %
 % \begin{macro}{\mglplot}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Added \doccommand{bgroup} and \doccommand{egroup} in order to keep changes private}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New command options: \texttt{gray}, \texttt{mglscale}, \texttt{quality}, \texttt{variant}}
 % Although the function of this command is quite simple and straightforward, it requires many lines of code and some tricks in order to reach the desired functionality.
 %    \begin{macrocode}
 
 \newcommand\mglplot[2][]{%
 %    \end{macrocode}
+% Since this is a command, we need to explicitly create a local group so that all changes keep private to the command.\footnote{In contrast, environments keep changes private by default.}
+%    \begin{macrocode}
+  \bgroup%
+%    \end{macrocode}
 % We add some \meta{key}=\meta{value} pairs locally. The |label| key works exactly as the one of the |mgl| environment.
 %    \begin{macrocode}
-  \define@key{MGL@keys}{label}{\edef\MGL@script@name{##1}}%
+  \define@key{MGL@gr@keys}{label}{\edef\MGL@script{##1}}%
 %    \end{macrocode}
 % The |setup| key defines the variable |\MGL@mglplot@setup| which is later used to call a setup function for the corresponding image.
 %    \begin{macrocode}
-  \define@key{MGL@keys}{setup}{\def\MGL@mglplot@setup{##1}}%
+  \define@key{MGL@gr@keys}{setup}{\def\MGL@mglplot@setup{##1}}%
 %    \end{macrocode}
 % The |separator| key uses the |\MGL@def@for@loop| to define |\MGL@for| so that it iterates over lists separated by the indicated separator symbol.
 %    \begin{macrocode}
-  \define@key{MGL@keys}{separator}{%
-    \MGL@def@for@loop{##1}%
-  }%
+  \define@key{MGL@gr@keys}{separator}{\MGL@def@for@loop{##1}}%
 %    \end{macrocode}
 % Now, we process the keys passed by the user.
 %    \begin{macrocode}
-  \MGL@setkeys{MGL@keys}{#1}%
+  \MGL@setkeys{MGL@gr@keys}{#1}%
 %    \end{macrocode}
 % If the user hasn't specified a name using the |label| option, then a name is autogenerated following the same naming mechanism of the |mgl| environment.
 %    \begin{macrocode}
-  \@ifundefined{MGL@script@name}{%
+  \@ifundefined{MGL@script}{%
     \stepcounter{MGL@script@no}
-    \edef\MGL@script@name{\MGL@main@script@name-MGL-\arabic{MGL@script@no}}
+    \edef\MGL@script{\MGL@main@script@name-MGL-\arabic{MGL@script@no}}
   }{}%
 %    \end{macrocode}
 % The name of the script is checked.
 %    \begin{macrocode}
-  \MGL@set@script@name{\MGL@script@name}%
+  \MGL@set@script@name{\MGL@script}%
 %    \end{macrocode}
 % If the user hasn't specified a setup, then the only code that has to be written is the non-optional argument of |\mglplot|; it is stored in the temporary variable |\MGL@temp@a|.
 %    \begin{macrocode}
     \mglplot@compare@code%
   }%
 %    \end{macrocode}
-% Finally, the corresponding image is included in the document.
+% The corresponding image is included in the document.
 %    \begin{macrocode}
   \MGL@includegraphics%
+%    \end{macrocode}
+% Finally, the local group is closed.
+%    \begin{macrocode}
+  \egroup%
 }
 %    \end{macrocode}
 % \begin{macro}{\mglplot@write@script}
 %    \end{macrocode}
 % The default quality is written to the main script.
 %    \begin{macrocode}
-  \MGL@write\MGL@main@stream{quality \MGL@quality}%
+  \MGL@write\MGL@main@stream{%
+    gray \MGL@gray^^J%
+    setsizescl \MGL@scale^^J%
+    quality \MGL@quality^^J%
+    variant \MGL@variant%
+  }%
 %    \end{macrocode}
 % The backup file is opened to write in the output stream.
 %    \begin{macrocode}
-  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@backups@dir\MGL@script@name.mgl}%
+  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@backups@dir\MGL@script.mgl}%
 %    \end{macrocode}
 % Now we use the |\MGL@for| command to iterate over |\MGL@temp@a|. It takes a piece of code up to the separator symbol indicated by the user, and stores it in the temporary variable |\MGL@temp@b|, which is then written to the main script and backup file.
 %    \begin{macrocode}
 % The instructions to save the image and reset the MGL parameters are written to the main script.
 %    \begin{macrocode}
   \MGL@write\MGL@main@stream{%
-    write '\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext'^^J%
+    write '\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext'^^J%
     ^^Jreset^^J%
   }%
 %    \end{macrocode}
-% Finally, |\MGL@unchanged{\MGL@script@name}| is written to the |.aux| file.
+% Finally, |\MGL@unchanged{\MGL@script}| is written to the |.aux| file.
 %    \begin{macrocode}
-  \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script@name}}%
+  \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script}}%
 }
 %    \end{macrocode}
 % \end{macro}
 %    \begin{macrocode}
 \def\mglplot@compare@code{%
 %    \end{macrocode}
-% The action that will finish this command is, for now, to write |\MGL@unchanged{\MGL@script@name}| in the |.aux| file; it is stored in the |\MGL@next| variable. If no changes in the code are found, this will remain as the last action; otherwise, it will be overwritten to do nothing.
+% The action that will finish this command is, for now, to write |\MGL@unchanged{\MGL@script}| in the |.aux| file; it is stored in the |\MGL@next| variable. If no changes in the code are found, this will remain as the last action; otherwise, it will be overwritten to do nothing.
 %    \begin{macrocode}
-  \def\MGL@next{\MGL@write\@auxout{\string\MGL@unchanged{\MGL@script@name}}}%
+  \def\MGL@next{\MGL@write\@auxout{\string\MGL@unchanged{\MGL@script}}}%
 %    \end{macrocode}
 % The backup file is opened for reading in the input stream.
 %    \begin{macrocode}
-  \MGL@openin\MGL@in@stream{\MGL@dir\MGL@backups@dir\MGL@script@name.mgl}%
+  \MGL@openin\MGL@in@stream{\MGL@dir\MGL@backups@dir\MGL@script.mgl}%
 %    \end{macrocode}
 % Once again, the |\MGL@for| command is used to iterate over the |\MGL@temp@a| variable defined by |\mglplot|. Pieces of code are taken up to the appearance of the separator symbol indicated by the user. In every iteration, the corresponding piece of code is stored in the |\MGL@temp@b| variable, one line of code is read from the input stream to the variable |\MGL@temp@c|, and these two are compared; if they are different, we redefined |\MGL@next| to do nothing.
 %    \begin{macrocode}
 %    \begin{macrocode}
   \MGL@set@script@name{#2}%
 %    \end{macrocode}
-% If the switch |\@MGL@list@script@| is true, we increase the counter for verbatim code (|MGL@verb@script@no|), and add a contents line to the |.lms| file, using the style set by |\l@MGL@script|. In order to be able to use special characters in the name of the script, we use the |\detokenize| primitive.
+% If the switch |\@MGL@list@script@| is true, we increase the counter for verbatim code (|MGL@verb@no|), and add a contents line to the |.lms| file, using the style set by |\l@MGL@script|. In order to be able to use special characters in the name of the script, we use the |\detokenize| primitive.
 %    \begin{macrocode}
   \if@MGL@list@script@%
-    \refstepcounter{MGL@verb@script@no}%
+    \refstepcounter{MGL@verb@no}%
     \addcontentsline{lms}{MGL@script}{%
-      \protect\numberline{\theMGL@verb@script@no.}%
-      {\ttfamily\protect\detokenize{\MGL@script@name.mgl}}%
+      \protect\numberline{\theMGL@verb@no.}%
+      {\ttfamily\protect\detokenize{\MGL@script.mgl}}%
     }%
   \fi%
 %    \end{macrocode}
 % The separator to indicate the begining of the verbatim code is positioned; we use the |\MGL@line@sep| command to draw it.
 %    \begin{macrocode}
   \item[\MGL@line@sep]\fbox{%
-    \bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script@name.mgl}%
+    \bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script.mgl}%
   }\hskip\labelsep\MGL@line@sep\par\par%
 %    \end{macrocode}
 % The |\verbatim@processline| is redefined to put |\the\verbatim@line| in an item of the list, and to to also write it to the script file.
 %    \end{macrocode}
 % The script file is opened for writing.
 %    \begin{macrocode}
-  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script@name.mgl}%
+  \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script.mgl}%
 %    \end{macrocode}
 % The writing process starts.
 %    \begin{macrocode}
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\endmglblock*}
-% It's defined as an alias for |\endmglblock|.
+% It is defined as an alias for |\endmglblock|.
 %    \begin{macrocode}
 \expandafter\let\csname endmglblock*\endcsname\endmglblock
 %    \end{macrocode}
 %    \begin{macrocode}
 \newcommand\mglverbatim@[1][]{%
   \@MGL@lineno@true%
-  \define@key{MGL@verb@keys}{label}{\edef\MGL@script@name{##1}}%
+  \define@key{MGL@verb@keys}{label}{\edef\MGL@script{##1}}%
   \setkeys{MGL@verb@keys}{#1}%
   \if@MGL@lineno@%
     \list{\mgllinenostyle\arabic{MGL@line@no}.}{\usecounter{MGL@line@no}}%
   \MGL@set@verbatim@code%
   \fboxrule=\mgllinethickness%
 %    \end{macrocode}
-% The separator that indicates the begining of the verbatim code is different depending on whether the user has specified a name associated to the code or not. If no name has been indicated, i.e., |\MGL@script@name| is undefined, the separator is just a line; otherwise, i.e., |\MGL@script@name| is defined, the separator is similar to the one of the |mglblock| environment.
+% The separator that indicates the begining of the verbatim code is different depending on whether the user has specified a name associated to the code or not. If no name has been indicated, i.e., |\MGL@script| is undefined, the separator is just a line; otherwise, i.e., |\MGL@script| is defined, the separator is similar to the one of the |mglblock| environment.
 %    \begin{macrocode}
-  \@ifundefined{MGL@script@name}{%
-    \edef\MGL@script@name{\mglverbatimname}%
+  \@ifundefined{MGL@script}{%
+    \edef\MGL@script{\mglverbatimname}%
     \item[\MGL@line@sep]\hskip-\labelsep\MGL@line@sep%
   }{%
     \item[\MGL@line@sep]\fbox{%
-      \bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script@name.mgl}%
+      \bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script.mgl}%
     }\hskip\labelsep\MGL@line@sep\par\par%
   }%
 %    \end{macrocode}
 % Note that, if the user requests an entry in the |\listofmglscripts|, the contents line is added to the same |.lms| file. So here start the similitudes again.
 %    \begin{macrocode}
   \if@MGL@list@script@%
-    \refstepcounter{MGL@verb@script@no}%
+    \refstepcounter{MGL@verb@no}%
     \addcontentsline{lms}{MGL@script}{%
-      \protect\numberline{\theMGL@verb@script@no.}%
-      {\ttfamily\protect\detokenize{\MGL@script@name}}%
+      \protect\numberline{\theMGL@verb@no.}%
+      {\ttfamily\protect\detokenize{\MGL@script}}%
     }%
   \fi%
   \def\verbatim@processline{%
 % \end{environment}
 %
 % \begin{environment}{mglcomment}
-% This environment has two different behaviors: When commentaries are allowed by the user, it behaves similarly to the |mglverbatim| environment; if commentaries are not allowed, it behaves as the |comment| environment from the \textsf{verbatim} package. So it is natural that we borrow code from them and adapt it to the corresponding situation.
+% This environment has two different behaviors: When comments are allowed by the user, it behaves similarly to the |mglverbatim| environment; if comments are not allowed, it behaves as the |comment| environment from the \textsf{verbatim} package. So it is natural that we borrow code from them and adapt it to the corresponding situation.
 % \begin{macro}{\mglcomment}
 % The switch |\@MGL@comments@| governs the behavior of this command.
 %    \begin{macrocode}
 
 \def\mglcomment{%
 %    \end{macrocode}
-% If the switch is true, i.e., the user requests displaying of commentaries, we start a list without labels, and set the parameters for verbatim text.
+% If the switch is true, i.e., the user requests displaying of comments, we start a list without labels, and set the parameters for verbatim text.
 %    \begin{macrocode}
   \if@MGL@comments@%
     \list{}{}%
     \MGL@set@verbatim@code%
 %    \end{macrocode}
-% The separator indicating the begining of the commentary is similar to the one used by the |mglblock| and |mglverbatim| environments; the differences are that, instead of using a solid line, we use a dashed line (|\MGL@dash@sep|), and instead of displaying the name of a script, we display |\mglcommentname|.
+% The separator indicating the begining of the comment is similar to the one used by the |mglblock| and |mglverbatim| environments; the differences are that, instead of using a solid line, we use a dashed line (|\MGL@dash@sep|), and instead of displaying the name of a script, we display |\mglcommentname|.
 %    \begin{macrocode}
     \item\hskip-\labelsep<\MGL@dash@sep\mglcommentname\MGL@dash@sep>%
 %    \end{macrocode}
-% The two following lines redefine the |\verbatim@processline| command to display the commentary text line by line as items of the list, and start the process of writing the text.
+% The two following lines redefine the |\verbatim@processline| command to display the comment text line by line as items of the list, and start the process of writing the text.
 %    \begin{macrocode}
     \def\verbatim@processline{\item\the\verbatim@line}%
     \verbatim@start%
 %    \end{macrocode}
-% If the switch is false, i.e., the user requests no to display commentaries, we start a \emph{space hack}, since no text output will be produced. Then, the category codes are changed with |\MGL@codes|, and the macros |\verbatim@startline|, |\verbatim@addtoline|, |\verbatim@processline| and |\verbatim@finish| are disabled, as done in the |comment| environment of the \textsf{verbatim} package. Finally, we call the |\verbatim@| command to start reading the text in the environment.
+% If the switch is false, i.e., the user requests no to display comments, we start a \emph{space hack}, since no text output will be produced. Then, the category codes are changed with |\MGL@codes|, and the macros |\verbatim@startline|, |\verbatim@addtoline|, |\verbatim@processline| and |\verbatim@finish| are disabled, as done in the |comment| environment of the \textsf{verbatim} package. Finally, we call the |\verbatim@| command to start reading the text in the environment.
 %    \begin{macrocode}
   \else%
     \@bsphack%
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\endmglcomment}
-% The |\@MGL@comments@| switch also governs the behavior of this command. If it's true, then the separator that ends the commentary ---which is the same as the one that starts it--- is displayed, and the list is ended; otherwise, simply the \emph{space hack} is ended.
+% The |\@MGL@comments@| switch also governs the behavior of this command. If it's true, then the separator that ends the comment ---which is the same as the one that starts it--- is displayed, and the list is ended; otherwise, simply the \emph{space hack} is ended.
 %    \begin{macrocode}
 \def\endmglcomment{%
   \if@MGL@comments@%
 % \noindent Since external scripts exist independently of the \LaTeX{} document, there is no need of environments to process them, just commands. Remember these commands work on the suposition that the scripts don't change.
 %
 % \begin{macro}{\mglgraphics}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New command options: \texttt{gray}, \texttt{mglscale}, \texttt{quality}, \texttt{variant}}
 % This command compiles the external script and includes it in the document. Although that process is simple, the code to execute it is relatively large due to the possibility of the user specifying an optional path, so many parameters have to be checked.
 %    \begin{macrocode}
 
 %    \end{macrocode}
 % We add the option |path| for the user to be able to specify the location of the script, which is stored in the variable |\MGL@force@path|.
 %    \begin{macrocode}
-  \define@key{MGL@keys}{path}{\def\MGL@forced@path{##1}}%
+  \define@key{MGL@gr@keys}{path}{\def\MGL@forced@path{##1}}%
 %    \end{macrocode}
 % The optional arguments are processed.
 %    \begin{macrocode}
-  \MGL@setkeys{MGL@keys}{#1}%
+  \MGL@setkeys{MGL@gr@keys}{#1}%
 %    \end{macrocode}
 % The name of the script is set, though it is not check for multiple naming. This is necessary, since |\MGL@includegraphics| uses this macro.
 %    \begin{macrocode}
-  \edef\MGL@script@name{#2}%
+  \edef\MGL@script{#2}%
 %    \end{macrocode}
 % If the corresponding image exists, then this script has been compiled in a previous \LaTeX{} run, so nothing is done, but the inclusion of the image.
 %    \begin{macrocode}
-  \IfFileExists{\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext}{}{%
+  \IfFileExists{\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext}{}{%
 %    \end{macrocode}
 % If the image doesn't exist, we check if the user has specified a custom location.
 %    \begin{macrocode}
 % If no custom location has been used, we iterate over the list of search paths (|\MGL@paths|): If we find the requested script, then we store its location in |\MGL@temp@b|.
 %    \begin{macrocode}
       \@for\MGL@temp@a:=\MGL@paths\do{%
-        \IfFileExists{\MGL@temp@a\MGL@script@name.mgl}{%
+        \IfFileExists{\MGL@temp@a\MGL@script.mgl}{%
           \edef\MGL@temp@b{\MGL@temp@a}%
         }{}%
       }%
 %    \end{macrocode}
 % If the user has specified a path for the script, we check if the script actually exists. If it does, we store its location inside |\MGL@temp@b|.
 %    \begin{macrocode}
-      \IfFileExists{\MGL@forced@path\MGL@script@name.mgl}{%
+      \IfFileExists{\MGL@forced@path\MGL@script.mgl}{%
         \edef\MGL@temp@b{\MGL@forced@path}%
       }{}%
     }%
 %    \begin{macrocode}
     \@ifundefined{MGL@temp@b}{%
       \PackageWarning{mgltex}{%
-        MGL script "\MGL@script@name.mgl" not found%
+        MGL script "\MGL@script.mgl" not found%
       }%
     }{%
 %    \end{macrocode}
 % If |\MGL@temp@b| is defined, the script has been found, so we compile it.
 %    \begin{macrocode}
       \MGL@write{18}{%
-        mglconv -q \MGL@quality\space -S \MGL@scale\space%
-        -s "\MGL@dir\MGL@scripts@dir\mglcommonscriptname.mgl"\space%
-        -o "\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext"\space%
-        "\MGL@temp@b\MGL@script@name.mgl"%
+        mglconv -q \MGL@quality\space -g \MGL@gray\space%
+        -S \MGL@scale\space -v \MGL@variant\space%
+        -s "\MGL@dir\MGL@scripts@dir\mglsetupscriptname.mgl"\space%
+        -o "\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext"\space%
+        "\MGL@temp@b\MGL@script.mgl"%
       }%
     }%
   }%
 %    \begin{macrocode}
   \setkeys{MGL@verb@keys}{#1}%
 %    \end{macrocode}
-% We don't need to check if there are multiple scripts with the same name, so we namually set |\MGL@script@name|, instead of using |\MGL@set@script@name|.
+% We don't need to check if there are multiple scripts with the same name, so we namually set |\MGL@script|, instead of using |\MGL@set@script@name|.
 %    \begin{macrocode}
-  \edef\MGL@script@name{#2}%
+  \edef\MGL@script{#2}%
 %    \end{macrocode}
 % We check if the user has specified a custom location for the script.
 %    \begin{macrocode}
 %    \end{macrocode}
 % If the script exists, we store its location in |\MGL@temp@a|%
 %    \begin{macrocode}
-      \IfFileExists{\MGL@temp@b\MGL@script@name.mgl}{%
+      \IfFileExists{\MGL@temp@b\MGL@script.mgl}{%
         \edef\MGL@temp@a{\MGL@temp@b}%
       }{}%
     }%
 %    \end{macrocode}
 % If the user specified the location of the script, we check if it exists, in which case we store its location in |\MGL@temp@a|.
 %    \begin{macrocode}
-    \IfFileExists{\MGL@script@name.mgl}{%
+    \IfFileExists{\MGL@script.mgl}{%
       \edef\MGL@temp@a{\MGL@forced@path}%
     }{}%
   }%
 %    \begin{macrocode}
   \@ifundefined{MGL@temp@a}{%
     \PackageWarning{mgltex}{%
-      MGL script "\MGL@forced@path\MGL@script@name.mgl" not found%
+      MGL script "\MGL@forced@path\MGL@script.mgl" not found%
     }%
     \center%
       \fbox{%
 %    \end{macrocode}
 % We first add the script to the \LaTeX{} list of included files.
 %    \begin{macrocode}
-  \@addtofilelist{\MGL@script@name.mgl}%
+  \@addtofilelist{\MGL@script.mgl}%
 %    \end{macrocode}
 % If the user has used the unstarred version of |\mglinclude|, we add a contents line to the |.lms| file.
 %    \begin{macrocode}
   \if@MGL@list@script@%
-    \refstepcounter{MGL@verb@script@no}%
+    \refstepcounter{MGL@verb@no}%
     \addcontentsline{lms}{MGL@script}{%
-      \protect\numberline{\theMGL@verb@script@no.}%
-      {\ttfamily\protect\detokenize{\MGL@script@name.mgl}}%
+      \protect\numberline{\theMGL@verb@no.}%
+      {\ttfamily\protect\detokenize{\MGL@script.mgl}}%
     }%
   \fi%
 %    \end{macrocode}
 %    \begin{macrocode}
   \fboxrule=\mgllinethickness%
   \item[\MGL@line@sep]\fbox{%
-    \bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script@name.mgl}%
+    \bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script.mgl}%
   }\hskip\labelsep\MGL@line@sep\par\par%
 %    \end{macrocode}
 % We redefine the |\verbatim@processline| macro from the \textsf{verbatim} package to put |\the\verbatim@line| on an item.
 %    \end{macrocode}
 % The script is opened for reading.
 %    \begin{macrocode}
-  \immediate\openin\MGL@in@stream="\MGL@temp@a\MGL@script@name.mgl"%
+  \immediate\openin\MGL@in@stream="\MGL@temp@a\MGL@script.mgl"%
 %    \end{macrocode}
 % We call |\mglinclude@@@| to start the transcription.
 %    \begin{macrocode}
 % \end{macro}\end{macro}
 %
 % \subsection{Additional commands}
-% \begin{macro}{\mglname}
-% \noindent The purpose of this command is to force the closure of the current main script, compile the corresponding figures, and open a new main script. At first, it is defined to only change the value of |\MGL@main@script@name| because the main script is not opened until the call of |\begin{document}|; but at that point, it is redefined to perform the described actions.
-%    \begin{macrocode}
-\def\mglname#1{\edef\MGL@main@script@name{#1}}
-%    \end{macrocode}
-% Here is the redefinition of |\mglname|.
-%    \begin{macrocode}
-\AtBeginDocument{%
-  \def\mglname#1{%
-%    \end{macrocode}
-% We start a space hack, ince this function has no real effect on the document.
-%    \begin{macrocode}
-    \@bsphack%
-%    \end{macrocode}
-% The MGL functions created throughout the document are written.
-%    \begin{macrocode}
-    \MGL@write@funcs%
-%    \end{macrocode}
-% We force the closure of the main script. We use |\immediate\closeout| instead of |\MGL@closeout| in case \textsf{\mglTeX} is off.
-%    \begin{macrocode}
-    \immediate\closeout{\MGL@main@stream}%
-%    \end{macrocode}
-% The closed script is compiled.
-%    \begin{macrocode}
-    \MGL@write{18}{%
-      mglconv -q \MGL@quality\space -S \MGL@scale\space%
-      -s "\MGL@dir\MGL@scripts@dir\mglcommonscriptname.mgl"\space%
-      -n "\MGL@dir\MGL@scripts@dir\MGL@main@script@name.mgl"%
-    }%
-%    \end{macrocode}
-% The name of the new main script is updated, and it is check for overwriting, using |\MGL@set@script@name| inside a local group, since this command defines |\MGL@script@name|, which we need undefined in some parts of the code of the package.
-%    \begin{macrocode}
-    \edef\MGL@main@script@name{#1}%
-    \bgroup\MGL@set@script@name{\MGL@main@script@name}\egroup%
-    \MGL@openout\MGL@main@stream{%
-      \MGL@dir\MGL@scripts@dir\MGL@main@script@name.mgl%
-    }%
-%    \end{macrocode}
-% The space hack is ended.
-%    \begin{macrocode}
-    \@esphack%
-  }%
-}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\mglswitch}
-% This command turns |on| and |off| the package according to its argument; it is just a call to the commands |\MGL@switch@on| or |\MGL@switch@off|.
-%    \begin{macrocode}
-\def\mglswitch#1{\csname MGL@switch@#1\endcsname}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\mglcomments} Depending on the option passed by the user, it calls |\@MGL@comments@on| or |\@MGL@comments@off|.
-%    \begin{macrocode}
-\def\mglcomments#1{\csname @MGL@comments@#1\endcsname}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\mgldir}
-% This command is the interface for the user to change the value of |\MGL@dir|. It is an only-preamble macro, since using it elsewhere would cause faulty behavior.
-%    \begin{macrocode}
-
-\def\mgldir#1{\def\MGL@dir{#1}}\@onlypreamble\mgldir
-%    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\mglscriptsdir}
-% This command modifies the value of |\MGL@scripts@dir|. It is also an only-preamble macro.
-%    \begin{macrocode}
-\def\mglscriptsdir#1{\def\MGL@scripts@dir{#1}}\@onlypreamble\mglscriptsdir
-%    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\mglgraphicsdir}
-% Modifies the value of |\MGL@graphics@dir|. It is an only-preamble macro.
-%    \begin{macrocode}
-\def\mglgraphicsdir#1{\def\MGL@graphics@dir{#1}}\@onlypreamble\mglgraphicsdir
-%    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\mglbackupsdir}
-% Modifies the value of |\MGL@backups@dir|. It is an only-preamble macro.
-%    \begin{macrocode}
-\def\mglbackupsdir#1{\def\MGL@backups@dir{#1}}\@onlypreamble\mglbackupsdir
-%    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\mglpaths}
-% This command adds a list of search paths for scripts to the existing one (|\MGL@paths|).
-%    \begin{macrocode}
-\def\mglpaths#1{\g@addto@macro\MGL@paths{,#1}}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\mglimgext}
-% This command changes the value of |\MGL@graph@ext|.
-%    \begin{macrocode}
-\def\mglimgext#1{\def\MGL@graph@ext{#1}}
-%    \end{macrocode}
-% \end{macro}
-%
 % \begin{macro}{\listofmglscripts}
-% This command creates the \emph{list of MGL scripts} section. It has to be defined differently depending on whether the used document class defines the |\l@chapter| command or it only the |\l@section| command, which set the style for making a table of contents entry for the |\chapter| command and the |\section| command, respectively. If none of them are defined, we define our own style based on the latter.
+% \noindent This command creates the \emph{list of MGL scripts} section. It has to be defined differently depending on whether the used document class defines the |\l@chapter| command or it only the |\l@section| command, which set the style for making a table of contents entry for the |\chapter| command and the |\section| command, respectively. If none of them are defined, we define our own style based on the latter.
 %    \begin{macrocode}
 
 \ifx\l@chapter\@undefined%
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\mglcommonscriptname}\begin{macro}{\mglcommentname}\begin{macro}{\listofmglscriptsname}\begin{macro}{\mglverbatimname}\begin{macro}{\mgllinenostyle}\begin{macro}{\mgldashwidth}\begin{macro}{\mgllinethickness}\begin{macro}{\mglbreakindent}
+% \begin{macro}{\mglTeX}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Add a small negative space in the logo, between the ``mgl'' and ``\TeX''}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Declared now as robust command}
+% This macro pretty-prints the name of the package. It has a starred version, which also prints the version.
 %    \begin{macrocode}
 
-\def\mglcommonscriptname{MGL_common_script}
-\def\mglcommentname{MGL commentary}
+\DeclareRobustCommand\mglTeX{%
+  mgl\TeX\@ifstar{~v4.2}{}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \subsection{Local settings commands}
+% \begin{macro}{\mglswitch}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Now accepts arguments \texttt{0} (equivalent to \texttt{off}) and \texttt{1} (equivalent to \texttt{on}), besides the usual  \texttt{off} and \texttt{on}}
+% \noindent This command turns |on| and |off| the package according to its argument; it is just a call to the commands |\MGL@switch@on| or |\MGL@switch@off|.
+%    \begin{macrocode}
+\def\mglswitch#1{%
+  \MGL@test@switch{#1}{\mglswitch}%
+  \csname MGL@switch@\MGL@temp@a\endcsname%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\mglcomments}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Now accepts arguments \texttt{0} (equivalent to \texttt{off}) and \texttt{1} (equivalent to \texttt{on}), besides the usual  \texttt{off} and \texttt{on}}
+% Depending on the option passed by the user, it calls |\@MGL@comments@on| or |\@MGL@comments@off|.
+%    \begin{macrocode}
+\def\mglcomments#1{%
+  \MGL@test@switch{#1}{\mglcomments}%
+  \csname @MGL@comments@\MGL@temp@a\endcsname%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\mglquality}
+% See under the title \emph{Initialization}, subsection \ref{Init}.
+% \end{macro}
+%
+% \begin{macro}{\mglscale}
+% See under the title \emph{Initialization}, subsection \ref{Init}.
+% \end{macro}
+%
+% \begin{macro}{\mglvariant}
+% See under the title \emph{Initialization}, subsection \ref{Init}.
+% \end{macro}
+%
+% \begin{macro}{\mglimgext}
+% This command changes the value of |\MGL@imgext|.
+%    \begin{macrocode}
+\def\mglimgext#1{\def\MGL@imgext{#1}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\mglname}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Now writes the MGL code line \texttt{setsize~600~400} to the main script}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{The MGL code line \texttt{setsize~600~400} is now written to the main script}
+% \noindent The purpose of this command is to force the closure of the current main script, compile the corresponding figures, and open a new main script. At first, it is defined to only change the value of |\MGL@main@script@name| because the main script is not opened until the call of |\begin{document}|; but at that point, it is redefined to perform the described actions.
+%    \begin{macrocode}
+\def\mglname#1{\edef\MGL@main@script@name{#1}}
+%    \end{macrocode}
+% Here is the redefinition of |\mglname| after the |\begin{document}| command.
+%    \begin{macrocode}
+\AtBeginDocument{%
+  \def\mglname#1{%
+%    \end{macrocode}
+% We start a space hack, ince this function has no real effect on the document.
+%    \begin{macrocode}
+    \@bsphack%
+%    \end{macrocode}
+% The MGL functions created throughout the document are written.
+%    \begin{macrocode}
+    \MGL@write@funcs%
+%    \end{macrocode}
+% We force the closure of the main script. We use |\immediate\closeout| instead of |\MGL@closeout| in case \textsf{\mglTeX} is off.
+%    \begin{macrocode}
+    \immediate\closeout{\MGL@main@stream}%
+%    \end{macrocode}
+% The closed script is compiled.
+%    \begin{macrocode}
+    \MGL@write{18}{%
+      mglconv -q \MGL@quality\space -g \MGL@gray\space%
+      -S \MGL@scale\space -v \MGL@variant\space%
+      -s "\MGL@dir\MGL@scripts@dir\mglsetupscriptname.mgl"\space%
+      -n "\MGL@dir\MGL@scripts@dir\MGL@main@script@name.mgl"%
+    }%
+%    \end{macrocode}
+% The name of the new main script is updated, and it is check for overwriting, using |\MGL@set@script@name| inside a local group, since this command defines |\MGL@script|, which we need undefined in some parts of the code of the package.
+%    \begin{macrocode}
+    \edef\MGL@main@script@name{#1}%
+    \bgroup\MGL@set@script@name{\MGL@main@script@name}\egroup%
+    \MGL@openout\MGL@main@stream{%
+      \MGL@dir\MGL@scripts@dir\MGL@main@script@name.mgl%
+    }%
+%    \end{macrocode}
+% We set the default size for the graphics that the main script will generate; without this line the |setsizescl| commands written automatically by \textsf{\mglTeX} wouldn't work.
+%    \begin{macrocode}
+    \MGL@write\MGL@main@script@name{setsize 600 400}
+%    \end{macrocode}
+% The space hack is ended.
+%    \begin{macrocode}
+    \@esphack%
+  }%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \subsection{Advanced settings commands}
+% \begin{macro}{\mgldir}
+% \noindent This command is the interface for the user to change the value of |\MGL@dir|. It is an only-preamble macro, since using it elsewhere would cause faulty behavior.
+%    \begin{macrocode}
+
+\def\mgldir#1{\def\MGL@dir{#1}}\@onlypreamble\mgldir
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\mglscriptsdir}
+% This command modifies the value of |\MGL@scripts@dir|. It is also an only-preamble macro.
+%    \begin{macrocode}
+\def\mglscriptsdir#1{\def\MGL@scripts@dir{#1}}\@onlypreamble\mglscriptsdir
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\mglgraphicsdir}
+% Modifies the value of |\MGL@graphics@dir|. It is an only-preamble macro.
+%    \begin{macrocode}
+\def\mglgraphicsdir#1{\def\MGL@graphics@dir{#1}}\@onlypreamble\mglgraphicsdir
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\mglbackupsdir}
+% Modifies the value of |\MGL@backups@dir|. It is an only-preamble macro.
+%    \begin{macrocode}
+\def\mglbackupsdir#1{\def\MGL@backups@dir{#1}}\@onlypreamble\mglbackupsdir
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\mglpaths}
+% This command adds a list of search paths for scripts to the existing one (|\MGL@paths|).
+%    \begin{macrocode}
+\def\mglpaths#1{\g@addto@macro\MGL@paths{,#1}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\mglsettings}
+%  \changes{\textbf{v4.2 ------------}}{2016/05/14}{Now calls the \doccommand{mglswitch} and \doccommand{mglcomments} commands for the \texttt{switch} and \texttt{comments} options, respectively}
+% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Added options \texttt{gray} and \texttt{variant}}
+% First, we define a \meta{key}=\meta{value} family, |MGL@sett@keys|, for this command.
+%    \begin{macrocode}
+\define@key{MGL@sett@keys}{dir}{\def\MGL@dir{#1}}
+\define@key{MGL@sett@keys}{scriptsdir}{\def\MGL@scripts@dir{#1}}
+\define@key{MGL@sett@keys}{graphicsdir}{\def\MGL@graphics@dir{#1}}
+\define@key{MGL@sett@keys}{backupsdir}{\def\MGL@backups@dir{#1}}
+\define@key{MGL@sett@keys}{paths}{\g@addto@macro\MGL@paths{,#1}}
+\define@key{MGL@sett@keys}{switch}{\mglswitch{#1}}
+\define@key{MGL@sett@keys}{comments}{\mglcomments{#1}}
+\define@key{MGL@sett@keys}{gray}{\mglgray{#1}}
+\define@key{MGL@sett@keys}{mglscale}{\mglscale{#1}}
+\define@key{MGL@sett@keys}{quality}{\mglquality{#1}}
+\define@key{MGL@sett@keys}{variant}{\mglvariant{#1}}
+\define@key{MGL@sett@keys}{imgext}{\def\MGL@imgext{.#1}}
+%    \end{macrocode}
+% The command receives and executes the \meta{key}=\meta{value} pairs for |MGL@sett@keys|. This is an only-preamble command.
+%    \begin{macrocode}
+\def\mglsettings#1{\setkeys{MGL@sett@keys}{#1}}
+\@onlypreamble\mglsettings
+%    \end{macrocode}
+% \end{macro}
+%
+% \subsection{User-definable macros}
+% \begin{macro}{\mglsetupscriptname}\begin{macro}{\mglcommentname}\begin{macro}{\listofmglscriptsname}\begin{macro}{\mglverbatimname}\begin{macro}{\mgllinenostyle}\begin{macro}{\mgldashwidth}\begin{macro}{\mgllinethickness}\begin{macro}{\mglbreakindent}
+% The user is allowed to modifu these commands, so no |@| symbol is used on them.
+%    \begin{macrocode}
+
+\def\mglsetupscriptname{MGL_setup_script}
+\def\mglcommentname{\mglTeX{} comment}
 \def\listofmglscriptsname{List of MGL scripts}
 \def\mglverbatimname{(Unnamed MGL verbatim script)}
 \def\mgllinenostyle{\footnotesize}
 %    \end{macrocode}
 % \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
 %
-% \begin{macro}{\mglTeX}
-% This macro pretty-prints the name of the package. It has a starred version, which also prints the version.
-%    \begin{macrocode}
-
-\def\mglTeX{%
-  mgl\TeX\@ifstar{~v4.1}{}%
-}
-%    \end{macrocode}
-% \end{macro}
-%
 % \subsection{Final adjustments}
 % To finish the code of \textsf{\mglTeX}, we set the behavior of the package at the call of the |\begin{document}| and |\end{document}| commands.
 %
-% We tell \LaTeX{} to check the name of the document's main script for overwriting. We do this by calling |\MGL@set@script@name| inside a local group, because it defines |\MGL@script@name|, which we need undefined in certain parts of the code. Then the script is opened. We use |\immediate\openout| instead of |\MGL@openout| for this purpose, since, otherwise, we run the risk of the main script not being created when needed, if the user turns off \textsf{\mglTeX} before the |\begin{document}| command, and turns it on immediately after.
+% We tell \LaTeX{} to check the name of the document's main script for overwriting. We do this by calling |\MGL@set@script@name| inside a local group, because it defines |\MGL@script|, which we need undefined in certain parts of the code. Then the script is opened. We use |\immediate\openout| instead of |\MGL@openout| for this purpose, since, otherwise, we run the risk of the main script not being created when needed, if the user turns off \textsf{\mglTeX} before the |\begin{document}| command, and turns it on immediately after. Finally, we set the default size for the graphics the main script will generate; without this line the |setsizescl| commands written automatically by \textsf{\mglTeX} wouldn't work.
 %    \begin{macrocode}
 
 \AtBeginDocument{%
   \bgroup\MGL@set@script@name{\MGL@main@script@name}\egroup%
   \immediate\openout\MGL@main@stream=%
   \MGL@dir\MGL@scripts@dir\MGL@main@script@name.mgl%
+  \MGL@write\MGL@main@stream{setsize 600 400}%
 }
 %    \end{macrocode}
+%
 % We also set the actions for the call of |\end{document}|
 %    \begin{macrocode}
+
 \AtEndDocument{%
 %    \end{macrocode}
 % |\MGL@write@funcs| will simply write the MGL functions throughout the \LaTeX{} document.
 % The main script is compiled.
 %    \begin{macrocode}
   \MGL@write{18}{%
-    mglconv -q \MGL@quality\space -S \MGL@scale\space%
-    -s "\MGL@dir\MGL@scripts@dir\mglcommonscriptname.mgl"\space%
+    mglconv -q \MGL@quality\space -g \MGL@gray\space%
+    -S \MGL@scale\space -v \MGL@variant\space%
+    -s "\MGL@dir\MGL@scripts@dir\mglsetupscriptname.mgl"\space%
     -n "\MGL@dir\MGL@scripts@dir\MGL@main@script@name.mgl"%
   }%
 }
index f58fa7239f197de32dbd21aba902a6e8053e043b..49d18eeaacc359eff84170e7551762ff04bb4f6c 100644 (file)
@@ -1,6 +1,6 @@
 %%
-%% Copyright (C) 2014--2015 by Diego Sejas Viscarra <diego.mathematician@gmail.com>
-%% Copyright (C) 2014--2015 by Alexey Balakin <mathgl.abalakin@gmail.com>
+%% Copyright (C) 2014--2016 by Diego Sejas Viscarra <dsejas.mathematics@gmail.com>
+%% Copyright (C) 2014--2016 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
@@ -60,4 +60,4 @@ with this program.  If not, see <http://www.gnu.org/licenses/>.
 \Msg{*                                                        *}
 \Msg{**********************************************************}
 
-\endbatchfile
\ No newline at end of file
+\endbatchfile
index 296f42ec5de0157e6e62565d358b91a37f441a6f..58c5dd6a3f8b768c158448f3fd5f711c06c0b929 100644 (file)
Binary files a/mgltex/mgltex.pdf and b/mgltex/mgltex.pdf differ
index d7d39eb7138e09201a7bdfcd319fa949c1b2cdb5..91447c8de17f9d7e7730dbfdf8799e39bad39b4e 100644 (file)
 \documentclass{article}
 
-\usepackage[jpg,comments]{mgltex}
+\usepackage[png,comments]{mgltex}
+\usepackage{hyperref}
 
-\title{\mglTeX{} package example}
-\author{Diego Sejas Viscarra, Alexey Balakin}
+\title{\mglTeX*{} usage sample}
+\author{Diego Sejas Viscarra \and Alexey Balakin}
 \date{\today}
 
-\mgldir{MGL/}
-\mglscriptsdir{scripts/}
-\mglgraphicsdir{graphics/}
-\mglbackupsdir{backups/}
-
-\begin{mglcommon}
-  define gravity 9.81
-\end{mglcommon}
-
-%\begin{mglsignature}
-%  This scripts was generated on date |today.
-%\end{mglsignature}
+\mglsettings{
+       dir=MGL/,
+       scriptsdir=scripts/,
+       graphicsdir=graphics/,
+       backupsdir=backups/
+}
 
+\begin{mglsetupscript}
+       define gravity 9.81 # [m/s^2]
+\end{mglsetupscript}
 
 \begin{document}
-  
-\maketitle
-
-\noindent The \LaTeX{} package \textsf{\mglTeX} (was made by Diego Sejas Viscarra) allows one to make figures directly from MGL scripts located in \LaTeX{} file. 
-
-For using this package you need to specify \texttt{--shell-escape} option for \emph{latex/pdflatex} or manually run \emph{mglconv} tool on produced MGL scripts for generation of images. Don't forget to run \emph{latex/pdflatex} a second time to insert the generated images into the output document.
-
-The package may have following options: \texttt{draft}, \texttt{final} --- the same as in the \emph{graphicx} package; \texttt{on}, \texttt{off} --- to activate/deactivate the creation of scripts and graphics; \texttt{comments}, \texttt{nocomments} --- to make visible/invisible commentaries contained inside \texttt{mglcomment} environments; \texttt{jpg}, \texttt{jpeg}, \texttt{png} --- to export graphics as JPEG/PNG images; \texttt{eps}, \texttt{epsz} --- to export to uncompressed/compressed EPS format as primitives; \texttt{bps}, \texttt{bpsz} --- to export to uncompressed/compressed EPS format as bitmap (doesn't work with \emph{pdflatex}); \texttt{pdf} --- to export to 3D PDF; \texttt{tex} --- to export to \LaTeX{}/\emph{tikz} document.
-
-The package defines the following environments:
-\begin{description}
-\item[mgl]
-       It writes its contents to a general script which has the same name as the LaTeX document, but its extension is \emph{.mgl}. The code in this environment is compiled and the image produced is included. It takes exactly the same optional arguments as the \texttt{\textbackslash{}includegraphics} command, plus an additional argument \emph{imgext}, which specifies the extension to save the image.
-\item[mgladdon]
-       It adds its contents to the general script, without producing any image. It useful to set some global properties (like size of the images) at beginning of the document.
-\item[mglcode]
-       Is exactly the same as \texttt{mgl}, but it writes its contents verbatim to its own file, whose name is specified as a mandatory argument.
-\item[mglscript]
-       Is exactly the same as \texttt{mglcode}, but it doesn't produce any image, nor accepts optional arguments. It is useful, for example, to create a MGL script, which can later be post processed by another package like "listings".
-\item[mglblock]
-       It writes its contents verbatim to a file, specified as a mandatory argument, and to the LaTeX document, and numerates each line of code.
-
-% This last three environments will test if the user is overwriting some file, and will issue a warning in that case.
-\item[mglverbatim]
-       Exactly the same as \texttt{mglblock}, but it doesn't write to a file. This environment doesn't have arguments.
-\item[mglfunc]
-       Is used to define MGL functions. It takes one mandatory argument, which is the name of the function, plus one additional argument, which specifies the number of arguments of the function. The environment needs to contain only the body of the function, since the first and last lines are appended automatically, and the resulting code is written at the end of the general script, which is also written automatically. The warning is produced if 2 or more function with the same name is defined.
-\item[mglsignature]
-Used to defined a commentary that will be added to every script. It is useful to include signature text or license text. Observe this is a verbatim-like environment, so no \LaTeX{} command will be executed inside it, but will be copied as is.
-
-As an alternative to this method of declaring signatures, the user can manually redefine the signature macro \texttt{\textbackslash{}mgltexsignature}, according to the following rules:
-  \begin{itemize}
-    \item The positions of the comment signs for the MGL language have to be manually specified in the signature using the \texttt{\textbackslash{}mglcomm} macro.
-    \item The new-line character is declared as ``\verb|^^J|''.
-    \item A percent sign (\texttt{\%}) has to be added at the end of every physical line of \texttt{\textbackslash{}mgltexsignature}, otherwise an inelegant space at the beginning of every line will appear.
-  \item Any \LaTeX{} command can be used in this case.
-\end{itemize}
-  For example, the default signature:
-  \begin{mglcomment}
-  \begin{quote}\small
-    \mglcomm\\
-    \mglcomm\ This script was generated from $<$document$>$.mgl on date $<$today$>$\\
-    \mglcomm
-  \end{quote}
-  \end{mglcomment}
-  can be achieved with
-  \begin{verbatim}
-    \def\mgltexsignature{%
-      \mglcomm^^J%
-      \mglcomm\ This script was generated from \jobname.mgl on date \today^^J%
-      \mglcomm%
-    }
-  \end{verbatim}
-\item[mglcomment]
-  Used to contain multiline commentaries. This commentaries will be visible/invisible in the output document, depending on the use of the package options \texttt{comments} and \texttt{nocomments} (see above), or the \texttt{\mglcomments{on}} and \texttt{\mglcomments{off}} commands (see bellow).
-  
-  When, visible, the comment will appear like this:
-  \begin{center}
-    \makeatletter
-    \verbatim@font
-    \makeatother
-    <------------------ MGL comment ------------------>\\
-    $<$Commentary$>$\\
-    <------------------ MGL comment ------------------>\\
-  \end{center}
-\item[mglsetup]
-       If many scripts with the same code are to be written, the repetitive code can be written inside this environment only once, then this code will be used automatically every time the \texttt{\textbackslash{}mglplot} command is used (see below). It takes one optional argument, which is a name to be associated to the corresponding contents of the environment; this name can be passed to the \texttt{\textbackslash{}mglplot} command to use the corresponding block of code automatically (see below).
-\end{description}
-
-The package also defines the following commands:
-\begin{description}
-\item[\textbackslash{}mglplot]
-       It takes one mandatory argument, which is MGL instructions separated by the symbol ':' this argument can be more than one line long. It takes the same optional arguments as the \texttt{mgl} environment, plus an additional argument \emph{settings}, which indicates the name associated to a block of code inside a \texttt{mglsetup} environment. The code inside the mandatory argument will be appended to the block of code specified, and the resulting code will be written to the general script.
-\item[\textbackslash{}mglgraphics]
-       This command takes the same optional arguments as the \texttt{mgl} environment, and one mandatory argument, which is the name of a MGL script. This command will compile the corresponding script and include the resulting image. It is useful when you have a script outside the LaTeX document, and you want to include the image, but you don't want to type the script again.
-\item[\textbackslash{}mglinclude]
-       This is like \texttt{\textbackslash{}mglgraphics} but, instead of creating/including the corresponding image, it writes the contents of the MGL script to the LaTeX document, and numerates the lines.
-\item[\textbackslash{}mgldir]
-       This command can be used in the preamble of the document to specify a directory where LaTeX will save the MGL scripts and generate the corresponding images. This directory is also where \texttt{\textbackslash{}mglgraphics} and \texttt{\textbackslash{}mglinclude} will look for scripts.
-\item[\textbackslash{}mglquality]
-  Can be used to adjust the quality of the MGL graphics produced. The following table shows the available qualities:
-  \begin{center}
-    \begin{tabular}{cl}
-      \hline
-      Quality & Description\\
-      \hline
-      \hline
-      $0$ & No face drawing (fastest)\\
-      \hline
-      $1$ & No color interpolation (fast)\\
-      \hline
-      $2$ & High quality (normal)\\
-      \hline
-      $3$ & High quality with 3d primitives (not implemented yet)\\
-      \hline
-      $4$ & No face drawing, direct bitmap drawing (low memory usage)\\
-      \hline
-      $5$ & No color interpolation, direct bitmap drawing (low memory usage)\\
-      \hline
-      $6$ & High quality, direct bitmap drawing (low memory usage)\\
-      \hline
-      $7$ & High quality with 3d primitives, direct bitmap drawing (not implemented yet)\\
-      \hline
-      $8$ & Draw dots instead of primitives (extremely fast)\\
-      \hline
-    \end{tabular}
-  \end{center}
-\item[\textbackslash{}mglswitch\{on\}, \textbackslash{}mglswitch\{off\}]
-  To activate/deactivate the creation of MGL scripts and images. Notice these commands have local behavior in the sense that their effect is from the point they are called on.
-\item[\textbackslash{}mglcomment\{on\}, \textbackslash{}mglnocomment\{off\}]
-  To make visible/invisible the contents of the \texttt{mglcomment} environments. These commands have local effect too.
-\item[\textbackslash{}mglTeX]
-       It just pretty prints the name of the package ``\mglTeX''.
-\end{description}
-
-
-An example of usage of \texttt{mgl} and \texttt{mglfunc} environments would be:
-\begin{verbatim}
-\begin{mglfunc}{prepare2d}
-  new a 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
-  new b 50 40 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
-\end{mglfunc}
-
-\begin{figure}[!ht]
-  \centering
-  \begin{mgl}[width=0.85\textwidth,height=7.5cm]
-    fog 0.5
-    call 'prepare2d'
-    subplot 2 2 0:title 'Surf plot (default)':rotate 50 60:light on:box:surf a
-
-    subplot 2 2 1:title '"\#" style; meshnum 10':rotate 50 60:box
-    surf a '#'; meshnum 10
-
-    subplot 2 2 2 : title 'Mesh plot' : rotate 50 60 : box
-    mesh a
-
-    new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)'
-    new y 50 40 '0.8*cos(pi*x)*sin(pi*(y+1)/2)'
-    new z 50 40 '0.8*cos(pi*(y+1)/2)'
-    subplot 2 2 3 : title 'parametric form' : rotate 50 60 : box
-    surf x y z 'BbwrR'
-  \end{mgl}
-\end{figure}
-\end{verbatim}
-Note, that \texttt{mglfunc} environment(s) can be located at any position (at the beginning, at the end, or somewhere else) of LaTeX document.
-\begin{mglfunc}{prepare2d}
-  new a 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
-  new b 50 40 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
-\end{mglfunc}
-
-\begin{figure}[!ht]
-  \centering
-  \begin{mgl}[width=0.85\textwidth,height=7.5cm]
-    fog 0.5
-    call 'prepare2d'
-    subplot 2 2 0 : title 'Surf plot (default)' : rotate 50 60 : light on : box : surf a
-
-    subplot 2 2 1 : title '"\#" style; meshnum 10' : rotate 50 60 : box
-    surf a '#'; meshnum 10
-
-    subplot 2 2 2 : title 'Mesh plot' : rotate 50 60 : box
-    mesh a
-
-    new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)'
-    new y 50 40 '0.8*cos(pi*x)*sin(pi*(y+1)/2)'
-    new z 50 40 '0.8*cos(pi*(y+1)/2)'
-    subplot 2 2 3 : title 'parametric form' : rotate 50 60 : box
-    surf x y z 'BbwrR'
-  \end{mgl}
-\end{figure}
-
-Following example show the usage of \texttt{mglscript} environment
-\begin{verbatim}
-\begin{mglscript}{Vectorial}
-call 'prepare2v'
-subplot 3 2 0 '' : title 'lolo' : box
-vect a b
-subplot 3 2 1 '' : title '"." style; "=" style' : box
-vect a b '.='
-subplot 3 2 2 '' : title '"f" style' : box
-vect a b 'f'
-subplot 3 2 3 '' : title '">" style' : box
-vect a b '>'
-subplot 3 2 4 '' : title '"<" style' : box
-vect a b '<'
-call 'prepare3v'
-subplot 3 2 5 : title '3d variant' : rotate 50 60 : box
-vect ex ey ez
-
-stop
-    
-func 'prepare2v'
-  new a 20 30 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
-  new b 20 30 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
-return
-    
-func 'prepare3v'
-  define $1 pow(x*x+y*y+(z-0.3)*(z-0.3)+0.03,1.5)
-  define $2 pow(x*x+y*y+(z+0.3)*(z+0.3)+0.03,1.5)
-  new ex 10 10 10 '0.2*x/$1-0.2*x/$2'
-  new ey 10 10 10 '0.2*y/$1-0.2*y/$2'
-  new ez 10 10 10 '0.2*(z-0.3)/$1-0.2*(z+0.3)/$2'
-return
-\end{mglscript}
-\end{verbatim}
-
-\begin{mglscript}{Vectorial}
-call 'prepare2v'
-subplot 3 2 0 '' : title 'lolo' : box
-vect a b
-subplot 3 2 1 '' : title '"." style; "=" style' : box
-vect a b '.='
-subplot 3 2 2 '' : title '"f" style' : box
-vect a b 'f'
-subplot 3 2 3 '' : title '">" style' : box
-vect a b '>'
-subplot 3 2 4 '' : title '"<" style' : box
-vect a b '<'
-call 'prepare3v'
-subplot 3 2 5 : title '3d variant' : rotate 50 60 : box
-vect ex ey ez
-
-stop
-    
-func 'prepare2v'
-  new a 20 30 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
-  new b 20 30 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'
-return
-    
-func 'prepare3v'
-  define $1 pow(x*x+y*y+(z-0.3)*(z-0.3)+0.03,1.5)
-  define $2 pow(x*x+y*y+(z+0.3)*(z+0.3)+0.03,1.5)
-  new ex 10 10 10 '0.2*x/$1-0.2*x/$2'
-  new ey 10 10 10 '0.2*y/$1-0.2*y/$2'
-  new ez 10 10 10 '0.2*(z-0.3)/$1-0.2*(z+0.3)/$2'
-return
-\end{mglscript}
-
-You should use \texttt{\textbackslash{}mglgraphics} command to display its contents
-\begin{verbatim}
-\begin{figure}[!ht]
-  \centering
-  \mglgraphics[width=40em,height=20em]{Vectorial}
-  \caption{A beautiful example}
-\end{figure}
-\end{verbatim}
-
-\begin{figure}[!ht]
-  \centering
-  \mglgraphics[width=40em,height=20em]{Vectorial}
-  \caption{A beautiful example}
-\end{figure}
-
-Alternatively, you can display the contents of the script in parallel to saving to a file, if you are using \texttt{mglblock} environment
-\begin{verbatim}
-\begin{mglblock}{Axis_projection}
-  ranges 0 1 0 1 0 1
-  new x 50 '0.25*(1+cos(2*pi*x))'
-  new y 50 '0.25*(1+sin(2*pi*x))'
-  new z 50 'x'
-  new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'
-  new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx
-  light on
-  
-  title 'Projection sample':ternary 4:rotate 50 60
-  box:axis:grid
-  plot x y z 'r2':surf a '#'
-  xlabel 'X':ylabel 'Y':zlabel 'Z'
-\end{mglblock}
-\begin{figure}[!ht]
-  \centering
-  \mglgraphics[scale=0.5]{Axis_projection}
-  \caption{The image from Axis\_projection.mgl script}
-\end{figure}
-\end{verbatim}
-
-\begin{mglblock}{Axis_projection}
-  ranges 0 1 0 1 0 1
-  new x 50 '0.25*(1+cos(2*pi*x))'
-  new y 50 '0.25*(1+sin(2*pi*x))'
-  new z 50 'x'
-  new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'
-  new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx
-  light on
-  
-  title 'Projection sample':ternary 4:rotate 50 60
-  box:axis:grid
-  plot x y z 'r2':surf a '#'
-  xlabel 'X':ylabel 'Y':zlabel 'Z'
+       
+       \maketitle
+       
+       \begin{abstract}
+               \noindent \mglTeX{} is a \LaTeX{} package that allows the creation of graphics directly from MGL scripts of the MathGL library (by Alexey Balakin) inside documents. The MGL code is extracted, executed (if shell escape is activated), and the resulting graphics are automatically included.
+               
+               This document is intended as a sample of the capabilities of \mglTeX{}, as well as a brief introduction to the package, for those who want to start right away to use it, without diving into the a little bit more technical documentation.
+       \end{abstract}
+       
+       \section{Basics on environments}
+       \begin{description}
+               \item[mgl] The easiest way to embed MGL code is the \verb|mgl| environment. It extracts its contents to a main script associated to the document.\footnote{Generally, the main script has the same name as the document being compiled. In order to rename it or create a new one, the \texttt{\textbackslash mglname} command can be used.} If shell escape is activated, \LaTeX{} will take care of calling \verb|mglconv| (the MathGL compiler) with the appropriate settings, and the resulting image will be automatically included.
+               
+               For example, you could write:
+               \begin{verbatim}
+                       \begin{figure}[!ht]
+                         \centering
+                         \begin{mgl}[width=0.85\textwidth,height=6cm]
+                           call 'prepare1d'
+                           subplot 2 1 0 '<_' : title 'Standard data plot'
+                           box : axis : grid 'xy' ';k'
+                           plot y ’rGb’
+                           
+                           subplot 2 1 1 '<_' : title 'Region plot'
+                                 ranges -1 1 -1 1 : origin 0 0
+                                 new y1 200 'x^3-x' : new y2 200 'x'
+                                 axis : grid 'xy' 'W'
+                                 region y1 y2 'ry'
+                                 plot y1 '2k' : plot y2 '2k'
+                                 text -0.75 -0.35 '\i{A}_1' 'k' : text 0.75 0.25 '\i{A}_2' 'k'
+                         \end{mgl}
+                         \caption{A simple plot create by \mglTeX's \texttt{mgl} environment}
+                       \end{figure}
+               \end{verbatim}
+               This will produce the following image:
+               \begin{figure}[!ht]
+                       \centering
+                       \begin{mgl}[width=0.85\textwidth,height=5.5cm]
+                               call 'prepare1d'
+                               subplot 2 1 0 '<_' : title 'Standard data plot'
+                               box : axis : grid 'xy' ';k'
+                               plot y '2'
+                               
+                               subplot 2 1 1 '<_' : title 'Region plot'
+                               ranges -1 1 -1 1 : origin 0 0
+                               new y1 200 'x^3-x' : new y2 200 'x'
+                               axis 'AKDTVISO' : grid 'xy' ';W'
+                               region y1 y2 'ry'
+                               plot y1 '2k' : plot y2 '2k'
+                               text -0.75 -0.35 '\i{A}_1' 'k' -2 : text 0.75 0.25 '\i{A}_2' 'k' -2
+                       \end{mgl}
+                       \caption{A simple plot create by \mglTeX's \texttt{mgl} environment}
+               \end{figure}
+               
+               Two important aspects of \mglTeX{} can be noted from this example: First, the \verb|mgl| environment accepts the same optional argument as the \verb|\includegraphics| command from the \verb|graphicx| package. Actually, it also accepts other optional arguments, called \verb|gray| (to activate/deactivate gray-scale mode), \verb|mglscale| (to set the factor for scaling the image file), \verb|quality| (to set the quality of the image), \verb|variant| (to chose the variant of the arguments of MGL commands in the script), \verb|imgext| (to specify the extension of the resulting graphic file), and \verb|label| (to specify a name to save the image). Most of these options are available to every \mglTeX{} environment or command to create graphics.
+               
+               The second aspect to be noted about the example is that this script calls a MGL function, \verb|prepare1d|, which hasn't been defined yet. \mglTeX{} provides the \verb|mglfunc| environment for this purpose (see below).
+               
+               \item[mglfunc] This environment can be used in any part of the \LaTeX{} document; \mglTeX{} takes care of placing the corresponding code at the end of the main script, as has to be done in the MGL language.
+               
+               For example, the function \verb|prepare1d| that is called in the script above is defined like this
+               \begin{verbatim}
+                 \begin{mglfunc}{prepare1d}
+                   new y 50 3
+                   modify y '0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)'
+                   modify y 'sin(2*pi*x)' 1
+                   modify y 'cos(2*pi*x)' 2
+                 \end{mglfunc}
+               \end{verbatim}
+               \begin{mglfunc}{prepare1d}
+                       new y 50 3
+                       modify y '0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)'
+                       modify y 'sin(2*pi*x)' 1
+                       modify y 'cos(2*pi*x)' 2
+               \end{mglfunc}
+               As you can see, only the body of the function has to be written. The number of arguments of the function can be passed to \verb|mglfunc| as optional argument, like in the code \verb|\begin{mglfunc}[3]{func_with_three_args}|.
+               
+               \item[mgladdon] This environment just adds its contents to the main script, without producing any image. It is useful to load dynamic libraries, define constants, etc.
+               
+               \item[mglcode] The \verb|mglcode| environment is similar to \verb|mgl|, but it creates its own script, whose name is passed as mandatory argument. The same optional arguments are accepted, except \verb|label| (for obvious reasons).
+               \begin{verbatim}
+                       \begin{figure}[!ht]
+                         \begin{mglcode}[scale=0.5]{vectorial_flow}
+                           new a 20 30 'sin(pi*x)*sin(pi*y)+cos(2*pi*x*y)'
+                           new b 20 30 'cos(pi*x)*cos(pi*y)+cos(2*pi*x*y)'
+                           
+                           subplot 1 1 0 '' : title 'Flow of vector field' : box
+                           flow a b 'v'; value 20
+                         \end{mglcode}
+                       \end{figure}
+               \end{verbatim}
+               \begin{figure}[!ht]
+                       \centering
+                       \begin{mglcode}[scale=0.5]{vectorial_flow}
+                               new a 20 30 'sin(pi*x)*sin(pi*y)+cos(2*pi*x*y)'
+                               new b 20 30 'cos(pi*x)*cos(pi*y)+cos(2*pi*x*y)'
+                               
+                               subplot 1 1 0 '' : title 'Flow of a vector field' : box
+                               flow a b '2v'; value 10
+                       \end{mglcode}
+               \end{figure}
+               
+               \item[mglscript] This environment just creates a script, whose name is specified as mandatory argument. It is useful, for example, to create MGL scripts which can later be post-processed by another package, like \verb|listings| or \verb|pygments|.
+               
+               For example, the following won't produce any image, just a script:
+               \begin{verbatim}
+                       \begin{mglscript}{Gaston_surface}
+                         subplot 1 1 0 '' : title 'Gaston\'s surface'
+                         ranges -13 13 -40 40
+                         new a 200 200 '-x+(2*0.84*cosh(0.4*x)*sinh(0.4*x))/' \
+                           '(0.4*((sqrt(0.84)*cosh(0.4*x))^2+(0.4*sin(sqrt(0.84)*y))))+' \
+                           '0.5*sin(pi/2*x)'
+                         new b 200 200 '(2*sqrt(0.84)*cosh(0.45*x)*(-(sqrt(0.84)*sin(y)*' \
+                           'cos(sqrt(0.84)*y))+cos(y)*sin(sqrt(0.84)*y)))/' \
+                           '(0.4*((sqrt(0.84)*cosh(0.4*x))^2+2*(0.4*sin(sqrt(0.84)*x))^2))'
+                         new c 200 200 '(2*sqrt(0.84)*cosh(0.45*x)*(-(sqrt(0.84)*cos(y)*' \
+                           'cos(sqrt(0.84)*y))-sin(y)*sin(sqrt(0.84)*y)))/' \
+                           '(0.4*((sqrt(0.84)*cosh(0.4*x))^2+2*(0.4*sin(sqrt(0.84)*x))^2))'
+                         rotate 60 60
+                         light on
+                         xrange c : yrange b : zrange a : crange c
+                         surf c b a '#'; meshnum 100
+                       \end{mglscript}
+               \end{verbatim}
+               \begin{mglscript}{Gaston_surface}
+                       subplot 1 1 0 ''
+                       ranges -13 13 -40 40
+                       new a 200 200 '-x+(2*0.84*cosh(0.4*x)*sinh(0.4*x))/(0.4*((sqrt(0.84)*cosh(0.4*x))^2+(0.4*sin(sqrt(0.84)*y))))+0.5*sin(pi/2*x)'
+                       new b 200 200 '(2*sqrt(0.84)*cosh(0.45*x)*(-(sqrt(0.84)*sin(y)*cos(sqrt(0.84)*y))+cos(y)*sin(sqrt(0.84)*y)))/(0.4*((sqrt(0.84)*cosh(0.4*x))^2+2*(0.4*sin(sqrt(0.84)*x))^2))'
+                       new c 200 200 '(2*sqrt(0.84)*cosh(0.45*x)*(-(sqrt(0.84)*cos(y)*cos(sqrt(0.84)*y))-sin(y)*sin(sqrt(0.84)*y)))/(0.4*((sqrt(0.84)*cosh(0.4*x))^2+2*(0.4*sin(sqrt(0.84)*x))^2))'
+                       rotate 60 60
+                       light on
+                       xrange c : yrange b : zrange a : crange c
+                       surf c b a '#'; meshnum 100
+                       title 'Gaston surface'
+               \end{mglscript}
+               
+               \item[mglblock] It writes its contents verbatim to a file, specified as mandatory argument, and to the \LaTeX{} document.
+               
+               For example:
+               \begin{verbatim}
+                       \begin{mglblock}{fractal}
+                               list A [0,0,0,.16,0,0,.01] [.85,.04,-.04,.85,0,1.6,.85] [.2,-.26,.23,.22,0,1.6,.07] [-.15,.28,.26,.24,0,.44,.07]
+                               ifs2d f A 100000
+                               subplot 2 1 0 '<_' : title 'A fractal fern'
+                               ranges f(0) f(1) : axis
+                               plot f(0) f(1) 'G#o '; size 0.05
+                               
+                               subplot 2 1 1 '<_' : title 'Bifurcation plot'
+                               ranges 0 4 0 1 : axis
+                               bifurcation 0.005 'x*y*(1-y)' 'R'
+                       \end{mglblock}
+               \end{verbatim}
+\begin{mglblock}{fractal}
+list A [0,0,0,.16,0,0,.01] [.85,.04,-.04,.85,0,1.6,.85] [.2,-.26,.23,.22,0,1.6,.07] [-.15,.28,.26,.24,0,.44,.07]
+ifs2d f A 100000
+subplot 2 1 0 '<_' : title 'A fractal fern'
+ranges f(0) f(1) : axis
+plot f(0) f(1) 'G#o '; size 0.05
+
+subplot 2 1 1 '<_' : title 'Bifurcation plot'
+ranges 0 4 0 1 : axis
+bifurcation 0.005 'x*y*(1-y)' 'R'
 \end{mglblock}
-\begin{figure}[!ht]
-  \centering
-  \mglgraphics[scale=0.5]{Axis_projection}
-  \caption{The image from Axis\_projection.mgl script}
-\end{figure}
-
-Finally, you can just show MGL script itself
-\begin{verbatim}
-\begin{mglverbatim}
-  ranges 0 1 0 1 0 1
-  new x 50 '0.25*(1+cos(2*pi*x))'
-  new y 50 '0.25*(1+sin(2*pi*x))'
-  new z 50 'x'
-  new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'
-  new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx
-  light on
-  
-  title 'Projection sample':ternary 4:rotate 50 60
-  box:axis:grid
-  plot x y z 'r2':surf a '#'
-  xlabel 'X':ylabel 'Y':zlabel 'Z'
-\end{mglverbatim}
-\end{verbatim}
-
-\begin{mglverbatim}
-  ranges 0 1 0 1 0 1
-  new x 50 '0.25*(1+cos(2*pi*x))'
-  new y 50 '0.25*(1+sin(2*pi*x))'
-  new z 50 'x'
-  new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'
-  new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx
-  light on
-  
-  title 'Projection sample':ternary 4:rotate 50 60
-  box:axis:grid
-  plot x y z 'r2':surf a '#'
-  xlabel 'X':ylabel 'Y':zlabel 'Z'
-\end{mglverbatim}
-
-
-An example of usage of \texttt{\textbackslash{}mglplot} command would be:
-\begin{verbatim}
-\begin{mglsetup}
-  box '@{W9}' : axis
-\end{mglsetup}
-\begin{mglsetup}[2d]
-  box : axis
-  grid 'xy' ';k'
-\end{mglsetup}
-\begin{mglsetup}[3d]
-  rotate 50 60
-  box : axis : grid 'xyz' ';k'
-\end{mglsetup}
-\begin{figure}[!ht]
-  \centering
-  \mglplot[scale=0.5]{new a 200 'sin(pi*x)':plot a '2B'}
-\end{figure}
-\begin{figure}[!ht]
-  \centering
-  \mglplot[scale=0.5,settings=2d]{
-    fplot 'sin(pi*x)' '2B' :
-    fplot 'cos(pi*x^2)' '2R'
-  }
-\end{figure}
-\begin{figure}[!ht]
-  \centering
-  \mglplot[width=0.5 \textwidth, settings=3d]
-  {fsurf 'sin(pi*x)+cos(pi*y)'}
-\end{figure}
-\end{verbatim}
-
-\begin{mglsetup}{generic}
-  box '@{W9}' : axis
-\end{mglsetup}
-\begin{mglsetup}{2d}
-  box : axis
-  grid 'xy' ';k'
-\end{mglsetup}
-\begin{mglsetup}{3d}
-  rotate 50 60
-  box : axis : grid 'xyz' ';k'
-\end{mglsetup}
-\begin{figure}[!ht]
-  \centering
-  \mglplot[scale=0.5,setup=generic]{new a 200 'x' : fplot 'sin(pi*x)' '2R' : plot a '2B'}
-\end{figure}
-\begin{figure}[!ht]
-  \centering
-  \mglplot[scale=0.5,setup=2d]{%
-    fplot 'sin(pi*x)' '2B' :%
-    fplot 'cos(pi*x^2)' '2R'%
-  }
-\end{figure}
-\begin{figure}[!ht]
-  \centering
-  \mglplot[width=0.5\textwidth, setup=3d]{fsurf 'sin(pi*x)+cos(pi*y)'}
-\end{figure}
-
-As an additional feature, when an image is not found or cannot be included, instead of issuing an error, \texttt{mgltex} prints a box with the word \emph{'MGL image not found'} in the LaTeX document.
-\begin{figure}[!ht]
-  \centering
-  \mglgraphics{xyz}
-\end{figure}
-
-Let's display the content of the MGL file using \texttt{\textbackslash{}mglinclude} command:
-\mglinclude{Vectorial}
-
-The following commentary will be visible, since \mglTeX{} has been called with the \texttt{comments} option.
-\begin{verbatim}
-  \begin{mglcomment}
-    This is a visible commentary
-    that can have multiple lines
-  \end{mglcomment}
-\end{verbatim}
-The result is:
+               As you can see, although this is a verbatim-like environment, very long lines of code are split to fit the paragraph. Each line of code is numbered, this can be disabled with the \verb|lineno| option, like \verb|\begin{mglblock}[lineno=false]{fractal}|.
+               
+               \item[mglverbatim] This is like \verb|mglblock| environment, but it doesn't produce any script, just typesets the code to the \LaTeX{} document. It accepts the \verb|lineno| option, plus the \verb|label| option, in case you want to associate a name to the code.
+               
+               \item[mglcomment] This environment is used to embed comments in the document. You can control whether the contents of this environment are displayed or not, using the \verb|comments| and \verb|nocomments| package options, or the \verb|\mglcomments{on}| and \verb|mglcomments{off}| commands.
+               
+               An example of this would be:
+               \begin{verbatim}
+                       \begin{mglcomments}
+                               This comment will be shown because we used the "comments" package option for mglTeX
+                       \end{mglcomments}
+               \end{verbatim}
 \begin{mglcomment}
-  This is a visible commentary
-  that can have multiple lines
+This comment will be shown because we used the "comments" package option for mglTeX
 \end{mglcomment}
-
-The following commentary won't be visible, since it is wrapped by \texttt{\textbackslash{}mglnocomments\{off\}} and \texttt{\textbackslash{}mglcomments\{on\}}.
-\begin{verbatim}
-  \mglcomments{off}
-  \begin{mglcomment}
-    This is an invisible commentary
-    that can have multiple lines
-  \end{mglcomment}
-  \mglcomments{on}
-\end{verbatim}
-\mglcomments{off}
-\begin{mglcomment}
-  This is an invisible commentary
-  that can have multiple lines
-\end{mglcomment}
-\mglcomments{on}
-
-The last example is the use of the \texttt{\textbackslash{}mglswitch\{on\}} and \texttt{\textbackslash{}mglswitch\{off\}} commands. For example, the following image won't be generated:
-\begin{verbatim}
-  \mglswitch{off}
-  \begin{figure}[!ht]
-    \centering
-    \begin{mgl}
-      box : axis
-      fplot 'sin(pi*x)' '2B'
-    \end{mgl}
-  \end{figure}
-  \mglswitch{on}
-\end{verbatim}
-The result is:
-\mglswitch{off}
-\begin{figure}[!ht]
-  \centering
-  \begin{mgl}
-    box : axis
-    fplot 'sin(pi*x)' '2B'
-  \end{mgl}
-\end{figure}
-\mglswitch{on}
+               Once again, long lines are broke down to fit the paragraph.
+       \end{description}
+       
+       \section{Basics on commands}
+       \begin{description}
+               \item[\textbackslash mglgraphics] This command takes the name of an external MGL script, compiles it, and includes the resulting image. It accespt the same optional arguments as the \verb|mgl| environment, except for \verb|label|, plus a \verb|path| option, which can be used to specify the location of the script. This is useful when you have a script outside of the \LaTeX{} document (sent by a colleague for example), but you don't want to transcript it to your document.
+               
+               For example, in order to display the image of the script we created with \verb|mglscript| environment, we write:
+               \begin{verbatim}
+                       \begin{figure}[!ht]
+                         \centering
+                         \mglgraphics[height=9cm,width=9cm]{Gaston_surface}
+                         \caption{Gaston's surface}
+                       \end{figure}
+               \end{verbatim}
+               \begin{figure}[!ht]
+                       \centering
+                       \mglgraphics[height=9cm,width=9cm]{Gaston_surface}
+                       \caption{Gaston's surface: Three-dimensional parametric surface}
+               \end{figure}
+               
+               We could also could compile the script we created with the \verb|mglblock| environment:
+               \begin{verbatim}
+                       \begin{figure}[!ht]
+                         \centering
+                         \mglgraphics[height=7cm,width=10cm]{fractal}
+                         \caption{Examples of fractal behavior}
+                       \end{figure}
+               \end{verbatim}
+               \begin{figure}[!ht]
+                       \centering
+                       \mglgraphics[height=7cm,width=10cm]{fractal}
+                       \caption{Examples of fractal behavior}
+               \end{figure}
+               
+               \item[\textbackslash mglinclude] This is equivalent to the \verb|mglblock| environment, but works for external scripts.
+               
+               \item[\textbackslash mglplot] This command allows the fast creation of plots. It takes one mandatory argument, which is a block of MGL code to produce the plot. Accepts the same optional arguments as the \verb|mgl| environment, plus an additional one, \verb|setup|, that can be used to specify a block of code to append, defined inside a \verb|mglsetup| environment (see the example below).
+               
+               The \verb|mglsetup| environment can be used if many plots will have the same settings (background color, etc.). Instead of writing the same code over and over again, it can be introduced in that environment, and used with the \verb|\mglplot| command.
+               
+               An example of use of the \verb|mglsetup| environment and the \verb|\mglplot| command would be:
+               \begin{verbatim}
+                       \begin{mglsetup}{3d}
+                         clf 'W'
+                         rotate 50 60
+                         light on
+                         box : axis : grid 'xyz' ';k'
+                       \end{mglsetup}
+                       \begin{figure}[!ht]
+                         \centering
+                         \mglplot[setup=3d,scale=0.5]{fsurf 'cos(4*pi*hypot(x,y))*exp(-abs(x+y))'}
+                       \end{figure}
+                       \begin{figure}[!ht]
+                         \centering
+                         \mglplot[setup=3d,scale=0.5]{fsurf 'sin(pi*(x+y))'}
+                       \end{figure}
+               \end{verbatim}
+               \begin{mglsetup}{3d}
+                       clf 'W'
+                       rotate 50 60
+                       light on : light 0 0 1 0 'w' 0.25
+                       box : axis : grid 'xyz' ';k'
+               \end{mglsetup}
+               \begin{figure}[!ht]
+                       \centering
+                       \mglplot[setup=3d,scale=0.5]{fsurf 'cos(4*pi*hypot(x,y))*exp(-abs(x+y))'}
+               \end{figure}
+               \begin{figure}[!ht]
+                       \centering
+                       \mglplot[setup=3d,scale=0.5]{fsurf 'sin(pi*(x+y))'}
+               \end{figure}
+       \end{description}
+       
+       There are more environments and commands defined by \mglTeX{}. The ones presented here are the most basic. More on this topic can be found in the documentation.
 \end{document}
\ No newline at end of file
index 0470c22ae657c4759a22ecd652c463f555a1341d..ea538cc4d27831fb91be3b9e4027f387ec06382c 100644 (file)
@@ -4,8 +4,8 @@ set(mgl_src
        data.cpp data_io.cpp data_ex.cpp data_png.cpp
        export_2d.cpp export_3d.cpp eval.cpp evalp.cpp exec.cpp export.cpp
        fit.cpp font.cpp obj.cpp other.cpp parser.cpp pde.cpp pixel.cpp
-       plot.cpp prim.cpp surf.cpp tex_table.cc vect.cpp volume.cpp evalc.cpp
-       s_hull/s_hull_pro.cpp window.cpp
+       plot.cpp prim.cpp surf.cpp vect.cpp volume.cpp evalc.cpp
+       s_hull/s_hull_pro.cpp window.cpp fractal.cpp
 )
 
 set(mgl_hdr
@@ -20,6 +20,7 @@ ${MathGL_BINARY_DIR}/include/mgl2/dllexport.h cont.hpp
        ../include/mgl2/parser.h        ../include/mgl2/addon.h         ../include/mgl2/evalc.h
        s_hull/s_hull_pro.h                     ../include/mgl2/wnd.h           ../include/mgl2/canvas_wnd.h
        ../include/mgl2/thread.h        ../include/mgl2/abstract.h      ../include/mgl2/pde.h
+#      tex_table.cc     def_font.cc
 )
 
 add_definitions(-DMGL_SRC)
@@ -42,76 +43,16 @@ if(MGL_HAVE_OPENGL)
 endif(MGL_HAVE_OPENGL)
 
 include(GenerateExportHeader)
-add_compiler_export_flags()
 mgl_add_lib(mgl ${mgl_src} ${mgl_hdr})
 generate_export_header(mgl EXPORT_FILE_NAME ../include/mgl2/dllexport.h)
 
-# if(MGL_HAVE_LTDL)
-#      target_link_libraries(mgl ${LTDL_LIB})
-#      include_directories(${LTDL_INCLUDE_DIR})
-# endif(MGL_HAVE_LTDL)
-
-if(MGL_HAVE_PDF)
-       include_directories(${HPDF_INCLUDE_DIR})
-       target_link_libraries(mgl ${HPDF_LIB})
-endif(MGL_HAVE_PDF)
-
-if(MGL_HAVE_PTHREAD)
-       target_link_libraries(mgl ${CMAKE_THREAD_LIBS_INIT})
-endif(MGL_HAVE_PTHREAD)
-
-if(MGL_HAVE_JPEG)
-       target_link_libraries(mgl ${JPEG_LIBRARIES})
-       include_directories(${JPEG_INCLUDE_DIR})
-endif(MGL_HAVE_JPEG)
-
-if(MGL_HAVE_GIF)
-       target_link_libraries(mgl ${GIF_LIBRARIES})
-       include_directories(${GIF_INCLUDE_DIR})
-endif(MGL_HAVE_GIF)
-
-if(MGL_HAVE_HDF5)
-       target_link_libraries(mgl ${HDF5_LIBRARIES} ${HDF5_C_SHARED_LIBRARY})
-       include_directories(${HDF5_INCLUDE_DIR})
-endif(MGL_HAVE_HDF5)
-
-if(MGL_HAVE_HDF4)
-       target_link_libraries(mgl ${HDF4MF_LIB} ${HDF4_LIB})
-       include_directories(${HDF4_INCLUDE_DIR})
-endif(MGL_HAVE_HDF4)
-
-if(MGL_HAVE_LTDL)
-       target_link_libraries(mgl ${LTDL_LIB} )
-       include_directories(${LTDL_INCLUDE_DIR})
-endif(MGL_HAVE_LTDL)
-
-if(MGL_HAVE_GSL)
-       target_link_libraries(mgl ${GSL_LIB} ${GSL_CBLAS_LIB} )
-       include_directories(${GSL_INCLUDE_DIR})
-endif(MGL_HAVE_GSL)
-
-if(MGL_HAVE_OPENGL)
-       target_link_libraries(mgl ${OPENGL_LIBRARIES} )
-       include_directories(${OPENGL_INCLUDE_DIR} )
-endif(MGL_HAVE_OPENGL)
-
-if(MGL_HAVE_PNG)
-       target_link_libraries(mgl ${PNG_LIBRARIES} )
-       include_directories(${PNG_INCLUDE_DIR})
-endif(MGL_HAVE_PNG)
-
-if(MGL_HAVE_ZLIB)
-       target_link_libraries(mgl ${ZLIB_LIBRARIES} )
-       include_directories(${ZLIB_INCLUDE_DIR})
-endif(MGL_HAVE_ZLIB)
-
-if(M_LIB)
-       target_link_libraries(mgl ${M_LIB})
-endif(M_LIB)
+target_link_libraries(mgl ${MGL_DEP_LIBS})
+target_link_libraries(mgl-static ${MGL_DEP_LIBS})
 
 if(MGL_HAVE_MPI)
        mgl_add_lib(mpi mpi.cpp ../include/mgl2/mpi.h)
        target_link_libraries(mgl-mpi ${MPI_LIBRARIES} )
+       target_link_libraries(mgl-mpi-static ${MPI_LIBRARIES} )
        target_include_directories(mgl-mpi SYSTEM PUBLIC ${MPI_CXX_INCLUDE_PATH})
 endif(MGL_HAVE_MPI)
 
index 9e9b8c950347d8ae6764236dc45dc6f19a8f7e9c..3a726d1f80fbd4c4dc7b811eaaa1681aef7c7cc4 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * addon.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
@@ -171,6 +171,7 @@ void MGL_EXPORT mgl_difr_grid_old(dual *a,int n,int step,dual q,int Border,dual
                memcpy(b,d,n*sizeof(dual));
                switch(Border)
                {
+                       default:
                        case 0:         // zero at border
                                b[0] = 0;       b[n-1] = 0;             break;
                        case 1:         // constant at border
index 36164ee3a182ccbb382ad46160cbf81f82b22d66..a3cd0b2aa6208cbe95892394cfd3a061123f0973 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * axis.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
@@ -216,8 +216,8 @@ void mglCanvas::SetTickTime(char dir, mreal d, const char *t)
        UpdateAxis();
 
        time_t tt;      tm t1,t2;
-       tt=aa.v1;       mgl_localtime(&tt, &t1, get(MGL_USE_GMTIME));
-       tt=aa.v2;       mgl_localtime(&tt, &t2, get(MGL_USE_GMTIME));
+       tt=(time_t)aa.v1;       mgl_localtime(&tt, &t1, get(MGL_USE_GMTIME));
+       tt=(time_t)aa.v2;       mgl_localtime(&tt, &t2, get(MGL_USE_GMTIME));
        if(aa.v1<aa.v2) // adjust periodic values
        {
                if(abs(t1.tm_year-t2.tm_year)==1)       t2.tm_yday += 365;
@@ -273,7 +273,7 @@ void mglCanvas::SetTickTime(char dir, mreal d, const char *t)
        if(v0+aa.dv!=v0 && v1+aa.dv!=v1)        for(v=v0;v<=v1;v+=aa.dv)
        {
                wchar_t buf[64];
-               tt = v; tm tp;          mgl_localtime(&tt, &tp, get(MGL_USE_GMTIME));
+               tt = (time_t)v; tm tp;          mgl_localtime(&tt, &tp, get(MGL_USE_GMTIME));
                wcsftime(buf,64,aa.t.c_str(),&tp);      aa.AddLabel(buf,v);
        }
 }
@@ -305,7 +305,7 @@ void mglCanvas::AdjustTicks(mglAxis &aa, bool ff)
        else
        {
                d /= -aa.d;
-               long n = floor(log10(d));
+               long n = lrint(floor(log10(d)));
                aa.dv = pow(10.,n)*mgl_int(d*pow(10.,-n));
                aa.o=0; aa.ds = pow(10.,n);
        }
index a1821c756256832c95842424dceec0e4d23043c8..b26dc84ff80dcee2d24660941942fbfbc674da51 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * base.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
 #include "mgl2/font.h"\r
 #include "mgl2/base.h"\r
 #include "mgl2/eval.h"\r
+#if MGL_HAVE_OMP\r
+#include <omp.h>\r
+#endif\r
+\r
+//-----------------------------------------------------------------------------\r
+void MGL_EXPORT mgl_mutex_unlock(void *mutex)\r
+{\r
+#if MGL_HAVE_PTHREAD\r
+       pthread_mutex_unlock((pthread_mutex_t *)mutex);\r
+#elif MGL_HAVE_OMP\r
+       omp_unset_lock((omp_lock_t *)mutex);\r
+#endif\r
+}\r
+//-----------------------------------------------------------------------------\r
+void MGL_EXPORT mgl_mutex_lock(void *mutex)\r
+{\r
+#if MGL_HAVE_PTHREAD\r
+       pthread_mutex_lock((pthread_mutex_t *)mutex);\r
+#elif MGL_HAVE_OMP\r
+       omp_set_lock((omp_lock_t *)mutex);\r
+#endif\r
+}\r
 //-----------------------------------------------------------------------------\r
 char *mgl_strdup(const char *s)\r
 {\r
@@ -105,13 +127,16 @@ mglBase::mglBase()
        pthread_mutex_init(&mutexClf,0);\r
        Pnt.set_mutex(&mutexClf);\r
        Prm.set_mutex(&mutexClf);\r
-       Txt.set_mutex(&mutexClf);\r
+//     Txt.set_mutex(&mutexClf);\r
 #endif\r
 #if MGL_HAVE_OMP\r
-       omp_init_lock(&lockClf);\r
-       Pnt.set_mutex(&lockClf);\r
-       Prm.set_mutex(&lockClf);\r
-       Txt.set_mutex(&lockClf);\r
+       lockClf = new omp_lock_t;\r
+       omp_init_lock((omp_lock_t*)lockClf);\r
+       Pnt.set_mutex(lockClf);\r
+       Prm.set_mutex(lockClf);\r
+//     Txt.set_mutex(&lockClf);\r
+#else\r
+       lockClf = NULL;\r
 #endif\r
        fnt=0;  *FontDef=0;     fx=fy=fz=fa=fc=0;\r
        AMin.Set(0,0,0,0);      AMax.Set(1,1,1,1);\r
@@ -127,12 +152,28 @@ mglBase::mglBase()
        MinS.Set(-1,-1,-1);     MaxS.Set(1,1,1);\r
        fnt = new mglFont;      fnt->gr = this; PrevState=NAN;  size_opt=NAN;\r
 }\r
+//-----------------------------------------------------------------------------\r
 mglBase::~mglBase()\r
 {\r
        ClearEq();      ClearPrmInd();  delete fnt;\r
-       Pnt.set_mutex(0);       Prm.set_mutex(0);       Txt.set_mutex(0);\r
+       Pnt.set_mutex(0);       Prm.set_mutex(0);       //Txt.set_mutex(0);\r
+#if MGL_HAVE_PTHREAD\r
+       pthread_mutex_destroy(&mutexPnt);\r
+       pthread_mutex_destroy(&mutexTxt);\r
+       pthread_mutex_destroy(&mutexSub);\r
+       pthread_mutex_destroy(&mutexLeg);\r
+       pthread_mutex_destroy(&mutexPrm);\r
+       pthread_mutex_destroy(&mutexPtx);\r
+       pthread_mutex_destroy(&mutexStk);\r
+       pthread_mutex_destroy(&mutexGrp);\r
+       pthread_mutex_destroy(&mutexGlf);\r
+       pthread_mutex_destroy(&mutexAct);\r
+       pthread_mutex_destroy(&mutexDrw);\r
+       pthread_mutex_destroy(&mutexClf);\r
+#endif\r
 #if MGL_HAVE_OMP\r
-       omp_destroy_lock(&lockClf);\r
+       omp_destroy_lock((omp_lock_t*)lockClf);\r
+       delete ((omp_lock_t*)lockClf);\r
 #endif\r
 }\r
 //-----------------------------------------------------------------------------\r
@@ -299,6 +340,11 @@ long mglBase::AddPnt(const mglMatrix *mat, mglPoint p, mreal c, mglPoint n, mrea
        if(ci<0 || ci>=(long)Txt.size())        ci=0;   // NOTE never should be here!!!\r
        const mglTexture &txt=Txt[ci];\r
        txt.GetC(c,a,q);        // RGBA color\r
+       if(get(MGL_GRAY_MODE))\r
+       {\r
+               float h = 0.3*q.r + 0.59*q.g + 0.11*q.b;\r
+               q.r = q.g = q.b = h;\r
+       }\r
 \r
        // add gap for texture coordinates for compatibility with OpenGL\r
        const mreal gap = 0./MGL_TEXTURE_COLOURS;\r
@@ -310,7 +356,7 @@ long mglBase::AddPnt(const mglMatrix *mat, mglPoint p, mreal c, mglPoint n, mrea
        if(!get(MGL_ENABLE_ALPHA))      {       q.a=1;  if(txt.Smooth!=2)       q.ta=1-gap;     }\r
        if(norefr)      q.v=0;\r
        if(!get(MGL_ENABLE_LIGHT) && !(scl&4))  q.u=q.v=NAN;\r
-       q.sub=mat->norot?-Sub.size():Sub.size()-1;\r
+       q.sub=mat->norot?-1*(short)Sub.size():Sub.size()-1;\r
        long k;\r
 #pragma omp critical(pnt)\r
        {k=Pnt.size();  MGL_PUSH(Pnt,q,mutexPnt);}      return k;\r
index a8ec2730a6811f6dcc117a7d8dca562848022650..148d0688b14c95d8510f050e345ffa877bbd761f 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * base.cpp is part of Math gric Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index b4130992ee2673c9900d30d3badbce0da712fbc5..8374232088e4e2a055a8e2e6c284e8b71a1fa254 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * canvas.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -763,7 +763,7 @@ void mglCanvas::Aspect(mreal Ax,mreal Ay,mreal Az)
                mreal fz=exp(M_LN10*floor(0.5+log10(fabs(dz/dx))));\r
                if(Ay>0)        fy*=Ay;\r
                if(Az>0)        fz*=Az;\r
-               Ax = Height*dx; Ay = Width*dy*fy;       Az = Depth*dz*fz;\r
+               Ax = inH*dx;    Ay = inW*dy*fy; Az = sqrt(inW*inH)*dz*fz;\r
        }\r
        mreal a = fabs(Ax) > fabs(Ay) ? fabs(Ax) : fabs(Ay);\r
        a = a > fabs(Az) ? a : fabs(Az);\r
@@ -775,6 +775,32 @@ void mglCanvas::Aspect(mreal Ax,mreal Ay,mreal Az)
        size_t n = Sub.size();  if(n>0) Sub[n-1].B = B;\r
 }\r
 //-----------------------------------------------------------------------------\r
+void mglCanvas::Shear(mreal Sx,mreal Sy)\r
+{\r
+       mreal R[6], Fx=1+fabs(Sx)*inH/inW, Fy=1+fabs(Sy)*inW/inH;\r
+       memcpy(R,B.b,6*sizeof(mreal));\r
+       B.b[0] = (R[0]+Sx*R[3])/Fx;     B.b[1] = (R[1]+Sx*R[4])/Fx;     B.b[2] = (R[2]+Sx*R[5])/Fx;\r
+       B.b[3] = (R[3]+Sy*R[0])/Fy;     B.b[4] = (R[4]+Sy*R[1])/Fy;     B.b[5] = (R[5]+Sy*R[2])/Fy;\r
+       size_t n = Sub.size();  if(n>0) Sub[n-1].B = B;\r
+}\r
+//-----------------------------------------------------------------------------\r
+void mglCanvas::ShearPlot(int num, int id, mreal sx, mreal sy, mreal xd, mreal yd)\r
+{\r
+       InPlot(0,1,0,1,true);\r
+       if(!(fabs(xd)<=1 && fabs(yd)<=1))       {       xd=1;   yd=0;   }\r
+       mreal wx,wy,dx,dy,wf,hf,x1,y1;\r
+       int ix=sy>=0?id:num-id-1, iy=sx>=0?id:num-id-1;\r
+       for(int i=0;i<3;i++)    // iterations to solve cubic equation\r
+       {\r
+               wx = fabs(sx)*inH/inW;  dx = xd + yd*wx;        wf = 1+wx+(num-1)*fabs(dx);\r
+               wy = fabs(sy)*inW/inH;  dy = yd + xd*wy;        hf = 1+wy+(num-1)*fabs(dy);\r
+               x1=(dx>=0?ix:(ix-num+1))*dx;\r
+               y1=(dy>=0?iy:(iy-num+1))*dy;\r
+               InPlot(x1/wf,(x1+1+wx)/wf,y1/hf,(y1+1+wy)/hf,true);\r
+       }\r
+       Shear(sx,sy);\r
+}\r
+//-----------------------------------------------------------------------------\r
 //     Lighting and transparency\r
 //-----------------------------------------------------------------------------\r
 void mglCanvas::Fog(mreal d, mreal dz) {       FogDist=d;      FogDz = dz;     }\r
index 3eb207b56195d9b1e2231c217e378667e58d5c37..6d7cbb7ccf8c85b3023514b7976e5e753746b273 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * canvas_cf.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -83,6 +83,7 @@ void MGL_EXPORT mgl_clear_frame(HMGL gr)
 void MGL_EXPORT mgl_set_transp_type(HMGL gr, int type)\r
 {      mglCanvas *g = dynamic_cast<mglCanvas *>(gr);   if(g)   g->SetTranspType(type); }\r
 void MGL_EXPORT mgl_set_alpha(HMGL gr, int enable)     {       gr->Alpha(enable);      }\r
+void MGL_EXPORT mgl_set_gray(HMGL gr, int enable)      {       gr->set(enable, MGL_GRAY_MODE); }\r
 void MGL_EXPORT mgl_set_fog(HMGL gr, double d, double dz)\r
 {      mglCanvas *g = dynamic_cast<mglCanvas *>(gr);   if(g)   g->Fog(d,dz);   }\r
 void MGL_EXPORT mgl_set_light(HMGL gr, int enable)     {       gr->Light(enable);      }\r
@@ -159,9 +160,13 @@ void MGL_EXPORT mgl_gridplot(HMGL gr, int nx, int ny, int i, double dd)
 //-----------------------------------------------------------------------------\r
 void MGL_EXPORT mgl_stickplot(HMGL gr, int num, int i, double tet, double phi)\r
 {      mglCanvas *g = dynamic_cast<mglCanvas *>(gr);   if(g)   g->StickPlot(num, i, tet, phi); }\r
+void MGL_EXPORT mgl_shearplot(HMGL gr, int num, int i, double sx, double sy, double xd, double yd)\r
+{      mglCanvas *g = dynamic_cast<mglCanvas *>(gr);   if(g)   g->ShearPlot(num, i, sx, sy, xd, yd);   }\r
 //-----------------------------------------------------------------------------\r
 void MGL_EXPORT mgl_aspect(HMGL gr, double Ax,double Ay,double Az)\r
 {      mglCanvas *g = dynamic_cast<mglCanvas *>(gr);   if(g)   g->Aspect(Ax,Ay,Az);    }\r
+void MGL_EXPORT mgl_shear(HMGL gr, double Sx,double Sy)\r
+{      mglCanvas *g = dynamic_cast<mglCanvas *>(gr);   if(g)   g->Shear(Sx,Sy);        }\r
 void MGL_EXPORT mgl_rotate(HMGL gr, double TetX,double TetZ,double TetY)\r
 {      mglCanvas *g = dynamic_cast<mglCanvas *>(gr);   if(g)   g->Rotate(TetX,TetZ,TetY);      }\r
 void MGL_EXPORT mgl_view(HMGL gr, double TetX,double TetZ,double TetY)\r
@@ -191,6 +196,7 @@ void MGL_EXPORT mgl_clear_frame_(uintptr_t *gr)                     {       _GR_->ClearFrame();     }
 //-----------------------------------------------------------------------------\r
 void MGL_EXPORT mgl_set_transp_type_(uintptr_t *gr, int *type)         {       _GR_->SetTranspType(*type);     }\r
 void MGL_EXPORT mgl_set_alpha_(uintptr_t *gr, int *enable)                     {       _GR_->Alpha(*enable);   }\r
+void MGL_EXPORT mgl_set_gray_(uintptr_t *gr, int *enable)                      {       _GR_->set(*enable, MGL_GRAY_MODE);      }\r
 void MGL_EXPORT mgl_set_fog_(uintptr_t *gr, mreal *d, mreal *dz)       {       _GR_->Fog(*d, *dz);             }\r
 void MGL_EXPORT mgl_set_light_(uintptr_t *gr, int *enable)                     {       _GR_->Light(*enable);   }\r
 void MGL_EXPORT mgl_set_attach_light_(uintptr_t *gr, int *enable)      {       _GR_->AttachLight(*enable);     }\r
@@ -236,6 +242,8 @@ void MGL_EXPORT mgl_gridplot_(uintptr_t *gr, int *nx, int *ny, int *i, mreal *d)
 {      mgl_gridplot(_GR_,*nx,*ny,*i,*d);       }\r
 void MGL_EXPORT mgl_stickplot_(uintptr_t *gr, int *num, int *i, mreal *tet, mreal *phi)\r
 {      _GR_->StickPlot(*num, *i, *tet, *phi);  }\r
+void MGL_EXPORT mgl_shearplot_(uintptr_t *gr, int *num, int *i, mreal *sy, mreal *sx, mreal *xd, mreal *yd)\r
+{      _GR_->ShearPlot(*num,*i,*sx,*sy,*xd,*yd);       }\r
 \r
 void MGL_EXPORT mgl_title_(uintptr_t *gr, const char *title, const char *stl, mreal *size, int l,int m)\r
 {      char *t=new char[l+1];  memcpy(t,title,l);      t[l]=0;\r
@@ -243,6 +251,8 @@ void MGL_EXPORT mgl_title_(uintptr_t *gr, const char *title, const char *stl, mr
        _GR_->Title(t,s,*size); delete []s;     delete []t;     }\r
 void MGL_EXPORT mgl_aspect_(uintptr_t *gr, mreal *Ax, mreal *Ay, mreal *Az)\r
 {      _GR_->Aspect(*Ax,*Ay,*Az);      }\r
+void MGL_EXPORT mgl_shear_(uintptr_t *gr, mreal *Sx, mreal *Sy)\r
+{      _GR_->Shear(*Sx,*Sy);   }\r
 void MGL_EXPORT mgl_rotate_(uintptr_t *gr, mreal *TetX, mreal *TetZ, mreal *TetY)\r
 {      _GR_->Rotate(*TetX,*TetZ,*TetY);        }\r
 void MGL_EXPORT mgl_view_(uintptr_t *gr, mreal *TetX, mreal *TetZ, mreal *TetY)\r
@@ -399,7 +409,7 @@ void MGL_EXPORT mgl_set_ticks_str_(uintptr_t *gr, const char *dir, const char *l
 void MGL_EXPORT mgl_set_ticks_val_(uintptr_t *gr, const char *dir, uintptr_t *val, const char *lbl, int *add,int,int l)\r
 {      char *s=new char[l+1];  memcpy(s,lbl,l);        s[l]=0;\r
        _GR_->SetTicksVal(*dir,_DA_(val),s,*add);       delete []s;     }\r
-void MGL_EXPORT mgl_add_tick_(uintptr_t *gr, const char *dir, mreal *val, const char *lbl, int *add,int,int l)\r
+void MGL_EXPORT mgl_add_tick_(uintptr_t *gr, const char *dir, mreal *val, const char *lbl, int,int l)\r
 {      char *s=new char[l+1];  memcpy(s,lbl,l);        s[l]=0;\r
        mgl_add_tick(_GR_,*dir,*val,s); delete []s;     }\r
 void MGL_EXPORT mgl_tune_ticks_(uintptr_t *gr, int *tune, mreal *fact_pos)\r
index ccfbb206159c915bfd3e0fd7c03af9e6cba5deec..891482b22d2b1e87e3168770979850e133bb0cd9 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * complex.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -912,7 +912,7 @@ void MGL_EXPORT mgl_datac_put_val(HADT d, dual val, long xx, long yy, long zz)
        if(xx>=nx || yy>=ny || zz>=nz)  return;\r
        dual *a=d->a;\r
        if(xx>=0 && yy>=0 && zz>=0)     a[xx+nx*(yy+zz*ny)] = val;\r
-       if(xx<0 && yy<0 && zz<0)\r
+       else if(xx<0 && yy<0 && zz<0)\r
 #pragma omp parallel for\r
                for(long i=0;i<nx*ny*nz;i++)    a[i] = val;\r
        else if(xx<0 && yy<0)\r
@@ -1086,22 +1086,28 @@ void MGL_EXPORT mgl_datac_diffr(HADT d, const char *how, mreal q)
 {\r
        if(!how || *how==0)     return;\r
        long nx=d->nx,ny=d->ny,nz=d->nz,ll=strlen(how);\r
-       long p[4]={0,0,(mglchr(how,'a')||mglchr(how,'r'))?1:0,0};\r
+       long p[4]={0,0,0,0};\r
        dual qq=q;\r
        for(long i=0;i<ll;i++)  if(how[i]>='0' && how[i]<='9')  p[3] = how[i]-'0';\r
+       bool axial = mglchr(how,'r')||mglchr(how,'r');\r
        if(mglchr(how,'z') && nz>1)\r
        {\r
-               p[0]=nz;        p[1]=nx*ny;\r
+               p[0]=nz;        p[1]=nx*ny;     p[2]=0;\r
                mglStartThreadC(mgl_difr,0,nx*ny,0,&qq,0,p);\r
        }\r
-       if(mglchr(how,'y') && ny>1)\r
+       if(mglchr(how,'y') && ny>1 && !axial)\r
        {\r
-               p[0]=ny;        p[1]=nx;\r
+               p[0]=ny;        p[1]=nx;        p[2]=0;\r
                mglStartThreadC(mgl_difr,0,nx*nz,0,&qq,0,p);\r
        }\r
-       if((mglchr(how,'x')||mglchr(how,'r')) && nx>1)\r
+       if(mglchr(how,'x') && nx>1 && !axial)\r
        {\r
-               p[0]=nx;        p[1]=1;\r
+               p[0]=nx;        p[1]=1; p[2]=0;\r
+               mglStartThreadC(mgl_difr,0,ny*nz,0,&qq,0,p);\r
+       }\r
+       if(axial && nx>1)\r
+       {\r
+               p[0]=nx;        p[1]=1; p[2]=1;\r
                mglStartThreadC(mgl_difr,0,ny*nz,0,&qq,0,p);\r
        }\r
 }\r
@@ -1171,7 +1177,7 @@ void MGL_EXPORT mgl_datac_refill_gs(HADT dat, HCDT xdat, HCDT vdat, mreal x1, mr
 #pragma omp parallel for\r
        for(long i=0;i<nx;i++)\r
        {\r
-               register dual d = mgl_gsplinec(coef,x0+dx*i,0,0);\r
+               dual d = mgl_gsplinec(coef,x0+dx*i,0,0);\r
                if(sl<0)        for(long j=0;j<nn;j++)  dat->a[i+j*nx] = d;\r
                else    dat->a[i+sl*nx] = d;\r
        }\r
@@ -1188,7 +1194,7 @@ void MGL_EXPORT mgl_datac_refill_x(HADT dat, HCDT xdat, HCDT vdat, mreal x1, mre
        for(long i=0;i<nx;i++)\r
        {\r
                register mreal u = mgl_index_1(x1+dx*i,xdat);\r
-               register dual d = mgl_datac_spline(vdat,u,0,0);\r
+               dual d = mgl_datac_spline(vdat,u,0,0);\r
                if(sl<0)        for(long j=0;j<nn;j++)  dat->a[i+j*nx] = d;\r
                else    dat->a[i+sl*nx] = d;\r
        }\r
@@ -1263,7 +1269,7 @@ void MGL_EXPORT mgl_datac_refill_xy(HADT dat, HCDT xdat, HCDT ydat, HCDT vdat, m
 #pragma omp parallel for collapse(2)\r
                for(long j=0;j<ny;j++)  for(long i=0;i<nx;i++)\r
                {\r
-                       register dual d = mgl_datac_spline(vdat,u.a[i],v.a[j],0);\r
+                       dual d = mgl_datac_spline(vdat,u.a[i],v.a[j],0);\r
                        register long i0=i+nx*j;\r
                        if(sl<0)        for(long k=0;k<nz;k++)  dat->a[i0+k*nn] = d;\r
                        else    dat->a[i0+sl*nn] = d;\r
index 5d5ab4ddea1c3468f03f2db793bb7dbf45529adf..3c3af89a584b803f591fd234161cdd5e9e075cd3 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * data_new.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -62,7 +62,7 @@ HADT MGL_EXPORT mgl_datac_subdata_ext(HCDT d, HCDT xx, HCDT yy, HCDT zz)
                mglData tmp;    tmp.a[0]=-1;\r
                return mgl_datac_subdata_ext(d,xx?xx:&tmp,yy?yy:&tmp,zz?zz:&tmp);\r
        }\r
-       \r
+\r
        long n=0,m=0,l=0,j,k;\r
        bool ix=false, iy=false, iz=false;\r
        if(xx->GetNz()>1)       // 3d data\r
@@ -330,20 +330,21 @@ HADT MGL_EXPORT mgl_datac_sum(HCDT dat, const char *dir)
        if(strchr(dir,'z') && nz>1)\r
        {\r
                mglStartThreadC(mgl_sumc_z,0,nx*ny,b,c,0,p);\r
-               memcpy(c,b,nx*ny*sizeof(mreal));        p[2] = 1;\r
+               memcpy(c,b,nx*ny*sizeof(dual)); p[2] = 1;\r
        }\r
        if(strchr(dir,'y') && ny>1)\r
        {\r
                mglStartThreadC(mgl_sumc_y,0,nx*p[2],b,c,0,p);\r
-               memcpy(c,b,nx*p[2]*sizeof(mreal));      p[1] = p[2];    p[2] = 1;\r
+               memcpy(c,b,nx*p[2]*sizeof(dual));       p[1] = p[2];    p[2] = 1;\r
        }\r
        if(strchr(dir,'x') && nx>1)\r
        {\r
                mglStartThreadC(mgl_sumc_x,0,p[1]*p[2],b,c,0,p);\r
                p[0] = p[1];    p[1] = p[2];    p[2] = 1;\r
+               memcpy(c,b,p[0]*p[1]*sizeof(dual));\r
        }\r
        mglDataC *r=new mglDataC(p[0],p[1],p[2]);\r
-       memcpy(r->a,b,p[0]*p[1]*p[2]*sizeof(dual));\r
+       memcpy(r->a,c,p[0]*p[1]*p[2]*sizeof(dual));\r
        delete []b;     delete []c;     return r;\r
 }\r
 uintptr_t MGL_EXPORT mgl_datac_sum_(uintptr_t *d, const char *dir,int l)\r
@@ -368,10 +369,10 @@ HADT MGL_EXPORT mgl_datac_momentum(HCDT dat, char dir, const char *how)
 #pragma omp parallel for\r
                for(long i=0;i<nx;i++)\r
                {\r
-                       register dual i1=0,i0=0;\r
+                       dual i1=0,i0=0;\r
                        for(long j=0;j<ny*nz;j++)\r
                        {\r
-                               register dual u=dat->vthr(i+nx*j);\r
+                               dual u=dat->vthr(i+nx*j);\r
                                i0 += u;        i1 += u*res->a[i+nx*j];\r
                        }\r
                        b->a[i] = i0!=mreal(0) ? i1/i0 : 0;\r
@@ -383,10 +384,10 @@ HADT MGL_EXPORT mgl_datac_momentum(HCDT dat, char dir, const char *how)
 #pragma omp parallel for\r
                for(long i=0;i<ny;i++)\r
                {\r
-                       register dual i1=0,i0=0;\r
+                       dual i1=0,i0=0;\r
                        for(long k=0;k<nz;k++)  for(long j=0;j<nx;j++)\r
                        {\r
-                               register dual u=dat->v(j,i,k);\r
+                               dual u=dat->v(j,i,k);\r
                                i0 += u;        i1 += u*res->a[j+nx*(i+ny*k)];\r
                        }\r
                        b->a[i] = i0!=mreal(0) ? i1/i0 : 0;\r
@@ -399,10 +400,10 @@ HADT MGL_EXPORT mgl_datac_momentum(HCDT dat, char dir, const char *how)
 #pragma omp parallel for\r
                for(long i=0;i<nz;i++)\r
                {\r
-                       register dual i1=0,i0=0;\r
+                       dual i1=0,i0=0;\r
                        for(long j=0;j<nn;j++)\r
                        {\r
-                               register dual u=dat->vthr(j+nn*i);\r
+                               dual u=dat->vthr(j+nn*i);\r
                                i0 += u;        i1 += u*res->a[j+nn*i];\r
                        }\r
                        b->a[i] = i0!=mreal(0) ? i1/i0 : 0;\r
@@ -421,25 +422,27 @@ HADT MGL_EXPORT mgl_datac_evaluate(HCDT dat, HCDT idat, HCDT jdat, HCDT kdat, in
        const mglDataC *dc=dynamic_cast<const mglDataC *>(dat);\r
        long nx=dat->GetNx(), ny=dat->GetNy(), nz=dat->GetNz();\r
        mglDataC *r=new mglDataC(idat->GetNx(),idat->GetNy(),idat->GetNz());\r
+       mreal dx = nx-1, dy = ny-1, dz = nz-1;\r
+       if(!norm)       dx=dy=dz=1;\r
        if(dd)\r
 #pragma omp parallel for\r
                for(long i=0;i<idat->GetNN();i++)\r
                {\r
-                       mreal x=idat->vthr(i), y=jdat?jdat->vthr(i):0, z=kdat?kdat->vthr(i):0;\r
+                       mreal x=dx*idat->vthr(i), y=jdat?dy*jdat->vthr(i):0, z=kdat?dz*kdat->vthr(i):0;\r
                        r->a[i] = mgl_isnum(x*y*z)?mglSpline3st<mreal>(dd->a,nx,ny,nz, x,y,z):NAN;\r
                }\r
        else if(dc)\r
 #pragma omp parallel for\r
                for(long i=0;i<idat->GetNN();i++)\r
                {\r
-                       mreal x=idat->vthr(i), y=jdat?jdat->vthr(i):0, z=kdat?kdat->vthr(i):0;\r
+                       mreal x=dx*idat->vthr(i), y=jdat?dy*jdat->vthr(i):0, z=kdat?dz*kdat->vthr(i):0;\r
                        r->a[i] = mgl_isnum(x*y*z)?mglSpline3st<dual>(dc->a,nx,ny,nz, x,y,z):NAN;\r
                }\r
        else\r
 #pragma omp parallel for\r
                for(long i=0;i<idat->GetNN();i++)\r
                {\r
-                       mreal x=idat->vthr(i), y=jdat?jdat->vthr(i):0, z=kdat?kdat->vthr(i):0;\r
+                       mreal x=dx*idat->vthr(i), y=jdat?dy*jdat->vthr(i):0, z=kdat?dz*kdat->vthr(i):0;\r
                        r->a[i] = mgl_isnum(x*y*z)?dat->linear(x,y,z):NAN;;\r
                }\r
        return r;\r
@@ -481,7 +484,7 @@ void MGL_EXPORT mgl_datac_mul_dat(HADT d, HCDT a)
        long nx=d->nx, ny=d->ny, nz=d->nz;\r
        long mx=a->GetNx(), my=a->GetNy(), mz=a->GetNz();\r
        const mglDataC *c = dynamic_cast<const mglDataC*>(a);\r
-       \r
+\r
        if(mz*my*mx==1)\r
        {\r
                dual v=c?c->a[0]:a->v(0);\r
@@ -515,7 +518,7 @@ void MGL_EXPORT mgl_datac_div_dat(HADT d, HCDT a)
        long nx=d->nx, ny=d->ny, nz=d->nz;\r
        long mx=a->GetNx(), my=a->GetNy(), mz=a->GetNz();\r
        const mglDataC *c = dynamic_cast<const mglDataC*>(a);\r
-       \r
+\r
        if(mz*my*mx==1)\r
        {\r
                dual v=c?c->a[0]:a->v(0);\r
@@ -549,7 +552,7 @@ void MGL_EXPORT mgl_datac_add_dat(HADT d, HCDT a)
        long nx=d->nx, ny=d->ny, nz=d->nz;\r
        long mx=a->GetNx(), my=a->GetNy(), mz=a->GetNz();\r
        const mglDataC *c = dynamic_cast<const mglDataC*>(a);\r
-       \r
+\r
        if(mz*my*mx==1)\r
        {\r
                dual v=c?c->a[0]:a->v(0);\r
@@ -583,7 +586,7 @@ void MGL_EXPORT mgl_datac_sub_dat(HADT d, HCDT a)
        long nx=d->nx, ny=d->ny, nz=d->nz;\r
        long mx=a->GetNx(), my=a->GetNy(), mz=a->GetNz();\r
        const mglDataC *c = dynamic_cast<const mglDataC*>(a);\r
-       \r
+\r
        if(mz*my*mx==1)\r
        {\r
                dual v=c?c->a[0]:a->v(0);\r
index a1dee5d99bd546ff467fb55ad2c34cda0a009160..26d3eb984084f7f0dcc9162bbb65656b02c86d4d 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * data_io.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -945,3 +945,14 @@ void MGL_EXPORT mgl_datac_save_hdf_(uintptr_t *d, const char *fname, const char
        char *t=new char[n+1];          memcpy(t,data,n);       t[n]=0;\r
        mgl_datac_save_hdf(_DC_,s,t,*rewrite);  delete []s;     delete []t;     }\r
 //-----------------------------------------------------------------------------\r
+void MGL_EXPORT mgl_datac_limit(HADT d, mreal v)\r
+{\r
+       long n = d->GetNN();\r
+       dual *a = d->a;\r
+       #pragma omp parallel for\r
+       for(long i=0;i<n;i++)\r
+       {       mreal b = abs(a[i]);    if(b>v) a[i] *= v/b;    }\r
+}\r
+void MGL_EXPORT mgl_datac_limit_(uintptr_t *d, mreal *v)\r
+{      mgl_datac_limit(_DC_, *v);      }\r
+//-----------------------------------------------------------------------------\r
index b39a034152ad47c628b463c9b8f3129bb1645366..e98984c736a97ad0db4ddbd6b02aa08206e3228c 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * cont.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -411,14 +411,14 @@ void MGL_EXPORT mgl_cont_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const c
                x = &xx;        y = &yy;\r
        }\r
        // x, y -- have the same size z\r
-       mglDataV zz(n, m);\r
+#pragma omp parallel for collapse(2)\r
        for(long i=0;i<v->GetNx();i++)  for(long j=0;j<z->GetNz();j++)\r
        {\r
                if(gr->NeedStop())      {       i = v->GetNx(); j = z->GetNz(); continue;       }\r
                mreal v0 = v->v(i), z0 = fixed ? gr->Min.z : v0;\r
                if(z->GetNz()>1)\r
                        z0 = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(j)/(z->GetNz()-1);\r
-               zz.Fill(z0,z0);\r
+               mglDataV zz(n, m);      zz.Fill(z0,z0);\r
                mgl_cont_gen(gr,v0,z,x,y,&zz,gr->GetC(s,v0),text,j);\r
        }\r
        gr->EndGroup();\r
@@ -526,21 +526,20 @@ void MGL_EXPORT mgl_contf_gen(HMGL gr, mreal v1, mreal v2, HCDT a, HCDT x, HCDT
        if(n<2 || m<2 || x->GetNx()*x->GetNy()!=n*m || y->GetNx()*y->GetNy()!=n*m || z->GetNx()*z->GetNy()!=n*m)\r
        {       gr->SetWarn(mglWarnDim,"ContFGen");     return; }\r
 \r
-       register long i,j;\r
        gr->Reserve(8*n*m);\r
        long *kk = new long[4*n], l1,l2, r1,r2, t1,t2, u1,u2, b1,b2, d1,d2, p[8],num;\r
        memset(kk,-1,2*n*sizeof(long));\r
-       for(i=0;i<n-1;i++)      // add intersection points for first line\r
+       for(long i=0;i<n-1;i++) // add intersection points for first line\r
        {\r
                mgl_add_range(gr,a,x,y,z, i,0,1,0, c,u1,u2, ak,v1,v2);\r
                kk[4*i]=u1;             kk[4*i+1]=u2;\r
                mgl_add_edges(gr,a,x,y,z, i,0,1,0, c,d1,d2, ak,v1,v2);\r
                kk[4*i+2]=d1;           kk[4*i+3]=d2;\r
        }\r
-       for(j=1;j<m;j++)        // add intersection points\r
+       for(long j=1;j<m;j++)   // add intersection points\r
        {\r
                mgl_add_range(gr,a,x,y,z, 0,j-1,0,1, c,r1,r2, ak,v1,v2);\r
-               for(i=0;i<n-1;i++)\r
+               for(long i=0;i<n-1;i++)\r
                {\r
                        l1 = r1;                l2 = r2;        num=0;\r
                        t1 = kk[4*i];   t2 = kk[4*i+1];\r
@@ -681,14 +680,14 @@ void MGL_EXPORT mgl_contf_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const
                x = &xx;        y = &yy;\r
        }\r
        // x, y -- have the same size z\r
-       mglDataV zz(n, m);\r
+#pragma omp parallel for collapse(2)\r
        for(long i=0;i<v->GetNx()-1;i++)        for(long j=0;j<z->GetNz();j++)\r
        {\r
                if(gr->NeedStop())      {       i = v->GetNx(); j = z->GetNz(); continue;       }\r
                mreal v0 = v->v(i), z0 = fixed ? gr->Min.z : v0;\r
                if(z->GetNz()>1)\r
                        z0 = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(j)/(z->GetNz()-1);\r
-               zz.Fill(z0,z0);\r
+               mglDataV zz(n, m);      zz.Fill(z0,z0);\r
                mgl_contf_gen(gr,v0,v->v(i+1),z,x,y,&zz,gr->GetC(s,v0),j);\r
        }\r
        gr->EndGroup();\r
@@ -782,15 +781,15 @@ void MGL_EXPORT mgl_contd_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const
        }\r
        // x, y -- have the same size z\r
        mreal dc = nc>1 ? 1/(MGL_FEPSILON*(nc-1)) : 0;\r
-       mglDataV zz(n, m);\r
+#pragma omp parallel for collapse(2)\r
        for(long i=0;i<v->GetNx()-1;i++)        for(long j=0;j<z->GetNz();j++)\r
        {\r
                if(gr->NeedStop())      {       i = v->GetNx(); j = z->GetNz(); continue;       }\r
                mreal v0 = v->v(i), z0 = fixed ? gr->Min.z : v0;\r
                if(z->GetNz()>1)\r
                        z0 = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(j)/(z->GetNz()-1);\r
-               zz.Fill(z0,z0);\r
-               mgl_contf_gen(gr,v0,v->v(i+1),z,x,y,&zz,s+i*dc,j);\r
+               mglDataV zz(n, m);      zz.Fill(z0,z0);\r
+               mgl_contf_gen(gr,v0,v->v(i+1),z,x,y,&zz,s+(i%nc)*dc,j);\r
        }\r
        gr->EndGroup();\r
 }\r
@@ -891,13 +890,13 @@ void MGL_EXPORT mgl_contv_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const
                x = &xx;        y = &yy;\r
        }\r
        // x, y -- have the same size z\r
-       mglDataV zz(n, m);\r
+#pragma omp parallel for collapse(2)\r
        for(long i=0;i<v->GetNx();i++)  for(long j=0;j<z->GetNz();j++)\r
        {\r
                if(gr->NeedStop())      {       i = v->GetNx(); j = z->GetNz(); continue;       }\r
                mreal v0 = v->v(i), z0 = fixed ? gr->Min.z : v0;\r
                if(z->GetNz()>1)        z0 = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(j)/(z->GetNz()-1);\r
-               zz.Fill(z0,z0);\r
+               mglDataV zz(n, m);      zz.Fill(z0,z0);\r
                mreal dv = (gr->Max.c-gr->Min.c)/8;\r
                if(i>0) dv = v->v(i-1)-v->v(i);\r
                else if(i<v->GetNx()-1) dv = v->v(i)-v->v(i+1);\r
@@ -1070,6 +1069,7 @@ void MGL_EXPORT mgl_cont3_xyz_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, HCDT
 \r
        _mgl_slice s;\r
        mgl_get_slice(s,x,y,z,a,dir,sVal,both);\r
+#pragma omp parallel for\r
        for(long i=0;i<v->GetNx();i++)\r
        {\r
                register mreal v0 = v->v(i);\r
@@ -1234,6 +1234,7 @@ void MGL_EXPORT mgl_contf3_xyz_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, HCDT
        long ss=gr->AddTexture(sch);\r
        _mgl_slice s;\r
        mgl_get_slice(s,x,y,z,a,dir,sVal,both);\r
+#pragma omp parallel for\r
        for(long i=0;i<v->GetNx()-1;i++)\r
        {\r
                register mreal v0 = v->v(i);\r
@@ -1458,6 +1459,7 @@ void MGL_EXPORT mgl_axial_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const
        // x, y -- have the same size z\r
        int wire = mglchr(sch,'#')?1:0;\r
        if(mglchr(sch,'.'))     wire = 2;\r
+#pragma omp parallel for collapse(2)\r
        for(long i=0;i<v->GetNx();i++)  for(long j=0;j<z->GetNz();j++)\r
        {\r
                if(gr->NeedStop())      {       i = v->GetNx(); j = z->GetNz(); continue;       }\r
index 6c97cf2859f40b13b6ce6f6712bc0241c4d3b25a..c9ed9658a46af25b712984b2457426429f88dbbb 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * crust.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -740,12 +740,14 @@ long MGL_NO_EXPORT mgl_crust(long n,mglPoint *pp,long **nn,mreal ff)
                rs += sqrt(rm);\r
        }\r
        rs *= ff/n;     rs = rs*rs;             // "average" distance\r
-       long ind[100], set[100], ii;    // indexes of "close" points, flag that it was added and its number\r
-       mglPoint qq[100];       // normalized point coordinates\r
+       const int nnum=100;\r
+       long *ind, *set, ii;    // indexes of "close" points, flag that it was added and its number\r
+       mglPoint *qq;   // normalized point coordinates\r
+       ind = new long[nnum];   set = new long[nnum];   qq = new mglPoint[nnum];\r
        long k1,k2,k3,m=0;\r
        for(i=0;i<n;i++)        // now the triangles will be found\r
        {\r
-               memset(set,0,100*sizeof(long));\r
+               memset(set,0,nnum*sizeof(long));\r
                for(ii=0,j=0;j<n;j++)   // find close vertexes\r
                {\r
                        r = mgl_anorm(pp[i]-pp[j]);\r
@@ -767,72 +769,6 @@ long MGL_NO_EXPORT mgl_crust(long n,mglPoint *pp,long **nn,mreal ff)
                }\r
                m = mgl_insert_trig(i,ind[k1],ind[0],nn);\r
        }\r
-       return m;\r
+       delete []set;   delete []ind;   delete []qq;    return m;\r
 }\r
 //-----------------------------------------------------------------------------\r
-void MGL_NO_EXPORT mgl_ifs_2d_point(HCDT A, mreal& x, mreal& y, mreal amax)\r
-{\r
-       long i, n=A->GetNy();\r
-       mreal r = amax*mgl_rnd(), sum_prob = 0, x1;\r
-       for(i=0;i<n;i++)\r
-       {\r
-               sum_prob += A->v(6,i);\r
-               if(r<sum_prob)  break;\r
-       }\r
-       x1= A->v(0,i)*x + A->v(1,i)*y + A->v(4,i);\r
-       y = A->v(2,i)*x + A->v(3,i)*y + A->v(5,i);      x = x1;\r
-}\r
-HMDT MGL_EXPORT mgl_data_ifs_2d(HCDT A, long n, long skip)\r
-{\r
-       if(!A || A->GetNx()<7 || n<1)   return 0;       // incompatible dimensions\r
-       mreal amax=0;\r
-       for(long i=0; i<A->GetNy(); i++)        amax += A->v(6,i);\r
-       if(amax<=0)     return 0;\r
-\r
-       mglData *f = new mglData(2,n);\r
-       mreal x = 0, y = 0;\r
-       for(long i=0; i<skip; i++)      mgl_ifs_2d_point(A, x, y,amax);\r
-       for(long i=0; i<n; i++)\r
-       {\r
-               mgl_ifs_2d_point(A, x, y, amax);\r
-               f->a[2*i] = x;  f->a[2*i+1] = y;\r
-       }\r
-       return f;\r
-}\r
-uintptr_t MGL_EXPORT mgl_data_ifs_2d_(uintptr_t *d, long *n, long *skip)\r
-{      return uintptr_t(mgl_data_ifs_2d(_DT_,*n,*skip));       }\r
-//-----------------------------------------------------------------------------\r
-void MGL_NO_EXPORT mgl_ifs_3d_point(HCDT A, mreal& x, mreal& y, mreal& z, mreal amax)\r
-{\r
-       int i, n=A->GetNy();\r
-       mreal r = amax*mgl_rnd(), sum_prob = 0, x1, y1;\r
-       for (i=0; i<n; i++)\r
-       {\r
-               sum_prob += A->v(12,i);\r
-               if(r < sum_prob)  break;\r
-       }\r
-       x1= A->v(0,i)*x + A->v(1,i)*y + A->v(2,i)*z + A->v(9,i);\r
-       y1= A->v(3,i)*x + A->v(4,i)*y + A->v(5,i)*z + A->v(10,i);\r
-       z = A->v(6,i)*x + A->v(7,i)*y + A->v(8,i)*z + A->v(11,i);\r
-       x = x1; y = y1;\r
-}\r
-HMDT MGL_EXPORT mgl_data_ifs_3d(HCDT A, long n, long skip)\r
-{\r
-       if(!A || A->GetNx()<13 || n<1)  return 0;   // incompatible dimensions\r
-       mreal amax = 0;\r
-       for(int i=0; i<A->GetNy(); i++) amax += A->v(12,i);\r
-       if(amax <= 0) return 0;\r
-\r
-       mglData *f = new mglData(3,n);\r
-       mreal x = 0, y = 0, z = 0;\r
-       for(long i=0; i<skip; i++)      mgl_ifs_3d_point(A, x, y, z, amax);\r
-       for(long i=0; i<n; i++)\r
-       {\r
-               mgl_ifs_3d_point(A, x, y, z, amax);\r
-               f->a[3*i] = x;  f->a[3*i+1] = y;        f->a[3*i+2] = z;\r
-       }\r
-       return f;\r
-}\r
-uintptr_t MGL_EXPORT mgl_data_ifs_3d_(uintptr_t *d, long *n, long *skip)\r
-{   return uintptr_t(mgl_data_ifs_3d(_DT_,*n,*skip));   }\r
-//-----------------------------------------------------------------------------\r
index c6927af102719c02cfed9c06ecee90c280d7d010..6263d232385de913b980f0df69ff06bdd76bc22c 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * data.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -1533,7 +1533,7 @@ void MGL_EXPORT mgl_data_put_val(HMDT d, mreal val, long xx, long yy, long zz)
        if(xx>=nx || yy>=ny || zz>=nz)  return;\r
        mreal *a=d->a;\r
        if(xx>=0 && yy>=0 && zz>=0)     a[xx+nx*(yy+zz*ny)] = val;\r
-       if(xx<0 && yy<0 && zz<0)\r
+       else if(xx<0 && yy<0 && zz<0)\r
 #pragma omp parallel for\r
                for(long i=0;i<nx*ny*nz;i++)    a[i] = val;\r
        else if(xx<0 && yy<0)\r
@@ -2097,18 +2097,20 @@ HMDT MGL_EXPORT mgl_data_evaluate(HCDT dat, HCDT idat, HCDT jdat, HCDT kdat, int
        const mglData *dd=dynamic_cast<const mglData *>(dat);\r
        long nx=dat->GetNx(), ny=dat->GetNy(), nz=dat->GetNz();\r
        mglData *r=new mglData(idat->GetNx(),idat->GetNy(),idat->GetNz());\r
+       mreal dx = nx-1, dy = ny-1, dz = nz-1;\r
+       if(!norm)       dx=dy=dz=1;\r
        if(dd)\r
 #pragma omp parallel for\r
                for(long i=0;i<idat->GetNN();i++)\r
                {\r
-                       mreal x=idat->vthr(i), y=jdat?jdat->vthr(i):0, z=kdat?kdat->vthr(i):0;\r
+                       mreal x=dx*idat->vthr(i), y=jdat?dy*jdat->vthr(i):0, z=kdat?dz*kdat->vthr(i):0;\r
                        r->a[i] = mgl_isnum(x*y*z)?mglSpline3st<mreal>(dd->a,nx,ny,nz, x,y,z):NAN;\r
                }\r
        else\r
 #pragma omp parallel for\r
                for(long i=0;i<idat->GetNN();i++)\r
                {\r
-                       mreal x=idat->vthr(i), y=jdat?jdat->vthr(i):0, z=kdat?kdat->vthr(i):0;\r
+                       mreal x=dx*idat->vthr(i), y=jdat?dy*jdat->vthr(i):0, z=kdat?dz*kdat->vthr(i):0;\r
                        r->a[i] = mgl_isnum(x*y*z)?dat->linear(x,y,z):NAN;;\r
                }\r
        return r;\r
index a719d851186beeee6d6d9410438a9979171e16a5..56eab8a4a4744f17143b54b1905701682737b5a8 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * data_new.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -48,7 +48,7 @@ HMDT MGL_EXPORT mgl_data_subdata_ext(HCDT d, HCDT xx, HCDT yy, HCDT zz)
                mglData tmp;    tmp.a[0]=-1;\r
                return mgl_data_subdata_ext(d,xx?xx:&tmp,yy?yy:&tmp,zz?zz:&tmp);\r
        }\r
-       \r
+\r
        long n=0,m=0,l=0,j,k;\r
        bool ix=false, iy=false, iz=false;\r
        if(xx->GetNz()>1)       // 3d data\r
@@ -286,9 +286,10 @@ HMDT MGL_EXPORT mgl_data_sum(HCDT dat, const char *dir)
        {\r
                mglStartThread(mgl_sum_x,0,p[1]*p[2],b,c,0,p);\r
                p[0] = p[1];    p[1] = p[2];    p[2] = 1;\r
+               memcpy(c,b,p[0]*p[1]*sizeof(mreal));\r
        }\r
        mglData *r=new mglData(p[0],p[1],p[2]);\r
-       memcpy(r->a,b,p[0]*p[1]*p[2]*sizeof(mreal));\r
+       memcpy(r->a,c,p[0]*p[1]*p[2]*sizeof(mreal));\r
        delete []b;     delete []c;     return r;\r
 }\r
 uintptr_t MGL_EXPORT mgl_data_sum_(uintptr_t *d, const char *dir,int l)\r
@@ -371,9 +372,10 @@ HMDT MGL_EXPORT mgl_data_max_dir(HCDT dat, const char *dir)
        {\r
                mglStartThread(mgl_max_x,0,p[1]*p[2],b,c,0,p);\r
                p[0] = p[1];    p[1] = p[2];    p[2] = 1;\r
+               memcpy(c,b,p[0]*p[1]*sizeof(mreal));\r
        }\r
        mglData *r=new mglData(p[0],p[1],p[2]);\r
-       memcpy(r->a,b,p[0]*p[1]*p[2]*sizeof(mreal));\r
+       memcpy(r->a,c,p[0]*p[1]*p[2]*sizeof(mreal));\r
        delete []b;     delete []c;     return r;\r
 }\r
 uintptr_t MGL_EXPORT mgl_data_max_dir_(uintptr_t *d, const char *dir,int l)\r
@@ -456,9 +458,10 @@ HMDT MGL_EXPORT mgl_data_min_dir(HCDT dat, const char *dir)
        {\r
                mglStartThread(mgl_min_x,0,p[1]*p[2],b,c,0,p);\r
                p[0] = p[1];    p[1] = p[2];    p[2] = 1;\r
+               memcpy(c,b,p[0]*p[1]*sizeof(mreal));\r
        }\r
        mglData *r=new mglData(p[0],p[1],p[2]);\r
-       memcpy(r->a,b,p[0]*p[1]*p[2]*sizeof(mreal));\r
+       memcpy(r->a,c,p[0]*p[1]*p[2]*sizeof(mreal));\r
        delete []b;     delete []c;     return r;\r
 }\r
 uintptr_t MGL_EXPORT mgl_data_min_dir_(uintptr_t *d, const char *dir,int l)\r
@@ -984,6 +987,6 @@ HMDT MGL_EXPORT mgl_data_pulse(HCDT dat, char dir)
        }\r
        delete []c;     return r;\r
 }\r
-uintptr_t MGL_EXPORT mgl_data_pulse_(uintptr_t *d, const char *dir,int l)\r
+uintptr_t MGL_EXPORT mgl_data_pulse_(uintptr_t *d, const char *dir,int)\r
 {      return uintptr_t(mgl_data_pulse(_DT_,dir[0]));  }\r
 //-----------------------------------------------------------------------------\r
index d8fbda8d4aacd445b50b515116b56bfe6b020ce5..4fbc2f422d82240f87ea6ffb8790108ee35a3392 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * data_gr.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
index 5834e72660286e73df1397e754da5d2371a004de..b109d300b19c7554a8e7e13ab39d801f1ec98ae8 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * data_io.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -421,13 +421,15 @@ int MGL_EXPORT mgl_data_scan_file(HMDT d,const char *fname, const char *templ)
                return  false;\r
        }\r
        s = mgl_read_gz(fp);    gzclose(fp);\r
-       if(*s)  bufs.push_back(s);\r
+       size_t len = strs[0].length();\r
+       const char *s0 = strs[0].c_str();\r
+       if(!strncmp(s, s0, len))        bufs.push_back(s);\r
        for(long i=0;s[i];i++)  if(s[i]=='\n')\r
        {\r
                while(s[i+1]=='\n')     i++;\r
                s[i]=0; i++;\r
-               if(s[i])        bufs.push_back(s+i);\r
-               else    break;\r
+               if(!strncmp(s+i, s0, len))      bufs.push_back(s+i);\r
+               if(!s[i])       break;\r
        }\r
        // parse lines and collect data\r
        size_t nx=strs.size(), ny=bufs.size();\r
@@ -766,7 +768,7 @@ void MGL_EXPORT mgl_data_fill(HMDT d, mreal x1,mreal x2,char dir)
 void MGL_EXPORT mgl_data_fill_(uintptr_t *d, mreal *x1,mreal *x2,const char *dir,int)\r
 {      mgl_data_fill(_DT_,*x1,*x2,*dir);       }\r
 //-----------------------------------------------------------------------------\r
-void MGL_EXPORT mgl_data_norm(HMDT d, mreal v1,mreal v2,long sym,long dim)\r
+void MGL_EXPORT mgl_data_norm(HMDT d, mreal v1,mreal v2,int sym,long dim)\r
 {\r
        long s,nn=d->nx*d->ny*d->nz;\r
        mreal a1=INFINITY,a2=-INFINITY,v,*a=d->a;\r
@@ -1254,3 +1256,14 @@ uintptr_t MGL_EXPORT mgl_data_column_(uintptr_t *d, const char *eq,int l)
        uintptr_t r = uintptr_t(mgl_data_column(_DT_,s));\r
        delete []s;     return r;       }\r
 //-----------------------------------------------------------------------------\r
+void MGL_EXPORT mgl_data_limit(HMDT d, mreal v)\r
+{\r
+       long n = d->GetNN();\r
+       mreal *a = d->a;\r
+       #pragma omp parallel for\r
+       for(long i=0;i<n;i++)\r
+       {       mreal b = fabs(a[i]);   if(b>v) a[i] *= v/b;    }\r
+}\r
+void MGL_EXPORT mgl_data_limit_(uintptr_t *d, mreal *v)\r
+{      mgl_data_limit(_DT_, *v);       }\r
+//-----------------------------------------------------------------------------\r
index d6a15be64cc24085f0404d88b4eeec9eaebb1b3d..b4a8bb39f4f51c3ccdc8daa2f4550dd637de43dd 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * data_png.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index e0d611c4eeefae60399b46250bdd5bbb79108d14..a4cb5430323cbe63bc0a50950e9a0fa192bf2b6c 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * eval.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 6be9232c500f570d89c9f66c905ea15aad7d1bd7..e703e06057fd943338c07281b7268d5dd9368c06 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * evalc.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -61,6 +61,9 @@ EQ_LG,                // decimal logarithm of x, lg(x) = ln(x)/ln(10)
 EQ_ABS,                // absolute value\r
 EQ_ARG,                // argument (or phase) of complex number\r
 EQ_CONJ,       // complex conjugate\r
+EQ_REAL,       // real part\r
+EQ_IMAG,       // imaginary part\r
+EQ_NORM,       // square of absolute value |u|^2\r
 EQ_LAST                // id of last entry\r
 };\r
 //-----------------------------------------------------------------------------\r
@@ -173,6 +176,9 @@ mglFormulaC::mglFormulaC(const char *string)
                else if(!strcmp(name,"abs")) Kod=EQ_ABS;\r
                else if(!strcmp(name,"arg")) Kod=EQ_ARG;\r
                else if(!strcmp(name,"conj")) Kod=EQ_CONJ;\r
+               else if(!strcmp(name,"real")) Kod=EQ_REAL;\r
+               else if(!strcmp(name,"imag")) Kod=EQ_IMAG;\r
+               else if(!strcmp(name,"norm")) Kod=EQ_NORM;\r
                else {  delete []str;   return; }       // unknown function\r
                n=mglFindInText(str,",");\r
                if(n>=0)\r
@@ -255,12 +261,15 @@ dual MGL_LOCAL_CONST logc(dual x) {       return log(x);  }
 dual MGL_LOCAL_CONST absc(dual x)      {       return abs(x);  }\r
 dual MGL_LOCAL_CONST argc(dual x)      {       return arg(x);  }\r
 dual MGL_LOCAL_CONST lgc(dual x)       {       return log10(x);}\r
+dual MGL_LOCAL_CONST realc(dual x)     {       return real(x); }\r
+dual MGL_LOCAL_CONST imagc(dual x)     {       return imag(x); }\r
+dual MGL_LOCAL_CONST normc(dual x)     {       return norm(x); }\r
 //-----------------------------------------------------------------------------\r
 typedef dual (*func_1)(dual);\r
 typedef dual (*func_2)(dual, dual);\r
 static const func_2 f2[EQ_SIN-EQ_LT] = {cltc,cgtc,ceqc,addc,subc,mulc,divc,ipwc,powc,llgc};\r
 static const func_1 f1[EQ_LAST-EQ_SIN] = {sinc,cosc,tanc,asinc,acosc,atanc,sinhc,coshc,tanhc,\r
-                                       asinhc,acoshc,atanhc,sqrtc,expc,expi,logc,lgc,absc,argc,conjc};\r
+                                       asinhc,acoshc,atanhc,sqrtc,expc,expi,logc,lgc,absc,argc,conjc,realc,imagc,normc};\r
 // evaluation of embedded (included) expressions\r
 dual mglFormulaC::CalcIn(const dual *a1) const\r
 {\r
index bfaed555f200bf34eba90dab9ca20826b1f9fbc6..df9fb00342c3996536f70ddd952ce9cc5e7f3712 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * evalp.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
@@ -143,13 +143,16 @@ HMDT mglApplyOperDiv(std::wstring a1, std::wstring a2, mglParser *arg, const std
        mreal va=a->a[0], vb=b->a[0], *aa=a->a, *bb=b->a, *cc=r->a;
        if(na==nb)
 #pragma omp parallel for
-               for(long i=0;i<nn;i++)  cc[i] = aa[i]/bb[i];
+               for(long i=0;i<nn;i++)  cc[i] = bb[i]!=0?aa[i]/bb[i]:NAN;
        else if(na==1)
 #pragma omp parallel for
-               for(long i=0;i<nn;i++)  cc[i] = va/bb[i];
-       else
+               for(long i=0;i<nn;i++)  cc[i] = bb[i]!=0?va/bb[i]:NAN;
+       else if(vb!=0)
 #pragma omp parallel for
                for(long i=0;i<nn;i++)  cc[i] = aa[i]/vb;
+       else
+#pragma omp parallel for
+               for(long i=0;i<nn;i++)  cc[i] = NAN;
        mgl_delete_data(d);     return r;
 }
 //-----------------------------------------------------------------------------
@@ -241,13 +244,16 @@ HADT mglApplyOperDivC(std::wstring a1, std::wstring a2, mglParser *arg, const st
        dual va=a->a[0], vb=b->a[0], *aa=a->a, *bb=b->a, *cc=r->a;
        if(na==nb)
 #pragma omp parallel for
-               for(long i=0;i<nn;i++)  cc[i] = aa[i]/bb[i];
+               for(long i=0;i<nn;i++)  cc[i] = bb[i]!=mreal(0)?aa[i]/bb[i]:NAN;
        else if(na==1)
 #pragma omp parallel for
-               for(long i=0;i<nn;i++)  cc[i] = va/bb[i];
-       else
+               for(long i=0;i<nn;i++)  cc[i] = bb[i]!=mreal(0)?va/bb[i]:NAN;
+       else if(vb!=mreal(0))
 #pragma omp parallel for
                for(long i=0;i<nn;i++)  cc[i] = aa[i]/vb;
+       else
+#pragma omp parallel for
+               for(long i=0;i<nn;i++)  cc[i] = NAN;
        mgl_delete_datac(d);    return r;
 }
 //-----------------------------------------------------------------------------
@@ -488,7 +494,7 @@ HMDT MGL_NO_EXPORT mglFormulaCalc(std::wstring str, mglParser *arg, const std::v
                else
                {
                        HMDT res = new mglData;
-                       char ch = str[0];
+                       wchar_t ch = str[0];
                        if(ch<':') res->a[0] = wcstod(str.c_str(),0);   // this is number
                        else if(!str.compare(L"pi"))    res->a[0] = M_PI;
                        else if(ch==':')        res->a[0] = -1;
@@ -686,6 +692,12 @@ HMDT MGL_NO_EXPORT mglFormulaCalc(std::wstring str, mglParser *arg, const std::v
                        HMDT res = mgl_datac_imag(a1);
                        mgl_delete_datac(a1);   return res;
                }
+               else if(!nm.compare(L"norm"))
+               {
+                       HADT a1 = mglFormulaCalcC(str, arg, head);
+                       HMDT res = mgl_datac_norm(a1);
+                       mgl_delete_datac(a1);   return res;
+               }
 #if MGL_HAVE_GSL
                else if(!nm.compare(L"i") && n>0)
                        return mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, gsl_sf_bessel_Inu);
@@ -739,9 +751,10 @@ dual MGL_LOCAL_CONST sqrtc(dual x);        //{     return sqrt(x); }
 dual MGL_LOCAL_CONST logc(dual x);     //{     return log(x);  }
 dual MGL_LOCAL_CONST absc(dual x);     //{     return abs(x);  }
 dual MGL_LOCAL_CONST argc(dual x);     //{     return arg(x);  }
-dual MGL_LOCAL_CONST lgc(dual x);              //{     return log10(x);}
-dual MGL_LOCAL_CONST realc(dual x)     {       return real(x); }
-dual MGL_LOCAL_CONST imagc(dual x)     {       return dual(0,imag(x)); }
+dual MGL_LOCAL_CONST lgc(dual x);      //{     return log10(x);}
+dual MGL_LOCAL_CONST realc(dual x);    //{     return real(x); }
+dual MGL_LOCAL_CONST imagc(dual x);    //{     return imag(x); }
+dual MGL_LOCAL_CONST normc(dual x);    //{     return norm(x); }
 //-----------------------------------------------------------------------------
 /// Parse string and substitute the script argument
 // All numbers are presented as mglData(1). Do boundary checking.
@@ -907,7 +920,7 @@ HADT MGL_NO_EXPORT mglFormulaCalcC(std::wstring str, mglParser *arg, const std::
                else
                {
                        HADT res = new mglDataC;
-                       char ch = str[0];
+                       wchar_t ch = str[0];
                        if(ch<':')      // this is real number
                                res->a[0] = (str[str.length()-1]=='i') ? dual(0,wcstod(str.c_str(),0)) :  mreal(wcstod(str.c_str(),0));
                        else if(ch=='i')        // this is imaginary number
@@ -970,7 +983,7 @@ HADT MGL_NO_EXPORT mglFormulaCalcC(std::wstring str, mglParser *arg, const std::
                        else if(!nm.compare(L"acosh"))  return mglApplyFuncC(str, arg, head, acoshc);
                        else if(!nm.compare(L"atanh"))  return mglApplyFuncC(str, arg, head, atanhc);
                        else if(!nm.compare(L"arg"))    return mglApplyFuncC(str, arg, head, argc);
-                       else if(!nm.compare(L"abs"))            return mglApplyFuncC(str, arg, head, absc);
+                       else if(!nm.compare(L"abs"))    return mglApplyFuncC(str, arg, head, absc);
                }
                else if(nm[0]=='c')
                {
@@ -1002,6 +1015,7 @@ HADT MGL_NO_EXPORT mglFormulaCalcC(std::wstring str, mglParser *arg, const std::
                        for(long i=0;i<res->GetNN();i++)        a[i] = dual(mgl_rnd(), mgl_rnd());      return res;     }
                else if(!nm.compare(L"real"))   return mglApplyFuncC(str, arg, head, realc);
                else if(!nm.compare(L"imag"))   return mglApplyFuncC(str, arg, head, imagc);
+               else if(!nm.compare(L"norm"))   return mglApplyFuncC(str, arg, head, normc);
        }
        HADT res = new mglDataC;        res->a[0]=NAN;  return res;
 }
index daa56a194246926a3c25f84363d8ccee1c59da2a..c561826c041db8d1ba3524f0330b457fc77e3b63 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * exec.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
@@ -66,6 +66,14 @@ int MGL_NO_EXPORT mgls_alpha(mglGraph *gr, long , mglArg *a, const char *k, cons
        else res = 1;   return res;
 }
 //-----------------------------------------------------------------------------
+int MGL_NO_EXPORT mgls_gray(mglGraph *gr, long , mglArg *a, const char *k, const char *)
+{
+       int res=0;
+       if(k[0]==0)     gr->Gray(true);
+       else if(!strcmp(k,"n")) gr->Gray(a[0].v!=0);
+       else res = 1;   return res;
+}
+//-----------------------------------------------------------------------------
 int MGL_NO_EXPORT mgls_pendelta(mglGraph *gr, long , mglArg *a, const char *k, const char *)
 {
        int res=0;
@@ -130,6 +138,13 @@ int MGL_NO_EXPORT mgls_aspect(mglGraph *gr, long , mglArg *a, const char *k, con
        else res = 1;   return res;
 }
 //-----------------------------------------------------------------------------
+int MGL_NO_EXPORT mgls_shear(mglGraph *gr, long , mglArg *a, const char *k, const char *)
+{
+       int res=0;
+       if(!strcmp(k,"nn"))     gr->Shear(a[0].v, a[1].v);
+       else res = 1;   return res;
+}
+//-----------------------------------------------------------------------------
 int MGL_NO_EXPORT mgls_axial(mglGraph *gr, long , mglArg *a, const char *k, const char *opt)
 {
        int res=0;
@@ -982,7 +997,7 @@ int MGL_NO_EXPORT mgls_refill(mglGraph *gr, long , mglArg *a, const char *k, con
        else res = 1;   return res;
 }
 //-----------------------------------------------------------------------------
-int MGL_NO_EXPORT mgls_gspline(mglGraph *gr, long , mglArg *a, const char *k, const char *opt)
+int MGL_NO_EXPORT mgls_gspline(mglGraph *gr, long , mglArg *a, const char *k, const char *)
 {
        int res=0;
        if(k[0]=='d' && a[0].d->temp)   return 5;
@@ -1645,6 +1660,13 @@ int MGL_NO_EXPORT mgls_setsize(mglGraph *gr, long , mglArg *a, const char *k, co
        else res = 1;   return res;
 }
 //-----------------------------------------------------------------------------
+int MGL_NO_EXPORT mgls_setsizescl(mglGraph *gr, long , mglArg *a, const char *k, const char *)
+{
+       int res=0;
+       if(!strcmp(k,"n"))      gr->SetSizeScl(a[0].v);
+       else res = 1;   return res;
+}
+//-----------------------------------------------------------------------------
 int MGL_NO_EXPORT mgls_sphere(mglGraph *gr, long , mglArg *a, const char *k, const char *opt)
 {
        int res=0;      gr->Self()->SaveState(opt);
@@ -2325,7 +2347,7 @@ int MGL_NO_EXPORT mgls_info(mglGraph *gr, long , mglArg *a, const char *k, const
        else res = 1;   return res;
 }
 //-----------------------------------------------------------------------------
-int MGL_NO_EXPORT mgls_print(mglGraph *gr, long , mglArg *a, const char *k, const char *)
+int MGL_NO_EXPORT mgls_print(mglGraph *, long , mglArg *a, const char *k, const char *)
 {
        int res=0;
        if(!strcmp(k,"d"))      printf("%s\n",a[0].d->PrintInfo());
@@ -2383,6 +2405,14 @@ int MGL_NO_EXPORT mgls_stickplot(mglGraph *gr, long , mglArg *a, const char *k,
        else res = 1;   return res;
 }
 //-----------------------------------------------------------------------------
+int MGL_NO_EXPORT mgls_shearplot(mglGraph *gr, long , mglArg *a, const char *k, const char *)
+{
+       int res=0;
+       if(!strcmp(k,"nnnn"))   gr->ShearPlot(mgl_int(a[0].v), mgl_int(a[1].v), a[2].v, a[3].v);
+       else if(!strcmp(k,"nnnnnn"))    gr->ShearPlot(mgl_int(a[0].v), mgl_int(a[1].v), a[2].v, a[3].v, a[4].v, a[5].v);
+       else res = 1;   return res;
+}
+//-----------------------------------------------------------------------------
 int MGL_NO_EXPORT mgls_pipe(mglGraph *gr, long , mglArg *a, const char *k, const char *opt)
 {
        int res=0;
@@ -2430,6 +2460,17 @@ int MGL_NO_EXPORT mgls_norm(mglGraph *, long , mglArg *a, const char *k, const c
        else res = 1;   return res;
 }
 //-----------------------------------------------------------------------------
+int MGL_NO_EXPORT mgls_limit(mglGraph *, long , mglArg *a, const char *k, const char *)
+{
+       int res=0;
+       if(k[0]=='d' && a[0].d->temp)   return 5;
+       mglData *d = dynamic_cast<mglData *>(a[0].d);
+       mglDataC *c = dynamic_cast<mglDataC *>(a[0].d);
+       if(d && !strcmp(k,"dn"))                d->Limit(a[1].v);
+       else if(c && !strcmp(k,"dn"))   c->Limit(a[1].v);
+       else res = 1;   return res;
+}
+//-----------------------------------------------------------------------------
 int MGL_NO_EXPORT mgls_hist(mglGraph *gr, long , mglArg *a, const char *k, const char *opt)
 {
        int res=0;
@@ -2752,7 +2793,7 @@ int MGL_NO_EXPORT mgls_fsurf(mglGraph *gr, long , mglArg *a, const char *k, cons
 int MGL_NO_EXPORT mgls_fgets(mglGraph *gr, long , mglArg *a, const char *k, const char *opt)
 {
        int res=0;      gr->Self()->SaveState(opt);
-       char buf[4096];
+       char *buf;      buf = new char[4096];
        FILE *fp;
        if(!strncmp(k,"nns",3))
        {
@@ -2761,7 +2802,7 @@ int MGL_NO_EXPORT mgls_fgets(mglGraph *gr, long , mglArg *a, const char *k, cons
                if(!fp)
                {
                        gr->SetWarn(mglWarnOpen,a[2].s.c_str());
-                       return res;
+                       delete []buf;   return res;
 }
                for(i=0;i<n;i++)        if(!fgets(buf,4096,fp)) continue;
                memset(buf,0,4096);
@@ -2769,7 +2810,7 @@ int MGL_NO_EXPORT mgls_fgets(mglGraph *gr, long , mglArg *a, const char *k, cons
                {
                        char b[32];     snprintf(b,32,"%d",n);  b[31]=0;
                        gr->SetWarn(mglWarnOpen,(a[2].s+" - line "+b).c_str());
-                       fclose(fp);     return res;
+                       fclose(fp);     delete []buf;   return res;
                }
                fclose(fp);
                gr->Puts(mglPoint(a[0].v,a[1].v,NAN),buf, (k[4]=='s')?a[4].s.c_str():"", k[5]=='n'?a[5].v:-1);
@@ -2781,7 +2822,7 @@ int MGL_NO_EXPORT mgls_fgets(mglGraph *gr, long , mglArg *a, const char *k, cons
                if(!fp)
                {
                        gr->SetWarn(mglWarnOpen,a[3].s.c_str());
-                       return res;
+                       delete []buf;   return res;
                }
                for(i=0;i<n;i++)        if(!fgets(buf,4096,fp)) continue;
                memset(buf,0,4096);
@@ -2789,15 +2830,15 @@ int MGL_NO_EXPORT mgls_fgets(mglGraph *gr, long , mglArg *a, const char *k, cons
                {
                        char b[32];     snprintf(b,32,"%d",n);  b[31]=0;
                        gr->SetWarn(mglWarnOpen,(a[3].s+" - line "+b).c_str());
-                       fclose(fp);     return res;
+                       fclose(fp);     delete []buf;   return res;
                }
                fclose(fp);
                gr->Puts(mglPoint(a[0].v,a[1].v,a[2].v),buf, (k[5]=='s')?a[5].s.c_str():"", k[6]=='n'?a[6].v:-1);
        }
-       else res = 1;   gr->Self()->LoadState();        return res;
+       else res = 1;   gr->Self()->LoadState();        delete []buf;   return res;
 }
 //-----------------------------------------------------------------------------
-int MGL_NO_EXPORT mgls_scanfile(mglGraph *gr, long , mglArg *a, const char *k, const char *)
+int MGL_NO_EXPORT mgls_scanfile(mglGraph *, long , mglArg *a, const char *k, const char *)
 {
        int res=0;
        if(!strcmp(k,"dss"))
@@ -3003,6 +3044,26 @@ int MGL_NO_EXPORT mgls_ode(mglGraph *, long , mglArg *a, const char *k, const ch
        else res = 1;   return res;
 }
 //-----------------------------------------------------------------------------
+int MGL_NO_EXPORT mgls_tridmat(mglGraph *gr, long , mglArg *a, const char *k, const char *opt)
+{
+       int res=0;
+       mglData *d = dynamic_cast<mglData *>(a[0].d);
+       mglDataC *c = dynamic_cast<mglDataC *>(a[0].d);
+       if(c && !strcmp(k,"ddddds"))
+               *c = mglTridMatC(*(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), a[5].s.c_str());
+       else if(d && !strcmp(k,"ddddds"))
+               *d = mglTridMat(*(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), a[5].s.c_str());
+       else res = 1;   return res;
+}
+//-----------------------------------------------------------------------------
+int MGL_NO_EXPORT mgls_diffract(mglGraph *gr, long , mglArg *a, const char *k, const char *opt)
+{
+       int res=0;
+       mglDataC *c = dynamic_cast<mglDataC *>(a[0].d);
+       if(c && !strcmp(k,"dsn"))       c->Diffraction(a[1].s.c_str(), a[2].v);
+       else res = 1;   return res;
+}
+//-----------------------------------------------------------------------------
 int MGL_NO_EXPORT mgls_pde(mglGraph *gr, long , mglArg *a, const char *k, const char *opt)
 {
        int res=0;
@@ -3380,6 +3441,27 @@ int MGL_NO_EXPORT mgls_version(mglGraph *gr, long , mglArg *a, const char *k, co
        else res = 1;   return res;
 }
 //-----------------------------------------------------------------------------
+int mgls_flame2d(mglGraph *, long, mglArg *a, const char *k, const char *)
+{
+       mglData *fx = dynamic_cast<mglData*>(a[0].d);
+       mglData *fy = dynamic_cast<mglData*>(a[1].d);
+       if(!fx) return 1;
+       int res = 0;
+       if (!strcmp(k, "dddn")) fx->Set(mglFlame2d(*(a[1].d), *(a[2].d), mgl_int(a[3].v)));
+       else if (!strcmp(k, "ddddn") && fy)
+       {
+               mglData f(mglFlame2d(*(a[2].d), *(a[3].d), mgl_int(a[4].v)));
+               fx->Set(f.SubData(0));  fy->Set(f.SubData(1));
+       }
+       else if (!strcmp(k, "dddnn"))   fx->Set(mglFlame2d(*(a[1].d), *(a[2].d), mgl_int(a[3].v), mgl_int(a[4].v)));
+       else if (!strcmp(k, "ddddnn") && fy)
+       {
+               mglData f(mglFlame2d(*(a[2].d), *(a[3].d), mgl_int(a[4].v), mgl_int(a[5].v)));
+               fx->Set(f.SubData(0));  fy->Set(f.SubData(1));
+       }
+       else res = 1;   return res;
+}
+//-----------------------------------------------------------------------------
 int mgls_ifs2d(mglGraph *, long, mglArg *a, const char *k, const char *)
 {
        mglData *fx = dynamic_cast<mglData*>(a[0].d);
@@ -3411,6 +3493,16 @@ int mgls_ifs3d(mglGraph *, long, mglArg *a, const char *k, const char *)
        else res = 1;   return res;
 }
 //-----------------------------------------------------------------------------
+int mgls_ifsfile(mglGraph *, long, mglArg *a, const char *k, const char *)
+{
+       mglData *f = dynamic_cast<mglData*>(a[0].d);
+       if(!f)  return 1;
+       int res = 0;
+       if (!strcmp(k, "dssn")) f->Set(mglIFSfile(a[1].s.c_str(), a[2].s.c_str(), mgl_int(a[3].v)));
+       else if (!strcmp(k, "dssnn"))   f->Set(mglIFSfile(a[1].s.c_str(), a[2].s.c_str(), mgl_int(a[3].v), mgl_int(a[4].v)));
+       else res = 1;   return res;
+}
+//-----------------------------------------------------------------------------
 mglCommand mgls_base_cmd[] = {
        {"addlegend","Add legend entry","addlegend 'txt' 'fmt'", mgls_addlegend,15},
        {"addto","Add data or number","addto Var Dat|Var num", mgls_addto ,3},
@@ -3433,7 +3525,7 @@ mglCommand mgls_base_cmd[] = {
        {"barh","Draw horizontal bars for 1D data", "barh Ydat ['fmt' above]|Xdat Ydat ['fmt' above]", mgls_barh ,7},
        {"bars","Draw bars for 1D data","bars Ydat ['fmt' above]|Xdat Ydat ['fmt' above]|Xdat Ydat Zdat ['fmt' above]", mgls_bars ,7},
        {"barwidth","Set default bars width","barwidth val", mgls_barwidth ,2},
-       {"beam","Draw quasioptical beam","beam Tr G1 G2 Adat r ['sch' flag num] ", mgls_beam ,9},
+       {"beam","Draw quasi-optical beam","beam Tr G1 G2 Adat r ['sch' flag num] ", mgls_beam ,9},
        {"belt","Draw belts","belt Zdat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_belt ,8},
        {"bifurcation","Draw Bifurcation diagram","bifurcation dx Func ['fmt']|dx 'func' ['fmt']", mgls_bifurcation,13},
        {"box","Draw bounding box","box ['fmt' ticks]", mgls_box ,12},
@@ -3446,7 +3538,7 @@ mglCommand mgls_base_cmd[] = {
        {"chdir","Change current directory","chdir 'path'", mgls_chdir ,2},
        {"circle","Draw circle","circle x y r ['fmt']|x y z r ['fmt']", mgls_circle ,13},
        {"clean","Remove duplicate rows","clean Dat id", mgls_clean ,3},
-       {"clearlegend","Clear legend antries","clearlegend", mgls_clearlegend ,15},
+       {"clearlegend","Clear legend entries","clearlegend", mgls_clearlegend ,15},
        {"clf","Clear picture","clf|'col'|r g b", mgls_clf ,12},
        {"cloud","Draw cloud","cloud Adat ['fmt']|Xdat Ydat Zdat Adat ['fmt']", mgls_cloud ,9},
        {"colorbar","Draw colorbar","colorbar ['fmt' pos]|Vdat ['fmt' pos]|'sch' pos x y [w h]|Vdat 'sch' pos x y [w h]", mgls_colorbar ,12},
@@ -3493,6 +3585,7 @@ mglCommand mgls_base_cmd[] = {
        {"dew","Draw dew plot","dew Udat Vdat ['fmt']|Xdat Ydat Udat Vdat ['fmt']", mgls_dew ,11},
        {"diff","Numerically differentiate data","diff Var 'dir'", mgls_diff ,16},
        {"diff2","Numerically double differentiate data","diff2 Var 'dir'", mgls_diff2 ,16},
+       {"diffract","Step for pulse diffraction","diffract Res 'how' q", mgls_diffract ,16},
        {"diffuse","Set diffusive light brightness","diffuse val", mgls_diffuse ,2},
        {"divto","Divide by data or number","divto Var Dat|Var num", mgls_divto ,3},
        {"dots","Draw dots for arbitrary data points","dots Xdat Ydat Zdat ['fmt']|Xdat Ydat Zdat Adat ['fmt']|Xdat Ydat Zdat Cdat Adat ['fmt']", mgls_dots ,9},
@@ -3520,6 +3613,7 @@ mglCommand mgls_base_cmd[] = {
        {"fillsample","Fill x-,k-samples for transforms","fillsample Var 'how'", mgls_fillsample ,3},
        {"fit","Fit data to formula","fit Res A 'eq' 'var' [Ini]|Res X A 'eq' 'var' [Ini]|Res X Y A 'eq' 'var' [Ini]|Res X Y Z A 'eq' 'var' [Ini]", mgls_fit ,4},
        {"fits","Fit data to formula","fits Res A S 'eq' 'var' [Ini]|Res X A S 'eq' 'var' [Ini]|Res X Y A S 'eq' 'var' [Ini]|Res X Y Z A S 'eq' 'var' [Ini]", mgls_fits ,4},
+       {"flame2d", "Computes the flame fractal", "flame2d F A B n [skip]|Fx Fy A B n [skip]", mgls_flame2d, 4},
        {"flow","Draw flow threads for vector field","flow Udat Vdat ['fmt' num]|Xdat Ydat Udat Vdat ['fmt' num]|Udat Vdat Wdat ['fmt' num]|Xdat Ydat Zdat Udat Vdat ['fmt' num]|\
        x0 y0 Udat Vdat ['fmt']|x0 y0 Xdat Ydat Udat Vdat ['fmt']|x0 y0 z0 Udat Vdat Wdat ['fmt']|x0 y0 z0 Xdat Ydat Zdat Udat Vdat Wdat ['fmt']", mgls_flow ,11},
        {"fog","Switch on/off fog","fog val [pos]", mgls_fog ,2},
@@ -3530,6 +3624,7 @@ mglCommand mgls_base_cmd[] = {
        {"fsurf","Plot surface by formula","fsurf 'z(x,y)' ['fmt']|'x(u,v)' 'y(u,v)' 'z(u,v)' ['fmt']", mgls_fsurf ,1},
        {"func","Start function definition and stop execution of main script","func 'name' [narg]", 0, 6},
        {"grad","Draw gradient lines for scalar field","grad Phi ['fmt' num]|Xdat Ydat Phi ['fmt' num]|Xdat Ydat Zdat Phi ['fmt' num]", mgls_grad ,8},
+       {"gray","Switch on/off gray-scale mode","gray [val]", mgls_gray ,2},
        {"grid","Draw grid","grid ['dir' 'fmt']", mgls_grid ,12},
        {"grid2","Draw grid for data array(s)","grid Zdat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_grid2 ,8},
        {"grid3","Draw grid at slices of 3D data","grid3 Adat 'dir' [pos 'fmt']|Xdat Ydat Zdat Adat 'dir' [pos 'fmt']", mgls_grid3 ,9},
@@ -3541,6 +3636,7 @@ mglCommand mgls_base_cmd[] = {
        {"if","Conditional operator","if val|Dat ['cond']", 0, 6},
        {"ifs2d", "Computes the attractor of an IFS", "ifs2d F A n [skip]|Fx Fy A n [skip]", mgls_ifs2d, 4},
        {"ifs3d", "Computes the attractor of an IFS for 3d case", "ifs3d F A n [skip]", mgls_ifs3d, 4},
+       {"ifsfile", "Computes the attractor of an IFS with parameters from *.ifs file", "ifsfile F 'fname' 'name' n [skip]", mgls_ifsfile, 4},
        {"import","Import data from PNG picture","import Dat 'fname' 'scheme' [v1 v2]", mgls_import ,4},
        {"info","Print message or information about the data","info Dat [detail]|'message'|const", mgls_info ,3},
        {"inplot","Set position of plot in picture","x1 x2 y1 y2 [rel]", mgls_inplot ,5},
@@ -3553,6 +3649,7 @@ mglCommand mgls_base_cmd[] = {
        {"legend","Draw legend","legend [pos 'fmt']|x y ['fmt']", mgls_legend ,15},
        {"legendmarks","Set number of marks in the legend","legendmarks val", mgls_legendmarks ,15},
        {"light","Setup light","light [val] | val num | num xpos ypos zpos ['fmt' br]", mgls_light ,2},
+       {"limit","Limit data to be inside [-v,v]","limit Dat v", mgls_limit ,16},
        {"line","Draw line","line x1 y1 x2 y2 ['fmt']|x1 y1 z1 x2 y2 z2 ['fmt']", mgls_line ,13},
        {"list","Creates new variable from list of numbers or data","list Var v1 ...|Var D1 ...", 0, 4},
        {"load","Load commands from external DLL","load 'fname'", 0, 6},
@@ -3599,7 +3696,7 @@ mglCommand mgls_base_cmd[] = {
        {"quality","Set plot quality","quality [val]", mgls_quality ,2},
        {"radar","Draw radar chart","radar Rdat ['fmt']", mgls_radar ,7},
        {"ranges","Set axis ranges","ranges x1 x2 y1 y2 [z1 z2]", mgls_ranges ,14},
-       {"rasterize","Rasterize and save to background","rasterize", mgls_rasterize ,12},
+       {"rasterize","Rasterize plot and save to background","rasterize", mgls_rasterize ,12},
        {"ray","Solve Hamiltonian ODE (find GO ray or trajectory)","ray Res 'ham' x0 y0 z0 px0 py0 pz0 [dz=0.1 tmax=10]", mgls_ray ,4},
        {"read","Read data from file","read Dat 'file' [nx ny nz] | ReDat ImDat 'file' [nx ny nz]", mgls_read ,4},
        {"readall","Read and join data from several files","readall Dat 'templ' [slice]", mgls_readall ,4},
@@ -3619,10 +3716,13 @@ mglCommand mgls_base_cmd[] = {
        {"rotate","Rotate plot","rotate tetz tetx [tety] | tet x y z", mgls_rotate ,5},
        {"rotatetext","Set to auto rotate text or not","rotatetext val", mgls_rotatetext ,15},
        {"save","Save data to file","save Dat 'file'|'str' 'file'|'str' 'file' 'how'", mgls_save ,3},
-       {"savehdf","Save data to HDF5 file","savehdf Dat 'file' 'id'", mgls_savehdf ,3},
-       {"scanfile","Get fromated data from file","scanfile Dat 'fname 'templ'", mgls_scanfile ,4},
+       {"savehdf","Save data to HDF5 file","savehdf Dat 'file' 'id' [rewrite]", mgls_savehdf ,3},
+       {"scanfile","Get formated data from file","scanfile Dat 'fname 'templ'", mgls_scanfile ,4},
        {"setsize","Set picture size","setsize width height", mgls_setsize ,2},
+       {"setsizescl","Set scaling factor for further setsize","setsizescl val", mgls_setsizescl ,2},
        {"sew","Remove jump into the data, like phase jumps","sew Dat ['dir' da]", mgls_sew ,16},
+       {"shear","Shear plot","shear valx valy", mgls_shear ,5},
+       {"shearplot","Set position of plot inside cell of sheared stick", "shearplot num ind sx sy [xd yd]", mgls_shearplot ,5},
        {"sinfft","Sin-Fourier transform at some direction","sinfft Dat 'dir'", mgls_sinfft ,16},
        {"smooth","Smooth data","smooth Dat [kind 'dir']", mgls_smooth ,16},
        {"solve","Find root Dat_{i,j,k}=val (inverse evaluate)","solve Res Dat val 'dir' [Idat norm]", mgls_solve ,4},
@@ -3633,7 +3733,7 @@ mglCommand mgls_base_cmd[] = {
        {"step","Draw step plot for 1D data","step Ydat ['fmt']|Xdat Ydat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_step ,7},
        {"stfa","Draw STFA diagram","stfa Udat Vdat dn ['fmt']|Xdat Ydat Udat Vdat dn ['fmt']", mgls_stfa ,10},
        {"stfad","Do STFA transform","stfad Res Real Imag dn ['dir']", mgls_stfad ,4},
-       {"stickplot","Set position of plot inside cell of stick", "stickplot num ind tet phi", mgls_stickplot ,5},
+       {"stickplot","Set position of plot inside cell of rotated stick", "stickplot num ind tet phi", mgls_stickplot ,5},
        {"stop","Stop execution","stop", 0, 6},
        {"subdata","Extract sub-array","subdata Res Dat nx [ny nz]", mgls_subdata ,4},
        {"subplot","Set position of plot","subplot m n pos ['style' dx dy]", mgls_subplot ,5},
@@ -3671,10 +3771,12 @@ mglCommand mgls_base_cmd[] = {
        {"triangulate","Find triangles of randomly placed points","triangulate Res Xdat Ydat [er]|Res Xdat Ydat Zdat [er]", mgls_triangulate ,4},
        {"tricont","Draw contour lines for surface of triangles","tricont Idat Xdat Ydat Cdat ['fmt']|Idat Xdat Ydat Zdat Cdat ['fmt']|Vdat Idat Xdat Ydat Cdat ['fmt']|Vdat Idat Xdat Ydat Zdat Cdat ['fmt']", mgls_tricont ,0},
        {"tricontv","Draw contour tubes for surface of triangles","tricontv Idat Xdat Ydat Cdat ['fmt']|Idat Xdat Ydat Zdat Cdat ['fmt']|Vdat Idat Xdat Ydat Cdat ['fmt']|Vdat Idat Xdat Ydat Zdat Cdat ['fmt']", mgls_tricontv ,0},
+       {"tridmat","Solve tridiagonal matrix","tridmat Res A B C D 'how'", mgls_tridmat ,4},
        {"triplot","Draw surface of triangles","triplot Idat Xdat Ydat ['fmt']|Idat Xdat Ydat Zdat ['fmt']|Idat Xdat Ydat Zdat Cdat ['fmt'] ", mgls_triplot ,0},
        {"tube","Draw curve by tube","tube Ydat Rdat ['fmt']|Ydat rval ['fmt']|Xdat Ydat Rdat ['fmt']|Xdat Ydat rval ['fmt']|Xdat Ydat Zdat Rdat ['fmt']|Xdat Ydat Zdat rval ['fmt']", mgls_tube ,7},
        {"tuneticks","Set ticks tuning","tuneticks val [fctr]", mgls_tuneticks ,14},
        {"var","Create new 1D data and fill it in range","var Dat nx x1 [x2]", mgls_var ,4},
+       {"variant","Select variant of plot style(s)","variant var", 0, 6},
        {"vect","Draw vector field","vect Udat Vdat ['fmt']|Xdat Ydat Udat Vdat ['fmt']|Udat Vdat Wdat ['fmt']|Xdat Ydat Zdat Udat Vdat Wdat ['fmt']", mgls_vect ,11},
        {"vect3","Draw vector field at slices of 3D data","vect Udat Vdat Wdat ['fmt' sval]|Xdat Ydat Zdat Udat Vdat Wdat ['fmt' sval]", mgls_vect3 ,11},
        {"version","Print MathGL version or check if it is valid","version |'ver'", mgls_version, 2},
index eac9c49e4f83cedbfc3b35d9ddd20a46a1afdd71..9125501b519281e4de3683a0b257ec57ba81a135 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * export.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
index b8013f4c9373fbf52c70476a4f065cbadf5f400d..ce368a3c7f63c076b63f24df03fcf533664f38bc 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * export_2d.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
@@ -22,8 +22,6 @@
 #include "mgl2/font.h"
 #include <time.h>
 #include <algorithm>
-#include <vector>
-#include <string>
 #include <sys/stat.h>
 #undef _GR_
 #define _GR_   ((mglCanvas *)(*gr))
@@ -321,7 +319,7 @@ void MGL_EXPORT mgl_write_eps(HMGL gr, const char *fname,const char *descr)
                                case 'P':       mgl_printf(fp, gz, "np %g %g mt m_P %sdr\n",x0,y0,str); break;
                                case 'X':       mgl_printf(fp, gz, "np %g %g mt m_X %sdr\n",x0,y0,str); break;
                                case 'C':       mgl_printf(fp, gz, "%g %g m_o %g %g m_c %sdr\n",x0,y0,x0,y0,str);       break;
-                               default:        mgl_printf(fp, gz, "%g %g m_c %sfill\n",x0,y0,str);
+                               case '.':       mgl_printf(fp, gz, "%g %g m_c %sfill\n",x0,y0,str);
                        }
                }
                else if(q.type==3)      // quad
@@ -499,7 +497,7 @@ void MGL_EXPORT mgl_write_svg(HMGL gr, const char *fname,const char *descr)
                        case '*':
                                mgl_printf(fp, gz, "<path d=\"M %g %g L %g %g M %g %g L %g %g M %g %g L %g %g\"/>\n",
                                                        x-s,y,x+s,y,x-0.6*s,y-0.8*s,x+0.6*s,y+0.8*s,x+0.6*s,y-0.8*s,x-0.6*s,y+0.8*s);   break;
-                       default:
+                       case '.':
                                mgl_printf(fp, gz, "<circle style=\"fill:#%02x%02x%02x\" cx=\"%g\" cy=\"%g\" r=\"0.15\"/>\n",
                                                        int(cp.r[0]),int(cp.r[1]),int(cp.r[2]),x,y);    break;
                        }
index 9ba30f2e40a2eaa303b27696f484095e6674c085..e9cdf3d85ffb23ad676b953f219cb64581ad88da 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * export_3d.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index f100f573f30e81fc05055513fc6511282dc675e9..e05ec0e2b9a67e07569b83f34c272ee03c25fe1c 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * fft.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
index 56cf1d6bbc5c261e53dc6649eb4889dd724cbc1c..3cb6630ade5fd425c6635cc38a609fdb116aae94 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * fit.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 1fd685c3af7b37696d7cd751c9062c4b99f0aa70..de68ad617d7223f2960db42feee1d01f89402925 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * font.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -30,9 +30,8 @@
 #include "mgl2/base.h"\r
 #include "mgl2/font.h"\r
 #include "def_font.cc"\r
+#include "tex_table.cc"\r
 //-----------------------------------------------------------------------------\r
-extern mglTeXsymb mgl_tex_symb[];\r
-extern long mgl_tex_num;\r
 //mglFont mglDefFont("nofont");\r
 mglFont mglDefFont;\r
 //-----------------------------------------------------------------------------\r
@@ -918,3 +917,18 @@ void mglFont::Copy(mglFont *f)
        memcpy(&glyphs[0],&(f->glyphs)[0],glyphs.size()*sizeof(mglGlyphDescr));\r
 }\r
 //-----------------------------------------------------------------------------\r
+long MGL_EXPORT mgl_check_tex_table()\r
+{\r
+       size_t i=0;     while(mgl_tex_symb[i].tex[0])   i++;\r
+       long res = 0;\r
+       if(mgl_tex_num!=i)\r
+       {       printf("real=%zu, set=%zu\n",i,mgl_tex_num);    res = -1;       }\r
+       for(i=0;mgl_tex_symb[i].tex[0];i++)\r
+       {\r
+               mglTeXsymb tst, *rts;   tst.tex = mgl_tex_symb[i].tex;\r
+               rts = (mglTeXsymb *) bsearch(&tst, mgl_tex_symb, mgl_tex_num, sizeof(mglTeXsymb), mgl_tex_symb_cmp);\r
+               if(!rts)\r
+               {       printf("Bad '%ls' at %zu\n",mgl_tex_symb[i].tex,i);     res = 1+i;      }\r
+       }\r
+       return res;\r
+}
\ No newline at end of file
diff --git a/src/fractal.cpp b/src/fractal.cpp
new file mode 100644 (file)
index 0000000..4be00b8
--- /dev/null
@@ -0,0 +1,463 @@
+/***************************************************************************
+*pixel.cpp is part of Math Graphic Library
+*Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+*                                                                        *
+*  This program is free software; you can redistribute it and/or modify  *
+*  it under the terms of the GNU Library General Public License as       *
+*  published by the Free Software Foundation; either version 3 of the    *
+*  License, or (at your option) any later version.                       *
+*                                                                        *
+*  This program is distributed in the hope that it will be useful,       *
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*  GNU General Public License for more details.                          *
+*                                                                        *
+*  You should have received a copy of the GNU Library 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.             *
+ ***************************************************************************/
+#include "mgl2/other.h"
+#include "mgl2/data.h"
+MGL_NO_EXPORT char *mgl_read_gz(gzFile fp);
+//-----------------------------------------------------------------------------
+//
+//     IFS series
+//
+//-----------------------------------------------------------------------------
+void MGL_NO_EXPORT mgl_ifs_2d_point(HCDT A, mreal& x, mreal& y, mreal amax)
+{
+       long i, n=A->GetNy();
+       mreal r = amax*mgl_rnd(), sum_prob = 0, x1;
+       for(i=0;i<n;i++)
+       {
+               sum_prob += A->v(6,i);
+               if(r<sum_prob)  break;
+       }
+       x1= A->v(0,i)*x + A->v(1,i)*y + A->v(4,i);
+       y = A->v(2,i)*x + A->v(3,i)*y + A->v(5,i);      x = x1;
+}
+HMDT MGL_EXPORT mgl_data_ifs_2d(HCDT A, long n, long skip)
+{
+       if(!A || A->GetNx()<7 || n<1)   return 0;       // incompatible dimensions
+       mreal amax=0;
+       for(long i=0; i<A->GetNy(); i++)        amax += A->v(6,i);
+       if(amax<=0)     return 0;
+       
+       mglData *f = new mglData(2,n);
+       mreal x = 0, y = 0;
+       for(long i=0; i<skip; i++)      mgl_ifs_2d_point(A, x, y,amax);
+       for(long i=0; i<n; i++)
+       {
+               mgl_ifs_2d_point(A, x, y, amax);
+               f->a[2*i] = x;  f->a[2*i+1] = y;
+       }
+       return f;
+}
+uintptr_t MGL_EXPORT mgl_data_ifs_2d_(uintptr_t *d, long *n, long *skip)
+{      return uintptr_t(mgl_data_ifs_2d(_DT_,*n,*skip));       }
+//-----------------------------------------------------------------------------
+void MGL_NO_EXPORT mgl_ifs_3d_point(HCDT A, mreal& x, mreal& y, mreal& z, mreal amax)
+{
+       int i, n=A->GetNy();
+       mreal r = amax*mgl_rnd(), sum_prob = 0, x1, y1;
+       for (i=0; i<n; i++)
+       {
+               sum_prob += A->v(12,i);
+               if(r < sum_prob)  break;
+       }
+       x1= A->v(0,i)*x + A->v(1,i)*y + A->v(2,i)*z + A->v(9,i);
+       y1= A->v(3,i)*x + A->v(4,i)*y + A->v(5,i)*z + A->v(10,i);
+       z = A->v(6,i)*x + A->v(7,i)*y + A->v(8,i)*z + A->v(11,i);
+       x = x1; y = y1;
+}
+HMDT MGL_EXPORT mgl_data_ifs_3d(HCDT A, long n, long skip)
+{
+       if(!A || A->GetNx()<13 || n<1)  return 0;   // incompatible dimensions
+       mreal amax = 0;
+       for(int i=0; i<A->GetNy(); i++) amax += A->v(12,i);
+       if(amax <= 0) return 0;
+       
+       mglData *f = new mglData(3,n);
+       mreal x = 0, y = 0, z = 0;
+       for(long i=0; i<skip; i++)      mgl_ifs_3d_point(A, x, y, z, amax);
+       for(long i=0; i<n; i++)
+       {
+               mgl_ifs_3d_point(A, x, y, z, amax);
+               f->a[3*i] = x;  f->a[3*i+1] = y;        f->a[3*i+2] = z;
+       }
+       return f;
+}
+uintptr_t MGL_EXPORT mgl_data_ifs_3d_(uintptr_t *d, long *n, long *skip)
+{   return uintptr_t(mgl_data_ifs_3d(_DT_,*n,*skip));   }
+//-----------------------------------------------------------------------------
+HMDT MGL_EXPORT mgl_data_ifs_file(const char *fname, const char *name, long n, long skip)
+{
+       gzFile fp = gzopen(fname,"r");
+       if(!fp) return 0;               // Couldn't open file file
+       char *buf = mgl_read_gz(fp);    gzclose(fp);
+       char *s = strstr(buf,name);
+       if(!s)  return 0;               // No data for fractal 'name' in the file
+
+       char *p = strchr(s,'{'), *e;
+       if(!p)  return 0;               // Wrong data format for fractal 'name' in the file
+       bool ext3d = false;
+       e = strstr(s,"(3D)");   if(e && e<p)    ext3d = true;
+       e = strstr(s,"(3d)");   if(e && e<p)    ext3d = true;
+       e = strchr(p,'}');
+       
+       std::vector<mreal> nums;
+       for(size_t i=0;p[i] && p+i<e;i++)
+       {
+               while(p[i]<=' ')        i++;
+               if(p[i]==';' || p[i]=='#')      while(p[i] && p[i]!='\n')       i++;
+               if(strchr("0123456789.+-",p[i]))        // this is number
+               {
+                       nums.push_back(atof(p+i));
+                       while(p[i]>' ') i++;
+               }
+       }
+       HMDT dat = new mglData, res;
+       if(ext3d)
+       {
+               dat->Set(&(nums[0]), 13, nums.size()/13, 1);
+               res = mgl_data_ifs_3d(dat, n, skip);
+       }
+       else
+       {
+               dat->Set(&(nums[0]), 7, nums.size()/7, 1);
+               res = mgl_data_ifs_2d(dat, n, skip);
+       }
+       delete dat;     free(buf);      return res;
+}
+uintptr_t mgl_data_ifs_file_(const char *fname, const char *name, long *n, long *skip,int l,int m)
+{      char *s=new char[l+1];          memcpy(s,fname,l);      s[l]=0;
+       char *t=new char[m+1];          memcpy(t,name,m);       t[m]=0;
+       uintptr_t r = uintptr_t(mgl_data_ifs_file(s,t,*n,*skip));
+       delete []s;     delete []t;             return r;       }
+//-----------------------------------------------------------------------------
+//
+//     Functions for flame fractal
+//
+//-----------------------------------------------------------------------------
+void MGL_NO_EXPORT mgl_linear_var0(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{      xNew += par[0]*x;       yNew += par[0]*y;       }
+void MGL_NO_EXPORT mgl_sinusoidal_var1(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{      xNew += par[0]*sin(x);  yNew += par[0]*sin(y);  }
+void MGL_NO_EXPORT mgl_spherical_var2(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{      mreal c1 = par[0]/(x*x+y*y);    xNew += c1*x;   yNew += c1*y;   }
+void MGL_NO_EXPORT mgl_swirl_var3(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal r2=x*x+y*y, c1=sin(r2), c2=cos(r2);       
+       xNew += par[0]*(x*c1 - y*c2);
+       yNew += par[0]*(x*c2 + y*c1);
+}
+void MGL_NO_EXPORT mgl_horseshoe_var4(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1 = par[0]/hypot(x,y);   
+       xNew += c1*(x*x-y*y);
+       yNew += 2*c1*x*y;
+}
+void MGL_NO_EXPORT mgl_polar_var5(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       xNew += par[0]*atan2(x,y)/M_PI;
+       yNew += par[0]*(hypot(x,y)-1);
+}
+void MGL_NO_EXPORT mgl_handkerchief_var6(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal r=hypot(x,y), t=atan2(x,y), c1=par[0]*r;
+       xNew += c1*sin(t+r);    yNew += c1*cos(t-r);
+}
+void MGL_NO_EXPORT mgl_heart_var7(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal r=hypot(x,y), c1=par[0]*r, c2=atan2(x,y)*r;
+       xNew +=  c1*sin(c2);    yNew += -c1*cos(c2);
+}
+void MGL_NO_EXPORT mgl_disc_var8(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=par[0]*atan2(x,y)/M_PI, c2=M_PI*hypot(x,y);
+       xNew += c1*sin(c2);             yNew += c1*cos(c2);
+}
+void MGL_NO_EXPORT mgl_spiral_var9(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal r=hypot(x,y), t=atan2(x,y), c1=par[0]/r;
+       xNew += c1*(cos(t)+sin(r));
+       yNew += c1*(sin(t)-cos(r));
+}
+void MGL_NO_EXPORT mgl_hyperbolic_var10(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal r=hypot(x,y), t=atan2(x,y);
+       xNew += par[0]*sin(t)/r;
+       yNew += par[0]*r*cos(t);
+}
+void MGL_NO_EXPORT mgl_diamond_var11(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal r=hypot(x,y), t=atan2(x,y);
+       xNew += par[0]*sin(t)*cos(r);
+       yNew += par[0]*cos(t)*sin(r);
+}
+void MGL_NO_EXPORT mgl_ex_var12(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal r=hypot(x,y), t=atan2(x,y), c1=par[0]*r;
+       mreal c2=mgl_ipow(sin(t+r),3), c3 = mgl_ipow(cos(t-r), 3);      
+       xNew += c1*(c2 + c3);   yNew += c1*(c2 - c3);
+}
+void MGL_NO_EXPORT mgl_julia_var13(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=par[0]*sqrt(hypot(x,y)), c2=atan2(x,y)/2, c3=(rand()%2)*M_PI;
+       xNew += c1*cos(c2+c3);  yNew += c1*sin(c2+c3);
+}
+void MGL_NO_EXPORT mgl_bent_var14(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       if (x>=0 && y>=0)
+       {       xNew += par[0]*x;       yNew += par[0]*y;       }
+       else if (x<0 && y>=0)
+       {       xNew += par[0]*2*x;     yNew += par[0]*y;       }
+       else if (x>=0 && x<0)
+       {       xNew += par[0]*x;       yNew += par[0]*y/2;     }
+       else
+       {       xNew += par[0]*2*x;     yNew += par[0]*y/2;     }
+}
+void MGL_NO_EXPORT mgl_waves_var15(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{      // NOTE: par[1]=b[i], par[2]=1/c[i]^2, par[3]=e[i], par[4]=1/f[i]^2
+       xNew += par[0]*(x + par[1]*sin(y*par[2]));
+       yNew += par[0]*(y + par[3]*sin(x*par[4]));
+}
+void MGL_NO_EXPORT mgl_fisheye_var16(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1 = par[0]*2/(hypot(x,y) + 1);
+       xNew += c1*y;   yNew += c1*x;
+}
+void MGL_NO_EXPORT mgl_popcorn_var17(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{      // NOTE: par[1]=c[i], par[2]=f[i]
+       xNew += par[0]*(x + par[1]*sin(tan(3*y)));
+       yNew += par[0]*(y + par[2]*sin(tan(3*x)));
+}
+void MGL_NO_EXPORT mgl_exponential_var18(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=par[0]*exp(x-1);
+       xNew += c1*cos(M_PI*y); yNew += c1*sin(M_PI*y);
+}
+void MGL_NO_EXPORT mgl_power_var19(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal t=atan2(x,y), c1=par[0]*pow(hypot(x,y), sin(t));
+       xNew += c1*cos(t);      yNew += c1*sin(t);
+}
+void MGL_NO_EXPORT mgl_cosine_var20(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       xNew +=  par[0]*cos(M_PI*x)*cosh(y);
+       yNew += -par[0]*sin(M_PI*x)*sinh(y);
+}
+void MGL_NO_EXPORT mgl_rings_var21(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{      // NOTE: par[1]=c[i]^2
+       mreal t=atan2(x,y), r=hypot(x,y), c1=par[0]*(fmod(r+par[1],2*par[1])-par[1]+r*(1-par[1])); // convert to int?
+       xNew += c1*cos(t);      yNew += c1*sin(t);
+}
+void MGL_NO_EXPORT mgl_fan_var22(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{      // NOTE: par[1]=c[i]^2, par[2]=f[i]
+       mreal t=atan2(x,y), c1=par[0]*hypot(x,y), c2;
+       c2 = fmod(t+par[2], M_PI*par[1]); // convert to int?
+       if (c2 > M_PI/2*par[1])    c2 = t - M_PI/2*par[1];
+       else    c2 += t;
+       xNew += c1*cos(c2);     yNew += c1*sin(c2);
+}
+void MGL_NO_EXPORT mgl_blob_var23(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal t=atan2(x,y), c1=par[0]*hypot(x,y)*(par[2]+(par[1]-par[2])/2*(sin(par[3]*t)));
+       xNew += c1*cos(t);      yNew += c1*sin(t);
+}
+void MGL_NO_EXPORT mgl_pdj_var24(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       xNew += par[0]*(sin(par[1]*y) - cos(par[2]*x));
+       yNew += par[0]*(sin(par[3]*x) - cos(par[4]*y));
+}
+void MGL_NO_EXPORT mgl_fan2_var25(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal t=atan2(x,y), c1, c2;
+       c1 = M_PI*par[1]*par[1];
+       c2 = t + par[2] - c1*int(2*t*par[2]/c1);
+       c1 /= 2;        c2 = c2>c1?t-c1:t+c1;
+       c1 = par[0]*hypot(x,y);
+       xNew += c1*sin(c2);     yNew += c1*cos(c2);
+}
+void MGL_NO_EXPORT mgl_rings2_var26(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal r=hypot(x,y), t=atan2(x,y), c1=par[1]*par[1];
+       c1 = par[0]*(r - 2*c1*int((r+c1)/(2*c1)) + r*(1-c1));
+       xNew += c1*cos(t);      yNew += c1*sin(t);
+}
+void MGL_NO_EXPORT mgl_eyefish_var27(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1 = par[0]*2/(hypot(x,y)+1);
+       xNew += c1*x;           yNew += c1*y;
+}
+void MGL_NO_EXPORT mgl_bubble_var28(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1 = par[0]*4/(x*x+y*y+4);
+       xNew += c1*x;           yNew += c1*y;
+}
+void MGL_NO_EXPORT mgl_cylinder_var29(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{      xNew += par[0]*sin(x);  yNew += par[0]*y;       }
+void MGL_NO_EXPORT mgl_perspective_var30(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1 = par[0]*par[2]/(par[2]-y*sin(par[1]));
+       xNew += c1*x;   yNew += c1*y*cos(par[1]);
+}
+void MGL_NO_EXPORT mgl_noise_var31(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=par[0]*mgl_rnd(), c2=2*M_PI*mgl_rnd();
+       xNew += c1*x*cos(c2);   yNew += c1*y*sin(c2);
+}
+void MGL_NO_EXPORT mgl_juliaN_var32(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=int(fabs(par[1])*mgl_rnd()), c2;
+       c2 = (atan2(y,x) + 2*M_PI*c1)/par[1];
+       c1 = par[0]*pow(hypot(x,y), par[2]/par[1]);
+       xNew += c1*cos(c2);     yNew += c1*sin(c2);
+}
+void MGL_NO_EXPORT mgl_juliaScope_var33(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=int(fabs(par[1])*mgl_rnd()), c2;
+       c2 = ((2*(rand()%2)-1)*atan2(y,x) + 2*M_PI*c1)/par[1];
+       c1 = par[0]*pow(hypot(x,y), par[2]/par[1]);
+       xNew += c1*cos(c2);     yNew += c1*sin(c2);
+}
+void MGL_NO_EXPORT mgl_blur_var34(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=par[0]*mgl_rnd(), c2=2*M_PI*mgl_rnd();
+       xNew += c1*cos(c2);     yNew += c1*sin(c2);
+}
+void MGL_NO_EXPORT mgl_gaussian_var35(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=par[0]*(4*mgl_rnd()-2), c2=2*M_PI*mgl_rnd();
+       xNew += c1*cos(c2);     yNew += c1*sin(c2);
+}
+void MGL_NO_EXPORT mgl_radialBlur_var36(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal r=hypot(x,y), c1=par[1]*M_PI/2, c2=par[0]*(4*mgl_rnd()-2), c3;
+       c3 = c2*cos(c1) - 1;    c2 = atan2(y,x) + c2 *sin(c1);
+       xNew += r*cos(c2) + c3*x;       yNew += r*sin(c2) + c3*y;
+}
+void MGL_NO_EXPORT mgl_pie_var37(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=int(mgl_rnd()*par[1] + 0.5), c2;
+       c2 = par[2] + 2*M_PI/par[1]*(c1 + mgl_rnd()*par[3]);
+       c1 = par[0]*mgl_rnd();
+       xNew += c1*cos(c2);     yNew += c1*sin(c2);
+}
+void MGL_NO_EXPORT mgl_ngon_var38(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=2*M_PI/par[2], c2;
+       c2 = atan2(y,x) - c1*floor(atan2(y,x)/c1);
+       if (c2 <= c1/2)    c2 -= c1;
+       c1 = par[0]*(par[3]*(1/cos(c2) - 1) + par[4])/pow(hypot(x,y), par[1]);
+       xNew += c1*x;           yNew += c1*y;
+}
+void MGL_NO_EXPORT mgl_curl_var39(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=1 + par[1]*x + par[2]*(x*x - y*y);
+       mreal c2 = par[1]*y + 2*par[2]*x*y;
+       mreal c3 = par[0]/(c1*c1 + c2*c2);
+       
+       xNew += c3*(c1*x + c2*y);       yNew += c3*(c1*y - c2*y);
+}
+void MGL_NO_EXPORT mgl_rectangles_var40(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       xNew += par[0]*((2*floor(x/par[1]) + 1)*par[1] - x);
+       yNew += par[0]*((2*floor(y/par[2]) + 1)*par[2] - y);
+}
+void MGL_NO_EXPORT mgl_arch_var41(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=mgl_rnd()*M_PI*par[0], c2=sin(c1);
+       xNew += par[0]*c2;      yNew += par[0]*c2*c2/cos(c1);
+}
+void MGL_NO_EXPORT mgl_tangent_var42(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{      xNew += par[0]*sin(x)/cos(y);   yNew += par[0]*tan(y);  }
+void MGL_NO_EXPORT mgl_square_var43(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       xNew += par[0]*(mgl_rnd() - 0.5);
+       yNew += par[0]*(mgl_rnd() - 0.5);
+}
+void MGL_NO_EXPORT mgl_rays_var43(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1 = par[0]*par[0]*tan(mgl_rnd()*M_PI*par[0])/(x*x+y*y);
+       xNew += c1*cos(x);      yNew += c1*sin(y);
+}
+void MGL_NO_EXPORT mgl_blade_var44(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=par[0]*x, c2=mgl_rnd()*hypot(x,y)*par[0];
+       xNew += c1*(cos(c2) + sin(c2)); // TODO check use of c2
+       yNew += c1*(cos(c2) - sin(c2));
+}
+void MGL_NO_EXPORT mgl_secant_var45(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{      xNew += par[0]*x;       yNew += 1/cos(par[0]*hypot(x,y));       }
+void MGL_NO_EXPORT mgl_twintrian_var47(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1=par[0]*x, c2, c3;
+       c2 = mgl_rnd()*hypot(x,y)*par[0];
+       c3 = log10(sin(c2)*sin(c2)) + cos(c2);
+       xNew += c1*c3;  yNew += c1*(c3 - M_PI*sin(c2));
+}
+void MGL_NO_EXPORT mgl_cross_var48(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par)
+{
+       mreal c1 = par[0]/fabs(x*x - y*y);
+       xNew += c1*x;   yNew += c1*y;
+}
+//-----------------------------------------------------------------------------
+typedef void (*flame_func)(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par);
+MGL_NO_EXPORT flame_func ffunc[mglFlameLAST] = {
+       mgl_linear_var0,        mgl_sinusoidal_var1,    mgl_spherical_var2,     mgl_swirl_var3,         mgl_horseshoe_var4,
+       mgl_polar_var5,         mgl_handkerchief_var6,  mgl_heart_var7,         mgl_disc_var8,          mgl_spiral_var9,
+       mgl_hyperbolic_var10,   mgl_diamond_var11,      mgl_ex_var12,           mgl_julia_var13,        mgl_bent_var14,
+       mgl_waves_var15,                mgl_fisheye_var16,      mgl_popcorn_var17,      mgl_exponential_var18,  mgl_power_var19,
+       mgl_cosine_var20,               mgl_rings_var21,        mgl_fan_var22,          mgl_blob_var23,         mgl_pdj_var24,
+       mgl_fan2_var25,                 mgl_rings2_var26,       mgl_eyefish_var27,      mgl_bubble_var28,       mgl_cylinder_var29,
+       mgl_perspective_var30,  mgl_noise_var31,        mgl_juliaN_var32,       mgl_juliaScope_var33,   mgl_blur_var34,
+       mgl_gaussian_var35,     mgl_radialBlur_var36,   mgl_pie_var37,          mgl_ngon_var38,         mgl_curl_var39,
+       mgl_rectangles_var40,   mgl_arch_var41,         mgl_tangent_var42,      mgl_square_var43,       mgl_rays_var43,
+       mgl_blade_var44,                mgl_secant_var45,       mgl_twintrian_var47,mgl_cross_var48     };
+//-----------------------------------------------------------------------------
+long MGL_NO_EXPORT mgl_flame_2d_point(HCDT A, HCDT F, mreal& x, mreal& y, mreal amax)
+{
+       long i, n=A->GetNy(), m=F->GetNy(), last_func=0, l=F->GetNx();
+       l = l>6?6:l;
+       mreal r = amax*mgl_rnd(), sum_prob = 0, x1, y1;
+       for(i=0;i<n;i++)
+       {
+               sum_prob += A->v(6,i);
+               if(r<sum_prob)  break;
+       }
+       x1 = A->v(0,i)*x + A->v(1,i)*y + A->v(4,i);
+       y1 = A->v(2,i)*x + A->v(3,i)*y + A->v(5,i);
+       x = y = 0;
+       for(long j=0;j<m;j++)
+       {
+               int v=int(F->v(0,j,i)+0.5);
+               mreal par[5] = {F->v(1,j,i),0,0,0,0};
+               for(int k=2;k<l;k++)    par[k-1]=F->v(k,j,i);
+               if(v<0 || v>=mglFlameLAST)      {       v=0;    par[0]=1;       }
+               ffunc[v](x,y,x1,y1,par);        last_func=v;
+       }
+       return last_func;
+}
+HMDT MGL_EXPORT mgl_data_flame_2d(HCDT A, HCDT F, long n, long skip)
+{
+       if(!A || A->GetNx()<7 || n<1)   return 0;       // incompatible dimensions
+       if(!F || F->GetNx()<2 || F->GetNz()!=A->GetNy())        return 0;       // incompatible dimensions
+       mreal amax=0;
+       for(long i=0; i<A->GetNy(); i++)        amax += A->v(6,i);
+       if(amax<=0)     return 0;
+       
+       mglData *f = new mglData(3,n);
+       mreal x = 0, y = 0;
+       for(long i=0; i<skip; i++)      mgl_flame_2d_point(A, F, x, y,amax);
+       for(long i=0; i<n; i++)
+       {
+               f->a[3*i+2] = mgl_flame_2d_point(A, F, x, y, amax);     // TODO color information ?!!
+               f->a[3*i] = x;  f->a[3*i+1] = y;
+       }
+       return f;
+}
+uintptr_t MGL_EXPORT mgl_data_flame_2d_(uintptr_t *d, uintptr_t *f, long *n, long *skip)
+{      return uintptr_t(mgl_data_flame_2d(_DT_,_DA_(f),*n,*skip));     }
+//-----------------------------------------------------------------------------
index febde6c6b5c9a10dec70049d53c0e5f1e393f498..1fae550168bd3ba3494585e495a5feb12ce21029 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * obj.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -32,8 +32,6 @@ void MGL_NO_EXPORT mgl_printf(void *fp, bool gz, const char *str, ...);
 #include <float.h>\r
 #include <math.h>\r
 \r
-#include <string>\r
-#include <vector>\r
 #include <deque>\r
 #include <map>\r
 #include <iostream>\r
index 06549af8de32cd43a6211e7f5c4c024cb0e2420f..ed9bf22c0f3b6e55dcb9ae2ae29a8fdd06850802 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * other.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -24,7 +24,7 @@
 #include "mgl2/data.h"\r
 #include "mgl2/base.h"\r
 //-----------------------------------------------------------------------------\r
-HCDT MGL_NO_EXPORT fill_slice_x(HMGL gr, double sv, HCDT a, mglData &xx, mglData &yy, mglData &zz, mglData &aa)\r
+HCDT MGL_NO_EXPORT fill_slice_x(HMGL gr, double sv, HCDT a, mglDataV &xx, mglDataV &yy, mglDataV &zz, mglData &aa)\r
 {\r
        long n=a->GetNx(),m=a->GetNy(),l=a->GetNz();\r
        if(l>1)\r
@@ -47,7 +47,7 @@ HCDT MGL_NO_EXPORT fill_slice_x(HMGL gr, double sv, HCDT a, mglData &xx, mglData
        return a;\r
 }\r
 //-----------------------------------------------------------------------------\r
-HCDT MGL_NO_EXPORT fill_slice_y(HMGL gr, double sv, HCDT a, mglData &xx, mglData &yy, mglData &zz, mglData &aa)\r
+HCDT MGL_NO_EXPORT fill_slice_y(HMGL gr, double sv, HCDT a, mglDataV &xx, mglDataV &yy, mglDataV &zz, mglData &aa)\r
 {\r
        long n=a->GetNx(),m=a->GetNy(),l=a->GetNz();\r
        if(l>1)\r
@@ -70,7 +70,7 @@ HCDT MGL_NO_EXPORT fill_slice_y(HMGL gr, double sv, HCDT a, mglData &xx, mglData
        return a;\r
 }\r
 //-----------------------------------------------------------------------------\r
-HCDT MGL_NO_EXPORT fill_slice_z(HMGL gr, double sv, HCDT a, mglData &xx, mglData &yy, mglData &zz, mglData &aa)\r
+HCDT MGL_NO_EXPORT fill_slice_z(HMGL gr, double sv, HCDT a, mglDataV &xx, mglDataV &yy, mglDataV &zz, mglData &aa)\r
 {\r
        long n=a->GetNx(),m=a->GetNy(),l=a->GetNz();\r
        xx.Create(n,m); yy.Create(n,m); zz.Create(n,m);\r
@@ -99,11 +99,11 @@ HCDT MGL_NO_EXPORT fill_slice_z(HMGL gr, double sv, HCDT a, mglData &xx, mglData
 void MGL_EXPORT mgl_dens_x(HMGL gr, HCDT a, const char *sch, double sv, const char *opt)\r
 {\r
        long n=a->GetNx(),m=a->GetNy();\r
-       if(mgl_isnan(sv))       sv = gr->GetOrgX('x');\r
        if(n<2 || m<2)  {       gr->SetWarn(mglWarnLow,"DensX");        return; }\r
-       if(sv<gr->Min.x || sv>gr->Max.x)        {       gr->SetWarn(mglWarnSlc,"DensX");        return; }\r
-       mglData xx,yy,zz,aa;\r
        gr->SaveState(opt);\r
+       if(mgl_isnan(sv))       sv = gr->GetOrgX('x');\r
+       if(sv<gr->Min.x || sv>gr->Max.x)        {       gr->SetWarn(mglWarnSlc,"DensX");        gr->LoadState();        return; }\r
+       mglDataV xx,yy,zz;      mglData aa;\r
        a = fill_slice_x(gr,sv,a,xx,yy,zz,aa);\r
        mgl_surfc_xy(gr,&xx,&yy,&zz,a,sch,0);\r
 }\r
@@ -111,11 +111,11 @@ void MGL_EXPORT mgl_dens_x(HMGL gr, HCDT a, const char *sch, double sv, const ch
 void MGL_EXPORT mgl_dens_y(HMGL gr, HCDT a, const char *sch, double sv, const char *opt)\r
 {\r
        long n=a->GetNx(),m=a->GetNy();\r
-       if(mgl_isnan(sv))       sv = gr->GetOrgX('x');\r
        if(n<2 || m<2)  {       gr->SetWarn(mglWarnLow,"DensY");        return; }\r
-       if(sv<gr->Min.x || sv>gr->Max.x)        {       gr->SetWarn(mglWarnSlc,"DensY");        return; }\r
-       mglData xx,yy,zz,aa;\r
        gr->SaveState(opt);\r
+       if(mgl_isnan(sv))       sv = gr->GetOrgY('y');\r
+       if(sv<gr->Min.y || sv>gr->Max.y)        {       gr->SetWarn(mglWarnSlc,"DensY");        gr->LoadState();        return; }\r
+       mglDataV xx,yy,zz;      mglData aa;\r
        a = fill_slice_y(gr,sv,a,xx,yy,zz,aa);\r
        mgl_surfc_xy(gr,&xx,&yy,&zz,a,sch,0);\r
 }\r
@@ -123,11 +123,11 @@ void MGL_EXPORT mgl_dens_y(HMGL gr, HCDT a, const char *sch, double sv, const ch
 void MGL_EXPORT mgl_dens_z(HMGL gr, HCDT a, const char *sch, double sv, const char *opt)\r
 {\r
        long n=a->GetNx(),m=a->GetNy();\r
-       if(mgl_isnan(sv))       sv = gr->GetOrgX('x');\r
        if(n<2 || m<2)  {       gr->SetWarn(mglWarnLow,"DensZ");        return; }\r
-       if(sv<gr->Min.x || sv>gr->Max.x)        {       gr->SetWarn(mglWarnSlc,"DensZ");        return; }\r
-       mglData xx,yy,zz,aa;\r
        gr->SaveState(opt);\r
+       if(mgl_isnan(sv))       sv = gr->GetOrgZ('z');\r
+       if(sv<gr->Min.z || sv>gr->Max.z)        {       gr->SetWarn(mglWarnSlc,"DensZ");        gr->LoadState();        return; }\r
+       mglDataV xx,yy,zz;      mglData aa;\r
        a = fill_slice_z(gr,sv,a,xx,yy,zz,aa);\r
        mgl_surfc_xy(gr,&xx,&yy,&zz,a,sch,0);\r
 }\r
@@ -157,12 +157,12 @@ void MGL_EXPORT mgl_cont_gen(HMGL gr, mreal val, HCDT a, HCDT x, HCDT y, HCDT z,
 void MGL_EXPORT mgl_cont_x_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt)\r
 {\r
        long n=a->GetNx(),m=a->GetNy();\r
-       if(mgl_isnan(sv))       sv = gr->GetOrgX('x');\r
        if(n<2 || m<2)  {       gr->SetWarn(mglWarnLow,"ContX");        return; }\r
-       if(sv<gr->Min.x || sv>gr->Max.x)        {       gr->SetWarn(mglWarnSlc,"ContX");        return; }\r
        gr->SaveState(opt);\r
+       if(mgl_isnan(sv))       sv = gr->GetOrgX('x');\r
+       if(sv<gr->Min.x || sv>gr->Max.x)        {       gr->SetWarn(mglWarnSlc,"ContX");        gr->LoadState();        return; }\r
        static int cgid=1;      gr->StartGroup("ContX",cgid++);\r
-       mglData xx,yy,zz,aa;\r
+       mglDataV xx,yy,zz;      mglData aa;\r
 \r
        int text=0;\r
        if(mglchr(sch,'t'))     text=1;\r
@@ -171,6 +171,7 @@ void MGL_EXPORT mgl_cont_x_val(HMGL gr, HCDT v, HCDT a, const char *sch, double
        gr->SetPenPal(sch);\r
 \r
        a = fill_slice_x(gr,sv,a,xx,yy,zz,aa);\r
+#pragma omp parallel for\r
        for(long i=0;i<v->GetNx();i++)\r
        {\r
                register mreal v0 = v->v(i);\r
@@ -182,12 +183,12 @@ void MGL_EXPORT mgl_cont_x_val(HMGL gr, HCDT v, HCDT a, const char *sch, double
 void MGL_EXPORT mgl_cont_y_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt)\r
 {\r
        long n=a->GetNx(),m=a->GetNy();\r
-       if(mgl_isnan(sv))       sv = gr->GetOrgX('x');\r
        if(n<2 || m<2)  {       gr->SetWarn(mglWarnLow,"ContY");        return; }\r
-       if(sv<gr->Min.x || sv>gr->Max.x)        {       gr->SetWarn(mglWarnSlc,"ContY");        return; }\r
        gr->SaveState(opt);\r
+       if(mgl_isnan(sv))       sv = gr->GetOrgY('y');\r
+       if(sv<gr->Min.y || sv>gr->Max.y)        {       gr->SetWarn(mglWarnSlc,"ContY");        gr->LoadState();        return; }\r
        static int cgid=1;      gr->StartGroup("ContY",cgid++);\r
-       mglData xx,yy,zz,aa;\r
+       mglDataV xx,yy,zz;      mglData aa;\r
 \r
        int text=0;\r
        if(mglchr(sch,'t'))     text=1;\r
@@ -196,6 +197,7 @@ void MGL_EXPORT mgl_cont_y_val(HMGL gr, HCDT v, HCDT a, const char *sch, double
        gr->SetPenPal(sch);\r
 \r
        a = fill_slice_y(gr,sv,a,xx,yy,zz,aa);\r
+#pragma omp parallel for\r
        for(long i=0;i<v->GetNx();i++)\r
        {\r
                register mreal v0 = v->v(i);\r
@@ -207,12 +209,12 @@ void MGL_EXPORT mgl_cont_y_val(HMGL gr, HCDT v, HCDT a, const char *sch, double
 void MGL_EXPORT mgl_cont_z_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt)\r
 {\r
        long n=a->GetNx(),m=a->GetNy();\r
-       if(mgl_isnan(sv))       sv = gr->GetOrgX('x');\r
        if(n<2 || m<2)  {       gr->SetWarn(mglWarnLow,"ContZ");        return; }\r
-       if(sv<gr->Min.x || sv>gr->Max.x)        {       gr->SetWarn(mglWarnSlc,"ContZ");        return; }\r
        gr->SaveState(opt);\r
+       if(mgl_isnan(sv))       sv = gr->GetOrgZ('z');\r
+       if(sv<gr->Min.z || sv>gr->Max.z)        {       gr->SetWarn(mglWarnSlc,"ContZ");        gr->LoadState();        return; }\r
        static int cgid=1;      gr->StartGroup("ContZ",cgid++);\r
-       mglData xx,yy,zz,aa;\r
+       mglDataV xx,yy,zz;      mglData aa;\r
 \r
        int text=0;\r
        if(mglchr(sch,'t'))     text=1;\r
@@ -221,6 +223,7 @@ void MGL_EXPORT mgl_cont_z_val(HMGL gr, HCDT v, HCDT a, const char *sch, double
        gr->SetPenPal(sch);\r
 \r
        a = fill_slice_z(gr,sv,a,xx,yy,zz,aa);\r
+#pragma omp parallel for\r
        for(long i=0;i<v->GetNx();i++)\r
        {\r
                register mreal v0 = v->v(i);\r
@@ -294,15 +297,16 @@ void MGL_EXPORT mgl_contf_gen(HMGL gr, mreal v1, mreal v2, HCDT a, HCDT x, HCDT
 void MGL_EXPORT mgl_contf_x_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt)\r
 {\r
        long n=a->GetNx(),m=a->GetNy();\r
-       if(mgl_isnan(sv))       sv = gr->GetOrgX('x');\r
        if(n<2 || m<2)  {       gr->SetWarn(mglWarnLow,"ContFX");       return; }\r
-       if(sv<gr->Min.x || sv>gr->Max.x)        {       gr->SetWarn(mglWarnSlc,"ContFX");       return; }\r
        gr->SaveState(opt);\r
+       if(mgl_isnan(sv))       sv = gr->GetOrgX('x');\r
+       if(sv<gr->Min.x || sv>gr->Max.x)        {       gr->SetWarn(mglWarnSlc,"ContFX");       gr->LoadState();        return; }\r
        static int cgid=1;      gr->StartGroup("ContFX",cgid++);\r
-       mglData xx,yy,zz,aa;\r
+       mglDataV xx,yy,zz;      mglData aa;\r
        long ss=gr->AddTexture(sch);\r
 \r
        a = fill_slice_x(gr,sv,a,xx,yy,zz,aa);\r
+#pragma omp parallel for\r
        for(long i=0;i<v->GetNx()-1;i++)\r
        {\r
                register mreal v0 = v->v(i);\r
@@ -314,15 +318,16 @@ void MGL_EXPORT mgl_contf_x_val(HMGL gr, HCDT v, HCDT a, const char *sch, double
 void MGL_EXPORT mgl_contf_y_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt)\r
 {\r
        long n=a->GetNx(),m=a->GetNy();\r
-       if(mgl_isnan(sv))       sv = gr->GetOrgX('x');\r
        if(n<2 || m<2)  {       gr->SetWarn(mglWarnLow,"ContFY");       return; }\r
-       if(sv<gr->Min.x || sv>gr->Max.x)        {       gr->SetWarn(mglWarnSlc,"ContFY");       return; }\r
        gr->SaveState(opt);\r
+       if(mgl_isnan(sv))       sv = gr->GetOrgY('y');\r
+       if(sv<gr->Min.y || sv>gr->Max.y)        {       gr->SetWarn(mglWarnSlc,"ContFY");       gr->LoadState();        return; }\r
        static int cgid=1;      gr->StartGroup("ContFY",cgid++);\r
-       mglData xx,yy,zz,aa;\r
+       mglDataV xx,yy,zz;      mglData aa;\r
        long ss=gr->AddTexture(sch);\r
 \r
        a = fill_slice_y(gr,sv,a,xx,yy,zz,aa);\r
+#pragma omp parallel for\r
        for(long i=0;i<v->GetNx()-1;i++)\r
        {\r
                register mreal v0 = v->v(i);\r
@@ -334,15 +339,16 @@ void MGL_EXPORT mgl_contf_y_val(HMGL gr, HCDT v, HCDT a, const char *sch, double
 void MGL_EXPORT mgl_contf_z_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt)\r
 {\r
        long n=a->GetNx(),m=a->GetNy();\r
-       if(mgl_isnan(sv))       sv = gr->GetOrgX('x');\r
        if(n<2 || m<2)  {       gr->SetWarn(mglWarnLow,"ContFZ");       return; }\r
-       if(sv<gr->Min.x || sv>gr->Max.x)        {       gr->SetWarn(mglWarnSlc,"ContFZ");       return; }\r
        gr->SaveState(opt);\r
+       if(mgl_isnan(sv))       sv = gr->GetOrgZ('z');\r
+       if(sv<gr->Min.z || sv>gr->Max.z)        {       gr->SetWarn(mglWarnSlc,"ContFZ");       gr->LoadState();        return; }\r
        static int cgid=1;      gr->StartGroup("ContFZ",cgid++);\r
-       mglData xx,yy,zz,aa;\r
+       mglDataV xx,yy,zz;      mglData aa;\r
        long ss=gr->AddTexture(sch);\r
 \r
        a = fill_slice_z(gr,sv,a,xx,yy,zz,aa);\r
+#pragma omp parallel for\r
        for(long i=0;i<v->GetNx()-1;i++)\r
        {\r
                register mreal v0 = v->v(i);\r
index 49aa1b725c9f5c18388bffd84d0a110064f99b2a..35a560fdb5877d0a98238381aac6755789ff0347 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * parse.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
@@ -100,7 +100,7 @@ const mglCommand *mglParser::FindCommand(const wchar_t *com) const
 }
 //-----------------------------------------------------------------------------
 // return values : 0 -- OK, 1 -- wrong arguments, 2 -- wrong command, 3 -- unclosed string
-int mglParser::Exec(mglGraph *gr, const wchar_t *com, long n, mglArg *a, const std::wstring &var, const wchar_t *opt)
+int mglParser::Exec(mglGraph *gr, const wchar_t *com, long n, mglArg *a, const std::wstring &/*var*/, const wchar_t *opt)
 {
        int i;
        const char *id="dsn";
@@ -135,7 +135,7 @@ int mglParser::Exec(mglGraph *gr, const wchar_t *com, long n, mglArg *a, const s
 //-----------------------------------------------------------------------------
 mglParser::mglParser(bool setsize)
 {
-       InUse = 1;      curGr = 0;
+       InUse = 1;      curGr = 0;      Variant = 0;
        Skip=Stop=for_br=false;
        memset(for_stack,0,40*sizeof(int));
        memset(if_stack,0,40*sizeof(int));
@@ -272,16 +272,17 @@ mglNum *mglParser::AddNum(const wchar_t *name)
 //-----------------------------------------------------------------------------
 int MGL_LOCAL_PURE mglFindArg(const std::wstring &str)
 {
-       register long l=0,k=0,i;
-       for(i=0;i<long(str.length());i++)
+       register long l=0,k=0;
+       const size_t s=str.length();
+       for(size_t i=0;i<s;i++)
        {
                if(str[i]=='\'') l++;
                if(str[i]=='{') k++;
                if(str[i]=='}') k--;
                if(l%2==0 && k==0)
                {
-                       if(str[i]=='#' || str[i]==';')  return -i;
-                       if(str[i]<=' ') return i;
+                       if(str[i]=='#' || str[i]==';')  return -long(i);
+                       if(str[i]<=' ') return long(i);
                }
        }
        return 0;
@@ -298,11 +299,27 @@ void mglParser::FillArg(mglGraph *gr, int k, std::wstring *arg, mglArg *a)
        {
                mglDataA *v;    mglNum *f;
                a[n-1].type = -1;
-               if(arg[n][0]=='|')      a[n-1].type = -1;
-               else if(arg[n][0]=='\'')        // this is string (simplest case)
+               std::wstring str = arg[n];
+               size_t i1=0, i2=str.length(), j=0;
+               bool s=true;
+               for(size_t i=0;i<i2;i++)
+               {
+                       if(str[i]=='\'')        s = !s;
+                       if(s && str[i]=='?')
+                       {
+                               if(j<Variant)   i1=i+1;
+                               else    i2=i;
+                               j++;
+                       }
+               }
+               str = str.substr(i1,i2-i1);
+
+               if(str.empty()) a[n-1].type = -2;
+               else if(str[0]=='|')    a[n-1].type = -1;
+               else if(str[0]=='\'')   // this is string (simplest case)
                {
                        a[n-1].type = 1;
-                       std::wstring &w=arg[n],f;
+                       std::wstring &w=str,f;
                        wchar_t buf[32];
                        long i,i1,ll=w.length();
                        for(i=1;i<ll;i++)
@@ -335,51 +352,51 @@ void mglParser::FillArg(mglGraph *gr, int k, std::wstring *arg, mglArg *a)
                                else    a[n-1].w += w[i];
                        }
                }
-               else if(arg[n][0]=='{')
+               else if(str[0]=='{')
                {       // this is temp data
                        mglData *u=new mglData;
-                       std::wstring s = arg[n].substr(1,arg[n].length()-2);
+                       std::wstring s = str.substr(1,str.length()-2);
                        a[n-1].w = u->s = L"/*"+s+L"*/";
                        a[n-1].type = 0;
                        ParseDat(gr, s, *u);    a[n-1].d = u;
                        u->temp=true;   DataList.push_back(u);
                }
-               else if((v = FindVar(arg[n].c_str()))!=0)       // try to find normal variables (for data creation)
+               else if((v = FindVar(str.c_str()))!=0)  // try to find normal variables (for data creation)
                {       a[n-1].type=0;  a[n-1].d=v;     a[n-1].w=v->s;  }
-               else if((f = FindNum(arg[n].c_str()))!=0)       // try to find normal number (for data creation)
+               else if((f = FindNum(str.c_str()))!=0)  // try to find normal number (for data creation)
                {       a[n-1].type=2;  a[n-1].d=0;     a[n-1].v=f->d;  a[n-1].c=f->c;  a[n-1].w = f->s;        }
-               else if(arg[n][0]=='!') // complex array is asked
+               else if(str[0]=='!')    // complex array is asked
                {       // parse all numbers and formulas by unified way
-                       HADT d = mglFormulaCalcC(arg[n].substr(1), this, DataList);
+                       HADT d = mglFormulaCalcC(str.substr(1), this, DataList);
                        if(d->GetNN()==1)
                        {
-                               if(CheckForName(arg[n].substr(1)))
+                               if(CheckForName(str.substr(1)))
                                {       a[n-1].type = 2;        a[n-1].v = d->v(0);     a[n-1].c = d->a[0];     }
                                else
-                               {       a[n-1].type = 0;        a[n-1].d = AddVar(arg[n].c_str());      }
+                               {       a[n-1].type = 0;        a[n-1].d = AddVar(str.c_str()); }
                                delete d;
                        }
                        else
                        {
-                               a[n-1].w = L"/*"+arg[n]+L"*/";
+                               a[n-1].w = L"/*"+str+L"*/";
                                d->temp=true;   DataList.push_back(d);
                                a[n-1].type = 0;        a[n-1].d = d;
                        }
                }
                else
                {       // parse all numbers and formulas by unified way
-                       HMDT d = mglFormulaCalc(arg[n], this, DataList);
+                       HMDT d = mglFormulaCalc(str, this, DataList);
                        if(d->GetNN()==1)
                        {
-                               if(CheckForName(arg[n]))
+                               if(CheckForName(str))
                                {       a[n-1].type = 2;        a[n-1].c = a[n-1].v = d->v(0);  }
                                else
-                               {       a[n-1].type = 0;        a[n-1].d = AddVar(arg[n].c_str());      }
+                               {       a[n-1].type = 0;        a[n-1].d = AddVar(str.c_str()); }
                                delete d;
                        }
                        else
                        {
-                               a[n-1].w = L"/*"+arg[n]+L"*/";
+                               a[n-1].w = L"/*"+str+L"*/";
                                d->temp=true;   DataList.push_back(d);
                                a[n-1].type = 0;        a[n-1].d = d;
                        }
@@ -573,7 +590,6 @@ int mglParser::Parse(mglGraph *gr, std::wstring str, long pos)
 {
        if(Stop || gr->NeedStop())      return 0;
        curGr = gr->Self();
-       std::wstring arg[1024];
        str=mgl_trim_ws(str);
        long n,k=0,m=0,mm=0,res;
        // try parse ':' -- several commands in line
@@ -598,7 +614,8 @@ int mglParser::Parse(mglGraph *gr, std::wstring str, long pos)
        PutArg(str,false);      str=mgl_trim_ws(str);
 
        std::wstring opt;
-       for(k=0;k<1024;k++)     // parse string to substrings (by spaces)
+       std::vector<std::wstring> arg;
+       while(!str.empty())     // parse string to substrings (by spaces)
        {
                n = mglFindArg(str);
                if(n<1) // this is option
@@ -607,17 +624,18 @@ int mglParser::Parse(mglGraph *gr, std::wstring str, long pos)
                        if(n<0) str = str.substr(0,-n);
                        break;
                }
-               arg[k] = str.substr(0,n);
+               arg.push_back(str.substr(0,n));
                str = mgl_trim_ws(str.substr(n+1));
        }
        // try to find last argument
-       if(str[0]!=0 && str[0]!='#' && str[0]!=';')     {       arg[k] = str;   k++;    }
-       if(k<1) n =0;
+       if(str[0]!=0 && str[0]!='#' && str[0]!=';')     arg.push_back(str);
+       k = arg.size();
+       if(k<1) n = 0;
        else
        {
                // fill arguments by its values
                mglArg *a = new mglArg[k];
-               FillArg(gr, k, arg, a);
+               FillArg(gr, k, &(arg[0]), a);
                // execute first special (program-flow-control) commands
                if(!skip() && !arg[0].compare(L"stop"))
                {       Stop = true;    delete []a;     return 0;       }
@@ -656,10 +674,16 @@ int mglParser::Parse(mglGraph *gr, std::wstring str, long pos)
                                std::wstring a1 = arg[1], a2=arg[2];    res = 0;
                                if(a1[0]=='\'') a1 = a1.substr(1,a1.length()-2);
                                if(a2[0]=='\'') a2 = a2.substr(1,a2.length()-2);
-                               mgl_rk_step_w(this, a1.c_str(), a2.c_str(), (k>=3 && a[2].type==2)?a[2].v:1);
+                               mgl_rk_step_w(this, a1.c_str(), a2.c_str(), (k>3 && a[2].type==2)?a[2].v:1);
                        }
                        delete []a;     return res;
                }
+               if(!arg[0].compare(L"variant"))
+               {
+                       int res=1;
+                       if(k==2 && a[0].type==2)        {       SetVariant(a[0].v);     res=0;  }
+                       delete []a;     return res;
+               }
                if(!arg[0].compare(L"call"))
                {
                        n = 1;
@@ -702,6 +726,7 @@ int mglParser::Parse(mglGraph *gr, std::wstring str, long pos)
                }
                if(!arg[0].compare(L"for"))
                {
+                       if(k<2) {       delete []a;     return 1;       }
                        n = 1;
                        char ch = arg[1][0];
                        int r = ch-'0';
@@ -737,10 +762,10 @@ int mglParser::Parse(mglGraph *gr, std::wstring str, long pos)
                        delete []a;     return n;
                }
                // alocate new arrays and execute the command itself
-               n = PreExec(gr, k, arg, a);
+               n = PreExec(gr, k, &(arg[0]), a);
                if(n>0) n--;
                else if(!arg[0].compare(L"setsize") && !AllowSetSize)   n = 2;
-               else    n = Exec(gr, arg[0].c_str(),k-1,a, arg[1].c_str(), opt.c_str());
+               else    n = Exec(gr, arg[0].c_str(),k-1,a, k>1?arg[1]:L"", opt.c_str());
                delete []a;
        }
        // delete temporary data arrays
@@ -887,7 +912,6 @@ int mglParser::FlowExec(mglGraph *, const std::wstring &com, long m, mglArg *a)
        return n+1;
 }
 //-----------------------------------------------------------------------------
-#include <string>
 void mglParser::Execute(mglGraph *gr, FILE *fp, bool print)
 {
        if(gr==0 || fp==0)      return;
@@ -1303,3 +1327,6 @@ void MGL_EXPORT mgl_rk_step_(uintptr_t *p, const char *eqs, const char *vars, do
        char *s=new char[m+1];  memcpy(s,vars,m);       s[m]=0;
        mgl_rk_step(_PR_,e,s,*dt);      delete []e;     delete []s;     }
 //---------------------------------------------------------------------------
+void MGL_EXPORT mgl_parser_variant(HMPR p, int var)    {       p->SetVariant(var);     }
+void MGL_EXPORT mgl_parser_variant_(uintptr_t *p, int *var)    {       mgl_parser_variant(_PR_,*var);  }
+//---------------------------------------------------------------------------
index b99338c06cf092dc76538531a00364ab669e3537..637f01472ebf4356ed3150169d217bf24c9ca69f 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * pde.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -29,12 +29,160 @@ HADT MGL_NO_EXPORT mglFormulaCalcC(const char *str, const std::vector<mglDataA*>
 //             Advanced PDE series in 2D case\r
 //\r
 //-----------------------------------------------------------------------------\r
+void MGL_NO_EXPORT mgl_operator_exp(long n, dual *h, dual *a, dual *f)\r
+{\r
+       memset(f,0,2*n*sizeof(dual));\r
+       const long i1=n/2, i2=3*n/2-1;\r
+#pragma omp parallel for\r
+       for(long j=0;j<n;j++)\r
+       {\r
+               long jp = (j+1)%n;\r
+               mreal h1=real(h[n*j]), h2=real(h[n-1+n*j]);\r
+               mreal g1=(h1+real(h[n*jp]))/2, g2=(h2+real(h[n-1+n*jp]))/2;\r
+               mreal k1=M_PI*2*j/n, k2 = M_PI*(2*j+1)/n;\r
+               for(long i=0;i<i1;i++)\r
+               {\r
+                       f[2*j] += a[i]*exp(dual(0,h1+i*k1));\r
+                       f[2*j+1] += a[i]*exp(dual(0,g1+i*k2));\r
+               }\r
+               for(long i=i1;i<i2;i++)\r
+               {\r
+                       mreal hh = real(h[i-i1+n*j]);\r
+                       f[2*j] += a[i]*exp(dual(0,hh+i*k1));\r
+                       f[2*j+1] += a[i]*exp(dual(0,(hh+real(h[i-i1+n*jp]))/2+i*k2));\r
+               }\r
+               for(long i=i2;i<2*n;i++)\r
+               {\r
+                       f[2*j] += a[i]*exp(dual(0,h2+i*k1));\r
+                       f[2*j+1] += a[i]*exp(dual(0,g2+i*k2));\r
+               }\r
+       }\r
+       memset(a,0,2*n*sizeof(dual));\r
+#pragma omp parallel for\r
+       for(long i=0;i<2*n;i++)\r
+       {\r
+               register long ii=i-i1;\r
+               if(ii<0)        ii=0;   if(ii>n-1)      ii=n-1;\r
+               double kk=M_PI*2*i/n;\r
+               for(long j=0;j<n;j++)\r
+               {\r
+                       mreal h1 = real(h[ii+n*j]), g1 = (h1+real(h[ii+n*((j+1)%n)]))/2;\r
+                       a[i] += f[2*j]*exp(dual(0,h1-kk*j));\r
+                       a[i] += f[2*j+1]*exp(dual(0,g1-kk*(j+0.5)));\r
+               }\r
+       }\r
+}\r
+//-----------------------------------------------------------------------------\r
+void MGL_NO_EXPORT mgl_operator_hrm(long n, dual *h, dual *a, dual *f, dual *g, dual *o)\r
+{\r
+       memset(f,0,2*n*sizeof(dual));\r
+       memset(g,0,2*n*sizeof(dual));\r
+       const long i1=n/2, i2=3*n/2-1;\r
+       #pragma omp parallel for\r
+       for(long j=0;j<n;j++)\r
+       {\r
+               long jp = (j+1)%n;\r
+               mreal h1=real(h[n*j]), h2=real(h[n-1+n*j]);\r
+               mreal g1=h1+real(h[n*jp])/2., g2=h2+real(h[n-1+n*jp])/2.;\r
+               mreal k1=M_PI*2*j/n, k2 = M_PI*(2*j+1)/n;\r
+               for(long i=0;i<i1;i++)\r
+               {\r
+                       dual e1=exp(dual(0,i*k1)), e2=exp(dual(0,i*k2));\r
+                       f[2*j] += a[i]*h1*e1;   f[2*j+1] += a[i]*g1*e2;\r
+                       g[2*j] += a[i]*e1;              g[2*j+1] += a[i]*e2;\r
+               }\r
+               for(long i=i1;i<i2;i++)\r
+               {\r
+                       mreal hh = real(h[i-i1+n*j]);\r
+                       mreal gg = hh+real(h[i-i1+n*jp])/2.;\r
+                       dual e1=exp(dual(0,i*k1)), e2=exp(dual(0,i*k2));\r
+                       f[2*j] += a[i]*hh*e1;   f[2*j+1] += a[i]*gg*e2;\r
+                       g[2*j] += a[i]*e1;              g[2*j+1] += a[i]*e2;\r
+               }\r
+               for(long i=i2;i<2*n;i++)\r
+               {\r
+                       dual e1=exp(dual(0,i*k1)), e2=exp(dual(0,i*k2));\r
+                       f[2*j] += a[i]*h2*e1;   f[2*j+1] += a[i]*g2*e2;\r
+                       g[2*j] += a[i]*e1;              g[2*j+1] += a[i]*e2;\r
+               }\r
+       }\r
+       memset(o,0,2*n*sizeof(dual));\r
+       #pragma omp parallel for\r
+       for(long i=0;i<2*n;i++)\r
+       {\r
+               register long ii=i-i1;\r
+               if(ii<0)        ii=0;   if(ii>n-1)      ii=n-1;\r
+               double kk=M_PI*2*i/n;\r
+               for(long j=0;j<n;j++)\r
+               {\r
+                       mreal h1 = real(h[ii+n*j]);\r
+                       mreal g1 = h1+real(h[ii+n*((j+1)%n)])/2.;\r
+                       dual e1=exp(dual(0,-j*kk)), e2=exp(dual(0,-kk*(j+0.5)));\r
+                       o[i] += f[2*j]*e1 + f[2*j+1]*e2;\r
+                       o[i] += g[2*j]*h1*e1 + g[2*j+1]*g1*e2;\r
+               }\r
+       }\r
+}\r
+//-----------------------------------------------------------------------------\r
+inline dual isqrt(dual a)\r
+{      mreal b=imag(a);        return b>=0?dual(sqrt(b),0):dual(0,sqrt(-b));   }\r
+void MGL_NO_EXPORT mgl_operator_lin(long n, dual *h, dual *a, dual *f, dual *g, dual *o)\r
+{\r
+       memset(f,0,2*n*sizeof(dual));\r
+       memset(g,0,2*n*sizeof(dual));\r
+       const long i1=n/2, i2=3*n/2-1;\r
+#pragma omp parallel for\r
+       for(long j=0;j<n;j++)\r
+       {\r
+               long jp = (j+1)%n;\r
+               dual h1=tanh(isqrt(h[n*j])), h2=tanh(isqrt(h[n-1+n*j]));\r
+               dual g1=tanh(h1+isqrt(h[n*jp]))/2., g2=tanh(h2+isqrt(h[n-1+n*jp]))/2.;\r
+               mreal k1=M_PI*2*j/n, k2 = M_PI*(2*j+1)/n;\r
+               for(long i=0;i<i1;i++)\r
+               {\r
+                       dual e1=exp(dual(0,i*k1)), e2=exp(dual(0,i*k2));\r
+                       f[2*j] += a[i]*h1*e1;   f[2*j+1] += a[i]*g1*e2;\r
+                       g[2*j] += a[i]*e1;              g[2*j+1] += a[i]*e2;\r
+               }\r
+               for(long i=i1;i<i2;i++)\r
+               {\r
+                       dual hh = tanh(isqrt(h[i-i1+n*j]));\r
+                       dual gg = tanh(hh+isqrt(h[i-i1+n*jp]))/2.;\r
+                       dual e1=exp(dual(0,i*k1)), e2=exp(dual(0,i*k2));\r
+                       f[2*j] += a[i]*hh*e1;   f[2*j+1] += a[i]*gg*e2;\r
+                       g[2*j] += a[i]*e1;              g[2*j+1] += a[i]*e2;\r
+               }\r
+               for(long i=i2;i<2*n;i++)\r
+               {\r
+                       dual e1=exp(dual(0,i*k1)), e2=exp(dual(0,i*k2));\r
+                       f[2*j] += a[i]*h2*e1;   f[2*j+1] += a[i]*g2*e2;\r
+                       g[2*j] += a[i]*e1;              g[2*j+1] += a[i]*e2;\r
+               }\r
+       }\r
+       memset(o,0,2*n*sizeof(dual));\r
+#pragma omp parallel for\r
+       for(long i=0;i<2*n;i++)\r
+       {\r
+               register long ii=i-i1;\r
+               if(ii<0)        ii=0;   if(ii>n-1)      ii=n-1;\r
+               double kk=M_PI*2*i/n;\r
+               for(long j=0;j<n;j++)\r
+               {\r
+                       dual h1 = tanh(isqrt(h[ii+n*j]));\r
+                       dual g1 = tanh(h1+isqrt(h[ii+n*((j+1)%n)]))/2.;\r
+                       dual e1=exp(dual(0,-j*kk)), e2=exp(dual(0,-kk*(j+0.5)));\r
+                       o[i] += f[2*j]*e1 + f[2*j+1]*e2;\r
+                       o[i] += g[2*j]*h1*e1 + g[2*j+1]*g1*e2;\r
+               }\r
+       }\r
+}\r
+//-----------------------------------------------------------------------------\r
 // Solve equation dx/dy = func(p,x,y,|u|)[u] where p=d/dx. There are no assumptions about form of func().\r
 HADT MGL_EXPORT mgl_pde_adv_c(HMGL gr, const char *func, HCDT ini_re, HCDT ini_im, mreal dt, mreal k0, const char *opt)\r
 {\r
        mreal gamma = gr->SaveState(opt);       if(mgl_isnan(gamma))    gamma = 20;\r
-       mglPoint Min=gr->Min, Max=gr->Max;\r
-       long nx=ini_re->GetNx(), nt = long((Max.y-Min.y)/dt)+1;\r
+       const mglPoint &Min=gr->Min, &Max=gr->Max;\r
+       const long nx=ini_re->GetNx(), nt = long((Max.y-Min.y)/dt)+1;\r
        if(nx<2 || nt<2 || Max.x==Min.x){       gr->SetWarn(mglWarnLow,"PDE");  return 0;       }       // Too small data\r
        if(ini_im->GetNx() != nx)               {       gr->SetWarn(mglWarnDim,"PDE");  return 0;       }       // Wrong dimensions\r
 \r
@@ -49,7 +197,7 @@ HADT MGL_EXPORT mgl_pde_adv_c(HMGL gr, const char *func, HCDT ini_re, HCDT ini_i
        list.push_back(&x);     list.push_back(&y);     list.push_back(&p);     list.push_back(&r);     list.push_back(&u);\r
 \r
        dual *a = new dual[2*nx];       memset(a,0,2*nx*sizeof(dual));  // Add "damping" area\r
-       dual *f = new dual[2*nx];       memset(f,0,2*nx*sizeof(dual));  // Effective "spectrum"\r
+       dual *f = new dual[6*nx], *g=f+2*nx, *s=f+4*nx;\r
 #pragma omp parallel for\r
        for(long i=0;i<nx;i++)  // Initial conditions\r
                a[i+nx/2] = dual(ini_re->v(i), ini_im->v(i));\r
@@ -60,57 +208,26 @@ HADT MGL_EXPORT mgl_pde_adv_c(HMGL gr, const char *func, HCDT ini_re, HCDT ini_i
                if(i<nx/2)              dmp[i] += gamma*mgl_ipow((nx/2-i)/mreal(nx/2),2);\r
                if(i>3*nx/2)    dmp[i] += gamma*mgl_ipow((i-3*nx/2-1)/mreal(nx/2),2);\r
        }\r
+       bool have_y = mglchr(func,'y');\r
        HADT ham;\r
+       if(!have_y)\r
+       {       ham = mglFormulaCalcC(func, list);      mgl_datac_mul_num(ham,dd);      }\r
        for(long k=0;k<nt;k++)\r
        {\r
-               y.Fill(k*dt);\r
                memcpy(u.a,a+nx/2,nx*sizeof(dual));\r
                memcpy(res->a+k*nx,a+nx/2,nx*sizeof(dual));\r
-               ham = mglFormulaCalcC(func, list);\r
-               memset(f,0,2*nx*sizeof(dual));\r
-               const long i1=nx/2, i2=3*nx/2-1;\r
-#pragma omp parallel for\r
-               for(long j=0;j<nx;j++)\r
-               {\r
-                       long jp = j<nx-1?j+1:0;\r
-                       dual h1=dual(0,dd)*ham->a[nx*j], h2=dual(0,dd)*ham->a[nx-1+nx*j];\r
-                       dual g1=(h1+dual(0,dd)*ham->a[nx*jp])/mreal(2), g2=(h2+dual(0,dd)*ham->a[nx-1+nx*jp])/mreal(2);\r
-                       mreal k1=M_PI*2*j/nx, k2 = M_PI*(2*j+1)/nx;\r
-                       for(long i=0;i<i1;i++)\r
-                       {\r
-                               f[2*j] += a[i]*exp(h1+dual(0,i*k1));\r
-                               f[2*j+1] += a[i]*exp(g1+dual(0,i*k2));\r
-                       }\r
-                       for(long i=i1;i<i2;i++)\r
-                       {\r
-                               dual hh = ham->a[i-i1+nx*j];\r
-                               f[2*j] += a[i]*exp(dual(0,dd)*hh+dual(0,i*k1));\r
-                               f[2*j+1] += a[i]*exp(dual(0,dd)*(hh+ham->a[i-i1+nx*jp])/mreal(2)+dual(0,i*k2));\r
-                       }\r
-                       for(long i=i2;i<2*nx;i++)\r
-                       {\r
-                               f[2*j] += a[i]*exp(h2+dual(0,i*k1));\r
-                               f[2*j+1] += a[i]*exp(g2+dual(0,i*k2));\r
-                       }\r
-               }\r
-               memset(a,0,2*nx*sizeof(dual));\r
+               if(have_y)\r
+               {       y.Fill(k*dt);   ham = mglFormulaCalcC(func, list);      mgl_datac_mul_num(ham,dd);      }\r
+               mgl_operator_exp(nx,ham->a,a,f);\r
+               mgl_operator_lin(nx,ham->a,a,f,g,s);\r
+               mgl_operator_lin(nx,ham->a,s,f,g,s);\r
 #pragma omp parallel for\r
                for(long i=0;i<2*nx;i++)\r
-               {\r
-                       register long ii=i-i1;\r
-                       if(ii<0)        ii=0;   if(ii>nx-1)     ii=nx-1;\r
-                       double kk=M_PI*2*i/nx;\r
-                       for(long j=0;j<nx;j++)\r
-                       {\r
-                               dual h1 = ham->a[ii+nx*j], g1 = (h1+ham->a[ii+nx*(j<nx-1?j+1:0)])/mreal(2);\r
-                               a[i] += f[2*j]*exp(dual(0,dd)*h1-dual(0,kk*j));\r
-                               a[i] += f[2*j+1]*exp(dual(0,dd)*g1-dual(0,kk*(j+0.5)));\r
-                       }\r
-                       a[i] *= exp(-dmp[i]*dt)/mreal(2*nx);\r
-               }\r
-               delete ham;\r
+                       a[i] = (a[i]-s[i]/mreal(8*nx*nx))*exp(-dmp[i]*dt)/mreal(2*nx);\r
+               if(have_y)      delete ham;\r
        }\r
        delete []a;     delete []f;     delete []dmp;\r
+       if(!have_y)     delete ham;\r
        gr->LoadState();        return res;\r
 }\r
 //-----------------------------------------------------------------------------\r
@@ -195,7 +312,7 @@ struct mgl_pde_ham
 };\r
 void MGL_NO_EXPORT mgl_pde_hprep(const mgl_pde_ham *f)\r
 {\r
-       long nx = f->nx, ny = f->ny;\r
+       const long nx = f->nx, ny = f->ny;\r
        mglDataV x(nx,ny), y(nx,ny), z, r(nx,ny);\r
        mglDataW p(nx,ny), q(nx,ny);\r
        x.s = L"x";     y.s = L"y";     p.s = L"p";     q.s = L"q";     r.s=L"#$mgl";\r
@@ -420,7 +537,7 @@ HMDT MGL_EXPORT mgl_ode_solve(void (*func)(const mreal *x, mreal *dx, void *par)
 HMDT MGL_EXPORT mgl_ode_solve_ex(void (*func)(const mreal *x, mreal *dx, void *par), int n, const mreal *x0, mreal dt, mreal tmax, void *par, void (*bord)(mreal *x, const mreal *xp, void *par))\r
 {\r
        if(tmax<dt)     return 0;       // nothing to do\r
-       int nt = int(tmax/dt+0.5)+1;\r
+       const long nt = int(tmax/dt+0.5)+1;\r
        mglData *res=new mglData(n,nt);\r
        mreal *x=new mreal[n], *k1=new mreal[n], *k2=new mreal[n], *k3=new mreal[n], *v=new mreal[n], hh=dt/2;\r
        register long i,k;\r
@@ -481,7 +598,7 @@ struct mgl_ap
        mgl_ap()        {       memset(this,0,sizeof(mgl_ap));  }\r
 };\r
 //-----------------------------------------------------------------------------\r
-void MGL_NO_EXPORT mgl_init_ra(int n, int n7, const mreal *r, mgl_ap *ra)      // prepare some intermediate data for QO (3d case)\r
+void MGL_NO_EXPORT mgl_init_ra(long n, int n7, const mreal *r, mgl_ap *ra)     // prepare some intermediate data for QO (3d case)\r
 {\r
        register double tt;\r
        tt = hypot(r[n7]-r[0], r[n7+1]-r[1]);\r
@@ -498,34 +615,35 @@ void MGL_NO_EXPORT mgl_init_ra(int n, int n7, const mreal *r, mgl_ap *ra) // pre
        ra[0].x2 = ra[0].y1*ra[0].z0 - ra[0].y0*ra[0].z1;       // vector g_2\r
        ra[0].y2 = ra[0].z1*ra[0].x0 - ra[0].z0*ra[0].x1;\r
        ra[0].z2 = ra[0].x1*ra[0].y0 - ra[0].x0*ra[0].y1;\r
-       register long i;\r
-       for(i=1;i<n;i++)        // NOTE: no parallel due to dependence on prev point!\r
+       for(long i=1;i<n;i++)   // NOTE: no parallel due to dependence on prev point!\r
        {\r
-               ra[i].dt = r[6+n7*i] - r[6+n7*(i-1)];\r
-               ra[i].x0 = r[n7*i]   - r[n7*(i-1)];             // NOTE: very rough formulas\r
-               ra[i].y0 = r[n7*i+1] - r[n7*(i-1)+1];   // for corresponding with dt one\r
-               ra[i].z0 = r[n7*i+2] - r[n7*(i-1)+2];   // for corresponding with dt one\r
-               tt = sqrt(ra[i].x0*ra[i].x0 + ra[i].y0*ra[i].y0 + ra[i].z0*ra[i].z0);\r
-               ra[i].x0 /= tt; ra[i].y0 /= tt; ra[i].z0 /= tt;\r
-               ra[i].ch = tt/ra[i].dt;\r
-               tt = ra[i].x0*ra[i-1].x1 + ra[i].y0*ra[i-1].y1 + ra[i].z0*ra[i-1].z1;\r
-               ra[i].x1 = ra[i-1].x1 - tt*ra[i].x0;    // vector g_1\r
-               ra[i].y1 = ra[i-1].y1 - tt*ra[i].y0;\r
-               ra[i].z1 = ra[i-1].z1 - tt*ra[i].z0;\r
-               ra[i].t1 = tt/(ra[i].dt*ra[i].ch);\r
-               tt = sqrt(ra[i].x1*ra[i].x1 + ra[i].y1*ra[i].y1 + ra[i].z1*ra[i].z1);\r
-               ra[i].x1 /= tt; ra[i].y1 /= tt; ra[i].z1 /= tt; // norm for reducing numeric error\r
-               ra[i].x2 = ra[i].y1*ra[i].z0 - ra[i].y0*ra[i].z1;       // vector g_2\r
-               ra[i].y2 = ra[i].z1*ra[i].x0 - ra[i].z0*ra[i].x1;\r
-               ra[i].z2 = ra[i].x1*ra[i].y0 - ra[i].x0*ra[i].y1;\r
-               tt = ra[i].x0*ra[i-1].x2 + ra[i].y0*ra[i-1].y2 + ra[i].z0*ra[i-1].z2;\r
-               ra[i].t2 = tt/(ra[i].dt*ra[i].ch);\r
-               // other parameters\r
-               ra[i].pt = r[n7*i+3]*ra[i].x0 + r[n7*i+4]*ra[i].y0 + r[n7*i+5]*ra[i].z0;\r
-               ra[i].q1 = r[n7*i+3]*ra[i].x1 + r[n7*i+4]*ra[i].y1 + r[n7*i+5]*ra[i].z1;\r
-               ra[i].q2 = r[n7*i+3]*ra[i].x2 + r[n7*i+4]*ra[i].y2 + r[n7*i+5]*ra[i].z2;\r
-               ra[i].d1 = (ra[i].q1-ra[i-1].q1)/(ra[i].dt*ra[i].ch);\r
-               ra[i].d2 = (ra[i].q2-ra[i-1].q2)/(ra[i].dt*ra[i].ch);\r
+               mgl_ap *ri=ra+i, *rp=ra+i-1;\r
+               const mreal *rr = r+n7*i;\r
+               ri->dt = rr[6] - rr[6-n7];\r
+               ri->x0 = rr[0] - rr[-n7];       // NOTE: very rough formulas\r
+               ri->y0 = rr[1] - rr[1-n7];      // for corresponding with dt one\r
+               ri->z0 = rr[2] - rr[2-n7];      // for corresponding with dt one\r
+               double ch = sqrt(ri->x0*ri->x0 + ri->y0*ri->y0 + ri->z0*ri->z0);\r
+               ri->x0 /= ch;   ri->y0 /= ch;   ri->z0 /= ch;\r
+               ri->ch = ch/ri->dt;\r
+               ri->pt = rr[3]*ri->x0 + rr[4]*ri->y0 + rr[5]*ri->z0;\r
+               ri->q1 = rr[3]*ri->x1 + rr[4]*ri->y1 + rr[5]*ri->z1;\r
+               ri->q2 = rr[3]*ri->x2 + rr[4]*ri->y2 + rr[5]*ri->z2;\r
+               // NOTE previous point is used here!\r
+               tt = ri->x0*rp->x1 + ri->y0*rp->y1 + ri->z0*rp->z1;\r
+               ri->x1 = rp->x1 - tt*ri->x0;    // vector g_1\r
+               ri->y1 = rp->y1 - tt*ri->y0;\r
+               ri->z1 = rp->z1 - tt*ri->z0;\r
+               ri->t1 = tt/ch;\r
+               tt = sqrt(ri->x1*ri->x1 + ri->y1*ri->y1 + ri->z1*ri->z1);\r
+               ri->x1 /= tt;   ri->y1 /= tt;   ri->z1 /= tt;   // norm for reducing numeric error\r
+               ri->x2 = ri->y1*ri->z0 - ri->y0*ri->z1; // vector g_2\r
+               ri->y2 = ri->z1*ri->x0 - ri->z0*ri->x1;\r
+               ri->z2 = ri->x1*ri->y0 - ri->x0*ri->y1;\r
+               tt = ri->x0*rp->x2 + ri->y0*rp->y2 + ri->z0*rp->z2;\r
+               ri->t2 = tt/ch;\r
+               ri->d1 = (ri->q1-rp->q1)/ch;\r
+               ri->d2 = (ri->q2-rp->q2)/ch;\r
        }\r
        memcpy(ra,ra+1,sizeof(mgl_ap)); // setup zero point\r
        ra[0].pt = r[3]*ra[0].x0 + r[4]*ra[0].y0 + r[5]*ra[0].z0;\r
@@ -554,7 +672,7 @@ MGL_NO_EXPORT void *mgl_qo2d_hprep(void *par)
        mgl_ap *ra = f->ra;\r
 \r
        const mreal *r = f->r;\r
-       long nx=t->n;\r
+       const long nx=t->n;\r
 #if !MGL_HAVE_PTHREAD\r
 #pragma omp parallel for\r
 #endif\r
@@ -581,7 +699,7 @@ HADT MGL_EXPORT mgl_qo2d_func_c(ddual (*ham)(mreal u, mreal x, mreal y, mreal px
 {\r
        const mglData *ray=dynamic_cast<const mglData *>(ray_dat);      // NOTE: Ray must be mglData!\r
        if(!ray)        return 0;\r
-       long nx=ini_re->GetNx(), nt=ray->ny, n7=ray->nx;\r
+       const long nx=ini_re->GetNx(), nt=ray->ny, n7=ray->nx;\r
        if(nx<2 || ini_im->GetNx()!=nx || nt<2) return 0;\r
        mglDataC *res=new mglDataC(nx,nt,1);\r
 \r
@@ -706,7 +824,7 @@ MGL_NO_EXPORT void *mgl_qo3d_hprep(void *par)
        mgl_qo3d_ham *f = (mgl_qo3d_ham *)t->v;\r
        mgl_ap *ra = f->ra;\r
        const mreal *r = f->r;\r
-       long nx=t->n;\r
+       const long nx=t->n;\r
 #if !MGL_HAVE_PTHREAD\r
 #pragma omp parallel for\r
 #endif\r
@@ -739,7 +857,7 @@ MGL_NO_EXPORT void *mgl_qo3d_post(void *par)
 {\r
        mglThreadD *t=(mglThreadD *)par;\r
        mgl_qo3d_ham *f = (mgl_qo3d_ham *)t->v;\r
-       long nx=t->n;\r
+       const long nx=t->n;\r
 #if !MGL_HAVE_PTHREAD\r
 #pragma omp parallel for\r
 #endif\r
@@ -764,7 +882,7 @@ HADT MGL_EXPORT mgl_qo3d_func_c(ddual (*ham)(mreal u, mreal x, mreal y, mreal z,
 {\r
        const mglData *ray=dynamic_cast<const mglData *>(ray_dat);      // NOTE: Ray must be mglData!\r
        if(!ray)        return 0;\r
-       long nx=ini_re->GetNx(), nt=ray->ny, n7=ray->nx;        // NOTE: only square grids are supported now (for simplicity)\r
+       const long nx=ini_re->GetNx(), nt=ray->ny, n7=ray->nx;  // NOTE: only square grids are supported now (for simplicity)\r
        if(nx<2 || ini_re->GetNx()!=nx || ini_im->GetNx()*ini_im->GetNy()!=nx*nx || nt<2)       return 0;\r
        mglDataC *res=new mglDataC(nx,nx,nt);\r
 \r
@@ -915,7 +1033,7 @@ uintptr_t MGL_EXPORT mgl_qo3d_solve_(const char *ham, uintptr_t* ini_re, uintptr
 MGL_NO_EXPORT void *mgl_jacob2(void *par)\r
 {\r
        mglThreadD *t=(mglThreadD *)par;\r
-       long nx=t->p[0], ny=t->p[1];\r
+       const long nx=t->p[0], ny=t->p[1];\r
        mreal *r=t->a;\r
        const mreal *x=t->b, *y=t->c;\r
 #if !MGL_HAVE_PTHREAD\r
@@ -934,7 +1052,7 @@ MGL_NO_EXPORT void *mgl_jacob2(void *par)
 }\r
 HMDT MGL_EXPORT mgl_jacobian_2d(HCDT x, HCDT y)\r
 {\r
-       int nx = x->GetNx(), ny=x->GetNy();\r
+       const long nx = x->GetNx(), ny=x->GetNy();\r
        if(nx!=y->GetNx() || ny!=y->GetNy() || nx<2 || ny<2)    return  0;\r
        mglData *r=new mglData(nx,ny,1);\r
        const mglData *xx=dynamic_cast<const mglData *>(x);\r
@@ -962,7 +1080,7 @@ HMDT MGL_EXPORT mgl_jacobian_2d(HCDT x, HCDT y)
 MGL_NO_EXPORT void *mgl_jacob3(void *par)\r
 {\r
        mglThreadD *t=(mglThreadD *)par;\r
-       long nx=t->p[0], ny=t->p[1], nz=t->p[2];\r
+       const long nx=t->p[0], ny=t->p[1], nz=t->p[2];\r
        mreal *r=t->a;\r
        const mreal *x=t->b, *y=t->c, *z=t->d;\r
 #if !MGL_HAVE_PTHREAD\r
@@ -985,7 +1103,7 @@ MGL_NO_EXPORT void *mgl_jacob3(void *par)
 }\r
 HMDT MGL_EXPORT mgl_jacobian_3d(HCDT x, HCDT y, HCDT z)\r
 {\r
-       int nx = x->GetNx(), ny=x->GetNy(), nz=x->GetNz(), nn = nx*ny*nz;\r
+       const long nx = x->GetNx(), ny=x->GetNy(), nz=x->GetNz(), nn = nx*ny*nz;\r
        if(nx<2 || ny<2 || nz<2)        return 0;\r
        if(nn!=y->GetNN() || nn!=z->GetNN())    return 0;\r
        mglData *r=new mglData(nx,ny,nz);\r
@@ -1024,3 +1142,325 @@ uintptr_t MGL_EXPORT mgl_jacobian_2d_(uintptr_t* x, uintptr_t* y)
 uintptr_t MGL_EXPORT mgl_jacobian_3d_(uintptr_t* x, uintptr_t* y, uintptr_t* z)\r
 {      return uintptr_t(mgl_jacobian_3d(_DA_(x), _DA_(y), _DA_(z)));   }\r
 //-----------------------------------------------------------------------------\r
+//\r
+//     Progonka\r
+//\r
+//-----------------------------------------------------------------------------\r
+void MGL_NO_EXPORT mgl_progonka_sr(HCDT A, HCDT B, HCDT C, HCDT D, mreal *dat, long n, long id, long i0, long di, bool difr)\r
+{\r
+       mreal *aa=dat, *bb=dat+n, *uu=dat+2*n;\r
+       mreal b0=B->vthr(i0), c0=C->vthr(i0), d0=D->vthr(id);\r
+       if(difr)        d0 = (2.-b0)*d0-c0*D->vthr(id+di);\r
+       aa[0] = -c0/b0; bb[0] = d0/b0;\r
+       for(long i=1;i<n;i++)\r
+       {\r
+               register long ii=i0+di*i, dd=id+di*i, tt = id+di*((i+1)%n);\r
+               mreal a=A->vthr(ii), b=B->vthr(ii), c=C->vthr(ii);\r
+               mreal d=difr?-a*D->vthr(dd-di)+(2.-b)*D->vthr(dd)-c*D->vthr(tt):D->vthr(dd);\r
+               aa[i] = -c/(b+a*aa[i-1]);\r
+               bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]);\r
+       }\r
+       uu[n-1] = bb[n-1];\r
+       for(long i=n-2;i>=0;i--)        uu[i] = bb[i]+aa[i]*uu[i+1];\r
+}\r
+void MGL_NO_EXPORT mgl_progonka_pr(HCDT A, HCDT B, HCDT C, HCDT D, mreal *dat, long n, long id, long i0, long di, bool difr)\r
+{\r
+       mreal *aa=dat, *bb=dat+n, *gg=dat+2*n, *uu=dat+3*n;\r
+       mreal a0=A->vthr(i0), b0=B->vthr(i0), c0=C->vthr(i0), d0=D->vthr(id);\r
+       if(difr)        d0 = -a0*D->vthr(id+di*(n-1))+(2.-b0)*d0-c0*D->vthr(id+di);\r
+       aa[0] =-c0/b0;  bb[0] = d0/b0;  gg[0] =-a0/b0;\r
+       for(long i=1;i<n;i++)\r
+       {\r
+               register long ii=i0+di*i, il=id+di*((i+1)%n), dd=id+di*i;\r
+               mreal a=A->vthr(ii), b=B->vthr(ii), c=C->vthr(ii);\r
+               mreal d=difr?-a*D->vthr(dd-di)+(2.-b)*D->vthr(dd)-c*D->vthr(il):D->vthr(dd);\r
+               aa[i] = -c/(b+a*aa[i-1]);\r
+               bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]);\r
+               gg[i] = -a*gg[i-1]/(b+a*aa[i-1]);\r
+       }\r
+       mreal P=bb[n-1]/(1.-gg[n-1]), Q=aa[n-1]/(1.-gg[n-1]);\r
+       aa[n-1] = Q;    bb[n-1] = P;\r
+       for(long i=n-2;i>=0;i--)\r
+       {\r
+               bb[i] += aa[i]*bb[i+1]+gg[i]*P;\r
+               aa[i] = aa[i]*aa[i+1]+gg[i]*Q;\r
+       }\r
+       mreal u0 = bb[0]/(1.-aa[0]);\r
+       for(long i=0;i<n;i++)   uu[i]=bb[i]+aa[i]*u0;\r
+}\r
+void MGL_NO_EXPORT mgl_progonka_hr(HCDT A, HCDT B, HCDT C, HCDT D, mreal *dat, long n, long id, long i0, bool difr)\r
+{\r
+       mreal *aa=dat, *bb=dat+n, *uu=dat+n*n;\r
+       mreal b0=B->vthr(i0), c0=C->vthr(i0), d0=D->vthr(id);\r
+       uu[0] = d0/b0*(difr?(2.-b0):1.);\r
+       b0=B->vthr(i0+n*n-1);   d0=D->vthr(id+n*n-1);\r
+       uu[n*n-1] = d0/b0*(difr?(2.-b0):1.);\r
+       long di = n-1, i1 = i0+n*(n-1), d1 = id+n*(n-1);\r
+       // suppose the square grid!\r
+       for(long j=1;j<n;j++)\r
+       {\r
+               // first bottom-left triangle\r
+               b0=B->vthr(i0+j);       c0=C->vthr(i0+j);       d0=D->vthr(id+j);\r
+               if(difr)        d0 = (2.-b0)*d0-c0*D->vthr(id+j+di);\r
+               aa[0] = -c0/b0; bb[0] = d0/b0;\r
+               for(long i=1;i<=j;i++)\r
+               {\r
+                       register long ii=i0+j+di*i, dd=id+j+di*i;\r
+                       mreal a=A->vthr(ii),b=B->vthr(ii),c=C->vthr(ii);\r
+                       mreal d=difr?-a*D->vthr(dd-di)+(2.-b)*D->vthr(dd)-c*D->vthr(dd+di):D->vthr(dd);\r
+                       aa[i] = -c/(b+a*aa[i-1]);\r
+                       bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]);\r
+               }\r
+               uu[j+di*(j-1)] = bb[j];\r
+               for(long i=j-1;i>=0;i--)\r
+                       uu[j+di*i] = bb[i]+aa[i]*uu[j+di*i+di];\r
+               // next top-right triangle\r
+               long j1=n-1-j;\r
+               b0=B->vthr(i1+j1);      c0=C->vthr(i1+j1);      d0=D->vthr(d1+j1);\r
+               if(difr)        d0 = (2.-b0)*d0-c0*D->vthr(d1+j1-di);\r
+               aa[0] = -c0/b0; bb[0] = d0/b0;\r
+               for(long i=1;i<=j;i++)\r
+               {\r
+                       register long ii=i1+j1-di*i, dd=d1+j1-di*i;\r
+                       mreal a=A->vthr(ii),b=B->vthr(ii),c=C->vthr(ii);\r
+                       mreal d=difr?-a*D->vthr(dd+di)+(2.-b)*D->vthr(dd)-c*D->vthr(dd-di):D->vthr(dd);\r
+                       aa[i] = -c/(b+a*aa[i-1]);\r
+                       bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]);\r
+               }\r
+               uu[j1+n*(n-1)-di*(j-1)] = bb[j];\r
+               for(long i=j-1;i>=0;i--)\r
+                       uu[j1+n*(n-1)-di*i] = bb[i]+aa[i]*uu[j1+n*(n-1)-di*i-di];\r
+       }\r
+}\r
+//-----------------------------------------------------------------------------\r
+HMDT MGL_EXPORT mgl_data_tridmat(HCDT A, HCDT B, HCDT C, HCDT D, const char *how)\r
+{\r
+       const long nx=D->GetNx(),ny=D->GetNy(),nz=D->GetNz();\r
+       const long nn=nx*ny*nz, np=nx*ny, na=A->GetNN();\r
+       if(B->GetNN()!=na || C->GetNN()!=na)    return 0;\r
+       mglData *r = new mglData(nx,ny,nz);\r
+       bool per = mglchr(how,'c');\r
+       bool difr = mglchr(how,'d');\r
+       if(mglchr(how,'x') && (na==nn || na==np || na==nx))\r
+#pragma omp parallel\r
+       {\r
+               mglData T(nx,4);        mreal *uu=T.a+(per?3:2)*nx;\r
+#pragma omp for collapse(2)\r
+               for(long k=0;k<nz;k++)  for(long j=0;j<ny;j++)\r
+               {\r
+                       long i0=0, i1=nx*(j+ny*k);\r
+                       if(na==nn)      i0=nx*(j+ny*k); else if(na==np) i0=nx*j;\r
+                       if(per) mgl_progonka_pr(A,B,C,D,T.a,nx,i1,i0,1,difr);\r
+                       else    mgl_progonka_sr(A,B,C,D,T.a,nx,i1,i0,1,difr);\r
+                       i0 = nx*(j+ny*k);\r
+                       for(long i=0;i<nx;i++)  r->a[i+i0] = uu[i];\r
+               }\r
+       }\r
+       else if(mglchr(how,'y') && (na==nn || na==np || na==ny))\r
+#pragma omp parallel\r
+       {\r
+               mglData T(ny,4);        mreal *uu=T.a+(per?3:2)*ny;\r
+#pragma omp for collapse(2)\r
+               for(long k=0;k<nz;k++)  for(long i=0;i<nx;i++)\r
+               {\r
+                       long i0=0, i1 = i+np*k;\r
+                       if(na==nn)      i0=i+np*k;      else if(na==np) i0=i;\r
+                       if(per) mgl_progonka_pr(A,B,C,D,T.a,ny,i1,i0,nx,difr);\r
+                       else    mgl_progonka_sr(A,B,C,D,T.a,ny,i1,i0,nx,difr);\r
+                       i0 = i+np*k;\r
+                       for(long j=0;j<ny;j++)  r->a[j*nx+i0] = uu[j];\r
+               }\r
+       }\r
+       else if(mglchr(how,'z') && (na==nn || na==nz))\r
+#pragma omp parallel\r
+       {\r
+               mglData T(nz,4);        mreal *uu=T.a+(per?3:2)*nz;\r
+#pragma omp for collapse(2)\r
+               for(long j=0;j<ny;j++)  for(long i=0;i<nx;i++)\r
+               {\r
+                       long i0 = na==nn?i+nx*j:0, i1 = i+nx*j;\r
+                       if(per) mgl_progonka_pr(A,B,C,D,T.a,nz,i1,i0,np,difr);\r
+                       else    mgl_progonka_sr(A,B,C,D,T.a,nz,i1,i0,np,difr);\r
+                       i0 = i+nx*j;\r
+                       for(long k=0;k<nz;k++)  r->a[k*np+i0] = uu[k];\r
+               }\r
+       }\r
+       else if(mglchr(how,'h') && ny==nx && (na==nn || na==np) && nx>1)\r
+#pragma omp parallel\r
+       {\r
+               mglData T(np,2);\r
+#pragma omp for\r
+               for(long k=0;k<nz;k++)\r
+               {\r
+                       mgl_progonka_hr(A,B,C,D,T.a,nx,k*np,na==nn ? k*np:0,difr);\r
+                       memcpy(r->a+k*np, T.a+np, np*sizeof(mreal));\r
+               }\r
+       }\r
+       else    {       delete r;       r=0;    }\r
+       return r;\r
+}\r
+//-----------------------------------------------------------------------------\r
+uintptr_t MGL_EXPORT mgl_data_tridmat_(uintptr_t *A, uintptr_t *B, uintptr_t *C, uintptr_t *D, const char *how, int l)\r
+{      char *s=new char[l+1];  memcpy(s,how,l);        s[l]=0;\r
+       uintptr_t r = uintptr_t(mgl_data_tridmat(_DA_(A),_DA_(B),_DA_(C),_DA_(D),s));\r
+       delete []s;     return r;\r
+}\r
+//-----------------------------------------------------------------------------\r
+void MGL_NO_EXPORT mgl_progonka_sc(HCDT A, HCDT B, HCDT C, HCDT D, dual *dat, long n, long id, long i0, long di, bool difr)\r
+{\r
+       dual *aa=dat, *bb=dat+n, *uu=dat+2*n;\r
+       dual b0=B->vcthr(i0), c0=C->vcthr(i0), d0=D->vcthr(id);\r
+       if(difr)        d0 = (2.-b0)*d0-c0*D->vcthr(id+di);\r
+       aa[0] = -c0/b0; bb[0] = d0/b0;\r
+       for(long i=1;i<n;i++)\r
+       {\r
+               register long ii=i0+di*i, dd=id+di*i, tt = id+di*((i+1)%n);\r
+               dual a=A->vcthr(ii), b=B->vcthr(ii), c=C->vcthr(ii);\r
+               dual d=difr?-a*D->vcthr(dd-di)+(2.-b)*D->vcthr(dd)-c*D->vcthr(tt):D->vcthr(dd);\r
+               aa[i] = -c/(b+a*aa[i-1]);\r
+               bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]);\r
+       }\r
+       uu[n-1] = bb[n-1];\r
+       for(long i=n-2;i>=0;i--)        uu[i] = bb[i]+aa[i]*uu[i+1];\r
+}\r
+void MGL_NO_EXPORT mgl_progonka_pc(HCDT A, HCDT B, HCDT C, HCDT D, dual *dat, long n, long id, long i0, long di, bool difr)\r
+{\r
+       dual *aa=dat, *bb=dat+n, *gg=dat+2*n, *uu=dat+3*n;\r
+       dual a0=A->vcthr(i0), b0=B->vcthr(i0), c0=C->vcthr(i0), d0=D->vcthr(id);\r
+       if(difr)        d0 = -a0*D->vcthr(id+di*(n-1))+(2.-b0)*d0-c0*D->vcthr(id+di);\r
+       aa[0] =-c0/b0;  bb[0] = d0/b0;  gg[0] =-a0/b0;\r
+       for(long i=1;i<n;i++)\r
+       {\r
+               register long ii=i0+di*i, il=id+di*((i+1)%n), dd=id+di*i;\r
+               dual a=A->vcthr(ii), b=B->vcthr(ii), c=C->vcthr(ii);\r
+               dual d=difr?-a*D->vcthr(dd-di)+(2.-b)*D->vcthr(dd)-c*D->vcthr(il):D->vcthr(dd);\r
+               aa[i] = -c/(b+a*aa[i-1]);\r
+               bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]);\r
+               gg[i] = -a*gg[i-1]/(b+a*aa[i-1]);\r
+       }\r
+       dual P=bb[n-1]/(1.-gg[n-1]), Q=aa[n-1]/(1.-gg[n-1]);\r
+       aa[n-1] = Q;    bb[n-1] = P;\r
+       for(long i=n-2;i>=0;i--)\r
+       {\r
+               bb[i] += aa[i]*bb[i+1]+gg[i]*P;\r
+               aa[i] = aa[i]*aa[i+1]+gg[i]*Q;\r
+       }\r
+       dual u0 = bb[0]/(1.-aa[0]);\r
+       for(long i=0;i<n;i++)   uu[i]=bb[i]+aa[i]*u0;\r
+}\r
+void MGL_NO_EXPORT mgl_progonka_hc(HCDT A, HCDT B, HCDT C, HCDT D, dual *dat, long n, long id, long i0, bool difr)\r
+{\r
+       dual *aa=dat, *bb=dat+n, *uu=dat+n*n;\r
+       dual b0=B->vcthr(i0), c0=C->vcthr(i0), d0=D->vcthr(id);\r
+       uu[0] = d0/b0*(difr?(2.-b0):1.);\r
+       b0=B->vcthr(i0+n*n-1);  d0=D->vcthr(id+n*n-1);\r
+       uu[n*n-1] = d0/b0*(difr?(2.-b0):1.);\r
+       long di = n-1, i1 = i0+n*(n-1), d1 = id+n*(n-1);\r
+       // suppose the square grid!\r
+       for(long j=1;j<n;j++)\r
+       {\r
+               // first bottom-left triangle\r
+               b0=B->vcthr(i0+j);      c0=C->vcthr(i0+j);      d0=D->vcthr(id+j);\r
+               if(difr)        d0 = (2.-b0)*d0-c0*D->vcthr(id+j+di);\r
+               aa[0] = -c0/b0; bb[0] = d0/b0;\r
+               for(long i=1;i<=j;i++)\r
+               {\r
+                       register long ii=i0+j+di*i, dd=id+j+di*i;\r
+                       dual a=A->vcthr(ii),b=B->vcthr(ii),c=C->vcthr(ii);\r
+                       dual d=difr?-a*D->vcthr(dd-di)+(2.-b)*D->vcthr(dd)-c*D->vcthr(dd+di):D->vcthr(dd);\r
+                       aa[i] = -c/(b+a*aa[i-1]);\r
+                       bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]);\r
+               }\r
+               uu[j+di*(j-1)] = bb[j];\r
+               for(long i=j-1;i>=0;i--)\r
+                       uu[j+di*i] = bb[i]+aa[i]*uu[j+di*i+di];\r
+               // next top-right triangle\r
+               long j1=n-1-j;\r
+               b0=B->vcthr(i1+j1);     c0=C->vcthr(i1+j1);     d0=D->vcthr(d1+j1);\r
+               if(difr)        d0 = (2.-b0)*d0-c0*D->vcthr(d1+j1-di);\r
+               aa[0] = -c0/b0; bb[0] = d0/b0;\r
+               for(long i=1;i<=j;i++)\r
+               {\r
+                       register long ii=i1+j1-di*i, dd=d1+j1-di*i;\r
+                       dual a=A->vcthr(ii),b=B->vcthr(ii),c=C->vcthr(ii);\r
+                       dual d=difr?-a*D->vcthr(dd+di)+(2.-b)*D->vcthr(dd)-c*D->vcthr(dd-di):D->vcthr(dd);\r
+                       aa[i] = -c/(b+a*aa[i-1]);\r
+                       bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]);\r
+               }\r
+               uu[j1+n*(n-1)-di*(j-1)] = bb[j];\r
+               for(long i=j-1;i>=0;i--)\r
+                       uu[j1+n*(n-1)-di*i] = bb[i]+aa[i]*uu[j1+n*(n-1)-di*i-di];\r
+       }\r
+}\r
+//-----------------------------------------------------------------------------\r
+HADT MGL_EXPORT mgl_datac_tridmat(HCDT A, HCDT B, HCDT C, HCDT D, const char *how)\r
+{\r
+       const long nx=D->GetNx(),ny=D->GetNy(),nz=D->GetNz();\r
+       const long nn=nx*ny*nz, np=nx*ny, na=A->GetNN();\r
+       if(B->GetNN()!=na || C->GetNN()!=na)    return 0;\r
+       mglDataC *r = new mglDataC(nx,ny,nz);\r
+       bool per = mglchr(how,'c');\r
+       bool difr = mglchr(how,'d');\r
+       if(mglchr(how,'x') && (na==nn || na==np || na==nx))\r
+#pragma omp parallel\r
+       {\r
+               mglDataC T(nx,4);       dual *uu=T.a+(per?3:2)*nx;\r
+#pragma omp for collapse(2)\r
+               for(long k=0;k<nz;k++)  for(long j=0;j<ny;j++)\r
+               {\r
+                       long i0=0, i1=nx*(j+ny*k);\r
+                       if(na==nn)      i0=i1;  else if(na==np) i0=nx*j;\r
+                       if(per) mgl_progonka_pc(A,B,C,D,T.a,nx,i1,i0,1,difr);\r
+                       else    mgl_progonka_sc(A,B,C,D,T.a,nx,i1,i0,1,difr);\r
+                       for(long i=0;i<nx;i++)  r->a[i+i1] = uu[i];\r
+               }\r
+       }\r
+       else if(mglchr(how,'y') && (na==nn || na==np || na==ny))\r
+#pragma omp parallel\r
+       {\r
+               mglDataC T(ny,4);       dual *uu=T.a+(per?3:2)*ny;\r
+#pragma omp for collapse(2)\r
+               for(long k=0;k<nz;k++)  for(long i=0;i<nx;i++)\r
+               {\r
+                       long i0=0, i1 = i+np*k;\r
+                       if(na==nn)      i0=i1;  else if(na==np) i0=i;\r
+                       if(per) mgl_progonka_pc(A,B,C,D,T.a,ny,i1,i0,nx,difr);\r
+                       else    mgl_progonka_sc(A,B,C,D,T.a,ny,i1,i0,nx,difr);\r
+                       i0 = i+np*k;\r
+                       for(long j=0;j<ny;j++)  r->a[j*nx+i0] = uu[j];\r
+               }\r
+       }\r
+       else if(mglchr(how,'z') && (na==nn || na==nz))\r
+#pragma omp parallel\r
+       {\r
+               mglDataC T(nz,4);       dual *uu=T.a+(per?3:2)*nz;\r
+#pragma omp for collapse(2)\r
+               for(long j=0;j<ny;j++)  for(long i=0;i<nx;i++)\r
+               {\r
+                       long i0 = na==nn?i+nx*j:0, i1 = i+nx*j;\r
+                       if(per) mgl_progonka_pc(A,B,C,D,T.a,nz,i1,i0,np,difr);\r
+                       else    mgl_progonka_sc(A,B,C,D,T.a,nz,i1,i0,np,difr);\r
+                       for(long k=0;k<nz;k++)  r->a[k*np+i1] = uu[k];\r
+               }\r
+       }\r
+       else if(mglchr(how,'h') && ny==nx && (na==nn || na==np) && nx>1)\r
+#pragma omp parallel\r
+       {\r
+               mglDataC T(np,2);\r
+#pragma omp for\r
+               for(long k=0;k<nz;k++)\r
+               {\r
+                       mgl_progonka_hc(A,B,C,D,T.a,nx,k*np, na==nn ? k*np:0,difr);\r
+                       memcpy(r->a+k*np, T.a+np, np*sizeof(dual));\r
+               }\r
+       }\r
+       else    {       delete r;       r=0;    }\r
+       return r;\r
+}\r
+//-----------------------------------------------------------------------------\r
+uintptr_t MGL_EXPORT mgl_datac_tridmat_(uintptr_t *A, uintptr_t *B, uintptr_t *C, uintptr_t *D, const char *how, int l)\r
+{      char *s=new char[l+1];  memcpy(s,how,l);        s[l]=0;\r
+       uintptr_t r = uintptr_t(mgl_datac_tridmat(_DA_(A),_DA_(B),_DA_(C),_DA_(D),s));\r
+       delete []s;     return r;\r
+}\r
+//-----------------------------------------------------------------------------\r
index 82ef44ccdbfd1178e40d2190743900a5fba76a44..60ded14bb4fe499516a9d0f14f57357591c7fbad 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * pixel.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -20,6 +20,9 @@
 #include <algorithm>\r
 #include "mgl2/canvas.h"\r
 #include "mgl2/thread.h"\r
+#if MGL_HAVE_OMP\r
+#include <omp.h>\r
+#endif\r
 \r
 inline mreal get_persp(float pf, float z, float Depth)\r
 //{    return (1-pf)/(1-pf*z/Depth);   }\r
@@ -46,7 +49,7 @@ void mglCanvas::SetSize(int w,int h,bool clf)
 #if MGL_HAVE_PTHREAD\r
        pthread_mutex_lock(&mutexClf);\r
 #elif MGL_HAVE_OMP\r
-       omp_set_lock(&lockClf);\r
+       omp_set_lock((omp_lock_t*)lockClf);\r
 #endif\r
        if(G)   {       delete []G;     delete []C;     delete []Z;     delete []G4;delete []GB;delete []OI;    G=0;    }\r
        G = new unsigned char[s*3];\r
@@ -60,7 +63,7 @@ void mglCanvas::SetSize(int w,int h,bool clf)
 #if MGL_HAVE_PTHREAD\r
        pthread_mutex_unlock(&mutexClf);\r
 #elif MGL_HAVE_OMP\r
-       omp_unset_lock(&lockClf);\r
+       omp_unset_lock((omp_lock_t*)lockClf);\r
 #endif\r
 \r
        InPlot(0,1,0,1,false);\r
@@ -71,7 +74,7 @@ void mglCanvas::SetSize(int w,int h,bool clf)
                pthread_mutex_lock(&mutexPnt);\r
                pthread_mutex_lock(&mutexClf);\r
 #elif MGL_HAVE_OMP\r
-               omp_set_lock(&lockClf);\r
+               omp_set_lock((omp_lock_t*)lockClf);\r
 #endif\r
                const long m = long(Prm.size());\r
                double dd = dx>dy?dy:dx;\r
@@ -115,7 +118,7 @@ void mglCanvas::SetSize(int w,int h,bool clf)
                pthread_mutex_unlock(&mutexClf);\r
                pthread_mutex_unlock(&mutexPnt);\r
 #elif MGL_HAVE_OMP\r
-               omp_unset_lock(&lockClf);\r
+               omp_unset_lock((omp_lock_t*)lockClf);\r
 #endif\r
                ClfZB();        Finish();\r
        }\r
@@ -672,7 +675,7 @@ void mglCanvas::Finish()
        pthread_mutex_lock(&mutexPnt);\r
        pthread_mutex_lock(&mutexClf);\r
 #elif MGL_HAVE_OMP\r
-       omp_set_lock(&lockClf);\r
+       omp_set_lock((omp_lock_t*)lockClf);\r
 #endif\r
        if(Quality==MGL_DRAW_DOTS)\r
        {\r
@@ -706,7 +709,7 @@ void mglCanvas::Finish()
        pthread_mutex_unlock(&mutexPnt);\r
        pthread_mutex_unlock(&mutexPrm);\r
 #elif MGL_HAVE_OMP\r
-       omp_unset_lock(&lockClf);\r
+       omp_unset_lock((omp_lock_t*)lockClf);\r
 #endif\r
 }\r
 //-----------------------------------------------------------------------------\r
@@ -912,7 +915,6 @@ void mglCanvas::combine(unsigned char *c1, const unsigned char *c2) const
        if(c2[3])\r
        {\r
                const register unsigned a1=c1[3], a2=c2[3];\r
-               if(a2==255 || a1==0)    {       memcpy(c1,c2,4);        return; }\r
                if((Flag&3)==0)\r
                {\r
                        register unsigned b1=255-a2;\r
@@ -931,10 +933,10 @@ void mglCanvas::combine(unsigned char *c1, const unsigned char *c2) const
                else if((Flag&3)==2)\r
                {\r
                        register unsigned b1,b2,b3;\r
-                       b1 = (c1[0]*a1 + c2[0]*a2)/256;         c1[0] = b1<255 ? b1 : 255;\r
-                       b2 = (c1[1]*a1 + c2[1]*a2)/256;         c1[1] = b2<255 ? b2 : 255;\r
-                       b3 = (c1[2]*a1 + c2[2]*a2)/256;         c1[2] = b3<255 ? b3 : 255;\r
-                       c1[3] = a1+a2>255? 255 : a1+a2;\r
+                       b1 = (c1[0]*a1 + c2[0]*a2)/255; c1[0] = b1<255 ? b1 : 255;\r
+                       b2 = (c1[1]*a1 + c2[1]*a2)/255; c1[1] = b2<255 ? b2 : 255;\r
+                       b3 = (c1[2]*a1 + c2[2]*a2)/255; c1[2] = b3<255 ? b3 : 255;\r
+                       c1[3] = 255;\r
                }\r
        }\r
 }\r
@@ -1193,7 +1195,7 @@ void mglCanvas::line_draw(const mglPnt &p1, const mglPnt &p2, const mglDrawReg *
                        if(u<0)                 v += u*u;\r
                        else if(u>dd)   v += (u-dd)*(u-dd);\r
 //                     if(v>pw*pw)             continue;\r
-                       if(!(pd & ( 1L<<long(fmod(pp+u/pw/1.5, 16)) ) ))        continue;\r
+                       if(!(pd & ((uint64_t)1<<long(fmod(pp+u/pw/1.5, 16)) ) ))        continue;\r
                        mglPnt p(p1+d*(u/dd));  col2int(p,r,oi);\r
                        r[3] = v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2));\r
                        pnt_plot(i,j,p.z+dz,r,oi);\r
@@ -1213,7 +1215,7 @@ void mglCanvas::line_draw(const mglPnt &p1, const mglPnt &p2, const mglDrawReg *
                        if(u<0)                 v += u*u;\r
                        else if(u>dd)   v += (u-dd)*(u-dd);\r
 //                     if(v>pw*pw)             continue;\r
-                       if(!(pd & (1L<<long(fmod(pp+u/pw/1.5, 16)))))           continue;\r
+                       if(!(pd & ((uint64_t)1<<long(fmod(pp+u/pw/1.5, 16)))))          continue;\r
                        mglPnt p(p1+d*(u/dd));  col2int(p,r,oi);\r
                        r[3] = v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2));\r
                        pnt_plot(i,j,p.z+dz,r,oi);\r
@@ -1270,7 +1272,7 @@ void mglCanvas::line_pix(long i, long j, const mglPnt &p1, const mglPnt &p2, con
        else if(u>dd)   v += (u-dd)*(u-dd);\r
        register float pw=dr->PenWidth, dpw=3*pen_delta;\r
        if(dr->ObjId==HighId)   {       pw *= 2;        dpw=2*pen_delta;        }\r
-       if(v>pw*pw || !(dr->PDef & ( 1L<<long(fmod(dr->pPos+u/pw/1.5, 16)) ) )) return;\r
+       if(v>pw*pw || !(dr->PDef & ( (uint64_t)1<<long(fmod(dr->pPos+u/pw/1.5, 16)) ) ))        return;\r
        mglPnt p(p1+d*(u/dd));\r
        unsigned char r[4];\r
        col2int(p,r,dr->ObjId);\r
index 4226c3133bd5f44eaa0ed1fb38bf581d70e1f4aa..30dc6bc1146f0a2f4819f18ef574d2f87ffa2ea7 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * plot.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -752,12 +752,13 @@ void MGL_EXPORT mgl_step_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const char *pen, c
 void MGL_EXPORT mgl_step_xy(HMGL gr, HCDT x, HCDT y, const char *pen, const char *opt)\r
 {\r
        long m,n=y->GetNx(), pal;\r
-       if(mgl_check_dim1(gr,x,y,0,0,"Step"))   return;\r
+       if(mgl_check_dim1(gr,x,y,0,0,"Step",true))      return;\r
 \r
        gr->SaveState(opt);\r
        static int cgid=1;      gr->StartGroup("Step",cgid++);\r
        m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy();\r
        bool sh = mglchr(pen,'!');\r
+       bool same = x->GetNx()==n;\r
 \r
        mreal zVal =gr->AdjustZMin();\r
        char mk=gr->SetPenPal(pen,&pal);        gr->Reserve(2*n*m);\r
@@ -767,21 +768,33 @@ void MGL_EXPORT mgl_step_xy(HMGL gr, HCDT x, HCDT y, const char *pen, const char
                if(gr->NeedStop())      break;\r
                long mx = j<x->GetNy() ? j:0, my = j<y->GetNy() ? j:0;\r
                gr->NextColor(pal);\r
-               long n1 = gr->AddPnt(mglPoint(x->v(0,mx), y->v(0,my), zVal));\r
+               mreal xx = x->v(0,mx);\r
+               long n1 = gr->AddPnt(mglPoint(same?xx:(xx+x->v(1,mx))/2, y->v(0,my), zVal));\r
                if(mk)  gr->mark_plot(n1,mk);\r
+               if(!same)       n1 = gr->AddPnt(mglPoint(xx, y->v(0,my), zVal));\r
                for(long i=1;i<n;i++)\r
                {\r
                        long n2 = n1;   // horizontal\r
-                       p.Set(x->v(i,mx), y->v(i-1,my), zVal);\r
+                       xx = x->v(i,mx);\r
+                       p.Set(xx, y->v(i-1,my), zVal);\r
                        mreal c = sh ? gr->NextColor(pal,i):gr->CDef;\r
                        n1 = gr->AddPnt(p,c);   gr->line_plot(n1,n2);\r
                        if(i==1)        gr->arrow_plot(n2,n1,gr->Arrow1);\r
 \r
                        n2 = n1;        // vertical\r
                        p.y = y->v(i,my);               n1 = gr->AddPnt(p,c);\r
-                       if(mk)  gr->mark_plot(n1,mk);\r
                        gr->line_plot(n1,n2);\r
-                       if(i==n-1)      gr->arrow_plot(n1,n2,gr->Arrow2);\r
+                       if(same && i==n-1)      gr->arrow_plot(n1,n2,gr->Arrow2);\r
+                       long nn = n1;\r
+                       if(!same)       nn = gr->AddPnt(mglPoint((xx+x->v(i+1,mx))/2, y->v(i,my), zVal));\r
+                       if(mk)  gr->mark_plot(nn,mk);\r
+               }\r
+               if(!same)\r
+               {\r
+                       p.Set(x->v(n,mx), y->v(n-1,my), zVal);\r
+                       mreal c = sh ? gr->NextColor(pal,n-1):gr->CDef;\r
+                       long n2 = gr->AddPnt(p,c);      gr->line_plot(n1,n2);\r
+                       gr->arrow_plot(n2,n1,gr->Arrow2);\r
                }\r
        }\r
        gr->EndGroup();\r
index 05496fbbdabced30974fef210721d1cefb99f118..e93dc02958ea2af47234936fcc035f498c48549d 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * prc.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 78ee1bdcd0aa4b19c51af3185b76e8c9c4e59fc3..2cfb92f0b1e8c53ab11a6812eb8e4a28f0460123 100644 (file)
@@ -18,6 +18,8 @@ typedef unsigned long uint32_t;
 #include <inttypes.h>
 #endif // _MSC_VER
 
+#include<mgl2/define.h>
+
 //const uint32_t PRCVersion=7094;   // For Adobe Reader 8 or later
 const uint32_t PRCVersion=8137; // For Adobe Reader 9 or later
 
index ec80c87885c3c743de9ef9050bb43ff8aca3a319..efec6be15c7905517022ac1ef04308b6d61b045e 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * prim.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index f9bb4180968b0823104573c50a2907c371314b68..2e632ec50a31a210da61708fc3b6d54d6ff82f89 100644 (file)
@@ -7,6 +7,7 @@
 #include <vector>
 #include <set>
 #include <limits>
+#include <mgl2/define.h>
 
 /*
        for use in s_hull_pro.cpp
index 288569d5549163ffbd30104dc16a05fd22481488..70bc15dbab54e2c030d5d3b056635dd4a47fc467 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * surf.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 6f277e65a8bd43e18b7923f579bc88fbadd0a791..86deba28bd475d631c4e18fbff411c4c92e07af1 100644 (file)
@@ -20,8 +20,8 @@
 #include "mgl2/font.h"
 
 /// Table of LaTeX symbols and its UTF8 codes. This array MUST BE sorted!!!
-MGL_EXPORT long mgl_tex_num=1924;
-MGL_EXPORT mglTeXsymb mgl_tex_symb[] = {
+const size_t mgl_tex_num=1924;
+const mglTeXsymb mgl_tex_symb[] = {
        {0x23, L"#"},
        {0x25, L"%"},
        {0x26, L"&"},
index 9ef80fa7bdd7f1b224b3252da61adf35b35ac052..ae98f7c6e6346d5266d784c47fc40fe950b30669 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * vect.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -498,23 +498,24 @@ void MGL_EXPORT mgl_vect3_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, uintptr_
 //     Flow 2d series\r
 //\r
 //-----------------------------------------------------------------------------\r
-void MGL_NO_EXPORT flow(mglBase *gr, double zVal, double u, double v, const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, long ss, bool vv)\r
+void MGL_NO_EXPORT flow(mglBase *gr, double zVal, double u, double v, HCDT x, HCDT y, HCDT ax, HCDT ay, long ss, bool vv)\r
 {\r
-       long n=100*(ax.nx+ax.ny);\r
-       bool nboth = x.nx*x.ny!=ax.nx*ax.ny || y.nx*y.ny!=ax.nx*ax.ny;\r
+       long n=100*(ax->GetNx()+ax->GetNy());\r
+       bool nboth = x->GetNx()*x->GetNy()!=ax->GetNx()*ax->GetNy() || y->GetNx()*y->GetNy()!=ax->GetNx()*ax->GetNy();\r
 \r
        mglPoint *pp = new mglPoint[n], dp;\r
        mglPoint dx(1/fabs(gr->Max.x-gr->Min.x),1/fabs(gr->Max.y-gr->Min.y),1/fabs(gr->Max.z-gr->Min.z));\r
-       mglPoint nx(ax.nx,ax.ny);\r
+       mglPoint nx(ax->GetNx(),ax->GetNy());\r
 \r
-       mreal dt = 0.5/(ax.nx > ax.ny ? ax.nx : ax.ny),e,f,g,ff[4],gg[4],h,s=2,acc=dt/20;\r
+       mreal dt = 0.5/(ax->GetNx() > ax->GetNy() ? ax->GetNx() : ax->GetNy());\r
+       mreal e,f,g,ff[4],gg[4],h,s=2,acc=dt/20;\r
        if(u<0 || v<0)  {       dt = -dt;       u = -u; v = -v; s *= -1;}\r
        long k=0;\r
        bool end = false;\r
        if(nboth) do{\r
                mglPoint dif;\r
-               pp[k].x = x.Spline1(dif,u,0,0); f = ax.Spline1(u,v,0)/dif.x;\r
-               pp[k].y = y.Spline1(dif,v,0,0); g = ay.Spline1(u,v,0)/dif.x;\r
+               pp[k].x = x->Spline1(dif,u,0,0);        f = ax->Spline1(u,v,0)/dif.x;\r
+               pp[k].y = y->Spline1(dif,v,0,0);        g = ay->Spline1(u,v,0)/dif.x;\r
                pp[k].z = zVal;\r
                if(mgl_isbad(f+g))      break;\r
                else    for(long m=0;m<k-1;m+=10)       // determines encircle\r
@@ -525,16 +526,16 @@ void MGL_NO_EXPORT flow(mglBase *gr, double zVal, double u, double v, const mglD
                // find next point by midpoint method\r
                h+=1;   ff[0]=f*dt/h;   gg[0]=g*dt/h;\r
                e = u+ff[0]/2;  h = v+gg[0]/2;\r
-               x.Spline1(dif,e,0,0);   f = ax.Spline1(e,h,0)/dif.x;\r
-               y.Spline1(dif,h,0,0);   g = ay.Spline1(e,h,0)/dif.x;\r
+               x->Spline1(dif,e,0,0);  f = ax->Spline1(e,h,0)/dif.x;\r
+               y->Spline1(dif,h,0,0);  g = ay->Spline1(e,h,0)/dif.x;\r
                h = 1+hypot(f,g);       ff[1]=f*dt/h;   gg[1]=g*dt/h;\r
                e = u+ff[1]/2;  h = v+gg[1]/2;\r
-               x.Spline1(dif,e,0,0);   f = ax.Spline1(e,h,0)/dif.x;\r
-               y.Spline1(dif,h,0,0);   g = ay.Spline1(e,h,0)/dif.x;\r
+               x->Spline1(dif,e,0,0);  f = ax->Spline1(e,h,0)/dif.x;\r
+               y->Spline1(dif,h,0,0);  g = ay->Spline1(e,h,0)/dif.x;\r
                h = 1+hypot(f,g);       ff[2]=f*dt/h;   gg[2]=g*dt/h;\r
                e = u+ff[2];    h = v+gg[2];\r
-               x.Spline1(dif,e,0,0);   f = ax.Spline1(e,h,0)/dif.x;\r
-               y.Spline1(dif,h,0,0);   g = ay.Spline1(e,h,0)/dif.x;\r
+               x->Spline1(dif,e,0,0);  f = ax->Spline1(e,h,0)/dif.x;\r
+               y->Spline1(dif,h,0,0);  g = ay->Spline1(e,h,0)/dif.x;\r
                h = 1+hypot(f,g);       ff[3]=f*dt/h;   gg[3]=g*dt/h;\r
                u += ff[0]/6+ff[1]/3+ff[2]/3+ff[3]/6;\r
                v += gg[0]/6+gg[1]/3+gg[2]/3+gg[3]/6;\r
@@ -544,9 +545,9 @@ void MGL_NO_EXPORT flow(mglBase *gr, double zVal, double u, double v, const mglD
        else do{\r
                mglPoint dif;\r
                register mreal xu,xv,yu,yv,det,xx,yy;\r
-               pp[k].x = x.Spline1(dif,u,v,0); xu=dif.x;       xv=dif.y;\r
-               pp[k].y = y.Spline1(dif,u,v,0); yu=dif.x;       yv=dif.y;\r
-               xx = ax.Spline1(u,v,0); yy = ay.Spline1(u,v,0);\r
+               pp[k].x = x->Spline1(dif,u,v,0);        xu=dif.x;       xv=dif.y;\r
+               pp[k].y = y->Spline1(dif,u,v,0);        yu=dif.x;       yv=dif.y;\r
+               xx = ax->Spline1(u,v,0);        yy = ay->Spline1(u,v,0);\r
                det = xv*yu-xu*yv;      f = (yy*xv-xx*yv)/det;  g = (xx*yu-yy*xu)/det;\r
                pp[k].z = zVal;\r
                if(mgl_isbad(f+g))      break;\r
@@ -558,21 +559,21 @@ void MGL_NO_EXPORT flow(mglBase *gr, double zVal, double u, double v, const mglD
                // find next point by midpoint method\r
                h+=1;   ff[0]=f*dt/h;   gg[0]=g*dt/h;\r
                e = u+ff[0]/2;  h = v+gg[0]/2;\r
-                       x.Spline1(dif,e,h,0);   xu=dif.x;       xv=dif.y;\r
-                       y.Spline1(dif,e,h,0);   yu=dif.x;       yv=dif.y;\r
-                       xx = ax.Spline1(e,h,0); yy = ay.Spline1(e,h,0);\r
+                       x->Spline1(dif,e,h,0);  xu=dif.x;       xv=dif.y;\r
+                       y->Spline1(dif,e,h,0);  yu=dif.x;       yv=dif.y;\r
+                       xx = ax->Spline1(e,h,0);        yy = ay->Spline1(e,h,0);\r
                        det = xv*yu-xu*yv;      f = (yy*xv-xx*yv)/det;  g = (xx*yu-yy*xu)/det;\r
                h = 1+hypot(f,g);       ff[1]=f*dt/h;   gg[1]=g*dt/h;\r
                e = u+ff[1]/2;  h = v+gg[1]/2;\r
-                       x.Spline1(dif,e,h,0);   xu=dif.x;       xv=dif.y;\r
-                       y.Spline1(dif,e,h,0);   yu=dif.x;       yv=dif.y;\r
-                       xx = ax.Spline1(e,h,0); yy = ay.Spline1(e,h,0);\r
+                       x->Spline1(dif,e,h,0);  xu=dif.x;       xv=dif.y;\r
+                       y->Spline1(dif,e,h,0);  yu=dif.x;       yv=dif.y;\r
+                       xx = ax->Spline1(e,h,0);        yy = ay->Spline1(e,h,0);\r
                        det = xv*yu-xu*yv;      f = (yy*xv-xx*yv)/det;  g = (xx*yu-yy*xu)/det;\r
                h = 1+hypot(f,g);       ff[2]=f*dt/h;   gg[2]=g*dt/h;\r
                e = u+ff[2];    h = v+gg[2];\r
-                       x.Spline1(dif,e,h,0);   xu=dif.x;       xv=dif.y;\r
-                       y.Spline1(dif,e,h,0);   yu=dif.x;       yv=dif.y;\r
-                       xx = ax.Spline1(e,h,0); yy = ay.Spline1(e,h,0);\r
+                       x->Spline1(dif,e,h,0);  xu=dif.x;       xv=dif.y;\r
+                       y->Spline1(dif,e,h,0);  yu=dif.x;       yv=dif.y;\r
+                       xx = ax->Spline1(e,h,0);        yy = ay->Spline1(e,h,0);\r
                        det = xv*yu-xu*yv;      f = (yy*xv-xx*yv)/det;  g = (xx*yu-yy*xu)/det;\r
                h = 1+hypot(f,g);       ff[3]=f*dt/h;   gg[3]=g*dt/h;\r
                u += ff[0]/6+ff[1]/3+ff[2]/3+ff[3]/6;\r
@@ -583,7 +584,7 @@ void MGL_NO_EXPORT flow(mglBase *gr, double zVal, double u, double v, const mglD
        if(k>1)\r
        {\r
                long j,a=long(0.3*gr->GetArrowSize()/fabs(dt));\r
-               gr->Reserve(k);         j = gr->AddPnt(pp[0],pp[0].c);\r
+               gr->Reserve(k); j = gr->AddPnt(pp[0],pp[0].c);\r
                for(long i=1;i<k;i++)\r
                {\r
                        long jj=j;      j = gr->AddPnt(pp[i],pp[i].c);\r
@@ -611,32 +612,42 @@ void MGL_EXPORT mgl_flow_xy(HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const cha
        // allocate memory\r
        mreal zVal = gr->Min.z;\r
        bool cnt=!mglchr(sch,'#');\r
-       mglData xx(x), yy(y), bx(ax), by(ay);\r
 \r
+       std::vector<mreal> u, v;\r
+       if(mglchr(sch,'*'))     for(long i=0;i<num;i++) for(long j=0;j<num;j++)\r
+       {\r
+               mreal t = (i+1.)/(num+1.), s = (j+1.)/(num+1.);\r
+               u.push_back(s);         v.push_back(t);\r
+               u.push_back(-s);        v.push_back(-t);\r
+       }\r
+       else    for(long i=0;i<num;i++)\r
+       {\r
+               mreal t = (i+1.)/(num+1.);\r
+               u.push_back(0);         v.push_back(t);\r
+               u.push_back(0);         v.push_back(-t);\r
+               u.push_back(1);         v.push_back(t);\r
+               u.push_back(-1);        v.push_back(-t);\r
+               u.push_back(t);         v.push_back(0);\r
+               u.push_back(-t);        v.push_back(0);\r
+               u.push_back(t);         v.push_back(1);\r
+               u.push_back(-t);        v.push_back(-1);\r
+               if(cnt)\r
+               {\r
+                       u.push_back(t);         v.push_back(0.5);\r
+                       u.push_back(-t);        v.push_back(-0.5);\r
+                       u.push_back(0.5);       v.push_back(t);\r
+                       u.push_back(-0.5);      v.push_back(-t);\r
+               }\r
+       }\r
        for(long k=0;k<ax->GetNz();k++)\r
        {\r
                if(gr->NeedStop())      break;\r
                if(ax->GetNz()>1)       zVal = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(k)/(ax->GetNz()-1);\r
-               for(long i=0;i<num;i++) for(int s=-1;s<=1;s+=2)\r
-               {\r
-                       mreal u,v;\r
-                       if(gr->NeedStop())      {       i=num;  s=2;    continue;       }\r
-                       u = 0;  v = (i+1.)/(num+1.);\r
-                       flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv);\r
-                       u = 1;  v = (i+1.)/(num+1.);\r
-                       flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv);\r
-                       u = (i+1.)/(num+1.);    v = 0;\r
-                       flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv);\r
-                       u = (i+1.)/(num+1.);    v = 1;\r
-                       flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv);\r
-                       if(cnt)\r
-                       {\r
-                               u = 0.5;        v = (i+1.)/(num+1.);\r
-                               flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv);\r
-                               u = (i+1.)/(num+1.);    v = 0.5;\r
-                               flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv);\r
-                       }\r
-               }\r
+               HMDT bx=mgl_data_subdata(ax,-1,-1,k), by=mgl_data_subdata(ay,-1,-1,k);\r
+#pragma omp parallel for\r
+               for(long i=0;i<long(u.size());i++)      if(!gr->NeedStop())\r
+                       flow(gr, zVal, u[i], v[i], x, y, bx, by,ss,vv);\r
+               mgl_delete_data(bx);    mgl_delete_data(by);\r
        }\r
        gr->EndGroup();\r
 }\r
@@ -701,8 +712,7 @@ void MGL_EXPORT mgl_flowp_xy(HMGL gr, double x0, double y0, double z0, HCDT x, H
                        v = (j0-(dxu*dy-dx*dyu)/d)/m;\r
                }\r
        }\r
-       mglData xx(x), yy(y), bx(ax), by(ay);\r
-       flow(gr, z0, u, v, xx, yy, bx, by,ss,vv);\r
+       flow(gr, z0, u, v, x, y, ax, ay,ss,vv);\r
        gr->EndGroup();\r
 }\r
 //-----------------------------------------------------------------------------\r
@@ -729,17 +739,17 @@ void MGL_EXPORT mgl_flowp_2d_(uintptr_t *gr, mreal *x0, mreal *y0, mreal *z0, ui
 //     Flow 3d series\r
 //\r
 //-----------------------------------------------------------------------------\r
-void flow(mglBase *gr, double u, double v, double w, const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az,long ss,bool vv, bool xo, bool zo)\r
+void flow(mglBase *gr, double u, double v, double w, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az,long ss,bool vv, bool xo, bool zo)\r
 {\r
-       static long n=100*(ax.nx+ax.ny+ax.nz);\r
-       long nn = ax.nx*ax.ny*ax.nz;\r
-       bool nboth = x.nx*x.ny*x.nz!=nn || y.nx*y.ny*y.nz!=nn || z.nx*z.ny*z.nz!=nn;\r
+       static long n=100*(ax->GetNx()+ax->GetNy()+ax->GetNz());\r
+       long nn = ax->GetNN();\r
+       bool nboth = x->GetNN()!=nn || y->GetNN()!=nn || z->GetNN()!=nn;\r
        mglPoint *pp = new mglPoint[n], dp;\r
        mglPoint dx(1/fabs(gr->Max.x-gr->Min.x),1/fabs(gr->Max.y-gr->Min.y),1/fabs(gr->Max.z-gr->Min.z));\r
-       mglPoint nx(ax.nx,ax.ny,ax.nz);\r
+       mglPoint nx(ax->GetNx(),ax->GetNy(),ax->GetNz());\r
 \r
-       nn = (ax.nx > ax.ny ? ax.nx : ax.ny);\r
-       nn = (nn > ax.nz ? nn : ax.nz);\r
+       nn = (ax->GetNx() > ax->GetNy() ? ax->GetNz() : ax->GetNy());\r
+       nn = (nn > ax->GetNz() ? nn : ax->GetNz());\r
        mreal dt = 0.2/nn, e,f,g,ee[4],ff[4],gg[4],h,s=2,u1,v1,w1,acc=dt/20;\r
        if(u<0 || v<0 || w<0)\r
        {       dt = -dt;       u = -u; v = -v; w = -w; s *= -1;}\r
@@ -747,9 +757,9 @@ void flow(mglBase *gr, double u, double v, double w, const mglData &x, const mgl
        bool end = false;\r
        if(nboth) do{\r
                mglPoint dif;\r
-               pp[k].x = x.Spline1(dif,u,0,0); e = ax.Spline1(u,v,w)/dif.x;\r
-               pp[k].y = y.Spline1(dif,v,0,0); f = ay.Spline1(u,v,w)/dif.x;\r
-               pp[k].z = z.Spline1(dif,w,0,0); g = az.Spline1(u,v,w)/dif.x;\r
+               pp[k].x = x->Spline1(dif,u,0,0);        e = ax->Spline1(u,v,w)/dif.x;\r
+               pp[k].y = y->Spline1(dif,v,0,0);        f = ay->Spline1(u,v,w)/dif.x;\r
+               pp[k].z = z->Spline1(dif,w,0,0);        g = az->Spline1(u,v,w)/dif.x;\r
                if(mgl_isbad(e+f+g))    end = true;\r
                else    for(long m=0;m<k-1;m+=10)       // determines encircle\r
                        if(mgl_anorm((pp[k]-pp[m])/dx)<acc)     end = true;\r
@@ -760,21 +770,21 @@ void flow(mglBase *gr, double u, double v, double w, const mglData &x, const mgl
                // find next point by midpoint method\r
                h+=1;   ee[0]=e*dt/h;   ff[0]=f*dt/h;   gg[0]=g*dt/h;\r
                u1 = u+ee[0]/2; v1 = v+ff[0]/2; w1 = w+gg[0]/2;\r
-               x.Spline1(dif,u1,0,0);  e = ax.Spline1(u1,v1,w1)/dif.x;\r
-               y.Spline1(dif,v1,0,0);  f = ay.Spline1(u1,v1,w1)/dif.x;\r
-               z.Spline1(dif,w1,0,0);  g = az.Spline1(u1,v1,w1)/dif.x;\r
+               x->Spline1(dif,u1,0,0); e = ax->Spline1(u1,v1,w1)/dif.x;\r
+               y->Spline1(dif,v1,0,0); f = ay->Spline1(u1,v1,w1)/dif.x;\r
+               z->Spline1(dif,w1,0,0); g = az->Spline1(u1,v1,w1)/dif.x;\r
                h = 1+sqrt(e*e+f*f+g*g);\r
                ee[1]=e*dt/h;   ff[1]=f*dt/h;   gg[1]=g*dt/h;\r
                u1 = u+ee[1]/2; v1 = v+ff[1]/2; w1 = w+gg[1]/2;\r
-               x.Spline1(dif,u1,0,0);  e = ax.Spline1(u1,v1,w1)/dif.x;\r
-               y.Spline1(dif,v1,0,0);  f = ay.Spline1(u1,v1,w1)/dif.x;\r
-               z.Spline1(dif,w1,0,0);  g = az.Spline1(u1,v1,w1)/dif.x;\r
+               x->Spline1(dif,u1,0,0); e = ax->Spline1(u1,v1,w1)/dif.x;\r
+               y->Spline1(dif,v1,0,0); f = ay->Spline1(u1,v1,w1)/dif.x;\r
+               z->Spline1(dif,w1,0,0); g = az->Spline1(u1,v1,w1)/dif.x;\r
                h = 1+sqrt(e*e+f*f+g*g);\r
                ee[2]=e*dt/h;   ff[2]=f*dt/h;   gg[2]=g*dt/h;\r
                u1 = u+ee[2];   v1 = v+ff[2];   w1 = w+gg[2];\r
-               x.Spline1(dif,u1,0,0);  e = ax.Spline1(u1,v1,w1)/dif.x;\r
-               y.Spline1(dif,v1,0,0);  f = ay.Spline1(u1,v1,w1)/dif.x;\r
-               z.Spline1(dif,w1,0,0);  g = az.Spline1(u1,v1,w1)/dif.x;\r
+               x->Spline1(dif,u1,0,0); e = ax->Spline1(u1,v1,w1)/dif.x;\r
+               y->Spline1(dif,v1,0,0); f = ay->Spline1(u1,v1,w1)/dif.x;\r
+               z->Spline1(dif,w1,0,0); g = az->Spline1(u1,v1,w1)/dif.x;\r
                h = 1+sqrt(e*e+f*f+g*g);\r
                ee[3]=e*dt/h;   ff[3]=f*dt/h;   gg[3]=g*dt/h;\r
                u += ee[0]/6+ee[1]/3+ee[2]/3+ee[3]/6;\r
@@ -786,10 +796,10 @@ void flow(mglBase *gr, double u, double v, double w, const mglData &x, const mgl
        else do{\r
                mglPoint dif;\r
                register mreal xu,xv,xw,yu,yv,yw,zv,zu,zw,det,xx,yy,zz;\r
-               pp[k].x = x.Spline1(dif,u,v,w); xu=dif.x;       xv=dif.y;       xw=dif.z;\r
-               pp[k].y = y.Spline1(dif,u,v,w); yu=dif.x;       yv=dif.y;       yw=dif.z;\r
-               pp[k].z = z.Spline1(dif,u,v,w); zu=dif.x;       zv=dif.y;       zw=dif.z;\r
-               xx = ax.Spline1(u,v,w); yy = ay.Spline1(u,v,w); zz = az.Spline1(u,v,w);\r
+               pp[k].x = x->Spline1(dif,u,v,w);        xu=dif.x;       xv=dif.y;       xw=dif.z;\r
+               pp[k].y = y->Spline1(dif,u,v,w);        yu=dif.x;       yv=dif.y;       yw=dif.z;\r
+               pp[k].z = z->Spline1(dif,u,v,w);        zu=dif.x;       zv=dif.y;       zw=dif.z;\r
+               xx = ax->Spline1(u,v,w);        yy = ay->Spline1(u,v,w);        zz = az->Spline1(u,v,w);\r
                det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu;\r
                e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det;\r
                f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det;\r
@@ -804,9 +814,9 @@ void flow(mglBase *gr, double u, double v, double w, const mglData &x, const mgl
                // find next point by midpoint method\r
                h+=1;   ee[0]=e*dt/h;   ff[0]=f*dt/h;   gg[0]=g*dt/h;\r
                u1 = u+ee[0]/2; v1 = v+ff[0]/2; w1 = w+gg[0]/2;\r
-               x.Spline1(dif,u1,v1,w1);        xu=dif.x;       xv=dif.y;       xw=dif.z;       xx = ax.Spline1(u1,v1,w1);\r
-               y.Spline1(dif,u1,v1,w1);        yu=dif.x;       yv=dif.y;       yw=dif.z;       yy = ay.Spline1(u1,v1,w1);\r
-               z.Spline1(dif,u1,v1,w1);        zu=dif.x;       zv=dif.y;       zw=dif.z;       zz = az.Spline1(u1,v1,w1);\r
+               x->Spline1(dif,u1,v1,w1);       xu=dif.x;       xv=dif.y;       xw=dif.z;       xx = ax->Spline1(u1,v1,w1);\r
+               y->Spline1(dif,u1,v1,w1);       yu=dif.x;       yv=dif.y;       yw=dif.z;       yy = ay->Spline1(u1,v1,w1);\r
+               z->Spline1(dif,u1,v1,w1);       zu=dif.x;       zv=dif.y;       zw=dif.z;       zz = az->Spline1(u1,v1,w1);\r
                det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu;\r
                e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det;\r
                f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det;\r
@@ -814,9 +824,9 @@ void flow(mglBase *gr, double u, double v, double w, const mglData &x, const mgl
                h = 1+sqrt(e*e+f*f+g*g);\r
                ee[1]=e*dt/h;   ff[1]=f*dt/h;   gg[1]=g*dt/h;\r
                u1 = u+ee[1]/2; v1 = v+ff[1]/2; w1 = w+gg[1]/2;\r
-               x.Spline1(dif,u1,v1,w1);        xu=dif.x;       xv=dif.y;       xw=dif.z;       xx = ax.Spline1(u1,v1,w1);\r
-               y.Spline1(dif,u1,v1,w1);        yu=dif.x;       yv=dif.y;       yw=dif.z;       yy = ay.Spline1(u1,v1,w1);\r
-               z.Spline1(dif,u1,v1,w1);        zu=dif.x;       zv=dif.y;       zw=dif.z;       zz = az.Spline1(u1,v1,w1);\r
+               x->Spline1(dif,u1,v1,w1);       xu=dif.x;       xv=dif.y;       xw=dif.z;       xx = ax->Spline1(u1,v1,w1);\r
+               y->Spline1(dif,u1,v1,w1);       yu=dif.x;       yv=dif.y;       yw=dif.z;       yy = ay->Spline1(u1,v1,w1);\r
+               z->Spline1(dif,u1,v1,w1);       zu=dif.x;       zv=dif.y;       zw=dif.z;       zz = az->Spline1(u1,v1,w1);\r
                det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu;\r
                e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det;\r
                f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det;\r
@@ -824,9 +834,9 @@ void flow(mglBase *gr, double u, double v, double w, const mglData &x, const mgl
                h = 1+sqrt(e*e+f*f+g*g);\r
                ee[2]=e*dt/h;   ff[2]=f*dt/h;   gg[2]=g*dt/h;\r
                u1 = u+ee[2];   v1 = v+ff[2];   w1 = w+gg[2];\r
-               x.Spline1(dif,u1,v1,w1);        xu=dif.x;       xv=dif.y;       xw=dif.z;       xx = ax.Spline1(u1,v1,w1);\r
-               y.Spline1(dif,u1,v1,w1);        yu=dif.x;       yv=dif.y;       yw=dif.z;       yy = ay.Spline1(u1,v1,w1);\r
-               z.Spline1(dif,u1,v1,w1);        zu=dif.x;       zv=dif.y;       zw=dif.z;       zz = az.Spline1(u1,v1,w1);\r
+               x->Spline1(dif,u1,v1,w1);       xu=dif.x;       xv=dif.y;       xw=dif.z;       xx = ax->Spline1(u1,v1,w1);\r
+               y->Spline1(dif,u1,v1,w1);       yu=dif.x;       yv=dif.y;       yw=dif.z;       yy = ay->Spline1(u1,v1,w1);\r
+               z->Spline1(dif,u1,v1,w1);       zu=dif.x;       zv=dif.y;       zw=dif.z;       zz = az->Spline1(u1,v1,w1);\r
                det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu;\r
                e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det;\r
                f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det;\r
@@ -885,33 +895,37 @@ void MGL_EXPORT mgl_flow_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay,
        long ss = gr->AddTexture(sch);\r
        bool vv = mglchr(sch,'v'), xo = mglchr(sch,'x'), zo = mglchr(sch,'z');\r
 \r
-       mglData xx(x), yy(y), zz(z), bx(ax), by(ay), bz(az);\r
-       for(long i=0;i<num;i++) for(long j=0;j<num;j++) for(int s=-1;s<=1;s+=2)\r
+       std::vector<mreal> u, v, w;\r
+       for(long i=0;i<num;i++) for(long j=0;j<num;j++)\r
        {\r
-               mreal u,v,w;\r
-               if(gr->NeedStop())      {       i=j=num;        s=2;    continue;       }\r
-               u = (i+1.)/(num+1.);    v = (j+1.)/(num+1.);    w = 0;\r
-               flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo);\r
-               u = (i+1.)/(num+1.);    v = (j+1.)/(num+1.);    w = 1;\r
-               flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo);\r
-               u = 0;  v = (j+1.)/(num+1.);    w = (i+1.)/(num+1.);\r
-               flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo);\r
-               u = 1;  v = (j+1.)/(num+1.);    w = (i+1.)/(num+1.);\r
-               flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo);\r
-               u = (i+1.)/(num+1.);    v = 0;  w = (j+1.)/(num+1.);\r
-               flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo);\r
-               u = (i+1.)/(num+1.);    v = 1;  w = (j+1.)/(num+1.);\r
-               flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo);\r
+               mreal t = (i+1.)/(num+1.), s = (j+1.)/(num+1.);\r
+               u.push_back(t);         v.push_back(s);         w.push_back(0);\r
+               u.push_back(-t);        v.push_back(-s);        w.push_back(0);\r
+               u.push_back(t);         v.push_back(s);         w.push_back(1);\r
+               u.push_back(-t);        v.push_back(-s);        w.push_back(-1);\r
+\r
+               u.push_back(t);         v.push_back(0);         w.push_back(s);\r
+               u.push_back(-t);        v.push_back(0);         w.push_back(-s);\r
+               u.push_back(t);         v.push_back(1);         w.push_back(s);\r
+               u.push_back(-t);        v.push_back(-1);        w.push_back(-s);\r
+\r
+               u.push_back(0);         v.push_back(s);         w.push_back(t);\r
+               u.push_back(0);         v.push_back(-s);        w.push_back(-t);\r
+               u.push_back(1);         v.push_back(s);         w.push_back(t);\r
+               u.push_back(-1);        v.push_back(-s);        w.push_back(-t);\r
                if(cnt)\r
                {\r
-                       u = (i+1.)/(num+1.);    v = (j+1.)/(num+1.);    w = 0.5;\r
-                       flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo);\r
-                       u = 0.5;        v = (j+1.)/(num+1.);    w = (i+1.)/(num+1.);\r
-                       flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo);\r
-                       u = (i+1.)/(num+1.);    v = 0.5;        w = (j+1.)/(num+1.);\r
-                       flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo);\r
+                       u.push_back(t);         v.push_back(s);         w.push_back(0.5);\r
+                       u.push_back(-t);        v.push_back(-s);        w.push_back(-0.5);\r
+                       u.push_back(t);         v.push_back(0.5);       w.push_back(s);\r
+                       u.push_back(-t);        v.push_back(-0.5);      w.push_back(-s);\r
+                       u.push_back(0.5);       v.push_back(s);         w.push_back(t);\r
+                       u.push_back(-0.5);      v.push_back(-s);        w.push_back(-t);\r
                }\r
        }\r
+#pragma omp parallel for\r
+       for(long i=0;i<long(u.size());i++)      if(!gr->NeedStop())\r
+               flow(gr, u[i], v[i], w[i], x, y, z, ax, ay, az,ss,vv,xo,zo);\r
        gr->EndGroup();\r
 }\r
 //-----------------------------------------------------------------------------\r
@@ -984,8 +998,7 @@ void MGL_EXPORT mgl_flowp_xyz(HMGL gr, double x0, double y0, double z0, HCDT x,
                        w = (i0+(dx*(dyv*dzu-dyu*dzv)+dxu*(dy*dzv-dyv*dz)+dxv*(dyu*dz-dy*dzu))/d)/l;\r
                }\r
        }\r
-       mglData xx(x), yy(y), zz(z), bx(ax), by(ay), bz(az);\r
-       flow(gr, u, v, w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo);\r
+       flow(gr, u, v, w, x, y, z, ax, ay, az,ss,vv,xo,zo);\r
        gr->EndGroup();\r
 }\r
 //-----------------------------------------------------------------------------\r
@@ -1075,25 +1088,25 @@ void MGL_EXPORT mgl_grad_(uintptr_t *gr, uintptr_t *ph, const char *sch, const c
 //     Pipe 2d series\r
 //\r
 //-----------------------------------------------------------------------------\r
-void MGL_NO_EXPORT flowr(mglBase *gr, double zVal, double u, double v, const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, double r0,long sc)\r
+void MGL_NO_EXPORT flowr(mglBase *gr, double zVal, double u, double v, HCDT x, HCDT y, HCDT ax, HCDT ay, double r0,long sc)\r
 {\r
-       long n=100*(ax.nx+ax.ny);\r
-       bool nboth = x.nx*x.ny!=ax.nx*ax.ny || y.nx*y.ny!=ax.nx*ax.ny;\r
+       long n=100*(ax->GetNx()+ax->GetNy());\r
+       bool nboth = x->GetNx()*x->GetNy()!=ax->GetNx()*ax->GetNy() || y->GetNx()*y->GetNy()!=ax->GetNx()*ax->GetNy();\r
 \r
        mglPoint *pp = new mglPoint[n], dp;\r
        mreal *cc = new mreal[n];\r
        mglPoint dx(1/fabs(gr->Max.x-gr->Min.x),1/fabs(gr->Max.y-gr->Min.y),1/fabs(gr->Max.z-gr->Min.z));\r
-       mglPoint nx(ax.nx,ax.ny);\r
+       mglPoint nx(ax->GetNx(),ax->GetNy());\r
 \r
-       mreal dt = 0.5/(ax.nx > ax.ny ? ax.nx : ax.ny),e,f,g,ff[4],gg[4],h,s=2,acc=dt/20;\r
+       mreal dt = 0.5/(ax->GetNx() > ax->GetNy() ? ax->GetNx() : ax->GetNy()),e,f,g,ff[4],gg[4],h,s=2,acc=dt/20;\r
        mreal ss = 16./mgl_ipow(gr->Max.c - gr->Min.c,2);\r
        if(u<0 || v<0)  {       dt = -dt;       u = -u; v = -v; s *= -1;}\r
        long k=0;\r
        bool end = false;\r
        if(nboth) do{\r
                mglPoint dif;\r
-               pp[k].x = x.Spline1(dif,u,0,0); f = ax.Spline1(u,v,0)/dif.x;\r
-               pp[k].y = y.Spline1(dif,v,0,0); g = ay.Spline1(u,v,0)/dif.x;\r
+               pp[k].x = x->Spline1(dif,u,0,0);        f = ax->Spline1(u,v,0)/dif.x;\r
+               pp[k].y = y->Spline1(dif,v,0,0);        g = ay->Spline1(u,v,0)/dif.x;\r
                pp[k].z = zVal;\r
                if(mgl_isbad(f+g))      end = true;\r
                else    for(long m=0;m<k-1;m+=10)       // determines encircle\r
@@ -1106,16 +1119,16 @@ void MGL_NO_EXPORT flowr(mglBase *gr, double zVal, double u, double v, const mgl
                // find next point by midpoint method\r
                h+=1;   ff[0]=f*dt/h;   gg[0]=g*dt/h;\r
                e = u+ff[0]/2;  h = v+gg[0]/2;\r
-               x.Spline1(dif,e,0,0);   f = ax.Spline1(e,h,0)/dif.x;\r
-               y.Spline1(dif,h,0,0);   g = ay.Spline1(e,h,0)/dif.x;\r
+               x->Spline1(dif,e,0,0);  f = ax->Spline1(e,h,0)/dif.x;\r
+               y->Spline1(dif,h,0,0);  g = ay->Spline1(e,h,0)/dif.x;\r
                h = 1+hypot(f,g);       ff[1]=f*dt/h;   gg[1]=g*dt/h;\r
                e = u+ff[1]/2;  h = v+gg[1]/2;\r
-               x.Spline1(dif,e,0,0);   f = ax.Spline1(e,h,0)/dif.x;\r
-               y.Spline1(dif,h,0,0);   g = ay.Spline1(e,h,0)/dif.x;\r
+               x->Spline1(dif,e,0,0);  f = ax->Spline1(e,h,0)/dif.x;\r
+               y->Spline1(dif,h,0,0);  g = ay->Spline1(e,h,0)/dif.x;\r
                h = 1+hypot(f,g);       ff[2]=f*dt/h;   gg[2]=g*dt/h;\r
                e = u+ff[2];    h = v+gg[2];\r
-               x.Spline1(dif,e,0,0);   f = ax.Spline1(e,h,0)/dif.x;\r
-               y.Spline1(dif,h,0,0);   g = ay.Spline1(e,h,0)/dif.x;\r
+               x->Spline1(dif,e,0,0);  f = ax->Spline1(e,h,0)/dif.x;\r
+               y->Spline1(dif,h,0,0);  g = ay->Spline1(e,h,0)/dif.x;\r
                h = 1+hypot(f,g);       ff[3]=f*dt/h;   gg[3]=g*dt/h;\r
                u += ff[0]/6+ff[1]/3+ff[2]/3+ff[3]/6;\r
                v += gg[0]/6+gg[1]/3+gg[2]/3+gg[3]/6;\r
@@ -1125,9 +1138,9 @@ void MGL_NO_EXPORT flowr(mglBase *gr, double zVal, double u, double v, const mgl
        else do{\r
                mglPoint dif;\r
                register mreal xu,xv,yu,yv,det,xx,yy;\r
-                       pp[k].x = x.Spline1(dif,u,v,0); xu=dif.x;       xv=dif.y;\r
-                       pp[k].y = y.Spline1(dif,u,v,0); yu=dif.x;       yv=dif.y;\r
-                       xx = ax.Spline1(u,v,0); yy = ay.Spline1(u,v,0);\r
+                       pp[k].x = x->Spline1(dif,u,v,0);        xu=dif.x;       xv=dif.y;\r
+                       pp[k].y = y->Spline1(dif,u,v,0);        yu=dif.x;       yv=dif.y;\r
+                       xx = ax->Spline1(u,v,0);        yy = ay->Spline1(u,v,0);\r
                        det = xv*yu-xu*yv;      f = (yy*xv-xx*yv)/det;  g = (xx*yu-yy*xu)/det;\r
                pp[k].z = zVal;\r
                if(mgl_isbad(f+g))      end = true;\r
@@ -1141,21 +1154,21 @@ void MGL_NO_EXPORT flowr(mglBase *gr, double zVal, double u, double v, const mgl
                // find next point by midpoint method\r
                h+=1;   ff[0]=f*dt/h;   gg[0]=g*dt/h;\r
                e = u+ff[0]/2;  h = v+gg[0]/2;\r
-                       x.Spline1(dif,e,h,0);   xu=dif.x;       xv=dif.y;\r
-                       y.Spline1(dif,e,h,0);   yu=dif.x;       yv=dif.y;\r
-                       xx = ax.Spline1(e,h,0); yy = ay.Spline1(e,h,0);\r
+                       x->Spline1(dif,e,h,0);  xu=dif.x;       xv=dif.y;\r
+                       y->Spline1(dif,e,h,0);  yu=dif.x;       yv=dif.y;\r
+                       xx = ax->Spline1(e,h,0);        yy = ay->Spline1(e,h,0);\r
                        det = xv*yu-xu*yv;      f = (yy*xv-xx*yv)/det;  g = (xx*yu-yy*xu)/det;\r
                h = 1+hypot(f,g);       ff[1]=f*dt/h;   gg[1]=g*dt/h;\r
                e = u+ff[1]/2;  h = v+gg[1]/2;\r
-                       x.Spline1(dif,e,h,0);   xu=dif.x;       xv=dif.y;\r
-                       y.Spline1(dif,e,h,0);   yu=dif.x;       yv=dif.y;\r
-                       xx = ax.Spline1(e,h,0); yy = ay.Spline1(e,h,0);\r
+                       x->Spline1(dif,e,h,0);  xu=dif.x;       xv=dif.y;\r
+                       y->Spline1(dif,e,h,0);  yu=dif.x;       yv=dif.y;\r
+                       xx = ax->Spline1(e,h,0);        yy = ay->Spline1(e,h,0);\r
                        det = xv*yu-xu*yv;      f = (yy*xv-xx*yv)/det;  g = (xx*yu-yy*xu)/det;\r
                h = 1+hypot(f,g);       ff[2]=f*dt/h;   gg[2]=g*dt/h;\r
                e = u+ff[2];    h = v+gg[2];\r
-                       x.Spline1(dif,e,h,0);   xu=dif.x;       xv=dif.y;\r
-                       y.Spline1(dif,e,h,0);   yu=dif.x;       yv=dif.y;\r
-                       xx = ax.Spline1(e,h,0); yy = ay.Spline1(e,h,0);\r
+                       x->Spline1(dif,e,h,0);  xu=dif.x;       xv=dif.y;\r
+                       y->Spline1(dif,e,h,0);  yu=dif.x;       yv=dif.y;\r
+                       xx = ax->Spline1(e,h,0);        yy = ay->Spline1(e,h,0);\r
                        det = xv*yu-xu*yv;      f = (yy*xv-xx*yv)/det;  g = (xx*yu-yy*xu)/det;\r
                h = 1+hypot(f,g);       ff[3]=f*dt/h;   gg[3]=g*dt/h;\r
                u += ff[0]/6+ff[1]/3+ff[2]/3+ff[3]/6;\r
@@ -1216,31 +1229,41 @@ void MGL_EXPORT mgl_pipe_xy(HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const cha
        bool cnt=!mglchr(sch,'#');\r
        if(mglchr(sch,'i'))     r0 = -fabs(r0);\r
 \r
-       mglData xx(x), yy(y), bx(ax), by(ay);\r
+       std::vector<mreal> u, v;\r
+       if(mglchr(sch,'*'))     for(long i=0;i<num;i++) for(long j=0;j<num;j++)\r
+       {\r
+               mreal t = (i+1.)/(num+1.), s = (j+1.)/(num+1.);\r
+               u.push_back(s);         v.push_back(t);\r
+               u.push_back(-s);                v.push_back(-t);\r
+       }\r
+       else    for(long i=0;i<num;i++)\r
+       {\r
+               mreal t = (i+1.)/(num+1.);\r
+               u.push_back(0);         v.push_back(t);\r
+               u.push_back(0);         v.push_back(-t);\r
+               u.push_back(1);         v.push_back(t);\r
+               u.push_back(-1);        v.push_back(-t);\r
+               u.push_back(t);         v.push_back(0);\r
+               u.push_back(-t);        v.push_back(0);\r
+               u.push_back(t);         v.push_back(1);\r
+               u.push_back(-t);        v.push_back(-1);\r
+               if(cnt)\r
+               {\r
+                       u.push_back(t);         v.push_back(0.5);\r
+                       u.push_back(-t);        v.push_back(-0.5);\r
+                       u.push_back(0.5);       v.push_back(t);\r
+                       u.push_back(-0.5);      v.push_back(-t);\r
+               }\r
+       }\r
        for(long k=0;k<ax->GetNz();k++)\r
        {\r
                if(gr->NeedStop())      break;\r
                if(ax->GetNz()>1)       zVal = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(k)/(ax->GetNz()-1);\r
-               for(long i=0;i<num;i++) for(int s=-1;s<=1;s+=2)\r
-               {\r
-                       mreal u,v;\r
-                       if(gr->NeedStop())      {       i=num;  s=2;    continue;       }\r
-                       u = 0;  v = (i+1.)/(num+1.);\r
-                       flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss);\r
-                       u = 1;  v = (i+1.)/(num+1.);\r
-                       flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss);\r
-                       u = (i+1.)/(num+1.);    v = 0;\r
-                       flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss);\r
-                       u = (i+1.)/(num+1.);    v = 1;\r
-                       flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss);\r
-                       if(cnt)\r
-                       {\r
-                               u = 0.5;        v = (i+1.)/(num+1.);\r
-                               flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss);\r
-                               u = (i+1.)/(num+1.);    v = 0.5;\r
-                               flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss);\r
-                       }\r
-               }\r
+               HMDT bx=mgl_data_subdata(ax,-1,-1,k), by=mgl_data_subdata(ay,-1,-1,k);\r
+#pragma omp parallel for\r
+               for(long i=0;i<long(u.size());i++)      if(!gr->NeedStop())\r
+                       flowr(gr, zVal, u[i], v[i], x, y, bx, by,r0,ss);\r
+               mgl_delete_data(bx);    mgl_delete_data(by);\r
        }\r
        gr->EndGroup();\r
 }\r
@@ -1267,18 +1290,18 @@ void MGL_EXPORT mgl_pipe_2d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, const
 //     Pipe 3d series\r
 //\r
 //-----------------------------------------------------------------------------\r
-void flowr(mglBase *gr, double u, double v, double w, const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, double r0,long sc)\r
+void flowr(mglBase *gr, double u, double v, double w, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, double r0,long sc)\r
 {\r
-       static long n=100*(ax.nx+ax.ny+ax.nz);\r
-       long nn = ax.nx*ax.ny*ax.nz;\r
-       bool nboth = x.nx*x.ny*x.nz!=nn || y.nx*y.ny*y.nz!=nn || z.nx*z.ny*z.nz!=nn;\r
+       static long n=100*(ax->GetNx()+ax->GetNy()+ax->GetNz());\r
+       long nn = ax->GetNN();\r
+       bool nboth = x->GetNN()!=nn || y->GetNN()!=nn || z->GetNN()!=nn;\r
        mglPoint *pp = new mglPoint[n], dp;\r
        mreal *cc = new mreal[n];\r
        mglPoint dx(1/fabs(gr->Max.x-gr->Min.x),1/fabs(gr->Max.y-gr->Min.y),1/fabs(gr->Max.z-gr->Min.z));\r
-       mglPoint nx(ax.nx,ax.ny,ax.nz);\r
+       mglPoint nx(ax->GetNx(),ax->GetNy(),ax->GetNz());\r
 \r
-       nn = (ax.nx > ax.ny ? ax.nx : ax.ny);\r
-       nn = (nn > ax.nz ? nn : ax.nz);\r
+       nn = (ax->GetNx() > ax->GetNy() ? ax->GetNx() : ax->GetNy());\r
+       nn = (nn > ax->GetNz() ? nn : ax->GetNz());\r
        mreal dt = 0.2/nn, e,f,g,ee[4],ff[4],gg[4],h,s=2,u1,v1,w1,acc=dt/20;\r
        mreal ss = 16./mgl_ipow(gr->Max.c - gr->Min.c,2);\r
 \r
@@ -1288,9 +1311,9 @@ void flowr(mglBase *gr, double u, double v, double w, const mglData &x, const mg
        bool end = false;\r
        if(nboth) do{\r
                mglPoint dif;\r
-               pp[k].x = x.Spline1(dif,u,0,0); e = ax.Spline1(u,v,w)/dif.x;\r
-               pp[k].y = y.Spline1(dif,v,0,0); f = ay.Spline1(u,v,w)/dif.x;\r
-               pp[k].z = z.Spline1(dif,w,0,0); g = az.Spline1(u,v,w)/dif.x;\r
+               pp[k].x = x->Spline1(dif,u,0,0);        e = ax->Spline1(u,v,w)/dif.x;\r
+               pp[k].y = y->Spline1(dif,v,0,0);        f = ay->Spline1(u,v,w)/dif.x;\r
+               pp[k].z = z->Spline1(dif,w,0,0);        g = az->Spline1(u,v,w)/dif.x;\r
                if(mgl_isbad(e+f+g))    end = true;\r
                else    for(long m=0;m<k-1;m+=10)       // determines encircle\r
                        if(mgl_anorm((pp[k]-pp[m])/dx)<acc)     end = true;\r
@@ -1302,21 +1325,21 @@ void flowr(mglBase *gr, double u, double v, double w, const mglData &x, const mg
                // find next point by midpoint method\r
                h+=1;   ee[0]=e*dt/h;   ff[0]=f*dt/h;   gg[0]=g*dt/h;\r
                u1 = u+ee[0]/2; v1 = v+ff[0]/2; w1 = w+gg[0]/2;\r
-               x.Spline1(dif,u1,0,0);  e = ax.Spline1(u1,v1,w1)/dif.x;\r
-               y.Spline1(dif,v1,0,0);  f = ay.Spline1(u1,v1,w1)/dif.x;\r
-               z.Spline1(dif,w1,0,0);  g = az.Spline1(u1,v1,w1)/dif.x;\r
+               x->Spline1(dif,u1,0,0); e = ax->Spline1(u1,v1,w1)/dif.x;\r
+               y->Spline1(dif,v1,0,0); f = ay->Spline1(u1,v1,w1)/dif.x;\r
+               z->Spline1(dif,w1,0,0); g = az->Spline1(u1,v1,w1)/dif.x;\r
                h = 1+sqrt(e*e+f*f+g*g);\r
                ee[1]=e*dt/h;   ff[1]=f*dt/h;   gg[1]=g*dt/h;\r
                u1 = u+ee[1]/2; v1 = v+ff[1]/2; w1 = w+gg[1]/2;\r
-               x.Spline1(dif,u1,0,0);  e = ax.Spline1(u1,v1,w1)/dif.x;\r
-               y.Spline1(dif,v1,0,0);  f = ay.Spline1(u1,v1,w1)/dif.x;\r
-               z.Spline1(dif,w1,0,0);  g = az.Spline1(u1,v1,w1)/dif.x;\r
+               x->Spline1(dif,u1,0,0); e = ax->Spline1(u1,v1,w1)/dif.x;\r
+               y->Spline1(dif,v1,0,0); f = ay->Spline1(u1,v1,w1)/dif.x;\r
+               z->Spline1(dif,w1,0,0); g = az->Spline1(u1,v1,w1)/dif.x;\r
                h = 1+sqrt(e*e+f*f+g*g);\r
                ee[2]=e*dt/h;   ff[2]=f*dt/h;   gg[2]=g*dt/h;\r
                u1 = u+ee[2];   v1 = v+ff[2];   w1 = w+gg[2];\r
-               x.Spline1(dif,u1,0,0);  e = ax.Spline1(u1,v1,w1)/dif.x;\r
-               y.Spline1(dif,v1,0,0);  f = ay.Spline1(u1,v1,w1)/dif.x;\r
-               z.Spline1(dif,w1,0,0);  g = az.Spline1(u1,v1,w1)/dif.x;\r
+               x->Spline1(dif,u1,0,0); e = ax->Spline1(u1,v1,w1)/dif.x;\r
+               y->Spline1(dif,v1,0,0); f = ay->Spline1(u1,v1,w1)/dif.x;\r
+               z->Spline1(dif,w1,0,0); g = az->Spline1(u1,v1,w1)/dif.x;\r
                h = 1+sqrt(e*e+f*f+g*g);\r
                ee[3]=e*dt/h;   ff[3]=f*dt/h;   gg[3]=g*dt/h;\r
                u += ee[0]/6+ee[1]/3+ee[2]/3+ee[3]/6;\r
@@ -1328,10 +1351,10 @@ void flowr(mglBase *gr, double u, double v, double w, const mglData &x, const mg
        else do{\r
                mglPoint dif;\r
                register mreal xu,xv,xw,yu,yv,yw,zv,zu,zw,det,xx,yy,zz;\r
-               pp[k].x = x.Spline1(dif,u,v,w); xu=dif.x;       xv=dif.y;       xw=dif.z;\r
-               pp[k].y = y.Spline1(dif,u,v,w); yu=dif.x;       yv=dif.y;       yw=dif.z;\r
-               pp[k].z = z.Spline1(dif,u,v,w); zu=dif.x;       zv=dif.y;       zw=dif.z;\r
-               xx = ax.Spline1(u,v,w); yy = ay.Spline1(u,v,w); zz = az.Spline1(u,v,w);\r
+               pp[k].x = x->Spline1(dif,u,v,w);        xu=dif.x;       xv=dif.y;       xw=dif.z;\r
+               pp[k].y = y->Spline1(dif,u,v,w);        yu=dif.x;       yv=dif.y;       yw=dif.z;\r
+               pp[k].z = z->Spline1(dif,u,v,w);        zu=dif.x;       zv=dif.y;       zw=dif.z;\r
+               xx = ax->Spline1(u,v,w);        yy = ay->Spline1(u,v,w);        zz = az->Spline1(u,v,w);\r
                det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu;\r
                e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det;\r
                f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det;\r
@@ -1347,9 +1370,9 @@ void flowr(mglBase *gr, double u, double v, double w, const mglData &x, const mg
                // find next point by midpoint method\r
                h+=1;   ee[0]=e*dt/h;   ff[0]=f*dt/h;   gg[0]=g*dt/h;\r
                u1 = u+ee[0]/2; v1 = v+ff[0]/2; w1 = w+gg[0]/2;\r
-               x.Spline1(dif,u1,v1,w1);        xu=dif.x;       xv=dif.y;       xw=dif.z;       xx = ax.Spline1(u1,v1,w1);\r
-               y.Spline1(dif,u1,v1,w1);        yu=dif.x;       yv=dif.y;       yw=dif.z;       yy = ay.Spline1(u1,v1,w1);\r
-               z.Spline1(dif,u1,v1,w1);        zu=dif.x;       zv=dif.y;       zw=dif.z;       zz = az.Spline1(u1,v1,w1);\r
+               x->Spline1(dif,u1,v1,w1);       xu=dif.x;       xv=dif.y;       xw=dif.z;       xx = ax->Spline1(u1,v1,w1);\r
+               y->Spline1(dif,u1,v1,w1);       yu=dif.x;       yv=dif.y;       yw=dif.z;       yy = ay->Spline1(u1,v1,w1);\r
+               z->Spline1(dif,u1,v1,w1);       zu=dif.x;       zv=dif.y;       zw=dif.z;       zz = az->Spline1(u1,v1,w1);\r
                det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu;\r
                e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det;\r
                f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det;\r
@@ -1357,9 +1380,9 @@ void flowr(mglBase *gr, double u, double v, double w, const mglData &x, const mg
                h = 1+sqrt(e*e+f*f+g*g);\r
                ee[1]=e*dt/h;   ff[1]=f*dt/h;   gg[1]=g*dt/h;\r
                u1 = u+ee[1]/2; v1 = v+ff[1]/2; w1 = w+gg[1]/2;\r
-               x.Spline1(dif,u1,v1,w1);        xu=dif.x;       xv=dif.y;       xw=dif.z;       xx = ax.Spline1(u1,v1,w1);\r
-               y.Spline1(dif,u1,v1,w1);        yu=dif.x;       yv=dif.y;       yw=dif.z;       yy = ay.Spline1(u1,v1,w1);\r
-               z.Spline1(dif,u1,v1,w1);        zu=dif.x;       zv=dif.y;       zw=dif.z;       zz = az.Spline1(u1,v1,w1);\r
+               x->Spline1(dif,u1,v1,w1);       xu=dif.x;       xv=dif.y;       xw=dif.z;       xx = ax->Spline1(u1,v1,w1);\r
+               y->Spline1(dif,u1,v1,w1);       yu=dif.x;       yv=dif.y;       yw=dif.z;       yy = ay->Spline1(u1,v1,w1);\r
+               z->Spline1(dif,u1,v1,w1);       zu=dif.x;       zv=dif.y;       zw=dif.z;       zz = az->Spline1(u1,v1,w1);\r
                det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu;\r
                e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det;\r
                f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det;\r
@@ -1367,9 +1390,9 @@ void flowr(mglBase *gr, double u, double v, double w, const mglData &x, const mg
                h = 1+sqrt(e*e+f*f+g*g);\r
                ee[2]=e*dt/h;   ff[2]=f*dt/h;   gg[2]=g*dt/h;\r
                u1 = u+ee[2];   v1 = v+ff[2];   w1 = w+gg[2];\r
-               x.Spline1(dif,u1,v1,w1);        xu=dif.x;       xv=dif.y;       xw=dif.z;       xx = ax.Spline1(u1,v1,w1);\r
-               y.Spline1(dif,u1,v1,w1);        yu=dif.x;       yv=dif.y;       yw=dif.z;       yy = ay.Spline1(u1,v1,w1);\r
-               z.Spline1(dif,u1,v1,w1);        zu=dif.x;       zv=dif.y;       zw=dif.z;       zz = az.Spline1(u1,v1,w1);\r
+               x->Spline1(dif,u1,v1,w1);       xu=dif.x;       xv=dif.y;       xw=dif.z;       xx = ax->Spline1(u1,v1,w1);\r
+               y->Spline1(dif,u1,v1,w1);       yu=dif.x;       yv=dif.y;       yw=dif.z;       yy = ay->Spline1(u1,v1,w1);\r
+               z->Spline1(dif,u1,v1,w1);       zu=dif.x;       zv=dif.y;       zw=dif.z;       zz = az->Spline1(u1,v1,w1);\r
                det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu;\r
                e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det;\r
                f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det;\r
@@ -1433,33 +1456,37 @@ void MGL_EXPORT mgl_pipe_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay,
        long ss = gr->AddTexture(sch);\r
        bool cnt=!mglchr(sch,'#');\r
 \r
-       mglData xx(x), yy(y), zz(z), bx(ax), by(ay), bz(az);\r
-       for(long i=0;i<num;i++) for(long j=0;j<num;j++) for(int s=-1;s<=1;s+=2)\r
+       std::vector<mreal> u, v, w;\r
+       for(long i=0;i<num;i++) for(long j=0;j<num;j++)\r
        {\r
-               mreal u,v,w;\r
-               if(gr->NeedStop())      {       i=j=num;        s=2;    continue;       }\r
-               u = (i+1.)/(num+1.);    v = (j+1.)/(num+1.);    w = 0;\r
-               flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss);\r
-               u = (i+1.)/(num+1.);    v = (j+1.)/(num+1.);    w = 1;\r
-               flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss);\r
-               u = 0;  v = (j+1.)/(num+1.);    w = (i+1.)/(num+1.);\r
-               flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss);\r
-               u = 1;  v = (j+1.)/(num+1.);    w = (i+1.)/(num+1.);\r
-               flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss);\r
-               u = (i+1.)/(num+1.);    v = 0;  w = (j+1.)/(num+1.);\r
-               flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss);\r
-               u = (i+1.)/(num+1.);    v = 1;  w = (j+1.)/(num+1.);\r
-               flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss);\r
+               mreal t = (i+1.)/(num+1.), s = (j+1.)/(num+1.);\r
+               u.push_back(t);         v.push_back(s);         w.push_back(0);\r
+               u.push_back(-t);        v.push_back(-s);        w.push_back(0);\r
+               u.push_back(t);         v.push_back(s);         w.push_back(1);\r
+               u.push_back(-t);        v.push_back(-s);        w.push_back(-1);\r
+\r
+               u.push_back(t);         v.push_back(0);         w.push_back(s);\r
+               u.push_back(-t);        v.push_back(0);         w.push_back(-s);\r
+               u.push_back(t);         v.push_back(1);         w.push_back(s);\r
+               u.push_back(-t);        v.push_back(-1);        w.push_back(-s);\r
+\r
+               u.push_back(0);         v.push_back(s);         w.push_back(t);\r
+               u.push_back(0);         v.push_back(-s);        w.push_back(-t);\r
+               u.push_back(1);         v.push_back(s);         w.push_back(t);\r
+               u.push_back(-1);        v.push_back(-s);        w.push_back(-t);\r
                if(cnt)\r
                {\r
-                       u = (i+1.)/(num+1.);    v = (j+1.)/(num+1.);    w = 0.5;\r
-                       flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss);\r
-                       u = 0.5;        v = (j+1.)/(num+1.);    w = (i+1.)/(num+1.);\r
-                       flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss);\r
-                       u = (i+1.)/(num+1.);    v = 0.5;        w = (j+1.)/(num+1.);\r
-                       flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss);\r
+                       u.push_back(t);         v.push_back(s);         w.push_back(0.5);\r
+                       u.push_back(-t);        v.push_back(-s);        w.push_back(-0.5);\r
+                       u.push_back(t);         v.push_back(0.5);       w.push_back(s);\r
+                       u.push_back(-t);        v.push_back(-0.5);      w.push_back(-s);\r
+                       u.push_back(0.5);       v.push_back(s);         w.push_back(t);\r
+                       u.push_back(-0.5);      v.push_back(-s);        w.push_back(-t);\r
                }\r
        }\r
+#pragma omp parallel for\r
+       for(long i=0;i<long(u.size());i++)      if(!gr->NeedStop())\r
+               flowr(gr, u[i], v[i], w[i], x, y, z, ax, ay, az,r0,ss);\r
        gr->EndGroup();\r
 }\r
 //-----------------------------------------------------------------------------\r
index a6090a5d28274ff90aadb4480a497a7c9d4b89f0..f34bb688604cad142e9d94d00843e3eba115cde8 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * surf.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -22,7 +22,6 @@
 #include "mgl2/data.h"\r
 #include "mgl2/eval.h"\r
 #include "mgl2/base.h"\r
-//#include <vector>\r
 //-----------------------------------------------------------------------------\r
 //\r
 //     CloudQ series\r
@@ -108,6 +107,21 @@ void MGL_EXPORT mgl_cloud_(uintptr_t *gr, uintptr_t *a, const char *sch, const c
 //     Surf3 series\r
 //\r
 //-----------------------------------------------------------------------------\r
+mreal MGL_NO_EXPORT mgl_get_norm(mreal x, mreal d1, mreal d2, mreal d3)\r
+{\r
+       mreal nx = d1*(1-x) + d2*x;\r
+       if(mgl_isbad(nx))\r
+       {\r
+               nx = d1*(1+x) - d3*x;\r
+               if(mgl_isbad(nx))\r
+               {\r
+                       if(mgl_isfin(d1))       nx = d1;\r
+                       if(mgl_isfin(d2))       nx = d2;\r
+                       if(mgl_isfin(d3))       nx = d3;\r
+               }\r
+       }\r
+       return nx;\r
+}\r
 mglPoint MGL_NO_EXPORT mgl_normal_3d(HCDT a, mglPoint p, bool inv, long n,long m,long l)\r
 {\r
        register long i,j,k;\r
@@ -117,18 +131,17 @@ mglPoint MGL_NO_EXPORT mgl_normal_3d(HCDT a, mglPoint p, bool inv, long n,long m
        i = i<n-1 ? i:n-2;      j = j<m-1 ? j:m-2;      k = k<l-1 ? k:l-2;\r
        x-=i;   y-=j;   z-=k;\r
 \r
-       nx = a->dvx(i,j,k)*(1-x) + a->dvx(i+1,j,k)*x;\r
-       ny = a->dvy(i,j,k)*(1-y) + a->dvy(i,j+1,k)*y;\r
-       nz = a->dvz(i,j,k)*(1-z) + a->dvz(i,j,k+1)*z;\r
+       nx = mgl_get_norm(x, a->dvx(i,j,k), a->dvx(i+1,j,k), i>0?a->dvx(i-1,j,k):NAN);\r
+       ny = mgl_get_norm(y, a->dvy(i,j,k), a->dvy(i,j+1,k), j>0?a->dvy(i,j-1,k):NAN);\r
+       nz = mgl_get_norm(z, a->dvz(i,j,k), a->dvz(i,j,k+1), k>0?a->dvz(i,j,k-1):NAN);\r
        return inv ? mglPoint(nx,ny,nz) : mglPoint(-nx,-ny,-nz);\r
 }\r
 //-----------------------------------------------------------------------------\r
-mreal MGL_NO_EXPORT mgl_normal_1d(HCDT a, mreal x, bool inv, long n)\r
+mreal MGL_NO_EXPORT mgl_normal_1d(HCDT a, mreal x, long n)\r
 {\r
-       register long i=long(x);        x-=i;\r
-       mreal nx = a->dvx(i);\r
-       if(i<n-1)       nx = nx*(1-x) + a->dvx(i+1)*x;\r
-       return inv ? nx : -nx;\r
+       register long i=long(x);\r
+       i = i<n-1 ? i:n-2;      x-=i;\r
+       return mgl_get_norm(x, a->dvx(i), a->dvx(i+1), i>0?a->dvx(i-1):NAN);\r
 }\r
 //-----------------------------------------------------------------------------\r
 mglPoint MGL_NO_EXPORT mgl_find_norm(bool nboth, HCDT x, HCDT y, HCDT z, HCDT a, mglPoint u, bool inv, long n,long m,long l)\r
@@ -136,9 +149,9 @@ mglPoint MGL_NO_EXPORT mgl_find_norm(bool nboth, HCDT x, HCDT y, HCDT z, HCDT a,
        mglPoint s = mgl_normal_3d(a,u,inv,n,m,l), t, q;\r
        if(nboth)\r
        {\r
-               q.x = s.x/mgl_normal_1d(x,u.x,true,n);\r
-               q.y = s.y/mgl_normal_1d(y,u.y,true,m);\r
-               q.z = s.z/mgl_normal_1d(z,u.z,true,l);\r
+               q.x = s.x/mgl_normal_1d(x,u.x,n);\r
+               q.y = s.y/mgl_normal_1d(y,u.y,m);\r
+               q.z = s.z/mgl_normal_1d(z,u.z,l);\r
        }\r
        else\r
        {\r
@@ -262,6 +275,7 @@ void MGL_NO_EXPORT mgl_surf3ca_gen(HMGL gr, double val, HCDT x, HCDT y, HCDT z,
                {\r
                        register long i1 = i+n*j;\r
                        mreal a0 = a->v(i,j,k);\r
+                       if(mgl_isnan(a0))       continue;\r
                        if(i<n-1)\r
                        {\r
                                mreal d = mgl_d(val,a0,a->v(i+1,j,k));\r
@@ -275,7 +289,7 @@ void MGL_NO_EXPORT mgl_surf3ca_gen(HMGL gr, double val, HCDT x, HCDT y, HCDT z,
                                {       ky2[i1] = kk.size();    kk.push_back(mglPoint(i,j+d,k));        }\r
                        }\r
                        if(k>0)\r
-                       {       \r
+                       {\r
                                mreal d = mgl_d(val,a->v(i,j,k-1),a0);\r
                                if(d>=0 && d<1)\r
                                {       kz[i1] = kk.size();             kk.push_back(mglPoint(i,j,k+d-1));      }\r
@@ -285,36 +299,38 @@ void MGL_NO_EXPORT mgl_surf3ca_gen(HMGL gr, double val, HCDT x, HCDT y, HCDT z,
                if(b && c)      for(size_t i=kk1;i<kk.size();i++)\r
                {\r
                        mglPoint &u = kk[i];\r
-                       u.c = gr->AddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) : \r
+                       mreal cc = c->linear(u.x,u.y,u.z), bb = b->linear(u.x,u.y,u.z);\r
+                       if(mgl_isnan(cc) || mgl_isnan(bb))      u.c = -1;       else\r
+                       u.c = gr->AddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) :\r
                                        mglPoint(x->linear(u.x,u.y,u.z),y->linear(u.x,u.y,u.z),z->linear(u.x,u.y,u.z)),\r
-                                       gr->GetC(ss,c->linear(u.x,u.y,u.z)),\r
-                                       mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l),\r
-                                       gr->GetA(b->linear(u.x,u.y,u.z)));\r
+                                       gr->GetC(ss,cc), mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l), gr->GetA(bb));\r
                }\r
                else if(c)      for(size_t i=kk1;i<kk.size();i++)\r
                {\r
                        mglPoint &u = kk[i];\r
-                       u.c = gr->AddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) : \r
+                       mreal cc = c->linear(u.x,u.y,u.z);\r
+                       if(mgl_isnan(cc))       u.c = -1;       else\r
+                       u.c = gr->AddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) :\r
                                        mglPoint(x->linear(u.x,u.y,u.z),y->linear(u.x,u.y,u.z),z->linear(u.x,u.y,u.z)),\r
-                                       gr->GetC(ss,c->linear(u.x,u.y,u.z)),\r
-                                       mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l));\r
+                                       gr->GetC(ss,cc), mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l));\r
                }\r
                else if(b)      for(size_t i=kk1;i<kk.size();i++)\r
                {\r
                        mglPoint &u = kk[i];\r
-                       u.c = gr->AddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) : \r
+                       mreal bb = b->linear(u.x,u.y,u.z);\r
+                       if(mgl_isnan(bb))       u.c = -1;       else\r
+                       u.c = gr->AddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) :\r
                                        mglPoint(x->linear(u.x,u.y,u.z),y->linear(u.x,u.y,u.z),z->linear(u.x,u.y,u.z)),\r
-                                       cv, mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l),\r
-                                       gr->GetA(b->linear(u.x,u.y,u.z)));\r
+                                       cv, mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l), gr->GetA(bb));\r
                }\r
                else    for(size_t i=kk1;i<kk.size();i++)\r
                {\r
                        mglPoint &u = kk[i];\r
-                       u.c = gr->AddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) : \r
+                       u.c = gr->AddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) :\r
                                        mglPoint(x->linear(u.x,u.y,u.z),y->linear(u.x,u.y,u.z),z->linear(u.x,u.y,u.z)),\r
                                        cv, mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l));\r
                }\r
-               \r
+\r
                if(k>0) mgl_surf3_plot(gr,n,m,kx1,kx2,ky1,ky2,kz,kk,wire);\r
        }\r
        delete []kx1;   delete []kx2;   delete []ky1;\r
@@ -408,20 +424,21 @@ void MGL_EXPORT mgl_surf3a_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, HCDT b,
        long num = mgl_isnan(r)?3:long(r+0.5);\r
        if(b->GetNx()==num && b->GetNy()==1 && b->GetNz()==1)\r
        {\r
-               mreal v,a0=gr->AlphaDef;\r
+               mreal a0=gr->AlphaDef;\r
                for(long i=0;i<num;i++)\r
                {\r
-                       v = gr->Max.c + (gr->Min.c-gr->Max.c)*(i+1.)/(num+1);\r
+                       mreal v = gr->Max.c + (gr->Min.c-gr->Max.c)*(i+1.)/(num+1);\r
                        gr->AlphaDef = gr->GetA(b->v(i));\r
                        mgl_surf3_xyz_val(gr,v,x,y,z,a,sch,0);\r
                }\r
                gr->AlphaDef = a0;\r
        }\r
-       else for(long i=0;i<num;i++)\r
-       {\r
-               mreal v = gr->Max.c + (gr->Min.c-gr->Max.c)*(i+1.)/(num+1);\r
-               mgl_surf3a_xyz_val(gr,v,x,y,z,a,b,sch,0);\r
-       }\r
+       else\r
+               for(long i=0;i<num;i++)\r
+               {\r
+                       mreal v = gr->Max.c + (gr->Min.c-gr->Max.c)*(i+1.)/(num+1);\r
+                       mgl_surf3a_xyz_val(gr,v,x,y,z,a,b,sch,0);\r
+               }\r
        gr->LoadState();\r
 }\r
 //-----------------------------------------------------------------------------\r
@@ -604,50 +621,43 @@ void MGL_EXPORT mgl_beam_val(HMGL gr, double val, HCDT tr, HCDT g1, HCDT g2, HCD
        if(tr->GetNx()<3 || tr->GetNy()<n || g1->GetNx()<3 || g1->GetNy()<n || g2->GetNx()<3 || g2->GetNy()<n)\r
        {       gr->SetWarn(mglWarnDim,"Beam"); return; }\r
        mglData x(a),y(a),z(a),b(a);\r
-       register long i,j,k,i0;\r
        mreal asum0=1;  r = fabs(r);\r
-       if(flag & 4)    for(j=0;j<m*l;j++)      asum0 += a->vthr(j)*a->vthr(j);\r
+       if(flag & 4)    for(long j=0;j<m*l;j++) asum0 += a->vthr(j)*a->vthr(j);\r
        if(asum0==0)    {       gr->SetWarn(mglWarnZero,"Beam");        return; }\r
-       for(i=0;i<n;i++)\r
+#pragma omp parallel for\r
+       for(long i=0;i<n;i++)\r
        {\r
-               if(gr->NeedStop())      break;\r
+               if(gr->NeedStop())      continue;\r
                if(flag & 4)\r
                {\r
                        mreal asum=0, amax=0;\r
-                       for(j=0;j<m*l;j++)\r
+                       for(long j=0;j<m*l;j++)\r
                        {\r
                                register mreal aa = a->vthr(j+m*l*i);\r
                                asum += aa*aa;  amax = amax>aa ? amax : aa;\r
                        }\r
                        amax = amax?sqrt(asum/asum0)/amax:0;\r
-#pragma omp parallel for\r
-                       for(j=0;j<m*l;j++)      b.a[j+m*l*i] = b.a[j+m*l*i]*amax;\r
+                       for(long j=0;j<m*l;j++) b.a[j+m*l*i] = b.a[j+m*l*i]*amax;\r
+               }\r
+               if(flag & 1)    for(long j=0;j<m;j++)   for(long k=0;k<l;k++)\r
+               {\r
+                       register long i0 = j+m*(k+l*i);\r
+                       x.a[i0] = 2*j/(m-1.)-1;\r
+                       y.a[i0] = 2*k/(l-1.)-1;\r
+                       z.a[i0] = gr->Max.z*i/(n-1.);\r
+               }\r
+               else    for(long j=0;j<m;j++)   for(long k=0;k<l;k++)\r
+               {\r
+                       register long i0 = j+m*(k+l*i);\r
+                       x.a[i0] = tr->v(0,i) + g1->v(0,i)*(2*j/(m-1.)-1)*r + g2->v(0,i)*(2*k/(l-1.)-1)*r;\r
+                       y.a[i0] = tr->v(1,i) + g1->v(1,i)*(2*j/(m-1.)-1)*r + g2->v(1,i)*(2*k/(l-1.)-1)*r;\r
+                       z.a[i0] = tr->v(2,i) + g1->v(2,i)*(2*j/(m-1.)-1)*r + g2->v(2,i)*(2*k/(l-1.)-1)*r;\r
+               }\r
+               if(flag & 2)    for(long j=0;j<m;j++)   for(long k=0;k<l;k++)\r
+               {\r
+                       register long i0 = j+m*(k+l*i);\r
+                       x.a[i0] = hypot(x.a[i0],y.a[i0]);\r
                }\r
-               if(flag & 1)\r
-#pragma omp parallel for collapse(2)\r
-                       for(j=0;j<m;j++)        for(k=0;k<l;k++)\r
-                       {\r
-                               i0 = j+m*(k+l*i);\r
-                               x.a[i0] = 2*j/(m-1.)-1;\r
-                               y.a[i0] = 2*k/(l-1.)-1;\r
-                               z.a[i0] = gr->Max.z*i/(n-1.);\r
-                       }\r
-               else\r
-#pragma omp parallel for collapse(2)\r
-                       for(j=0;j<m;j++)        for(k=0;k<l;k++)\r
-                       {\r
-                               i0 = j+m*(k+l*i);\r
-                               x.a[i0] = tr->v(0,i) + g1->v(0,i)*(2*j/(m-1.)-1)*r + g2->v(0,i)*(2*k/(l-1.)-1)*r;\r
-                               y.a[i0] = tr->v(1,i) + g1->v(1,i)*(2*j/(m-1.)-1)*r + g2->v(1,i)*(2*k/(l-1.)-1)*r;\r
-                               z.a[i0] = tr->v(2,i) + g1->v(2,i)*(2*j/(m-1.)-1)*r + g2->v(2,i)*(2*k/(l-1.)-1)*r;\r
-                       }\r
-               if(flag & 2)\r
-#pragma omp parallel for collapse(2)\r
-                       for(j=0;j<m;j++)        for(k=0;k<l;k++)\r
-                       {\r
-                               long i0 = j+m*(k+l*i);\r
-                               x.a[i0] = hypot(x.a[i0],y.a[i0]);\r
-                       }\r
        }\r
        mgl_surf3_xyz_val(gr,val,&x,&y,&z,&b,stl,0);\r
 }\r
index 1f0001bfc9c89f981f95f34a3d6eedd7dc0d10a4..ca5b9b9991d9fca41222ad9d0a8d7fb746fccf35 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * window.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -86,20 +86,24 @@ void mglCanvasWnd::DelFrame(long i)
 //-----------------------------------------------------------------------------\r
 void mglCanvasWnd::SetDrawFunc(int (*draw)(mglBase *gr, void *p), void *par, void (*reload)(void *p))\r
 {\r
-       ResetFrames();\r
-       if(get(MGL_CLF_ON_UPD)) DefaultPlotParam();\r
-       const std::string loc = setlocale(LC_NUMERIC, NULL);    setlocale(LC_NUMERIC, "C");\r
-       // use frames for quickly redrawing while adding/changing primitives\r
-       if(mgl_is_frames(this)) NewFrame();\r
+       if(draw)\r
+       {\r
+               ResetFrames();\r
+               if(get(MGL_CLF_ON_UPD)) DefaultPlotParam();\r
+               const std::string loc = setlocale(LC_NUMERIC, NULL);    setlocale(LC_NUMERIC, "C");\r
+               // use frames for quickly redrawing while adding/changing primitives\r
+               if(mgl_is_frames(this)) NewFrame();\r
 \r
-       int n = draw ? draw(this,par) : 0;\r
-       if(n<NumFig && n>=0)    NumFig = n;\r
-       DrawFunc = draw;                FuncPar = par;\r
-       LoadFunc = reload;\r
+               int n = draw(this,par);\r
+               if(n<NumFig && n>=0)    NumFig = n;\r
+               DrawFunc = draw;                FuncPar = par;\r
+               LoadFunc = reload;\r
 \r
-       if(mgl_is_frames(this)) EndFrame();\r
-       if(n>=0)        SetCurFig(0);\r
-       setlocale(LC_NUMERIC, loc.c_str());\r
+               if(mgl_is_frames(this)) EndFrame();\r
+               if(n>=0)        SetCurFig(0);\r
+               setlocale(LC_NUMERIC, loc.c_str());\r
+       }\r
+       else    LoadFunc = 0;\r
 }\r
 //-----------------------------------------------------------------------------\r
 const unsigned char *mglCanvasWnd::GetBits()\r
index c668416e6c85b23ac0eb7b758ac62ea3b04672a4..c766a1f46b8e8fef26a6ccd424f98facea703db7 100644 (file)
@@ -8,7 +8,7 @@ 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)!
+@strong{Any picture is created in memory first.} The internal (memory) representation can be different: bitmap picture (for @code{SetQuality(MGL_DRAW_LMEM)} or @code{@ref{quality} 6}) 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
@@ -42,9 +42,9 @@ In addition to the general concepts I want to comment on some non-trivial or les
 
 Two axis representations are used in MathGL. The first one consists of normalizing coordinates of data points in axis range (see @ref{Axis settings}). If @code{SetCut()} is @code{true} then the outlier points are omitted, otherwise they are projected to the bounding box (see @ref{Cutting}). Also, the point will be omitted if it lies inside the box defined by @code{SetCutBox()} or if the value of formula @code{CutOff()} is nonzero for its coordinates. After that, transformation formulas defined by @code{SetFunc()} or @code{SetCoor()} are applied to the data point (see @ref{Curved coordinates}). Finally, the data point is plotted by one of the functions.
 
-The range of @emph{x, y, z}-axis can be specified by @code{SetRange()} or @code{SetRanges()} functions. Its origin is specified by @code{SetOrigin()} function. At this you can you can use @code{NAN} values for selecting axis origin automatically.
+The range of @emph{x, y, z}-axis can be specified by @code{SetRange()} or @ref{ranges} functions. Its origin is specified by @ref{origin} function. At this you can you can use @code{NAN} values for selecting axis origin automatically.
 
-There is 4-th axis @emph{c} (color axis or colorbar) in addition to the usual axes @emph{x, y, z}. It sets the range of values for the surface coloring. Its borders are automatically set to values of z-range during the call of @code{SetRanges()} function. Also, one can directly set it by call @code{SetRange('c', ...)}. Use @code{Colorbar()} function for drawing the colorbar.
+There is 4-th axis @emph{c} (color axis or colorbar) in addition to the usual axes @emph{x, y, z}. It sets the range of values for the surface coloring. Its borders are automatically set to values of z-range during the call of @ref{ranges} function. Also, one can directly set it by call @code{SetRange('c', ...)}. Use @ref{colorbar} function for drawing the colorbar.
 
 The form (appearence) of tick labels is controlled by @code{SetTicks()} function (@pxref{Ticks}). Function @var{SetTuneTicks} switches on/off tick enhancing by factoring out acommon multiplier (for small coordinate values, like 0.001 to 0.002, or large, like from 1000 to 2000) or common component (for narrow range, like from 0.999 to 1.000). Finally, you may use functions @code{SetTickTempl()} for setting templates for tick labels (it supports TeX symbols). Also, there is a possibility to print arbitrary text as tick labels the by help of @code{SetTicksVal()} function.
 
@@ -86,7 +86,7 @@ melone color.
 @cindex Mark style
 @cindex Arrows
 
-The line style is defined by the string which may contain specifications for color (@samp{wkrgbcymhRGBCYMHWlenupqLENUPQ}), dashing style (@samp{-|;:ji=} or space), width (@samp{123456789}) and marks (@samp{*o+xsd.^v<>} and @samp{#} modifier). If one of the type of information is omitted then default values used with next color from palette (see @ref{Palette and colors}). Note, that internal color counter will be nullified by any change of palette. This includes even hidden change (for example, by @code{Box()} or @code{Axis()} functions).
+The line style is defined by the string which may contain specifications for color (@samp{wkrgbcymhRGBCYMHWlenupqLENUPQ}), dashing style (@samp{-|;:ji=} or space), width (@samp{123456789}) and marks (@samp{*o+xsd.^v<>} and @samp{#} modifier). If one of the type of information is omitted then default values used with next color from palette (see @ref{Palette and colors}). Note, that internal color counter will be nullified by any change of palette. This includes even hidden change (for example, by @ref{box} or @ref{axis} functions).
 @ifhtml
 @html
 By default palette contain following colors: <span style="color: rgb(76, 76, 76);">dark gray</span> &lsquo;<samp>H</samp>&rsquo;, <span style="color: rgb(0, 0, 255);">blue</span> &lsquo;<samp>b</samp>&rsquo;, <span style="color: rgb(0, 255, 0);">green</span> &lsquo;<samp>g</samp>&rsquo;, <span style="color: rgb(255, 0, 0);">red</span> &lsquo;<samp>r</samp>&rsquo;, <span style="color: rgb(0, 255, 255);">cyan</span> &lsquo;<samp>c</samp>&rsquo;, <span style="color: rgb(255, 0, 255);">magenta</span> &lsquo;<samp>m</samp>&rsquo;, <span style="color: rgb(255, 255, 0);">yellow</span> &lsquo;<samp>y</samp>&rsquo;, <span style="color: rgb(127, 127, 127);">gray</span> &lsquo;<samp>h</samp>&rsquo;, <span style="color: rgb(0, 255, 127);">green-blue</span> &lsquo;<samp>l</samp>&rsquo;, <span style="color: rgb(0, 127, 255);">sky-blue</span> &lsquo;<samp>n</samp>&rsquo;, <span style="color: rgb(255, 127, 0);">orange</span> &lsquo;<samp>q</samp>&rsquo;, <span style="color: rgb(127, 255, 0);">green-yellow</span> &lsquo;<samp>e</samp>&rsquo;, <span style="color: rgb(127, 0, 255);">blue-violet</span> &lsquo;<samp>u</samp>&rsquo;, <span style="color: rgb(255, 0, 127);">purple</span> &lsquo;<samp>p</samp>&rsquo;.
index d0bea9395fb617bb880bfa5b38fa3ca2d7eff1e4..8252f9e66e3c02b495fd46b014420f29621f8a59 100644 (file)
@@ -6,7 +6,7 @@
 Всего основных концепций (базисных идей) шесть:
 @enumerate
 @item
-@strong{Все рисунки создаются в памяти.} Это могут быть как растровые картинки (для @code{SetQuality(MGL_DRAW_LMEM)}), так и векторные списки примитивов (по умолчанию). Дальнейшая судьба рисунков определяется пользователем: можно сохранить в файл, вывести на экран, создать анимацию/кино, дополнительно отредактировать и т.д. Такой подход обеспечивает высокую переносимость библиотеки -- один и тот же программный код создаст в точности одинаковый рисунок на @emph{любой} операционной системе. Кроме того, при таком подходе рисунки можно создавать непосредственно в консольной программе -- графическое окно не нужно!
+@strong{Все рисунки создаются в памяти.} Это могут быть как растровые картинки (для @code{SetQuality(MGL_DRAW_LMEM)} или @code{@ref{quality} 6}), так и векторные списки примитивов (по умолчанию). Дальнейшая судьба рисунков определяется пользователем: можно сохранить в файл, вывести на экран, создать анимацию/кино, дополнительно отредактировать и т.д. Такой подход обеспечивает высокую переносимость библиотеки -- один и тот же программный код создаст в точности одинаковый рисунок на @emph{любой} операционной системе. Кроме того, при таком подходе рисунки можно создавать непосредственно в консольной программе -- графическое окно не нужно!
 @item
 @strong{Все настройки графиков (стиль линий, цветовые схемы поверхностей, стиль и цвет текста) задаются строками.} Это обеспечивает: удобство для пользователя -- короткую строку легче читать и здесь тяжелее ошибиться, чем в большом списке параметров; переносимость -- строки выглядят одинаково на всех платформах и не надо заботиться о типе и числе аргументов.
 @item
@@ -40,9 +40,9 @@
 
 Представление системы координат в MathGL состоит из двух частей. Вначале координаты нормируются в диапазон изменения осей координат (@pxref{Axis settings}). Если флаг @code{SetCut()} установлен, то точки вне интервала отбрасываются, в противном случае, они проецируются на ограничивающий параллелепипед (см. @ref{Cutting}). Кроме того, отбрасываются точки внутри границ, определенных переменными @var{CutMin}x@var{CutMax} и точки, для которых значение функции @code{CutOff}() не равно нулю. После этого формулы перехода в криволинейную систему координат @code{SetFunc()}применяются к каждой точке. Наконец, точка данных отображается с помощью одной из графических функций.
 
-Диапазон изменения @emph{x, y, z}-координат задается функциями @code{SetRange()} или @code{SetRanges()}. Точка пересечения осей координат задается функцией @code{SetOrigin()}. При этом можно использовать NAN значения для автоматического выбора положения оси.
+Диапазон изменения @emph{x, y, z}-координат задается функциями @code{SetRange()} или @ref{ranges}. Точка пересечения осей координат задается функцией @code{SetOrigin()}. При этом можно использовать NAN значения для автоматического выбора положения оси.
 
-Кроме привычных осей @emph{x, y, z} есть еще одна ось -- цветовая шкала -- ось @emph{c}. Она используется при окрашивании поверхностей и задает границы изменения функции при окрашивании. Ее границы автоматически устанавливаются равными диапазону z-оси при вызове @code{SetRanges()}. Возможно и ручное изменение границ цветового интервала посредством вызова @code{SetRange('c', ...)}. Используйте @code{Colorbar()} для отображения цветовой шкалы.
+Кроме привычных осей @emph{x, y, z} есть еще одна ось -- цветовая шкала -- ось @emph{c}. Она используется при окрашивании поверхностей и задает границы изменения функции при окрашивании. Ее границы автоматически устанавливаются равными диапазону z-оси при вызове @ref{ranges}. Возможно и ручное изменение границ цветового интервала посредством вызова @code{SetRange('c', ...)}. Используйте @ref{colorbar} для отображения цветовой шкалы.
 
 Вид меток по осям определяется функцией @code{SetTicks()} (@pxref{Ticks}). Функция @var{SetTuneTicks} включает/выключает выделение общего множителя (большого или малого факторов в диапазоне) для меток осей координат. Наконец, если стандартный вид меток не устраивает пользователя, то их шаблон можно задать явно (можно использовать и ТеХ символы), воспользовавшись функцией  @code{SetTickTempl()}. Кроме того, в качестве меток можно вывести произвольный текст использовав функцию @code{SetTicksVal()}.
 
index 92f29e3350e6f60db703748d99e52e86cafde30b..ec36cfb90bcb4fd8d0b2a8c082447474be190e06 100644 (file)
@@ -488,6 +488,15 @@ Sets RGB values for color with given @var{id}. This is global setting which infl
 @end ifclear
 
 
+@anchor{gray}
+@deftypefn {MGL command} {} gray @code{val}
+@ifclear UDAV
+@deftypefnx {Method on @code{mglGraph}} @code{void} Gray (@code{bool} enable)
+@deftypefnx {C function} @code{void} mgl_set_gray (@code{HMGL} gr, @code{int} enable)
+@end ifclear
+Sets the gray-scale mode on/off.
+@end deftypefn
+
 @c ==================================================================
 @external{}
 @node Masks, Error handling, Palette and colors, Graphics setup
@@ -984,7 +993,7 @@ The line style of axis (@var{stl}), ticks (@var{tck}) and subticks (@var{sub}).
 @cindex Push
 @cindex Pop
 
-These functions control how and where further plotting will be placed. There is a certain calling order of these functions for the better plot appearance. First one should be @ref{subplot}, @ref{multiplot} or @ref{inplot} for specifying the place. Second one can be @ref{title} for adding title for the subplot. After it a @ref{rotate} and @ref{aspect}. And finally any other plotting functions may be called. Alternatively you can use @ref{columnplot}, @ref{gridplot}, @ref{stickplot} or relative @ref{inplot} for positioning plots in the column (or grid, or stick) one by another without gap between plot axis (bounding boxes). @sref{Subplots}
+These functions control how and where further plotting will be placed. There is a certain calling order of these functions for the better plot appearance. First one should be @ref{subplot}, @ref{multiplot} or @ref{inplot} for specifying the place. Second one can be @ref{title} for adding title for the subplot. After it a @ref{rotate}, @ref{shear} and @ref{aspect}. And finally any other plotting functions may be called. Alternatively you can use @ref{columnplot}, @ref{gridplot}, @ref{stickplot}, @ref{shearplot} or relative @ref{inplot} for positioning plots in the column (or grid, or stick) one by another without gap between plot axis (bounding boxes). @sref{Subplots}
 
 @anchor{subplot}
 @deftypefn {MGL command} {} subplot @code{nx ny m ['stl'='<>_^' dx=0 dy=0]}
@@ -1067,6 +1076,16 @@ Puts further plotting in @var{ind}-th cell of @var{nx}*@var{ny} grid. The positi
 Puts further plotting in @var{ind}-th cell of stick with @var{num} cells. At this, stick is rotated on angles @var{tet}, @var{phi}. The position is relative to previous @ref{subplot} (or @ref{inplot} with @var{rel}=@code{false}).
 @end deftypefn
 
+@anchor{shearplot}
+@deftypefn {MGL command} {} shearplot @code{num ind sx sy [xd yd]}
+@ifclear UDAV
+@deftypefnx {Method on @code{mglGraph}} @code{void} ShearPlot (@code{int} num, @code{int} ind, @code{mreal} sx, @code{mreal} sy, @code{mreal} xd=@code{1}, @code{mreal} yd=@code{0})
+@deftypefnx {C function} @code{void} mgl_shearplot (@code{HMGL} gr, @code{int} num, @code{int} ind, @code{mreal} sx, @code{mreal} sy, @code{mreal} xd, @code{mreal} yd)
+@end ifclear
+Puts further plotting in @var{ind}-th cell of stick with @var{num} cells. At this, cell is sheared on values @var{sx}, @var{sy}. Stick direction is specified be @var{xd} and @var{yd}. The position is relative to previous @ref{subplot} (or @ref{inplot} with @var{rel}=@code{false}).
+@end deftypefn
+
+
 @anchor{title}
 @deftypefn {MGL command} {} title 'title' ['stl'='' @code{size=-2}]
 @ifclear UDAV
@@ -1102,6 +1121,15 @@ Rotates a further plotting relative to each axis @{x, z, y@} consecutively on an
 Rotates a further plotting around vector @{@var{x}, @var{y}, @var{z}@} on angle @var{Tet}.
 @end deftypefn
 
+@anchor{shear}
+@deftypefn {MGL command} {} shear @code{sx sy}
+@ifclear UDAV
+@deftypefnx {Method on @code{mglGraph}} @code{void} Shear (@code{mreal} sx, @code{mreal} sy)
+@deftypefnx {C function} @code{void} mgl_shear (@code{HMGL} gr, @code{mreal} sx, @code{mreal} sy)
+@end ifclear
+Shears a further plotting on values @var{sx}, @var{sy}.
+@end deftypefn
+
 @anchor{aspect}
 @deftypefn {MGL command} {} aspect @code{ax ay [az=1]}
 @ifclear UDAV
@@ -1178,12 +1206,14 @@ Functions in this group save or give access to produced picture. So, usually the
 Sets size of picture in pixels. This function @strong{should be} called before any other plotting because it completely remove picture contents if @var{clear}=@code{true}. Function just clear pixels and scale all primitives if @var{clear}=@code{false}.
 @end deftypefn
 
+@anchor{setsizescl}
+@deftypefn {MGL command} {} setsizescl @code{factor}
 @ifclear UDAV
-@deftypefn {Method on @code{mglGraph}} @code{void} SetSizeScl (@code{double} factor)
+@deftypefnx {Method on @code{mglGraph}} @code{void} SetSizeScl (@code{double} factor)
 @deftypefnx {C function} @code{void} mgl_set_size_scl (@code{HMGL} gr, @code{double} factor)
+@end ifclear
 Set factor for width and height in all further calls of @ref{setsize}.
 @end deftypefn
-@end ifclear
 
 @anchor{quality}
 @deftypefn {MGL command} {} quality [@code{val}=2]
@@ -3181,6 +3211,8 @@ color scheme -- up-half (warm) corresponds to normal flow (like attractor), bott
 @item
 @samp{#} for starting threads from edges only;
 @item
+@samp{*} for starting threads from a 2D array of points inside the data;
+@item
 @samp{v} for drawing arrows on the threads;
 @item
 @samp{x}, @samp{z} for drawing tapes of normals in x-y and y-z planes correspondingly.
index 31777bccf4c09239791b347d07a403c0647d2db8..70aaae2fdd0f8c213906536e1b05cfda76260c67 100644 (file)
@@ -473,6 +473,15 @@ MGL не требует создания данного типа объекто
 @end deftypefn
 @end ifclear
 
+@anchor{gray}
+@deftypefn {Команда MGL} {} gray @code{val}
+@ifclear UDAV
+@deftypefnx {Метод класса @code{mglGraph}} @code{void} Gray (@code{bool} enable)
+@deftypefnx {Функция С} @code{void} mgl_set_gray (@code{HMGL} gr, @code{int} enable)
+@end ifclear
+Включает/выключает вывод графика в оттенках серого.
+@end deftypefn
+
 @c ==================================================================
 @external{}
 @node Masks, Error handling, Palette and colors, Graphics setup
@@ -966,7 +975,7 @@ Ternary -- специальный тип графика для 3 зависим
 @cindex Push
 @cindex Pop
 
-Эти функции контролируют где и как график будет расположен. Существует определенный порядок вызова этих функций для лучшего вида графика. Вначале должны вызываться функции @ref{subplot}, @ref{multiplot} или @ref{inplot} для указания местоположения вывода. После них -- функции вращения @ref{rotate} и @ref{aspect}. И наконец любые другие функции для рисования графика. Вместо вращения графика можно вызвать функцию @ref{columnplot}, @ref{gridplot}, @ref{stickplot} или относительную @ref{inplot} для расположения графиков в столбец одного над другим без зазора между осями. @sref{Subplots}
+Эти функции контролируют где и как график будет расположен. Существует определенный порядок вызова этих функций для лучшего вида графика. Вначале должны вызываться функции @ref{subplot}, @ref{multiplot} или @ref{inplot} для указания местоположения вывода. После них -- функции вращения @ref{rotate}, @ref{shear} и @ref{aspect}. И наконец любые другие функции для рисования графика. Вместо вращения графика можно вызвать функцию @ref{columnplot}, @ref{gridplot}, @ref{stickplot}, @ref{shearplot} или относительную @ref{inplot} для расположения графиков в столбец одного над другим без зазора между осями. @sref{Subplots}
 
 @anchor{subplot}
 @deftypefn {Команда MGL} {} subplot @code{nx ny m ['stl'='<>_^' dx=0 dy=0]}
@@ -1026,6 +1035,15 @@ Ternary -- специальный тип графика для 3 зависим
 Помещает последующий вывод в @var{ind}-ую ячейку "бруска" из @var{num} ячеек. При этом сам брусок повернут на углы @var{tet}, @var{phi}. Положение выбирается относительно последнего вызова  @ref{subplot} (или @ref{inplot} с @var{rel}=@code{false}).
 @end deftypefn
 
+@anchor{shearplot}
+@deftypefn {Команда MGL} {} shearplot @code{num ind sx sy [xd yd]}
+@ifclear UDAV
+@deftypefnx {Метод класса @code{mglGraph}} @code{void} ShearPlot (@code{int} num, @code{int} ind, @code{mreal} sx, @code{mreal} sy, @code{mreal} xd=@code{1}, @code{mreal} yd=@code{0})
+@deftypefnx {Функция С} @code{void} mgl_shearplot (@code{HMGL} gr, @code{int} num, @code{int} ind, @code{mreal} sx, @code{mreal} sy, @code{mreal} xd, @code{mreal} yd)
+@end ifclear
+Помещает последующий вывод в @var{ind}-ую ячейку "бруска" из @var{num} ячеек. При этом сама ячейка скошена на @var{sx}, @var{sy}. Направление бруска задается переменными @var{xd} и @var{yd}. Положение выбирается относительно последнего вызова  @ref{subplot} (или @ref{inplot} с @var{rel}=@code{false}).
+@end deftypefn
+
 @anchor{title}
 @deftypefn {Команда MGL} {} title 'title' ['stl'='' @code{size=-2}]
 @ifclear UDAV
@@ -1054,6 +1072,17 @@ Ternary -- специальный тип графика для 3 зависим
 Вращает систему координат относительно вектора @{@var{x}, @var{y}, @var{z}@} на угол @var{Tet}.
 @end deftypefn
 
+
+@anchor{shear}
+@deftypefn {Команда MGL} {} shear @code{sx sy}
+@ifclear UDAV
+@deftypefnx {Метод класса @code{mglGraph}} @code{void} Shear (@code{mreal} sx, @code{mreal} sy)
+@deftypefnx {Функция С} @code{void} mgl_shear (@code{HMGL} gr, @code{mreal} sx, @code{mreal} sy)
+@end ifclear
+Сдвигает (скашивает) систему координат на значения @var{sx}, @var{sy}.
+@end deftypefn
+
+
 @anchor{aspect}
 @deftypefn {Команда MGL} {} aspect @code{ax ay [az=1]}
 @ifclear UDAV
@@ -1132,12 +1161,14 @@ Ternary -- специальный тип графика для 3 зависим
 @end deftypefn
 
 
+@anchor{setsizescl}
+@deftypefn {Команда MGL} {} setsizescl @code{factor}
 @ifclear UDAV
-@deftypefn {Метод класса @code{mglGraph}} @code{void} SetSizeScl (@code{double} factor)
+@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetSizeScl (@code{double} factor)
 @deftypefnx {Функция С} @code{void} mgl_set_size_scl (@code{HMGL} gr, @code{double} factor)
+@end ifclear
 Задает множитель для высоты и ширины во всех последующих вызовах @ref{setsize}.
 @end deftypefn
-@end ifclear
 
 
 @anchor{quality}
@@ -3093,6 +3124,8 @@ Draw bitmap (logo) along whole axis range, which can be changed by @ref{Command
 @item
 @samp{#} для использования нитей, начинающихся только на границе;
 @item
+@samp{*} для использования нитей, начинающихся с двумерной сетки внутри данных;
+@item
 @samp{v} для рисования стрелок на нитях;
 @item
 @samp{x}, @samp{z} для рисования лент нормалей, начинающихся в плоскостях x-y и y-z соответственно.
index d2b7a1bea0eeaf7253600a236cc3eee156640de8..e5def93acb6822f5bdb6af39075be1494f94d8a4 100644 (file)
@@ -1132,10 +1132,38 @@ By default quadratic averaging over 5 points is used.
 Find envelop for data values along direction @var{dir}.
 @end deftypefn
 
+@anchor{diffract}
+@deftypefn {MGL command} {} diffract dat 'how' @code{q}
+@ifclear UDAV
+@deftypefnx {Method on @code{mglDataC}} @code{void} Diffraction (@code{const char *}how, @code{mreal} q)
+@deftypefnx {C function} @code{void} mgl_datac_diffr (@code{HADT} dat, @code{const char *}how, @code{mreal} q)
+@end ifclear
+Calculates one step of diffraction by finite-difference method with parameter @var{q}=@math{\delta t/\delta x^2} using method with 3-d order of accuracy. Parameter @var{how} may contain:
+@itemize @bullet
+ @item @samp{xyz} for calculations along x-,y-,z-directions correspondingly;
+@item
+ @samp{r} for using axial symmetric Laplace operator for x-direction;
+@item
+ @samp{0} for zero boundary conditions;
+@item
+ @samp{1} for constant boundary conditions;
+@item
+ @samp{2} for linear boundary conditions;
+@item
+ @samp{3} for parabolic boundary conditions;
+@item
+ @samp{4} for exponential boundary conditions;
+@item
+ @samp{5} for gaussian boundary conditions.
+@end itemize
+@end deftypefn
+
+
 @anchor{norm}
 @deftypefn {MGL command} {} norm dat @code{v1 v2 [sym=off dim=0]}
 @ifclear UDAV
-@deftypefnx {Method on @code{mglData}} @code{void} Norm (@code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{bool} sym=@code{false}, @code{int} dim=@code{0})
+@deftypefnx {Method on @code{mglData}} @code{void} Norm (@code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{bool} sym=@code{false}, @code{long} dim=@code{0})
+@deftypefnx {C function} @code{void} mgl_data_norm (@code{HMDT} dat, @code{mreal} v1, @code{mreal} v2, @code{int} sym, @code{long} dim)
 @end ifclear
 Normalizes the data to range [@var{v1},@var{v2}]. If flag @var{sym}=@code{true} then symmetrical interval [-max(|v1|,|v2|), max(|v1|,|v2|)] is used. Modification will be applied only for slices >=@var{dim}.
 @end deftypefn
@@ -1155,6 +1183,17 @@ Normalizes data slice-by-slice along direction @var{dir} the data in slices to r
 @end ifnottex
 @end deftypefn
 
+@anchor{limit}
+@deftypefn {MGL command} {} limit dat @code{val}
+@ifclear UDAV
+@deftypefnx {Method on @code{mglData}} @code{void} Limit (@code{mreal} val)
+@deftypefnx {Method on @code{mglDataC}} @code{void} Limit (@code{mreal} val)
+@deftypefnx {C function} @code{void} mgl_data_limit (@code{HMDT} dat, @code{mreal} val)
+@deftypefnx {C function} @code{void} mgl_datac_limit (@code{HADT} dat, @code{mreal} val)
+@end ifclear
+Limits the data values to be inside the range [-@var{val},@var{val}], keeping the original sign of the value (phase for complex numbers). This is equivalent to operation @code{a[i] *= abs(a[i])<val?1.:val/abs(a[i]);}.
+@end deftypefn
+
 @c ------------------------------------------------------------------
 @external{}
 @node Interpolation, Data information, Data changing, Data processing
@@ -1529,11 +1568,34 @@ Does Fourier transform of complex data @var{re}+i*@var{im} in directions @var{di
 @deftypefn {MGL command} {} stfad @sc{res} real imag @code{dn} ['dir'='x']
 @ifclear UDAV
 @deftypefnx {Global function} @code{mglData} mglSTFA (@code{const mglDataA &}real, @code{const mglDataA &}imag, @code{int} dn, @code{char} dir=@code{'x'})
-@deftypefnx {C function} @code{HMDT} mgl_data_stfa (@code{HCDT} real, @code{HCDT} imag, @code{int} dn,@code{char} dir)
+@deftypefnx {C function} @code{HMDT} mgl_data_stfa (@code{HCDT} real, @code{HCDT} imag, @code{int} dn, @code{char} dir)
 @end ifclear
 Short time Fourier transformation for real and imaginary parts. Output  is amplitude of partial Fourier of length @var{dn}. For example if @var{dir}=@samp{x}, result will have size @{int(nx/dn), dn, ny@} and it will contain @math{res[i,j,k]=|\sum_d^dn exp(I*j*d)*(real[i*dn+d,k]+I*imag[i*dn+d,k])|/dn}.
 @end deftypefn
 
+@anchor{tridmat}
+@deftypefn {MGL command} {} tridmat @sc{res adat bdat cdat ddat} 'how'
+@ifclear UDAV
+@deftypefnx {Global function} @code{mglData} mglTridMat (@code{const mglDataA &}A, @code{const mglDataA &}B, @code{const mglDataA &}C, @code{const mglDataA &}D, @code{const char *}how)
+@deftypefnx {Global function} @code{mglDataC} mglTridMatC (@code{const mglDataA &}A, @code{const mglDataA &}B, @code{const mglDataA &}C, @code{const mglDataA &}D, @code{const char *}how)
+@deftypefnx {C function} @code{HMDT} mgl_data_tridmat (@code{HCDT} A, @code{HCDT} B, @code{HCDT} C, @code{HCDT} D, @code{const char*}how)
+@deftypefnx {C function} @code{HADT} mgl_datac_tridmat (@code{HCDT} A, @code{HCDT} B, @code{HCDT} C, @code{HCDT} D, @code{const char*}how)
+@end ifclear
+Get array as solution of tridiagonal system of equations @var{A}[i]*x[i-1]+@var{B}[i]*x[i]+@var{C}[i]*x[i+1]=@var{D}[i]. String @var{how} may contain:
+@itemize @bullet
+@item
+@samp{xyz} for solving along x-,y-,z-directions correspondingly;
+@item
+@samp{h} for solving along hexagonal direction at x-y plain (require square matrix);
+@item
+@samp{c} for using periodical boundary conditions;
+@item
+@samp{d} for for diffraction/diffuse calculation (i.e. for using -@var{A}[i]*@var{D}[i-1]+(2-@var{B}[i])*@var{D}[i]-@var{C}[i]*@var{D}[i+1] at right part instead of @var{D}[i]).
+@end itemize
+Data dimensions of arrays @var{A}, @var{B}, @var{C} should be equal. Also their dimensions need to be equal to all or to minor dimension(s) of array @var{D}. @sref{PDE solving hints}
+@end deftypefn
+
+
 @anchor{pde}
 @deftypefn {MGL command} {} pde @sc{res} 'ham' ini_re ini_im [@code{dz=0.1 k0=100}]
 @ifclear UDAV
@@ -1668,6 +1730,33 @@ z[i+1] = dat[6,i]*x[i] + dat[7,i]*y[i] + dat[8,i]*z[i] + dat[10,i];
 Value @code{dat[12,i]} is used as weight factor for i-th row of matrix @var{dat}. At this first @var{skip} iterations will be omitted. Data array @var{dat} must have x-size greater or equal to 13. @sref{IFS sample}
 @end deftypefn
 
+@anchor{ifsfile}
+@deftypefn {MGL command} {} ifsfile @sc{res} 'fname' 'name' @code{num} [@code{skip=20}]
+@ifclear UDAV
+@deftypefnx {Global function} @code{mglData} mglIFSfile (@code{const char *}fname, @code{const char *}name, @code{long} num, @code{long} skip=@code{20})
+@deftypefnx {C function} @code{HMDT} mgl_data_ifs_file (@code{const char *}fname, @code{const char *}name, @code{long} num, @code{long} skip)
+@end ifclear
+Reads parameters of IFS fractal named @var{name} from file @var{fname} and computes @var{num} points for this fractal. At this first @var{skip} iterations will be omitted. See also @ref{ifs2d}, @ref{ifs3d}.
+
+IFS file may contain several records. Each record contain the name of fractal (@samp{binary} in the example below) and the body of fractal, which is enclosed in curly braces @{@}. Symbol @samp{;} start the comment. If the name of fractal contain @samp{(3D)} or @samp{(3d)} then the 3d IFS fractal is specified. The sample below contain two fractals: @samp{binary} -- usual 2d fractal, and @samp{3dfern (3D)} -- 3d fractal.
+
+@verbatim
+ binary
+ { ; comment allowed here
+  ; and here
+  .5  .0 .0 .5 -2.563477 -0.000003 .333333   ; also comment allowed here
+  .5  .0 .0 .5  2.436544 -0.000003 .333333
+  .0 -.5 .5 .0  4.873085  7.563492 .333333
+  }
+
+ 3dfern (3D) {
+   .00  .00 0 .0 .18 .0 0  0.0 0.00 0 0.0 0 .01
+   .85  .00 0 .0 .85 .1 0 -0.1 0.85 0 1.6 0 .85
+   .20 -.20 0 .2 .20 .0 0  0.0 0.30 0 0.8 0 .07
+  -.20  .20 0 .2 .20 .0 0  0.0 0.30 0 0.8 0 .07
+  }
+@end verbatim
+@end deftypefn
 
 
 @c ------------------------------------------------------------------
index ab646042a199d7d9a922171215db2e0cb9a26623..225bf120259fbc387fbd8000fbf78e3d276629fa 100644 (file)
@@ -425,7 +425,7 @@ a_ij^new = a_i^old where j=0...@var{n1}. Соответственно, для @v
 @end deftypefn
 
 
-@deftypefn {Method on @code{mglData}} @code{void} SetList (@code{long} n, ...)
+@deftypefn {Метод класса @code{mglData}} @code{void} SetList (@code{long} n, ...)
 Allocate memory and set data from variable argument list of @emph{double} values. Note, you need to specify decimal point @samp{.} for integer values! For example, the code @code{SetList(2,0.,1.);} is correct, but the code @code{SetList(2,0,1);} is incorrect.
 @end deftypefn
 
@@ -557,7 +557,7 @@ Allocate memory and set data from variable argument list of @emph{double} values
 @anchor{gspline}
 @deftypefn {Команда MGL} {} gspline dat xdat vdat [sl=-1]
 @ifclear UDAV
-@deftypefnx {Method on @code{mglData}} @code{void} RefillGS (@code{const mglDataA &}x, @code{const mglDataA &}v, @code{mreal} x1, @code{mreal} x2, @code{long} sl=@code{-1})
+@deftypefnx {Метод класса @code{mglData}} @code{void} RefillGS (@code{const mglDataA &}x, @code{const mglDataA &}v, @code{mreal} x1, @code{mreal} x2, @code{long} sl=@code{-1})
 @deftypefnx {Функция С} @code{void} mgl_data_refill_gs (@code{HMDT} a, @code{HCDT} x, @code{HCDT} v, @code{mreal} x1, @code{mreal} x2, @code{long} sl)
 @end ifclear
 Заполняет значениями глобального кубического сплайна для массива @var{v} в точках @var{x}=@code{X[i]}, где @code{X} равномерно распределен в диапазоне [@var{x1},@var{x2}] и имеет такой же размер как и заполняемый массив. Если параметр @var{sl} равен 0 или положительный, то изменятся будет только @var{sl}-ый срез.
@@ -1118,10 +1118,37 @@ These functions change the data in some direction like differentiations, integra
 Находит огибающую данных в выбранном направлении @var{dir}.
 @end deftypefn
 
+@anchor{diffract}
+@deftypefn {Команда MGL} {} diffract dat 'how' @code{q}
+@ifclear UDAV
+@deftypefnx {Метод класса @code{mglDataC}} @code{void} Diffraction (@code{const char *}how, @code{mreal} q)
+@deftypefnx {Функция С} @code{void} mgl_datac_diffr (@code{HADT} dat, @code{const char *}how, @code{mreal} q)
+@end ifclear
+Вычисляет один шаг диффракции в конечно-разностной схеме с параметром @var{q}=@math{\delta t/\delta x^2} используя метод третьего порядка точности. Параметр @var{how} может содержать:
+@itemize @bullet
+ @item @samp{xyz} для расчета вдоль x-,y-,z-направления;
+@item
+ @samp{r} для аксиально симметричного лапласиана по направлению x;
+@item
+ @samp{0} для нулевых граничных условий;
+@item
+ @samp{1} для постоянных граничных условий;
+@item
+ @samp{2} для линейных граничных условий;
+@item
+ @samp{3} для параболлических граничных условий;
+@item
+ @samp{4} для экспоненциальных граничных условий;
+@item
+ @samp{5} для гауссовых граничных условий.
+@end itemize
+@end deftypefn
+
 @anchor{norm}
 @deftypefn {Команда MGL} {} norm dat @code{v1 v2 [sym=off dim=0]}
 @ifclear UDAV
-@deftypefnx {Метод класса @code{mglData}} @code{void} Norm (@code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{bool} sym=@code{false}, @code{int} dim=@code{0})
+@deftypefnx {Метод класса @code{mglData}} @code{void} Norm (@code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{bool} sym=@code{false}, @code{long} dim=@code{0})
+@deftypefnx {Функция С} @code{void} mgl_data_norm (@code{HMDT} dat, @code{mreal} v1, @code{mreal} v2, @code{int} sym, @code{long} dim)
 @end ifclear
 Нормирует данные в интервал [@var{v1},@var{v2}]. Если @var{sym}=@code{true}, то используется симметричный интервал [-max(|v1|,|v2|), max(|v1|,|v2|)]. Изменения применяются только к срезам >=@var{dim}.
 @end deftypefn
@@ -1141,6 +1168,17 @@ These functions change the data in some direction like differentiations, integra
 @end ifnottex
 @end deftypefn
 
+@anchor{limit}
+@deftypefn {Команда MGL} {} limit dat @code{val}
+@ifclear UDAV
+@deftypefnx {Метод класса @code{mglData}} @code{void} Limit (@code{mreal} val)
+@deftypefnx {Метод класса @code{mglDataC}} @code{void} Limit (@code{mreal} val)
+@deftypefnx {Функция С} @code{void} mgl_data_limit (@code{HMDT} dat, @code{mreal} val)
+@deftypefnx {Функция С} @code{void} mgl_datac_limit (@code{HADT} dat, @code{mreal} val)
+@end ifclear
+Ограничивает амплитуду данных диапазоном [-@var{val},@var{val}]. При этом сохраняется исходный знак (фаза для комплексных чисел). Эквивалентно операции @code{a[i] *= abs(a[i])<val?1.:val/abs(a[i]);}.
+@end deftypefn
+
 @c ------------------------------------------------------------------
 @external{}
 @node Interpolation, Data information, Data changing, Data processing
@@ -1516,11 +1554,33 @@ These functions change the data in some direction like differentiations, integra
 @deftypefn {Команда MGL} {} stfad @sc{res} real imag @code{dn} ['dir'='x']
 @ifclear UDAV
 @deftypefnx {Global function} @code{mglData} mglSTFA (@code{const mglDataA &}real, @code{const mglDataA &}imag, @code{int} dn, @code{char} dir=@code{'x'})
-@deftypefnx {Функция С} @code{HMDT} mgl_data_stfa (@code{HCDT} real, @code{HCDT} imag, @code{int} dn,@code{char} dir)
+@deftypefnx {Функция С} @code{HMDT} mgl_data_stfa (@code{HCDT} real, @code{HCDT} imag, @code{int} dn, @code{char} dir)
 @end ifclear
 Выполняет оконное преобразование Фурье длиной @var{dn} для комплексных данных @var{real}, @var{imag} и возвращает модуль результата. Например, для @var{dir}=@samp{x} результат будет иметь размер @{int(nx/dn), dn, ny@} и будет равен @math{res[i,j,k]=|\sum_d^dn exp(I*j*d)*(real[i*dn+d,k]+I*imag[i*dn+d,k])|/dn}.
 @end deftypefn
 
+@anchor{tridmat}
+@deftypefn {Команда MGL} {} tridmat @sc{res adat bdat cdat ddat} 'how'
+@ifclear UDAV
+@deftypefnx {Global function} @code{mglData} mglTridMat (@code{const mglDataA &}A, @code{const mglDataA &}B, @code{const mglDataA &}C, @code{const mglDataA &}D, @code{const char *}how)
+@deftypefnx {Global function} @code{mglDataC} mglTridMatC (@code{const mglDataA &}A, @code{const mglDataA &}B, @code{const mglDataA &}C, @code{const mglDataA &}D, @code{const char *}how)
+@deftypefnx {Функция С} @code{HMDT} mgl_data_tridmat (@code{HCDT} A, @code{HCDT} B, @code{HCDT} C, @code{HCDT} D, @code{const char*}how)
+@deftypefnx {Функция С} @code{HADT} mgl_datac_tridmat (@code{HCDT} A, @code{HCDT} B, @code{HCDT} C, @code{HCDT} D, @code{const char*}how)
+@end ifclear
+Возвращает решение трехдиагональной системы уравнений @var{A}[i]*x[i-1]+@var{B}[i]*x[i]+@var{C}[i]*x[i+1]=@var{D}[i]. Строка @var{how} может содержать:
+@itemize @bullet
+@item
+@samp{xyz} для решения вдоль x-,y-,z-направлений;
+@item
+@samp{h} для решения вдоль диагонали на плоскости x-y (требует квадратную матрицу);
+@item
+@samp{c} для использования периодических граничных условий;
+@item
+@samp{d} для расчета диффракции/диффузии (т.е. для использования -@var{A}[i]*@var{D}[i-1]+(2-@var{B}[i])*@var{D}[i]-@var{C}[i]*@var{D}[i+1] в правой частиц вместо @var{D}[i]).
+@end itemize
+Размеры массивов @var{A}, @var{B}, @var{C} должны быть одинаковы. Также их размерности должны совпадать со всеми или с "младшими" размерностями массива @var{D}. @sref{PDE solving hints}
+@end deftypefn
+
 @anchor{pde}
 @deftypefn {Команда MGL} {} pde @sc{res} 'ham' ini_re ini_im [@code{dz=0.1 k0=100}]
 @ifclear UDAV
@@ -1651,6 +1711,34 @@ z[i+1] = dat[6,i]*x[i] + dat[7,i]*y[i] + dat[8,i]*z[i] + dat[10,i];
 Значение @code{dat[6,i]} -- весовой коэффициент для i-ой строки матрицы @var{dat}. Первые @var{skip} итераций будут опущены. Массив @var{dat} должен иметь размер по x больше или равный 13. @sref{IFS sample}
 @end deftypefn
 
+@anchor{ifsfile}
+@deftypefn {Команда MGL} {} ifsfile @sc{res} 'fname' 'name' @code{num} [@code{skip=20}]
+@ifclear UDAV
+@deftypefnx {Global function} @code{mglData} mglIFSfile (@code{const char *}fname, @code{const char *}name, @code{long} num, @code{long} skip=@code{20})
+@deftypefnx {Функция С} @code{HMDT} mgl_data_ifs_file (@code{const char *}fname, @code{const char *}name, @code{long} num, @code{long} skip)
+@end ifclear
+Считывает параметры фрактала @var{name} из файла @var{fname} и находит @var{num} точек для него. Первые @var{skip} итераций будут опущены. См. также @ref{ifs2d}, @ref{ifs3d}.
+
+Файл IFS может содержать несколько записей. Каждая запись содержит имя фрактала (@samp{binary} в примере ниже) и тело в фигурных скобках @{@} с параметрами фрактала. Символ @samp{;} начинает комментарий. Если имя содержит @samp{(3D)} или @samp{(3d)}, то определен 3d IFS фрактал. Пример содержит два фрактала: @samp{binary} -- обычный 2d фрактал, и @samp{3dfern (3D)} -- 3d фрактал.
+
+@verbatim
+ binary
+ { ; comment allowed here
+  ; and here
+  .5  .0 .0 .5 -2.563477 -0.000003 .333333   ; also comment allowed here
+  .5  .0 .0 .5  2.436544 -0.000003 .333333
+  .0 -.5 .5 .0  4.873085  7.563492 .333333
+  }
+
+ 3dfern (3D) {
+   .00  .00 0 .0 .18 .0 0  0.0 0.00 0 0.0 0 .01
+   .85  .00 0 .0 .85 .1 0 -0.1 0.85 0 1.6 0 .85
+   .20 -.20 0 .2 .20 .0 0  0.0 0.30 0 0.8 0 .07
+  -.20  .20 0 .2 .20 .0 0  0.0 0.30 0 0.8 0 .07
+  }
+@end verbatim
+@end deftypefn
+
 @c ------------------------------------------------------------------
 @external{}
 @node Evaluate expression, Special data classes, Global functions, Data processing
index 918c67cbd0877c09b84098d4c798a2f1d49f22c3..d9baf5f4619116152d4f051aec55eb7a72ea21cd 100644 (file)
@@ -126,7 +126,7 @@ Let me demonstrate possibilities of plot positioning and rotation. MathGL has a
 @verbatim
 subplot 2 2 0
 box:text -1 1.1 'Just box' ':L'
-inplot 0.2 0.5 0.7 off
+inplot 0.2 0.5 0.7 off
 box:text 0 1.2 'InPlot example'
 
 subplot 2 2 1:title 'Rotate only'
@@ -135,8 +135,8 @@ rotate 50 60:box
 subplot 2 2 2:title 'Rotate and Aspect'
 rotate 50 60:aspect 1 1 2:box
 
-subplot 2 2 3:title 'Aspect in other direction'
-rotate 50 60:aspect 1 2 2:box
+subplot 2 2 3:title 'Shear'
+box 'c':shear 0.2 0.1:box
 @end verbatim
 Here I used function @code{Puts} for printing the text in arbitrary position of picture (see @ref{Text printing}). Text coordinates and size are connected with axes. However, text coordinates may be everywhere, including the outside the bounding box. I'll show its features later in @ref{Text features}.
 
@@ -147,9 +147,9 @@ Note that several commands can be placed in a string if they are separated by @s
 More complicated sample show how to use most of positioning functions:
 @verbatim
 subplot 3 2 0:title 'StickPlot'
-stickplot 3 0 20 30:box 'r':text 0 0 '0' 'r'
-stickplot 3 1 20 30:box 'g':text 0 0 '1' 'g'
-stickplot 3 2 20 30:box 'b':text 0 0 '2' 'b'
+stickplot 3 0 20 30:box 'r':text 0 0 '0' 'r'
+stickplot 3 1 20 30:box 'g':text 0 0 '1' 'g'
+stickplot 3 2 20 30:box 'b':text 0 0 '2' 'b'
 
 subplot 3 2 3 '':title 'ColumnPlot'
 columnplot 3 0:box 'r':text 0 0 '0' 'r'
@@ -165,7 +165,10 @@ gridplot 2 2 3:box 'm':text 0 0 '3' 'm'
 subplot 3 2 5 '':title 'InPlot':box
 inplot 0.4 1 0.6 1 on:box 'r'
 
-multiplot 3 2 1 2 1 '':title 'MultiPlot':box
+multiplot 3 2 1 2 1 '':title 'MultiPlot and ShearPlot':box
+shearplot 3 0 0.2 0.1:box 'r':text 0 0 '0' 'r'
+shearplot 3 1 0.2 0.1:box 'g':text 0 0 '1' 'g'
+shearplot 3 2 0.2 0.1:box 'b':text 0 0 '2' 'b'
 @end verbatim
 
 @pfig{inplot, Example for most of positioning functions.}
@@ -2695,7 +2698,7 @@ There is difference in indirect access functions. Function @ref{subdata} use use
 subplot 1 1 0 '':title 'SubData vs Evaluate'
 new in 9 'x^3/1.1':plot in 'ko ':box
 new arg 99 '4*x+4'
-evaluate e in arg:plot e 'b.'; legend 'Evaluate'
+evaluate e in arg off:plot e 'b.'; legend 'Evaluate'
 subdata s in arg:plot s 'r.';legend 'SubData'
 legend 2
 @end verbatim
index ddc3186eb377a553e38f35f1e4e5f794f544645e..eb0924e9f56dbe7e863baff81dd5a4270f96ebb2 100644 (file)
@@ -126,7 +126,7 @@ Let me demonstrate possibilities of plot positioning and rotation. MathGL has a
 @verbatim
 subplot 2 2 0
 box:text -1 1.1 'Just box' ':L'
-inplot 0.2 0.5 0.7 off
+inplot 0.2 0.5 0.7 off
 box:text 0 1.2 'InPlot example'
 
 subplot 2 2 1:title 'Rotate only'
@@ -135,8 +135,8 @@ rotate 50 60:box
 subplot 2 2 2:title 'Rotate and Aspect'
 rotate 50 60:aspect 1 1 2:box
 
-subplot 2 2 3:title 'Aspect in other direction'
-rotate 50 60:aspect 1 2 2:box
+subplot 2 2 3:title 'Shear'
+box 'c':shear 0.2 0.1:box
 @end verbatim
 Here I used function @code{Puts} for printing the text in arbitrary position of picture (see @ref{Text printing}). Text coordinates and size are connected with axes. However, text coordinates may be everywhere, including the outside the bounding box. I'll show its features later in @ref{Text features}.
 
@@ -147,9 +147,9 @@ Note that several commands can be placed in a string if they are separated by @s
 More complicated sample show how to use most of positioning functions:
 @verbatim
 subplot 3 2 0:title 'StickPlot'
-stickplot 3 0 20 30:box 'r':text 0 0 '0' 'r'
-stickplot 3 1 20 30:box 'g':text 0 0 '1' 'g'
-stickplot 3 2 20 30:box 'b':text 0 0 '2' 'b'
+stickplot 3 0 20 30:box 'r':text 0 0 '0' 'r'
+stickplot 3 1 20 30:box 'g':text 0 0 '1' 'g'
+stickplot 3 2 20 30:box 'b':text 0 0 '2' 'b'
 
 subplot 3 2 3 '':title 'ColumnPlot'
 columnplot 3 0:box 'r':text 0 0 '0' 'r'
@@ -165,7 +165,10 @@ gridplot 2 2 3:box 'm':text 0 0 '3' 'm'
 subplot 3 2 5 '':title 'InPlot':box
 inplot 0.4 1 0.6 1 on:box 'r'
 
-multiplot 3 2 1 2 1 '':title 'MultiPlot':box
+multiplot 3 2 1 2 1 '':title 'MultiPlot and ShearPlot':box
+shearplot 3 0 0.2 0.1:box 'r':text 0 0 '0' 'r'
+shearplot 3 1 0.2 0.1:box 'g':text 0 0 '1' 'g'
+shearplot 3 2 0.2 0.1:box 'b':text 0 0 '2' 'b'
 @end verbatim
 
 @pfig{inplot, Example for most of positioning functions.}
@@ -2695,7 +2698,7 @@ There is difference in indirect access functions. Function @ref{subdata} use use
 subplot 1 1 0 '':title 'SubData vs Evaluate'
 new in 9 'x^3/1.1':plot in 'ko ':box
 new arg 99 '4*x+4'
-evaluate e in arg:plot e 'b.'; legend 'Evaluate'
+evaluate e in arg off:plot e 'b.'; legend 'Evaluate'
 subdata s in arg:plot s 'r.';legend 'SubData'
 legend 2
 @end verbatim
index ceb404aa2a90386f094d54e518b0ea20ceefa331..d49f53b8e2fd86debb60e63433d0a402bc99b042 100644 (file)
@@ -707,8 +707,8 @@ int sample(mglGraph *gr)
   gr->Rotate(50,60);  gr->Box();
   gr->SubPlot(2,2,2); gr->Title("Rotate and Aspect");
   gr->Rotate(50,60);  gr->Aspect(1,1,2);  gr->Box();
-  gr->SubPlot(2,2,3); gr->Title("Aspect in other direction");
-  gr->Rotate(50,60);  gr->Aspect(1,2,2);  gr->Box();
+  gr->SubPlot(2,2,3); gr->Title("Shear");
+  gr->Box("c"); gr->Shear(0.2,0.1); gr->Box();
   return 0;
 }
 @end verbatim
@@ -735,7 +735,10 @@ int sample(mglGraph *gr)
   gr->GridPlot(2, 2, 3);  gr->Box("m"); gr->Puts(mglPoint(0),"3","m");
   gr->SubPlot(3,2,5,"");  gr->Title("InPlot");  gr->Box();
   gr->InPlot(0.4, 1, 0.6, 1, true); gr->Box("r");
-  gr->MultiPlot(3,2,1, 2, 1,"");  gr->Title("MultiPlot"); gr->Box();
+  gr->MultiPlot(3,2,1, 2, 1,"");  gr->Title("MultiPlot and ShearPlot"); gr->Box();
+  gr->ShearPlot(3, 0, 0.2, 0.1);  gr->Box("r"); gr->Puts(mglPoint(0),"0","r");
+  gr->ShearPlot(3, 1, 0.2, 0.1);  gr->Box("g"); gr->Puts(mglPoint(0),"1","g");
+  gr->ShearPlot(3, 2, 0.2, 0.1);  gr->Box("b"); gr->Puts(mglPoint(0),"2","b");
   return 0;
 }
 @end verbatim
@@ -3916,7 +3919,7 @@ int sample(mglGraph *gr)
   mglData in(9), arg(99), e, s;
   gr->Fill(in,"x^3/1.1"); gr->Fill(arg,"4*x+4");
   gr->Plot(in,"ko ");     gr->Box();
-  e = in.Evaluate(arg);   gr->Plot(e,"b.","legend 'Evaluate'");
+  e = in.Evaluate(arg,false); gr->Plot(e,"b.","legend 'Evaluate'");
   s = in.SubData(arg);    gr->Plot(s,"r.","legend 'SubData'");
   gr->Legend(2);
 }
index 2fca8a27a16ee1165c40be88061012e2fd2e1a8d..8e42004b4a05dde30f80dd3388b0fd819568aefd 100644 (file)
@@ -706,8 +706,8 @@ int sample(mglGraph *gr)
   gr->Rotate(50,60);  gr->Box();
   gr->SubPlot(2,2,2); gr->Title("Rotate and Aspect");
   gr->Rotate(50,60);  gr->Aspect(1,1,2);  gr->Box();
-  gr->SubPlot(2,2,3); gr->Title("Aspect in other direction");
-  gr->Rotate(50,60);  gr->Aspect(1,2,2);  gr->Box();
+  gr->SubPlot(2,2,3); gr->Title("Shear");
+  gr->Box("c"); gr->Shear(0.2,0.1); gr->Box();
   return 0;
 }
 @end verbatim
@@ -734,7 +734,10 @@ int sample(mglGraph *gr)
   gr->GridPlot(2, 2, 3);  gr->Box("m"); gr->Puts(mglPoint(0),"3","m");
   gr->SubPlot(3,2,5,"");  gr->Title("InPlot");  gr->Box();
   gr->InPlot(0.4, 1, 0.6, 1, true); gr->Box("r");
-  gr->MultiPlot(3,2,1, 2, 1,"");  gr->Title("MultiPlot"); gr->Box();
+  gr->MultiPlot(3,2,1, 2, 1,"");  gr->Title("MultiPlot and ShearPlot"); gr->Box();
+  gr->ShearPlot(3, 0, 0.2, 0.1);  gr->Box("r"); gr->Puts(mglPoint(0),"0","r");
+  gr->ShearPlot(3, 1, 0.2, 0.1);  gr->Box("g"); gr->Puts(mglPoint(0),"1","g");
+  gr->ShearPlot(3, 2, 0.2, 0.1);  gr->Box("b"); gr->Puts(mglPoint(0),"2","b");
   return 0;
 }
 @end verbatim
@@ -3899,7 +3902,7 @@ int sample(mglGraph *gr)
   mglData in(9), arg(99), e, s;
   gr->Fill(in,"x^3/1.1"); gr->Fill(arg,"4*x+4");
   gr->Plot(in,"ko ");     gr->Box();
-  e = in.Evaluate(arg);   gr->Plot(e,"b.","legend 'Evaluate'");
+  e = in.Evaluate(arg,false); gr->Plot(e,"b.","legend 'Evaluate'");
   s = in.SubData(arg);    gr->Plot(s,"r.","legend 'SubData'");
   gr->Legend(2);
 }
index 96fee70578705f6cdaac868a16d72c56e62e0853..089d1a67787e8b8bd771cc75ad28009efc3b4dd5 100644 (file)
@@ -6,6 +6,7 @@ This appendix contain description of file formats used by MathGL.
 * Font files::
 * MGLD format::
 * JSON format::
+* IFS format::
 @end menu
 
 @c ------------------------------------------------------------------
@@ -75,7 +76,7 @@ Here nT is the number of triangles; nL is the number of line vertexes; xA, yA, x
 
 @c ------------------------------------------------------------------
 @external{}
-@node JSON format, , MGLD format, File formats
+@node JSON format, IFS format, MGLD format, File formats
 @section JSON format
 @nav{}
 
@@ -97,7 +98,7 @@ array of coordinates of points (vertexes), each element is array in form [x, y,
 @item nprim
 number of primitives;
 @item prim
-array of primitives, each element is array in form [type, n1, n2, n3, n4, id, s, w, p, z, color]. 
+array of primitives, each element is array in form [type, n1, n2, n3, n4, id, s, w, p, z, color].
 
 Here @var{type} is kind of primitive (0 - mark, 1 - line, 2 - triangle, 3 - quadrangle, 4 - glyph), @var{n1}...@var{n4} is index of point for vertexes and @var{n2} can be index of glyph coordinate, @var{s} and @var{w} are size and width if applicable, @var{z} is average z-coordinate, @var{id} is primitive identification number, @var{p} is scaling factor for glyphs.
 
@@ -112,4 +113,29 @@ number of glyph descriptions
 array of glyph descriptions, each element is array in form @code{[nL, [xP0, yP0, xP1, yP1 ...]]}. Here @code{nL} is the number of line vertexes; and @code{xP, yP, xQ, yQ} are coordinates of lines. Line coordinate xP=0x3fff, yP=0x3fff denote line breaking.
 
 @end table
+
+@c ------------------------------------------------------------------
+@external{}
+@node IFS format, , JSON format, File formats
+@section IFS format
+@nav{}
+
+MathGL can read IFS fractal parameters (see @ref{ifsfile}) from a IFS file. Let remind IFS file format. File may contain several records. Each record contain the name of fractal (@samp{binary} in the example below) and the body of fractal, which is enclosed in curly braces @{@}. Symbol @samp{;} start the comment. If the name of fractal contain @samp{(3D)} or @samp{(3d)} then the 3d IFS fractal is specified. The sample below contain two fractals: @samp{binary} -- usual 2d fractal, and @samp{3dfern (3D)} -- 3d fractal.
+
+@verbatim
+ binary
+ { ; comment allowed here
+  ; and here
+  .5  .0 .0 .5 -2.563477 -0.000003 .333333   ; also comment allowed here
+  .5  .0 .0 .5  2.436544 -0.000003 .333333
+  .0 -.5 .5 .0  4.873085  7.563492 .333333
+  }
+
+ 3dfern (3D) {
+   .00  .00 0 .0 .18 .0 0  0.0 0.00 0 0.0 0 .01
+   .85  .00 0 .0 .85 .1 0 -0.1 0.85 0 1.6 0 .85
+   .20 -.20 0 .2 .20 .0 0  0.0 0.30 0 0.8 0 .07
+  -.20  .20 0 .2 .20 .0 0  0.0 0.30 0 0.8 0 .07
+  }
+@end verbatim
 @external{}
index 96fee70578705f6cdaac868a16d72c56e62e0853..089d1a67787e8b8bd771cc75ad28009efc3b4dd5 100644 (file)
@@ -6,6 +6,7 @@ This appendix contain description of file formats used by MathGL.
 * Font files::
 * MGLD format::
 * JSON format::
+* IFS format::
 @end menu
 
 @c ------------------------------------------------------------------
@@ -75,7 +76,7 @@ Here nT is the number of triangles; nL is the number of line vertexes; xA, yA, x
 
 @c ------------------------------------------------------------------
 @external{}
-@node JSON format, , MGLD format, File formats
+@node JSON format, IFS format, MGLD format, File formats
 @section JSON format
 @nav{}
 
@@ -97,7 +98,7 @@ array of coordinates of points (vertexes), each element is array in form [x, y,
 @item nprim
 number of primitives;
 @item prim
-array of primitives, each element is array in form [type, n1, n2, n3, n4, id, s, w, p, z, color]. 
+array of primitives, each element is array in form [type, n1, n2, n3, n4, id, s, w, p, z, color].
 
 Here @var{type} is kind of primitive (0 - mark, 1 - line, 2 - triangle, 3 - quadrangle, 4 - glyph), @var{n1}...@var{n4} is index of point for vertexes and @var{n2} can be index of glyph coordinate, @var{s} and @var{w} are size and width if applicable, @var{z} is average z-coordinate, @var{id} is primitive identification number, @var{p} is scaling factor for glyphs.
 
@@ -112,4 +113,29 @@ number of glyph descriptions
 array of glyph descriptions, each element is array in form @code{[nL, [xP0, yP0, xP1, yP1 ...]]}. Here @code{nL} is the number of line vertexes; and @code{xP, yP, xQ, yQ} are coordinates of lines. Line coordinate xP=0x3fff, yP=0x3fff denote line breaking.
 
 @end table
+
+@c ------------------------------------------------------------------
+@external{}
+@node IFS format, , JSON format, File formats
+@section IFS format
+@nav{}
+
+MathGL can read IFS fractal parameters (see @ref{ifsfile}) from a IFS file. Let remind IFS file format. File may contain several records. Each record contain the name of fractal (@samp{binary} in the example below) and the body of fractal, which is enclosed in curly braces @{@}. Symbol @samp{;} start the comment. If the name of fractal contain @samp{(3D)} or @samp{(3d)} then the 3d IFS fractal is specified. The sample below contain two fractals: @samp{binary} -- usual 2d fractal, and @samp{3dfern (3D)} -- 3d fractal.
+
+@verbatim
+ binary
+ { ; comment allowed here
+  ; and here
+  .5  .0 .0 .5 -2.563477 -0.000003 .333333   ; also comment allowed here
+  .5  .0 .0 .5  2.436544 -0.000003 .333333
+  .0 -.5 .5 .0  4.873085  7.563492 .333333
+  }
+
+ 3dfern (3D) {
+   .00  .00 0 .0 .18 .0 0  0.0 0.00 0 0.0 0 .01
+   .85  .00 0 .0 .85 .1 0 -0.1 0.85 0 1.6 0 .85
+   .20 -.20 0 .2 .20 .0 0  0.0 0.30 0 0.8 0 .07
+  -.20  .20 0 .2 .20 .0 0  0.0 0.30 0 0.8 0 .07
+  }
+@end verbatim
 @external{}
index e631a217ee813f61669dded402a1e3659cc498cc..fa03fd7617c7b39bd2d7e8190ad1cd72c2886e4b 100644 (file)
@@ -24,7 +24,7 @@ MathGL library supports the simplest scripts for data handling and plotting. The
 @section MGL definition
 @nav{}
 
-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 important, 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.
+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. Words are separated from each other by space or tabulation symbol. The upper or lower case of words is important, 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).
 
@@ -60,6 +60,13 @@ Before the first using all variables must be defined with the help of commands,
 
 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{text ydat ['stl'='']} or @code{text x y 'txt' ['fnt'='' size=-1]}. 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{text x y 'txt' '' 1} or @code{text x y 'txt' ''} is correct, but @code{text x y 'txt' 1} is incorrect (argument @code{'fnt'} is missed).
 
+You can provide several variants of arguments for a command by using @samp{?} symbol for separating them. The actual argument being used is set by @ref{variant}. At this, the last argument is used if the value of @ref{variant} is large than the number of provided variants. By default the first argument is used (i.e. as for @code{variant 0}). For example, the first plot will be drawn by blue (default is the first argument @samp{b}), but the plot after @code{variant 1} will be drawn by red dash (the second is @samp{r|}):
+@verbatim
+fplot 'x' 'b'?'r'
+variant 1
+fplot 'x^3' 'b'?'r|'
+@end verbatim
+
 
 @c ------------------------------------------------------------------
 @external{}
@@ -181,6 +188,12 @@ The code between @code{once on} and @code{once off} will be executed only once.
 Terminate execution.
 @end deftypefn
 
+@cindex variant
+@anchor{variant}
+@deftypefn {MGL command} {} variant @code{val}
+Set variant of argument(s) separated by @samp{?} symbol to be used in further commands.
+@end deftypefn
+
 
 @cindex rkstep
 @anchor{rkstep}
@@ -434,6 +447,11 @@ Allow to parse @ref{load} command or not.
 Sends stop signal which terminate execution at next command.
 @end deftypefn
 
+@deftypefn {Method on @code{mglParse}} @code{void} SetVariant (@code{int} var=@code{0})
+@deftypefnx {C function} @code{void} mgl_parser_variant (@code{HMPR} p, @code{int} var=@code{0})
+Sets variant of argument(s) separated by @samp{?} symbol to be used in further commands.
+@end deftypefn
+
 
 @deftypefn {Method on @code{mglParse}} @code{long} GetCmdNum ()
 @deftypefnx {C function} @code{long} mgl_parser_cmd_num (@code{HMPR} p)
index d51da364ec4325a3618346bb8c4871c20f3720f9..f03006ae18ed455ff68210812bb60bda48ed6c3e 100644 (file)
@@ -61,6 +61,13 @@ MathGL имеет встроенный скриптовый язык MGL для
 
 Команды могут иметь несколько наборов аргументов (например, @code{plot ydat} и @code{plot xdat ydat}). Все аргументы команды для выбранного набора должны быть указаны, однако часть из них могут иметь значения по умолчанию. Такие аргументы в описании команд будут помещены в квадратные скобки [], например @code{plot ydat ['stl'='' zval=nan]}. При этом запись @code{[arg1 arg2 arg3 ...]} подразумевает @code{[arg1 [arg2 [arg3 ...]]]}, т.е. опускать можно только аргументы с конца, если вы согласны с их значениями по умолчанию. Например, @code{plot ydat '' 1} или @code{plot ydat ''} правильно, а @code{plot ydat 1} не правильно (аргумент @code{'stl'} пропущен).
 
+Можно предоставить несколько вариантов аргументов комманд при использовании символа @samp{?} для их разделения. Конкретный вариант аргумента, используемый при выполнении команды, задается значением команды @ref{variant}. При этом будет использован последний вариант, если задано слишком большое значение. По умолчанию используется первый вариант (т.е. как при @code{variant 0}). Например в следующем коде будет сначала нарисован график синим цветом (первый аргумент @samp{b}), а затем красным пунктиром -- после @code{variant 1} будет использован второй аргумент @samp{r|}:
+@verbatim
+fplot 'x' 'b'?'r'
+variant 1
+fplot 'x^3' 'b'?'r|'
+@end verbatim
+
 
 
 @c TODO Translate it!
@@ -75,80 +82,80 @@ MathGL имеет встроенный скриптовый язык MGL для
 
 @cindex chdir
 @anchor{chdir}
-@deftypefn {MGL command} {} chdir 'path'
+@deftypefn {Команда MGL} {} chdir 'path'
 Переходит в папку @var{path}.
 @end deftypefn
 
 @cindex ask
 @anchor{ask}
-@deftypefn {MGL command} {} ask $N 'question'
+@deftypefn {Команда MGL} {} ask $N 'question'
 Задает @var{N}-ый аргумент скрипта равным ответу пользователя на вопрос @var{question}. Обычно команда показывает диалог с вопросом и полем ввода текста ответа. Здесь @var{N} это цифра (0...9) или буква (a...z).
 @end deftypefn
 
 @cindex define
 @anchor{define}
-@deftypefn {MGL command} {} define $N smth
+@deftypefn {Команда MGL} {} define $N smth
 Задает @var{N}-ый аргумент скрипта равным @var{smth}. Отмечу, что @var{smth} используется как есть (с символами @samp{'} если присутствуют). Выполняется только подстановка других макроопределений $0...$9, $a...$z. Здесь @var{N} это цифра (0...9) или буква (a...z).
 @end deftypefn
-@deftypefn {MGL command} {} define name smth
+@deftypefn {Команда MGL} {} define name smth
 Определяет константу (скаляр) с именем @code{name} и числовым значением @code{smth}. Позднее она может быть использована как обычное число.
 @end deftypefn
 @cindex defchr
 @anchor{defchr}
-@deftypefn {MGL command} {} defchr $N smth
+@deftypefn {Команда MGL} {} defchr $N smth
 Задает @var{N}-ый аргумент скрипта равным символу с UTF кодом @var{smth}. Здесь @var{N} это цифра (0...9) или буква (a...z).
 @end deftypefn
 @cindex defnum
 @anchor{defnum}
-@deftypefn {MGL command} {} defnum $N smth
+@deftypefn {Команда MGL} {} defnum $N smth
 Задает @var{N}-ый аргумент скрипта равным числовому значению @var{smth}. Здесь @var{N} это цифра (0...9) или буква (a...z).
 @end deftypefn
 
 @comment  @cindex defpal
 @comment  @anchor{defpal}
-@comment  @deftypefn {MGL command} {} defpal $N smth
+@comment  @deftypefn {Команда MGL} {} defpal $N smth
 @comment  Задает @var{N}-ый аргумент скрипта равным символу палитры с индексом, найденным из @var{smth}. Здесь @var{N} это цифра (0...9) или буква (a...z).
 @comment  @end deftypefn
 
 @cindex call
 @anchor{call}
-@deftypefn {MGL command} {} call 'fname' [ARG1 ARG2 ... ARG9]
+@deftypefn {Команда MGL} {} call 'fname' [ARG1 ARG2 ... ARG9]
 Переходит к выполнению (вызывает) подпрограммы @var{fname} (или внешнего скрипта, если функция не была найдена). Опциональные аргументы передаются в подпрограмму. См. также @ref{func}.
 @end deftypefn
 
 @cindex func
 @anchor{func}
-@deftypefn {MGL command} {} func 'fname' [narg=0]
+@deftypefn {Команда MGL} {} func 'fname' [narg=0]
 Определяет подпрограмму с именем @var{fname} и задает число требуемых аргументов. Аргументы будут помещены в параметры скрипта $1, $2, ... $9. Отмечу, что выполнение основной программы будет остановлено при встрече @code{func} -- действует аналогично комманде @ref{stop}. См. также @ref{return}.
 
 @end deftypefn
 @cindex return
 @anchor{return}
-@deftypefn {MGL command} {} return
+@deftypefn {Команда MGL} {} return
 Возвращается из подпрограммы. См. также @ref{func}.
 @end deftypefn
 
 @cindex load
 @anchor{load}
-@deftypefn {MGL command} {} load 'filename'
+@deftypefn {Команда MGL} {} load 'filename'
 Загружает дополнительные команды MGL из внешней динамической библиотеки @var{filename}. Данная библиотека должна содержать массив с именем @code{mgl_cmd_extra} типа  @code{mglCommand}, который содержит описание новых комманд.
 @end deftypefn
 
 
 @cindex if
 @anchor{if}
-@deftypefn {MGL command} {} if dat 'cond'
+@deftypefn {Команда MGL} {} if dat 'cond'
 Начинает блок команд, выполняемый если каждый элемент @var{dat} удовлетворяет условию @var{cond}.
 @end deftypefn
-@deftypefn {MGL command} {} if @code{val}
+@deftypefn {Команда MGL} {} if @code{val}
 Начинает блок команд, выполняемый если @code{val} не ноль.
 @end deftypefn
 @cindex elseif
 @anchor{elseif}
-@deftypefn {MGL command} {} elseif dat 'cond'
+@deftypefn {Команда MGL} {} elseif dat 'cond'
 Начинает блок команд, выполняемый если предыдущий @code{if} или @code{elseif} не был выполнен и каждый элемент @var{dat} удовлетворяет условию @var{cond}.
 @end deftypefn
-@deftypefn {MGL command} {} elseif @code{val}
+@deftypefn {Команда MGL} {} elseif @code{val}
 Начинает блок команд, выполняемый если предыдущий @code{if} или @code{elseif} не был выполнен и @code{val} не ноль.
 @end deftypefn
 @cindex else
@@ -164,7 +171,7 @@ MathGL имеет встроенный скриптовый язык MGL для
 
 @cindex for
 @anchor{for}
-@deftypefn {MGL command} {} for $N @code{v1 v2 [dv=1]}
+@deftypefn {Команда MGL} {} for $N @code{v1 v2 [dv=1]}
 Начинает блок команд, выполняемый в цикле с $@var{N}-ым аргументом изменяющимся от @var{v1} до @var{v2} с шагом @var{dv}. Здесь @var{N} это цифра (0...9) или буква (a...z).
 @end deftypefn
 @deftypefn {Команда MGL} {} for $N dat
@@ -178,18 +185,27 @@ MathGL имеет встроенный скриптовый язык MGL для
 
 @cindex once
 @anchor{once}
-@deftypefn {MGL command} {} once @code{val}
+@deftypefn {Команда MGL} {} once @code{val}
 Определяет код (между @code{once on} и @code{once off}) который будет выполнен только один раз. Полезно для работы с большими данными в программах типа UDAV.
 @end deftypefn
 @cindex stop
 @anchor{stop}
-@deftypefn {MGL command} {} stop
+@deftypefn {Команда MGL} {} stop
 Останавливает выполнение скрипта.
 @end deftypefn
 
+
+@cindex variant
+@anchor{variant}
+@deftypefn {Команда MGL} {} variant @code{val}
+Задает вариант аргумента(ов), разделенных символом @samp{?}, для всех последующих комманд.
+@end deftypefn
+
+
+
 @cindex rkstep
 @anchor{rkstep}
-@deftypefn {MGL command} {} rkstep eq1;... var1;... [@code{dt=1}]
+@deftypefn {Команда MGL} {} rkstep eq1;... var1;... [@code{dt=1}]
 Выполняет один шаг решения системы обыкновенных дифференциальных уравнений @{var1' = eq1, ... @} с временным шагом @var{dt}. Здесь переменные @samp{var1}, ... -- переменные, определенные в MGL скрипте ранее. При решении используется метод Рунге-Кутта 4-го порядка.
 @end deftypefn
 
@@ -443,6 +459,11 @@ As an additional feature, when an image is not found or cannot be included, inst
 Посылает сигнал завершения выполнения для следующей команды.
 @end deftypefn
 
+@deftypefn {Метод класса @code{mglParse}} @code{void} SetVariant (@code{int} var=@code{0})
+@deftypefnx {Функция С} @code{void} mgl_parser_variant (@code{HMPR} p, @code{int} var=@code{0})
+Задает вариант аргумента(ов), разделенных символом @samp{?}, для всех последующих комманд.
+@end deftypefn
+
 
 @deftypefn {Метод класса @code{mglParse}} @code{long} GetCmdNum ()
 @deftypefnx {Функция С} @code{long} mgl_parser_cmd_num (@code{HMPR} p)
@@ -469,10 +490,10 @@ As an additional feature, when an image is not found or cannot be included, inst
 Возвращает описание команды MGL с именем @var{name}.
 @end deftypefn
 
-@deftypefn {Method on @code{mglParse}} @code{void} RK_Step (@code{const char *}eqs, @code{const char *}vars, @code{mreal} dt=@code{1})
-@deftypefnx {Method on @code{mglParse}} @code{void} RK_Step (@code{const wchar_t *}eqs, @code{const wchar_t *}vars, @code{mreal} dt=@code{1})
-@deftypefnx {C function} @code{void} mgl_rk_step (@code{HMPR} p, @code{const char *}eqs, @code{const char *}vars, @code{mreal} dt)
-@deftypefnx {C function} @code{void} mgl_rk_step_w (@code{HMPR} p, @code{const wchar_t *}eqs, @code{const wchar_t *}vars, @code{mreal} dt)
+@deftypefn {Метод класса @code{mglParse}} @code{void} RK_Step (@code{const char *}eqs, @code{const char *}vars, @code{mreal} dt=@code{1})
+@deftypefnx {Метод класса @code{mglParse}} @code{void} RK_Step (@code{const wchar_t *}eqs, @code{const wchar_t *}vars, @code{mreal} dt=@code{1})
+@deftypefnx {Функция С} @code{void} mgl_rk_step (@code{HMPR} p, @code{const char *}eqs, @code{const char *}vars, @code{mreal} dt)
+@deftypefnx {Функция С} @code{void} mgl_rk_step_w (@code{HMPR} p, @code{const wchar_t *}eqs, @code{const wchar_t *}vars, @code{mreal} dt)
 Make one step for ordinary differential equation(s) @{var1' = eq1, ... @} with time-step @var{dt}. Here strings @var{eqs} and @var{vars} contain the equations and variable names separated by symbol @samp{;}. The variable(s) @samp{var1}, ... are the ones, defined in MGL script previously. The Runge-Kutta 4-th order method is used.
 @end deftypefn
 
index 00e102bbbd0436930d3faa0c177a057132602794..16be5545591d5dc5c7e7be15bf223d507cff2a85 100644 (file)
@@ -70,6 +70,8 @@ one of marks (see @ref{Line styles});
 
 one of mask for face filling (see @ref{Color scheme});
 
+set to start flow threads from 2d array inside data (see @ref{flow});
+
 operation in @ref{Textual formulas}.
 
 @item +
@@ -112,14 +114,16 @@ line dashing style (see @ref{Line styles});
 
 stop color scheme parsing (see @ref{Color scheme});
 
-range operation in @ref{MGL scripts}.
+range operation in @ref{MGL scripts};
+
+separator of commands in @ref{MGL scripts}.
 
 @item ;
 line dashing style (see @ref{Line styles});
 
 one of mask for face filling (see @ref{Color scheme});
 
-end of an option in @ref{MGL scripts} or in @ref{Command options}.
+start of an option in @ref{MGL scripts} or in @ref{Command options}.
 
 @item <
 one of marks (see @ref{Line styles});
@@ -176,7 +180,9 @@ set to draw edges for @ref{cone};
 
 set to draw filled boxes for @ref{boxs};
 
-reduce text size inside a string (see @ref{Font styles}).
+reduce text size inside a string (see @ref{Font styles});
+
+operation in @ref{Textual formulas}.
 
 @item ^
 one of marks (see @ref{Line styles});
index 00e102bbbd0436930d3faa0c177a057132602794..16be5545591d5dc5c7e7be15bf223d507cff2a85 100644 (file)
@@ -70,6 +70,8 @@ one of marks (see @ref{Line styles});
 
 one of mask for face filling (see @ref{Color scheme});
 
+set to start flow threads from 2d array inside data (see @ref{flow});
+
 operation in @ref{Textual formulas}.
 
 @item +
@@ -112,14 +114,16 @@ line dashing style (see @ref{Line styles});
 
 stop color scheme parsing (see @ref{Color scheme});
 
-range operation in @ref{MGL scripts}.
+range operation in @ref{MGL scripts};
+
+separator of commands in @ref{MGL scripts}.
 
 @item ;
 line dashing style (see @ref{Line styles});
 
 one of mask for face filling (see @ref{Color scheme});
 
-end of an option in @ref{MGL scripts} or in @ref{Command options}.
+start of an option in @ref{MGL scripts} or in @ref{Command options}.
 
 @item <
 one of marks (see @ref{Line styles});
@@ -176,7 +180,9 @@ set to draw edges for @ref{cone};
 
 set to draw filled boxes for @ref{boxs};
 
-reduce text size inside a string (see @ref{Font styles}).
+reduce text size inside a string (see @ref{Font styles});
+
+operation in @ref{Textual formulas}.
 
 @item ^
 one of marks (see @ref{Line styles});
index 8ac338c314605846de911e2aeefed3622a89fe0b..150c2723042eed0b3179ffc5047e69d7927675b6 100644 (file)
@@ -1,4 +1,4 @@
 @set VERSION ${MathGL_VERSION_MAJOR}.${MathGL_VERSION_MINOR}
 @set MINVER 
-@c @set MINVER .1
+@set MINVER .1
 @set NIGHT ${MGL_NIGHT}
index a1087f1c33c5a3f1d5894bcf1f090b34900c8a99..5a71907b5aa0b869e4cfb1b341abcd0233f138e3 100644 (file)
@@ -1,3 +1,5 @@
+2.3.5.1 Released 30 May 2015
+2.3.5 Released 16 May 2015
 2.3.4 Released 11 February 2015
 2.3.3 Released 01 June 2015
 2.3.2 Released 2 February 2015
index 967c47778a2dcff55f56dcd5bce70a15b0e92eee..62510b160986b1ccd9f35a29986fe3dc1bffd3a4 100644 (file)
@@ -52,8 +52,12 @@ Generally, MathGL is GPL library. However, you can use LGPL license for MathGL c
 
 @strong{Latest news}
 @itemize
-@item @emph{13 February 2016.}
-New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes, which denoted @ref{News, here}.
+
+@item @strong{20 June 2016.}
+New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes and bugfixes. @strong{NOTE}: there is incompatible change -- the library libmgl-qt is removed. You need to use libmgl-qt4 or libmgl-qt5 explicitly to reduce the possible error of wrong Qt libs linking.
+
+@item @emph{16 May 2016.}
+New version (v.2.3.5) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes, which denoted @ref{News, here}.
 @item @emph{7 August 2014.}
 New version (v.2.3) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are many major improvements for both MathGL core and for UDAV, which denoted @ref{News, here}.
 @end itemize
@@ -75,6 +79,123 @@ Javascript interface was developed with support of @url{http://www.datadvance.ne
 
 @itemize
 
+@item @strong{20 June 2016.}
+New version (v.2.3.5.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes and bugfixes. @strong{INCOMPATIBLE}: the library libmgl-qt is removed. You need to use libmgl-qt4 or libmgl-qt5 explicitly to reduce the possible error of wrong Qt libs linking.
+
+@item @strong{16 May 2016.}
+New version (v.2.3.5) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes:
+@itemize @bullet
+@item Update @ref{LaTeX package} (thanks to Diego Sejas Viscarra)
+
+@itemize @bullet
+@item
+@code{\MGL@@codes}: Bugfix: category code for tabulators is changed too
+@item
+@code{\MGL@@quality}: 9 is accepted as quality value now
+@item
+@code{\MGL@@scale}: Now accepts any positive value
+@item
+@code{\MGL@@test@@switch}: New command to verify and validate switching arguments
+@item
+@code{\mglTeX}: Add a small negative space in the logo, between the "mgl" and "TEX"
+@item
+@code{\mglTeX}: Declared now as robust command
+@item
+@code{\mglcomments}: Now accepts arguments 0 (equivalent to @code{off}) and 1 (equivalent to @code{on}), besides the usual @code{off} and @code{on}
+@item
+@code{\mglgraphics}: New command options: @code{gray, mglscale, quality, variant}
+@item
+@code{\mglname}: Now writes the MGL code line @samp{setsize 600 400} to the main script
+@item
+@code{\mglplot}: Added @code{\bgroup} and @code{\egroup} in order to keep changes private
+@item
+New command options: @code{gray, mglscale, quality, variant}
+@item
+@code{\mglsettings}: Added options @code{gray} and @code{variant}
+@item
+Now calls the @code{\mglswitch} and @code{\mglcomments} commands for the switch and comments options, respectively
+@item
+@code{\mglswitch}: Now accepts arguments 0 (equivalent to @code{off}) and 1 (equivalent to @code{on}), besides the usual @code{off} and @code{on}
+@item
+mglTeX now depends on the ifpdf package
+@item
+Change definition of @code{\mglcommentname} from MGL comment to mglTEX comment
+@item
+Introduce the concept of global, local and private settings in the documentation
+@item
+New commands: @code{\mglgray} (to activate/deactivate) gray-scale mode locally, and @code{\mglvariant} (to set variant of arguments in MGL scripts locally)
+@item
+New package option @code{9q} for setting quality to 9 (for testing purposes of the author)
+@item
+New package options @code{0v, 1v, 2v} to select variant of arguments in MGL scripts
+@item
+New package options @code{gray, color} to activate/deactivate gray-scale mode for graphics
+@item
+Remove the @code{\MGL@@setkeys} command, since it isn’t needed as first thought
+@item
+Rename @code{\MGL@@document@@scripts} to @code{\MGL@@doc@@scripts}
+@item
+Rename @code{\MGL@@script@@name} to @code{\MGL@@script}
+@item
+Rename command @code{\MGL@@graph@@ext} to @code{\MGL@@imgext}
+@item
+Rename command @code{\mglcommonscriptname} to @code{\mglsetupscriptname}
+@item
+Rename environment @code{mglcommon} to @code{mglsetupscript} (@code{mglcommon} is still available, but deprecated)
+@item
+Rename family @code{MGL@@keys} as @code{MGL@@gr@@keys} for consistency
+@item
+Reorganize and update documentation
+@item
+Some minor bugfixes
+@item
+The MGL code line @samp{setsize 600 400} is now automatically written to the main script in order for the scaling options and commands to work
+@item
+@code{mgl}: New environment options: gray, mglscale, quality, variant
+@item
+@code{\mglcode}: New environment options: gray, mglscale, quality, variant
+@end itemize
+
+@item
+Add MGL command @ref{variant} to select proper variant of arguments (like @samp{var1?var2?var3?...}) in MGL commands.
+@item
+Remove limitation of maximal number (was 1000) of arguments for MGL commands. This is actual for 'list' command.
+@item
+Add mglWnd::Widget() for accessing widget which is used for drawing.
+@item
+Add @ref{gray} for producing gray-scaled image.
+@item
+Add MGL command @ref{setsizescl} for scaling all further @ref{setsize}.
+@item
+Add @ref{shear} for shearing plot.
+@item
+Add @ref{shearplot} for placing plots side-by-side with some shearing.
+@item
+Add @ref{limit} for limit maximal absolute value of data.
+@item
+Add @ref{tridmat} for tridiagonal matrix algorithm.
+@item
+Add MGL command @ref{diffract} for single step diffraction calculation.
+@item
+Add @ref{ifsfile} for reading IFS fractal parameters from *.ifs file.
+@item
+Add style @samp{*} for 2d versions of @ref{flow} to draw threads from points inside axis range.
+@item
+Add @samp{norm()} to the list of known functions
+@item
+Compatibility changes for MS VisualStudio, MacOS, Win64.
+@item
+Bugfix for legend export into EPS and SVG.
+@item
+Bugfix for importing data from std::vector.
+@item
+Improve Surf3*() drawing.
+@item
+Force NAN if divided by 0 in formulas.
+@item
+Option "-S" of mglconv now perform scaling in any cases
+@end itemize
+
 @item @strong{13 February 2016.}
 New version (v.2.3.4) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes:
 @itemize @bullet
index 967c47778a2dcff55f56dcd5bce70a15b0e92eee..f53e3f926e036a646ef381e208556bba285e532f 100644 (file)
@@ -52,8 +52,10 @@ Generally, MathGL is GPL library. However, you can use LGPL license for MathGL c
 
 @strong{Latest news}
 @itemize
-@item @emph{13 February 2016.}
-New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes, which denoted @ref{News, here}.
+@item @strong{20 June 2016.}
+New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes and bugfixes. @strong{NOTE}: there is incompatible change -- the library libmgl-qt is removed. You need to use libmgl-qt4 or libmgl-qt5 explicitly to reduce the possible error of wrong Qt libs linking.
+@item @emph{16 May 2016.}
+New version (v.2.3.5) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes, which denoted @ref{News, here}.
 @item @emph{7 August 2014.}
 New version (v.2.3) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are many major improvements for both MathGL core and for UDAV, which denoted @ref{News, here}.
 @end itemize
@@ -75,6 +77,123 @@ Javascript interface was developed with support of @url{http://www.datadvance.ne
 
 @itemize
 
+@item @strong{20 June 2016.}
+New version (v.2.3.5.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes and bugfixes. @strong{INCOMPATIBLE}: the library libmgl-qt is removed. You need to use libmgl-qt4 or libmgl-qt5 explicitly to reduce the possible error of wrong Qt libs linking.
+
+@item @strong{16 May 2016.}
+New version (v.2.3.5) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes:
+@itemize @bullet
+@item Update @ref{LaTeX package} (thanks to Diego Sejas Viscarra)
+
+@itemize @bullet
+@item
+@code{\MGL@@codes}: Bugfix: category code for tabulators is changed too
+@item
+@code{\MGL@@quality}: 9 is accepted as quality value now
+@item
+@code{\MGL@@scale}: Now accepts any positive value
+@item
+@code{\MGL@@test@@switch}: New command to verify and validate switching arguments
+@item
+@code{\mglTeX}: Add a small negative space in the logo, between the "mgl" and "TEX"
+@item
+@code{\mglTeX}: Declared now as robust command
+@item
+@code{\mglcomments}: Now accepts arguments 0 (equivalent to @code{off}) and 1 (equivalent to @code{on}), besides the usual @code{off} and @code{on}
+@item
+@code{\mglgraphics}: New command options: @code{gray, mglscale, quality, variant}
+@item
+@code{\mglname}: Now writes the MGL code line @samp{setsize 600 400} to the main script
+@item
+@code{\mglplot}: Added @code{\bgroup} and @code{\egroup} in order to keep changes private
+@item
+New command options: @code{gray, mglscale, quality, variant}
+@item
+@code{\mglsettings}: Added options @code{gray} and @code{variant}
+@item
+Now calls the @code{\mglswitch} and @code{\mglcomments} commands for the switch and comments options, respectively
+@item
+@code{\mglswitch}: Now accepts arguments 0 (equivalent to @code{off}) and 1 (equivalent to @code{on}), besides the usual @code{off} and @code{on}
+@item
+mglTeX now depends on the ifpdf package
+@item
+Change definition of @code{\mglcommentname} from MGL comment to mglTEX comment
+@item
+Introduce the concept of global, local and private settings in the documentation
+@item
+New commands: @code{\mglgray} (to activate/deactivate) gray-scale mode locally, and @code{\mglvariant} (to set variant of arguments in MGL scripts locally)
+@item
+New package option @code{9q} for setting quality to 9 (for testing purposes of the author)
+@item
+New package options @code{0v, 1v, 2v} to select variant of arguments in MGL scripts
+@item
+New package options @code{gray, color} to activate/deactivate gray-scale mode for graphics
+@item
+Remove the @code{\MGL@@setkeys} command, since it isn’t needed as first thought
+@item
+Rename @code{\MGL@@document@@scripts} to @code{\MGL@@doc@@scripts}
+@item
+Rename @code{\MGL@@script@@name} to @code{\MGL@@script}
+@item
+Rename command @code{\MGL@@graph@@ext} to @code{\MGL@@imgext}
+@item
+Rename command @code{\mglcommonscriptname} to @code{\mglsetupscriptname}
+@item
+Rename environment @code{mglcommon} to @code{mglsetupscript} (@code{mglcommon} is still available, but deprecated)
+@item
+Rename family @code{MGL@@keys} as @code{MGL@@gr@@keys} for consistency
+@item
+Reorganize and update documentation
+@item
+Some minor bugfixes
+@item
+The MGL code line @samp{setsize 600 400} is now automatically written to the main script in order for the scaling options and commands to work
+@item
+@code{mgl}: New environment options: gray, mglscale, quality, variant
+@item
+@code{\mglcode}: New environment options: gray, mglscale, quality, variant
+@end itemize
+
+@item
+Add MGL command @ref{variant} to select proper variant of arguments (like @samp{var1?var2?var3?...}) in MGL commands.
+@item
+Remove limitation of maximal number (was 1000) of arguments for MGL commands. This is actual for 'list' command.
+@item
+Add mglWnd::Widget() for accessing widget which is used for drawing.
+@item
+Add @ref{gray} for producing gray-scaled image.
+@item
+Add MGL command @ref{setsizescl} for scaling all further @ref{setsize}.
+@item
+Add @ref{shear} for shearing plot.
+@item
+Add @ref{shearplot} for placing plots side-by-side with some shearing.
+@item
+Add @ref{limit} for limit maximal absolute value of data.
+@item
+Add @ref{tridmat} for tridiagonal matrix algorithm.
+@item
+Add MGL command @ref{diffract} for single step diffraction calculation.
+@item
+Add @ref{ifsfile} for reading IFS fractal parameters from *.ifs file.
+@item
+Add style @samp{*} for 2d versions of @ref{flow} to draw threads from points inside axis range.
+@item
+Add @samp{norm()} to the list of known functions
+@item
+Compatibility changes for MS VisualStudio, MacOS, Win64.
+@item
+Bugfix for legend export into EPS and SVG.
+@item
+Bugfix for importing data from std::vector.
+@item
+Improve Surf3*() drawing.
+@item
+Force NAN if divided by 0 in formulas.
+@item
+Option "-S" of mglconv now perform scaling in any cases
+@end itemize
+
 @item @strong{13 February 2016.}
 New version (v.2.3.4) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes:
 @itemize @bullet
index d9f51699192788524e3ae781fac35fdf36a4e47e..79cb4b49aef276d96e2696c63ff9d25e163e6536 100644 (file)
@@ -176,6 +176,12 @@ showing the last mouse click position in the widget.
 Gets last position of mouse click.
 @end deftypefn
 
+@deftypefn {Method on @code{mglWnd}} @code{void *} Widget ()
+@deftypefnx {C function} @code{void *} mgl_fltk_widget (@code{HMGL} gr)
+@deftypefnx {C function} @code{void *} mgl_qt_widget (@code{HMGL} gr)
+Return pointer to widget (@ref{Fl_MathGL class} or @ref{QMathGL class}) used for plotting.
+@end deftypefn
+
 
 @c ------------------------------------------------------------------
 @external{}
index 5066c5891d93d485bd74a00fe6efcb02cfb6de7e..7f08187e517c1d8a06f6a738e070d8b33f5484d5 100644 (file)
@@ -177,6 +177,12 @@ public:
 Возвращает положение щелчка мыши.
 @end deftypefn
 
+@deftypefn {Method on @code{mglWnd}} @code{void *} Widget ()
+@deftypefnx {C function} @code{void *} mgl_fltk_widget (@code{HMGL} gr)
+@deftypefnx {C function} @code{void *} mgl_qt_widget (@code{HMGL} gr)
+Возвращает указатель на виджет (@ref{Fl_MathGL class} or @ref{QMathGL class}), используемый для рисования.
+@end deftypefn
+
 @c ------------------------------------------------------------------
 @external{}
 @node mglDraw class, Fl_MathGL class, mglWnd class, Widget classes
index 2bef2163cf59eeb1d294ed1f9439c21012ffe3c0..c86c56f0f426903d924ac7e46e79c2730cc0cf34 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -47,19 +47,23 @@ void DrawGlyph(int id, mglPoint pos, double angle, double scale, const char *stl
 11. Iris plot -- https://en.wikipedia.org/wiki/Iris_flower_data_set
 12. Parallel drawing in QMathGL.
 
+17. Speed up QMathGL + option to whole redraw instead of view
+
 ZZ. Update *.i for new functions {before release!!!}
 
 
 ============= DOCUMENTATION =============
 
-A. Paper about MathGL!!! 6099610006
+A. Paper about MathGL!!!
 B. Add chapter with real samples
 C. Translate to Russian everything
 D. Docs about JS interface
 
-6. Update Qt and UDAV figures
-
-YY. Sample like http://pyxplot.org.uk/examples/05ap/02hlines/index.html using Stem()
+1. Update Qt and UDAV figures
+2. Sample about PDE -- add 'tridmat' + 'diffract'
+3. Replace mgl-qt!!!
+4. Step_xy() now can have x.nx>y.nx -- same as Bars()
+5. Docs about 'flame2d'
 
 ============= UDAV =============
 
index 4c80b360ad6138e3194620f06138fe02ac648dc6..8ed4e9adfc3621d21d709cb09efaf57d697c3809 100644 (file)
@@ -18,16 +18,6 @@ if(WIN32)
        set(udav_src ${udav_src} udav.rc)
 endif(WIN32)
 
-if(MGL_HAVE_HDF5)
-#      target_link_libraries(mgl ${HDF5_LIBRARIES})
-       include_directories(${HDF5_INCLUDE_DIR})
-endif(MGL_HAVE_HDF5)
-
-if(MGL_HAVE_GSL)
-#      target_link_libraries(mgl ${GSL_LIB} ${GSL_CBLAS_LIB} )
-       include_directories(${GSL_INCLUDE_DIR})
-endif(MGL_HAVE_GSL)
-
 if(enable-qt5)
        include(../cmake-qt5.txt)
        qt5_add_resources(udav_rc_src ${udav_rc} )
@@ -38,11 +28,9 @@ endif(enable-qt5)
 add_executable(udav ${udav_src} ${udav_moc_hdr} ${udav_rc_src})
 #set_target_properties(udav PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
 if(enable-qt5)
-       target_link_libraries(udav mgl-qt5)
-       qt5_use_modules(udav ${MGL_QT5_LIBS})
+       target_link_libraries(udav mgl-qt5 ${MGL_QT5_LIBS})
 else(enable-qt5)
-       target_link_libraries(udav mgl-qt4)
-       qt4_use_modules(udav ${MGL_QT4_LIBS})
+       target_link_libraries(udav mgl-qt4 ${MGL_QT4_LIBS})
 endif(enable-qt5)
 
 if(MGL_HAVE_PTHREAD)
index 4a34682dbbbf44513687c4d056b7a6ffd5f1d7ce..0637591dbf5774b0d28dbc3d56dc230fa77ea0ae 100644 (file)
@@ -21,6 +21,9 @@
 #define ANIMPARAM_H
 //-----------------------------------------------------------------------------
 #include <QDialog>
+#if defined(_MSC_VER)
+#include <mgl2/define.h>
+#endif
 //-----------------------------------------------------------------------------
 class QLineEdit;
 class QTextEdit;
index 950886a53d43b17dc58a1827ec983b4db6a66fd9..eec9d767d7e833aa1b9e51e18155615755829a05 100644 (file)
@@ -145,7 +145,7 @@ void DatPanel::setVar(mglDataA *v)
        nx = ny = nz = kz = 0;
        if(v)
        {
-               QString s = QString::fromStdWString(v->s);
+               QString s = QString::fromWCharArray(v->s.c_str());
                v->o = this;    v->func = deleteDat;
                refresh();
                setWindowTitle(s + tr(" - UDAV variable"));
@@ -211,7 +211,7 @@ void DatPanel::putValue(int r, int c)
        if(s=="nan")    f=NAN;
        else if(s=="inf")       f=INFINITY;
        else if(s=="-inf")      f=-INFINITY;
-       else    g = mgl_str2dual(s.toStdString().c_str());      //f = s.toDouble();
+       else    g = mgl_str2dual(s.toLocal8Bit().constData());  //f = s.toDouble();
        f = real(g);
        mglDataC *cc = dynamic_cast<mglDataC*>(var);
        if(cc)
@@ -251,15 +251,15 @@ void DatPanel::save()
        {
                bool ok;
                QString s = QInputDialog::getText(this, tr("UDAV - Export to PNG"), tr("Enter color scheme for picture"), QLineEdit::Normal, MGL_DEF_SCH, &ok);
-               if(ok)  var->Export(fn.toStdString().c_str(), s.toStdString().c_str());
+               if(ok)  var->Export(fn.toLocal8Bit().constData(), s.toLocal8Bit().constData());
        }
        else if(ext=="h5" || ext=="hdf")
        {
                bool ok;
-               QString s = QInputDialog::getText(this, tr("UDAV - Save to HDF"), tr("Enter data name"), QLineEdit::Normal, QString::fromStdWString(var->s), &ok);
-               if(ok)  var->SaveHDF(fn.toStdString().c_str(), s.toStdString().c_str());
+               QString s = QInputDialog::getText(this, tr("UDAV - Save to HDF"), tr("Enter data name"), QLineEdit::Normal, QString::fromWCharArray(var->s.c_str()), &ok);
+               if(ok)  var->SaveHDF(fn.toLocal8Bit().constData(), s.toLocal8Bit().constData());
        }
-       else    var->Save(fn.toStdString().c_str());
+       else    var->Save(fn.toLocal8Bit().constData());
 }
 //-----------------------------------------------------------------------------
 void DatPanel::load()
@@ -273,15 +273,15 @@ void DatPanel::load()
        {
                bool ok;
                QString s = QInputDialog::getText(this, tr("UDAV - Import PNG"), tr("Enter color scheme for picture"), QLineEdit::Normal, MGL_DEF_SCH, &ok);
-               if(ok)  d->Import(fn.toStdString().c_str(), s.toStdString().c_str());
+               if(ok)  d->Import(fn.toLocal8Bit().constData(), s.toLocal8Bit().constData());
        }
        else if(ext=="h5" || ext=="hdf")
        {
                bool ok;
-               QString s = QInputDialog::getText(this, tr("UDAV - Read from HDF"), tr("Enter data name"), QLineEdit::Normal, QString::fromStdWString(var->s), &ok);
-               if(ok)  d->ReadHDF(fn.toStdString().c_str(), s.toStdString().c_str());
+               QString s = QInputDialog::getText(this, tr("UDAV - Read from HDF"), tr("Enter data name"), QLineEdit::Normal, QString::fromWCharArray(var->s.c_str()), &ok);
+               if(ok)  d->ReadHDF(fn.toLocal8Bit().constData(), s.toLocal8Bit().constData());
        }
-       else    d->Read(fn.toStdString().c_str());
+       else    d->Read(fn.toLocal8Bit().constData());
        refresh();
 }
 //-----------------------------------------------------------------------------
@@ -465,7 +465,7 @@ void DatPanel::hist()
        bool res = d->exec();
        if(res && !v1->text().isEmpty() && !v2->text().isEmpty() && !id->text().isEmpty())
        {
-               mglData *vv = dynamic_cast<mglData*>(parser.AddVar(id->text().toStdString().c_str()));
+               mglData *vv = dynamic_cast<mglData*>(parser.AddVar(id->text().toLocal8Bit().constData()));
                if(vv)  vv->Set(mgl_data_hist(var, nm->value(), v1->text().toDouble(), v2->text().toDouble(),0));
                updateDataItems();
        }
@@ -558,7 +558,7 @@ void DatPanel::newdat()
        bool res = d->exec();
        QString         val = f1->text(), mgl;
        int k = c->currentIndex();
-       QString self = QString::fromStdWString(var->s);
+       QString self = QString::fromWCharArray(var->s.c_str());
        if(res)
        {
                if(k<0)
@@ -594,7 +594,7 @@ void DatPanel::newdat()
        if(!mgl.isEmpty())
        {
                mglGraph gr;
-               parser.Execute(&gr,mgl.toStdString().c_str());
+               parser.Execute(&gr,mgl.toLocal8Bit().constData());
                if(k>=6)        opers += mgl+"\n";
                updateDataItems();
        }
@@ -635,7 +635,7 @@ void DatPanel::oper()
        bool res = d->exec();
        QString         val = f1->text(), mgl;
        int k = c->currentIndex();
-       QString self = QString::fromStdWString(var->s);
+       QString self = QString::fromWCharArray(var->s.c_str());
        if(res)
        {
                if(k<0)
@@ -665,7 +665,7 @@ void DatPanel::oper()
        if(!mgl.isEmpty())
        {
                mglGraph gr;
-               parser.Execute(&gr,mgl.toStdString().c_str());
+               parser.Execute(&gr,mgl.toLocal8Bit().constData());
                opers += mgl+"\n";
                updateDataItems();
        }
@@ -836,5 +836,5 @@ void DatPanel::toolLeft(QBoxLayout *l)
        bb = new QToolButton(this);     l->addWidget(bb);       bb->setDefaultAction(a);
 }
 //-----------------------------------------------------------------------------
-QString DatPanel::dataName()   {       return QString::fromStdWString(var->s); }
+QString DatPanel::dataName()   {       return QString::fromWCharArray(var->s.c_str()); }
 //-----------------------------------------------------------------------------
index 3ad3c551599be96f483488de995f68348796a04d..af3f0f4d6c224b2b3dbf70c3b43e6435c6361801 100644 (file)
@@ -132,7 +132,7 @@ void DataDialog::updateNames()
        for(i=0;i<n;i++)
        {
                const mglDataA *v = parser.GetVar(i);
-               if(v)   name->addItem(QString::fromStdWString(v->s));
+               if(v)   name->addItem(QString::fromWCharArray(v->s.c_str()));
        }
 }
 //-----------------------------------------------------------------------------
index 2bb3177a437ff184e87004986de5e844aaa3bf1c..1db3a5a6b25b2ad23d5725c3c925dee5815ec00c 100644 (file)
@@ -21,6 +21,9 @@
 #define FILES_DLG_H
 //-----------------------------------------------------------------------------
 #include <QDialog>
+#if defined(_MSC_VER)
+#include <mgl2/define.h>
+#endif
 class QLineEdit;
 class QComboBox;
 class QRadioButton;
index 921c25956c3f46b2457474e5cc8a253ff8c62c17..221901c13ef6fbd7cf42158ee020308bcbb18684 100644 (file)
@@ -24,6 +24,9 @@
 class QCheckBox;
 class QLineEdit;
 class QPushButton;
+#if defined(_MSC_VER)
+#include <mgl2/define.h>
+#endif
 //-----------------------------------------------------------------------------
 /// Dialog for finding something in text
 class FindDialog : public QDialog
index 132f7ed4b2775d4e3fe9ae3765aca482ac5118cf..c6e4a1d66d523ac2b06ac63f764729f2f06ef993 100644 (file)
@@ -21,6 +21,9 @@
 #define HELP_PNL_H
 //-----------------------------------------------------------------------------
 #include <QWidget>
+#if defined(_MSC_VER)
+#include <mgl2/define.h>
+#endif
 class QTextBrowser;
 class QLineEdit;
 //-----------------------------------------------------------------------------
index be555e42f1f262bad34f8d8bdde52dac912e1718..bb67fe0aecaf0aa050eb1886600ac78ff37b79a7 100644 (file)
 #include "hint_dlg.h"
 #include "mgl2/data_cf.h"
 //-----------------------------------------------------------------------------
-#define qtr    HintDialog::tr
-QString hints[] = {
-       qtr("You can shift axis range by pressing middle button and moving mouse. Also, you can zoom in/out axis range by using mouse wheel."),
-       qtr("You can rotate/shift/zoom whole plot by mouse. Just press 'Rotate' toolbutton, click image and hold a mouse button: left button for rotation, right button for zoom/perspective, middle button for shift."),
-       qtr("You may quickly draw the data from file. Just use: udav 'filename.dat' in command line."),
-       qtr("You can copy the current image to clipboard by pressing Ctrl-Shift-C. Later you can paste it directly into yours document or presentation."),
-       qtr("You can export image into a set of format (EPS, SVG, PNG, JPEG) by pressing right mouse button inside image and selecting 'Export as ...'."),
-       qtr("You can setup colors for script highlighting in Property dialog. Just select menu item 'Settings/Properties'."),
-       qtr("You can save the parameter of animation inside MGL script by using comment started from '##a ' or '##c ' for loops."),
-       qtr("New drawing never clears things drawn already. For example, you can make a surface with contour lines by calling commands 'surf' and 'cont' one after another (in any order). "),
-       qtr("You can put several plots in the same image by help of commands 'subplot' or 'inplot'."),
-       qtr("All indexes (of data arrays, subplots and so on) are always start from 0."),
-       qtr("You can edit MGL file in any text editor. Also you can run it in console by help of commands: mglconv, mglview."),
-       qtr("You can use command 'once on|off' for marking the block which should be executed only once. For example, this can be the block of large data reading/creating/handling. Press F9 (or menu item 'Graphics/Reload') to re-execute this block."),
-       qtr("You can use command 'stop' for terminating script parsing. It is useful if you don't want to execute a part of script."),
-       qtr("You can type arbitrary expression as input argument for data or number. In last case (for numbers), the first value of data array is used."),
-       qtr("There is powerful calculator with a lot of special functions. You can use buttons or keyboard to type the expression. Also you can use existed variables in the expression."),
-       qtr("The calculator can help you to put complex expression in the script. Just type the expression (which may depend on coordinates x,y,z and so on) and put it into the script."),
-       qtr("You can easily insert file or folder names, last fitted formula or numerical value of selection by using menu Edit|Insert."),
-       qtr("The special dialog (Edit|Insert|New Command) help you select the command, fill its arguments and put it into the script."),
-       qtr("You can put several plotting commands in the same line or in separate function, for highlighting all of them simultaneously."),
-       qtr("")
-};
-//-----------------------------------------------------------------------------
 //
 //     Hint dialog
 //
 //-----------------------------------------------------------------------------
 HintDialog::HintDialog(QWidget *parent) : QDialog(parent)
 {
-       for(numHints=0;!hints[numHints].isEmpty();numHints++);
+       hints.append(tr("You can shift axis range by pressing middle button and moving mouse. Also, you can zoom in/out axis range by using mouse wheel."));
+       hints.append(tr("You can rotate/shift/zoom whole plot by mouse. Just press 'Rotate' toolbutton, click image and hold a mouse button: left button for rotation, right button for zoom/perspective, middle button for shift."));
+       hints.append(tr("You may quickly draw the data from file. Just use: udav 'filename.dat' in command line."));
+       hints.append(tr("You can copy the current image to clipboard by pressing Ctrl-Shift-C. Later you can paste it directly into yours document or presentation."));
+       hints.append(tr("You can export image into a set of format (EPS, SVG, PNG, JPEG) by pressing right mouse button inside image and selecting 'Export as ...'."));
+       hints.append(tr("You can setup colors for script highlighting in Property dialog. Just select menu item 'Settings/Properties'."));
+       hints.append(tr("You can save the parameter of animation inside MGL script by using comment started from '##a ' or '##c ' for loops."));
+       hints.append(tr("New drawing never clears things drawn already. For example, you can make a surface with contour lines by calling commands 'surf' and 'cont' one after another (in any order). "));
+       hints.append(tr("You can put several plots in the same image by help of commands 'subplot' or 'inplot'."));
+       hints.append(tr("All indexes (of data arrays, subplots and so on) are always start from 0."));
+       hints.append(tr("You can edit MGL file in any text editor. Also you can run it in console by help of commands: mglconv, mglview."));
+       hints.append(tr("You can use command 'once on|off' for marking the block which should be executed only once. For example, this can be the block of large data reading/creating/handling. Press F9 (or menu item 'Graphics/Reload') to re-execute this block."));
+       hints.append(tr("You can use command 'stop' for terminating script parsing. It is useful if you don't want to execute a part of script."));
+       hints.append(tr("You can type arbitrary expression as input argument for data or number. In last case (for numbers), the first value of data array is used."));
+       hints.append(tr("There is powerful calculator with a lot of special functions. You can use buttons or keyboard to type the expression. Also you can use existed variables in the expression."));
+       hints.append(tr("The calculator can help you to put complex expression in the script. Just type the expression (which may depend on coordinates x,y,z and so on) and put it into the script."));
+       hints.append(tr("You can easily insert file or folder names, last fitted formula or numerical value of selection by using menu Edit|Insert."));
+       hints.append(tr("The special dialog (Edit|Insert|New Command) help you select the command, fill its arguments and put it into the script."));
+       hints.append(tr("You can put several plotting commands in the same line or in separate function, for highlighting all of them simultaneously."));
+
+       numHints=hints.size();
        cur = int(mgl_rnd()*numHints);
        setWindowTitle(tr("UDAV - Hint"));
        QHBoxLayout *a;
index 338b222c95fe4069fdae613a75759af15ed14aba..8bb2a6679b994f441688ce6525285406b2c0cbb6 100644 (file)
@@ -23,7 +23,6 @@
 #include <QTextEdit>
 #include <QDialog>
 class QCheckBox;
-extern QString hints[];
 //-----------------------------------------------------------------------------
 /// Dialog for showing hints
 class HintDialog : public QDialog
@@ -42,6 +41,7 @@ private slots:
 private:
        int cur;
        int numHints;
+       QVector<QString> hints;
        QTextEdit *text;
        QCheckBox *start;
 };
index 528da56c8d88afdd216f4c46fb8ad25511164dee..fadae24c108eb5a4aa03ef3209e45999e32dded2 100644 (file)
@@ -63,7 +63,7 @@ void InfoDialog::refresh(bool force)
 {
        if(!var || (!force && (!allowRefresh || !isVisible()))) return;
        QString text, name, sub;
-       name = QString::fromStdWString(var->s);
+       name = QString::fromWCharArray(var->s.c_str());
        sub = "(:,:,"+QString::number(kz)+")\n";
        int i = kind->currentIndex();
        if(i<1) text = "yrange "+name+"\nplot "+name + sub;
index 7b9da01bcd268f07020036a3ff12556b9fd1eed8..fa1db0e12d705d8f9e2cbd74de954b933b877ac7 100644 (file)
@@ -83,7 +83,7 @@ void MemPanel::newTable()
        QString name = QInputDialog::getText(this, tr("UDAV - New variable"),
                                tr("Enter name for new variable"), QLineEdit::Normal, "", &ok);
        if(!ok || name.isEmpty())       return;
-       mglDataA *v = parser.AddVar(name.toStdString().c_str());
+       mglDataA *v = parser.AddVar(name.toLocal8Bit().constData());
        QWidget *t;
        if(v->o)        t = (QWidget *)v->o;
        else            t = newDataWnd(infoDlg,wnd,v);
@@ -96,7 +96,7 @@ void MemPanel::editData(int n)
        if(tab->rowCount()<1)   return;
        if(n<0) n = tab->currentRow();
        if(n<0) n = 0;
-       mglDataA *v = parser.FindVar(tab->item(n,0)->text().toStdString().c_str());
+       mglDataA *v = parser.FindVar(tab->item(n,0)->text().toLocal8Bit().constData());
        if(!v)  return;
        QWidget *t;
        if(v->o)        t = (QWidget *)v->o;
@@ -109,9 +109,9 @@ void MemPanel::delData()
        if(tab->rowCount()<1)   return;
        int     n = tab->currentRow();
        if(n<0) n = 0;
-       mglDataA *v = parser.FindVar(tab->item(n,0)->text().toStdString().c_str());
+       mglDataA *v = parser.FindVar(tab->item(n,0)->text().toLocal8Bit().constData());
        if(!v && v->o)  ((QWidget *)v->o)->close();
-       parser.DeleteVar(tab->item(n,0)->text().toStdString().c_str());
+       parser.DeleteVar(tab->item(n,0)->text().toLocal8Bit().constData());
        refresh();
 }
 //-----------------------------------------------------------------------------
@@ -128,10 +128,10 @@ void MemPanel::infoData()
        if(tab->rowCount()<1)   return;
        int     n = tab->currentRow();
        if(n<0) n = 0;
-       mglDataA *v = parser.FindVar(tab->item(n,0)->text().toStdString().c_str());
+       mglDataA *v = parser.FindVar(tab->item(n,0)->text().toLocal8Bit().constData());
        if(!v)  return;
        infoDlg->setVar(v);
-       QString s = QString::fromStdWString(v->s);
+       QString s = QString::fromWCharArray(v->s.c_str());
        infoDlg->setWindowTitle(s + tr(" - UDAV preview"));
        infoDlg->refresh();
        infoDlg->show();
@@ -149,7 +149,7 @@ void MemPanel::refresh()
        {
                mglDataA *v = parser.GetVar(i);
                if(!v)  continue;
-               s = QString::fromStdWString(v->s);
+               s = QString::fromWCharArray(v->s.c_str());
                it = new QTableWidgetItem(s);
                tab->setItem(m,0,it);   it->setFlags(flags);
                s.sprintf("%ld * %ld * %ld", v->GetNx(), v->GetNy(), v->GetNz());
index 3d1d24fc1a8c67763fedef9dbcffc3de3a2a23fd..39e295b56cb322d17154b506d44b00b9eaea27a5 100644 (file)
@@ -248,10 +248,12 @@ void NewCmdDialog::nameChanged(int s)
        // clear old
        kind->clear();  kinds.clear();  for(k=0;k<NUM_CH;k++)   argn[k].clear();
        // try to find the keyword
-       if(!parser.CmdType(n.toStdString().c_str()))    return;
-       info->setText(QString::fromLocal8Bit(parser.CmdDesc(n.toStdString().c_str())));
+       QByteArray qcmd = n.toLatin1();
+       const char *cmd = qcmd.constData();
+       if(!parser.CmdType(cmd))        return;
+       info->setText(parser.CmdDesc(cmd));
 
-       par = QString::fromLocal8Bit(parser.CmdFormat(n.toStdString().c_str()));
+       par = parser.CmdFormat(cmd);
        int i0 = par.indexOf(' ');      // first space if present
        if(i0<0)        {       kind->addItem(par);     return; }       // no arguments
        // parse kind of arguments
index 58ae5fd7ca9aa86e8e7a7de8eb354359b7cf008e..961d47ea4ea112a4b8ad73ae7206344a5b4ff60e 100644 (file)
@@ -116,29 +116,29 @@ void DataOpenDialog::prepareResult()
        // prepare unique value of name for next time
        char buf[32];   snprintf(buf,32,"mgl_%d",numDataOpened);
        buf[31]=0;      name->setText(buf);
-       mglData *v = dynamic_cast<mglData*>(parser.AddVar(data.toStdString().c_str()));
+       mglData *v = dynamic_cast<mglData*>(parser.AddVar(data.toLocal8Bit().constData()));
        if(!v)  return;
        int dd=0;
        if(rA->isChecked())     //      auto sizes
        {
-               setlocale(LC_NUMERIC, "C");     v->Read(file.toStdString().c_str());    setlocale(LC_NUMERIC, "");
+               setlocale(LC_NUMERIC, "C");     v->Read(file.toLocal8Bit().constData());        setlocale(LC_NUMERIC, "");
                if(v->nx==1)    {       v->nx = v->ny;  v->ny = v->nz;  }
                code=QString("#read %1 '%2'\n").arg(data).arg(file);
        }
        else if(rM->isChecked())        //      manual sizes
        {
                int x=nx->text().toInt(), y=ny->text().toInt(), z=nz->text().toInt();
-               setlocale(LC_NUMERIC, "C");     v->Read(file.toStdString().c_str(),x,y,z);      setlocale(LC_NUMERIC, "");
+               setlocale(LC_NUMERIC, "C");     v->Read(file.toLocal8Bit().constData(),x,y,z);  setlocale(LC_NUMERIC, "");
                code=QString("#read %1 '%2' %3 %4 %5\n").arg(data).arg(file).arg(x).arg(y).arg(z);
        }
        else if(r2->isChecked())        //      matrix
        {
-               setlocale(LC_NUMERIC, "C");     v->ReadMat(file.toStdString().c_str()); setlocale(LC_NUMERIC, "");
+               setlocale(LC_NUMERIC, "C");     v->ReadMat(file.toLocal8Bit().constData());     setlocale(LC_NUMERIC, "");
                code=QString("#readmat %1 '%2'\n").arg(data).arg(file);         dd=1;
        }
        else if(r3->isChecked())        //      3d-data
        {
-               setlocale(LC_NUMERIC, "C");     v->ReadMat(file.toStdString().c_str(),3);       setlocale(LC_NUMERIC, "");
+               setlocale(LC_NUMERIC, "C");     v->ReadMat(file.toLocal8Bit().constData(),3);   setlocale(LC_NUMERIC, "");
                code=QString("#readmat %1 '%2' 3\n").arg(data).arg(file);       dd=2;
        }
        if(scr->lineEdit()->text().isEmpty() || scr->lineEdit()->text()==tr("default"))
@@ -173,7 +173,7 @@ void DataOpenDialog::prepareResult()
 void DataOpenDialog::setFile(const QString &fname)
 {
        file=fname;
-       mglData d(file.toStdString().c_str());
+       mglData d(file.toLocal8Bit().constData());
        rA->setText(tr("Auto detect data sizes (%1 x %2 x %3)").arg(d.nx).arg(d.ny).arg(d.nz));
 }
 //-----------------------------------------------------------------------------
index 2e2595295219eafa40afb68191faf5699ffb3c42..796c1e1a83432554fdc1364578f604493b8616db 100644 (file)
@@ -21,6 +21,9 @@
 #define OPTION_DLG_H
 //-----------------------------------------------------------------------------
 #include <QDialog>
+#if defined(_MSC_VER)
+#include <mgl2/define.h>
+#endif
 class QLineEdit;
 class QComboBox;
 class QRadioButton;
index 5b501a90c1f55f1a3153c452ecc9a2d2d0305b4d..6e365a44d982872b01489321487cd2f28cfe0011 100644 (file)
@@ -21,6 +21,9 @@
 #define SETUPDIALOG_H
 //-----------------------------------------------------------------------------
 #include <qdialog.h>
+#if defined(_MSC_VER)
+#include <mgl2/define.h>
+#endif
 class QLineEdit;
 class QCheckBox;
 class QComboBox;
index f9e0c296acd5ad38b433b74100727d1330d2d196..d98c7c54b3fe2134cbdaa32a390189144282b8fb 100644 (file)
@@ -451,7 +451,7 @@ void StyleDialog::updatePic()
                        else            result += col[i-1];\r
                }\r
                i = width->value();             if(i>1) result += char('0'+i);\r
-               gr.Plot(x,y,result.toStdString().c_str());\r
+               gr.Plot(x,y,result.toLocal8Bit().constData());\r
                break;\r
        case 1: // color sceheme\r
        case 3: // manual mask\r
@@ -492,7 +492,7 @@ void StyleDialog::updatePic()
                \r
                i = axial->currentIndex();\r
                if(i>0) result = result+':'+char('x'+i-1);\r
-               gr.Surf(a,result.toStdString().c_str());\r
+               gr.Surf(a,result.toLocal8Bit().constData());\r
                break;\r
        case 2: // text style\r
                if(font_sch->isChecked())       for(j=0;j<7;j++)\r
@@ -518,7 +518,7 @@ void StyleDialog::updatePic()
                if(rbL->isChecked())    result += 'L';\r
                if(rbC->isChecked())    result += 'C';\r
                if(rbR->isChecked())    result += 'R';\r
-               gr.Puts(mglPoint(0,-0.5),"Font test",result.toStdString().c_str(),-10);\r
+               gr.Puts(mglPoint(0,-0.5),"Font test",result.toLocal8Bit().constData(),-10);\r
                break;\r
        }\r
        result = "'" + result + "'";\r
index 80b1c64d963f98cc796a4ac781326de1a25d0c30..07ddedfa86cdb196dc868f390e96f741d21f9a6d 100644 (file)
@@ -231,6 +231,7 @@ void SubplotDialog::updatePic()
 {
        static mglGraph gr;     gr.SetSize(pic->width(),pic->height());
        mglParse par;
+       wchar_t *wcmd;
 
        setlocale(LC_NUMERIC, "C");
        QString stl="'";        // style for subplot
@@ -255,7 +256,11 @@ void SubplotDialog::updatePic()
                {       cmd += ":title '"+title->text()+"'";    if(!fmt.isEmpty())      cmd += fmt;     }
                if(Tet || Phi)  cmd += ":rotate "+QString::number(Tet)+" "+QString::number(Phi);
                if(Ax!=1 || Ay!=1)      cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay);
-               par.Execute(&gr, cmd.toStdWString().c_str());   gr.Box();
+               wcmd = new wchar_t[cmd.size()+1];
+               cmd.toWCharArray(wcmd);
+               wcmd[cmd.size()] = 0;
+               par.Execute(&gr, wcmd); gr.Box();
+               delete[] wcmd;
                res->setText(cmd);
        }
        else if(cm->isChecked())        // multiplot
@@ -267,7 +272,11 @@ void SubplotDialog::updatePic()
                {       cmd += ":title '"+title->text()+"'";    if(!fmt.isEmpty())      cmd += fmt;     }
                if(Tet || Phi)  cmd += ":rotate "+QString::number(Tet)+" "+QString::number(Phi);
                if(Ax!=1 || Ay!=1)      cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay);
-               par.Execute(&gr, cmd.toStdWString().c_str());   gr.Box();
+               wcmd = new wchar_t[cmd.size() + 1];
+               cmd.toWCharArray(wcmd);
+               wcmd[cmd.size()] = 0;
+               par.Execute(&gr, wcmd); gr.Box();
+               delete[] wcmd;
                res->setText(cmd);
        }
        else if(cg->isChecked())        // gridplot
@@ -277,7 +286,11 @@ void SubplotDialog::updatePic()
                for(int i=0;i<n*m;i++)  if(i!=k)        {       gr.GridPlot(n,m,i,d);   gr.Box("h");    }
                cmd = "gridplot "+QString::number(n)+" "+QString::number(m)+" "+QString::number(k)+" "+QString::number(d);
                if(Ax!=1 || Ay!=1)      cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay);
-               par.Execute(&gr, cmd.toStdWString().c_str());   gr.Box();
+               wcmd = new wchar_t[cmd.size() + 1];
+               cmd.toWCharArray(wcmd);
+               wcmd[cmd.size()] = 0;
+               par.Execute(&gr, wcmd); gr.Box();
+               delete[] wcmd;
                res->setText(cmd);
        }
        else if(cs->isChecked())        // stickplot
@@ -286,7 +299,11 @@ void SubplotDialog::updatePic()
                for(int i=0;i<n;i++)    if(i!=k)        {       gr.StickPlot(n,i,Tet,Phi);      gr.Box("h");    }
                cmd = "stickplot "+QString::number(n)+" "+QString::number(k)+" "+QString::number(Tet)+" "+QString::number(Phi);
                if(Ax!=1 || Ay!=1)      cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay);
-               par.Execute(&gr, cmd.toStdWString().c_str());   gr.Box();
+               wcmd = new wchar_t[cmd.size() + 1];
+               cmd.toWCharArray(wcmd);
+               wcmd[cmd.size()] = 0;
+               par.Execute(&gr, wcmd); gr.Box();
+               delete[] wcmd;
                res->setText(cmd);
        }
        else if(cc->isChecked())        // columnplot   // TODO add angles
@@ -297,7 +314,11 @@ void SubplotDialog::updatePic()
                cmd = "columnplot "+QString::number(n)+" "+QString::number(k)+" "+QString::number(d);
                if(Tet || Phi)  cmd += ":rotate "+QString::number(Tet)+" "+QString::number(Phi);
                if(Ax!=1 || Ay!=1)      cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay);
-               par.Execute(&gr, cmd.toStdWString().c_str());   gr.Box();
+               wcmd = new wchar_t[cmd.size() + 1];
+               cmd.toWCharArray(wcmd);
+               wcmd[cmd.size()] = 0;
+               par.Execute(&gr, wcmd); gr.Box();
+               delete[] wcmd;
                res->setText(cmd);
        }
        else if(ci->isChecked())        // inplot
@@ -308,7 +329,11 @@ void SubplotDialog::updatePic()
                {       cmd += ":title '"+title->text()+"'";    if(!fmt.isEmpty())      cmd += fmt;     }
                if(Tet || Phi)  cmd += ":rotate "+QString::number(Tet)+" "+QString::number(Phi);
                if(Ax!=1 || Ay!=1)      cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay);
-               par.Execute(&gr, cmd.toStdWString().c_str());   gr.Box();
+               wcmd = new wchar_t[cmd.size() + 1];
+               cmd.toWCharArray(wcmd);
+               wcmd[cmd.size()] = 0;
+               par.Execute(&gr, wcmd); gr.Box();
+               delete[] wcmd;
                res->setText(cmd);
        }
        setlocale(LC_NUMERIC, "");
index 293c10b0b36c4d9a2d7fff12d900c9702eb552a3..416732764042ad5dfefa99111fb3c7ddaf441e20 100644 (file)
@@ -63,7 +63,7 @@ TextPanel::TextPanel(QWidget *parent) : QWidget(parent)
        if(!files_dlg)  files_dlg= new FilesDialog;
 
        register int i,n=parser.GetCmdNum();
-       for(i=0;i<n;i++)        words<<QString::fromLocal8Bit(parser.GetCmdName(i));
+       for(i=0;i<n;i++)        words<<QString::fromLatin1(parser.GetCmdName(i));
        vars = words;
 
        connect(setupDlg, SIGNAL(putText(const QString &)), this, SLOT(animPutText(const QString &)));
@@ -161,7 +161,7 @@ void TextPanel::refreshData()
        for(i=0;i<n;i++)
        {
                const mglDataA *v=parser.GetVar(i);
-               if(v && v->s.length()>2)        vars<<QString::fromStdWString(v->s);
+               if(v && v->s.length()>2)        vars<<QString::fromWCharArray(v->s.c_str());
        }
        setCompleter(mglCompleter);
 }
@@ -293,7 +293,7 @@ void TextPanel::loadHDF5(const QString &fileName)
        hid_t hf,hg,hd,hs,ht;
        hsize_t dims[3];
        long rank;
-       hf = H5Fopen(fileName.toStdString().c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
+       hf = H5Fopen(fileName.toLocal8Bit().constData(), H5F_ACC_RDONLY, H5P_DEFAULT);
        if(!hf) return;
        hg = H5Gopen(hf, "/");
        hsize_t num, nx, ny, nz, i;
@@ -359,7 +359,7 @@ void TextPanel::saveHDF5(const QString &fileName)
        long rank = 3;
 
        H5Eset_auto(0,0);
-       hf = H5Fcreate(fileName.toStdString().c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+       hf = H5Fcreate(fileName.toLocal8Bit().constData(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
        if(hf<0)
        {
                setStatus(tr("Could not write to %1").arg(fileName));
@@ -372,7 +372,7 @@ void TextPanel::saveHDF5(const QString &fileName)
                txt += edit->toPlainText();
                dims[0] = txt.length()+1;
                char *buf = new char[dims[0]+1];
-               memcpy(buf, txt.toStdString().c_str(), dims[0]);
+               memcpy(buf, txt.toLocal8Bit().constData(), dims[0]);
                buf[dims[0]]=0;
                hs = H5Screate_simple(1, dims, 0);
                hd = H5Dcreate(hf, "mgl_script", H5T_C_S1, hs, H5P_DEFAULT);
index 7a046108de8d60f79dfa794267b3879139d5c3cc..846f54fde37642074ad4d86f25ee9272b7781677 100644 (file)
@@ -305,7 +305,8 @@ bool TextEdit::isErrLine(int line) const
 void TextEdit::setErrMessage(const QString &mess)
 {
        err.clear();
-       const char *s = mess.toStdString().c_str();
+       QByteArray qs = mess.toLatin1();
+       const char *s = qs.constData();
        s = strstr(s,"in line ");
        while(s)
        {
index 6a54db948253944f1061c5c7ca2743f27b182cd7..080cafd2cc2a8b274281aedbaeeaef41ddec9b83 100644 (file)
@@ -41,6 +41,9 @@
 #define TEXTEDIT_H
 //-----------------------------------------------------------------------------
 #include <QTextEdit>
+#if defined(_MSC_VER)
+#include <mgl2/define.h>
+#endif
 //-----------------------------------------------------------------------------
 class QCompleter;
 class Numb;
index 9ce96a604db0e96a0361d0690a9eb337d8f34845..f885946a5e75a98a23de2e424443504a5ccb1757 100644 (file)
@@ -424,9 +424,11 @@ void MainWindow::editPosChanged()
        for(i=0;i<n;i++)        if(dlm.contains(text[i]))       break;
        text.truncate(i);
 
-       const char *desc = parser.CmdDesc(text.toStdString().c_str());
-       const char *form = parser.CmdFormat(text.toStdString().c_str());
-       if(form)        setStatus(QString::fromLocal8Bit(desc)+": "+QString::fromLocal8Bit(form));
+       QByteArray qxtext = text.toLatin1();
+       const char *ctext = qxtext.constData();
+       const char *desc = parser.CmdDesc(ctext);
+       const char *form = parser.CmdFormat(ctext);
+       if(form)        setStatus(QString(desc)+": "+QString(form));
        else    setStatus(tr("Not recognized"));
 }
 //-----------------------------------------------------------------------------
@@ -540,7 +542,7 @@ void MainWindow::setStatus(const QString &txt)
 void MainWindow::setCurrentFile(const QString &fileName)
 {
        filename = fileName;
-       mgl_set_plotid(graph->mgl->getGraph(), fileName.toStdString().c_str());
+       mgl_set_plotid(graph->mgl->getGraph(), fileName.toLocal8Bit().constData());
        edit->setModified(false);
        if(filename.isEmpty())
                setWindowTitle(tr("untitled - UDAV"));
index 9dca3b13ba49b2dcc4db7f1b2e001778990f36f3..b3c6932333abfd81778d239042a7de3d11f2e7d7 100644 (file)
@@ -1,15 +1,19 @@
-include_directories(${GSL_INCLUDE_DIR})
 add_executable(make_pas make_pas.cpp)
 
 add_executable(mglconv mglconv.cpp)
-target_link_libraries(mglconv mgl)
+if(MSVC)
+set(link_type -static)
+else(MSVC)
+set(link_type)
+endif(MSVC)
+target_link_libraries(mglconv mgl${link_type} ${getopt_lib-static})
 install(
        TARGETS mglconv
        RUNTIME DESTINATION bin
 )
 
 add_executable(mgl.cgi mglcgi.cpp)
-target_link_libraries(mgl.cgi mgl)
+target_link_libraries(mgl.cgi mgl${link_type})
 install(
        TARGETS mgl.cgi
 # should be /usr/lib/cgi-bin/
@@ -20,12 +24,10 @@ if(QT_ENABLED)
        add_executable(mglview mglview.cpp)
        if(enable-qt5)
                include(../cmake-qt5.txt)
-               target_link_libraries(mglview mgl-qt5)
-               qt5_use_modules(mglview ${MGL_QT5_LIBS})
+               target_link_libraries(mglview mgl-qt5${link_type} ${getopt_lib-static} ${MGL_QT5_LIBS})
        else(enable-qt5)
                include(../cmake-qt4.txt)
-               target_link_libraries(mglview mgl-qt4)
-               qt4_use_modules(mglview ${MGL_QT4_LIBS})
+               target_link_libraries(mglview mgl-qt4${link_type} ${getopt_lib-static} ${MGL_QT4_LIBS})
        endif(enable-qt5)
 
        install(
index fd38efdf5553fbd27f9187d2a23e552f6bd732ec..eb677902842f1f0c43f607d061a357498dbe6e3c 100644 (file)
@@ -1,5 +1,7 @@
 #include <stdio.h>
 #include <string.h>
+#include<mgl2/define.h>
+
 
 const char *files[] =
 {
index befec3001b942c25c8960c03b44740be6c66b567..ea72b90138b68968094e5241f9f89f907b170db9 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * mglcgi.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   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  *
index 9f6551c9024918e4e0c9edc14fbc7eb099f82671..f9dd48011f4ac3c295bd91f5adae62f15d2c6c51 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * mglconv.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\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
 #include <locale.h>\r
 #include <getopt.h>\r
 #include "mgl2/mgl.h"\r
+\r
+#ifdef _MSC_VER\r
+#define mnpos (std::basic_string<wchar_t>::size_type)-1\r
+#else\r
+#define mnpos std::wstring::npos\r
+#endif\r
 void mgl_error_print(const char *Message, void *par);\r
 void mgl_ask_gets(const wchar_t *quest, wchar_t *res);\r
 //-----------------------------------------------------------------------------\r
@@ -35,7 +41,7 @@ int main(int argc, char *argv[])
 \r
        while(1)\r
        {\r
-               int ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:hno:L:C:A:s:S:q:");\r
+               int ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:hno:L:C:A:s:S:q:v:g:");\r
                if(ch>='1' && ch<='9')  p.AddParam(ch-'0', optarg);\r
                else if(ch=='s')\r
                {\r
@@ -52,10 +58,12 @@ int main(int argc, char *argv[])
                else if(ch=='L')        setlocale(LC_CTYPE, optarg);\r
                else if(ch=='S')        mgl_set_size_scl(atof(optarg));\r
                else if(ch=='q')        gr.SetQuality(atoi(optarg));\r
+               else if(ch=='v')        p.SetVariant(atoi(optarg));\r
+               else if(ch=='g')        gr.Gray(atoi(optarg));\r
                else if(ch=='A')\r
                {\r
                        std::wstring str;\r
-                       for(long i=0;optarg[i];i++)     str.push_back(optarg[i]);\r
+                       for(size_t i=0;optarg[i];i++)   str.push_back(optarg[i]);\r
                        var.push_back(str);\r
                }\r
                else if(ch=='C')\r
@@ -82,6 +90,8 @@ int main(int argc, char *argv[])
                                "\t-s fname     set MGL script for setting up the plot\n"\r
                                "\t-S val       set scaling factor for images\n"\r
                                "\t-q val       set quality for output (val=0...9)\n"\r
+                               "\t-g val       set gray-scale mode (val=0|1)\n"\r
+                               "\t-v val       set variant of arguments\n"\r
                                "\t-o name      set output file name\n"\r
                                "\t-n           no default output (script should save results by itself)\n"\r
                                "\t-A val       add animation value val\n"\r
@@ -107,16 +117,16 @@ int main(int argc, char *argv[])
        while(!feof(fp) && size_t(cw=fgetwc(fp))!=WEOF) str.push_back(cw);\r
        if(*iname)      fclose(fp);\r
 \r
-       unsigned long n;\r
-       for(long i=0;;) // collect exact values\r
+       size_t n;\r
+       for(size_t i=0;;)       // collect exact values\r
        {\r
                n = str.find(L"##a ",i);\r
-               if(n==std::string::npos)        break;\r
+               if (n == mnpos) break;\r
                i = n+4;        var.push_back(str.substr(i,str.find('\n',i)));\r
        }\r
        n = str.find(L"##c ");\r
-       if(n!=std::string::npos)\r
-       {\r
+       if (n != mnpos)\r
+               {\r
                double v1,v2,dv,v;\r
                wscanf(str.c_str()+n+4,L"%lg%lg%lg",&v1,&v2,&dv);\r
                wchar_t ss[64];\r
@@ -124,18 +134,19 @@ int main(int argc, char *argv[])
                {       mglprintf(ss,64,L"%g",v);       var.push_back(ss);      }\r
        }\r
        bool gif = !strcmp(oname+strlen(oname)-4,".gif");\r
+       gr.SetSize(600,400);    // specially call for "S" option\r
        if(var.size()>1)        // there is animation\r
        {\r
                if(gif) gr.StartGIF(oname);\r
-               for(unsigned long i=0;i<var.size();i++)\r
+               for(size_t i=0;i<var.size();i++)\r
                {\r
                        gr.NewFrame();\r
-                       printf("frame %ld for $0 = \"%ls\"\n",i,var[i].c_str());\r
+                       printf("frame %zu for $0 = \"%ls\"\n",i,var[i].c_str());\r
                        p.AddParam(0,var[i].c_str());\r
                        p.Execute(&gr,str.c_str());\r
                        if(gr.Message()[0])     printf("%s\n",gr.Message());\r
                        gr.EndFrame();\r
-                       snprintf(buf,2048,"%s-%ld",oname,i);    buf[2047]=0;\r
+                       snprintf(buf,2048,"%s-%zu",oname,i);    buf[2047]=0;\r
                        if(!gif)        gr.WriteFrame(buf);\r
                }\r
                if(gif) gr.CloseGIF();\r
index a005cebaf343ed75a0df82ae6b1f6b3c90ca9532..4f8204f9b50344fa30192c06b4e7294e9400c7d8 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * mglview.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   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  *
 
 #include "mgl2/mgl.h"
 #include "mgl2/qt.h"
+#include "mgl2/parser.h"
 //-----------------------------------------------------------------------------
 std::wstring str, opt;
 mglParse p(true);
-void mgl_error_print(const char *Message, void *par);
-void mgl_ask_fltk(const wchar_t *quest, wchar_t *res);
-void mgl_ask_qt(const wchar_t *quest, wchar_t *res);
-void mgl_ask_gets(const wchar_t *quest, wchar_t *res);
 //-----------------------------------------------------------------------------
 int show(mglGraph *gr)
 {
@@ -41,9 +38,10 @@ int main(int argc, char **argv)
 {
        char iname[256]="";
        mgl_suppress_warn(true);
+       bool gray = false;
        while(1)
        {
-               int ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:hL:s:");
+               int ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:hL:s:g:v:");
                if(ch>='1' && ch<='9')  p.AddParam(ch-'0', optarg);
                else if(ch=='s')
                {
@@ -56,6 +54,8 @@ int main(int argc, char **argv)
                                fclose(fp);
                        }
                }
+               else if(ch=='v')        p.SetVariant(atoi(optarg));
+               else if(ch=='g')        gray= atoi(optarg);
                else if(ch=='L')        setlocale(LC_CTYPE, optarg);
                else if(ch=='h' || (ch==-1 && optind>=argc))
                {
@@ -65,6 +65,8 @@ int main(int argc, char **argv)
                                "\t-1 str       set str as argument $1 for script\n"
                                "\t...          ...\n"
                                "\t-9 str       set str as argument $9 for script\n"
+                               "\t-g val       set gray-scale mode (val=0|1)\n"
+                               "\t-v val       set variant of arguments\n"
                                "\t-s opt       set MGL script for setting up the plot\n"
                                "\t-L loc       set locale to loc\n"
                                "\t-            get script from standard input\n"
@@ -93,6 +95,8 @@ int main(int argc, char **argv)
        mgl_ask_func = mgl_ask_gets;
        mgl_ask_func = mgl_ask_qt;
        mglQT gr(mgld?NULL:show, *iname?iname:"mglview");
+       if(gray)        gr.Gray(gray);
+
        if(mgld)
        {
                gr.Setup(false);
index f05ea5ad5380fc52b94741b2507300970beaca5a..f08f4493d1ceb83da919cd525c052de66ab5b1b7 100644 (file)
@@ -1,11 +1,11 @@
 include(GenerateExportHeader)
-add_compiler_export_flags()
 
 if(MGL_HAVE_FLTK)
        mgl_add_lib(fltk fltk.cpp ../include/mgl2/fltk.h)
        target_include_directories(mgl-fltk SYSTEM PUBLIC ${FLTK_INCLUDE_DIR})
        target_include_directories(mgl-fltk-static SYSTEM PUBLIC ${FLTK_INCLUDE_DIR})
        target_link_libraries(mgl-fltk mgl ${FLTK_LIBRARIES})
+       target_link_libraries(mgl-fltk-static mgl-static ${FLTK_LIBRARIES})
 endif(MGL_HAVE_FLTK)
 
 if(MGL_HAVE_GLUT)
@@ -13,13 +13,14 @@ if(MGL_HAVE_GLUT)
        target_include_directories(mgl-glut SYSTEM PUBLIC ${GLUT_INCLUDE_DIR})
        target_include_directories(mgl-glut-static SYSTEM PUBLIC ${GLUT_INCLUDE_DIR})
        target_link_libraries(mgl-glut mgl ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES})
+       target_link_libraries(mgl-glut-static mgl-static ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES})
 endif(MGL_HAVE_GLUT)
 
 if(MGL_HAVE_WX)
        mgl_add_lib(wx wx.cpp ../include/mgl2/wx.h)
        include(${wxWidgets_USE_FILE})
-       target_link_libraries(mgl-wx mgl)
-       target_link_libraries(mgl-wx ${wxWidgets_LIBRARIES})
+       target_link_libraries(mgl-wx mgl ${wxWidgets_LIBRARIES})
+       target_link_libraries(mgl-wx-static mgl-static ${wxWidgets_LIBRARIES})
 endif(MGL_HAVE_WX)
 
 add_subdirectory( qt4 )
index 551681391eec27c2c2bfbfc65dd2c66c62b6992f..b09372881f4ed5107fb431cb5cb2fdd75f2cbbb6 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * fltk.cpp is part of Math Graphic Library
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
@@ -175,6 +175,14 @@ void Fl_MathGL::update()
                const char *buf = mgl_get_mess(gr);
                if(*buf)        fl_message("%s",buf);
        }
+       else if(mgl_get_num_frame(gr)>0)
+       {
+               mgl_set_alpha(gr,flag&1);       mgl_set_light(gr,flag&2);
+               if(tet_val)     tet = tet_val->value();
+               if(phi_val)     phi = phi_val->value();
+               mgl_zoom(gr,x1,y1,x2,y2);       mgl_view(gr,-phi,-tet,0);
+               mgl_get_frame(gr,0);
+       }
        if(mgl_get_width(gr)!=w() || mgl_get_height(gr)!=h())
                size(mgl_get_width(gr), mgl_get_height(gr));
        gr->AskStop(false);     redraw();
@@ -349,8 +357,8 @@ void Fl_MGLView::exec_pause()
        }
        if(mutex)
        {
-               if(pauseC)      pthread_mutex_lock(mutex);
-               else    pthread_mutex_unlock(mutex);
+               pthread_mutex_trylock(mutex);
+               if(!pauseC)     pthread_mutex_unlock(mutex);
        }
 #endif
 }
@@ -764,6 +772,11 @@ HMGL MGL_EXPORT mgl_create_graph_fltk(int (*draw)(HMGL gr, void *p), const char
        g->Window(0,0,draw,title,par,load);
        return g;
 }
+void* mgl_fltk_widget(HMGL gr)
+{
+       mglCanvasFL *g = dynamic_cast<mglCanvasFL *>(gr);
+       return g?g->mgl:NULL;
+}
 int MGL_EXPORT mgl_fltk_run()          {       return Fl::run();       }
 //-----------------------------------------------------------------------------
 uintptr_t MGL_EXPORT mgl_create_graph_fltk_(const char *title, int l)
index 99651d68ad0ad5f5052cb65572b2b9c41a67b33f..4298fc93b1235943c1c606910814bdb898b27281 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * glut.cpp is part of Math Graphic Library\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
index 485abe9e65b9f6b86a8b35568fe4dc67b4a3036d..b7b2f6c376dfe70b6a41446b4d6689df5a8fbbc9 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************
  * qt.cpp is part of Math Graphic Library                              *
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU Library General Public License as       *
@@ -330,8 +330,15 @@ void QMathGL::update()
                else if(draw)   {       mglGraph g(gr); draw->Draw(&g); }
                if(mgl_is_frames(gr))   mgl_end_frame(gr);
                setlocale(LC_NUMERIC, "");
-               gr->AskStop(false);     afterPlot();
+               gr->AskStop(false);
        }
+       else if(mgl_get_num_frame(gr)>0)
+       {
+               mgl_set_alpha(gr,alpha);        mgl_set_light(gr,light);
+//             mgl_zoom(gr,x1,y1,x2,y2);       mgl_view(gr,-phi,-tet,0);
+               mgl_get_frame(gr,0);
+       }
+       afterPlot();
 }
 //-----------------------------------------------------------------------------
 void QMathGL::afterPlot()
@@ -359,7 +366,7 @@ void QMathGL::drawPrim()
        {
                mgl_set_obj_id(gr,i+MGL_MAX_LINES);
                QString tst = primitives.section('\n',i,i);
-               pr.Parse(&gg,primitives.section('\n',i,i).toStdString().c_str(),i+MGL_MAX_LINES);
+               pr.Parse(&gg,primitives.section('\n',i,i).toLocal8Bit().constData(),i+MGL_MAX_LINES);
        }
        gg.SetRanges(ox1,ox2);  gg.Pop();       setlocale(LC_NUMERIC, "");
 }
@@ -671,7 +678,7 @@ void QMathGL::exportGIF(QString fname)
        if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0);
        else
 #if MGL_HAVE_GIF
-               mgl_write_gif(gr,setExtension(fname,"png").toStdString().c_str(), appName.toStdString().c_str());
+               mgl_write_gif(gr,setExtension(fname,"png").toLocal8Bit().constData(), appName.toLocal8Bit().constData());
 #else
                img.save(setExtension(fname,"gif"));
 #endif
@@ -683,7 +690,7 @@ void QMathGL::exportPNG(QString fname)
        if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0);
        else
 #if MGL_HAVE_PNG
-               mgl_write_png(gr,setExtension(fname,"png").toStdString().c_str(), appName.toStdString().c_str());
+               mgl_write_png(gr,setExtension(fname,"png").toLocal8Bit().constData(), appName.toLocal8Bit().constData());
 #else
                img.save(setExtension(fname,"png"));
 #endif
@@ -695,7 +702,7 @@ void QMathGL::exportPNGs(QString fname)
        if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0);
        else
 #if MGL_HAVE_PNG
-               mgl_write_png_solid(gr,setExtension(fname,"png").toStdString().c_str(), appName.toStdString().c_str());
+               mgl_write_png_solid(gr,setExtension(fname,"png").toLocal8Bit().constData(), appName.toLocal8Bit().constData());
 #else
                img.save(setExtension(fname,"png"));
 #endif
@@ -707,7 +714,7 @@ void QMathGL::exportJPG(QString fname)
        if(fname.isEmpty())     QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0);
        else
 #if MGL_HAVE_JPEG
-               mgl_write_jpg(gr,setExtension(fname,"jpg").toStdString().c_str(), appName.toStdString().c_str());
+               mgl_write_jpg(gr,setExtension(fname,"jpg").toLocal8Bit().constData(), appName.toLocal8Bit().constData());
 #else
                img.save(setExtension(fname,"jpg"));
 #endif
@@ -720,7 +727,7 @@ void QMathGL::exportBPS(QString fname)
        else
        {
                setlocale(LC_NUMERIC, "C");
-               mgl_write_bps(gr,setExtension(fname,"eps").toStdString().c_str(), appName.toStdString().c_str());
+               mgl_write_bps(gr,setExtension(fname,"eps").toLocal8Bit().constData(), appName.toLocal8Bit().constData());
                setlocale(LC_NUMERIC, "");
        }
 }
@@ -732,7 +739,7 @@ void QMathGL::exportEPS(QString fname)
        else
        {
                setlocale(LC_NUMERIC, "C");
-               mgl_write_eps(gr,setExtension(fname,"eps").toStdString().c_str(), appName.toStdString().c_str());
+               mgl_write_eps(gr,setExtension(fname,"eps").toLocal8Bit().constData(), appName.toLocal8Bit().constData());
                setlocale(LC_NUMERIC, "");
        }
 }
@@ -744,7 +751,7 @@ void QMathGL::exportSVG(QString fname)
        else
        {
                setlocale(LC_NUMERIC, "C");
-               mgl_write_svg(gr,setExtension(fname,"svg").toStdString().c_str(), appName.toStdString().c_str());
+               mgl_write_svg(gr,setExtension(fname,"svg").toLocal8Bit().constData(), appName.toLocal8Bit().constData());
                setlocale(LC_NUMERIC, "");
        }
 }
@@ -756,7 +763,7 @@ void QMathGL::exportXYZ(QString fname)
        else
        {
                setlocale(LC_NUMERIC, "C");
-               mgl_write_xyz(gr,setExtension(fname,"xyz").toStdString().c_str(), appName.toStdString().c_str());
+               mgl_write_xyz(gr,setExtension(fname,"xyz").toLocal8Bit().constData(), appName.toLocal8Bit().constData());
                setlocale(LC_NUMERIC, "");
        }
 }
@@ -768,7 +775,7 @@ void QMathGL::exportTEX(QString fname)
        else
        {
                setlocale(LC_NUMERIC, "C");
-               mgl_write_tex(gr,setExtension(fname,"tex").toStdString().c_str(), appName.toStdString().c_str());
+               mgl_write_tex(gr,setExtension(fname,"tex").toLocal8Bit().constData(), appName.toLocal8Bit().constData());
                setlocale(LC_NUMERIC, "");
        }
 }
@@ -780,7 +787,7 @@ void QMathGL::exportOFF(QString fname)
        else
        {
                setlocale(LC_NUMERIC, "C");
-               mgl_write_off(gr,setExtension(fname,"off").toStdString().c_str(), appName.toStdString().c_str(),0);
+               mgl_write_off(gr,setExtension(fname,"off").toLocal8Bit().constData(), appName.toLocal8Bit().constData(),0);
                setlocale(LC_NUMERIC, "");
        }
 }
@@ -792,7 +799,7 @@ void QMathGL::exportOBJ(QString fname)
        else
        {
                setlocale(LC_NUMERIC, "C");
-               mgl_write_obj(gr,setExtension(fname,"obj").toStdString().c_str(), appName.toStdString().c_str(),1);
+               mgl_write_obj(gr,setExtension(fname,"obj").toLocal8Bit().constData(), appName.toLocal8Bit().constData(),1);
                setlocale(LC_NUMERIC, "");
        }
 }
@@ -804,7 +811,7 @@ void QMathGL::exportSTL(QString fname)
        else
        {
                setlocale(LC_NUMERIC, "C");
-               mgl_write_stl(gr,setExtension(fname,"stl").toStdString().c_str(), appName.toStdString().c_str());
+               mgl_write_stl(gr,setExtension(fname,"stl").toLocal8Bit().constData(), appName.toLocal8Bit().constData());
                setlocale(LC_NUMERIC, "");
        }
 }
@@ -816,7 +823,7 @@ void QMathGL::exportSTL(QString fname)
        else
        {
                setlocale(LC_NUMERIC, "C");
-               mgl_write_x3d(gr,setExtension(fname,"x3d").toStdString().c_str(), appName.toStdString().c_str());
+               mgl_write_x3d(gr,setExtension(fname,"x3d").toLocal8Bit().constData(), appName.toLocal8Bit().constData());
                setlocale(LC_NUMERIC, "");
        }
 }*/
@@ -828,7 +835,7 @@ void QMathGL::exportTGA(QString fname)
        else
        {
                setlocale(LC_NUMERIC, "C");
-               mgl_write_tga(gr,setExtension(fname,"tga").toStdString().c_str(), appName.toStdString().c_str());
+               mgl_write_tga(gr,setExtension(fname,"tga").toLocal8Bit().constData(), appName.toLocal8Bit().constData());
                setlocale(LC_NUMERIC, "");
        }
 }
@@ -840,7 +847,7 @@ void QMathGL::exportPRC(QString fname)
        else
        {
                setlocale(LC_NUMERIC, "C");
-               mgl_write_prc(gr,setExtension(fname,"prc").toStdString().c_str(), appName.toStdString().c_str(),1);
+               mgl_write_prc(gr,setExtension(fname,"prc").toLocal8Bit().constData(), appName.toLocal8Bit().constData(),1);
                setlocale(LC_NUMERIC, "");
        }
 }
@@ -852,7 +859,7 @@ void QMathGL::exportMGLD(QString fname)
        else
        {
                setlocale(LC_NUMERIC, "C");
-               mgl_export_mgld(gr,setExtension(fname,"mgld").toStdString().c_str(), appName.toStdString().c_str());
+               mgl_export_mgld(gr,setExtension(fname,"mgld").toLocal8Bit().constData(), appName.toLocal8Bit().constData());
                setlocale(LC_NUMERIC, "");
        }
 }
@@ -884,7 +891,7 @@ void QMathGL::copyClickCoor()
 //-----------------------------------------------------------------------------
 void QMathGL::setMGLFont(QString path)
 {      if(path.isEmpty())      mgl_restore_font(gr);
-       else    mgl_load_font(gr,path.toStdString().c_str(),0); }
+       else    mgl_load_font(gr,path.toLocal8Bit().constData(),0);     }
 //-----------------------------------------------------------------------------
 void QMathGL::setSize(int w, int h)
 {
@@ -1324,6 +1331,11 @@ HMGL MGL_EXPORT mgl_create_graph_qt(int (*draw)(HMGL gr, void *p), const char *t
        g->Window(0,0,draw,title,par,load);
        return g;
 }
+void* mgl_qt_widget(HMGL gr)
+{
+       mglCanvasQT *g = dynamic_cast<mglCanvasQT *>(gr);
+       return g?g->QMGL:NULL;
+}
 int MGL_EXPORT mgl_qt_run()    {       return (qApp)?qApp->exec():-1;  }
 //-----------------------------------------------------------------------------
 uintptr_t MGL_EXPORT mgl_create_graph_qt_(const char *title, int l)
index 569f931143e84c871420a1c1c0a96e25d2d601f3..df45e98e274b6193d9b0052fad28d8573a702f75 100644 (file)
@@ -1,29 +1,22 @@
 include(GenerateExportHeader)
-add_compiler_export_flags()
 
 if(enable-qt4)
        include(../../cmake-qt4.txt)
        set(MGL_QT4_FILES ../qt.cpp ../../include/mgl2/qt.h ../../include/mgl2/qmathgl.h)
        mgl_add_lib(qt4 ${MGL_QT4_FILES})
-       qt4_use_modules(mgl-qt4 ${MGL_QT4_LIBS})
-       qt4_use_modules(mgl-qt4-static ${MGL_QT4_LIBS})
-       target_link_libraries(mgl-qt4 mgl)
-       target_link_libraries(mgl-qt4-static mgl)
-       if(NOT enable-qt5asqt)
+       target_link_libraries(mgl-qt4 mgl ${MGL_QT4_LIBS})
+       target_link_libraries(mgl-qt4-static mgl-static ${MGL_QT4_LIBS})
+       if(enable-qt4asqt)
                mgl_add_lib(qt ${MGL_QT4_FILES})
-               qt4_use_modules(mgl-qt ${MGL_QT4_LIBS})
-               qt4_use_modules(mgl-qt-static ${MGL_QT4_LIBS})
-               target_link_libraries(mgl-qt mgl)
-               target_link_libraries(mgl-qt-static mgl)
-       endif(NOT enable-qt5asqt)
+               target_link_libraries(mgl-qt mgl ${MGL_QT4_LIBS})
+               target_link_libraries(mgl-qt-static mgl-static ${MGL_QT4_LIBS})
+       endif(enable-qt4asqt)
 
        if(MGL_HAVE_FLTK AND NOT enable-qt5)
                mgl_add_lib(wnd ${MGL_QT4_FILES} ../fltk.cpp ../../include/mgl2/fltk.h)
                target_include_directories(mgl-wnd SYSTEM PUBLIC ${FLTK_INCLUDE_DIR})
                target_include_directories(mgl-wnd-static SYSTEM PUBLIC ${FLTK_INCLUDE_DIR})
-               qt4_use_modules(mgl-wnd ${MGL_QT4_LIBS})
-               qt4_use_modules(mgl-wnd-static ${MGL_QT4_LIBS})
-               target_link_libraries(mgl-wnd mgl ${FLTK_LIBRARIES})
-               target_link_libraries(mgl-wnd-static mgl ${FLTK_LIBRARIES})
+               target_link_libraries(mgl-wnd mgl ${FLTK_LIBRARIES} ${MGL_QT4_LIBS})
+               target_link_libraries(mgl-wnd-static mgl-static ${FLTK_LIBRARIES} ${MGL_QT4_LIBS})
        endif(MGL_HAVE_FLTK AND  NOT enable-qt5)
 endif(enable-qt4)
index dcc30e53ebde5e4e48c12a32042627a2cd18914b..aa70337fc9826bc430c60b73849071e72849bee6 100644 (file)
@@ -1,28 +1,21 @@
 include(GenerateExportHeader)
-add_compiler_export_flags()
 
 if(enable-qt5)
        include(../../cmake-qt5.txt)
        set(MGL_QT5_FILES ../qt.cpp ../../include/mgl2/qt.h ../../include/mgl2/qmathgl.h)
        mgl_add_lib(qt5 ${MGL_QT5_FILES})
-       qt5_use_modules(mgl-qt5 ${MGL_QT5_LIBS})
-       qt5_use_modules(mgl-qt5-static ${MGL_QT5_LIBS})
-       target_link_libraries(mgl-qt5 mgl)
-       target_link_libraries(mgl-qt5-static mgl)
+       target_link_libraries(mgl-qt5 mgl ${MGL_QT5_LIBS})
+       target_link_libraries(mgl-qt5-static mgl-static ${MGL_QT5_LIBS})
        if(enable-qt5asqt)
                mgl_add_lib(qt ${MGL_QT5_FILES})
-               qt5_use_modules(mgl-qt ${MGL_QT5_LIBS})
-               qt5_use_modules(mgl-qt-static ${MGL_QT5_LIBS})
-               target_link_libraries(mgl-qt mgl)
-               target_link_libraries(mgl-qt-static mgl)
+               target_link_libraries(mgl-qt mgl ${MGL_QT5_LIBS})
+               target_link_libraries(mgl-qt-static mgl-static ${MGL_QT5_LIBS})
        endif(enable-qt5asqt)
        if(MGL_HAVE_FLTK)
                mgl_add_lib(wnd ${MGL_QT5_FILES} ../fltk.cpp ../../include/mgl2/fltk.h)
                target_include_directories(mgl-wnd SYSTEM PUBLIC ${FLTK_INCLUDE_DIR})
                target_include_directories(mgl-wnd-static SYSTEM PUBLIC ${FLTK_INCLUDE_DIR})
-               qt5_use_modules(mgl-wnd ${MGL_QT5_LIBS})
-               qt5_use_modules(mgl-wnd-static ${MGL_QT5_LIBS})
-               target_link_libraries(mgl-wnd mgl ${FLTK_LIBRARIES})
-               target_link_libraries(mgl-wnd-static mgl ${FLTK_LIBRARIES})
+               target_link_libraries(mgl-wnd mgl ${FLTK_LIBRARIES} ${MGL_QT5_LIBS})
+               target_link_libraries(mgl-wnd-static mgl-static ${FLTK_LIBRARIES} ${MGL_QT5_LIBS})
        endif(MGL_HAVE_FLTK)
 endif(enable-qt5)
index b36401067d3ad230b56c1aeb6a4bf84aa6dabd6c..99a2c8686993a3347deb50950a94db5d5083378f 100644 (file)
@@ -1,6 +1,6 @@
 /***************************************************************************\r
  * wx.cpp is part of Math Graphic Library                              *\r
- * Copyright (C) 2007-2014 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
+ * Copyright (C) 2007-2016 Alexey Balakin <mathgl.abalakin@gmail.ru>       *\r
  *                                                                         *\r
  *   This program is free software; you can redistribute it and/or modify  *\r
  *   it under the terms of the GNU Library General Public License as       *\r
@@ -202,6 +202,12 @@ void wxMathGL::Update()
                        dlg.ShowModal();\r
                }\r
        }\r
+       else if(mgl_get_num_frame(gr)>0)\r
+       {\r
+               mgl_set_alpha(gr,alpha);        mgl_set_light(gr,light);\r
+//             mgl_zoom(gr,x1,y1,x2,y2);       mgl_view(gr,-phi,-tet,0);\r
+               mgl_get_frame(gr,0);\r
+       }\r
        MousePos.Empty();       Repaint();\r
 }\r
 //-----------------------------------------------------------------------------\r
@@ -313,7 +319,7 @@ const char *mglw_str(const wxString &str)
 {\r
        static char *buf=0;\r
        if(buf) delete []buf;\r
-       long i, n=str.Len();\r
+       size_t i, n=str.Len();\r
        buf = new char[n+1];    buf[n]=0;\r
        for(i=0;i<n;i++)        buf[i] = str.GetChar(i);\r
        return buf;\r