From 9beecfbfae4fc384f3901a140b6d30d21cb23bd2 Mon Sep 17 00:00:00 2001 From: Dimitrios Eftaxiopoulos Date: Sat, 28 Dec 2013 16:19:13 +0200 Subject: [PATCH] Imported Upstream version 2.2 --- CMakeLists.txt | 172 +++- ChangeLog.txt | 32 + brush.ods | Bin 10909 -> 19306 bytes examples/full_test.cpp | 118 ++- examples/glut_example.cpp | 1 + examples/mpi_test.cpp | 39 + examples/qt_example.cpp | 10 +- examples/samples.cpp | 497 +++++++--- examples/wnd_samples.cpp | 50 +- examples/wx_example.cpp | 105 +-- include/CMakeLists.txt | 1 + include/config.h.in | 31 +- include/mgl2/abstract.h | 105 +++ include/mgl2/addon.h | 4 +- include/mgl2/base.h | 207 ++--- include/mgl2/base_cf.h | 26 +- include/mgl2/canvas.h | 161 ++-- include/mgl2/canvas_cf.h | 9 +- include/mgl2/canvas_wnd.h | 2 +- include/mgl2/cont.h | 6 +- include/mgl2/data.h | 56 +- include/mgl2/data_cf.h | 56 +- include/mgl2/datac.h | 27 +- include/mgl2/datac_cf.h | 18 +- include/mgl2/define.h | 109 +-- include/mgl2/eval.h | 2 +- include/mgl2/evalc.h | 2 +- include/mgl2/fit.h | 2 +- include/mgl2/fltk.h | 18 +- include/mgl2/font.h | 31 +- include/mgl2/glut.h | 2 +- include/mgl2/mgl.h | 82 +- include/mgl2/mpi.h | 3 +- include/mgl2/opengl.h | 23 +- include/mgl2/other.h | 7 +- include/mgl2/parser.h | 28 +- include/mgl2/pde.h | 56 ++ include/mgl2/plot.h | 17 +- include/mgl2/prim.h | 2 +- include/mgl2/qmathgl.h | 19 +- include/mgl2/qt.h | 4 +- include/mgl2/surf.h | 2 +- include/mgl2/thread.h | 86 ++ include/mgl2/type.h | 8 +- include/mgl2/vect.h | 2 +- include/mgl2/volume.h | 2 +- include/mgl2/window.h | 7 +- include/mgl2/wnd.h | 5 +- include/mgl2/wx.h | 40 +- json/main.js | 38 +- json/mathgl.Graph.js | 859 +++++++++--------- json/mathgl.WebkitBackend.js | 18 +- lang/CMakeLists.txt | 13 +- lang/data.i | 455 ++++++++++ lang/mathgl.i | 18 +- lang/mgl.i | 1309 ++++++++++++++++++++++++++ lang/sed_rules | 13 + lang/type.i | 99 ++ mathgl-2x.cbp | 19 +- mgllab/editor.cpp | 3 +- src/CMakeLists.txt | 19 +- src/addon.cpp | 67 +- src/axis.cpp | 320 ++++--- src/base.cpp | 443 +++++---- src/base_cf.cpp | 48 +- src/canvas.cpp | 547 +++++------ src/canvas_cf.cpp | 4 + src/complex.cpp | 611 +++++++++---- src/complex_io.cpp | 217 ++--- src/cont.cpp | 309 ++++--- src/crust.cpp | 235 ++--- src/data.cpp | 1411 +++++++++++++++++------------ src/{data_new.cpp => data_ex.cpp} | 471 +++++----- src/data_gr.cpp | 177 ++++ src/data_io.cpp | 319 ++++--- src/data_png.cpp | 99 +- src/eval.cpp | 64 +- src/evalc.cpp | 25 +- src/evalp.cpp | 577 +++++------- src/exec.cpp | 80 +- src/export.cpp | 74 +- src/export_2d.cpp | 129 +-- src/export_3d.cpp | 302 +++--- src/fft.cpp | 1141 +++++++++++++++-------- src/fit.cpp | 280 +++--- src/font.cpp | 324 ++++--- src/interp.hpp | 384 ++++++++ src/mpi.cpp | 12 +- src/obj.cpp | 4 - src/opengl.cpp | 170 +++- src/other.cpp | 163 ++-- src/parser.cpp | 482 +++++----- src/pde.cpp | 380 ++++---- src/pixel.cpp | 1341 +++++++++++++++++++++------ src/plot.cpp | 762 +++++++++------- src/prc/writePRC.h | 7 - src/prim.cpp | 218 ++--- src/surf.cpp | 305 ++++--- src/vect.cpp | 525 +++++------ src/volume.cpp | 79 +- src/window.cpp | 1 + texinfo/CMakeLists.txt | 194 ++-- texinfo/appendix_en.texi | 2 + texinfo/appendix_ru.texi | 2 + texinfo/concept_en.texi | 46 +- texinfo/concept_ru.texi | 89 +- texinfo/core_en.texi | 288 ++++-- texinfo/core_ru.texi | 320 +++++-- texinfo/data_en.texi | 130 ++- texinfo/data_ru.texi | 235 +++-- texinfo/doc_en.texi | 126 +-- texinfo/doc_ru.texi | 124 +-- texinfo/ex_mgl_en.texi | 405 ++++++--- texinfo/ex_mgl_ru.texi | 419 ++++++--- texinfo/example_en.texi | 481 +++++++--- texinfo/example_ru.texi | 529 +++++++---- texinfo/formats_en.texi | 7 +- texinfo/formats_ru.texi | 7 +- texinfo/index.html | 23 +- texinfo/json.html | 2 +- texinfo/mathgl.js | 74 +- texinfo/mathgl_en.texi | 75 +- texinfo/mathgl_ru.texi | 78 +- texinfo/mgl_en.texi | 29 +- texinfo/mgl_ru.texi | 31 +- texinfo/other_en.texi | 6 +- texinfo/other_ru.texi | 6 +- texinfo/overview_en.texi | 10 + texinfo/overview_ru.texi | 11 + texinfo/parse_en.texi | 26 +- texinfo/parse_ru.texi | 242 ++--- texinfo/surf_cont_fog_g.png | Bin 30517 -> 0 bytes texinfo/symbols_en.texi | 64 +- texinfo/symbols_ru.texi | 68 +- texinfo/time.texi | 112 +++ texinfo/time_big.texi | 112 +++ texinfo/title.html | 10 - texinfo/toc_en.html | 44 - texinfo/toc_fr.html | 45 - texinfo/toc_ru.html | 54 -- texinfo/udav_en.texi | 6 + texinfo/udav_ru.texi | 6 + texinfo/version.texi | 2 + texinfo/web_en.texi | 80 +- texinfo/web_fr.texi | 4 +- texinfo/web_ru.texi | 80 +- texinfo/widget_en.texi | 178 +++- texinfo/widget_ru.texi | 184 +++- todo.txt | 55 +- udav/dat_pnl.cpp | 15 +- udav/info_dlg.cpp | 2 +- udav/plot_pnl.cpp | 16 +- udav/udav_wnd.cpp | 5 +- widgets/CMakeLists.txt | 15 +- widgets/fltk.cpp | 20 +- widgets/glut.cpp | 42 +- widgets/qt.cpp | 39 +- widgets/wx.cpp | 303 +------ 158 files changed, 15561 insertions(+), 8279 deletions(-) create mode 100644 examples/mpi_test.cpp create mode 100644 include/mgl2/abstract.h create mode 100644 include/mgl2/pde.h create mode 100644 include/mgl2/thread.h create mode 100644 lang/data.i create mode 100644 lang/mgl.i create mode 100644 lang/sed_rules create mode 100644 lang/type.i rename src/{data_new.cpp => data_ex.cpp} (71%) create mode 100644 src/data_gr.cpp create mode 100644 src/interp.hpp delete mode 100644 texinfo/surf_cont_fog_g.png create mode 100644 texinfo/time.texi create mode 100644 texinfo/time_big.texi delete mode 100644 texinfo/title.html delete mode 100644 texinfo/toc_en.html delete mode 100644 texinfo/toc_fr.html delete mode 100644 texinfo/toc_ru.html create mode 100644 texinfo/version.texi diff --git a/CMakeLists.txt b/CMakeLists.txt index 3364973..8a06dd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,13 +3,14 @@ cmake_minimum_required(VERSION 2.8.6) project( MathGL ) if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: + 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) endif(NOT CMAKE_BUILD_TYPE) set(CMAKE_VERBOSE_MAKEFILE ON) set(MathGL_VERSION_MAJOR 2) -set(MathGL_VERSION_MINOR 1.3) +set(MathGL_VERSION_MINOR 2.0) +set(MathGL_SOVERSION 7.1.0) MACRO(MGL_DEPENDENT_OPTION option doc default depends1 force1 depends2 force2) @@ -60,14 +61,26 @@ set(MGL_LIB_INSTALL_DIR "lib" CACHE STRING "Set library install directory") option(enable-double "Enable double precision in MathGL library" ON) option(enable-simple "Slightly increase drawing speed but disable mglDataA class") option(enable-mpi "Enable mpi") -option(enable-doc "Enable documentation building") +option(enable-opengl "Enable OpenGL support" ON) +option(enable-all-docs "Enable all documentation building") +#option(enable-doc "Enable documentation building") option(enable-all "Enable all core features") option(enable-all-widgets "Enable all Widgets") option(enable-all-swig "Enable all SWIG based interfaces") -option(enable-pthread "Enable POSIX threads support" ON) +option(enable-pthread "Enable POSIX threads support" OFF) +option(enable-openmp "Enable POSIX threads support" ON) option(enable-lgpl "Enable only LGPL part of MathGL") option(enable-mgl2 "Use names 'libmgl2-*' instead of 'libmgl-*'") #option(enable-ltdl "Enable loading modules support") +CMAKE_DEPENDENT_OPTION(enable-doc-site "Enable HTML documentation for website" OFF "NOT enable-all-docs" ON) +CMAKE_DEPENDENT_OPTION(enable-doc-html "Enable HTML documentation" OFF "NOT enable-all-docs" ON) +CMAKE_DEPENDENT_OPTION(enable-doc-info "Enable INFO documentation" OFF "NOT enable-all-docs" ON) +CMAKE_DEPENDENT_OPTION(enable-doc-pdf-ru "Enable Russian PDF documentation" OFF "NOT enable-all-docs" ON) +CMAKE_DEPENDENT_OPTION(enable-doc-pdf-en "Enable English PDF documentation" OFF "NOT enable-all-docs" ON) +CMAKE_DEPENDENT_OPTION(enable-doc-prc "Enable PDF samples for HTML docs" OFF "NOT enable-all-docs" ON) +CMAKE_DEPENDENT_OPTION(enable-doc-json "Enable JSON samples for HTML docs" OFF "NOT enable-all-docs" ON) +option(enable-texi2html "Use texi2html (obsolete package) instead of texi2any" OFF) + CMAKE_DEPENDENT_OPTION(enable-zlib "Enable zlib support" ON "NOT enable-all" ON) CMAKE_DEPENDENT_OPTION(enable-png "Enable png support" ON "NOT enable-all" ON) CMAKE_DEPENDENT_OPTION(enable-jpeg "Enable jpeg support" OFF "NOT enable-all" ON) @@ -76,12 +89,12 @@ MGL_DEPENDENT_OPTION(enable-hdf4 "Enable hdf4 support" OFF "NOT enable-lgpl" ON MGL_DEPENDENT_OPTION(enable-hdf5 "Enable hdf5 support" OFF "NOT enable-lgpl" ON "NOT enable-all" ON) CMAKE_DEPENDENT_OPTION(enable-pdf "Enable pdf support" OFF "NOT enable-all" ON) CMAKE_DEPENDENT_OPTION(enable-gif "Enable gif support" OFF "NOT enable-all" ON) -CMAKE_DEPENDENT_OPTION(enable-opengl "Enable OpenGL support" ON "NOT enable-mpi" OFF) -MGL_DEPENDENT_OPTION(enable-glut "Enable glut support" OFF "NOT enable-lgpl;NOT enable-mpi" ON "NOT enable-all-widgets" ON) -MGL_DEPENDENT_OPTION(enable-fltk "Enable fltk widget" OFF "NOT enable-lgpl;NOT enable-mpi" ON "NOT enable-all-widgets" ON) -CMAKE_DEPENDENT_OPTION(enable-wx "Enable wxWidget widget" OFF "NOT enable-lgpl;NOT enable-mpi" OFF) -MGL_DEPENDENT_OPTION(enable-qt "Enable Qt4 widget" OFF "NOT enable-lgpl;NOT enable-mpi" ON "NOT enable-all-widgets" ON) +MGL_DEPENDENT_OPTION(enable-glut "Enable glut support" OFF "NOT enable-lgpl" ON "NOT enable-all-widgets" ON) +MGL_DEPENDENT_OPTION(enable-fltk "Enable fltk widget" OFF "NOT enable-lgpl" ON "NOT enable-all-widgets" ON) +CMAKE_DEPENDENT_OPTION(enable-wx "Enable wxWidget widget" OFF "NOT enable-lgpl" OFF) +MGL_DEPENDENT_OPTION(enable-qt "Enable Qt4 widget" OFF "NOT enable-lgpl" ON "NOT enable-all-widgets" ON) MGL_DEPENDENT_OPTION(enable-python "Enable python interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON) +MGL_DEPENDENT_OPTION(enable-lua "Enable Lua (v.5.1) interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON) MGL_DEPENDENT_OPTION(enable-octave "Enable octave interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON) MGL_DEPENDENT_OPTION(enable-octave-install "Octave interface will install for all users" ON "NOT enable-lgpl" ON "NOT enable-all-swig" ON) @@ -103,7 +116,15 @@ endif(NOT WIN32) include(CheckFunctionExists) include(CMakePushCheckState) +include(TestBigEndian) + +TEST_BIG_ENDIAN(WORDS_BIGENDIAN) +if(WORDS_BIGENDIAN) + ADD_DEFINITIONS("-DWORDS_BIGENDIAN") +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) @@ -115,6 +136,9 @@ if(NOT MGL_SIN) message(SEND_ERROR "Math library not found") endif(MGL_SIN_M) endif(NOT MGL_SIN) +if(HAVE_MEMRCHR) + ADD_DEFINITIONS("-DHAVE_MEMRCHR") +endif(HAVE_MEMRCHR) if(enable-double) set(MGL_USE_DOUBLE 1) @@ -129,6 +153,20 @@ else(enable-simple) set(MGL_NO_DATA_A 0) endif(enable-simple) +if(enable-openmp) + find_package(OpenMP) + if(OPENMP_FOUND) + set(MGL_HAVE_OMP 1) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + else(OPENMP_FOUND) + message(SEND_ERROR "Couldn't find OpenMP. You can enable POSIX threads instead.") + set(MGL_HAVE_OMP 0) + endif(OPENMP_FOUND) +else(enable-openmp) + set(MGL_HAVE_OMP 0) +endif(enable-openmp) + if(enable-mpi) set(MGL_HAVE_MPI 1) find_package(MPI REQUIRED) @@ -193,7 +231,6 @@ else(enable-hdf4) endif(enable-hdf4) if(enable-hdf5) -# message(STATUS "enable hdf5") set(MGL_HAVE_HDF5 1) include(FindHDF5) if(NOT HDF5_FOUND) @@ -251,8 +288,6 @@ 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) -# message(STATUS "Found libHaru library at: ${HPDF_LIB}") -# message(STATUS "Found libHaru headers: ${HPDF_INCLUDE_DIR}") else(enable-pdf) set(MGL_HAVE_PDF 0) endif(enable-pdf) @@ -300,17 +335,14 @@ else(enable-fltk) set(MGL_HAVE_FLTK 0) endif(enable-fltk) -#if((enable-all-widgets OR enable-wx) AND (NOT enable-lgpl) ) if(enable-wx) set(MGL_HAVE_WX 1) FIND_PACKAGE(wxWidgets COMPONENTS base core gl) if(NOT wxWidgets_FOUND) message(SEND_ERROR "Couldn't find wxWidgets library.") endif(NOT wxWidgets_FOUND) -#else((enable-all-widgets OR enable-wx) AND (NOT enable-lgpl) ) else(enable-wx) set(MGL_HAVE_WX 0) -#endif((enable-all-widgets OR enable-wx) AND (NOT enable-lgpl) ) endif(enable-wx) if(enable-qt) @@ -324,6 +356,7 @@ else(enable-qt) endif(enable-qt) if(enable-python) + set(MGL_HAVE_SWIG 1) set(MGL_HAVE_PYTHON 1) FIND_PACKAGE(PythonInterp) if(NOT PYTHONINTERP_FOUND) @@ -346,7 +379,20 @@ else(enable-python) set(MGL_HAVE_PYTHON 0) endif(enable-python) +if(enable-lua) + set(MGL_HAVE_SWIG 1) + set(MGL_HAVE_LUA 1) + INCLUDE(FindLua51) + if(NOT LUA51_FOUND) + message(SEND_ERROR "Couldn't find Lua 5.1 library.") + endif(NOT LUA51_FOUND) +else(enable-lua) + set(MGL_HAVE_LUA 0) +endif(enable-lua) + + if(enable-octave) + set(MGL_HAVE_SWIG 1) set(MGL_HAVE_OCTAVE 1) find_program(oct_prog octave-config) if(NOT oct_prog) @@ -368,37 +414,95 @@ else(enable-octave) set(MGL_HAVE_OCTAVE 0) endif(enable-octave) -if(enable-doc) - set(MGL_HAVE_DOC 1) +if(enable-doc-info) + set(MGL_HAVE_DOC_INFO 1) find_program(findmi makeinfo) if(NOT findmi) message(SEND_ERROR "Couldn't find makeinfo needed for documentation building.") endif(NOT findmi) - find_program(findth texi2html) - if(NOT findth) - message(SEND_ERROR "Couldn't find texi2html needed for documentation building.") - endif(NOT findth) +else(enable-doc-info) + set(MGL_HAVE_DOC_INFO 0) +endif(enable-doc-info) + +if(enable-doc-html OR enable-doc-site) + if(enable-texi2html) + find_program(findth texi2html) + if(NOT findth) + message(SEND_ERROR "Couldn't find texi2html needed for documentation building.") + endif(NOT findth) + else(enable-texi2html) + find_program(findth texi2any) + if(NOT findth) + message(SEND_ERROR "Couldn't find texi2any needed for documentation building.") + endif(NOT findth) + endif(enable-texi2html) +endif(enable-doc-html OR enable-doc-site) + +if(enable-texi2html) + set(site_en ${CMAKE_BINARY_DIR}/texinfo/doc_en/doc_en.html) + set(site_ru ${CMAKE_BINARY_DIR}/texinfo/doc_ru/doc_ru.html) + set(th_opt ) +else(enable-texi2html) + set(th_opt --html) + set(site_en ${CMAKE_BINARY_DIR}/texinfo/doc_en/index.html) + set(site_ru ${CMAKE_BINARY_DIR}/texinfo/doc_ru/index.html) +endif(enable-texi2html) + +if(enable-doc-html) + set(MGL_HAVE_DOC_HTML 1) +else(enable-doc-html) + set(MGL_HAVE_DOC_HTML 0) +endif(enable-doc-html) + + +if(enable-doc-site) + set(MGL_HAVE_DOC_SITE 1) +else(enable-doc-site) + set(MGL_HAVE_DOC_SITE 0) +endif(enable-doc-site) + +if(enable-doc-pdf-ru) + set(MGL_HAVE_DOC_PDF_RU 1) find_program(findtp texi2pdf) if(NOT findtp) message(SEND_ERROR "Couldn't find texi2pdf needed for documentation building.") endif(NOT findtp) -else(enable-doc) - set(MGL_HAVE_DOC 0) -endif(enable-doc) +else(enable-doc-pdf-ru) + set(MGL_HAVE_DOC_PDF_RU 0) +endif(enable-doc-pdf-ru) -if(MGL_HAVE_PYTHON OR MGL_HAVE_OCTAVE) +if(enable-doc-pdf-en) + set(MGL_HAVE_DOC_PDF_EN 1) + find_program(findtp texi2pdf) + if(NOT findtp) + message(SEND_ERROR "Couldn't find texi2pdf needed for documentation building.") + endif(NOT findtp) +else(enable-doc-pdf-en) + set(MGL_HAVE_DOC_PDF_EN 0) +endif(enable-doc-pdf-en) + +if(enable-doc-json) + set(MGL_HAVE_DOC_JSON 1) +else(enable-doc-json) + set(MGL_HAVE_DOC_JSON 0) +endif(enable-doc-json) + +if(enable-doc-prc) + set(MGL_HAVE_DOC_PRC 1) + if(NOT enable-pdf) + message(SEND_ERROR "You need to enable pdf support for MathGL.") + endif(NOT enable-pdf) +else(enable-doc-prc) + set(MGL_HAVE_DOC_PRC 0) +endif(enable-doc-prc) + +if(MGL_HAVE_SWIG) FIND_PACKAGE(SWIG) if(NOT SWIG_FOUND) message(SEND_ERROR "Couldn't find swig needed for interfaces compiling.") endif(NOT SWIG_FOUND) INCLUDE(${SWIG_USE_FILE}) -endif(MGL_HAVE_PYTHON OR MGL_HAVE_OCTAVE) - -#execute_process( -# COMMAND ${oct_prog} -q --eval \'strcat\(octave_config_info\("canonical_host_type"\), "-", octave_config_info\("api_version"\)\)'|sed -e 's/ans = //' -# OUTPUT_VARIABLE OCTAVE_ARCH -# ) -#message(SEND_ERROR "${OCTAVE_ARCH}") +endif(MGL_HAVE_SWIG) if(UNIX) add_definitions(-DNO_COLOR_ARRAY) @@ -418,5 +522,9 @@ add_subdirectory( lang ) if(NOT MSVC AND NOT BORLAND) add_subdirectory( utils ) 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 ) +endif(MGL_HAVE_DOC_HTML OR MGL_HAVE_DOC_SITE OR MGL_HAVE_DOC_INFO OR MGL_HAVE_DOC_PDF_RU OR MGL_HAVE_DOC_PDF_EN ) + endif(NOT MSVC AND NOT BORLAND) diff --git a/ChangeLog.txt b/ChangeLog.txt index 9d2da36..6520551 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,35 @@ +2.2 Release 11 November 2013 + +* Add OpenMP calls mostly everywhere (can work as replacement of pthreads - a bit faster since more loops is parallelized). +* Greatly speed up consequent FFT and Hankel transforms. Add mgl_clear_fft() function for manual clearing of saved FFT/Hankel data. +* Add OHLC() plot for drawing Open-High-Low-Close diagram +* Add wxMathGL widget. +* Add interface for Lua v.5.1. +* Add mask for face drawing if one of symbols "-+=;oOsS~<>jdD*^" is specified in color scheme. This work only for export in bitmap images. +* Add Quality=8 for dots drawing (extremely fast). +* Add styles '4','6','8' for Cone() and Cones() to produce square, hex-, octo-prism. +* Add style 't' for Cones() to produce tubes (cylinders). +* Add style '^' for Legend() to left/right align legend if its coordinates are right/left from the center +* Add style '<', '^', '>' for aligning/centering boxes in Bars(), Barh(), BoxPlot(), Cones(). Also this plots become centered by default if nx sizes are the same for all data. +* Add Dots() function which set independently both color and alpha of dots +* Improve automatic axis position. Add style '^' for inverse automatic axis position. +* Improve tick labeling. Add style TuneTicks&4 for zero filling of tick labels. +* Add mglData::Refill() for filling by interpolation of parametrically dependent data +* Add transparency for Area() and Region() plots. +* Add mgl_clf_chr() function and extend 'clf' command. +* Fourier now perform true inverse Fourier transform (instead of backward one). +* Improve/change lighting from local sources. Add SetDiffuse() function. +* C functions now return NULL if HMDT data cannot be created for given input argument(s). +* Enable line width for Mesh() and Fall() plots. +* Replace +INF and -INF by NAN in textual formula output. +* Add manual compression of JSON. +* Define WORDS_BIGENDIAN and HAVE_MEMRCHR (thanks to Dinar Valeev). +* Bugfix for cleaning unused points. +* Fix 'setsize' command at UDAV starting. +* Rewrite MGL parsing by using std::wstring for avoiding possible bugs of wcs*() functions. +* Minor bugfixes. +* Update docs. + 2.1.3.1 Released 8 May 2013 * Compatibility changes for MS VS. diff --git a/brush.ods b/brush.ods index 9b0be4ea76a41534923d8a6b47485f7de042ec1e..ae9110c28c3abc8317432ab21b7059bc9f965930 100644 GIT binary patch literal 19306 zcmbWf17Kdu_C6e2jcqk)Y}^4D16pfcdsBN_Ya2r=18aRpOG7IMT6-HiLtO)V6GKA>`G3*5ghI(FfdmBf z^1%e?R5o$6)U(nxwXmmi_;pEZV`Us7FDnKQgAD^n0xuyhtO)o$2?PWT1O)=PDyW}o z0s=xpk`NY9c1b%<_cl@4Cg|h)N*X5}A6{GvCkPd;NLg~N#wSkgPe=`7ZW7yONJ+9& z$q0^yQ)|kJ{H2uAH`jhpdq+VW^arhUex z$H_xLf5WN$4fiO=sPSk^D_`HJlAzt=!)aUVeU^Yfm^&~rm<&1@qjtef?3sYLBZ~RM zj%?4eh@|+ABuWz9rL#ntClC@CG2$F>4CIkde^_@omctrQI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EJW~x?ypx@{)znc6c>@&y)4vM{+8(d3H;L`?I{mnH5u%zh0Z|1F>1-|+c0p!~Od zkl`uze};R%2AF^5g9tG%i|}vwz%N_<5^(;R6C!xLEUv%dbQysDTP}sa;c^*}{#!0H zzu|Hjpnm7_bLAs6_!(s)Le$H06~3PSY2!ZxtUp)fPo}>*OGJQrSsdU@FT>S;;(m1p e2v>SpP8k2-ST&T<&=F(=@V{H|y{gHKc=|t%#4v{d diff --git a/examples/full_test.cpp b/examples/full_test.cpp index c050a0b..cf8b599 100644 --- a/examples/full_test.cpp +++ b/examples/full_test.cpp @@ -49,11 +49,11 @@ int type = 0; int dotest = 0; int width = 800; int height = 600; -int mini = 0; int big = 0; int srnd = 0; int use_mgl = 0; int verbose = 0; +int quality = MGL_DRAW_NORM; //----------------------------------------------------------------------------- void mgls_prepare1d(mglData *y, mglData *y1=0, mglData *y2=0, mglData *x1=0, mglData *x2=0); void mgls_prepare2d(mglData *a, mglData *b=0, mglData *v=0); @@ -64,23 +64,21 @@ void mgls_prepare3v(mglData *ex, mglData *ey, mglData *ez); void save(mglGraph *gr,const char *name,const char *suf); void smgl_stfa(mglGraph *gr); // STFA sample void smgl_text(mglGraph *gr); // text drawing +void smgl_surf(mglGraph *gr); void test(mglGraph *gr) { - smgl_text(gr); return; - mglParse par; - par.AllowSetSize(true); setlocale(LC_CTYPE, ""); - par.Execute(gr,"xrange 1362565462 1365935062:ticktime 'x' 7*86400 '%d/%m/%y':axis"); -// FILE *fp=fopen("/home/balakin/progr/mathgl-code/mathgl-2x/build/test.mgl","r"); -// par.Execute(gr,fp,true); -// fclose(fp); +// par.Execute(gr,"axis"); + par.Execute(gr,"axis 'lg(x)' '' '':axis:box:fplot 'x^2'"); } //----------------------------------------------------------------------------- #if !defined(_MSC_VER) && !defined(__BORLANDC__) static struct option longopts[] = { + { "mini", no_argument, &big, 3 }, { "big", no_argument, &big, 1 }, + { "web", no_argument, &big, 2 }, { "bps", no_argument, &type, 8 }, { "help", no_argument, NULL, '?' }, { "height", required_argument, NULL, 'h' }, @@ -91,7 +89,6 @@ static struct option longopts[] = { "kind", required_argument, NULL, 'k' }, { "list", no_argument, NULL, 'l' }, { "mgl", no_argument, &use_mgl, 1 }, - { "mini", no_argument, &mini, 1 }, { "none", no_argument, &type, 7 }, { "obj", no_argument, &type, 11 }, { "obj_old",no_argument, &type, 10 }, @@ -107,9 +104,11 @@ static struct option longopts[] = { "jsonz", no_argument, &type, 16 }, { "test", no_argument, &dotest, 1 }, { "font", no_argument, &dotest, 2 }, + { "time", no_argument, &dotest, 3 }, { "thread", required_argument, NULL, 't' }, { "verbose",no_argument, &verbose, 1 }, { "width", required_argument, NULL, 'w' }, + { "quality",required_argument, NULL, 'q' }, { NULL, 0, NULL, 0 } }; //----------------------------------------------------------------------------- @@ -121,10 +120,11 @@ void usage() "--height=num - png picture height\n" "--mini - png picture is 200x150\n" "--big - png picture is 1920x1440\n" + "--web - png picture is 640x480\n" "--prc - output prc\n" "--pdf - output pdf\n" "--eps - output EPS\n" - "--eps - output LaTeX\n" + "--tex - output LaTeX\n" "--jpeg - output JPEG\n" "--json - output JSON\n" "--jsonz - output JSONz\n" @@ -140,8 +140,10 @@ void usage() "--kind=name - produce only this sample\n" "--thread=num - number of threads used\n" "--mgl - use MGL scripts for samples\n" - "--test - perform test\n" + "--test - run in test mode\n" + "--time - measure execution time for all samples\n" "--font - write current font as C++ file\n" + "--quality=val - use specified quality for plot(s)\n" ); } #endif @@ -150,7 +152,6 @@ void save(mglGraph *gr,const char *name,const char *suf="") { // return; char buf[128]; - printf("%s ",name); fflush(stdout); switch(type) { case 1: // EPS @@ -172,7 +173,7 @@ void save(mglGraph *gr,const char *name,const char *suf="") case 6: // GIF snprintf(buf,128,"%s%s.gif",name,suf); gr->WriteGIF(buf); break; - case 7: // none + case 7: gr->Finish(); // none break; case 8: // EPS to PNG snprintf(buf,128,"%s%s.png",name,suf); @@ -201,7 +202,7 @@ void save(mglGraph *gr,const char *name,const char *suf="") gr->WriteJSON(buf); break; case 16: // JSON snprintf(buf,128,"%s%s.jsonz",name,suf); - gr->WriteJSON(buf); break; + gr->WriteJSON(buf,"",true); break; default:// PNG (no alpha) #if MGL_HAVE_PNG snprintf(buf,128,"%s%s.png",name,suf); @@ -228,6 +229,7 @@ int main(int argc,char **argv) case 0: break; case 'w': width =atoi(optarg); break; case 'h': height=atoi(optarg); break; + case 'q': quality =atoi(optarg); break; case 'k': strncpy(name, optarg,256); tmp=strchr(name,'.'); if(tmp) *tmp=0; tmp=strchr(name,'-'); if(tmp) *tmp=0; @@ -242,12 +244,16 @@ int main(int argc,char **argv) #endif if(dotest==1) printf("Global (before):%s\n",mglGlobalMess.c_str()); - gr = new mglGraph; //gr->SetQuality(0); + gr = new mglGraph; if( type==11|| type==12|| type==5 || type==9) width=height; - if(mini) { gr->SetSize(190,145); suf = "-sm"; } - else if(big) - { gr->SetSize(1920,1440); suf = "-lg"; } - else gr->SetSize(width,height); + switch(big) + { + case 1: gr->SetSize(1920,1440); suf = "-lg"; break; + case 2: gr->SetSize(640,480); break; + case 3: gr->SetSize(192,144); suf = "-sm"; break; + default: gr->SetSize(width,height); + } + gr->SetQuality(quality); if(dotest==1) { @@ -262,29 +268,68 @@ int main(int argc,char **argv) else if(dotest==2) { mgl_create_cpp_font(gr->Self(), L"!-~,¡-ÿ,̀-̏,Α-ω,ϑ,ϕ,ϖ,ϰ,ϱ,ϵ,А-я,ℏ,ℑ,ℓ,ℜ,←-↙,∀-∯,≠-≯,⟂"); delete gr; return 0; } + else if(dotest==3) + { + int qual[7]={0,1,2,4,5,6,8}; + size_t ll=strlen(mmgl_dat_prepare)+1; + mglParse par; + par.AllowSetSize(true); setlocale(LC_CTYPE, ""); + FILE *fp = fopen(big?"time_big.texi":"time.texi","w"); + fprintf(fp,"@multitable @columnfractions .16 .12 .12 .12 .12 .12 .12 .12\n"); + fprintf(fp,"@headitem Name"); + for(int i=0;i<7;i++) fprintf(fp," @tab q=%d",qual[i]); + clock_t beg,end; + while(s->name[0]) // all samples + { + char *buf = new char[strlen(s->mgl)+ll]; + strcpy(buf,s->mgl); strcat(buf,mmgl_dat_prepare); + fprintf(fp,"\n@item %s",s->name); + + printf("%s",s->name); + for(int i=0;i<7;i++) + { + gr->DefaultPlotParam(); + gr->SetQuality(qual[i]); gr->Clf(); + beg = clock(); + if(!use_mgl) s->func(gr); + else par.Execute(gr,buf); + gr->Finish(); + end = clock(); + fprintf(fp," @tab %.3g",double(end-beg)/CLOCKS_PER_SEC); + printf("\t%d->%g",qual[i],double(end-beg)/CLOCKS_PER_SEC); + fflush(fp); fflush(stdout); + } + printf("\n"); delete []buf; s++; + } + fprintf(fp,"\n@end multitable\n"); fclose(fp); + } + + if(type==15 || type==16) big=3; // save mini version for json - if(type==15 || type==16) mini=1; // save mini version for json - if(srnd) mgl_srnd(1); gr->VertexColor(false); gr->Compression(false); - if(name[0]==0) while(s->name[0]) // all samples + if(name[0]==0) { - gr->DefaultPlotParam(); gr->Clf(); - if(use_mgl) + while(s->name[0]) // all samples { - mglParse par; - par.AllowSetSize(true); - setlocale(LC_CTYPE, ""); - char *buf = new char[strlen(s->mgl)+strlen(mmgl_dat_prepare)+1]; - strcpy(buf,s->mgl); strcat(buf,mmgl_dat_prepare); - printf("\n-------\n%s\n-------\n",verbose?buf:s->mgl); - par.Execute(gr,buf); delete []buf; - const char *mess = gr->Message(); - if(*mess) printf("Warnings: %s\n-------\n",mess); + gr->DefaultPlotParam(); gr->Clf(); + if(use_mgl) + { + mglParse par; + par.AllowSetSize(true); + setlocale(LC_CTYPE, ""); + char *buf = new char[strlen(s->mgl)+strlen(mmgl_dat_prepare)+1]; + strcpy(buf,s->mgl); strcat(buf,mmgl_dat_prepare); + printf("\n-------\n%s\n-------\n",verbose?buf:s->mgl); + par.Execute(gr,buf); delete []buf; + const char *mess = gr->Message(); + if(*mess) printf("Warnings: %s\n-------\n",mess); + } + else s->func(gr); + save(gr, s->name, suf); + printf("%s ",s->name); fflush(stdout); s++; } - else s->func(gr); - save(gr, s->name, suf); - fflush(stdout); s++; + printf("\n"); } else // manual sample { @@ -312,7 +357,6 @@ int main(int argc,char **argv) } else printf("no sample %s\n",name); } - printf("\n"); delete gr; return 0; } //----------------------------------------------------------------------------- diff --git a/examples/glut_example.cpp b/examples/glut_example.cpp index 419bb74..e88678c 100644 --- a/examples/glut_example.cpp +++ b/examples/glut_example.cpp @@ -21,6 +21,7 @@ //----------------------------------------------------------------------------- int test_wnd(mglGraph *gr); int sample(mglGraph *gr); +int sample_m(mglGraph *gr); int sample_1(mglGraph *gr); int sample_2(mglGraph *gr); int sample_3(mglGraph *gr); diff --git a/examples/mpi_test.cpp b/examples/mpi_test.cpp new file mode 100644 index 0000000..7d32780 --- /dev/null +++ b/examples/mpi_test.cpp @@ -0,0 +1,39 @@ +#include +#include +#include +#define MCW MPI_COMM_WORLD + +int main(int argc, char *argv[]) +{ + // initialize MPI + int rank=0, numproc=1; + MPI_Init(&argc, &argv); + MPI_Comm_size(MPI_COMM_WORLD,&numproc); + MPI_Comm_rank(MPI_COMM_WORLD,&rank); + if(rank==0) printf("Use %d processes.\n", numproc); + + // initialize data similarly for all ranks + mglData a(128,128); + mglGraphMPI gr; + // do the same plot for its own range + char buf[64]; + sprintf(buf,"xrange %g %g",2.*rank/numproc-1,2.*(rank+1)/numproc-1); + gr.Fill(a,"sin(2*pi*x)",buf); + // plot data in each rank + gr.Rotate(40,60); + gr.Surf(a,"",buf); + // collect information + if(rank!=0) gr.MPI_Send(0); + else for(int i=1;i -#endif mglPoint pnt; // some global variable for changeable data void *mgl_qt_tmp(void *); //----------------------------------------------------------------------------- @@ -45,7 +42,7 @@ public: mglWnd *Gr; // graphics to be updated int Draw(mglGraph *gr); void Calc(); -} foo; +}; //----------------------------------------------------- void Foo::Calc() { @@ -71,8 +68,9 @@ int Foo::Draw(mglGraph *gr) int main(int argc,char **argv) { #ifdef PTHREAD_SAMPLE - mglQT gr(&foo,"MathGL examples"); - foo.Gr = &gr; foo.Run(); + Foo *foo = new Foo; + mglQT gr(foo,"MathGL examples"); + foo->Gr = &gr; foo->Run(); return gr.Run(); #else mglQT *gr; diff --git a/examples/samples.cpp b/examples/samples.cpp index 2c64bb6..fb6831e 100644 --- a/examples/samples.cpp +++ b/examples/samples.cpp @@ -24,7 +24,7 @@ void mgls_prepare2d(mglData *a, mglData *b=0, mglData *v=0); void mgls_prepare3d(mglData *a, mglData *b=0); void mgls_prepare2v(mglData *a, mglData *b); void mgls_prepare3v(mglData *ex, mglData *ey, mglData *ez); -extern int mini; +extern int big; //----------------------------------------------------------------------------- struct mglSample /// Structure for list of samples { @@ -73,12 +73,12 @@ void smgl_fexport(mglGraph *gr) // test file export gr->Line(mglPoint(x0,1-5*d),mglPoint(x1,1-5*d),"ki"); gr->Puts(mglPoint(x2,y-5*d),"Small dash-dot 'i'",":rL"); gr->Line(mglPoint(x0,1-6*d),mglPoint(x1,1-6*d),"k:"); gr->Puts(mglPoint(x2,y-6*d),"Dots ':'",":rL"); gr->Line(mglPoint(x0,1-7*d),mglPoint(x1,1-7*d),"k "); gr->Puts(mglPoint(x2,y-7*d),"None ' '",":rL"); - + d=0.25; x1=-1; x0=-0.8; y = -0.05; - gr->Mark(mglPoint(x1,5*d),"k."); gr->Puts(mglPoint(x0,y+5*d),"'.'",":rL"); - gr->Mark(mglPoint(x1,4*d),"k+"); gr->Puts(mglPoint(x0,y+4*d),"'+'",":rL"); - gr->Mark(mglPoint(x1,3*d),"kx"); gr->Puts(mglPoint(x0,y+3*d),"'x'",":rL"); - gr->Mark(mglPoint(x1,2*d),"k*"); gr->Puts(mglPoint(x0,y+2*d),"'*'",":rL"); + gr->Mark(mglPoint(x1,5*d),"k."); gr->Puts(mglPoint(x0,y+5*d),"'.'",":rL"); + gr->Mark(mglPoint(x1,4*d),"k+"); gr->Puts(mglPoint(x0,y+4*d),"'+'",":rL"); + gr->Mark(mglPoint(x1,3*d),"kx"); gr->Puts(mglPoint(x0,y+3*d),"'x'",":rL"); + gr->Mark(mglPoint(x1,2*d),"k*"); gr->Puts(mglPoint(x0,y+2*d),"'*'",":rL"); gr->Mark(mglPoint(x1,d),"ks"); gr->Puts(mglPoint(x0,y+d),"'s'",":rL"); gr->Mark(mglPoint(x1,0),"kd"); gr->Puts(mglPoint(x0,y),"'d'",":rL"); gr->Mark(mglPoint(x1,-d,0),"ko"); gr->Puts(mglPoint(x0,y-d),"'o'",":rL"); @@ -86,7 +86,7 @@ void smgl_fexport(mglGraph *gr) // test file export gr->Mark(mglPoint(x1,-3*d,0),"kv"); gr->Puts(mglPoint(x0,y-3*d),"'v'",":rL"); gr->Mark(mglPoint(x1,-4*d,0),"k<"); gr->Puts(mglPoint(x0,y-4*d),"'<'",":rL"); gr->Mark(mglPoint(x1,-5*d,0),"k>"); gr->Puts(mglPoint(x0,y-5*d),"'>'",":rL"); - + d=0.25; x1=-0.5; x0=-0.3; y = -0.05; gr->Mark(mglPoint(x1,5*d),"k#."); gr->Puts(mglPoint(x0,y+5*d),"'\\#.'",":rL"); gr->Mark(mglPoint(x1,4*d),"k#+"); gr->Puts(mglPoint(x0,y+4*d),"'\\#+'",":rL"); @@ -99,7 +99,7 @@ void smgl_fexport(mglGraph *gr) // test file export gr->Mark(mglPoint(x1,-3*d,0),"k#v"); gr->Puts(mglPoint(x0,y-3*d),"'\\#v'",":rL"); gr->Mark(mglPoint(x1,-4*d,0),"k#<"); gr->Puts(mglPoint(x0,y-4*d),"'\\#<'",":rL"); gr->Mark(mglPoint(x1,-5*d,0),"k#>"); gr->Puts(mglPoint(x0,y-5*d),"'\\#>'",":rL"); - + gr->SubPlot(3,2,1); double a=0.1,b=0.4,c=0.5; gr->Line(mglPoint(a,1),mglPoint(b,1),"k-A"); gr->Puts(mglPoint(c,1),"Style 'A' or 'A\\_'",":rL"); @@ -113,7 +113,7 @@ void smgl_fexport(mglGraph *gr) // test file export gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"k-_"); gr->Puts(mglPoint(c,-0.6),"Style '\\_' or none",":rL"); gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-AS"); gr->Puts(mglPoint(c,-0.8),"Style 'AS'",":rL"); gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-_A"); gr->Puts(mglPoint(c,-1),"Style '\\_A'",":rL"); - + a=-1; b=-0.7; c=-0.6; gr->Line(mglPoint(a,1),mglPoint(b,1),"kAA"); gr->Puts(mglPoint(c,1),"Style 'AA'",":rL"); gr->Line(mglPoint(a,0.8),mglPoint(b,0.8),"kVV"); gr->Puts(mglPoint(c,0.8),"Style 'VV'",":rL"); @@ -126,7 +126,7 @@ void smgl_fexport(mglGraph *gr) // test file export gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"k-__"); gr->Puts(mglPoint(c,-0.6),"Style '\\_\\_'",":rL"); gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-VA"); gr->Puts(mglPoint(c,-0.8),"Style 'VA'",":rL"); gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-AV"); gr->Puts(mglPoint(c,-1),"Style 'AV'",":rL"); - + gr->SubPlot(3,2,2); //#LENUQ gr->FaceZ(mglPoint(-1, -1), 0.4, 0.3, "L#"); gr->Puts(mglPoint(-0.8,-0.9), "L", "w:C", -1.4); @@ -173,7 +173,7 @@ void smgl_fexport(mglGraph *gr) // test file export // HEX gr->FaceZ(mglPoint(-1, -1.3), 1, 0.3, "{xff9966}#"); gr->Puts(mglPoint(-0.5,-1.2), "\\{xff9966\\}", "k:C", -1.4); gr->FaceZ(mglPoint(0, -1.3), 1, 0.3, "{x83CAFF}#"); gr->Puts(mglPoint( 0.5,-1.2), "\\{x83CAFF\\}", "k:C", -1.4); - + gr->SubPlot(3,2,3); char stl[3]="r1", txt[4]="'1'"; for(int i=0;i<10;i++) @@ -182,20 +182,20 @@ void smgl_fexport(mglGraph *gr) // test file export gr->Line(mglPoint(-1,0.2*i-1),mglPoint(1,0.2*i-1),stl); gr->Puts(mglPoint(1.05,0.2*i-1),txt,":L"); } - + gr->SubPlot(3,2,4); gr->Title("TriPlot sample"); gr->Rotate(50,60); double t[] = {0,1,2, 0,1,3, 0,2,3, 1,2,3}; double xt[] = {-1,1,0,0}, yt[] = {-1,-1,1,0}, zt[] = {-1,-1,-1,1}; mglData tt(4,3,t), uu(4,xt), vv(4,yt), ww(4,zt); gr->TriPlot(tt,uu,vv,ww,"b"); gr->TriPlot(tt,uu,vv,ww,"k#"); - + gr->SubPlot(3,2,5); mglData r(4); r.Fill(1,4); gr->SetRanges(1,4,1,4); gr->Axis(); gr->Mark(r,r,"s"); gr->Plot(r,"b"); - + gr->WriteJPEG("fexport.jpg"); gr->WritePNG("fexport.png"); gr->WriteBMP("fexport.bmp"); @@ -203,7 +203,7 @@ void smgl_fexport(mglGraph *gr) // test file export gr->WriteEPS("fexport.eps"); gr->WriteSVG("fexport.svg"); gr->WriteGIF("fexport.gif"); - + gr->WriteXYZ("fexport.xyz"); gr->WriteSTL("fexport.stl"); gr->WriteOFF("fexport.off"); @@ -212,6 +212,102 @@ void smgl_fexport(mglGraph *gr) // test file export gr->WritePRC("fexport.prc"); } //----------------------------------------------------------------------------- +const char *mmgl_refill="new x 10 '0.5+rnd':cumsum x 'x':norm x -1 1\n" +"copy y sin(pi*x)/2\nbox:axis:plot x y 'o '\n" +"new r 100:refill r x y\nplot r 'r'\nfplot 'sin(pi*x)/2' 'B:'"; +void smgl_refill(mglGraph *gr) +{ + mglData x(10), y(10), r(100); + x.Modify("0.5+rnd"); x.CumSum("x"); x.Norm(-1,1); + y.Modify("sin(pi*v)/2",x); + gr->Axis(); gr->Box(); gr->Plot(x,y,"o "); + gr->Refill(r,x,y); // or you can use r.Refill(x,y,-1,1); + gr->Plot(r,"r"); gr->FPlot("sin(pi*x)/2","B:"); +} +//----------------------------------------------------------------------------- +const char *mmgl_correl="new a 100 'exp(-10*x^2)'\n" +"new b 100 'exp(-10*(x+0.5)^2)'\n" +"yrange 0 1\nsubplot 1 2 0 '_':title 'Input fields'\n" +"plot a:plot b:box:axis\n" +"correl r a b 'x'\nnorm r 0 1:swap r 'x' # make it human readable\n" +"subplot 1 2 1 '_':title 'Correlation of a and b'\n" +"plot r 'r':axis:box\nline 0.5 0 0.5 1 'B|'\n"; +void smgl_correl(mglGraph *gr) +{ + mglData a(100),b(100); + gr->Fill(a,"exp(-10*x^2)"); gr->Fill(b,"exp(-10*(x+0.5)^2)"); + gr->SetRange('y',0,1); + gr->SubPlot(1,2,0,"_"); gr->Title("Input fields"); + gr->Plot(a); gr->Plot(b); gr->Axis(); gr->Box(); + mglData r = a.Correl(b,"x"); + r.Norm(0,1); r.Swap("x"); // make it human readable + gr->SubPlot(1,2,1,"_"); gr->Title("Correlation of a and b"); + gr->Plot(r,"r"); gr->Axis(); gr->Box(); + gr->Line(mglPoint(0.5,0),mglPoint(0.5,1),"B|"); +} +//----------------------------------------------------------------------------- +const char *mmgl_mask="new a 10 10 'x'\n" +"subplot 5 4 0 '':title '\"-\" mask':dens a '3-'\n" +"subplot 5 4 1 '':title '\"+\" mask':dens a '3+'\n" +"subplot 5 4 2 '':title '\"=\" mask':dens a '3='\n" +"subplot 5 4 3 '':title '\";\" mask':dens a '3;'\n" +"subplot 5 4 4 '':title '\";I\" mask':dens a '3;I'\n" +"subplot 5 4 5 '':title '\"o\" mask':dens a '3o'\n" +"subplot 5 4 6 '':title '\"O\" mask':dens a '3O'\n" +"subplot 5 4 7 '':title '\"s\" mask':dens a '3s'\n" +"subplot 5 4 8 '':title '\"S\" mask':dens a '3S'\n" +"subplot 5 4 9 '':title '\";/\" mask':dens a '3;/'\n" +"subplot 5 4 10 '':title '\"~\" mask':dens a '3~'\n" +"subplot 5 4 11 '':title '\"<\" mask':dens a '3<'\n" +"subplot 5 4 12 '':title '\">\" mask':dens a '3>'\n" +"subplot 5 4 13 '':title '\"j\" mask':dens a '3j'\n" +"subplot 5 4 14 '':title '\"-;\\\" mask':dens a '3;\\ '\n" +"subplot 5 4 15 '':title '\"d\" mask':dens a '3d'\n" +"subplot 5 4 16 '':title '\"D\" mask':dens a '3D'\n" +"subplot 5 4 17 '':title '\"*\" mask':dens a '3*'\n" +"subplot 5 4 18 '':title '\"^\" mask':dens a '3^'\n" +"subplot 5 4 19 '':title 'manual mask'\n" +"mask '+' 'ff00182424f80000':dens a '3+'"; +void smgl_mask(mglGraph *gr) +{ + mglData a(10,10); a.Fill(-1,1); + gr->SubPlot(5,4,0,""); gr->Title("'-' mask"); gr->Dens(a,"3-"); + gr->SubPlot(5,4,1,""); gr->Title("'+' mask"); gr->Dens(a,"3+"); + gr->SubPlot(5,4,2,""); gr->Title("'=' mask"); gr->Dens(a,"3="); + gr->SubPlot(5,4,3,""); gr->Title("';' mask"); gr->Dens(a,"3;"); + gr->SubPlot(5,4,4,""); gr->Title("';I' mask"); gr->Dens(a,"3;I"); + gr->SubPlot(5,4,5,""); gr->Title("'o' mask"); gr->Dens(a,"3o"); + gr->SubPlot(5,4,6,""); gr->Title("'O' mask"); gr->Dens(a,"3O"); + gr->SubPlot(5,4,7,""); gr->Title("'s' mask"); gr->Dens(a,"3s"); + gr->SubPlot(5,4,8,""); gr->Title("'S' mask"); gr->Dens(a,"3S"); + gr->SubPlot(5,4,9,""); gr->Title("';/' mask"); gr->Dens(a,"3;/"); + gr->SubPlot(5,4,10,""); gr->Title("'~' mask"); gr->Dens(a,"3~"); + gr->SubPlot(5,4,11,""); gr->Title("'<' mask"); gr->Dens(a,"3<"); + gr->SubPlot(5,4,12,""); gr->Title("'>' mask"); gr->Dens(a,"3>"); + gr->SubPlot(5,4,13,""); gr->Title("'j' mask"); gr->Dens(a,"3j"); + gr->SubPlot(5,4,14,""); gr->Title("';\\\\' mask"); gr->Dens(a,"3;\\"); + gr->SubPlot(5,4,15,""); gr->Title("'d' mask"); gr->Dens(a,"3d"); + gr->SubPlot(5,4,16,""); gr->Title("'D' mask"); gr->Dens(a,"3D"); + gr->SubPlot(5,4,17,""); gr->Title("'*' mask"); gr->Dens(a,"3*"); + gr->SubPlot(5,4,18,""); gr->Title("'^' mask"); gr->Dens(a,"3^"); + gr->SubPlot(5,4,19,""); gr->Title("manual mask"); + gr->SetMask('+', "ff00182424f80000"); gr->Dens(a,"3+"); +} +//----------------------------------------------------------------------------- +const char *mmgl_export="new a 100 100 'x^2*y':new b 100 100\n" +"export a 'test_data.png' 'BbcyrR' -1 1\n" +"import b 'test_data.png' 'BbcyrR' -1 1\n" +"subplot 2 1 0 '':title 'initial':box:dens a\n" +"subplot 2 1 1 '':title 'imported':box:dens b"; +void smgl_export(mglGraph *gr) // basic data operations +{ + mglData a(100,100), b; gr->Fill(a,"x^2*y"); + a.Export("test_data.png","BbcyrR"); + b.Import("test_data.png","BbcyrR",-1,1); + gr->SubPlot(2,1,0,""); gr->Title("initial"); gr->Box(); gr->Dens(a); + gr->SubPlot(2,1,1,""); gr->Title("imported"); gr->Box(); gr->Dens(b); +} +//----------------------------------------------------------------------------- const char *mmgl_data1="new a 40 50 60 'exp(-x^2-4*y^2-16*z^2)'\n" "light on:alpha on\n" "copy b a:diff b 'x':subplot 5 3 0:call 'splot'\n" @@ -321,7 +417,7 @@ void smgl_param1(mglGraph *gr) // 1d parametric plots gr->SubPlot(4,3,2); gr->Rotate(40,60); gr->Box(); gr->Tens(x,y,z,c); gr->SubPlot(4,3,3); gr->Rotate(40,60); gr->Box(); gr->Bars(x,y,z); gr->SubPlot(4,3,4); gr->Rotate(40,60); gr->Box(); gr->Stem(x,y,z); - gr->SubPlot(4,3,5); gr->Rotate(40,60); gr->Box(); gr->TextMark(x,y,z,"\\alpha"); + gr->SubPlot(4,3,5); gr->Rotate(40,60); gr->Box(); gr->TextMark(x,y,z,c*2,"\\alpha"); gr->SubPlot(4,3,6); gr->Rotate(40,60); gr->Box(); gr->Tube(x,y,z,c/10,"","light on"); gr->SubPlot(4,3,7); gr->Rotate(40,60); gr->Box(); gr->Mark(x,y,z,c,"s"); gr->SubPlot(4,3,8); gr->Rotate(40,60); gr->Box(); gr->Error(x,y,z/10,c/10); @@ -355,7 +451,7 @@ void smgl_param2(mglGraph *gr) // 2d parametric plots mglData x(100,100), y(100,100), z(100,100), c(100,100); gr->Fill(x,"sin(pi*(x+y)/2)*cos(pi*y/2)"); gr->Fill(y,"cos(pi*(x+y)/2)*cos(pi*y/2)"); gr->Fill(z,"sin(pi*y/2)"); gr->Fill(c,"cos(pi*x)"); - + gr->SubPlot(4,4,0); gr->Rotate(40,60); gr->Box(); gr->Surf(x,y,z); gr->SubPlot(4,4,1); gr->Rotate(40,60); gr->Box(); gr->SurfC(x,y,z,c); gr->SubPlot(4,4,2); gr->Rotate(40,60); gr->Box(); gr->SurfA(x,y,z,c,"","alpha 1"); @@ -443,7 +539,7 @@ void smgl_paramv(mglGraph *gr) // parametric plots for vector field gr->SubPlot(3,3,4); gr->Rotate(40,60); gr->Box(); gr->Vect(x,y,z,ex,ey,ez); gr->SubPlot(3,3,5); gr->Rotate(40,60); gr->Box(); gr->Vect3(x,y,z,ex,ey,ez); gr->Vect3(x,y,z,ex,ey,ez,"x"); gr->Vect3(x,y,z,ex,ey,ez,"z"); - gr->Grid3(x,y,z,z,"{r9}"); gr->Grid3(x,y,z,z,"{r9}x"); gr->Grid3(x,y,z,z,"{r9}z"); + gr->Grid3(x,y,z,z,"{r9}"); gr->Grid3(x,y,z,z,"{g9}x"); gr->Grid3(x,y,z,z,"{b9}z"); gr->SubPlot(3,3,6); gr->Rotate(40,60); gr->Box(); gr->Flow(x,y,z,ex,ey,ez); gr->SubPlot(3,3,7); gr->Rotate(40,60); gr->Box(); gr->Pipe(x,y,z,ex,ey,ez); } @@ -512,8 +608,8 @@ void smgl_triangulation(mglGraph *gr) // surface triangulation mglData x(100), y(100), z(100); gr->Fill(x,"2*rnd-1"); gr->Fill(y,"2*rnd-1"); gr->Fill(z,"v^2-w^2",x,y); mglData d = mglTriangulation(x,y), g(30,30); - - if(!mini) gr->Title("Triangulation"); + + if(big!=3) gr->Title("Triangulation"); gr->Rotate(40,60); gr->Box(); gr->Light(true); gr->TriPlot(d,x,y,z); gr->TriPlot(d,x,y,z,"#k"); @@ -542,8 +638,8 @@ const char *mmgl_schemes="call 'sch' 0 'kw'\ncall 'sch' 1 'wk'\ncall 'sch' 2 'kH "call 'sch' 8 'GgwmM'\ncall 'sch' 9 'UuwqR'\ncall 'sch' 10 'QqwcC'\ncall 'sch' 11 'CcwyY'\n" "call 'sch' 12 'bcwyr'\ncall 'sch' 13 'bwr'\ncall 'sch' 14 'BbcyrR'\ncall 'sch' 15 'UbcyqR'\n" "call 'sch' 16 'BbcwyrR'\ncall 'sch' 17 'bgr'\ncall 'sch' 18 'BbcyrR|'\ncall 'sch' 19 'b\\{g,0.3\\}r'\n" -"stop\nfunc 'sch' 2\nsubplot 2 10 $1 '<>_^' 0.2 0:fsurf 'x' '$2'\n" -"text 0.07+0.5*mod($1,2) 0.92-0.1*int($1/2) '$2' 'A'\nreturn\n"; +"stop\nfunc 'sch' 2\nsubplot 2 10 $1 '<>_^' 0.2 0:fsurf 'x' $2\n" +"text 0.07+0.5*mod($1,2) 0.92-0.1*int($1/2) $2 'A'\nreturn\n"; void smgl_schemes(mglGraph *gr) // Color table { mglData a(256,2); a.Fill(-1,1); @@ -736,7 +832,7 @@ const char *mmgl_text="call 'prepare1d'\nsubplot 2 2 0 ''\ntext 0 1 'Text can be "line -1 -1 1 1 'rA':text 0 0 1 1 'At angle' '@'\nline -1 -1 -1 1 'rA':text -1 0 -1 1 'Vertical'\n"; void smgl_text(mglGraph *gr) // text drawing { - if(!mini) gr->SubPlot(2,2,0,""); + if(big!=3) gr->SubPlot(2,2,0,""); gr->Putsw(mglPoint(0,1),L"Text can be in ASCII and in Unicode"); gr->Puts(mglPoint(0,0.6),"It can be \\wire{wire}, \\big{big} or #r{colored}"); gr->Puts(mglPoint(0,0.2),"One can change style in string: " @@ -746,7 +842,7 @@ void smgl_text(mglGraph *gr) // text drawing gr->Puts(mglPoint(0,-0.6),"Easy to change indexes ^{up} _{down} @{center}"); gr->Puts(mglPoint(0,-1),"It parse TeX: \\int \\alpha \\cdot " "\\sqrt3{sin(\\pi x)^2 + \\gamma_{i_k}} dx"); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1,""); gr->Puts(mglPoint(0,0.5), "\\sqrt{\\frac{\\alpha^{\\gamma^2}+\\overset 1{\\big\\infty}}{\\sqrt3{2+b}}}", "@", -2); @@ -764,6 +860,30 @@ void smgl_text(mglGraph *gr) // text drawing gr->Line(mglPoint(-1,-1),mglPoint(-1,1),"rA"); gr->Puts(mglPoint(-1,0),mglPoint(-1,1),"Vertical"); } //----------------------------------------------------------------------------- +const char *mmgl_text2="call 'prepare1d'\n" +"subplot 1 3 0 '':box:plot y(:,0)\ntext y 'This is very very long string drawn along a curve' 'k'\ntext y 'Another string drawn above a curve' 'Tr'\n" +"subplot 1 3 1 '':box:plot y(:,0)\ntext y 'This is very very long string drawn along a curve' 'k:C'\ntext y 'Another string drawn above a curve' 'Tr:C'\n" +"subplot 1 3 2 '':box:plot y(:,0)\ntext y 'This is very very long string drawn along a curve' 'k:R'\ntext y 'Another string drawn above a curve' 'Tr:R'\n"; +void smgl_text2(mglGraph *gr) // text drawing +{ + mglData y; mgls_prepare1d(&y); + if(big!=3) gr->SubPlot(1,3,0,""); + gr->Box(); gr->Plot(y.SubData(-1,0)); + gr->Text(y,"This is very very long string drawn along a curve","k"); + gr->Text(y,"Another string drawn above a curve","Tr"); + if(big==3) return; + + gr->SubPlot(1,3,1,""); + gr->Box(); gr->Plot(y.SubData(-1,0)); + gr->Text(y,"This is very very long string drawn along a curve","k:C"); + gr->Text(y,"Another string drawn above a curve","Tr:C"); + + gr->SubPlot(1,3,2,""); + gr->Box(); gr->Plot(y.SubData(-1,0)); + gr->Text(y,"This is very very long string drawn along a curve","k:R"); + gr->Text(y,"Another string drawn above a curve","Tr:R"); +} +//----------------------------------------------------------------------------- const char *mmgl_fonts="define d 0.25\nloadfont 'STIX':text 0 1.1 'default font (STIX)'\nloadfont 'adventor':text 0 1.1-d 'adventor font'\n" "loadfont 'bonum':text 0 1.1-2*d 'bonum font'\nloadfont 'chorus':text 0 1.1-3*d 'chorus font'\nloadfont 'cursor':text 0 1.1-4*d 'cursor font'\n" "loadfont 'heros':text 0 1.1-5*d 'heros font'\nloadfont 'heroscn':text 0 1.1-6*d 'heroscn font'\nloadfont 'pagella':text 0 1.1-7*d 'pagella font'\n" @@ -793,9 +913,9 @@ void smgl_bars(mglGraph *gr) { mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); gr->SetOrigin(0,0,0); - if(!mini) { gr->SubPlot(3,2,0,""); gr->Title("Bars plot (default)"); } + if(big!=3) { gr->SubPlot(3,2,0,""); gr->Title("Bars plot (default)"); } gr->Box(); gr->Bars(ys); - if(mini) return; + if(big==3) return; gr->SubPlot(3,2,1,""); gr->Title("2 colors"); gr->Box(); gr->Bars(ys,"cbgGyr"); gr->SubPlot(3,2,4,""); gr->Title("'\\#' style"); gr->Box(); gr->Bars(ys,"#"); gr->SubPlot(3,2,5); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); @@ -814,9 +934,9 @@ void smgl_barh(mglGraph *gr) { mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); gr->SetOrigin(0,0,0); - if(!mini) { gr->SubPlot(2,2,0,""); gr->Title("Barh plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Barh plot (default)"); } gr->Box(); gr->Barh(ys); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1,""); gr->Title("2 colors"); gr->Box(); gr->Barh(ys,"cbgGyr"); gr->SetRanges(-3,3,-1,1); // increase range since summation can exceed [-1,1] gr->SubPlot(2,2,2,""); gr->Title("'a' style"); gr->Box(); gr->Barh(ys,"a"); @@ -830,9 +950,9 @@ const char *mmgl_area="call 'prepare1d'\norigin 0 0 0\nsubplot 2 2 0 '':title 'A void smgl_area(mglGraph *gr) { mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); - if(!mini) { gr->SubPlot(2,2,0,""); gr->Title("Area plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Area plot (default)"); } gr->Box(); gr->Area(y); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1,""); gr->Title("2 colors"); gr->Box(); gr->Area(y,"cbgGyr"); gr->SubPlot(2,2,2,""); gr->Title("'!' style"); gr->Box(); gr->Area(y,"!"); gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); @@ -848,9 +968,9 @@ const char *mmgl_plot="call 'prepare1d'\nsubplot 2 2 0 '':title 'Plot plot (defa void smgl_plot(mglGraph *gr) { mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); - if(!mini) { gr->SubPlot(2,2,0,""); gr->Title("Plot plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Plot plot (default)"); } gr->Box(); gr->Plot(y); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,2,""); gr->Title("'!' style; 'rgb' palette"); gr->Box(); gr->Plot(y,"o!rgb"); gr->SubPlot(2,2,3,""); gr->Title("just markers"); gr->Box(); gr->Plot(y," +"); gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); @@ -860,15 +980,15 @@ void smgl_plot(mglGraph *gr) } //----------------------------------------------------------------------------- const char *mmgl_tens="call 'prepare1d'\nsubplot 2 2 0 '':title 'Tens plot (default)':box:tens y(:,0) y(:,1)\n" -"subplot 2 2 2 '':title '" " style':box:tens y(:,0) y(:,1) 'o '\n" +"subplot 2 2 2 '':title '\" \" style':box:tens y(:,0) y(:,1) 'o '\n" "new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'\n" "subplot 2 2 1:title '3d variant':rotate 50 60:box:tens xc yc z z 's'\n"; void smgl_tens(mglGraph *gr) { mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); - if(!mini) { gr->SubPlot(2,2,0,""); gr->Title("Tens plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Tens plot (default)"); } gr->Box(); gr->Tens(y.SubData(-1,0), y.SubData(-1,1)); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,2,""); gr->Title("' ' style"); gr->Box(); gr->Tens(y.SubData(-1,0), y.SubData(-1,1),"o "); gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); @@ -885,9 +1005,9 @@ void smgl_region(mglGraph *gr) { mglData y; mgls_prepare1d(&y); mglData y1 = y.SubData(-1,1), y2 = y.SubData(-1,2); gr->SetOrigin(0,0,0); - if(!mini) { gr->SubPlot(2,2,0,""); gr->Title("Region plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Region plot (default)"); } gr->Box(); gr->Region(y1,y2); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1,""); gr->Title("2 colors"); gr->Box(); gr->Region(y1,y2,"yr"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); gr->SubPlot(2,2,2,""); gr->Title("'!' style"); gr->Box(); gr->Region(y1,y2,"!"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); gr->SubPlot(2,2,3,""); gr->Title("'i' style"); gr->Box(); gr->Region(y1,y2,"ir"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); @@ -901,9 +1021,9 @@ void smgl_stem(mglGraph *gr) mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); - if(!mini) { gr->SubPlot(2,2,0,""); gr->Title("Stem plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Stem plot (default)"); } gr->Box(); gr->Stem(y); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); gr->Stem(xc,yc,z,"rx"); gr->SubPlot(2,2,2,""); gr->Title("'!' style"); gr->Box(); gr->Stem(y,"o!rgb"); @@ -917,22 +1037,34 @@ void smgl_step(mglGraph *gr) mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); - if(!mini) { gr->SubPlot(2,2,0,""); gr->Title("Step plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Step plot (default)"); } gr->Box(); gr->Step(y); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); gr->Step(xc,yc,z,"r"); gr->SubPlot(2,2,2,""); gr->Title("'!' style"); gr->Box(); gr->Step(y,"s!rgb"); } //----------------------------------------------------------------------------- -const char *mmgl_boxplot="new a 10 7 '(2*rnd-1)^3/2'\nsubplot 1 1 0 '':title 'Boxplot plot':box:boxplot a"; +const char *mmgl_boxplot="new a 10 7 '(2*rnd-1)^3/2'\nsubplot 1 1 0 '':title 'Boxplot plot':box:boxplot a\n"; void smgl_boxplot(mglGraph *gr) // flow threads and density plot { mglData a(10,7); a.Modify("(2*rnd-1)^3/2"); - if(!mini) { gr->SubPlot(1,1,0,""); gr->Title("Boxplot plot"); } + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("Boxplot plot"); } gr->Box(); gr->BoxPlot(a); } //----------------------------------------------------------------------------- +const char *mmgl_ohlc="new o 10 '0.5*sin(pi*x)'\nnew c 10 '0.5*sin(pi*(x+2/9))'\n" +"new l 10 '0.3*rnd-0.8'\nnew h 10 '0.3*rnd+0.5'\n" +"subplot 1 1 0 '':title 'OHLC plot':box:ohlc o h l c\n"; +void smgl_ohlc(mglGraph *gr) // flow threads and density plot +{ + mglData o(10), h(10), l(10), c(10); + gr->Fill(o,"0.5*sin(pi*x)"); gr->Fill(c,"0.5*sin(pi*(x+2/9))"); + gr->Fill(l,"0.3*rnd-0.8"); gr->Fill(h,"0.3*rnd+0.5"); + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("OHLC plot"); } + gr->Box(); gr->OHLC(o,h,l,c); +} +//----------------------------------------------------------------------------- const char *mmgl_type0="call 'prepare2d'\nalpha on:light on:transptype 0:clf\nsubplot 2 2 0:rotate 50 60:surf a:box\n" "subplot 2 2 1:rotate 50 60:dens a:box\nsubplot 2 2 2:rotate 50 60:cont a:box\n" "subplot 2 2 3:rotate 50 60:axial a:box"; @@ -1055,6 +1187,39 @@ void smgl_molecule(mglGraph *gr) // example of moleculas gr->DoubleSided( true ); // put back } //----------------------------------------------------------------------------- +const char *mmgl_error2="new x0 10 'rnd':new ex 10 '0.1'\nnew y0 10 'rnd':new ey 10 '0.1'\nranges 0 1 0 1\n" +"subplot 4 3 0 '':box:error x0 y0 ex ey '#+@'\n" +"subplot 4 3 1 '':box:error x0 y0 ex ey '#x@'\n" +"subplot 4 3 2 '':box:error x0 y0 ex ey '#s@'; alpha 0.5\n" +"subplot 4 3 3 '':box:error x0 y0 ex ey 's@'\n" +"subplot 4 3 4 '':box:error x0 y0 ex ey 'd@'\n" +"subplot 4 3 5 '':box:error x0 y0 ex ey '#d@'; alpha 0.5\n" +"subplot 4 3 6 '':box:error x0 y0 ex ey '+@'\n" +"subplot 4 3 7 '':box:error x0 y0 ex ey 'x@'\n" +"subplot 4 3 8 '':box:error x0 y0 ex ey 'o@'\n" +"subplot 4 3 9 '':box:error x0 y0 ex ey '#o@'; alpha 0.5\n" +"subplot 4 3 10 '':box:error x0 y0 ex ey '#.@'\n" +"subplot 4 3 11 '':box:error x0 y0 ex ey; alpha 0.5\n"; +void smgl_error2(mglGraph *gr) +{ + mglData x0(10), y0(10), ex(10), ey(10); + for(int i=0;i<10;i++) + { x0.a[i] = mgl_rnd(); y0.a[i] = mgl_rnd(); ey.a[i] = ex.a[i] = 0.1; } + gr->SetRanges(0,1,0,1); gr->Alpha(true); + gr->SubPlot(4,3,0,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#+@"); + gr->SubPlot(4,3,1,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#x@"); + gr->SubPlot(4,3,2,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#s@","alpha 0.5"); + gr->SubPlot(4,3,3,""); gr->Box(); gr->Error(x0,y0,ex,ey,"s@"); + gr->SubPlot(4,3,4,""); gr->Box(); gr->Error(x0,y0,ex,ey,"d@"); + gr->SubPlot(4,3,5,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#d@","alpha 0.5"); + gr->SubPlot(4,3,6,""); gr->Box(); gr->Error(x0,y0,ex,ey,"+@"); + gr->SubPlot(4,3,7,""); gr->Box(); gr->Error(x0,y0,ex,ey,"x@"); + gr->SubPlot(4,3,8,""); gr->Box(); gr->Error(x0,y0,ex,ey,"o@"); + gr->SubPlot(4,3,9,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#o@","alpha 0.5"); + gr->SubPlot(4,3,10,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#.@"); + gr->SubPlot(4,3,11,""); gr->Box(); gr->Error(x0,y0,ex,ey); +} +//----------------------------------------------------------------------------- const char *mmgl_error="call 'prepare1d'\nnew y 50 '0.7*sin(pi*x-pi) + 0.5*cos(3*pi*(x+1)/2) + 0.2*sin(pi*(x+1)/2)'\n" "new x0 10 'x + 0.1*rnd-0.05':new ex 10 '0.1':new ey 10 '0.2'\n" "new y0 10 '0.7*sin(pi*x-pi) + 0.5*cos(3*pi*(x+1)/2) + 0.2*sin(pi*(x+1)/2) + 0.2*rnd-0.1'\n" @@ -1075,9 +1240,9 @@ void smgl_error(mglGraph *gr) y0.a[i] = 0.7*sin(2*M_PI*x)+0.5*cos(3*M_PI*x)+0.2*sin(M_PI*x)+0.2*mgl_rnd()-0.1; ey0.a[i]=0.2; ex0.a[i]=0.1; } - if(!mini) { gr->SubPlot(2,2,0,""); gr->Title("Error plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Error plot (default)"); } gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ex0,ey0,"ko"); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1,""); gr->Title("'!' style; no e_x"); gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ey0,"o!rgb"); gr->SubPlot(2,2,2,""); gr->Title("'\\@' style"); gr->Alpha(true); @@ -1098,9 +1263,9 @@ const char *mmgl_chart="new ch 7 2 'rnd+0.1':light on\n" void smgl_chart(mglGraph *gr) { mglData ch(7,2); for(int i=0;i<7*2;i++) ch.a[i]=mgl_rnd()+0.1; - if(!mini) { gr->SubPlot(2,2,0); gr->Title("Chart plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Chart plot (default)"); } gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Chart(ch); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("'\\#' style"); gr->Rotate(50,60); gr->Box(); gr->Chart(ch,"#"); gr->SubPlot(2,2,2); gr->Title("Pie chart; ' ' color"); @@ -1115,7 +1280,7 @@ const char *mmgl_mark="call 'prepare1d'\nsubplot 1 1 0 '':title 'Mark plot (defa void smgl_mark(mglGraph *gr) { mglData y,y1; mgls_prepare1d(&y,&y1); - if(!mini) { gr->SubPlot(1,1,0,""); gr->Title("Mark plot (default)"); } + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("Mark plot (default)"); } gr->Box(); gr->Mark(y,y1,"s"); } //----------------------------------------------------------------------------- @@ -1124,7 +1289,7 @@ const char *mmgl_radar="new yr 10 3 '0.4*sin(pi*(x+1.5+y/2)+0.1*rnd)'\n" void smgl_radar(mglGraph *gr) { mglData yr(10,3); yr.Modify("0.4*sin(pi*(2*x+y))+0.1*rnd"); - if(!mini) { gr->SubPlot(1,1,0,""); gr->Title("Radar plot (with grid, '\\#')"); } + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("Radar plot (with grid, '\\#')"); } gr->Radar(yr,"#"); } //----------------------------------------------------------------------------- @@ -1135,7 +1300,7 @@ void smgl_candle(mglGraph *gr) mglData y(30); gr->Fill(y,"sin(pi*x/2)^2"); mglData y1(30); gr->Fill(y1,"v/2",y); mglData y2(30); gr->Fill(y2,"(1+v)/2",y); - if(!mini) { gr->SubPlot(1,1,0,""); gr->Title("Candle plot (default)"); } + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("Candle plot (default)"); } gr->SetRange('y',0,1); gr->Box(); gr->Candle(y,y1,y2); } //----------------------------------------------------------------------------- @@ -1143,7 +1308,7 @@ const char *mmgl_textmark="call 'prepare1d'\nsubplot 1 1 0 '':title 'TextMark pl void smgl_textmark(mglGraph *gr) { mglData y,y1; mgls_prepare1d(&y,&y1); - if(!mini) { gr->SubPlot(1,1,0,""); gr->Title("TextMark plot (default)"); } + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("TextMark plot (default)"); } gr->Box(); gr->TextMark(y,y1,"\\gamma","r"); } //----------------------------------------------------------------------------- @@ -1156,9 +1321,9 @@ const char *mmgl_tube="call 'prepare1d'\nlight on\n" void smgl_tube(mglGraph *gr) { mglData y,y1,y2; mgls_prepare1d(&y,&y1,&y2); y1/=20; - if(!mini) { gr->SubPlot(2,2,0,""); gr->Title("Tube plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Tube plot (default)"); } gr->Light(true); gr->Box(); gr->Tube(y,0.05); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1,""); gr->Title("variable radius"); gr->Box(); gr->Tube(y,y1); gr->SubPlot(2,2,2,""); gr->Title("'\\#' style"); gr->Box(); gr->Tube(y,0.05,"#"); mglData yc(50), xc(50), z(50); z.Modify("2*x-1"); @@ -1180,9 +1345,9 @@ void smgl_tape(mglGraph *gr) mglData xc(50), yc(50), z(50); yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); z.Fill(-1,1); - if(!mini) { gr->SubPlot(2,2,0,""); gr->Title("Tape plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Tape plot (default)"); } gr->Box(); gr->Tape(y); gr->Plot(y,"k"); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("3d variant, 2 colors"); gr->Rotate(50,60); gr->Light(true); gr->Box(); gr->Plot(xc,yc,z,"k"); gr->Tape(xc,yc,z,"rg"); gr->SubPlot(2,2,2); gr->Title("3d variant, x only"); gr->Rotate(50,60); @@ -1191,13 +1356,13 @@ void smgl_tape(mglGraph *gr) gr->Box(); gr->Plot(xc,yc,z,"k"); gr->Tape(xc,yc,z,"zg"); gr->Tape(xc,yc,z,"zg#"); } //----------------------------------------------------------------------------- -const char *mmgl_fog="call 'prepare2d'\ntitle 'Fog sample':rotate 50 60:light on:fog 1\nbox:surf a\n"; +const char *mmgl_fog="call 'prepare2d'\ntitle 'Fog sample':rotate 50 60:light on:fog 1\nbox:surf a:cont a 'y'\n"; void smgl_fog(mglGraph *gr) { mglData a; mgls_prepare2d(&a); - if(!mini) gr->Title("Fog sample"); + if(big!=3) gr->Title("Fog sample"); gr->Light(true); gr->Rotate(50,60); gr->Fog(1); gr->Box(); - gr->Surf(a); + gr->Surf(a); gr->Cont(a,"y"); } //----------------------------------------------------------------------------- const char *mmgl_map="new a 50 40 'x':new b 50 40 'y':zrange -2 2:text 0 0 '\\to'\n" @@ -1254,7 +1419,7 @@ void smgl_qo2d(mglGraph *gr) mglData r, xx, yy, a, im(128), re(128); const char *ham = "p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)"; r = mglRay(ham, mglPoint(-0.7, -1), mglPoint(0, 0.5), 0.02, 2); - if(!mini) {gr->SubPlot(1,1,0,"<_"); gr->Title("Beam and ray tracing");} + if(big!=3) {gr->SubPlot(1,1,0,"<_"); gr->Title("Beam and ray tracing");} gr->Plot(r.SubData(0), r.SubData(1), "k"); gr->Axis(); gr->Label('x', "\\i x"); gr->Label('y', "\\i y"); // now start beam tracing @@ -1279,7 +1444,7 @@ void smgl_pde(mglGraph *gr) // PDE sample gr->Fill(re,"exp(-48*(x+0.7)^2)"); a = gr->PDE("p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)", re, im, 0.01, 30); a.Transpose("yxz"); - if(!mini) {gr->SubPlot(1,1,0,"<_"); gr->Title("PDE solver"); } + if(big!=3) {gr->SubPlot(1,1,0,"<_"); gr->Title("PDE solver"); } gr->SetRange('c',0,1); gr->Dens(a,"wyrRk"); gr->Axis(); gr->Label('x', "\\i x"); gr->Label('y', "\\i z"); gr->FPlot("-x", "k|"); @@ -1290,7 +1455,7 @@ const char *mmgl_conta="call 'prepare3d'\ntitle 'Cont3 sample':rotate 50 60:box\ void smgl_conta(mglGraph *gr) { mglData c; mgls_prepare3d(&c); - if(!mini) gr->Title("Cont3 sample"); + if(big!=3) gr->Title("Cont3 sample"); gr->Rotate(50,60); gr->Box(); gr->Cont3(c,"x"); gr->Cont3(c); gr->Cont3(c,"z"); } @@ -1300,7 +1465,7 @@ const char *mmgl_contfa="call 'prepare3d'\ntitle 'Cont3 sample':rotate 50 60:box void smgl_contfa(mglGraph *gr) { mglData c; mgls_prepare3d(&c); - if(!mini) gr->Title("ContF3 sample"); + if(big!=3) gr->Title("ContF3 sample"); gr->Rotate(50,60); gr->Light(true); gr->Box(); gr->ContF3(c,"x"); gr->ContF3(c); gr->ContF3(c,"z"); gr->Cont3(c,"kx"); gr->Cont3(c,"k"); gr->Cont3(c,"kz"); @@ -1311,7 +1476,7 @@ const char *mmgl_densa="call 'prepare3d'\ntitle 'Dens3 sample':rotate 50 60:alph void smgl_densa(mglGraph *gr) { mglData c; mgls_prepare3d(&c); - if(!mini) gr->Title("Dens3 sample"); + if(big!=3) gr->Title("Dens3 sample"); gr->Rotate(50,60); gr->Alpha(true); gr->SetAlphaDef(0.7); gr->SetOrigin(0,0,0); gr->Axis("_xyz"); gr->Box(); gr->Dens3(c,"x"); gr->Dens3(c); gr->Dens3(c,"z"); @@ -1322,7 +1487,7 @@ const char *mmgl_dens_xyz="call 'prepare3d'\ntitle 'Dens[XYZ] sample':rotate 50 void smgl_dens_xyz(mglGraph *gr) { mglData c; mgls_prepare3d(&c); - if(!mini) gr->Title("Dens[XYZ] sample"); + if(big!=3) gr->Title("Dens[XYZ] sample"); gr->Rotate(50,60); gr->Box(); gr->DensX(c.Sum("x"),0,-1); gr->DensY(c.Sum("y"),0,1); gr->DensZ(c.Sum("z"),0,-1); } @@ -1332,7 +1497,7 @@ const char *mmgl_cont_xyz="call 'prepare3d'\ntitle 'Cont[XYZ] sample':rotate 50 void smgl_cont_xyz(mglGraph *gr) { mglData c; mgls_prepare3d(&c); - if(!mini) gr->Title("Cont[XYZ] sample"); + if(big!=3) gr->Title("Cont[XYZ] sample"); gr->Rotate(50,60); gr->Box(); gr->ContX(c.Sum("x"),"",-1); gr->ContY(c.Sum("y"),"",1); gr->ContZ(c.Sum("z"),"",-1); } @@ -1342,24 +1507,24 @@ const char *mmgl_contf_xyz="call 'prepare3d'\ntitle 'ContF[XYZ] sample':rotate 5 void smgl_contf_xyz(mglGraph *gr) { mglData c; mgls_prepare3d(&c); - if(!mini) gr->Title("ContF[XYZ] sample"); + if(big!=3) gr->Title("ContF[XYZ] sample"); gr->Rotate(50,60); gr->Box(); gr->ContFX(c.Sum("x"),"",-1); gr->ContFY(c.Sum("y"),"",1); gr->ContFZ(c.Sum("z"),"",-1); } //----------------------------------------------------------------------------- const char *mmgl_cloud="call 'prepare3d'\nsubplot 2 2 0:title 'Cloud plot':rotate 50 60:alpha on:box:cloud c 'wyrRk'\n" -"subplot 2 2 1:title '\"!\" style':rotate 50 60:box:cloud c '!wyrRk'\n" +"subplot 2 2 1:title '\"i\" style':rotate 50 60:box:cloud c 'iwyrRk'\n" "subplot 2 2 2:title '\".\" style':rotate 50 60:box:cloud c '.wyrRk'\n" "subplot 2 2 3:title 'meshnum 10':rotate 50 60:box:cloud c 'wyrRk'; meshnum 10\n"; void smgl_cloud(mglGraph *gr) { mglData c; mgls_prepare3d(&c); - if(!mini) { gr->SubPlot(2,2,0); gr->Title("Cloud plot"); } + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Cloud plot"); } gr->Rotate(50,60); gr->Alpha(true); gr->Box(); gr->Cloud(c,"wyrRk"); - if(mini) return; - gr->SubPlot(2,2,1); gr->Title("'!' style"); - gr->Rotate(50,60); gr->Box(); gr->Cloud(c,"!wyrRk"); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("'i' style"); + gr->Rotate(50,60); gr->Box(); gr->Cloud(c,"iwyrRk"); gr->SubPlot(2,2,2); gr->Title("'.' style"); gr->Rotate(50,60); gr->Box(); gr->Cloud(c,".wyrRk"); gr->SubPlot(2,2,3); gr->Title("meshnum 10"); @@ -1373,9 +1538,9 @@ const char *mmgl_cont="call 'prepare2d'\nlist v -0.5 -0.15 0 0.15 0.5\nsubplot 2 void smgl_cont(mglGraph *gr) { mglData a,v(5); mgls_prepare2d(&a); v.a[0]=-0.5; v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; - if(!mini) { gr->SubPlot(2,2,0); gr->Title("Cont plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Cont plot (default)"); } gr->Rotate(50,60); gr->Box(); gr->Cont(a); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("manual levels"); gr->Rotate(50,60); gr->Box(); gr->Cont(v,a); gr->SubPlot(2,2,2); gr->Title("'\\_' style"); @@ -1396,9 +1561,9 @@ void smgl_contf(mglGraph *gr) v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)"); - if(!mini) { gr->SubPlot(2,2,0); gr->Title("ContF plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("ContF plot (default)"); } gr->Rotate(50,60); gr->Box(); gr->ContF(a); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("manual levels"); gr->Rotate(50,60); gr->Box(); gr->ContF(v,a); gr->SubPlot(2,2,2); gr->Title("'\\_' style"); @@ -1419,9 +1584,9 @@ void smgl_contd(mglGraph *gr) v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)"); - if(!mini) { gr->SubPlot(2,2,0); gr->Title("ContD plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("ContD plot (default)"); } gr->Rotate(50,60); gr->Box(); gr->ContD(a); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("manual levels"); gr->Rotate(50,60); gr->Box(); gr->ContD(v,a); gr->SubPlot(2,2,2); gr->Title("'\\_' style"); @@ -1439,9 +1604,9 @@ void smgl_contv(mglGraph *gr) { mglData a,v(5); mgls_prepare2d(&a); v.a[0]=-0.5; v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; - if(!mini) { gr->SubPlot(2,2,0); gr->Title("ContV plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("ContV plot (default)"); } gr->Rotate(50,60); gr->Box(); gr->ContV(a); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("manual levels"); gr->Rotate(50,60); gr->Box(); gr->ContV(v,a); gr->SubPlot(2,2,2); gr->Title("'\\_' style"); @@ -1458,9 +1623,9 @@ const char *mmgl_torus="call 'prepare1d'\nsubplot 2 2 0:title 'Torus plot (defau void smgl_torus(mglGraph *gr) { mglData y1,y2; mgls_prepare1d(0,&y1,&y2); - if(!mini) { gr->SubPlot(2,2,0); gr->Title("Torus plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Torus plot (default)"); } gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Torus(y1,y2); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("'x' style"); gr->Rotate(50,60); gr->Box(); gr->Torus(y1,y2,"x"); gr->SubPlot(2,2,2); gr->Title("'z' style"); gr->Rotate(50,60); gr->Box(); gr->Torus(y1,y2,"z"); gr->SubPlot(2,2,3); gr->Title("'\\#' style"); gr->Rotate(50,60); gr->Box(); gr->Torus(y1,y2,"#"); @@ -1473,9 +1638,9 @@ const char *mmgl_axial="call 'prepare2d'\nsubplot 2 2 0:title 'Axial plot (defau void smgl_axial(mglGraph *gr) { mglData a; mgls_prepare2d(&a); - if(!mini) { gr->SubPlot(2,2,0); gr->Title("Axial plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Axial plot (default)"); } gr->Light(true); gr->Alpha(true); gr->Rotate(50,60); gr->Box(); gr->Axial(a); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("'x' style; '.'style"); gr->Rotate(50,60); gr->Box(); gr->Axial(a,"x."); gr->SubPlot(2,2,2); gr->Title("'z' style"); gr->Rotate(50,60); gr->Box(); gr->Axial(a,"z"); gr->SubPlot(2,2,3); gr->Title("'\\#' style"); gr->Rotate(50,60); gr->Box(); gr->Axial(a,"#"); @@ -1486,12 +1651,43 @@ const char *mmgl_several_light="call 'prepare2d'\ntitle 'Several light sources': void smgl_several_light(mglGraph *gr) // several light sources { mglData a; mgls_prepare2d(&a); - if(!mini) gr->Title("Several light sources"); + if(big!=3) gr->Title("Several light sources"); gr->Rotate(50,60); gr->Light(true); gr->AddLight(1,mglPoint(0,1,0),'c'); gr->AddLight(2,mglPoint(1,0,0),'y'); gr->AddLight(3,mglPoint(0,-1,0),'m'); gr->Box(); gr->Surf(a,"h"); } //----------------------------------------------------------------------------- +const char *mmgl_light="light on:quality 6\ncall 'prepare2d'\n" +"subplot 2 2 0:title 'Default':rotate 50 60:box:surf a\nline -1 -0.7 1.7 -1 -0.7 0.7 'BA'\n\n" +"light 0 1 0 1 -2 -1 -1\nsubplot 2 2 1:title 'Local':rotate 50 60:box:surf a\n" +"line 1 0 1 -1 -1 0 'BAO'\n\n" +"diffuse 0\nsubplot 2 2 2:title 'no diffuse':rotate 50 60:box:surf a\n" +"line 1 0 1 -1 -1 0 'BAO'\n\n" +"diffuse 0.5:light 0 1 0 1 -2 -1 -1 'w' 0\n" +"subplot 2 2 3:title 'diffusive only':rotate 50 60:box:surf a\n" +"line 1 0 1 -1 -1 0 'BAO'\n"; +void smgl_light(mglGraph *gr) // local light sources +{ + mglData a; mgls_prepare2d(&a); + if(big==3) + { gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Surf(a); return; } + int qual = gr->GetQuality(); + gr->Light(true); gr->SetQuality(6); + gr->SubPlot(2,2,0); gr->Title("Default"); gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(-1,-0.7,1.7),mglPoint(-1,-0.7,0.7),"BA"); + gr->AddLight(0,mglPoint(1,0,1),mglPoint(-2,-1,-1)); + gr->SubPlot(2,2,1); gr->Title("Local"); gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO"); + gr->SetDiffuse(0); + gr->SubPlot(2,2,2); gr->Title("no diffuse"); gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO"); + gr->SetDiffuse(0.5); + gr->AddLight(0,mglPoint(1,0,1),mglPoint(-2,-1,-1),'w',0); + gr->SubPlot(2,2,3); gr->Title("diffusive only"); gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO"); + gr->SetQuality(qual); +} +//----------------------------------------------------------------------------- const char *mmgl_surf3="call 'prepare3d'\nlight on:alpha on\n" "subplot 2 2 0:title 'Surf3 plot (default)'\nrotate 50 60:box:surf3 c\n" "subplot 2 2 1:title '\"\\#\" style'\nrotate 50 60:box:surf3 c '#'\n" @@ -1499,10 +1695,10 @@ const char *mmgl_surf3="call 'prepare3d'\nlight on:alpha on\n" void smgl_surf3(mglGraph *gr) { mglData c; mgls_prepare3d(&c); - if(!mini) { gr->SubPlot(2,2,0); gr->Title("Surf3 plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Surf3 plot (default)"); } gr->Rotate(50,60); gr->Light(true); gr->Alpha(true); gr->Box(); gr->Surf3(c); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("'\\#' style"); gr->Rotate(50,60); gr->Box(); gr->Surf3(c,"#"); gr->SubPlot(2,2,2); gr->Title("'.' style"); @@ -1513,7 +1709,7 @@ const char *mmgl_surf3a="call 'prepare3d'\ntitle 'Surf3A plot':rotate 50 60:ligh void smgl_surf3a(mglGraph *gr) { mglData c,d; mgls_prepare3d(&c,&d); - if(!mini) gr->Title("Surf3A plot"); + if(big!=3) gr->Title("Surf3A plot"); gr->Rotate(50,60); gr->Light(true); gr->Alpha(true); gr->Box(); gr->Surf3A(c,d); } @@ -1522,7 +1718,7 @@ const char *mmgl_surf3c="call 'prepare3d'\ntitle 'Surf3C plot':rotate 50 60:ligh void smgl_surf3c(mglGraph *gr) { mglData c,d; mgls_prepare3d(&c,&d); - if(!mini) gr->Title("Surf3C plot"); + if(big!=3) gr->Title("Surf3C plot"); gr->Rotate(50,60); gr->Light(true); gr->Alpha(true); gr->Box(); gr->Surf3C(c,d); } @@ -1551,7 +1747,7 @@ const char *mmgl_traj="call 'prepare1d'\nsubplot 1 1 0 '':title 'Traj plot':box: void smgl_traj(mglGraph *gr) { mglData x,y,y1,y2; mgls_prepare1d(&y,&y1,&y2,&x); - if(!mini) {gr->SubPlot(1,1,0,""); gr->Title("Traj plot");} + if(big!=3) {gr->SubPlot(1,1,0,""); gr->Title("Traj plot");} gr->Box(); gr->Plot(x,y); gr->Traj(x,y,y1,y2); } //----------------------------------------------------------------------------- @@ -1559,7 +1755,7 @@ const char *mmgl_mesh="call 'prepare2d'\ntitle 'Mesh plot':rotate 50 60:box:mesh void smgl_mesh(mglGraph *gr) { mglData a; mgls_prepare2d(&a); - if(!mini) gr->Title("Mesh plot"); + if(big!=3) gr->Title("Mesh plot"); gr->Rotate(50,60); gr->Box(); gr->Mesh(a); } //----------------------------------------------------------------------------- @@ -1567,7 +1763,7 @@ const char *mmgl_fall="call 'prepare2d'\ntitle 'Fall plot':rotate 50 60:box:fall void smgl_fall(mglGraph *gr) { mglData a; mgls_prepare2d(&a); - if(!mini) gr->Title("Fall plot"); + if(big!=3) gr->Title("Fall plot"); gr->Rotate(50,60); gr->Box(); gr->Fall(a); } //----------------------------------------------------------------------------- @@ -1579,9 +1775,9 @@ const char *mmgl_surf="call 'prepare2d'\nsubplot 2 2 0:title 'Surf plot (default void smgl_surf(mglGraph *gr) { mglData a; mgls_prepare2d(&a); - if(!mini) { gr->SubPlot(2,2,0); gr->Title("Surf plot (default)"); } + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Surf plot (default)"); } gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Surf(a); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("'\\#' style; meshnum 10"); gr->Rotate(50,60); gr->Box(); gr->Surf(a,"#","meshnum 10"); gr->SubPlot(2,2,2); gr->Title("'.' style"); @@ -1621,7 +1817,7 @@ const char *mmgl_belt="call 'prepare2d'\ntitle 'Belt plot':rotate 50 60:box:belt void smgl_belt(mglGraph *gr) { mglData a; mgls_prepare2d(&a); - if(!mini) gr->Title("Belt plot"); + if(big!=3) gr->Title("Belt plot"); gr->Rotate(50,60); gr->Box(); gr->Belt(a); } //----------------------------------------------------------------------------- @@ -1634,9 +1830,9 @@ void smgl_dens(mglGraph *gr) { mglData a,a1(30,40,3); mgls_prepare2d(&a); gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)"); - if(!mini) {gr->SubPlot(2,2,0,""); gr->Title("Dens plot (default)");} + if(big!=3) {gr->SubPlot(2,2,0,""); gr->Title("Dens plot (default)");} gr->Box(); gr->Dens(a); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); gr->Dens(a); gr->SubPlot(2,2,2,""); gr->Title("'\\#' style; meshnum 10"); @@ -1649,7 +1845,7 @@ const char *mmgl_surfc="call 'prepare2d'\ntitle 'SurfC plot':rotate 50 60:light void smgl_surfc(mglGraph *gr) { mglData a,b; mgls_prepare2d(&a,&b); - if(!mini) gr->Title("SurfC plot"); gr->Rotate(50,60); + if(big!=3) gr->Title("SurfC plot"); gr->Rotate(50,60); gr->Light(true); gr->Box(); gr->SurfC(a,b); } //----------------------------------------------------------------------------- @@ -1657,7 +1853,7 @@ const char *mmgl_surfa="call 'prepare2d'\ntitle 'SurfA plot':rotate 50 60:light void smgl_surfa(mglGraph *gr) { mglData a,b; mgls_prepare2d(&a,&b); - if(!mini) gr->Title("SurfA plot"); gr->Rotate(50,60); + if(big!=3) gr->Title("SurfA plot"); gr->Rotate(50,60); gr->Alpha(true); gr->Light(true); gr->Box(); gr->SurfA(a,b); } //----------------------------------------------------------------------------- @@ -1665,7 +1861,7 @@ const char *mmgl_tile="call 'prepare2d'\ntitle 'Tile plot':rotate 50 60:box:tile void smgl_tile(mglGraph *gr) { mglData a; mgls_prepare2d(&a); - if(!mini) gr->Title("Tile plot"); + if(big!=3) gr->Title("Tile plot"); gr->Rotate(40,60); gr->Box(); gr->Tile(a); } //----------------------------------------------------------------------------- @@ -1673,7 +1869,7 @@ const char *mmgl_tiles="call 'prepare2d'\nsubplot 1 1 0 '':title 'Tiles plot':bo void smgl_tiles(mglGraph *gr) { mglData a,b; mgls_prepare2d(&a,&b); - if(!mini) {gr->SubPlot(1,1,0,""); gr->Title("TileS plot");} + if(big!=3) {gr->SubPlot(1,1,0,""); gr->Title("TileS plot");} gr->Box(); gr->TileS(a,b); } //----------------------------------------------------------------------------- @@ -1685,9 +1881,9 @@ void smgl_boxs(mglGraph *gr) { mglData a; mgls_prepare2d(&a); gr->SetOrigin(0,0,0); gr->Light(true); - if(!mini) {gr->SubPlot(2,2,0); gr->Title("Boxs plot (default)");} + if(big!=3) {gr->SubPlot(2,2,0); gr->Title("Boxs plot (default)");} gr->Rotate(40,60); gr->Box(); gr->Boxs(a); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("'\\@' style"); gr->Rotate(50,60); gr->Box(); gr->Boxs(a,"@"); gr->SubPlot(2,2,2); gr->Title("'\\#' style"); @@ -1709,7 +1905,7 @@ void smgl_fit(mglGraph *gr) // nonlinear fitting double ini[3] = {1,1,3}; mglData Ini(3,ini); res = gr->Fit(rnd, "a+b*sin(c*x)", "abc", Ini); - if(!mini) gr->Title("Fitting sample"); + if(big!=3) gr->Title("Fitting sample"); gr->SetRange('y',-2,2); gr->Box(); gr->Plot(rnd, ". "); gr->Axis(); gr->Plot(res, "r"); gr->Plot(in, "b"); gr->Puts(mglPoint(-0.9, -1.3), "fitted:", "r:L"); @@ -1726,10 +1922,10 @@ const char *mmgl_vecta="call 'prepare3v'\nsubplot 2 1 0:title 'Vect3 sample':rot void smgl_vecta(mglGraph *gr) { mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); - if(!mini) { gr->SubPlot(2,1,0); gr->Title("Vect3 sample"); } + if(big!=3) { gr->SubPlot(2,1,0); gr->Title("Vect3 sample"); } gr->Rotate(50,60); gr->SetOrigin(0,0,0); gr->Axis("_xyz"); gr->Box(); gr->Vect3(ex,ey,ez,"x"); gr->Vect3(ex,ey,ez); gr->Vect3(ex,ey,ez,"z"); - if(mini) return; + if(big==3) return; gr->SubPlot(2,1,1); gr->Title("'f' style"); gr->Rotate(50,60); gr->SetOrigin(0,0,0); gr->Axis("_xyz"); gr->Box(); gr->Vect3(ex,ey,ez,"fx"); gr->Vect3(ex,ey,ez,"f"); gr->Vect3(ex,ey,ez,"fz"); @@ -1745,9 +1941,9 @@ const char *mmgl_vect="call 'prepare2v'\ncall 'prepare3v'\nsubplot 3 2 0 '':titl void smgl_vect(mglGraph *gr) { mglData a,b; mgls_prepare2v(&a,&b); - if(!mini) {gr->SubPlot(3,2,0,""); gr->Title("Vect plot (default)");} + if(big!=3) {gr->SubPlot(3,2,0,""); gr->Title("Vect plot (default)");} gr->Box(); gr->Vect(a,b); - if(mini) return; + if(big==3) return; gr->SubPlot(3,2,1,""); gr->Title("'.' style; '=' style"); gr->Box(); gr->Vect(a,b,"=."); gr->SubPlot(3,2,2,""); gr->Title("'f' style"); gr->Box(); gr->Vect(a,b,"f"); gr->SubPlot(3,2,3,""); gr->Title("'>' style"); gr->Box(); gr->Vect(a,b,">"); @@ -1764,9 +1960,9 @@ const char *mmgl_flow="call 'prepare2v'\ncall 'prepare3v'\nsubplot 2 2 0 '':titl void smgl_flow(mglGraph *gr) { mglData a,b; mgls_prepare2v(&a,&b); - if(!mini) {gr->SubPlot(2,2,0,""); gr->Title("Flow plot (default)");} + if(big!=3) {gr->SubPlot(2,2,0,""); gr->Title("Flow plot (default)");} gr->Box(); gr->Flow(a,b); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1,""); gr->Title("'v' style"); gr->Box(); gr->Flow(a,b,"v"); gr->SubPlot(2,2,2,""); gr->Title("'\\#' style"); gr->Box(); gr->Flow(a,b,"#"); mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); @@ -1781,9 +1977,9 @@ const char *mmgl_pipe="call 'prepare2v'\ncall 'prepare3v'\nsubplot 2 2 0 '':titl void smgl_pipe(mglGraph *gr) { mglData a,b; mgls_prepare2v(&a,&b); - if(!mini) {gr->SubPlot(2,2,0,""); gr->Title("Pipe plot (default)");} + if(big!=3) {gr->SubPlot(2,2,0,""); gr->Title("Pipe plot (default)");} gr->Light(true); gr->Box(); gr->Pipe(a,b); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1,""); gr->Title("'i' style"); gr->Box(); gr->Pipe(a,b,"i"); gr->SubPlot(2,2,2,""); gr->Title("'\\#' style"); gr->Box(); gr->Pipe(a,b,"#"); mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); @@ -1795,7 +1991,7 @@ const char *mmgl_dew="call 'prepare2v'\nsubplot 1 1 0 '':title 'Dew plot':light void smgl_dew(mglGraph *gr) { mglData a,b; mgls_prepare2v(&a,&b); - if(!mini) {gr->SubPlot(1,1,0,""); gr->Title("Dew plot");} + if(big!=3) {gr->SubPlot(1,1,0,""); gr->Title("Dew plot");} gr->Box(); gr->Light(true); gr->Dew(a,b); } //----------------------------------------------------------------------------- @@ -1803,29 +1999,35 @@ const char *mmgl_grad="call 'prepare2d'\nsubplot 1 1 0 '':title 'Grad plot':box: void smgl_grad(mglGraph *gr) { mglData a; mgls_prepare2d(&a); - if(!mini) {gr->SubPlot(1,1,0,""); gr->Title("Grad plot");} + if(big!=3) {gr->SubPlot(1,1,0,""); gr->Title("Grad plot");} gr->Box(); gr->Grad(a); gr->Dens(a,"{u8}w{q8}"); } //----------------------------------------------------------------------------- -const char *mmgl_cones="new ys 10 3 '0.8*sin(pi*(x+y/4+1.25))+0.2*rnd'\n" -"subplot 2 2 0:title 'Cones plot':rotate 50 60:light on:origin 0 0 0:box:cones ys\n" -"subplot 2 2 1:title '2 colors':rotate 50 60:light on:origin 0 0 0:box:cones ys 'cbgGyr'\n" -"subplot 2 2 2:title '\"\\#\" style':rotate 50 60:light on:origin 0 0 0:box:cones ys '#'\n" -"subplot 2 2 3:title '\"a\" style':rotate 50 60:zrange -2 2:light on:origin 0 0 0:box:cones ys 'a'\n"; +const char *mmgl_cones="new ys 10 3 '0.8*sin(pi*(x+y/4+1.25))+0.2*rnd'\nlight on:origin 0 0 0\n" +"subplot 3 2 0:title 'Cones plot':rotate 50 60:box:cones ys\n" +"subplot 3 2 1:title '2 colors':rotate 50 60:box:cones ys 'cbgGyr'\n" +"subplot 3 2 2:title '\"\\#\" style':rotate 50 60:box:cones ys '#'\n" +"subplot 3 2 3:title '\"a\" style':rotate 50 60:zrange -2 2:box:cones ys 'a'\n" +"subplot 3 2 4:title '\"t\" style':rotate 50 60:box:cones ys 't'\n" +"subplot 3 2 5:title '\"4\" style':rotate 50 60:box:cones ys '4'\n"; void smgl_cones(mglGraph *gr) { mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); gr->Light(true); gr->SetOrigin(0,0,0); - if(!mini) { gr->SubPlot(2,2,0); gr->Title("Cones plot"); } + if(big!=3) { gr->SubPlot(3,2,0); gr->Title("Cones plot"); } gr->Rotate(50,60); gr->Box(); gr->Cones(ys); - if(mini) return; - gr->SubPlot(2,2,1); gr->Title("2 colors"); + if(big==3) return; + gr->SubPlot(3,2,1); gr->Title("2 colors"); gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"cbgGyr"); - gr->SubPlot(2,2,2); gr->Title("'\\#' style"); + gr->SubPlot(3,2,2); gr->Title("'\\#' style"); gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"#"); - gr->SubPlot(2,2,3); gr->Title("'a' style"); + gr->SubPlot(3,2,3); gr->Title("'a' style"); gr->SetRange('z',-2,2); // increase range since summation can exceed [-1,1] gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"a"); + gr->SubPlot(3,2,4); gr->Title("'t' style"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"t"); + gr->SubPlot(3,2,5); gr->Title("'4' style"); + 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" @@ -1994,12 +2196,13 @@ void smgl_loglog(mglGraph *gr) // log-log axis } //----------------------------------------------------------------------------- const char *mmgl_venn="list x -0.3 0 0.3:list y 0.3 -0.3 0.3:list e 0.7 0.7 0.7\n" -"subplot 1 1 0:title 'Venn-like diagram':alpha on:error x y e e '!rgb@#o'"; +"subplot 1 1 0:title 'Venn-like diagram'\ntransptype 1:alpha on:error x y e e '!rgb@#o'"; void smgl_venn(mglGraph *gr) { double xx[3]={-0.3,0,0.3}, yy[3]={0.3,-0.3,0.3}, ee[3]={0.7,0.7,0.7}; mglData x(3,xx), y(3,yy), e(3,ee); - gr->SubPlot(1,1,0); gr->Title("Venn-like diagram"); gr->Alpha(true); gr->Error(x,y,e,e,"!rgb@#o"); + gr->SubPlot(1,1,0); gr->Title("Venn-like diagram"); + gr->SetTranspType(1); gr->Alpha(true); gr->Error(x,y,e,e,"!rgb@#o","alpha 0.1"); } //----------------------------------------------------------------------------- const char *mmgl_stereo="call 'prepare2d'\nlight on\nsubplot 2 1 0:rotate 50 60+1:box:surf a\nsubplot 2 1 1:rotate 50 60-1:box:surf a\n"; @@ -2083,7 +2286,7 @@ void smgl_primitives(mglGraph *gr) // flag # gr->Puts(mglPoint(0.9,1),"sh=1"); gr->Ball(mglPoint(0.9,0,1),'k'); gr->Drop(mglPoint(0.9,0),mglPoint(0,1),0.5,"r",1); gr->Line(mglPoint(-0.9,0,1),mglPoint(0.9,0,1),"b"); - + gr->Puts(mglPoint(-0.9,-1.1),"asp=0.33"); gr->Drop(mglPoint(-0.9,-0.7),mglPoint(0,1),0.5,"b",0,0.33); gr->Puts(mglPoint(-0.3,-1.1),"asp=0.67"); @@ -2103,9 +2306,9 @@ const char *mmgl_table="new ys 10 3 '0.8*sin(pi*(x+y/4+1.25))+0.2*rnd'\n" void smgl_table(mglGraph *gr) { mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); - if(!mini) { gr->SubPlot(2,2,0); gr->Title("Table plot"); } + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Table plot"); } gr->Table(ys,"y_1\ny_2\ny_3"); gr->Box(); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("no borders, colored"); gr->Table(ys,"y_1\ny_2\ny_3","r|"); gr->SubPlot(2,2,2); gr->Title("no font decrease"); @@ -2119,7 +2322,7 @@ const char *mmgl_label="new ys 10 '0.2*rnd-0.8*sin(pi*x)'\n" void smgl_label(mglGraph *gr) { mglData ys(10); ys.Modify("0.8*sin(pi*2*x)+0.2*rnd"); - if(!mini) { gr->SubPlot(1,1,0,""); gr->Title("Label plot"); } + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("Label plot"); } gr->Box(); gr->Plot(ys," *"); gr->Label(ys,"y=%y"); } //----------------------------------------------------------------------------- @@ -2143,12 +2346,12 @@ void smgl_colorbar(mglGraph *gr) mglData a,v; mgls_prepare2d(&a,0,&v); gr->Box(); gr->ContD(v,a); gr->Colorbar(v,"<"); gr->Colorbar(v,">"); gr->Colorbar(v,"_"); gr->Colorbar(v,"^"); - + gr->SubPlot(2,2,3); gr->Title(" "); gr->Puts(mglPoint(-0.5,1.55),"Color positions",":C",-2); gr->Colorbar("bwr>",0.25,0); gr->Puts(mglPoint(-0.9,1.2),"Default"); gr->Colorbar("b{w,0.3}r>",0.5,0); gr->Puts(mglPoint(-0.1,1.2),"Manual"); - + gr->Puts(mglPoint(1,1.55),"log-scale",":C",-2); gr->SetRange('c',0.01,1e3); gr->Colorbar(">",0.75,0); gr->Puts(mglPoint(0.65,1.2),"Normal scale"); @@ -2171,9 +2374,9 @@ void smgl_legend(mglGraph *gr) gr->AddLegend("sin(\\pi \\sqrt{x})","rd"); gr->AddLegend("just text"," "); gr->AddLegend("no indent for this",""); - if(!mini) {gr->SubPlot(2,2,0,""); gr->Title("Legend (default)");} + if(big!=3) {gr->SubPlot(2,2,0,""); gr->Title("Legend (default)");} gr->Box(); gr->Legend(); - if(mini) return; + if(big==3) return; gr->Legend(3,"A#"); gr->Puts(mglPoint(0.75,0.65),"Absolute position","A"); gr->SubPlot(2,2,2,""); gr->Title("coloring"); gr->Box(); @@ -2314,8 +2517,8 @@ void smgl_projection(mglGraph *gr) // flag # y.Modify("0.25*(1+sin(2*pi*x))"); rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx); z.Modify("x"); - - if(!mini) gr->Title("Projection sample"); + + if(big!=3) gr->Title("Projection sample"); gr->Ternary(4); gr->Rotate(50,60); gr->Light(true); gr->Plot(x,y,z,"r2"); gr->Surf(a,"#"); @@ -2337,8 +2540,8 @@ void smgl_projection5(mglGraph *gr) // flag # y.Modify("0.25*(1+sin(2*pi*x))"); rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx); z.Modify("x"); - - if(!mini) gr->Title("Projection sample (ternary)"); + + if(big!=3) gr->Title("Projection sample (ternary)"); gr->Ternary(5); gr->Rotate(50,60); gr->Light(true); gr->Plot(x,y,z,"r2"); gr->Surf(a,"#"); @@ -2370,7 +2573,7 @@ void smgl_triplot(mglGraph *gr) gr->SubPlot(2,2,2); gr->Title("QuadPlot coloring"); gr->Rotate(50,60); gr->QuadPlot(qq,xx,yy,zz,yy,"yr"); gr->QuadPlot(qq,xx,yy,zz,"k#"); - + double t[] = {0,1,2, 0,1,3, 0,2,3, 1,2,3}; double xt[] = {-1,1,0,0}, yt[] = {-1,-1,1,0}, zt[] = {-1,-1,-1,1}; mglData tt(4,3,t), uu(4,xt), vv(4,yt), ww(4,zt); @@ -2397,7 +2600,7 @@ void smgl_dots(mglGraph *gr) y.a[i] = 0.9*cos(t)*sin(f); z.a[i] = 0.6*sin(t); } - if(!mini) gr->Title("Dots sample"); + if(big!=3) gr->Title("Dots sample"); gr->Rotate(50,60); gr->Box(); gr->Dots(x,y,z); } //----------------------------------------------------------------------------- @@ -2422,12 +2625,12 @@ void smgl_mirror(mglGraph *gr) // flag # { mglData a(31,41); gr->Fill(a,"-pi*x*exp(-(y+1)^2-4*x^2)"); - - if(!mini) { gr->SubPlot(2,2,0); gr->Title("Options for coordinates"); } + + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Options for coordinates"); } gr->Alpha(true); gr->Light(true); gr->Rotate(40,60); gr->Box(); gr->Surf(a,"r","yrange 0 1"); gr->Surf(a,"b","yrange 0 -1"); - if(mini) return; + if(big==3) return; gr->SubPlot(2,2,1); gr->Title("Option 'meshnum'"); gr->Rotate(40,60); gr->Box(); gr->Mesh(a,"r","yrange 0 1"); gr->Mesh(a,"b","yrange 0 -1; meshnum 5"); @@ -2465,6 +2668,7 @@ mglSample samp[] = { {"contf_xyz", smgl_contf_xyz, mmgl_contf_xyz}, {"contfa", smgl_contfa, mmgl_contfa}, {"contv", smgl_contv, mmgl_contv}, + {"correl", smgl_correl, mmgl_correl}, // {"crust", smgl_crust, mmgl_crust}, // TODO: open after triangulation {"curvcoor", smgl_curvcoor, mmgl_curvcoor}, {"cut", smgl_cut, mmgl_cut}, @@ -2477,7 +2681,9 @@ mglSample samp[] = { {"densa", smgl_densa, mmgl_densa}, {"dew", smgl_dew, mmgl_dew}, {"dots", smgl_dots, mmgl_dots}, - {"error", smgl_error, mmgl_error }, + {"error", smgl_error, mmgl_error}, + {"error2", smgl_error2, mmgl_error2}, + {"export", smgl_export, mmgl_export}, {"fall", smgl_fall, mmgl_fall}, {"fexport", smgl_fexport, mmgl_fexport}, {"fit", smgl_fit, mmgl_fit}, @@ -2489,12 +2695,15 @@ mglSample samp[] = { {"inplot", smgl_inplot, mmgl_inplot}, {"label", smgl_label, mmgl_label}, {"legend", smgl_legend, mmgl_legend }, + {"light", smgl_light, mmgl_light}, {"loglog", smgl_loglog, mmgl_loglog}, {"map", smgl_map, mmgl_map}, {"mark", smgl_mark, mmgl_mark}, + {"mask", smgl_mask, mmgl_mask}, {"mesh", smgl_mesh, mmgl_mesh}, {"mirror", smgl_mirror, mmgl_mirror }, {"molecule", smgl_molecule, mmgl_molecule }, + {"ohlc", smgl_ohlc, mmgl_ohlc}, {"param1", smgl_param1, mmgl_param1}, {"param2", smgl_param2, mmgl_param2}, {"param3", smgl_param3, mmgl_param3}, @@ -2508,6 +2717,7 @@ mglSample samp[] = { {"projection5", smgl_projection5, mmgl_projection5 }, {"qo2d", smgl_qo2d, mmgl_qo2d}, {"radar", smgl_radar, mmgl_radar}, + {"refill", smgl_refill, mmgl_refill}, {"region", smgl_region, mmgl_region}, {"schemes", smgl_schemes, mmgl_schemes }, {"several_light", smgl_several_light, mmgl_several_light }, @@ -2528,6 +2738,7 @@ mglSample samp[] = { {"tens", smgl_tens, mmgl_tens}, {"ternary", smgl_ternary, mmgl_ternary }, {"text", smgl_text, mmgl_text}, + {"text2", smgl_text2, mmgl_text2}, {"textmark", smgl_textmark, mmgl_textmark}, {"ticks", smgl_ticks, mmgl_ticks}, {"tile", smgl_tile, mmgl_tile}, diff --git a/examples/wnd_samples.cpp b/examples/wnd_samples.cpp index 865875d..501a1f1 100644 --- a/examples/wnd_samples.cpp +++ b/examples/wnd_samples.cpp @@ -49,7 +49,7 @@ mgl_set_test_mode(true); gr->ShowFrame(1); gr->ShowFrame(2); gr->ShowFrame(3); - // gr->Puts(mglPoint(0,1),"1"); +// gr->Puts(mglPoint(0,1),"1"); gr->Finish(); return 0; } @@ -427,14 +427,14 @@ int sample_d(mglGraph *gr) //----------------------------------------------------------------------------- void mgls_prepare1d(mglData *y, mglData *y1, mglData *y2, mglData *x1, mglData *x2) { - register long i,n=50; + long n=50; if(y) y->Create(n,3); if(x1) x1->Create(n); if(x2) x2->Create(n); if(y1) y1->Create(n); if(y2) y2->Create(n); - double xx; - for(i=0;ia[i] = 0.7*sin(2*M_PI*xx) + 0.5*cos(3*M_PI*xx) + 0.2*sin(M_PI*xx); @@ -450,13 +450,14 @@ void mgls_prepare1d(mglData *y, mglData *y1, mglData *y2, mglData *x1, mglData * //----------------------------------------------------------------------------- void mgls_prepare2d(mglData *a, mglData *b, mglData *v) { - register long i,j,n=50,m=40,i0; + long n=50,m=40; if(a) a->Create(n,m); if(b) b->Create(n,m); if(v) { v->Create(9); v->Fill(-1,1); } - double x,y; - for(i=0;ia[i0] = 0.6*sin(2*M_PI*x)*sin(3*M_PI*y)+0.4*cos(3*M_PI*x*y); if(b) b->a[i0] = 0.6*cos(2*M_PI*x)*cos(3*M_PI*y)+0.4*cos(3*M_PI*x*y); } @@ -464,12 +465,13 @@ void mgls_prepare2d(mglData *a, mglData *b, mglData *v) //----------------------------------------------------------------------------- void mgls_prepare3d(mglData *a, mglData *b) { - register long i,j,k,n=61,m=50,l=40,i0; + long n=61,m=50,l=40; if(a) a->Create(n,m,l); if(b) b->Create(n,m,l); - double x,y,z; - for(i=0;ia[i0] = -2*(x*x + y*y + z*z*z*z - z*z - 0.1); if(b) b->a[i0] = 1-2*tanh((x+y)*(x+y)); } @@ -477,12 +479,13 @@ void mgls_prepare3d(mglData *a, mglData *b) //----------------------------------------------------------------------------- void mgls_prepare2v(mglData *a, mglData *b) { - register long i,j,n=20,m=30,i0; + long n=20,m=30; if(a) a->Create(n,m); if(b) b->Create(n,m); - double x,y; - for(i=0;ia[i0] = 0.6*sin(2*M_PI*x)*sin(3*M_PI*y)+0.4*cos(3*M_PI*x*y); if(b) b->a[i0] = 0.6*cos(2*M_PI*x)*cos(3*M_PI*y)+0.4*cos(3*M_PI*x*y); } @@ -490,13 +493,14 @@ void mgls_prepare2v(mglData *a, mglData *b) //----------------------------------------------------------------------------- void mgls_prepare3v(mglData *ex, mglData *ey, mglData *ez) { - register long i,j,k,n=10,i0; + long n=10; if(!ex || !ey || !ez) return; ex->Create(n,n,n); ey->Create(n,n,n); ez->Create(n,n,n); - double x,y,z, r1,r2; - for(i=0;ia[i0]=z*y*r2*r2; ey->a[i0]=x*y*r2*r2+1; @@ -504,8 +508,8 @@ void mgls_prepare3v(mglData *ex, mglData *ey, mglData *ez) /* ex->a[i0]=3*z; ey->a[i0]=1; ez->a[i0]=-3*x;*/ - r1 = pow(x*x+y*y+(z-0.3)*(z-0.3)+0.03,1.5); - r2 = pow(x*x+y*y+(z+0.3)*(z+0.3)+0.03,1.5); + double r1 = pow(x*x+y*y+(z-0.3)*(z-0.3)+0.03,1.5); + double r2 = pow(x*x+y*y+(z+0.3)*(z+0.3)+0.03,1.5); ex->a[i0]=0.2*x/r1 - 0.2*x/r2; ey->a[i0]=0.2*y/r1 - 0.2*y/r2; ez->a[i0]=0.2*(z-0.3)/r1 - 0.2*(z+0.3)/r2; diff --git a/examples/wx_example.cpp b/examples/wx_example.cpp index c7a8685..e440b3b 100644 --- a/examples/wx_example.cpp +++ b/examples/wx_example.cpp @@ -17,61 +17,64 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include #include "mgl2/wx.h" //----------------------------------------------------------------------------- -#ifdef ENABLE_MGLGRAPHWX -int test(mglGraph *gr, void *); -int sample(mglGraph *gr, void *); -int sample_1(mglGraph *gr, void *); -int sample_2(mglGraph *gr, void *); -int sample_3(mglGraph *gr, void *); -int sample_d(mglGraph *gr, void *); +int test_wnd(mglGraph *gr); +int sample(mglGraph *gr); +int sample_1(mglGraph *gr); +int sample_2(mglGraph *gr); +int sample_3(mglGraph *gr); +int sample_d(mglGraph *gr); //----------------------------------------------------------------------------- -//#define PTHREAD_SAMPLE -#ifdef PTHREAD_SAMPLE -#include -#endif -mglPoint pnt; // some global variable for changable data -void *mgl_wx_tmp(void *) { mglWxRun(); return 0; } +class testApp : public wxApp +{ +public: + virtual bool OnInit(); +}; +//----------------------------------------------------------------------------- +class testFrame: public wxFrame +{ +public: + testFrame(wxFrame *frame, const wxString& title); + ~testFrame() {} +private: + enum { idMenuQuit = 1000 }; + void OnClose(wxCloseEvent& event) { Destroy(); } + void OnQuit(wxCommandEvent& event) { Destroy(); } + + wxScrolledWindow *scroll; + wxMathGL *mgl; + DECLARE_EVENT_TABLE() +}; +//----------------------------------------------------------------------------- +IMPLEMENT_APP(testApp); +//----------------------------------------------------------------------------- +bool testApp::OnInit() +{ + testFrame* frame = new testFrame(0L, _("MathGL + wxWidgets sample")); + frame->Show(); + return true; +} +//----------------------------------------------------------------------------- +BEGIN_EVENT_TABLE(testFrame, wxFrame) + EVT_CLOSE(testFrame::OnClose) + EVT_MENU(idMenuQuit, testFrame::OnQuit) +END_EVENT_TABLE() //----------------------------------------------------------------------------- -int main(int argc,char **argv) +testFrame::testFrame(wxFrame *frame, const wxString& title) : wxFrame(frame, -1, title) { -#ifdef PTHREAD_SAMPLE - mglGraphWX gr; - gr.Window(argc,argv,NULL,"test",0,0); // create window - gr.ClfOnUpdate = false; - static pthread_t tmp; - pthread_create(&tmp, 0, mgl_qt_tmp, 0); - pthread_detach(tmp); // run window handling in the separate thread - for(int i=0;i<10;i++) // do calculation - { - sleep(2); // which can be very long - pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1); - gr.Clf(); // make new drawing - gr.Line(mglPoint(),pnt,"Ar2"); - char str[10] = "i=0"; str[3] = '0'+i; - gr.Text(mglPoint(),""); - gr.Update(); // update window - } - return 0; // finish calculations and close the window -#else - mglGraphWX gr; - char key = 0; - if(argc>1 && argv[1][0]!='-') key = argv[1][0]; - else printf("You may specify argument '1', '2', '3' or 'd' for viewing examples of 1d, 2d, 3d or dual plotting\n"); - switch(key) - { - case '1': gr.Window(argc,argv,sample_1,"1D plots"); break; - case '2': gr.Window(argc,argv,sample_2,"2D plots"); break; - case '3': gr.Window(argc,argv,sample_3,"3D plots"); break; - case 'd': gr.Window(argc,argv,sample_d,"Dual plots"); break; - case 't': gr.Window(argc,argv,test,"Testing"); break; - default: gr.Window(argc,argv,sample,"Example of molecules"); break; - } - return mglWxRun(); -#endif + // create a menu bar + wxMenuBar* mbar = new wxMenuBar(); + wxMenu* fileMenu = new wxMenu(_T("")); + fileMenu->Append(idMenuQuit, _("&Quit\tAlt-F4"), _("Quit the application")); + mbar->Append(fileMenu, _("&File")); + SetMenuBar(mbar); + SetSize(800,620); + + scroll = new wxScrolledWindow(this); + mgl = new wxMathGL(scroll); + mgl->SetDraw(mgl_draw_graph,(void*)sample); + mgl->Update(); } //----------------------------------------------------------------------------- -#else -int main(int argc,char **argv) { return 0; } -#endif \ No newline at end of file diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index b868776..cbde2e5 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -8,6 +8,7 @@ install(DIRECTORY mgl2/ DESTINATION ${MGL_INCLUDE_PATH} PATTERN "qt.h" EXCLUDE PATTERN "qmathgl.h" EXCLUDE PATTERN "window.h" EXCLUDE + PATTERN "*old.h" EXCLUDE PATTERN "*~" EXCLUDE PATTERN "*.fs" PATTERN "*.pas" diff --git a/include/config.h.in b/include/config.h.in index 629342d..f5171a5 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -1,25 +1,24 @@ #ifndef _MGL_CONFIG_H_ #define _MGL_CONFIG_H_ -#define MGL_USE_DOUBLE ${MGL_USE_DOUBLE} -#define MGL_NO_DATA_A ${MGL_NO_DATA_A} +#define MGL_USE_DOUBLE ${MGL_USE_DOUBLE} +#define MGL_NO_DATA_A ${MGL_NO_DATA_A} -#define MGL_HAVE_GSL ${MGL_HAVE_GSL} -#define MGL_HAVE_LTDL ${MGL_HAVE_LTDL} #if defined(_MSC_VER) || defined(__BORLANDC__) -#define MGL_HAVE_PTHREAD 0 +#define MGL_HAVE_PTHREAD 0 #else -#define MGL_HAVE_PTHREAD ${MGL_HAVE_PTHREAD} +#define MGL_HAVE_PTHREAD ${MGL_HAVE_PTHREAD} #endif -#define MGL_HAVE_HDF4 ${MGL_HAVE_HDF4} -#define MGL_HAVE_HDF5 ${MGL_HAVE_HDF5} -#define MGL_HAVE_JPEG ${MGL_HAVE_JPEG} -#define MGL_HAVE_PNG ${MGL_HAVE_PNG} -#define MGL_HAVE_ZLIB ${MGL_HAVE_ZLIB} -#define MGL_HAVE_PDF ${MGL_HAVE_PDF} -#define MGL_HAVE_GIF ${MGL_HAVE_GIF} -#define MGL_HAVE_OPENGL ${MGL_HAVE_OPENGL} -#define MGL_HAVE_MPI ${MGL_HAVE_MPI} -#define MGL_FONT_PATH "${MGL_FONT_PATH}" +#define MGL_HAVE_ZLIB ${MGL_HAVE_ZLIB} +#define MGL_HAVE_PNG ${MGL_HAVE_PNG} +#define MGL_HAVE_GSL ${MGL_HAVE_GSL} +#define MGL_HAVE_OPENGL ${MGL_HAVE_OPENGL} +#define MGL_HAVE_OMP ${MGL_HAVE_OMP} +#define MGL_HAVE_JPEG ${MGL_HAVE_JPEG} +#define MGL_HAVE_GIF ${MGL_HAVE_GIF} +#define MGL_HAVE_PDF ${MGL_HAVE_PDF} +#define MGL_HAVE_HDF4 ${MGL_HAVE_HDF4} +#define MGL_HAVE_HDF5 ${MGL_HAVE_HDF5} +#define MGL_FONT_PATH "${MGL_FONT_PATH}" #endif diff --git a/include/mgl2/abstract.h b/include/mgl2/abstract.h new file mode 100644 index 0000000..a076071 --- /dev/null +++ b/include/mgl2/abstract.h @@ -0,0 +1,105 @@ +/*************************************************************************** + * thread.h is part of Math Graphic Library + * Copyright (C) 2007-2012 Alexey Balakin * + * * + * 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. * + ***************************************************************************/ +#ifndef _MGL_ABSTRACT_H_ +#define _MGL_ABSTRACT_H_ + +#include "mgl2/define.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +#include +#include "mgl2/type.h" +//----------------------------------------------------------------------------- +class mglBase; +class mglData; +class mglParser; +class mglFormula; +class mglFormulaC; +class mglFont; +typedef mglBase* HMGL; +typedef mglData* HMDT; +typedef mglParser* HMPR; +typedef mglFormula* HMEX; +typedef mglFormulaC* HAEX; +//----------------------------------------------------------------------------- +#if MGL_NO_DATA_A +#define mglDataA mglData +typedef const mglData* HCDT; +#include "mgl2/data.h" +#else +//----------------------------------------------------------------------------- +/// 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); +//----------------------------------------------------------------------------- +/// Abstract class for data array +class MGL_EXPORT mglDataA +{ +public: + virtual ~mglDataA() {} + virtual mreal v(long i,long j=0,long k=0) const = 0; + virtual mreal vthr(long i) const = 0; + virtual long GetNx() const = 0; + virtual long GetNy() const = 0; + virtual long GetNz() const = 0; + inline long GetNN() const { return GetNx()*GetNy()*GetNz(); } + virtual mreal Maximal() const = 0; + virtual mreal Minimal() const = 0; + virtual mreal dvx(long i,long j=0,long k=0) const = 0; +// { return i>0 ? (i0 ? (j0 ? (kjdD*^" correspondingly +extern uint64_t mgl_mask_val[16]; +#define MGL_MASK_ID "-+=;oOsS~<>jdD*^" +#define MGL_SOLID_MASK 0xffffffffffffffff +//----------------------------------------------------------------------------- +#else +typedef void *HMGL; +typedef void *HMDT; +typedef void *HMEX; +typedef void *HAEX; +typedef void *HMPR; +typedef const void *HCDT; +#endif + +#if MGL_SRC +#define _Da_(d) (*((const mglDataA *)(d))) +#define _DA_(a) ((const mglDataA *)*(a)) +#define _GR_ ((mglBase *)(*gr)) +//#define _D_(d) *((mglData *)*(d)) +#define _DM_(a) ((mglData *)*(a)) +#define _DT_ ((mglData *)*d) +#endif + +#endif diff --git a/include/mgl2/addon.h b/include/mgl2/addon.h index 37036d6..01272c7 100644 --- a/include/mgl2/addon.h +++ b/include/mgl2/addon.h @@ -47,7 +47,7 @@ double MGL_EXPORT mgl_ipow(double x,int n); /// Get random number with Gaussian distribution double MGL_EXPORT mgl_gauss_rnd(); /// Fill frequencies for FFT -void MGL_EXPORT mgl_fft_freq(double *freq,size_t nn); +void MGL_EXPORT mgl_fft_freq(double *freq,long nn); /// Remove double spaces from the string void MGL_EXPORT mgl_strcls(char *str); @@ -58,6 +58,8 @@ int MGL_EXPORT mgl_chrpos(const char *str,char fnd); /// Get uncommented string from file (NOTE: it is not thread safe!!!) MGL_EXPORT char *mgl_fgetstr(FILE *fp); +/// Get parameters from uncommented strings of file (NOTE: it is not thread safe!!!) +void MGL_EXPORT mgl_fgetpar(FILE *fp, const char *str, ...); /// Check if symbol denote true int MGL_EXPORT mgl_istrue(char ch); /// Print test message diff --git a/include/mgl2/base.h b/include/mgl2/base.h index 5f0d9df..c973d9a 100644 --- a/include/mgl2/base.h +++ b/include/mgl2/base.h @@ -19,62 +19,21 @@ ***************************************************************************/ #ifndef _MGL_BASE_H_ #define _MGL_BASE_H_ -#if !defined(_MSC_VER) && !defined(__BORLANDC__) -#include -#endif -#if defined(__BORLANDC__) -typedef unsigned uintptr_t; -#endif -#include "mgl2/define.h" +//#if !defined(_MSC_VER) && !defined(__BORLANDC__) +#include "mgl2/abstract.h" #ifdef __cplusplus #include #include -#include "mgl2/type.h" -//----------------------------------------------------------------------------- -class mglBase; -class mglData; -class mglParser; -class mglFormula; -class mglFormulaC; -class mglFont; -typedef mglBase* HMGL; -typedef mglData* HMDT; -typedef mglParser* HMPR; -typedef mglFormula* HMEX; -typedef mglFormulaC* HAEX; -//----------------------------------------------------------------------------- -#if MGL_NO_DATA_A -#define mglDataA mglData -typedef const mglData* HCDT; -#include "mgl2/data.h" + +#if MGL_HAVE_PTHREAD +#include +#define MGL_PUSH(a,v,m) {pthread_mutex_lock(&m); a.push_back(v); pthread_mutex_unlock(&m);} #else -//----------------------------------------------------------------------------- -/// 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); -//----------------------------------------------------------------------------- -/// Abstract class for data array -class mglDataA -{ -public: - virtual ~mglDataA() {} - virtual mreal v(long i,long j=0,long k=0) const = 0; - virtual mreal vthr(long i) const = 0; - virtual long GetNx() const = 0; - virtual long GetNy() const = 0; - virtual long GetNz() const = 0; - inline long GetNN() const { return GetNx()*GetNy()*GetNz(); } - virtual mreal Maximal() const = 0; - virtual mreal Minimal() const = 0; - virtual mreal dvx(long i,long j=0,long k=0) const = 0; -// { return i>0 ? (i0 ? (j0 ? (k(const mglPrim &a,const mglPrim &b); //----------------------------------------------------------------------------- /// Structure for group of primitives -struct mglGroup +struct MGL_EXPORT mglGroup { std::vector p; ///< list of primitives (not filled!!!) int Id; ///< Current list of primitives @@ -110,7 +93,7 @@ struct mglGroup }; //----------------------------------------------------------------------------- /// Structure for text label -struct mglText +struct MGL_EXPORT mglText { std::wstring text; std::string stl; @@ -120,7 +103,7 @@ struct mglText }; //----------------------------------------------------------------------------- /// Structure for internal point representation -struct mglPnt // NOTE: use float for reducing memory size +struct MGL_EXPORT mglPnt // NOTE: use float for reducing memory size { float xx,yy,zz; // original coordinates float x,y,z; // coordinates @@ -153,8 +136,8 @@ struct MGL_EXPORT mglGlyph short *trig, *line; ///< vertexes of triangles and lines mglGlyph() { nl=nt=0; trig=line=0; } - mglGlyph(const mglGlyph &a) { trig=line=0; *this=a; } - mglGlyph(long Nt, long Nl) { trig=line=0; Create(Nt,Nl); } + mglGlyph(const mglGlyph &a) { nl=nt=0; trig=line=0; *this=a; } + mglGlyph(long Nt, long Nl) { nl=nt=0; trig=line=0; Create(Nt,Nl); } ~mglGlyph() { if(trig) delete []trig; if(line) delete []line; } void Create(long Nt, long Nl); @@ -174,7 +157,7 @@ struct MGL_EXPORT mglTexture char Sch[260]; ///< Color scheme used int Smooth; ///< Type of texture (smoothing and so on) mreal Alpha; ///< Transparency - + mglTexture() { n=Smooth=0; Alpha=1; } mglTexture(const char *cols, int smooth=0,mreal alpha=1) { n=0; Set(cols,smooth,alpha); } @@ -195,17 +178,8 @@ const mglColor BC( 0, 0, 0); const mglColor WC( 1, 1, 1); const mglColor RC( 1, 0, 0); //----------------------------------------------------------------------------- -/// Structure for color ID -struct mglColorID -{ - char id; - mglColor col; -}; -MGL_EXPORT extern mglColorID mglColorIds[31]; -MGL_EXPORT extern std::string mglGlobalMess; ///< Buffer for receiving global messages -//----------------------------------------------------------------------------- /// Structure active points -struct mglActivePos +struct MGL_EXPORT mglActivePos { int x,y; ///< coordinates of active point int id; ///< object id for active point @@ -233,16 +207,16 @@ public: mreal CDef; ///< Default (current) color in texture mreal AlphaDef; ///< Default value of alpha channel (transparency) mreal BarWidth; ///< Relative width of rectangles in Bars(). - int MeshNum; ///< Set approximate number of lines in Mesh and Grid. By default (=0) it draw all lines. - int FaceNum; ///< Set approximate number of visible faces and lines. By default (=0) it draw everything. + int MeshNum; ///< Set approximate number of lines in Mesh and Grid. By default (=0) it draw all lines. + int FaceNum; ///< Set approximate number of visible faces and lines. By default (=0) it draw everything. char Arrow1, Arrow2;///< Style of arrows at end and at start of curve long InUse; ///< Smart pointer (number of users) - long Flag; ///< Flags for controlling drawing + uint32_t Flag; ///< Flags for controlling drawing - inline bool get(long fl) const { return Flag&fl; } - inline void set(long fl) { Flag |= fl; } - inline void clr(long fl) { Flag &=~fl; } - inline void set(bool v,long fl) { Flag = v ? Flag|fl : Flag&(~fl); } + inline bool get(uint32_t fl) const { return Flag&fl; } + inline void set(uint32_t fl) { Flag |= fl; } + inline void clr(uint32_t fl) { Flag &=~fl; } + inline void set(bool v,uint32_t fl) { Flag = v ? Flag|fl : Flag&(~fl); } /// Set axis range scaling -- simplified way to shift/zoom axis range -- need to replot whole image! inline void ZoomAxis(mglPoint p1=mglPoint(0,0,0,0), mglPoint p2=mglPoint(1,1,1,1)) { AMin = p1; AMax = p2; } @@ -288,14 +262,20 @@ public: inline void SetCutBox(mreal x1, mreal y1, mreal z1, mreal x2, mreal y2, mreal z2) { CutMin=mglPoint(x1,y1,z1); CutMax=mglPoint(x2,y2,z2); } inline void SetCutBox(mglPoint v1, mglPoint v2) { CutMin=v1; CutMax=v2; } + /// Reset mask to solid state + inline void ResetMask() { mask = MGL_SOLID_MASK; MaskAn = DefMaskAn; } + /// Set default mask rotation angle + inline void SetMaskAngle(int angle) { DefMaskAn = angle; } /// Set the using of light on/off. virtual bool Light(bool enable) { bool t=get(MGL_ENABLE_LIGHT); set(enable,MGL_ENABLE_LIGHT); return t; } /// Set ambient light brightness virtual void SetAmbient(mreal bright=0.5); + /// Set diffusive light brightness + virtual void SetDiffuse(mreal bright=0.5); /// Use diffusive light (only for local light sources) - inline void SetDifLight(bool dif) { set(dif,MGL_DIFFUSIVE); } + inline void SetDifLight(bool dif) { SetDiffuse(dif?0.5:0); } /// Set the transparency on/off. virtual bool Alpha(bool enable) { bool t=get(MGL_ENABLE_ALPHA); set(enable,MGL_ENABLE_ALPHA); return t; } @@ -354,7 +334,7 @@ public: virtual mreal GetRatio() const; virtual int GetWidth() const; virtual int GetHeight() const; - + /// Set to use or not text rotation inline void SetRotatedText(bool val) { set(val,MGL_ENABLE_RTEXT); } /// Set default font style and color @@ -373,10 +353,13 @@ public: /// Set plot quality virtual void SetQuality(int qual=MGL_DRAW_NORM) { Quality=qual; } inline int GetQuality() const { return Quality; } + inline void SetDrawReg(long nx=1, long ny=1, long m=0) { dr_x=nx; dr_y=ny; dr_p=m; } // ~~~~~~~~~~~~~~~~~~~~~~ Developer functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// Add point to the Pnt and return its position - long AddPnt(mglPoint p, mreal c=-1, mglPoint n=mglPoint(NAN), mreal a=-1, int scl=1); + inline long AddPnt(mglPoint p, mreal c=-1, mglPoint n=mglPoint(NAN), mreal a=-1, int scl=1) + { return AddPnt(&B,p,c,n,a,scl); } + long AddPnt(const mglMatrix *M, mglPoint p, mreal c=-1, mglPoint n=mglPoint(NAN), mreal a=-1, int scl=1); long CopyNtoC(long k, mreal c); long CopyProj(long from, mglPoint p, mglPoint n); virtual void Reserve(long n); ///< Allocate n-cells for Pnt and return current position @@ -388,7 +371,10 @@ public: void AddActive(long k,int n=0); /// Clear unused points and primitives void ClearUnused(); - + + inline mreal GetPenWidth() { return PenWidth; } + + inline const mglMatrix *GetB() const { return &B; } inline mglPoint GetPntP(long i) const { const mglPnt &p=Pnt[i]; return mglPoint(p.x,p.y,p.z); } inline mglPoint GetPntN(long i) const @@ -407,11 +393,11 @@ public: inline const mglTexture &GetTxt(long i) const { return Txt[i]; } inline long GetTxtNum() const { return Txt.size(); } /// Scale coordinates and cut off some points - virtual bool ScalePoint(mglPoint &p, mglPoint &n, bool use_nan=true) const; + virtual bool ScalePoint(const mglMatrix *M, mglPoint &p, mglPoint &n, bool use_nan=true) const; - virtual mreal GetOrgX(char dir) const=0; ///< Get Org.x (parse NAN value) - virtual mreal GetOrgY(char dir) const=0; ///< Get Org.y (parse NAN value) - virtual mreal GetOrgZ(char dir) const=0; ///< Get Org.z (parse NAN value) + virtual mreal GetOrgX(char dir, bool inv=false) const=0; ///< Get Org.x (parse NAN value) + virtual mreal GetOrgY(char dir, bool inv=false) const=0; ///< Get Org.y (parse NAN value) + virtual mreal GetOrgZ(char dir, bool inv=false) const=0; ///< Get Org.z (parse NAN value) /// Get color depending on single variable z, which should be scaled if scale=true inline mreal GetC(long s,mreal z,bool scale = true) const @@ -419,14 +405,17 @@ public: /// Get alpha value depending on single variable a mreal GetA(mreal a) const; /// Set pen/palette - char SetPenPal(const char *stl, long *id=0); + char SetPenPal(const char *stl, long *id=0, bool pal=true); /// Add texture (like color scheme) and return the position of first color long AddTexture(const char *cols, int smooth=0); // inline mreal AddTexture(char col) { return AddTexture(mglColor(col)); } mreal AddTexture(mglColor col); inline void DefColor(mglColor col) { CDef = AddTexture(col); } + /// Set mask for face coloring + void SetMask(const char *mask); /// Set next color from palette mreal NextColor(long &id); + mreal NextColor(long id, long sh); virtual void mark_plot(long p, char type, mreal size=1)=0; virtual void arrow_plot(long p1, long p2, char st)=0; @@ -456,7 +445,7 @@ protected: std::vector Sub; ///< InPlot regions {n1=x1,n2=x2,n3=y1,n4=y2,id} std::vector Ptx; ///< Text labels for mglPrim std::vector Leg; ///< Text labels for legend - std::vector Glf; ///< Glyphs data + std::vector Glf; ///< Glyphs data std::vector Txt; ///< Pointer to textures #if MGL_HAVE_PTHREAD pthread_mutex_t mutexPnt, mutexTxt, mutexLeg, mutexGlf, mutexAct, mutexDrw; @@ -469,6 +458,11 @@ protected: mreal PenWidth; ///< Pen width for further line plotting (must be >0 !!!) // long numT; ///< Number of textures mreal AmbBr; ///< Default ambient light brightness + mreal DifBr; ///< Default diffusive light brightness + + mglMatrix Bp; ///< Transformation matrix for View() and Zoom() + mglMatrix B; ///< Transformation matrix + mglMatrix B1; ///< Transformation matrix for colorbar mglFont *fnt; ///< Class for printing vector text mreal FontSize; ///< The size of font for tick and axis labels @@ -486,8 +480,10 @@ protected: mreal ArrowSize; ///< The size of arrows. char last_style[64];///< Last pen style mreal font_factor; ///< Font scaling factor + + long dr_x, dr_y, dr_p; ///< default drawing region for quality&4 mode - virtual void LightScale()=0; ///< Scale positions of light sources + virtual void LightScale(const mglMatrix *M)=0; ///< Scale positions of light sources // block for SaveState() mglPoint MinS; ///< Saved lower edge of bounding box for graphics. @@ -498,14 +494,22 @@ protected: bool saved; ///< State is saved std::string leg_str;///< text to be save in legend + union + { + uint64_t mask; ///< Mask to be used for coloring + unsigned char mask_ch[8]; + }; + int MaskAn; ///< Mask rotation angle in degrees + int DefMaskAn; ///< Default mask rotation angle in degrees + private: mglPoint CutMin; ///< Lower edge of bounding box for cut off. mglPoint CutMax; ///< Upper edge of bounding box for cut off. - void RecalcCRange(); ///< Recalculate internal parameter for correct coloring. + bool RecalcCRange(); ///< Recalculate internal parameter for correct coloring. void RecalcBorder(); ///< Recalculate internal parameter for correct transformation rules. - void SetFBord(mreal x,mreal y,mreal z); ///< Set internal boundng box depending on transformation formula + bool SetFBord(mreal x,mreal y,mreal z); ///< Set internal boundng box depending on transformation formula void ClearEq(); ///< Clear the used variables for axis transformation }; //----------------------------------------------------------------------------- @@ -517,20 +521,5 @@ bool MGL_EXPORT mgl_check_vec3(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay bool MGL_EXPORT mgl_check_trig(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT a, const char *name, int d=3); bool MGL_EXPORT mgl_isboth(HCDT x, HCDT y, HCDT z, HCDT a); //----------------------------------------------------------------------------- -#define _Da_(d) (*((const mglDataA *)(d))) -#define _DA_(a) ((const mglDataA *)*(a)) -#define _GR_ ((mglBase *)(*gr)) -//----------------------------------------------------------------------------- -//#define _D_(d) *((mglData *)*(d)) -#define _DM_(a) ((mglData *)*(a)) -#define _DT_ ((mglData *)*d) -//----------------------------------------------------------------------------- -#else -typedef void *HMGL; -typedef void *HMDT; -typedef void *HMEX; -typedef void *HAEX; -typedef void *HMPR; -typedef const void *HCDT; #endif #endif diff --git a/include/mgl2/base_cf.h b/include/mgl2/base_cf.h index c0a5597..1f4024d 100644 --- a/include/mgl2/base_cf.h +++ b/include/mgl2/base_cf.h @@ -19,7 +19,7 @@ ***************************************************************************/ #ifndef _MGL_BASE_CF_H_ #define _MGL_BASE_CF_H_ -#include "mgl2/base.h" +#include "mgl2/abstract.h" //----------------------------------------------------------------------------- #ifdef __cplusplus extern "C" { @@ -46,12 +46,18 @@ int MGL_EXPORT mgl_get_quality_(uintptr_t *gr); /// Set plot quality void MGL_EXPORT mgl_set_quality(HMGL gr, int qual); void MGL_EXPORT mgl_set_quality_(uintptr_t *gr, int *qual); +/// Set drawing region for Quality&4 +void MGL_EXPORT mgl_set_draw_reg(HMGL gr, long nx, long ny, long m); +void MGL_EXPORT mgl_set_draw_reg_(uintptr_t *gr, int *nx, int *ny, int *m); + /// Is frames int MGL_EXPORT mgl_is_frames(HMGL gr); /// Get bit-value flag of HMGL state (for advanced users only) -int MGL_EXPORT mgl_get_flag(HMGL gr, long flag); +int MGL_EXPORT mgl_get_flag(HMGL gr, uint32_t flag); +int MGL_EXPORT mgl_get_flag_(uintptr_t *gr, unsigned long *flag); /// Set bit-value flag of HMGL state (for advanced users only) -void MGL_EXPORT mgl_set_flag(HMGL gr, int val, long flag); +void MGL_EXPORT mgl_set_flag(HMGL gr, int val, uint32_t flag); +void MGL_EXPORT mgl_set_flag_(uintptr_t *gr, int *val, unsigned long *flag); /// Change counter of HMGL uses (for advanced users only). Non-zero counter prevent automatic object removing. long MGL_EXPORT mgl_use_graph(HMGL gr, int inc); long MGL_EXPORT mgl_use_graph_(uintptr_t *gr, int *inc); @@ -79,6 +85,15 @@ void MGL_EXPORT mgl_set_color_(char *id, mreal *r, mreal *g, mreal *b, int); /// Set default color scheme void MGL_EXPORT mgl_set_def_sch(HMGL gr, const char *sch); void MGL_EXPORT mgl_set_def_sch_(uintptr_t *gr, const char *sch,int); +/// Set mask for face coloring as array of type 'unsigned char[8]' +void MGL_EXPORT mgl_set_mask(char id, const char *mask); +void MGL_EXPORT mgl_set_mask_(const char *id, const char *mask,int,int); +/// Set mask for face coloring as unsigned long number +void MGL_EXPORT mgl_set_mask_val(char id, uint64_t mask); +void MGL_EXPORT mgl_set_mask_val_(const char *id, uint64_t *mask,int); +/// Set default mask rotation angle +void MGL_EXPORT mgl_set_mask_angle(HMGL gr, int angle); +void MGL_EXPORT mgl_set_mask_angle_(uintptr_t *gr, int *angle); /// Set default value of alpha-channel void MGL_EXPORT mgl_set_alpha_default(HMGL gr, double alpha); @@ -99,7 +114,10 @@ void MGL_EXPORT mgl_clear_unused_(uintptr_t *gr); /// Set ambient light brightness void MGL_EXPORT mgl_set_ambbr(HMGL gr, double i); void MGL_EXPORT mgl_set_ambbr_(uintptr_t *gr, mreal *i); -/// Use diffusive light (only for local light sources) +/// Set diffusive light brightness +void MGL_EXPORT mgl_set_difbr(HMGL gr, double i); +void MGL_EXPORT mgl_set_difbr_(uintptr_t *gr, mreal *i); +/// Use diffusive light (only for local light sources) -- OBSOLETE void MGL_EXPORT mgl_set_light_dif(HMGL gr, int enable); void MGL_EXPORT mgl_set_light_dif_(uintptr_t *gr, int *enable); diff --git a/include/mgl2/canvas.h b/include/mgl2/canvas.h index 3b7f222..aeef0df 100644 --- a/include/mgl2/canvas.h +++ b/include/mgl2/canvas.h @@ -23,26 +23,15 @@ //----------------------------------------------------------------------------- struct GifFileType; //----------------------------------------------------------------------------- -/// Structure for transformation matrix -struct mglMatrix -{ - mreal b[9]; - mreal x,y,z,pf; - mglMatrix() { clear(); } - inline void clear() { x=y=z=0; memset(b,0,9*sizeof(mreal)); b[0]=b[4]=b[8]=1; } - inline mglMatrix &operator=(const mglMatrix &a) - { x=a.x; y=a.y; z=a.z; pf=a.pf; memcpy(b,a.b,9*sizeof(mreal)); return *this; } -}; -//----------------------------------------------------------------------------- /// Structure for drawing axis and ticks -struct mglAxis +struct MGL_EXPORT mglAxis { - mglAxis() { dv=ds=d=v0=v1=v2=o=sh=0; ns=f=ch=*t=0; pos = 't'; } + mglAxis() { dv=ds=d=v0=v1=v2=o=sh=0; ns=f=ch=0; pos = 't'; inv=false; } mglAxis(const mglAxis &aa) { dv=aa.dv; ds=aa.ds; d=aa.d; dir=aa.dir; sh=aa.sh; v0=aa.v0; v1=aa.v1; v2=aa.v2; o=aa.o; pos=aa.pos; - a = aa.a; b = aa.b; org=aa.org; txt=aa.txt; - ns=aa.ns; f=aa.f; ch=aa.ch; wcscpy(t,aa.t); } + a = aa.a; b = aa.b; org=aa.org; txt=aa.txt; inv=aa.inv; + ns=aa.ns; f=aa.f; ch=aa.ch; t=aa.t; } inline void AddLabel(const wchar_t *lbl, mreal v) { txt.push_back(mglText(lbl,"",v)); } inline void AddLabel(const std::wstring &lbl, mreal v) @@ -51,7 +40,7 @@ struct mglAxis mreal dv,ds; ///< Actual step for ticks and subticks. mreal d; ///< Step for axis ticks (if positive) or its number (if negative). int ns; ///< Number of axis subticks. - wchar_t t[256]; ///< Tick template (set "" to use default one ("%.2g" in simplest case)) + std::wstring t; ///< Tick template (set "" to use default one ("%.2g" in simplest case)) mglPoint dir; ///< Axis direction mglPoint a,b; ///< Directions of over axis mglPoint org; @@ -61,13 +50,14 @@ struct mglAxis mreal o; ///< Point of starting ticks numbering (if NAN then Org is used). int f; ///< Flag 0x1 - time, 0x2 - manual, 0x4 - fixed dv std::vector txt; ///< Axis labels - char ch; ///< Character of axis (like 'x','y','z','c') + char ch; ///< Character of axis (like 'x','y','z','c') char pos; ///< Text position ('t' by default, or 'T' for opposite) mreal sh; ///< Extra shift of ticks and axis labels + bool inv; ///< Inverse automatic origin position }; //----------------------------------------------------------------------------- /// Structure for light source -struct mglLight +struct MGL_EXPORT mglLight { mglLight() { n=false; a=b=0; } bool n; ///< Availability of light sources @@ -82,9 +72,14 @@ struct mglLight //----------------------------------------------------------------------------- class mglCanvas; /// Structure for light source -struct mglDrawReg +struct MGL_EXPORT mglDrawReg { - unsigned long PDef; + union + { + uint64_t PDef; + unsigned char m[8]; + }; + int angle; ///< mask rotation values in degrees int ObjId; mreal PenWidth, pPos; int x1,x2,y1,y2; @@ -92,7 +87,7 @@ struct mglDrawReg }; //----------------------------------------------------------------------------- /// Structure contains everything for drawing -struct mglDrawDat +struct MGL_EXPORT mglDrawDat { std::vector Pnt; ///< Internal points std::vector Prm; ///< Primitives (lines, triangles and so on) -- need for export @@ -101,10 +96,13 @@ struct mglDrawDat std::vector Txt; ///< Pointer to textures }; //----------------------------------------------------------------------------- +union mglRGBA { uint32_t c; unsigned char r[4]; }; +//----------------------------------------------------------------------------- /// Class contains all functionality for creating different mathematical plots class MGL_EXPORT mglCanvas : public mglBase { friend struct mglPrim; +friend struct mglDrawReg; public: using mglBase::Light; @@ -123,8 +121,9 @@ using mglBase::Light; /// Clear transformation matrix. inline void Identity(bool rel=false) { InPlot(0,1,0,1,rel); } + inline void Identity(mglMatrix &M, bool rel=false) { InPlot(M,0,1,0,1,rel); } /// Push transformation matrix into stack - inline void Push() { MGL_PUSH(stack,B,mutexStk); } + void Push(); /// Set PlotFactor inline void SetPlotFactor(mreal val) { if(val<=0) {B.pf=1.55; set(MGL_AUTO_FACTOR);} else {B.pf=val; clr(MGL_AUTO_FACTOR);} } @@ -133,13 +132,15 @@ using mglBase::Light; /// Pop transformation matrix from stack inline void Pop() { B = stack.back(); stack.pop_back(); } /// Clear up the frame - virtual void Clf(mglColor back=WC); + virtual void Clf(mglColor back=NC); /// Put further plotting in cell of stick rotated on angles tet, phi void StickPlot(int num, int i, mreal tet, mreal phi); /// Put further plotting in some region of whole frame surface. - void InPlot(mreal x1,mreal x2,mreal y1,mreal y2,bool rel=true); + inline void InPlot(mreal x1,mreal x2,mreal y1,mreal y2,bool rel=true) + { InPlot(B,x1,x2,y1,y2,rel); } void InPlot(mreal x1,mreal x2,mreal y1,mreal y2, const char *style); + void InPlot(mglMatrix &M,mreal x1,mreal x2,mreal y1,mreal y2,bool rel=true); /// Add title for current subplot/inplot void Title(const char *title,const char *stl="#",mreal size=-2); void Title(const wchar_t *title,const char *stl="#",mreal size=-2); @@ -148,7 +149,7 @@ using mglBase::Light; /// Rotate a further plotting. void Rotate(mreal TetX,mreal TetZ,mreal TetY=0); /// Rotate a further plotting around vector {x,y,z}. - void RotateN(mreal Tet,mreal x,mreal y,mreal z); + void RotateN(mreal Tet,mreal x,mreal y,mreal z) ; /// Set perspective (in range [0,1)) for plot. Set to zero for switching off. void Perspective(mreal a) { Bp.pf = fabs(a); } @@ -185,7 +186,7 @@ using mglBase::Light; int GetSplId(long xs,long ys) const; /// Check if there is active point or primitive (n=-1) int IsActive(int xs, int ys,int &n); - + /// Create new frame. virtual int NewFrame(); /// Finish frame drawing @@ -202,19 +203,20 @@ using mglBase::Light; virtual void SetFrame(long i); /// Add drawing data from i-th frame to the current drawing void ShowFrame(long i); - + /// Start write frames to cinema using GIF format void StartGIF(const char *fname, int ms=100); /// Stop writing cinema using GIF format void CloseGIF(); /// Finish plotting. Normally this function is called internaly. - virtual void Finish(bool fast=true); + virtual void Finish(); /// Export points and primitives in file using MGLD format bool ExportMGLD(const char *fname, const char *descr=0); /// Import points and primitives from file using MGLD format bool ImportMGLD(const char *fname, bool add=false); /// Export in JSON format suitable for later drawing by JavaScript - bool WriteJSON(const char *fname); + bool WriteJSON(const char *fname, bool force_zlib=false); + std::string GetJSON(); /// Set the transparency type inline void SetTranspType(int val) @@ -288,8 +290,6 @@ using mglBase::Light; void StartAutoGroup (const char *); void EndGroup(); - /// Retur color for primitive depending lighting - mglColor GetColor(const mglPrim &p); /// Set extra shift for tick and axis labels inline void SetTickShift(mglPoint p) { ax.sh = p.x; ay.sh = p.y; az.sh = p.z; ac.sh = p.c; } @@ -302,7 +302,12 @@ using mglBase::Light; int *OI; ///< ObjId arrays (size width*height) /// Plot point p with color c void pnt_plot(long x,long y,mreal z,const unsigned char c[4], int obj_id); - + void pnt_fast(long x,long y,mreal z,const unsigned char c[4], int obj_id); + /// preparing primitives for 2d export or bitmap drawing (0 default, 1 for 2d vector, 2 for 3d vector) + void PreparePrim(int fast); + inline uint32_t GetPntCol(long i) { return pnt_col[i]; } + inline uint32_t GetPrmCol(long i) { return prm_col[i]; } + protected: mreal Delay; ///< Delay for animation in seconds // NOTE: Z should be float for reducing space and for compatibility reasons @@ -326,9 +331,6 @@ protected: int Width; ///< Width of the image int Height; ///< Height of the image int Depth; ///< Depth of the image - mglMatrix Bp; ///< Transformation matrix for View() and Zoom() - mglMatrix B; ///< Transformation matrix - mglMatrix B1; ///< Transformation matrix for colorbar mreal inW, inH; ///< Width and height of last InPlot mreal inX, inY; ///< Coordinates of last InPlot mglLight light[10]; ///< Light sources @@ -352,14 +354,16 @@ protected: /// Clear ZBuffer only void ClfZB(bool force=false); /// Scale coordinates and cut off some points - bool ScalePoint(mglPoint &p, mglPoint &n, bool use_nan=true) const; - void LightScale(); ///< Additionally scale positions of light sources + bool ScalePoint(const mglMatrix *M, mglPoint &p, mglPoint &n, bool use_nan=true) const; + void LightScale(const mglMatrix *M); ///< Additionally scale positions of light sources /// Push drawing data (for frames only). NOTE: can be VERY large long PushDrwDat(); - - mreal GetOrgX(char dir) const; ///< Get Org.x (parse NAN value) - mreal GetOrgY(char dir) const; ///< Get Org.y (parse NAN value) - mreal GetOrgZ(char dir) const; ///< Get Org.z (parse NAN value) + /// Retur color for primitive depending lighting + uint32_t GetColor(const mglPrim &p); + + mreal GetOrgX(char dir, bool inv=false) const; ///< Get Org.x (parse NAN value) + mreal GetOrgY(char dir, bool inv=false) const; ///< Get Org.y (parse NAN value) + mreal GetOrgZ(char dir, bool inv=false) const; ///< Get Org.z (parse NAN value) void mark_plot(long p, char type, mreal size=1); void arrow_plot(long p1, long p2, char st); @@ -370,12 +374,12 @@ protected: mreal text_plot(long p,const wchar_t *text,const char *fnt,mreal size=-1,mreal sh=0,mreal col=-('k'), bool rot=true); void add_prim(mglPrim &a); ///< add primitive to list - void mark_draw(const mglPnt &p, char type, mreal size, mglDrawReg *d); - void arrow_draw(const mglPnt &p1, const mglPnt &p2, char st, mreal size, mglDrawReg *d); - virtual void line_draw(const mglPnt &p1, const mglPnt &p2, mglDrawReg *d); - virtual void trig_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool anorm, mglDrawReg *d); - virtual void quad_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, const mglPnt &p4, mglDrawReg *d); - virtual void pnt_draw(const mglPnt &p, mglDrawReg *d); + void arrow_draw(const mglPnt &p1, const mglPnt &p2, char st, mreal size, const mglDrawReg *d); + virtual void mark_draw(const mglPnt &p, char type, mreal size, mglDrawReg *d); + virtual void line_draw(const mglPnt &p1, const mglPnt &p2, const mglDrawReg *d); + virtual void trig_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool anorm, const mglDrawReg *d); + virtual void quad_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, const mglPnt &p4, const mglDrawReg *d); + virtual void pnt_draw(const mglPnt &p, const mglDrawReg *d); void arrow_draw(long n1, long n2, char st, float ll); void arrow_plot_3d(long n1, long n2, char st, float ll); void glyph_draw(const mglPrim &P, mglDrawReg *d); @@ -385,66 +389,83 @@ protected: mglPoint RestorePnt(mglPoint ps, bool norm=false) const; // functions for multi-threading - void PreparePrim(bool fast); - void pxl_combine(size_t id, size_t n, const void *); - void pxl_memcpy(size_t id, size_t n, const void *); - void pxl_backgr(size_t id, size_t n, const void *); - void pxl_primdr(size_t id, size_t n, const void *); - void pxl_transform(size_t id, size_t n, const void *); - void pxl_setz(size_t id, size_t n, const void *); - void pxl_setz_adv(size_t id, size_t n, const void *); - void pxl_other(size_t id, size_t n, const void *p); + void pxl_pntcol(long id, long n, const void *); + void pxl_prmcol(long id, long n, const void *); + void pxl_combine(long id, long n, const void *); + void pxl_memcpy(long id, long n, const void *); + void pxl_backgr(long id, long n, const void *); + void pxl_primdr(long id, long n, const void *); + void pxl_dotsdr(long id, long n, const void *); + void pxl_primpx(long id, long n, const void *); + void pxl_transform(long id, long n, const void *); + void pxl_setz(long id, long n, const void *); + void pxl_setz_adv(long id, long n, const void *); + void pxl_other(long id, long n, const void *p); /// Put drawing from other mglCanvas (for multithreading, like subplots) void PutDrawReg(mglDrawReg *d, const mglCanvas *gr); - + private: + std::vector pnt_col, prm_col; // mreal _tetx,_tety,_tetz; // extra angles std::vector stack; ///< stack for transformation matrices - int dr_nx1, dr_nx2, dr_ny1, dr_ny2; // Allowed drawing region GifFileType *gif; mreal fscl,ftet; ///< last scale and rotation for glyphs long forg; ///< original point (for directions) size_t grp_counter; ///< Counter for StartGroup(); EndGroup(); + mglMatrix Bt; ///< temporary matrix for text /// Draw generic colorbar void colorbar(HCDT v, const mreal *s, int where, mreal x, mreal y, mreal w, mreal h); /// Draw labels for ticks - void DrawLabels(mglAxis &aa); + void DrawLabels(mglAxis &aa, bool inv=false); /// Get label style char GetLabelPos(mreal c, long kk, mglAxis &aa); /// Draw tick - void tick_draw(mglPoint o, mglPoint d1, mglPoint d2, int f, const char *stl); + void tick_draw(mglPoint o, mglPoint d1, mglPoint d2, int f); mreal FindOptOrg(char dir, int ind) const; /// Transform mreal color and alpha to bits format unsigned char* col2int(const mglPnt &p, unsigned char *r, int obj_id); /// Combine colors in 2 plane. void combine(unsigned char *c1, const unsigned char *c2); /// Fast drawing of line between 2 points - void fast_draw(const mglPnt &p1, const mglPnt &p2, mglDrawReg *d); + void fast_draw(const mglPnt &p1, const mglPnt &p2, const mglDrawReg *d); /// Additionally scale points p for positioning in image - void PostScale(mglPoint &p) const; + void PostScale(const mglMatrix *M, mglPoint &p) const; /// Scale points p for projection to the face number nface in image long ProjScale(int nface, long p, bool text=false); - inline void PostScale(mglPoint *p,long n) const { for(long i=0;i @@ -28,9 +29,9 @@ //----------------------------------------------------------------------------- /// Class for working with data array #if MGL_NO_DATA_A -class mglData +class MGL_EXPORT mglData #else -class mglData : public mglDataA +class MGL_EXPORT mglData : public mglDataA #endif { public: @@ -88,16 +89,16 @@ public: inline void Set(const double *A,long NX,long NY=1,long NZ=1) { mgl_data_set_double(this,A,NX,NY,NZ); } /// Allocate memory and copy the data from the (float **) array - inline void Set(const float **A,long N1,long N2) + inline void Set(float const * const *A,long N1,long N2) { mgl_data_set_float2(this,A,N1,N2); } /// Allocate memory and copy the data from the (double **) array - inline void Set(const double **A,long N1,long N2) + inline void Set(double const * const *A,long N1,long N2) { mgl_data_set_double2(this,A,N1,N2); } /// Allocate memory and copy the data from the (float ***) array - inline void Set(const float ***A,long N1,long N2,long N3) + inline void Set(float const * const * const *A,long N1,long N2,long N3) { mgl_data_set_float3(this,A,N1,N2,N3); } /// Allocate memory and copy the data from the (double ***) array - inline void Set(const double ***A,long N1,long N2,long N3) + inline void Set(double const * const * const *A,long N1,long N2,long N3) { mgl_data_set_double3(this,A,N1,N2,N3); } /// Allocate memory and scanf the data from the string inline void Set(const char *str,long NX,long NY=1,long NZ=1) @@ -146,7 +147,7 @@ public: /// Join with another data array inline void Join(const mglDataA &d) { mgl_data_join(this,&d); } - + /// Modify the data by specified formula inline void Modify(const char *eq,long dim=0) { mgl_data_modify(this, eq, dim); } @@ -166,9 +167,28 @@ public: /// Equidistantly fill the data to range [x1,x2] in direction dir inline void Fill(mreal x1,mreal x2=NaN,char dir='x') { return mgl_data_fill(this,x1,x2,dir); } - /// Set the data by triangulated surface values assuming x,y,z in range [r1,r2] + /// Fill the data by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in range [p1,p2] + inline void Refill(const mglDataA &xdat, const mglDataA &vdat, mreal x1, mreal x2,long sl=-1) + { mgl_data_refill_x(this,&xdat,&vdat,x1,x2,sl); } + inline void Refill(const mglDataA &xdat, const mglDataA &vdat, mglPoint p1, mglPoint p2,long sl=-1) + { mgl_data_refill_x(this,&xdat,&vdat,p1.x,p2.x,sl); } + inline void Refill(const mglDataA &xdat, const mglDataA &ydat, const mglDataA &vdat, mglPoint p1, mglPoint p2,long sl=-1) + { mgl_data_refill_xy(this,&xdat,&ydat,&vdat,p1.x,p2.x,p1.y,p2.y,sl); } + inline void Refill(const mglDataA &xdat, const mglDataA &ydat, const mglDataA &zdat, const mglDataA &vdat, mglPoint p1, mglPoint p2) + { mgl_data_refill_xyz(this,&xdat,&ydat,&zdat,&vdat,p1.x,p2.x,p1.y,p2.y,p1.z,p2.z); } + /// Fill the data by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in axis range of gr + inline void Refill(mglBase *gr, const mglDataA &xdat, const mglDataA &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,this,&xdat,0,0,&vdat,sl,opt); } + inline void Refill(mglBase *gr, const mglDataA &xdat, const mglDataA &ydat, const mglDataA &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,this,&xdat,&ydat,0,&vdat,sl,opt); } + inline void Refill(mglBase *gr, const mglDataA &xdat, const mglDataA &ydat, const mglDataA &zdat, const mglDataA &vdat, const char *opt="") + { mgl_data_refill_gr(gr,this,&xdat,&ydat,&zdat,&vdat,-1,opt); } + /// Set the data by triangulated surface values assuming x,y,z in axis range of gr inline void Grid(mglBase *gr, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *opt="") { mgl_data_grid(gr,this,&x,&y,&z,opt); } + /// Set the data by triangulated surface values assuming x,y,z in range [p1, p2] + inline void Grid(const mglDataA &xdat, const mglDataA &ydat, const mglDataA &vdat, mglPoint p1, mglPoint p2) + { mgl_data_grid_xy(this,&xdat,&ydat,&vdat,p1.x,p2.x,p1.y,p2.y); } /// Put value to data element(s) inline void Put(mreal val, long i=-1, long j=-1, long k=-1) { mgl_data_put_val(this,val,i,j,k); } @@ -248,7 +268,7 @@ public: inline mglData Combine(const mglDataA &dat) const { return mglData(true,mgl_data_combine(this,&dat)); } /// Resize the data to new size of box [x1,x2]*[y1,y2]*[z1,z2] - inline mglData Resize(long mx,long my=1,long mz=1, mreal x1=0,mreal x2=1, mreal y1=0,mreal y2=1, mreal z1=0,mreal z2=1) const + inline mglData Resize(long mx,long my=0,long mz=0, mreal x1=0,mreal x2=1, mreal y1=0,mreal y2=1, mreal z1=0,mreal z2=1) const { return mglData(true,mgl_data_resize_box(this,mx,my,mz,x1,x2,y1,y2,z1,z2)); } /// Get array which values is result of interpolation this for coordinates from other arrays inline mglData Evaluate(const mglData &idat, bool norm=true) const @@ -260,7 +280,13 @@ public: /// Find roots for set of nonlinear equations defined by textual formula inline mglData Roots(const char *func, char var='x') const { return mglData(true,mgl_data_roots(func, this, var)); } - + /// Find correlation with another data arrays + inline mglData Correl(const mglDataA &dat, const char *dir) const + { return mglData(true,mgl_data_correl(this,&dat,dir)); } + /// Find auto correlation function + inline mglData AutoCorrel(const char *dir) const + { return mglData(true,mgl_data_correl(this,this,dir)); } + /// Cumulative summation the data in given direction or directions inline void CumSum(const char *dir) { mgl_data_cumsum(this,dir); } /// Integrate (cumulative summation) the data in given direction or directions @@ -331,7 +357,7 @@ public: { return mglData(true,mgl_data_solve(this, val, dir, 0, norm)); } inline mglData Solve(mreal val, char dir, const mglData &i0, bool norm=true) const { return mglData(true,mgl_data_solve(this, val, dir, &i0, norm)); } - + /// 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 mgl_data_spline_ext(this, x,y,z, &(dif.x),&(dif.y), &(dif.z)); } @@ -346,7 +372,7 @@ public: inline mreal Linear1(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const { mreal res=mgl_data_linear_ext(this,x*(nx-1),y*(ny-1),z*(nz-1), &(dif.x),&(dif.y), &(dif.z)); dif.x*=nx>1?nx-1:1; dif.y*=ny>1?ny-1:1; dif.z*=nz>1?nz-1:1; return res; } - + /// Get information about the data (sizes and momentum) to string inline const char *PrintInfo() const { return mgl_data_info(this); } /// Print information about the data (sizes and momentum) to FILE (for example, stdout) @@ -420,11 +446,11 @@ protected: #endif /// Get the value in given cell of the data without border checking inline mreal v(long i,long j=0,long k=0) const -#ifdef DEBUG +#ifndef DEBUG + { return a[i+nx*(j+ny*k)]; } +#else { if(i<0 || j<0 || k<0 || i>=nx || j>=ny || k>=nz) printf("Wrong index in mglData"); return a[i+nx*(j+ny*k)]; } -#else - { return a[i+nx*(j+ny*k)]; } #endif inline mreal vthr(long i) const { return a[i]; } // add for speeding up !!! diff --git a/include/mgl2/data_cf.h b/include/mgl2/data_cf.h index e827af3..964c330 100644 --- a/include/mgl2/data_cf.h +++ b/include/mgl2/data_cf.h @@ -20,7 +20,7 @@ #ifndef _MGL_DATA_CF_H_ #define _MGL_DATA_CF_H_ //----------------------------------------------------------------------------- -#include "mgl2/base.h" +#include "mgl2/abstract.h" //----------------------------------------------------------------------------- #if MGL_HAVE_GSL #include @@ -82,16 +82,16 @@ void MGL_EXPORT mgl_data_set_double(HMDT dat, const double *A,long mx,long my,lo void MGL_EXPORT mgl_data_set_double_(uintptr_t *dat, const double *A,int *NX,int *NY,int *NZ); void MGL_EXPORT mgl_data_set_double1_(uintptr_t *d, const double *A,int *N1); /// Allocate memory and copy the data from the (float **) array -void MGL_EXPORT mgl_data_set_float2(HMDT d, const float **A,long N1,long N2); +void MGL_EXPORT mgl_data_set_float2(HMDT d, float const * const *A,long N1,long N2); void MGL_EXPORT mgl_data_set_float2_(uintptr_t *d, const float *A,int *N1,int *N2); /// Allocate memory and copy the data from the (double **) array -void MGL_EXPORT mgl_data_set_double2(HMDT d, const double **A,long N1,long N2); +void MGL_EXPORT mgl_data_set_double2(HMDT d, double const * const *A,long N1,long N2); void MGL_EXPORT mgl_data_set_double2_(uintptr_t *d, const double *A,int *N1,int *N2); /// Allocate memory and copy the data from the (float ***) array -void MGL_EXPORT mgl_data_set_float3(HMDT d, const float ***A,long N1,long N2,long N3); +void MGL_EXPORT mgl_data_set_float3(HMDT d, float const * const * const *A,long N1,long N2,long N3); void MGL_EXPORT mgl_data_set_float3_(uintptr_t *d, const float *A,int *N1,int *N2,int *N3); /// Allocate memory and copy the data from the (double ***) array -void MGL_EXPORT mgl_data_set_double3(HMDT d, const double ***A,long N1,long N2,long N3); +void MGL_EXPORT mgl_data_set_double3(HMDT d, double const * const * const *A,long N1,long N2,long N3); void MGL_EXPORT mgl_data_set_double3_(uintptr_t *d, const double *A,int *N1,int *N2,int *N3); /// Import data from abstract type void MGL_EXPORT mgl_data_set(HMDT dat, HCDT a); @@ -173,9 +173,24 @@ void MGL_EXPORT mgl_data_fill_(uintptr_t *dat, mreal *x1,mreal *x2,const char *d /// Modify the data by specified formula assuming x,y,z in range [r1,r2] void MGL_EXPORT mgl_data_fill_eq(HMGL gr, HMDT dat, const char *eq, HCDT vdat, HCDT wdat,const char *opt); void MGL_EXPORT mgl_data_fill_eq_(uintptr_t *gr, uintptr_t *dat, const char *eq, uintptr_t *vdat, uintptr_t *wdat,const char *opt, int, int); +/// Fill dat by interpolated values of vdat parametrically depended on xdat for x in range [x1,x2] +void MGL_EXPORT mgl_data_refill_x(HMDT dat, HCDT xdat, HCDT vdat, mreal x1, mreal x2, long sl); +void MGL_EXPORT mgl_data_refill_x_(uintptr_t *dat, uintptr_t *xdat, uintptr_t *vdat, mreal *x1, mreal *x2, long *sl); +/// Fill dat by interpolated values of vdat parametrically depended on xdat,ydat for x,y in range [x1,x2]*[y1,y2] +void MGL_EXPORT mgl_data_refill_xy(HMDT dat, HCDT xdat, HCDT ydat, HCDT vdat, mreal x1, mreal x2, mreal y1, mreal y2, long sl); +void MGL_EXPORT mgl_data_refill_xy_(uintptr_t *dat, uintptr_t *xdat, uintptr_t *ydat, uintptr_t *vdat, mreal *x1, mreal *x2, mreal *y1, mreal *y2, long *sl); +/// Fill dat by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in range [x1,x2]*[y1,y2]*[z1,z2] +void MGL_EXPORT mgl_data_refill_xyz(HMDT dat, HCDT xdat, HCDT ydat, HCDT zdat, HCDT vdat, mreal x1, mreal x2, mreal y1, mreal y2, mreal z1, mreal z2); +void MGL_EXPORT mgl_data_refill_xyz_(uintptr_t *dat, uintptr_t *xdat, uintptr_t *ydat, uintptr_t *zdat, uintptr_t *vdat, mreal *x1, mreal *x2, mreal *y1, mreal *y2, mreal *z1, mreal *z2); +/// Fill dat by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in axis range +void MGL_EXPORT mgl_data_refill_gr(HMGL gr, HMDT dat, HCDT xdat, HCDT ydat, HCDT zdat, HCDT vdat, long sl, const char *opt); +void MGL_EXPORT mgl_data_refill_gr_(uintptr_t *gr, uintptr_t *dat, uintptr_t *xdat, uintptr_t *ydat, uintptr_t *zdat, uintptr_t *vdat, long *sl, const char *opt,int); /// Set the data by triangulated surface values assuming x,y,z in range [r1,r2] void MGL_EXPORT mgl_data_grid(HMGL gr, HMDT d, HCDT xdat, HCDT ydat, HCDT zdat,const char *opt); void MGL_EXPORT mgl_data_grid_(uintptr_t *gr, uintptr_t *dat, uintptr_t *xdat, uintptr_t *ydat, uintptr_t *zdat, const char *opt,int); +/// Set the data by triangulated surface values assuming x,y,z in range [x1,x2]*[y1,y2] +void MGL_EXPORT mgl_data_grid_xy(HMDT d, HCDT xdat, HCDT ydat, HCDT zdat, mreal x1, mreal x2, mreal y1, mreal y2); +void MGL_EXPORT mgl_data_grid_xy_(uintptr_t *dat, uintptr_t *xdat, uintptr_t *ydat, uintptr_t *zdat, mreal *x1, mreal *x2, mreal *y1, mreal *y2); /// Put value to data element(s) void MGL_EXPORT mgl_data_put_val(HMDT dat, mreal val, long i, long j, long k); void MGL_EXPORT mgl_data_put_val_(uintptr_t *dat, mreal *val, int *i, int *j, int *k); @@ -309,13 +324,20 @@ void MGL_EXPORT mgl_data_cosfft_(uintptr_t *dat, const char *dir,int); /// Fill data by 'x'/'k' samples for Hankel ('h') or Fourier ('f') transform void MGL_EXPORT mgl_data_fill_sample(HMDT dat, const char *how); void MGL_EXPORT mgl_data_fill_sample_(uintptr_t *dat, const char *how,int); +/// Find correlation between 2 data arrays +HMDT MGL_EXPORT mgl_data_correl(HCDT dat1, HCDT dat2, const char *dir); +uintptr_t MGL_EXPORT mgl_data_correl_(uintptr_t dat1, uintptr_t dat2, const char *dir,int); /// Allocate and prepare data for Fourier transform by nthr threads MGL_EXPORT void *mgl_fft_alloc(long n, void **space, long nthr); +MGL_EXPORT void *mgl_fft_alloc_thr(long n); /// Free data for Fourier transform void MGL_EXPORT mgl_fft_free(void *wt, void **ws, long nthr); +void MGL_EXPORT mgl_fft_free_thr(void *wt); /// Make Fourier transform of data x of size n and step s between points -void MGL_EXPORT mgl_fft(double *x, long s, long n, const void *wt, void *ws, bool inv); +void MGL_EXPORT mgl_fft(double *x, long s, long n, const void *wt, void *ws, int inv); +/// Clear internal data for speeding up FFT and Hankel transforms +void MGL_EXPORT mgl_clear_fft(); /// Interpolate by cubic spline the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] mreal MGL_EXPORT mgl_data_spline(HCDT dat, mreal x,mreal y,mreal z); @@ -395,28 +417,6 @@ void MGL_EXPORT mgl_data_add_num_(uintptr_t *dat, mreal *d); void MGL_EXPORT mgl_data_sub_num(HMDT dat, mreal d); void MGL_EXPORT mgl_data_sub_num_(uintptr_t *dat, mreal *d); -/// Saves result of PDE solving (|u|^2) for "Hamiltonian" ham with initial conditions ini -HMDT MGL_EXPORT mgl_pde_solve(HMGL gr, const char *ham, HCDT ini_re, HCDT ini_im, mreal dz, mreal k0,const char *opt); -uintptr_t MGL_EXPORT mgl_pde_solve_(uintptr_t* gr, const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, mreal *dz, mreal *k0,const char *opt,int,int); -/// Saves result of PDE solving for "Hamiltonian" ham with initial conditions ini along a curve ray (must have nx>=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) -HMDT MGL_EXPORT mgl_qo2d_solve(const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy); -HMDT MGL_EXPORT mgl_qo2d_func(dual (*ham)(mreal u, mreal x, mreal y, mreal px, mreal py, void *par), void *par, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy); -uintptr_t MGL_EXPORT mgl_qo2d_solve_(const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, uintptr_t* ray, mreal *r, mreal *k0, uintptr_t* xx, uintptr_t* yy, int); -/// Saves result of PDE solving for "Hamiltonian" ham with initial conditions ini along a curve ray (must have nx>=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) -HMDT MGL_EXPORT mgl_qo3d_solve(const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz); -HMDT MGL_EXPORT mgl_qo3d_func(dual (*ham)(mreal u, mreal x, mreal y, mreal z, mreal px, mreal py, mreal pz, void *par), void *par, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz); -uintptr_t MGL_EXPORT mgl_qo3d_solve_(const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, uintptr_t* ray, mreal *r, mreal *k0, uintptr_t* xx, uintptr_t* yy, uintptr_t* zz, int); -/// Saves result of ODE solving of n equations with right part func and initial conditions x0 over time interval [0,tmax] with time step dt -HMDT MGL_EXPORT mgl_ode_solve(void (*func)(const mreal *x, mreal *dx, void *par), int n, mreal *x0, mreal dt, mreal tmax, void *par); -/// Finds ray with starting point r0, p0 (and prepares ray data for mgl_qo2d_solve) -HMDT MGL_EXPORT mgl_ray_trace(const char *ham, mreal x0, mreal y0, mreal z0, mreal px, mreal py, mreal pz, mreal dt, mreal tmax); -uintptr_t MGL_EXPORT mgl_ray_trace_(const char *ham, mreal *x0, mreal *y0, mreal *z0, mreal *px, mreal *py, mreal *pz, mreal *dt, mreal *tmax,int); -/// Calculate Jacobian determinant for D{x(u,v), y(u,v)} = dx/du*dy/dv-dx/dv*dy/du -HMDT MGL_EXPORT mgl_jacobian_2d(HCDT x, HCDT y); -uintptr_t MGL_EXPORT mgl_jacobian_2d_(uintptr_t* x, uintptr_t* y); -/// Calculate Jacobian determinant for D{x(u,v,w), y(u,v,w), z(u,v,w)} -HMDT MGL_EXPORT mgl_jacobian_3d(HCDT x, HCDT y, HCDT z); -uintptr_t MGL_EXPORT mgl_jacobian_3d_(uintptr_t* x, uintptr_t* y, uintptr_t* z); /// Integral data transformation (like Fourier 'f' or 'i', Hankel 'h' or None 'n') for amplitude and phase HMDT MGL_EXPORT mgl_transform_a(HCDT am, HCDT ph, const char *tr); uintptr_t MGL_EXPORT mgl_transform_a_(uintptr_t *am, uintptr_t *ph, const char *tr, int); diff --git a/include/mgl2/datac.h b/include/mgl2/datac.h index 5661e55..5d7e414 100644 --- a/include/mgl2/datac.h +++ b/include/mgl2/datac.h @@ -31,7 +31,7 @@ #define mgl4 mreal(4) //----------------------------------------------------------------------------- /// Class for working with data array -class mglDataC : public mglDataA +class MGL_EXPORT mglDataC : public mglDataA { public: @@ -162,6 +162,13 @@ public: inline void Fill(dual x1,dual x2=NaN,char dir='x') { return mgl_datac_fill(this,x1,x2,dir); } + /// Put value to data element(s) + inline void Put(dual val, long i=-1, long j=-1, long k=-1) + { mgl_datac_put_val(this,val,i,j,k); } + /// Put array to data element(s) + inline void Put(const mglDataA &dat, long i=-1, long j=-1, long k=-1) + { mgl_datac_put_dat(this,&dat,i,j,k); } + /// Set names for columns (slices) inline void SetColumnId(const char *ids) { mgl_datac_set_id(this,ids); } @@ -256,6 +263,13 @@ public: inline mglData Evaluate(const mglData &idat, const mglData &jdat, const mglData &kdat, bool norm=true) const { return mglData(true,mgl_data_evaluate(this,&idat,&jdat,&kdat,norm)); } + /// Find correlation with another data arrays + inline mglDataC Correl(const mglData &dat, const char *dir) const + { return mglDataC(true,mgl_datac_correl(this,&dat,dir)); } + /// Find auto correlation function + inline mglDataC AutoCorrel(const char *dir) const + { return mglDataC(true,mgl_datac_correl(this,this,dir)); } + /// Cumulative summation the data in given direction or directions inline void CumSum(const char *dir) { mgl_datac_cumsum(this,dir); } /// Integrate (cumulative summation) the data in given direction or directions @@ -280,6 +294,12 @@ public: /// Fourier transform inline void FFT(const char *dir) { mgl_datac_fft(this,dir); } + /// Interpolate by cubic spline the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] + inline dual Spline(mreal x,mreal y=0,mreal z=0) const + { return mgl_datac_spline(this, x,y,z); } + /// Interpolate by cubic spline the data to given point x,\a y,\a z which normalized in range [0, 1] + inline dual Spline1(mreal x,mreal y=0,mreal z=0) const + { return mgl_datac_spline(this, x*(nx-1),y*(ny-1),z*(nz-1)); } /// Interpolate by linear function the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] inline dual Linear(mreal x,mreal y=0,mreal z=0) const { return mgl_datac_linear(this,x,y,z); } @@ -371,6 +391,11 @@ protected: return k>0? abs(k @@ -142,6 +142,13 @@ 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); void MGL_EXPORT mgl_datac_modify_vw_(uintptr_t *dat, const char *eq, uintptr_t *vdat, uintptr_t *wdat,int); +/// Put value to data element(s) +void MGL_EXPORT mgl_datac_put_val(HADT dat, dual val, long i, long j, long k); +void MGL_EXPORT mgl_datac_put_val_(uintptr_t *dat, dual *val, int *i, int *j, int *k); +/// Put array to data element(s) +void MGL_EXPORT mgl_datac_put_dat(HADT dat, HCDT val, long i, long j, long k); +void MGL_EXPORT mgl_datac_put_dat_(uintptr_t *dat, uintptr_t *val, int *i, int *j, int *k); + /// Reduce size of the data void MGL_EXPORT mgl_datac_squeeze(HADT dat, long rx,long ry,long rz,long smooth); void MGL_EXPORT mgl_datac_squeeze_(uintptr_t *dat, int *rx,int *ry,int *rz,int *smooth); @@ -192,6 +199,9 @@ void MGL_EXPORT mgl_datac_hankel_(uintptr_t *dat, const char *dir,int); /// Apply Fourier transform void MGL_EXPORT mgl_datac_fft(HADT dat, const char *dir); void MGL_EXPORT mgl_datac_fft_(uintptr_t *dat, const char *dir,int); +/// Find correlation between 2 data arrays +HADT MGL_EXPORT mgl_datac_correl(HCDT dat1, HCDT dat2, const char *dir); +uintptr_t MGL_EXPORT mgl_datac_correl_(uintptr_t dat1, uintptr_t dat2, const char *dir,int); HMDT MGL_EXPORT mgl_datac_real(HCDT dat); uintptr_t MGL_EXPORT mgl_datac_real_(uintptr_t *dat); @@ -208,6 +218,12 @@ dual MGL_EXPORT mgl_datac_linear_(uintptr_t *d, mreal *x,mreal *y,mreal *z); /// 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] dual MGL_EXPORT mgl_datac_linear_ext(HCDT d, mreal x,mreal y,mreal z, dual *dx,dual *dy,dual *dz); dual MGL_EXPORT mgl_datac_linear_ext_(uintptr_t *d, mreal *x,mreal *y,mreal *z, dual *dx,dual *dy,dual *dz); +/// Interpolate by cubic spline the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +dual MGL_EXPORT mgl_datac_spline(HCDT dat, mreal x,mreal y,mreal z); +dual MGL_EXPORT mgl_datac_spline_(uintptr_t *dat, mreal *x,mreal *y,mreal *z); +/// 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] +dual MGL_EXPORT mgl_datac_spline_ext(HCDT dat, mreal x,mreal y,mreal z, dual *dx,dual *dy,dual *dz); +dual MGL_EXPORT mgl_datac_spline_ext_(uintptr_t *dat, mreal *x,mreal *y,mreal *z, dual *dx,dual *dy,dual *dz); #ifdef __cplusplus } diff --git a/include/mgl2/define.h b/include/mgl2/define.h index aa23043..55c6d58 100644 --- a/include/mgl2/define.h +++ b/include/mgl2/define.h @@ -21,9 +21,14 @@ #define _MGL_DEFINE_H_ //----------------------------------------------------------------------------- #include "mgl2/config.h" +#ifndef SWIG #include "mgl2/dllexport.h" +#if MGL_HAVE_OMP +#include +#endif +#endif -#define MGL_VER2 1.3 +#define MGL_VER2 2.0 // minor version of MathGL 2.* (like 1.3 for v.2.1.3) //----------------------------------------------------------------------------- #ifdef WIN32 //_MSC_VER needs this before math.h #define _USE_MATH_DEFINES @@ -46,6 +51,22 @@ #endif #endif +#if defined(_MSC_VER) || defined(__BORLANDC__) +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed long int32_t; +typedef signed long long int64_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned long uint32_t; +typedef unsigned long long uint64_t; +#else +#include +#endif +#if defined(__BORLANDC__) +typedef unsigned long uintptr_t; +#endif + #include #include #include @@ -58,6 +79,8 @@ #endif #if defined(_MSC_VER) +#define collapse(a) // MSVS don't support OpenMP 3.* +#define strtoull _strtoui64 #define hypot _hypot #define getcwd _getcwd #define chdir _chdir // BORLAND has chdir @@ -108,6 +131,10 @@ typedef float mreal; #define mgl_min(a,b) (((a)>(b)) ? (b) : (a)) #define mgl_max(a,b) (((a)>(b)) ? (a) : (b)) #define mgl_isnan(a) ((a)!=(a)) +//#define mgl_isnum(a) ((a)==(a) && 2*(a)!=(a)) +#define mgl_isnum(a) ((a)==(a)) +#define mgl_isfin(a) ((a)-(a)==0.) +#define mgl_isbad(a) ((a)-(a)!=0.) //----------------------------------------------------------------------------- #define SMOOTH_NONE 0 #define SMOOTH_LINE_3 1 @@ -141,6 +168,8 @@ enum{ // types of predefined curvelinear coordinate systems #define MGL_DRAW_FAST 1 // fast, no color interpolation #define MGL_DRAW_NORM 2 // high quality, slower #define MGL_DRAW_LMEM 4 // low memory usage (direct to pixel) +#define MGL_DRAW_DOTS 8 // draw dots instead of primitives +#define MGL_DRAW_NONE 9 // no ouput (for testing only) //----------------------------------------------------------------------------- enum{ // Codes for warnings/messages mglWarnNone = 0,// Everything OK @@ -160,6 +189,10 @@ enum{ // Codes for warnings/messages mglWarnTern, // Axis ranges are incompatible mglWarnNull, // Pointer is NULL mglWarnSpc, // Not enough space for plot + mglScrArg, // Wrong argument(s) in MGL script + mglScrCmd, // Wrong command in MGL script + mglScrLong, // Too long line in MGL script + mglScrStr, // Unbalanced ' in MGL script mglWarnEnd // Maximal number of warnings (must be last) }; //----------------------------------------------------------------------------- @@ -184,7 +217,7 @@ enum{ // Codes for warnings/messages #define MGL_SHOW_POS 0x001000 ///< Switch to show or not mouse click position #define MGL_CLF_ON_UPD 0x002000 ///< Clear plot before Update() #define MGL_NOSUBTICKS 0x004000 ///< Disable subticks drawing (for bounding box) -#define MGL_DIFFUSIVE 0x008000 ///< Use diffusive light instead of specular +//#define MGL_DIFFUSIVE 0x008000 ///< Use diffusive light instead of specular #define MGL_VECT_FRAME 0x010000 ///< Use DrwDat to remember all data of frames #define MGL_REDUCEACC 0x020000 ///< Reduce accuracy of points (to reduc size of output files) #define MGL_PREFERVC 0x040000 ///< Prefer vertex color instead of texture if output format supports @@ -193,66 +226,11 @@ enum{ // Codes for warnings/messages //----------------------------------------------------------------------------- #ifdef __cplusplus //----------------------------------------------------------------------------- +extern float mgl_cos[360]; ///< contain cosine with step 1 degree +//----------------------------------------------------------------------------- #include typedef std::complex dual; //----------------------------------------------------------------------------- -struct mglThreadD -{ - mreal *a; // float* array with parameters or results - const mreal *b,*c,*d,*e; // float* arrays with parameters - const long *p; // long* array with parameters - const void *v; // pointer to data/grapher - int id; // thread id - long n; // total number of iteration - const char *s; -}; -struct mglThreadC -{ - dual *a; // dual* array with parameters or results - const dual *b,*c,*d,*e; // dual* arrays with parameters - const long *p; // long* array with parameters - const void *v; // pointer to data/grapher - int id; // thread id - long n; // total number of iteration - const char *s; -}; -struct mglThreadV -{ - mreal *a; // float* array with parameters or results - dual *aa; // dual* array with parameters or results - const void *b,*c; // float* arrays with parameters - const mreal *d; // float* arrays with parameters - const long *p; // long* array with parameters - const void *v; // pointer to data/grapher - int id; // thread id - long n; // total number of iteration -}; -struct mglThreadT -{ - void *a; // dual* or mreal* array with input or results - double *b; // dual* array with input or results - const long *p; // long* array with parameters - const void *v; // pointer to table/parameter - void **w; // pointer to workspace - int id; // thread id - long n; // total number of iteration - const void *re,*im; -}; -/// Start several thread for the task -void MGL_EXPORT mglStartThread(void *(*func)(void *), void (*post)(mglThreadD *,mreal *), long n, - mreal *a=0, const mreal *b=0, const mreal *c=0, const long *p=0, - const void *v=0, const mreal *d=0, const mreal *e=0, const char *s=0); -void MGL_EXPORT mglStartThreadV(void *(*func)(void *), long n, mreal *a, const void *b=0, - const void *c=0, const long *p=0, const void *v=0, const mreal *d=0); -void MGL_EXPORT mglStartThreadV(void *(*func)(void *), long n, dual *a, const void *b=0, - const void *c=0, const long *p=0, const void *v=0, const mreal *d=0); -void MGL_EXPORT mglStartThreadC(void *(*func)(void *), void (*post)(mglThreadC *,dual *), long n, - dual *a=0, const dual *b=0, const dual *c=0, const long *p=0, - const void *v=0, const dual *d=0, const dual *e=0, const char *s=0); -void MGL_EXPORT mglStartThreadT(void *(*func)(void *), long n, void *a, double *b, const void *v=0, - void **w=0, const long *p=0, const void *re=0, const void *im=0); -MGL_EXPORT extern int mglNumThr; ///< Number of thread for plotting and data handling -//----------------------------------------------------------------------------- extern "C" { #else #include @@ -262,12 +240,16 @@ typedef double _Complex dual; typedef float _Complex dual; #endif #endif +/// Find length of wchar_t string (bypass standard wcslen bug) +size_t MGL_EXPORT mgl_wcslen(const wchar_t *str); /// Get RGB values for given color id or fill by -1 if no one found void MGL_EXPORT mgl_chrrgb(char id, float rgb[3]); /// Check if string contain color id and return its number long MGL_EXPORT mgl_have_color(const char *stl); /// Find symbol in string excluding {} and return its position or NULL const char *mglchr(const char *str, char ch); +/// Find any symbol from chr in string excluding {} and return its position or NULL +const char *mglchrs(const char *str, const char *chr); /// Set number of thread for plotting and data handling void MGL_EXPORT mgl_set_num_thr(int n); void MGL_EXPORT mgl_test_txt(const char *str, ...); @@ -280,16 +262,11 @@ void MGL_EXPORT mgl_strlwr(char *str); void MGL_EXPORT mgl_wcslwr(wchar_t *str); /// Convert wchar_t* string into char* one void MGL_EXPORT mgl_wcstombs(char *dst, const wchar_t *src, int size); +/// Clear internal data for speeding up FFT and Hankel transforms +void MGL_EXPORT mgl_clear_fft(); #ifdef __cplusplus } #endif -//#if MGL_HAVE_PTHREAD && defined(MGL_SRC) -#if MGL_HAVE_PTHREAD -#include -#define MGL_PUSH(a,v,m) {pthread_mutex_lock(&m); a.push_back(v); pthread_mutex_unlock(&m);} -#else -#define MGL_PUSH(a,v,m) a.push_back(v); -#endif //----------------------------------------------------------------------------- #endif //----------------------------------------------------------------------------- diff --git a/include/mgl2/eval.h b/include/mgl2/eval.h index a8d780f..1f5cfc6 100644 --- a/include/mgl2/eval.h +++ b/include/mgl2/eval.h @@ -29,7 +29,7 @@ const int MGL_VS = 'z'-'a'+1; //----------------------------------------------------------------------------- /// Class for evaluating formula specified by the string -class mglFormula // îáúåêò äëÿ ââîäà è âû÷èñëåíèÿ ôîðìóë +class MGL_EXPORT mglFormula // îáúåêò äëÿ ââîäà è âû÷èñëåíèÿ ôîðìóë { public: /// Evaluates the formula for 'x','r'=\a x, 'y','n'=\a y, 'z','t'=\a z, 'u'=\a u diff --git a/include/mgl2/evalc.h b/include/mgl2/evalc.h index 3b0469b..800688b 100644 --- a/include/mgl2/evalc.h +++ b/include/mgl2/evalc.h @@ -23,7 +23,7 @@ #include "mgl2/eval.h" //----------------------------------------------------------------------------- /// Class for evaluating formula specified by the string -class mglFormulaC // ������ ��� ����� � ���������� ������ +class MGL_EXPORT mglFormulaC // ������ ��� ����� � ���������� ������ { public: /// Evaluates the formula for 'x','r'=\a x, 'y','n'=\a y, 'z','t'=\a z, 'u'=\a u diff --git a/include/mgl2/fit.h b/include/mgl2/fit.h index 8ab759a..26c7932 100644 --- a/include/mgl2/fit.h +++ b/include/mgl2/fit.h @@ -19,7 +19,7 @@ ***************************************************************************/ #ifndef _MGL_FIT_H_ #define _MGL_FIT_H_ -#include "mgl2/base.h" +#include "mgl2/abstract.h" //----------------------------------------------------------------------------- #ifdef __cplusplus extern "C" { diff --git a/include/mgl2/fltk.h b/include/mgl2/fltk.h index 75f45a5..bfc9813 100644 --- a/include/mgl2/fltk.h +++ b/include/mgl2/fltk.h @@ -21,7 +21,7 @@ #ifndef _MGL_FLTK_H_ #define _MGL_FLTK_H_ -#include +#include //----------------------------------------------------------------------------- #ifdef __cplusplus extern "C" { @@ -40,7 +40,7 @@ int MGL_EXPORT mgl_fltk_thr(); #include //----------------------------------------------------------------------------- /// Wrapper class for windows displaying graphics -class mglFLTK : public mglWnd +class MGL_EXPORT mglFLTK : public mglWnd { public: mglFLTK(const char *title="MathGL") : mglWnd() @@ -69,7 +69,7 @@ public: class mglCanvas; //----------------------------------------------------------------------------- /// Class is FLTK widget which display MathGL graphics -class Fl_MathGL : public Fl_Widget +class MGL_EXPORT Fl_MathGL : public Fl_Widget { public: Fl_Valuator *tet_val; ///< pointer to external tet-angle validator @@ -91,9 +91,9 @@ public: /// Get pointer to grapher inline HMGL get_graph() { return (HMGL)gr; } /// Set drawing functions and its parameter - inline void set_draw(int (*func)(mglBase *gr, void *par), void *par=0) - { draw_func = func; draw_par = par; } - inline void set_draw(mglDraw *dr) { draw_cl = dr; } + inline void set_draw(int (*func)(mglBase *gr, void *par), void *par) + { if(draw_cl) delete draw_cl; draw_cl=0; draw_func=func; draw_par=par; } + inline void set_draw(mglDraw *dr) { if(draw_cl) delete draw_cl; draw_cl=dr; draw_func=0; } inline void set_draw(int (*dr)(mglGraph *gr)) { set_draw(dr?mgl_draw_graph:0,(void*)dr); } void set_state(bool z, bool r) { zoom = z; rotate = r; } @@ -108,7 +108,7 @@ public: { popup = pmenu; wpar = wdg; vpar = v; } inline void zoom_region(mreal xx1,mreal xx2,mreal yy1, mreal yy2) { x1=xx1; y1=yy1; x2=xx2; y2=yy2; } - + protected: mglCanvas *gr; ///< pointer to grapher void *draw_par; ///< Parameters for drawing function mglCanvasWnd::DrawFunc. @@ -133,7 +133,7 @@ protected: void resize(int x, int y, int w, int h); ///< resize control }; //----------------------------------------------------------------------------- -class Fl_MGLView : public Fl_Window +class MGL_EXPORT Fl_MGLView : public Fl_Window { public: Fl_MathGL *FMGL; ///< Control which draw graphics @@ -155,6 +155,8 @@ public: void setoff_zoom() { setoff(zoom, zoom_bt); } void setoff_rotate(){ setoff(rotate, rotate_bt); } bool is_sshow() { return sshow; } + void adjust() + { mgl_set_size(FMGL->get_graph(),scroll->w(),scroll->h()); FMGL->size(scroll->w(),scroll->h()); update(); } Fl_MGLView(int x, int y, int w, int h, const char *label=0); ~Fl_MGLView(); diff --git a/include/mgl2/font.h b/include/mgl2/font.h index 1a6ab79..ab6bdbe 100644 --- a/include/mgl2/font.h +++ b/include/mgl2/font.h @@ -22,6 +22,7 @@ #define _MGL_FONT_H_ #include "mgl2/define.h" +#include //----------------------------------------------------------------------------- #define MGL_FONT_BOLD 0x01000000 // This value is used binary #define MGL_FONT_ITAL 0x02000000 // This value is used binary @@ -43,14 +44,14 @@ #define MGL_DEF_FONT_NAME "STIX" #endif //----------------------------------------------------------------------------- -struct mglTeXsymb { unsigned kod; const wchar_t *tex; }; +struct MGL_EXPORT mglTeXsymb { unsigned kod; const wchar_t *tex; }; const float mgl_fgen = 4*14; /// Get font color, style and align for internal parser char mglGetStyle(const char *how, int *font, int *align=0); class mglBase; //----------------------------------------------------------------------------- /// Class for font typeface and text plotting procedures -class mglFont +class MGL_EXPORT mglFont { public: mglBase *gr; ///< mglBase class used for drawing characters @@ -94,16 +95,16 @@ public: inline short GetWidth(int s, long j) const { return width[s][j]; } inline float GetFact(int s) const { return fact[s]; } protected: - wchar_t *id; ///< Unicode ID for glyph - unsigned *tr[4]; ///< Shift of glyph description by triangles (for solid font) - unsigned *ln[4]; ///< Shift of glyph description by lines (for wire font) - short *numt[4]; ///< Number of triangles in glyph description (for solid font) - short *numl[4]; ///< Number of lines in glyph description (for wire font) - short *width[4]; ///< Width of glyph for wire font - float fact[4]; ///< Divider for width of glyph - unsigned numg; ///< Number of glyphs - short *Buf; ///< Buffer for glyph descriptions - long numb; ///< Buffer size + wchar_t *id; ///< Unicode ID for glyph + int *tr[4]; ///< Shift of glyph description by triangles (for solid font) + int *ln[4]; ///< Shift of glyph description by lines (for wire font) + short *numt[4]; ///< Number of triangles in glyph description (for solid font) + short *numl[4]; ///< Number of lines in glyph description (for wire font) + short *width[4];///< Width of glyph for wire font + float fact[4]; ///< Divider for width of glyph + unsigned numg; ///< Number of glyphs + short *Buf; ///< Buffer for glyph descriptions + long numb; ///< Buffer size /// Print text string for font specified by integer constant float Puts(const wchar_t *str,int font,int align, float col) const; @@ -121,11 +122,11 @@ protected: unsigned Symbol(char ch) const; private: float get_ptr(long &i,unsigned *str, unsigned **b1, unsigned **b2,float &w1,float &w2, float f1, float f2, int st) const; - bool read_data(const char *fname, float *ff, short *wdt, short *numl, unsigned *posl, short *numt, unsigned *post, unsigned &cur); + bool read_data(const char *fname, float *ff, short *wdt, short *numl, int *posl, short *numt, int *post, std::vector &buf); void main_copy(); - bool read_main(const char *fname, unsigned &cur); + bool read_main(const char *fname, std::vector &buf); void mem_alloc(); - bool read_def(unsigned &cur); + bool read_def(); void draw_ouline(int st, float x, float y, float f, float g, float ww, float ccol) const; }; //----------------------------------------------------------------------------- diff --git a/include/mgl2/glut.h b/include/mgl2/glut.h index 2a23ab1..baabcba 100644 --- a/include/mgl2/glut.h +++ b/include/mgl2/glut.h @@ -30,7 +30,7 @@ HMGL MGL_EXPORT mgl_create_graph_glut(int (*draw)(HMGL gr, void *p), const char #ifdef __cplusplus } //----------------------------------------------------------------------------- -class mglGLUT: public mglGraph +class MGL_EXPORT mglGLUT: public mglGraph { public: mglGLUT(int (*draw)(HMGL gr, void *p), const char *title="MathGL", void *par=0, void (*load)(void *p)=0) : mglGraph(-1) diff --git a/include/mgl2/mgl.h b/include/mgl2/mgl.h index 713823f..2dfe4e6 100644 --- a/include/mgl2/mgl.h +++ b/include/mgl2/mgl.h @@ -21,11 +21,12 @@ #define _MGL_H_ #include "mgl2/mgl_cf.h" +#ifdef __cplusplus #include "mgl2/data.h" #include "mgl2/datac.h" //----------------------------------------------------------------------------- /// Wrapper class for all graphics -class mglGraph +class MGL_EXPORT mglGraph { protected: HMGL gr; @@ -56,7 +57,7 @@ public: inline void SetPlotId(const char *id) { mgl_set_plotid(gr,id); } /// Get name of plot for saving filename inline const char *GetPlotId() { return mgl_get_plotid(gr); } - + /// Set the transparency on/off. inline void Alpha(bool enable) { mgl_set_alpha(gr, enable); } /// Set default value of alpha-channel @@ -68,7 +69,7 @@ public: inline void Light(bool enable) { mgl_set_light(gr, enable); } /// Switch on/off the specified light source. inline void Light(int n,bool enable) { mgl_set_light_n(gr, n, enable); } - /// Use diffusive light (only for local light sources) + /// Use diffusive light (only for local light sources) -- OBSOLETE inline void SetDifLight(bool dif) { mgl_set_light_dif(gr, dif); } /// Add a light source. inline void AddLight(int n, mglPoint p, char col='w', double bright=0.5, double ap=0) @@ -77,6 +78,8 @@ public: { mgl_add_light_loc(gr, n, r.x, r.y, r.z, p.x, p.y, p.z, col, bright, ap); } /// Set ambient light brightness inline void SetAmbient(double i) { mgl_set_ambbr(gr, i); } + /// Set diffusive light brightness + inline void SetDiffuse(double i) { mgl_set_difbr(gr, i); } /// Set the fog distance or switch it off (if d=0). inline void Fog(double d, double dz=0.25) { mgl_set_fog(gr, d, dz); } @@ -90,7 +93,7 @@ public: inline void SetMeshNum(int num) { mgl_set_meshnum(gr, num); } /// Set number of visible faces (use 0 to draw all of them) inline void SetFaceNum(int num) { mgl_set_facenum(gr, num); } - + /// Set cutting for points outside of bounding box inline void SetCut(bool cut) { mgl_set_cut(gr, cut); } /// Set additional cutting box @@ -124,6 +127,15 @@ public: /// Set default color scheme inline void SetDefScheme(const char *sch) { mgl_set_def_sch(gr, sch); } + /// Sets RGB values for color with given id + static inline void SetColor(char id, double r, double g, double b) { mgl_set_color(id, r, g, b); } + /// Set mask for face coloring as array of type 'unsigned char[8]' + static inline void SetMask(char id, const char *mask) { mgl_set_mask(id, mask); } + /// Set mask for face coloring as uint64_t number + static inline void SetMask(char id, uint64_t mask) { mgl_set_mask_val(id, mask); } + /// Set default mask rotation angle + inline void SetMaskAngle(int angle) { mgl_set_mask_angle(gr, angle); } + /// Get last warning code inline int GetWarn() { return mgl_get_warn(gr);} /// Set warning code ant fill message @@ -224,7 +236,7 @@ public: /// Set to draw tick labels at axis origin inline void SetOriginTick(bool enable=true) { mgl_set_flag(gr,!enable, MGL_NO_ORIGIN); } - + /// Put further plotting in some region of whole frame. inline void SubPlot(int nx,int ny,int m,const char *style="<>_^", double dx=0, double dy=0) { mgl_subplot_d(gr, nx, ny, m, style, dx, dy); } @@ -252,7 +264,7 @@ public: inline void Push() { mgl_mat_push(gr); } /// Pop transformation matrix from stack inline void Pop() { mgl_mat_pop(gr); } - + /// Add title for current subplot/inplot inline void Title(const char *title,const char *stl="",double size=-2) { mgl_title(gr,title,stl,size); } @@ -283,6 +295,8 @@ public: inline void SetQuality(int qual=MGL_DRAW_NORM) { mgl_set_quality(gr, qual); } /// Get plot quality inline int GetQuality() { return mgl_get_quality(gr); } + /// Set drawing region for Quality&4 + inline void SetDrawReg(long nx=1, long ny=1, long m=0) { mgl_set_draw_reg(gr,nx,ny,m); } /// Start group of objects inline void StartGroup(const char *name) { mgl_start_group(gr, name); } /// End group of objects @@ -347,8 +361,11 @@ public: inline void WritePRC(const char *fname,const char *descr="",bool make_pdf=true) { mgl_write_prc(gr, fname, descr, make_pdf); } /// Export in JSON format suitable for later drawing by JavaScript - inline void WriteJSON(const char *fname,const char *descr="") - { mgl_write_json(gr, fname, descr); } + inline void WriteJSON(const char *fname,const char *descr="",bool force_z=false) + { if(force_z) mgl_write_json_z(gr, fname, descr); + else mgl_write_json(gr, fname, descr); } + /// Return string of JSON data suitable for later drawing by JavaScript + inline const char *GetJSON() { return mgl_get_json(gr); } /// Force preparing the image. It can be useful for OpenGL mode mostly. inline void Finish() { mgl_finish(gr); } @@ -368,7 +385,7 @@ public: inline void SetFrame(int i) { mgl_set_frame(gr, i); } /// Append drawing data from i-th frame (work if MGL_VECT_FRAME is set on) inline void ShowFrame(int i){ mgl_show_frame(gr, i); } - + /// Start write frames to cinema using GIF format inline void StartGIF(const char *fname, int ms=100) { mgl_start_gif(gr, fname,ms); } @@ -440,6 +457,7 @@ public: /// Clear up the frame inline void Clf(double r, double g, double b) { mgl_clf_rgb(gr, r, g, b); } + inline void Clf(char col) { mgl_clf_chr(gr, col); } inline void Clf() { mgl_clf(gr); } /// Clear unused points and primitives. Useful only in combination with SetFaceNum(). inline void ClearUnused() { mgl_clear_unused(gr); } @@ -628,6 +646,13 @@ public: /// Draw chart for data a inline void Chart(const mglDataA &a, const char *colors="", const char *opt="") { mgl_chart(gr, &a, colors,opt); } + + /// Draw Open-High-Low-Close (OHLC) diagram + inline void OHLC(const mglDataA &x, const mglDataA &open, const mglDataA &high, const mglDataA &low, const mglDataA &close, const char *pen="", const char *opt="") + { mgl_ohlc_x(gr, &x, &open,&high,&low,&close,pen,opt); } + inline void OHLC(const mglDataA &open, const mglDataA &high, const mglDataA &low, const mglDataA &close, const char *pen="", const char *opt="") + { mgl_ohlc(gr, &open,&high,&low,&close,pen,opt); } + /// Draw box-plot (special 5-value plot used in statistic) inline void BoxPlot(const mglDataA &x, const mglDataA &y, const char *pen="", const char *opt="") { mgl_boxplot_xy(gr, &x, &y, pen,opt); } @@ -708,7 +733,7 @@ public: { mgl_table(gr, x, y, &val, text, fnt, opt); } inline void Table(double x, double y, const mglDataA &val, const wchar_t *text, const char *fnt="#|", const char *opt="") { mgl_tablew(gr, x, y, &val, text, fnt, opt); } - + /// Draw tube with radius r around curve {x,y,z} inline void Tube(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &r, const char *pen="", const char *opt="") { mgl_tube_xyzr(gr, &x, &y, &z, &r, pen, opt); } @@ -1060,9 +1085,12 @@ public: /// Draw dots in points {x,y,z}. inline void Dots(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") { mgl_dots(gr, &x, &y, &z, sch, opt); } - /// Draw semitransparent dots in points {x,y,z} with alpha a. + /// Draw semitransparent dots in points {x,y,z} with specified alpha a. inline void Dots(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *sch="", const char *opt="") { mgl_dots_a(gr, &x, &y, &z, &a, sch, opt); } + /// Draw semitransparent dots in points {x,y,z} with specified color c and alpha a. + inline void Dots(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &c, const mglDataA &a, const char *sch="", const char *opt="") + { mgl_dots_ca(gr, &x, &y, &z, &c, &a, sch, opt); } /// Draw surface reconstructed for points in arrays {x,y,z}. inline void Crust(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") { mgl_crust(gr, &x, &y, &z, sch, opt); } @@ -1140,11 +1168,19 @@ public: { mgl_datac_fill_eq(gr, &u, eq, &v, 0, opt); } inline void Fill(mglDataC &u, const char *eq, const mglDataA &v, const mglDataA &w, const char *opt="") { mgl_datac_fill_eq(gr, &u, eq, &v, &w, opt); } - + + /// Fill dat by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in axis range + inline void Refill(mglData &dat, const mglDataA &xdat, const mglDataA &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,&dat,&xdat,0,0,&vdat,sl,opt); } + inline void Refill(mglData &dat, const mglDataA &xdat, const mglDataA &ydat, const mglDataA &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,&dat,&xdat,&ydat,0,&vdat,sl,opt); } + inline void Refill(mglData &dat, const mglDataA &xdat, const mglDataA &ydat, const mglDataA &zdat, const mglDataA &vdat, const char *opt="") + { mgl_data_refill_gr(gr,&dat,&xdat,&ydat,&zdat,&vdat,-1,opt); } + /// Set the data by triangulated surface values assuming x,y,z in range [Min, Max] inline void DataGrid(mglData &d, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *opt="") { mgl_data_grid(gr,&d,&x,&y,&z,opt); } - + /// Make histogram (distribution) of data. This function do not plot data. inline mglData Hist(const mglDataA &x, const mglDataA &a, const char *opt="") { return mglData(true, mgl_hist_x(gr, &x, &a, opt)); } @@ -1161,8 +1197,9 @@ public: // inline void TextureColor(bool){} // NOTE: Add later -- IDTF }; //----------------------------------------------------------------------------- +#ifndef SWIG /// Structure for handling named mglData (used by mglParse class). -class mglVar : public mglData +class MGL_EXPORT mglVar : public mglData { public: std::wstring s; ///< Data name @@ -1171,7 +1208,7 @@ public: mglVar *prev; ///< Pointer to previous instance in list bool temp; ///< This is temporary variable void (*func)(void *); ///< Callback function for destroying - + mglVar():mglData() { o=0; next=prev=0; func=0; temp=false; } virtual ~mglVar() { @@ -1194,9 +1231,10 @@ public: if(next) next->prev = this; } }; +#endif //----------------------------------------------------------------------------- /// Wrapper class for MGL parsing -class mglParse +class MGL_EXPORT mglParse { HMPR pr; public: @@ -1259,7 +1297,7 @@ public: { return mglData(true,mgl_parser_calc(pr,formula)); } inline mglData Calc(const wchar_t *formula) { return mglData(true,mgl_parser_calcw(pr,formula)); } - + /// Find variable with given name or add a new one /// NOTE !!! You must not delete obtained data arrays !!! inline mglVar *AddVar(const char *name) @@ -1280,7 +1318,7 @@ public: }; //----------------------------------------------------------------------------- /// Wrapper class expression evaluating -class mglExpr +class MGL_EXPORT mglExpr { HMEX ex; public: @@ -1302,8 +1340,9 @@ public: #endif }; //----------------------------------------------------------------------------- +#ifndef SWIG /// Wrapper class expression evaluating -class mglExprC +class MGL_EXPORT mglExprC { HAEX ex; public: @@ -1319,11 +1358,12 @@ public: var['x'-'a']=x; var['y'-'a']=y; var['z'-'a']=z; var['u'-'a']=u; var['v'-'a']=v; var['w'-'a']=w; return mgl_cexpr_eval_v(ex,var); } -#ifndef SWIG /// Return value of expression for given variables inline dual Eval(dual var[26]) { return mgl_cexpr_eval_v(ex,var); } -#endif }; +#endif +//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- #endif +#endif \ No newline at end of file diff --git a/include/mgl2/mpi.h b/include/mgl2/mpi.h index 4c456c9..f874594 100644 --- a/include/mgl2/mpi.h +++ b/include/mgl2/mpi.h @@ -37,8 +37,9 @@ void MGL_EXPORT mgl_mpi_recv_(uintptr_t *gr, int *id); #include "mgl2/mgl.h" //----------------------------------------------------------------------------- /// Wrapper class for all graphics -class mglGraphMPI:public mglGraph +class MGL_EXPORT mglGraphMPI:public mglGraph { +public: inline mglGraphMPI(int kind=0, int width=600, int height=400):mglGraph(kind,width,height){} inline mglGraphMPI(const mglGraph &graph):mglGraph(graph){} inline mglGraphMPI(HMGL graph):mglGraph(graph){} diff --git a/include/mgl2/opengl.h b/include/mgl2/opengl.h index 4b2c7ea..cd99788 100644 --- a/include/mgl2/opengl.h +++ b/include/mgl2/opengl.h @@ -29,20 +29,20 @@ public: ~mglCanvasGL(); void SetQuality(int =0) { Quality=2; } - void Finish(bool fast=true); + void Finish(); void SetSize(int ,int ) {} void View(mreal tetX,mreal tetY,mreal tetZ); void Zoom(mreal x1, mreal y1, mreal x2, mreal y2); - int NewFrame(); +/* int NewFrame(); void EndFrame(); - void DelFrame(long ){} - + void DelFrame(long ){}*/ + bool Alpha(bool enable); void Fog(mreal d, mreal dz=0.25); bool Light(bool enable); void Light(int n, bool enable); void AddLight(int n,mglPoint r,mglPoint d, char c='w', mreal bright=0.5, mreal ap=0); - void Clf(mglColor Back=WC); + void Clf(mglColor Back=NC); protected: // provide fastest variant for usual points (not glyphs or marks) @@ -50,14 +50,17 @@ protected: void trig_draw(long n1, long n2, long n3); void quad_draw(long n1, long n2, long n3, long n4); // variant for glyphs or marks - void line_draw(const mglPnt &p1, const mglPnt &p2, mglDrawReg *d); - void trig_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool anorm, mglDrawReg *d); - void quad_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, const mglPnt &p4, mglDrawReg *d); - void pnt_draw(const mglPnt &p, mglDrawReg *d); + void line_draw(const mglPnt &p1, const mglPnt &p2, const mglDrawReg *d); + void trig_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool anorm, const mglDrawReg *d); + void quad_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, const mglPnt &p4, const mglDrawReg *d); + void pnt_draw(const mglPnt &p, const mglDrawReg *d); + void mark_draw(const mglPnt &q, char type, mreal size, mglDrawReg *d); unsigned char **GetRGBLines(long &w, long &h, unsigned char *&f, bool solid=true); - void LightScale(); + void LightScale(const mglMatrix *M); void set_pen(unsigned style,mreal width); + + void gl_clf(mglColor Back=WC); }; //----------------------------------------------------------------------------- #endif diff --git a/include/mgl2/other.h b/include/mgl2/other.h index 7de2dfb..3582a86 100644 --- a/include/mgl2/other.h +++ b/include/mgl2/other.h @@ -19,7 +19,7 @@ ***************************************************************************/ #ifndef _MGL_OTHER_H_ #define _MGL_OTHER_H_ -#include "mgl2/base.h" +#include "mgl2/abstract.h" //----------------------------------------------------------------------------- #ifdef __cplusplus extern "C" { @@ -61,9 +61,12 @@ void MGL_EXPORT mgl_tricont_xyc_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, u /// Draw dots in points {x,y,z}. void MGL_EXPORT mgl_dots(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); void MGL_EXPORT mgl_dots_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); -/// Draw semitransparent dots in points {x,y,z} with alpha a. +/// Draw semitransparent dots in points {x,y,z} with specified alpha a. void MGL_EXPORT mgl_dots_a(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt); void MGL_EXPORT mgl_dots_a_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, const char *opt,int,int); +/// Draw semitransparent dots in points {x,y,z} with specified color c and alpha a. +void MGL_EXPORT mgl_dots_ca(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT c, HCDT a, const char *sch, const char *opt); +void MGL_EXPORT mgl_dots_ca_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, uintptr_t *a, const char *sch, const char *opt,int,int); /// Draw surface reconstructed for points in arrays {x,y,z}. void MGL_EXPORT mgl_crust(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); diff --git a/include/mgl2/parser.h b/include/mgl2/parser.h index 2a451b5..3c8056e 100644 --- a/include/mgl2/parser.h +++ b/include/mgl2/parser.h @@ -69,11 +69,11 @@ struct mglFunc { long pos; int narg; -// std::wstring func; - wchar_t func[64]; + std::wstring func; +// wchar_t func[64]; mglFunc(long p, const wchar_t *f); mglFunc(const mglFunc &f); - mglFunc() { pos=narg=-1; *func=0; } + mglFunc() { pos=narg=-1; } }; //----------------------------------------------------------------------------- /// Structure for stack of functions and its arguments. @@ -98,7 +98,6 @@ public: bool AllowFileIO; ///< Allow reading/saving files bool Stop; ///< Stop command was. Flag prevent further execution mglCommand *Cmd; ///< Table of MGL commands (can be changed by user). It MUST be sorted by 'name'!!! - wchar_t *op1, *op2; ///< Buffer for options (are used if out!=NULL) long InUse; ///< Smart pointer (number of users) mglParser(bool setsize=false); @@ -113,7 +112,7 @@ public: /// Parse and execute the unicode string of MGL script inline int Parse(HMGL gr, const wchar_t *str, long pos=0) { mglGraph GR(gr); return Parse(&GR,str,pos); } - int Parse(mglGraph *gr, const wchar_t *str, long pos=0); + int Parse(mglGraph *gr, std::wstring str, long pos=0); /// Execute MGL script file fname inline void Execute(HMGL gr, FILE *fp, bool print=false) { mglGraph GR(gr); Execute(&GR,fp,print); } @@ -133,7 +132,7 @@ public: /// Scan for functions (use NULL for reset) void ScanFunc(const wchar_t *line); /// Check if name is function and return its address (or 0 if no) - long IsFunc(const wchar_t *name, int *narg=0); + long IsFunc(const std::wstring &name, int *narg=0); /// Find variable or return 0 if absent mglVar *FindVar(const char *name); mglVar *FindVar(const wchar_t *name); @@ -176,21 +175,20 @@ private: int for_addr; ///< Flag for saving address in variable (for_addr-1) bool for_br; ///< Break is switched on (skip all comands until 'next') - /// Length of parameter strings - size_t GetParLen(); - size_t GetParLen(const wchar_t *str); /// Parse command - int Exec(mglGraph *gr, const wchar_t *com, long n, mglArg *a, const wchar_t *var, const wchar_t *opt); + int Exec(mglGraph *gr, const wchar_t *com, long n, mglArg *a, const std::wstring &var, const wchar_t *opt); /// Fill arguments a from strings - void FillArg(mglGraph *gr, int n, wchar_t **arg, mglArg *a); + void FillArg(mglGraph *gr, int n, std::wstring *arg, mglArg *a); /// PreExecute stage -- parse some commands and create variables - int PreExec(mglGraph *gr, long n, wchar_t **arg, mglArg *a); + int PreExec(mglGraph *gr, long n, std::wstring *arg, mglArg *a); /// Execute program-flow control commands - int FlowExec(mglGraph *gr, const wchar_t *com, long n, mglArg *a); + int FlowExec(mglGraph *gr, const std::wstring &com, long n, mglArg *a); /// Parse and execute the unicode string of MGL script - int ParseDat(mglGraph *gr, const wchar_t *str, mglData &res); + int ParseDat(mglGraph *gr, std::wstring str, mglData &res); + /// Define '$' parameters or start for loop + int ParseDef(std::wstring &str); /// Parse $N arguments - void PutArg(const wchar_t *string, wchar_t *str, bool def); + void PutArg(std::wstring &str, bool def); /// In skip mode bool inline ifskip() { return (if_pos>0 && !(if_stack[if_pos-1]&1)); } bool inline skip() { return (Skip || ifskip() || for_br); } diff --git a/include/mgl2/pde.h b/include/mgl2/pde.h new file mode 100644 index 0000000..8c37983 --- /dev/null +++ b/include/mgl2/pde.h @@ -0,0 +1,56 @@ +/*************************************************************************** + * data_cf.h is part of Math Graphic Library + * Copyright (C) 2007-2012 Alexey Balakin * + * * + * 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. * + ***************************************************************************/ +#ifndef _MGL_PDE_H_ +#define _MGL_PDE_H_ +//----------------------------------------------------------------------------- +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif + +/// Saves result of PDE solving (|u|^2) for "Hamiltonian" ham with initial conditions ini +HMDT MGL_EXPORT mgl_pde_solve(HMGL gr, const char *ham, HCDT ini_re, HCDT ini_im, mreal dz, mreal k0,const char *opt); +uintptr_t MGL_EXPORT mgl_pde_solve_(uintptr_t* gr, const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, mreal *dz, mreal *k0,const char *opt,int,int); +/// Saves result of PDE solving for "Hamiltonian" ham with initial conditions ini along a curve ray (must have nx>=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +HMDT MGL_EXPORT mgl_qo2d_solve(const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy); +HMDT MGL_EXPORT mgl_qo2d_func(dual (*ham)(mreal u, mreal x, mreal y, mreal px, mreal py, void *par), void *par, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy); +uintptr_t MGL_EXPORT mgl_qo2d_solve_(const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, uintptr_t* ray, mreal *r, mreal *k0, uintptr_t* xx, uintptr_t* yy, int); +/// Saves result of PDE solving for "Hamiltonian" ham with initial conditions ini along a curve ray (must have nx>=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +HMDT MGL_EXPORT mgl_qo3d_solve(const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz); +HMDT MGL_EXPORT mgl_qo3d_func(dual (*ham)(mreal u, mreal x, mreal y, mreal z, mreal px, mreal py, mreal pz, void *par), void *par, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz); +uintptr_t MGL_EXPORT mgl_qo3d_solve_(const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, uintptr_t* ray, mreal *r, mreal *k0, uintptr_t* xx, uintptr_t* yy, uintptr_t* zz, int); +/// Saves result of ODE solving of n equations with right part func and initial conditions x0 over time interval [0,tmax] with time step dt +HMDT MGL_EXPORT mgl_ode_solve(void (*func)(const mreal *x, mreal *dx, void *par), int n, mreal *x0, mreal dt, mreal tmax, void *par); +/// Finds ray with starting point r0, p0 (and prepares ray data for mgl_qo2d_solve) +HMDT MGL_EXPORT mgl_ray_trace(const char *ham, mreal x0, mreal y0, mreal z0, mreal px, mreal py, mreal pz, mreal dt, mreal tmax); +uintptr_t MGL_EXPORT mgl_ray_trace_(const char *ham, mreal *x0, mreal *y0, mreal *z0, mreal *px, mreal *py, mreal *pz, mreal *dt, mreal *tmax,int); +/// Calculate Jacobian determinant for D{x(u,v), y(u,v)} = dx/du*dy/dv-dx/dv*dy/du +HMDT MGL_EXPORT mgl_jacobian_2d(HCDT x, HCDT y); +uintptr_t MGL_EXPORT mgl_jacobian_2d_(uintptr_t* x, uintptr_t* y); +/// Calculate Jacobian determinant for D{x(u,v,w), y(u,v,w), z(u,v,w)} +HMDT MGL_EXPORT mgl_jacobian_3d(HCDT x, HCDT y, HCDT z); +uintptr_t MGL_EXPORT mgl_jacobian_3d_(uintptr_t* x, uintptr_t* y, uintptr_t* z); + +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/plot.h b/include/mgl2/plot.h index 8936917..c022493 100644 --- a/include/mgl2/plot.h +++ b/include/mgl2/plot.h @@ -19,7 +19,7 @@ ***************************************************************************/ #ifndef _MGL_1D_H_ #define _MGL_1D_H_ -#include "mgl2/base.h" +#include "mgl2/abstract.h" //----------------------------------------------------------------------------- #ifdef __cplusplus extern "C" { @@ -98,7 +98,7 @@ void MGL_EXPORT mgl_stem_xy(HMGL graph, HCDT x, HCDT y, const char *pen, const c void MGL_EXPORT mgl_stem_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int,int); /// Draw vertical lines from points {x,y} with x in x-axis range to axis plane void MGL_EXPORT mgl_stem(HMGL graph, HCDT y, const char *pen, const char *opt); -void MGL_EXPORT mgl_stem_(uintptr_t *graph, uintptr_t *y, const char *pen, const char *opt,int,int); +void MGL_EXPORT mgl_stem_(uintptr_t *graph, uintptr_t *y, const char *pen, const char *opt,int,int); /// Draw stairs for points in arrays {x,y,z} void MGL_EXPORT mgl_step_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt); @@ -108,7 +108,7 @@ void MGL_EXPORT mgl_step_xy(HMGL graph, HCDT x, HCDT y, const char *pen, const c void MGL_EXPORT mgl_step_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int,int); /// Draw stairs for points in arrays {x,y} with x in x-axis range void MGL_EXPORT mgl_step(HMGL graph, HCDT y, const char *pen, const char *opt); -void MGL_EXPORT mgl_step_(uintptr_t *graph, uintptr_t *y, const char *pen, const char *opt,int,int); +void MGL_EXPORT mgl_step_(uintptr_t *graph, uintptr_t *y, const char *pen, const char *opt,int,int); /// Draw vertical bars from points {x,y,z} to axis plane void MGL_EXPORT mgl_bars_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt); @@ -118,14 +118,21 @@ void MGL_EXPORT mgl_bars_xy(HMGL graph, HCDT x, HCDT y, const char *pen, const c void MGL_EXPORT mgl_bars_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int,int); /// Draw vertical bars from points {x,y} with x in x-axis range to axis plane void MGL_EXPORT mgl_bars(HMGL graph, HCDT y, const char *pen, const char *opt); -void MGL_EXPORT mgl_bars_(uintptr_t *graph, uintptr_t *y, const char *pen, const char *opt,int,int); +void MGL_EXPORT mgl_bars_(uintptr_t *graph, uintptr_t *y, const char *pen, const char *opt,int,int); /// Draw horizontal bars from points {v,y} to axis plane void MGL_EXPORT mgl_barh_yx(HMGL graph, HCDT y, HCDT v, const char *pen, const char *opt); void MGL_EXPORT mgl_barh_yx_(uintptr_t *graph, uintptr_t *y, uintptr_t *v, const char *pen, const char *opt,int,int); /// Draw horizontal bars from points {v,y} with y in y-axis range to axis plane void MGL_EXPORT mgl_barh(HMGL graph, HCDT v, const char *pen, const char *opt); -void MGL_EXPORT mgl_barh_(uintptr_t *graph, uintptr_t *v, const char *pen, const char *opt,int,int); +void MGL_EXPORT mgl_barh_(uintptr_t *graph, uintptr_t *v, const char *pen, const char *opt,int,int); + +/// Draw Open-High-Low-Close (OHLC) diagram +void MGL_EXPORT mgl_ohlc_x(HMGL graph, HCDT x, HCDT open, HCDT high, HCDT low, HCDT close, const char *pen, const char *opt); +void MGL_EXPORT mgl_ohlc_x_(uintptr_t *graph, uintptr_t *x, uintptr_t *open, uintptr_t *high, uintptr_t *low, uintptr_t *close, const char *pen, const char *opt,int,int); +/// Draw Open-High-Low-Close (OHLC) diagram with x in x-axis range +void MGL_EXPORT mgl_ohlc(HMGL graph, HCDT open, HCDT high, HCDT low, HCDT close, const char *pen, const char *opt); +void MGL_EXPORT mgl_ohlc_(uintptr_t *graph, uintptr_t *open, uintptr_t *high, uintptr_t *low, uintptr_t *close, const char *pen, const char *opt,int,int); /// Draw chart for data a void MGL_EXPORT mgl_chart(HMGL graph, HCDT a, const char *col, const char *opt); diff --git a/include/mgl2/prim.h b/include/mgl2/prim.h index 68f5fc9..fc9dcb6 100644 --- a/include/mgl2/prim.h +++ b/include/mgl2/prim.h @@ -19,7 +19,7 @@ ***************************************************************************/ #ifndef _MGL_PRIM_H_ #define _MGL_PRIM_H_ -#include "mgl2/base.h" +#include "mgl2/abstract.h" //----------------------------------------------------------------------------- #ifdef __cplusplus extern "C" { diff --git a/include/mgl2/qmathgl.h b/include/mgl2/qmathgl.h index 9c9459e..531ccd7 100644 --- a/include/mgl2/qmathgl.h +++ b/include/mgl2/qmathgl.h @@ -55,12 +55,10 @@ public: { setGraph(GR->Self()); } inline HMGL getGraph() { return (HMGL)gr; } /// Set drawing functions and its parameter - inline void setDraw(int (*func)(mglBase *gr, void *par), void *par=0) - { draw_func = func; draw_par = par; emit usePrimChanged(draw_func || draw); } - inline void setDraw(mglDraw *dr) - { draw = dr; emit usePrimChanged(draw_func || draw); } - inline void setDraw(int (*draw)(mglGraph *gr)) - { setDraw(draw?mgl_draw_graph:0,(void*)draw); } + void setDraw(int (*func)(mglBase *gr, void *par), void *par); + void setDraw(mglDraw *dr); + inline void setDraw(int (*func)(mglGraph *gr)) + { setDraw(func?mgl_draw_graph:0,(void*)func); } inline void zoomRegion(mreal xx1,mreal xx2,mreal yy1, mreal yy2) { x1=xx1; y1=yy1; x2=xx2; y2=yy2; } @@ -90,6 +88,7 @@ public slots: void imgSize(int w, int h); ///< Set image size void setViewYZ(bool v); ///< Switch on/off rotation around Y and Z axis + void setCustZoom(bool a); ///< Switch on/off using custom zoom void setZoom(bool z); ///< Switch on/off mouse zooming void setRotate(bool r); ///< Switch on/off mouse rotation void zoomIn(); ///< Zoom in graphics @@ -155,7 +154,9 @@ signals: void objChanged(int objId); ///< User double-click to select object/line void refreshData(); void doubleClick(int id); ///< Double mouse click by object with id - void askStyle(int id); ///< Update style + void askStyle(int id); ///< Update style + /// user can define its own zooming function + void customZoom(double x1, double y1, double x2, double y2, double tet, double phi, double per); protected: void paintEvent(QPaintEvent *); @@ -177,6 +178,7 @@ protected: double per; ///< Value of perspective ( must be in [0,1) ) bool alpha; ///< Transparency state bool light; ///< Lightning state + bool custZoom; ///< Use custom zoom instead of built in bool zoom; ///< Mouse zoom state bool grid; ///< Grid drawing state bool rotate; ///< Mouse rotation state @@ -193,8 +195,9 @@ private: }; //----------------------------------------------------------------------------- /// Class for drawing the MGL script -struct mglDrawScript : public mglDraw +class MGL_EXPORT mglDrawScript : public mglDraw { +public: HMPR par; ///< Parser to be used QString text; ///< Script to be drawn long line; ///< Line which will be highlited diff --git a/include/mgl2/qt.h b/include/mgl2/qt.h index fb7f7c1..3f14d09 100644 --- a/include/mgl2/qt.h +++ b/include/mgl2/qt.h @@ -19,7 +19,7 @@ ***************************************************************************/ #ifndef _MGL_QT_H_ #define _MGL_QT_H_ -#include +#include //----------------------------------------------------------------------------- #ifdef __cplusplus extern "C" { @@ -36,7 +36,7 @@ int MGL_EXPORT mgl_qt_run_(); #include //----------------------------------------------------------------------------- /// Wrapper class for windows displaying graphics -class mglQT : public mglWnd +class MGL_EXPORT mglQT : public mglWnd { public: mglQT(const char *title="MathGL") : mglWnd() diff --git a/include/mgl2/surf.h b/include/mgl2/surf.h index 59d668c..c6dc3c3 100644 --- a/include/mgl2/surf.h +++ b/include/mgl2/surf.h @@ -19,7 +19,7 @@ ***************************************************************************/ #ifndef _MGL_SURF_H_ #define _MGL_SURF_H_ -#include "mgl2/base.h" +#include "mgl2/abstract.h" //----------------------------------------------------------------------------- #ifdef __cplusplus extern "C" { diff --git a/include/mgl2/thread.h b/include/mgl2/thread.h new file mode 100644 index 0000000..618d04d --- /dev/null +++ b/include/mgl2/thread.h @@ -0,0 +1,86 @@ +/*************************************************************************** + * thread.h is part of Math Graphic Library + * Copyright (C) 2007-2012 Alexey Balakin * + * * + * 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. * + ***************************************************************************/ +#ifndef _MGL_THREAD_H_ +#define _MGL_THREAD_H_ +#include "mgl2/define.h" +//----------------------------------------------------------------------------- +#if MGL_HAVE_PTHREAD +#include +#endif +//----------------------------------------------------------------------------- +struct mglThreadD +{ + mreal *a; // float* array with parameters or results + const mreal *b,*c,*d,*e; // float* arrays with parameters + const long *p; // long* array with parameters + const void *v; // pointer to data/grapher + int id; // thread id + long n; // total number of iteration + const char *s; +}; +struct mglThreadC +{ + dual *a; // dual* array with parameters or results + const dual *b,*c,*d,*e; // dual* arrays with parameters + const long *p; // long* array with parameters + const void *v; // pointer to data/grapher + int id; // thread id + long n; // total number of iteration + const char *s; +}; +struct mglThreadV +{ + mreal *a; // float* array with parameters or results + dual *aa; // dual* array with parameters or results + const void *b,*c; // float* arrays with parameters + const mreal *d; // float* arrays with parameters + const long *p; // long* array with parameters + const void *v; // pointer to data/grapher + int id; // thread id + long n; // total number of iteration +}; +struct mglThreadT +{ + void *a; // dual* or mreal* array with input or results + double *b; // dual* array with input or results + const long *p; // long* array with parameters + const void *v; // pointer to table/parameter + void **w; // pointer to workspace + int id; // thread id + long n; // total number of iteration + const void *re,*im; +}; +/// Start several thread for the task +void MGL_EXPORT mglStartThread(void *(*func)(void *), void (*post)(mglThreadD *,mreal *), long n, + mreal *a=0, const mreal *b=0, const mreal *c=0, const long *p=0, + const void *v=0, const mreal *d=0, const mreal *e=0, const char *s=0); +void MGL_EXPORT mglStartThreadV(void *(*func)(void *), long n, mreal *a, const void *b=0, + const void *c=0, const long *p=0, const void *v=0, const mreal *d=0); +void MGL_EXPORT mglStartThreadV(void *(*func)(void *), long n, dual *a, const void *b=0, + const void *c=0, const long *p=0, const void *v=0, const mreal *d=0); +void MGL_EXPORT mglStartThreadC(void *(*func)(void *), void (*post)(mglThreadC *,dual *), long n, + dual *a=0, const dual *b=0, const dual *c=0, const long *p=0, + const void *v=0, const dual *d=0, const dual *e=0, const char *s=0); +void MGL_EXPORT mglStartThreadT(void *(*func)(void *), long n, void *a, double *b, const void *v=0, + void **w=0, const long *p=0, const void *re=0, const void *im=0); +MGL_EXPORT extern int mglNumThr; ///< Number of thread for plotting and data handling +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/include/mgl2/type.h b/include/mgl2/type.h index fb803ed..d7c01de 100644 --- a/include/mgl2/type.h +++ b/include/mgl2/type.h @@ -19,9 +19,7 @@ ***************************************************************************/ #ifndef _MGL_TYPE_H_ #define _MGL_TYPE_H_ -#if !defined(_MSC_VER) && !defined(__BORLANDC__) -#include -#endif + #include "mgl2/define.h" //----------------------------------------------------------------------------- const mreal Pi = M_PI; @@ -34,7 +32,7 @@ const mreal mgl_min_a = 1./256; #define MGL_SET_RGB(p,rr,gg,bb) {p.r=(rr);p.g=(gg);p.b=(bb);} //----------------------------------------------------------------------------- /// Class for point in 3D space -struct mglPoint +struct MGL_EXPORT mglPoint { mreal x,y,z,c; mglPoint(mreal X=0,mreal Y=0,mreal Z=0,mreal C=0){x=X;y=Y;z=Z;c=C;} @@ -88,7 +86,7 @@ inline mreal mgl_norm(const mglPoint &p) #endif //----------------------------------------------------------------------------- /// Class for RGBA color -struct mglColor +struct MGL_EXPORT mglColor { float r; ///< Red component of color float g; ///< Green component of color diff --git a/include/mgl2/vect.h b/include/mgl2/vect.h index e45e4c2..fe61bc8 100644 --- a/include/mgl2/vect.h +++ b/include/mgl2/vect.h @@ -19,7 +19,7 @@ ***************************************************************************/ #ifndef _MGL_VECT_H_ #define _MGL_VECT_H_ -#include "mgl2/base.h" +#include "mgl2/abstract.h" //----------------------------------------------------------------------------- #ifdef __cplusplus extern "C" { diff --git a/include/mgl2/volume.h b/include/mgl2/volume.h index 7a9d248..a53e604 100644 --- a/include/mgl2/volume.h +++ b/include/mgl2/volume.h @@ -19,7 +19,7 @@ ***************************************************************************/ #ifndef _MGL_VOL_H_ #define _MGL_VOL_H_ -#include "mgl2/base.h" +#include "mgl2/abstract.h" //----------------------------------------------------------------------------- #ifdef __cplusplus extern "C" { diff --git a/include/mgl2/window.h b/include/mgl2/window.h index 7835efc..9c615b2 100644 --- a/include/mgl2/window.h +++ b/include/mgl2/window.h @@ -25,7 +25,7 @@ #include "mgl2/wx.h" //----------------------------------------------------------------------------- /// Wrapper class for all windows displaying graphics -class mglWindow : public mglWnd +class MGL_EXPORT mglWindow : public mglWnd { int wnd; ///< Type of window public: @@ -35,26 +35,23 @@ public: { wnd=kind; if(wnd==1) gr = mgl_create_graph_qt(draw,title,par,load); - else if(wnd==2) gr = mgl_create_graph_wx(draw,title,par,load); else gr = mgl_create_graph_fltk(draw,title,par,load); } mglWindow(int (*draw)(mglGraph *gr), const char *title="MathGL", int kind=0) : mglWnd() { wnd=kind; if(wnd==1) gr = mgl_create_graph_qt(draw?mgl_draw_graph:0,title,(void*)draw,0); - else if(wnd==2) gr = mgl_create_graph_wx(draw?mgl_draw_graph:0,title,(void*)draw,0); else gr = mgl_create_graph_fltk(draw?mgl_draw_graph:0,title,(void*)draw,0); } mglWindow(mglDraw *draw, const char *title="MathGL", int kind=0) : mglWnd() { wnd=kind; if(wnd==1) gr = mgl_create_graph_qt(draw?mgl_draw_class:0,title,draw,mgl_reload_class); - else if(wnd==2) gr = mgl_create_graph_wx(draw?mgl_draw_class:0,title,draw,mgl_reload_class); else gr = mgl_create_graph_fltk(draw?mgl_draw_class:0,title,draw,mgl_reload_class); mgl_set_click_func(gr, mgl_click_class); } /// Run main loop for event handling - int Run() { return wnd==0? mgl_fltk_run():(wnd==1?mgl_qt_run():mgl_wx_run()); } + int Run() { return wnd==0? mgl_fltk_run():mgl_qt_run(); } /// Run main loop for event handling in separate thread (for FLTK only) inline int RunThr() { return wnd==0 ? mgl_fltk_thr():0; } }; diff --git a/include/mgl2/wnd.h b/include/mgl2/wnd.h index dc0d907..98fe225 100644 --- a/include/mgl2/wnd.h +++ b/include/mgl2/wnd.h @@ -24,8 +24,9 @@ //----------------------------------------------------------------------------- /// Class for drawing in windows (like, mglCanvasFL, mglCanvasQT and so on) /// Make inherited class and redefine Draw() function if you don't want to use function pointers. -struct mglDraw +class MGL_EXPORT mglDraw { +public: virtual int Draw(mglGraph *)=0; ///< Function for drawing virtual void Reload() {} ///< Function for reloading data virtual void Click() {} ///< Callback function on mouse click @@ -51,7 +52,7 @@ void MGL_EXPORT mgl_reload_class(void *p); } //----------------------------------------------------------------------------- /// Abstract class for windows displaying graphics -class mglWnd : public mglGraph +class MGL_EXPORT mglWnd : public mglGraph { public: mglWnd() : mglGraph(-1) {} diff --git a/include/mgl2/wx.h b/include/mgl2/wx.h index 4876ad9..287df0d 100644 --- a/include/mgl2/wx.h +++ b/include/mgl2/wx.h @@ -20,47 +20,18 @@ #ifndef MGL_WX_H #define MGL_WX_H //----------------------------------------------------------------------------- -#include -//----------------------------------------------------------------------------- -#ifdef __cplusplus -extern "C" { -#endif -/// Creates WX window for plotting -HMGL MGL_EXPORT mgl_create_graph_wx(int (*draw)(HMGL gr, void *p), const char *title, void *par, void (*load)(void *p)); -uintptr_t MGL_EXPORT mgl_create_graph_wx_(const char *title, int); -/// Run main WX loop for event handling. -int MGL_EXPORT mgl_wx_run(); -int MGL_EXPORT mgl_wx_run_(); -#ifdef __cplusplus -} -//----------------------------------------------------------------------------- #include -//----------------------------------------------------------------------------- -/// Wrapper class for windows displaying graphics -class mglWX : public mglWnd -{ -public: - mglWX(const char *title="MathGL") : mglWnd() - { gr = mgl_create_graph_wx(0,title,0,0); } - mglWX(int (*draw)(HMGL gr, void *p), const char *title="MathGL", void *par=NULL, void (*load)(void *p)=0) : mglWnd() - { gr = mgl_create_graph_wx(draw,title,par,load); } - mglWX(int (*draw)(mglGraph *gr), const char *title="MathGL") : mglWnd() - { gr = mgl_create_graph_wx(draw?mgl_draw_graph:0,title,(void*)draw,0); } - mglWX(mglDraw *draw, const char *title="MathGL") : mglWnd() - { gr = mgl_create_graph_wx(draw?mgl_draw_class:0,title,draw,mgl_reload_class); - mgl_set_click_func(gr, mgl_click_class); } - int Run() { return mgl_wx_run(); } ///< Run main loop for event handling - -}; -//----------------------------------------------------------------------------- #include #include #include #include class mglCanvas; //----------------------------------------------------------------------------- +/// Convert MathGL image to wxBitmap +wxBitmap MGL_EXPORT ConvertFromGraph(HMGL gr); +//----------------------------------------------------------------------------- /// Class is Wx widget which display MathGL graphics -class wxMathGL : public wxWindow +class MGL_EXPORT wxMathGL : public wxWindow { public: wxString appName; ///< Application name for message boxes @@ -127,7 +98,6 @@ public: void Animation(bool st=true); ///< Start animation void About(); ///< Show about information - void AboutQt(); ///< Show information about Qt version protected: void OnPaint(wxPaintEvent& event); @@ -163,8 +133,6 @@ protected: DECLARE_EVENT_TABLE() private: int x0, y0, xe, ye; ///< Temporary variables for mouse - unsigned char *grBuf; }; //----------------------------------------------------------------------------- #endif -#endif diff --git a/json/main.js b/json/main.js index e35326b..6fbeead 100644 --- a/json/main.js +++ b/json/main.js @@ -24,34 +24,12 @@ var main = function() { //var script = "rotate 10 20: box:axis:fsurf 'sin(pi*x*y)'"; var makeSampleScript = function() { - var mgl = ""; - mgl += "ranges -2 2 -2 2 -2 2:" // NOTE: Ranges MUST BE specified for correctly work of zoomaxis feature - mgl += "facenum 50:"; -// mgl += "rotate 1 0:"; - - //mgl += "origin 0 0 0:axis 'Uxyz':xlabel 'x':ylabel 'y':zlabel 'z':" - mgl += "origin 0 0 0:axis 'x':xlabel 'x':ylabel 'y':zlabel 'z':" - - mgl += "box:" - -//mgl += "fsurf 'x':" - mgl += "fplot 'sin(x^2)'\n"; // This is just for testing zoomaxis features - mgl += "fplot 'sin(2*pi*t)' '2*t-1' 'cos(2*pi*t)' 'm2o':"; -//mgl += "fsurf '0':" -// mgl += "fplot 'sin(2*pi*t)' '2*t-1' '2*cos(2*pi*t)' 'm2o':"; - - //mgl += "axis:fsurf 'sin(2*pi*x*y)':"; -mgl += "axis:fsurf 'cos(2*pi*x*y)':"; - - //mgl += "zoomaxis"; -/////// mgl += "box:axis:fplot 'sin(2*pi*t)' 'cos(2*pi*t)' '2*t-1' 'm2o'\n"; - - //mgl += "xlabel 'x':ylabel 'y':axis:fsurf 'sin(2*pi*x*y)'\n"; - //mgl += "box:axis:fplot 'sin(2*pi*t)' 'cos(2*pi*t)' '2*t-1' 'm2o'\n"; - // only axes are kept for debug purposes - - // mgl += "rotate 1 0:xlabel 'x':ylabel 'y':axis:\n"; - -//mgl += "fsurf 'sin(2*pi*x*y)':" - return mgl; + var mgl = "origintick off\n"; + mgl += "ranges -2 2 -2 2 -2 2:" // NOTE: Ranges MUST BE specified for correctly work of zoomaxis feature + mgl += "facenum 50:"; + mgl += "origin 0 0 0:axis :xlabel 'x':ylabel 'y':zlabel 'z':" + mgl += "box:fplot 'sin(x^2)'\n"; // This is just for testing zoomaxis features + mgl += "fplot 'sin(2*pi*t)' '2*t-1' 'cos(2*pi*t)' 'm2o':"; + mgl += "text 0 0 'aaa'"; + return mgl; } diff --git a/json/mathgl.Graph.js b/json/mathgl.Graph.js index 7cb17f9..6ce28a9 100644 --- a/json/mathgl.Graph.js +++ b/json/mathgl.Graph.js @@ -8,21 +8,21 @@ * @param canvas {Canvas} canvas to plot graph on */ mathgl.Graph = function(canvas, backend) { - this.__backend = backend; - this.__canvas = canvas; - this.__view = null; - this.__geometry = null; - // indicate whether rendering handlers are in the event queue - this.__isDraftRenderingInScheduled = false; - this.__isPreciseRenderingScheduled = false; - // draft rendering finished timestamp - this.__draftFinishedTimestamp = new Date(); - this.__backgroundFillStyle = '#EEEEFF'; - this.__preciseRenderingDelay = 700; - // TODO add setters/getters - this.__maxDraftPoints = 9000; - this.__x1 = 0; this.__y1 = 0; - this.__x2 = 1; this.__y2 = 1; + this.__backend = backend; + this.__canvas = canvas; + this.__view = null; + this.__geometry = null; + // indicate whether rendering handlers are in the event queue + this.__isDraftRenderingInScheduled = false; + this.__isPreciseRenderingScheduled = false; + // draft rendering finished timestamp + this.__draftFinishedTimestamp = new Date(); + this.__backgroundFillStyle = '#EEEEFF'; + this.__preciseRenderingDelay = 700; + // TODO add setters/getters + this.__maxDraftPoints = 9000; + this.__x1 = 0; this.__y1 = 0; this.__z1 = 0; + this.__x2 = 1; this.__y2 = 1; this.__z2 = 1; } @@ -31,18 +31,18 @@ mathgl.Graph = function(canvas, backend) { * @param mgl {String} MGL script */ mathgl.Graph.prototype.init = function(mgl) { - // request backend for geometry object - this.__geometry = this.__backend.geometry(mgl); - this.__geometry.mgl = mgl; - // construct view according the view type recieved from backend (within geometry object) and initialize it - - this.__view = new mathgl.View(); - // connect method which starts rendering to view object - this.__view.setRenderLauncher(mathgl.bind(this.__renderStart, this)); - // connect pick point handler - this.__view.setPickPointHandler(mathgl.bind(this.__pickPointHandler, this)); - // attach canvas to view - this.__view.attachCanvas(this.__canvas); + // request backend for geometry object + this.__geometry = this.__backend.geometry(mgl); + this.__geometry.mgl = mgl; + // construct view according the view type recieved from backend (within geometry object) and initialize it + + this.__view = new mathgl.View(); + // connect method which starts rendering to view object + this.__view.setRenderLauncher(mathgl.bind(this.__renderStart, this)); + // connect pick point handler + this.__view.setPickPointHandler(mathgl.bind(this.__pickPointHandler, this)); + // attach canvas to view + this.__view.attachCanvas(this.__canvas); } @@ -51,7 +51,7 @@ mathgl.Graph.prototype.init = function(mgl) { * @param json {String} string in JSON format with previously saved state */ mathgl.Graph.prototype.load = function(json) { - throw new Error("TODO"); + throw new Error("TODO"); } @@ -60,7 +60,7 @@ mathgl.Graph.prototype.load = function(json) { * @return {String} state serialized to JSON string */ mathgl.Graph.prototype.save = function() { - throw new Error("TODO"); + throw new Error("TODO"); } @@ -69,327 +69,322 @@ mathgl.Graph.prototype.save = function() { * @param fillStyle something that will be accepted by canvas' 2d context as fill style, e.g. color, gradient, pattern. */ mathgl.Graph.prototype.setBackgroundFillStyle = function(fillStyle) { - this.__backgroundFillStyle = fillStyle; + this.__backgroundFillStyle = fillStyle; } /** @return background fill style */ mathgl.Graph.prototype.backgroundFillStyle = function() { - return this.__backgroundFillStyle; + return this.__backgroundFillStyle; } /** called when user picks the point on the graph, point shall be somehow displayed/highlighted */ mathgl.Graph.prototype.__pickPointHandler = function(x, y) { - console.log("Point picked: ", x, y); - var obj = this.__geometry; - var xy = x*obj.width/this.__canvas.width + " " + y*obj.height/this.__canvas.height; - // introduce zoom and view coomand for server side - var zoom = "zoom "+(0.5-obj.pf/2)+" "+(0.5-obj.pf/2)+" "+(0.5+obj.pf/2)+" "+(0.5+obj.pf/2)+"\n"; - var view1 = "view 0 "+this.__view.__pitch*180/Math.PI+" 0"+"\n"; - var view2 = "view 0 0 "+(-this.__view.__yaw)*180/Math.PI+"\n"; - console.debug(xy,"pf=",obj.pf,zoom+view1+view2) - // now ask server side for proper coordinates - var res = globalBackend.coor(xy, zoom+view1+view2+obj.mgl); - console.debug("coordinates are ", res); + var obj = this.__geometry; + var xy = x*obj.width/this.__canvas.width + " " + y*obj.height/this.__canvas.height; + // introduce zoom and view coomand for server side + var zoom = "zoom "+(0.5-obj.pf/2)+" "+(0.5-obj.pf/2)+" "+(0.5+obj.pf/2)+" "+(0.5+obj.pf/2)+"\n"; + var view1 = "view 0 "+this.__view.__pitch*180/Math.PI+" 0"+"\n"; + var view2 = "view 0 0 "+(-this.__view.__yaw)*180/Math.PI+"\n"; + // now ask server side for proper coordinates + var res = this.__backend.coor(xy, zoom+view1+view2+obj.mgl); } /** called when user shift axis range */ -mathgl.Graph.prototype.shiftAxis = function(x, y) { - var dx = x*(this.__x2-this.__x1), dy = y*(this.__y2-this.__y1) - this.__x1 += dx; this.__x2 += dx; - this.__y1 += dy; this.__y2 += dy; - // introduce zoomaxis coomand for server side - var zoom = "zoomaxis "+this.__x1+" "+this.__y1+" "+this.__x2+" "+this.__y2+"\n"; - var mgl = this.__geometry.mgl; - console.log(zoom, "Old: ", this.__geometry); - // now ask server side for proper coordinates - this.__geometry = this.__backend.geometry(zoom+mgl); - this.__geometry.mgl = mgl; - console.log("New: ", this.__geometry); - this.__renderStart(); +mathgl.Graph.prototype.shiftAxis = function(x, y, z) { + var dx = x*(this.__x2-this.__x1), dy = y*(this.__y2-this.__y1), dz = z*(this.__z2-this.__z1) + this.__x1 += dx; this.__x2 += dx; + this.__y1 += dy; this.__y2 += dy; + this.__z1 += dz; this.__z2 += dz; + // introduce zoomaxis coomand for server side + var zoom = "zoomaxis "+this.__x1+" "+this.__y1+" "+this.__z1+" "+this.__x2+" "+this.__y2+" "+this.__z2+"\n"; + var mgl = this.__geometry.mgl; + // now ask server side for proper coordinates + this.__geometry = this.__backend.geometry(zoom+mgl); + this.__geometry.mgl = mgl; + this.__renderStart(); } /** called when user shift axis range */ mathgl.Graph.prototype.zoomAxis = function(factor) { - var d, c; - d=(this.__x2-this.__x1)*factor/2; c=(this.__x2+this.__x1)/2; - this.__x1 = c-d; this.__x2 = c+d; - d=(this.__y2-this.__y1)*factor/2; c=(this.__y2+this.__y1)/2; - this.__y1 = c-d; this.__y2 = c+d; - // introduce zoomaxis coomand for server side - var zoom = "zoomaxis "+this.__x1+" "+this.__y1+" "+this.__x2+" "+this.__y2+"\n"; - var mgl = this.__geometry.mgl; - console.log(zoom, "Old: ", this.__geometry); - // now ask server side for proper coordinates - this.__geometry = this.__backend.geometry(zoom+this.__geometry.mgl); - this.__geometry.mgl = mgl; - console.log("New: ", this.__geometry); - this.__renderStart(); + var d, c; + d=(this.__x2-this.__x1)*factor/2; c=(this.__x2+this.__x1)/2; + this.__x1 = c-d; this.__x2 = c+d; + d=(this.__y2-this.__y1)*factor/2; c=(this.__y2+this.__y1)/2; + this.__y1 = c-d; this.__y2 = c+d; + d=(this.__z2-this.__z1)*factor/2; c=(this.__z2+this.__z1)/2; + this.__z1 = c-d; this.__z2 = c+d; + // introduce zoomaxis coomand for server side + var zoom = "zoomaxis "+this.__x1+" "+this.__y1+" "+this.__z1+" "+this.__x2+" "+this.__y2+" "+this.__z2+"\n"; + var mgl = this.__geometry.mgl; + // now ask server side for proper coordinates + this.__geometry = this.__backend.geometry(zoom+this.__geometry.mgl); + this.__geometry.mgl = mgl; + this.__renderStart(); } /** initiate the chains of rendering the geometry to the canvas */ mathgl.Graph.prototype.__renderStart = function() { - // do nothing if processing is already started - if (!this.__isDraftRenderingInScheduled) { - // enqueue draft rendering step - this.__isDraftRenderingInScheduled = true; - setTimeout(mathgl.bind(this.__renderDraft, this), 0); - } + // do nothing if processing is already started + if (!this.__isDraftRenderingInScheduled) { + // enqueue draft rendering step + this.__isDraftRenderingInScheduled = true; + setTimeout(mathgl.bind(this.__renderDraft, this), 0); + } } /** draft rendering */ mathgl.Graph.prototype.__renderDraft = function() { - this.__drawMesh(false); - this.__isDraftRenderingInScheduled = false; - - // enqueue precise rendering step - if (!this.__isPreciseRenderingScheduled) { - this.__isPreciseRenderingScheduled = true; - setTimeout(mathgl.bind(this.__renderPrecise, this), this.__preciseRenderingDelay); - } - this.__draftFinishedTimestamp = new Date(); + this.__drawMesh(false); + this.__isDraftRenderingInScheduled = false; + + // enqueue precise rendering step + if (!this.__isPreciseRenderingScheduled) { + this.__isPreciseRenderingScheduled = true; + setTimeout(mathgl.bind(this.__renderPrecise, this), this.__preciseRenderingDelay); + } + this.__draftFinishedTimestamp = new Date(); } /** precise rendering */ mathgl.Graph.prototype.__renderPrecise = function() { - // do nothing if draft rendering is scheduled - if (this.__isDraftRenderingInScheduled) { - this.__isPreciseRenderingScheduled = false; - return; - } - - // check that enough time has passed since last occurance of draft rendering finished - // rechedule pricese rendering if it is not - var current = new Date(); - if (current - this.__draftFinishedTimestamp < this.__preciseRenderingDelay) { - setTimeout(mathgl.bind(this.__renderPrecise, this), this.__preciseRenderingDelay - (current - this.__draftFinishedTimestamp)); - return; - } - this.__drawMesh(true); - this.__isPreciseRenderingScheduled = false; + // do nothing if draft rendering is scheduled + if (this.__isDraftRenderingInScheduled) { + this.__isPreciseRenderingScheduled = false; + return; + } + + // check that enough time has passed since last occurance of draft rendering finished + // rechedule pricese rendering if it is not + var current = new Date(); + if (current - this.__draftFinishedTimestamp < this.__preciseRenderingDelay) { + setTimeout(mathgl.bind(this.__renderPrecise, this), this.__preciseRenderingDelay - (current - this.__draftFinishedTimestamp)); + return; + } + this.__drawMesh(true); + this.__isPreciseRenderingScheduled = false; } /** fill canvas background */ mathgl.Graph.prototype.__drawBackground = function() { - var c = this.__canvas.getContext("2d"); - var h = this.__canvas.height; - var w = this.__canvas.width; - c.fillStyle = this.__backgroundFillStyle; - c.fillRect(0, 0 , w, h); + var c = this.__canvas.getContext("2d"); + var h = this.__canvas.height; + var w = this.__canvas.width; + c.fillStyle = this.__backgroundFillStyle; + c.fillRect(0, 0 , w, h); } /** auxiliary function to draw mesh */ mathgl.Graph.prototype.__drawMesh = function(isPrecise) { - var c = this.__canvas.getContext("2d"); - var m = this.__view.viewMatrix().inverse(); -// var vvv = $M([[1,0,0,1]]); -// console.log(vvv.x(m).elements); - var obj = this.__geometry; - var h = this.__canvas.height; - var dy = h / obj.height; - var w = this.__canvas.width; - var dx = w / obj.width; - obj.pf = -m.e(4,3); - obj.b = [dx*m.e(1,1), dx*m.e(2,1), dx*m.e(3,1), - dy*m.e(1,2), dy*m.e(2,2), dy*m.e(3,2), - m.e(1,3), m.e(2,3), m.e(3,3), - w/2, h/2, obj.depth/2]; - - this.__drawBackground(); - - if (!isPrecise) { - obj.fast = 1; - obj.good = 0; - this.__mgl_draw_fast(obj,c,1); - } else { - obj.fast = 0; - obj.good = 1; - this.__mgl_draw_good(obj,c,1); - } + var c = this.__canvas.getContext("2d"); + var m = this.__view.viewMatrix().inverse(); +// var vvv = $M([[1,0,0,1]]); + var obj = this.__geometry; + var h = this.__canvas.height; + var dy = h / obj.height; + var w = this.__canvas.width; + var dx = w / obj.width; + obj.pf = -m.e(4,3); + obj.b = [dx*m.e(1,1), dx*m.e(2,1), dx*m.e(3,1), + dy*m.e(1,2), dy*m.e(2,2), dy*m.e(3,2), + m.e(1,3), m.e(2,3), m.e(3,3), + w/2, h/2, obj.depth/2]; + + this.__drawBackground(); + + if (!isPrecise) { + obj.fast = 1; + obj.good = 0; + this.__mgl_draw_fast(obj,c,1); + } else { + obj.fast = 0; + obj.good = 1; + this.__mgl_draw_good(obj,c,1); + } } /** perform fast drawing */ mathgl.Graph.prototype.__mgl_draw_fast = function(obj, ctx, skip) { - if(obj.fast==0) return; - this.__mgl_prepare(obj,skip); // update coordinates - var i,n1,n2; - // for each primitive skipping superfluous - for(var i=0;i * + * * + * 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 +class mglData +{ +public: + + long nx; ///< number of points in 1st dimensions ('x' dimension) + long ny; ///< number of points in 2nd dimensions ('y' dimension) + long nz; ///< number of points in 3d dimensions ('z' dimension) + mreal *a; ///< data array + std::string id; ///< column (or slice) names + bool link; ///< use external data (i.e. don't free it) + + /// Initiate by other mglData variable + inline mglData(const mglData &d) { a=0; mgl_data_set(this,&d); } // NOTE: must be constructor for mglData& to exclude copy one + inline mglData(const mglData *d) { a=0; mgl_data_set(this, d); } + inline mglData(bool, mglData *d) // NOTE: Variable d will be deleted!!! + { if(d) + { nx=d->nx; ny=d->ny; nz=d->nz; a=d->a; d->a=0; + id=d->id; link=d->link; delete d; } + else { a=0; Create(1); } } + /// Initiate by flat array + inline mglData(int size, const float *d) { a=0; Set(d,size); } + inline mglData(int rows, int cols, const float *d) { a=0; Set(d,cols,rows); } + inline mglData(int size, const double *d) { a=0; Set(d,size); } + inline mglData(int rows, int cols, const double *d) { a=0; Set(d,cols,rows); } + inline mglData(const double *d, int size) { a=0; Set(d,size); } + inline mglData(const double *d, int rows, int cols) { a=0; Set(d,cols,rows); } + /// Read data from file + inline mglData(const char *fname) { a=0; Read(fname); } + /// Allocate the memory for data array and initialize it zero + inline mglData(long xx=1,long yy=1,long zz=1) { a=0; Create(xx,yy,zz); } + /// Delete the array + virtual ~mglData() { if(!link && a) delete []a; } + inline mreal GetVal(long i, long j=0, long k=0) + { return mgl_data_get_value(this,i,j,k);} + inline void SetVal(mreal f, long i, long j=0, long k=0) + { mgl_data_set_value(this,f,i,j,k); } + /// Get sizes + inline long GetNx() const { return nx; } + inline long GetNy() const { return ny; } + inline long GetNz() const { return nz; } + + /// Link external data array (don't delete it at exit) + inline void Link(mreal *A, long NX, long NY=1, long NZ=1) + { mgl_data_link(this,A,NX,NY,NZ); } + inline void Link(mglData &d) { Link(d.a,d.nx,d.ny,d.nz); } + /// Allocate memory and copy the data from the gsl_vector + inline void Set(gsl_vector *m) { mgl_data_set_vector(this,m); } + /// Allocate memory and copy the data from the gsl_matrix + inline void Set(gsl_matrix *m) { mgl_data_set_matrix(this,m); } + + /// Allocate memory and copy the data from the (float *) array + inline void Set(const float *A,long NX,long NY=1,long NZ=1) + { mgl_data_set_float(this,A,NX,NY,NZ); } + /// Allocate memory and copy the data from the (double *) array + inline void Set(const double *A,long NX,long NY=1,long NZ=1) + { mgl_data_set_double(this,A,NX,NY,NZ); } + /// Allocate memory and copy the data from the (float **) array + inline void Set(float const * const *A,long N1,long N2) + { mgl_data_set_float2(this,A,N1,N2); } + /// Allocate memory and copy the data from the (double **) array + inline void Set(double const * const *A,long N1,long N2) + { mgl_data_set_double2(this,A,N1,N2); } + /// Allocate memory and copy the data from the (float ***) array + inline void Set(float const * const * const *A,long N1,long N2,long N3) + { mgl_data_set_float3(this,A,N1,N2,N3); } + /// Allocate memory and copy the data from the (double ***) array + inline void Set(double const * const * const *A,long N1,long N2,long N3) + { mgl_data_set_double3(this,A,N1,N2,N3); } + /// Allocate memory and scanf the data from the string + inline void Set(const char *str,long NX,long NY=1,long NZ=1) + { mgl_data_set_values(this,str,NX,NY,NZ); } + /// Import data from abstract type + inline void Set(const mglData &dat) { mgl_data_set(this, &dat); } + + /// Create or recreate the array with specified size and fill it by zero + inline void Create(long mx,long my=1,long mz=1) + { mgl_data_create(this,mx,my,mz); } + /// Rearange data dimensions + inline void Rearrange(long mx, long my=0, long mz=0) + { mgl_data_rearrange(this,mx,my,mz); } + /// Transpose dimensions of the data (generalization of Transpose) + inline void Transpose(const char *dim="yx") + { mgl_data_transpose(this,dim); } + /// Extend data dimensions + inline void Extend(long n1, long n2=0) + { mgl_data_extend(this,n1,n2); } + /// Reduce size of the data + inline void Squeeze(long rx,long ry=1,long rz=1,bool smooth=false) + { mgl_data_squeeze(this,rx,ry,rz,smooth); } + /// Crop the data + inline void Crop(long n1, long n2,char dir='x') + { mgl_data_crop(this,n1,n2,dir); } + /// Insert data rows/columns/slices + inline void Insert(char dir, long at=0, long num=1) + { mgl_data_insert(this,dir,at,num); } + /// Delete data rows/columns/slices + inline void Delete(char dir, long at=0, long num=1) + { mgl_data_delete(this,dir,at,num); } + /// Remove rows with duplicate values in column id + inline void Clean(long id) + { mgl_data_clean(this,id); } + /// Join with another data array + inline void Join(const mglData &d) + { mgl_data_join(this,&d); } + + /// Modify the data by specified formula + inline void Modify(const char *eq,long dim=0) + { mgl_data_modify(this, eq, dim); } + /// Modify the data by specified formula + inline void Modify(const char *eq,const mglData &vdat, const mglData &wdat) + { mgl_data_modify_vw(this,eq,&vdat,&wdat); } + /// Modify the data by specified formula + inline void Modify(const char *eq,const mglData &vdat) + { mgl_data_modify_vw(this,eq,&vdat,0); } + /// Modify the data by specified formula assuming x,y,z in range [r1,r2] + inline void Fill(mglBase *gr, const char *eq, const char *opt="") + { mgl_data_fill_eq(gr,this,eq,0,0,opt); } + inline void Fill(mglBase *gr, const char *eq, const mglData &vdat, const char *opt="") + { mgl_data_fill_eq(gr,this,eq,&vdat,0,opt); } + inline void Fill(mglBase *gr, const char *eq, const mglData &vdat, const mglData &wdat,const char *opt="") + { mgl_data_fill_eq(gr,this,eq,&vdat,&wdat,opt); } + /// Equidistantly fill the data to range [x1,x2] in direction dir + inline void Fill(mreal x1,mreal x2=NaN,char dir='x') + { return mgl_data_fill(this,x1,x2,dir); } + /// Fill the data by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in range [p1,p2] + inline void Refill(const mglData &xdat, const mglData &vdat, mreal x1, mreal x2,long sl=-1) + { mgl_data_refill_x(this,&xdat,&vdat,x1,x2,sl); } + inline void Refill(const mglData &xdat, const mglData &vdat, mglPoint p1, mglPoint p2,long sl=-1) + { mgl_data_refill_x(this,&xdat,&vdat,p1.x,p2.x,sl); } + inline void Refill(const mglData &xdat, const mglData &ydat, const mglData &vdat, mglPoint p1, mglPoint p2,long sl=-1) + { mgl_data_refill_xy(this,&xdat,&ydat,&vdat,p1.x,p2.x,p1.y,p2.y,sl); } + inline void Refill(const mglData &xdat, const mglData &ydat, const mglData &zdat, const mglData &vdat, mglPoint p1, mglPoint p2) + { mgl_data_refill_xyz(this,&xdat,&ydat,&zdat,&vdat,p1.x,p2.x,p1.y,p2.y,p1.z,p2.z); } + /// Fill the data by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in axis range of gr + inline void Refill(mglBase *gr, const mglData &xdat, const mglData &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,this,&xdat,0,0,&vdat,sl,opt); } + inline void Refill(mglBase *gr, const mglData &xdat, const mglData &ydat, const mglData &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,this,&xdat,&ydat,0,&vdat,sl,opt); } + inline void Refill(mglBase *gr, const mglData &xdat, const mglData &ydat, const mglData &zdat, const mglData &vdat, const char *opt="") + { mgl_data_refill_gr(gr,this,&xdat,&ydat,&zdat,&vdat,-1,opt); } +/// Set the data by triangulated surface values assuming x,y,z in axis range of gr + inline void Grid(mglBase *gr, const mglData &x, const mglData &y, const mglData &z, const char *opt="") + { mgl_data_grid(gr,this,&x,&y,&z,opt); } + /// Set the data by triangulated surface values assuming x,y,z in range [p1, p2] + inline void Grid(const mglData &xdat, const mglData &ydat, const mglData &vdat, mglPoint p1, mglPoint p2) + { mgl_data_grid_xy(this,&xdat,&ydat,&vdat,p1.x,p2.x,p1.y,p2.y); } + /// Put value to data element(s) + inline void Put(mreal val, long i=-1, long j=-1, long k=-1) + { mgl_data_put_val(this,val,i,j,k); } + /// Put array to data element(s) + inline void Put(const mglData &dat, long i=-1, long j=-1, long k=-1) + { mgl_data_put_dat(this,&dat,i,j,k); } + /// Set names for columns (slices) + inline void SetColumnId(const char *ids) + { mgl_data_set_id(this,ids); } + /// Make new id + inline void NewId() { id.clear(); } + + /// Read data from tab-separated text file with auto determining size + inline bool Read(const char *fname) + { return mgl_data_read(this,fname); } + /// Read data from text file with specifeid size + inline bool Read(const char *fname,long mx,long my=1,long mz=1) + { return mgl_data_read_dim(this,fname,mx,my,mz); } + /// Save whole data array (for ns=-1) or only ns-th slice to text file + inline void Save(const char *fname,long ns=-1) const + { mgl_data_save(this,fname,ns); } + /// Export data array (for ns=-1) or only ns-th slice to PNG file according color scheme + inline void Export(const char *fname,const char *scheme,mreal v1=0,mreal v2=0,long ns=-1) const + { mgl_data_export(this,fname,scheme,v1,v2,ns); } + /// Import data array from PNG file according color scheme + inline void Import(const char *fname,const char *scheme,mreal v1=0,mreal v2=1) + { mgl_data_import(this,fname,scheme,v1,v2); } + /// Read data from tab-separated text files with auto determining size which filenames are result of sprintf(fname,templ,t) where t=from:step:to + inline bool ReadRange(const char *templ, double from, double to, double step=1, bool as_slice=false) + { return mgl_data_read_range(this,templ,from,to,step,as_slice); } + /// Read data from tab-separated text files with auto determining size which filenames are satisfied to template (like "t_*.dat") + inline bool ReadAll(const char *templ, bool as_slice=false) + { return mgl_data_read_all(this, templ, as_slice); } + /// Read data from text file with size specified at beginning of the file + inline bool ReadMat(const char *fname, long dim=2) + { return mgl_data_read_mat(this,fname,dim); } + /// Read data array from HDF file (parse HDF4 and HDF5 files) + inline int ReadHDF(const char *fname,const char *data) + { return mgl_data_read_hdf(this,fname,data); } + /// Save data to HDF file + inline void SaveHDF(const char *fname,const char *data,bool rewrite=false) const + { mgl_data_save_hdf(this,fname,data,rewrite); } + /// Put HDF data names into buf as '\t' separated. + inline static int DatasHDF(const char *fname, char *buf, long size) + { return mgl_datas_hdf(fname,buf,size); } + + /// Get column (or slice) of the data filled by formulas of named columns + inline mglData Column(const char *eq) const + { return mglData(true,mgl_data_column(this,eq)); } + /// Get momentum (1D-array) of data along direction 'dir'. String looks like "x1" for median in x-direction, "x2" for width in x-dir and so on. + inline mglData Momentum(char dir, const char *how) const + { return mglData(true,mgl_data_momentum(this,dir,how)); } + /// Get sub-array of the data with given fixed indexes + inline mglData SubData(long xx,long yy=-1,long zz=-1) const + { return mglData(true,mgl_data_subdata(this,xx,yy,zz)); } + inline mglData SubData(const mglData &xx, const mglData &yy, const mglData &zz) const + { return mglData(true,mgl_data_subdata_ext(this,&xx,&yy,&zz)); } + /// Get trace of the data array + inline mglData Trace() const + { return mglData(true,mgl_data_trace(this)); } + /// Create n-th points distribution of this data values in range [v1, v2] + inline mglData Hist(long n,mreal v1=0,mreal v2=1, long nsub=0) const + { return mglData(true,mgl_data_hist(this,n,v1,v2,nsub)); } + /// Create n-th points distribution of this data values in range [v1, v2] with weight w + inline mglData Hist(const mglData &w, long n,mreal v1=0,mreal v2=1, long nsub=0) const + { return mglData(true,mgl_data_hist_w(this,&w,n,v1,v2,nsub)); } + /// Get array which is result of summation in given direction or directions + inline mglData Sum(const char *dir) const + { return mglData(true,mgl_data_sum(this,dir)); } + /// Get array which is result of maximal values in given direction or directions + inline mglData Max(const char *dir) const + { return mglData(true,mgl_data_max_dir(this,dir)); } + /// Get array which is result of minimal values in given direction or directions + inline mglData Min(const char *dir) const + { return mglData(true,mgl_data_min_dir(this,dir)); } + /// Get the data which is direct multiplication (like, d[i,j] = this[i]*a[j] and so on) + inline mglData Combine(const mglData &dat) const + { return mglData(true,mgl_data_combine(this,&dat)); } + /// Resize the data to new size of box [x1,x2]*[y1,y2]*[z1,z2] + inline mglData Resize(long mx,long my=0,long mz=0, mreal x1=0,mreal x2=1, mreal y1=0,mreal y2=1, mreal z1=0,mreal z2=1) const + { return mglData(true,mgl_data_resize_box(this,mx,my,mz,x1,x2,y1,y2,z1,z2)); } + /// Get array which values is result of interpolation this for coordinates from other arrays + inline mglData Evaluate(const mglData &idat, bool norm=true) const + { return mglData(true,mgl_data_evaluate(this,&idat,0,0,norm)); } + inline mglData Evaluate(const mglData &idat, const mglData &jdat, bool norm=true) const + { return mglData(true,mgl_data_evaluate(this,&idat,&jdat,0,norm)); } + inline mglData Evaluate(const mglData &idat, const mglData &jdat, const mglData &kdat, bool norm=true) const + { return mglData(true,mgl_data_evaluate(this,&idat,&jdat,&kdat,norm)); } + /// Find roots for set of nonlinear equations defined by textual formula + inline mglData Roots(const char *func, char var='x') const + { return mglData(true,mgl_data_roots(func, this, var)); } + /// Find correlation with another data arrays + inline mglData Correl(const mglData &dat, const char *dir) const + { return mglData(true,mgl_data_correl(this,&dat,dir)); } + /// Find auto correlation function + inline mglData AutoCorrel(const char *dir) const + { return mglData(true,mgl_data_correl(this,this,dir)); } + + /// Cumulative summation the data in given direction or directions + inline void CumSum(const char *dir) { mgl_data_cumsum(this,dir); } + /// Integrate (cumulative summation) the data in given direction or directions + inline void Integral(const char *dir) { mgl_data_integral(this,dir); } + /// Differentiate the data in given direction or directions + inline void Diff(const char *dir) { mgl_data_diff(this,dir); } + /// Differentiate the parametrically specified data along direction v1 with v2=const + inline void Diff(const mglData &v1, const mglData &v2) + { mgl_data_diff_par(this,&v1,&v2,0); } + /// Differentiate the parametrically specified data along direction v1 with v2,v3=const + inline void Diff(const mglData &v1, const mglData &v2, const mglData &v3) + { mgl_data_diff_par(this,&v1,&v2,&v3); } + /// Double-differentiate (like Laplace operator) the data in given direction + inline void Diff2(const char *dir) { mgl_data_diff2(this,dir); } + + /// Swap left and right part of the data in given direction (useful for Fourier spectrum) + inline void Swap(const char *dir) { mgl_data_swap(this,dir); } + /// Roll data along direction dir by num slices + inline void Roll(char dir, long num) { mgl_data_roll(this,dir,num); } + /// Mirror the data in given direction (useful for Fourier spectrum) + inline void Mirror(const char *dir) { mgl_data_mirror(this,dir); } + /// Sort rows (or slices) by values of specified column + inline void Sort(long idx, long idy=-1) { mgl_data_sort(this,idx,idy); } + + /// Set as the data envelop + inline void Envelop(char dir='x') + { mgl_data_envelop(this,dir); } + /// Remove phase jump + inline void Sew(const char *dirs="xyz", mreal da=2*Pi) + { mgl_data_sew(this,dirs,da); } + /// Smooth the data on specified direction or directions + inline void Smooth(const char *dirs="xyz",mreal delta=0) + { mgl_data_smooth(this,dirs,delta); } + /// Normalize the data to range [v1,v2] + inline void Norm(mreal v1=0,mreal v2=1,bool sym=false,long dim=0) + { mgl_data_norm(this,v1,v2,sym,dim); } + /// Normalize the data to range [v1,v2] slice by slice + inline void NormSl(mreal v1=0,mreal v2=1,char dir='z',bool keep_en=true,bool sym=false) + { mgl_data_norm_slice(this,v1,v2,dir,keep_en,sym); } + + /// Apply Hankel transform + inline void Hankel(const char *dir) { mgl_data_hankel(this,dir); } + /// Apply Sin-Fourier transform + inline void SinFFT(const char *dir) { mgl_data_sinfft(this,dir); } + /// Apply Cos-Fourier transform + inline void CosFFT(const char *dir) { mgl_data_cosfft(this,dir); } + /// Fill data by 'x'/'k' samples for Hankel ('h') or Fourier ('f') transform + inline void FillSample(const char *how) + { mgl_data_fill_sample(this,how); } + + /// 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 mgl_data_spline(this, 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 mgl_data_spline(this, x*(nx-1),y*(ny-1),z*(nz-1)); } + /// 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(this,x,y,z); } + /// 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(this,x*(nx-1),y*(ny-1),z*(nz-1)); } + /// Return an approximated x-value (root) when dat(x) = val + inline mreal Solve(mreal val, bool use_spline=true, long i0=0) const + { return mgl_data_solve_1d(this, val, use_spline, i0); } + /// Return an approximated value (root) when dat(x) = val + inline mglData Solve(mreal val, char dir, bool norm=true) const + { return mglData(true,mgl_data_solve(this, val, dir, 0, norm)); } + inline mglData Solve(mreal val, char dir, const mglData &i0, bool norm=true) const + { return mglData(true,mgl_data_solve(this, val, dir, &i0, norm)); } + + /// 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 mgl_data_spline_ext(this, 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=mgl_data_spline_ext(this, x*(nx-1),y*(ny-1),z*(nz-1), &(dif.x),&(dif.y), &(dif.z)); + dif.x*=nx>1?nx-1:1; dif.y*=ny>1?ny-1:1; dif.z*=nz>1?nz-1:1; return res; } + /// 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*(nx-1),y*(ny-1),z*(nz-1), &(dif.x),&(dif.y), &(dif.z)); + dif.x*=nx>1?nx-1:1; dif.y*=ny>1?ny-1:1; dif.z*=nz>1?nz-1:1; return res; } + + /// Get information about the data (sizes and momentum) to string + inline const char *PrintInfo() const { return mgl_data_info(this); } + /// Print information about the data (sizes and momentum) to FILE (for example, stdout) + inline void PrintInfo(FILE *fp) const + { if(fp) { fprintf(fp,"%s",mgl_data_info(this)); fflush(fp); } } + /// Get maximal value of the data + inline mreal Maximal() const { return mgl_data_max(this); } + /// Get minimal value of the data + inline mreal Minimal() const { return mgl_data_min(this); } + /// Get maximal value of the data and its position + inline mreal Maximal(long &i,long &j,long &k) const + { return mgl_data_max_int(this,&i,&j,&k); } + /// Get minimal value of the data and its position + inline mreal Minimal(long &i,long &j,long &k) const + { return mgl_data_min_int(this,&i,&j,&k); } + /// Get maximal value of the data and its approximated position + inline mreal Maximal(mreal &x,mreal &y,mreal &z) const + { return mgl_data_max_real(this,&x,&y,&z); } + /// Get minimal value of the data and its approximated position + inline mreal Minimal(mreal &x,mreal &y,mreal &z) const + { return mgl_data_min_real(this,&x,&y,&z); } + /// Get "energy" and find first (median) and second (width) momenta of data + inline mreal Momentum(char dir,mreal &m,mreal &w) const + { return mgl_data_momentum_val(this,dir,&m,&w,0,0); } + /// Get "energy and find 4 momenta of data: median, width, skewness, kurtosis + inline mreal Momentum(char dir,mreal &m,mreal &w,mreal &s,mreal &k) const + { return mgl_data_momentum_val(this,dir,&m,&w,&s,&k); } + /// Find position (after specified in i,j,k) of first nonzero value of formula + inline mreal Find(const char *cond, long &i, long &j, long &k) const + { return mgl_data_first(this,cond,&i,&j,&k); } + /// Find position (before specified in i,j,k) of last nonzero value of formula + inline mreal Last(const char *cond, long &i, long &j, long &k) const + { return mgl_data_last(this,cond,&i,&j,&k); } + /// Find position of first in direction 'dir' nonzero value of formula + inline long Find(const char *cond, char dir, long i=0, long j=0, long k=0) const + { return mgl_data_find(this,cond,dir,i,j,k); } + /// Find if any nonzero value of formula + inline bool FindAny(const char *cond) const + { return mgl_data_find_any(this,cond); } + + /// Copy data from other mglData variable + inline mglData &operator=(const mglData &d) + { if(this!=&d) Set(d.a,d.nx,d.ny,d.nz); return *this; } + inline mreal operator=(mreal val) + { for(long i=0;i=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +inline mglData mglQO2d(const char *ham, const mglData &ini_re, const mglData &ini_im, const mglData &ray, mreal r=1, mreal k0=100) +{ return mglData(true, mgl_qo2d_solve(ham, &ini_re, &ini_im, &ray, r, k0, 0, 0)); } +inline mglData mglQO2d(const char *ham, const mglData &ini_re, const mglData &ini_im, const mglData &ray, mglData &xx, mglData &yy, mreal r=1, mreal k0=100) +{ return mglData(true, mgl_qo2d_solve(ham, &ini_re, &ini_im, &ray, r, k0, &xx, &yy)); } +/// Saves result of PDE solving for "Hamiltonian" ham with initial conditions ini along a curve ray (must have nx>=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +inline mglData mglQO3d(const char *ham, const mglData &ini_re, const mglData &ini_im, const mglData &ray, mreal r=1, mreal k0=100) +{ return mglData(true, mgl_qo3d_solve(ham, &ini_re, &ini_im, &ray, r, k0, 0, 0, 0)); } +inline mglData mglQO3d(const char *ham, const mglData &ini_re, const mglData &ini_im, const mglData &ray, mglData &xx, mglData &yy, mglData &zz, mreal r=1, mreal k0=100) +{ return mglData(true, mgl_qo3d_solve(ham, &ini_re, &ini_im, &ray, r, k0, &xx, &yy, &zz)); } +/// Finds ray with starting point r0, p0 (and prepares ray data for mglQO2d) +inline mglData mglRay(const char *ham, mglPoint r0, mglPoint p0, mreal dt=0.1, mreal tmax=10) +{ return mglData(true, mgl_ray_trace(ham, r0.x, r0.y, r0.z, p0.x, p0.y, p0.z, dt, tmax)); } +/// Calculate Jacobian determinant for D{x(u,v), y(u,v)} = dx/du*dy/dv-dx/dv*dy/du +inline mglData mglJacobian(const mglData &x, const mglData &y) +{ return mglData(true, mgl_jacobian_2d(&x, &y)); } +/// Calculate Jacobian determinant for D{x(u,v,w), y(u,v,w), z(u,v,w)} +inline mglData mglJacobian(const mglData &x, const mglData &y, const mglData &z) +{ return mglData(true, mgl_jacobian_3d(&x, &y, &z)); } +/// Do something like Delone triangulation +inline mglData mglTriangulation(const mglData &x, const mglData &y, const mglData &z) +{ return mglData(true,mgl_triangulation_3d(&x,&y,&z)); } +inline mglData mglTriangulation(const mglData &x, const mglData &y) +{ return mglData(true,mgl_triangulation_2d(&x,&y)); } +//----------------------------------------------------------------------------- diff --git a/lang/mathgl.i b/lang/mathgl.i index 7069cfd..5bd9517 100644 --- a/lang/mathgl.i +++ b/lang/mathgl.i @@ -37,11 +37,9 @@ %{ #define SWIG_FILE_WITH_INIT -//#include "mgl2/config.h" #include "mgl2/type.h" #include "mgl2/data.h" #include "mgl2/mgl.h" -//#include "mgl2/window.h" %} #if MGL_USE_DOUBLE @@ -86,15 +84,13 @@ import_array(); %apply (int DIM1, int DIM2, int DIM3, double* IN_ARRAY3) {(int rows, int cols, int slc, const double* d)}; #endif -//%include "mgl2/config.h" -%include "mgl2/type.h" -%include "mgl2/data.h" -%include "mgl2/mgl.h" -//%include "mgl2/window.h" +%include "type.i" +%include "data.i" +%include "mgl.i" %extend mglData { - float __getitem__( int i) { return self->GetVal(i); }; - float __paren( int i) { return self->GetVal(i); }; - void __setitem__( int i, float y) { self->SetVal(y,i); }; - void __paren_asgn( int i, float y) { self->SetVal(y,i); }; + mreal __getitem__( int i) { return self->GetVal(i); }; + mreal __paren( int i) { return self->GetVal(i); }; + void __setitem__( int i, mreal y) { self->SetVal(y,i); }; + void __paren_asgn( int i, mreal y) { self->SetVal(y,i); }; }; diff --git a/lang/mgl.i b/lang/mgl.i new file mode 100644 index 0000000..88703ba --- /dev/null +++ b/lang/mgl.i @@ -0,0 +1,1309 @@ +/*************************************************************************** + * mgl.h is part of Math Graphic Library + * Copyright (C) 2007-2012 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +//----------------------------------------------------------------------------- +/// Wrapper class for all graphics +class mglGraph +{ +protected: + HMGL gr; +public: + inline mglGraph(int kind=0, int width=600, int height=400) + { + if(kind==-1) gr=NULL; +#if MGL_HAVE_OPENGL + else if(kind==1) gr=mgl_create_graph_gl(); +#else + else if(kind==1) + { gr=mgl_create_graph(width, height); + mglGlobalMess += "OpenGL support was disabled. Please, enable it and rebuild MathGL.\n"; } +#endif + else gr=mgl_create_graph(width, height); + } + inline mglGraph(const mglGraph &graph) + { gr = graph.gr; mgl_use_graph(gr,1); } + inline mglGraph(HMGL graph) + { gr = graph; mgl_use_graph(gr,1); } + virtual ~mglGraph() + { if(mgl_use_graph(gr,-1)<1) mgl_delete_graph(gr); } + /// Get pointer to internal mglCanvas object + inline HMGL Self() { return gr; } + /// Set default parameters for plotting + inline void DefaultPlotParam() { mgl_set_def_param(gr); } + /// Set name of plot for saving filename + inline void SetPlotId(const char *id) { mgl_set_plotid(gr,id); } + /// Get name of plot for saving filename + inline const char *GetPlotId() { return mgl_get_plotid(gr); } + + /// Set the transparency on/off. + inline void Alpha(bool enable) { mgl_set_alpha(gr, enable); } + /// Set default value of alpha-channel + inline void SetAlphaDef(double alpha) { mgl_set_alpha_default(gr, alpha); } + /// Set the transparency type (0 - usual, 1 - glass, 2 - lamp) + inline void SetTranspType(int type) { mgl_set_transp_type(gr, type); } + + /// Set the using of light on/off. + inline void Light(bool enable) { mgl_set_light(gr, enable); } + /// Switch on/off the specified light source. + inline void Light(int n,bool enable) { mgl_set_light_n(gr, n, enable); } + /// Use diffusive light (only for local light sources) -- OBSOLETE + inline void SetDifLight(bool dif) { mgl_set_light_dif(gr, dif); } + /// Add a light source. + inline void AddLight(int n, mglPoint p, char col='w', double bright=0.5, double ap=0) + { mgl_add_light_ext(gr, n, p.x, p.y, p.z, col, bright, ap); } + inline void AddLight(int n, mglPoint r, mglPoint p, char col='w', double bright=0.5, double ap=0) + { mgl_add_light_loc(gr, n, r.x, r.y, r.z, p.x, p.y, p.z, col, bright, ap); } + /// Set ambient light brightness + inline void SetAmbient(double i) { mgl_set_ambbr(gr, i); } + /// Set diffusive light brightness + inline void SetDiffuse(double i) { mgl_set_difbr(gr, i); } + /// Set the fog distance or switch it off (if d=0). + inline void Fog(double d, double dz=0.25) { mgl_set_fog(gr, d, dz); } + + /// Set relative width of rectangles in Bars, Barh, BoxPlot + inline void SetBarWidth(double width) { mgl_set_bar_width(gr, width); } + /// Set default size of marks (locally you can use "size" option) + inline void SetMarkSize(double size) { mgl_set_mark_size(gr, size); } + /// Set default size of arrows (locally you can use "size" option) + inline void SetArrowSize(double size) { mgl_set_arrow_size(gr, size); } + /// Set number of mesh lines (use 0 to draw all of them) + inline void SetMeshNum(int num) { mgl_set_meshnum(gr, num); } + /// Set number of visible faces (use 0 to draw all of them) + inline void SetFaceNum(int num) { mgl_set_facenum(gr, num); } + + /// Set cutting for points outside of bounding box + inline void SetCut(bool cut) { mgl_set_cut(gr, cut); } + /// Set additional cutting box + inline void SetCutBox(mglPoint p1, mglPoint p2) + { mgl_set_cut_box(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z); } + /// Set the cutting off condition (formula) + inline void CutOff(const char *EqC) { mgl_set_cutoff(gr, EqC); } + + /// Set default font size + inline void SetFontSize(double size) { mgl_set_font_size(gr, size); } + /// Set default font style and color + inline void SetFontDef(const char *fnt) { mgl_set_font_def(gr, fnt); } + /// Set FontSize by size in pt and picture DPI (default is 16 pt for dpi=72) + virtual void SetFontSizePT(double pt, int dpi=72){ SetFontSize(pt*27.f/dpi); } + /// Set FontSize by size in centimeters and picture DPI (default is 0.56 cm = 16 pt) + inline void SetFontSizeCM(double cm, int dpi=72) { SetFontSizePT(cm*28.45f,dpi); } + /// Set FontSize by size in inch and picture DPI (default is 0.22 in = 16 pt) + inline void SetFontSizeIN(double in, int dpi=72) { SetFontSizePT(in*72.27f,dpi); } + /// Load font from file + inline void LoadFont(const char *name, const char *path=NULL) + { mgl_load_font(gr, name, path); } + /// Copy font from another mglGraph instance + inline void CopyFont(const mglGraph *GR) { mgl_copy_font(gr, GR->gr);} + /// Restore font (load default font for new HMGL objects) + inline void RestoreFont() { mgl_restore_font(gr); } + /// Set to use or not text rotation + inline void SetRotatedText(bool rotated) { mgl_set_rotated_text(gr, rotated); } + + /// Set default palette + inline void SetPalette(const char *colors) { mgl_set_palette(gr, colors); } + /// Set default color scheme + inline void SetDefScheme(const char *sch) { mgl_set_def_sch(gr, sch); } + + /// Sets RGB values for color with given id + static inline void SetColor(char id, double r, double g, double b) { mgl_set_color(id, r, g, b); } + /// Set mask for face coloring as array of type 'unsigned char[8]' + static inline void SetMask(char id, const char *mask) { mgl_set_mask(id, mask); } + /// Set mask for face coloring as uint64_t number + static inline void SetMask(char id, uint64_t mask) { mgl_set_mask_val(id, mask); } + /// Set default mask rotation angle + inline void SetMaskAngle(int angle) { mgl_set_mask_angle(gr, angle); } + + /// Get last warning code + inline int GetWarn() { return mgl_get_warn(gr);} + /// Set warning code ant fill message + inline void SetWarn(int code, const char *info) { mgl_set_warn(gr,code,info); } + /// Set buffer for warning messages + inline const char *Message() { return mgl_get_mess(gr); } + + /// Set axis range scaling -- simplified way to shift/zoom axis range -- need to replot whole image! + inline void ZoomAxis(mglPoint p1=mglPoint(0,0,0,0), mglPoint p2=mglPoint(1,1,1,1)) + { mgl_zoom_axis(gr, p1.x,p1.y,p1.z,p1.c, p2.x,p2.y,p2.z,p2.c); } + /// Set range in direction dir as [v1, v2] + inline void SetRange(char dir, double v1, double v2) + { mgl_set_range_val(gr, dir, v1, v2); } + /// Set range in direction dir as minimal and maximal values of data a + inline void SetRange(char dir, const mglData &dat, bool add=false) + { mgl_set_range_dat(gr, dir, &dat, add); } + /// Set values of axis range as minimal and maximal values of datas + inline void SetRanges(const mglData &xx, const mglData &yy, const mglData &zz, const mglData &cc) + { mgl_set_range_dat(gr,'x',&xx,0); mgl_set_range_dat(gr,'y',&yy,0); + mgl_set_range_dat(gr,'z',&zz,0); mgl_set_range_dat(gr,'c',&cc,0); } + /// Set values of axis range as minimal and maximal values of datas + inline void SetRanges(const mglData &xx, const mglData &yy, const mglData &zz) + { mgl_set_range_dat(gr,'x',&xx,0); mgl_set_range_dat(gr,'y',&yy,0); + mgl_set_range_dat(gr,'z',&zz,0); mgl_set_range_dat(gr,'c',&zz,0); } + /// Set values of axis range as minimal and maximal values of datas + inline void SetRanges(const mglData &xx, const mglData &yy) + { mgl_set_range_dat(gr,'x',&xx,0); mgl_set_range_dat(gr,'y',&yy,0); } + /// Set values of axis ranges + inline void SetRanges(double x1, double x2, double y1, double y2, double z1=0, double z2=0) + { mgl_set_ranges(gr, x1, x2, y1, y2, z1, z2); } + /// Set values of axis ranges + inline void SetRanges(mglPoint p1, mglPoint p2) + { mgl_set_ranges(gr, p1.x, p2.x, p1.y, p2.y, p1.z, p2.z); } + /// Set ranges for automatic variables + inline void SetAutoRanges(double x1, double x2, double y1=0, double y2=0, double z1=0, double z2=0, double c1=0, double c2=0) + { mgl_set_auto_ranges(gr, x1, x2, y1, y2, z1, z2, c1, c2); } + /// Set ranges for automatic variables + inline void SetAutoRanges(mglPoint p1, mglPoint p2) + { mgl_set_auto_ranges(gr, p1.x, p2.x, p1.y, p2.y, p1.z, p2.z, p1.c, p2.c); } + /// Set axis origin + inline void SetOrigin(mglPoint p) + { mgl_set_origin(gr, p.x, p.y, p.z); } + inline void SetOrigin(double x0, double y0, double z0=NaN) + { mgl_set_origin(gr, x0, y0, z0); } + + /// Set the transformation formulas for coordinate + inline void SetFunc(const char *EqX, const char *EqY, const char *EqZ=NULL, const char *EqA=NULL) + { mgl_set_func(gr, EqX, EqY, EqZ, EqA); } + /// Set one of predefined transformation rule + inline void SetCoor(int how) { mgl_set_coor(gr, how); } + /// Set to draw Ternary axis (triangle like axis, grid and so on) + inline void Ternary(int val) { mgl_set_ternary(gr, val); } + + /// Set to use or not tick labels rotation + inline void SetTickRotate(bool val) { mgl_set_tick_rotate(gr,val); } + /// Set to use or not tick labels skipping + inline void SetTickSkip(bool val) { mgl_set_tick_skip(gr,val); } + /// Set tick length + inline void SetTickLen(double len, double stt=1) + { mgl_set_tick_len(gr, len, stt); } + /// Set axis and ticks style + inline void SetAxisStl(const char *stl="k", const char *tck=0, const char *sub=0) + { mgl_set_axis_stl(gr, stl, tck, sub); } + + /// Set time templates for ticks + inline void SetTicksTime(char dir, double d=0, const char *t="") + { mgl_set_ticks_time(gr,dir,d,t); } + /// Set ticks text (\n separated). Use "" to disable this feature. + inline void SetTicksVal(char dir, const char *lbl, bool add=false) + { mgl_set_ticks_str(gr,dir,lbl,add); } + inline void SetTicksVal(char dir, const wchar_t *lbl, bool add=false) + { mgl_set_ticks_wcs(gr,dir,lbl,add); } + /// Set ticks position and text (\n separated). Use "" to disable this feature. + inline void SetTicksVal(char dir, const mglData &v, const char *lbl, bool add=false) + { mgl_set_ticks_val(gr,dir,&v,lbl,add); } + inline void SetTicksVal(char dir, const mglData &v, const wchar_t *lbl, bool add=false) + { mgl_set_ticks_valw(gr,dir,&v,lbl,add); } + /// Set the ticks parameters + inline void SetTicks(char dir, double d=0, int ns=0, double org=NaN) + { mgl_set_ticks(gr, dir, d, ns, org); } + /// Auto adjust ticks + inline void Adjust(const char *dir="xyzc") + { mgl_adjust_ticks(gr, dir); } + /// Set templates for ticks + inline void SetTickTempl(char dir, const char *t) + { mgl_set_tick_templ(gr,dir,t); } + inline void SetTickTempl(char dir, const wchar_t *t) + { mgl_set_tick_templw(gr,dir,t); } + /// Tune ticks + inline void SetTuneTicks(int tune, double fact_pos=1.15) + { mgl_tune_ticks(gr, tune, fact_pos); } + /// Set additional shift of tick labels + inline void SetTickShift(mglPoint p) + { mgl_set_tick_shift(gr,p.x,p.y,p.z,p.c); } + /// Set to use UTC time instead of local time + inline void SetTimeUTC(bool enable) + { mgl_set_flag(gr,enable, MGL_USE_GMTIME); } + /// Set to draw tick labels at axis origin + inline void SetOriginTick(bool enable=true) + { mgl_set_flag(gr,!enable, MGL_NO_ORIGIN); } + + /// Put further plotting in some region of whole frame. + inline void SubPlot(int nx,int ny,int m,const char *style="<>_^", double dx=0, double dy=0) + { mgl_subplot_d(gr, nx, ny, m, style, dx, dy); } + /// Like SubPlot() but "join" several cells + inline void MultiPlot(int nx,int ny,int m, int dx, int dy, const char *style="<>_^") + { mgl_multiplot(gr, nx, ny, m, dx, dy, style); } + /// Put further plotting in a region of whole frame. + inline void InPlot(double x1,double x2,double y1,double y2, bool rel=true) + { if(rel) mgl_relplot(gr, x1, x2, y1, y2); + else mgl_inplot(gr, x1, x2, y1, y2); } + /// Put further plotting in column cell of previous subplot + inline void ColumnPlot(int num, int ind, double d=0) + { mgl_columnplot(gr,num,ind,d); } + /// Put further plotting in matrix cell of previous subplot + inline void GridPlot(int nx, int ny, int ind, double d=0) + { mgl_gridplot(gr,nx,ny,ind,d); } + /// Put further plotting in cell of stick rotated on angles tet, phi + inline void StickPlot(int num, int i, double tet, double phi) + { mgl_stickplot(gr,num,i,tet,phi); } + + /// Set factor of plot size + inline void SetPlotFactor(double val) + { mgl_set_plotfactor(gr,val); } + /// Push transformation matrix into stack + inline void Push() { mgl_mat_push(gr); } + /// Pop transformation matrix from stack + inline void Pop() { mgl_mat_pop(gr); } + + /// Add title for current subplot/inplot + inline void Title(const char *title,const char *stl="",double size=-2) + { mgl_title(gr,title,stl,size); } + inline void Title(const wchar_t *title,const char *stl="",double size=-2) + { mgl_titlew(gr,title,stl,size); } + /// Set aspect ratio for further plotting. + inline void Aspect(double Ax,double Ay,double Az=1) + { mgl_aspect(gr, Ax, Ay, Az); } + /// Rotate a further plotting. + inline void Rotate(double TetX,double TetZ=0,double TetY=0) + { mgl_rotate(gr, TetX, TetZ, TetY); } + /// Rotate a further plotting around vector {x,y,z}. + inline void RotateN(double Tet,double x,double y,double z) + { mgl_rotate_vector(gr, Tet, x, y, z); } + /// Set perspective (in range [0,1)) for plot. Set to zero for switching off. + inline void Perspective(double val) + { mgl_perspective(gr, val); } + /// Set angle of view independently from Rotate(). + inline void View(double TetX,double TetZ=0,double TetY=0) + { mgl_view(gr, TetX, TetZ, TetY); } + /// Zoom in/out a part of picture (use Zoom(0, 0, 1, 1) for restore default) + inline void Zoom(double x1, double y1, double x2, double y2) + { mgl_zoom(gr, x1, y1, x2, y2); } + + /// Set size of frame in pixels. Normally this function is called internally. + inline void SetSize(int width, int height) { mgl_set_size(gr, width, height); } + /// Set plot quality + inline void SetQuality(int qual=MGL_DRAW_NORM) { mgl_set_quality(gr, qual); } + /// Get plot quality + inline int GetQuality() { return mgl_get_quality(gr); } + /// Set drawing region for Quality&4 + inline void SetDrawReg(long nx, long ny, long m){ mgl_set_draw_reg(gr,nx,ny,m); } + /// Start group of objects + inline void StartGroup(const char *name) { mgl_start_group(gr, name); } + /// End group of objects + inline void EndGroup() { mgl_end_group(gr); } + /// Highlight objects with given id + inline void Highlight(int id) { mgl_highlight(gr, id); } + + /// Show current image + inline void ShowImage(const char *viewer, bool keep=0) + { mgl_show_image(gr, viewer, keep); } + /// Write the frame in file (depending extension, write current frame if fname is empty) + inline void WriteFrame(const char *fname=0,const char *descr="") + { mgl_write_frame(gr, fname, descr); } + /// Write the frame in file using JPEG format + inline void WriteJPEG(const char *fname,const char *descr="") + { mgl_write_jpg(gr, fname, descr); } + /// Write the frame in file using PNG format with transparency + inline void WritePNG(const char *fname,const char *descr="", bool alpha=true) + { if(alpha) mgl_write_png(gr, fname, descr); + else mgl_write_png_solid(gr, fname, descr); } + /// Write the frame in file using BMP format + inline void WriteBMP(const char *fname,const char *descr="") + { mgl_write_bmp(gr, fname, descr); } + /// Write the frame in file using BMP format + inline void WriteTGA(const char *fname,const char *descr="") + { mgl_write_tga(gr, fname, descr); } + /// Write the frame in file using PostScript format + inline void WriteEPS(const char *fname,const char *descr="") + { mgl_write_eps(gr, fname, descr); } + /// Write the frame in file using LaTeX format + inline void WriteTEX(const char *fname,const char *descr="") + { mgl_write_tex(gr, fname, descr); } + /// Write the frame in file using PostScript format as bitmap + inline void WriteBPS(const char *fname,const char *descr="") + { mgl_write_bps(gr, fname, descr); } + /// Write the frame in file using SVG format + inline void WriteSVG(const char *fname,const char *descr="") + { mgl_write_svg(gr, fname, descr); } + /// Write the frame in file using GIF format (only for current frame!) + inline void WriteGIF(const char *fname,const char *descr="") + { mgl_write_gif(gr, fname, descr); } + + /// Write the frame in file using OBJ format + inline void WriteOBJ(const char *fname,const char *descr="",bool use_png=true) + { mgl_write_obj(gr, fname, descr, use_png); } + /// Write the frame in file using OBJ format - Balakin way + inline void WriteOBJold(const char *fname,const char *descr="",bool use_png=true) + { mgl_write_obj_old(gr, fname, descr, use_png); } + /// Write the frame in file using XYZ format + inline void WriteXYZ(const char *fname,const char *descr="") + { mgl_write_xyz(gr, fname, descr); } + /// Write the frame in file using STL format (faces only) + inline void WriteSTL(const char *fname,const char *descr="") + { mgl_write_stl(gr, fname, descr); } + /// Write the frame in file using OFF format + inline void WriteOFF(const char *fname,const char *descr="", bool colored=false) + { mgl_write_off(gr, fname, descr,colored); } +// /// Write the frame in file using X3D format +// inline void WriteX3D(const char *fname,const char *descr="") +// { mgl_write_x3d(gr, fname, descr); } + /// Write the frame in file using PRC format + inline void WritePRC(const char *fname,const char *descr="",bool make_pdf=true) + { mgl_write_prc(gr, fname, descr, make_pdf); } + /// Export in JSON format suitable for later drawing by JavaScript + inline void WriteJSON(const char *fname,const char *descr="",bool force_z=false) + { if(force_z) mgl_write_json_z(gr, fname, descr); + else mgl_write_json(gr, fname, descr); } + /// Return string of JSON data suitable for later drawing by JavaScript + inline const char *GetJSON() { return mgl_get_json(gr); } + + /// Force preparing the image. It can be useful for OpenGL mode mostly. + inline void Finish() { mgl_finish(gr); } + /// Create new frame. + inline void NewFrame() { mgl_new_frame(gr); } + /// Finish frame drawing + inline void EndFrame() { mgl_end_frame(gr); } + /// Get the number of created frames + inline int GetNumFrame() { return mgl_get_num_frame(gr); } + /// Reset frames counter (start it from zero) + inline void ResetFrames() { mgl_reset_frames(gr); } + /// Delete primitives for i-th frame (work if MGL_VECT_FRAME is set on) + inline void DelFrame(int i) { mgl_del_frame(gr, i); } + /// Get drawing data for i-th frame (work if MGL_VECT_FRAME is set on) + inline void GetFrame(int i) { mgl_get_frame(gr, i); } + /// Set drawing data for i-th frame (work if MGL_VECT_FRAME is set on). Work as EndFrame() but don't add frame to GIF image. + inline void SetFrame(int i) { mgl_set_frame(gr, i); } + /// Append drawing data from i-th frame (work if MGL_VECT_FRAME is set on) + inline void ShowFrame(int i){ mgl_show_frame(gr, i); } + + /// Start write frames to cinema using GIF format + inline void StartGIF(const char *fname, int ms=100) + { mgl_start_gif(gr, fname,ms); } + /// Stop writing cinema using GIF format + inline void CloseGIF() { mgl_close_gif(gr); } + /// Export points and primitives in file using MGLD format + inline void ExportMGLD(const char *fname, const char *descr=0) + { mgl_export_mgld(gr, fname, descr); } + /// Import points and primitives from file using MGLD format + inline void ImportMGLD(const char *fname, bool add=false) + { mgl_import_mgld(gr, fname, add); } + + /// Copy RGB values into array which is allocated by user + inline void GetRGB(char *imgdata, int imglen) + { + long w=mgl_get_width(gr), h=mgl_get_height(gr); + if(imglen>=3*w*h) memcpy(imgdata, mgl_get_rgb(gr),3*w*h); + } + inline const unsigned char *GetRGB() { return mgl_get_rgb(gr); } + /// Copy RGBA values into array which is allocated by user + inline void GetRGBA(char *imgdata, int imglen) + { + long w=mgl_get_width(gr), h=mgl_get_height(gr); + if(imglen>=4*w*h) memcpy(imgdata, mgl_get_rgba(gr),4*w*h); + } + inline const unsigned char *GetRGBA() { return mgl_get_rgba(gr); } + /// Copy BGRN values into array which is allocated by user + inline void GetBGRN(unsigned char *imgdata, int imglen) + { + long w=mgl_get_width(gr), h=mgl_get_height(gr), i; + const unsigned char *buf=mgl_get_rgb(gr); + if(imglen>=4*w*h) for(i=0;igr); } + + /// Clear up the frame + inline void Clf(double r, double g, double b) { mgl_clf_rgb(gr, r, g, b); } + inline void Clf(char col) { mgl_clf_chr(gr, col); } + inline void Clf() { mgl_clf(gr); } + /// Clear unused points and primitives. Useful only in combination with SetFaceNum(). + inline void ClearUnused() { mgl_clear_unused(gr); } + /// Draws the point (ball) at position {x,y,z} with color c + inline void Ball(mglPoint p, char c='r') + { char s[3]={'.',c,0}; mgl_mark(gr, p.x, p.y, p.z, s); } + /// Draws the mark at position p + inline void Mark(mglPoint p, const char *mark) + { mgl_mark(gr, p.x, p.y, p.z, mark); } + /// Draws the line between points by specified pen + inline void Line(mglPoint p1, mglPoint p2, const char *pen="B",int n=2) + { mgl_line(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, pen, n); } + /// Draws the spline curve between points by specified pen + inline void Curve(mglPoint p1, mglPoint d1, mglPoint p2, mglPoint d2, const char *pen="B", int n=100) + { mgl_curve(gr, p1.x, p1.y, p1.z, d1.x, d1.y, d1.z, p2.x, p2.y, p2.z, d2.x, d2.y, d2.z, pen, n); } + /// Draws the 3d error box e for point p + inline void Error(mglPoint p, mglPoint e, const char *pen="k") + { mgl_error_box(gr, p.x, p.y, p.z, e.x, e.y, e.z, pen); } + + /// Draws the face between points with color stl (include interpolation up to 4 colors). + inline void Face(mglPoint p1, mglPoint p2, mglPoint p3, mglPoint p4, const char *stl="r") + { mgl_face(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, p3.x, p3.y, p3.z, p4.x, p4.y, p4.z, stl); } + /// Draws the face in y-z plane at point p with color stl (include interpolation up to 4 colors). + inline void FaceX(mglPoint p, double wy, double wz, const char *stl="w", double dx=0, double dy=0) + { mgl_facex(gr, p.x, p.y, p.z, wy, wz, stl, dx, dy); } + /// Draws the face in x-z plane at point p with color stl (include interpolation up to 4 colors). + inline void FaceY(mglPoint p, double wx, double wz, const char *stl="w", double dx=0, double dy=0) + { mgl_facey(gr, p.x, p.y, p.z, wx, wz, stl, dx, dy); } + /// Draws the face in x-y plane at point p with color stl (include interpolation up to 4 colors). + inline void FaceZ(mglPoint p, double wx, double wy, const char *stl="w", double dx=0, double dy=0) + { mgl_facez(gr, p.x, p.y, p.z, wx, wy, stl, dx, dy); } + /// Draws the drop at point p in direction d with color col and radius r + inline void Drop(mglPoint p, mglPoint d, double r, const char *col="r", double shift=1, double ap=1) + { mgl_drop(gr, p.x, p.y, p.z, d.x, d.y, d.z, r, col, shift, ap); } + /// Draws the sphere at point p with color col and radius r + inline void Sphere(mglPoint p, double r, const char *col="r") + { mgl_sphere(gr, p.x, p.y, p.z, r, col); } + /// Draws the cone between points p1,p2 with radius r1,r2 and with style stl + inline void Cone(mglPoint p1, mglPoint p2, double r1, double r2=-1, const char *stl="r@") + { mgl_cone(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z,r1,r2,stl); } + /// Draws the ellipse between points p1,p2 with color stl and width r + inline void Ellipse(mglPoint p1, mglPoint p2, double r, const char *stl="r") + { mgl_ellipse(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, r,stl); } + /// Draws the circle at point p with color stl and radius r + inline void Circle(mglPoint p, double r, const char *stl="r") + { mgl_ellipse(gr, p.x, p.y, p.z, p.x, p.y, p.z, r,stl); } + /// Draws the rhomb between points p1,p2 with color stl and width r + inline void Rhomb(mglPoint p1, mglPoint p2, double r, const char *stl="r") + { mgl_rhomb(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, r,stl); } + + /// Print text in position p with specified font + inline void Putsw(mglPoint p,const wchar_t *text,const char *font=":C",double size=-1) + { mgl_putsw(gr, p.x, p.y, p.z, text, font, size); } + inline void Puts(mglPoint p,const char *text,const char *font=":C",double size=-1) + { mgl_puts(gr, p.x, p.y, p.z, text, font, size); } + inline void Putsw(double x, double y,const wchar_t *text,const char *font=":AC",double size=-1) + { mgl_putsw(gr, x, y, 0, text, font, size); } + inline void Puts(double x, double y,const char *text,const char *font=":AC",double size=-1) + { mgl_puts(gr, x, y, 0, text, font, size); } + /// Print text in position p along direction d with specified font + inline void Putsw(mglPoint p, mglPoint d, const wchar_t *text, const char *font=":L", double size=-1) + { mgl_putsw_dir(gr, p.x, p.y, p.z, d.x, d.y, d.z, text, font, size); } + inline void Puts(mglPoint p, mglPoint d, const char *text, const char *font=":L", double size=-1) + { mgl_puts_dir(gr, p.x, p.y, p.z, d.x, d.y, d.z, text, font, size); } + + /// Print text along the curve + inline void Text(const mglData &x, const mglData &y, const mglData &z, const char *text, const char *font="", const char *opt="") + { mgl_text_xyz(gr, &x, &y, &z, text, font, opt); } + inline void Text(const mglData &x, const mglData &y, const char *text, const char *font="", const char *opt="") + { mgl_text_xy(gr, &x, &y, text, font, opt); } + inline void Text(const mglData &y, const char *text, const char *font="", const char *opt="") + { mgl_text_y(gr, &y, text, font, opt); } + inline void Text(const mglData &x, const mglData &y, const mglData &z, const wchar_t *text, const char *font="", const char *opt="") + { mgl_textw_xyz(gr, &x, &y, &z, text, font, opt); } + inline void Text(const mglData &x, const mglData &y, const wchar_t *text, const char *font="", const char *opt="") + { mgl_textw_xy(gr, &x, &y, text, font, opt); } + inline void Text(const mglData &y, const wchar_t *text, const char *font="", const char *opt="") + { mgl_textw_y(gr, &y, text, font, opt); } + + /// Draws bounding box outside the plotting volume with color c. + inline void Box(const char *col="", bool ticks=true) + { mgl_box_str(gr, col, ticks); } + /// Draw axises with ticks in direction(s) dir. + inline void Axis(const char *dir="xyzt", const char *stl="", const char *opt="") + { mgl_axis(gr, dir,stl,opt); } + /// Draw grid lines perpendicular to direction(s) dir. + inline void Grid(const char *dir="xyzt",const char *pen="B", const char *opt="") + { mgl_axis_grid(gr, dir, pen, opt); } + /// Print the label text for axis dir. + inline void Label(char dir, const char *text, double pos=+1, const char *opt="") + { mgl_label(gr, dir, text, pos, opt); } + inline void Label(char dir, const wchar_t *text, double pos=+1, const char *opt="") + { mgl_labelw(gr, dir, text, pos, opt); } + + /// Draw colorbar at edge of axis + inline void Colorbar(const char *sch="") + { mgl_colorbar(gr, sch); } + inline void Colorbar(const char *sch,double x,double y,double w=1,double h=1) + { mgl_colorbar_ext(gr, sch, x,y,w,h); } + /// Draw colorbar with manual colors at edge of axis + inline void Colorbar(const mglData &val, const char *sch="") + { mgl_colorbar_val(gr, &val, sch); } + inline void Colorbar(const mglData &val, const char *sch,double x,double y,double w=1,double h=1) + { mgl_colorbar_val_ext(gr, &val, sch, x,y,w,h); } + + /// Add string to legend + inline void AddLegend(const char *text,const char *style) + { mgl_add_legend(gr, text, style); } + inline void AddLegend(const wchar_t *text,const char *style) + { mgl_add_legendw(gr, text, style); } + /// Clear saved legend string + inline void ClearLegend() + { mgl_clear_legend(gr); } + /// Draw legend of accumulated strings at position {x,y} + inline void Legend(double x, double y, const char *font="#", const char *opt="") + { mgl_legend_pos(gr, x, y, font, opt); } + /// Draw legend of accumulated strings + inline void Legend(int where=3, const char *font="#", const char *opt="") + { mgl_legend(gr, where, font, opt); } + /// Set number of marks in legend sample + inline void SetLegendMarks(int num) { mgl_set_legend_marks(gr, num); } + + /// Draw usual curve {x,y,z} + inline void Plot(const mglData &x, const mglData &y, const mglData &z, const char *pen="", const char *opt="") + { mgl_plot_xyz(gr, &x, &y, &z, pen, opt); } + inline void Plot(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_plot_xy(gr, &x, &y, pen,opt); } + inline void Plot(const mglData &y, const char *pen="", const char *opt="") + { mgl_plot(gr, &y, pen,opt); } + /// Draw tape(s) which rotates as (bi-)normales of curve {x,y,z} + inline void Tape(const mglData &x, const mglData &y, const mglData &z, const char *pen="", const char *opt="") + { mgl_tape_xyz(gr, &x, &y, &z, pen, opt); } + inline void Tape(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_tape_xy(gr, &x, &y, pen,opt); } + inline void Tape(const mglData &y, const char *pen="", const char *opt="") + { mgl_tape(gr, &y, pen,opt); } + /// Draw radar chart (plot in curved coordinates) + inline void Radar(const mglData &a, const char *pen="", const char *opt="") + { mgl_radar(gr, &a, pen, opt); } + /// Draw stairs for points in arrays {x,y,z} + inline void Step(const mglData &x, const mglData &y, const mglData &z, const char *pen="", const char *opt="") + { mgl_step_xyz(gr, &x, &y, &z, pen, opt); } + inline void Step(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_step_xy(gr, &x, &y, pen, opt); } + inline void Step(const mglData &y, const char *pen="", const char *opt="") + { mgl_step(gr, &y, pen, opt); } + /// Draw curve {x,y,z} which is colored by c (like tension plot) + inline void Tens(const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *pen="", const char *opt="") + { mgl_tens_xyz(gr, &x, &y, &z, &c, pen, opt); } + inline void Tens(const mglData &x, const mglData &y, const mglData &c, const char *pen="", const char *opt="") + { mgl_tens_xy(gr, &x, &y, &c, pen, opt); } + inline void Tens(const mglData &y, const mglData &c, const char *pen="", const char *opt="") + { mgl_tens(gr, &y, &c, pen, opt); } + /// Fill area between curve {x,y,z} and axis plane + inline void Area(const mglData &x, const mglData &y, const mglData &z, const char *pen="", const char *opt="") + { mgl_area_xyz(gr, &x, &y, &z, pen, opt); } + inline void Area(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_area_xy(gr, &x, &y, pen, opt); } + inline void Area(const mglData &y, const char *pen="", const char *opt="") + { mgl_area(gr, &y, pen, opt); } + /// Fill area between curves y1 and y2 specified parametrically + inline void Region(const mglData &y1, const mglData &y2, const char *pen="", const char *opt="") + { mgl_region(gr, &y1, &y2, pen, opt); } + inline void Region(const mglData &x, const mglData &y1, const mglData &y2, const char *pen="", const char *opt="") + { mgl_region_xy(gr, &x, &y1, &y2, pen, opt); } + /// Draw vertical lines from points {x,y,z} to axis plane + inline void Stem(const mglData &x, const mglData &y, const mglData &z, const char *pen="", const char *opt="") + { mgl_stem_xyz(gr, &x, &y, &z, pen, opt); } + inline void Stem(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_stem_xy(gr, &x, &y, pen, opt); } + inline void Stem(const mglData &y, const char *pen="", const char *opt="") + { mgl_stem(gr, &y, pen, opt); } + + /// Draw vertical bars from points {x,y,z} to axis plane + inline void Bars(const mglData &x, const mglData &y, const mglData &z, const char *pen="", const char *opt="") + { mgl_bars_xyz(gr, &x, &y, &z, pen, opt); } + inline void Bars(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_bars_xy(gr, &x, &y, pen, opt); } + inline void Bars(const mglData &y, const char *pen="", const char *opt="") + { mgl_bars(gr, &y, pen, opt); } + /// Draw horizontal bars from points {x,y} to axis plane + inline void Barh(const mglData &y, const mglData &v, const char *pen="", const char *opt="") + { mgl_barh_yx(gr, &y, &v, pen, opt); } + inline void Barh(const mglData &v, const char *pen="", const char *opt="") + { mgl_barh(gr, &v, pen, opt); } + /// Draw chart for data a + inline void Chart(const mglData &a, const char *colors="", const char *opt="") + { mgl_chart(gr, &a, colors,opt); } + /// Draw Open-High-Low-Close (OHLC) diagram + inline void OHLC(const mglData &x, const mglData &open, const mglData &high, const mglData &low, const mglData &close, const char *pen="", const char *opt="") + { mgl_ohlc_x(gr, &x, &open,&high,&low,&close,pen,opt); } + inline void OHLC(const mglData &open, const mglData &high, const mglData &low, const mglData &close, const char *pen="", const char *opt="") + { mgl_ohlc(gr, &open,&high,&low,&close,pen,opt); } + + /// Draw box-plot (special 5-value plot used in statistic) + inline void BoxPlot(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_boxplot_xy(gr, &x, &y, pen,opt); } + inline void BoxPlot(const mglData &y, const char *pen="", const char *opt="") + { mgl_boxplot(gr, &y, pen,opt); } + /// Draw candle plot + inline void Candle(const mglData &x, const mglData &v1, const mglData &v2, const mglData &y1, const mglData &y2, const char *pen="", const char *opt="") + { mgl_candle_xyv(gr, &x, &v1, &v2, &y1, &y2, pen, opt); } + inline void Candle(const mglData &v1, const mglData &v2, const mglData &y1, const mglData &y2, const char *pen="", const char *opt="") + { mgl_candle_yv(gr, &v1, &v2, &y1, &y2, pen, opt); } + inline void Candle(const mglData &v1, const mglData &v2, const char *pen="", const char *opt="") + { mgl_candle_yv(gr, &v1, &v2, NULL, NULL, pen, opt); } + inline void Candle(const mglData &y, const mglData &y1, const mglData &y2, const char *pen="", const char *opt="") + { mgl_candle(gr, &y, &y1, &y2, pen, opt); } + inline void Candle(const mglData &y, const char *pen="", const char *opt="") + { mgl_candle(gr, &y, NULL, NULL, pen, opt); } + /// Draw cones from points {x,y,z} to axis plane + inline void Cones(const mglData &x, const mglData &y, const mglData &z, const char *pen="@", const char *opt="") + { mgl_cones_xyz(gr, &x, &y, &z, pen, opt); } + inline void Cones(const mglData &x, const mglData &z, const char *pen="@", const char *opt="") + { mgl_cones_xz(gr, &x, &z, pen, opt); } + inline void Cones(const mglData &z, const char *pen="@", const char *opt="") + { mgl_cones(gr, &z, pen, opt); } + + /// Draw error boxes {ex,ey} at points {x,y} + inline void Error(const mglData &y, const mglData &ey, const char *pen="", const char *opt="") + { mgl_error(gr, &y, &ey, pen, opt); } + inline void Error(const mglData &x, const mglData &y, const mglData &ey, const char *pen="", const char *opt="") + { mgl_error_xy(gr, &x, &y, &ey, pen, opt); } + inline void Error(const mglData &x, const mglData &y, const mglData &ex, const mglData &ey, const char *pen="", const char *opt="") + { mgl_error_exy(gr, &x, &y, &ex, &ey, pen, opt); } + /// Draw marks with size r at points {x,y,z} + inline void Mark(const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *pen, const char *opt="") + { mgl_mark_xyz(gr, &x, &y, &z, &r, pen, opt); } + inline void Mark(const mglData &x, const mglData &y, const mglData &r, const char *pen, const char *opt="") + { mgl_mark_xy(gr, &x, &y, &r, pen, opt); } + inline void Mark(const mglData &y, const mglData &r, const char *pen, const char *opt="") + { mgl_mark_y(gr, &y, &r, pen, opt); } + /// Draw textual marks with size r at points {x,y,z} + inline void TextMark(const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *text, const char *fnt="", const char *opt="") + { mgl_textmark_xyzr(gr, &x, &y, &z, &r, text, fnt, opt); } + inline void TextMark(const mglData &x, const mglData &y, const mglData &r, const char *text, const char *fnt="", const char *opt="") + { mgl_textmark_xyr(gr, &x, &y, &r, text, fnt, opt); } + inline void TextMark(const mglData &y, const mglData &r, const char *text, const char *fnt="", const char *opt="") + { mgl_textmark_yr(gr, &y, &r, text, fnt, opt); } + inline void TextMark(const mglData &y, const char *text, const char *fnt="", const char *opt="") + { mgl_textmark(gr, &y, text, fnt, opt); } + inline void TextMark(const mglData &x, const mglData &y, const mglData &z, const mglData &r, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_textmarkw_xyzr(gr, &x, &y, &z, &r, text, fnt, opt); } + inline void TextMark(const mglData &x, const mglData &y, const mglData &r, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_textmarkw_xyr(gr, &x, &y, &r, text, fnt, opt); } + inline void TextMark(const mglData &y, const mglData &r, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_textmarkw_yr(gr, &y, &r, text, fnt, opt); } + inline void TextMark(const mglData &y, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_textmarkw(gr, &y, text, fnt, opt); } + + /// Draw labels for points coordinate(s) at points {x,y,z} + inline void Label(const mglData &x, const mglData &y, const mglData &z, const char *text, const char *fnt="", const char *opt="") + { mgl_label_xyz(gr, &x, &y, &z, text, fnt, opt); } + inline void Label(const mglData &x, const mglData &y, const char *text, const char *fnt="", const char *opt="") + { mgl_label_xy(gr, &x, &y, text, fnt, opt); } + inline void Label(const mglData &y, const char *text, const char *fnt="", const char *opt="") + { mgl_label_y(gr, &y, text, fnt, opt); } + inline void Label(const mglData &x, const mglData &y, const mglData &z, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_labelw_xyz(gr, &x, &y, &z, text, fnt, opt); } + inline void Label(const mglData &x, const mglData &y, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_labelw_xy(gr, &x, &y, text, fnt, opt); } + inline void Label(const mglData &y, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_labelw_y(gr, &y, text, fnt, opt); } + + /// Draw table for values val along given direction with row labels text + inline void Table(const mglData &val, const char *text, const char *fnt="#|", const char *opt="") + { mgl_table(gr, 0, 0, &val, text, fnt, opt); } + inline void Table(const mglData &val, const wchar_t *text, const char *fnt="#|", const char *opt="") + { mgl_tablew(gr, 0, 0, &val, text, fnt, opt); } + /// Draw table for values val along given direction with row labels text at given position + inline void Table(double x, double y, const mglData &val, const char *text, const char *fnt="#|", const char *opt="") + { mgl_table(gr, x, y, &val, text, fnt, opt); } + inline void Table(double x, double y, const mglData &val, const wchar_t *text, const char *fnt="#|", const char *opt="") + { mgl_tablew(gr, x, y, &val, text, fnt, opt); } + + /// Draw tube with radius r around curve {x,y,z} + inline void Tube(const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *pen="", const char *opt="") + { mgl_tube_xyzr(gr, &x, &y, &z, &r, pen, opt); } + inline void Tube(const mglData &x, const mglData &y, const mglData &z, double r, const char *pen="", const char *opt="") + { mgl_tube_xyz(gr, &x, &y, &z, r, pen, opt); } + inline void Tube(const mglData &x, const mglData &y, const mglData &r, const char *pen="", const char *opt="") + { mgl_tube_xyr(gr, &x, &y, &r, pen, opt); } + inline void Tube(const mglData &x, const mglData &y, double r, const char *pen="", const char *opt="") + { mgl_tube_xy(gr, &x, &y, r, pen, opt); } + inline void Tube(const mglData &y, const mglData &r, const char *pen="", const char *opt="") + { mgl_tube_r(gr, &y, &r, pen, opt); } + inline void Tube(const mglData &y, double r, const char *pen="", const char *opt="") + { mgl_tube(gr, &y, r, pen, opt); } + /// Draw surface of curve {r,z} rotatation around axis + inline void Torus(const mglData &r, const mglData &z, const char *pen="", const char *opt="") + { mgl_torus(gr, &r, &z, pen,opt); } + + /// Draw mesh lines for 2d data specified parametrically + inline void Mesh(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_mesh_xy(gr, &x, &y, &z, stl, opt); } + inline void Mesh(const mglData &z, const char *stl="", const char *opt="") + { mgl_mesh(gr, &z, stl, opt); } + /// Draw mesh lines for 2d data specified parametrically + inline void Fall(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_fall_xy(gr, &x, &y, &z, stl, opt); } + inline void Fall(const mglData &z, const char *stl="", const char *opt="") + { mgl_fall(gr, &z, stl, opt); } + /// Draw belts for 2d data specified parametrically + inline void Belt(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_belt_xy(gr, &x, &y, &z, stl, opt); } + inline void Belt(const mglData &z, const char *stl="", const char *opt="") + { mgl_belt(gr, &z, stl, opt); } + /// Draw surface for 2d data specified parametrically with color proportional to z + inline void Surf(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_surf_xy(gr, &x, &y, &z, stl, opt); } + inline void Surf(const mglData &z, const char *stl="", const char *opt="") + { mgl_surf(gr, &z, stl, opt); } + /// Draw grid lines for density plot of 2d data specified parametrically + inline void Grid(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_grid_xy(gr, &x, &y, &z, stl, opt); } + inline void Grid(const mglData &z, const char *stl="", const char *opt="") + { mgl_grid(gr, &z, stl, opt); } + /// Draw vertical tiles for 2d data specified parametrically + inline void Tile(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_tile_xy(gr, &x, &y, &z, stl, opt); } + inline void Tile(const mglData &z, const char *stl="", const char *opt="") + { mgl_tile(gr, &z, stl, opt); } + /// Draw density plot for 2d data specified parametrically + inline void Dens(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_dens_xy(gr, &x, &y, &z, stl, opt); } + inline void Dens(const mglData &z, const char *stl="", const char *opt="") + { mgl_dens(gr, &z, stl, opt); } + /// Draw vertical boxes for 2d data specified parametrically + inline void Boxs(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_boxs_xy(gr, &x, &y, &z, stl, opt); } + inline void Boxs(const mglData &z, const char *stl="", const char *opt="") + { mgl_boxs(gr, &z, stl, opt); } + + /// Draw contour lines for 2d data specified parametrically + inline void Cont(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_cont_xy_val(gr, &v, &x, &y, &z, sch, opt); } + inline void Cont(const mglData &v, const mglData &z, const char *sch="", const char *opt="") + { mgl_cont_val(gr, &v, &z, sch, opt); } + inline void Cont(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_cont_xy(gr, &x, &y, &z, sch, opt); } + inline void Cont(const mglData &z, const char *sch="", const char *opt="") + { mgl_cont(gr, &z, sch, opt); } + /// Draw solid contours for 2d data specified parametrically + inline void ContF(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_contf_xy_val(gr, &v, &x, &y, &z, sch, opt); } + inline void ContF(const mglData &v, const mglData &z, const char *sch="", const char *opt="") + { mgl_contf_val(gr, &v, &z, sch, opt); } + inline void ContF(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_contf_xy(gr, &x, &y, &z, sch, opt); } + inline void ContF(const mglData &z, const char *sch="", const char *opt="") + { mgl_contf(gr, &z, sch, opt); } + /// Draw solid contours for 2d data specified parametrically with manual colors + inline void ContD(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_contd_xy_val(gr, &v, &x, &y, &z, sch, opt); } + inline void ContD(const mglData &v, const mglData &z, const char *sch="", const char *opt="") + { mgl_contd_val(gr, &v, &z, sch, opt); } + inline void ContD(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_contd_xy(gr, &x, &y, &z, sch, opt); } + inline void ContD(const mglData &z, const char *sch="", const char *opt="") + { mgl_contd(gr, &z, sch, opt); } + /// Draw contour tubes for 2d data specified parametrically + inline void ContV(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_contv_xy_val(gr, &v, &x, &y, &z, sch, opt); } + inline void ContV(const mglData &v, const mglData &z, const char *sch="", const char *opt="") + { mgl_contv_val(gr, &v, &z, sch, opt); } + inline void ContV(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_contv_xy(gr, &x, &y, &z, sch, opt); } + inline void ContV(const mglData &z, const char *sch="", const char *opt="") + { mgl_contv(gr, &z, sch, opt); } + + /// Draw axial-symmetric isosurfaces for 2d data specified parametrically + inline void Axial(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_axial_xy_val(gr, &v, &x, &y, &z, sch,opt); } + inline void Axial(const mglData &v, const mglData &z, const char *sch="", const char *opt="") + { mgl_axial_val(gr, &v, &z, sch, opt); } + inline void Axial(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_axial_xy(gr, &x, &y, &z, sch, opt); } + inline void Axial(const mglData &z, const char *sch="", const char *opt="") + { mgl_axial(gr, &z, sch, opt); } + + /// Draw grid lines for density plot at slice for 3d data specified parametrically + inline void Grid3(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", double sVal=-1, const char *opt="") + { mgl_grid3_xyz(gr, &x, &y, &z, &a, stl, sVal, opt); } + inline void Grid3(const mglData &a, const char *stl="", double sVal=-1, const char *opt="") + { mgl_grid3(gr, &a, stl, sVal, opt); } + /// Draw density plot at slice for 3d data specified parametrically + inline void Dens3(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", double sVal=-1, const char *opt="") + { mgl_dens3_xyz(gr, &x, &y, &z, &a, stl, sVal, opt); } + inline void Dens3(const mglData &a, const char *stl="", double sVal=-1, const char *opt="") + { mgl_dens3(gr, &a, stl, sVal, opt); } + + /// Draw isosurface(s) for 3d data specified parametrically + inline void Surf3(double Val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", const char *opt="") + { mgl_surf3_xyz_val(gr, Val, &x, &y, &z, &a, stl, opt); } + inline void Surf3(double Val, const mglData &a, const char *stl="", const char *opt="") + { mgl_surf3_val(gr, Val, &a, stl, opt); } + inline void Surf3(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", const char *opt="") + { mgl_surf3_xyz(gr, &x, &y, &z, &a, stl, opt); } + inline void Surf3(const mglData &a, const char *stl="", const char *opt="") + { mgl_surf3(gr, &a, stl, opt); } + + /// Draw a semi-transparent cloud for 3d data + inline void Cloud(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", const char *opt="") + { mgl_cloud_xyz(gr, &x, &y, &z, &a, stl, opt); } + inline void Cloud(const mglData &a, const char *stl="", const char *opt="") + { mgl_cloud(gr, &a, stl, opt); } + + /// Draw contour lines at slice for 3d data specified parametrically + inline void Cont3(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_cont3_xyz_val(gr, &v, &x, &y, &z, &a, sch, sVal, opt); } + inline void Cont3(const mglData &v, const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_cont3_val(gr, &v, &a, sch, sVal, opt); } + inline void Cont3(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_cont3_xyz(gr, &x, &y, &z, &a, sch, sVal, opt); } + inline void Cont3(const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_cont3(gr, &a, sch, sVal, opt); } + + /// Draw solid contours at slice for 3d data specified parametrically + inline void ContF3(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_contf3_xyz_val(gr, &v, &x, &y, &z, &a, sch, sVal, opt); } + inline void ContF3(const mglData &v, const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_contf3_val(gr, &v, &a, sch, sVal, opt); } + inline void ContF3(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_contf3_xyz(gr, &x, &y, &z, &a, sch, sVal, opt); } + inline void ContF3(const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_contf3(gr, &a, sch, sVal, opt); } + + /// Draw several isosurfaces for 3d beam in curvilinear coordinates + inline void Beam(const mglData &tr, const mglData &g1, const mglData &g2, const mglData &a, double r, const char *stl=0, int flag=0, int num=3) + { mgl_beam(gr, &tr,&g1,&g2,&a,r,stl,flag,num); } + inline void Beam(double val, const mglData &tr, const mglData &g1, const mglData &g2, const mglData &a, double r, const char *stl=NULL, int flag=0) + { mgl_beam_val(gr,val,&tr,&g1,&g2,&a,r,stl,flag); } + + /// Draw vertical tiles with variable size r for 2d data specified parametrically + inline void TileS(const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *stl="", const char *opt="") + { mgl_tiles_xy(gr, &x, &y, &z, &r, stl, opt); } + inline void TileS(const mglData &z, const mglData &r, const char *stl="", const char *opt="") + { mgl_tiles(gr, &z, &r, stl, opt); } + /// Draw surface for 2d data specified parametrically with color proportional to c + inline void SurfC(const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="", const char *opt="") + { mgl_surfc_xy(gr, &x, &y, &z, &c, sch,opt); } + inline void SurfC(const mglData &z, const mglData &c, const char *sch="", const char *opt="") + { mgl_surfc(gr, &z, &c, sch,opt); } + /// Draw surface for 2d data specified parametrically with alpha proportional to c + inline void SurfA(const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="", const char *opt="") + { mgl_surfa_xy(gr, &x, &y, &z, &c, sch,opt); } + inline void SurfA(const mglData &z, const mglData &c, const char *sch="", const char *opt="") + { mgl_surfa(gr, &z, &c, sch,opt); } + + /// Color map of matrix a to matrix b, both matrix can parametrically depend on coordinates + inline void Map(const mglData &x, const mglData &y, const mglData &a, const mglData &b, const char *sch="", const char *opt="") + { mgl_map_xy(gr, &x, &y, &a, &b, sch, opt); } + inline void Map(const mglData &a, const mglData &b, const char *sch="", const char *opt="") + { mgl_map(gr, &a, &b, sch, opt); } + /// Draw density plot for spectra-gramm specified parametrically + inline void STFA(const mglData &x, const mglData &y, const mglData &re, const mglData &im, int dn, const char *sch="", const char *opt="") + { mgl_stfa_xy(gr, &x, &y, &re, &im, dn, sch, opt); } + inline void STFA(const mglData &re, const mglData &im, int dn, const char *sch="", const char *opt="") + { mgl_stfa(gr, &re, &im, dn, sch, opt); } + + /// Draw isosurface(s) for 3d data specified parametrically with alpha proportional to b + inline void Surf3A(double Val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3a_xyz_val(gr, Val, &x, &y, &z, &a, &b, stl, opt); } + inline void Surf3A(double Val, const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3a_val(gr, Val, &a, &b, stl, opt); } + inline void Surf3A(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3a_xyz(gr, &x, &y, &z, &a, &b, stl, opt); } + inline void Surf3A(const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3a(gr, &a, &b, stl, opt); } + + /// Draw isosurface(s) for 3d data specified parametrically with color proportional to b + inline void Surf3C(double Val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3c_xyz_val(gr, Val, &x, &y, &z, &a, &b, stl,opt); } + inline void Surf3C(double Val, const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3c_val(gr, Val, &a, &b, stl, opt); } + inline void Surf3C(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3c_xyz(gr, &x, &y, &z, &a, &b, stl, opt); } + inline void Surf3C(const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3c(gr, &a, &b, stl, opt); } + + /// Plot dew drops for vector field {ax,ay} parametrically depended on coordinate {x,y} + inline void Dew(const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_dew_xy(gr, &x, &y, &ax, &ay, sch, opt); } + inline void Dew(const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_dew_2d(gr, &ax, &ay, sch, opt); } + /// Plot vectors at position {x,y,z} along {ax,ay,az} with length/color proportional to |a| + inline void Traj(const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_traj_xy(gr, &x, &y, &ax, &ay, sch, opt); } + inline void Traj(const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_traj_xyz(gr, &x, &y, &z, &ax, &ay, &az, sch, opt); } + + /// Plot vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with length/color proportional to |a| + inline void Vect(const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_vect_xy(gr, &x, &y, &ax, &ay, sch, opt); } + inline void Vect(const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_vect_2d(gr, &ax, &ay, sch, opt); } + inline void Vect(const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_vect_xyz(gr, &x, &y, &z, &ax, &ay, &az, sch, opt); } + inline void Vect(const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_vect_3d(gr, &ax, &ay, &az, sch, opt); } + + /// Draw vector plot at slice for 3d data specified parametrically + inline void Vect3(const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *stl="", double sVal=-1, const char *opt="") + { mgl_vect3_xyz(gr, &x, &y, &z, &ax,&ay,&az, stl, sVal, opt); } + inline void Vect3(const mglData &ax, const mglData &ay, const mglData &az, const char *stl="", double sVal=-1, const char *opt="") + { mgl_vect3(gr, &ax,&ay,&az, stl, sVal, opt); } + + /// Plot flows for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color proportional to |a| + inline void Flow(const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_flow_xy(gr, &x, &y, &ax, &ay, sch, opt); } + inline void Flow(const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_flow_2d(gr, &ax, &ay, sch, opt); } + inline void Flow(const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_flow_xyz(gr, &x, &y, &z, &ax, &ay, &az, sch, opt); } + inline void Flow(const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_flow_3d(gr, &ax, &ay, &az, sch, opt); } + + /// Plot flow from point p for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color proportional to |a| + inline void FlowP(mglPoint p, const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_flowp_xy(gr, p.x, p.y, p.z, &x, &y, &ax, &ay, sch, opt); } + inline void FlowP(mglPoint p, const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_flowp_2d(gr, p.x, p.y, p.z, &ax, &ay, sch, opt); } + inline void FlowP(mglPoint p, const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_flowp_xyz(gr, p.x, p.y, p.z, &x, &y, &z, &ax, &ay, &az, sch, opt); } + inline void FlowP(mglPoint p, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_flowp_3d(gr, p.x, p.y, p.z, &ax, &ay, &az, sch, opt); } + + /// Plot flows for gradient of scalar field phi parametrically depended on coordinate {x,y,z} + inline void Grad(const mglData &x, const mglData &y, const mglData &z, const mglData &phi, const char *sch="", const char *opt="") + { mgl_grad_xyz(gr,&x,&y,&z,&phi,sch,opt); } + inline void Grad(const mglData &x, const mglData &y, const mglData &phi, const char *sch="", const char *opt="") + { mgl_grad_xy(gr,&x,&y,&phi,sch,opt); } + inline void Grad(const mglData &phi, const char *sch="", const char *opt="") + { mgl_grad(gr,&phi,sch,opt); } + + /// Plot flow pipes for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color and radius proportional to |a| + inline void Pipe(const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", double r0=0.05, const char *opt="") + { mgl_pipe_xy(gr, &x, &y, &ax, &ay, sch, r0, opt); } + inline void Pipe(const mglData &ax, const mglData &ay, const char *sch="", double r0=0.05, const char *opt="") + { mgl_pipe_2d(gr, &ax, &ay, sch, r0, opt); } + inline void Pipe(const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", double r0=0.05, const char *opt="") + { mgl_pipe_xyz(gr, &x, &y, &z, &ax, &ay, &az, sch, r0, opt); } + inline void Pipe(const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", double r0=0.05, const char *opt="") + { mgl_pipe_3d(gr, &ax, &ay, &az, sch, r0, opt); } + + /// Draw density plot for data at x = sVal + inline void DensX(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_dens_x(gr, &a, stl, sVal, opt); } + /// Draw density plot for data at y = sVal + inline void DensY(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_dens_y(gr, &a, stl, sVal, opt); } + /// Draw density plot for data at z = sVal + inline void DensZ(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_dens_z(gr, &a, stl, sVal, opt); } + /// Draw contour lines for data at x = sVal + inline void ContX(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_x(gr, &a, stl, sVal, opt); } + inline void ContX(const mglData &v, const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_x_val(gr, &v, &a, stl, sVal, opt); } + /// Draw contour lines for data at y = sVal + inline void ContY(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_y(gr, &a, stl, sVal, opt); } + inline void ContY(const mglData &v, const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_y_val(gr, &v, &a, stl, sVal, opt); } + /// Draw contour lines for data at z = sVal + inline void ContZ(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_z(gr, &a, stl, sVal, opt); } + inline void ContZ(const mglData &v, const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_z_val(gr, &v, &a, stl, sVal, opt); } + /// Draw solid contours for data at x = sVal + inline void ContFX(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_x(gr, &a, stl, sVal, opt); } + inline void ContFX(const mglData &v, const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_x_val(gr, &v, &a, stl, sVal, opt); } + /// Draw solid contours for data at y = sVal + inline void ContFY(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_y(gr, &a, stl, sVal, opt); } + inline void ContFY(const mglData &v, const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_y_val(gr, &v, &a, stl, sVal, opt); } + /// Draw solid contours for data at z = sVal + inline void ContFZ(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_z(gr, &a, stl, sVal, opt); } + inline void ContFZ(const mglData &v, const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_z_val(gr, &v, &a, stl, sVal, opt); } + + /// Draw curve for formula with x in x-axis range + inline void FPlot(const char *fy, const char *stl="", const char *opt="") + { mgl_fplot(gr, fy, stl, opt); } + /// Draw curve for formulas parametrically depended on t in range [0,1] + inline void FPlot(const char *fx, const char *fy, const char *fz, const char *stl, const char *opt="") + { mgl_fplot_xyz(gr, fx, fy, fz, stl, opt); } + /// Draw surface by formula with x,y in axis range + inline void FSurf(const char *fz, const char *stl="", const char *opt="") + { mgl_fsurf(gr, fz, stl, opt); } + /// Draw surface by formulas parametrically depended on u,v in range [0,1] + inline void FSurf(const char *fx, const char *fy, const char *fz, const char *stl, const char *opt="") + { mgl_fsurf_xyz(gr, fx, fy, fz, stl, opt); } + + /// Draw triangle mesh for points in arrays {x,y,z} with specified color c. + inline void TriPlot(const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="", const char *opt="") + { mgl_triplot_xyzc(gr, &nums, &x, &y, &z, &c, sch, opt); } + inline void TriPlot(const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_triplot_xyz(gr, &nums, &x, &y, &z, sch, opt); } + inline void TriPlot(const mglData &nums, const mglData &x, const mglData &y, const char *sch="", const char *opt="") + { mgl_triplot_xy(gr, &nums, &x, &y, sch, opt); } + /// Draw quad mesh for points in arrays {x,y,z} with specified color c. + inline void QuadPlot(const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="", const char *opt="") + { mgl_quadplot_xyzc(gr, &nums, &x, &y, &z, &c, sch, opt); } + inline void QuadPlot(const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_quadplot_xyz(gr, &nums, &x, &y, &z, sch, opt); } + inline void QuadPlot(const mglData &nums, const mglData &x, const mglData &y, const char *sch="", const char *opt="") + { mgl_quadplot_xy(gr, &nums, &x, &y, sch, opt); } + + /// Draw contour lines for triangle mesh for points in arrays {x,y,z} with specified color c. + inline void TriCont(const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_tricont_xyc(gr, &nums, &x, &y, &z, sch, opt); } + inline void TriContV(const mglData &v, const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_tricont_xycv(gr, &v, &nums, &x, &y, &z, sch, opt); } + inline void TriCont(const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", const char *opt="") + { mgl_tricont_xyzc(gr, &nums, &x, &y, &z, &a, sch, opt); } + inline void TriContV(const mglData &v, const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", const char *opt="") + { mgl_tricont_xyzcv(gr, &v, &nums, &x, &y, &z, &a, sch, opt); } + + /// Draw dots in points {x,y,z}. + inline void Dots(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_dots(gr, &x, &y, &z, sch, opt); } + /// Draw semitransparent dots in points {x,y,z} with specified alpha a. + inline void Dots(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", const char *opt="") + { mgl_dots_a(gr, &x, &y, &z, &a, sch, opt); } + /// Draw semitransparent dots in points {x,y,z} with specified color c and alpha a. + inline void Dots(const mglData &x, const mglData &y, const mglData &z, const mglData &c, const mglData &a, const char *sch="", const char *opt="") + { mgl_dots_ca(gr, &x, &y, &z, &c, &a, sch, opt); } + /// Draw surface reconstructed for points in arrays {x,y,z}. + inline void Crust(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_crust(gr, &x, &y, &z, sch, opt); } + + /// Fit data along x-direction for each data row. Return array with values for found formula. + inline mglData Fit(const mglData &y, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_1(gr, &y, eq,var,0, opt)); } + inline mglData Fit(const mglData &y, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_1(gr, &y, eq, var, &ini, opt)); } + /// Fit data along x-, y-directions for each data slice. Return array with values for found formula. + inline mglData Fit2(const mglData &z, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_2(gr, &z, eq, var,0, opt)); } + inline mglData Fit2(const mglData &z, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_2(gr, &z, eq, var, &ini, opt)); } + /// Fit data along along all directions. Return array with values for found formula. + inline mglData Fit3(const mglData &a, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_3(gr, &a, eq, var,0, opt)); } + inline mglData Fit3(const mglData &a, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_3(gr, &a, eq, var, &ini, opt)); } + /// Fit data along x-direction for each data row. Return array with values for found formula. + inline mglData Fit(const mglData &x, const mglData &y, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_xy(gr, &x, &y, eq, var,0, opt)); } + inline mglData Fit(const mglData &x, const mglData &y, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xy(gr, &x, &y, eq, var, &ini, opt)); } + /// Fit data along x-, y-directions for each data slice. Return array with values for found formula. + inline mglData Fit(const mglData &x, const mglData &y, const mglData &z, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_xyz(gr, &x, &y, &z, eq, var,0, opt)); } + inline mglData Fit(const mglData &x, const mglData &y, const mglData &z, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xyz(gr, &x, &y, &z, eq, var, &ini, opt)); } + /// Fit data along along all directions. Return array with values for found formula. + inline mglData Fit(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_xyza(gr, &x, &y, &z, &a, eq, var,0, opt)); } + inline mglData Fit(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xyza(gr, &x, &y, &z, &a, eq,var, &ini, opt)); } + /// Fit data with dispersion s along x-direction for each data row. Return array with values for found formula. + inline mglData FitS(const mglData &y, const mglData &s, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_ys(gr, &y, &s, eq, var,0, opt)); } + inline mglData FitS(const mglData &y, const mglData &s, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_ys(gr, &y, &s, eq, var, &ini, opt)); } + inline mglData FitS(const mglData &x, const mglData &y, const mglData &s, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_xys(gr, &x, &y, &s, eq, var,0, opt)); } + inline mglData FitS(const mglData &x, const mglData &y, const mglData &s, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xys(gr, &x, &y, &s, eq, var, &ini, opt)); } + /// Fit data with dispersion s along x-, y-directions for each data slice. Return array with values for found formula. + inline mglData FitS(const mglData &x, const mglData &y, const mglData &z, const mglData &s, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_xyzs(gr, &x, &y, &z, &s, eq, var,0, opt)); } + inline mglData FitS(const mglData &x, const mglData &y, const mglData &z, const mglData &s, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xyzs(gr, &x, &y, &z, &s, eq, var, &ini, opt)); } + /// Fit data with dispersion s along all directions. Return array with values for found formula. + inline mglData FitS(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &s, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_xyzas(gr, &x, &y, &z, &a, &s, eq, var,0, opt)); } + inline mglData FitS(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &s, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xyzas(gr, &x, &y, &z, &a, &s, eq, var, &ini, opt)); } + /// Print fitted last formula (with coefficients) + inline void PutsFit(mglPoint p, const char *prefix=0, const char *font="", double size=-1) + { mgl_puts_fit(gr, p.x, p.y, p.z, prefix, font, size); } + /// Get last fitted formula + inline const char *GetFit() + { return mgl_get_fit(gr); } + + /// Solve PDE with x,y,z in range [Min, Max] + inline mglData PDE(const char *ham, const mglData &ini_re, const mglData &ini_im, double dz=0.1, double k0=100, const char *opt="") + { return mglData(true,mgl_pde_solve(gr,ham,&ini_re,&ini_im,dz,k0, opt)); } + /// Fill data by formula with x,y,z in range [Min, Max] + inline void Fill(mglData &u, const char *eq, const char *opt="") + { mgl_data_fill_eq(gr, &u, eq, 0, 0, opt); } + inline void Fill(mglData &u, const char *eq, const mglData &v, const char *opt="") + { mgl_data_fill_eq(gr, &u, eq, &v, 0, opt); } + inline void Fill(mglData &u, const char *eq, const mglData &v, const mglData &w, const char *opt="") + { mgl_data_fill_eq(gr, &u, eq, &v, &w, opt); } + /// Fill data by formula with x,y,z in range [Min, Max] + inline void Fill(mglDataC &u, const char *eq, const char *opt="") + { mgl_datac_fill_eq(gr, &u, eq, 0, 0, opt); } + inline void Fill(mglDataC &u, const char *eq, const mglData &v, const char *opt="") + { mgl_datac_fill_eq(gr, &u, eq, &v, 0, opt); } + inline void Fill(mglDataC &u, const char *eq, const mglData &v, const mglData &w, const char *opt="") + { mgl_datac_fill_eq(gr, &u, eq, &v, &w, opt); } + + /// Fill dat by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in axis range + inline void Refill(mglData &dat, const mglData &xdat, const mglData &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,&dat,&xdat,0,0,&vdat,sl,opt); } + inline void Refill(mglData &dat, const mglData &xdat, const mglData &ydat, const mglData &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,&dat,&xdat,&ydat,0,&vdat,sl,opt); } + inline void Refill(mglData &dat, const mglData &xdat, const mglData &ydat, const mglData &zdat, const mglData &vdat, const char *opt="") + { mgl_data_refill_gr(gr,&dat,&xdat,&ydat,&zdat,&vdat,-1,opt); } + + /// Set the data by triangulated surface values assuming x,y,z in range [Min, Max] + inline void DataGrid(mglData &d, const mglData &x, const mglData &y, const mglData &z, const char *opt="") + { mgl_data_grid(gr,&d,&x,&y,&z,opt); } + + /// Make histogram (distribution) of data. This function do not plot data. + inline mglData Hist(const mglData &x, const mglData &a, const char *opt="") + { return mglData(true, mgl_hist_x(gr, &x, &a, opt)); } + inline mglData Hist(const mglData &x, const mglData &y, const mglData &a, const char *opt="") + { return mglData(true, mgl_hist_xy(gr, &x, &y, &a, opt)); } + inline mglData Hist(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *opt="") + { return mglData(true, mgl_hist_xyz(gr, &x, &y, &z, &a, opt)); } + + inline void Compression(bool){} // NOTE: Add later -- IDTF + /// Set the preference for vertex color on/off (for formats that support it, now only PRC does). + inline void VertexColor(bool enable) { mgl_set_flag(gr,enable, MGL_PREFERVC); } + /// Render only front side of surfaces for dubugging purposes (for formats that support it, now only PRC does). + inline void DoubleSided(bool enable) { mgl_set_flag(gr,!enable, MGL_ONESIDED); } +// inline void TextureColor(bool){} // NOTE: Add later -- IDTF +}; +//----------------------------------------------------------------------------- +/// Wrapper class for MGL parsing +class mglParse +{ + HMPR pr; +public: + mglParse(HMPR p) { pr = p; mgl_use_parser(pr,1); } + mglParse(mglParse &p) { pr = p.pr; mgl_use_parser(pr,1); } + mglParse(bool setsize=false) + { pr=mgl_create_parser(); mgl_parser_allow_setsize(pr, setsize); } + ~mglParse() { if(mgl_use_parser(pr,-1)<1) mgl_delete_parser(pr); } + /// Get pointer to internal mglParser object + inline HMPR Self() { return pr; } + /// Parse and draw single line of the MGL script + inline int Parse(mglGraph *gr, const char *str, int pos) + { return mgl_parse_line(gr->Self(), pr, str, pos); } + inline int Parse(mglGraph *gr, const wchar_t *str, int pos) + { return mgl_parse_linew(gr->Self(), pr, str, pos); } + /// Execute MGL script text with '\n' separated lines + inline void Execute(mglGraph *gr, const char *str) + { mgl_parse_text(gr->Self(), pr, str); } + inline void Execute(mglGraph *gr, const wchar_t *str) + { mgl_parse_textw(gr->Self(), pr, str); } + /// Execute and draw script from the file + inline void Execute(mglGraph *gr, FILE *fp, bool print=false) + { mgl_parse_file(gr->Self(), pr, fp, print); } + + /// Return type of command: 0 - not found, 1 - data plot, 2 - other plot, + /// 3 - setup, 4 - data handle, 5 - data create, 6 - subplot, 7 - program + /// 8 - 1d plot, 9 - 2d plot, 10 - 3d plot, 11 - dd plot, 12 - vector plot + /// 13 - axis, 14 - primitives, 15 - axis setup, 16 - text/legend, 17 - data transform + inline int CmdType(const char *name) + { return mgl_parser_cmd_type(pr, name); } + /// Return string of command format (command name and its argument[s]) + inline const char *CmdFormat(const char *name) + { return mgl_parser_cmd_frmt(pr, name); } + /// Return description of MGL command + inline const char *CmdDesc(const char *name) + { return mgl_parser_cmd_desc(pr, name); } + /// Get name of command with nmber n + inline const char *GetCmdName(long n) + { return mgl_parser_cmd_name(pr,n); } + /// Get number of defined commands + inline long GetCmdNum() + { return mgl_parser_cmd_num(pr); } + + /// Set value for parameter $N + inline void AddParam(int id, const char *str) + { mgl_parser_add_param(pr, id, str); } + inline void AddParam(int id, const wchar_t *str) + { mgl_parser_add_paramw(pr, id, str); } + /// Restore once flag + inline void RestoreOnce() { mgl_parser_restore_once(pr); } + /// Allow changing size of the picture + inline void AllowSetSize(bool allow) { mgl_parser_allow_setsize(pr, allow); } + /// Allow reading/saving files + inline void AllowFileIO(bool allow) { mgl_parser_allow_file_io(pr, allow); } + /// Set flag to stop script parsing + inline void Stop() { mgl_parser_stop(pr); } + + /// Return result of formula evaluation + inline mglData Calc(const char *formula) + { return mglData(true,mgl_parser_calc(pr,formula)); } + inline mglData Calc(const wchar_t *formula) + { return mglData(true,mgl_parser_calcw(pr,formula)); } + + /// Find variable with given name or add a new one + /// NOTE !!! You must not delete obtained data arrays !!! + inline mglVar *AddVar(const char *name) + { return dynamic_cast(mgl_parser_add_var(pr, name)); } + inline mglVar *AddVar(const wchar_t *name) + { return dynamic_cast(mgl_parser_add_varw(pr, name)); } + /// Find variable with given name or return NULL if no one + /// NOTE !!! You must not delete obtained data arrays !!! + inline mglVar *FindVar(const char *name) + { return dynamic_cast(mgl_parser_find_var(pr, name)); } + inline mglVar *FindVar(const wchar_t *name) + { return dynamic_cast(mgl_parser_find_varw(pr, name)); } + /// Delete variable with name + inline void DeleteVar(const char *name) { mgl_parser_del_var(pr, name); } + inline void DeleteVar(const wchar_t *name) { mgl_parser_del_varw(pr, name); } + /// Delete all data variables + void DeleteAll() { mgl_parser_del_all(pr); } +}; +//----------------------------------------------------------------------------- +/// Wrapper class expression evaluating +class mglExpr +{ + HMEX ex; +public: + mglExpr(const char *expr) { ex = mgl_create_expr(expr); } + ~mglExpr() { mgl_delete_expr(ex); } + /// Return value of expression for given x,y,z variables + inline double Eval(double x, double y=0, double z=0) + { return mgl_expr_eval(ex,x,y,z); } + /// Return value of expression differentiation over variable dir for given x,y,z variables + inline double Diff(char dir, double x, double y=0, double z=0) + { return mgl_expr_diff(ex,dir, x,y,z); } +}; +//----------------------------------------------------------------------------- +/// Wrapper class expression evaluating +class mglExprC +{ + HAEX ex; +public: + mglExprC(const char *expr) { ex = mgl_create_cexpr(expr); } + ~mglExprC() { mgl_delete_cexpr(ex); } + /// Return value of expression for given x,y,z variables + inline dual Eval(dual x, dual y=0, dual z=0) + { return mgl_cexpr_eval(ex,x,y,z); } + /// Return value of expression for given x,y,z,u,v,w variables + inline dual Eval(dual x, dual y, dual z, dual u, dual v, dual w) + { + dual var[26]; + var['x'-'a']=x; var['y'-'a']=y; var['z'-'a']=z; + var['u'-'a']=u; var['v'-'a']=v; var['w'-'a']=w; + return mgl_cexpr_eval_v(ex,var); } +}; +//----------------------------------------------------------------------------- diff --git a/lang/sed_rules b/lang/sed_rules new file mode 100644 index 0000000..8ee5fb6 --- /dev/null +++ b/lang/sed_rules @@ -0,0 +1,13 @@ +1,19d +s/MGL_EXPORT//g +s/mglDataA/mglData/g +/SWIG/,/endif/ { s/.*//g } +s/^.*---.*$//g +s/^#include.*$//g +s/^#define.*$//g +s/^.*public mglData$//g +s/^#ifndef _MGL_DATA_H_.*$//g +s/^#ifndef _MGL_H_.*$//g +s/^#ifdef __cplusplus.*$//g +/^\s*$/d +N;$!P;$!D;$d diff --git a/lang/type.i b/lang/type.i new file mode 100644 index 0000000..133642a --- /dev/null +++ b/lang/type.i @@ -0,0 +1,99 @@ +/*************************************************************************** + * type.i is part of Math Graphic Library + * Copyright (C) 2007-2012 Alexey Balakin * + * * + * 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/config.h" +#if MGL_USE_DOUBLE +typedef double mreal; +#else +typedef float mreal; +#endif +//----------------------------------------------------------------------------- +const mreal Pi = M_PI; +const mreal NaN = NAN; +const mreal mgl_min_a = 1./256; +//----------------------------------------------------------------------------- +/// Class for point in 3D space +struct mglPoint +{ + mreal x,y,z,c; + mglPoint(mreal X=0,mreal Y=0,mreal Z=0,mreal C=0){x=X;y=Y;z=Z;c=C;} + inline bool IsNAN() { return (x!=x || y!=y || z!=z || c!=c); } + inline mreal val(int i) { return (i<2 ? (i==0 ? x:y) : (i==2 ? z:c)); } + inline mreal norm() { return sqrt(x*x+y*y+z*z); } + inline void Normalize() { mreal v=norm(); x/=v; y/=v; z/=v; } + + inline void operator+=(const mglPoint &a) { x+=a.x; y+=a.y; z+=a.z; c+=a.c; } + inline void operator-=(const mglPoint &a) { x-=a.x; y-=a.y; z-=a.z; c-=a.c; } + inline void operator+=(mreal a) { x+=a; y+=a; z+=a; } + inline void operator-=(mreal a) { x-=a; y-=a; z-=a; } + inline void operator*=(mreal a) { x*=a; y*=a; z*=a; } + inline void operator/=(mreal a) { x/=a; y/=a; z/=a; } +}; +//----------------------------------------------------------------------------- +/// Class for RGBA color +struct mglColor +{ + float r; ///< Red component of color + float g; ///< Green component of color + float b; ///< Blue component of color + float a; ///< Alpha component of color + + /// Constructor for RGB components manualy + mglColor(float R,float G,float B, float A=1){ r=R; g=G; b=B; a=A; } + /// Constructor set default color + mglColor() { r=g=b=0; a=1; } + /// Constructor set color from character id + mglColor(char c, float bright=1) { Set(c,bright); } + /// Set color as Red, Green, Blue values + void Set(float R,float G,float B,float A=1) { r=R; g=G; b=B; a=A; } + /// Set color as Red, Green, Blue values + void Set(mglColor c, float bright=1) + { + if(bright<0) bright=0; if(bright>2.f) bright=2.f; + r = bright<=1 ? c.r*bright : 1 - (1-c.r)*(2-bright); + g = bright<=1 ? c.g*bright : 1 - (1-c.g)*(2-bright); + b = bright<=1 ? c.b*bright : 1 - (1-c.b)*(2-bright); a = 1; + } + /// Check if color is valid + inline bool Valid() + { return (r>=0 && r<=1 && g>=0 && g<=1 && b>=0 && b<=1 && a>=0 && a<=1); } + /// Get maximal spectral component + inline float Norm() + { return r>g ? r : (g>b ? g : b); } + inline float NormS() + { return r*r+g*g+b*b; } + /// Set color from symbolic id + inline void Set(char p, float bright=1) + { + float rgb[3]; mgl_chrrgb(p,rgb); + Set(mglColor(rgb[0],rgb[1],rgb[2]),bright); + } + /// Copy color from other one + inline bool operator==(const mglColor &c) const + { return !memcmp(this, &c, sizeof(mglColor)); } + inline bool operator!=(const mglColor &c) const + { return memcmp(this, &c, sizeof(mglColor)); } + inline bool operator<(const mglColor &c) const + { return memcmp(this, &c, sizeof(mglColor))<0; } + // transparency still the same + inline void operator*=(float v) { r*=v; g*=v; b*=v; a*=v; } + inline void operator+=(const mglColor &c) { r+=c.r; g+=c.g; b+=c.b; a+=c.a; } + inline void operator-=(const mglColor &c) { r-=c.r; g-=c.g; b-=c.b; a-=c.a; } +}; +//----------------------------------------------------------------------------- diff --git a/mathgl-2x.cbp b/mathgl-2x.cbp index a958f50..40ea8f6 100644 --- a/mathgl-2x.cbp +++ b/mathgl-2x.cbp @@ -12,28 +12,28 @@