diff -Nru mathgl-2.3.4/addons/getopt/CMakeLists.txt mathgl-2.3.5.1/addons/getopt/CMakeLists.txt --- mathgl-2.3.4/addons/getopt/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ mathgl-2.3.5.1/addons/getopt/CMakeLists.txt 2016-06-19 17:06:03.000000000 +0000 @@ -0,0 +1,2 @@ +add_library(getopt-static STATIC getopt.c getopt.h) +target_compile_definitions(getopt-static PUBLIC MGL_STATIC_DEFINE) diff -Nru mathgl-2.3.4/addons/getopt/getopt.c mathgl-2.3.5.1/addons/getopt/getopt.c --- mathgl-2.3.4/addons/getopt/getopt.c 1970-01-01 00:00:00.000000000 +0000 +++ mathgl-2.3.5.1/addons/getopt/getopt.c 2016-06-19 17:06:03.000000000 +0000 @@ -0,0 +1,973 @@ +/* Getopt for Microsoft C +This code is a modification of the Free Software Foundation, Inc. +Getopt library for parsing command line argument the purpose was +to provide a Microsoft Visual C friendly derivative. This code +provides functionality for both Unicode and Multibyte builds. + +Date: 02/03/2011 - Ludvik Jerabek - Initial Release +Version: 1.0 +Comment: Supports getopt, getopt_long, and getopt_long_only +and POSIXLY_CORRECT environment flag +License: LGPL + +Revisions: + +02/03/2011 - Ludvik Jerabek - Initial Release +02/20/2011 - Ludvik Jerabek - Fixed compiler warnings at Level 4 +07/05/2011 - Ludvik Jerabek - Added no_argument, required_argument, optional_argument defs +08/03/2011 - Ludvik Jerabek - Fixed non-argument runtime bug which caused runtime exception +08/09/2011 - Ludvik Jerabek - Added code to export functions for DLL and LIB +02/15/2012 - Ludvik Jerabek - Fixed _GETOPT_THROW definition missing in implementation file +08/01/2012 - Ludvik Jerabek - Created separate functions for char and wchar_t characters so single dll can do both unicode and ansi +10/15/2012 - Ludvik Jerabek - Modified to match latest GNU features +06/19/2015 - Ludvik Jerabek - Fixed maximum option limitation caused by option_a (255) and option_w (65535) structure val variable + +**DISCLAIMER** +THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING, BUT Not LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE +EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT +APPLY TO YOU. IN NO EVENT WILL I BE LIABLE TO ANY PARTY FOR ANY +DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES FOR ANY +USE OF THIS MATERIAL INCLUDING, WITHOUT LIMITATION, ANY LOST +PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON +YOUR INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN If WE ARE +EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +*/ +#define _CRT_SECURE_NO_WARNINGS +#include +#include +#include +#include "getopt.h" + +#ifdef __cplusplus + #define _GETOPT_THROW throw() +#else + #define _GETOPT_THROW +#endif + +int optind = 1; +int opterr = 1; +int optopt = '?'; +enum ENUM_ORDERING { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER }; + +// +// +// Ansi structures and functions follow +// +// + +static struct _getopt_data_a +{ + int optind; + int opterr; + int optopt; + char *optarg; + int __initialized; + char *__nextchar; + enum ENUM_ORDERING __ordering; + int __posixly_correct; + int __first_nonopt; + int __last_nonopt; +} getopt_data_a; +char *optarg_a; + +static void exchange_a(char **argv, struct _getopt_data_a *d) +{ + int bottom = d->__first_nonopt; + int middle = d->__last_nonopt; + int top = d->optind; + char *tem; + while (top > middle && middle > bottom) + { + if (top - middle > middle - bottom) + { + int len = middle - bottom; + register int i; + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + } + top -= len; + } + else + { + int len = top - middle; + register int i; + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + } + bottom += len; + } + } + d->__first_nonopt += (d->optind - d->__last_nonopt); + d->__last_nonopt = d->optind; +} +static const char *_getopt_initialize_a (const char *optstring, struct _getopt_data_a *d, int posixly_correct) +{ + d->__first_nonopt = d->__last_nonopt = d->optind; + d->__nextchar = NULL; + d->__posixly_correct = posixly_correct | !!getenv("POSIXLY_CORRECT"); + if (optstring[0] == '-') + { + d->__ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + d->__ordering = REQUIRE_ORDER; + ++optstring; + } + else if (d->__posixly_correct) + d->__ordering = REQUIRE_ORDER; + else + d->__ordering = PERMUTE; + return optstring; +} +int _getopt_internal_r_a (int argc, char *const *argv, const char *optstring, const struct option_a *longopts, int *longind, int long_only, struct _getopt_data_a *d, int posixly_correct) +{ + int print_errors = d->opterr; + if (argc < 1) + return -1; + d->optarg = NULL; + if (d->optind == 0 || !d->__initialized) + { + if (d->optind == 0) + d->optind = 1; + optstring = _getopt_initialize_a (optstring, d, posixly_correct); + d->__initialized = 1; + } + else if (optstring[0] == '-' || optstring[0] == '+') + optstring++; + if (optstring[0] == ':') + print_errors = 0; + if (d->__nextchar == NULL || *d->__nextchar == '\0') + { + if (d->__last_nonopt > d->optind) + d->__last_nonopt = d->optind; + if (d->__first_nonopt > d->optind) + d->__first_nonopt = d->optind; + if (d->__ordering == PERMUTE) + { + if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind) + exchange_a ((char **) argv, d); + else if (d->__last_nonopt != d->optind) + d->__first_nonopt = d->optind; + while (d->optind < argc && (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')) + d->optind++; + d->__last_nonopt = d->optind; + } + if (d->optind != argc && !strcmp(argv[d->optind], "--")) + { + d->optind++; + if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind) + exchange_a((char **) argv, d); + else if (d->__first_nonopt == d->__last_nonopt) + d->__first_nonopt = d->optind; + d->__last_nonopt = argc; + d->optind = argc; + } + if (d->optind == argc) + { + if (d->__first_nonopt != d->__last_nonopt) + d->optind = d->__first_nonopt; + return -1; + } + if ((argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')) + { + if (d->__ordering == REQUIRE_ORDER) + return -1; + d->optarg = argv[d->optind++]; + return 1; + } + d->__nextchar = (argv[d->optind] + 1 + (longopts != NULL && argv[d->optind][1] == '-')); + } + if (longopts != NULL && (argv[d->optind][1] == '-' || (long_only && (argv[d->optind][2] || !strchr(optstring, argv[d->optind][1]))))) + { + char *nameend; + unsigned int namelen; + const struct option_a *p; + const struct option_a *pfound = NULL; + struct option_list + { + const struct option_a *p; + struct option_list *next; + } *ambig_list = NULL; + int exact = 0; + int indfound = -1; + int option_index; + for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++); + namelen = (unsigned int)(nameend - d->__nextchar); + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp(p->name, d->__nextchar, namelen)) + { + if (namelen == (unsigned int)strlen(p->name)) + { + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + pfound = p; + indfound = option_index; + } + else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) + { + struct option_list *newp = (struct option_list*)alloca(sizeof(*newp)); + newp->p = p; + newp->next = ambig_list; + ambig_list = newp; + } + } + if (ambig_list != NULL && !exact) + { + if (print_errors) + { + struct option_list first; + first.p = pfound; + first.next = ambig_list; + ambig_list = &first; + fprintf (stderr, "%s: option '%s' is ambiguous; possibilities:", argv[0], argv[d->optind]); + do + { + fprintf (stderr, " '--%s'", ambig_list->p->name); + ambig_list = ambig_list->next; + } + while (ambig_list != NULL); + fputc ('\n', stderr); + } + d->__nextchar += strlen(d->__nextchar); + d->optind++; + d->optopt = 0; + return '?'; + } + if (pfound != NULL) + { + option_index = indfound; + d->optind++; + if (*nameend) + { + if (pfound->has_arg) + d->optarg = nameend + 1; + else + { + if (print_errors) + { + if (argv[d->optind - 1][1] == '-') + { + fprintf(stderr, "%s: option '--%s' doesn't allow an argument\n",argv[0], pfound->name); + } + else + { + fprintf(stderr, "%s: option '%c%s' doesn't allow an argument\n",argv[0], argv[d->optind - 1][0],pfound->name); + } + } + d->__nextchar += strlen(d->__nextchar); + d->optopt = pfound->val; + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (d->optind < argc) + d->optarg = argv[d->optind++]; + else + { + if (print_errors) + { + fprintf(stderr,"%s: option '--%s' requires an argument\n",argv[0], pfound->name); + } + d->__nextchar += strlen(d->__nextchar); + d->optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + d->__nextchar += strlen(d->__nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + if (!long_only || argv[d->optind][1] == '-' || strchr(optstring, *d->__nextchar) == NULL) + { + if (print_errors) + { + if (argv[d->optind][1] == '-') + { + fprintf(stderr, "%s: unrecognized option '--%s'\n",argv[0], d->__nextchar); + } + else + { + fprintf(stderr, "%s: unrecognized option '%c%s'\n",argv[0], argv[d->optind][0], d->__nextchar); + } + } + d->__nextchar = (char *)""; + d->optind++; + d->optopt = 0; + return '?'; + } + } + { + char c = *d->__nextchar++; + char *temp = (char*)strchr(optstring, c); + if (*d->__nextchar == '\0') + ++d->optind; + if (temp == NULL || c == ':' || c == ';') + { + if (print_errors) + { + fprintf(stderr, "%s: invalid option -- '%c'\n", argv[0], c); + } + d->optopt = c; + return '?'; + } + if (temp[0] == 'W' && temp[1] == ';') + { + char *nameend; + const struct option_a *p; + const struct option_a *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = 0; + int option_index; + if (longopts == NULL) + goto no_longs; + if (*d->__nextchar != '\0') + { + d->optarg = d->__nextchar; + d->optind++; + } + else if (d->optind == argc) + { + if (print_errors) + { + fprintf(stderr,"%s: option requires an argument -- '%c'\n",argv[0], c); + } + d->optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } + else + d->optarg = argv[d->optind++]; + for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '='; nameend++); + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp(p->name, d->__nextchar, nameend - d->__nextchar)) + { + if ((unsigned int) (nameend - d->__nextchar) == strlen(p->name)) + { + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + pfound = p; + indfound = option_index; + } + else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) + ambig = 1; + } + if (ambig && !exact) + { + if (print_errors) + { + fprintf(stderr, "%s: option '-W %s' is ambiguous\n",argv[0], d->optarg); + } + d->__nextchar += strlen(d->__nextchar); + d->optind++; + return '?'; + } + if (pfound != NULL) + { + option_index = indfound; + if (*nameend) + { + if (pfound->has_arg) + d->optarg = nameend + 1; + else + { + if (print_errors) + { + fprintf(stderr, "%s: option '-W %s' doesn't allow an argument\n",argv[0], pfound->name); + } + d->__nextchar += strlen(d->__nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (d->optind < argc) + d->optarg = argv[d->optind++]; + else + { + if (print_errors) + { + fprintf(stderr, "%s: option '-W %s' requires an argument\n",argv[0], pfound->name); + } + d->__nextchar += strlen(d->__nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + else + d->optarg = NULL; + d->__nextchar += strlen(d->__nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } +no_longs: + d->__nextchar = NULL; + return 'W'; + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + if (*d->__nextchar != '\0') + { + d->optarg = d->__nextchar; + d->optind++; + } + else + d->optarg = NULL; + d->__nextchar = NULL; + } + else + { + if (*d->__nextchar != '\0') + { + d->optarg = d->__nextchar; + d->optind++; + } + else if (d->optind == argc) + { + if (print_errors) + { + fprintf(stderr,"%s: option requires an argument -- '%c'\n",argv[0], c); + } + d->optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + d->optarg = argv[d->optind++]; + d->__nextchar = NULL; + } + } + return c; + } +} +int _getopt_internal_a (int argc, char *const *argv, const char *optstring, const struct option_a *longopts, int *longind, int long_only, int posixly_correct) +{ + int result; + getopt_data_a.optind = optind; + getopt_data_a.opterr = opterr; + result = _getopt_internal_r_a (argc, argv, optstring, longopts,longind, long_only, &getopt_data_a,posixly_correct); + optind = getopt_data_a.optind; + optarg_a = getopt_data_a.optarg; + optopt = getopt_data_a.optopt; + return result; +} +int getopt_a (int argc, char *const *argv, const char *optstring) _GETOPT_THROW +{ + return _getopt_internal_a (argc, argv, optstring, (const struct option_a *) 0, (int *) 0, 0, 0); +} +int getopt_long_a (int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW +{ + return _getopt_internal_a (argc, argv, options, long_options, opt_index, 0, 0); +} +int getopt_long_only_a (int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW +{ + return _getopt_internal_a (argc, argv, options, long_options, opt_index, 1, 0); +} +int _getopt_long_r_a (int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index, struct _getopt_data_a *d) +{ + return _getopt_internal_r_a (argc, argv, options, long_options, opt_index,0, d, 0); +} +int _getopt_long_only_r_a (int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index, struct _getopt_data_a *d) +{ + return _getopt_internal_r_a (argc, argv, options, long_options, opt_index, 1, d, 0); +} + +// +// +// Unicode Structures and Functions +// +// + +static struct _getopt_data_w +{ + int optind; + int opterr; + int optopt; + wchar_t *optarg; + int __initialized; + wchar_t *__nextchar; + enum ENUM_ORDERING __ordering; + int __posixly_correct; + int __first_nonopt; + int __last_nonopt; +} getopt_data_w; +wchar_t *optarg_w; + +static void exchange_w(wchar_t **argv, struct _getopt_data_w *d) +{ + int bottom = d->__first_nonopt; + int middle = d->__last_nonopt; + int top = d->optind; + wchar_t *tem; + while (top > middle && middle > bottom) + { + if (top - middle > middle - bottom) + { + int len = middle - bottom; + register int i; + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + } + top -= len; + } + else + { + int len = top - middle; + register int i; + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + } + bottom += len; + } + } + d->__first_nonopt += (d->optind - d->__last_nonopt); + d->__last_nonopt = d->optind; +} +static const wchar_t *_getopt_initialize_w (const wchar_t *optstring, struct _getopt_data_w *d, int posixly_correct) +{ + d->__first_nonopt = d->__last_nonopt = d->optind; + d->__nextchar = NULL; + d->__posixly_correct = posixly_correct | !!_wgetenv(L"POSIXLY_CORRECT"); + if (optstring[0] == L'-') + { + d->__ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == L'+') + { + d->__ordering = REQUIRE_ORDER; + ++optstring; + } + else if (d->__posixly_correct) + d->__ordering = REQUIRE_ORDER; + else + d->__ordering = PERMUTE; + return optstring; +} +int _getopt_internal_r_w (int argc, wchar_t *const *argv, const wchar_t *optstring, const struct option_w *longopts, int *longind, int long_only, struct _getopt_data_w *d, int posixly_correct) +{ + int print_errors = d->opterr; + if (argc < 1) + return -1; + d->optarg = NULL; + if (d->optind == 0 || !d->__initialized) + { + if (d->optind == 0) + d->optind = 1; + optstring = _getopt_initialize_w (optstring, d, posixly_correct); + d->__initialized = 1; + } + else if (optstring[0] == L'-' || optstring[0] == L'+') + optstring++; + if (optstring[0] == L':') + print_errors = 0; + if (d->__nextchar == NULL || *d->__nextchar == L'\0') + { + if (d->__last_nonopt > d->optind) + d->__last_nonopt = d->optind; + if (d->__first_nonopt > d->optind) + d->__first_nonopt = d->optind; + if (d->__ordering == PERMUTE) + { + if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind) + exchange_w((wchar_t **) argv, d); + else if (d->__last_nonopt != d->optind) + d->__first_nonopt = d->optind; + while (d->optind < argc && (argv[d->optind][0] != L'-' || argv[d->optind][1] == L'\0')) + d->optind++; + d->__last_nonopt = d->optind; + } + if (d->optind != argc && !wcscmp(argv[d->optind], L"--")) + { + d->optind++; + if (d->__first_nonopt != d->__last_nonopt && d->__last_nonopt != d->optind) + exchange_w((wchar_t **) argv, d); + else if (d->__first_nonopt == d->__last_nonopt) + d->__first_nonopt = d->optind; + d->__last_nonopt = argc; + d->optind = argc; + } + if (d->optind == argc) + { + if (d->__first_nonopt != d->__last_nonopt) + d->optind = d->__first_nonopt; + return -1; + } + if ((argv[d->optind][0] != L'-' || argv[d->optind][1] == L'\0')) + { + if (d->__ordering == REQUIRE_ORDER) + return -1; + d->optarg = argv[d->optind++]; + return 1; + } + d->__nextchar = (argv[d->optind] + 1 + (longopts != NULL && argv[d->optind][1] == L'-')); + } + if (longopts != NULL && (argv[d->optind][1] == L'-' || (long_only && (argv[d->optind][2] || !wcschr(optstring, argv[d->optind][1]))))) + { + wchar_t *nameend; + unsigned int namelen; + const struct option_w *p; + const struct option_w *pfound = NULL; + struct option_list + { + const struct option_w *p; + struct option_list *next; + } *ambig_list = NULL; + int exact = 0; + int indfound = -1; + int option_index; + for (nameend = d->__nextchar; *nameend && *nameend != L'='; nameend++); + namelen = (unsigned int)(nameend - d->__nextchar); + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!wcsncmp(p->name, d->__nextchar, namelen)) + { + if (namelen == (unsigned int)wcslen(p->name)) + { + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + pfound = p; + indfound = option_index; + } + else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) + { + struct option_list *newp = (struct option_list*)alloca(sizeof(*newp)); + newp->p = p; + newp->next = ambig_list; + ambig_list = newp; + } + } + if (ambig_list != NULL && !exact) + { + if (print_errors) + { + struct option_list first; + first.p = pfound; + first.next = ambig_list; + ambig_list = &first; + fwprintf(stderr, L"%ls: option '%ls' is ambiguous; possibilities:", argv[0], argv[d->optind]); + do + { + fwprintf (stderr, L" '--%ls'", ambig_list->p->name); + ambig_list = ambig_list->next; + } + while (ambig_list != NULL); + fputwc (L'\n', stderr); + } + d->__nextchar += wcslen(d->__nextchar); + d->optind++; + d->optopt = 0; + return L'?'; + } + if (pfound != NULL) + { + option_index = indfound; + d->optind++; + if (*nameend) + { + if (pfound->has_arg) + d->optarg = nameend + 1; + else + { + if (print_errors) + { + if (argv[d->optind - 1][1] == L'-') + { + fwprintf(stderr, L"%ls: option '--%ls' doesn't allow an argument\n",argv[0], pfound->name); + } + else + { + fwprintf(stderr, L"%ls: option '%c%ls' doesn't allow an argument\n",argv[0], argv[d->optind - 1][0],pfound->name); + } + } + d->__nextchar += wcslen(d->__nextchar); + d->optopt = pfound->val; + return L'?'; + } + } + else if (pfound->has_arg == 1) + { + if (d->optind < argc) + d->optarg = argv[d->optind++]; + else + { + if (print_errors) + { + fwprintf(stderr,L"%ls: option '--%ls' requires an argument\n",argv[0], pfound->name); + } + d->__nextchar += wcslen(d->__nextchar); + d->optopt = pfound->val; + return optstring[0] == L':' ? L':' : L'?'; + } + } + d->__nextchar += wcslen(d->__nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + if (!long_only || argv[d->optind][1] == L'-' || wcschr(optstring, *d->__nextchar) == NULL) + { + if (print_errors) + { + if (argv[d->optind][1] == L'-') + { + fwprintf(stderr, L"%ls: unrecognized option '--%ls'\n",argv[0], d->__nextchar); + } + else + { + fwprintf(stderr, L"%ls: unrecognized option '%c%ls'\n",argv[0], argv[d->optind][0], d->__nextchar); + } + } + d->__nextchar = (wchar_t *)L""; + d->optind++; + d->optopt = 0; + return L'?'; + } + } + { + wchar_t c = *d->__nextchar++; + wchar_t *temp = (wchar_t*)wcschr(optstring, c); + if (*d->__nextchar == L'\0') + ++d->optind; + if (temp == NULL || c == L':' || c == L';') + { + if (print_errors) + { + fwprintf(stderr, L"%ls: invalid option -- '%c'\n", argv[0], c); + } + d->optopt = c; + return L'?'; + } + if (temp[0] == L'W' && temp[1] == L';') + { + wchar_t *nameend; + const struct option_w *p; + const struct option_w *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = 0; + int option_index; + if (longopts == NULL) + goto no_longs; + if (*d->__nextchar != L'\0') + { + d->optarg = d->__nextchar; + d->optind++; + } + else if (d->optind == argc) + { + if (print_errors) + { + fwprintf(stderr,L"%ls: option requires an argument -- '%c'\n",argv[0], c); + } + d->optopt = c; + if (optstring[0] == L':') + c = L':'; + else + c = L'?'; + return c; + } + else + d->optarg = argv[d->optind++]; + for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != L'='; nameend++); + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!wcsncmp(p->name, d->__nextchar, nameend - d->__nextchar)) + { + if ((unsigned int) (nameend - d->__nextchar) == wcslen(p->name)) + { + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + pfound = p; + indfound = option_index; + } + else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) + ambig = 1; + } + if (ambig && !exact) + { + if (print_errors) + { + fwprintf(stderr, L"%ls: option '-W %ls' is ambiguous\n",argv[0], d->optarg); + } + d->__nextchar += wcslen(d->__nextchar); + d->optind++; + return L'?'; + } + if (pfound != NULL) + { + option_index = indfound; + if (*nameend) + { + if (pfound->has_arg) + d->optarg = nameend + 1; + else + { + if (print_errors) + { + fwprintf(stderr, L"%ls: option '-W %ls' doesn't allow an argument\n",argv[0], pfound->name); + } + d->__nextchar += wcslen(d->__nextchar); + return L'?'; + } + } + else if (pfound->has_arg == 1) + { + if (d->optind < argc) + d->optarg = argv[d->optind++]; + else + { + if (print_errors) + { + fwprintf(stderr, L"%ls: option '-W %ls' requires an argument\n",argv[0], pfound->name); + } + d->__nextchar += wcslen(d->__nextchar); + return optstring[0] == L':' ? L':' : L'?'; + } + } + else + d->optarg = NULL; + d->__nextchar += wcslen(d->__nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } +no_longs: + d->__nextchar = NULL; + return L'W'; + } + if (temp[1] == L':') + { + if (temp[2] == L':') + { + if (*d->__nextchar != L'\0') + { + d->optarg = d->__nextchar; + d->optind++; + } + else + d->optarg = NULL; + d->__nextchar = NULL; + } + else + { + if (*d->__nextchar != L'\0') + { + d->optarg = d->__nextchar; + d->optind++; + } + else if (d->optind == argc) + { + if (print_errors) + { + fwprintf(stderr,L"%ls: option requires an argument -- '%c'\n",argv[0], c); + } + d->optopt = c; + if (optstring[0] == L':') + c = L':'; + else + c = L'?'; + } + else + d->optarg = argv[d->optind++]; + d->__nextchar = NULL; + } + } + return c; + } +} +int _getopt_internal_w (int argc, wchar_t *const *argv, const wchar_t *optstring, const struct option_w *longopts, int *longind, int long_only, int posixly_correct) +{ + int result; + getopt_data_w.optind = optind; + getopt_data_w.opterr = opterr; + result = _getopt_internal_r_w (argc, argv, optstring, longopts,longind, long_only, &getopt_data_w,posixly_correct); + optind = getopt_data_w.optind; + optarg_w = getopt_data_w.optarg; + optopt = getopt_data_w.optopt; + return result; +} +int getopt_w (int argc, wchar_t *const *argv, const wchar_t *optstring) _GETOPT_THROW +{ + return _getopt_internal_w (argc, argv, optstring, (const struct option_w *) 0, (int *) 0, 0, 0); +} +int getopt_long_w (int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW +{ + return _getopt_internal_w (argc, argv, options, long_options, opt_index, 0, 0); +} +int getopt_long_only_w (int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW +{ + return _getopt_internal_w (argc, argv, options, long_options, opt_index, 1, 0); +} +int _getopt_long_r_w (int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index, struct _getopt_data_w *d) +{ + return _getopt_internal_r_w (argc, argv, options, long_options, opt_index,0, d, 0); +} +int _getopt_long_only_r_w (int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index, struct _getopt_data_w *d) +{ + return _getopt_internal_r_w (argc, argv, options, long_options, opt_index, 1, d, 0); +} \ No newline at end of file diff -Nru mathgl-2.3.4/addons/getopt/getopt.h mathgl-2.3.5.1/addons/getopt/getopt.h --- mathgl-2.3.4/addons/getopt/getopt.h 1970-01-01 00:00:00.000000000 +0000 +++ mathgl-2.3.5.1/addons/getopt/getopt.h 2016-06-19 17:06:03.000000000 +0000 @@ -0,0 +1,121 @@ +/* Getopt for Microsoft C +This code is a modification of the Free Software Foundation, Inc. +Getopt library for parsing command line argument the purpose was +to provide a Microsoft Visual C friendly derivative. This code +provides functionality for both Unicode and Multibyte builds. + +Date: 02/03/2011 - Ludvik Jerabek - Initial Release +Version: 1.0 +Comment: Supports getopt, getopt_long, and getopt_long_only +and POSIXLY_CORRECT environment flag +License: LGPL + +Revisions: + +02/03/2011 - Ludvik Jerabek - Initial Release +02/20/2011 - Ludvik Jerabek - Fixed compiler warnings at Level 4 +07/05/2011 - Ludvik Jerabek - Added no_argument, required_argument, optional_argument defs +08/03/2011 - Ludvik Jerabek - Fixed non-argument runtime bug which caused runtime exception +08/09/2011 - Ludvik Jerabek - Added code to export functions for DLL and LIB +02/15/2012 - Ludvik Jerabek - Fixed _GETOPT_THROW definition missing in implementation file +08/01/2012 - Ludvik Jerabek - Created separate functions for char and wchar_t characters so single dll can do both unicode and ansi +10/15/2012 - Ludvik Jerabek - Modified to match latest GNU features +06/19/2015 - Ludvik Jerabek - Fixed maximum option limitation caused by option_a (255) and option_w (65535) structure val variable + +**DISCLAIMER** +THIS MATERIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING, BUT Not LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE +EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT +APPLY TO YOU. IN NO EVENT WILL I BE LIABLE TO ANY PARTY FOR ANY +DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES FOR ANY +USE OF THIS MATERIAL INCLUDING, WITHOUT LIMITATION, ANY LOST +PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON +YOUR INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN If WE ARE +EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +*/ +#ifndef __GETOPT_H_ + #define __GETOPT_H_ + #include + #define _GETOPT_API MGL_EXPORT + + // Change behavior for C\C++ + #ifdef __cplusplus + #define _BEGIN_EXTERN_C extern "C" { + #define _END_EXTERN_C } + #define _GETOPT_THROW throw() + #else + #define _BEGIN_EXTERN_C + #define _END_EXTERN_C + #define _GETOPT_THROW + #endif + + // Standard GNU options + #define null_argument 0 /*Argument Null*/ + #define no_argument 0 /*Argument Switch Only*/ + #define required_argument 1 /*Argument Required*/ + #define optional_argument 2 /*Argument Optional*/ + + // Shorter Options + #define ARG_NULL 0 /*Argument Null*/ + #define ARG_NONE 0 /*Argument Switch Only*/ + #define ARG_REQ 1 /*Argument Required*/ + #define ARG_OPT 2 /*Argument Optional*/ + + #include + #include + +_BEGIN_EXTERN_C + + extern _GETOPT_API int optind; + extern _GETOPT_API int opterr; + extern _GETOPT_API int optopt; + + // Ansi + struct option_a + { + const char* name; + int has_arg; + int *flag; + int val; + }; + extern _GETOPT_API char *optarg_a; + extern _GETOPT_API int getopt_a(int argc, char *const *argv, const char *optstring) _GETOPT_THROW; + extern _GETOPT_API int getopt_long_a(int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW; + extern _GETOPT_API int getopt_long_only_a(int argc, char *const *argv, const char *options, const struct option_a *long_options, int *opt_index) _GETOPT_THROW; + + // Unicode + struct option_w + { + const wchar_t* name; + int has_arg; + int *flag; + int val; + }; + extern _GETOPT_API wchar_t *optarg_w; + extern _GETOPT_API int getopt_w(int argc, wchar_t *const *argv, const wchar_t *optstring) _GETOPT_THROW; + extern _GETOPT_API int getopt_long_w(int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW; + extern _GETOPT_API int getopt_long_only_w(int argc, wchar_t *const *argv, const wchar_t *options, const struct option_w *long_options, int *opt_index) _GETOPT_THROW; + +_END_EXTERN_C + + #undef _BEGIN_EXTERN_C + #undef _END_EXTERN_C + #undef _GETOPT_THROW + #undef _GETOPT_API + + #ifdef _UNICODE + #define getopt getopt_w + #define getopt_long getopt_long_w + #define getopt_long_only getopt_long_only_w + #define option option_w + #define optarg optarg_w + #else + #define getopt getopt_a + #define getopt_long getopt_long_a + #define getopt_long_only getopt_long_only_a + #define option option_a + #define optarg optarg_a + #endif +#endif // __GETOPT_H_ diff -Nru mathgl-2.3.4/ChangeLog.txt mathgl-2.3.5.1/ChangeLog.txt --- mathgl-2.3.4/ChangeLog.txt 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/ChangeLog.txt 2016-06-19 17:06:02.000000000 +0000 @@ -1,3 +1,66 @@ +2.3.5.1 Released 2 June 2016 + +* INCOMPATIBLE: library libmgl-qt is removed. You need to use libmgl-qt4 or libmgl-qt5 explicitly now. +* Compatibility changes for latest MS VisualStudio. +* Bugfixes. + +2.3.5 Released 16 May 2016 + +* Greatly update mgltex (by Diego Sejas Viscarra) + o \MGL@codes: Bugfix: category code for tabulators is changed too + o \MGL@quality: 9 is accepted as quality value now + o \MGL@scale: Now accepts any positive value + o \MGL@test@switch: New command to verify and validate switching arguments + o \mglTeX: Add a small negative space in the logo, between the "mgl" and "TEX" + o \mglTeX: Declared now as robust command + o \mglcomments: Now accepts arguments 0 (equivalent to off) and 1 (equivalent to on), besides the usual off and on + o \mglgraphics: New command options: gray, mglscale, quality, variant + o \mglname: Now writes the MGL code line setsize 600 400 to the main script + o \mglplot: Added \bgroup and \egroup in order to keep changes private + o New command options: gray, mglscale, quality, variant + o \mglsettings: Added options gray and variant + o Now calls the \mglswitch and \mglcomments commands for the switch and comments options, respectively + o \mglswitch: Now accepts arguments 0 (equivalent to off) and 1 (equivalent to on), besides the usual off and on + o mglTeX now depends on the ifpdf package + o Change definition of \mglcommentname from MGL comment to mglTEX comment + o Introduce the concept of global, local and private settings in the documentation + o New commands: \mglgray (to activate/deactivate) gray-scale mode locally, and \mglvariant (to set variant of arguments in MGL scripts locally) + o New package option 9q for setting quality to 9 (for testing purposes of the author) + o New package options 0v, 1v, 2v to select variant of arguments in MGL scripts + o New package options gray, color to activate/deactivate gray-scale mode for graphics + o Remove the \MGL@setkeys command, since it isn’t needed as first thought + o Rename \MGL@document@scripts to \MGL@doc@scripts + o Rename \MGL@script@name to \MGL@script + o Rename command \MGL@graph@ext to \MGL@imgext + o Rename command \mglcommonscriptname to mglsetupscriptname + o Rename environment mglcommon to mglsetupscript (mglcommon is still available, but deprecated) + o Rename family MGL@keys as MGL@gr@keys for consistency + o Reorganize and update documentation + o Some minor bugfixes + o The MGL code line "setsize 600 400" is now automatically written to the main script in order for the scaling options and commands to work + o mgl: New environment options: gray, mglscale, quality, variant + o mglcode: New environment options: gray, mglscale, quality, variant +* Add MGL command 'variant' to select proper variant of arguments (like "var1?var2?var3?...") in MGL commands. +* Remove limitation of maximal number (was 1000) of arguments for MGL commands. This is actual for 'list' command. +* Add mglWnd::Widget() for accessing widget which is used for drawing. +* Add Gray() for producing gray-scaled image. +* Add MGL command 'setsizescl' for scaling all further 'setsize'. +* Add Shear() for shearing plot. +* Add ShearPlot() for placing plots side-by-side with some shearing. +* Add mglData::Limit() for limit maximal absolute value of data. +* Add mglTridMat() for tridiagonal matrix algorithm. +* Add MGL command 'diffract' for single step diffraction calculation. +* Add 'ifsfile' for reading IFS fractal parameters from *.ifs file. +* Add style '*' for 2d versions of Pipe() and Flow() to draw threads from points inside axis range. +* Add "norm()" to the list of known functions +* Compatibility changes for MS VisualStudio, MacOS, Win64. +* Bugfix for legend export into EPS and SVG. +* Bugfix for importing data from std::vector. +* Improve Surf3*() drawing. +* Force NAN if divided by 0 in formulas. +* Option "-S" of mglconv now perform scaling in any cases + + 2.3.4 Released 13 February 2016 * Add mglData::Pulse() for determining pulse parameters. diff -Nru mathgl-2.3.4/CMakeLists.txt mathgl-2.3.5.1/CMakeLists.txt --- mathgl-2.3.4/CMakeLists.txt 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/CMakeLists.txt 2016-06-19 17:06:40.000000000 +0000 @@ -1,10 +1,12 @@ -cmake_minimum_required(VERSION 2.8.9) +cmake_minimum_required(VERSION 2.8.12) if(POLICY CMP0043) cmake_policy(SET CMP0043 OLD) endif() project( MathGL ) +set(MGL_DEP_LIBS) + if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) @@ -12,8 +14,8 @@ set(CMAKE_VERBOSE_MAKEFILE ON) set(MathGL_VERSION_MAJOR 2) -set(MathGL_VERSION_MINOR 3.4) -set(MathGL_SOVERSION 7.4.1) +set(MathGL_VERSION_MINOR 3.5) +set(MathGL_SOVERSION 7.4.3) function(mgl_add_lib mgl_tmp_lib) if(${mgl_tmp_lib} MATCHES mgl) @@ -28,16 +30,29 @@ add_library(${mgllib} SHARED ${mgl_src_lst}) add_library(${mgllib}-static STATIC ${mgl_src_lst}) set_target_properties(${mgllib} PROPERTIES SOVERSION ${MathGL_SOVERSION}) - set_target_properties(${mgllib} PROPERTIES CLEAN_DIRECT_OUTPUT 1) set_target_properties(${mgllib} PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS") - set_target_properties(${mgllib}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + set_target_properties(${mgllib} PROPERTIES C_VISIBILITY_PRESET hidden) + set_target_properties(${mgllib} PROPERTIES CXX_VISIBILITY_PRESET hidden) + set_target_properties(${mgllib} PROPERTIES VISIBILITY_INLINES_HIDDEN 1) target_compile_definitions(${mgllib}-static PUBLIC MGL_STATIC_DEFINE) - + if(MSVC) + set(mgl_lib_static "-static") + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(mgl_lib_end "d") + else(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(mgl_lib_end) + endif(CMAKE_BUILD_TYPE STREQUAL "Debug") + elseif(MSVC) + set(mgl_lib_static) + set_target_properties(${mgllib} PROPERTIES CLEAN_DIRECT_OUTPUT 1) + set_target_properties(${mgllib}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + endif(MSVC) if(enable-mgl2) - set_target_properties(${mgllib} PROPERTIES OUTPUT_NAME "${mgllib2}") - set_target_properties(${mgllib}-static PROPERTIES OUTPUT_NAME "${mgllib2}") + set_target_properties(${mgllib} PROPERTIES OUTPUT_NAME "${mgllib2}${mgl_lib_end}") + set_target_properties(${mgllib}-static PROPERTIES OUTPUT_NAME "${mgllib2}${mgl_lib_static}${mgl_lib_end}") else(enable-mgl2) - set_target_properties(${mgllib}-static PROPERTIES OUTPUT_NAME "${mgllib}") + set_target_properties(${mgllib} PROPERTIES OUTPUT_NAME "${mgllib}${mgl_lib_end}") + set_target_properties(${mgllib}-static PROPERTIES OUTPUT_NAME "${mgllib}${mgl_lib_static}${mgl_lib_end}") endif(enable-mgl2) install( @@ -136,17 +151,30 @@ CMAKE_DEPENDENT_OPTION(enable-fltk "Enable fltk widget" OFF "NOT enable-all-widgets" ON) CMAKE_DEPENDENT_OPTION(enable-wx "Enable wxWidget widget" OFF "NOT enable-all-widgets" ON) CMAKE_DEPENDENT_OPTION(enable-qt4 "Enable Qt4 widget" OFF "NOT enable-all-widgets" ON) +CMAKE_DEPENDENT_OPTION(enable-qt4asqt "Set Qt4 as default libmgl-qt" OFF "enable-qt4" OFF) CMAKE_DEPENDENT_OPTION(enable-qt5 "Enable Qt5 widget" OFF "NOT enable-all-widgets" ON) -CMAKE_DEPENDENT_OPTION(enable-qt5asqt "Set Qt5 as default libmgl-qt" ON "enable-qt5" OFF) +CMAKE_DEPENDENT_OPTION(enable-qt5asqt "Set Qt5 as default libmgl-qt" OFF "enable-qt5" OFF) -if(UNIX AND enable-rvalue) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") -endif(UNIX AND enable-rvalue) - -# MSVC does not require any special flags +# msvc fwprintf print char* for the specifier of "%s" format +if(MSVC AND MSVC_VERSION GREATER 1899) + SET(CMAKE_CXX_FLAGS "/EHsc -D_CRT_STDIO_ISO_WIDE_SPECIFIERS ${CMAKE_CXX_FLAGS}") + SET(CMAKE_C_FLAGS "-D_CRT_STDIO_ISO_WIDE_SPECIFIERS ${CMAKE_C_FLAGS}") +endif(MSVC AND MSVC_VERSION GREATER 1899) if(enable-qt4 OR enable-qt5) -set(QT_ENABLED ON) + set(QT_ENABLED ON) + if(enable-qt4asqt AND enable-qt5asqt) + message(SEND_ERROR "You cannot make Qt4 and Qt5 as qt at the same time.") + endif(enable-qt4asqt AND enable-qt5asqt) + if(enable-qt4 AND NOT enable-qt5) + set(enable-qt4asqt TRUE) + endif(enable-qt4 AND NOT enable-qt5) + if(enable-qt5 AND NOT enable-qt4) + set(enable-qt5asqt TRUE) + endif(enable-qt5 AND NOT enable-qt4) +# if(NOT enable-opengl) +# message(SEND_ERROR "You cannot build MathGL with Qt4 or Qt5 without OpenGL enabled.") +# endif(NOT enable-opengl) endif(enable-qt4 OR enable-qt5) CMAKE_DEPENDENT_OPTION(enable-json-sample "Enable JSON sample" ON "QT_ENABLED" OFF) @@ -183,16 +211,18 @@ CHECK_FUNCTION_EXISTS(sin MGL_SIN) CHECK_FUNCTION_EXISTS(memrchr HAVE_MEMRCHR) if(NOT MGL_SIN) - cmake_push_check_state() - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m) - CHECK_FUNCTION_EXISTS(sin MGL_SIN_M) - cmake_pop_check_state() - if(MGL_SIN_M) - set(M_LIB m) - elseif(MGL_SIN_M) - message(SEND_ERROR "Math library not found") - endif(MGL_SIN_M) + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m) + CHECK_FUNCTION_EXISTS(sin MGL_SIN_M) + cmake_pop_check_state() + if(MGL_SIN_M) + set(M_LIB m) + elseif(MGL_SIN_M) + message(SEND_ERROR "Math library not found") + endif(MGL_SIN_M) endif(NOT MGL_SIN) +set(MGL_DEP_LIBS ${M_LIB} ${MGL_DEP_LIBS}) + if(HAVE_MEMRCHR) ADD_DEFINITIONS(-DHAVE_MEMRCHR) endif(HAVE_MEMRCHR) @@ -201,7 +231,7 @@ check_type_size("long" SIZEOF_LONG) include(CheckCXXSourceCompiles) -unset(MGL_HAVE_C99_COMPLEX) +#unset(MGL_HAVE_C99_COMPLEX) CHECK_CXX_SOURCE_COMPILES( "#include #include @@ -214,7 +244,7 @@ set(MGL_HAVE_C99_COMPLEX 0) endif(NOT MGL_HAVE_C99_COMPLEX) -unset(MGL_HAVE_NAN_INF) +#unset(MGL_HAVE_NAN_INF) CHECK_CXX_SOURCE_COMPILES( "#include int main(){double a=NAN, b=INFINITY;return 0;}" MGL_HAVE_NAN_INF) @@ -222,7 +252,7 @@ set(MGL_HAVE_NAN_INF 0) endif(NOT MGL_HAVE_NAN_INF) -unset(MGL_HAVE_ATTRIBUTE) +#unset(MGL_HAVE_ATTRIBUTE) CHECK_CXX_SOURCE_COMPILES( "int __attribute__((pure)) test1() {return 0;} int __attribute__((const)) test2(int x) {return x*x;} @@ -231,7 +261,7 @@ set(MGL_HAVE_ATTRIBUTE 0) endif(NOT MGL_HAVE_ATTRIBUTE) -unset(MGL_HAVE_TYPEOF) +unset(MGL_HAVE_TYPEOF CACHE) CHECK_CXX_SOURCE_COMPILES( "#define mgl_isnum(a) ({typeof (a) _a = (a); _a==_a;}) int main(){bool a=mgl_isnum(1);return 0;}" MGL_HAVE_TYPEOF) @@ -239,13 +269,30 @@ set(MGL_HAVE_TYPEOF 0) endif(NOT MGL_HAVE_TYPEOF) -unset(MGL_HAVE_RVAL) -CHECK_CXX_SOURCE_COMPILES( -"struct test { test() {} test(test&& a){} }; -int main() { test t; return 0; }" MGL_HAVE_RVAL) -if(NOT MGL_HAVE_RVAL) +if(NOT MSVC AND enable-rvalue) + SET(CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}") + unset(MGL_HAVE_RVAL CACHE) + CHECK_CXX_SOURCE_COMPILES( + "struct test { test() {} test(test&& a){} }; + int main() { test t; return 0; }" MGL_HAVE_RVAL) + if(NOT MGL_HAVE_RVAL) + message(SEND_ERROR "Couldn't enable rvalue.") +# set(MGL_HAVE_RVAL 0) + endif(NOT MGL_HAVE_RVAL) +else(NOT MSVC AND enable-rvalue) set(MGL_HAVE_RVAL 0) -endif(NOT MGL_HAVE_RVAL) +endif(NOT MSVC AND enable-rvalue) + + + +CHECK_CXX_SOURCE_COMPILES( +"#include +int main(int argc, char *args[]) { +int ch = getopt(argc, args, \"1:2:3:4:5:6:7:8:9:hno:L:C:A:s:S:q:\"); return 0; }" MGL_HAVE_GETOPT) +if(NOT MGL_HAVE_GETOPT) + include_directories(${MathGL_SOURCE_DIR}/addons/getopt) + set(getopt_lib-static getopt-static) +endif(NOT MGL_HAVE_GETOPT) if(enable-double) set(MGL_USE_DOUBLE 1) @@ -281,24 +328,22 @@ set(MGL_HAVE_MPI 0) endif(enable-mpi) -if(enable-pthread) - set(MGL_HAVE_PTHREAD 1) - include(FindThreads) - if(NOT CMAKE_USE_PTHREADS_INIT) - message(SEND_ERROR "Couldn't find POSIX threads library.") - endif(NOT CMAKE_USE_PTHREADS_INIT) -else(enable-pthread) - set(MGL_HAVE_PTHREAD 0) -endif(enable-pthread) if(enable-pthr-widget OR enable-pthread) + if(enable-pthread) + set(MGL_HAVE_PTHREAD 1) + else(enable-pthread) + set(MGL_HAVE_PTHREAD 0) + endif(enable-pthread) set(MGL_HAVE_PTHR_WIDGET 1) include(FindThreads) if(NOT CMAKE_USE_PTHREADS_INIT) message(SEND_ERROR "Couldn't find POSIX threads library.") endif(NOT CMAKE_USE_PTHREADS_INIT) + set(MGL_DEP_LIBS ${CMAKE_THREAD_LIBS_INIT} ${MGL_DEP_LIBS}) else(enable-pthr-widget OR enable-pthread) set(MGL_HAVE_PTHR_WIDGET 0) + set(MGL_HAVE_PTHREAD 0) endif(enable-pthr-widget OR enable-pthread) if(enable-gsl) @@ -318,6 +363,8 @@ int main(){gsl_multifit_fdfsolver *s=0;gsl_matrix *J = 0; gsl_multifit_fdfsolver_jac(s, J);}" MGL_HAVE_GSL2) endif(NOT GSL_LIB OR NOT GSL_CBLAS_LIB OR NOT GSL_INCLUDE_DIR) + set(MGL_DEP_LIBS ${GSL_LIB} ${GSL_CBLAS_LIB} ${MGL_DEP_LIBS}) + include_directories(${GSL_INCLUDE_DIR}) else(enable-gsl) set(MGL_HAVE_GSL 0) endif(enable-gsl) @@ -331,6 +378,8 @@ message(SEND_ERROR "${LTDL_INCLUDE_DIR}") message(SEND_ERROR "Couldn't find LTDL library.") endif(NOT LTDL_LIB OR NOT LTDL_INCLUDE_DIR) + set(MGL_DEP_LIBS ${LTDL_LIB} ${MGL_DEP_LIBS}) + include_directories(${LTDL_INCLUDE_DIR}) else(enable-all OR enable-ltdl) set(MGL_HAVE_LTDL 0) endif(enable-all OR enable-ltdl) @@ -346,6 +395,8 @@ message(SEND_ERROR "${HDF4_INCLUDE_DIR}") message(SEND_ERROR "Couldn't find HDF4 libraries.") endif(NOT HDF4_LIB OR NOT HDF4MF_LIB OR NOT HDF4_INCLUDE_DIR) + set(MGL_DEP_LIBS ${HDF4MF_LIB} ${HDF4_LIB} ${MGL_DEP_LIBS}) + include_directories(${HDF4_INCLUDE_DIR}) else(enable-hdf4) set(MGL_HAVE_HDF4 0) endif(enable-hdf4) @@ -359,6 +410,8 @@ message(SEND_ERROR "Couldn't find HDF5 library.") endif(NOT HDF5_FOUND) endif(NOT HDF5_FOUND) + set(MGL_DEP_LIBS ${HDF5_LIBRARIES} ${HDF5_C_SHARED_LIBRARY} ${MGL_DEP_LIBS}) + include_directories(${HDF5_INCLUDE_DIR}) else(enable-hdf5) set(MGL_HAVE_HDF5 0) endif(enable-hdf5) @@ -369,6 +422,8 @@ if(NOT JPEG_FOUND) message(SEND_ERROR "Couldn't find JPEG library.") endif(NOT JPEG_FOUND) + set(MGL_DEP_LIBS ${JPEG_LIBRARIES} ${MGL_DEP_LIBS}) + include_directories(${JPEG_INCLUDE_DIR}) else(enable-jpeg) set(MGL_HAVE_JPEG 0) endif(enable-jpeg) @@ -380,6 +435,8 @@ if(NOT ZLIB_FOUND) message(SEND_ERROR "Couldn't find ZLib library.") endif(NOT ZLIB_FOUND) + set(MGL_DEP_LIBS ${ZLIB_LIBRARIES} ${MGL_DEP_LIBS}) + include_directories(${ZLIB_INCLUDE_DIR}) else(enable-zlib) set(MGL_HAVE_ZLIB 0) endif(enable-zlib) @@ -393,6 +450,8 @@ if(NOT PNG_FOUND) message(SEND_ERROR "Couldn't find PNG library.") endif(NOT PNG_FOUND) + set(MGL_DEP_LIBS ${PNG_LIBRARIES} ${MGL_DEP_LIBS}) + include_directories(${PNG_INCLUDE_DIR}) else(enable-png) set(MGL_HAVE_PNG 0) endif(enable-png) @@ -411,6 +470,8 @@ if(NOT HPDF_INCLUDE_DIR) message(SEND_ERROR "Couldn't find headers of 3d-enabled version of libhpdf.") endif(NOT HPDF_INCLUDE_DIR) + include_directories(${HPDF_INCLUDE_DIR}) + set(MGL_DEP_LIBS ${HPDF_LIB} ${MGL_DEP_LIBS}) else(enable-pdf) set(MGL_HAVE_PDF 0) endif(enable-pdf) @@ -421,6 +482,8 @@ if(NOT GIF_FOUND) message(SEND_ERROR "Couldn't find GIF library.") endif(NOT GIF_FOUND) + set(MGL_DEP_LIBS ${GIF_LIBRARIES} ${MGL_DEP_LIBS}) + include_directories(${GIF_INCLUDE_DIR}) else(enable-gif) set(MGL_HAVE_GIF 0) endif(enable-gif) @@ -431,6 +494,8 @@ if(NOT OPENGL_FOUND) message(SEND_ERROR "Couldn't find OpenGL libraries.") endif(NOT OPENGL_FOUND) + set(MGL_DEP_LIBS ${OPENGL_LIBRARIES} ${MGL_DEP_LIBS}) + include_directories(${OPENGL_INCLUDE_DIR} ) else(enable-opengl) set(MGL_HAVE_OPENGL 0) endif(enable-opengl) @@ -557,6 +622,10 @@ add_definitions(-DWIN32) endif(WIN32) +if(NOT MGL_HAVE_GETOPT) + add_subdirectory( addons/getopt ) +endif(NOT MGL_HAVE_GETOPT) + add_subdirectory( src ) add_subdirectory( widgets ) add_subdirectory( include ) @@ -566,17 +635,15 @@ if(enable-python OR enable-lua OR enable-octave) add_subdirectory( lang ) endif(enable-python OR enable-lua OR enable-octave) - if(NOT MSVC AND NOT BORLAND) - add_subdirectory( utils ) - endif(NOT MSVC AND NOT BORLAND) +add_subdirectory( utils ) +add_subdirectory( examples ) if(NOT WIN32) add_subdirectory( fonts ) endif(NOT WIN32) -# add_subdirectory( mgllab ) +# add_subdirectory( mgllab ) endif(NOT enable-lgpl) if(NOT MSVC AND NOT BORLAND) - add_subdirectory( examples ) if(MGL_HAVE_DOC_HTML OR MGL_HAVE_DOC_SITE OR MGL_HAVE_DOC_INFO OR MGL_HAVE_DOC_PDF_RU OR MGL_HAVE_DOC_PDF_EN ) add_subdirectory( texinfo ) diff -Nru mathgl-2.3.4/cmake-qt4.txt mathgl-2.3.5.1/cmake-qt4.txt --- mathgl-2.3.4/cmake-qt4.txt 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/cmake-qt4.txt 2016-06-19 17:06:02.000000000 +0000 @@ -1,14 +1,20 @@ set(MGL_HAVE_QT4 1) +set(MGL_QT4_LIBS) if(enable-json-sample) -set(MGL_QT4_LIBS Core Gui Network WebKit OpenGL) -FIND_PACKAGE(Qt4 4.8 REQUIRED QtCore QtGui QtNetwork QtWebKit QtOpenGL) +set(MGL_QT4_LIBS_FIND QtCore QtGui QtNetwork QtWebKit QtOpenGL) else(enable-json-sample) -set(MGL_QT4_LIBS Core Gui OpenGL) -FIND_PACKAGE(Qt4 4.8 REQUIRED QtCore QtGui QtOpenGL) +set(MGL_QT4_LIBS_FIND QtCore QtGui QtOpenGL) endif(enable-json-sample) + +FIND_PACKAGE(Qt4 4.8 REQUIRED ${MGL_QT4_LIBS_FIND}) + if(NOT QT4_FOUND) message(SEND_ERROR "Couldn't find Qt4 library.") endif(NOT QT4_FOUND) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) + +foreach(mgl_qt4_lib ${MGL_QT4_LIBS_FIND}) + set(MGL_QT4_LIBS ${MGL_QT4_LIBS} Qt4::${mgl_qt4_lib}) +endforeach(mgl_qt4_lib) diff -Nru mathgl-2.3.4/cmake-qt5.txt mathgl-2.3.5.1/cmake-qt5.txt --- mathgl-2.3.4/cmake-qt5.txt 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/cmake-qt5.txt 2016-06-19 17:06:02.000000000 +0000 @@ -1,37 +1,18 @@ set(MGL_HAVE_QT5 1) -find_package(Qt5Core REQUIRED) -find_package(Qt5Widgets REQUIRED) -find_package(Qt5Gui REQUIRED) -find_package(Qt5PrintSupport REQUIRED) -find_package(Qt5OpenGL REQUIRED) -if(NOT Qt5OpenGL_FOUND) - message(SEND_ERROR "Couldn't find Qt5 OpenGL library.") -endif(NOT Qt5OpenGL_FOUND) -if(NOT Qt5Core_FOUND) - message(SEND_ERROR "Couldn't find Qt5 Core library.") -endif(NOT Qt5Core_FOUND) -if(NOT Qt5Gui_FOUND) - message(SEND_ERROR "Couldn't find Qt5 Gui library.") -endif(NOT Qt5Gui_FOUND) -if(NOT Qt5PrintSupport_FOUND) - message(SEND_ERROR "Couldn't find Qt5 PrintSupport library.") -endif(NOT Qt5PrintSupport_FOUND) -set(MGL_QT5_LIBS Core Gui Widgets PrintSupport OpenGL) + +set(MGL_QT5_LIBS_FIND Core Gui Widgets PrintSupport OpenGL) + if(enable-json-sample) -find_package(Qt5Network REQUIRED) -find_package(Qt5WebKit REQUIRED) -find_package(Qt5WebKitWidgets REQUIRED) -if(NOT Qt5Network_FOUND) - message(SEND_ERROR "Couldn't find Qt5 Network library.") -endif(NOT Qt5Network_FOUND) -if(NOT Qt5WebKit_FOUND) - message(SEND_ERROR "Couldn't find Qt5 WebKit library.") -endif(NOT Qt5WebKit_FOUND) -if(NOT Qt5WebKitWidgets_FOUND) - message(SEND_ERROR "Couldn't find Qt5 WebKitWidgets library.") -endif(NOT Qt5WebKitWidgets_FOUND) -set(MGL_QT5_LIBS ${MGL_QT5_LIBS} Network WebKit WebKitWidgets) + set(MGL_QT5_LIBS_FIND ${MGL_QT5_LIBS_FIND} Network WebKit WebKitWidgets) endif(enable-json-sample) +foreach(mgl_qt5_lib ${MGL_QT5_LIBS_FIND}) + set(MGL_QT5_LIBS ${MGL_QT5_LIBS} Qt5::${mgl_qt5_lib}) + find_package(Qt5${mgl_qt5_lib} REQUIRED) + if(NOT Qt5${mgl_qt5_lib}_FOUND) + message(SEND_ERROR "Couldn't find Qt5 ${mgl_qt5_lib} library.") + endif(NOT Qt5${mgl_qt5_lib}_FOUND) +endforeach(mgl_qt5_lib) + set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) diff -Nru mathgl-2.3.4/debian/changelog mathgl-2.3.5.1/debian/changelog --- mathgl-2.3.4/debian/changelog 2016-05-19 14:27:01.000000000 +0000 +++ mathgl-2.3.5.1/debian/changelog 2017-02-09 00:22:01.000000000 +0000 @@ -1,8 +1,8 @@ -mathgl (2.3.4-1build1) yakkety; urgency=medium +mathgl (2.3.5.1-1ubuntu1~yakkety) yakkety; urgency=medium - * Rebuild against liboctave3v5. + * Imported Upstream version 2.3.5 - -- Gianfranco Costamagna Thu, 19 May 2016 16:27:01 +0200 + -- tehuser Wed, 08 Feb 2017 22:34:13 +0100 mathgl (2.3.4-1) unstable; urgency=medium diff -Nru mathgl-2.3.4/debian/libmgl-fltk7.4.1.install mathgl-2.3.5.1/debian/libmgl-fltk7.4.1.install --- mathgl-2.3.4/debian/libmgl-fltk7.4.1.install 2016-02-20 15:05:06.000000000 +0000 +++ mathgl-2.3.5.1/debian/libmgl-fltk7.4.1.install 2017-02-08 23:11:20.000000000 +0000 @@ -1 +0,0 @@ -debian/tmp/usr/lib/libmgl-fltk.so.* \ No newline at end of file diff -Nru mathgl-2.3.4/debian/libmgl-glut7.4.1.install mathgl-2.3.5.1/debian/libmgl-glut7.4.1.install --- mathgl-2.3.4/debian/libmgl-glut7.4.1.install 2016-02-20 15:05:06.000000000 +0000 +++ mathgl-2.3.5.1/debian/libmgl-glut7.4.1.install 2017-02-08 23:11:38.000000000 +0000 @@ -1 +0,0 @@ -debian/tmp/usr/lib/libmgl-glut.so.* \ No newline at end of file diff -Nru mathgl-2.3.4/debian/libmgl-mpi7.4.1.install mathgl-2.3.5.1/debian/libmgl-mpi7.4.1.install --- mathgl-2.3.4/debian/libmgl-mpi7.4.1.install 2016-02-20 15:05:06.000000000 +0000 +++ mathgl-2.3.5.1/debian/libmgl-mpi7.4.1.install 2017-02-08 23:11:42.000000000 +0000 @@ -1 +0,0 @@ -debian/tmp/usr/lib/libmgl-mpi.so.* \ No newline at end of file diff -Nru mathgl-2.3.4/debian/libmgl-qt5-7.4.1.install mathgl-2.3.5.1/debian/libmgl-qt5-7.4.1.install --- mathgl-2.3.4/debian/libmgl-qt5-7.4.1.install 2016-02-20 15:05:06.000000000 +0000 +++ mathgl-2.3.5.1/debian/libmgl-qt5-7.4.1.install 2017-02-08 23:11:06.000000000 +0000 @@ -1,2 +0,0 @@ -debian/tmp/usr/lib/libmgl-qt.so.* -debian/tmp/usr/lib/libmgl-qt5.so.* \ No newline at end of file diff -Nru mathgl-2.3.4/debian/libmgl-wnd7.4.1.install mathgl-2.3.5.1/debian/libmgl-wnd7.4.1.install --- mathgl-2.3.4/debian/libmgl-wnd7.4.1.install 2016-02-20 15:05:06.000000000 +0000 +++ mathgl-2.3.5.1/debian/libmgl-wnd7.4.1.install 2017-02-08 23:11:46.000000000 +0000 @@ -1 +0,0 @@ -debian/tmp/usr/lib/libmgl-wnd.so.* \ No newline at end of file diff -Nru mathgl-2.3.4/debian/libmgl-wx7.4.1.install mathgl-2.3.5.1/debian/libmgl-wx7.4.1.install --- mathgl-2.3.4/debian/libmgl-wx7.4.1.install 2016-02-20 15:05:06.000000000 +0000 +++ mathgl-2.3.5.1/debian/libmgl-wx7.4.1.install 2017-02-08 23:11:48.000000000 +0000 @@ -1 +0,0 @@ -debian/tmp/usr/lib/libmgl-wx.so.* \ No newline at end of file diff -Nru mathgl-2.3.4/debian/mathgl-doc-en.install mathgl-2.3.5.1/debian/mathgl-doc-en.install --- mathgl-2.3.4/debian/mathgl-doc-en.install 2016-02-20 15:05:06.000000000 +0000 +++ mathgl-2.3.5.1/debian/mathgl-doc-en.install 2017-02-08 23:11:58.000000000 +0000 @@ -1,7 +1,7 @@ #debian/tmp/usr/share/doc/mathgl/*.png #debian/tmp/usr/share/doc/mathgl/*.html -debian/tmp/usr/share/doc/mathgl/*.pdf +#debian/tmp/usr/share/doc/mathgl/*.pdf #debian/tmp/usr/share/doc/mathgl/png/* #debian/tmp/usr/share/doc/mathgl/udav/* -debian/tmp/usr/share/info/mathgl_en.info* usr/share/info/ -debian/folder/mathgl-doc-en /usr/share/doc-base/ \ No newline at end of file +#debian/tmp/usr/share/info/mathgl_en.info* usr/share/info/ +#debian/folder/mathgl-doc-en /usr/share/doc-base/ diff -Nru mathgl-2.3.4/debian/mathgl-doc-ru.install mathgl-2.3.5.1/debian/mathgl-doc-ru.install --- mathgl-2.3.4/debian/mathgl-doc-ru.install 2016-02-20 15:05:06.000000000 +0000 +++ mathgl-2.3.5.1/debian/mathgl-doc-ru.install 2017-02-08 23:12:02.000000000 +0000 @@ -1,4 +1,4 @@ -usr/share/doc/mathgl/mathgl_ru.html/ usr/share/doc/mathgl-doc-ru/ -usr/share/doc/mathgl/mgl_ru.html/ usr/share/doc/mathgl-doc-ru/ -usr/share/doc/mathgl/png/ usr/share/doc/mathgl-doc-ru/ -debian/folder/mathgl-doc-ru /usr/share/doc-base/ \ No newline at end of file +#usr/share/doc/mathgl/mathgl_ru.html/ usr/share/doc/mathgl-doc-ru/ +#usr/share/doc/mathgl/mgl_ru.html/ usr/share/doc/mathgl-doc-ru/ +#usr/share/doc/mathgl/png/ usr/share/doc/mathgl-doc-ru/ +#debian/folder/mathgl-doc-ru /usr/share/doc-base/ diff -Nru mathgl-2.3.4/debian/mathgl.install mathgl-2.3.5.1/debian/mathgl.install --- mathgl-2.3.4/debian/mathgl.install 2016-02-20 15:05:06.000000000 +0000 +++ mathgl-2.3.5.1/debian/mathgl.install 2017-02-08 23:12:10.000000000 +0000 @@ -1,3 +1,3 @@ debian/tmp/usr/bin/mgl* -debian/tmp/usr/share/mathgl/mgl.cgi /usr/bin -debian/tmp/usr/share/mime/packages/mgl.xml \ No newline at end of file +#debian/tmp/usr/share/mathgl/mgl.cgi /usr/bin +#debian/tmp/usr/share/mime/packages/mgl.xml diff -Nru mathgl-2.3.4/debian/mgl-lua.install mathgl-2.3.5.1/debian/mgl-lua.install --- mathgl-2.3.4/debian/mgl-lua.install 2016-02-20 15:05:06.000000000 +0000 +++ mathgl-2.3.5.1/debian/mgl-lua.install 2017-02-08 23:12:13.000000000 +0000 @@ -1 +1 @@ -debian/tmp/usr/lib/mgl-lua.so \ No newline at end of file +#debian/tmp/usr/lib/mgl-lua.so diff -Nru mathgl-2.3.4/debian/patches/CMakeLists.patch mathgl-2.3.5.1/debian/patches/CMakeLists.patch --- mathgl-2.3.4/debian/patches/CMakeLists.patch 2016-02-20 15:05:06.000000000 +0000 +++ mathgl-2.3.5.1/debian/patches/CMakeLists.patch 2017-02-08 23:25:47.000000000 +0000 @@ -1,40 +1,52 @@ --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -95,7 +95,7 @@ +@@ -110,17 +110,17 @@ string(TIMESTAMP MGL_NIGHT "%d.%m.%y") option(enable-double "Enable double precision in MathGL library" ON) -option(enable-mpi "Enable mpi") -+option(enable-mpi "Enable mpi" ON) - option(enable-opengl "Enable OpenGL support" ON) - option(enable-all-docs "Enable all documentation building") +-option(enable-opengl "Enable OpenGL support" ON) +-option(enable-all-docs "Enable all documentation building") ++option(enable-mpi "Enable mpi" OFF) ++option(enable-opengl "Enable OpenGL support" OFF) ++option(enable-all-docs "Enable all documentation building" OFF) #option(enable-doc "Enable documentation building") -@@ -103,9 +103,9 @@ - option(enable-all-widgets "Enable all Widgets") - option(enable-all-swig "Enable all SWIG based interfaces") + 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-all-widgets "Enable all Widgets" OFF) ++option(enable-all-swig "Enable all SWIG based interfaces" OFF) option(enable-rvalue "Enable move constructor support (need C++11)" OFF) --option(enable-pthread "Enable POSIX threads support" OFF) -+option(enable-pthread "Enable POSIX threads support" ON) - option(enable-pthr-widget "Enable POSIX threads for widgets" ON) + option(enable-pthread "Enable POSIX threads support" OFF) +-option(enable-pthr-widget "Enable POSIX threads for widgets" ON) -option(enable-openmp "Enable OpenMP support" ON) ++option(enable-pthr-widget "Enable POSIX threads for widgets" OFF) +option(enable-openmp "Enable OpenMP support" OFF) if(enable-pthread AND enable-openmp) message(SEND_ERROR "You can't enable POSIX threads and OpenMP at the same time!") -@@ -113,7 +113,7 @@ - - option(enable-lgpl "Enable only LGPL part of MathGL") +@@ -130,29 +130,29 @@ option(enable-mgl2 "Use names 'libmgl2-*' instead of 'libmgl-*'") --option(enable-ltdl "Enable loading modules support") -+option(enable-ltdl "Enable loading modules support" ON) + 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) -@@ -126,18 +126,18 @@ +-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) ++CMAKE_DEPENDENT_OPTION(enable-doc-html "Enable HTML documentation" OFF "NOT enable-all-docs" OFF) ++CMAKE_DEPENDENT_OPTION(enable-doc-info "Enable INFO documentation" OFF "NOT enable-all-docs" OFF) ++CMAKE_DEPENDENT_OPTION(enable-doc-pdf-ru "Enable Russian PDF documentation" OFF "NOT enable-all-docs" OFF) ++CMAKE_DEPENDENT_OPTION(enable-doc-pdf-en "Enable English PDF documentation" OFF "NOT enable-all-docs" OFF) ++CMAKE_DEPENDENT_OPTION(enable-doc-prc "Enable PDF samples for HTML docs" OFF "NOT enable-all-docs" OFF) ++CMAKE_DEPENDENT_OPTION(enable-doc-json "Enable JSOFF samples for HTML docs" OFF "NOT enable-all-docs" OFF) + option(enable-texi2html "Use texi2html (obsolete package) instead of texi2any" OFF) + CMAKE_DEPENDENT_OPTION(enable-mgltex "Enable installation of mgltex package (MGL scripts in LATEX document)" OFF "NOT enable-lgpl" OFF) CMAKE_DEPENDENT_OPTION(enable-zlib "Enable zlib support" ON "NOT enable-all" ON) CMAKE_DEPENDENT_OPTION(enable-png "Enable png support" ON "NOT enable-all" ON) --CMAKE_DEPENDENT_OPTION(enable-jpeg "Enable jpeg support" OFF "NOT enable-all" ON) + CMAKE_DEPENDENT_OPTION(enable-jpeg "Enable jpeg support" OFF "NOT enable-all" ON) -MGL_DEPENDENT_OPTION(enable-gsl "Enable gsl support" OFF "NOT enable-lgpl" ON "NOT enable-all" ON) -MGL_DEPENDENT_OPTION(enable-hdf4 "Enable hdf4 support" OFF "NOT enable-lgpl" ON "NOT enable-all" ON) -MGL_DEPENDENT_OPTION(enable-hdf5 "Enable hdf5 support" OFF "NOT enable-lgpl" ON "NOT enable-all" ON) @@ -43,34 +55,28 @@ -CMAKE_DEPENDENT_OPTION(enable-glut "Enable glut support" OFF "NOT enable-all-widgets" ON) -CMAKE_DEPENDENT_OPTION(enable-fltk "Enable fltk widget" OFF "NOT enable-all-widgets" ON) -CMAKE_DEPENDENT_OPTION(enable-wx "Enable wxWidget widget" OFF "NOT enable-all-widgets" ON) -+CMAKE_DEPENDENT_OPTION(enable-jpeg "Enable jpeg support" ON "NOT enable-all" ON) -+MGL_DEPENDENT_OPTION(enable-gsl "Enable gsl support" ON "NOT enable-lgpl" ON "NOT enable-all" ON) -+MGL_DEPENDENT_OPTION(enable-hdf4 "Enable hdf4 support" ON "NOT enable-lgpl" ON "NOT enable-all" ON) -+MGL_DEPENDENT_OPTION(enable-hdf5 "Enable hdf5 support" ON "NOT enable-lgpl" ON "NOT enable-all" ON) -+CMAKE_DEPENDENT_OPTION(enable-pdf "Enable pdf support" ON "NOT enable-all" ON) -+CMAKE_DEPENDENT_OPTION(enable-gif "Enable gif support" ON "NOT enable-all" ON) -+CMAKE_DEPENDENT_OPTION(enable-glut "Enable glut support" ON "NOT enable-all-widgets" ON) -+CMAKE_DEPENDENT_OPTION(enable-fltk "Enable fltk widget" ON "NOT enable-all-widgets" ON) -+CMAKE_DEPENDENT_OPTION(enable-wx "Enable wxWidget widget" ON "NOT enable-all-widgets" ON) - CMAKE_DEPENDENT_OPTION(enable-qt4 "Enable Qt4 widget" OFF "NOT enable-all-widgets" ON) +-CMAKE_DEPENDENT_OPTION(enable-qt4 "Enable Qt4 widget" OFF "NOT enable-all-widgets" ON) ++MGL_DEPENDENT_OPTION(enable-gsl "Enable gsl support" ON "NOT enable-lgpl" OFF "NOT enable-all" OFF) ++MGL_DEPENDENT_OPTION(enable-hdf4 "Enable hdf4 support" OFF "NOT enable-lgpl" OFF "NOT enable-all" OFF) ++MGL_DEPENDENT_OPTION(enable-hdf5 "Enable hdf5 support" OFF "NOT enable-lgpl" OFF "NOT enable-all" OFF) ++CMAKE_DEPENDENT_OPTION(enable-pdf "Enable pdf support" OFF "NOT enable-all" OFF) ++CMAKE_DEPENDENT_OPTION(enable-gif "Enable gif support" OFF "NOT enable-all" OFF) ++CMAKE_DEPENDENT_OPTION(enable-glut "Enable glut support" OFF "NOT enable-all-widgets" OFF) ++CMAKE_DEPENDENT_OPTION(enable-fltk "Enable fltk widget" OFF "NOT enable-all-widgets" OFF) ++CMAKE_DEPENDENT_OPTION(enable-wx "Enable wxWidget widget" OFF "NOT enable-all-widgets" OFF) ++CMAKE_DEPENDENT_OPTION(enable-qt4 "Enable Qt4 widget" OFF "NOT enable-all-widgets" OFF) + CMAKE_DEPENDENT_OPTION(enable-qt4asqt "Set Qt4 as default libmgl-qt" OFF "enable-qt4" OFF) -CMAKE_DEPENDENT_OPTION(enable-qt5 "Enable Qt5 widget" OFF "NOT enable-all-widgets" ON) --CMAKE_DEPENDENT_OPTION(enable-qt5asqt "Set Qt5 as default libmgl-qt" ON "enable-qt5" OFF) -+CMAKE_DEPENDENT_OPTION(enable-qt5 "Enable Qt5 widget" ON "NOT enable-all-widgets" ON) -+CMAKE_DEPENDENT_OPTION(enable-qt5asqt "Set Qt5 as default libmgl-qt" ON "enable-qt5" ON) ++CMAKE_DEPENDENT_OPTION(enable-qt5 "Enable Qt5 widget" OFF "NOT enable-all-widgets" OFF) + CMAKE_DEPENDENT_OPTION(enable-qt5asqt "Set Qt5 as default libmgl-qt" OFF "enable-qt5" OFF) - if(UNIX AND enable-rvalue) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") -@@ -149,10 +149,10 @@ - set(QT_ENABLED ON) + # msvc fwprintf print char* for the specifier of "%s" format +@@ -177,7 +177,7 @@ + # endif(NOT enable-opengl) endif(enable-qt4 OR enable-qt5) -CMAKE_DEPENDENT_OPTION(enable-json-sample "Enable JSON sample" ON "QT_ENABLED" OFF) --MGL_DEPENDENT_OPTION(enable-python "Enable python interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON) -+CMAKE_DEPENDENT_OPTION(enable-json-sample "Enable JSON sample" ON "QT_ENABLED" ON) -+MGL_DEPENDENT_OPTION(enable-python "Enable python interface" ON "NOT enable-lgpl" ON "NOT enable-all-swig" ON) ++CMAKE_DEPENDENT_OPTION(enable-json-sample "Enable JSOFF sample" OFF "QT_ENABLED" OFF) + 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 "Enable octave interface" ON "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) - - include_directories( ${MathGL_SOURCE_DIR}/include ${MathGL_BINARY_DIR}/include) + MGL_DEPENDENT_OPTION(enable-octave "Enable octave interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON) diff -Nru mathgl-2.3.4/debian/python-mathgl.install mathgl-2.3.5.1/debian/python-mathgl.install --- mathgl-2.3.4/debian/python-mathgl.install 2016-02-20 15:05:06.000000000 +0000 +++ mathgl-2.3.5.1/debian/python-mathgl.install 2017-02-08 23:10:53.000000000 +0000 @@ -1,2 +0,0 @@ -debian/tmp/usr/lib/python*/dist-packages/*.so -debian/tmp/usr/lib/python*/dist-packages/*.py \ No newline at end of file diff -Nru mathgl-2.3.4/debian/udav.install mathgl-2.3.5.1/debian/udav.install --- mathgl-2.3.4/debian/udav.install 2016-02-20 15:05:06.000000000 +0000 +++ mathgl-2.3.5.1/debian/udav.install 2017-02-08 23:12:21.000000000 +0000 @@ -1,4 +1,4 @@ -debian/tmp/usr/bin/udav -debian/tmp/usr/share/pixmaps/udav.png -udav/udav.desktop /usr/share/applications -debian/tmp/usr/share/udav/udav_ru.qm \ No newline at end of file +#debian/tmp/usr/bin/udav +#debian/tmp/usr/share/pixmaps/udav.png +#udav/udav.desktop /usr/share/applications +#debian/tmp/usr/share/udav/udav_ru.qm diff -Nru mathgl-2.3.4/examples/CMakeLists.txt mathgl-2.3.5.1/examples/CMakeLists.txt --- mathgl-2.3.4/examples/CMakeLists.txt 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/examples/CMakeLists.txt 2016-06-19 17:06:40.000000000 +0000 @@ -1,9 +1,5 @@ -if(MGL_HAVE_GSL) - include_directories(${GSL_INCLUDE_DIR}) -endif(MGL_HAVE_GSL) - add_executable(mgl_example wnd_samples.cpp full_test.cpp samples.cpp) -target_link_libraries(mgl_example mgl) +target_link_libraries(mgl_example mgl-static ${getopt_lib-static}) if(MGL_HAVE_FLTK) include_directories(${FLTK_INCLUDE_DIR}) @@ -31,19 +27,18 @@ include(../cmake-qt4.txt) target_link_libraries(mgl_qt_example mgl-qt4) endif(enable-qt5) - add_executable(mgl_qgl_example wnd_samples.cpp qgl_example.cpp) - if(enable-qt5) - target_link_libraries(mgl_qgl_example mgl) - qt5_use_modules(mgl_qgl_example ${MGL_QT5_LIBS}) - else(enable-qt5) - target_link_libraries(mgl_qgl_example mgl) - qt4_use_modules(mgl_qgl_example ${MGL_QT4_LIBS}) - endif(enable-qt5) - + + if(MGL_HAVE_OPENGL) + add_executable(mgl_qgl_example wnd_samples.cpp qgl_example.cpp) + if(enable-qt5) + target_link_libraries(mgl_qgl_example mgl ${MGL_QT5_LIBS}) + else(enable-qt5) + target_link_libraries(mgl_qgl_example mgl ${MGL_QT4_LIBS}) + endif(enable-qt5) + endif(MGL_HAVE_OPENGL) endif(QT_ENABLED) if(MGL_HAVE_LTDL) - include_directories(${LTDL_INCLUDE_DIR}) add_library(mgl_module MODULE mgl_module.cpp) target_link_libraries(mgl_module mgl) # for compatibility with win32 endif(MGL_HAVE_LTDL) diff -Nru mathgl-2.3.4/examples/fltk_example.cpp mathgl-2.3.5.1/examples/fltk_example.cpp --- mathgl-2.3.4/examples/fltk_example.cpp 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/examples/fltk_example.cpp 2016-06-19 17:06:40.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * fltk_example.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -125,20 +125,22 @@ else printf("You may specify argument '1', '2', '3', 'd' for viewing examples of 1d, 2d, 3d, dual plotting,\nor 'm' for multi-threading sample.\n"); switch(key) { - case '0': gr = new mglFLTK((mglDraw *)NULL,"1D plots"); break; + case '0': gr = new mglFLTK((mglDraw *)NULL,"1D plots"); + gr->Rotate(40,60); gr->Box(); gr->Light(true); + gr->FSurf("sin(4*pi*x*y)"); gr->Update(); break; case '1': gr = new mglFLTK(sample_1,"1D plots"); break; case '2': gr = new mglFLTK(sample_2,"2D plots"); break; case '3': gr = new mglFLTK(sample_3,"3D plots"); break; case 'd': gr = new mglFLTK(sample_d,"Dual plots");break; case 't': gr = new mglFLTK(test_wnd,"Testing"); break; + case 'f': gr = new mglFLTK("Frame drawing"); + gr->NewFrame(); gr->Box(); gr->EndFrame(); break; #if MGL_HAVE_PTHR_WIDGET case 'm': gr = new mglFLTK(&dr,"Multi-threading test"); dr.SetWnd(gr); dr.Run(); break; #endif default: gr = new mglFLTK(sample,"Drop and waves"); break; } - if(key=='0') - { gr->Rotate(40,60); gr->Box(); gr->Light(true); gr->FSurf("sin(4*pi*x*y)"); gr->Update(); } gr->Run(); return 0; } #endif diff -Nru mathgl-2.3.4/examples/FractInt.ifs mathgl-2.3.5.1/examples/FractInt.ifs --- mathgl-2.3.4/examples/FractInt.ifs 1970-01-01 00:00:00.000000000 +0000 +++ mathgl-2.3.5.1/examples/FractInt.ifs 2016-06-19 17:06:40.000000000 +0000 @@ -0,0 +1,158 @@ + + binary + { ; comment allowed here + ; and here + .5 .0 .0 .5 -2.563477 -0.000003 .333333 ; also comment allowed here + .5 .0 .0 .5 2.436544 -0.000003 .333333 + .0 -.5 .5 .0 4.873085 7.563492 .333333 + } + +coral{.307692 -.531469 -.461538 -.293706 5.401953 8.655175 .40 ; also comment + .307692 -.076923 .153846 -.447552 -1.295248 4.152990 .15 + .000000 .545455 .692308 -.195804 -4.893637 7.269794 .45 + } + +crystal { + .696970 -.481061 -.393939 -.662879 2.147003 10.310288 .747826 + .090909 -.443182 .515152 -.094697 4.286558 2.925762 .252174 + } + +dragon { + .824074 .281482 -.212346 .864198 -1.882290 -0.110607 .787473 + .088272 .520988 -.463889 -.377778 0.785360 8.095795 .212527 + } + +fern {0 0 0 .16 0 0 .01 + .85 .04 -.04 .85 0 1.6 .85 + .2 -.26 .23 .22 0 1.6 .07 + -.15 .28 .26 .24 0 .44 .07 + } + +3dfern (3D) { + .00 .00 0 .0 .18 .0 0 0.0 0.00 0 0.0 0 .01 + .85 .00 0 .0 .85 .1 0 -0.1 0.85 0 1.6 0 .85 + .20 -.20 0 .2 .20 .0 0 0.0 0.30 0 0.8 0 .07 + -.20 .20 0 .2 .20 .0 0 0.0 0.30 0 0.8 0 .07 + } + +floor { + .0 -.5 .5 .0 -1.732366 3.366182 .333333 + .5 .0 .0 .5 -0.027891 5.014877 .333333 + .0 .5 -.5 .0 1.620804 3.310401 .333333 + } + +koch3 { + .307692 -.000000 .000000 .294118 4.119164 1.604278 .151515 + .192308 -.205882 .653846 .088235 -0.688840 5.978916 .253788 + .192308 .205882 -.653846 .088235 0.668580 5.962514 .253788 + .307692 -.000000 .000000 .294118 -4.136530 1.604278 .151515 + .384615 -.000000 .000000 -.294118 -0.007718 2.941176 .189394 + } + +spiral { + .787879 -.424242 .242424 .859848 1.758647 1.408065 .895652 + -.121212 .257576 .151515 .053030 -6.721654 1.377236 .052174 + .181818 -.136364 .090909 .181818 6.086107 1.568035 .052174 + } + +swirl5 { + .745455 -.459091 .406061 .887121 1.460279 0.691072 .912675 + -.424242 -.065152 -.175758 -.218182 3.809567 6.741476 .087325 + } + +tree { + 0 0 0 .5 0 0 .05 + .42 -.42 .42 .42 0 .2 .4 + .42 .42 -.42 .42 0 .2 .4 + .1 0 0 .1 0 .2 .15 + } + +triangle { + .5 0 0 .5 0 0 .33 + .5 0 0 .5 0 1 .33 + .5 0 0 .5 1 1 .34 + } + +zigzag2 { + -.632407 -.614815 -.545370 .659259 3.840822 1.282321 .888128 + -.036111 .444444 .210185 .037037 2.071081 8.330552 .111872 + } + + +3dTetrahedron (3D) { ; by Alex Matulich + 0.50 0 0 0 0.50 0 0 0 0.50 0.00 0.00 1.00 0.25 + 0.50 0 0 0 0.50 0 0 0 0.50 0.00 0.87 -0.50 0.25 + 0.50 0 0 0 0.50 0 0 0 0.50 -0.87 -0.50 -0.50 0.25 + 0.50 0 0 0 0.50 0 0 0 0.50 0.87 -0.50 -0.50 0.25 +} +3d5Tetrahedron (3D) { ; by Alex Matulich + 0.44 0 0 0 0.44 0 0 0 0.44 0.00 0.00 1.00 0.20 + 0.44 0 0 0 0.44 0 0 0 0.44 0.00 0.87 -0.50 0.20 + 0.44 0 0 0 0.44 0 0 0 0.44 -0.87 -0.50 -0.50 0.20 + 0.44 0 0 0 0.44 0 0 0 0.44 0.87 -0.50 -0.50 0.20 + 0.44 0 0 0 0.44 0 0 0 0.44 0.00 0.00 0.00 0.20 +} +3dHexahedron (3D) { ; by Alex Matulich + 0.44 0 0 0 0.44 0 0 0 0.44 0.00 0.00 0.90 0.20 + 0.44 0 0 0 0.44 0 0 0 0.44 0.87 -0.50 0.00 0.20 + 0.44 0 0 0 0.44 0 0 0 0.44 -0.87 -0.50 0.00 0.20 + 0.44 0 0 0 0.44 0 0 0 0.44 0.00 1.00 0.00 0.20 + 0.44 0 0 0 0.44 0 0 0 0.44 0.00 0.00 -0.90 0.20 +} +3dCube (3d) { ; by Alex Matulich + 0.35 0 0 0 0.35 0 0 0 0.35 1.00 1.00 1.00 0.12 + 0.35 0 0 0 0.35 0 0 0 0.35 1.00 1.00 -1.00 0.13 + 0.35 0 0 0 0.35 0 0 0 0.35 1.00 -1.00 1.00 0.12 + 0.35 0 0 0 0.35 0 0 0 0.35 1.00 -1.00 -1.00 0.13 + 0.35 0 0 0 0.35 0 0 0 0.35 -1.00 1.00 1.00 0.12 + 0.35 0 0 0 0.35 0 0 0 0.35 -1.00 1.00 -1.00 0.13 + 0.35 0 0 0 0.35 0 0 0 0.35 -1.00 -1.00 1.00 0.12 + 0.35 0 0 0 0.35 0 0 0 0.35 -1.00 -1.00 -1.00 0.13 +} +3dOctahedron (3D) { ; by Alex Matulich + 0.40 0 0 0 0.40 0 0 0 0.40 0.00 0.00 1.00 0.17 + 0.40 0 0 0 0.40 0 0 0 0.40 1.00 0.00 0.00 0.16 + 0.40 0 0 0 0.40 0 0 0 0.40 0.00 1.00 0.00 0.17 + 0.40 0 0 0 0.40 0 0 0 0.40 -1.00 0.00 0.00 0.17 + 0.40 0 0 0 0.40 0 0 0 0.40 0.00 -1.00 0.00 0.16 + 0.40 0 0 0 0.40 0 0 0 0.40 0.00 0.00 -1.00 0.17 +} +3dDuodecahedron (3D) { ; by Alex Matulich + 0.28 0 0 0 0.28 0 0 0 0.28 0.00 0.00 0.96 0.09 + 0.28 0 0 0 0.28 0 0 0 0.28 0.00 0.85 0.43 0.08 + 0.28 0 0 0 0.28 0 0 0 0.28 0.81 0.26 0.43 0.08 + 0.28 0 0 0 0.28 0 0 0 0.28 -0.81 0.26 0.43 0.09 + 0.28 0 0 0 0.28 0 0 0 0.28 0.50 -0.69 0.43 0.08 + 0.28 0 0 0 0.28 0 0 0 0.28 -0.50 -0.69 0.43 0.08 + 0.28 0 0 0 0.28 0 0 0 0.28 0.50 0.69 -0.43 0.09 + 0.28 0 0 0 0.28 0 0 0 0.28 -0.50 0.69 -0.43 0.08 + 0.28 0 0 0 0.28 0 0 0 0.28 0.81 -0.26 -0.43 0.08 + 0.28 0 0 0 0.28 0 0 0 0.28 -0.81 -0.26 -0.43 0.09 + 0.28 0 0 0 0.28 0 0 0 0.28 0.00 -0.85 -0.43 0.08 + 0.28 0 0 0 0.28 0 0 0 0.28 0.00 0.00 -0.96 0.08 +} + +fractint { ; by Pieter Branderhorst + 0.00 -0.11 0.22 0.00 -6.25 4.84 0.06 + 0.11 0.02 0.00 0.11 -6.30 5.99 0.03 + 0.06 0.02 0.00 0.10 -6.25 4.51 0.02 + 0.00 -0.11 0.22 0.00 -4.34 4.84 0.06 + 0.08 0.00 0.00 0.11 -4.50 5.99 0.02 + 0.00 0.11 -0.08 0.00 -4.30 6.15 0.02 + -0.09 0.00 -0.01 -0.13 -4.15 5.94 0.02 + 0.06 0.11 -0.13 0.00 -4.69 4.15 0.04 + 0.03 -0.11 0.23 0.11 -2.26 4.43 0.07 + 0.03 0.11 -0.25 0.00 -2.57 4.99 0.07 + 0.06 0.00 0.00 0.11 -2.40 4.46 0.02 + 0.00 0.11 -0.19 0.00 -1.62 4.99 0.06 + 0.09 -0.01 0.00 0.10 -0.58 2.96 0.03 + -0.09 0.00 0.00 -0.11 -0.65 7.10 0.03 + 0.12 0.00 -0.00 0.11 1.24 6.00 0.03 + 0.00 0.11 -0.22 0.00 0.68 4.80 0.06 + -0.12 0.00 0.00 -0.13 6.17 7.18 0.03 + 0.00 -0.11 0.22 0.00 6.78 4.84 0.06 + 0.00 0.08 -0.25 0.02 2.21 4.95 0.07 + 0.00 -0.11 0.22 0.00 4.10 4.84 0.06 + 0.00 -0.11 0.22 0.00 5.25 5.23 0.06 + 0.08 0.11 -0.25 0.00 3.57 4.99 0.08 + } diff -Nru mathgl-2.3.4/examples/full_test.cpp mathgl-2.3.5.1/examples/full_test.cpp --- mathgl-2.3.4/examples/full_test.cpp 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/examples/full_test.cpp 2016-06-19 17:06:40.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * full_test.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -20,15 +20,14 @@ #include #include #include -#if !defined(_MSC_VER) && !defined(__BORLANDC__) #include -#endif #include "mgl2/mgl.h" #include "mgl2/font.h" #include "mgl2/eval.h" //----------------------------------------------------------------------------- -void mgl_create_cpp_font(HMGL gr, const wchar_t *how); +void MGL_EXPORT mgl_create_cpp_font(HMGL gr, const wchar_t *how); +long MGL_EXPORT mgl_check_tex_table(); //----------------------------------------------------------------------------- struct mglSample /// Structure for list of samples { @@ -75,7 +74,6 @@ return; } //----------------------------------------------------------------------------- -#if !defined(_MSC_VER) && !defined(__BORLANDC__) static struct option longopts[] = { { "big", no_argument, &big, 1 }, @@ -156,7 +154,6 @@ "--fexport - test most of output formats\n" ); } -#endif //----------------------------------------------------------------------------- void save(mglGraph *gr,const char *name,const char *suf="") { @@ -389,15 +386,6 @@ gr->ImportMGLD("fexport.mgld"); } //----------------------------------------------------------------------------- -extern mglTeXsymb mgl_tex_symb[]; -extern long mgl_tex_num; -int MGL_LOCAL_PURE mgl_tex_symb_cmp(const void *a, const void *b) -{ - const mglTeXsymb *aa = (const mglTeXsymb *)a; - const mglTeXsymb *bb = (const mglTeXsymb *)b; - return wcscmp(aa->tex, bb->tex); -} -//----------------------------------------------------------------------------- int main(int argc,char **argv) { mgl_suppress_warn(true); @@ -407,7 +395,6 @@ time_t st,en; time(&st); mglGraph *gr = NULL; mglSample *s=samp; -#if !defined(_MSC_VER) && !defined(__BORLANDC__) while(( ch = getopt_long_only(argc, argv, "", longopts, NULL)) != -1) switch(ch) { @@ -426,7 +413,6 @@ case '?': default: usage(); return 0; } -#endif if(dotest==1) printf("Global (before):%s\n",mglGlobalMess.c_str()); gr = new mglGraph; @@ -498,14 +484,7 @@ { smgl_fexport(gr); delete gr; return 0; } else if(dotest==5) { - long i=0; while(mgl_tex_symb[i].tex[0]) i++; - if(mgl_tex_num!=i) printf("real=%lu, set=%ld\n",i,mgl_tex_num); - for(long i=0;mgl_tex_symb[i].tex[0];i++) - { - mglTeXsymb tst, *rts; tst.tex = mgl_tex_symb[i].tex; - rts = (mglTeXsymb *) bsearch(&tst, mgl_tex_symb, mgl_tex_num, sizeof(mglTeXsymb), mgl_tex_symb_cmp); - if(!rts) printf("Bad '%ls' at %lu\n",mgl_tex_symb[i].tex,i); - } + mgl_check_tex_table(); delete gr; return 0; } diff -Nru mathgl-2.3.4/examples/glut_example.cpp mathgl-2.3.5.1/examples/glut_example.cpp --- mathgl-2.3.4/examples/glut_example.cpp 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/examples/glut_example.cpp 2016-06-19 17:06:40.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * glut_example.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/examples/qgl_example.cpp mathgl-2.3.5.1/examples/qgl_example.cpp --- mathgl-2.3.4/examples/qgl_example.cpp 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/examples/qgl_example.cpp 2016-06-19 17:06:40.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * qt_example.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -19,6 +19,7 @@ ***************************************************************************/ #include "qgl_example.h" #include +//#include //----------------------------------------------------------------------------- int main(int argc, char *argv[]) { diff -Nru mathgl-2.3.4/examples/qt_example.cpp mathgl-2.3.5.1/examples/qt_example.cpp --- mathgl-2.3.4/examples/qt_example.cpp 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/examples/qt_example.cpp 2016-06-19 17:06:40.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * qt_example.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -139,20 +139,22 @@ else printf("You may specify argument '1', '2', '3', 'd' for viewing examples of 1d, 2d, 3d, dual plotting,\nor 'm' for multi-threading sample.\n"); switch(key) { - case '0': gr = new mglQT((mglDraw *)NULL,"1D plots"); break; + case '0': gr = new mglQT((mglDraw *)NULL,"1D plots"); + gr->Rotate(40,60); gr->Box(); gr->Light(true); + gr->FSurf("sin(4*pi*x*y)"); gr->Update(); break; case '1': gr = new mglQT(sample_1,"1D plots"); break; case '2': gr = new mglQT(sample_2,"2D plots"); break; case '3': gr = new mglQT(sample_3,"3D plots"); break; case 'd': gr = new mglQT(sample_d,"Dual plots"); break; - case 't': gr = new mglQT(test_wnd,"Testing"); break; + case 't': gr = new mglQT(test_wnd,"Testing"); break; + case 'f': gr = new mglQT("Frame drawing"); + gr->NewFrame(); gr->Box(); gr->EndFrame(); break; #if MGL_HAVE_PTHR_WIDGET case 'm': gr = new mglQT(&dr,"Multi-threading test"); dr.SetWnd(gr); dr.Run(); break; #endif default: gr = new mglQT(sample,"Drop and waves"); break; } - if(key=='0') - { gr->Rotate(40,60); gr->Box(); gr->Light(true); gr->FSurf("sin(4*pi*x*y)"); gr->Update(); } gr->Run(); return 0; } #endif diff -Nru mathgl-2.3.4/examples/samples.cpp mathgl-2.3.5.1/examples/samples.cpp --- mathgl-2.3.4/examples/samples.cpp 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/examples/samples.cpp 2016-06-19 17:06:40.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * samples.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -105,7 +105,7 @@ //----------------------------------------------------------------------------- const char *mmgl_indirect="subplot 1 1 0 '':title 'SubData vs Evaluate'\n" "new in 9 'x^3/1.1':plot in 'ko ':box\nnew arg 99 '4*x+4'\n" -"evaluate e in arg:plot e 'b.'; legend 'Evaluate'\n" +"evaluate e in arg off:plot e 'b.'; legend 'Evaluate'\n" "subdata s in arg:plot s 'r.';legend 'SubData'\nlegend 2"; void smgl_indirect(mglGraph *gr) { @@ -113,7 +113,7 @@ mglData in(9), arg(99), e, s; gr->Fill(in,"x^3/1.1"); gr->Fill(arg,"4*x+4"); gr->Plot(in,"ko "); gr->Box(); - e = in.Evaluate(arg); gr->Plot(e,"b.","legend 'Evaluate'"); + e = in.Evaluate(arg,false); gr->Plot(e,"b.","legend 'Evaluate'"); s = in.SubData(arg); gr->Plot(s,"r.","legend 'SubData'"); gr->Legend(2); } @@ -1979,9 +1979,11 @@ gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"4"); } //----------------------------------------------------------------------------- -const char *mmgl_aspect="subplot 2 2 0:box:text -1 1.1 'Just box' ':L'\ninplot 0.2 0.5 0.7 1 off:box:text 0 1.2 'InPlot example'\n" -"subplot 2 2 1:title 'Rotate only':rotate 50 60:box\nsubplot 2 2 2:title 'Rotate and Aspect':rotate 50 60:aspect 1 1 2:box\n" -"subplot 2 2 3:title 'Aspect in other direction':rotate 50 60:aspect 1 2 2:box"; +const char *mmgl_aspect="subplot 2 2 0:box:text -1 1.1 'Just box' ':L'\n" +"inplot 0.2 0.5 0.7 1 off:box:text 0 1.2 'InPlot example'\n" +"subplot 2 2 1:title 'Rotate only':rotate 50 60:box\n" +"subplot 2 2 2:title 'Rotate and Aspect':rotate 50 60:aspect 1 1 2:box\n" +"subplot 2 2 3:title 'Shear':box 'c':shear 0.2 0.1:box"; void smgl_aspect(mglGraph *gr) // transformation { gr->SubPlot(2,2,0); gr->Box(); @@ -1992,18 +1994,20 @@ gr->Rotate(50,60); gr->Box(); gr->SubPlot(2,2,2); gr->Title("Rotate and Aspect"); gr->Rotate(50,60); gr->Aspect(1,1,2); gr->Box(); - gr->SubPlot(2,2,3); gr->Title("Aspect in other direction"); - gr->Rotate(50,60); gr->Aspect(1,2,2); gr->Box(); + gr->SubPlot(2,2,3); gr->Title("Shear"); + gr->Box("c"); gr->Shear(0.2,0.1); gr->Box(); } //----------------------------------------------------------------------------- -const char *mmgl_inplot="subplot 3 2 0:title 'StickPlot'\nstickplot 3 0 20 30:box 'r':text 0 0 '0' 'r'\n" -"stickplot 3 1 20 30:box 'g':text 0 0 '1' 'g'\nstickplot 3 2 20 30:box 'b':text 0 0 '2' 'b'\n" +const char *mmgl_inplot="subplot 3 2 0:title 'StickPlot'\nstickplot 3 0 20 30:box 'r':text 0 0 0 '0' 'r'\n" +"stickplot 3 1 20 30:box 'g':text 0 0 0 '1' 'g'\nstickplot 3 2 20 30:box 'b':text 0 9 0 '2' 'b'\n" "subplot 3 2 3 '':title 'ColumnPlot'\ncolumnplot 3 0:box 'r':text 0 0 '0' 'r'\n" "columnplot 3 1:box 'g':text 0 0 '1' 'g'\ncolumnplot 3 2:box 'b':text 0 0 '2' 'b'\n" "subplot 3 2 4 '':title 'GridPlot'\ngridplot 2 2 0:box 'r':text 0 0 '0' 'r'\n" "gridplot 2 2 1:box 'g':text 0 0 '1' 'g'\ngridplot 2 2 2:box 'b':text 0 0 '2' 'b'\n" "gridplot 2 2 3:box 'm':text 0 0 '3' 'm'\nsubplot 3 2 5 '':title 'InPlot':box\n" -"inplot 0.4 1 0.6 1 on:box 'r'\nmultiplot 3 2 1 2 1 '':title 'MultiPlot':box"; +"inplot 0.4 1 0.6 1 on:box 'r'\nmultiplot 3 2 1 2 1 '':title 'MultiPlot and ShearPlot':box\n" +"shearplot 3 0 0.2 0.1:box 'r':text 0 0 '0' 'r'\nshearplot 3 1 0.2 0.1:box 'g':text 0 0 '1' 'g'\n" +"shearplot 3 2 0.2 0.1:box 'b':text 0 0 '2' 'b'"; void smgl_inplot(mglGraph *gr) { gr->SubPlot(3,2,0); gr->Title("StickPlot"); @@ -2021,7 +2025,10 @@ gr->GridPlot(2, 2, 3); gr->Box("m"); gr->Puts(mglPoint(0),"3","m"); gr->SubPlot(3,2,5,""); gr->Title("InPlot"); gr->Box(); gr->InPlot(0.4, 1, 0.6, 1, true); gr->Box("r"); - gr->MultiPlot(3,2,1, 2, 1,""); gr->Title("MultiPlot"); gr->Box(); + gr->MultiPlot(3,2,1, 2, 1,""); gr->Title("MultiPlot and ShearPlot"); gr->Box(); + gr->ShearPlot(3, 0, 0.2, 0.1); gr->Box("r"); gr->Puts(mglPoint(0),"0","r"); + gr->ShearPlot(3, 1, 0.2, 0.1); gr->Box("g"); gr->Puts(mglPoint(0),"1","g"); + gr->ShearPlot(3, 2, 0.2, 0.1); gr->Box("b"); gr->Puts(mglPoint(0),"2","b"); } //----------------------------------------------------------------------------- const char *mmgl_combined="call 'prepare2v'\ncall 'prepare3d'\nnew v 10:fill v -0.5 1:copy d sqrt(a^2+b^2)\n" diff -Nru mathgl-2.3.4/examples/wnd_samples.cpp mathgl-2.3.5.1/examples/wnd_samples.cpp --- mathgl-2.3.4/examples/wnd_samples.cpp 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/examples/wnd_samples.cpp 2016-06-19 17:06:40.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * wnd_sample.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/examples/wx_example.cpp mathgl-2.3.5.1/examples/wx_example.cpp --- mathgl-2.3.4/examples/wx_example.cpp 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/examples/wx_example.cpp 2016-06-19 17:06:40.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * wx_example.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/fonts/CMakeLists.txt mathgl-2.3.5.1/fonts/CMakeLists.txt --- mathgl-2.3.4/fonts/CMakeLists.txt 2016-02-13 19:03:18.000000000 +0000 +++ mathgl-2.3.5.1/fonts/CMakeLists.txt 2016-06-19 17:05:47.000000000 +0000 @@ -1,6 +1,5 @@ - add_executable(make_bin make_bin.cpp) -target_link_libraries(make_bin mgl) +target_link_libraries(make_bin mgl-static ${getopt_lib-static}) set(MGL_FONTS STIX adventor bonum cursor heroscn heros pagella schola termes) set(MGL_FONTS_BIN ) diff -Nru mathgl-2.3.4/fonts/make_bin.cpp mathgl-2.3.5.1/fonts/make_bin.cpp --- mathgl-2.3.4/fonts/make_bin.cpp 2016-02-13 19:03:18.000000000 +0000 +++ mathgl-2.3.5.1/fonts/make_bin.cpp 2016-06-19 17:05:47.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * make_bin.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/abstract.h mathgl-2.3.5.1/include/mgl2/abstract.h --- mathgl-2.3.4/include/mgl2/abstract.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/abstract.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * abstract.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -23,7 +23,6 @@ #include "mgl2/define.h" //----------------------------------------------------------------------------- #ifdef __cplusplus -#include #include "mgl2/type.h" #define MGL_TO_WCS(str,code) if(str && *str){size_t s=mbstowcs(0,str,0); wchar_t *wcs=new wchar_t[s+1]; mbstowcs(wcs,str,s); wcs[s]=0; code; delete []wcs;}else{const wchar_t *wcs=L""; code;} //----------------------------------------------------------------------------- @@ -135,6 +134,10 @@ mreal MGL_EXPORT mgl_data_linear_ext(HCDT dat, mreal x,mreal y,mreal z, mreal *dx,mreal *dy,mreal *dz); mreal MGL_EXPORT mgl_data_linear_ext_(uintptr_t *dat, mreal *x,mreal *y,mreal *z, mreal *dx,mreal *dy,mreal *dz); +/// Internal function for (un-)locking mutex in mglStack +void MGL_EXPORT mgl_mutex_lock(void *); +void MGL_EXPORT mgl_mutex_unlock(void *); + //----------------------------------------------------------------------------- /// Callback function for asking user a question. Result shouldn't exceed 1024. extern MGL_EXPORT void (*mgl_ask_func)(const wchar_t *quest, wchar_t *res); @@ -152,7 +155,7 @@ mglDataA() { temp=false; func=0; o=0; } virtual ~mglDataA() { if(func) func(o); } - virtual void set_v(mreal val, long i,long j=0,long k=0) {} + virtual void set_v(mreal /*val*/, long /*i*/,long /*j*/=0,long /*k*/=0) {} /// Get the interpolated value and its derivatives in given data cell without border checking virtual mreal valueD(mreal x,mreal y=0,mreal z=0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const =0; /// Get the interpolated value in given data cell without border checking @@ -164,7 +167,10 @@ inline mreal linearD(mreal x,mreal y=0,mreal z=0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const { return mgl_data_linear_ext(this,x,y,z,dx,dy,dz); } virtual mreal v(long i,long j=0,long k=0) const = 0; - virtual mreal vthr(long i) const = 0; + virtual mreal vthr(long i) const + { return v(i%GetNx(), (i/GetNx())%GetNy(), i/(GetNx()*GetNy())); } + virtual dual vc(long i,long j=0,long k=0) const { return v(i,j,k); } + virtual dual vcthr(long i) const { return vthr(i); } virtual long GetNx() const = 0; virtual long GetNy() const = 0; virtual long GetNz() const = 0; @@ -236,6 +242,34 @@ /// Find if any nonzero value of formula inline bool FindAny(const char *cond) const { return mgl_data_find_any(this,cond); } + + /// Interpolate by cubic spline the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] + inline mreal Spline(mreal x,mreal y=0,mreal z=0) const + { return value(x,y,z); } + /// Interpolate by cubic spline the data to given point x,\a y,\a z which normalized in range [0, 1] + inline mreal Spline1(mreal x,mreal y=0,mreal z=0) const + { return value(x*(GetNx()-1),y*(GetNy()-1),z*(GetNz()-1)); } + /// Interpolate by cubic spline the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] + inline mreal Spline(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const + { return valueD(x,y,z, &(dif.x),&(dif.y), &(dif.z)); } + /// Interpolate by cubic spline the data and return its derivatives at given point x,\a y,\a z which normalized in range [0, 1] + inline mreal Spline1(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const + { mreal res=valueD(x*(GetNx()-1),y*(GetNy()-1),z*(GetNz()-1), &(dif.x),&(dif.y), &(dif.z)); + dif.x*=GetNx()>1?GetNx()-1:1; dif.y*=GetNy()>1?GetNy()-1:1; dif.z*=GetNz()>1?GetNz()-1:1; return res; } + + /// Interpolate by linear function the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] + inline mreal Linear(mreal x,mreal y=0,mreal z=0) const + { return mgl_data_linear_ext(this,x,y,z,0,0,0); } + /// Interpolate by line the data to given point x,\a y,\a z which normalized in range [0, 1] + inline mreal Linear1(mreal x,mreal y=0,mreal z=0) const + { return mgl_data_linear_ext(this,x*(GetNx()-1),y*(GetNy()-1),z*(GetNz()-1),0,0,0); } + /// Interpolate by linear function the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] + inline mreal Linear(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const + { return mgl_data_linear_ext(this,x,y,z, &(dif.x),&(dif.y), &(dif.z)); } + /// Interpolate by line the data and return its derivatives at given point x,\a y,\a z which normalized in range [0, 1] + inline mreal Linear1(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const + { mreal res=mgl_data_linear_ext(this,x*(GetNx()-1),y*(GetNy()-1),z*(GetNz()-1), &(dif.x),&(dif.y), &(dif.z)); + dif.x*=GetNx()>1?GetNx()-1:1; dif.y*=GetNy()>1?GetNy()-1:1; dif.z*=GetNz()>1?GetNz()-1:1; return res; } }; //----------------------------------------------------------------------------- /// Structure for color ID diff -Nru mathgl-2.3.4/include/mgl2/addon.h mathgl-2.3.5.1/include/mgl2/addon.h --- mathgl-2.3.4/include/mgl2/addon.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/addon.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * addon.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/base_cf.h mathgl-2.3.5.1/include/mgl2/base_cf.h --- mathgl-2.3.4/include/mgl2/base_cf.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/base_cf.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * base_cf.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/base.h mathgl-2.3.5.1/include/mgl2/base.h --- mathgl-2.3.4/include/mgl2/base.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/base.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * base.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -23,8 +23,6 @@ #include "mgl2/abstract.h" #ifdef __cplusplus -#include -#include #if (MGL_HAVE_PTHREAD|MGL_HAVE_PTHR_WIDGET) #include @@ -35,9 +33,6 @@ #else #define MGL_PUSH(a,v,m) a.push_back(v); #endif -#if MGL_HAVE_OMP -#include -#endif //----------------------------------------------------------------------------- inline mreal mgl_d(mreal v,mreal v1,mreal v2) { return v2!=v1?(v-v1)/(v2-v1):NAN; } //----------------------------------------------------------------------------- @@ -59,11 +54,11 @@ mglStack(const mglStack &st) { np=st.np; dat = (T**)malloc(np*sizeof(T*)); pb=st.pb; m=n=0; reserve(st.n); - for(size_t i=0;i>pb); if(num>np) { dat = (T**)realloc(dat, num*sizeof(T*)); np=num; } - for(size_t i=m;i>pb; return dat[d][i-(d<>pb; return dat[d][i-(d< &operator=(const mglStack &st) { pb=st.pb; clear(); reserve(st.n); - for(size_t i=0;i; +template class MGL_EXPORT mglStack; +template class MGL_EXPORT std::vector; +template class MGL_EXPORT std::vector; +template class MGL_EXPORT std::vector; +template class MGL_EXPORT std::vector; +template class MGL_EXPORT std::vector; +template class MGL_EXPORT std::vector; +template class MGL_EXPORT mglStack; +#endif +//----------------------------------------------------------------------------- /// Base class for canvas which handle all basic drawing class MGL_EXPORT mglBase { @@ -336,7 +332,7 @@ std::string Mess; ///< Buffer for receiving messages int ObjId; ///< object id for mglPrim int HighId; ///< object id to be highlited - mglStack Grp; ///< List of groups with names -- need for export + std::vector Grp; ///< List of groups with names -- need for export mglStack Act; ///< Position of active points std::string PlotId; ///< Id of plot for saving filename (in GLUT window for example) @@ -605,14 +601,12 @@ std::vector Ptx; ///< Text labels for mglPrim std::vector Leg; ///< Text labels for legend std::vector Glf; ///< Glyphs data - mglStack Txt; ///< Pointer to textures + std::vector Txt; ///< Pointer to textures #if MGL_HAVE_PTHREAD pthread_mutex_t mutexPnt, mutexTxt, mutexLeg, mutexGlf, mutexAct, mutexDrw; pthread_mutex_t mutexSub, mutexPrm, mutexPtx, mutexStk, mutexGrp, mutexClf; #endif -#if MGL_HAVE_OMP - omp_lock_t lockClf; -#endif + void *lockClf; ///< pointer to mutex for mglStack int TernAxis; ///< Flag that Ternary axis is used unsigned PDef; ///< Pen bit mask diff -Nru mathgl-2.3.4/include/mgl2/canvas_cf.h mathgl-2.3.5.1/include/mgl2/canvas_cf.h --- mathgl-2.3.4/include/mgl2/canvas_cf.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/canvas_cf.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * canvas_cf.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -388,6 +388,9 @@ /// Set the transparency on/off. void MGL_EXPORT mgl_set_alpha(HMGL gr, int enable); void MGL_EXPORT mgl_set_alpha_(uintptr_t *gr, int *enable); +/// Set the gray-scale mode on/off. +void MGL_EXPORT mgl_set_gray(HMGL gr, int enable); +void MGL_EXPORT mgl_set_gray_(uintptr_t *gr, int *enable); /// Set the fog distance or switch it off (if d=0). void MGL_EXPORT mgl_set_fog(HMGL gr, double d, double dz); void MGL_EXPORT mgl_set_fog_(uintptr_t *gr, mreal *dist, mreal *dz); @@ -479,6 +482,9 @@ /// Put further plotting in cell of stick rotated on angles tet, phi. void MGL_EXPORT mgl_stickplot(HMGL gr, int num, int ind, double tet, double phi); void MGL_EXPORT mgl_stickplot_(uintptr_t *gr, int *num, int *i, mreal *tet, mreal *phi); +/// Put further plotting in cell of stick sheared on sx, sy. +void MGL_EXPORT mgl_shearplot(HMGL gr, int num, int ind, double sx, double sy, double xd, double yd); +void MGL_EXPORT mgl_shearplot_(uintptr_t *gr, int *num, int *i, mreal *sy, mreal *sx, mreal *xd, mreal *yd); /// Add title for current subplot/inplot. /** Style '#' draw box around the title. */ void MGL_EXPORT mgl_title(HMGL gr, const char *title, const char *stl, double size); @@ -491,6 +497,9 @@ /// Set aspect ratio for further plotting. void MGL_EXPORT mgl_aspect(HMGL gr, double Ax,double Ay,double Az); void MGL_EXPORT mgl_aspect_(uintptr_t *gr, mreal *Ax, mreal *Ay, mreal *Az); +/// Set aspect ratio for further plotting. +void MGL_EXPORT mgl_shear(HMGL gr, double Sx,double Sz); +void MGL_EXPORT mgl_shear_(uintptr_t *gr, mreal *Sx, mreal *Sy); /// Rotate a further plotting. void MGL_EXPORT mgl_rotate(HMGL gr, double TetX,double TetZ,double TetY); void MGL_EXPORT mgl_rotate_(uintptr_t *gr, mreal *TetX, mreal *TetZ, mreal *TetY); @@ -641,6 +650,9 @@ /// Set flag to stop script parsing void MGL_EXPORT mgl_parser_stop(HMPR p); void MGL_EXPORT mgl_parser_stop_(uintptr_t* p); +/// Set variant of argument(s) separated by '?' to be used +void MGL_EXPORT mgl_parser_variant(HMPR p, int var); +void MGL_EXPORT mgl_parser_variant_(uintptr_t* p, int *var); /// 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 diff -Nru mathgl-2.3.4/include/mgl2/canvas.h mathgl-2.3.5.1/include/mgl2/canvas.h --- mathgl-2.3.4/include/mgl2/canvas.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/canvas.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * canvas.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -99,8 +99,11 @@ std::vector Sub; ///< InPlot regions std::vector Ptx; ///< Text labels for mglPrim std::vector Glf; ///< Glyphs data - mglStack Txt; ///< Pointer to textures + std::vector Txt; ///< Pointer to textures }; +#if defined(_MSC_VER) +template class MGL_EXPORT std::vector; +#endif //----------------------------------------------------------------------------- union mglRGBA { uint32_t c; unsigned char r[4]; }; //----------------------------------------------------------------------------- @@ -143,6 +146,8 @@ /// 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 cell of stick sheared on sx, sy + void ShearPlot(int num, int i, mreal sx, mreal sy, mreal xd, mreal yd); /// Put further plotting in some region of whole frame surface. inline void InPlot(mreal x1,mreal x2,mreal y1,mreal y2,bool rel=true) { InPlot(B,x1,x2,y1,y2,rel); } @@ -153,6 +158,8 @@ void Title(const wchar_t *title,const char *stl="#",mreal size=-2); /// Set aspect ratio for further plotting. void Aspect(mreal Ax,mreal Ay,mreal Az); + /// Shear a further plotting. + void Shear(mreal Sx,mreal Sy); /// Rotate a further plotting. void Rotate(mreal TetX,mreal TetZ,mreal TetY=0); /// Rotate a further plotting around vector {x,y,z}. diff -Nru mathgl-2.3.4/include/mgl2/canvas_wnd.h mathgl-2.3.5.1/include/mgl2/canvas_wnd.h --- mathgl-2.3.4/include/mgl2/canvas_wnd.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/canvas_wnd.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * canvas_wnd.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/cont.h mathgl-2.3.5.1/include/mgl2/cont.h --- mathgl-2.3.4/include/mgl2/cont.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/cont.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * cont.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/datac_cf.h mathgl-2.3.5.1/include/mgl2/datac_cf.h --- mathgl-2.3.4/include/mgl2/datac_cf.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/datac_cf.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * data_cf.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -88,6 +88,16 @@ void MGL_EXPORT mgl_datac_set_values(HADT dat, const char *val, long nx, long ny, long nz); void MGL_EXPORT mgl_datac_set_values_(uintptr_t *d, const char *val, int *nx, int *ny, int *nz, int l); +/// Get array as solution of tridiagonal matrix solution a[i]*x[i-1]+b[i]*x[i]+c[i]*x[i+1]=d[i] +/** String \a how may contain: + * 'x', 'y', 'z' for solving along x-,y-,z-directions, or + * 'h' for solving along hexagonal direction at x-y plain (need nx=ny), + * 'c' for using periodical boundary conditions, + * 'd' for diffraction/diffuse calculation. + * NOTE: It work for flat data model only (i.e. for a[i,j]==a[i+nx*j]) */ +HADT MGL_EXPORT mgl_datac_tridmat(HCDT A, HCDT B, HCDT C, HCDT D, const char *how); +uintptr_t MGL_EXPORT mgl_datac_tridmat_(uintptr_t *A, uintptr_t *B, uintptr_t *C, uintptr_t *D, const char *how, int); + /// Returns pointer to internal data array MGL_EXPORT dual *mgl_datac_data(HADT dat); /// Returns pointer to data element [i,j,k] @@ -196,6 +206,10 @@ 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); +/// Limit the data to be inside [-v,v], keeping the original sign +void MGL_EXPORT mgl_datac_limit(HADT dat, mreal v); +void MGL_EXPORT mgl_datac_limit_(uintptr_t *dat, mreal *v); + /// 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); diff -Nru mathgl-2.3.4/include/mgl2/data_cf.h mathgl-2.3.5.1/include/mgl2/data_cf.h --- mathgl-2.3.4/include/mgl2/data_cf.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/data_cf.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * data_cf.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -133,11 +133,14 @@ void MGL_EXPORT mgl_data_transpose(HMDT dat, const char *dim); void MGL_EXPORT mgl_data_transpose_(uintptr_t *dat, const char *dim,int); /// Normalize the data to range [v1,v2] -void MGL_EXPORT mgl_data_norm(HMDT dat, mreal v1,mreal v2,long sym,long dim); +void MGL_EXPORT mgl_data_norm(HMDT dat, mreal v1,mreal v2,int sym,long dim); void MGL_EXPORT mgl_data_norm_(uintptr_t *dat, mreal *v1,mreal *v2,int *sym,int *dim); /// Normalize the data to range [v1,v2] slice by slice void MGL_EXPORT mgl_data_norm_slice(HMDT dat, mreal v1,mreal v2,char dir,long keep_en,long sym); void MGL_EXPORT mgl_data_norm_slice_(uintptr_t *dat, mreal *v1,mreal *v2,char *dir,int *keep_en,int *sym,int l); +/// Limit the data to be inside [-v,v], keeping the original sign +void MGL_EXPORT mgl_data_limit(HMDT dat, mreal v); +void MGL_EXPORT mgl_data_limit_(uintptr_t *dat, mreal *v); /// Get sub-array of the data with given fixed indexes HMDT MGL_EXPORT mgl_data_subdata(HCDT dat, long xx,long yy,long zz); uintptr_t MGL_EXPORT mgl_data_subdata_(uintptr_t *dat, int *xx,int *yy,int *zz); @@ -201,6 +204,39 @@ /** NOTE: A.nx must be >= 13. */ HMDT MGL_EXPORT mgl_data_ifs_3d(HCDT A, long n, long skip); uintptr_t MGL_EXPORT mgl_data_ifs_3d_(uintptr_t *A, long *n, long *skip); +/// Get array which is n-th points {x[i],y[i],z[i]} for iterated function system (fractal) defined in *.ifs file 'fname' and named as 'name' +HMDT MGL_EXPORT mgl_data_ifs_file(const char *fname, const char *name, long n, long skip); +uintptr_t mgl_data_ifs_file_(const char *fname, const char *name, long *n, long *skip,int l,int m); +/// Codes for flame fractal functions +enum { + mglFlameLinear=0, mglFlameSin, mglFlameSphere, mglFlameSwirl, mglFlameHorseshoe, + mglFlamePolar, mglFlameHandkerchief, mglFlameHeart, mglFlameDisk, mglFlameSpiral, + mglFlameHyperbolic, mglFlameDiamond, mglFlameEx, mglFlameJulia, mglFlameBent, + mglFlameWaves, mglFlameFishEye, mglFlamePopcorn, mglFlameExponent, mglFlamePower, + mglFlameCos, mglFlameRings, mglFlameFan, mglFlameBlob, mglFlamePdj, + mglFlameFan2, mglFlameRings2, mglFlameEyefish, mglFlameBubble, mglFlameCylinder, + mglFlamePerspective, mglFlameNoise, mglFlameJuliaN, mglFlameJuliaScope, mglFlameBlur, + mglFlameGaussian, mglFlameRadialBlur, mglFlamePie, mglFlameNgon, mglFlameCurl, + mglFlameRectangles, mglFlameArch, mglFlameTangent, mglFlameSquare, mglFlameRays, + mglFlameBlade, mglFlameSecant, mglFlameTwintrian, mglFlameCross, mglFlameLAST +}; +/// Get array which is n-th pairs {x[i],y[i]} for Flame fractal generated by A with functions F +/** NOTE: A.nx must be >= 7 and F.nx >= 2 and F.nz=A.ny. + * F[0,i,j] denote function id. F[1,i,j] give function weight. F(2:5,i,j) provide function parameters. + * Resulting point is {xnew,ynew} = sum_i F[1,i,j]*F[0,i,j]{IFS2d(A[j]){x,y}}. */ +HMDT MGL_EXPORT mgl_data_flame_2d(HCDT A, HCDT F, long n, long skip); +uintptr_t MGL_EXPORT mgl_data_flame_2d_(uintptr_t *A, uintptr_t *F, long *n, long *skip); + + +/// Get array as solution of tridiagonal matrix solution a[i]*x[i-1]+b[i]*x[i]+c[i]*x[i+1]=d[i] +/** String \a how may contain: + * 'x', 'y', 'z' for solving along x-,y-,z-directions, or + * 'h' for solving along hexagonal direction at x-y plain (need nx=ny), + * 'c' for using periodical boundary conditions, + * 'd' for diffraction/diffuse calculation. + * NOTE: It work for flat data model only (i.e. for a[i,j]==a[i+nx*j]) */ +HMDT MGL_EXPORT mgl_data_tridmat(HCDT A, HCDT B, HCDT C, HCDT D, const char *how); +uintptr_t MGL_EXPORT mgl_data_tridmat_(uintptr_t *A, uintptr_t *B, uintptr_t *C, uintptr_t *D, const char *how, int); /// Returns pointer to data element [i,j,k] MGL_EXPORT mreal *mgl_data_value(HMDT dat, long i,long j,long k); diff -Nru mathgl-2.3.4/include/mgl2/datac.h mathgl-2.3.5.1/include/mgl2/datac.h --- mathgl-2.3.4/include/mgl2/datac.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/datac.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * datac.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -354,6 +354,9 @@ * By default quadratic averaging over 5 points is used. */ inline void Smooth(const char *dirs="xyz",mreal delta=0) { mgl_datac_smooth(this,dirs,delta); } + /// Limit the data to be inside [-v,v], keeping the original sign + inline void Limit(mreal v) + { mgl_datac_limit(this, v); } /// Hankel transform inline void Hankel(const char *dir) { mgl_datac_hankel(this,dir); } @@ -445,6 +448,9 @@ /// Set the value in given cell of the data void set_v(mreal val, long i,long j=0,long k=0) { mgl_datac_set_value(this,val,i,j,k); } #endif + /// Get the complex value in given cell of the data + dual vc(long i,long j=0,long k=0) const { return a[i+nx*(j+ny*k)]; } + dual vcthr(long i) const { return a[i]; } /// Get the interpolated value and its derivatives in given data cell without border checking mreal valueD(mreal x,mreal y=0,mreal z=0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const { dual aa,ax,ay,az; mreal res; @@ -482,6 +488,15 @@ inline mglDataC mglQO3dc(const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mglData &xx, mglData &yy, mglData &zz, mreal r=1, mreal k0=100) { return mglDataC(true, mgl_qo3d_solve_c(ham, &ini_re, &ini_im, &ray, r, k0, &xx, &yy, &zz)); } //----------------------------------------------------------------------------- +/// Get array as solution of tridiagonal system of equations a[i]*x[i-1]+b[i]*x[i]+c[i]*x[i+1]=d[i] +/** String \a how may contain: + * 'x', 'y', 'z' for solving along x-,y-,z-directions, or + * 'h' for solving along hexagonal direction at x-y plain (need nx=ny), + * 'c' for using periodical boundary conditions, + * 'd' for diffraction/diffuse calculation. */ +inline mglDataC mglTridMatC(const mglDataA &A, const mglDataA &B, const mglDataA &C, const mglDataC &D, const char *how) +{ return mglDataC(true, mgl_datac_tridmat(&A, &B, &C, &D, how)); } +//----------------------------------------------------------------------------- /// Get sub-array of the data with given fixed indexes inline mglDataC mglSubDataC(const mglDataA &dat, long xx, long yy=-1, long zz=-1) { return mglDataC(true,mgl_datac_subdata(&dat,xx,yy,zz)); } diff -Nru mathgl-2.3.4/include/mgl2/data.h mathgl-2.3.5.1/include/mgl2/data.h --- mathgl-2.3.4/include/mgl2/data.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/data.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * data.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -23,8 +23,6 @@ #include "mgl2/data_cf.h" #include "mgl2/pde.h" //----------------------------------------------------------------------------- -#include -#include #include //----------------------------------------------------------------------------- mreal MGL_EXPORT mglLinear(const mreal *a, long nx, long ny, long nz, mreal x, mreal y, mreal z); @@ -135,9 +133,9 @@ { if(d.size()>0) { Create(d.size()); for(long i=0;i &d) - { if(d.size()>0) Set(&(a[0]),d.size()); else Create(1); } + { if(d.size()>0) Set(&(d[0]),d.size()); else Create(1); } inline void Set(const std::vector &d) - { if(d.size()>0) Set(&(a[0]),d.size()); else Create(1); } + { if(d.size()>0) Set(&(d[0]),d.size()); else Create(1); } /// Allocate memory and set data from variable argument list of double values inline void SetList(long n, ...) { @@ -364,6 +362,9 @@ /// 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); } + /// Limit the data to be inside [-v,v], keeping the original sign + inline void Limit(mreal v) + { mgl_data_limit(this, v); } /// Apply Hankel transform inline void Hankel(const char *dir) { mgl_data_hankel(this,dir); } @@ -392,34 +393,6 @@ 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 to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] - inline mreal Spline(mreal x,mreal y=0,mreal z=0) const - { return value(x,y,z); } - /// Interpolate by cubic spline the data to given point x,\a y,\a z which normalized in range [0, 1] - inline mreal Spline1(mreal x,mreal y=0,mreal z=0) const - { return value(x*(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_ext(this,x,y,z,0,0,0); } - /// Interpolate by line the data to given point x,\a y,\a z which normalized in range [0, 1] - inline mreal Linear1(mreal x,mreal y=0,mreal z=0) const - { return mgl_data_linear_ext(this,x*(nx-1),y*(ny-1),z*(nz-1),0,0,0); } - - /// Interpolate by cubic spline the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] - inline mreal Spline(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const - { return valueD(x,y,z, &(dif.x),&(dif.y), &(dif.z)); } - /// Interpolate by cubic spline the data and return its derivatives at given point x,\a y,\a z which normalized in range [0, 1] - inline mreal Spline1(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const - { mreal res=valueD(x*(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; } - /// Copy data from other mglData variable inline const mglDataA &operator=(const mglDataA &d) { if(this!=&d) mgl_data_set(this,&d); return d; } @@ -542,6 +515,16 @@ /// Saves result of ODE solving (|u|^2) for "Hamiltonian" ham with initial conditions ini inline mglData mglODE(const char *df, const char *var, const mglDataA &ini, mreal dt=0.1, mreal tmax=10) { return mglData(true, mgl_ode_solve_str(df,var, &ini, dt, tmax)); } +//----------------------------------------------------------------------------- +/// Get array as solution of tridiagonal system of equations a[i]*x[i-1]+b[i]*x[i]+c[i]*x[i+1]=d[i] +/** String \a how may contain: + * 'x', 'y', 'z' for solving along x-,y-,z-directions, or + * 'h' for solving along hexagonal direction at x-y plain (need nx=ny), + * 'c' for using periodical boundary conditions, + * 'd' for diffraction/diffuse calculation. */ +inline mglData mglTridMat(const mglDataA &A, const mglDataA &B, const mglDataA &C, const mglDataA &D, const char *how) +{ return mglData(true, mgl_data_tridmat(&A, &B, &C, &D, how)); } +//----------------------------------------------------------------------------- /// Calculate Jacobian determinant for D{x(u,v), y(u,v)} = dx/du*dy/dv-dx/dv*dy/du inline mglData mglJacobian(const mglDataA &x, const mglDataA &y) { return mglData(true, mgl_jacobian_2d(&x, &y)); } @@ -559,6 +542,16 @@ /// Get array which is n-th points {x[i],y[i],z[i]} for iterated function system (fractal) generated by A inline mglData mglIFS3d(const mglDataA &A, long n, long skip=20) { return mglData(true,mgl_data_ifs_3d(&A,n,skip)); } +/// Get array which is n-th points {x[i],y[i],z[i]} for iterated function system (fractal) defined in *.ifs file 'fname' and named as 'name' +inline mglData mglIFSfile(const char *fname, const char *name, long n, long skip=20) +{ return mglData(true,mgl_data_ifs_file(fname,name,n,skip)); } +/// Get array which is n-th pairs {x[i],y[i]} for flame fractal generated by A with functions F +/// Get array which is n-th pairs {x[i],y[i]} for Flame fractal generated by A with functions F +/** NOTE: A.nx must be >= 7 and F.nx >= 2 and F.nz=A.ny. + * F[0,i,j] denote function id. F[1,i,j] give function weight, F(2:5,i,j) provide function parameters. + * Resulting point is {xnew,ynew} = sum_i F[1,i,j]*F[0,i,j]{IFS2d(A[j]){x,y}}. */ +inline mglData mglFlame2d(const mglDataA &A, const mglDataA &F, long n, long skip=20) +{ return mglData(true,mgl_data_flame_2d(&A,&F,n,skip)); } //----------------------------------------------------------------------------- /// Get sub-array of the data with given fixed indexes inline mglData mglSubData(const mglDataA &dat, long xx, long yy=-1, long zz=-1) @@ -882,10 +875,10 @@ { ind = i; s = name; } /// Get the interpolated value and its derivatives in given data cell without border checking - mreal valueD(mreal x,mreal y=0,mreal z=0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const + mreal valueD(mreal x,mreal y=0,mreal =0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const { if(dz) *dz=0; return dat.valueD(ind,x,y,0,dx,dy); } /// Get the interpolated value in given data cell without border checking - mreal value(mreal x,mreal y=0,mreal z=0) const + mreal value(mreal x,mreal y=0,mreal =0) const { return dat.value(ind,x,y); } /// Get the value in given cell of the data without border checking mreal v(long i,long j=0,long =0) const @@ -929,10 +922,10 @@ { ind = i; s = name; } /// Get the interpolated value and its derivatives in given data cell without border checking - mreal valueD(mreal x,mreal y=0,mreal z=0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const + mreal valueD(mreal x,mreal =0,mreal =0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const { if(dy) *dy=0; if(dz) *dz=0; return dat.valueD(x,ind,0,dx); } /// Get the interpolated value in given data cell without border checking - mreal value(mreal x,mreal y=0,mreal z=0) const + mreal value(mreal x,mreal =0,mreal =0) const { return dat.value(x,ind,0); } /// Get the value in given cell of the data without border checking mreal v(long i,long =0,long =0) const @@ -940,9 +933,9 @@ mreal vthr(long i) const { return dat.vthr(i+dat.GetNx()*ind); } // add for speeding up !!! - mreal dvx(long i,long j=0,long =0) const + mreal dvx(long i,long =0,long =0) const { return dat.dvx(i,ind,0); } - mreal dvy(long i,long j=0,long =0) const + mreal dvy(long ,long =0,long =0) const { return 0; } mreal dvz(long ,long =0,long =0) const { return 0; } @@ -967,21 +960,21 @@ const std::vector &operator=(const std::vector &st) { dat = st; return st; } /// Get the interpolated value and its derivatives in given data cell without border checking - mreal valueD(mreal x,mreal y=0,mreal z=0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const + mreal valueD(mreal x,mreal =0,mreal =0,mreal *dx=0,mreal *dy=0,mreal *dz=0) const { return mglSpline3(dat.data(),dat.size(),1,1,x,0,0,dx,dy,dz); } /// Get the interpolated value in given data cell without border checking - mreal value(mreal x,mreal y=0,mreal z=0) const + mreal value(mreal x,mreal =0,mreal =0) const { return mglSpline3s(dat.data(),dat.size(),1,1,x,0,0); } - mreal v(long i,long j=0,long k=0) const { return dat[i]; } + mreal v(long i,long =0,long =0) const { return dat[i]; } mreal vthr(long i) const { return dat[i]; }; long GetNx() const { return dat.size(); } long GetNy() const { return 1; } long GetNz() const { return 1; } - mreal dvx(long i,long j=0,long k=0) const + mreal dvx(long i,long =0,long =0) const { return i>0? (i * + * Copyright (C) 2007-2016 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 * @@ -20,6 +20,19 @@ #ifndef _MGL_DEFINE_H_ #define _MGL_DEFINE_H_ //----------------------------------------------------------------------------- +// Disable warnings for MSVC: +// 4190 - C-linkage of std::complex, +// 4996 - deprecated abi functions +// 4786 - disable warnings on 255 char debug symbols +// 4231 - disable warnings on extern before template instantiation +// 4800 - "int,uint32_t,etc" forcing value to bool 'true' or 'false' (performance warning) +// 4244 - conversion from 'mreal,double' to 'float', possible loss of data +// 4267 - conversion from 'size_t' to 'long,int,etc', possible loss of data +// 4305 - truncation from 'double' to 'float' +#if defined(_MSC_VER) +#pragma warning(disable: 4996 4190 4786 4231 4800 4244 4267 4305) +#endif + #include "mgl2/config.h" #ifndef SWIG @@ -28,6 +41,12 @@ #endif #include "mgl2/dllexport.h" +#if defined(_MSC_VER) +#define MGL_OBSOLETE MGL_NO_EXPORT +#else +#define MGL_OBSOLETE MGL_EXPORT +#endif + #if MGL_HAVE_ATTRIBUTE #define MGL_FUNC_CONST __attribute__((const)) #define MGL_FUNC_PURE __attribute__((pure)) @@ -92,8 +111,8 @@ #include #if defined(_MSC_VER) -#if (_MSC_VER<=1800) #define collapse(a) // MSVS don't support OpenMP 3.* +#if (_MSC_VER<=1800) #define strtoull _strtoui64 //#define hypot _hypot #define getcwd _getcwd @@ -267,6 +286,7 @@ #define MGL_PREFERVC 0x040000 ///< Prefer vertex color instead of texture if output format supports #define MGL_ONESIDED 0x080000 ///< Render only front side of surfaces if output format supports (for debugging) #define MGL_NO_ORIGIN 0x100000 ///< Don't draw tick labels at axis origin +#define MGL_GRAY_MODE 0x100000 ///< Convert all colors to gray ones //----------------------------------------------------------------------------- #if MGL_HAVE_C99_COMPLEX #include @@ -282,10 +302,26 @@ #define mgl_abs(x) cabs(x) #endif #ifdef __cplusplus +#include +#include +#if defined(_MSC_VER) +template class MGL_EXPORT std::allocator; +template class MGL_EXPORT std::allocator; +template struct MGL_EXPORT std::char_traits; +template struct MGL_EXPORT std::char_traits; +template class MGL_EXPORT std::basic_string< char, std::char_traits, std::allocator >; +template class MGL_EXPORT std::basic_string< wchar_t, std::char_traits, std::allocator >; +template class MGL_EXPORT std::vector; +template class MGL_EXPORT std::vector; +#endif //----------------------------------------------------------------------------- extern float mgl_cos[360]; ///< contain cosine with step 1 degree //----------------------------------------------------------------------------- #include +#if defined(_MSC_VER) +template class MGL_EXPORT std::complex; +template class MGL_EXPORT std::complex; +#endif typedef std::complex dual; typedef std::complex ddual; #if !MGL_HAVE_C99_COMPLEX diff -Nru mathgl-2.3.4/include/mgl2/evalc.h mathgl-2.3.5.1/include/mgl2/evalc.h --- mathgl-2.3.4/include/mgl2/evalc.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/evalc.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * evalc.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/eval.h mathgl-2.3.5.1/include/mgl2/eval.h --- mathgl-2.3.4/include/mgl2/eval.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/eval.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * eval.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/fit.h mathgl-2.3.5.1/include/mgl2/fit.h --- mathgl-2.3.4/include/mgl2/fit.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/fit.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * fit.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/Fl_MathGL.h mathgl-2.3.5.1/include/mgl2/Fl_MathGL.h --- mathgl-2.3.4/include/mgl2/Fl_MathGL.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/Fl_MathGL.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * Fl_MathGL.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/fltk.h mathgl-2.3.5.1/include/mgl2/fltk.h --- mathgl-2.3.4/include/mgl2/fltk.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/fltk.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * fltk.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -35,6 +35,8 @@ int MGL_EXPORT mgl_fltk_thr(); /// Callback function for asking user. void MGL_EXPORT mgl_ask_fltk(const wchar_t *quest, wchar_t *res); +/// Return pointer to widget (Fl_MGLView*) used for plotting +MGL_EXPORT void *mgl_fltk_widget(HMGL gr); #ifdef __cplusplus } //----------------------------------------------------------------------------- @@ -43,7 +45,7 @@ /// Wrapper class for windows displaying graphics class MGL_EXPORT mglFLTK : public mglWnd { - mglFLTK(const mglFLTK &t) {} // copying is not allowed + mglFLTK(const mglFLTK &) {} // copying is not allowed const mglFLTK &operator=(const mglFLTK &t) { return t; } public: mglFLTK(const char *title="MathGL") : mglWnd() @@ -61,6 +63,8 @@ virtual ~mglFLTK() {} int Run() { return mgl_fltk_run(); } ///< Run main loop for event handling int RunThr() { return mgl_fltk_thr(); } ///< Run main loop for event handling in separate thread + /// Return pointer to widget (Fl_MGLView*) used for plotting + void *Widget() { return mgl_fltk_widget(gr); } }; //----------------------------------------------------------------------------- #endif diff -Nru mathgl-2.3.4/include/mgl2/font.h mathgl-2.3.5.1/include/mgl2/font.h --- mathgl-2.3.4/include/mgl2/font.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/font.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * font.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -22,7 +22,6 @@ #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 @@ -50,6 +49,9 @@ }; inline bool operator<(const mglGlyphDescr &a,const mglGlyphDescr &b) { return a.id(const mglGlyphDescr &a,const mglGlyphDescr &b) { return a.id>b.id; } +#if defined(_MSC_VER) +template class MGL_EXPORT std::vector; +#endif //----------------------------------------------------------------------------- struct MGL_EXPORT mglTeXsymb { unsigned kod; const wchar_t *tex; }; const float mgl_fgen = 4*14; diff -Nru mathgl-2.3.4/include/mgl2/glut.h mathgl-2.3.5.1/include/mgl2/glut.h --- mathgl-2.3.4/include/mgl2/glut.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/glut.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * glut.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -51,7 +51,7 @@ //----------------------------------------------------------------------------- class MGL_EXPORT mglGLUT: public mglGraph { - mglGLUT(const mglGLUT &t) {} // copying is not allowed + mglGLUT(const mglGLUT &) {} // copying is not allowed const mglGLUT &operator=(const mglGLUT &t) { return t; } public: mglGLUT(int (*draw)(HMGL gr, void *p), const char *title="MathGL", void *par=0, void (*load)(void *p)=0) : mglGraph(-1) diff -Nru mathgl-2.3.4/include/mgl2/mgl_cf.h mathgl-2.3.5.1/include/mgl2/mgl_cf.h --- mathgl-2.3.4/include/mgl2/mgl_cf.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/mgl_cf.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * mgl_cf.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/mgl.h mathgl-2.3.5.1/include/mgl2/mgl.h --- mathgl-2.3.4/include/mgl2/mgl.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/mgl.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * mgl.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -29,7 +29,7 @@ /// Wrapper class for all graphics class MGL_EXPORT mglGraph { - mglGraph(const mglGraph &t) {} // copying is not allowed + mglGraph(const mglGraph &) {} // copying is not allowed const mglGraph &operator=(const mglGraph &t) { return t; } protected: HMGL gr; @@ -69,6 +69,8 @@ /// Set the transparency on/off. inline void Alpha(bool enable) { mgl_set_alpha(gr, enable); } + /// Set the gray-scale mode on/off. + inline void Gray(bool enable) { mgl_set_gray(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) @@ -304,6 +306,9 @@ /// 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); } + /// Put further plotting in cell of stick sheared on sx, sy. + inline void ShearPlot(int num, int i, mreal sx, mreal sy, mreal xd=1, mreal yd=0) + { mgl_shearplot(gr,num,i,sx,sy,xd,yd); } /// Set factor of plot size inline void SetPlotFactor(double val) @@ -324,6 +329,9 @@ /// Set aspect ratio for further plotting. inline void Aspect(double Ax,double Ay,double Az=1) { mgl_aspect(gr, Ax, Ay, Az); } + /// Shear a further plotting. + inline void Shear(double Sx,double Sy) + { mgl_shear(gr, Sx, Sy); } /// Rotate a further plotting. inline void Rotate(double TetX,double TetZ=0,double TetY=0) { mgl_rotate(gr, TetX, TetZ, TetY); } @@ -2204,7 +2212,10 @@ inline void AllowDllCall(bool allow) { mgl_parser_allow_dll_call(pr, allow); } /// Set flag to stop script parsing inline void Stop() { mgl_parser_stop(pr); } - + /// Set variant of argument(s) separated by '?' to be used in further commands + inline void SetVariant(int var=0) + { mgl_parser_variant(pr, var); } + /// Return result of formula evaluation inline mglData Calc(const char *formula) { return mglData(true,mgl_parser_calc(pr,formula)); } diff -Nru mathgl-2.3.4/include/mgl2/mpi.h mathgl-2.3.5.1/include/mgl2/mpi.h --- mathgl-2.3.4/include/mgl2/mpi.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/mpi.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * mpi.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/opengl.h mathgl-2.3.5.1/include/mgl2/opengl.h --- mathgl-2.3.4/include/mgl2/opengl.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/opengl.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * opengl.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/other.h mathgl-2.3.5.1/include/mgl2/other.h --- mathgl-2.3.4/include/mgl2/other.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/other.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * other.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/parser.h mathgl-2.3.5.1/include/mgl2/parser.h --- mathgl-2.3.4/include/mgl2/parser.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/parser.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * parser.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -22,7 +22,6 @@ #ifdef __cplusplus #include "mgl2/mgl.h" -#include #if MGL_HAVE_LTDL #include #endif @@ -161,6 +160,8 @@ void DeleteVar(const wchar_t *name); /// Delete all data variables void DeleteAll(); + /// Set variant of argument(s) separated by '?' to be used + inline void SetVariant(int var=0) { Variant = var<=0?0:var; } private: // long parlen; ///< Length of parameter strings std::wstring par[40]; ///< Parameter for substituting instead of $1, ..., $9 @@ -176,6 +177,7 @@ int for_stack[40]; ///< The order of for-variables int for_addr; ///< Flag for saving address in variable (for_addr-1) bool for_br; ///< Break is switched on (skip all comands until 'next') + unsigned Variant; ///< Select variant of argument(s) separated by '?' /// Parse command int Exec(mglGraph *gr, const wchar_t *com, long n, mglArg *a, const std::wstring &var, const wchar_t *opt); diff -Nru mathgl-2.3.4/include/mgl2/pde.h mathgl-2.3.5.1/include/mgl2/pde.h --- mathgl-2.3.4/include/mgl2/pde.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/pde.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * pde.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/plot.h mathgl-2.3.5.1/include/mgl2/plot.h --- mathgl-2.3.4/include/mgl2/plot.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/plot.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * plot.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/prim.h mathgl-2.3.5.1/include/mgl2/prim.h --- mathgl-2.3.4/include/mgl2/prim.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/prim.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * prim.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/qmathgl.h mathgl-2.3.5.1/include/mgl2/qmathgl.h --- mathgl-2.3.4/include/mgl2/qmathgl.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/qmathgl.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * qmathgl.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -20,10 +20,9 @@ #ifndef _MGL_QMATHGL_H_ #define _MGL_QMATHGL_H_ //----------------------------------------------------------------------------- -#include +#include #include #include -#include //----------------------------------------------------------------------------- class QTextEdit; class QMenu; @@ -233,7 +232,16 @@ mglDrawScript(HMPR p):mglDraw() { par=p; line=-1; } virtual ~mglDrawScript() {} int Draw(mglGraph *gr) - { gr->Highlight(line+1); mgl_parse_textw(gr->Self(),par,text.toStdWString().c_str()); return 0; } + { + wchar_t *wtext; + wtext = new wchar_t[text.size()+1]; + text.toWCharArray(wtext); + wtext[text.size()] = 0; + gr->Highlight(line + 1); + mgl_parse_textw(gr->Self(), par, wtext); + delete[] wtext; + return 0; + } }; //----------------------------------------------------------------------------- /// Convert bitmap from mglCanvasWnd to QPixmap diff -Nru mathgl-2.3.4/include/mgl2/qt.h mathgl-2.3.5.1/include/mgl2/qt.h --- mathgl-2.3.4/include/mgl2/qt.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/qt.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * qt.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -30,6 +30,8 @@ /// Run main Qt loop for event handling. int MGL_EXPORT mgl_qt_run(); int MGL_EXPORT mgl_qt_run_(); +/// Return pointer to widget (QMathGL*) used for plotting +MGL_EXPORT void *mgl_qt_widget(HMGL gr); #ifdef __cplusplus } //----------------------------------------------------------------------------- @@ -38,7 +40,7 @@ /// Wrapper class for windows displaying graphics class MGL_EXPORT mglQT : public mglWnd { - mglQT(const mglQT &t) {} // copying is not allowed + mglQT(const mglQT &) {} // copying is not allowed const mglQT &operator=(const mglQT &t) { return t; } public: mglQT(const char *title="MathGL") : mglWnd() @@ -52,6 +54,8 @@ mgl_set_click_func(gr, mgl_click_class); } virtual ~mglQT() {} int Run() { return mgl_qt_run(); } ///< Run main loop for event handling + /// Return pointer to widget (QMathGL*) used for plotting + void *Widget() { return mgl_qt_widget(gr); } }; //----------------------------------------------------------------------------- void MGL_EXPORT mgl_ask_qt(const wchar_t *quest, wchar_t *res); diff -Nru mathgl-2.3.4/include/mgl2/surf.h mathgl-2.3.5.1/include/mgl2/surf.h --- mathgl-2.3.4/include/mgl2/surf.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/surf.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * surf.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/thread.h mathgl-2.3.5.1/include/mgl2/thread.h --- mathgl-2.3.4/include/mgl2/thread.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/thread.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * thread.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/type.h mathgl-2.3.5.1/include/mgl2/type.h --- mathgl-2.3.4/include/mgl2/type.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/type.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * type.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/vect.h mathgl-2.3.5.1/include/mgl2/vect.h --- mathgl-2.3.4/include/mgl2/vect.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/vect.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * vect.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/volume.h mathgl-2.3.5.1/include/mgl2/volume.h --- mathgl-2.3.4/include/mgl2/volume.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/volume.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * volume.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/window.h mathgl-2.3.5.1/include/mgl2/window.h --- mathgl-2.3.4/include/mgl2/window.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/window.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * window.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/include/mgl2/wnd.h mathgl-2.3.5.1/include/mgl2/wnd.h --- mathgl-2.3.4/include/mgl2/wnd.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/wnd.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * wnd.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -56,7 +56,7 @@ pthread_t thr; bool running; pthread_mutex_t mutex; - + #else mglDraw() {} virtual ~mglDraw() {} @@ -74,12 +74,14 @@ /// Abstract class for windows displaying graphics class MGL_EXPORT mglWnd : public mglGraph { - mglWnd(const mglWnd &t) {} // copying is not allowed + mglWnd(const mglWnd &) {} // copying is not allowed const mglWnd &operator=(const mglWnd &t) { return t; } public: mglWnd() : mglGraph(-1) {} virtual ~mglWnd() { mgl_use_graph(gr,-255); } virtual int Run()=0; ///< Run main loop for event handling + /// Return pointer to widget used for plotting + virtual void *Widget() { return NULL; } inline void ToggleAlpha() ///< Switch on/off transparency (do not overwrite user settings) { mgl_wnd_toggle_alpha(gr); } diff -Nru mathgl-2.3.4/include/mgl2/wx.h mathgl-2.3.5.1/include/mgl2/wx.h --- mathgl-2.3.4/include/mgl2/wx.h 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/include/mgl2/wx.h 2016-06-19 17:01:14.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * wx.h.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/json/Backend.cpp mathgl-2.3.5.1/json/Backend.cpp --- mathgl-2.3.4/json/Backend.cpp 2016-02-13 19:03:31.000000000 +0000 +++ mathgl-2.3.5.1/json/Backend.cpp 2016-06-19 17:06:03.000000000 +0000 @@ -11,13 +11,18 @@ { qDebug() << __FUNCTION__; const char *tmp = tmpnam(0); + wchar_t *wtext; mglGraph gr; gr.SetFaceNum(200); mglParse pr; pr.AllowSetSize(true); setlocale(LC_CTYPE, ""); setlocale(LC_NUMERIC, "C"); - pr.Execute(&gr,text.toStdWString().c_str()); + wtext = new wchar_t[text.size()+1]; + text.toWCharArray(wtext); + wtext[text.size()] = 0; + pr.Execute(&gr,wtext); + delete[] wtext; gr.WriteJSON(tmp); setlocale(LC_NUMERIC, ""); @@ -32,13 +37,18 @@ //----------------------------------------------------------------------------- QString Backend::coor(const QString& xy, const QString& text) const { + wchar_t *wtext; qDebug() << __FUNCTION__; mglGraph gr; mglParse pr; pr.AllowSetSize(true); setlocale(LC_CTYPE, ""); setlocale(LC_NUMERIC, "C"); - pr.Execute(&gr,text.toStdWString().c_str()); + wtext = new wchar_t[text.size()+1]; + text.toWCharArray(wtext); + wtext[text.size()] = 0; + pr.Execute(&gr,wtext); + delete[] wtext; gr.Finish(); int x = (int)xy.section(" ",0,0).toDouble(); @@ -54,6 +64,7 @@ { qDebug() << __FUNCTION__; const char *tmp = tmpnam(0); + wchar_t *wmgl; mglGraph gr; #if 0 gr.SetFaceNum(200); @@ -62,7 +73,11 @@ pr.AllowSetSize(true); setlocale(LC_CTYPE, ""); setlocale(LC_NUMERIC, "C"); - pr.Execute(&gr,mgl.toStdWString().c_str()); + wmgl = new wchar_t[mgl.size()+1]; + mgl.toWCharArray(wmgl); + wmgl[mgl.size()] = 0; + pr.Execute(&gr,wmgl); + delete[] wmgl; gr.WriteJSON(tmp); setlocale(LC_NUMERIC, ""); diff -Nru mathgl-2.3.4/json/Backend.hpp mathgl-2.3.5.1/json/Backend.hpp --- mathgl-2.3.4/json/Backend.hpp 2016-02-13 19:03:31.000000000 +0000 +++ mathgl-2.3.5.1/json/Backend.hpp 2016-06-19 17:06:03.000000000 +0000 @@ -2,6 +2,9 @@ #include #include +#if defined(_MSC_VER) +#include +#endif class Backend : public QObject { diff -Nru mathgl-2.3.4/json/CMakeLists.txt mathgl-2.3.5.1/json/CMakeLists.txt --- mathgl-2.3.4/json/CMakeLists.txt 2016-02-13 19:03:31.000000000 +0000 +++ mathgl-2.3.5.1/json/CMakeLists.txt 2016-06-19 17:06:03.000000000 +0000 @@ -14,11 +14,9 @@ add_executable(MglForJsTestBench ${json_src} ${json_moc_hdr} ${json_ui_src}) if(enable-qt5) target_compile_definitions(MglForJsTestBench PUBLIC MGL_USE_QT5) - target_link_libraries(MglForJsTestBench mgl-qt5) - qt5_use_modules(MglForJsTestBench ${MGL_QT5_LIBS}) + target_link_libraries(MglForJsTestBench mgl-qt5 ${MGL_QT5_LIBS}) else(enable-qt5) - target_link_libraries(MglForJsTestBench mgl-qt) - qt4_use_modules(MglForJsTestBench ${MGL_QT4_LIBS}) + target_link_libraries(MglForJsTestBench mgl-qt4 ${MGL_QT4_LIBS}) endif(enable-qt5) endif(enable-json-sample) diff -Nru mathgl-2.3.4/lang/mgl.i mathgl-2.3.5.1/lang/mgl.i --- mathgl-2.3.4/lang/mgl.i 2016-02-13 19:01:06.000000000 +0000 +++ mathgl-2.3.5.1/lang/mgl.i 2016-06-19 17:01:08.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * mgl.h is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/make_release mathgl-2.3.5.1/make_release --- mathgl-2.3.4/make_release 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/make_release 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -#!/bin/bash -# Make releases - -VER=2.3.4 -LVER=${VER}.LGPL -BIN=MathGL -LBIN=MathGL-LGPL -SRC=/home/balakin/mathgl-code/mathgl-2x -BSRC=${SRC}/build - -mkdir mathgl-${VER}-mingw.i686 -mkdir mathgl-${VER}-mingw.i686/bin/ -cp -p ${BIN}/bin/* mathgl-${VER}-mingw.i686/bin/ -mkdir mathgl-${VER}-mingw.i686/lib/ -cp -p ${BIN}/lib/* mathgl-${VER}-mingw.i686/lib/ -mkdir mathgl-${VER}-mingw.i686/include/ -mkdir mathgl-${VER}-mingw.i686/include/mgl2/ -cp -p ${BIN}/include/mgl2/* mathgl-${VER}-mingw.i686/include/mgl2/ -cp -p ${SRC}/ChangeLog.txt mathgl-${VER}-mingw.i686/ -cp -p ${SRC}/FindMathGL2.cmake mathgl-${VER}-mingw.i686/mathgl2-config.cmake -7z a mathgl-${VER}-mingw.i686.7z mathgl-${VER}-mingw.i686/ -rm -R mathgl-${VER}-mingw.i686 - -mkdir mathgl-${LVER}-mingw.i686 -mkdir mathgl-${LVER}-mingw.i686/bin/ -cp -p ${LBIN}/bin/* mathgl-${LVER}-mingw.i686/bin/ -mkdir mathgl-${VER}-mingw.i686/lib/ -cp -p ${LBIN}/lib/* mathgl-${LVER}-mingw.i686/lib/ -mkdir mathgl-${LVER}-mingw.i686/include/ -mkdir mathgl-${LVER}-mingw.i686/include/mgl2/ -cp -p ${LBIN}/include/mgl2/* mathgl-${LVER}-mingw.i686/include/mgl2/ -cp -p ${SRC}/ChangeLog.txt mathgl-${LVER}-mingw.i686/ -cp -p ${SRC}/FindMathGL2.cmake mathgl-${LVER}-mingw.i686/mathgl2-config.cmake -7z a mathgl-${LVER}-mingw.i686.7z mathgl-${LVER}-mingw.i686/ -rm -R mathgl-${LVER}-mingw.i686 - -mkdir mgl_scripts-${VER} -cp -pR ${BIN}/extra/* mgl_scripts-${VER}/ -cp -p ${BIN}/bin/* mgl_scripts-${VER}/ -cp -p ${BIN}/share/mathgl/mgl.cgi.exe mgl_scripts-${VER}/ -cp -p ${BIN}/share/udav/*.qm mgl_scripts-${VER}/ -cp -p ${BSRC}/texinfo/mgl_??.html mgl_scripts-${VER}/ -cp -p ${SRC}/ChangeLog.txt mgl_scripts-${VER}/ -7z a mgl_scripts-${VER}.7z mgl_scripts-${VER}/ -rm -R mgl_scripts-${VER} - -cp -p ${BSRC}/texinfo/mathgl_en.pdf mathgl-${VER}.eng.pdf -cp -p ${BSRC}/texinfo/mgl_en.pdf mgl-${VER}.eng.pdf -cp -p ${SRC}/ChangeLog.txt ChangeLog-${VER}.txt -7z a mathgl-doc-html-${VER}.7z ${BSRC}/texinfo/m*html ${BSRC}/texinfo/png/ - -svn checkout svn://svn.code.sf.net/p/mathgl/code/mathgl-2x/ mathgl-${VER} -cd mathgl-${VER} -./clean-svn -cd .. -tar -zcf mathgl-${VER}.tar.gz mathgl-${VER}/ -rm -R mathgl-${VER} diff -Nru mathgl-2.3.4/mgltex/mgltex.dtx mathgl-2.3.5.1/mgltex/mgltex.dtx --- mathgl-2.3.4/mgltex/mgltex.dtx 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/mgltex/mgltex.dtx 2016-06-19 17:06:01.000000000 +0000 @@ -22,17 +22,17 @@ % % %\NeedsTeXFormat{LaTeX2e} -%\ProvidesPackage{mgltex}[2016/01/28 v4.1 Embed MGL scripts into LaTeX documents] +%\ProvidesPackage{mgltex}[2016/04/26 v4.2 Embed MGL scripts into LaTeX documents] % % %<*driver> \documentclass[10pt]{ltxdoc} \usepackage{color} +\usepackage{mgltex} +\DeclareRobustCommand\mglTeX{mgl\kern-0.04em\TeX}% Otherwise, incompatibility with \CharacterTable \IfFileExists{hyperref.sty}{% - \usepackage[hidelinks=true]{hyperref}% + \usepackage[hidelinks]{hyperref}% }{} -\usepackage{mgltex} -\def\mglTeX{mgl\TeX} % Otherwise, incompatibility with \CharacterTable \EnableCrossrefs \CodelineIndex \RecordChanges @@ -87,48 +87,75 @@ % \makeatother % \egroup % -% \changes{v1.0}{2014/09/27}{Initial version} -% \changes{v2.0}{2014/11/23}{Possible bugfix by adding \texttt{\textbackslash expandafter} to commands to ignore/write lines of MGL code} -% \changes{v2.0}{2014/11/23}{Add environment \texttt{mglsignature} that adds a commentary every MGL script} -% \changes{v2.0}{2014/11/23}{Eliminate line ignoring commands to create more elegant scripts, due to the a new command that adds comments to the scripts} -% \changes{v2.0}{2014/11/23}{Move the MGL \emph{stop} command from the \texttt{\textbackslash{}AtEndDocument} command to the \texttt{\textbackslash{}mgl@func} buffer} -% \changes{v3.0}{/2015/03/29}{Add detection of changes in MGL scripts to speed up compilation time (only changed scripts are recompiled)} -% \changes{v3.0}{/2015/03/29}{Add command \texttt{\textbackslash mgldir}, \texttt{\textbackslash mglscriptsdir}, \texttt{\textbackslash mglgraphicsdir} and \texttt{\textbackslash mglbackupsdir} to specify a main directory for \textsf{\mglTeX} and directories for the creation of scripts, graphics and backups} -% \changes{v3.0}{/2015/03/29}{Add the \texttt{\textbackslash mglquality} command to specify a default quality} -% \changes{v3.0}{/2015/03/29}{Add the \texttt{\textbackslash mglwidth} and \texttt{\textbackslash mglheight} commands to specify the default size of the images produced} -% \changes{v3.0}{/2015/03/29}{Add the \texttt{\textbackslash mglsettings} command to configure behavior of the package} -% \changes{v3.0}{/2015/03/29}{Improve environment \texttt{mglsignature} by adding the possibility of using \LaTeX{} commands inside it} -% \changes{v4.0}{/2015/08/17}{Completely rewrite of \textsf{\mglTeX}} -% \changes{v4.0}{/2015/08/17}{\textsf{\mglTeX} now depends of the \textsf{verbatim} package} -% \changes{v4.0}{/2015/08/17}{All environments write their contents \emph{verbatim}} -% \changes{v4.0}{/2015/08/17}{Add package options \texttt{0q}, \ldots, \texttt{8q} to specify quality} -% \changes{v4.0}{/2015/08/17}{Add the \texttt{\textbackslash mglpaths} command to add directories to the search paths for MGL scripts} -% \changes{v4.0}{/2015/08/17}{Add the \texttt{\textbackslash mglname} command to force clousure of the current main script, its compilation, and the opening of a new main script} -% \changes{v4.0}{/2015/08/17}{Add the option \texttt{label} to the \texttt{mgl} environment in order to override the automatic naming of the script and corresponding image} -% \changes{v4.0}{/2015/08/17}{Add the option \texttt{label} to the \texttt{mglverbatim} environment to name the verbatim code} -% \changes{v4.0}{/2015/08/17}{Add the option \texttt{separator} to the command \texttt{\textbackslash mglplot} to brake the code into different physical text lines} -% \changes{v4.0}{/2015/08/17}{Add the option \texttt{path} to the commands \texttt{\textbackslash mglgraphics} and \texttt{\textbackslash mglinclude} to force a path to search MGL scripts} -% \changes{v4.0}{/2015/08/17}{Make verbatim-like environments and \texttt{\textbackslash mglinclude} command more visually elegant} -% \changes{v4.0}{/2015/08/17}{Numbering in verbatim-like environments is optional now} -% \changes{v4.0}{/2015/08/17}{Add the command \texttt{\textbackslash listofmglscripts} to create a list of all MGL scripts included verbatim in the document} -% \changes{v4.0}{/2015/08/17}{Add the command \texttt{\textbackslash mglTeXwVer} that prints the name of the package with its version in a coherent manner, and separated by an unbreakable space} -% \changes{v4.0}{/2015/08/17}{Verbatim-like environments and the \texttt{\textbackslash mglinclude} command have starred versions wich prevent the command \texttt{\textbackslash listofmglscripts} to list them} -% \changes{v4.0}{/2015/08/17}{Remove \texttt{mglsignature} environment for being considered useless, and to avoid interference with the detection of changes in MGL scripts, to speed up script writing and to make the package less resource-consuming} -% \changes{v4.0}{/2015/08/17}{Remove the \texttt{\textbackslash mglwidth} and \texttt{\textbackslash mglheight} commands for being considered useless} -% \changes{v4.0}{/2015/08/17}{Remove the \texttt{\textbackslash MGL@setkeys} command, since it isn't needed as first thought} -% \changes{v4.0}{/2015/08/17}{Many improvements, including, but not limited to, speed up, increased coherence and cleanness of the code, less resource consumption} -% \changes{v4.0}{/2015/08/17}{Many bugfixes} -% -% \changes{v4.1}{/2016/01/28}{Add the command \texttt{\textbackslash mglimgext} to specify locally the extension to save the generated graphics} -% \changes{v4.1}{/2016/01/28}{Add the command \texttt{\textbackslash mglswitch}, which replaces \texttt{\textbackslash mgltexon} and \texttt{\textbackslash mgltexoff}} -% \changes{v4.1}{/2016/01/28}{Rename the commands \texttt{\textbackslash mgltexon} as \texttt{\textbackslash MGL@switch@on} and \texttt{\textbackslash mgltexoff} as \texttt{\textbackslash MGL@switch@off} in order to avoid the user from unpurposely overwriting them} -% \changes{v4.1}{/2016/01/28}{The command \texttt{\textbackslash mglcomments} has been reimplemented to accept one mandatory argument: \texttt{\textbackslash mglcomments\{on\}} replaces the old \texttt{\textbackslash mglcomments}, while \texttt{\textbackslash mglcomments\{off\}} replaces the old \texttt{\textbackslash mglnocomments}} -% \changes{v4.1}{/2016/01/28}{Remove the command \texttt{\textbackslash mglnocomments} (rendered useless by the new implementation of \texttt{\textbackslash mglcomments})} -% \changes{v4.1}{/2016/01/28}{Remove the command \texttt{\textbackslash mglTeXwVer} (rendered useless by the implementation of the starred version of \texttt{\textbackslash mglTeX})} -% \changes{v4.1}{/2016/01/28}{Restore the command \texttt{\textbackslash mglsettings}, which was unintentionally deleted in version~4.0} -% \changes{v4.1}{/2016/01/28}{Expand the key-val list family for the command \texttt{\textbackslash mglsettings}} -% \changes{v4.1}{/2016/01/28}{Reimplement the \texttt{\textbackslash @MGL@comments@} switch} -% \changes{v4.1}{/2016/01/28}{A starred version of the command \texttt{\textbackslash mglTeX} has been implemented, which prints the version of the package besides its name} +% \def\doccommand#1{\texttt{\textbackslash#1}} +% +% \changes{\textbf{v1.0 ------------}}{2014/09/27}{Initial version} +% +% +% \changes{\textbf{v2.0 ------------}}{2014/11/23}{Possible bugfix by adding \doccommand{expandafter} to commands to ignore/write lines of MGL code} +% \changes{\textbf{v2.0 ------------}}{2014/11/23}{Add environment \texttt{mglsignature} that adds a comment to every MGL script} +% \changes{\textbf{v2.0 ------------}}{2014/11/23}{Eliminate line ignoring commands to create more elegant scripts, due to the a new command that adds comments to the scripts} +% \changes{\textbf{v2.0 ------------}}{2014/11/23}{Move the MGL \emph{stop} command from the \texttt{\textbackslash{}AtEndDocument} command to the \doccommand{mgl@func} buffer} +% +% +% \changes{\textbf{v3.0 ------------}}{2015/03/29}{Add detection of changes in MGL scripts to speed up compilation time (only changed scripts are recompiled)} +% \changes{\textbf{v3.0 ------------}}{2015/03/29}{Add command \doccommand{mgldir}, \doccommand{mglscriptsdir}, \doccommand{mglgraphicsdir} and \doccommand{mglbackupsdir} to specify a main directory for \textsf{\mglTeX} and directories for the creation of scripts, graphics and backups} +% \changes{\textbf{v3.0 ------------}}{2015/03/29}{Add the \doccommand{mglquality} command to specify a default quality} +% \changes{\textbf{v3.0 ------------}}{2015/03/29}{Add the \doccommand{mglwidth} and \doccommand{mglheight} commands to specify the default size of the images produced} +% \changes{\textbf{v3.0 ------------}}{2015/03/29}{Add the \doccommand{mglsettings} command to configure behavior of the package} +% \changes{\textbf{v3.0 ------------}}{2015/03/29}{Improve environment \texttt{mglsignature} by adding the possibility of using \LaTeX{} commands inside it} +% +% +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Complete rewrite of \textsf{\mglTeX}} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{\textsf{\mglTeX} now depends of the \textsf{verbatim} package} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{All environments write their contents \emph{verbatim}} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add package options \texttt{0q}, \ldots, \texttt{8q} to specify quality} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the \doccommand{mglpaths} command to add directories to the search paths for MGL scripts} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the \doccommand{mglname} command to force clousure of the current main script, its compilation, and the opening of a new main script} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the option \texttt{label} to the \texttt{mgl} environment in order to override the automatic naming of the script and corresponding image} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the option \texttt{label} to the \texttt{mglverbatim} environment to name the verbatim code} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the option \texttt{separator} to the command \doccommand{mglplot} to brake the code into different physical text lines} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the option \texttt{path} to the commands \doccommand{mglgraphics} and \doccommand{mglinclude} to force a path to search MGL scripts} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Verbatim-like environments and \doccommand{mglinclude} command are more visually elegant now} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Numbering in verbatim-like environments is optional now} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the command \doccommand{listofmglscripts} to create a list of all MGL scripts included verbatim in the document} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Add the command \doccommand{mglTeXwVer} that prints the name of the package with its version in a coherent manner, and separated by an unbreakable space} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Verbatim-like environments and the \doccommand{mglinclude} command have starred versions wich prevent the command \doccommand{listofmglscripts} to list them} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Remove \texttt{mglsignature} environment for being considered useless, and to avoid interference with the detection of changes in MGL scripts, to speed up script writing and to make the package less resource-consuming} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Remove the \doccommand{mglwidth} and \doccommand{mglheight} commands for being considered useless} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Many improvements, including, but not limited to, speed up, increased coherence and cleanness of the code, less resource consumption} +% \changes{\textbf{v4.0 ------------}}{2015/08/17}{Many bugfixes} +% +% +% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Add the command \doccommand{mglimgext} to specify locally the extension to save the generated graphics} +% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Add the command \doccommand{mglswitch}, which replaces \doccommand{mgltexon} and \doccommand{mgltexoff}} +% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Rename the commands \doccommand{mgltexon} as \doccommand{MGL@switch@on} and \doccommand{mgltexoff} as \doccommand{MGL@switch@off} in order to avoid the user from unpurposely overwriting them} +% \changes{\textbf{v4.1 ------------}}{2016/01/28}{The command \doccommand{mglcomments} has been reimplemented to accept one mandatory argument: \doccommand{mglcomments\{on\}} replaces the old \doccommand{mglcomments}, while \doccommand{mglcomments\{off\}} replaces the old \doccommand{mglnocomments}} +% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Remove the command \doccommand{mglnocomments} (rendered useless by the new implementation of \doccommand{mglcomments})} +% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Remove the command \doccommand{mglTeXwVer} (rendered useless by the implementation of the starred version of \doccommand{mglTeX})} +% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Restore the command \doccommand{mglsettings}, which was unintentionally deleted in version~4.0} +% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Expand the key-val list family for the command \doccommand{mglsettings}} +% \changes{\textbf{v4.1 ------------}}{2016/01/28}{Reimplement the \doccommand{@MGL@comments@} switch} +% \changes{\textbf{v4.1 ------------}}{2016/01/28}{A starred version of the command \doccommand{mglTeX} has been implemented, which prints the version of the package besides its name} +% +% +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New package options \texttt{gray}, \texttt{color} to activate/deactivate gray-scale mode for graphics} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New package options \texttt{0v}, \texttt{1v}, \texttt{2v} to select variant of arguments in MGL scripts} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New package option \texttt{9q} for setting quality to \texttt{9} (for testing purposes of the author)} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New commands: \doccommand{mglgray} (to activate/deactivate) gray-scale mode locally, and \doccommand{mglvariant} (to set variant of arguments in MGL scripts locally)} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Rename environment \texttt{mglcommon} to \texttt{mglsetupscript} (\texttt{mglcommon} is still available, but deprecated)} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Rename command \doccommand{mglcommonscriptname} to \texttt{mglsetupscriptname}} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Rename command \doccommand{MGL@graph@ext} to \doccommand{MGL@imgext}} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Rename family \texttt{MGL@keys} as \texttt{MGL@gr@keys} for consistency} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Reorganize and update documentation} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{\mglTeX{} now depends on the \texttt{ifpdf} package} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{The MGL code line \texttt{setsize~600~400} is now automatically written to the main script in order for the scaling options and commands to work} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Remove the \doccommand{MGL@setkeys} command, since it isn't needed as first thought} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Some minor bugfixes} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Change definition of \doccommand{mglcommentname} from \emph{MGL comment} to \emph{\mglTeX{} comment}} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Rename \doccommand{MGL@document@scripts} to \doccommand{MGL@doc@scripts}} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Rename \doccommand{MGL@script@name} tp \doccommand{MGL@script}} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Introduce the concept of \emph{global}, \emph{local} and \emph{private} settings in the documentation} % % \GetFileInfo{mgltex.sty} % @@ -137,7 +164,7 @@ % \DoNotIndex{\@flushglue,\@for,\@ifnextchar,\@makeother,\{,\},\ ,\AtBeginDocument,\AtEndDocument,\centering} % \DoNotIndex{\closein,\closeout,\csname,\endcsname,\CurrentOption,\DeclareGraphicsExtensions,\define@key,\DeclareOption} % \DoNotIndex{\detokenize,\do,\dospecials,\endlinechar,\endlist,\escapechar,\ExecuteOptions,\expandafter,\footnotesize} -% \DoNotIndex{\framebox,\Gin@extensions,\Huge,\ifeof,\IfFileExists,\ifx,\immediate,\include,\includegraphics,\item,\itemsep} +% \DoNotIndex{\framebox,\Huge,\ifeof,\IfFileExists,\ifx,\immediate,\include,\includegraphics,\item,\itemsep} % \DoNotIndex{\itshape,\jobname,\labelsep,\leftskip,\let,\long,\mbox,\newcounter,\newread,\newtoks,\newwrite,\noexpand} % \DoNotIndex{\obeyspaces,\openin,\openout,\PackageError,\PackageWarning,\parfillskip,\parindent,\parskip} % \DoNotIndex{\PassOptionsToPackage,\ProcessOptions,\read,\relax,\RequirePackage,\rightskip,\setcounter,\setkeys,\setlength} @@ -150,7 +177,7 @@ % \DoNotIndex{\endcenter,\everypar,\fbox,\fboxrule,\frenchspacing,\g@addto@macro,\global,\hb@xt@,\hbadness,\hfil,\hfill} % \DoNotIndex{\hrule,\hskip,\hss,\if@minipage,\if@tempswa,\ifhmode,\ifnum,\interlinepenalty,\itemindent,\kern,\l@chapter} % \DoNotIndex{\l@section,\large,\leavevmode,\MakeUppercase,\newdimen,\nobreak,\nopagebreak,\normalfont,\null,\numberline} -% \DoNotIndex{\p@,\par,\unpenalty,\usecounter,\@ifstar,\^} +% \DoNotIndex{\p@,\par,\unpenalty,\usecounter,\@ifstar,\^,\iffalse,\iftrue,\ifpdf} % % \title{The \textsf{\mglTeX} package\thanks{This document corresponds to \textsf{\mglTeX}~\fileversion, dated \filedate.}} % \author{Diego Sejas Viscarra\\\texttt{dsejas.mathematics@gmail.com}} @@ -160,13 +187,13 @@ % \begin{abstract} % \noindent MathGL is a fast and efficient library by Alexey Balakin for the creation of high-quality publication-ready scientific graphics. Although it defines interfaces for many programming languages, it also implements its own scripting language, called \emph{MGL}, which can be used independently. With the package \textsf{\mglTeX}, MGL scripts can be embedded within any \LaTeX{} document, and the corresponding images are automatically created and included. % -% This manual documents the use of the commands and environments of~\textsf{\mglTeX}. +% This manual documents the usage of the commands and environments of~\textsf{\mglTeX}. % \end{abstract} % % \tableofcontents % % \section{Introduction} -% MathGL is a fast and efficient library by Alexey Balakin for the creation of high-quality publication-ready scientific graphics. It implements more than $50$ different types of graphics for 1d, 2d and 3d large sets of data. It supports exporting images to bitmap formats (PNG, JPEG, BMP, etc.), or vector formats (EPS, \TeX, SVG, etc.), or 3d image formats (STL, OBJ, XYZ, etc.), and even its own native 3d format, MGLD. MathGL also defines its own vector font specification format, and supports UTF-16 encoding with \TeX-like symbol parsing. It supports various kinds of transparency and lighting, textual formula evaluation, arbitrary curvilinear coordinate systems, loading of subroutines from .dll or .so libraries, and many other useful features. +% \noindent MathGL is a fast and efficient library by Alexey Balakin for the creation of high-quality publication-ready scientific graphics. It implements more than $50$ different types of graphics for 1d, 2d and 3d large sets of data. It supports exporting images to bitmap formats (PNG, JPEG, BMP, etc.), or vector formats (EPS, \TeX, SVG, etc.), or 3d image formats (STL, OBJ, XYZ, etc.), and even its own native 3d format, MGLD. MathGL also defines its own vector font specification format, and supports UTF-16 encoding with \TeX-like symbol parsing. It supports various kinds of transparency and lighting, textual formula evaluation, arbitrary curvilinear coordinate systems, loading of subroutines from .dll or .so libraries, and many other useful features. % % MathGL has interfaces for a wide variety of programming languages, such as C/C++, Fortran, Python, Octave, Pascal, Forth, and many others, but it also defines its own scripting language, called \emph{MGL}, which can be used to generate graphics independently of any programming language. The \textsf{\mglTeX} package adds support to embed MGL code inside \LaTeX{} documents, which is automatically extracted and executed, and the resulting images are included in the document. % @@ -179,13 +206,16 @@ % \begin{enumerate} % \item Any meta-variable that contain the word \emph{directory} indicates the name of a directory, in the form of an absolute or relative path, ending with the slash (``/'') character. % \item Any meta-variable that contain the word \emph{subdirectory} indicates a relative path ending with the slash (``/'') character. -% \item \meta{$x_1\vert x_2\vert\ldots\vert x_n$} indicates that any of the values $x_1$, $x_2$, \ldots, $x_n$ can be placed there. +% \item \meta{$x_1\vert x_2\vert\ldots\vert x_n$} indicates that any of the values $x_1$, $x_2$, \ldots, $x_n$ can be placed there. A special case is \meta{$x_1\vert x_2\vert\ldots$}, where no upper limit is set. +% \item The possible values of a meta-variable could also be indicated by a property. For example \meta{$x:x>0$} indicates that any positive value can be used in that location. % \item A meta-variable of the form \meta{list of something} or \meta{something list} indicate a comma-separated list of values of type $\meta{something}$; if only one value is used, no comma is needed. -% \item A meta-variable with underscores (``\_'') in its description indicate that spaces should not be used in that location. +% \item A meta-variable with underscores (``|_|'') in its description indicate that spaces should not be used in that location. % \item \meta{key-val list} refers to a list of \meta{key}=\meta{value} pairs of options, where \meta{key} is a keyword name for an option and \meta{value} is a value assigned to it. % \end{enumerate} % -% As is conventional for \LaTeX{} packages, the commands and environments of \textsf{\mglTeX{}} accept optional commands inside brackets and mandatory arguments inside curly braces. +% As is conventional for \LaTeX{} packages, the environments and commands defined by \textsf{\mglTeX} accept optional commands inside brackets ("|[|" and "|]|"), and mandatory arguments inside curly braces ("|{|" and "|}|"). +% +% While reading the following, it must be noted that most of \textsf{\mglTeX} settings have three modes: global, local and private. A setting is \emph{global} if it applies to the whole document, it is \emph{local} if it applies to the document from one point onwards, and it is \emph{private} if it applies only to a particular MGL script. Global settings are set thorugh package options or with the command |\mglsettings| (explained later), local settings have associated commands (subsection \ref{local setts}), and private settings are specified as optional arguments for environments and commands. An example of this would be the package option |4q|, the command |\mglquality{4}|, and the optional argument for environments and commands |quality=4|, to set the quality for graphics to |4| in the three different modes, respectively. % % \section{Usage} % \noindent The simplest way to load \textsf{\mglTeX} to a \LaTeX{} document is to write the command @@ -198,14 +228,16 @@ % \end{center} % where \meta{options list} can contain one or more of the following options: % \begin{itemize} -% \item |draft|: The generated images won't be included in the document. This option is useful when fast compilation of the document is needed. -% \item |final|: Overrides the |draft| option. -% \item |on|: To rewrite, recompile and include the changed MGL scripts and/or corresponding graphics. -% \item |off|: To avoid creation, compilation and/or inclusion of the MGL scripts and corresponding images. -% \item |comments|: To allow the contents of the |mglcomment| environments to be shown in the \LaTeX{} document. -% \item |nocomments|: To avoid showing the contents of the |mglcomment| environments in the \LaTeX{} document. -% \item |1x|, \ldots, |9x|: To specify the scale for the creation of graphics (|1x| is normal scaling, |2x| is twice as bigger, etc). -% \item |0q|, \ldots, |8q|: To specify the quality for the creation of graphics. An info message indicating the characteristics of the chosen quality is printed in the .log file according to the following table: +% \item \textbf{draft:} The generated images won't be included in the document. This option is useful when fast compilation of the document is needed. +% \item \textbf{final:} Overrides the |draft| option. +% \item \textbf{on:} To rewrite, recompile and include the changed MGL scripts and/or corresponding graphics. +% \item \textbf{off:} To avoid creation, compilation and/or inclusion of the MGL scripts and corresponding images. +% \item \textbf{comments:} To allow the contents of the |mglcomment| environments to be shown in the \LaTeX{} document. +% \item \textbf{nocomments:} To avoid showing the contents of the |mglcomment| environments in the \LaTeX{} document. +% \item \textbf{gray:} To create the MGL graphics in gray-scale mode. +% \item \textbf{color:} To create the MGL graphics in color mode. +% \item \textbf{1x, \ldots, 9x:} To specify the scale for the creation of graphics (|1x| is normal scaling, |2x| is twice as bigger, etc). +% \item \textbf{0q, \ldots, 9q:} To specify the quality for the creation of graphics. An info message indicating the characteristics of the chosen quality is printed in the .log file according to the following table: % \begin{center} % \DeleteShortVerb{\|} % \begin{tabular}{|c|l|} @@ -232,14 +264,17 @@ % \hline % $8$ & Draw dots instead of primitives (extremely fast)\\ % \hline +% $9$ & No drawing (for testing purposes)\\ +% \hline % \end{tabular} % \MakeShortVerb{\|} % \end{center} -% \item |png|, |jpg|, |jpeg|: To export images to a bitmap format. -% \item |eps|, |epsz|: To export to uncompressed/compressed vectorial EPS format. -% \item |bps|, |bpsz|: To export to uncompressed/compressed bitmap EPS format. -% \item |pdf|: To export to 3D PDF format. -% \item |tex|: To export to \LaTeX{}/\emph{tikz} document. +% \item \textbf{0v, 1v, 2v:} To set the default variant of arguments for the MGL commands. +% \item \textbf{png, jpg, jpeg:} To export images to a bitmap format. +% \item \textbf{eps, epsz:} To export to uncompressed/compressed vectorial EPS format. +% \item \textbf{bps, bpsz:} To export to uncompressed/compressed bitmap EPS format. +% \item \textbf{pdf:} To export to 3D PDF format. +% \item \textbf{tex:} To export to \LaTeX{}/\emph{tikz} document. % \end{itemize} % If two or more mutually exclusive options are specified, only the last one will be used by \textsf{\mglTeX}. For example, if one specifies the options |0q|, |3q| and |8q|---in that order---, then the quality will be set to $8$. % @@ -282,7 +317,7 @@ % \end{quote} % % \subsection{Environments for MGL code embedding} -% \DescribeEnv{mgl}\noindent The main environment defined by \textsf{\mglTeX} is |mgl|. It extracts its contents to a main script, called \meta{main\_script\_name}.mgl, where \meta{main\_script\_name} stands for a name specified by the user with the |\mglname| command (see below), or the name of the \LaTeX{} document being executed otherwise; this script is compiled, and the corresponding image is included. +% \DescribeEnv{mgl}\noindent The main environment defined by \textsf{\mglTeX} is |mgl|. It extracts its contents to a main script, called \meta{main\_script\_name}.mgl, where \meta{main\_script\_name} stands for a name specified by the user with the |\mglname| command (explained later), or the name of the \LaTeX{} document being executed otherwise; this script is compiled, and the corresponding image is included. % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] @@ -292,9 +327,18 @@ % \hline % \end{tabular} % \end{center} -% Here, \meta{key-val list} can have the same optional arguments as the |\includegraphics| command from the \textsf{graphicx} package, plus two additional ones, |imgext|, which can be used to specify the extension to save the graphic, and |label|, which can be used to indicate a name for the corresponding graphic (otherwise, an automatic naming will be applied). The \meta{MGL code} doesn't need to contain any specific instruction to create the image since \textsf{\mglTeX} takes care of that. +% Here, \meta{key-val list} can have the following optional arguments: +% \begin{itemize} +% \item \textbf{bb, bbllx, bblly, bburx, bbury, natwidth, natheight, hiresbb, viewport, trim, angle, origin, width, height, totalheight, keepaspectratio, scale, clip, draft, type, ext, read, command:} These are the same options of the |\includegraphics| command from the \textsf{graphicx} package. +% \item \textbf{gray:} Can be used to activate (|gray=on| or |gray=1|) or deactivate (|gray=off| or |gray=0|) gray-scale mode privately (only for the current graphic). +% \item \textbf{mglscale:} Any positive value for this option is used to physically scale the resulting image file, i.g., |mglscale=2| will create an image file twice as bigger. +% \item \textbf{quality:} Sets the quality of the current graphic. Valid values are integers between |0| and |9|. +% \item \textbf{variant:} Sets the variant of argument for the commands in the current script. +% \item \textbf{imgext:} Can be used to set the extension for the current image. +% \item \textbf{label:} Can be used to indicate a name for the corresponding graphic (otherwise, an automatic naming will be applied) +% \end{itemize} % -% \DescribeEnv{mgladdon} This environment adds its contents to the document's main script, but it doesn't produce any image. It doesn't require any kind of arguments. It is useful to add ``complementary code'', like loading of dynamic libraries, set default size for the graphics, etc. +% \DescribeEnv{mgladdon} This environment adds its contents to the document's main script, but it doesn't produce any image. It doesn't require any kind of arguments. It is useful to add ``complementary code'', like instructions to load dynamic libraries, set default size for the graphics, etc. % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] @@ -316,7 +360,15 @@ % \end{tabular} % \end{center} % -% \DescribeEnv{mglcode} It has the same function as the |mgl| environment, but the corresponding code is written to a separate script, whose name is specified as mandatory argument. It accepts the same optional arguments as |mgl|, except, of course, the |label| option. +% \DescribeEnv{mglcode} It has the same function as the |mgl| environment, but the corresponding code is written to a separate script, whose name is specified as mandatory argument. It accepts the following optional arguments: +% \begin{itemize} +% \item \textbf{bb, bbllx, bblly, bburx, bbury, natwidth, natheight, hiresbb, viewport, trim, angle, origin, width, height, totalheight, keepaspectratio, scale, clip, draft, type, ext, read, command:} These are the same options of the |\includegraphics| command from the \textsf{graphicx} package. +% \item \textbf{gray:} Can be used to activate (|gray=on| or |gray=1|) or deactivate (|gray=off| or |gray=0|) gray-scale mode privately (only for the current graphic). +% \item \textbf{mglscale:} Any positive value for this option is used to physically scale the resulting image file, i.g., |mglscale=2| will create an image file twice as bigger. +% \item \textbf{quality:} Sets the quality of the current graphic. Valid values are integers between |0| and |9|. +% \item \textbf{variant:} Sets the variant of argument for the commands in the current script. +% \item \textbf{imgext:} Can be used to set the extension for the current image. +% \end{itemize} % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] @@ -338,13 +390,13 @@ % \end{tabular} % \end{center} % -% \DescribeEnv{mglcommon} This is used to create a common ``setup'' script to define constants, parameters, etc. that will be available to the others. +% \DescribeEnv{mglsetupscript} This is used to create a common ``setup'' script to define constants, parameters, etc. that will be available to the others. % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] -% |\begin{mglcommon}|\\[0.5em] +% |\begin{mglsetupscript}|\\[0.5em] % \hss\meta{MGL code}\hss\\[0.5em] -% |\end{mglcommon}|\\[0.25em] +% |\end{mglsetupscript}|\\[0.25em] % \hline % \end{tabular} % \end{center} @@ -352,12 +404,23 @@ % % For example, one could write % \begin{quote} -% |\begin{mglcommon}|\\ +% |\begin{mglsetupscript}|\\ % |define gravity 9.81 # [m/s^2]|\\ -% |\end{mglcommon}| +% |\end{mglsetupscript}| % \end{quote} % to make the constant \emph{gravity} available to every script. % +% \DescribeEnv{mglcommon} This is a synomyn for the |mglsetupscript| environment. It is and will always be kept in \textsf{\mglTeX} for backwards compatibility with older versions of the package, but its use is \emph{deprecated}. +% \begin{center} +% \begin{tabular}{l} +% \hline\\[-0.75em] +% |\begin{mglcommon}|\\[0.5em] +% \hss\meta{MGL code}\hss\\[0.5em] +% |\end{mglcommon}|\\[0.25em] +% \hline +% \end{tabular} +% \end{center} +% % \subsection{Fast creation of graphics} % \noindent\textsf{\mglTeX} defines a convenient way to work with many graphics that have exactly the same settings (same rotation angles, same type of grid, same lighting, etc.): instead of writing repetitive code every time it's needed, it can be stored inside a |mglsetup| environment, and then can be used when needed with the |\mglplot| command. % @@ -372,7 +435,18 @@ % \end{tabular} % \end{center} % -% \DescribeMacro{\mglplot} This command is used for fast generation of graphics with default settings, and can be used in parallel with the |mglsetup| environment. It accepts one mandatory argument which consists of MGL instructions, separated by the symbol ``:'', and can span through various text lines. It accepts the same optional arguments as the |mgl| environment, plus two additional ones, called |setup| and |separator|. The |setup| option specifies a keyword associated to a |mglsetup| block, which will be executed before the code in the mandatory argument. The |separator| option specifies a text symbol that will break the code in the mandatory argument into a new physical line in the main script every time is encountered. +% \DescribeMacro{\mglplot} This command is used for fast generation of graphics with default settings, and can be used in parallel with the |mglsetup| environment. It accepts one mandatory argument which consists of MGL instructions, separated by the symbol ``:'', and can span through various text lines. It accepts the following optional arguments: +% \begin{itemize} +% \item \textbf{bb, bbllx, bblly, bburx, bbury, natwidth, natheight, hiresbb, viewport, trim, angle, origin, width, height, totalheight, keepaspectratio, scale, clip, draft, type, ext, read, command:} These are the same options of the |\includegraphics| command from the \textsf{graphicx} package. +% \item \textbf{gray:} Can be used to activate (|gray=on| or |gray=1|) or deactivate (|gray=off| or |gray=0|) gray-scale mode privately (only for the current graphic). +% \item \textbf{mglscale:} Any positive value for this option is used to physically scale the resulting image file, e.g., |mglscale=2| will create an image file twice as bigger. +% \item \textbf{quality:} Sets the quality of the current graphic. Valid values are integers between |0| and |9|. +% \item \textbf{variant:} Sets the variant of argument for the commands in the current script. +% \item \textbf{imgext:} Can be used to set the extension for the current image. +% \item \textbf{label:} Can be used to indicate a name for the corresponding graphic (otherwise, an automatic naming will be applied) +% \item \textbf{setup:} Specifies a keyword associated to a |mglsetup| block, which will be executed before the code in the mandatory argument. +% \item \textbf{separator:} Specifies a text symbol that will break the code in the mandatory argument into a new physical line in the main script every time is encountered. +% \end{itemize} % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] @@ -382,11 +456,15 @@ % \end{center} % % \subsection{Verbatim-like environments} -% \noindent The main purpose of these environments is to typeset their contents to the \LaTeX{} document, elegantly separated from the rest of the text. They have two versions: an unstarred version which can be listed later with the |\listofmglscripts| command (see below), and a starred version which won't be listed. +% \noindent The main purpose of these environments is to typeset their contents to the \LaTeX{} document, elegantly separated from the rest of the text. They have two versions: an unstarred version which can be listed later with the |\listofmglscripts| command (explained later), and a starred version which won't be listed. % -% Although these environments are intended to mimic the behavior of the |verbatim| environment from \LaTeX{}, there is an important difference, namely, long lines will be broken when the page margin is reached. This intended behavior is set because a language like MGL can easily have very long lines of code, like textual formulas, vectors input as lists of values, etc. Of course, no hyphenation will be performed, but the code will be indented in the second, third, etc. continuation lines by an amount specified by |\mglbreakindent| (see below). +% Although these environments are intended to mimic the behavior of the |verbatim| environment from \LaTeX{}, there is an important difference, namely, long lines will be broken when the page margin is reached. This intended behavior is set because a language like MGL can easily have very long lines of code, like textual formulas, vectors input as lists of values, etc. Of course, no hyphenation will be performed, but the code will be indented in the second, third, etc. continuation lines by an amount specified by |\mglbreakindent| (explained later). % -% \DescribeEnv{mglblock}\DescribeEnv{mglblock*} Besides typesetting its contents to the document, |mglblock| creates a script whose name is specified as mandatory argument. It also accepts one optional argument, called |lineno|, whose default value is |true|, used to activate (|lineno=true|) or deactivate (|lineno=false|) line numbering inside the environment. The default behavior is to number each line of code. +% \DescribeEnv{mglblock}\DescribeEnv{mglblock*} Besides typesetting its contents to the document, |mglblock| creates a script whose name is specified as mandatory argument. It accepts one optional argument: +% \begin{itemize} +% \item \textbf{lineno:} Used to activate (|lineno=true| or simply |lineno|) or deactivate (|lineno=false|) line numbering inside the environment. +% \end{itemize} +% By default, each line of code is numbered. % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] @@ -409,13 +487,13 @@ % \begin{quote} % \makeatletter % \MGL@set@script@name{example_script}% -% \refstepcounter{MGL@verb@script@no}% -% \addcontentsline{lms}{MGL@script}{\protect\numberline{\theMGL@verb@script@no.}{\ttfamily\protect\detokenize{\MGL@script@name.mgl}}}% +% \refstepcounter{MGL@verb@no}% +% \addcontentsline{lms}{MGL@script}{\protect\numberline{\theMGL@verb@no.}{\ttfamily\protect\detokenize{\MGL@script.mgl}}}% % \setcounter{MGL@line@no}{0}% % \list{\mgllinenostyle\arabic{MGL@line@no}.}{}% % \MGL@set@pseudo@verb@env % \fboxrule=\mgllinethickness% -% \item[\MGL@line@sep]\fbox{\bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script@name.mgl}}\hskip\labelsep\MGL@line@sep\par\par% +% \item[\MGL@line@sep]\fbox{\bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script.mgl}}\hskip\labelsep\MGL@line@sep\par\par% % \stepcounter{MGL@line@no}% % \item new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)' % \stepcounter{MGL@line@no}% @@ -430,7 +508,12 @@ % \endlist% % \end{quote} % -% \DescribeEnv{mglverbatim}\DescribeEnv{mglverbatim*} This environment only typesets its contents to the \LaTeX{} document without creating any script. It accepts the |lineno| option, with default value |true|, plus an one called |label|, intended to specify a name associated to the corresponding code. The default behavior is to number each line of code. +% \DescribeEnv{mglverbatim}\DescribeEnv{mglverbatim*} This environment only typesets its contents to the \LaTeX{} document without creating any script. It accepts two optional arguments +% \begin{itemize} +% \item \textbf{lineno:} Used to activate (|lineno=true| or simply |lineno|) or deactivate (|lineno=false|) line numbering inside the environment. +% \item \textbf{label:} Used to specify a name associated to the corresponding code. +% \end{itemize} +% The default behavior is to number each line of code. % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] @@ -458,8 +541,8 @@ % \fboxrule=\mgllinethickness% % \MGL@set@script@name{\mglverbatimname}% % \item[\MGL@line@sep]\hskip-\labelsep\MGL@line@sep% -% \refstepcounter{MGL@verb@script@no}% -% \addcontentsline{lms}{MGL@script}{\protect\numberline{\theMGL@verb@script@no.}{\ttfamily\protect\detokenize{\MGL@script@name}}}% +% \refstepcounter{MGL@verb@no}% +% \addcontentsline{lms}{MGL@script}{\protect\numberline{\theMGL@verb@no.}{\ttfamily\protect\detokenize{\MGL@script}}}% % \stepcounter{MGL@line@no}% % \item new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)' % \stepcounter{MGL@line@no}% @@ -475,35 +558,51 @@ % \end{quote} % \noindent If a |label| is specified, the output will look exactly as that of the |mglblock| environment. % -% \DescribeEnv{mglcomment} This environment is used to embed commentaries in the \LaTeX{} document. The commentary won't be visible in the case of the user passing the option |nocomments| to the package, but it will be typeset \emph{verbatim} to the document if the user passes the option |comments|. +% \DescribeEnv{mglcomment} This environment is used to embed comments. The comment won't be visible in the case of the user passing the option |nocomments| to the package, but it will be typeset \emph{verbatim} to the document if the user passes the option |comments|. % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] % |\begin{mglcomment}|\\[0.5em] -% \hss\meta{Commentary}\hss\\[0.5em] +% \hss\meta{Comment}\hss\\[0.5em] % |\end{mglcomment}|\\[0.25em] % \hline % \end{tabular} % \end{center} -% If the user requests visible commentaries, this will result in the appearance of something like the following in the \LaTeX{} document: +% If the user requests visible comments, this will result in the appearance of something like the following in the \LaTeX{} document: % \begin{quote} % \makeatletter % \list{}{}% % \MGL@set@pseudo@verb@env % \item\hskip-\labelsep<\MGL@dash@sep\mglcommentname\MGL@dash@sep>% -% \item This is a MGL commentary +% \item This is a mglTeX comment % \item\hskip-\labelsep<\MGL@dash@sep\mglcommentname\MGL@dash@sep>% % \endlist% % \end{quote} % % \subsection{Working with external scripts} -% \noindent External scripts exist in their own files, independently of the \LaTeX{} document ---for example, a script sent by a colleague, a script created before the actual writing of the \LaTeX{} document, etc. \textsf{\mglTeX} provides convenient ways to deal with external scripts, as if they were embedded. It must be noted, however, that the package works on the suposition that these scripts are in their final version, so no change detection is performed on them. If a external script is changed, the corresponding graphic must be manually deleted in oreder to force recompilation. +% \noindent \textsf{\mglTeX} provides convenient ways to deal with external scripts (scripts that exist in their own files, independently of the \LaTeX{} document, like scripts sent by a colleague or created before the actual writing of the \LaTeX{} document, etc). It must be noted, however, that the package works on the suposition that these scripts are in their final version, so no change detection is performed on them. If a external script is changed, the corresponding graphic must be manually deleted in oreder to force recompilation. +% +% \DescribeMacro{\mglgraphics} This command takes the name of an external MGL script as mandatory argument, which will be automatically executed, and the resulting image will be included. The same optional arguments accepted by this command are: +% \begin{itemize} +% \item \textbf{bb, bbllx, bblly, bburx, bbury, natwidth, natheight, hiresbb, viewport, trim, angle, origin, width, height, totalheight, keepaspectratio, clip, draft, type, ext, read, command:} These are the same options of the |\includegraphics| command from the \textsf{graphicx} package. +% \item \textbf{gray:} Can be used to activate (|gray=on| or |gray=1|) or deactivate (|gray=off| or |gray=0|) gray-scale mode privately (only for the current graphic). +% \item \textbf{mglscale:} Any positive value for this option is used to physically scale the resulting image file, i.g., |mglscale=2| will create an image file twice as bigger. +% \item \textbf{quality:} Sets the quality of the current graphic. Valid values are integers between |0| and |9|. +% \item \textbf{variant:} Sets the variant of argument for the commands in the current script. +% \item \textbf{imgext:} Can be used to set the extension for the current image. +% \item \textbf{path:} Can be used to specify the location of the script. +% \end{itemize} % -% \DescribeMacro{\mglinclude}\DescribeMacro{\mglinclude*} This command is the equivalent of the |mglverbatim| environment for external scripts. It takes one mandatory argument, which is the name of a MGL script, which will be automatically transcript \emph{verbatim} on the \LaTeX{} document. It accepts the same optional arguments as the |\mglgraphics| command, plus the |lineno| option to activate/deactivate line numbering. There are unstarred version of this command will be listed if |\listofmglscripts| is used, while the starred version won't. +% \DescribeMacro{\mglinclude}\DescribeMacro{\mglinclude*} This command is the equivalent of the |mglverbatim| environment for external scripts. It takes one mandatory argument, which is the name of a MGL script, which will be automatically transcript \emph{verbatim} on the \LaTeX{} document. It accepts the following optional arguments: +% \begin{itemize} +% \item \textbf{lineno:} Used to activate (|lineno=true| or simply |lineno|) or deactivate (|lineno=false|) line numbering inside the environment. +% \item \textbf{path:} Can be used to specify the location of the script. +% \end{itemize} +% The unstarred version of this command will be listed if |\listofmglscripts| is used (explained later), while the starred version won't. % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] -% |\mglinclude|\marg{script\_name}\oarg{key-val list}\\[0.25em] +% |\mglinclude|\oarg{key-val list}\marg{script\_name}\\[0.25em] % \hline % \end{tabular} % \end{center} @@ -515,32 +614,81 @@ % \end{tabular} % \end{center} % -% \DescribeMacro{\mglgraphics} This takes one mandatory argument, which is the name of an external MGL script, which will be automatically executed, and the resulting image will be included. The same optional arguments as the |\includegraphics| command are accepted, plus the |imgext| option to specify the extension of the resulting graphic, and an additional option, |path|, which can be used to specify the location of the script. +% \subsection{Additional commands} +% \DescribeMacro{\listofmglscripts}\noindent Opens a new section or chapter---depending on the \LaTeX{} class used---, where all the scripts that have been transcript in the document with the unstarred versions of the |mglblock| and |mglverbatim| environments, and the |\mglinclude| command, are listed. In case a |mglverbatim| is used, but no |label| is specified, the default name to display is specified by the |\mglverbatimname| macro (explained later), otherwise, the corresponding label is typeset. % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] -% |\mglgraphics|\oarg{key-val list}\marg{script\_name}\\[0.25em] +% |\listofmglscripts|\\[0.25em] % \hline % \end{tabular} % \end{center} +% The output is like this: +% \begin{center} +% \begin{minipage}{0.9\textwidth} +% \listofmglscripts +% \end{minipage} +% \end{center} % -% \subsection{Additional commands} -% \DescribeMacro{\mglname}\noindent This command can be used in the preamble of the document to indicate the name of the main script, passed as mandatory argument. If used after the |\begin{document}| command, it will force the closure of the current main script, create the corresponding graphics, and start a new script with the specified name. +% \DescribeMacro{\mglTeX}\DescribeMacro{\mglTeX*} This command just pretty-prints the name of the package, i.e., the logo: +% \begin{center} +% \Huge\mglTeX +% \end{center} +% The starred version will also print the version in a coherent manner. % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] -% |\mglname|\marg{main\_script\_name}\\[0.25em] +% |\mglTeX|\\[0.25em] +% \hline +% \end{tabular} +% \end{center} +% \begin{center} +% \begin{tabular}{l} +% \hline\\[-0.75em] +% |\mglTeX*|\\[0.25em] % \hline % \end{tabular} % \end{center} % -% The use of this command is encouraged when writing large documents, like books or thesis, to create a main script per document block (section, chapter, part, etc.). Since the |mgl| environment and the |\mglplot| command use an internal counter to automatically name scripts, unless the |label| option is used; if a new script is added this way to the document, it will alter the original numbering, causing \textsf{\mglTeX} to recompile the scripts from that point on (for more details, read subsection \ref{subsection: recompilation decision}). If the |\mglname| command is used, only the scripts of the current document block will be recompiled. +% In an environment where the typesetting of the logo is impossible (a text editor, for instance), it can (and should) be replaced by ``mglTeX''. +% +% \subsection{Local settings commands}\label{local setts} +% \noindent These commands are intended to be equivalent to the package options, but with a local-only effect, meaning that the new settings are applied from the point these commands are used onward. % -% \DescribeMacro{\mglimgext} Can be used to specify the extension to save graphics. Its effect is local, meaning that the new quality will be applied from the point this command is used~on. +% \DescribeMacro{\mglswitch} This command is equivalent to the package options |on| and |off|, depending on the argument passed. % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] -% |\mglimgext|\marg{image extension}\\[0.25em] +% |\mglswitch{|\meta{off\,$\vert$on\,$\vert$0\,$\vert$1}|}|\\[0.25em] +% \hline +% \end{tabular} +% \end{center} +% +% Observe that |\mglswitch{on}| and |\mglswitch{off}| can be used to save time when writing a document, wrapping a section with them, avoiding recompilation of the corresponding scripts. +% +% \DescribeMacro{\mglcomments} This command is equivalent to the package options |comments| and |nocomments|, depending on the argument passed. +% \begin{center} +% \begin{tabular}{l} +% \hline\\[-0.75em] +% |\mglcomments{|\meta{off\,$\vert$on\,$\vert$0\,$\vert$1}|}|\\[0.25em] +% \hline +% \end{tabular} +% \end{center} +% +% \DescribeMacro{\mglgray} It is equivalent to the package options |gray| and |color|, depending on the argument passed. +% \begin{center} +% \begin{tabular}{l} +% \hline\\[-0.75em] +% |\mglgray{|\meta{off\,$\vert$on\,$\vert$0\,$\vert$1}|}|\\[0.25em] +% \hline +% \end{tabular} +% \end{center} +% +% \DescribeMacro{\mglscale} Can be used to specify the default scaling for the creation of MGL graphics (1 is normal scaling, 2 is twice as bigger, etc.). +% \begin{center} +% \begin{tabular}{l} +% \hline\\[-0.75em] +% |\mglscale|\marg{$x:x>0$}\\[0.25em] % \hline % \end{tabular} % \end{center} @@ -572,6 +720,8 @@ % \hline % $8$ & Draw dots instead of primitives (extremely fast)\\ % \hline +% $9$ & No drawing (for testing purposes)\\ +% \hline % \end{tabular} % \MakeShortVerb{\|} % \end{center} @@ -579,72 +729,41 @@ % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] -% |\mglquality|\marg{0$\vert$1$\vert$\ldots$\vert$8}\\[0.25em] +% |\mglquality|\marg{0\,$\vert$1\,$\vert$\ldots\,$\vert$9}\\[0.25em] % \hline % \end{tabular} % \end{center} % -% \DescribeMacro{\mglscale} Can be used to specify the default scaling for the creation of MGL graphics (1 is normal scaling, 2 is twice as bigger, etc.). Its effect is local, meaning that the new scaling will be applied from the point this command is used on. Any non negative value can be specified. +% \DescribeMacro{\mglvariant} It is useful to set the default variant of arguments for MGL commands. % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] -% |\mglscale|\marg{1$\vert$2$\vert$\ldots$\vert$9}\\[0.25em] +% |\mglvariant|\marg{0\,$\vert$1\,$\vert$\ldots}\\[0.25em] % \hline % \end{tabular} % \end{center} % -% \DescribeMacro{\mglswitch} This command is equivalent to the package options |on| and |off|, depending on the argument passed, but it's effect is local. +% \DescribeMacro{\mglimgext} Can be used to specify the extension to save graphics. % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] -% |\mglswitch{|\meta{on$\vert$off}|}|\\[0.25em] +% |\mglimgext|\marg{image extension}\\[0.25em] % \hline % \end{tabular} % \end{center} % -% Observe that |\mglswitch{on}| and |\mglswitch{off}| can be used to save time when writing a document, wrapping a section with them, avoiding recompilation of the corresponding scripts. -% -% \DescribeMacro{\mglcomments} This command is equivalent to the package options |comments| and |nocomments|, depending on the argument passed, but its effect is local. +% \DescribeMacro{\mglname}\noindent If used in the preamble of the document this commands just sets the name of the. If used after the |\begin{document}| command, it will force the closure of the current main script, create the corresponding graphics, and start a new main script with the specified name. % \begin{center} % \begin{tabular}{l} % \hline\\[-0.75em] -% |\mglcomments{|\meta{on$\vert$off$\vert$true$\vert$false}|}|\\[0.25em] +% |\mglname|\marg{main\_script\_name}\\[0.25em] % \hline % \end{tabular} % \end{center} % -% \DescribeMacro{\listofmglscripts} Opens a new section or chapter---depending on the \LaTeX{} class used---, where all the scripts that have been transcript in the document with the unstarred versions of the |mglblock| and |mglverbatim| environments, and the |\mglinclude| command, are listed. In case a |mglverbatim| is used, but no |label| is specified, the default name to display is specified by the |\mglverbatimname| macro (see below), otherwise, the corresponding label is typeset. -% \begin{center} -% \begin{tabular}{l} -% \hline\\[-0.75em] -% |\listofmglscripts|\\[0.25em] -% \hline -% \end{tabular} -% \end{center} -% The output is like this: -% \begin{center} -% \begin{minipage}{0.9\textwidth} -% \listofmglscripts -% \end{minipage} -% \end{center} -% -% \DescribeMacro{\mglTeX}\DescribeMacro{\mglTeX*} This command just pretty-prints the name of the package; if followed by an asterisk, it will also print the version, separated with an unbreakable space. -% \begin{center} -% \begin{tabular}{l} -% \hline\\[-0.75em] -% |\mglTeX|\\[0.25em] -% \hline -% \end{tabular} -% \end{center} -% \begin{center} -% \begin{tabular}{l} -% \hline\\[-0.75em] -% |\mglTeX*|\\[0.25em] -% \hline -% \end{tabular} -% \end{center} +% The use of this command is encouraged when writing large documents, like books or thesis, to create a main script per document block (section, chapter, part, etc.). Since the |mgl| environment and the |\mglplot| command use an internal counter to automatically name scripts, unless the |label| option is used; if a new script is added this way to the document, it will alter the original numbering, causing \textsf{\mglTeX} to recompile the scripts from that point on (for more details, read subsection \ref{subsection: recompilation decision}). If the |\mglname| command is used, only the scripts of the current document block will be recompiled. % -% \subsection{Advanced setup commands} +% \subsection{Advanced settings commands} % \noindent Although \textsf{\mglTeX} is completely functional without any further set up, there are some parameters of its behavior that could be useful to modify. The following commands must be used in the preamble of the document only, since the first MGL script is created at the moment of the |\begin{document}| command, and otherwise they could create weird errors during compilation; trying to use them somewhere else will produce an error. % % \DescribeMacro{\mgldir} This command can be used to specify the main working directory for \textsf{\mglTeX}. Inside it, the scripts, backup files and graphics will be created, or can be separated inside subdirectories. This is useful, for example, to avoid many scripts and graphics from polluting the directory where the \LaTeX{} document is. @@ -695,7 +814,7 @@ % \end{center} % This command can be used many times or can be used to specify many paths at once. In the case of using it many times, each call will add the new directory or directories to the list of searching paths. % -% \DescribeMacro{mglsettings} This command has been added for the confort of the user, since it handles all of the basic and advanced settings of \textsf{\mglTeX}, as an alternative to some package options and commands. It takes one mandatory argument which should be a list of \meta{key}=\meta{value} pairs, according to the following table: +% \DescribeMacro{\mglsettings} This command has been added for the confort of the user, since it handles all of the basic and advanced settings of \textsf{\mglTeX}, as an alternative to some package options and commands. It takes one mandatory argument which should be a list of \meta{key}=\meta{value} pairs, according to the following table: % \begin{center} % \DeleteShortVerb{\|} % \begin{tabular}{|l|l|l|} @@ -713,9 +832,17 @@ % \hline % paths & \meta{directory list} & Paths to external scripts\\ % \hline -% quality & \meta{0$\vert$1$\vert$\ldots$\vert$8} & Quality for creation of graphics\\ +% switch & \meta{off\,$\vert$on\,$\vert$0\,$\vert$1} & Turn off/on \mglTeX\\ +% \hline +% comments & \meta{off\,$\vert$on\,$\vert$0\,$\vert$1} & Turn off/on comments\\ % \hline -% scale & \meta{1$\vert$2$\vert$\ldots$\vert$9} & Scale for creation of graphics\\ +% gray & \meta{off\,$\vert$on\,$\vert$0\,$\vert$1} & Turn off/on gray-scale mode\\ +% \hline +% mglscale & \meta{$x:x>0$} & Scale for creation of graphics\\ +% \hline +% quality & \meta{0\,$\vert$1\,$\vert$\ldots\,$\vert$9} & Quality for creation of graphics\\ +% \hline +% variant & \meta{0\,$\vert$1\,$\vert$\ldots} & Variant of arguments for MGL commands\\ % \hline % imgext & \meta{image extension} & Extension for creation of graphics\\ % \hline @@ -731,16 +858,16 @@ % \end{center} % % \subsection{User-definable macros} -% \noindent There are macros that the user is allowed to modify in order to customize some aspects of the behavior of \textsf{\mglTeX}. For example, if writing in spanish, french or russian, the user would like to modify the name of the common script, the words typeset in the separator lines of MGL commentaries, the name of the list of MGL scripts, etc. +% \noindent There are macros that the user is allowed to modify in order to customize some aspects of the behavior of \textsf{\mglTeX}. For example, if writing in spanish, french or russian, the user would like to modify the name of the common script, the words typeset in the separator lines of mglTeX comments, the name of the list of MGL scripts, etc. % -% \DescribeMacro{\mglcommonscriptname} It is the name for the common script that takes the contents of the |mglcommon| environment. The default name is defined by +% \DescribeMacro{\mglsetupscriptname} It is the name for the common setup script that takes the contents of the |mglseuptscipt| or |mglcommon| environments. The default name is defined by % \begin{quote} -% |\def\mglcommonscriptname{MGL_common_script}| +% |\def\mglsetupscriptname{MGL_setup_script}| % \end{quote} % -% \DescribeMacro{\mglcommentname} This macro expands to the words typeset before and after a MGL commentary, in the middle of the separator lines. The default words are set by +% \DescribeMacro{\mglcommentname} This macro expands to the words typeset before and after a \textsf{\mglTeX} comment, in the middle of the separator lines. The default words are set by % \begin{quote} -% |\def\mglcommentname{MGL commentary}| +% |\def\mglcommentname{\mglTeX{} comment}| % \end{quote} % % \DescribeMacro{\listofmglscriptsname} This is the name of the section/chapter created by the command |\listofmglscripts|. The default is set by @@ -841,18 +968,48 @@ % \StopEventually{\PrintChanges\PrintIndex} % % \section{Implementation} -% \noindent This section documents the complete implementation of \textsf{\mglTeX}. It's main purpose is to facilitate the understanding and maintanance of the package's code. For the following, we use ``|@|'' in the name of macros the user should not modify; the prefix ``|MGL|'' is used to simulate a namespace, so the macros from \textsf{\mglTeX} won't interfere with the ones from other packages. +% \noindent This section documents the complete code of \textsf{\mglTeX}. It's main purpose is to facilitate the understanding and maintanance of the package's code. For the following, we use ``|@|'' in the name of macros the user should not modify; the prefix ``|MGL|'' is used to simulate a namespace, so the macros from \textsf{\mglTeX} won't interfere with the ones from other packages. % -% \subsection{Initialization} +% \subsection{Initialization}\label{Init} % \noindent We first define some macros that will serve different purposes on different parts of the package. +% \begin{macro}{\MGL@off}\begin{macro}{\MGL@on}\begin{macro}{\MGL@zero}\begin{macro}{\MGL@one} +% These are used in the command |\MGL@test@switch| (explained later) to determine whether the user has passed one of the options |off|, |on|, |0| or |1| to a command. +% \begin{macrocode} +\def\MGL@off{off} +\def\MGL@on{on} +\def\MGL@zero{0} +\def\MGL@one{1} +% \end{macrocode} +% \end{macro}\end{macro}\end{macro}\end{macro} +% \begin{macro}{\MGL@test@switch} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New command to verify and validate switching arguments} +% It is called by a command to test whether the user has passed the option |off|, |on|, |0| (equivalent to |off|) or |1| (equivalent to |on|); if the option is correct, it is replaced by its equivalent, otherwise, a warning is issued. It takes two arguments: the first one is the option to test, the second one is the name of the command calling this macro. +% \begin{macrocode} +\def\MGL@test@switch#1#2{% + \def\MGL@temp@a{#1}% + \ifx\MGL@temp@a\MGL@on% + \else\ifx\MGL@temp@a\MGL@off% + \else\ifx\MGL@temp@a\MGL@one% + \def\MGL@temp@a{on}% + \else\ifx\MGL@temp@a\MGL@zero% + \def\MGL@temp@a{off}% + \else% + \PackageWarning{mgltex}{% + Unrecognizable option "#1" passed to command \protect#2% + }% + \fi\fi\fi\fi% +} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\MGL@TeX@ext} -% Is used to determine whether the user has chosen to save graphics in \LaTeX/Tikz format. +% Is used in the command |\MGL@includegraphics| (explained later) to determine whether the user has chosen to save graphics in \LaTeX/Tikz format. % \begin{macrocode} \def\MGL@TeX@ext{.tex} % \end{macrocode} % \end{macro} % -% The macros |\MGL@switch@on| and |\MGL@switch@off| are called when the package options |on| and |off| are passed, respectively. +% The macros |\MGL@switch@on| and |\MGL@switch@off| are called when the package options |on| and |off| are passed, respectively, or when the commands |\mglswitch{on}| and |\mglswitch{off}| are used, respectively. % \begin{macro}{\MGL@switch@on} % (Re)defines the commands to open, read, write and close scripts, and the command that includes MGL graphics. % \begin{macrocode} @@ -918,27 +1075,27 @@ % \begin{macrocode} \def\MGL@includegraphics{% % \end{macrocode} -% First checks if the image exists. Note the |\MGL@dir| and |\MGL@graphics@dir| macros are set by the user with the |\mgldir| and |\mglgraphicsdir| commands, respectively, while |\MGL@script@name| stores the name of the script ---and thus the image--- executed, and |\MGL@graph@ext| is the extension chosen by the user to save the graphics. +% First checks if the image exists. Note the |\MGL@dir| and |\MGL@graphics@dir| macros are set by the user with the |\mgldir| and |\mglgraphicsdir| commands, respectively, while |\MGL@script| stores the name of the script ---and thus the image--- executed, and |\MGL@imgext| is the extension chosen by the user to save the graphics. % \begin{macrocode} - \IfFileExists{\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext}{% + \IfFileExists{\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext}{% % \end{macrocode} % If the chosen extension is |.tex|, a \LaTeX/Tikz file has been created, which has to be simply included in the document; it will be automatically compiled by \LaTeX{}. (Observe we use the |\MGL@TeX@ext| macro defined above.) % \begin{macrocode} - \ifx\MGL@graph@ext\MGL@TeX@ext% - \include{\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext}% + \ifx\MGL@imgext\MGL@TeX@ext% + \include{\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext}% % \end{macrocode} % If the chosen extension is not |.tex|, a normal visual image has been created, so the |\includegraphics| command is invoked to deal with it. The options for this command (like |scale|, |angle|, etc.) are stored in the |\MGL@graph@keys| macro, which is defined by every environment or command that creates and compiles MGL scripts, according to the optional arguments the user has passed. % \begin{macrocode} \else% \expandafter\includegraphics\expandafter[\MGL@graph@keys]{% - \MGL@dir\MGL@graphics@dir\MGL@script@name% + \MGL@dir\MGL@graphics@dir\MGL@script% }% \fi% }{% % \end{macrocode} % If the requested image doesn't exist, the issue a warning message for the user, and print a warning framed box (``\textbf{MGL image not found}'') in the place the image should occupy. % \begin{macrocode} - \PackageWarning{mgltex}{MGL image "\MGL@script@name" not found}% + \PackageWarning{mgltex}{MGL image "\MGL@script" not found}% \fbox{% \centering% \bfseries\Huge% @@ -976,24 +1133,44 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\@MGL@comments@on}\begin{macro}{\@MGL@comments@off} -% We will need a boolean switch to activate/deactivate commentaries later. +% \begin{macro}{\@MGL@comments@off}\begin{macro}{\@MGL@comments@on} +% We will need a boolean switch to activate/deactivate comments later. % \begin{macrocode} +\def\@MGL@comments@off{\let\if@MGL@comments@\iffalse} \def\@MGL@comments@on{\let\if@MGL@comments@\iftrue} -\def\@MGL@comments@off{\let\if@mglcomments@\iffalse} % \end{macrocode} % \end{macro}\end{macro} % +% \begin{macro}{\MGL@gray}\begin{macro}{\MGL@gray@off}\begin{macro}{\MGL@gray@on} +% The commands |\MGL@gray@off| and |\MGL@gray@on| simply set the value of |\MGL@gray| to $0$ and $1$, respectively; this value will be used later through the |-g| command line option from |mglconv|. +% \begin{macrocode} + +\def\MGL@gray@off{\def\MGL@gray{0}} +\def\MGL@gray@on{\def\MGL@gray{1}} +% \end{macrocode} +% \end{macro}\end{macro}\end{macro} +% \begin{macro}{\mglgray} +% Depending on the option passed by the user, it calls |\@MGL@gray@on| or |\@MGL@gray@off|. +% \begin{macrocode} +\def\mglgray#1{% + \MGL@test@switch{#1}{\mglgray}% + \csname @MGL@gray@\MGL@temp@a\endcsname% +} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\mglscale}\begin{macro}{\MGL@scale} -% |\mglscale| sets the value of the |\MGL@scale| macro, which is used later to specify the default scaling for graphics. It only accepts integer values from $1$ to $9$, otherwise it issues a warning and restarts the scaling to $1$. In order to be able to check the validity of the value passed by the user, we first set the |\MGL@scale| macro to that value and test it with the |\ifcase| conditional; if the value is valid, we do nothing, but if it is invalid, we issue a warning and overwrite |\MGL@scale| to $1$. +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Now accepts any positive value} +% |\mglscale| sets the value of the |\MGL@scale| macro, which is used later to specify the default scaling for graphics. It only accepts positive values, otherwise it issues a warning and restarts the scaling to $1$. In order to be able to check the validity of the value passed by the user, we first set the |\MGL@scale| macro to that value and test it with the |\ifdim| conditional.\footnote{We can't use \doccommand{ifnum} here because it only accepts integer values.} Since this conditional tests dimensions only, the value passed by the user is multiplied by |\p@| (value |1pt|), so it can be compared with |\z@| (value |0pt|). % \begin{macrocode} \def\mglscale#1{ - \def\MGL@scale{#1}% - \ifcase\MGL@scale\or\or\or\or\or\or\or\or\else% + \ifdim#1\p@>\z@% + \def\MGL@scale{#1}% + \else% \PackageWarning{mgltex}{% - Scaling value of \MGL@scale\space not allowed; using default (1)% + Scaling value of #1\space not allowed; using default (1)% }% \def\MGL@scale{1}% \fi% @@ -1002,8 +1179,8 @@ % \end{macro}\end{macro} % % \begin{macro}{\mglquality}\begin{macro}{\MGL@quality} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{\texttt{9} is accepted as quality value now} % |\mglquality| sets the value of the |\MGL@quality| macro, which is used later to specify the default quality for graphics. It only accepts integer values from $0$ to $8$ (the only ones defined by |MathGL|), otherwise it issues a warning and restarts to $2$ (the default for |MathGL|). In order to be able to check the validity of the value passed by the user, we first set the |\MGL@quality| macro to that value and test it with the |\ifcase| conditional; if the value is valid, we print an info message to the |.log| file about the characteristics of the chosen quality, but if it is invalid, we issue a warning and overwrite |\MGL@scale| to $2$. -% \end{macro}\end{macro} % \begin{macrocode} \def\mglquality#1{% @@ -1026,11 +1203,13 @@ }% \or% \PackageInfo{mgltex}{% - Quality 4: No face drawing, direct bitmap drawing (low memory usage)% + Quality 4: No face drawing, direct bitmap drawing + (low memory usage)% }% \or% \PackageInfo{mgltex}{% - Quality 5: No color interpolation, direct bitmap drawing (low memory usage)% + Quality 5: No color interpolation, direct bitmap drawing + (low memory usage)% }% \or% \PackageInfo{mgltex}{% @@ -1038,12 +1217,17 @@ }% \or% \PackageInfo{mgltex}{% - Quality 7: High quality with 3d primitives, direct bitmap drawing (not implemented yet)% + Quality 7: High quality with 3d primitives, direct bitmap drawing % + (not implemented yet)% }% \or% \PackageInfo{mgltex}{% Quality 8: Draw dots instead of primitives (extremely fast)% }% + \or% + \PackageInfo{mgltex}{% + Quality 9: No drawing (for testing purposes)% + }% \else% \PackageWarning{mgltex}{% Quality #1 not available; using default (2)% @@ -1052,6 +1236,23 @@ \fi% } % \end{macrocode} +% \end{macro}\end{macro} +% +% \begin{macro}{\mglvariant}\begin{macro}{\MGL@variant} +% |\mglvariant| sets the value of the |\MGL@variant| macro, which is passed later to |mglconv| thorugh its |-v| command line option. It only accepts non-negative integer, otherwise it issues a warning and restarts to $0$ (the default for |MathGL|). In order to be able to check the validity of the value passed by the user, we use the |\ifnum| conditional; if the value is invalid we issue a warning and overwrite |\MGL@variant| to $0$. +% \begin{macrocode} + +\def\mglvariant#1{% + \def\MGL@variant{#1}% + \ifnum\MGL@variant<0% + \PackageWarning{mgltex}{% + Variant #1 not allowed; using default (0)% + }% + \def\MGL@variant{0}% + \fi% +} +% \end{macrocode} +% \end{macro}\end{macro} % % Now we declare the options |final| and |draft|, which are simply passed to the \textsf{graphicx} package. % \begin{macrocode} @@ -1063,57 +1264,61 @@ \PassOptionsToPackage{\CurrentOption}{graphicx}% } % \end{macrocode} -% Now we can declare the package options |on| and |off| so that they execute |\MGL@switch@on| and |\MGL@switch@off|, respectively. +% +% The rest of the package options just call an adequate command or set an adequate value for a macro. % \begin{macrocode} + \DeclareOption{on}{\MGL@switch@on} \DeclareOption{off}{\MGL@switch@off} -% \end{macrocode} -% Now, the options call the respective commands. -% \begin{macrocode} + \DeclareOption{nocomments}{\@MGL@comments@off} \DeclareOption{comments}{\@MGL@comments@on} -% \end{macrocode} -% The pacakage options |1x|, \ldots, |9x| just call |\mglscale| with the appropiate value. -% \begin{macrocode} -\DeclareOption{1x}{\mglscale{1}} -\DeclareOption{2x}{\mglscale{2}} -\DeclareOption{3x}{\mglscale{3}} -\DeclareOption{4x}{\mglscale{4}} -\DeclareOption{5x}{\mglscale{5}} -\DeclareOption{6x}{\mglscale{6}} -\DeclareOption{7x}{\mglscale{7}} -\DeclareOption{8x}{\mglscale{8}} -\DeclareOption{9x}{\mglscale{9}} -% \end{macrocode} -% The package options |0q|, \ldots, |8q| just call |\mglquality| with the appropiate value. -% \begin{macrocode} -\DeclareOption{0q}{\mglquality{0}} -\DeclareOption{1q}{\mglquality{1}} -\DeclareOption{2q}{\mglquality{2}} -\DeclareOption{3q}{\mglquality{3}} -\DeclareOption{4q}{\mglquality{4}} -\DeclareOption{5q}{\mglquality{5}} -\DeclareOption{6q}{\mglquality{6}} -\DeclareOption{7q}{\mglquality{7}} -\DeclareOption{8q}{\mglquality{8}} -% \end{macrocode} -% -% \begin{macro}{\MGL@graph@ext} -% The following options set the default graphics extension, which is stored in the |\MGL@graph@ext| macro for later use. -% \begin{macrocode} - -\DeclareOption{eps}{\def\MGL@graph@ext{.eps}} -\DeclareOption{epsz}{\def\MGL@graph@ext{.epsz}} -\DeclareOption{epsgz}{\def\MGL@graph@ext{.eps.gz}} -\DeclareOption{bps}{\def\MGL@graph@ext{.bps}} -\DeclareOption{bpsz}{\def\MGL@graph@ext{.bpsz}} -\DeclareOption{bpsgz}{\def\MGL@graph@ext{.bps.gz}} -\DeclareOption{pdf}{\def\MGL@graph@ext{.pdf}} -\DeclareOption{png}{\def\MGL@graph@ext{.png}} -\DeclareOption{jpg}{\def\MGL@graph@ext{.jpg}} -\DeclareOption{jpeg}{\def\MGL@graph@ext{.jpeg}} -\DeclareOption{gif}{\def\MGL@graph@ext{.gif}} -\DeclareOption{tex}{\def\MGL@graph@ext{.tex}} + +\DeclareOption{gray}{\MGL@gray@on} +\DeclareOption{color}{\MGL@gray@off} + +\DeclareOption{1x}{\def\MGL@scale{1}} +\DeclareOption{2x}{\def\MGL@scale{2}} +\DeclareOption{3x}{\def\MGL@scale{3}} +\DeclareOption{4x}{\def\MGL@scale{4}} +\DeclareOption{5x}{\def\MGL@scale{5}} +\DeclareOption{6x}{\def\MGL@scale{6}} +\DeclareOption{7x}{\def\MGL@scale{7}} +\DeclareOption{8x}{\def\MGL@scale{8}} +\DeclareOption{9x}{\def\MGL@scale{9}} + +\DeclareOption{0q}{\def\MGL@quality{0}} +\DeclareOption{1q}{\def\MGL@quality{1}} +\DeclareOption{2q}{\def\MGL@quality{2}} +\DeclareOption{3q}{\def\MGL@quality{3}} +\DeclareOption{4q}{\def\MGL@quality{4}} +\DeclareOption{5q}{\def\MGL@quality{5}} +\DeclareOption{6q}{\def\MGL@quality{6}} +\DeclareOption{7q}{\def\MGL@quality{7}} +\DeclareOption{8q}{\def\MGL@quality{8}} +\DeclareOption{9q}{\def\MGL@quality{9}} + +\DeclareOption{0v}{\def\MGL@variant{0}} +\DeclareOption{1v}{\def\MGL@variant{1}} +\DeclareOption{2v}{\def\MGL@variant{2}} +% \end{macrocode} +% +% \begin{macro}{\MGL@imgext} +% The following options set the default graphics extension, which is stored in the |\MGL@imgext| macro for later use. +% \begin{macrocode} + +\DeclareOption{eps}{\def\MGL@imgext{.eps}} +\DeclareOption{epsz}{\def\MGL@imgext{.epsz}} +\DeclareOption{epsgz}{\def\MGL@imgext{.eps.gz}} +\DeclareOption{bps}{\def\MGL@imgext{.bps}} +\DeclareOption{bpsz}{\def\MGL@imgext{.bpsz}} +\DeclareOption{bpsgz}{\def\MGL@imgext{.bps.gz}} +\DeclareOption{pdf}{\def\MGL@imgext{.pdf}} +\DeclareOption{png}{\def\MGL@imgext{.png}} +\DeclareOption{jpg}{\def\MGL@imgext{.jpg}} +\DeclareOption{jpeg}{\def\MGL@imgext{.jpeg}} +\DeclareOption{gif}{\def\MGL@imgext{.gif}} +\DeclareOption{tex}{\def\MGL@imgext{.tex}} % \end{macrocode} % \end{macro} % @@ -1126,65 +1331,10 @@ % We now declare the default package options, and, finally, process the options the user specifies in the order they are introduced. % \begin{macrocode} -\ExecuteOptions{final,on,nocomments,1x,2q,eps} +\ExecuteOptions{final,on,nocomments,color,1x,2q,0v,eps} \ProcessOptions* % \end{macrocode} % -% \textsf{\mglTeX} requires the \textsf{keyval} package to define \meta{key}=\meta{value} options for the environments and commands; the \textsf{graphicx} package apports the facilities for inclusion of graphics, and the \textsf{verbatim} package is used as engine for the environments. -% \begin{macrocode} - -\RequirePackage{keyval} -\RequirePackage{graphicx} -\RequirePackage{verbatim} -% \end{macrocode} -% -% \begin{macro}{\MGL@graph@keys} -% The main family of \meta{key}=\meta{value} pairs is defined. These pairs are common to every environment or command that produces graphics. Most of the \meta{key}'s are redefinitions of the optional arguments for the |\includegraphics| commands, so they are stored inside the |\MGL@graph@keys| macro, which is later passed to that command as optional argument by |\MGL@includegraphics|. -% \begin{macrocode} - -\define@key{MGL@keys}{bb}{\g@addto@macro\MGL@graph@keys{bb=#1,}} -\define@key{MGL@keys}{bbllx}{\g@addto@macro\MGL@graph@keys{bbllx=#1,}} -\define@key{MGL@keys}{bblly}{\g@addto@macro\MGL@graph@keys{bblly=#1,}} -\define@key{MGL@keys}{bburx}{\g@addto@macro\MGL@graph@keys{bburx=#1,}} -\define@key{MGL@keys}{bbury}{\g@addto@macro\MGL@graph@keys{bbury=#1,}} -\define@key{MGL@keys}{natwidth}{\g@addto@macro\MGL@graph@keys{natwidth=#1,}} -\define@key{MGL@keys}{natheight}{\g@addto@macro\MGL@graph@keys{natheight=#1,}} -\define@key{MGL@keys}{hiresbb}{\g@addto@macro\MGL@graph@keys{hiresbb=#1,}} -\define@key{MGL@keys}{viewport}{\g@addto@macro\MGL@graph@keys{viewport=#1,}} -\define@key{MGL@keys}{trim}{\g@addto@macro\MGL@graph@keys{trim=#1,}} -\define@key{MGL@keys}{angle}{\g@addto@macro\MGL@graph@keys{angle=#1,}} -\define@key{MGL@keys}{origin}{\g@addto@macro\MGL@graph@keys{origin=#1,}} -\define@key{MGL@keys}{width}{\g@addto@macro\MGL@graph@keys{width=#1,}} -\define@key{MGL@keys}{height}{\g@addto@macro\MGL@graph@keys{height=#1,}} -\define@key{MGL@keys}{totalheight}{\g@addto@macro\MGL@graph@keys{totalheight=#1,}} -\define@key{MGL@keys}{keepaspectratio}[true]{% - \g@addto@macro\MGL@graph@keys{keepaspectratio=#1,}% -} -\define@key{MGL@keys}{scale}{\g@addto@macro\MGL@graph@keys{scale=#1,}} -\define@key{MGL@keys}{clip}[true]{\g@addto@macro\MGL@graph@keys{clip=#1,}} -\define@key{MGL@keys}{draft}[true]{\g@addto@macro\MGL@graph@keys{draft=#1,}} -\define@key{MGL@keys}{type}{\g@addto@macro\MGL@graph@keys{type=#1,}} -\define@key{MGL@keys}{ext}{\g@addto@macro\MGL@graph@keys{ext=#1,}} -\define@key{MGL@keys}{read}{\g@addto@macro\MGL@graph@keys{read=#1,}} -\define@key{MGL@keys}{command}{\g@addto@macro\MGL@graph@keys{command=#1,}} -% \end{macrocode} -% \end{macro} -% \begin{macro}{\MGL@graph@ext} -% Stores the default extension for the creation of the graphics. -% \begin{macrocode} -\define@key{MGL@keys}{imgext}{\def\MGL@graph@ext{.#1}} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@MGL@lineno@} -% The only \meta{key}=\meta{value} pair needed for verbatim-like environments and commands is the one for the |lineno| option, which sets the value of the |\@MGL@lineno@| boolean macro. -% \begin{macrocode} - -\newif\if@MGL@lineno@ -\define@key{MGL@verb@keys}{lineno}[true]{\csname @MGL@lineno@#1\endcsname} -% \end{macrocode} -% \end{macro} -% % \begin{macro}{\MGL@dir} % This is the \textsf{\mglTeX} main working directory. By default, it is defined to empty, so it points to the path of the \LaTeX{} document. % \begin{macrocode} @@ -1216,24 +1366,6 @@ \def\MGL@paths{\MGL@dir\MGL@scripts@dir,\MGL@dir\MGL@backups@dir} % \end{macrocode} % \end{macro} -% \begin{macro}{\mglsettings} -% First, we define a \meta{key}=\meta{value} family, |MGL@sett@keys|, for the |\mglsettings| command. -% \begin{macrocode} -\define@key{MGL@sett@keys}{dir}{\def\MGL@dir{#1}} -\define@key{MGL@sett@keys}{scriptsdir}{\def\MGL@scripts@dir{#1}} -\define@key{MGL@sett@keys}{graphicsdir}{\def\MGL@graphics@dir{#1}} -\define@key{MGL@sett@keys}{backupsdir}{\def\MGL@backups@dir{#1}} -\define@key{MGL@sett@keys}{paths}{\g@addto@macro\MGL@paths{,#1}} -\define@key{MGL@sett@keys}{quality}{\mglquality{#1}} -\define@key{MGL@sett@keys}{scale}{\mglscale{#1}} -\define@key{MGL@sett@keys}{imgext}{\def\MGL@graph@ext{.#1}} -% \end{macrocode} -% The command receives and executes the \meta{key}=\meta{value} pairs for |MGL@sett@keys|. This is an only-preamble command. -% \begin{macrocode} -\def\mglsettings#1{\setkeys{MGL@sett@keys}{#1}} -\@onlypreamble\mglsettings -% \end{macrocode} -% \end{macro} % % \begin{macro}{\MGL@main@script@name} % \noindent This macro stores the name of the of the document's main script. It is initialized to the name of the \LaTeX{} document. @@ -1275,10 +1407,10 @@ \newcounter{MGL@line@no} % \end{macrocode} % \end{macro} -% \begin{macro}{MGL@verb@script@no} +% \begin{macro}{MGL@verb@no} % The counter used to numerate verbatim-written scripts with the |\listofmglscripts| command. % \begin{macrocode} -\newcounter{MGL@verb@script@no} +\newcounter{MGL@verb@no} % \end{macrocode} % \end{macro} % \begin{macro}{\@MGL@list@script@} @@ -1293,11 +1425,30 @@ \def\l@MGL@script{\@dottedtocline{1}{0em}{1.5em}} % \end{macrocode} % \end{macro} -% Finally, the supported graphic formats are declared, and the |\verbatim@finish| command from the \textsf{verbatim} package is disabled to avoid it from writing a blank line at the end of every script (see subsection~\ref{subsection: warning}). +% +% \textsf{\mglTeX} requires the \textsf{keyval} package to define \meta{key}=\meta{value} options for the environments and commands; the \textsf{graphicx} package apports the facilities for inclusion of graphics; the \textsf{ifpdf} package is used to determine whether the user is compiling to |pdf| or not when indicating the default graphics extensionsthe \textsf{verbatim} package is used as engine for the environments. +% \begin{macrocode} + +\RequirePackage{keyval} +\RequirePackage{graphicx} +\RequirePackage{ifpdf} +\RequirePackage{verbatim} +% \end{macrocode} +% +% The supported graphic extensions are declared. These extensions depend on whether we are compiling to |pdf| or not, so the |\ifpdf| conditional from the homonym package is used. +% \begin{macrocode} +\ifpdf% + \DeclareGraphicsExtensions{% + .pdf,.png,.jpg,.jpeg,.gif% + }% +\else% + \DeclareGraphicsExtensions{% + .eps,.epsz,.eps.gz,.bps,.bpsz,.bps.gz% + }% +\fi% +% \end{macrocode} +% Finally, the |\verbatim@finish| command from the \textsf{verbatim} package is disabled to avoid it from writing a blank line at the end of every script (see subsection~\ref{subsection: warning}). % \begin{macrocode} -\DeclareGraphicsExtensions{% - .eps,.epsz,.eps.gz,.bps,.bpsz,.bps.gz,.pdf,.png,.jpg,.jpeg,.gif% -} \let\verbatim@finish\relax % \end{macrocode} % @@ -1315,35 +1466,135 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\MGL@graph@keys} +% The main family of \meta{key}=\meta{value} pairs is defined. These pairs are common to every environment or command that produces graphics. Most of the \meta{key}'s are redefinitions of the optional arguments for the |\includegraphics| commands, so they are stored inside the |\MGL@graph@keys| macro, which is later passed to that command as optional argument by |\MGL@includegraphics|. +% \begin{macrocode} + +\define@key{MGL@gr@keys}{bb}{% + \g@addto@macro\MGL@graph@keys{bb=#1,}% +} +\define@key{MGL@gr@keys}{bbllx}{% + \g@addto@macro\MGL@graph@keys{bbllx=#1,}% +} +\define@key{MGL@gr@keys}{bblly}{% + \g@addto@macro\MGL@graph@keys{bblly=#1,}% +} +\define@key{MGL@gr@keys}{bburx}{% + \g@addto@macro\MGL@graph@keys{bburx=#1,}% +} +\define@key{MGL@gr@keys}{bbury}{% + \g@addto@macro\MGL@graph@keys{bbury=#1,}% +} +\define@key{MGL@gr@keys}{natwidth}{% + \g@addto@macro\MGL@graph@keys{natwidth=#1,}% +} +\define@key{MGL@gr@keys}{natheight}{% + \g@addto@macro\MGL@graph@keys{natheight=#1,}% +} +\define@key{MGL@gr@keys}{hiresbb}{% + \g@addto@macro\MGL@graph@keys{hiresbb=#1,}% +} +\define@key{MGL@gr@keys}{viewport}{% + \g@addto@macro\MGL@graph@keys{viewport=#1,}% +} +\define@key{MGL@gr@keys}{trim}{% + \g@addto@macro\MGL@graph@keys{trim=#1,}% +} +\define@key{MGL@gr@keys}{angle}{% + \g@addto@macro\MGL@graph@keys{angle=#1,}% +} +\define@key{MGL@gr@keys}{origin}{% + \g@addto@macro\MGL@graph@keys{origin=#1,}% +} +\define@key{MGL@gr@keys}{width}{% + \g@addto@macro\MGL@graph@keys{width=#1,}% +} +\define@key{MGL@gr@keys}{height}{% + \g@addto@macro\MGL@graph@keys{height=#1,}% +} +\define@key{MGL@gr@keys}{totalheight}{% + \g@addto@macro\MGL@graph@keys{totalheight=#1,}% +} +\define@key{MGL@gr@keys}{keepaspectratio}[true]{% + \g@addto@macro\MGL@graph@keys{keepaspectratio=#1,}% +} +\define@key{MGL@gr@keys}{scale}{% + \g@addto@macro\MGL@graph@keys{scale=#1,}% +} +\define@key{MGL@gr@keys}{clip}[true]{% + \g@addto@macro\MGL@graph@keys{clip=#1,}% +} +\define@key{MGL@gr@keys}{draft}[true]{% + \g@addto@macro\MGL@graph@keys{draft=#1,}% +} +\define@key{MGL@gr@keys}{type}{% + \g@addto@macro\MGL@graph@keys{type=#1,}% +} +\define@key{MGL@gr@keys}{ext}{% + \g@addto@macro\MGL@graph@keys{ext=#1,}% +} +\define@key{MGL@gr@keys}{read}{% + \g@addto@macro\MGL@graph@keys{read=#1,}% +} +\define@key{MGL@gr@keys}{command}{% + \g@addto@macro\MGL@graph@keys{command=#1,}% +} +% \end{macrocode} +% \end{macro} +% The following four \meta{key}=\meta{value} pairs call the adequate \textsf{\mglTeX} command. +% \begin{macrocode} +\define@key{MGL@gr@keys}{gray}[0]{\mglgray{#1}} +\define@key{MGL@gr@keys}{mglscale}{\mglscale{#1}} +\define@key{MGL@gr@keys}{quality}{\mglquality{#1}} +\define@key{MGL@gr@keys}{variant}{\mglvariant{#1}} +% \end{macrocode} +% \begin{macro}{\MGL@imgext} +% |\MGL@imgext| stores the default extension for the creation of the graphics. +% \begin{macrocode} +\define@key{MGL@gr@keys}{imgext}{\def\MGL@imgext{.#1}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@MGL@lineno@} +% The only \meta{key}=\meta{value} pair needed for verbatim-like environments and commands is the one for the |lineno| option, which sets the value of the |\@MGL@lineno@| boolean macro. +% \begin{macrocode} + +\newif\if@MGL@lineno@ +\define@key{MGL@verb@keys}{lineno}[true]{\csname @MGL@lineno@#1\endcsname} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\MGL@codes} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Bugfix: category code for tabulators is changed too} % This macro changes the category codes of all special characters (like |\|, |$|, etc.) to $12$ (other), so they don't have any special meaning and can be processed as normal text. The exception is the new line character (|^^M|), which is kept active for compatibility with the \textsf{verbatim} package. % \begin{macrocode} \def\MGL@codes{% \let\do\@makeother\dospecials% + \catcode`\^^I=12% \catcode`\^^M\active% } % \end{macrocode} % \end{macro} % -% \begin{macro}{\MGL@document@scripts} +% \begin{macro}{\MGL@doc@scripts} % A macro to store the names of the scripts created or compiled in the document. % \begin{macrocode} -\def\MGL@document@scripts{} +\def\MGL@doc@scripts{} % \end{macrocode} % \end{macro} -% \begin{macro}{\MGL@set@script@name}\begin{macro}{\MGL@script@name} -% |\MGL@set@script@name| receives the name of a script without extension as argument, defines |\MGL@script@name| as that name, and checks if it has already been created or compiled, by comparing it with the names already stored in |\MGL@document@scripts|; if it's there already, warns the user. Finally, adds the name of the script to |\MGL@document@scripts|. +% \begin{macro}{\MGL@set@script@name}\begin{macro}{\MGL@script} +% |\MGL@set@script@name| receives the name of a script without extension as argument, defines |\MGL@script| as that name, and checks if it has already been created or compiled, by comparing it with the names already stored in |\MGL@doc@scripts|; if it's there already, warns the user. Finally, adds the name of the script to |\MGL@doc@scripts|. % \begin{macrocode} \def\MGL@set@script@name#1{% - \edef\MGL@script@name{#1}% - \@for\MGL@temp@a:=\MGL@document@scripts\do{% - \ifx\MGL@temp@a\MGL@script@name% - \PackageWarning{mgltex}{Multiple MGL scripts named "\MGL@script@name.mgl"}% + \edef\MGL@script{#1}% + \@for\MGL@temp@a:=\MGL@doc@scripts\do{% + \ifx\MGL@temp@a\MGL@script% + \PackageWarning{mgltex}{Multiple MGL scripts named "\MGL@script.mgl"}% \fi% }% - \g@addto@macro\MGL@document@scripts{\MGL@script@name,}% + \g@addto@macro\MGL@doc@scripts{\MGL@script,}% } % \end{macrocode} % \end{macro}\end{macro} @@ -1359,14 +1610,14 @@ % \end{macro} % % \begin{macro}{\MGL@process@script} -% It checks whether the ``switch'' |\MGL@@@\MGL@script@name| is undefined, in which case executes its first argument. If the switch is defined, it checks if the corresponding image has been created; if so, it executes its second argument; otherwise, the first one. +% It checks whether the ``switch'' |\MGL@@@\MGL@script| is undefined, in which case executes its first argument. If the switch is defined, it checks if the corresponding image has been created; if so, it executes its second argument; otherwise, the first one. % \begin{macrocode} \def\MGL@process@script#1#2{% - \@ifundefined{MGL@@@\MGL@script@name}{% + \@ifundefined{MGL@@@\MGL@script}{% #1% }{% - \IfFileExists{\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext}{% + \IfFileExists{\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext}{% #2% }{% #1% @@ -1420,11 +1671,11 @@ \def\MGL@compare@code#1{% % \end{macrocode} % \begin{macro}{\MGL@next} -% This macro is called at the end of environments that use the |\MGL@compare@code| macro, and performs the ending actions of the comparision process, which are closing the |\MGL@in@stream| and writing the |\MGL@unchanged{\MGL@script@name}| to the |.aux| file. If during the comparison process a difference in the code is found, |\MGL@next| is redefined to only close the |\MGL@in@stream|. +% This macro is called at the end of environments that use the |\MGL@compare@code| macro, and performs the ending actions of the comparision process, which are closing the |\MGL@in@stream| and writing the |\MGL@unchanged{\MGL@script}| to the |.aux| file. If during the comparison process a difference in the code is found, |\MGL@next| is redefined to only close the |\MGL@in@stream|. % \begin{macrocode} \def\MGL@next{% \MGL@closein\MGL@in@stream% - \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script@name}}% + \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script}}% }% % \end{macrocode} % \end{macro} @@ -1574,6 +1825,7 @@ % \noindent For the following, we agree that if a macro is required by an environment, and it hasn't been already defined, it will be defined between the commands that start and end such environment; also the command's name will have the environment's name as prefix. % % \begin{environment}{mgl} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New environment options: \texttt{gray}, \texttt{mglscale}, \texttt{quality}, \texttt{variant}} % This environment has to transcript its contents to the document's main script, and create a backup of the code simultaneously; the backup is used to detect changes in following compilations. % \begin{macro}{\mgl} % The command that starts the |mgl| environment. It is called by the |\begin{mgl}| command. @@ -1583,22 +1835,22 @@ % \end{macrocode} % We define an additional \meta{key}=\meta{value} pair in the main family of pairs, corresponding to the |label| option for this environment. This definition is local because we don't want to be valid outside the environment. % \begin{macrocode} - \define@key{MGL@keys}{label}{\def\MGL@script@name{##1}}% + \define@key{MGL@gr@keys}{label}{\def\MGL@script{##1}}% % \end{macrocode} % The list of comma-separated options is processed. % \begin{macrocode} - \MGL@setkeys{MGL@keys}{#1}% + \MGL@setkeys{MGL@gr@keys}{#1}% % \end{macrocode} % If the user hasn't used the |label| option, the automatic naming mechanism is called. Note that |\MGL@main@script@name| is set using the |\mglname| command. % \begin{macrocode} - \@ifundefined{MGL@script@name}{% + \@ifundefined{MGL@script}{% \stepcounter{MGL@script@no}% - \edef\MGL@script@name{\MGL@main@script@name-MGL-\arabic{MGL@script@no}}% + \edef\MGL@script{\MGL@main@script@name-MGL-\arabic{MGL@script@no}}% }{}% % \end{macrocode} % We use the |\MGL@set@script@name| to test whether the given name has already been used. % \begin{macrocode} - \MGL@set@script@name{\MGL@script@name}% + \MGL@set@script@name{\MGL@script}% % \end{macrocode} % |\MGL@codes| is used to change the codes of special characters. % \begin{macrocode} @@ -1609,7 +1861,7 @@ \MGL@process@script{% \MGL@write@script% }{% - \MGL@compare@code{\MGL@dir\MGL@backups@dir\MGL@script@name.mgl}% + \MGL@compare@code{\MGL@dir\MGL@backups@dir\MGL@script.mgl}% }% } % \end{macrocode} @@ -1620,15 +1872,15 @@ \def\MGL@write@script{% % \end{macrocode} % \begin{macro}{\MGL@next} -% It contains the actions to perform immediately after the end of |\MGL@write@script|. They are close the output stream; write in the main script the commands to save the image, and to reset the initial values for all MGL parameters and clear the image; finally, write |\MGL@unchanged{\MGL@script@name}| in the |.aux| file. +% It contains the actions to perform immediately after the end of |\MGL@write@script|. They are close the output stream; write in the main script the commands to save the image, and to reset the initial values for all MGL parameters and clear the image; finally, write |\MGL@unchanged{\MGL@script}| in the |.aux| file. % \begin{macrocode} \def\MGL@next{% \MGL@closeout\MGL@out@stream% \MGL@write\MGL@main@stream{% - write '\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext'^^J% + write '\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext'^^J% ^^Jreset^^J% }% - \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script@name}}% + \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script}}% }% % \end{macrocode} % \end{macro} @@ -1639,13 +1891,18 @@ \MGL@write\MGL@out@stream{\the\verbatim@line}% }% % \end{macrocode} -% Before writing the MGL code of the environment, we set the default quality. +% Before writing the MGL code of the environment, we set the default gray/color mode, mglscale, quality and variant. % \begin{macrocode} - \MGL@write\MGL@main@stream{quality \MGL@quality}% + \MGL@write\MGL@main@stream{% + gray \MGL@gray^^J% + setsizescl \MGL@scale^^J% + quality \MGL@quality^^J% + variant \MGL@variant% + }% % \end{macrocode} % We open the backup file in the output stream. % \begin{macrocode} - \MGL@openout\MGL@out@stream{\MGL@dir\MGL@backups@dir\MGL@script@name.mgl}% + \MGL@openout\MGL@out@stream{\MGL@dir\MGL@backups@dir\MGL@script.mgl}% % \end{macrocode} % The transcription process starts by calling the |\verbatim@start| command. % \begin{macrocode} @@ -1718,11 +1975,11 @@ % \end{macrocode} % The backup file is opened for writing. % \begin{macrocode} - \MGL@openout\MGL@out@stream{\MGL@dir\MGL@backups@dir\MGL@script@name.mgl}% + \MGL@openout\MGL@out@stream{\MGL@dir\MGL@backups@dir\MGL@script.mgl}% % \end{macrocode} % The head of the function is written. % \begin{macrocode} - \MGL@write\MGL@out@stream{func '\MGL@script@name' #1}% + \MGL@write\MGL@out@stream{func '\MGL@script' #1}% % \end{macrocode} % The writing process is started. % \begin{macrocode} @@ -1752,19 +2009,20 @@ % \end{environment} % % \begin{environment}{mglcode} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New environment options: \texttt{gray}, \texttt{mglscale}, \texttt{quality}, \texttt{variant}} % This environment also checks for changes on the code, but, since it writes to its own script, there is no need to create a backup file (the check is performed using the script itself). % \begin{macro}{\mglcode} % It starts the |mglcode| environment. Its anatomy is similar to that of the |\mgl| command. % \begin{macrocode} \newcommand\mglcode[2][]{% - \MGL@setkeys{MGL@keys}{#1}% + \MGL@setkeys{MGL@gr@keys}{#1}% \MGL@set@script@name{#2}% \MGL@codes% \MGL@process@script{% \mglcode@write@script% }{% - \MGL@compare@code{\MGL@dir\MGL@scripts@dir\MGL@script@name.mgl}% + \MGL@compare@code{\MGL@dir\MGL@scripts@dir\MGL@script.mgl}% }% } % \end{macrocode} @@ -1783,17 +2041,18 @@ % \begin{macrocode} \MGL@closeout\MGL@out@stream% % \end{macrocode} -% The |\MGL@unchanged{\MGL@script@name}| command is written to the |.aux| file. +% The |\MGL@unchanged{\MGL@script}| command is written to the |.aux| file. % \begin{macrocode} - \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script@name}}% + \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script}}% % \end{macrocode} % The script compilation instruction is written to the terminal. % \begin{macrocode} \MGL@write{18}{% - mglconv -q \MGL@quality\space -S \MGL@scale\space% - -s "\MGL@dir\MGL@scripts@dir\mglcommonscriptname.mgl"\space% - -o "\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext"\space% - "\MGL@dir\MGL@scripts@dir\MGL@script@name.mgl"% + mglconv -q \MGL@quality\space -g \MGL@gray\space% + -S \MGL@scale\space -v \MGL@variant\space% + -s "\MGL@dir\MGL@scripts@dir\mglsetupscriptname.mgl"\space% + -o "\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext"\space% + "\MGL@dir\MGL@scripts@dir\MGL@script.mgl"% }% }% % \end{macrocode} @@ -1804,7 +2063,7 @@ % \end{macrocode} % The script is opened for writing in the output stream. % \begin{macrocode} - \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script@name.mgl}% + \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script.mgl}% % \end{macrocode} % The writing process is started by calling the |\verbatim@start| command. % \begin{macrocode} @@ -1833,7 +2092,7 @@ \MGL@set@script@name{#1}% \MGL@codes% \def\verbatim@processline{\MGL@write\MGL@out@stream{\the\verbatim@line}}% - \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script@name.mgl}% + \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script.mgl}% \verbatim@start% } % \end{macrocode} @@ -1849,42 +2108,55 @@ % \end{macro} % \end{environment} % -% \begin{environment}{mglcommon} -% This environment doesn't require any backup file nor any scanning for changes. Although the user sets the name of the script by redifining |\mglcommonscriptname|, it is necessary to perform a check of the name, just in case a name has been inadvertedly repeated. -% \begin{macro}{\mglcommon} -% Starts the |mglcommon| environment. +% \begin{environment}{mglsetupscript}\begin{environment}{mglcommon} +% This environment doesn't require any backup file nor any scanning for changes. Although the user sets the name of the script by redifining |\mglsetupscriptname|, it is necessary to perform a check of the name, just in case a name has been inadvertedly repeated. +% \begin{macro}{\mglsetupscript} +% Starts the |mglsetupscript| environment. % \begin{macrocode} -\def\mglcommon{% +\def\mglsetupscript{% \@bsphack% - \MGL@set@script@name{\mglcommonscriptname}% + \MGL@set@script@name{\mglsetupscriptname}% \MGL@codes% \def\verbatim@processline{\MGL@write\MGL@out@stream{\the\verbatim@line}}% - \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script@name.mgl}% + \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script.mgl}% \verbatim@start% } % \end{macrocode} % It is declared to be an only-preamble command, so it can't be used after the |\begin{document}| instruction. % \begin{macrocode} +\@onlypreamble\mglsetupscript +% \end{macrocode} +% \end{macro} +% \begin{macro}{\mglcommon} +% This macro is defined to be a synonym for |\mglcommon| (to keep backwards compatibility). +% \begin{macrocode} +\let\mglcommon\mglsetupscript \@onlypreamble\mglcommon % \end{macrocode} % \end{macro} -% \begin{macro}{\endmglcommon} -% It ends the |mglcommon| environment. +% \begin{macro}{\endmglsetupscript} +% It ends the |mglsetupscript| environment. % \begin{macrocode} -\def\endmglcommon{% +\def\endmglsetupscript{% \MGL@closeout\MGL@out@stream% \@esphack% } % \end{macrocode} % \end{macro} -% \end{environment} +% \begin{macro}{\endmglcommon} +% It is defined to be a synonym for |\endmglsetupscript|. +% \begin{macrocode} +\let\endmglcommon\endmglsetupscript +% \end{macrocode} +% \end{macro} +% \end{environment}\end{environment} % % \subsection{Fast creation of graphics} % \begin{environment}{mglsetup} % This environment is meant to contain code that is executed just before the instruction of a |\mglplot| command, producing always the same ouput. Instead of writing a new chunk of code for that purpose, |mglsetup| is defined as a special case of the |mglfunc| environment, with the exception that the MGL function obtained this way doesn't accept any argument ---thus producing always the same output. % \begin{macro}{\mglsetup} -% It is defined as an alias for |\mglfunc|, but only the name of the MGL function is passed to it, forcing the assumption that the number of arguments for the function is zero. +% It is defined as an alias for |\mglfunc|, but only the name of the MGL function is passed to it, forcing the assumption that its number of arguments is zero. % \begin{macrocode} \def\mglsetup#1{\mglfunc{#1}}% @@ -1899,39 +2171,43 @@ % \end{environment} % % \begin{macro}{\mglplot} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Added \doccommand{bgroup} and \doccommand{egroup} in order to keep changes private} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New command options: \texttt{gray}, \texttt{mglscale}, \texttt{quality}, \texttt{variant}} % Although the function of this command is quite simple and straightforward, it requires many lines of code and some tricks in order to reach the desired functionality. % \begin{macrocode} \newcommand\mglplot[2][]{% % \end{macrocode} +% Since this is a command, we need to explicitly create a local group so that all changes keep private to the command.\footnote{In contrast, environments keep changes private by default.} +% \begin{macrocode} + \bgroup% +% \end{macrocode} % We add some \meta{key}=\meta{value} pairs locally. The |label| key works exactly as the one of the |mgl| environment. % \begin{macrocode} - \define@key{MGL@keys}{label}{\edef\MGL@script@name{##1}}% + \define@key{MGL@gr@keys}{label}{\edef\MGL@script{##1}}% % \end{macrocode} % The |setup| key defines the variable |\MGL@mglplot@setup| which is later used to call a setup function for the corresponding image. % \begin{macrocode} - \define@key{MGL@keys}{setup}{\def\MGL@mglplot@setup{##1}}% + \define@key{MGL@gr@keys}{setup}{\def\MGL@mglplot@setup{##1}}% % \end{macrocode} % The |separator| key uses the |\MGL@def@for@loop| to define |\MGL@for| so that it iterates over lists separated by the indicated separator symbol. % \begin{macrocode} - \define@key{MGL@keys}{separator}{% - \MGL@def@for@loop{##1}% - }% + \define@key{MGL@gr@keys}{separator}{\MGL@def@for@loop{##1}}% % \end{macrocode} % Now, we process the keys passed by the user. % \begin{macrocode} - \MGL@setkeys{MGL@keys}{#1}% + \MGL@setkeys{MGL@gr@keys}{#1}% % \end{macrocode} % If the user hasn't specified a name using the |label| option, then a name is autogenerated following the same naming mechanism of the |mgl| environment. % \begin{macrocode} - \@ifundefined{MGL@script@name}{% + \@ifundefined{MGL@script}{% \stepcounter{MGL@script@no} - \edef\MGL@script@name{\MGL@main@script@name-MGL-\arabic{MGL@script@no}} + \edef\MGL@script{\MGL@main@script@name-MGL-\arabic{MGL@script@no}} }{}% % \end{macrocode} % The name of the script is checked. % \begin{macrocode} - \MGL@set@script@name{\MGL@script@name}% + \MGL@set@script@name{\MGL@script}% % \end{macrocode} % If the user hasn't specified a setup, then the only code that has to be written is the non-optional argument of |\mglplot|; it is stored in the temporary variable |\MGL@temp@a|. % \begin{macrocode} @@ -1952,9 +2228,13 @@ \mglplot@compare@code% }% % \end{macrocode} -% Finally, the corresponding image is included in the document. +% The corresponding image is included in the document. % \begin{macrocode} \MGL@includegraphics% +% \end{macrocode} +% Finally, the local group is closed. +% \begin{macrocode} + \egroup% } % \end{macrocode} % \begin{macro}{\mglplot@write@script} @@ -1964,11 +2244,16 @@ % \end{macrocode} % The default quality is written to the main script. % \begin{macrocode} - \MGL@write\MGL@main@stream{quality \MGL@quality}% + \MGL@write\MGL@main@stream{% + gray \MGL@gray^^J% + setsizescl \MGL@scale^^J% + quality \MGL@quality^^J% + variant \MGL@variant% + }% % \end{macrocode} % The backup file is opened to write in the output stream. % \begin{macrocode} - \MGL@openout\MGL@out@stream{\MGL@dir\MGL@backups@dir\MGL@script@name.mgl}% + \MGL@openout\MGL@out@stream{\MGL@dir\MGL@backups@dir\MGL@script.mgl}% % \end{macrocode} % Now we use the |\MGL@for| command to iterate over |\MGL@temp@a|. It takes a piece of code up to the separator symbol indicated by the user, and stores it in the temporary variable |\MGL@temp@b|, which is then written to the main script and backup file. % \begin{macrocode} @@ -1984,13 +2269,13 @@ % The instructions to save the image and reset the MGL parameters are written to the main script. % \begin{macrocode} \MGL@write\MGL@main@stream{% - write '\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext'^^J% + write '\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext'^^J% ^^Jreset^^J% }% % \end{macrocode} -% Finally, |\MGL@unchanged{\MGL@script@name}| is written to the |.aux| file. +% Finally, |\MGL@unchanged{\MGL@script}| is written to the |.aux| file. % \begin{macrocode} - \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script@name}}% + \MGL@write\@auxout{\string\MGL@unchanged{\MGL@script}}% } % \end{macrocode} % \end{macro} @@ -1999,13 +2284,13 @@ % \begin{macrocode} \def\mglplot@compare@code{% % \end{macrocode} -% The action that will finish this command is, for now, to write |\MGL@unchanged{\MGL@script@name}| in the |.aux| file; it is stored in the |\MGL@next| variable. If no changes in the code are found, this will remain as the last action; otherwise, it will be overwritten to do nothing. +% The action that will finish this command is, for now, to write |\MGL@unchanged{\MGL@script}| in the |.aux| file; it is stored in the |\MGL@next| variable. If no changes in the code are found, this will remain as the last action; otherwise, it will be overwritten to do nothing. % \begin{macrocode} - \def\MGL@next{\MGL@write\@auxout{\string\MGL@unchanged{\MGL@script@name}}}% + \def\MGL@next{\MGL@write\@auxout{\string\MGL@unchanged{\MGL@script}}}% % \end{macrocode} % The backup file is opened for reading in the input stream. % \begin{macrocode} - \MGL@openin\MGL@in@stream{\MGL@dir\MGL@backups@dir\MGL@script@name.mgl}% + \MGL@openin\MGL@in@stream{\MGL@dir\MGL@backups@dir\MGL@script.mgl}% % \end{macrocode} % Once again, the |\MGL@for| command is used to iterate over the |\MGL@temp@a| variable defined by |\mglplot|. Pieces of code are taken up to the appearance of the separator symbol indicated by the user. In every iteration, the corresponding piece of code is stored in the |\MGL@temp@b| variable, one line of code is read from the input stream to the variable |\MGL@temp@c|, and these two are compared; if they are different, we redefined |\MGL@next| to do nothing. % \begin{macrocode} @@ -2062,13 +2347,13 @@ % \begin{macrocode} \MGL@set@script@name{#2}% % \end{macrocode} -% If the switch |\@MGL@list@script@| is true, we increase the counter for verbatim code (|MGL@verb@script@no|), and add a contents line to the |.lms| file, using the style set by |\l@MGL@script|. In order to be able to use special characters in the name of the script, we use the |\detokenize| primitive. +% If the switch |\@MGL@list@script@| is true, we increase the counter for verbatim code (|MGL@verb@no|), and add a contents line to the |.lms| file, using the style set by |\l@MGL@script|. In order to be able to use special characters in the name of the script, we use the |\detokenize| primitive. % \begin{macrocode} \if@MGL@list@script@% - \refstepcounter{MGL@verb@script@no}% + \refstepcounter{MGL@verb@no}% \addcontentsline{lms}{MGL@script}{% - \protect\numberline{\theMGL@verb@script@no.}% - {\ttfamily\protect\detokenize{\MGL@script@name.mgl}}% + \protect\numberline{\theMGL@verb@no.}% + {\ttfamily\protect\detokenize{\MGL@script.mgl}}% }% \fi% % \end{macrocode} @@ -2094,7 +2379,7 @@ % The separator to indicate the begining of the verbatim code is positioned; we use the |\MGL@line@sep| command to draw it. % \begin{macrocode} \item[\MGL@line@sep]\fbox{% - \bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script@name.mgl}% + \bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script.mgl}% }\hskip\labelsep\MGL@line@sep\par\par% % \end{macrocode} % The |\verbatim@processline| is redefined to put |\the\verbatim@line| in an item of the list, and to to also write it to the script file. @@ -2106,7 +2391,7 @@ % \end{macrocode} % The script file is opened for writing. % \begin{macrocode} - \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script@name.mgl}% + \MGL@openout\MGL@out@stream{\MGL@dir\MGL@scripts@dir\MGL@script.mgl}% % \end{macrocode} % The writing process starts. % \begin{macrocode} @@ -2125,7 +2410,7 @@ % \end{macrocode} % \end{macro} % \begin{macro}{\endmglblock*} -% It's defined as an alias for |\endmglblock|. +% It is defined as an alias for |\endmglblock|. % \begin{macrocode} \expandafter\let\csname endmglblock*\endcsname\endmglblock % \end{macrocode} @@ -2154,7 +2439,7 @@ % \begin{macrocode} \newcommand\mglverbatim@[1][]{% \@MGL@lineno@true% - \define@key{MGL@verb@keys}{label}{\edef\MGL@script@name{##1}}% + \define@key{MGL@verb@keys}{label}{\edef\MGL@script{##1}}% \setkeys{MGL@verb@keys}{#1}% \if@MGL@lineno@% \list{\mgllinenostyle\arabic{MGL@line@no}.}{\usecounter{MGL@line@no}}% @@ -2164,24 +2449,24 @@ \MGL@set@verbatim@code% \fboxrule=\mgllinethickness% % \end{macrocode} -% The separator that indicates the begining of the verbatim code is different depending on whether the user has specified a name associated to the code or not. If no name has been indicated, i.e., |\MGL@script@name| is undefined, the separator is just a line; otherwise, i.e., |\MGL@script@name| is defined, the separator is similar to the one of the |mglblock| environment. +% The separator that indicates the begining of the verbatim code is different depending on whether the user has specified a name associated to the code or not. If no name has been indicated, i.e., |\MGL@script| is undefined, the separator is just a line; otherwise, i.e., |\MGL@script| is defined, the separator is similar to the one of the |mglblock| environment. % \begin{macrocode} - \@ifundefined{MGL@script@name}{% - \edef\MGL@script@name{\mglverbatimname}% + \@ifundefined{MGL@script}{% + \edef\MGL@script{\mglverbatimname}% \item[\MGL@line@sep]\hskip-\labelsep\MGL@line@sep% }{% \item[\MGL@line@sep]\fbox{% - \bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script@name.mgl}% + \bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script.mgl}% }\hskip\labelsep\MGL@line@sep\par\par% }% % \end{macrocode} % Note that, if the user requests an entry in the |\listofmglscripts|, the contents line is added to the same |.lms| file. So here start the similitudes again. % \begin{macrocode} \if@MGL@list@script@% - \refstepcounter{MGL@verb@script@no}% + \refstepcounter{MGL@verb@no}% \addcontentsline{lms}{MGL@script}{% - \protect\numberline{\theMGL@verb@script@no.}% - {\ttfamily\protect\detokenize{\MGL@script@name}}% + \protect\numberline{\theMGL@verb@no.}% + {\ttfamily\protect\detokenize{\MGL@script}}% }% \fi% \def\verbatim@processline{% @@ -2211,29 +2496,29 @@ % \end{environment} % % \begin{environment}{mglcomment} -% This environment has two different behaviors: When commentaries are allowed by the user, it behaves similarly to the |mglverbatim| environment; if commentaries are not allowed, it behaves as the |comment| environment from the \textsf{verbatim} package. So it is natural that we borrow code from them and adapt it to the corresponding situation. +% This environment has two different behaviors: When comments are allowed by the user, it behaves similarly to the |mglverbatim| environment; if comments are not allowed, it behaves as the |comment| environment from the \textsf{verbatim} package. So it is natural that we borrow code from them and adapt it to the corresponding situation. % \begin{macro}{\mglcomment} % The switch |\@MGL@comments@| governs the behavior of this command. % \begin{macrocode} \def\mglcomment{% % \end{macrocode} -% If the switch is true, i.e., the user requests displaying of commentaries, we start a list without labels, and set the parameters for verbatim text. +% If the switch is true, i.e., the user requests displaying of comments, we start a list without labels, and set the parameters for verbatim text. % \begin{macrocode} \if@MGL@comments@% \list{}{}% \MGL@set@verbatim@code% % \end{macrocode} -% The separator indicating the begining of the commentary is similar to the one used by the |mglblock| and |mglverbatim| environments; the differences are that, instead of using a solid line, we use a dashed line (|\MGL@dash@sep|), and instead of displaying the name of a script, we display |\mglcommentname|. +% The separator indicating the begining of the comment is similar to the one used by the |mglblock| and |mglverbatim| environments; the differences are that, instead of using a solid line, we use a dashed line (|\MGL@dash@sep|), and instead of displaying the name of a script, we display |\mglcommentname|. % \begin{macrocode} \item\hskip-\labelsep<\MGL@dash@sep\mglcommentname\MGL@dash@sep>% % \end{macrocode} -% The two following lines redefine the |\verbatim@processline| command to display the commentary text line by line as items of the list, and start the process of writing the text. +% The two following lines redefine the |\verbatim@processline| command to display the comment text line by line as items of the list, and start the process of writing the text. % \begin{macrocode} \def\verbatim@processline{\item\the\verbatim@line}% \verbatim@start% % \end{macrocode} -% If the switch is false, i.e., the user requests no to display commentaries, we start a \emph{space hack}, since no text output will be produced. Then, the category codes are changed with |\MGL@codes|, and the macros |\verbatim@startline|, |\verbatim@addtoline|, |\verbatim@processline| and |\verbatim@finish| are disabled, as done in the |comment| environment of the \textsf{verbatim} package. Finally, we call the |\verbatim@| command to start reading the text in the environment. +% If the switch is false, i.e., the user requests no to display comments, we start a \emph{space hack}, since no text output will be produced. Then, the category codes are changed with |\MGL@codes|, and the macros |\verbatim@startline|, |\verbatim@addtoline|, |\verbatim@processline| and |\verbatim@finish| are disabled, as done in the |comment| environment of the \textsf{verbatim} package. Finally, we call the |\verbatim@| command to start reading the text in the environment. % \begin{macrocode} \else% \@bsphack% @@ -2248,7 +2533,7 @@ % \end{macrocode} % \end{macro} % \begin{macro}{\endmglcomment} -% The |\@MGL@comments@| switch also governs the behavior of this command. If it's true, then the separator that ends the commentary ---which is the same as the one that starts it--- is displayed, and the list is ended; otherwise, simply the \emph{space hack} is ended. +% The |\@MGL@comments@| switch also governs the behavior of this command. If it's true, then the separator that ends the comment ---which is the same as the one that starts it--- is displayed, and the list is ended; otherwise, simply the \emph{space hack} is ended. % \begin{macrocode} \def\endmglcomment{% \if@MGL@comments@% @@ -2266,6 +2551,7 @@ % \noindent Since external scripts exist independently of the \LaTeX{} document, there is no need of environments to process them, just commands. Remember these commands work on the suposition that the scripts don't change. % % \begin{macro}{\mglgraphics} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{New command options: \texttt{gray}, \texttt{mglscale}, \texttt{quality}, \texttt{variant}} % This command compiles the external script and includes it in the document. Although that process is simple, the code to execute it is relatively large due to the possibility of the user specifying an optional path, so many parameters have to be checked. % \begin{macrocode} @@ -2277,19 +2563,19 @@ % \end{macrocode} % We add the option |path| for the user to be able to specify the location of the script, which is stored in the variable |\MGL@force@path|. % \begin{macrocode} - \define@key{MGL@keys}{path}{\def\MGL@forced@path{##1}}% + \define@key{MGL@gr@keys}{path}{\def\MGL@forced@path{##1}}% % \end{macrocode} % The optional arguments are processed. % \begin{macrocode} - \MGL@setkeys{MGL@keys}{#1}% + \MGL@setkeys{MGL@gr@keys}{#1}% % \end{macrocode} % The name of the script is set, though it is not check for multiple naming. This is necessary, since |\MGL@includegraphics| uses this macro. % \begin{macrocode} - \edef\MGL@script@name{#2}% + \edef\MGL@script{#2}% % \end{macrocode} % If the corresponding image exists, then this script has been compiled in a previous \LaTeX{} run, so nothing is done, but the inclusion of the image. % \begin{macrocode} - \IfFileExists{\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext}{}{% + \IfFileExists{\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext}{}{% % \end{macrocode} % If the image doesn't exist, we check if the user has specified a custom location. % \begin{macrocode} @@ -2298,7 +2584,7 @@ % If no custom location has been used, we iterate over the list of search paths (|\MGL@paths|): If we find the requested script, then we store its location in |\MGL@temp@b|. % \begin{macrocode} \@for\MGL@temp@a:=\MGL@paths\do{% - \IfFileExists{\MGL@temp@a\MGL@script@name.mgl}{% + \IfFileExists{\MGL@temp@a\MGL@script.mgl}{% \edef\MGL@temp@b{\MGL@temp@a}% }{}% }% @@ -2306,7 +2592,7 @@ % \end{macrocode} % If the user has specified a path for the script, we check if the script actually exists. If it does, we store its location inside |\MGL@temp@b|. % \begin{macrocode} - \IfFileExists{\MGL@forced@path\MGL@script@name.mgl}{% + \IfFileExists{\MGL@forced@path\MGL@script.mgl}{% \edef\MGL@temp@b{\MGL@forced@path}% }{}% }% @@ -2315,17 +2601,18 @@ % \begin{macrocode} \@ifundefined{MGL@temp@b}{% \PackageWarning{mgltex}{% - MGL script "\MGL@script@name.mgl" not found% + MGL script "\MGL@script.mgl" not found% }% }{% % \end{macrocode} % If |\MGL@temp@b| is defined, the script has been found, so we compile it. % \begin{macrocode} \MGL@write{18}{% - mglconv -q \MGL@quality\space -S \MGL@scale\space% - -s "\MGL@dir\MGL@scripts@dir\mglcommonscriptname.mgl"\space% - -o "\MGL@dir\MGL@graphics@dir\MGL@script@name\MGL@graph@ext"\space% - "\MGL@temp@b\MGL@script@name.mgl"% + mglconv -q \MGL@quality\space -g \MGL@gray\space% + -S \MGL@scale\space -v \MGL@variant\space% + -s "\MGL@dir\MGL@scripts@dir\mglsetupscriptname.mgl"\space% + -o "\MGL@dir\MGL@graphics@dir\MGL@script\MGL@imgext"\space% + "\MGL@temp@b\MGL@script.mgl"% }% }% }% @@ -2370,9 +2657,9 @@ % \begin{macrocode} \setkeys{MGL@verb@keys}{#1}% % \end{macrocode} -% We don't need to check if there are multiple scripts with the same name, so we namually set |\MGL@script@name|, instead of using |\MGL@set@script@name|. +% We don't need to check if there are multiple scripts with the same name, so we namually set |\MGL@script|, instead of using |\MGL@set@script@name|. % \begin{macrocode} - \edef\MGL@script@name{#2}% + \edef\MGL@script{#2}% % \end{macrocode} % We check if the user has specified a custom location for the script. % \begin{macrocode} @@ -2384,7 +2671,7 @@ % \end{macrocode} % If the script exists, we store its location in |\MGL@temp@a|% % \begin{macrocode} - \IfFileExists{\MGL@temp@b\MGL@script@name.mgl}{% + \IfFileExists{\MGL@temp@b\MGL@script.mgl}{% \edef\MGL@temp@a{\MGL@temp@b}% }{}% }% @@ -2392,7 +2679,7 @@ % \end{macrocode} % If the user specified the location of the script, we check if it exists, in which case we store its location in |\MGL@temp@a|. % \begin{macrocode} - \IfFileExists{\MGL@script@name.mgl}{% + \IfFileExists{\MGL@script.mgl}{% \edef\MGL@temp@a{\MGL@forced@path}% }{}% }% @@ -2401,7 +2688,7 @@ % \begin{macrocode} \@ifundefined{MGL@temp@a}{% \PackageWarning{mgltex}{% - MGL script "\MGL@forced@path\MGL@script@name.mgl" not found% + MGL script "\MGL@forced@path\MGL@script.mgl" not found% }% \center% \fbox{% @@ -2427,15 +2714,15 @@ % \end{macrocode} % We first add the script to the \LaTeX{} list of included files. % \begin{macrocode} - \@addtofilelist{\MGL@script@name.mgl}% + \@addtofilelist{\MGL@script.mgl}% % \end{macrocode} % If the user has used the unstarred version of |\mglinclude|, we add a contents line to the |.lms| file. % \begin{macrocode} \if@MGL@list@script@% - \refstepcounter{MGL@verb@script@no}% + \refstepcounter{MGL@verb@no}% \addcontentsline{lms}{MGL@script}{% - \protect\numberline{\theMGL@verb@script@no.}% - {\ttfamily\protect\detokenize{\MGL@script@name.mgl}}% + \protect\numberline{\theMGL@verb@no.}% + {\ttfamily\protect\detokenize{\MGL@script.mgl}}% }% \fi% % \end{macrocode} @@ -2455,7 +2742,7 @@ % \begin{macrocode} \fboxrule=\mgllinethickness% \item[\MGL@line@sep]\fbox{% - \bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script@name.mgl}% + \bfseries\ttfamily\expandafter\detokenize\expandafter{\MGL@script.mgl}% }\hskip\labelsep\MGL@line@sep\par\par% % \end{macrocode} % We redefine the |\verbatim@processline| macro from the \textsf{verbatim} package to put |\the\verbatim@line| on an item. @@ -2466,7 +2753,7 @@ % \end{macrocode} % The script is opened for reading. % \begin{macrocode} - \immediate\openin\MGL@in@stream="\MGL@temp@a\MGL@script@name.mgl"% + \immediate\openin\MGL@in@stream="\MGL@temp@a\MGL@script.mgl"% % \end{macrocode} % We call |\mglinclude@@@| to start the transcription. % \begin{macrocode} @@ -2504,106 +2791,8 @@ % \end{macro}\end{macro} % % \subsection{Additional commands} -% \begin{macro}{\mglname} -% \noindent The purpose of this command is to force the closure of the current main script, compile the corresponding figures, and open a new main script. At first, it is defined to only change the value of |\MGL@main@script@name| because the main script is not opened until the call of |\begin{document}|; but at that point, it is redefined to perform the described actions. -% \begin{macrocode} -\def\mglname#1{\edef\MGL@main@script@name{#1}} -% \end{macrocode} -% Here is the redefinition of |\mglname|. -% \begin{macrocode} -\AtBeginDocument{% - \def\mglname#1{% -% \end{macrocode} -% We start a space hack, ince this function has no real effect on the document. -% \begin{macrocode} - \@bsphack% -% \end{macrocode} -% The MGL functions created throughout the document are written. -% \begin{macrocode} - \MGL@write@funcs% -% \end{macrocode} -% We force the closure of the main script. We use |\immediate\closeout| instead of |\MGL@closeout| in case \textsf{\mglTeX} is off. -% \begin{macrocode} - \immediate\closeout{\MGL@main@stream}% -% \end{macrocode} -% The closed script is compiled. -% \begin{macrocode} - \MGL@write{18}{% - mglconv -q \MGL@quality\space -S \MGL@scale\space% - -s "\MGL@dir\MGL@scripts@dir\mglcommonscriptname.mgl"\space% - -n "\MGL@dir\MGL@scripts@dir\MGL@main@script@name.mgl"% - }% -% \end{macrocode} -% The name of the new main script is updated, and it is check for overwriting, using |\MGL@set@script@name| inside a local group, since this command defines |\MGL@script@name|, which we need undefined in some parts of the code of the package. -% \begin{macrocode} - \edef\MGL@main@script@name{#1}% - \bgroup\MGL@set@script@name{\MGL@main@script@name}\egroup% - \MGL@openout\MGL@main@stream{% - \MGL@dir\MGL@scripts@dir\MGL@main@script@name.mgl% - }% -% \end{macrocode} -% The space hack is ended. -% \begin{macrocode} - \@esphack% - }% -} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\mglswitch} -% This command turns |on| and |off| the package according to its argument; it is just a call to the commands |\MGL@switch@on| or |\MGL@switch@off|. -% \begin{macrocode} -\def\mglswitch#1{\csname MGL@switch@#1\endcsname} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\mglcomments} Depending on the option passed by the user, it calls |\@MGL@comments@on| or |\@MGL@comments@off|. -% \begin{macrocode} -\def\mglcomments#1{\csname @MGL@comments@#1\endcsname} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\mgldir} -% This command is the interface for the user to change the value of |\MGL@dir|. It is an only-preamble macro, since using it elsewhere would cause faulty behavior. -% \begin{macrocode} - -\def\mgldir#1{\def\MGL@dir{#1}}\@onlypreamble\mgldir -% \end{macrocode} -% \end{macro} -% \begin{macro}{\mglscriptsdir} -% This command modifies the value of |\MGL@scripts@dir|. It is also an only-preamble macro. -% \begin{macrocode} -\def\mglscriptsdir#1{\def\MGL@scripts@dir{#1}}\@onlypreamble\mglscriptsdir -% \end{macrocode} -% \end{macro} -% \begin{macro}{\mglgraphicsdir} -% Modifies the value of |\MGL@graphics@dir|. It is an only-preamble macro. -% \begin{macrocode} -\def\mglgraphicsdir#1{\def\MGL@graphics@dir{#1}}\@onlypreamble\mglgraphicsdir -% \end{macrocode} -% \end{macro} -% \begin{macro}{\mglbackupsdir} -% Modifies the value of |\MGL@backups@dir|. It is an only-preamble macro. -% \begin{macrocode} -\def\mglbackupsdir#1{\def\MGL@backups@dir{#1}}\@onlypreamble\mglbackupsdir -% \end{macrocode} -% \end{macro} -% \begin{macro}{\mglpaths} -% This command adds a list of search paths for scripts to the existing one (|\MGL@paths|). -% \begin{macrocode} -\def\mglpaths#1{\g@addto@macro\MGL@paths{,#1}} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\mglimgext} -% This command changes the value of |\MGL@graph@ext|. -% \begin{macrocode} -\def\mglimgext#1{\def\MGL@graph@ext{#1}} -% \end{macrocode} -% \end{macro} -% % \begin{macro}{\listofmglscripts} -% This command creates the \emph{list of MGL scripts} section. It has to be defined differently depending on whether the used document class defines the |\l@chapter| command or it only the |\l@section| command, which set the style for making a table of contents entry for the |\chapter| command and the |\section| command, respectively. If none of them are defined, we define our own style based on the latter. +% \noindent This command creates the \emph{list of MGL scripts} section. It has to be defined differently depending on whether the used document class defines the |\l@chapter| command or it only the |\l@section| command, which set the style for making a table of contents entry for the |\chapter| command and the |\section| command, respectively. If none of them are defined, we define our own style based on the latter. % \begin{macrocode} \ifx\l@chapter\@undefined% @@ -2682,11 +2871,178 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\mglcommonscriptname}\begin{macro}{\mglcommentname}\begin{macro}{\listofmglscriptsname}\begin{macro}{\mglverbatimname}\begin{macro}{\mgllinenostyle}\begin{macro}{\mgldashwidth}\begin{macro}{\mgllinethickness}\begin{macro}{\mglbreakindent} +% \begin{macro}{\mglTeX} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Add a small negative space in the logo, between the ``mgl'' and ``\TeX''} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Declared now as robust command} +% This macro pretty-prints the name of the package. It has a starred version, which also prints the version. % \begin{macrocode} -\def\mglcommonscriptname{MGL_common_script} -\def\mglcommentname{MGL commentary} +\DeclareRobustCommand\mglTeX{% + mgl\TeX\@ifstar{~v4.2}{}% +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Local settings commands} +% \begin{macro}{\mglswitch} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Now accepts arguments \texttt{0} (equivalent to \texttt{off}) and \texttt{1} (equivalent to \texttt{on}), besides the usual \texttt{off} and \texttt{on}} +% \noindent This command turns |on| and |off| the package according to its argument; it is just a call to the commands |\MGL@switch@on| or |\MGL@switch@off|. +% \begin{macrocode} +\def\mglswitch#1{% + \MGL@test@switch{#1}{\mglswitch}% + \csname MGL@switch@\MGL@temp@a\endcsname% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\mglcomments} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Now accepts arguments \texttt{0} (equivalent to \texttt{off}) and \texttt{1} (equivalent to \texttt{on}), besides the usual \texttt{off} and \texttt{on}} +% Depending on the option passed by the user, it calls |\@MGL@comments@on| or |\@MGL@comments@off|. +% \begin{macrocode} +\def\mglcomments#1{% + \MGL@test@switch{#1}{\mglcomments}% + \csname @MGL@comments@\MGL@temp@a\endcsname% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\mglquality} +% See under the title \emph{Initialization}, subsection \ref{Init}. +% \end{macro} +% +% \begin{macro}{\mglscale} +% See under the title \emph{Initialization}, subsection \ref{Init}. +% \end{macro} +% +% \begin{macro}{\mglvariant} +% See under the title \emph{Initialization}, subsection \ref{Init}. +% \end{macro} +% +% \begin{macro}{\mglimgext} +% This command changes the value of |\MGL@imgext|. +% \begin{macrocode} +\def\mglimgext#1{\def\MGL@imgext{#1}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\mglname} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Now writes the MGL code line \texttt{setsize~600~400} to the main script} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{The MGL code line \texttt{setsize~600~400} is now written to the main script} +% \noindent The purpose of this command is to force the closure of the current main script, compile the corresponding figures, and open a new main script. At first, it is defined to only change the value of |\MGL@main@script@name| because the main script is not opened until the call of |\begin{document}|; but at that point, it is redefined to perform the described actions. +% \begin{macrocode} +\def\mglname#1{\edef\MGL@main@script@name{#1}} +% \end{macrocode} +% Here is the redefinition of |\mglname| after the |\begin{document}| command. +% \begin{macrocode} +\AtBeginDocument{% + \def\mglname#1{% +% \end{macrocode} +% We start a space hack, ince this function has no real effect on the document. +% \begin{macrocode} + \@bsphack% +% \end{macrocode} +% The MGL functions created throughout the document are written. +% \begin{macrocode} + \MGL@write@funcs% +% \end{macrocode} +% We force the closure of the main script. We use |\immediate\closeout| instead of |\MGL@closeout| in case \textsf{\mglTeX} is off. +% \begin{macrocode} + \immediate\closeout{\MGL@main@stream}% +% \end{macrocode} +% The closed script is compiled. +% \begin{macrocode} + \MGL@write{18}{% + mglconv -q \MGL@quality\space -g \MGL@gray\space% + -S \MGL@scale\space -v \MGL@variant\space% + -s "\MGL@dir\MGL@scripts@dir\mglsetupscriptname.mgl"\space% + -n "\MGL@dir\MGL@scripts@dir\MGL@main@script@name.mgl"% + }% +% \end{macrocode} +% The name of the new main script is updated, and it is check for overwriting, using |\MGL@set@script@name| inside a local group, since this command defines |\MGL@script|, which we need undefined in some parts of the code of the package. +% \begin{macrocode} + \edef\MGL@main@script@name{#1}% + \bgroup\MGL@set@script@name{\MGL@main@script@name}\egroup% + \MGL@openout\MGL@main@stream{% + \MGL@dir\MGL@scripts@dir\MGL@main@script@name.mgl% + }% +% \end{macrocode} +% We set the default size for the graphics that the main script will generate; without this line the |setsizescl| commands written automatically by \textsf{\mglTeX} wouldn't work. +% \begin{macrocode} + \MGL@write\MGL@main@script@name{setsize 600 400} +% \end{macrocode} +% The space hack is ended. +% \begin{macrocode} + \@esphack% + }% +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Advanced settings commands} +% \begin{macro}{\mgldir} +% \noindent This command is the interface for the user to change the value of |\MGL@dir|. It is an only-preamble macro, since using it elsewhere would cause faulty behavior. +% \begin{macrocode} + +\def\mgldir#1{\def\MGL@dir{#1}}\@onlypreamble\mgldir +% \end{macrocode} +% \end{macro} +% \begin{macro}{\mglscriptsdir} +% This command modifies the value of |\MGL@scripts@dir|. It is also an only-preamble macro. +% \begin{macrocode} +\def\mglscriptsdir#1{\def\MGL@scripts@dir{#1}}\@onlypreamble\mglscriptsdir +% \end{macrocode} +% \end{macro} +% \begin{macro}{\mglgraphicsdir} +% Modifies the value of |\MGL@graphics@dir|. It is an only-preamble macro. +% \begin{macrocode} +\def\mglgraphicsdir#1{\def\MGL@graphics@dir{#1}}\@onlypreamble\mglgraphicsdir +% \end{macrocode} +% \end{macro} +% \begin{macro}{\mglbackupsdir} +% Modifies the value of |\MGL@backups@dir|. It is an only-preamble macro. +% \begin{macrocode} +\def\mglbackupsdir#1{\def\MGL@backups@dir{#1}}\@onlypreamble\mglbackupsdir +% \end{macrocode} +% \end{macro} +% \begin{macro}{\mglpaths} +% This command adds a list of search paths for scripts to the existing one (|\MGL@paths|). +% \begin{macrocode} +\def\mglpaths#1{\g@addto@macro\MGL@paths{,#1}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\mglsettings} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Now calls the \doccommand{mglswitch} and \doccommand{mglcomments} commands for the \texttt{switch} and \texttt{comments} options, respectively} +% \changes{\textbf{v4.2 ------------}}{2016/05/14}{Added options \texttt{gray} and \texttt{variant}} +% First, we define a \meta{key}=\meta{value} family, |MGL@sett@keys|, for this command. +% \begin{macrocode} +\define@key{MGL@sett@keys}{dir}{\def\MGL@dir{#1}} +\define@key{MGL@sett@keys}{scriptsdir}{\def\MGL@scripts@dir{#1}} +\define@key{MGL@sett@keys}{graphicsdir}{\def\MGL@graphics@dir{#1}} +\define@key{MGL@sett@keys}{backupsdir}{\def\MGL@backups@dir{#1}} +\define@key{MGL@sett@keys}{paths}{\g@addto@macro\MGL@paths{,#1}} +\define@key{MGL@sett@keys}{switch}{\mglswitch{#1}} +\define@key{MGL@sett@keys}{comments}{\mglcomments{#1}} +\define@key{MGL@sett@keys}{gray}{\mglgray{#1}} +\define@key{MGL@sett@keys}{mglscale}{\mglscale{#1}} +\define@key{MGL@sett@keys}{quality}{\mglquality{#1}} +\define@key{MGL@sett@keys}{variant}{\mglvariant{#1}} +\define@key{MGL@sett@keys}{imgext}{\def\MGL@imgext{.#1}} +% \end{macrocode} +% The command receives and executes the \meta{key}=\meta{value} pairs for |MGL@sett@keys|. This is an only-preamble command. +% \begin{macrocode} +\def\mglsettings#1{\setkeys{MGL@sett@keys}{#1}} +\@onlypreamble\mglsettings +% \end{macrocode} +% \end{macro} +% +% \subsection{User-definable macros} +% \begin{macro}{\mglsetupscriptname}\begin{macro}{\mglcommentname}\begin{macro}{\listofmglscriptsname}\begin{macro}{\mglverbatimname}\begin{macro}{\mgllinenostyle}\begin{macro}{\mgldashwidth}\begin{macro}{\mgllinethickness}\begin{macro}{\mglbreakindent} +% The user is allowed to modifu these commands, so no |@| symbol is used on them. +% \begin{macrocode} + +\def\mglsetupscriptname{MGL_setup_script} +\def\mglcommentname{\mglTeX{} comment} \def\listofmglscriptsname{List of MGL scripts} \def\mglverbatimname{(Unnamed MGL verbatim script)} \def\mgllinenostyle{\footnotesize} @@ -2696,30 +3052,23 @@ % \end{macrocode} % \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro} % -% \begin{macro}{\mglTeX} -% This macro pretty-prints the name of the package. It has a starred version, which also prints the version. -% \begin{macrocode} - -\def\mglTeX{% - mgl\TeX\@ifstar{~v4.1}{}% -} -% \end{macrocode} -% \end{macro} -% % \subsection{Final adjustments} % To finish the code of \textsf{\mglTeX}, we set the behavior of the package at the call of the |\begin{document}| and |\end{document}| commands. % -% We tell \LaTeX{} to check the name of the document's main script for overwriting. We do this by calling |\MGL@set@script@name| inside a local group, because it defines |\MGL@script@name|, which we need undefined in certain parts of the code. Then the script is opened. We use |\immediate\openout| instead of |\MGL@openout| for this purpose, since, otherwise, we run the risk of the main script not being created when needed, if the user turns off \textsf{\mglTeX} before the |\begin{document}| command, and turns it on immediately after. +% We tell \LaTeX{} to check the name of the document's main script for overwriting. We do this by calling |\MGL@set@script@name| inside a local group, because it defines |\MGL@script|, which we need undefined in certain parts of the code. Then the script is opened. We use |\immediate\openout| instead of |\MGL@openout| for this purpose, since, otherwise, we run the risk of the main script not being created when needed, if the user turns off \textsf{\mglTeX} before the |\begin{document}| command, and turns it on immediately after. Finally, we set the default size for the graphics the main script will generate; without this line the |setsizescl| commands written automatically by \textsf{\mglTeX} wouldn't work. % \begin{macrocode} \AtBeginDocument{% \bgroup\MGL@set@script@name{\MGL@main@script@name}\egroup% \immediate\openout\MGL@main@stream=% \MGL@dir\MGL@scripts@dir\MGL@main@script@name.mgl% + \MGL@write\MGL@main@stream{setsize 600 400}% } % \end{macrocode} +% % We also set the actions for the call of |\end{document}| % \begin{macrocode} + \AtEndDocument{% % \end{macrocode} % |\MGL@write@funcs| will simply write the MGL functions throughout the \LaTeX{} document. @@ -2733,8 +3082,9 @@ % The main script is compiled. % \begin{macrocode} \MGL@write{18}{% - mglconv -q \MGL@quality\space -S \MGL@scale\space% - -s "\MGL@dir\MGL@scripts@dir\mglcommonscriptname.mgl"\space% + mglconv -q \MGL@quality\space -g \MGL@gray\space% + -S \MGL@scale\space -v \MGL@variant\space% + -s "\MGL@dir\MGL@scripts@dir\mglsetupscriptname.mgl"\space% -n "\MGL@dir\MGL@scripts@dir\MGL@main@script@name.mgl"% }% } diff -Nru mathgl-2.3.4/mgltex/mgltex.ins mathgl-2.3.5.1/mgltex/mgltex.ins --- mathgl-2.3.4/mgltex/mgltex.ins 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/mgltex/mgltex.ins 2016-06-19 17:06:01.000000000 +0000 @@ -1,6 +1,6 @@ %% -%% Copyright (C) 2014--2015 by Diego Sejas Viscarra -%% Copyright (C) 2014--2015 by Alexey Balakin +%% Copyright (C) 2014--2016 by Diego Sejas Viscarra +%% Copyright (C) 2014--2016 by 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 @@ -60,4 +60,4 @@ \Msg{* *} \Msg{**********************************************************} -\endbatchfile \ No newline at end of file +\endbatchfile Binary files /tmp/tmphXTxTr/tbanPDYGhj/mathgl-2.3.4/mgltex/mgltex.pdf and /tmp/tmphXTxTr/SKVbg2MUec/mathgl-2.3.5.1/mgltex/mgltex.pdf differ diff -Nru mathgl-2.3.4/mgltex/Recompilation_decision.eps mathgl-2.3.5.1/mgltex/Recompilation_decision.eps --- mathgl-2.3.4/mgltex/Recompilation_decision.eps 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/mgltex/Recompilation_decision.eps 2016-06-19 17:06:01.000000000 +0000 @@ -1,6 +1,6 @@ %!PS-Adobe-3.0 EPSF-3.0 %%Creator: cairo 1.13.1 (http://cairographics.org) -%%CreationDate: Sat Nov 7 08:28:35 2015 +%%CreationDate: Sat Nov 7 15:28:00 2015 %%Pages: 1 %%DocumentData: Clean7Bit %%LanguageLevel: 3 @@ -1624,28 +1624,117 @@ ET Q q 0 g -2.4 w +2.15895 w 0 J 0 j [] 0.0 d 4 M q 1 0 0 -1 0 790.399963 cm -316.762 33.48 m 316.762 86.008 l S Q +316.762 37.789 m 316.762 80.293 l S Q +321.988 721.4 m 316.781 707.248 l 311.578 721.4 l 314.652 719.138 318.855 + 719.15 321.988 721.4 c h +321.988 721.4 m f* +0.809606 w +1 j +q 0 1 1 0 0 790.399963 cm +-69 321.988 m -83.152 316.781 l -69 311.578 l -71.262 314.652 -71.25 318.855 + -69 321.988 c h +-69 321.988 m S Q +2.15579 w +0 j q 1 0 0 -1 0 790.399963 cm -316.762 147.812 m 316.762 199.551 l S Q +316.762 152.66 m 316.762 194.406 l S Q +321.98 607.271 m 316.781 593.138 l 311.586 607.271 l 314.652 605.013 318.852 + 605.029 321.98 607.271 c h +321.98 607.271 m f* +0.808421 w +1 j +q 0 1 1 0 0 790.399963 cm +-183.129 321.98 m -197.262 316.781 l -183.129 311.586 l -185.387 314.652 + -185.371 318.852 -183.129 321.98 c h +-183.129 321.98 m S Q +2.295753 w +0 j q 1 0 0 -1 0 790.399963 cm -256.559 257.719 m 139.379 257.719 l 139.379 365.215 l S Q +252.547 257.68 m 139.148 257.68 l 139.148 359.32 l S Q +144.703 443.091 m 139.172 428.041 l 133.637 443.091 l 136.902 440.685 141.375 + 440.701 144.703 443.091 c h +144.703 443.091 m f* +0.860907 w +1 j +q 0 1 1 0 0 790.399963 cm +-347.309 144.703 m -362.359 139.172 l -347.309 133.637 l -349.715 136.902 + -349.699 141.375 -347.309 144.703 c h +-347.309 144.703 m S Q +2.324777 w +0 j q 1 0 0 -1 0 790.399963 cm -378.305 257.715 m 495.484 257.715 l 495.484 365.211 l S Q +381.137 257.691 m 495.648 257.691 l 495.648 360.906 l S Q +501.273 441.658 m 495.668 426.416 l 490.066 441.658 l 493.375 439.22 497.902 + 439.236 501.273 441.658 c h +501.273 441.658 m f* +0.871792 w +1 j +q 0 1 1 0 0 790.399963 cm +-348.742 501.273 m -363.984 495.668 l -348.742 490.066 l -351.18 493.375 + -351.164 497.902 -348.742 501.273 c h +-348.742 501.273 m S Q +2.290224 w +0 j q 1 0 0 -1 0 790.399963 cm -225.398 398.059 m 316.828 397.484 l 316.828 474.172 l S Q +228.438 397.988 m 317.062 397.453 l 317.062 469.492 l S Q +322.605 332.888 m 317.086 317.873 l 311.562 332.888 l 314.824 330.49 319.281 + 330.502 322.605 332.888 c h +322.605 332.888 m f* +0.858834 w +1 j +q 0 1 1 0 0 790.399963 cm +-457.512 322.605 m -472.527 317.086 l -457.512 311.562 l -459.91 314.824 + -459.898 319.281 -457.512 322.605 c h +-457.512 322.605 m S Q +2.300242 w +0 j q 1 0 0 -1 0 790.399963 cm -377.992 533.152 m 495.168 533.152 l 495.168 640.648 l S Q +379.918 533.141 m 495.336 533.141 l 495.336 633.395 l S Q +500.902 169.041 m 495.359 153.962 l 489.812 169.041 l 493.086 166.63 497.566 + 166.646 500.902 169.041 c h +500.902 169.041 m f* +0.862591 w +1 j +q 0 1 1 0 0 790.399963 cm +-621.359 500.902 m -636.438 495.359 l -621.359 489.812 l -623.77 493.086 + -623.754 497.566 -621.359 500.902 c h +-621.359 500.902 m S Q +2.29295 w +0 j q 1 0 0 -1 0 790.399963 cm -255.668 532.582 m 138.488 532.582 l 138.488 640.078 l S Q +252.285 532.551 m 138.273 532.551 l 138.273 633.395 l S Q +143.824 168.998 m 138.297 153.966 l 132.77 168.998 l 136.031 166.595 140.496 + 166.611 143.824 168.998 c h +143.824 168.998 m f* +0.859856 w +1 j +q 0 1 1 0 0 790.399963 cm +-621.402 143.824 m -636.434 138.297 l -621.402 132.77 l -623.805 136.031 + -623.789 140.496 -621.402 143.824 c h +-621.402 143.824 m S Q +2.335361 w +0 j q 1 0 0 -1 0 790.399963 cm -255.688 674.629 m 373.973 674.629 l S Q +258.828 674.629 m 370.828 674.629 l S Q +2.348876 w q 1 0 0 -1 0 790.399963 cm -316.828 674.629 m 316.828 752.344 l S Q +316.828 674.629 m 316.828 749.066 l S Q +322.512 53.619 m 316.852 38.22 l 311.188 53.619 l 314.531 51.162 319.105 + 51.173 322.512 53.619 c h +322.512 53.619 m f* +0.880828 w +1 j +q 0 1 1 0 0 790.399963 cm +-736.781 322.512 m -752.18 316.852 l -736.781 311.187 l -739.238 314.531 + -739.227 319.105 -736.781 322.512 c h +-736.781 322.512 m S Q +2.4 w +0 j q 1 0 0 -1 0 790.399963 cm 495.113 422.059 m 495.113 451.77 l 332.828 451.199 l 332.828 451.199 317.516 429.449 301.457 451.18 c 138.828 451.484 l 138.543 532.629 l S Q Binary files /tmp/tmphXTxTr/tbanPDYGhj/mathgl-2.3.4/mgltex/Recompilation_decision.pdf and /tmp/tmphXTxTr/SKVbg2MUec/mathgl-2.3.5.1/mgltex/Recompilation_decision.pdf differ diff -Nru mathgl-2.3.4/mgltex/Recompilation_decision.svg mathgl-2.3.5.1/mgltex/Recompilation_decision.svg --- mathgl-2.3.4/mgltex/Recompilation_decision.svg 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/mgltex/Recompilation_decision.svg 2016-06-19 17:06:01.000000000 +0000 @@ -19,13 +19,125 @@ + + + + + + + + + + + + + + + + + + + + + + inkscape:isstock="true" + inkscape:collect="always"> image/svg+xml - + @@ -1218,95 +1330,107 @@ inkscape:groupmode="layer" id="layer1" transform="translate(56.035869,-48.362179)" /> - - + + Start - - FindStart + + + + \MGL@@@<script> - - Is itFind\MGL@@@<script> + + + + defined? - - CompareIs itdefined? + + + + script vs. code + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve">Comparescript vs. code + - Rewrite/recompile + script - - UndefineRewrite/recompilescript + + + + \MGL@@@<script> - - DefineUndefine\MGL@@@<script> + + + + \MGL@@@<script> - - Define\MGL@@@<script> + + + + End - - AretheyEnd + + + + equal? + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve">Aretheyequal? + - - + + Yes - - Yes + + + + Yes - - Yes + + + + No - - No + + + + No + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:27.5px;line-height:100%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;" + xml:space="preserve">No + diff -Nru mathgl-2.3.4/mgltex/sample.tex mathgl-2.3.5.1/mgltex/sample.tex --- mathgl-2.3.4/mgltex/sample.tex 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/mgltex/sample.tex 2016-06-19 17:06:01.000000000 +0000 @@ -1,472 +1,276 @@ \documentclass{article} -\usepackage[jpg,comments]{mgltex} +\usepackage[png,comments]{mgltex} +\usepackage{hyperref} -\title{\mglTeX{} package example} -\author{Diego Sejas Viscarra, Alexey Balakin} +\title{\mglTeX*{} usage sample} +\author{Diego Sejas Viscarra \and Alexey Balakin} \date{\today} -\mgldir{MGL/} -\mglscriptsdir{scripts/} -\mglgraphicsdir{graphics/} -\mglbackupsdir{backups/} - -\begin{mglcommon} - define gravity 9.81 -\end{mglcommon} - -%\begin{mglsignature} -% This scripts was generated on date |today. -%\end{mglsignature} - +\mglsettings{ + dir=MGL/, + scriptsdir=scripts/, + graphicsdir=graphics/, + backupsdir=backups/ +} + +\begin{mglsetupscript} + define gravity 9.81 # [m/s^2] +\end{mglsetupscript} \begin{document} - -\maketitle - -\noindent The \LaTeX{} package \textsf{\mglTeX} (was made by Diego Sejas Viscarra) allows one to make figures directly from MGL scripts located in \LaTeX{} file. - -For using this package you need to specify \texttt{--shell-escape} option for \emph{latex/pdflatex} or manually run \emph{mglconv} tool on produced MGL scripts for generation of images. Don't forget to run \emph{latex/pdflatex} a second time to insert the generated images into the output document. - -The package may have following options: \texttt{draft}, \texttt{final} --- the same as in the \emph{graphicx} package; \texttt{on}, \texttt{off} --- to activate/deactivate the creation of scripts and graphics; \texttt{comments}, \texttt{nocomments} --- to make visible/invisible commentaries contained inside \texttt{mglcomment} environments; \texttt{jpg}, \texttt{jpeg}, \texttt{png} --- to export graphics as JPEG/PNG images; \texttt{eps}, \texttt{epsz} --- to export to uncompressed/compressed EPS format as primitives; \texttt{bps}, \texttt{bpsz} --- to export to uncompressed/compressed EPS format as bitmap (doesn't work with \emph{pdflatex}); \texttt{pdf} --- to export to 3D PDF; \texttt{tex} --- to export to \LaTeX{}/\emph{tikz} document. - -The package defines the following environments: -\begin{description} -\item[mgl] - It writes its contents to a general script which has the same name as the LaTeX document, but its extension is \emph{.mgl}. The code in this environment is compiled and the image produced is included. It takes exactly the same optional arguments as the \texttt{\textbackslash{}includegraphics} command, plus an additional argument \emph{imgext}, which specifies the extension to save the image. -\item[mgladdon] - It adds its contents to the general script, without producing any image. It useful to set some global properties (like size of the images) at beginning of the document. -\item[mglcode] - Is exactly the same as \texttt{mgl}, but it writes its contents verbatim to its own file, whose name is specified as a mandatory argument. -\item[mglscript] - Is exactly the same as \texttt{mglcode}, but it doesn't produce any image, nor accepts optional arguments. It is useful, for example, to create a MGL script, which can later be post processed by another package like "listings". -\item[mglblock] - It writes its contents verbatim to a file, specified as a mandatory argument, and to the LaTeX document, and numerates each line of code. - -% This last three environments will test if the user is overwriting some file, and will issue a warning in that case. -\item[mglverbatim] - Exactly the same as \texttt{mglblock}, but it doesn't write to a file. This environment doesn't have arguments. -\item[mglfunc] - Is used to define MGL functions. It takes one mandatory argument, which is the name of the function, plus one additional argument, which specifies the number of arguments of the function. The environment needs to contain only the body of the function, since the first and last lines are appended automatically, and the resulting code is written at the end of the general script, which is also written automatically. The warning is produced if 2 or more function with the same name is defined. -\item[mglsignature] -Used to defined a commentary that will be added to every script. It is useful to include signature text or license text. Observe this is a verbatim-like environment, so no \LaTeX{} command will be executed inside it, but will be copied as is. - -As an alternative to this method of declaring signatures, the user can manually redefine the signature macro \texttt{\textbackslash{}mgltexsignature}, according to the following rules: - \begin{itemize} - \item The positions of the comment signs for the MGL language have to be manually specified in the signature using the \texttt{\textbackslash{}mglcomm} macro. - \item The new-line character is declared as ``\verb|^^J|''. - \item A percent sign (\texttt{\%}) has to be added at the end of every physical line of \texttt{\textbackslash{}mgltexsignature}, otherwise an inelegant space at the beginning of every line will appear. - \item Any \LaTeX{} command can be used in this case. -\end{itemize} - For example, the default signature: - \begin{mglcomment} - \begin{quote}\small - \mglcomm\\ - \mglcomm\ This script was generated from $<$document$>$.mgl on date $<$today$>$\\ - \mglcomm - \end{quote} - \end{mglcomment} - can be achieved with - \begin{verbatim} - \def\mgltexsignature{% - \mglcomm^^J% - \mglcomm\ This script was generated from \jobname.mgl on date \today^^J% - \mglcomm% - } - \end{verbatim} -\item[mglcomment] - Used to contain multiline commentaries. This commentaries will be visible/invisible in the output document, depending on the use of the package options \texttt{comments} and \texttt{nocomments} (see above), or the \texttt{\mglcomments{on}} and \texttt{\mglcomments{off}} commands (see bellow). - - When, visible, the comment will appear like this: - \begin{center} - \makeatletter - \verbatim@font - \makeatother - <------------------ MGL comment ------------------>\\ - $<$Commentary$>$\\ - <------------------ MGL comment ------------------>\\ - \end{center} -\item[mglsetup] - If many scripts with the same code are to be written, the repetitive code can be written inside this environment only once, then this code will be used automatically every time the \texttt{\textbackslash{}mglplot} command is used (see below). It takes one optional argument, which is a name to be associated to the corresponding contents of the environment; this name can be passed to the \texttt{\textbackslash{}mglplot} command to use the corresponding block of code automatically (see below). -\end{description} - -The package also defines the following commands: -\begin{description} -\item[\textbackslash{}mglplot] - It takes one mandatory argument, which is MGL instructions separated by the symbol ':' this argument can be more than one line long. It takes the same optional arguments as the \texttt{mgl} environment, plus an additional argument \emph{settings}, which indicates the name associated to a block of code inside a \texttt{mglsetup} environment. The code inside the mandatory argument will be appended to the block of code specified, and the resulting code will be written to the general script. -\item[\textbackslash{}mglgraphics] - This command takes the same optional arguments as the \texttt{mgl} environment, and one mandatory argument, which is the name of a MGL script. This command will compile the corresponding script and include the resulting image. It is useful when you have a script outside the LaTeX document, and you want to include the image, but you don't want to type the script again. -\item[\textbackslash{}mglinclude] - This is like \texttt{\textbackslash{}mglgraphics} but, instead of creating/including the corresponding image, it writes the contents of the MGL script to the LaTeX document, and numerates the lines. -\item[\textbackslash{}mgldir] - This command can be used in the preamble of the document to specify a directory where LaTeX will save the MGL scripts and generate the corresponding images. This directory is also where \texttt{\textbackslash{}mglgraphics} and \texttt{\textbackslash{}mglinclude} will look for scripts. -\item[\textbackslash{}mglquality] - Can be used to adjust the quality of the MGL graphics produced. The following table shows the available qualities: - \begin{center} - \begin{tabular}{cl} - \hline - Quality & Description\\ - \hline - \hline - $0$ & No face drawing (fastest)\\ - \hline - $1$ & No color interpolation (fast)\\ - \hline - $2$ & High quality (normal)\\ - \hline - $3$ & High quality with 3d primitives (not implemented yet)\\ - \hline - $4$ & No face drawing, direct bitmap drawing (low memory usage)\\ - \hline - $5$ & No color interpolation, direct bitmap drawing (low memory usage)\\ - \hline - $6$ & High quality, direct bitmap drawing (low memory usage)\\ - \hline - $7$ & High quality with 3d primitives, direct bitmap drawing (not implemented yet)\\ - \hline - $8$ & Draw dots instead of primitives (extremely fast)\\ - \hline - \end{tabular} - \end{center} -\item[\textbackslash{}mglswitch\{on\}, \textbackslash{}mglswitch\{off\}] - To activate/deactivate the creation of MGL scripts and images. Notice these commands have local behavior in the sense that their effect is from the point they are called on. -\item[\textbackslash{}mglcomment\{on\}, \textbackslash{}mglnocomment\{off\}] - To make visible/invisible the contents of the \texttt{mglcomment} environments. These commands have local effect too. -\item[\textbackslash{}mglTeX] - It just pretty prints the name of the package ``\mglTeX''. -\end{description} - - -An example of usage of \texttt{mgl} and \texttt{mglfunc} environments would be: -\begin{verbatim} -\begin{mglfunc}{prepare2d} - new a 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' - new b 50 40 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' -\end{mglfunc} - -\begin{figure}[!ht] - \centering - \begin{mgl}[width=0.85\textwidth,height=7.5cm] - fog 0.5 - call 'prepare2d' - subplot 2 2 0:title 'Surf plot (default)':rotate 50 60:light on:box:surf a - - subplot 2 2 1:title '"\#" style; meshnum 10':rotate 50 60:box - surf a '#'; meshnum 10 - - subplot 2 2 2 : title 'Mesh plot' : rotate 50 60 : box - mesh a - - new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)' - new y 50 40 '0.8*cos(pi*x)*sin(pi*(y+1)/2)' - new z 50 40 '0.8*cos(pi*(y+1)/2)' - subplot 2 2 3 : title 'parametric form' : rotate 50 60 : box - surf x y z 'BbwrR' - \end{mgl} -\end{figure} -\end{verbatim} -Note, that \texttt{mglfunc} environment(s) can be located at any position (at the beginning, at the end, or somewhere else) of LaTeX document. -\begin{mglfunc}{prepare2d} - new a 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' - new b 50 40 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' -\end{mglfunc} - -\begin{figure}[!ht] - \centering - \begin{mgl}[width=0.85\textwidth,height=7.5cm] - fog 0.5 - call 'prepare2d' - subplot 2 2 0 : title 'Surf plot (default)' : rotate 50 60 : light on : box : surf a - - subplot 2 2 1 : title '"\#" style; meshnum 10' : rotate 50 60 : box - surf a '#'; meshnum 10 - - subplot 2 2 2 : title 'Mesh plot' : rotate 50 60 : box - mesh a - - new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)' - new y 50 40 '0.8*cos(pi*x)*sin(pi*(y+1)/2)' - new z 50 40 '0.8*cos(pi*(y+1)/2)' - subplot 2 2 3 : title 'parametric form' : rotate 50 60 : box - surf x y z 'BbwrR' - \end{mgl} -\end{figure} - -Following example show the usage of \texttt{mglscript} environment -\begin{verbatim} -\begin{mglscript}{Vectorial} -call 'prepare2v' -subplot 3 2 0 '' : title 'lolo' : box -vect a b -subplot 3 2 1 '' : title '"." style; "=" style' : box -vect a b '.=' -subplot 3 2 2 '' : title '"f" style' : box -vect a b 'f' -subplot 3 2 3 '' : title '">" style' : box -vect a b '>' -subplot 3 2 4 '' : title '"<" style' : box -vect a b '<' -call 'prepare3v' -subplot 3 2 5 : title '3d variant' : rotate 50 60 : box -vect ex ey ez - -stop - -func 'prepare2v' - new a 20 30 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' - new b 20 30 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' -return - -func 'prepare3v' - define $1 pow(x*x+y*y+(z-0.3)*(z-0.3)+0.03,1.5) - define $2 pow(x*x+y*y+(z+0.3)*(z+0.3)+0.03,1.5) - new ex 10 10 10 '0.2*x/$1-0.2*x/$2' - new ey 10 10 10 '0.2*y/$1-0.2*y/$2' - new ez 10 10 10 '0.2*(z-0.3)/$1-0.2*(z+0.3)/$2' -return -\end{mglscript} -\end{verbatim} - -\begin{mglscript}{Vectorial} -call 'prepare2v' -subplot 3 2 0 '' : title 'lolo' : box -vect a b -subplot 3 2 1 '' : title '"." style; "=" style' : box -vect a b '.=' -subplot 3 2 2 '' : title '"f" style' : box -vect a b 'f' -subplot 3 2 3 '' : title '">" style' : box -vect a b '>' -subplot 3 2 4 '' : title '"<" style' : box -vect a b '<' -call 'prepare3v' -subplot 3 2 5 : title '3d variant' : rotate 50 60 : box -vect ex ey ez - -stop - -func 'prepare2v' - new a 20 30 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' - new b 20 30 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' -return - -func 'prepare3v' - define $1 pow(x*x+y*y+(z-0.3)*(z-0.3)+0.03,1.5) - define $2 pow(x*x+y*y+(z+0.3)*(z+0.3)+0.03,1.5) - new ex 10 10 10 '0.2*x/$1-0.2*x/$2' - new ey 10 10 10 '0.2*y/$1-0.2*y/$2' - new ez 10 10 10 '0.2*(z-0.3)/$1-0.2*(z+0.3)/$2' -return -\end{mglscript} - -You should use \texttt{\textbackslash{}mglgraphics} command to display its contents -\begin{verbatim} -\begin{figure}[!ht] - \centering - \mglgraphics[width=40em,height=20em]{Vectorial} - \caption{A beautiful example} -\end{figure} -\end{verbatim} - -\begin{figure}[!ht] - \centering - \mglgraphics[width=40em,height=20em]{Vectorial} - \caption{A beautiful example} -\end{figure} - -Alternatively, you can display the contents of the script in parallel to saving to a file, if you are using \texttt{mglblock} environment -\begin{verbatim} -\begin{mglblock}{Axis_projection} - ranges 0 1 0 1 0 1 - new x 50 '0.25*(1+cos(2*pi*x))' - new y 50 '0.25*(1+sin(2*pi*x))' - new z 50 'x' - new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)' - new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx - light on - - title 'Projection sample':ternary 4:rotate 50 60 - box:axis:grid - plot x y z 'r2':surf a '#' - xlabel 'X':ylabel 'Y':zlabel 'Z' -\end{mglblock} -\begin{figure}[!ht] - \centering - \mglgraphics[scale=0.5]{Axis_projection} - \caption{The image from Axis\_projection.mgl script} -\end{figure} -\end{verbatim} - -\begin{mglblock}{Axis_projection} - ranges 0 1 0 1 0 1 - new x 50 '0.25*(1+cos(2*pi*x))' - new y 50 '0.25*(1+sin(2*pi*x))' - new z 50 'x' - new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)' - new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx - light on - - title 'Projection sample':ternary 4:rotate 50 60 - box:axis:grid - plot x y z 'r2':surf a '#' - xlabel 'X':ylabel 'Y':zlabel 'Z' + + \maketitle + + \begin{abstract} + \noindent \mglTeX{} is a \LaTeX{} package that allows the creation of graphics directly from MGL scripts of the MathGL library (by Alexey Balakin) inside documents. The MGL code is extracted, executed (if shell escape is activated), and the resulting graphics are automatically included. + + This document is intended as a sample of the capabilities of \mglTeX{}, as well as a brief introduction to the package, for those who want to start right away to use it, without diving into the a little bit more technical documentation. + \end{abstract} + + \section{Basics on environments} + \begin{description} + \item[mgl] The easiest way to embed MGL code is the \verb|mgl| environment. It extracts its contents to a main script associated to the document.\footnote{Generally, the main script has the same name as the document being compiled. In order to rename it or create a new one, the \texttt{\textbackslash mglname} command can be used.} If shell escape is activated, \LaTeX{} will take care of calling \verb|mglconv| (the MathGL compiler) with the appropriate settings, and the resulting image will be automatically included. + + For example, you could write: + \begin{verbatim} + \begin{figure}[!ht] + \centering + \begin{mgl}[width=0.85\textwidth,height=6cm] + call 'prepare1d' + subplot 2 1 0 '<_' : title 'Standard data plot' + box : axis : grid 'xy' ';k' + plot y ’rGb’ + + subplot 2 1 1 '<_' : title 'Region plot' + ranges -1 1 -1 1 : origin 0 0 + new y1 200 'x^3-x' : new y2 200 'x' + axis : grid 'xy' 'W' + region y1 y2 'ry' + plot y1 '2k' : plot y2 '2k' + text -0.75 -0.35 '\i{A}_1' 'k' : text 0.75 0.25 '\i{A}_2' 'k' + \end{mgl} + \caption{A simple plot create by \mglTeX's \texttt{mgl} environment} + \end{figure} + \end{verbatim} + This will produce the following image: + \begin{figure}[!ht] + \centering + \begin{mgl}[width=0.85\textwidth,height=5.5cm] + call 'prepare1d' + subplot 2 1 0 '<_' : title 'Standard data plot' + box : axis : grid 'xy' ';k' + plot y '2' + + subplot 2 1 1 '<_' : title 'Region plot' + ranges -1 1 -1 1 : origin 0 0 + new y1 200 'x^3-x' : new y2 200 'x' + axis 'AKDTVISO' : grid 'xy' ';W' + region y1 y2 'ry' + plot y1 '2k' : plot y2 '2k' + text -0.75 -0.35 '\i{A}_1' 'k' -2 : text 0.75 0.25 '\i{A}_2' 'k' -2 + \end{mgl} + \caption{A simple plot create by \mglTeX's \texttt{mgl} environment} + \end{figure} + + Two important aspects of \mglTeX{} can be noted from this example: First, the \verb|mgl| environment accepts the same optional argument as the \verb|\includegraphics| command from the \verb|graphicx| package. Actually, it also accepts other optional arguments, called \verb|gray| (to activate/deactivate gray-scale mode), \verb|mglscale| (to set the factor for scaling the image file), \verb|quality| (to set the quality of the image), \verb|variant| (to chose the variant of the arguments of MGL commands in the script), \verb|imgext| (to specify the extension of the resulting graphic file), and \verb|label| (to specify a name to save the image). Most of these options are available to every \mglTeX{} environment or command to create graphics. + + The second aspect to be noted about the example is that this script calls a MGL function, \verb|prepare1d|, which hasn't been defined yet. \mglTeX{} provides the \verb|mglfunc| environment for this purpose (see below). + + \item[mglfunc] This environment can be used in any part of the \LaTeX{} document; \mglTeX{} takes care of placing the corresponding code at the end of the main script, as has to be done in the MGL language. + + For example, the function \verb|prepare1d| that is called in the script above is defined like this + \begin{verbatim} + \begin{mglfunc}{prepare1d} + new y 50 3 + modify y '0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)' + modify y 'sin(2*pi*x)' 1 + modify y 'cos(2*pi*x)' 2 + \end{mglfunc} + \end{verbatim} + \begin{mglfunc}{prepare1d} + new y 50 3 + modify y '0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)' + modify y 'sin(2*pi*x)' 1 + modify y 'cos(2*pi*x)' 2 + \end{mglfunc} + As you can see, only the body of the function has to be written. The number of arguments of the function can be passed to \verb|mglfunc| as optional argument, like in the code \verb|\begin{mglfunc}[3]{func_with_three_args}|. + + \item[mgladdon] This environment just adds its contents to the main script, without producing any image. It is useful to load dynamic libraries, define constants, etc. + + \item[mglcode] The \verb|mglcode| environment is similar to \verb|mgl|, but it creates its own script, whose name is passed as mandatory argument. The same optional arguments are accepted, except \verb|label| (for obvious reasons). + \begin{verbatim} + \begin{figure}[!ht] + \begin{mglcode}[scale=0.5]{vectorial_flow} + new a 20 30 'sin(pi*x)*sin(pi*y)+cos(2*pi*x*y)' + new b 20 30 'cos(pi*x)*cos(pi*y)+cos(2*pi*x*y)' + + subplot 1 1 0 '' : title 'Flow of vector field' : box + flow a b 'v'; value 20 + \end{mglcode} + \end{figure} + \end{verbatim} + \begin{figure}[!ht] + \centering + \begin{mglcode}[scale=0.5]{vectorial_flow} + new a 20 30 'sin(pi*x)*sin(pi*y)+cos(2*pi*x*y)' + new b 20 30 'cos(pi*x)*cos(pi*y)+cos(2*pi*x*y)' + + subplot 1 1 0 '' : title 'Flow of a vector field' : box + flow a b '2v'; value 10 + \end{mglcode} + \end{figure} + + \item[mglscript] This environment just creates a script, whose name is specified as mandatory argument. It is useful, for example, to create MGL scripts which can later be post-processed by another package, like \verb|listings| or \verb|pygments|. + + For example, the following won't produce any image, just a script: + \begin{verbatim} + \begin{mglscript}{Gaston_surface} + subplot 1 1 0 '' : title 'Gaston\'s surface' + ranges -13 13 -40 40 + new a 200 200 '-x+(2*0.84*cosh(0.4*x)*sinh(0.4*x))/' \ + '(0.4*((sqrt(0.84)*cosh(0.4*x))^2+(0.4*sin(sqrt(0.84)*y))))+' \ + '0.5*sin(pi/2*x)' + new b 200 200 '(2*sqrt(0.84)*cosh(0.45*x)*(-(sqrt(0.84)*sin(y)*' \ + 'cos(sqrt(0.84)*y))+cos(y)*sin(sqrt(0.84)*y)))/' \ + '(0.4*((sqrt(0.84)*cosh(0.4*x))^2+2*(0.4*sin(sqrt(0.84)*x))^2))' + new c 200 200 '(2*sqrt(0.84)*cosh(0.45*x)*(-(sqrt(0.84)*cos(y)*' \ + 'cos(sqrt(0.84)*y))-sin(y)*sin(sqrt(0.84)*y)))/' \ + '(0.4*((sqrt(0.84)*cosh(0.4*x))^2+2*(0.4*sin(sqrt(0.84)*x))^2))' + rotate 60 60 + light on + xrange c : yrange b : zrange a : crange c + surf c b a '#'; meshnum 100 + \end{mglscript} + \end{verbatim} + \begin{mglscript}{Gaston_surface} + subplot 1 1 0 '' + ranges -13 13 -40 40 + new a 200 200 '-x+(2*0.84*cosh(0.4*x)*sinh(0.4*x))/(0.4*((sqrt(0.84)*cosh(0.4*x))^2+(0.4*sin(sqrt(0.84)*y))))+0.5*sin(pi/2*x)' + new b 200 200 '(2*sqrt(0.84)*cosh(0.45*x)*(-(sqrt(0.84)*sin(y)*cos(sqrt(0.84)*y))+cos(y)*sin(sqrt(0.84)*y)))/(0.4*((sqrt(0.84)*cosh(0.4*x))^2+2*(0.4*sin(sqrt(0.84)*x))^2))' + new c 200 200 '(2*sqrt(0.84)*cosh(0.45*x)*(-(sqrt(0.84)*cos(y)*cos(sqrt(0.84)*y))-sin(y)*sin(sqrt(0.84)*y)))/(0.4*((sqrt(0.84)*cosh(0.4*x))^2+2*(0.4*sin(sqrt(0.84)*x))^2))' + rotate 60 60 + light on + xrange c : yrange b : zrange a : crange c + surf c b a '#'; meshnum 100 + title 'Gaston surface' + \end{mglscript} + + \item[mglblock] It writes its contents verbatim to a file, specified as mandatory argument, and to the \LaTeX{} document. + + For example: + \begin{verbatim} + \begin{mglblock}{fractal} + list A [0,0,0,.16,0,0,.01] [.85,.04,-.04,.85,0,1.6,.85] [.2,-.26,.23,.22,0,1.6,.07] [-.15,.28,.26,.24,0,.44,.07] + ifs2d f A 100000 + subplot 2 1 0 '<_' : title 'A fractal fern' + ranges f(0) f(1) : axis + plot f(0) f(1) 'G#o '; size 0.05 + + subplot 2 1 1 '<_' : title 'Bifurcation plot' + ranges 0 4 0 1 : axis + bifurcation 0.005 'x*y*(1-y)' 'R' + \end{mglblock} + \end{verbatim} +\begin{mglblock}{fractal} +list A [0,0,0,.16,0,0,.01] [.85,.04,-.04,.85,0,1.6,.85] [.2,-.26,.23,.22,0,1.6,.07] [-.15,.28,.26,.24,0,.44,.07] +ifs2d f A 100000 +subplot 2 1 0 '<_' : title 'A fractal fern' +ranges f(0) f(1) : axis +plot f(0) f(1) 'G#o '; size 0.05 + +subplot 2 1 1 '<_' : title 'Bifurcation plot' +ranges 0 4 0 1 : axis +bifurcation 0.005 'x*y*(1-y)' 'R' \end{mglblock} -\begin{figure}[!ht] - \centering - \mglgraphics[scale=0.5]{Axis_projection} - \caption{The image from Axis\_projection.mgl script} -\end{figure} - -Finally, you can just show MGL script itself -\begin{verbatim} -\begin{mglverbatim} - ranges 0 1 0 1 0 1 - new x 50 '0.25*(1+cos(2*pi*x))' - new y 50 '0.25*(1+sin(2*pi*x))' - new z 50 'x' - new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)' - new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx - light on - - title 'Projection sample':ternary 4:rotate 50 60 - box:axis:grid - plot x y z 'r2':surf a '#' - xlabel 'X':ylabel 'Y':zlabel 'Z' -\end{mglverbatim} -\end{verbatim} - -\begin{mglverbatim} - ranges 0 1 0 1 0 1 - new x 50 '0.25*(1+cos(2*pi*x))' - new y 50 '0.25*(1+sin(2*pi*x))' - new z 50 'x' - new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)' - new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx - light on - - title 'Projection sample':ternary 4:rotate 50 60 - box:axis:grid - plot x y z 'r2':surf a '#' - xlabel 'X':ylabel 'Y':zlabel 'Z' -\end{mglverbatim} - - -An example of usage of \texttt{\textbackslash{}mglplot} command would be: -\begin{verbatim} -\begin{mglsetup} - box '@{W9}' : axis -\end{mglsetup} -\begin{mglsetup}[2d] - box : axis - grid 'xy' ';k' -\end{mglsetup} -\begin{mglsetup}[3d] - rotate 50 60 - box : axis : grid 'xyz' ';k' -\end{mglsetup} -\begin{figure}[!ht] - \centering - \mglplot[scale=0.5]{new a 200 'sin(pi*x)':plot a '2B'} -\end{figure} -\begin{figure}[!ht] - \centering - \mglplot[scale=0.5,settings=2d]{ - fplot 'sin(pi*x)' '2B' : - fplot 'cos(pi*x^2)' '2R' - } -\end{figure} -\begin{figure}[!ht] - \centering - \mglplot[width=0.5 \textwidth, settings=3d] - {fsurf 'sin(pi*x)+cos(pi*y)'} -\end{figure} -\end{verbatim} - -\begin{mglsetup}{generic} - box '@{W9}' : axis -\end{mglsetup} -\begin{mglsetup}{2d} - box : axis - grid 'xy' ';k' -\end{mglsetup} -\begin{mglsetup}{3d} - rotate 50 60 - box : axis : grid 'xyz' ';k' -\end{mglsetup} -\begin{figure}[!ht] - \centering - \mglplot[scale=0.5,setup=generic]{new a 200 'x' : fplot 'sin(pi*x)' '2R' : plot a '2B'} -\end{figure} -\begin{figure}[!ht] - \centering - \mglplot[scale=0.5,setup=2d]{% - fplot 'sin(pi*x)' '2B' :% - fplot 'cos(pi*x^2)' '2R'% - } -\end{figure} -\begin{figure}[!ht] - \centering - \mglplot[width=0.5\textwidth, setup=3d]{fsurf 'sin(pi*x)+cos(pi*y)'} -\end{figure} - -As an additional feature, when an image is not found or cannot be included, instead of issuing an error, \texttt{mgltex} prints a box with the word \emph{'MGL image not found'} in the LaTeX document. -\begin{figure}[!ht] - \centering - \mglgraphics{xyz} -\end{figure} - -Let's display the content of the MGL file using \texttt{\textbackslash{}mglinclude} command: -\mglinclude{Vectorial} - -The following commentary will be visible, since \mglTeX{} has been called with the \texttt{comments} option. -\begin{verbatim} - \begin{mglcomment} - This is a visible commentary - that can have multiple lines - \end{mglcomment} -\end{verbatim} -The result is: + As you can see, although this is a verbatim-like environment, very long lines of code are split to fit the paragraph. Each line of code is numbered, this can be disabled with the \verb|lineno| option, like \verb|\begin{mglblock}[lineno=false]{fractal}|. + + \item[mglverbatim] This is like \verb|mglblock| environment, but it doesn't produce any script, just typesets the code to the \LaTeX{} document. It accepts the \verb|lineno| option, plus the \verb|label| option, in case you want to associate a name to the code. + + \item[mglcomment] This environment is used to embed comments in the document. You can control whether the contents of this environment are displayed or not, using the \verb|comments| and \verb|nocomments| package options, or the \verb|\mglcomments{on}| and \verb|mglcomments{off}| commands. + + An example of this would be: + \begin{verbatim} + \begin{mglcomments} + This comment will be shown because we used the "comments" package option for mglTeX + \end{mglcomments} + \end{verbatim} \begin{mglcomment} - This is a visible commentary - that can have multiple lines +This comment will be shown because we used the "comments" package option for mglTeX \end{mglcomment} - -The following commentary won't be visible, since it is wrapped by \texttt{\textbackslash{}mglnocomments\{off\}} and \texttt{\textbackslash{}mglcomments\{on\}}. -\begin{verbatim} - \mglcomments{off} - \begin{mglcomment} - This is an invisible commentary - that can have multiple lines - \end{mglcomment} - \mglcomments{on} -\end{verbatim} -\mglcomments{off} -\begin{mglcomment} - This is an invisible commentary - that can have multiple lines -\end{mglcomment} -\mglcomments{on} - -The last example is the use of the \texttt{\textbackslash{}mglswitch\{on\}} and \texttt{\textbackslash{}mglswitch\{off\}} commands. For example, the following image won't be generated: -\begin{verbatim} - \mglswitch{off} - \begin{figure}[!ht] - \centering - \begin{mgl} - box : axis - fplot 'sin(pi*x)' '2B' - \end{mgl} - \end{figure} - \mglswitch{on} -\end{verbatim} -The result is: -\mglswitch{off} -\begin{figure}[!ht] - \centering - \begin{mgl} - box : axis - fplot 'sin(pi*x)' '2B' - \end{mgl} -\end{figure} -\mglswitch{on} + Once again, long lines are broke down to fit the paragraph. + \end{description} + + \section{Basics on commands} + \begin{description} + \item[\textbackslash mglgraphics] This command takes the name of an external MGL script, compiles it, and includes the resulting image. It accespt the same optional arguments as the \verb|mgl| environment, except for \verb|label|, plus a \verb|path| option, which can be used to specify the location of the script. This is useful when you have a script outside of the \LaTeX{} document (sent by a colleague for example), but you don't want to transcript it to your document. + + For example, in order to display the image of the script we created with \verb|mglscript| environment, we write: + \begin{verbatim} + \begin{figure}[!ht] + \centering + \mglgraphics[height=9cm,width=9cm]{Gaston_surface} + \caption{Gaston's surface} + \end{figure} + \end{verbatim} + \begin{figure}[!ht] + \centering + \mglgraphics[height=9cm,width=9cm]{Gaston_surface} + \caption{Gaston's surface: Three-dimensional parametric surface} + \end{figure} + + We could also could compile the script we created with the \verb|mglblock| environment: + \begin{verbatim} + \begin{figure}[!ht] + \centering + \mglgraphics[height=7cm,width=10cm]{fractal} + \caption{Examples of fractal behavior} + \end{figure} + \end{verbatim} + \begin{figure}[!ht] + \centering + \mglgraphics[height=7cm,width=10cm]{fractal} + \caption{Examples of fractal behavior} + \end{figure} + + \item[\textbackslash mglinclude] This is equivalent to the \verb|mglblock| environment, but works for external scripts. + + \item[\textbackslash mglplot] This command allows the fast creation of plots. It takes one mandatory argument, which is a block of MGL code to produce the plot. Accepts the same optional arguments as the \verb|mgl| environment, plus an additional one, \verb|setup|, that can be used to specify a block of code to append, defined inside a \verb|mglsetup| environment (see the example below). + + The \verb|mglsetup| environment can be used if many plots will have the same settings (background color, etc.). Instead of writing the same code over and over again, it can be introduced in that environment, and used with the \verb|\mglplot| command. + + An example of use of the \verb|mglsetup| environment and the \verb|\mglplot| command would be: + \begin{verbatim} + \begin{mglsetup}{3d} + clf 'W' + rotate 50 60 + light on + box : axis : grid 'xyz' ';k' + \end{mglsetup} + \begin{figure}[!ht] + \centering + \mglplot[setup=3d,scale=0.5]{fsurf 'cos(4*pi*hypot(x,y))*exp(-abs(x+y))'} + \end{figure} + \begin{figure}[!ht] + \centering + \mglplot[setup=3d,scale=0.5]{fsurf 'sin(pi*(x+y))'} + \end{figure} + \end{verbatim} + \begin{mglsetup}{3d} + clf 'W' + rotate 50 60 + light on : light 0 0 1 0 'w' 0.25 + box : axis : grid 'xyz' ';k' + \end{mglsetup} + \begin{figure}[!ht] + \centering + \mglplot[setup=3d,scale=0.5]{fsurf 'cos(4*pi*hypot(x,y))*exp(-abs(x+y))'} + \end{figure} + \begin{figure}[!ht] + \centering + \mglplot[setup=3d,scale=0.5]{fsurf 'sin(pi*(x+y))'} + \end{figure} + \end{description} + + There are more environments and commands defined by \mglTeX{}. The ones presented here are the most basic. More on this topic can be found in the documentation. \end{document} \ No newline at end of file diff -Nru mathgl-2.3.4/src/addon.cpp mathgl-2.3.5.1/src/addon.cpp --- mathgl-2.3.4/src/addon.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/addon.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * addon.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -171,6 +171,7 @@ memcpy(b,d,n*sizeof(dual)); switch(Border) { + default: case 0: // zero at border b[0] = 0; b[n-1] = 0; break; case 1: // constant at border diff -Nru mathgl-2.3.4/src/axis.cpp mathgl-2.3.5.1/src/axis.cpp --- mathgl-2.3.4/src/axis.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/axis.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * axis.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -216,8 +216,8 @@ UpdateAxis(); time_t tt; tm t1,t2; - tt=aa.v1; mgl_localtime(&tt, &t1, get(MGL_USE_GMTIME)); - tt=aa.v2; mgl_localtime(&tt, &t2, get(MGL_USE_GMTIME)); + tt=(time_t)aa.v1; mgl_localtime(&tt, &t1, get(MGL_USE_GMTIME)); + tt=(time_t)aa.v2; mgl_localtime(&tt, &t2, get(MGL_USE_GMTIME)); if(aa.v1 * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/src/base.cpp mathgl-2.3.5.1/src/base.cpp --- mathgl-2.3.4/src/base.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/base.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * base.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -20,6 +20,28 @@ #include "mgl2/font.h" #include "mgl2/base.h" #include "mgl2/eval.h" +#if MGL_HAVE_OMP +#include +#endif + +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mutex_unlock(void *mutex) +{ +#if MGL_HAVE_PTHREAD + pthread_mutex_unlock((pthread_mutex_t *)mutex); +#elif MGL_HAVE_OMP + omp_unset_lock((omp_lock_t *)mutex); +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mutex_lock(void *mutex) +{ +#if MGL_HAVE_PTHREAD + pthread_mutex_lock((pthread_mutex_t *)mutex); +#elif MGL_HAVE_OMP + omp_set_lock((omp_lock_t *)mutex); +#endif +} //----------------------------------------------------------------------------- char *mgl_strdup(const char *s) { @@ -105,13 +127,16 @@ pthread_mutex_init(&mutexClf,0); Pnt.set_mutex(&mutexClf); Prm.set_mutex(&mutexClf); - Txt.set_mutex(&mutexClf); +// Txt.set_mutex(&mutexClf); #endif #if MGL_HAVE_OMP - omp_init_lock(&lockClf); - Pnt.set_mutex(&lockClf); - Prm.set_mutex(&lockClf); - Txt.set_mutex(&lockClf); + lockClf = new omp_lock_t; + omp_init_lock((omp_lock_t*)lockClf); + Pnt.set_mutex(lockClf); + Prm.set_mutex(lockClf); +// Txt.set_mutex(&lockClf); +#else + lockClf = NULL; #endif fnt=0; *FontDef=0; fx=fy=fz=fa=fc=0; AMin.Set(0,0,0,0); AMax.Set(1,1,1,1); @@ -127,12 +152,28 @@ MinS.Set(-1,-1,-1); MaxS.Set(1,1,1); fnt = new mglFont; fnt->gr = this; PrevState=NAN; size_opt=NAN; } +//----------------------------------------------------------------------------- mglBase::~mglBase() { ClearEq(); ClearPrmInd(); delete fnt; - Pnt.set_mutex(0); Prm.set_mutex(0); Txt.set_mutex(0); + Pnt.set_mutex(0); Prm.set_mutex(0); //Txt.set_mutex(0); +#if MGL_HAVE_PTHREAD + pthread_mutex_destroy(&mutexPnt); + pthread_mutex_destroy(&mutexTxt); + pthread_mutex_destroy(&mutexSub); + pthread_mutex_destroy(&mutexLeg); + pthread_mutex_destroy(&mutexPrm); + pthread_mutex_destroy(&mutexPtx); + pthread_mutex_destroy(&mutexStk); + pthread_mutex_destroy(&mutexGrp); + pthread_mutex_destroy(&mutexGlf); + pthread_mutex_destroy(&mutexAct); + pthread_mutex_destroy(&mutexDrw); + pthread_mutex_destroy(&mutexClf); +#endif #if MGL_HAVE_OMP - omp_destroy_lock(&lockClf); + omp_destroy_lock((omp_lock_t*)lockClf); + delete ((omp_lock_t*)lockClf); #endif } //----------------------------------------------------------------------------- @@ -299,6 +340,11 @@ if(ci<0 || ci>=(long)Txt.size()) ci=0; // NOTE never should be here!!! const mglTexture &txt=Txt[ci]; txt.GetC(c,a,q); // RGBA color + if(get(MGL_GRAY_MODE)) + { + float h = 0.3*q.r + 0.59*q.g + 0.11*q.b; + q.r = q.g = q.b = h; + } // add gap for texture coordinates for compatibility with OpenGL const mreal gap = 0./MGL_TEXTURE_COLOURS; @@ -310,7 +356,7 @@ if(!get(MGL_ENABLE_ALPHA)) { q.a=1; if(txt.Smooth!=2) q.ta=1-gap; } if(norefr) q.v=0; if(!get(MGL_ENABLE_LIGHT) && !(scl&4)) q.u=q.v=NAN; - q.sub=mat->norot?-Sub.size():Sub.size()-1; + q.sub=mat->norot?-1*(short)Sub.size():Sub.size()-1; long k; #pragma omp critical(pnt) {k=Pnt.size(); MGL_PUSH(Pnt,q,mutexPnt);} return k; diff -Nru mathgl-2.3.4/src/canvas_cf.cpp mathgl-2.3.5.1/src/canvas_cf.cpp --- mathgl-2.3.4/src/canvas_cf.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/canvas_cf.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * canvas_cf.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -83,6 +83,7 @@ void MGL_EXPORT mgl_set_transp_type(HMGL gr, int type) { mglCanvas *g = dynamic_cast(gr); if(g) g->SetTranspType(type); } void MGL_EXPORT mgl_set_alpha(HMGL gr, int enable) { gr->Alpha(enable); } +void MGL_EXPORT mgl_set_gray(HMGL gr, int enable) { gr->set(enable, MGL_GRAY_MODE); } void MGL_EXPORT mgl_set_fog(HMGL gr, double d, double dz) { mglCanvas *g = dynamic_cast(gr); if(g) g->Fog(d,dz); } void MGL_EXPORT mgl_set_light(HMGL gr, int enable) { gr->Light(enable); } @@ -159,9 +160,13 @@ //----------------------------------------------------------------------------- void MGL_EXPORT mgl_stickplot(HMGL gr, int num, int i, double tet, double phi) { mglCanvas *g = dynamic_cast(gr); if(g) g->StickPlot(num, i, tet, phi); } +void MGL_EXPORT mgl_shearplot(HMGL gr, int num, int i, double sx, double sy, double xd, double yd) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->ShearPlot(num, i, sx, sy, xd, yd); } //----------------------------------------------------------------------------- void MGL_EXPORT mgl_aspect(HMGL gr, double Ax,double Ay,double Az) { mglCanvas *g = dynamic_cast(gr); if(g) g->Aspect(Ax,Ay,Az); } +void MGL_EXPORT mgl_shear(HMGL gr, double Sx,double Sy) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Shear(Sx,Sy); } void MGL_EXPORT mgl_rotate(HMGL gr, double TetX,double TetZ,double TetY) { mglCanvas *g = dynamic_cast(gr); if(g) g->Rotate(TetX,TetZ,TetY); } void MGL_EXPORT mgl_view(HMGL gr, double TetX,double TetZ,double TetY) @@ -191,6 +196,7 @@ //----------------------------------------------------------------------------- void MGL_EXPORT mgl_set_transp_type_(uintptr_t *gr, int *type) { _GR_->SetTranspType(*type); } void MGL_EXPORT mgl_set_alpha_(uintptr_t *gr, int *enable) { _GR_->Alpha(*enable); } +void MGL_EXPORT mgl_set_gray_(uintptr_t *gr, int *enable) { _GR_->set(*enable, MGL_GRAY_MODE); } void MGL_EXPORT mgl_set_fog_(uintptr_t *gr, mreal *d, mreal *dz) { _GR_->Fog(*d, *dz); } void MGL_EXPORT mgl_set_light_(uintptr_t *gr, int *enable) { _GR_->Light(*enable); } void MGL_EXPORT mgl_set_attach_light_(uintptr_t *gr, int *enable) { _GR_->AttachLight(*enable); } @@ -236,6 +242,8 @@ { mgl_gridplot(_GR_,*nx,*ny,*i,*d); } void MGL_EXPORT mgl_stickplot_(uintptr_t *gr, int *num, int *i, mreal *tet, mreal *phi) { _GR_->StickPlot(*num, *i, *tet, *phi); } +void MGL_EXPORT mgl_shearplot_(uintptr_t *gr, int *num, int *i, mreal *sy, mreal *sx, mreal *xd, mreal *yd) +{ _GR_->ShearPlot(*num,*i,*sx,*sy,*xd,*yd); } void MGL_EXPORT mgl_title_(uintptr_t *gr, const char *title, const char *stl, mreal *size, int l,int m) { char *t=new char[l+1]; memcpy(t,title,l); t[l]=0; @@ -243,6 +251,8 @@ _GR_->Title(t,s,*size); delete []s; delete []t; } void MGL_EXPORT mgl_aspect_(uintptr_t *gr, mreal *Ax, mreal *Ay, mreal *Az) { _GR_->Aspect(*Ax,*Ay,*Az); } +void MGL_EXPORT mgl_shear_(uintptr_t *gr, mreal *Sx, mreal *Sy) +{ _GR_->Shear(*Sx,*Sy); } void MGL_EXPORT mgl_rotate_(uintptr_t *gr, mreal *TetX, mreal *TetZ, mreal *TetY) { _GR_->Rotate(*TetX,*TetZ,*TetY); } void MGL_EXPORT mgl_view_(uintptr_t *gr, mreal *TetX, mreal *TetZ, mreal *TetY) @@ -399,7 +409,7 @@ void MGL_EXPORT mgl_set_ticks_val_(uintptr_t *gr, const char *dir, uintptr_t *val, const char *lbl, int *add,int,int l) { char *s=new char[l+1]; memcpy(s,lbl,l); s[l]=0; _GR_->SetTicksVal(*dir,_DA_(val),s,*add); delete []s; } -void MGL_EXPORT mgl_add_tick_(uintptr_t *gr, const char *dir, mreal *val, const char *lbl, int *add,int,int l) +void MGL_EXPORT mgl_add_tick_(uintptr_t *gr, const char *dir, mreal *val, const char *lbl, int,int l) { char *s=new char[l+1]; memcpy(s,lbl,l); s[l]=0; mgl_add_tick(_GR_,*dir,*val,s); delete []s; } void MGL_EXPORT mgl_tune_ticks_(uintptr_t *gr, int *tune, mreal *fact_pos) diff -Nru mathgl-2.3.4/src/canvas.cpp mathgl-2.3.5.1/src/canvas.cpp --- mathgl-2.3.4/src/canvas.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/canvas.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * canvas.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -763,7 +763,7 @@ mreal fz=exp(M_LN10*floor(0.5+log10(fabs(dz/dx)))); if(Ay>0) fy*=Ay; if(Az>0) fz*=Az; - Ax = Height*dx; Ay = Width*dy*fy; Az = Depth*dz*fz; + Ax = inH*dx; Ay = inW*dy*fy; Az = sqrt(inW*inH)*dz*fz; } mreal a = fabs(Ax) > fabs(Ay) ? fabs(Ax) : fabs(Ay); a = a > fabs(Az) ? a : fabs(Az); @@ -775,6 +775,32 @@ size_t n = Sub.size(); if(n>0) Sub[n-1].B = B; } //----------------------------------------------------------------------------- +void mglCanvas::Shear(mreal Sx,mreal Sy) +{ + mreal R[6], Fx=1+fabs(Sx)*inH/inW, Fy=1+fabs(Sy)*inW/inH; + memcpy(R,B.b,6*sizeof(mreal)); + B.b[0] = (R[0]+Sx*R[3])/Fx; B.b[1] = (R[1]+Sx*R[4])/Fx; B.b[2] = (R[2]+Sx*R[5])/Fx; + B.b[3] = (R[3]+Sy*R[0])/Fy; B.b[4] = (R[4]+Sy*R[1])/Fy; B.b[5] = (R[5]+Sy*R[2])/Fy; + size_t n = Sub.size(); if(n>0) Sub[n-1].B = B; +} +//----------------------------------------------------------------------------- +void mglCanvas::ShearPlot(int num, int id, mreal sx, mreal sy, mreal xd, mreal yd) +{ + InPlot(0,1,0,1,true); + if(!(fabs(xd)<=1 && fabs(yd)<=1)) { xd=1; yd=0; } + mreal wx,wy,dx,dy,wf,hf,x1,y1; + int ix=sy>=0?id:num-id-1, iy=sx>=0?id:num-id-1; + for(int i=0;i<3;i++) // iterations to solve cubic equation + { + wx = fabs(sx)*inH/inW; dx = xd + yd*wx; wf = 1+wx+(num-1)*fabs(dx); + wy = fabs(sy)*inW/inH; dy = yd + xd*wy; hf = 1+wy+(num-1)*fabs(dy); + x1=(dx>=0?ix:(ix-num+1))*dx; + y1=(dy>=0?iy:(iy-num+1))*dy; + InPlot(x1/wf,(x1+1+wx)/wf,y1/hf,(y1+1+wy)/hf,true); + } + Shear(sx,sy); +} +//----------------------------------------------------------------------------- // Lighting and transparency //----------------------------------------------------------------------------- void mglCanvas::Fog(mreal d, mreal dz) { FogDist=d; FogDz = dz; } diff -Nru mathgl-2.3.4/src/CMakeLists.txt mathgl-2.3.5.1/src/CMakeLists.txt --- mathgl-2.3.4/src/CMakeLists.txt 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/CMakeLists.txt 2016-06-19 17:01:20.000000000 +0000 @@ -4,8 +4,8 @@ data.cpp data_io.cpp data_ex.cpp data_png.cpp export_2d.cpp export_3d.cpp eval.cpp evalp.cpp exec.cpp export.cpp fit.cpp font.cpp obj.cpp other.cpp parser.cpp pde.cpp pixel.cpp - plot.cpp prim.cpp surf.cpp tex_table.cc vect.cpp volume.cpp evalc.cpp - s_hull/s_hull_pro.cpp window.cpp + plot.cpp prim.cpp surf.cpp vect.cpp volume.cpp evalc.cpp + s_hull/s_hull_pro.cpp window.cpp fractal.cpp ) set(mgl_hdr @@ -20,6 +20,7 @@ ../include/mgl2/parser.h ../include/mgl2/addon.h ../include/mgl2/evalc.h s_hull/s_hull_pro.h ../include/mgl2/wnd.h ../include/mgl2/canvas_wnd.h ../include/mgl2/thread.h ../include/mgl2/abstract.h ../include/mgl2/pde.h +# tex_table.cc def_font.cc ) add_definitions(-DMGL_SRC) @@ -42,76 +43,16 @@ endif(MGL_HAVE_OPENGL) include(GenerateExportHeader) -add_compiler_export_flags() mgl_add_lib(mgl ${mgl_src} ${mgl_hdr}) generate_export_header(mgl EXPORT_FILE_NAME ../include/mgl2/dllexport.h) -# if(MGL_HAVE_LTDL) -# target_link_libraries(mgl ${LTDL_LIB}) -# include_directories(${LTDL_INCLUDE_DIR}) -# endif(MGL_HAVE_LTDL) - -if(MGL_HAVE_PDF) - include_directories(${HPDF_INCLUDE_DIR}) - target_link_libraries(mgl ${HPDF_LIB}) -endif(MGL_HAVE_PDF) - -if(MGL_HAVE_PTHREAD) - target_link_libraries(mgl ${CMAKE_THREAD_LIBS_INIT}) -endif(MGL_HAVE_PTHREAD) - -if(MGL_HAVE_JPEG) - target_link_libraries(mgl ${JPEG_LIBRARIES}) - include_directories(${JPEG_INCLUDE_DIR}) -endif(MGL_HAVE_JPEG) - -if(MGL_HAVE_GIF) - target_link_libraries(mgl ${GIF_LIBRARIES}) - include_directories(${GIF_INCLUDE_DIR}) -endif(MGL_HAVE_GIF) - -if(MGL_HAVE_HDF5) - target_link_libraries(mgl ${HDF5_LIBRARIES} ${HDF5_C_SHARED_LIBRARY}) - include_directories(${HDF5_INCLUDE_DIR}) -endif(MGL_HAVE_HDF5) - -if(MGL_HAVE_HDF4) - target_link_libraries(mgl ${HDF4MF_LIB} ${HDF4_LIB}) - include_directories(${HDF4_INCLUDE_DIR}) -endif(MGL_HAVE_HDF4) - -if(MGL_HAVE_LTDL) - target_link_libraries(mgl ${LTDL_LIB} ) - include_directories(${LTDL_INCLUDE_DIR}) -endif(MGL_HAVE_LTDL) - -if(MGL_HAVE_GSL) - target_link_libraries(mgl ${GSL_LIB} ${GSL_CBLAS_LIB} ) - include_directories(${GSL_INCLUDE_DIR}) -endif(MGL_HAVE_GSL) - -if(MGL_HAVE_OPENGL) - target_link_libraries(mgl ${OPENGL_LIBRARIES} ) - include_directories(${OPENGL_INCLUDE_DIR} ) -endif(MGL_HAVE_OPENGL) - -if(MGL_HAVE_PNG) - target_link_libraries(mgl ${PNG_LIBRARIES} ) - include_directories(${PNG_INCLUDE_DIR}) -endif(MGL_HAVE_PNG) - -if(MGL_HAVE_ZLIB) - target_link_libraries(mgl ${ZLIB_LIBRARIES} ) - include_directories(${ZLIB_INCLUDE_DIR}) -endif(MGL_HAVE_ZLIB) - -if(M_LIB) - target_link_libraries(mgl ${M_LIB}) -endif(M_LIB) +target_link_libraries(mgl ${MGL_DEP_LIBS}) +target_link_libraries(mgl-static ${MGL_DEP_LIBS}) if(MGL_HAVE_MPI) mgl_add_lib(mpi mpi.cpp ../include/mgl2/mpi.h) target_link_libraries(mgl-mpi ${MPI_LIBRARIES} ) + target_link_libraries(mgl-mpi-static ${MPI_LIBRARIES} ) target_include_directories(mgl-mpi SYSTEM PUBLIC ${MPI_CXX_INCLUDE_PATH}) endif(MGL_HAVE_MPI) diff -Nru mathgl-2.3.4/src/complex.cpp mathgl-2.3.5.1/src/complex.cpp --- mathgl-2.3.4/src/complex.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/complex.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * complex.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -912,7 +912,7 @@ if(xx>=nx || yy>=ny || zz>=nz) return; dual *a=d->a; if(xx>=0 && yy>=0 && zz>=0) a[xx+nx*(yy+zz*ny)] = val; - if(xx<0 && yy<0 && zz<0) + else if(xx<0 && yy<0 && zz<0) #pragma omp parallel for for(long i=0;inx,ny=d->ny,nz=d->nz,ll=strlen(how); - long p[4]={0,0,(mglchr(how,'a')||mglchr(how,'r'))?1:0,0}; + long p[4]={0,0,0,0}; dual qq=q; for(long i=0;i='0' && how[i]<='9') p[3] = how[i]-'0'; + bool axial = mglchr(how,'r')||mglchr(how,'r'); if(mglchr(how,'z') && nz>1) { - p[0]=nz; p[1]=nx*ny; + p[0]=nz; p[1]=nx*ny; p[2]=0; mglStartThreadC(mgl_difr,0,nx*ny,0,&qq,0,p); } - if(mglchr(how,'y') && ny>1) + if(mglchr(how,'y') && ny>1 && !axial) { - p[0]=ny; p[1]=nx; + p[0]=ny; p[1]=nx; p[2]=0; mglStartThreadC(mgl_difr,0,nx*nz,0,&qq,0,p); } - if((mglchr(how,'x')||mglchr(how,'r')) && nx>1) + if(mglchr(how,'x') && nx>1 && !axial) { - p[0]=nx; p[1]=1; + p[0]=nx; p[1]=1; p[2]=0; + mglStartThreadC(mgl_difr,0,ny*nz,0,&qq,0,p); + } + if(axial && nx>1) + { + p[0]=nx; p[1]=1; p[2]=1; mglStartThreadC(mgl_difr,0,ny*nz,0,&qq,0,p); } } @@ -1171,7 +1177,7 @@ #pragma omp parallel for for(long i=0;ia[i+j*nx] = d; else dat->a[i+sl*nx] = d; } @@ -1188,7 +1194,7 @@ for(long i=0;ia[i+j*nx] = d; else dat->a[i+sl*nx] = d; } @@ -1263,7 +1269,7 @@ #pragma omp parallel for collapse(2) for(long j=0;ja[i0+k*nn] = d; else dat->a[i0+sl*nn] = d; diff -Nru mathgl-2.3.4/src/complex_ex.cpp mathgl-2.3.5.1/src/complex_ex.cpp --- mathgl-2.3.4/src/complex_ex.cpp 2016-02-13 19:01:08.000000000 +0000 +++ mathgl-2.3.5.1/src/complex_ex.cpp 2016-06-19 17:01:18.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * data_new.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -62,7 +62,7 @@ mglData tmp; tmp.a[0]=-1; return mgl_datac_subdata_ext(d,xx?xx:&tmp,yy?yy:&tmp,zz?zz:&tmp); } - + long n=0,m=0,l=0,j,k; bool ix=false, iy=false, iz=false; if(xx->GetNz()>1) // 3d data @@ -330,20 +330,21 @@ if(strchr(dir,'z') && nz>1) { mglStartThreadC(mgl_sumc_z,0,nx*ny,b,c,0,p); - memcpy(c,b,nx*ny*sizeof(mreal)); p[2] = 1; + memcpy(c,b,nx*ny*sizeof(dual)); p[2] = 1; } if(strchr(dir,'y') && ny>1) { mglStartThreadC(mgl_sumc_y,0,nx*p[2],b,c,0,p); - memcpy(c,b,nx*p[2]*sizeof(mreal)); p[1] = p[2]; p[2] = 1; + memcpy(c,b,nx*p[2]*sizeof(dual)); p[1] = p[2]; p[2] = 1; } if(strchr(dir,'x') && nx>1) { mglStartThreadC(mgl_sumc_x,0,p[1]*p[2],b,c,0,p); p[0] = p[1]; p[1] = p[2]; p[2] = 1; + memcpy(c,b,p[0]*p[1]*sizeof(dual)); } mglDataC *r=new mglDataC(p[0],p[1],p[2]); - memcpy(r->a,b,p[0]*p[1]*p[2]*sizeof(dual)); + memcpy(r->a,c,p[0]*p[1]*p[2]*sizeof(dual)); delete []b; delete []c; return r; } uintptr_t MGL_EXPORT mgl_datac_sum_(uintptr_t *d, const char *dir,int l) @@ -368,10 +369,10 @@ #pragma omp parallel for for(long i=0;ivthr(i+nx*j); + dual u=dat->vthr(i+nx*j); i0 += u; i1 += u*res->a[i+nx*j]; } b->a[i] = i0!=mreal(0) ? i1/i0 : 0; @@ -383,10 +384,10 @@ #pragma omp parallel for for(long i=0;iv(j,i,k); + dual u=dat->v(j,i,k); i0 += u; i1 += u*res->a[j+nx*(i+ny*k)]; } b->a[i] = i0!=mreal(0) ? i1/i0 : 0; @@ -399,10 +400,10 @@ #pragma omp parallel for for(long i=0;ivthr(j+nn*i); + dual u=dat->vthr(j+nn*i); i0 += u; i1 += u*res->a[j+nn*i]; } b->a[i] = i0!=mreal(0) ? i1/i0 : 0; @@ -421,25 +422,27 @@ const mglDataC *dc=dynamic_cast(dat); long nx=dat->GetNx(), ny=dat->GetNy(), nz=dat->GetNz(); mglDataC *r=new mglDataC(idat->GetNx(),idat->GetNy(),idat->GetNz()); + mreal dx = nx-1, dy = ny-1, dz = nz-1; + if(!norm) dx=dy=dz=1; if(dd) #pragma omp parallel for for(long i=0;iGetNN();i++) { - mreal x=idat->vthr(i), y=jdat?jdat->vthr(i):0, z=kdat?kdat->vthr(i):0; + mreal x=dx*idat->vthr(i), y=jdat?dy*jdat->vthr(i):0, z=kdat?dz*kdat->vthr(i):0; r->a[i] = mgl_isnum(x*y*z)?mglSpline3st(dd->a,nx,ny,nz, x,y,z):NAN; } else if(dc) #pragma omp parallel for for(long i=0;iGetNN();i++) { - mreal x=idat->vthr(i), y=jdat?jdat->vthr(i):0, z=kdat?kdat->vthr(i):0; + mreal x=dx*idat->vthr(i), y=jdat?dy*jdat->vthr(i):0, z=kdat?dz*kdat->vthr(i):0; r->a[i] = mgl_isnum(x*y*z)?mglSpline3st(dc->a,nx,ny,nz, x,y,z):NAN; } else #pragma omp parallel for for(long i=0;iGetNN();i++) { - mreal x=idat->vthr(i), y=jdat?jdat->vthr(i):0, z=kdat?kdat->vthr(i):0; + mreal x=dx*idat->vthr(i), y=jdat?dy*jdat->vthr(i):0, z=kdat?dz*kdat->vthr(i):0; r->a[i] = mgl_isnum(x*y*z)?dat->linear(x,y,z):NAN;; } return r; @@ -481,7 +484,7 @@ long nx=d->nx, ny=d->ny, nz=d->nz; long mx=a->GetNx(), my=a->GetNy(), mz=a->GetNz(); const mglDataC *c = dynamic_cast(a); - + if(mz*my*mx==1) { dual v=c?c->a[0]:a->v(0); @@ -515,7 +518,7 @@ long nx=d->nx, ny=d->ny, nz=d->nz; long mx=a->GetNx(), my=a->GetNy(), mz=a->GetNz(); const mglDataC *c = dynamic_cast(a); - + if(mz*my*mx==1) { dual v=c?c->a[0]:a->v(0); @@ -549,7 +552,7 @@ long nx=d->nx, ny=d->ny, nz=d->nz; long mx=a->GetNx(), my=a->GetNy(), mz=a->GetNz(); const mglDataC *c = dynamic_cast(a); - + if(mz*my*mx==1) { dual v=c?c->a[0]:a->v(0); @@ -583,7 +586,7 @@ long nx=d->nx, ny=d->ny, nz=d->nz; long mx=a->GetNx(), my=a->GetNy(), mz=a->GetNz(); const mglDataC *c = dynamic_cast(a); - + if(mz*my*mx==1) { dual v=c?c->a[0]:a->v(0); diff -Nru mathgl-2.3.4/src/complex_io.cpp mathgl-2.3.5.1/src/complex_io.cpp --- mathgl-2.3.4/src/complex_io.cpp 2016-02-13 19:01:08.000000000 +0000 +++ mathgl-2.3.5.1/src/complex_io.cpp 2016-06-19 17:01:18.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * data_io.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -945,3 +945,14 @@ char *t=new char[n+1]; memcpy(t,data,n); t[n]=0; mgl_datac_save_hdf(_DC_,s,t,*rewrite); delete []s; delete []t; } //----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_limit(HADT d, mreal v) +{ + long n = d->GetNN(); + dual *a = d->a; + #pragma omp parallel for + for(long i=0;iv) a[i] *= v/b; } +} +void MGL_EXPORT mgl_datac_limit_(uintptr_t *d, mreal *v) +{ mgl_datac_limit(_DC_, *v); } +//----------------------------------------------------------------------------- diff -Nru mathgl-2.3.4/src/cont.cpp mathgl-2.3.5.1/src/cont.cpp --- mathgl-2.3.4/src/cont.cpp 2016-02-13 19:01:08.000000000 +0000 +++ mathgl-2.3.5.1/src/cont.cpp 2016-06-19 17:01:18.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * cont.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -411,14 +411,14 @@ x = &xx; y = &yy; } // x, y -- have the same size z - mglDataV zz(n, m); +#pragma omp parallel for collapse(2) for(long i=0;iGetNx();i++) for(long j=0;jGetNz();j++) { if(gr->NeedStop()) { i = v->GetNx(); j = z->GetNz(); continue; } mreal v0 = v->v(i), z0 = fixed ? gr->Min.z : v0; if(z->GetNz()>1) z0 = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(j)/(z->GetNz()-1); - zz.Fill(z0,z0); + mglDataV zz(n, m); zz.Fill(z0,z0); mgl_cont_gen(gr,v0,z,x,y,&zz,gr->GetC(s,v0),text,j); } gr->EndGroup(); @@ -526,21 +526,20 @@ if(n<2 || m<2 || x->GetNx()*x->GetNy()!=n*m || y->GetNx()*y->GetNy()!=n*m || z->GetNx()*z->GetNy()!=n*m) { gr->SetWarn(mglWarnDim,"ContFGen"); return; } - register long i,j; gr->Reserve(8*n*m); long *kk = new long[4*n], l1,l2, r1,r2, t1,t2, u1,u2, b1,b2, d1,d2, p[8],num; memset(kk,-1,2*n*sizeof(long)); - for(i=0;iGetNx()-1;i++) for(long j=0;jGetNz();j++) { if(gr->NeedStop()) { i = v->GetNx(); j = z->GetNz(); continue; } mreal v0 = v->v(i), z0 = fixed ? gr->Min.z : v0; if(z->GetNz()>1) z0 = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(j)/(z->GetNz()-1); - zz.Fill(z0,z0); + mglDataV zz(n, m); zz.Fill(z0,z0); mgl_contf_gen(gr,v0,v->v(i+1),z,x,y,&zz,gr->GetC(s,v0),j); } gr->EndGroup(); @@ -782,15 +781,15 @@ } // x, y -- have the same size z mreal dc = nc>1 ? 1/(MGL_FEPSILON*(nc-1)) : 0; - mglDataV zz(n, m); +#pragma omp parallel for collapse(2) for(long i=0;iGetNx()-1;i++) for(long j=0;jGetNz();j++) { if(gr->NeedStop()) { i = v->GetNx(); j = z->GetNz(); continue; } mreal v0 = v->v(i), z0 = fixed ? gr->Min.z : v0; if(z->GetNz()>1) z0 = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(j)/(z->GetNz()-1); - zz.Fill(z0,z0); - mgl_contf_gen(gr,v0,v->v(i+1),z,x,y,&zz,s+i*dc,j); + mglDataV zz(n, m); zz.Fill(z0,z0); + mgl_contf_gen(gr,v0,v->v(i+1),z,x,y,&zz,s+(i%nc)*dc,j); } gr->EndGroup(); } @@ -891,13 +890,13 @@ x = &xx; y = &yy; } // x, y -- have the same size z - mglDataV zz(n, m); +#pragma omp parallel for collapse(2) for(long i=0;iGetNx();i++) for(long j=0;jGetNz();j++) { if(gr->NeedStop()) { i = v->GetNx(); j = z->GetNz(); continue; } mreal v0 = v->v(i), z0 = fixed ? gr->Min.z : v0; if(z->GetNz()>1) z0 = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(j)/(z->GetNz()-1); - zz.Fill(z0,z0); + mglDataV zz(n, m); zz.Fill(z0,z0); mreal dv = (gr->Max.c-gr->Min.c)/8; if(i>0) dv = v->v(i-1)-v->v(i); else if(iGetNx()-1) dv = v->v(i)-v->v(i+1); @@ -1070,6 +1069,7 @@ _mgl_slice s; mgl_get_slice(s,x,y,z,a,dir,sVal,both); +#pragma omp parallel for for(long i=0;iGetNx();i++) { register mreal v0 = v->v(i); @@ -1234,6 +1234,7 @@ long ss=gr->AddTexture(sch); _mgl_slice s; mgl_get_slice(s,x,y,z,a,dir,sVal,both); +#pragma omp parallel for for(long i=0;iGetNx()-1;i++) { register mreal v0 = v->v(i); @@ -1458,6 +1459,7 @@ // x, y -- have the same size z int wire = mglchr(sch,'#')?1:0; if(mglchr(sch,'.')) wire = 2; +#pragma omp parallel for collapse(2) for(long i=0;iGetNx();i++) for(long j=0;jGetNz();j++) { if(gr->NeedStop()) { i = v->GetNx(); j = z->GetNz(); continue; } diff -Nru mathgl-2.3.4/src/crust.cpp mathgl-2.3.5.1/src/crust.cpp --- mathgl-2.3.4/src/crust.cpp 2016-02-13 19:01:08.000000000 +0000 +++ mathgl-2.3.5.1/src/crust.cpp 2016-06-19 17:01:18.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * crust.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -740,12 +740,14 @@ rs += sqrt(rm); } rs *= ff/n; rs = rs*rs; // "average" distance - long ind[100], set[100], ii; // indexes of "close" points, flag that it was added and its number - mglPoint qq[100]; // normalized point coordinates + const int nnum=100; + long *ind, *set, ii; // indexes of "close" points, flag that it was added and its number + mglPoint *qq; // normalized point coordinates + ind = new long[nnum]; set = new long[nnum]; qq = new mglPoint[nnum]; long k1,k2,k3,m=0; for(i=0;iGetNy(); - mreal r = amax*mgl_rnd(), sum_prob = 0, x1; - for(i=0;iv(6,i); - if(rv(0,i)*x + A->v(1,i)*y + A->v(4,i); - y = A->v(2,i)*x + A->v(3,i)*y + A->v(5,i); x = x1; -} -HMDT MGL_EXPORT mgl_data_ifs_2d(HCDT A, long n, long skip) -{ - if(!A || A->GetNx()<7 || n<1) return 0; // incompatible dimensions - mreal amax=0; - for(long i=0; iGetNy(); i++) amax += A->v(6,i); - if(amax<=0) return 0; - - mglData *f = new mglData(2,n); - mreal x = 0, y = 0; - for(long i=0; ia[2*i] = x; f->a[2*i+1] = y; - } - return f; -} -uintptr_t MGL_EXPORT mgl_data_ifs_2d_(uintptr_t *d, long *n, long *skip) -{ return uintptr_t(mgl_data_ifs_2d(_DT_,*n,*skip)); } -//----------------------------------------------------------------------------- -void MGL_NO_EXPORT mgl_ifs_3d_point(HCDT A, mreal& x, mreal& y, mreal& z, mreal amax) -{ - int i, n=A->GetNy(); - mreal r = amax*mgl_rnd(), sum_prob = 0, x1, y1; - for (i=0; iv(12,i); - if(r < sum_prob) break; - } - x1= A->v(0,i)*x + A->v(1,i)*y + A->v(2,i)*z + A->v(9,i); - y1= A->v(3,i)*x + A->v(4,i)*y + A->v(5,i)*z + A->v(10,i); - z = A->v(6,i)*x + A->v(7,i)*y + A->v(8,i)*z + A->v(11,i); - x = x1; y = y1; -} -HMDT MGL_EXPORT mgl_data_ifs_3d(HCDT A, long n, long skip) -{ - if(!A || A->GetNx()<13 || n<1) return 0; // incompatible dimensions - mreal amax = 0; - for(int i=0; iGetNy(); i++) amax += A->v(12,i); - if(amax <= 0) return 0; - - mglData *f = new mglData(3,n); - mreal x = 0, y = 0, z = 0; - for(long i=0; ia[3*i] = x; f->a[3*i+1] = y; f->a[3*i+2] = z; - } - return f; -} -uintptr_t MGL_EXPORT mgl_data_ifs_3d_(uintptr_t *d, long *n, long *skip) -{ return uintptr_t(mgl_data_ifs_3d(_DT_,*n,*skip)); } -//----------------------------------------------------------------------------- diff -Nru mathgl-2.3.4/src/data.cpp mathgl-2.3.5.1/src/data.cpp --- mathgl-2.3.4/src/data.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/data.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * data.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -1533,7 +1533,7 @@ if(xx>=nx || yy>=ny || zz>=nz) return; mreal *a=d->a; if(xx>=0 && yy>=0 && zz>=0) a[xx+nx*(yy+zz*ny)] = val; - if(xx<0 && yy<0 && zz<0) + else if(xx<0 && yy<0 && zz<0) #pragma omp parallel for for(long i=0;i(dat); long nx=dat->GetNx(), ny=dat->GetNy(), nz=dat->GetNz(); mglData *r=new mglData(idat->GetNx(),idat->GetNy(),idat->GetNz()); + mreal dx = nx-1, dy = ny-1, dz = nz-1; + if(!norm) dx=dy=dz=1; if(dd) #pragma omp parallel for for(long i=0;iGetNN();i++) { - mreal x=idat->vthr(i), y=jdat?jdat->vthr(i):0, z=kdat?kdat->vthr(i):0; + mreal x=dx*idat->vthr(i), y=jdat?dy*jdat->vthr(i):0, z=kdat?dz*kdat->vthr(i):0; r->a[i] = mgl_isnum(x*y*z)?mglSpline3st(dd->a,nx,ny,nz, x,y,z):NAN; } else #pragma omp parallel for for(long i=0;iGetNN();i++) { - mreal x=idat->vthr(i), y=jdat?jdat->vthr(i):0, z=kdat?kdat->vthr(i):0; + mreal x=dx*idat->vthr(i), y=jdat?dy*jdat->vthr(i):0, z=kdat?dz*kdat->vthr(i):0; r->a[i] = mgl_isnum(x*y*z)?dat->linear(x,y,z):NAN;; } return r; diff -Nru mathgl-2.3.4/src/data_ex.cpp mathgl-2.3.5.1/src/data_ex.cpp --- mathgl-2.3.4/src/data_ex.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/data_ex.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * data_new.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -48,7 +48,7 @@ mglData tmp; tmp.a[0]=-1; return mgl_data_subdata_ext(d,xx?xx:&tmp,yy?yy:&tmp,zz?zz:&tmp); } - + long n=0,m=0,l=0,j,k; bool ix=false, iy=false, iz=false; if(xx->GetNz()>1) // 3d data @@ -286,9 +286,10 @@ { mglStartThread(mgl_sum_x,0,p[1]*p[2],b,c,0,p); p[0] = p[1]; p[1] = p[2]; p[2] = 1; + memcpy(c,b,p[0]*p[1]*sizeof(mreal)); } mglData *r=new mglData(p[0],p[1],p[2]); - memcpy(r->a,b,p[0]*p[1]*p[2]*sizeof(mreal)); + memcpy(r->a,c,p[0]*p[1]*p[2]*sizeof(mreal)); delete []b; delete []c; return r; } uintptr_t MGL_EXPORT mgl_data_sum_(uintptr_t *d, const char *dir,int l) @@ -371,9 +372,10 @@ { mglStartThread(mgl_max_x,0,p[1]*p[2],b,c,0,p); p[0] = p[1]; p[1] = p[2]; p[2] = 1; + memcpy(c,b,p[0]*p[1]*sizeof(mreal)); } mglData *r=new mglData(p[0],p[1],p[2]); - memcpy(r->a,b,p[0]*p[1]*p[2]*sizeof(mreal)); + memcpy(r->a,c,p[0]*p[1]*p[2]*sizeof(mreal)); delete []b; delete []c; return r; } uintptr_t MGL_EXPORT mgl_data_max_dir_(uintptr_t *d, const char *dir,int l) @@ -456,9 +458,10 @@ { mglStartThread(mgl_min_x,0,p[1]*p[2],b,c,0,p); p[0] = p[1]; p[1] = p[2]; p[2] = 1; + memcpy(c,b,p[0]*p[1]*sizeof(mreal)); } mglData *r=new mglData(p[0],p[1],p[2]); - memcpy(r->a,b,p[0]*p[1]*p[2]*sizeof(mreal)); + memcpy(r->a,c,p[0]*p[1]*p[2]*sizeof(mreal)); delete []b; delete []c; return r; } uintptr_t MGL_EXPORT mgl_data_min_dir_(uintptr_t *d, const char *dir,int l) @@ -984,6 +987,6 @@ } delete []c; return r; } -uintptr_t MGL_EXPORT mgl_data_pulse_(uintptr_t *d, const char *dir,int l) +uintptr_t MGL_EXPORT mgl_data_pulse_(uintptr_t *d, const char *dir,int) { return uintptr_t(mgl_data_pulse(_DT_,dir[0])); } //----------------------------------------------------------------------------- diff -Nru mathgl-2.3.4/src/data_gr.cpp mathgl-2.3.5.1/src/data_gr.cpp --- mathgl-2.3.4/src/data_gr.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/data_gr.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * data_gr.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/src/data_io.cpp mathgl-2.3.5.1/src/data_io.cpp --- mathgl-2.3.4/src/data_io.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/data_io.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * data_io.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -421,13 +421,15 @@ return false; } s = mgl_read_gz(fp); gzclose(fp); - if(*s) bufs.push_back(s); + size_t len = strs[0].length(); + const char *s0 = strs[0].c_str(); + if(!strncmp(s, s0, len)) bufs.push_back(s); for(long i=0;s[i];i++) if(s[i]=='\n') { while(s[i+1]=='\n') i++; s[i]=0; i++; - if(s[i]) bufs.push_back(s+i); - else break; + if(!strncmp(s+i, s0, len)) bufs.push_back(s+i); + if(!s[i]) break; } // parse lines and collect data size_t nx=strs.size(), ny=bufs.size(); @@ -766,7 +768,7 @@ void MGL_EXPORT mgl_data_fill_(uintptr_t *d, mreal *x1,mreal *x2,const char *dir,int) { mgl_data_fill(_DT_,*x1,*x2,*dir); } //----------------------------------------------------------------------------- -void MGL_EXPORT mgl_data_norm(HMDT d, mreal v1,mreal v2,long sym,long dim) +void MGL_EXPORT mgl_data_norm(HMDT d, mreal v1,mreal v2,int sym,long dim) { long s,nn=d->nx*d->ny*d->nz; mreal a1=INFINITY,a2=-INFINITY,v,*a=d->a; @@ -1254,3 +1256,14 @@ uintptr_t r = uintptr_t(mgl_data_column(_DT_,s)); delete []s; return r; } //----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_limit(HMDT d, mreal v) +{ + long n = d->GetNN(); + mreal *a = d->a; + #pragma omp parallel for + for(long i=0;iv) a[i] *= v/b; } +} +void MGL_EXPORT mgl_data_limit_(uintptr_t *d, mreal *v) +{ mgl_data_limit(_DT_, *v); } +//----------------------------------------------------------------------------- diff -Nru mathgl-2.3.4/src/data_png.cpp mathgl-2.3.5.1/src/data_png.cpp --- mathgl-2.3.4/src/data_png.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/data_png.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * data_png.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/src/evalc.cpp mathgl-2.3.5.1/src/evalc.cpp --- mathgl-2.3.4/src/evalc.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/evalc.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * evalc.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -61,6 +61,9 @@ EQ_ABS, // absolute value EQ_ARG, // argument (or phase) of complex number EQ_CONJ, // complex conjugate +EQ_REAL, // real part +EQ_IMAG, // imaginary part +EQ_NORM, // square of absolute value |u|^2 EQ_LAST // id of last entry }; //----------------------------------------------------------------------------- @@ -173,6 +176,9 @@ else if(!strcmp(name,"abs")) Kod=EQ_ABS; else if(!strcmp(name,"arg")) Kod=EQ_ARG; else if(!strcmp(name,"conj")) Kod=EQ_CONJ; + else if(!strcmp(name,"real")) Kod=EQ_REAL; + else if(!strcmp(name,"imag")) Kod=EQ_IMAG; + else if(!strcmp(name,"norm")) Kod=EQ_NORM; else { delete []str; return; } // unknown function n=mglFindInText(str,","); if(n>=0) @@ -255,12 +261,15 @@ dual MGL_LOCAL_CONST absc(dual x) { return abs(x); } dual MGL_LOCAL_CONST argc(dual x) { return arg(x); } dual MGL_LOCAL_CONST lgc(dual x) { return log10(x);} +dual MGL_LOCAL_CONST realc(dual x) { return real(x); } +dual MGL_LOCAL_CONST imagc(dual x) { return imag(x); } +dual MGL_LOCAL_CONST normc(dual x) { return norm(x); } //----------------------------------------------------------------------------- typedef dual (*func_1)(dual); typedef dual (*func_2)(dual, dual); static const func_2 f2[EQ_SIN-EQ_LT] = {cltc,cgtc,ceqc,addc,subc,mulc,divc,ipwc,powc,llgc}; static const func_1 f1[EQ_LAST-EQ_SIN] = {sinc,cosc,tanc,asinc,acosc,atanc,sinhc,coshc,tanhc, - asinhc,acoshc,atanhc,sqrtc,expc,expi,logc,lgc,absc,argc,conjc}; + asinhc,acoshc,atanhc,sqrtc,expc,expi,logc,lgc,absc,argc,conjc,realc,imagc,normc}; // evaluation of embedded (included) expressions dual mglFormulaC::CalcIn(const dual *a1) const { diff -Nru mathgl-2.3.4/src/eval.cpp mathgl-2.3.5.1/src/eval.cpp --- mathgl-2.3.4/src/eval.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/eval.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * eval.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/src/evalp.cpp mathgl-2.3.5.1/src/evalp.cpp --- mathgl-2.3.4/src/evalp.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/evalp.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * evalp.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -143,13 +143,16 @@ mreal va=a->a[0], vb=b->a[0], *aa=a->a, *bb=b->a, *cc=r->a; if(na==nb) #pragma omp parallel for - for(long i=0;ia[0], vb=b->a[0], *aa=a->a, *bb=b->a, *cc=r->a; if(na==nb) #pragma omp parallel for - for(long i=0;ia[0] = wcstod(str.c_str(),0); // this is number else if(!str.compare(L"pi")) res->a[0] = M_PI; else if(ch==':') res->a[0] = -1; @@ -686,6 +692,12 @@ HMDT res = mgl_datac_imag(a1); mgl_delete_datac(a1); return res; } + else if(!nm.compare(L"norm")) + { + HADT a1 = mglFormulaCalcC(str, arg, head); + HMDT res = mgl_datac_norm(a1); + mgl_delete_datac(a1); return res; + } #if MGL_HAVE_GSL else if(!nm.compare(L"i") && n>0) return mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, gsl_sf_bessel_Inu); @@ -739,9 +751,10 @@ dual MGL_LOCAL_CONST logc(dual x); //{ return log(x); } dual MGL_LOCAL_CONST absc(dual x); //{ return abs(x); } dual MGL_LOCAL_CONST argc(dual x); //{ return arg(x); } -dual MGL_LOCAL_CONST lgc(dual x); //{ return log10(x);} -dual MGL_LOCAL_CONST realc(dual x) { return real(x); } -dual MGL_LOCAL_CONST imagc(dual x) { return dual(0,imag(x)); } +dual MGL_LOCAL_CONST lgc(dual x); //{ return log10(x);} +dual MGL_LOCAL_CONST realc(dual x); //{ return real(x); } +dual MGL_LOCAL_CONST imagc(dual x); //{ return imag(x); } +dual MGL_LOCAL_CONST normc(dual x); //{ return norm(x); } //----------------------------------------------------------------------------- /// Parse string and substitute the script argument // All numbers are presented as mglData(1). Do boundary checking. @@ -907,7 +920,7 @@ else { HADT res = new mglDataC; - char ch = str[0]; + wchar_t ch = str[0]; if(ch<':') // this is real number res->a[0] = (str[str.length()-1]=='i') ? dual(0,wcstod(str.c_str(),0)) : mreal(wcstod(str.c_str(),0)); else if(ch=='i') // this is imaginary number @@ -970,7 +983,7 @@ else if(!nm.compare(L"acosh")) return mglApplyFuncC(str, arg, head, acoshc); else if(!nm.compare(L"atanh")) return mglApplyFuncC(str, arg, head, atanhc); else if(!nm.compare(L"arg")) return mglApplyFuncC(str, arg, head, argc); - else if(!nm.compare(L"abs")) return mglApplyFuncC(str, arg, head, absc); + else if(!nm.compare(L"abs")) return mglApplyFuncC(str, arg, head, absc); } else if(nm[0]=='c') { @@ -1002,6 +1015,7 @@ for(long i=0;iGetNN();i++) a[i] = dual(mgl_rnd(), mgl_rnd()); return res; } else if(!nm.compare(L"real")) return mglApplyFuncC(str, arg, head, realc); else if(!nm.compare(L"imag")) return mglApplyFuncC(str, arg, head, imagc); + else if(!nm.compare(L"norm")) return mglApplyFuncC(str, arg, head, normc); } HADT res = new mglDataC; res->a[0]=NAN; return res; } diff -Nru mathgl-2.3.4/src/exec.cpp mathgl-2.3.5.1/src/exec.cpp --- mathgl-2.3.4/src/exec.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/exec.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * exec.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -66,6 +66,14 @@ else res = 1; return res; } //----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_gray(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(k[0]==0) gr->Gray(true); + else if(!strcmp(k,"n")) gr->Gray(a[0].v!=0); + else res = 1; return res; +} +//----------------------------------------------------------------------------- int MGL_NO_EXPORT mgls_pendelta(mglGraph *gr, long , mglArg *a, const char *k, const char *) { int res=0; @@ -130,6 +138,13 @@ else res = 1; return res; } //----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_shear(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nn")) gr->Shear(a[0].v, a[1].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- int MGL_NO_EXPORT mgls_axial(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) { int res=0; @@ -982,7 +997,7 @@ else res = 1; return res; } //----------------------------------------------------------------------------- -int MGL_NO_EXPORT mgls_gspline(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +int MGL_NO_EXPORT mgls_gspline(mglGraph *gr, long , mglArg *a, const char *k, const char *) { int res=0; if(k[0]=='d' && a[0].d->temp) return 5; @@ -1645,6 +1660,13 @@ else res = 1; return res; } //----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_setsizescl(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetSizeScl(a[0].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- int MGL_NO_EXPORT mgls_sphere(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) { int res=0; gr->Self()->SaveState(opt); @@ -2325,7 +2347,7 @@ else res = 1; return res; } //----------------------------------------------------------------------------- -int MGL_NO_EXPORT mgls_print(mglGraph *gr, long , mglArg *a, const char *k, const char *) +int MGL_NO_EXPORT mgls_print(mglGraph *, long , mglArg *a, const char *k, const char *) { int res=0; if(!strcmp(k,"d")) printf("%s\n",a[0].d->PrintInfo()); @@ -2383,6 +2405,14 @@ else res = 1; return res; } //----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_shearplot(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nnnn")) gr->ShearPlot(mgl_int(a[0].v), mgl_int(a[1].v), a[2].v, a[3].v); + else if(!strcmp(k,"nnnnnn")) gr->ShearPlot(mgl_int(a[0].v), mgl_int(a[1].v), a[2].v, a[3].v, a[4].v, a[5].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- int MGL_NO_EXPORT mgls_pipe(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) { int res=0; @@ -2430,6 +2460,17 @@ else res = 1; return res; } //----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_limit(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(k[0]=='d' && a[0].d->temp) return 5; + mglData *d = dynamic_cast(a[0].d); + mglDataC *c = dynamic_cast(a[0].d); + if(d && !strcmp(k,"dn")) d->Limit(a[1].v); + else if(c && !strcmp(k,"dn")) c->Limit(a[1].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- int MGL_NO_EXPORT mgls_hist(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) { int res=0; @@ -2752,7 +2793,7 @@ int MGL_NO_EXPORT mgls_fgets(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) { int res=0; gr->Self()->SaveState(opt); - char buf[4096]; + char *buf; buf = new char[4096]; FILE *fp; if(!strncmp(k,"nns",3)) { @@ -2761,7 +2802,7 @@ if(!fp) { gr->SetWarn(mglWarnOpen,a[2].s.c_str()); - return res; + delete []buf; return res; } for(i=0;iSetWarn(mglWarnOpen,(a[2].s+" - line "+b).c_str()); - fclose(fp); return res; + fclose(fp); delete []buf; return res; } fclose(fp); gr->Puts(mglPoint(a[0].v,a[1].v,NAN),buf, (k[4]=='s')?a[4].s.c_str():"", k[5]=='n'?a[5].v:-1); @@ -2781,7 +2822,7 @@ if(!fp) { gr->SetWarn(mglWarnOpen,a[3].s.c_str()); - return res; + delete []buf; return res; } for(i=0;iSetWarn(mglWarnOpen,(a[3].s+" - line "+b).c_str()); - fclose(fp); return res; + fclose(fp); delete []buf; return res; } fclose(fp); gr->Puts(mglPoint(a[0].v,a[1].v,a[2].v),buf, (k[5]=='s')?a[5].s.c_str():"", k[6]=='n'?a[6].v:-1); } - else res = 1; gr->Self()->LoadState(); return res; + else res = 1; gr->Self()->LoadState(); delete []buf; return res; } //----------------------------------------------------------------------------- -int MGL_NO_EXPORT mgls_scanfile(mglGraph *gr, long , mglArg *a, const char *k, const char *) +int MGL_NO_EXPORT mgls_scanfile(mglGraph *, long , mglArg *a, const char *k, const char *) { int res=0; if(!strcmp(k,"dss")) @@ -3003,6 +3044,26 @@ else res = 1; return res; } //----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_tridmat(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + mglData *d = dynamic_cast(a[0].d); + mglDataC *c = dynamic_cast(a[0].d); + if(c && !strcmp(k,"ddddds")) + *c = mglTridMatC(*(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), a[5].s.c_str()); + else if(d && !strcmp(k,"ddddds")) + *d = mglTridMat(*(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), a[5].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_diffract(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + mglDataC *c = dynamic_cast(a[0].d); + if(c && !strcmp(k,"dsn")) c->Diffraction(a[1].s.c_str(), a[2].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- int MGL_NO_EXPORT mgls_pde(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) { int res=0; @@ -3380,6 +3441,27 @@ else res = 1; return res; } //----------------------------------------------------------------------------- +int mgls_flame2d(mglGraph *, long, mglArg *a, const char *k, const char *) +{ + mglData *fx = dynamic_cast(a[0].d); + mglData *fy = dynamic_cast(a[1].d); + if(!fx) return 1; + int res = 0; + if (!strcmp(k, "dddn")) fx->Set(mglFlame2d(*(a[1].d), *(a[2].d), mgl_int(a[3].v))); + else if (!strcmp(k, "ddddn") && fy) + { + mglData f(mglFlame2d(*(a[2].d), *(a[3].d), mgl_int(a[4].v))); + fx->Set(f.SubData(0)); fy->Set(f.SubData(1)); + } + else if (!strcmp(k, "dddnn")) fx->Set(mglFlame2d(*(a[1].d), *(a[2].d), mgl_int(a[3].v), mgl_int(a[4].v))); + else if (!strcmp(k, "ddddnn") && fy) + { + mglData f(mglFlame2d(*(a[2].d), *(a[3].d), mgl_int(a[4].v), mgl_int(a[5].v))); + fx->Set(f.SubData(0)); fy->Set(f.SubData(1)); + } + else res = 1; return res; +} +//----------------------------------------------------------------------------- int mgls_ifs2d(mglGraph *, long, mglArg *a, const char *k, const char *) { mglData *fx = dynamic_cast(a[0].d); @@ -3411,6 +3493,16 @@ else res = 1; return res; } //----------------------------------------------------------------------------- +int mgls_ifsfile(mglGraph *, long, mglArg *a, const char *k, const char *) +{ + mglData *f = dynamic_cast(a[0].d); + if(!f) return 1; + int res = 0; + if (!strcmp(k, "dssn")) f->Set(mglIFSfile(a[1].s.c_str(), a[2].s.c_str(), mgl_int(a[3].v))); + else if (!strcmp(k, "dssnn")) f->Set(mglIFSfile(a[1].s.c_str(), a[2].s.c_str(), mgl_int(a[3].v), mgl_int(a[4].v))); + else res = 1; return res; +} +//----------------------------------------------------------------------------- mglCommand mgls_base_cmd[] = { {"addlegend","Add legend entry","addlegend 'txt' 'fmt'", mgls_addlegend,15}, {"addto","Add data or number","addto Var Dat|Var num", mgls_addto ,3}, @@ -3433,7 +3525,7 @@ {"barh","Draw horizontal bars for 1D data", "barh Ydat ['fmt' above]|Xdat Ydat ['fmt' above]", mgls_barh ,7}, {"bars","Draw bars for 1D data","bars Ydat ['fmt' above]|Xdat Ydat ['fmt' above]|Xdat Ydat Zdat ['fmt' above]", mgls_bars ,7}, {"barwidth","Set default bars width","barwidth val", mgls_barwidth ,2}, - {"beam","Draw quasioptical beam","beam Tr G1 G2 Adat r ['sch' flag num] ", mgls_beam ,9}, + {"beam","Draw quasi-optical beam","beam Tr G1 G2 Adat r ['sch' flag num] ", mgls_beam ,9}, {"belt","Draw belts","belt Zdat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_belt ,8}, {"bifurcation","Draw Bifurcation diagram","bifurcation dx Func ['fmt']|dx 'func' ['fmt']", mgls_bifurcation,13}, {"box","Draw bounding box","box ['fmt' ticks]", mgls_box ,12}, @@ -3446,7 +3538,7 @@ {"chdir","Change current directory","chdir 'path'", mgls_chdir ,2}, {"circle","Draw circle","circle x y r ['fmt']|x y z r ['fmt']", mgls_circle ,13}, {"clean","Remove duplicate rows","clean Dat id", mgls_clean ,3}, - {"clearlegend","Clear legend antries","clearlegend", mgls_clearlegend ,15}, + {"clearlegend","Clear legend entries","clearlegend", mgls_clearlegend ,15}, {"clf","Clear picture","clf|'col'|r g b", mgls_clf ,12}, {"cloud","Draw cloud","cloud Adat ['fmt']|Xdat Ydat Zdat Adat ['fmt']", mgls_cloud ,9}, {"colorbar","Draw colorbar","colorbar ['fmt' pos]|Vdat ['fmt' pos]|'sch' pos x y [w h]|Vdat 'sch' pos x y [w h]", mgls_colorbar ,12}, @@ -3493,6 +3585,7 @@ {"dew","Draw dew plot","dew Udat Vdat ['fmt']|Xdat Ydat Udat Vdat ['fmt']", mgls_dew ,11}, {"diff","Numerically differentiate data","diff Var 'dir'", mgls_diff ,16}, {"diff2","Numerically double differentiate data","diff2 Var 'dir'", mgls_diff2 ,16}, + {"diffract","Step for pulse diffraction","diffract Res 'how' q", mgls_diffract ,16}, {"diffuse","Set diffusive light brightness","diffuse val", mgls_diffuse ,2}, {"divto","Divide by data or number","divto Var Dat|Var num", mgls_divto ,3}, {"dots","Draw dots for arbitrary data points","dots Xdat Ydat Zdat ['fmt']|Xdat Ydat Zdat Adat ['fmt']|Xdat Ydat Zdat Cdat Adat ['fmt']", mgls_dots ,9}, @@ -3520,6 +3613,7 @@ {"fillsample","Fill x-,k-samples for transforms","fillsample Var 'how'", mgls_fillsample ,3}, {"fit","Fit data to formula","fit Res A 'eq' 'var' [Ini]|Res X A 'eq' 'var' [Ini]|Res X Y A 'eq' 'var' [Ini]|Res X Y Z A 'eq' 'var' [Ini]", mgls_fit ,4}, {"fits","Fit data to formula","fits Res A S 'eq' 'var' [Ini]|Res X A S 'eq' 'var' [Ini]|Res X Y A S 'eq' 'var' [Ini]|Res X Y Z A S 'eq' 'var' [Ini]", mgls_fits ,4}, + {"flame2d", "Computes the flame fractal", "flame2d F A B n [skip]|Fx Fy A B n [skip]", mgls_flame2d, 4}, {"flow","Draw flow threads for vector field","flow Udat Vdat ['fmt' num]|Xdat Ydat Udat Vdat ['fmt' num]|Udat Vdat Wdat ['fmt' num]|Xdat Ydat Zdat Udat Vdat ['fmt' num]|\ x0 y0 Udat Vdat ['fmt']|x0 y0 Xdat Ydat Udat Vdat ['fmt']|x0 y0 z0 Udat Vdat Wdat ['fmt']|x0 y0 z0 Xdat Ydat Zdat Udat Vdat Wdat ['fmt']", mgls_flow ,11}, {"fog","Switch on/off fog","fog val [pos]", mgls_fog ,2}, @@ -3530,6 +3624,7 @@ {"fsurf","Plot surface by formula","fsurf 'z(x,y)' ['fmt']|'x(u,v)' 'y(u,v)' 'z(u,v)' ['fmt']", mgls_fsurf ,1}, {"func","Start function definition and stop execution of main script","func 'name' [narg]", 0, 6}, {"grad","Draw gradient lines for scalar field","grad Phi ['fmt' num]|Xdat Ydat Phi ['fmt' num]|Xdat Ydat Zdat Phi ['fmt' num]", mgls_grad ,8}, + {"gray","Switch on/off gray-scale mode","gray [val]", mgls_gray ,2}, {"grid","Draw grid","grid ['dir' 'fmt']", mgls_grid ,12}, {"grid2","Draw grid for data array(s)","grid Zdat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_grid2 ,8}, {"grid3","Draw grid at slices of 3D data","grid3 Adat 'dir' [pos 'fmt']|Xdat Ydat Zdat Adat 'dir' [pos 'fmt']", mgls_grid3 ,9}, @@ -3541,6 +3636,7 @@ {"if","Conditional operator","if val|Dat ['cond']", 0, 6}, {"ifs2d", "Computes the attractor of an IFS", "ifs2d F A n [skip]|Fx Fy A n [skip]", mgls_ifs2d, 4}, {"ifs3d", "Computes the attractor of an IFS for 3d case", "ifs3d F A n [skip]", mgls_ifs3d, 4}, + {"ifsfile", "Computes the attractor of an IFS with parameters from *.ifs file", "ifsfile F 'fname' 'name' n [skip]", mgls_ifsfile, 4}, {"import","Import data from PNG picture","import Dat 'fname' 'scheme' [v1 v2]", mgls_import ,4}, {"info","Print message or information about the data","info Dat [detail]|'message'|const", mgls_info ,3}, {"inplot","Set position of plot in picture","x1 x2 y1 y2 [rel]", mgls_inplot ,5}, @@ -3553,6 +3649,7 @@ {"legend","Draw legend","legend [pos 'fmt']|x y ['fmt']", mgls_legend ,15}, {"legendmarks","Set number of marks in the legend","legendmarks val", mgls_legendmarks ,15}, {"light","Setup light","light [val] | val num | num xpos ypos zpos ['fmt' br]", mgls_light ,2}, + {"limit","Limit data to be inside [-v,v]","limit Dat v", mgls_limit ,16}, {"line","Draw line","line x1 y1 x2 y2 ['fmt']|x1 y1 z1 x2 y2 z2 ['fmt']", mgls_line ,13}, {"list","Creates new variable from list of numbers or data","list Var v1 ...|Var D1 ...", 0, 4}, {"load","Load commands from external DLL","load 'fname'", 0, 6}, @@ -3599,7 +3696,7 @@ {"quality","Set plot quality","quality [val]", mgls_quality ,2}, {"radar","Draw radar chart","radar Rdat ['fmt']", mgls_radar ,7}, {"ranges","Set axis ranges","ranges x1 x2 y1 y2 [z1 z2]", mgls_ranges ,14}, - {"rasterize","Rasterize and save to background","rasterize", mgls_rasterize ,12}, + {"rasterize","Rasterize plot and save to background","rasterize", mgls_rasterize ,12}, {"ray","Solve Hamiltonian ODE (find GO ray or trajectory)","ray Res 'ham' x0 y0 z0 px0 py0 pz0 [dz=0.1 tmax=10]", mgls_ray ,4}, {"read","Read data from file","read Dat 'file' [nx ny nz] | ReDat ImDat 'file' [nx ny nz]", mgls_read ,4}, {"readall","Read and join data from several files","readall Dat 'templ' [slice]", mgls_readall ,4}, @@ -3619,10 +3716,13 @@ {"rotate","Rotate plot","rotate tetz tetx [tety] | tet x y z", mgls_rotate ,5}, {"rotatetext","Set to auto rotate text or not","rotatetext val", mgls_rotatetext ,15}, {"save","Save data to file","save Dat 'file'|'str' 'file'|'str' 'file' 'how'", mgls_save ,3}, - {"savehdf","Save data to HDF5 file","savehdf Dat 'file' 'id'", mgls_savehdf ,3}, - {"scanfile","Get fromated data from file","scanfile Dat 'fname 'templ'", mgls_scanfile ,4}, + {"savehdf","Save data to HDF5 file","savehdf Dat 'file' 'id' [rewrite]", mgls_savehdf ,3}, + {"scanfile","Get formated data from file","scanfile Dat 'fname 'templ'", mgls_scanfile ,4}, {"setsize","Set picture size","setsize width height", mgls_setsize ,2}, + {"setsizescl","Set scaling factor for further setsize","setsizescl val", mgls_setsizescl ,2}, {"sew","Remove jump into the data, like phase jumps","sew Dat ['dir' da]", mgls_sew ,16}, + {"shear","Shear plot","shear valx valy", mgls_shear ,5}, + {"shearplot","Set position of plot inside cell of sheared stick", "shearplot num ind sx sy [xd yd]", mgls_shearplot ,5}, {"sinfft","Sin-Fourier transform at some direction","sinfft Dat 'dir'", mgls_sinfft ,16}, {"smooth","Smooth data","smooth Dat [kind 'dir']", mgls_smooth ,16}, {"solve","Find root Dat_{i,j,k}=val (inverse evaluate)","solve Res Dat val 'dir' [Idat norm]", mgls_solve ,4}, @@ -3633,7 +3733,7 @@ {"step","Draw step plot for 1D data","step Ydat ['fmt']|Xdat Ydat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_step ,7}, {"stfa","Draw STFA diagram","stfa Udat Vdat dn ['fmt']|Xdat Ydat Udat Vdat dn ['fmt']", mgls_stfa ,10}, {"stfad","Do STFA transform","stfad Res Real Imag dn ['dir']", mgls_stfad ,4}, - {"stickplot","Set position of plot inside cell of stick", "stickplot num ind tet phi", mgls_stickplot ,5}, + {"stickplot","Set position of plot inside cell of rotated stick", "stickplot num ind tet phi", mgls_stickplot ,5}, {"stop","Stop execution","stop", 0, 6}, {"subdata","Extract sub-array","subdata Res Dat nx [ny nz]", mgls_subdata ,4}, {"subplot","Set position of plot","subplot m n pos ['style' dx dy]", mgls_subplot ,5}, @@ -3671,10 +3771,12 @@ {"triangulate","Find triangles of randomly placed points","triangulate Res Xdat Ydat [er]|Res Xdat Ydat Zdat [er]", mgls_triangulate ,4}, {"tricont","Draw contour lines for surface of triangles","tricont Idat Xdat Ydat Cdat ['fmt']|Idat Xdat Ydat Zdat Cdat ['fmt']|Vdat Idat Xdat Ydat Cdat ['fmt']|Vdat Idat Xdat Ydat Zdat Cdat ['fmt']", mgls_tricont ,0}, {"tricontv","Draw contour tubes for surface of triangles","tricontv Idat Xdat Ydat Cdat ['fmt']|Idat Xdat Ydat Zdat Cdat ['fmt']|Vdat Idat Xdat Ydat Cdat ['fmt']|Vdat Idat Xdat Ydat Zdat Cdat ['fmt']", mgls_tricontv ,0}, + {"tridmat","Solve tridiagonal matrix","tridmat Res A B C D 'how'", mgls_tridmat ,4}, {"triplot","Draw surface of triangles","triplot Idat Xdat Ydat ['fmt']|Idat Xdat Ydat Zdat ['fmt']|Idat Xdat Ydat Zdat Cdat ['fmt'] ", mgls_triplot ,0}, {"tube","Draw curve by tube","tube Ydat Rdat ['fmt']|Ydat rval ['fmt']|Xdat Ydat Rdat ['fmt']|Xdat Ydat rval ['fmt']|Xdat Ydat Zdat Rdat ['fmt']|Xdat Ydat Zdat rval ['fmt']", mgls_tube ,7}, {"tuneticks","Set ticks tuning","tuneticks val [fctr]", mgls_tuneticks ,14}, {"var","Create new 1D data and fill it in range","var Dat nx x1 [x2]", mgls_var ,4}, + {"variant","Select variant of plot style(s)","variant var", 0, 6}, {"vect","Draw vector field","vect Udat Vdat ['fmt']|Xdat Ydat Udat Vdat ['fmt']|Udat Vdat Wdat ['fmt']|Xdat Ydat Zdat Udat Vdat Wdat ['fmt']", mgls_vect ,11}, {"vect3","Draw vector field at slices of 3D data","vect Udat Vdat Wdat ['fmt' sval]|Xdat Ydat Zdat Udat Vdat Wdat ['fmt' sval]", mgls_vect3 ,11}, {"version","Print MathGL version or check if it is valid","version |'ver'", mgls_version, 2}, diff -Nru mathgl-2.3.4/src/export_2d.cpp mathgl-2.3.5.1/src/export_2d.cpp --- mathgl-2.3.4/src/export_2d.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/export_2d.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * export_2d.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -22,8 +22,6 @@ #include "mgl2/font.h" #include #include -#include -#include #include #undef _GR_ #define _GR_ ((mglCanvas *)(*gr)) @@ -321,7 +319,7 @@ case 'P': mgl_printf(fp, gz, "np %g %g mt m_P %sdr\n",x0,y0,str); break; case 'X': mgl_printf(fp, gz, "np %g %g mt m_X %sdr\n",x0,y0,str); break; case 'C': mgl_printf(fp, gz, "%g %g m_o %g %g m_c %sdr\n",x0,y0,x0,y0,str); break; - default: mgl_printf(fp, gz, "%g %g m_c %sfill\n",x0,y0,str); + case '.': mgl_printf(fp, gz, "%g %g m_c %sfill\n",x0,y0,str); } } else if(q.type==3) // quad @@ -499,7 +497,7 @@ case '*': mgl_printf(fp, gz, "\n", x-s,y,x+s,y,x-0.6*s,y-0.8*s,x+0.6*s,y+0.8*s,x+0.6*s,y-0.8*s,x-0.6*s,y+0.8*s); break; - default: + case '.': mgl_printf(fp, gz, "\n", int(cp.r[0]),int(cp.r[1]),int(cp.r[2]),x,y); break; } diff -Nru mathgl-2.3.4/src/export_3d.cpp mathgl-2.3.5.1/src/export_3d.cpp --- mathgl-2.3.4/src/export_3d.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/export_3d.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * export_3d.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/src/export.cpp mathgl-2.3.5.1/src/export.cpp --- mathgl-2.3.4/src/export.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/export.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * export.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/src/fft.cpp mathgl-2.3.5.1/src/fft.cpp --- mathgl-2.3.4/src/fft.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/fft.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * fft.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/src/fit.cpp mathgl-2.3.5.1/src/fit.cpp --- mathgl-2.3.4/src/fit.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/fit.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * fit.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/src/font.cpp mathgl-2.3.5.1/src/font.cpp --- mathgl-2.3.4/src/font.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/font.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * font.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -30,9 +30,8 @@ #include "mgl2/base.h" #include "mgl2/font.h" #include "def_font.cc" +#include "tex_table.cc" //----------------------------------------------------------------------------- -extern mglTeXsymb mgl_tex_symb[]; -extern long mgl_tex_num; //mglFont mglDefFont("nofont"); mglFont mglDefFont; //----------------------------------------------------------------------------- @@ -918,3 +917,18 @@ memcpy(&glyphs[0],&(f->glyphs)[0],glyphs.size()*sizeof(mglGlyphDescr)); } //----------------------------------------------------------------------------- +long MGL_EXPORT mgl_check_tex_table() +{ + size_t i=0; while(mgl_tex_symb[i].tex[0]) i++; + long res = 0; + if(mgl_tex_num!=i) + { printf("real=%zu, set=%zu\n",i,mgl_tex_num); res = -1; } + for(i=0;mgl_tex_symb[i].tex[0];i++) + { + mglTeXsymb tst, *rts; tst.tex = mgl_tex_symb[i].tex; + rts = (mglTeXsymb *) bsearch(&tst, mgl_tex_symb, mgl_tex_num, sizeof(mglTeXsymb), mgl_tex_symb_cmp); + if(!rts) + { printf("Bad '%ls' at %zu\n",mgl_tex_symb[i].tex,i); res = 1+i; } + } + return res; +} \ No newline at end of file diff -Nru mathgl-2.3.4/src/fractal.cpp mathgl-2.3.5.1/src/fractal.cpp --- mathgl-2.3.4/src/fractal.cpp 1970-01-01 00:00:00.000000000 +0000 +++ mathgl-2.3.5.1/src/fractal.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -0,0 +1,463 @@ +/*************************************************************************** +*pixel.cpp is part of Math Graphic Library +*Copyright (C) 2007-2016 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/other.h" +#include "mgl2/data.h" +MGL_NO_EXPORT char *mgl_read_gz(gzFile fp); +//----------------------------------------------------------------------------- +// +// IFS series +// +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_ifs_2d_point(HCDT A, mreal& x, mreal& y, mreal amax) +{ + long i, n=A->GetNy(); + mreal r = amax*mgl_rnd(), sum_prob = 0, x1; + for(i=0;iv(6,i); + if(rv(0,i)*x + A->v(1,i)*y + A->v(4,i); + y = A->v(2,i)*x + A->v(3,i)*y + A->v(5,i); x = x1; +} +HMDT MGL_EXPORT mgl_data_ifs_2d(HCDT A, long n, long skip) +{ + if(!A || A->GetNx()<7 || n<1) return 0; // incompatible dimensions + mreal amax=0; + for(long i=0; iGetNy(); i++) amax += A->v(6,i); + if(amax<=0) return 0; + + mglData *f = new mglData(2,n); + mreal x = 0, y = 0; + for(long i=0; ia[2*i] = x; f->a[2*i+1] = y; + } + return f; +} +uintptr_t MGL_EXPORT mgl_data_ifs_2d_(uintptr_t *d, long *n, long *skip) +{ return uintptr_t(mgl_data_ifs_2d(_DT_,*n,*skip)); } +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_ifs_3d_point(HCDT A, mreal& x, mreal& y, mreal& z, mreal amax) +{ + int i, n=A->GetNy(); + mreal r = amax*mgl_rnd(), sum_prob = 0, x1, y1; + for (i=0; iv(12,i); + if(r < sum_prob) break; + } + x1= A->v(0,i)*x + A->v(1,i)*y + A->v(2,i)*z + A->v(9,i); + y1= A->v(3,i)*x + A->v(4,i)*y + A->v(5,i)*z + A->v(10,i); + z = A->v(6,i)*x + A->v(7,i)*y + A->v(8,i)*z + A->v(11,i); + x = x1; y = y1; +} +HMDT MGL_EXPORT mgl_data_ifs_3d(HCDT A, long n, long skip) +{ + if(!A || A->GetNx()<13 || n<1) return 0; // incompatible dimensions + mreal amax = 0; + for(int i=0; iGetNy(); i++) amax += A->v(12,i); + if(amax <= 0) return 0; + + mglData *f = new mglData(3,n); + mreal x = 0, y = 0, z = 0; + for(long i=0; ia[3*i] = x; f->a[3*i+1] = y; f->a[3*i+2] = z; + } + return f; +} +uintptr_t MGL_EXPORT mgl_data_ifs_3d_(uintptr_t *d, long *n, long *skip) +{ return uintptr_t(mgl_data_ifs_3d(_DT_,*n,*skip)); } +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_data_ifs_file(const char *fname, const char *name, long n, long skip) +{ + gzFile fp = gzopen(fname,"r"); + if(!fp) return 0; // Couldn't open file file + char *buf = mgl_read_gz(fp); gzclose(fp); + char *s = strstr(buf,name); + if(!s) return 0; // No data for fractal 'name' in the file + + char *p = strchr(s,'{'), *e; + if(!p) return 0; // Wrong data format for fractal 'name' in the file + bool ext3d = false; + e = strstr(s,"(3D)"); if(e && e nums; + for(size_t i=0;p[i] && p+i' ') i++; + } + } + HMDT dat = new mglData, res; + if(ext3d) + { + dat->Set(&(nums[0]), 13, nums.size()/13, 1); + res = mgl_data_ifs_3d(dat, n, skip); + } + else + { + dat->Set(&(nums[0]), 7, nums.size()/7, 1); + res = mgl_data_ifs_2d(dat, n, skip); + } + delete dat; free(buf); return res; +} +uintptr_t mgl_data_ifs_file_(const char *fname, const char *name, long *n, long *skip,int l,int m) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *t=new char[m+1]; memcpy(t,name,m); t[m]=0; + uintptr_t r = uintptr_t(mgl_data_ifs_file(s,t,*n,*skip)); + delete []s; delete []t; return r; } +//----------------------------------------------------------------------------- +// +// Functions for flame fractal +// +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_linear_var0(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ xNew += par[0]*x; yNew += par[0]*y; } +void MGL_NO_EXPORT mgl_sinusoidal_var1(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ xNew += par[0]*sin(x); yNew += par[0]*sin(y); } +void MGL_NO_EXPORT mgl_spherical_var2(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ mreal c1 = par[0]/(x*x+y*y); xNew += c1*x; yNew += c1*y; } +void MGL_NO_EXPORT mgl_swirl_var3(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal r2=x*x+y*y, c1=sin(r2), c2=cos(r2); + xNew += par[0]*(x*c1 - y*c2); + yNew += par[0]*(x*c2 + y*c1); +} +void MGL_NO_EXPORT mgl_horseshoe_var4(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1 = par[0]/hypot(x,y); + xNew += c1*(x*x-y*y); + yNew += 2*c1*x*y; +} +void MGL_NO_EXPORT mgl_polar_var5(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + xNew += par[0]*atan2(x,y)/M_PI; + yNew += par[0]*(hypot(x,y)-1); +} +void MGL_NO_EXPORT mgl_handkerchief_var6(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal r=hypot(x,y), t=atan2(x,y), c1=par[0]*r; + xNew += c1*sin(t+r); yNew += c1*cos(t-r); +} +void MGL_NO_EXPORT mgl_heart_var7(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal r=hypot(x,y), c1=par[0]*r, c2=atan2(x,y)*r; + xNew += c1*sin(c2); yNew += -c1*cos(c2); +} +void MGL_NO_EXPORT mgl_disc_var8(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=par[0]*atan2(x,y)/M_PI, c2=M_PI*hypot(x,y); + xNew += c1*sin(c2); yNew += c1*cos(c2); +} +void MGL_NO_EXPORT mgl_spiral_var9(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal r=hypot(x,y), t=atan2(x,y), c1=par[0]/r; + xNew += c1*(cos(t)+sin(r)); + yNew += c1*(sin(t)-cos(r)); +} +void MGL_NO_EXPORT mgl_hyperbolic_var10(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal r=hypot(x,y), t=atan2(x,y); + xNew += par[0]*sin(t)/r; + yNew += par[0]*r*cos(t); +} +void MGL_NO_EXPORT mgl_diamond_var11(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal r=hypot(x,y), t=atan2(x,y); + xNew += par[0]*sin(t)*cos(r); + yNew += par[0]*cos(t)*sin(r); +} +void MGL_NO_EXPORT mgl_ex_var12(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal r=hypot(x,y), t=atan2(x,y), c1=par[0]*r; + mreal c2=mgl_ipow(sin(t+r),3), c3 = mgl_ipow(cos(t-r), 3); + xNew += c1*(c2 + c3); yNew += c1*(c2 - c3); +} +void MGL_NO_EXPORT mgl_julia_var13(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=par[0]*sqrt(hypot(x,y)), c2=atan2(x,y)/2, c3=(rand()%2)*M_PI; + xNew += c1*cos(c2+c3); yNew += c1*sin(c2+c3); +} +void MGL_NO_EXPORT mgl_bent_var14(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + if (x>=0 && y>=0) + { xNew += par[0]*x; yNew += par[0]*y; } + else if (x<0 && y>=0) + { xNew += par[0]*2*x; yNew += par[0]*y; } + else if (x>=0 && x<0) + { xNew += par[0]*x; yNew += par[0]*y/2; } + else + { xNew += par[0]*2*x; yNew += par[0]*y/2; } +} +void MGL_NO_EXPORT mgl_waves_var15(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ // NOTE: par[1]=b[i], par[2]=1/c[i]^2, par[3]=e[i], par[4]=1/f[i]^2 + xNew += par[0]*(x + par[1]*sin(y*par[2])); + yNew += par[0]*(y + par[3]*sin(x*par[4])); +} +void MGL_NO_EXPORT mgl_fisheye_var16(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1 = par[0]*2/(hypot(x,y) + 1); + xNew += c1*y; yNew += c1*x; +} +void MGL_NO_EXPORT mgl_popcorn_var17(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ // NOTE: par[1]=c[i], par[2]=f[i] + xNew += par[0]*(x + par[1]*sin(tan(3*y))); + yNew += par[0]*(y + par[2]*sin(tan(3*x))); +} +void MGL_NO_EXPORT mgl_exponential_var18(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=par[0]*exp(x-1); + xNew += c1*cos(M_PI*y); yNew += c1*sin(M_PI*y); +} +void MGL_NO_EXPORT mgl_power_var19(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal t=atan2(x,y), c1=par[0]*pow(hypot(x,y), sin(t)); + xNew += c1*cos(t); yNew += c1*sin(t); +} +void MGL_NO_EXPORT mgl_cosine_var20(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + xNew += par[0]*cos(M_PI*x)*cosh(y); + yNew += -par[0]*sin(M_PI*x)*sinh(y); +} +void MGL_NO_EXPORT mgl_rings_var21(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ // NOTE: par[1]=c[i]^2 + mreal t=atan2(x,y), r=hypot(x,y), c1=par[0]*(fmod(r+par[1],2*par[1])-par[1]+r*(1-par[1])); // convert to int? + xNew += c1*cos(t); yNew += c1*sin(t); +} +void MGL_NO_EXPORT mgl_fan_var22(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ // NOTE: par[1]=c[i]^2, par[2]=f[i] + mreal t=atan2(x,y), c1=par[0]*hypot(x,y), c2; + c2 = fmod(t+par[2], M_PI*par[1]); // convert to int? + if (c2 > M_PI/2*par[1]) c2 = t - M_PI/2*par[1]; + else c2 += t; + xNew += c1*cos(c2); yNew += c1*sin(c2); +} +void MGL_NO_EXPORT mgl_blob_var23(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal t=atan2(x,y), c1=par[0]*hypot(x,y)*(par[2]+(par[1]-par[2])/2*(sin(par[3]*t))); + xNew += c1*cos(t); yNew += c1*sin(t); +} +void MGL_NO_EXPORT mgl_pdj_var24(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + xNew += par[0]*(sin(par[1]*y) - cos(par[2]*x)); + yNew += par[0]*(sin(par[3]*x) - cos(par[4]*y)); +} +void MGL_NO_EXPORT mgl_fan2_var25(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal t=atan2(x,y), c1, c2; + c1 = M_PI*par[1]*par[1]; + c2 = t + par[2] - c1*int(2*t*par[2]/c1); + c1 /= 2; c2 = c2>c1?t-c1:t+c1; + c1 = par[0]*hypot(x,y); + xNew += c1*sin(c2); yNew += c1*cos(c2); +} +void MGL_NO_EXPORT mgl_rings2_var26(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal r=hypot(x,y), t=atan2(x,y), c1=par[1]*par[1]; + c1 = par[0]*(r - 2*c1*int((r+c1)/(2*c1)) + r*(1-c1)); + xNew += c1*cos(t); yNew += c1*sin(t); +} +void MGL_NO_EXPORT mgl_eyefish_var27(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1 = par[0]*2/(hypot(x,y)+1); + xNew += c1*x; yNew += c1*y; +} +void MGL_NO_EXPORT mgl_bubble_var28(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1 = par[0]*4/(x*x+y*y+4); + xNew += c1*x; yNew += c1*y; +} +void MGL_NO_EXPORT mgl_cylinder_var29(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ xNew += par[0]*sin(x); yNew += par[0]*y; } +void MGL_NO_EXPORT mgl_perspective_var30(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1 = par[0]*par[2]/(par[2]-y*sin(par[1])); + xNew += c1*x; yNew += c1*y*cos(par[1]); +} +void MGL_NO_EXPORT mgl_noise_var31(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=par[0]*mgl_rnd(), c2=2*M_PI*mgl_rnd(); + xNew += c1*x*cos(c2); yNew += c1*y*sin(c2); +} +void MGL_NO_EXPORT mgl_juliaN_var32(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=int(fabs(par[1])*mgl_rnd()), c2; + c2 = (atan2(y,x) + 2*M_PI*c1)/par[1]; + c1 = par[0]*pow(hypot(x,y), par[2]/par[1]); + xNew += c1*cos(c2); yNew += c1*sin(c2); +} +void MGL_NO_EXPORT mgl_juliaScope_var33(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=int(fabs(par[1])*mgl_rnd()), c2; + c2 = ((2*(rand()%2)-1)*atan2(y,x) + 2*M_PI*c1)/par[1]; + c1 = par[0]*pow(hypot(x,y), par[2]/par[1]); + xNew += c1*cos(c2); yNew += c1*sin(c2); +} +void MGL_NO_EXPORT mgl_blur_var34(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=par[0]*mgl_rnd(), c2=2*M_PI*mgl_rnd(); + xNew += c1*cos(c2); yNew += c1*sin(c2); +} +void MGL_NO_EXPORT mgl_gaussian_var35(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=par[0]*(4*mgl_rnd()-2), c2=2*M_PI*mgl_rnd(); + xNew += c1*cos(c2); yNew += c1*sin(c2); +} +void MGL_NO_EXPORT mgl_radialBlur_var36(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal r=hypot(x,y), c1=par[1]*M_PI/2, c2=par[0]*(4*mgl_rnd()-2), c3; + c3 = c2*cos(c1) - 1; c2 = atan2(y,x) + c2 *sin(c1); + xNew += r*cos(c2) + c3*x; yNew += r*sin(c2) + c3*y; +} +void MGL_NO_EXPORT mgl_pie_var37(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=int(mgl_rnd()*par[1] + 0.5), c2; + c2 = par[2] + 2*M_PI/par[1]*(c1 + mgl_rnd()*par[3]); + c1 = par[0]*mgl_rnd(); + xNew += c1*cos(c2); yNew += c1*sin(c2); +} +void MGL_NO_EXPORT mgl_ngon_var38(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=2*M_PI/par[2], c2; + c2 = atan2(y,x) - c1*floor(atan2(y,x)/c1); + if (c2 <= c1/2) c2 -= c1; + c1 = par[0]*(par[3]*(1/cos(c2) - 1) + par[4])/pow(hypot(x,y), par[1]); + xNew += c1*x; yNew += c1*y; +} +void MGL_NO_EXPORT mgl_curl_var39(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=1 + par[1]*x + par[2]*(x*x - y*y); + mreal c2 = par[1]*y + 2*par[2]*x*y; + mreal c3 = par[0]/(c1*c1 + c2*c2); + + xNew += c3*(c1*x + c2*y); yNew += c3*(c1*y - c2*y); +} +void MGL_NO_EXPORT mgl_rectangles_var40(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + xNew += par[0]*((2*floor(x/par[1]) + 1)*par[1] - x); + yNew += par[0]*((2*floor(y/par[2]) + 1)*par[2] - y); +} +void MGL_NO_EXPORT mgl_arch_var41(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=mgl_rnd()*M_PI*par[0], c2=sin(c1); + xNew += par[0]*c2; yNew += par[0]*c2*c2/cos(c1); +} +void MGL_NO_EXPORT mgl_tangent_var42(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ xNew += par[0]*sin(x)/cos(y); yNew += par[0]*tan(y); } +void MGL_NO_EXPORT mgl_square_var43(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + xNew += par[0]*(mgl_rnd() - 0.5); + yNew += par[0]*(mgl_rnd() - 0.5); +} +void MGL_NO_EXPORT mgl_rays_var43(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1 = par[0]*par[0]*tan(mgl_rnd()*M_PI*par[0])/(x*x+y*y); + xNew += c1*cos(x); yNew += c1*sin(y); +} +void MGL_NO_EXPORT mgl_blade_var44(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=par[0]*x, c2=mgl_rnd()*hypot(x,y)*par[0]; + xNew += c1*(cos(c2) + sin(c2)); // TODO check use of c2 + yNew += c1*(cos(c2) - sin(c2)); +} +void MGL_NO_EXPORT mgl_secant_var45(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ xNew += par[0]*x; yNew += 1/cos(par[0]*hypot(x,y)); } +void MGL_NO_EXPORT mgl_twintrian_var47(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1=par[0]*x, c2, c3; + c2 = mgl_rnd()*hypot(x,y)*par[0]; + c3 = log10(sin(c2)*sin(c2)) + cos(c2); + xNew += c1*c3; yNew += c1*(c3 - M_PI*sin(c2)); +} +void MGL_NO_EXPORT mgl_cross_var48(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par) +{ + mreal c1 = par[0]/fabs(x*x - y*y); + xNew += c1*x; yNew += c1*y; +} +//----------------------------------------------------------------------------- +typedef void (*flame_func)(mreal &xNew, mreal &yNew, mreal x, mreal y, const mreal *par); +MGL_NO_EXPORT flame_func ffunc[mglFlameLAST] = { + mgl_linear_var0, mgl_sinusoidal_var1, mgl_spherical_var2, mgl_swirl_var3, mgl_horseshoe_var4, + mgl_polar_var5, mgl_handkerchief_var6, mgl_heart_var7, mgl_disc_var8, mgl_spiral_var9, + mgl_hyperbolic_var10, mgl_diamond_var11, mgl_ex_var12, mgl_julia_var13, mgl_bent_var14, + mgl_waves_var15, mgl_fisheye_var16, mgl_popcorn_var17, mgl_exponential_var18, mgl_power_var19, + mgl_cosine_var20, mgl_rings_var21, mgl_fan_var22, mgl_blob_var23, mgl_pdj_var24, + mgl_fan2_var25, mgl_rings2_var26, mgl_eyefish_var27, mgl_bubble_var28, mgl_cylinder_var29, + mgl_perspective_var30, mgl_noise_var31, mgl_juliaN_var32, mgl_juliaScope_var33, mgl_blur_var34, + mgl_gaussian_var35, mgl_radialBlur_var36, mgl_pie_var37, mgl_ngon_var38, mgl_curl_var39, + mgl_rectangles_var40, mgl_arch_var41, mgl_tangent_var42, mgl_square_var43, mgl_rays_var43, + mgl_blade_var44, mgl_secant_var45, mgl_twintrian_var47,mgl_cross_var48 }; +//----------------------------------------------------------------------------- +long MGL_NO_EXPORT mgl_flame_2d_point(HCDT A, HCDT F, mreal& x, mreal& y, mreal amax) +{ + long i, n=A->GetNy(), m=F->GetNy(), last_func=0, l=F->GetNx(); + l = l>6?6:l; + mreal r = amax*mgl_rnd(), sum_prob = 0, x1, y1; + for(i=0;iv(6,i); + if(rv(0,i)*x + A->v(1,i)*y + A->v(4,i); + y1 = A->v(2,i)*x + A->v(3,i)*y + A->v(5,i); + x = y = 0; + for(long j=0;jv(0,j,i)+0.5); + mreal par[5] = {F->v(1,j,i),0,0,0,0}; + for(int k=2;kv(k,j,i); + if(v<0 || v>=mglFlameLAST) { v=0; par[0]=1; } + ffunc[v](x,y,x1,y1,par); last_func=v; + } + return last_func; +} +HMDT MGL_EXPORT mgl_data_flame_2d(HCDT A, HCDT F, long n, long skip) +{ + if(!A || A->GetNx()<7 || n<1) return 0; // incompatible dimensions + if(!F || F->GetNx()<2 || F->GetNz()!=A->GetNy()) return 0; // incompatible dimensions + mreal amax=0; + for(long i=0; iGetNy(); i++) amax += A->v(6,i); + if(amax<=0) return 0; + + mglData *f = new mglData(3,n); + mreal x = 0, y = 0; + for(long i=0; ia[3*i+2] = mgl_flame_2d_point(A, F, x, y, amax); // TODO color information ?!! + f->a[3*i] = x; f->a[3*i+1] = y; + } + return f; +} +uintptr_t MGL_EXPORT mgl_data_flame_2d_(uintptr_t *d, uintptr_t *f, long *n, long *skip) +{ return uintptr_t(mgl_data_flame_2d(_DT_,_DA_(f),*n,*skip)); } +//----------------------------------------------------------------------------- diff -Nru mathgl-2.3.4/src/obj.cpp mathgl-2.3.5.1/src/obj.cpp --- mathgl-2.3.4/src/obj.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/obj.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * obj.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -32,8 +32,6 @@ #include #include -#include -#include #include #include #include diff -Nru mathgl-2.3.4/src/other.cpp mathgl-2.3.5.1/src/other.cpp --- mathgl-2.3.4/src/other.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/other.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * other.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -24,7 +24,7 @@ #include "mgl2/data.h" #include "mgl2/base.h" //----------------------------------------------------------------------------- -HCDT MGL_NO_EXPORT fill_slice_x(HMGL gr, double sv, HCDT a, mglData &xx, mglData &yy, mglData &zz, mglData &aa) +HCDT MGL_NO_EXPORT fill_slice_x(HMGL gr, double sv, HCDT a, mglDataV &xx, mglDataV &yy, mglDataV &zz, mglData &aa) { long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); if(l>1) @@ -47,7 +47,7 @@ return a; } //----------------------------------------------------------------------------- -HCDT MGL_NO_EXPORT fill_slice_y(HMGL gr, double sv, HCDT a, mglData &xx, mglData &yy, mglData &zz, mglData &aa) +HCDT MGL_NO_EXPORT fill_slice_y(HMGL gr, double sv, HCDT a, mglDataV &xx, mglDataV &yy, mglDataV &zz, mglData &aa) { long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); if(l>1) @@ -70,7 +70,7 @@ return a; } //----------------------------------------------------------------------------- -HCDT MGL_NO_EXPORT fill_slice_z(HMGL gr, double sv, HCDT a, mglData &xx, mglData &yy, mglData &zz, mglData &aa) +HCDT MGL_NO_EXPORT fill_slice_z(HMGL gr, double sv, HCDT a, mglDataV &xx, mglDataV &yy, mglDataV &zz, mglData &aa) { long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); xx.Create(n,m); yy.Create(n,m); zz.Create(n,m); @@ -99,11 +99,11 @@ void MGL_EXPORT mgl_dens_x(HMGL gr, HCDT a, const char *sch, double sv, const char *opt) { long n=a->GetNx(),m=a->GetNy(); - if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"DensX"); return; } - if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"DensX"); return; } - mglData xx,yy,zz,aa; gr->SaveState(opt); + if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); + if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"DensX"); gr->LoadState(); return; } + mglDataV xx,yy,zz; mglData aa; a = fill_slice_x(gr,sv,a,xx,yy,zz,aa); mgl_surfc_xy(gr,&xx,&yy,&zz,a,sch,0); } @@ -111,11 +111,11 @@ void MGL_EXPORT mgl_dens_y(HMGL gr, HCDT a, const char *sch, double sv, const char *opt) { long n=a->GetNx(),m=a->GetNy(); - if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"DensY"); return; } - if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"DensY"); return; } - mglData xx,yy,zz,aa; gr->SaveState(opt); + if(mgl_isnan(sv)) sv = gr->GetOrgY('y'); + if(svMin.y || sv>gr->Max.y) { gr->SetWarn(mglWarnSlc,"DensY"); gr->LoadState(); return; } + mglDataV xx,yy,zz; mglData aa; a = fill_slice_y(gr,sv,a,xx,yy,zz,aa); mgl_surfc_xy(gr,&xx,&yy,&zz,a,sch,0); } @@ -123,11 +123,11 @@ void MGL_EXPORT mgl_dens_z(HMGL gr, HCDT a, const char *sch, double sv, const char *opt) { long n=a->GetNx(),m=a->GetNy(); - if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"DensZ"); return; } - if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"DensZ"); return; } - mglData xx,yy,zz,aa; gr->SaveState(opt); + if(mgl_isnan(sv)) sv = gr->GetOrgZ('z'); + if(svMin.z || sv>gr->Max.z) { gr->SetWarn(mglWarnSlc,"DensZ"); gr->LoadState(); return; } + mglDataV xx,yy,zz; mglData aa; a = fill_slice_z(gr,sv,a,xx,yy,zz,aa); mgl_surfc_xy(gr,&xx,&yy,&zz,a,sch,0); } @@ -157,12 +157,12 @@ void MGL_EXPORT mgl_cont_x_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt) { long n=a->GetNx(),m=a->GetNy(); - if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"ContX"); return; } - if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContX"); return; } gr->SaveState(opt); + if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); + if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContX"); gr->LoadState(); return; } static int cgid=1; gr->StartGroup("ContX",cgid++); - mglData xx,yy,zz,aa; + mglDataV xx,yy,zz; mglData aa; int text=0; if(mglchr(sch,'t')) text=1; @@ -171,6 +171,7 @@ gr->SetPenPal(sch); a = fill_slice_x(gr,sv,a,xx,yy,zz,aa); +#pragma omp parallel for for(long i=0;iGetNx();i++) { register mreal v0 = v->v(i); @@ -182,12 +183,12 @@ void MGL_EXPORT mgl_cont_y_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt) { long n=a->GetNx(),m=a->GetNy(); - if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"ContY"); return; } - if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContY"); return; } gr->SaveState(opt); + if(mgl_isnan(sv)) sv = gr->GetOrgY('y'); + if(svMin.y || sv>gr->Max.y) { gr->SetWarn(mglWarnSlc,"ContY"); gr->LoadState(); return; } static int cgid=1; gr->StartGroup("ContY",cgid++); - mglData xx,yy,zz,aa; + mglDataV xx,yy,zz; mglData aa; int text=0; if(mglchr(sch,'t')) text=1; @@ -196,6 +197,7 @@ gr->SetPenPal(sch); a = fill_slice_y(gr,sv,a,xx,yy,zz,aa); +#pragma omp parallel for for(long i=0;iGetNx();i++) { register mreal v0 = v->v(i); @@ -207,12 +209,12 @@ void MGL_EXPORT mgl_cont_z_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt) { long n=a->GetNx(),m=a->GetNy(); - if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"ContZ"); return; } - if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContZ"); return; } gr->SaveState(opt); + if(mgl_isnan(sv)) sv = gr->GetOrgZ('z'); + if(svMin.z || sv>gr->Max.z) { gr->SetWarn(mglWarnSlc,"ContZ"); gr->LoadState(); return; } static int cgid=1; gr->StartGroup("ContZ",cgid++); - mglData xx,yy,zz,aa; + mglDataV xx,yy,zz; mglData aa; int text=0; if(mglchr(sch,'t')) text=1; @@ -221,6 +223,7 @@ gr->SetPenPal(sch); a = fill_slice_z(gr,sv,a,xx,yy,zz,aa); +#pragma omp parallel for for(long i=0;iGetNx();i++) { register mreal v0 = v->v(i); @@ -294,15 +297,16 @@ void MGL_EXPORT mgl_contf_x_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt) { long n=a->GetNx(),m=a->GetNy(); - if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"ContFX"); return; } - if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContFX"); return; } gr->SaveState(opt); + if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); + if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContFX"); gr->LoadState(); return; } static int cgid=1; gr->StartGroup("ContFX",cgid++); - mglData xx,yy,zz,aa; + mglDataV xx,yy,zz; mglData aa; long ss=gr->AddTexture(sch); a = fill_slice_x(gr,sv,a,xx,yy,zz,aa); +#pragma omp parallel for for(long i=0;iGetNx()-1;i++) { register mreal v0 = v->v(i); @@ -314,15 +318,16 @@ void MGL_EXPORT mgl_contf_y_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt) { long n=a->GetNx(),m=a->GetNy(); - if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"ContFY"); return; } - if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContFY"); return; } gr->SaveState(opt); + if(mgl_isnan(sv)) sv = gr->GetOrgY('y'); + if(svMin.y || sv>gr->Max.y) { gr->SetWarn(mglWarnSlc,"ContFY"); gr->LoadState(); return; } static int cgid=1; gr->StartGroup("ContFY",cgid++); - mglData xx,yy,zz,aa; + mglDataV xx,yy,zz; mglData aa; long ss=gr->AddTexture(sch); a = fill_slice_y(gr,sv,a,xx,yy,zz,aa); +#pragma omp parallel for for(long i=0;iGetNx()-1;i++) { register mreal v0 = v->v(i); @@ -334,15 +339,16 @@ void MGL_EXPORT mgl_contf_z_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt) { long n=a->GetNx(),m=a->GetNy(); - if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"ContFZ"); return; } - if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContFZ"); return; } gr->SaveState(opt); + if(mgl_isnan(sv)) sv = gr->GetOrgZ('z'); + if(svMin.z || sv>gr->Max.z) { gr->SetWarn(mglWarnSlc,"ContFZ"); gr->LoadState(); return; } static int cgid=1; gr->StartGroup("ContFZ",cgid++); - mglData xx,yy,zz,aa; + mglDataV xx,yy,zz; mglData aa; long ss=gr->AddTexture(sch); a = fill_slice_z(gr,sv,a,xx,yy,zz,aa); +#pragma omp parallel for for(long i=0;iGetNx()-1;i++) { register mreal v0 = v->v(i); diff -Nru mathgl-2.3.4/src/parser.cpp mathgl-2.3.5.1/src/parser.cpp --- mathgl-2.3.4/src/parser.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/parser.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * parse.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -100,7 +100,7 @@ } //----------------------------------------------------------------------------- // return values : 0 -- OK, 1 -- wrong arguments, 2 -- wrong command, 3 -- unclosed string -int mglParser::Exec(mglGraph *gr, const wchar_t *com, long n, mglArg *a, const std::wstring &var, const wchar_t *opt) +int mglParser::Exec(mglGraph *gr, const wchar_t *com, long n, mglArg *a, const std::wstring &/*var*/, const wchar_t *opt) { int i; const char *id="dsn"; @@ -135,7 +135,7 @@ //----------------------------------------------------------------------------- mglParser::mglParser(bool setsize) { - InUse = 1; curGr = 0; + InUse = 1; curGr = 0; Variant = 0; Skip=Stop=for_br=false; memset(for_stack,0,40*sizeof(int)); memset(if_stack,0,40*sizeof(int)); @@ -272,16 +272,17 @@ //----------------------------------------------------------------------------- int MGL_LOCAL_PURE mglFindArg(const std::wstring &str) { - register long l=0,k=0,i; - for(i=0;is = L"/*"+s+L"*/"; a[n-1].type = 0; ParseDat(gr, s, *u); a[n-1].d = u; u->temp=true; DataList.push_back(u); } - else if((v = FindVar(arg[n].c_str()))!=0) // try to find normal variables (for data creation) + else if((v = FindVar(str.c_str()))!=0) // try to find normal variables (for data creation) { a[n-1].type=0; a[n-1].d=v; a[n-1].w=v->s; } - else if((f = FindNum(arg[n].c_str()))!=0) // try to find normal number (for data creation) + else if((f = FindNum(str.c_str()))!=0) // try to find normal number (for data creation) { a[n-1].type=2; a[n-1].d=0; a[n-1].v=f->d; a[n-1].c=f->c; a[n-1].w = f->s; } - else if(arg[n][0]=='!') // complex array is asked + else if(str[0]=='!') // complex array is asked { // parse all numbers and formulas by unified way - HADT d = mglFormulaCalcC(arg[n].substr(1), this, DataList); + HADT d = mglFormulaCalcC(str.substr(1), this, DataList); if(d->GetNN()==1) { - if(CheckForName(arg[n].substr(1))) + if(CheckForName(str.substr(1))) { a[n-1].type = 2; a[n-1].v = d->v(0); a[n-1].c = d->a[0]; } else - { a[n-1].type = 0; a[n-1].d = AddVar(arg[n].c_str()); } + { a[n-1].type = 0; a[n-1].d = AddVar(str.c_str()); } delete d; } else { - a[n-1].w = L"/*"+arg[n]+L"*/"; + a[n-1].w = L"/*"+str+L"*/"; d->temp=true; DataList.push_back(d); a[n-1].type = 0; a[n-1].d = d; } } else { // parse all numbers and formulas by unified way - HMDT d = mglFormulaCalc(arg[n], this, DataList); + HMDT d = mglFormulaCalc(str, this, DataList); if(d->GetNN()==1) { - if(CheckForName(arg[n])) + if(CheckForName(str)) { a[n-1].type = 2; a[n-1].c = a[n-1].v = d->v(0); } else - { a[n-1].type = 0; a[n-1].d = AddVar(arg[n].c_str()); } + { a[n-1].type = 0; a[n-1].d = AddVar(str.c_str()); } delete d; } else { - a[n-1].w = L"/*"+arg[n]+L"*/"; + a[n-1].w = L"/*"+str+L"*/"; d->temp=true; DataList.push_back(d); a[n-1].type = 0; a[n-1].d = d; } @@ -573,7 +590,6 @@ { if(Stop || gr->NeedStop()) return 0; curGr = gr->Self(); - std::wstring arg[1024]; str=mgl_trim_ws(str); long n,k=0,m=0,mm=0,res; // try parse ':' -- several commands in line @@ -598,7 +614,8 @@ PutArg(str,false); str=mgl_trim_ws(str); std::wstring opt; - for(k=0;k<1024;k++) // parse string to substrings (by spaces) + std::vector arg; + while(!str.empty()) // parse string to substrings (by spaces) { n = mglFindArg(str); if(n<1) // this is option @@ -607,17 +624,18 @@ if(n<0) str = str.substr(0,-n); break; } - arg[k] = str.substr(0,n); + arg.push_back(str.substr(0,n)); str = mgl_trim_ws(str.substr(n+1)); } // try to find last argument - if(str[0]!=0 && str[0]!='#' && str[0]!=';') { arg[k] = str; k++; } - if(k<1) n =0; + if(str[0]!=0 && str[0]!='#' && str[0]!=';') arg.push_back(str); + k = arg.size(); + if(k<1) n = 0; else { // fill arguments by its values mglArg *a = new mglArg[k]; - FillArg(gr, k, arg, a); + FillArg(gr, k, &(arg[0]), a); // execute first special (program-flow-control) commands if(!skip() && !arg[0].compare(L"stop")) { Stop = true; delete []a; return 0; } @@ -656,10 +674,16 @@ std::wstring a1 = arg[1], a2=arg[2]; res = 0; if(a1[0]=='\'') a1 = a1.substr(1,a1.length()-2); if(a2[0]=='\'') a2 = a2.substr(1,a2.length()-2); - mgl_rk_step_w(this, a1.c_str(), a2.c_str(), (k>=3 && a[2].type==2)?a[2].v:1); + mgl_rk_step_w(this, a1.c_str(), a2.c_str(), (k>3 && a[2].type==2)?a[2].v:1); } delete []a; return res; } + if(!arg[0].compare(L"variant")) + { + int res=1; + if(k==2 && a[0].type==2) { SetVariant(a[0].v); res=0; } + delete []a; return res; + } if(!arg[0].compare(L"call")) { n = 1; @@ -702,6 +726,7 @@ } if(!arg[0].compare(L"for")) { + if(k<2) { delete []a; return 1; } n = 1; char ch = arg[1][0]; int r = ch-'0'; @@ -737,10 +762,10 @@ delete []a; return n; } // alocate new arrays and execute the command itself - n = PreExec(gr, k, arg, a); + n = PreExec(gr, k, &(arg[0]), a); if(n>0) n--; else if(!arg[0].compare(L"setsize") && !AllowSetSize) n = 2; - else n = Exec(gr, arg[0].c_str(),k-1,a, arg[1].c_str(), opt.c_str()); + else n = Exec(gr, arg[0].c_str(),k-1,a, k>1?arg[1]:L"", opt.c_str()); delete []a; } // delete temporary data arrays @@ -887,7 +912,6 @@ return n+1; } //----------------------------------------------------------------------------- -#include void mglParser::Execute(mglGraph *gr, FILE *fp, bool print) { if(gr==0 || fp==0) return; @@ -1303,3 +1327,6 @@ char *s=new char[m+1]; memcpy(s,vars,m); s[m]=0; mgl_rk_step(_PR_,e,s,*dt); delete []e; delete []s; } //--------------------------------------------------------------------------- +void MGL_EXPORT mgl_parser_variant(HMPR p, int var) { p->SetVariant(var); } +void MGL_EXPORT mgl_parser_variant_(uintptr_t *p, int *var) { mgl_parser_variant(_PR_,*var); } +//--------------------------------------------------------------------------- diff -Nru mathgl-2.3.4/src/pde.cpp mathgl-2.3.5.1/src/pde.cpp --- mathgl-2.3.4/src/pde.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/pde.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * pde.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -29,12 +29,160 @@ // Advanced PDE series in 2D case // //----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_operator_exp(long n, dual *h, dual *a, dual *f) +{ + memset(f,0,2*n*sizeof(dual)); + const long i1=n/2, i2=3*n/2-1; +#pragma omp parallel for + for(long j=0;jn-1) ii=n-1; + double kk=M_PI*2*i/n; + for(long j=0;jn-1) ii=n-1; + double kk=M_PI*2*i/n; + for(long j=0;j=0?dual(sqrt(b),0):dual(0,sqrt(-b)); } +void MGL_NO_EXPORT mgl_operator_lin(long n, dual *h, dual *a, dual *f, dual *g, dual *o) +{ + memset(f,0,2*n*sizeof(dual)); + memset(g,0,2*n*sizeof(dual)); + const long i1=n/2, i2=3*n/2-1; +#pragma omp parallel for + for(long j=0;jn-1) ii=n-1; + double kk=M_PI*2*i/n; + for(long j=0;jSaveState(opt); if(mgl_isnan(gamma)) gamma = 20; - mglPoint Min=gr->Min, Max=gr->Max; - long nx=ini_re->GetNx(), nt = long((Max.y-Min.y)/dt)+1; + const mglPoint &Min=gr->Min, &Max=gr->Max; + const long nx=ini_re->GetNx(), nt = long((Max.y-Min.y)/dt)+1; if(nx<2 || nt<2 || Max.x==Min.x){ gr->SetWarn(mglWarnLow,"PDE"); return 0; } // Too small data if(ini_im->GetNx() != nx) { gr->SetWarn(mglWarnDim,"PDE"); return 0; } // Wrong dimensions @@ -49,7 +197,7 @@ list.push_back(&x); list.push_back(&y); list.push_back(&p); list.push_back(&r); list.push_back(&u); dual *a = new dual[2*nx]; memset(a,0,2*nx*sizeof(dual)); // Add "damping" area - dual *f = new dual[2*nx]; memset(f,0,2*nx*sizeof(dual)); // Effective "spectrum" + dual *f = new dual[6*nx], *g=f+2*nx, *s=f+4*nx; #pragma omp parallel for for(long i=0;iv(i), ini_im->v(i)); @@ -60,57 +208,26 @@ if(i3*nx/2) dmp[i] += gamma*mgl_ipow((i-3*nx/2-1)/mreal(nx/2),2); } + bool have_y = mglchr(func,'y'); HADT ham; + if(!have_y) + { ham = mglFormulaCalcC(func, list); mgl_datac_mul_num(ham,dd); } for(long k=0;ka+k*nx,a+nx/2,nx*sizeof(dual)); - ham = mglFormulaCalcC(func, list); - memset(f,0,2*nx*sizeof(dual)); - const long i1=nx/2, i2=3*nx/2-1; -#pragma omp parallel for - for(long j=0;ja[nx*j], h2=dual(0,dd)*ham->a[nx-1+nx*j]; - dual g1=(h1+dual(0,dd)*ham->a[nx*jp])/mreal(2), g2=(h2+dual(0,dd)*ham->a[nx-1+nx*jp])/mreal(2); - mreal k1=M_PI*2*j/nx, k2 = M_PI*(2*j+1)/nx; - for(long i=0;ia[i-i1+nx*j]; - f[2*j] += a[i]*exp(dual(0,dd)*hh+dual(0,i*k1)); - f[2*j+1] += a[i]*exp(dual(0,dd)*(hh+ham->a[i-i1+nx*jp])/mreal(2)+dual(0,i*k2)); - } - for(long i=i2;i<2*nx;i++) - { - f[2*j] += a[i]*exp(h2+dual(0,i*k1)); - f[2*j+1] += a[i]*exp(g2+dual(0,i*k2)); - } - } - memset(a,0,2*nx*sizeof(dual)); + if(have_y) + { y.Fill(k*dt); ham = mglFormulaCalcC(func, list); mgl_datac_mul_num(ham,dd); } + mgl_operator_exp(nx,ham->a,a,f); + mgl_operator_lin(nx,ham->a,a,f,g,s); + mgl_operator_lin(nx,ham->a,s,f,g,s); #pragma omp parallel for for(long i=0;i<2*nx;i++) - { - register long ii=i-i1; - if(ii<0) ii=0; if(ii>nx-1) ii=nx-1; - double kk=M_PI*2*i/nx; - for(long j=0;ja[ii+nx*j], g1 = (h1+ham->a[ii+nx*(jLoadState(); return res; } //----------------------------------------------------------------------------- @@ -195,7 +312,7 @@ }; void MGL_NO_EXPORT mgl_pde_hprep(const mgl_pde_ham *f) { - long nx = f->nx, ny = f->ny; + const long nx = f->nx, ny = f->ny; mglDataV x(nx,ny), y(nx,ny), z, r(nx,ny); mglDataW p(nx,ny), q(nx,ny); x.s = L"x"; y.s = L"y"; p.s = L"p"; q.s = L"q"; r.s=L"#$mgl"; @@ -420,7 +537,7 @@ HMDT MGL_EXPORT mgl_ode_solve_ex(void (*func)(const mreal *x, mreal *dx, void *par), int n, const mreal *x0, mreal dt, mreal tmax, void *par, void (*bord)(mreal *x, const mreal *xp, void *par)) { if(tmaxdt = rr[6] - rr[6-n7]; + ri->x0 = rr[0] - rr[-n7]; // NOTE: very rough formulas + ri->y0 = rr[1] - rr[1-n7]; // for corresponding with dt one + ri->z0 = rr[2] - rr[2-n7]; // for corresponding with dt one + double ch = sqrt(ri->x0*ri->x0 + ri->y0*ri->y0 + ri->z0*ri->z0); + ri->x0 /= ch; ri->y0 /= ch; ri->z0 /= ch; + ri->ch = ch/ri->dt; + ri->pt = rr[3]*ri->x0 + rr[4]*ri->y0 + rr[5]*ri->z0; + ri->q1 = rr[3]*ri->x1 + rr[4]*ri->y1 + rr[5]*ri->z1; + ri->q2 = rr[3]*ri->x2 + rr[4]*ri->y2 + rr[5]*ri->z2; + // NOTE previous point is used here! + tt = ri->x0*rp->x1 + ri->y0*rp->y1 + ri->z0*rp->z1; + ri->x1 = rp->x1 - tt*ri->x0; // vector g_1 + ri->y1 = rp->y1 - tt*ri->y0; + ri->z1 = rp->z1 - tt*ri->z0; + ri->t1 = tt/ch; + tt = sqrt(ri->x1*ri->x1 + ri->y1*ri->y1 + ri->z1*ri->z1); + ri->x1 /= tt; ri->y1 /= tt; ri->z1 /= tt; // norm for reducing numeric error + ri->x2 = ri->y1*ri->z0 - ri->y0*ri->z1; // vector g_2 + ri->y2 = ri->z1*ri->x0 - ri->z0*ri->x1; + ri->z2 = ri->x1*ri->y0 - ri->x0*ri->y1; + tt = ri->x0*rp->x2 + ri->y0*rp->y2 + ri->z0*rp->z2; + ri->t2 = tt/ch; + ri->d1 = (ri->q1-rp->q1)/ch; + ri->d2 = (ri->q2-rp->q2)/ch; } memcpy(ra,ra+1,sizeof(mgl_ap)); // setup zero point ra[0].pt = r[3]*ra[0].x0 + r[4]*ra[0].y0 + r[5]*ra[0].z0; @@ -554,7 +672,7 @@ mgl_ap *ra = f->ra; const mreal *r = f->r; - long nx=t->n; + const long nx=t->n; #if !MGL_HAVE_PTHREAD #pragma omp parallel for #endif @@ -581,7 +699,7 @@ { const mglData *ray=dynamic_cast(ray_dat); // NOTE: Ray must be mglData! if(!ray) return 0; - long nx=ini_re->GetNx(), nt=ray->ny, n7=ray->nx; + const long nx=ini_re->GetNx(), nt=ray->ny, n7=ray->nx; if(nx<2 || ini_im->GetNx()!=nx || nt<2) return 0; mglDataC *res=new mglDataC(nx,nt,1); @@ -706,7 +824,7 @@ mgl_qo3d_ham *f = (mgl_qo3d_ham *)t->v; mgl_ap *ra = f->ra; const mreal *r = f->r; - long nx=t->n; + const long nx=t->n; #if !MGL_HAVE_PTHREAD #pragma omp parallel for #endif @@ -739,7 +857,7 @@ { mglThreadD *t=(mglThreadD *)par; mgl_qo3d_ham *f = (mgl_qo3d_ham *)t->v; - long nx=t->n; + const long nx=t->n; #if !MGL_HAVE_PTHREAD #pragma omp parallel for #endif @@ -764,7 +882,7 @@ { const mglData *ray=dynamic_cast(ray_dat); // NOTE: Ray must be mglData! if(!ray) return 0; - long nx=ini_re->GetNx(), nt=ray->ny, n7=ray->nx; // NOTE: only square grids are supported now (for simplicity) + const long nx=ini_re->GetNx(), nt=ray->ny, n7=ray->nx; // NOTE: only square grids are supported now (for simplicity) if(nx<2 || ini_re->GetNx()!=nx || ini_im->GetNx()*ini_im->GetNy()!=nx*nx || nt<2) return 0; mglDataC *res=new mglDataC(nx,nx,nt); @@ -915,7 +1033,7 @@ MGL_NO_EXPORT void *mgl_jacob2(void *par) { mglThreadD *t=(mglThreadD *)par; - long nx=t->p[0], ny=t->p[1]; + const long nx=t->p[0], ny=t->p[1]; mreal *r=t->a; const mreal *x=t->b, *y=t->c; #if !MGL_HAVE_PTHREAD @@ -934,7 +1052,7 @@ } HMDT MGL_EXPORT mgl_jacobian_2d(HCDT x, HCDT y) { - int nx = x->GetNx(), ny=x->GetNy(); + const long nx = x->GetNx(), ny=x->GetNy(); if(nx!=y->GetNx() || ny!=y->GetNy() || nx<2 || ny<2) return 0; mglData *r=new mglData(nx,ny,1); const mglData *xx=dynamic_cast(x); @@ -962,7 +1080,7 @@ MGL_NO_EXPORT void *mgl_jacob3(void *par) { mglThreadD *t=(mglThreadD *)par; - long nx=t->p[0], ny=t->p[1], nz=t->p[2]; + const long nx=t->p[0], ny=t->p[1], nz=t->p[2]; mreal *r=t->a; const mreal *x=t->b, *y=t->c, *z=t->d; #if !MGL_HAVE_PTHREAD @@ -985,7 +1103,7 @@ } HMDT MGL_EXPORT mgl_jacobian_3d(HCDT x, HCDT y, HCDT z) { - int nx = x->GetNx(), ny=x->GetNy(), nz=x->GetNz(), nn = nx*ny*nz; + const long nx = x->GetNx(), ny=x->GetNy(), nz=x->GetNz(), nn = nx*ny*nz; if(nx<2 || ny<2 || nz<2) return 0; if(nn!=y->GetNN() || nn!=z->GetNN()) return 0; mglData *r=new mglData(nx,ny,nz); @@ -1024,3 +1142,325 @@ uintptr_t MGL_EXPORT mgl_jacobian_3d_(uintptr_t* x, uintptr_t* y, uintptr_t* z) { return uintptr_t(mgl_jacobian_3d(_DA_(x), _DA_(y), _DA_(z))); } //----------------------------------------------------------------------------- +// +// Progonka +// +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_progonka_sr(HCDT A, HCDT B, HCDT C, HCDT D, mreal *dat, long n, long id, long i0, long di, bool difr) +{ + mreal *aa=dat, *bb=dat+n, *uu=dat+2*n; + mreal b0=B->vthr(i0), c0=C->vthr(i0), d0=D->vthr(id); + if(difr) d0 = (2.-b0)*d0-c0*D->vthr(id+di); + aa[0] = -c0/b0; bb[0] = d0/b0; + for(long i=1;ivthr(ii), b=B->vthr(ii), c=C->vthr(ii); + mreal d=difr?-a*D->vthr(dd-di)+(2.-b)*D->vthr(dd)-c*D->vthr(tt):D->vthr(dd); + aa[i] = -c/(b+a*aa[i-1]); + bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]); + } + uu[n-1] = bb[n-1]; + for(long i=n-2;i>=0;i--) uu[i] = bb[i]+aa[i]*uu[i+1]; +} +void MGL_NO_EXPORT mgl_progonka_pr(HCDT A, HCDT B, HCDT C, HCDT D, mreal *dat, long n, long id, long i0, long di, bool difr) +{ + mreal *aa=dat, *bb=dat+n, *gg=dat+2*n, *uu=dat+3*n; + mreal a0=A->vthr(i0), b0=B->vthr(i0), c0=C->vthr(i0), d0=D->vthr(id); + if(difr) d0 = -a0*D->vthr(id+di*(n-1))+(2.-b0)*d0-c0*D->vthr(id+di); + aa[0] =-c0/b0; bb[0] = d0/b0; gg[0] =-a0/b0; + for(long i=1;ivthr(ii), b=B->vthr(ii), c=C->vthr(ii); + mreal d=difr?-a*D->vthr(dd-di)+(2.-b)*D->vthr(dd)-c*D->vthr(il):D->vthr(dd); + aa[i] = -c/(b+a*aa[i-1]); + bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]); + gg[i] = -a*gg[i-1]/(b+a*aa[i-1]); + } + mreal P=bb[n-1]/(1.-gg[n-1]), Q=aa[n-1]/(1.-gg[n-1]); + aa[n-1] = Q; bb[n-1] = P; + for(long i=n-2;i>=0;i--) + { + bb[i] += aa[i]*bb[i+1]+gg[i]*P; + aa[i] = aa[i]*aa[i+1]+gg[i]*Q; + } + mreal u0 = bb[0]/(1.-aa[0]); + for(long i=0;ivthr(i0), c0=C->vthr(i0), d0=D->vthr(id); + uu[0] = d0/b0*(difr?(2.-b0):1.); + b0=B->vthr(i0+n*n-1); d0=D->vthr(id+n*n-1); + uu[n*n-1] = d0/b0*(difr?(2.-b0):1.); + long di = n-1, i1 = i0+n*(n-1), d1 = id+n*(n-1); + // suppose the square grid! + for(long j=1;jvthr(i0+j); c0=C->vthr(i0+j); d0=D->vthr(id+j); + if(difr) d0 = (2.-b0)*d0-c0*D->vthr(id+j+di); + aa[0] = -c0/b0; bb[0] = d0/b0; + for(long i=1;i<=j;i++) + { + register long ii=i0+j+di*i, dd=id+j+di*i; + mreal a=A->vthr(ii),b=B->vthr(ii),c=C->vthr(ii); + mreal d=difr?-a*D->vthr(dd-di)+(2.-b)*D->vthr(dd)-c*D->vthr(dd+di):D->vthr(dd); + aa[i] = -c/(b+a*aa[i-1]); + bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]); + } + uu[j+di*(j-1)] = bb[j]; + for(long i=j-1;i>=0;i--) + uu[j+di*i] = bb[i]+aa[i]*uu[j+di*i+di]; + // next top-right triangle + long j1=n-1-j; + b0=B->vthr(i1+j1); c0=C->vthr(i1+j1); d0=D->vthr(d1+j1); + if(difr) d0 = (2.-b0)*d0-c0*D->vthr(d1+j1-di); + aa[0] = -c0/b0; bb[0] = d0/b0; + for(long i=1;i<=j;i++) + { + register long ii=i1+j1-di*i, dd=d1+j1-di*i; + mreal a=A->vthr(ii),b=B->vthr(ii),c=C->vthr(ii); + mreal d=difr?-a*D->vthr(dd+di)+(2.-b)*D->vthr(dd)-c*D->vthr(dd-di):D->vthr(dd); + aa[i] = -c/(b+a*aa[i-1]); + bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]); + } + uu[j1+n*(n-1)-di*(j-1)] = bb[j]; + for(long i=j-1;i>=0;i--) + uu[j1+n*(n-1)-di*i] = bb[i]+aa[i]*uu[j1+n*(n-1)-di*i-di]; + } +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_data_tridmat(HCDT A, HCDT B, HCDT C, HCDT D, const char *how) +{ + const long nx=D->GetNx(),ny=D->GetNy(),nz=D->GetNz(); + const long nn=nx*ny*nz, np=nx*ny, na=A->GetNN(); + if(B->GetNN()!=na || C->GetNN()!=na) return 0; + mglData *r = new mglData(nx,ny,nz); + bool per = mglchr(how,'c'); + bool difr = mglchr(how,'d'); + if(mglchr(how,'x') && (na==nn || na==np || na==nx)) +#pragma omp parallel + { + mglData T(nx,4); mreal *uu=T.a+(per?3:2)*nx; +#pragma omp for collapse(2) + for(long k=0;ka[i+i0] = uu[i]; + } + } + else if(mglchr(how,'y') && (na==nn || na==np || na==ny)) +#pragma omp parallel + { + mglData T(ny,4); mreal *uu=T.a+(per?3:2)*ny; +#pragma omp for collapse(2) + for(long k=0;ka[j*nx+i0] = uu[j]; + } + } + else if(mglchr(how,'z') && (na==nn || na==nz)) +#pragma omp parallel + { + mglData T(nz,4); mreal *uu=T.a+(per?3:2)*nz; +#pragma omp for collapse(2) + for(long j=0;ja[k*np+i0] = uu[k]; + } + } + else if(mglchr(how,'h') && ny==nx && (na==nn || na==np) && nx>1) +#pragma omp parallel + { + mglData T(np,2); +#pragma omp for + for(long k=0;ka+k*np, T.a+np, np*sizeof(mreal)); + } + } + else { delete r; r=0; } + return r; +} +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_data_tridmat_(uintptr_t *A, uintptr_t *B, uintptr_t *C, uintptr_t *D, const char *how, int l) +{ char *s=new char[l+1]; memcpy(s,how,l); s[l]=0; + uintptr_t r = uintptr_t(mgl_data_tridmat(_DA_(A),_DA_(B),_DA_(C),_DA_(D),s)); + delete []s; return r; +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_progonka_sc(HCDT A, HCDT B, HCDT C, HCDT D, dual *dat, long n, long id, long i0, long di, bool difr) +{ + dual *aa=dat, *bb=dat+n, *uu=dat+2*n; + dual b0=B->vcthr(i0), c0=C->vcthr(i0), d0=D->vcthr(id); + if(difr) d0 = (2.-b0)*d0-c0*D->vcthr(id+di); + aa[0] = -c0/b0; bb[0] = d0/b0; + for(long i=1;ivcthr(ii), b=B->vcthr(ii), c=C->vcthr(ii); + dual d=difr?-a*D->vcthr(dd-di)+(2.-b)*D->vcthr(dd)-c*D->vcthr(tt):D->vcthr(dd); + aa[i] = -c/(b+a*aa[i-1]); + bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]); + } + uu[n-1] = bb[n-1]; + for(long i=n-2;i>=0;i--) uu[i] = bb[i]+aa[i]*uu[i+1]; +} +void MGL_NO_EXPORT mgl_progonka_pc(HCDT A, HCDT B, HCDT C, HCDT D, dual *dat, long n, long id, long i0, long di, bool difr) +{ + dual *aa=dat, *bb=dat+n, *gg=dat+2*n, *uu=dat+3*n; + dual a0=A->vcthr(i0), b0=B->vcthr(i0), c0=C->vcthr(i0), d0=D->vcthr(id); + if(difr) d0 = -a0*D->vcthr(id+di*(n-1))+(2.-b0)*d0-c0*D->vcthr(id+di); + aa[0] =-c0/b0; bb[0] = d0/b0; gg[0] =-a0/b0; + for(long i=1;ivcthr(ii), b=B->vcthr(ii), c=C->vcthr(ii); + dual d=difr?-a*D->vcthr(dd-di)+(2.-b)*D->vcthr(dd)-c*D->vcthr(il):D->vcthr(dd); + aa[i] = -c/(b+a*aa[i-1]); + bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]); + gg[i] = -a*gg[i-1]/(b+a*aa[i-1]); + } + dual P=bb[n-1]/(1.-gg[n-1]), Q=aa[n-1]/(1.-gg[n-1]); + aa[n-1] = Q; bb[n-1] = P; + for(long i=n-2;i>=0;i--) + { + bb[i] += aa[i]*bb[i+1]+gg[i]*P; + aa[i] = aa[i]*aa[i+1]+gg[i]*Q; + } + dual u0 = bb[0]/(1.-aa[0]); + for(long i=0;ivcthr(i0), c0=C->vcthr(i0), d0=D->vcthr(id); + uu[0] = d0/b0*(difr?(2.-b0):1.); + b0=B->vcthr(i0+n*n-1); d0=D->vcthr(id+n*n-1); + uu[n*n-1] = d0/b0*(difr?(2.-b0):1.); + long di = n-1, i1 = i0+n*(n-1), d1 = id+n*(n-1); + // suppose the square grid! + for(long j=1;jvcthr(i0+j); c0=C->vcthr(i0+j); d0=D->vcthr(id+j); + if(difr) d0 = (2.-b0)*d0-c0*D->vcthr(id+j+di); + aa[0] = -c0/b0; bb[0] = d0/b0; + for(long i=1;i<=j;i++) + { + register long ii=i0+j+di*i, dd=id+j+di*i; + dual a=A->vcthr(ii),b=B->vcthr(ii),c=C->vcthr(ii); + dual d=difr?-a*D->vcthr(dd-di)+(2.-b)*D->vcthr(dd)-c*D->vcthr(dd+di):D->vcthr(dd); + aa[i] = -c/(b+a*aa[i-1]); + bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]); + } + uu[j+di*(j-1)] = bb[j]; + for(long i=j-1;i>=0;i--) + uu[j+di*i] = bb[i]+aa[i]*uu[j+di*i+di]; + // next top-right triangle + long j1=n-1-j; + b0=B->vcthr(i1+j1); c0=C->vcthr(i1+j1); d0=D->vcthr(d1+j1); + if(difr) d0 = (2.-b0)*d0-c0*D->vcthr(d1+j1-di); + aa[0] = -c0/b0; bb[0] = d0/b0; + for(long i=1;i<=j;i++) + { + register long ii=i1+j1-di*i, dd=d1+j1-di*i; + dual a=A->vcthr(ii),b=B->vcthr(ii),c=C->vcthr(ii); + dual d=difr?-a*D->vcthr(dd+di)+(2.-b)*D->vcthr(dd)-c*D->vcthr(dd-di):D->vcthr(dd); + aa[i] = -c/(b+a*aa[i-1]); + bb[i] = (d-a*bb[i-1])/(b+a*aa[i-1]); + } + uu[j1+n*(n-1)-di*(j-1)] = bb[j]; + for(long i=j-1;i>=0;i--) + uu[j1+n*(n-1)-di*i] = bb[i]+aa[i]*uu[j1+n*(n-1)-di*i-di]; + } +} +//----------------------------------------------------------------------------- +HADT MGL_EXPORT mgl_datac_tridmat(HCDT A, HCDT B, HCDT C, HCDT D, const char *how) +{ + const long nx=D->GetNx(),ny=D->GetNy(),nz=D->GetNz(); + const long nn=nx*ny*nz, np=nx*ny, na=A->GetNN(); + if(B->GetNN()!=na || C->GetNN()!=na) return 0; + mglDataC *r = new mglDataC(nx,ny,nz); + bool per = mglchr(how,'c'); + bool difr = mglchr(how,'d'); + if(mglchr(how,'x') && (na==nn || na==np || na==nx)) +#pragma omp parallel + { + mglDataC T(nx,4); dual *uu=T.a+(per?3:2)*nx; +#pragma omp for collapse(2) + for(long k=0;ka[i+i1] = uu[i]; + } + } + else if(mglchr(how,'y') && (na==nn || na==np || na==ny)) +#pragma omp parallel + { + mglDataC T(ny,4); dual *uu=T.a+(per?3:2)*ny; +#pragma omp for collapse(2) + for(long k=0;ka[j*nx+i0] = uu[j]; + } + } + else if(mglchr(how,'z') && (na==nn || na==nz)) +#pragma omp parallel + { + mglDataC T(nz,4); dual *uu=T.a+(per?3:2)*nz; +#pragma omp for collapse(2) + for(long j=0;ja[k*np+i1] = uu[k]; + } + } + else if(mglchr(how,'h') && ny==nx && (na==nn || na==np) && nx>1) +#pragma omp parallel + { + mglDataC T(np,2); +#pragma omp for + for(long k=0;ka+k*np, T.a+np, np*sizeof(dual)); + } + } + else { delete r; r=0; } + return r; +} +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_datac_tridmat_(uintptr_t *A, uintptr_t *B, uintptr_t *C, uintptr_t *D, const char *how, int l) +{ char *s=new char[l+1]; memcpy(s,how,l); s[l]=0; + uintptr_t r = uintptr_t(mgl_datac_tridmat(_DA_(A),_DA_(B),_DA_(C),_DA_(D),s)); + delete []s; return r; +} +//----------------------------------------------------------------------------- diff -Nru mathgl-2.3.4/src/pixel.cpp mathgl-2.3.5.1/src/pixel.cpp --- mathgl-2.3.4/src/pixel.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/pixel.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * pixel.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -20,6 +20,9 @@ #include #include "mgl2/canvas.h" #include "mgl2/thread.h" +#if MGL_HAVE_OMP +#include +#endif inline mreal get_persp(float pf, float z, float Depth) //{ return (1-pf)/(1-pf*z/Depth); } @@ -46,7 +49,7 @@ #if MGL_HAVE_PTHREAD pthread_mutex_lock(&mutexClf); #elif MGL_HAVE_OMP - omp_set_lock(&lockClf); + omp_set_lock((omp_lock_t*)lockClf); #endif if(G) { delete []G; delete []C; delete []Z; delete []G4;delete []GB;delete []OI; G=0; } G = new unsigned char[s*3]; @@ -60,7 +63,7 @@ #if MGL_HAVE_PTHREAD pthread_mutex_unlock(&mutexClf); #elif MGL_HAVE_OMP - omp_unset_lock(&lockClf); + omp_unset_lock((omp_lock_t*)lockClf); #endif InPlot(0,1,0,1,false); @@ -71,7 +74,7 @@ pthread_mutex_lock(&mutexPnt); pthread_mutex_lock(&mutexClf); #elif MGL_HAVE_OMP - omp_set_lock(&lockClf); + omp_set_lock((omp_lock_t*)lockClf); #endif const long m = long(Prm.size()); double dd = dx>dy?dy:dx; @@ -115,7 +118,7 @@ pthread_mutex_unlock(&mutexClf); pthread_mutex_unlock(&mutexPnt); #elif MGL_HAVE_OMP - omp_unset_lock(&lockClf); + omp_unset_lock((omp_lock_t*)lockClf); #endif ClfZB(); Finish(); } @@ -672,7 +675,7 @@ pthread_mutex_lock(&mutexPnt); pthread_mutex_lock(&mutexClf); #elif MGL_HAVE_OMP - omp_set_lock(&lockClf); + omp_set_lock((omp_lock_t*)lockClf); #endif if(Quality==MGL_DRAW_DOTS) { @@ -706,7 +709,7 @@ pthread_mutex_unlock(&mutexPnt); pthread_mutex_unlock(&mutexPrm); #elif MGL_HAVE_OMP - omp_unset_lock(&lockClf); + omp_unset_lock((omp_lock_t*)lockClf); #endif } //----------------------------------------------------------------------------- @@ -912,7 +915,6 @@ if(c2[3]) { const register unsigned a1=c1[3], a2=c2[3]; - if(a2==255 || a1==0) { memcpy(c1,c2,4); return; } if((Flag&3)==0) { register unsigned b1=255-a2; @@ -931,10 +933,10 @@ else if((Flag&3)==2) { register unsigned b1,b2,b3; - b1 = (c1[0]*a1 + c2[0]*a2)/256; c1[0] = b1<255 ? b1 : 255; - b2 = (c1[1]*a1 + c2[1]*a2)/256; c1[1] = b2<255 ? b2 : 255; - b3 = (c1[2]*a1 + c2[2]*a2)/256; c1[2] = b3<255 ? b3 : 255; - c1[3] = a1+a2>255? 255 : a1+a2; + b1 = (c1[0]*a1 + c2[0]*a2)/255; c1[0] = b1<255 ? b1 : 255; + b2 = (c1[1]*a1 + c2[1]*a2)/255; c1[1] = b2<255 ? b2 : 255; + b3 = (c1[2]*a1 + c2[2]*a2)/255; c1[2] = b3<255 ? b3 : 255; + c1[3] = 255; } } } @@ -1193,7 +1195,7 @@ if(u<0) v += u*u; else if(u>dd) v += (u-dd)*(u-dd); // if(v>pw*pw) continue; - if(!(pd & ( 1L<dd) v += (u-dd)*(u-dd); // if(v>pw*pw) continue; - if(!(pd & (1L<dd) v += (u-dd)*(u-dd); register float pw=dr->PenWidth, dpw=3*pen_delta; if(dr->ObjId==HighId) { pw *= 2; dpw=2*pen_delta; } - if(v>pw*pw || !(dr->PDef & ( 1L<pPos+u/pw/1.5, 16)) ) )) return; + if(v>pw*pw || !(dr->PDef & ( (uint64_t)1<pPos+u/pw/1.5, 16)) ) )) return; mglPnt p(p1+d*(u/dd)); unsigned char r[4]; col2int(p,r,dr->ObjId); diff -Nru mathgl-2.3.4/src/plot.cpp mathgl-2.3.5.1/src/plot.cpp --- mathgl-2.3.4/src/plot.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/plot.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * plot.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -752,12 +752,13 @@ void MGL_EXPORT mgl_step_xy(HMGL gr, HCDT x, HCDT y, const char *pen, const char *opt) { long m,n=y->GetNx(), pal; - if(mgl_check_dim1(gr,x,y,0,0,"Step")) return; + if(mgl_check_dim1(gr,x,y,0,0,"Step",true)) return; gr->SaveState(opt); static int cgid=1; gr->StartGroup("Step",cgid++); m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); bool sh = mglchr(pen,'!'); + bool same = x->GetNx()==n; mreal zVal =gr->AdjustZMin(); char mk=gr->SetPenPal(pen,&pal); gr->Reserve(2*n*m); @@ -767,21 +768,33 @@ if(gr->NeedStop()) break; long mx = jGetNy() ? j:0, my = jGetNy() ? j:0; gr->NextColor(pal); - long n1 = gr->AddPnt(mglPoint(x->v(0,mx), y->v(0,my), zVal)); + mreal xx = x->v(0,mx); + long n1 = gr->AddPnt(mglPoint(same?xx:(xx+x->v(1,mx))/2, y->v(0,my), zVal)); if(mk) gr->mark_plot(n1,mk); + if(!same) n1 = gr->AddPnt(mglPoint(xx, y->v(0,my), zVal)); for(long i=1;iv(i,mx), y->v(i-1,my), zVal); + xx = x->v(i,mx); + p.Set(xx, y->v(i-1,my), zVal); mreal c = sh ? gr->NextColor(pal,i):gr->CDef; n1 = gr->AddPnt(p,c); gr->line_plot(n1,n2); if(i==1) gr->arrow_plot(n2,n1,gr->Arrow1); n2 = n1; // vertical p.y = y->v(i,my); n1 = gr->AddPnt(p,c); - if(mk) gr->mark_plot(n1,mk); gr->line_plot(n1,n2); - if(i==n-1) gr->arrow_plot(n1,n2,gr->Arrow2); + if(same && i==n-1) gr->arrow_plot(n1,n2,gr->Arrow2); + long nn = n1; + if(!same) nn = gr->AddPnt(mglPoint((xx+x->v(i+1,mx))/2, y->v(i,my), zVal)); + if(mk) gr->mark_plot(nn,mk); + } + if(!same) + { + p.Set(x->v(n,mx), y->v(n-1,my), zVal); + mreal c = sh ? gr->NextColor(pal,n-1):gr->CDef; + long n2 = gr->AddPnt(p,c); gr->line_plot(n1,n2); + gr->arrow_plot(n2,n1,gr->Arrow2); } } gr->EndGroup(); diff -Nru mathgl-2.3.4/src/prc/PRC.h mathgl-2.3.5.1/src/prc/PRC.h --- mathgl-2.3.4/src/prc/PRC.h 2016-02-13 19:01:08.000000000 +0000 +++ mathgl-2.3.5.1/src/prc/PRC.h 2016-06-19 17:01:18.000000000 +0000 @@ -18,6 +18,8 @@ #include #endif // _MSC_VER +#include + //const uint32_t PRCVersion=7094; // For Adobe Reader 8 or later const uint32_t PRCVersion=8137; // For Adobe Reader 9 or later diff -Nru mathgl-2.3.4/src/prc.cpp mathgl-2.3.5.1/src/prc.cpp --- mathgl-2.3.4/src/prc.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/prc.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * prc.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/src/prim.cpp mathgl-2.3.5.1/src/prim.cpp --- mathgl-2.3.4/src/prim.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/prim.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * prim.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/src/s_hull/s_hull_pro.h mathgl-2.3.5.1/src/s_hull/s_hull_pro.h --- mathgl-2.3.4/src/s_hull/s_hull_pro.h 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/s_hull/s_hull_pro.h 2016-06-19 17:01:20.000000000 +0000 @@ -7,6 +7,7 @@ #include #include #include +#include /* for use in s_hull_pro.cpp diff -Nru mathgl-2.3.4/src/surf.cpp mathgl-2.3.5.1/src/surf.cpp --- mathgl-2.3.4/src/surf.cpp 2016-02-13 19:01:09.000000000 +0000 +++ mathgl-2.3.5.1/src/surf.cpp 2016-06-19 17:01:20.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * surf.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/src/tex_table.cc mathgl-2.3.5.1/src/tex_table.cc --- mathgl-2.3.4/src/tex_table.cc 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/tex_table.cc 2016-06-19 17:01:24.000000000 +0000 @@ -20,8 +20,8 @@ #include "mgl2/font.h" /// Table of LaTeX symbols and its UTF8 codes. This array MUST BE sorted!!! -MGL_EXPORT long mgl_tex_num=1924; -MGL_EXPORT mglTeXsymb mgl_tex_symb[] = { +const size_t mgl_tex_num=1924; +const mglTeXsymb mgl_tex_symb[] = { {0x23, L"#"}, {0x25, L"%"}, {0x26, L"&"}, diff -Nru mathgl-2.3.4/src/vect.cpp mathgl-2.3.5.1/src/vect.cpp --- mathgl-2.3.4/src/vect.cpp 2016-02-13 19:01:08.000000000 +0000 +++ mathgl-2.3.5.1/src/vect.cpp 2016-06-19 17:01:18.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * vect.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -498,23 +498,24 @@ // Flow 2d series // //----------------------------------------------------------------------------- -void MGL_NO_EXPORT flow(mglBase *gr, double zVal, double u, double v, const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, long ss, bool vv) +void MGL_NO_EXPORT flow(mglBase *gr, double zVal, double u, double v, HCDT x, HCDT y, HCDT ax, HCDT ay, long ss, bool vv) { - long n=100*(ax.nx+ax.ny); - bool nboth = x.nx*x.ny!=ax.nx*ax.ny || y.nx*y.ny!=ax.nx*ax.ny; + long n=100*(ax->GetNx()+ax->GetNy()); + bool nboth = x->GetNx()*x->GetNy()!=ax->GetNx()*ax->GetNy() || y->GetNx()*y->GetNy()!=ax->GetNx()*ax->GetNy(); mglPoint *pp = new mglPoint[n], dp; mglPoint dx(1/fabs(gr->Max.x-gr->Min.x),1/fabs(gr->Max.y-gr->Min.y),1/fabs(gr->Max.z-gr->Min.z)); - mglPoint nx(ax.nx,ax.ny); + mglPoint nx(ax->GetNx(),ax->GetNy()); - mreal dt = 0.5/(ax.nx > ax.ny ? ax.nx : ax.ny),e,f,g,ff[4],gg[4],h,s=2,acc=dt/20; + mreal dt = 0.5/(ax->GetNx() > ax->GetNy() ? ax->GetNx() : ax->GetNy()); + mreal e,f,g,ff[4],gg[4],h,s=2,acc=dt/20; if(u<0 || v<0) { dt = -dt; u = -u; v = -v; s *= -1;} long k=0; bool end = false; if(nboth) do{ mglPoint dif; - pp[k].x = x.Spline1(dif,u,0,0); f = ax.Spline1(u,v,0)/dif.x; - pp[k].y = y.Spline1(dif,v,0,0); g = ay.Spline1(u,v,0)/dif.x; + pp[k].x = x->Spline1(dif,u,0,0); f = ax->Spline1(u,v,0)/dif.x; + pp[k].y = y->Spline1(dif,v,0,0); g = ay->Spline1(u,v,0)/dif.x; pp[k].z = zVal; if(mgl_isbad(f+g)) break; else for(long m=0;mSpline1(dif,e,0,0); f = ax->Spline1(e,h,0)/dif.x; + y->Spline1(dif,h,0,0); g = ay->Spline1(e,h,0)/dif.x; h = 1+hypot(f,g); ff[1]=f*dt/h; gg[1]=g*dt/h; e = u+ff[1]/2; h = v+gg[1]/2; - x.Spline1(dif,e,0,0); f = ax.Spline1(e,h,0)/dif.x; - y.Spline1(dif,h,0,0); g = ay.Spline1(e,h,0)/dif.x; + x->Spline1(dif,e,0,0); f = ax->Spline1(e,h,0)/dif.x; + y->Spline1(dif,h,0,0); g = ay->Spline1(e,h,0)/dif.x; h = 1+hypot(f,g); ff[2]=f*dt/h; gg[2]=g*dt/h; e = u+ff[2]; h = v+gg[2]; - x.Spline1(dif,e,0,0); f = ax.Spline1(e,h,0)/dif.x; - y.Spline1(dif,h,0,0); g = ay.Spline1(e,h,0)/dif.x; + x->Spline1(dif,e,0,0); f = ax->Spline1(e,h,0)/dif.x; + y->Spline1(dif,h,0,0); g = ay->Spline1(e,h,0)/dif.x; h = 1+hypot(f,g); ff[3]=f*dt/h; gg[3]=g*dt/h; u += ff[0]/6+ff[1]/3+ff[2]/3+ff[3]/6; v += gg[0]/6+gg[1]/3+gg[2]/3+gg[3]/6; @@ -544,9 +545,9 @@ else do{ mglPoint dif; register mreal xu,xv,yu,yv,det,xx,yy; - pp[k].x = x.Spline1(dif,u,v,0); xu=dif.x; xv=dif.y; - pp[k].y = y.Spline1(dif,u,v,0); yu=dif.x; yv=dif.y; - xx = ax.Spline1(u,v,0); yy = ay.Spline1(u,v,0); + pp[k].x = x->Spline1(dif,u,v,0); xu=dif.x; xv=dif.y; + pp[k].y = y->Spline1(dif,u,v,0); yu=dif.x; yv=dif.y; + xx = ax->Spline1(u,v,0); yy = ay->Spline1(u,v,0); det = xv*yu-xu*yv; f = (yy*xv-xx*yv)/det; g = (xx*yu-yy*xu)/det; pp[k].z = zVal; if(mgl_isbad(f+g)) break; @@ -558,21 +559,21 @@ // find next point by midpoint method h+=1; ff[0]=f*dt/h; gg[0]=g*dt/h; e = u+ff[0]/2; h = v+gg[0]/2; - x.Spline1(dif,e,h,0); xu=dif.x; xv=dif.y; - y.Spline1(dif,e,h,0); yu=dif.x; yv=dif.y; - xx = ax.Spline1(e,h,0); yy = ay.Spline1(e,h,0); + x->Spline1(dif,e,h,0); xu=dif.x; xv=dif.y; + y->Spline1(dif,e,h,0); yu=dif.x; yv=dif.y; + xx = ax->Spline1(e,h,0); yy = ay->Spline1(e,h,0); det = xv*yu-xu*yv; f = (yy*xv-xx*yv)/det; g = (xx*yu-yy*xu)/det; h = 1+hypot(f,g); ff[1]=f*dt/h; gg[1]=g*dt/h; e = u+ff[1]/2; h = v+gg[1]/2; - x.Spline1(dif,e,h,0); xu=dif.x; xv=dif.y; - y.Spline1(dif,e,h,0); yu=dif.x; yv=dif.y; - xx = ax.Spline1(e,h,0); yy = ay.Spline1(e,h,0); + x->Spline1(dif,e,h,0); xu=dif.x; xv=dif.y; + y->Spline1(dif,e,h,0); yu=dif.x; yv=dif.y; + xx = ax->Spline1(e,h,0); yy = ay->Spline1(e,h,0); det = xv*yu-xu*yv; f = (yy*xv-xx*yv)/det; g = (xx*yu-yy*xu)/det; h = 1+hypot(f,g); ff[2]=f*dt/h; gg[2]=g*dt/h; e = u+ff[2]; h = v+gg[2]; - x.Spline1(dif,e,h,0); xu=dif.x; xv=dif.y; - y.Spline1(dif,e,h,0); yu=dif.x; yv=dif.y; - xx = ax.Spline1(e,h,0); yy = ay.Spline1(e,h,0); + x->Spline1(dif,e,h,0); xu=dif.x; xv=dif.y; + y->Spline1(dif,e,h,0); yu=dif.x; yv=dif.y; + xx = ax->Spline1(e,h,0); yy = ay->Spline1(e,h,0); det = xv*yu-xu*yv; f = (yy*xv-xx*yv)/det; g = (xx*yu-yy*xu)/det; h = 1+hypot(f,g); ff[3]=f*dt/h; gg[3]=g*dt/h; u += ff[0]/6+ff[1]/3+ff[2]/3+ff[3]/6; @@ -583,7 +584,7 @@ if(k>1) { long j,a=long(0.3*gr->GetArrowSize()/fabs(dt)); - gr->Reserve(k); j = gr->AddPnt(pp[0],pp[0].c); + gr->Reserve(k); j = gr->AddPnt(pp[0],pp[0].c); for(long i=1;iAddPnt(pp[i],pp[i].c); @@ -611,32 +612,42 @@ // allocate memory mreal zVal = gr->Min.z; bool cnt=!mglchr(sch,'#'); - mglData xx(x), yy(y), bx(ax), by(ay); + std::vector u, v; + if(mglchr(sch,'*')) for(long i=0;iGetNz();k++) { if(gr->NeedStop()) break; if(ax->GetNz()>1) zVal = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(k)/(ax->GetNz()-1); - for(long i=0;iNeedStop()) { i=num; s=2; continue; } - u = 0; v = (i+1.)/(num+1.); - flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv); - u = 1; v = (i+1.)/(num+1.); - flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv); - u = (i+1.)/(num+1.); v = 0; - flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv); - u = (i+1.)/(num+1.); v = 1; - flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv); - if(cnt) - { - u = 0.5; v = (i+1.)/(num+1.); - flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv); - u = (i+1.)/(num+1.); v = 0.5; - flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv); - } - } + HMDT bx=mgl_data_subdata(ax,-1,-1,k), by=mgl_data_subdata(ay,-1,-1,k); +#pragma omp parallel for + for(long i=0;iNeedStop()) + flow(gr, zVal, u[i], v[i], x, y, bx, by,ss,vv); + mgl_delete_data(bx); mgl_delete_data(by); } gr->EndGroup(); } @@ -701,8 +712,7 @@ v = (j0-(dxu*dy-dx*dyu)/d)/m; } } - mglData xx(x), yy(y), bx(ax), by(ay); - flow(gr, z0, u, v, xx, yy, bx, by,ss,vv); + flow(gr, z0, u, v, x, y, ax, ay,ss,vv); gr->EndGroup(); } //----------------------------------------------------------------------------- @@ -729,17 +739,17 @@ // Flow 3d series // //----------------------------------------------------------------------------- -void flow(mglBase *gr, double u, double v, double w, const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az,long ss,bool vv, bool xo, bool zo) +void flow(mglBase *gr, double u, double v, double w, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az,long ss,bool vv, bool xo, bool zo) { - static long n=100*(ax.nx+ax.ny+ax.nz); - long nn = ax.nx*ax.ny*ax.nz; - bool nboth = x.nx*x.ny*x.nz!=nn || y.nx*y.ny*y.nz!=nn || z.nx*z.ny*z.nz!=nn; + static long n=100*(ax->GetNx()+ax->GetNy()+ax->GetNz()); + long nn = ax->GetNN(); + bool nboth = x->GetNN()!=nn || y->GetNN()!=nn || z->GetNN()!=nn; mglPoint *pp = new mglPoint[n], dp; mglPoint dx(1/fabs(gr->Max.x-gr->Min.x),1/fabs(gr->Max.y-gr->Min.y),1/fabs(gr->Max.z-gr->Min.z)); - mglPoint nx(ax.nx,ax.ny,ax.nz); + mglPoint nx(ax->GetNx(),ax->GetNy(),ax->GetNz()); - nn = (ax.nx > ax.ny ? ax.nx : ax.ny); - nn = (nn > ax.nz ? nn : ax.nz); + nn = (ax->GetNx() > ax->GetNy() ? ax->GetNz() : ax->GetNy()); + nn = (nn > ax->GetNz() ? nn : ax->GetNz()); mreal dt = 0.2/nn, e,f,g,ee[4],ff[4],gg[4],h,s=2,u1,v1,w1,acc=dt/20; if(u<0 || v<0 || w<0) { dt = -dt; u = -u; v = -v; w = -w; s *= -1;} @@ -747,9 +757,9 @@ bool end = false; if(nboth) do{ mglPoint dif; - pp[k].x = x.Spline1(dif,u,0,0); e = ax.Spline1(u,v,w)/dif.x; - pp[k].y = y.Spline1(dif,v,0,0); f = ay.Spline1(u,v,w)/dif.x; - pp[k].z = z.Spline1(dif,w,0,0); g = az.Spline1(u,v,w)/dif.x; + pp[k].x = x->Spline1(dif,u,0,0); e = ax->Spline1(u,v,w)/dif.x; + pp[k].y = y->Spline1(dif,v,0,0); f = ay->Spline1(u,v,w)/dif.x; + pp[k].z = z->Spline1(dif,w,0,0); g = az->Spline1(u,v,w)/dif.x; if(mgl_isbad(e+f+g)) end = true; else for(long m=0;mSpline1(dif,u1,0,0); e = ax->Spline1(u1,v1,w1)/dif.x; + y->Spline1(dif,v1,0,0); f = ay->Spline1(u1,v1,w1)/dif.x; + z->Spline1(dif,w1,0,0); g = az->Spline1(u1,v1,w1)/dif.x; h = 1+sqrt(e*e+f*f+g*g); ee[1]=e*dt/h; ff[1]=f*dt/h; gg[1]=g*dt/h; u1 = u+ee[1]/2; v1 = v+ff[1]/2; w1 = w+gg[1]/2; - x.Spline1(dif,u1,0,0); e = ax.Spline1(u1,v1,w1)/dif.x; - y.Spline1(dif,v1,0,0); f = ay.Spline1(u1,v1,w1)/dif.x; - z.Spline1(dif,w1,0,0); g = az.Spline1(u1,v1,w1)/dif.x; + x->Spline1(dif,u1,0,0); e = ax->Spline1(u1,v1,w1)/dif.x; + y->Spline1(dif,v1,0,0); f = ay->Spline1(u1,v1,w1)/dif.x; + z->Spline1(dif,w1,0,0); g = az->Spline1(u1,v1,w1)/dif.x; h = 1+sqrt(e*e+f*f+g*g); ee[2]=e*dt/h; ff[2]=f*dt/h; gg[2]=g*dt/h; u1 = u+ee[2]; v1 = v+ff[2]; w1 = w+gg[2]; - x.Spline1(dif,u1,0,0); e = ax.Spline1(u1,v1,w1)/dif.x; - y.Spline1(dif,v1,0,0); f = ay.Spline1(u1,v1,w1)/dif.x; - z.Spline1(dif,w1,0,0); g = az.Spline1(u1,v1,w1)/dif.x; + x->Spline1(dif,u1,0,0); e = ax->Spline1(u1,v1,w1)/dif.x; + y->Spline1(dif,v1,0,0); f = ay->Spline1(u1,v1,w1)/dif.x; + z->Spline1(dif,w1,0,0); g = az->Spline1(u1,v1,w1)/dif.x; h = 1+sqrt(e*e+f*f+g*g); ee[3]=e*dt/h; ff[3]=f*dt/h; gg[3]=g*dt/h; u += ee[0]/6+ee[1]/3+ee[2]/3+ee[3]/6; @@ -786,10 +796,10 @@ else do{ mglPoint dif; register mreal xu,xv,xw,yu,yv,yw,zv,zu,zw,det,xx,yy,zz; - pp[k].x = x.Spline1(dif,u,v,w); xu=dif.x; xv=dif.y; xw=dif.z; - pp[k].y = y.Spline1(dif,u,v,w); yu=dif.x; yv=dif.y; yw=dif.z; - pp[k].z = z.Spline1(dif,u,v,w); zu=dif.x; zv=dif.y; zw=dif.z; - xx = ax.Spline1(u,v,w); yy = ay.Spline1(u,v,w); zz = az.Spline1(u,v,w); + pp[k].x = x->Spline1(dif,u,v,w); xu=dif.x; xv=dif.y; xw=dif.z; + pp[k].y = y->Spline1(dif,u,v,w); yu=dif.x; yv=dif.y; yw=dif.z; + pp[k].z = z->Spline1(dif,u,v,w); zu=dif.x; zv=dif.y; zw=dif.z; + xx = ax->Spline1(u,v,w); yy = ay->Spline1(u,v,w); zz = az->Spline1(u,v,w); det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu; e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det; f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det; @@ -804,9 +814,9 @@ // find next point by midpoint method h+=1; ee[0]=e*dt/h; ff[0]=f*dt/h; gg[0]=g*dt/h; u1 = u+ee[0]/2; v1 = v+ff[0]/2; w1 = w+gg[0]/2; - x.Spline1(dif,u1,v1,w1); xu=dif.x; xv=dif.y; xw=dif.z; xx = ax.Spline1(u1,v1,w1); - y.Spline1(dif,u1,v1,w1); yu=dif.x; yv=dif.y; yw=dif.z; yy = ay.Spline1(u1,v1,w1); - z.Spline1(dif,u1,v1,w1); zu=dif.x; zv=dif.y; zw=dif.z; zz = az.Spline1(u1,v1,w1); + x->Spline1(dif,u1,v1,w1); xu=dif.x; xv=dif.y; xw=dif.z; xx = ax->Spline1(u1,v1,w1); + y->Spline1(dif,u1,v1,w1); yu=dif.x; yv=dif.y; yw=dif.z; yy = ay->Spline1(u1,v1,w1); + z->Spline1(dif,u1,v1,w1); zu=dif.x; zv=dif.y; zw=dif.z; zz = az->Spline1(u1,v1,w1); det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu; e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det; f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det; @@ -814,9 +824,9 @@ h = 1+sqrt(e*e+f*f+g*g); ee[1]=e*dt/h; ff[1]=f*dt/h; gg[1]=g*dt/h; u1 = u+ee[1]/2; v1 = v+ff[1]/2; w1 = w+gg[1]/2; - x.Spline1(dif,u1,v1,w1); xu=dif.x; xv=dif.y; xw=dif.z; xx = ax.Spline1(u1,v1,w1); - y.Spline1(dif,u1,v1,w1); yu=dif.x; yv=dif.y; yw=dif.z; yy = ay.Spline1(u1,v1,w1); - z.Spline1(dif,u1,v1,w1); zu=dif.x; zv=dif.y; zw=dif.z; zz = az.Spline1(u1,v1,w1); + x->Spline1(dif,u1,v1,w1); xu=dif.x; xv=dif.y; xw=dif.z; xx = ax->Spline1(u1,v1,w1); + y->Spline1(dif,u1,v1,w1); yu=dif.x; yv=dif.y; yw=dif.z; yy = ay->Spline1(u1,v1,w1); + z->Spline1(dif,u1,v1,w1); zu=dif.x; zv=dif.y; zw=dif.z; zz = az->Spline1(u1,v1,w1); det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu; e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det; f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det; @@ -824,9 +834,9 @@ h = 1+sqrt(e*e+f*f+g*g); ee[2]=e*dt/h; ff[2]=f*dt/h; gg[2]=g*dt/h; u1 = u+ee[2]; v1 = v+ff[2]; w1 = w+gg[2]; - x.Spline1(dif,u1,v1,w1); xu=dif.x; xv=dif.y; xw=dif.z; xx = ax.Spline1(u1,v1,w1); - y.Spline1(dif,u1,v1,w1); yu=dif.x; yv=dif.y; yw=dif.z; yy = ay.Spline1(u1,v1,w1); - z.Spline1(dif,u1,v1,w1); zu=dif.x; zv=dif.y; zw=dif.z; zz = az.Spline1(u1,v1,w1); + x->Spline1(dif,u1,v1,w1); xu=dif.x; xv=dif.y; xw=dif.z; xx = ax->Spline1(u1,v1,w1); + y->Spline1(dif,u1,v1,w1); yu=dif.x; yv=dif.y; yw=dif.z; yy = ay->Spline1(u1,v1,w1); + z->Spline1(dif,u1,v1,w1); zu=dif.x; zv=dif.y; zw=dif.z; zz = az->Spline1(u1,v1,w1); det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu; e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det; f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det; @@ -885,33 +895,37 @@ long ss = gr->AddTexture(sch); bool vv = mglchr(sch,'v'), xo = mglchr(sch,'x'), zo = mglchr(sch,'z'); - mglData xx(x), yy(y), zz(z), bx(ax), by(ay), bz(az); - for(long i=0;i u, v, w; + for(long i=0;iNeedStop()) { i=j=num; s=2; continue; } - u = (i+1.)/(num+1.); v = (j+1.)/(num+1.); w = 0; - flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); - u = (i+1.)/(num+1.); v = (j+1.)/(num+1.); w = 1; - flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); - u = 0; v = (j+1.)/(num+1.); w = (i+1.)/(num+1.); - flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); - u = 1; v = (j+1.)/(num+1.); w = (i+1.)/(num+1.); - flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); - u = (i+1.)/(num+1.); v = 0; w = (j+1.)/(num+1.); - flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); - u = (i+1.)/(num+1.); v = 1; w = (j+1.)/(num+1.); - flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); + mreal t = (i+1.)/(num+1.), s = (j+1.)/(num+1.); + u.push_back(t); v.push_back(s); w.push_back(0); + u.push_back(-t); v.push_back(-s); w.push_back(0); + u.push_back(t); v.push_back(s); w.push_back(1); + u.push_back(-t); v.push_back(-s); w.push_back(-1); + + u.push_back(t); v.push_back(0); w.push_back(s); + u.push_back(-t); v.push_back(0); w.push_back(-s); + u.push_back(t); v.push_back(1); w.push_back(s); + u.push_back(-t); v.push_back(-1); w.push_back(-s); + + u.push_back(0); v.push_back(s); w.push_back(t); + u.push_back(0); v.push_back(-s); w.push_back(-t); + u.push_back(1); v.push_back(s); w.push_back(t); + u.push_back(-1); v.push_back(-s); w.push_back(-t); if(cnt) { - u = (i+1.)/(num+1.); v = (j+1.)/(num+1.); w = 0.5; - flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); - u = 0.5; v = (j+1.)/(num+1.); w = (i+1.)/(num+1.); - flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); - u = (i+1.)/(num+1.); v = 0.5; w = (j+1.)/(num+1.); - flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); + u.push_back(t); v.push_back(s); w.push_back(0.5); + u.push_back(-t); v.push_back(-s); w.push_back(-0.5); + u.push_back(t); v.push_back(0.5); w.push_back(s); + u.push_back(-t); v.push_back(-0.5); w.push_back(-s); + u.push_back(0.5); v.push_back(s); w.push_back(t); + u.push_back(-0.5); v.push_back(-s); w.push_back(-t); } } +#pragma omp parallel for + for(long i=0;iNeedStop()) + flow(gr, u[i], v[i], w[i], x, y, z, ax, ay, az,ss,vv,xo,zo); gr->EndGroup(); } //----------------------------------------------------------------------------- @@ -984,8 +998,7 @@ w = (i0+(dx*(dyv*dzu-dyu*dzv)+dxu*(dy*dzv-dyv*dz)+dxv*(dyu*dz-dy*dzu))/d)/l; } } - mglData xx(x), yy(y), zz(z), bx(ax), by(ay), bz(az); - flow(gr, u, v, w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); + flow(gr, u, v, w, x, y, z, ax, ay, az,ss,vv,xo,zo); gr->EndGroup(); } //----------------------------------------------------------------------------- @@ -1075,25 +1088,25 @@ // Pipe 2d series // //----------------------------------------------------------------------------- -void MGL_NO_EXPORT flowr(mglBase *gr, double zVal, double u, double v, const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, double r0,long sc) +void MGL_NO_EXPORT flowr(mglBase *gr, double zVal, double u, double v, HCDT x, HCDT y, HCDT ax, HCDT ay, double r0,long sc) { - long n=100*(ax.nx+ax.ny); - bool nboth = x.nx*x.ny!=ax.nx*ax.ny || y.nx*y.ny!=ax.nx*ax.ny; + long n=100*(ax->GetNx()+ax->GetNy()); + bool nboth = x->GetNx()*x->GetNy()!=ax->GetNx()*ax->GetNy() || y->GetNx()*y->GetNy()!=ax->GetNx()*ax->GetNy(); mglPoint *pp = new mglPoint[n], dp; mreal *cc = new mreal[n]; mglPoint dx(1/fabs(gr->Max.x-gr->Min.x),1/fabs(gr->Max.y-gr->Min.y),1/fabs(gr->Max.z-gr->Min.z)); - mglPoint nx(ax.nx,ax.ny); + mglPoint nx(ax->GetNx(),ax->GetNy()); - mreal dt = 0.5/(ax.nx > ax.ny ? ax.nx : ax.ny),e,f,g,ff[4],gg[4],h,s=2,acc=dt/20; + mreal dt = 0.5/(ax->GetNx() > ax->GetNy() ? ax->GetNx() : ax->GetNy()),e,f,g,ff[4],gg[4],h,s=2,acc=dt/20; mreal ss = 16./mgl_ipow(gr->Max.c - gr->Min.c,2); if(u<0 || v<0) { dt = -dt; u = -u; v = -v; s *= -1;} long k=0; bool end = false; if(nboth) do{ mglPoint dif; - pp[k].x = x.Spline1(dif,u,0,0); f = ax.Spline1(u,v,0)/dif.x; - pp[k].y = y.Spline1(dif,v,0,0); g = ay.Spline1(u,v,0)/dif.x; + pp[k].x = x->Spline1(dif,u,0,0); f = ax->Spline1(u,v,0)/dif.x; + pp[k].y = y->Spline1(dif,v,0,0); g = ay->Spline1(u,v,0)/dif.x; pp[k].z = zVal; if(mgl_isbad(f+g)) end = true; else for(long m=0;mSpline1(dif,e,0,0); f = ax->Spline1(e,h,0)/dif.x; + y->Spline1(dif,h,0,0); g = ay->Spline1(e,h,0)/dif.x; h = 1+hypot(f,g); ff[1]=f*dt/h; gg[1]=g*dt/h; e = u+ff[1]/2; h = v+gg[1]/2; - x.Spline1(dif,e,0,0); f = ax.Spline1(e,h,0)/dif.x; - y.Spline1(dif,h,0,0); g = ay.Spline1(e,h,0)/dif.x; + x->Spline1(dif,e,0,0); f = ax->Spline1(e,h,0)/dif.x; + y->Spline1(dif,h,0,0); g = ay->Spline1(e,h,0)/dif.x; h = 1+hypot(f,g); ff[2]=f*dt/h; gg[2]=g*dt/h; e = u+ff[2]; h = v+gg[2]; - x.Spline1(dif,e,0,0); f = ax.Spline1(e,h,0)/dif.x; - y.Spline1(dif,h,0,0); g = ay.Spline1(e,h,0)/dif.x; + x->Spline1(dif,e,0,0); f = ax->Spline1(e,h,0)/dif.x; + y->Spline1(dif,h,0,0); g = ay->Spline1(e,h,0)/dif.x; h = 1+hypot(f,g); ff[3]=f*dt/h; gg[3]=g*dt/h; u += ff[0]/6+ff[1]/3+ff[2]/3+ff[3]/6; v += gg[0]/6+gg[1]/3+gg[2]/3+gg[3]/6; @@ -1125,9 +1138,9 @@ else do{ mglPoint dif; register mreal xu,xv,yu,yv,det,xx,yy; - pp[k].x = x.Spline1(dif,u,v,0); xu=dif.x; xv=dif.y; - pp[k].y = y.Spline1(dif,u,v,0); yu=dif.x; yv=dif.y; - xx = ax.Spline1(u,v,0); yy = ay.Spline1(u,v,0); + pp[k].x = x->Spline1(dif,u,v,0); xu=dif.x; xv=dif.y; + pp[k].y = y->Spline1(dif,u,v,0); yu=dif.x; yv=dif.y; + xx = ax->Spline1(u,v,0); yy = ay->Spline1(u,v,0); det = xv*yu-xu*yv; f = (yy*xv-xx*yv)/det; g = (xx*yu-yy*xu)/det; pp[k].z = zVal; if(mgl_isbad(f+g)) end = true; @@ -1141,21 +1154,21 @@ // find next point by midpoint method h+=1; ff[0]=f*dt/h; gg[0]=g*dt/h; e = u+ff[0]/2; h = v+gg[0]/2; - x.Spline1(dif,e,h,0); xu=dif.x; xv=dif.y; - y.Spline1(dif,e,h,0); yu=dif.x; yv=dif.y; - xx = ax.Spline1(e,h,0); yy = ay.Spline1(e,h,0); + x->Spline1(dif,e,h,0); xu=dif.x; xv=dif.y; + y->Spline1(dif,e,h,0); yu=dif.x; yv=dif.y; + xx = ax->Spline1(e,h,0); yy = ay->Spline1(e,h,0); det = xv*yu-xu*yv; f = (yy*xv-xx*yv)/det; g = (xx*yu-yy*xu)/det; h = 1+hypot(f,g); ff[1]=f*dt/h; gg[1]=g*dt/h; e = u+ff[1]/2; h = v+gg[1]/2; - x.Spline1(dif,e,h,0); xu=dif.x; xv=dif.y; - y.Spline1(dif,e,h,0); yu=dif.x; yv=dif.y; - xx = ax.Spline1(e,h,0); yy = ay.Spline1(e,h,0); + x->Spline1(dif,e,h,0); xu=dif.x; xv=dif.y; + y->Spline1(dif,e,h,0); yu=dif.x; yv=dif.y; + xx = ax->Spline1(e,h,0); yy = ay->Spline1(e,h,0); det = xv*yu-xu*yv; f = (yy*xv-xx*yv)/det; g = (xx*yu-yy*xu)/det; h = 1+hypot(f,g); ff[2]=f*dt/h; gg[2]=g*dt/h; e = u+ff[2]; h = v+gg[2]; - x.Spline1(dif,e,h,0); xu=dif.x; xv=dif.y; - y.Spline1(dif,e,h,0); yu=dif.x; yv=dif.y; - xx = ax.Spline1(e,h,0); yy = ay.Spline1(e,h,0); + x->Spline1(dif,e,h,0); xu=dif.x; xv=dif.y; + y->Spline1(dif,e,h,0); yu=dif.x; yv=dif.y; + xx = ax->Spline1(e,h,0); yy = ay->Spline1(e,h,0); det = xv*yu-xu*yv; f = (yy*xv-xx*yv)/det; g = (xx*yu-yy*xu)/det; h = 1+hypot(f,g); ff[3]=f*dt/h; gg[3]=g*dt/h; u += ff[0]/6+ff[1]/3+ff[2]/3+ff[3]/6; @@ -1216,31 +1229,41 @@ bool cnt=!mglchr(sch,'#'); if(mglchr(sch,'i')) r0 = -fabs(r0); - mglData xx(x), yy(y), bx(ax), by(ay); + std::vector u, v; + if(mglchr(sch,'*')) for(long i=0;iGetNz();k++) { if(gr->NeedStop()) break; if(ax->GetNz()>1) zVal = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(k)/(ax->GetNz()-1); - for(long i=0;iNeedStop()) { i=num; s=2; continue; } - u = 0; v = (i+1.)/(num+1.); - flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss); - u = 1; v = (i+1.)/(num+1.); - flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss); - u = (i+1.)/(num+1.); v = 0; - flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss); - u = (i+1.)/(num+1.); v = 1; - flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss); - if(cnt) - { - u = 0.5; v = (i+1.)/(num+1.); - flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss); - u = (i+1.)/(num+1.); v = 0.5; - flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss); - } - } + HMDT bx=mgl_data_subdata(ax,-1,-1,k), by=mgl_data_subdata(ay,-1,-1,k); +#pragma omp parallel for + for(long i=0;iNeedStop()) + flowr(gr, zVal, u[i], v[i], x, y, bx, by,r0,ss); + mgl_delete_data(bx); mgl_delete_data(by); } gr->EndGroup(); } @@ -1267,18 +1290,18 @@ // Pipe 3d series // //----------------------------------------------------------------------------- -void flowr(mglBase *gr, double u, double v, double w, const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, double r0,long sc) +void flowr(mglBase *gr, double u, double v, double w, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, double r0,long sc) { - static long n=100*(ax.nx+ax.ny+ax.nz); - long nn = ax.nx*ax.ny*ax.nz; - bool nboth = x.nx*x.ny*x.nz!=nn || y.nx*y.ny*y.nz!=nn || z.nx*z.ny*z.nz!=nn; + static long n=100*(ax->GetNx()+ax->GetNy()+ax->GetNz()); + long nn = ax->GetNN(); + bool nboth = x->GetNN()!=nn || y->GetNN()!=nn || z->GetNN()!=nn; mglPoint *pp = new mglPoint[n], dp; mreal *cc = new mreal[n]; mglPoint dx(1/fabs(gr->Max.x-gr->Min.x),1/fabs(gr->Max.y-gr->Min.y),1/fabs(gr->Max.z-gr->Min.z)); - mglPoint nx(ax.nx,ax.ny,ax.nz); + mglPoint nx(ax->GetNx(),ax->GetNy(),ax->GetNz()); - nn = (ax.nx > ax.ny ? ax.nx : ax.ny); - nn = (nn > ax.nz ? nn : ax.nz); + nn = (ax->GetNx() > ax->GetNy() ? ax->GetNx() : ax->GetNy()); + nn = (nn > ax->GetNz() ? nn : ax->GetNz()); mreal dt = 0.2/nn, e,f,g,ee[4],ff[4],gg[4],h,s=2,u1,v1,w1,acc=dt/20; mreal ss = 16./mgl_ipow(gr->Max.c - gr->Min.c,2); @@ -1288,9 +1311,9 @@ bool end = false; if(nboth) do{ mglPoint dif; - pp[k].x = x.Spline1(dif,u,0,0); e = ax.Spline1(u,v,w)/dif.x; - pp[k].y = y.Spline1(dif,v,0,0); f = ay.Spline1(u,v,w)/dif.x; - pp[k].z = z.Spline1(dif,w,0,0); g = az.Spline1(u,v,w)/dif.x; + pp[k].x = x->Spline1(dif,u,0,0); e = ax->Spline1(u,v,w)/dif.x; + pp[k].y = y->Spline1(dif,v,0,0); f = ay->Spline1(u,v,w)/dif.x; + pp[k].z = z->Spline1(dif,w,0,0); g = az->Spline1(u,v,w)/dif.x; if(mgl_isbad(e+f+g)) end = true; else for(long m=0;mSpline1(dif,u1,0,0); e = ax->Spline1(u1,v1,w1)/dif.x; + y->Spline1(dif,v1,0,0); f = ay->Spline1(u1,v1,w1)/dif.x; + z->Spline1(dif,w1,0,0); g = az->Spline1(u1,v1,w1)/dif.x; h = 1+sqrt(e*e+f*f+g*g); ee[1]=e*dt/h; ff[1]=f*dt/h; gg[1]=g*dt/h; u1 = u+ee[1]/2; v1 = v+ff[1]/2; w1 = w+gg[1]/2; - x.Spline1(dif,u1,0,0); e = ax.Spline1(u1,v1,w1)/dif.x; - y.Spline1(dif,v1,0,0); f = ay.Spline1(u1,v1,w1)/dif.x; - z.Spline1(dif,w1,0,0); g = az.Spline1(u1,v1,w1)/dif.x; + x->Spline1(dif,u1,0,0); e = ax->Spline1(u1,v1,w1)/dif.x; + y->Spline1(dif,v1,0,0); f = ay->Spline1(u1,v1,w1)/dif.x; + z->Spline1(dif,w1,0,0); g = az->Spline1(u1,v1,w1)/dif.x; h = 1+sqrt(e*e+f*f+g*g); ee[2]=e*dt/h; ff[2]=f*dt/h; gg[2]=g*dt/h; u1 = u+ee[2]; v1 = v+ff[2]; w1 = w+gg[2]; - x.Spline1(dif,u1,0,0); e = ax.Spline1(u1,v1,w1)/dif.x; - y.Spline1(dif,v1,0,0); f = ay.Spline1(u1,v1,w1)/dif.x; - z.Spline1(dif,w1,0,0); g = az.Spline1(u1,v1,w1)/dif.x; + x->Spline1(dif,u1,0,0); e = ax->Spline1(u1,v1,w1)/dif.x; + y->Spline1(dif,v1,0,0); f = ay->Spline1(u1,v1,w1)/dif.x; + z->Spline1(dif,w1,0,0); g = az->Spline1(u1,v1,w1)/dif.x; h = 1+sqrt(e*e+f*f+g*g); ee[3]=e*dt/h; ff[3]=f*dt/h; gg[3]=g*dt/h; u += ee[0]/6+ee[1]/3+ee[2]/3+ee[3]/6; @@ -1328,10 +1351,10 @@ else do{ mglPoint dif; register mreal xu,xv,xw,yu,yv,yw,zv,zu,zw,det,xx,yy,zz; - pp[k].x = x.Spline1(dif,u,v,w); xu=dif.x; xv=dif.y; xw=dif.z; - pp[k].y = y.Spline1(dif,u,v,w); yu=dif.x; yv=dif.y; yw=dif.z; - pp[k].z = z.Spline1(dif,u,v,w); zu=dif.x; zv=dif.y; zw=dif.z; - xx = ax.Spline1(u,v,w); yy = ay.Spline1(u,v,w); zz = az.Spline1(u,v,w); + pp[k].x = x->Spline1(dif,u,v,w); xu=dif.x; xv=dif.y; xw=dif.z; + pp[k].y = y->Spline1(dif,u,v,w); yu=dif.x; yv=dif.y; yw=dif.z; + pp[k].z = z->Spline1(dif,u,v,w); zu=dif.x; zv=dif.y; zw=dif.z; + xx = ax->Spline1(u,v,w); yy = ay->Spline1(u,v,w); zz = az->Spline1(u,v,w); det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu; e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det; f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det; @@ -1347,9 +1370,9 @@ // find next point by midpoint method h+=1; ee[0]=e*dt/h; ff[0]=f*dt/h; gg[0]=g*dt/h; u1 = u+ee[0]/2; v1 = v+ff[0]/2; w1 = w+gg[0]/2; - x.Spline1(dif,u1,v1,w1); xu=dif.x; xv=dif.y; xw=dif.z; xx = ax.Spline1(u1,v1,w1); - y.Spline1(dif,u1,v1,w1); yu=dif.x; yv=dif.y; yw=dif.z; yy = ay.Spline1(u1,v1,w1); - z.Spline1(dif,u1,v1,w1); zu=dif.x; zv=dif.y; zw=dif.z; zz = az.Spline1(u1,v1,w1); + x->Spline1(dif,u1,v1,w1); xu=dif.x; xv=dif.y; xw=dif.z; xx = ax->Spline1(u1,v1,w1); + y->Spline1(dif,u1,v1,w1); yu=dif.x; yv=dif.y; yw=dif.z; yy = ay->Spline1(u1,v1,w1); + z->Spline1(dif,u1,v1,w1); zu=dif.x; zv=dif.y; zw=dif.z; zz = az->Spline1(u1,v1,w1); det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu; e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det; f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det; @@ -1357,9 +1380,9 @@ h = 1+sqrt(e*e+f*f+g*g); ee[1]=e*dt/h; ff[1]=f*dt/h; gg[1]=g*dt/h; u1 = u+ee[1]/2; v1 = v+ff[1]/2; w1 = w+gg[1]/2; - x.Spline1(dif,u1,v1,w1); xu=dif.x; xv=dif.y; xw=dif.z; xx = ax.Spline1(u1,v1,w1); - y.Spline1(dif,u1,v1,w1); yu=dif.x; yv=dif.y; yw=dif.z; yy = ay.Spline1(u1,v1,w1); - z.Spline1(dif,u1,v1,w1); zu=dif.x; zv=dif.y; zw=dif.z; zz = az.Spline1(u1,v1,w1); + x->Spline1(dif,u1,v1,w1); xu=dif.x; xv=dif.y; xw=dif.z; xx = ax->Spline1(u1,v1,w1); + y->Spline1(dif,u1,v1,w1); yu=dif.x; yv=dif.y; yw=dif.z; yy = ay->Spline1(u1,v1,w1); + z->Spline1(dif,u1,v1,w1); zu=dif.x; zv=dif.y; zw=dif.z; zz = az->Spline1(u1,v1,w1); det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu; e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det; f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det; @@ -1367,9 +1390,9 @@ h = 1+sqrt(e*e+f*f+g*g); ee[2]=e*dt/h; ff[2]=f*dt/h; gg[2]=g*dt/h; u1 = u+ee[2]; v1 = v+ff[2]; w1 = w+gg[2]; - x.Spline1(dif,u1,v1,w1); xu=dif.x; xv=dif.y; xw=dif.z; xx = ax.Spline1(u1,v1,w1); - y.Spline1(dif,u1,v1,w1); yu=dif.x; yv=dif.y; yw=dif.z; yy = ay.Spline1(u1,v1,w1); - z.Spline1(dif,u1,v1,w1); zu=dif.x; zv=dif.y; zw=dif.z; zz = az.Spline1(u1,v1,w1); + x->Spline1(dif,u1,v1,w1); xu=dif.x; xv=dif.y; xw=dif.z; xx = ax->Spline1(u1,v1,w1); + y->Spline1(dif,u1,v1,w1); yu=dif.x; yv=dif.y; yw=dif.z; yy = ay->Spline1(u1,v1,w1); + z->Spline1(dif,u1,v1,w1); zu=dif.x; zv=dif.y; zw=dif.z; zz = az->Spline1(u1,v1,w1); det = -xu*yv*zw+xv*yu*zw+xu*yw*zv-xw*yu*zv-xv*yw*zu+xw*yv*zu; e = (-xv*yw*zz+xw*yv*zz+xv*yy*zw-xx*yv*zw-xw*yy*zv+xx*yw*zv)/det; f = (xu*yw*zz-xw*yu*zz-xu*yy*zw+xx*yu*zw+xw*yy*zu-xx*yw*zu)/det; @@ -1433,33 +1456,37 @@ long ss = gr->AddTexture(sch); bool cnt=!mglchr(sch,'#'); - mglData xx(x), yy(y), zz(z), bx(ax), by(ay), bz(az); - for(long i=0;i u, v, w; + for(long i=0;iNeedStop()) { i=j=num; s=2; continue; } - u = (i+1.)/(num+1.); v = (j+1.)/(num+1.); w = 0; - flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); - u = (i+1.)/(num+1.); v = (j+1.)/(num+1.); w = 1; - flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); - u = 0; v = (j+1.)/(num+1.); w = (i+1.)/(num+1.); - flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); - u = 1; v = (j+1.)/(num+1.); w = (i+1.)/(num+1.); - flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); - u = (i+1.)/(num+1.); v = 0; w = (j+1.)/(num+1.); - flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); - u = (i+1.)/(num+1.); v = 1; w = (j+1.)/(num+1.); - flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); + mreal t = (i+1.)/(num+1.), s = (j+1.)/(num+1.); + u.push_back(t); v.push_back(s); w.push_back(0); + u.push_back(-t); v.push_back(-s); w.push_back(0); + u.push_back(t); v.push_back(s); w.push_back(1); + u.push_back(-t); v.push_back(-s); w.push_back(-1); + + u.push_back(t); v.push_back(0); w.push_back(s); + u.push_back(-t); v.push_back(0); w.push_back(-s); + u.push_back(t); v.push_back(1); w.push_back(s); + u.push_back(-t); v.push_back(-1); w.push_back(-s); + + u.push_back(0); v.push_back(s); w.push_back(t); + u.push_back(0); v.push_back(-s); w.push_back(-t); + u.push_back(1); v.push_back(s); w.push_back(t); + u.push_back(-1); v.push_back(-s); w.push_back(-t); if(cnt) { - u = (i+1.)/(num+1.); v = (j+1.)/(num+1.); w = 0.5; - flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); - u = 0.5; v = (j+1.)/(num+1.); w = (i+1.)/(num+1.); - flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); - u = (i+1.)/(num+1.); v = 0.5; w = (j+1.)/(num+1.); - flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); + u.push_back(t); v.push_back(s); w.push_back(0.5); + u.push_back(-t); v.push_back(-s); w.push_back(-0.5); + u.push_back(t); v.push_back(0.5); w.push_back(s); + u.push_back(-t); v.push_back(-0.5); w.push_back(-s); + u.push_back(0.5); v.push_back(s); w.push_back(t); + u.push_back(-0.5); v.push_back(-s); w.push_back(-t); } } +#pragma omp parallel for + for(long i=0;iNeedStop()) + flowr(gr, u[i], v[i], w[i], x, y, z, ax, ay, az,r0,ss); gr->EndGroup(); } //----------------------------------------------------------------------------- diff -Nru mathgl-2.3.4/src/volume.cpp mathgl-2.3.5.1/src/volume.cpp --- mathgl-2.3.4/src/volume.cpp 2016-02-13 19:01:11.000000000 +0000 +++ mathgl-2.3.5.1/src/volume.cpp 2016-06-19 17:01:24.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * surf.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -22,7 +22,6 @@ #include "mgl2/data.h" #include "mgl2/eval.h" #include "mgl2/base.h" -//#include //----------------------------------------------------------------------------- // // CloudQ series @@ -108,6 +107,21 @@ // Surf3 series // //----------------------------------------------------------------------------- +mreal MGL_NO_EXPORT mgl_get_norm(mreal x, mreal d1, mreal d2, mreal d3) +{ + mreal nx = d1*(1-x) + d2*x; + if(mgl_isbad(nx)) + { + nx = d1*(1+x) - d3*x; + if(mgl_isbad(nx)) + { + if(mgl_isfin(d1)) nx = d1; + if(mgl_isfin(d2)) nx = d2; + if(mgl_isfin(d3)) nx = d3; + } + } + return nx; +} mglPoint MGL_NO_EXPORT mgl_normal_3d(HCDT a, mglPoint p, bool inv, long n,long m,long l) { register long i,j,k; @@ -117,18 +131,17 @@ i = idvx(i,j,k)*(1-x) + a->dvx(i+1,j,k)*x; - ny = a->dvy(i,j,k)*(1-y) + a->dvy(i,j+1,k)*y; - nz = a->dvz(i,j,k)*(1-z) + a->dvz(i,j,k+1)*z; + nx = mgl_get_norm(x, a->dvx(i,j,k), a->dvx(i+1,j,k), i>0?a->dvx(i-1,j,k):NAN); + ny = mgl_get_norm(y, a->dvy(i,j,k), a->dvy(i,j+1,k), j>0?a->dvy(i,j-1,k):NAN); + nz = mgl_get_norm(z, a->dvz(i,j,k), a->dvz(i,j,k+1), k>0?a->dvz(i,j,k-1):NAN); return inv ? mglPoint(nx,ny,nz) : mglPoint(-nx,-ny,-nz); } //----------------------------------------------------------------------------- -mreal MGL_NO_EXPORT mgl_normal_1d(HCDT a, mreal x, bool inv, long n) +mreal MGL_NO_EXPORT mgl_normal_1d(HCDT a, mreal x, long n) { - register long i=long(x); x-=i; - mreal nx = a->dvx(i); - if(idvx(i+1)*x; - return inv ? nx : -nx; + register long i=long(x); + i = idvx(i), a->dvx(i+1), i>0?a->dvx(i-1):NAN); } //----------------------------------------------------------------------------- mglPoint MGL_NO_EXPORT mgl_find_norm(bool nboth, HCDT x, HCDT y, HCDT z, HCDT a, mglPoint u, bool inv, long n,long m,long l) @@ -136,9 +149,9 @@ mglPoint s = mgl_normal_3d(a,u,inv,n,m,l), t, q; if(nboth) { - q.x = s.x/mgl_normal_1d(x,u.x,true,n); - q.y = s.y/mgl_normal_1d(y,u.y,true,m); - q.z = s.z/mgl_normal_1d(z,u.z,true,l); + q.x = s.x/mgl_normal_1d(x,u.x,n); + q.y = s.y/mgl_normal_1d(y,u.y,m); + q.z = s.z/mgl_normal_1d(z,u.z,l); } else { @@ -262,6 +275,7 @@ { register long i1 = i+n*j; mreal a0 = a->v(i,j,k); + if(mgl_isnan(a0)) continue; if(iv(i+1,j,k)); @@ -275,7 +289,7 @@ { ky2[i1] = kk.size(); kk.push_back(mglPoint(i,j+d,k)); } } if(k>0) - { + { mreal d = mgl_d(val,a->v(i,j,k-1),a0); if(d>=0 && d<1) { kz[i1] = kk.size(); kk.push_back(mglPoint(i,j,k+d-1)); } @@ -285,36 +299,38 @@ if(b && c) for(size_t i=kk1;iAddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) : + mreal cc = c->linear(u.x,u.y,u.z), bb = b->linear(u.x,u.y,u.z); + if(mgl_isnan(cc) || mgl_isnan(bb)) u.c = -1; else + u.c = gr->AddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) : mglPoint(x->linear(u.x,u.y,u.z),y->linear(u.x,u.y,u.z),z->linear(u.x,u.y,u.z)), - gr->GetC(ss,c->linear(u.x,u.y,u.z)), - mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l), - gr->GetA(b->linear(u.x,u.y,u.z))); + gr->GetC(ss,cc), mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l), gr->GetA(bb)); } else if(c) for(size_t i=kk1;iAddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) : + mreal cc = c->linear(u.x,u.y,u.z); + if(mgl_isnan(cc)) u.c = -1; else + u.c = gr->AddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) : mglPoint(x->linear(u.x,u.y,u.z),y->linear(u.x,u.y,u.z),z->linear(u.x,u.y,u.z)), - gr->GetC(ss,c->linear(u.x,u.y,u.z)), - mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l)); + gr->GetC(ss,cc), mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l)); } else if(b) for(size_t i=kk1;iAddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) : + mreal bb = b->linear(u.x,u.y,u.z); + if(mgl_isnan(bb)) u.c = -1; else + u.c = gr->AddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) : mglPoint(x->linear(u.x,u.y,u.z),y->linear(u.x,u.y,u.z),z->linear(u.x,u.y,u.z)), - cv, mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l), - gr->GetA(b->linear(u.x,u.y,u.z))); + cv, mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l), gr->GetA(bb)); } else for(size_t i=kk1;iAddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) : + u.c = gr->AddPnt(nboth ? mglPoint(x->linear(u.x,0,0),y->linear(u.y,0,0),z->linear(u.z,0,0)) : mglPoint(x->linear(u.x,u.y,u.z),y->linear(u.x,u.y,u.z),z->linear(u.x,u.y,u.z)), cv, mgl_find_norm(nboth, x,y,z,a, u, inv,n,m,l)); } - + if(k>0) mgl_surf3_plot(gr,n,m,kx1,kx2,ky1,ky2,kz,kk,wire); } delete []kx1; delete []kx2; delete []ky1; @@ -408,20 +424,21 @@ long num = mgl_isnan(r)?3:long(r+0.5); if(b->GetNx()==num && b->GetNy()==1 && b->GetNz()==1) { - mreal v,a0=gr->AlphaDef; + mreal a0=gr->AlphaDef; for(long i=0;iMax.c + (gr->Min.c-gr->Max.c)*(i+1.)/(num+1); + mreal v = gr->Max.c + (gr->Min.c-gr->Max.c)*(i+1.)/(num+1); gr->AlphaDef = gr->GetA(b->v(i)); mgl_surf3_xyz_val(gr,v,x,y,z,a,sch,0); } gr->AlphaDef = a0; } - else for(long i=0;iMax.c + (gr->Min.c-gr->Max.c)*(i+1.)/(num+1); - mgl_surf3a_xyz_val(gr,v,x,y,z,a,b,sch,0); - } + else + for(long i=0;iMax.c + (gr->Min.c-gr->Max.c)*(i+1.)/(num+1); + mgl_surf3a_xyz_val(gr,v,x,y,z,a,b,sch,0); + } gr->LoadState(); } //----------------------------------------------------------------------------- @@ -604,50 +621,43 @@ if(tr->GetNx()<3 || tr->GetNy()GetNx()<3 || g1->GetNy()GetNx()<3 || g2->GetNy()SetWarn(mglWarnDim,"Beam"); return; } mglData x(a),y(a),z(a),b(a); - register long i,j,k,i0; mreal asum0=1; r = fabs(r); - if(flag & 4) for(j=0;jvthr(j)*a->vthr(j); + if(flag & 4) for(long j=0;jvthr(j)*a->vthr(j); if(asum0==0) { gr->SetWarn(mglWarnZero,"Beam"); return; } - for(i=0;iNeedStop()) break; + if(gr->NeedStop()) continue; if(flag & 4) { mreal asum=0, amax=0; - for(j=0;jvthr(j+m*l*i); asum += aa*aa; amax = amax>aa ? amax : aa; } amax = amax?sqrt(asum/asum0)/amax:0; -#pragma omp parallel for - for(j=0;jMax.z*i/(n-1.); + } + else for(long j=0;jv(0,i) + g1->v(0,i)*(2*j/(m-1.)-1)*r + g2->v(0,i)*(2*k/(l-1.)-1)*r; + y.a[i0] = tr->v(1,i) + g1->v(1,i)*(2*j/(m-1.)-1)*r + g2->v(1,i)*(2*k/(l-1.)-1)*r; + z.a[i0] = tr->v(2,i) + g1->v(2,i)*(2*j/(m-1.)-1)*r + g2->v(2,i)*(2*k/(l-1.)-1)*r; + } + if(flag & 2) for(long j=0;jMax.z*i/(n-1.); - } - else -#pragma omp parallel for collapse(2) - for(j=0;jv(0,i) + g1->v(0,i)*(2*j/(m-1.)-1)*r + g2->v(0,i)*(2*k/(l-1.)-1)*r; - y.a[i0] = tr->v(1,i) + g1->v(1,i)*(2*j/(m-1.)-1)*r + g2->v(1,i)*(2*k/(l-1.)-1)*r; - z.a[i0] = tr->v(2,i) + g1->v(2,i)*(2*j/(m-1.)-1)*r + g2->v(2,i)*(2*k/(l-1.)-1)*r; - } - if(flag & 2) -#pragma omp parallel for collapse(2) - for(j=0;j * + * Copyright (C) 2007-2016 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 * @@ -86,20 +86,24 @@ //----------------------------------------------------------------------------- void mglCanvasWnd::SetDrawFunc(int (*draw)(mglBase *gr, void *p), void *par, void (*reload)(void *p)) { - ResetFrames(); - if(get(MGL_CLF_ON_UPD)) DefaultPlotParam(); - const std::string loc = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C"); - // use frames for quickly redrawing while adding/changing primitives - if(mgl_is_frames(this)) NewFrame(); + if(draw) + { + ResetFrames(); + if(get(MGL_CLF_ON_UPD)) DefaultPlotParam(); + const std::string loc = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C"); + // use frames for quickly redrawing while adding/changing primitives + if(mgl_is_frames(this)) NewFrame(); - int n = draw ? draw(this,par) : 0; - if(n=0) NumFig = n; - DrawFunc = draw; FuncPar = par; - LoadFunc = reload; + int n = draw(this,par); + if(n=0) NumFig = n; + DrawFunc = draw; FuncPar = par; + LoadFunc = reload; - if(mgl_is_frames(this)) EndFrame(); - if(n>=0) SetCurFig(0); - setlocale(LC_NUMERIC, loc.c_str()); + if(mgl_is_frames(this)) EndFrame(); + if(n>=0) SetCurFig(0); + setlocale(LC_NUMERIC, loc.c_str()); + } + else LoadFunc = 0; } //----------------------------------------------------------------------------- const unsigned char *mglCanvasWnd::GetBits() diff -Nru mathgl-2.3.4/texinfo/concept_en.texi mathgl-2.3.5.1/texinfo/concept_en.texi --- mathgl-2.3.4/texinfo/concept_en.texi 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/concept_en.texi 2016-06-19 17:06:39.000000000 +0000 @@ -8,7 +8,7 @@ There are six most general (base) concepts: @enumerate @item -@strong{Any picture is created in memory first.} The internal (memory) representation can be different: bitmap picture (for @code{SetQuality(MGL_DRAW_LMEM)}) or the list of vector primitives (default). After that the user may decide what he/she want: save to file, display on the screen, run animation, do additional editing and so on. This approach assures a high portability of the program -- the source code will produce exactly the same picture in @emph{any} OS. Another big positive consequence is the ability to create the picture in the console program (using command line, without creating a window)! +@strong{Any picture is created in memory first.} The internal (memory) representation can be different: bitmap picture (for @code{SetQuality(MGL_DRAW_LMEM)} or @code{@ref{quality} 6}) or the list of vector primitives (default). After that the user may decide what he/she want: save to file, display on the screen, run animation, do additional editing and so on. This approach assures a high portability of the program -- the source code will produce exactly the same picture in @emph{any} OS. Another big positive consequence is the ability to create the picture in the console program (using command line, without creating a window)! @item @strong{Every plot settings (style of lines, font, color scheme) are specified by a string.} It provides convenience for user/programmer -- short string with parameters is more comprehensible than a large set of parameters. Also it provides portability -- the strings are the same in any OS so that it is not necessary to think about argument types. @item @@ -42,9 +42,9 @@ Two axis representations are used in MathGL. The first one consists of normalizing coordinates of data points in axis range (see @ref{Axis settings}). If @code{SetCut()} is @code{true} then the outlier points are omitted, otherwise they are projected to the bounding box (see @ref{Cutting}). Also, the point will be omitted if it lies inside the box defined by @code{SetCutBox()} or if the value of formula @code{CutOff()} is nonzero for its coordinates. After that, transformation formulas defined by @code{SetFunc()} or @code{SetCoor()} are applied to the data point (see @ref{Curved coordinates}). Finally, the data point is plotted by one of the functions. -The range of @emph{x, y, z}-axis can be specified by @code{SetRange()} or @code{SetRanges()} functions. Its origin is specified by @code{SetOrigin()} function. At this you can you can use @code{NAN} values for selecting axis origin automatically. +The range of @emph{x, y, z}-axis can be specified by @code{SetRange()} or @ref{ranges} functions. Its origin is specified by @ref{origin} function. At this you can you can use @code{NAN} values for selecting axis origin automatically. -There is 4-th axis @emph{c} (color axis or colorbar) in addition to the usual axes @emph{x, y, z}. It sets the range of values for the surface coloring. Its borders are automatically set to values of z-range during the call of @code{SetRanges()} function. Also, one can directly set it by call @code{SetRange('c', ...)}. Use @code{Colorbar()} function for drawing the colorbar. +There is 4-th axis @emph{c} (color axis or colorbar) in addition to the usual axes @emph{x, y, z}. It sets the range of values for the surface coloring. Its borders are automatically set to values of z-range during the call of @ref{ranges} function. Also, one can directly set it by call @code{SetRange('c', ...)}. Use @ref{colorbar} function for drawing the colorbar. The form (appearence) of tick labels is controlled by @code{SetTicks()} function (@pxref{Ticks}). Function @var{SetTuneTicks} switches on/off tick enhancing by factoring out acommon multiplier (for small coordinate values, like 0.001 to 0.002, or large, like from 1000 to 2000) or common component (for narrow range, like from 0.999 to 1.000). Finally, you may use functions @code{SetTickTempl()} for setting templates for tick labels (it supports TeX symbols). Also, there is a possibility to print arbitrary text as tick labels the by help of @code{SetTicksVal()} function. @@ -86,7 +86,7 @@ @cindex Mark style @cindex Arrows -The line style is defined by the string which may contain specifications for color (@samp{wkrgbcymhRGBCYMHWlenupqLENUPQ}), dashing style (@samp{-|;:ji=} or space), width (@samp{123456789}) and marks (@samp{*o+xsd.^v<>} and @samp{#} modifier). If one of the type of information is omitted then default values used with next color from palette (see @ref{Palette and colors}). Note, that internal color counter will be nullified by any change of palette. This includes even hidden change (for example, by @code{Box()} or @code{Axis()} functions). +The line style is defined by the string which may contain specifications for color (@samp{wkrgbcymhRGBCYMHWlenupqLENUPQ}), dashing style (@samp{-|;:ji=} or space), width (@samp{123456789}) and marks (@samp{*o+xsd.^v<>} and @samp{#} modifier). If one of the type of information is omitted then default values used with next color from palette (see @ref{Palette and colors}). Note, that internal color counter will be nullified by any change of palette. This includes even hidden change (for example, by @ref{box} or @ref{axis} functions). @ifhtml @html By default palette contain following colors: dark grayH’, blueb’, greeng’, redr’, cyanc’, magentam’, yellowy’, grayh’, green-bluel’, sky-bluen’, orangeq’, green-yellowe’, blue-violetu’, purplep’. diff -Nru mathgl-2.3.4/texinfo/concept_ru.texi mathgl-2.3.5.1/texinfo/concept_ru.texi --- mathgl-2.3.4/texinfo/concept_ru.texi 2016-02-13 19:03:44.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/concept_ru.texi 2016-06-19 17:06:30.000000000 +0000 @@ -6,7 +6,7 @@ Всего основных концепций (базисных идей) шесть: @enumerate @item -@strong{Все рисунки создаются в памяти.} Это могут быть как растровые картинки (для @code{SetQuality(MGL_DRAW_LMEM)}), так и векторные списки примитивов (по умолчанию). Дальнейшая судьба рисунков определяется пользователем: можно сохранить в файл, вывести на экран, создать анимацию/кино, дополнительно отредактировать и т.д. Такой подход обеспечивает высокую переносимость библиотеки -- один и тот же программный код создаст в точности одинаковый рисунок на @emph{любой} операционной системе. Кроме того, при таком подходе рисунки можно создавать непосредственно в консольной программе -- графическое окно не нужно! +@strong{Все рисунки создаются в памяти.} Это могут быть как растровые картинки (для @code{SetQuality(MGL_DRAW_LMEM)} или @code{@ref{quality} 6}), так и векторные списки примитивов (по умолчанию). Дальнейшая судьба рисунков определяется пользователем: можно сохранить в файл, вывести на экран, создать анимацию/кино, дополнительно отредактировать и т.д. Такой подход обеспечивает высокую переносимость библиотеки -- один и тот же программный код создаст в точности одинаковый рисунок на @emph{любой} операционной системе. Кроме того, при таком подходе рисунки можно создавать непосредственно в консольной программе -- графическое окно не нужно! @item @strong{Все настройки графиков (стиль линий, цветовые схемы поверхностей, стиль и цвет текста) задаются строками.} Это обеспечивает: удобство для пользователя -- короткую строку легче читать и здесь тяжелее ошибиться, чем в большом списке параметров; переносимость -- строки выглядят одинаково на всех платформах и не надо заботиться о типе и числе аргументов. @item @@ -40,9 +40,9 @@ Представление системы координат в MathGL состоит из двух частей. Вначале координаты нормируются в диапазон изменения осей координат (@pxref{Axis settings}). Если флаг @code{SetCut()} установлен, то точки вне интервала отбрасываются, в противном случае, они проецируются на ограничивающий параллелепипед (см. @ref{Cutting}). Кроме того, отбрасываются точки внутри границ, определенных переменными @var{CutMin}x@var{CutMax} и точки, для которых значение функции @code{CutOff}() не равно нулю. После этого формулы перехода в криволинейную систему координат @code{SetFunc()}применяются к каждой точке. Наконец, точка данных отображается с помощью одной из графических функций. -Диапазон изменения @emph{x, y, z}-координат задается функциями @code{SetRange()} или @code{SetRanges()}. Точка пересечения осей координат задается функцией @code{SetOrigin()}. При этом можно использовать NAN значения для автоматического выбора положения оси. +Диапазон изменения @emph{x, y, z}-координат задается функциями @code{SetRange()} или @ref{ranges}. Точка пересечения осей координат задается функцией @code{SetOrigin()}. При этом можно использовать NAN значения для автоматического выбора положения оси. -Кроме привычных осей @emph{x, y, z} есть еще одна ось -- цветовая шкала -- ось @emph{c}. Она используется при окрашивании поверхностей и задает границы изменения функции при окрашивании. Ее границы автоматически устанавливаются равными диапазону z-оси при вызове @code{SetRanges()}. Возможно и ручное изменение границ цветового интервала посредством вызова @code{SetRange('c', ...)}. Используйте @code{Colorbar()} для отображения цветовой шкалы. +Кроме привычных осей @emph{x, y, z} есть еще одна ось -- цветовая шкала -- ось @emph{c}. Она используется при окрашивании поверхностей и задает границы изменения функции при окрашивании. Ее границы автоматически устанавливаются равными диапазону z-оси при вызове @ref{ranges}. Возможно и ручное изменение границ цветового интервала посредством вызова @code{SetRange('c', ...)}. Используйте @ref{colorbar} для отображения цветовой шкалы. Вид меток по осям определяется функцией @code{SetTicks()} (@pxref{Ticks}). Функция @var{SetTuneTicks} включает/выключает выделение общего множителя (большого или малого факторов в диапазоне) для меток осей координат. Наконец, если стандартный вид меток не устраивает пользователя, то их шаблон можно задать явно (можно использовать и ТеХ символы), воспользовавшись функцией @code{SetTickTempl()}. Кроме того, в качестве меток можно вывести произвольный текст использовав функцию @code{SetTicksVal()}. diff -Nru mathgl-2.3.4/texinfo/core_en.texi mathgl-2.3.5.1/texinfo/core_en.texi --- mathgl-2.3.4/texinfo/core_en.texi 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/core_en.texi 2016-06-19 17:06:39.000000000 +0000 @@ -488,6 +488,15 @@ @end ifclear +@anchor{gray} +@deftypefn {MGL command} {} gray @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Gray (@code{bool} enable) +@deftypefnx {C function} @code{void} mgl_set_gray (@code{HMGL} gr, @code{int} enable) +@end ifclear +Sets the gray-scale mode on/off. +@end deftypefn + @c ================================================================== @external{} @node Masks, Error handling, Palette and colors, Graphics setup @@ -984,7 +993,7 @@ @cindex Push @cindex Pop -These functions control how and where further plotting will be placed. There is a certain calling order of these functions for the better plot appearance. First one should be @ref{subplot}, @ref{multiplot} or @ref{inplot} for specifying the place. Second one can be @ref{title} for adding title for the subplot. After it a @ref{rotate} and @ref{aspect}. And finally any other plotting functions may be called. Alternatively you can use @ref{columnplot}, @ref{gridplot}, @ref{stickplot} or relative @ref{inplot} for positioning plots in the column (or grid, or stick) one by another without gap between plot axis (bounding boxes). @sref{Subplots} +These functions control how and where further plotting will be placed. There is a certain calling order of these functions for the better plot appearance. First one should be @ref{subplot}, @ref{multiplot} or @ref{inplot} for specifying the place. Second one can be @ref{title} for adding title for the subplot. After it a @ref{rotate}, @ref{shear} and @ref{aspect}. And finally any other plotting functions may be called. Alternatively you can use @ref{columnplot}, @ref{gridplot}, @ref{stickplot}, @ref{shearplot} or relative @ref{inplot} for positioning plots in the column (or grid, or stick) one by another without gap between plot axis (bounding boxes). @sref{Subplots} @anchor{subplot} @deftypefn {MGL command} {} subplot @code{nx ny m ['stl'='<>_^' dx=0 dy=0]} @@ -1067,6 +1076,16 @@ Puts further plotting in @var{ind}-th cell of stick with @var{num} cells. At this, stick is rotated on angles @var{tet}, @var{phi}. The position is relative to previous @ref{subplot} (or @ref{inplot} with @var{rel}=@code{false}). @end deftypefn +@anchor{shearplot} +@deftypefn {MGL command} {} shearplot @code{num ind sx sy [xd yd]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} ShearPlot (@code{int} num, @code{int} ind, @code{mreal} sx, @code{mreal} sy, @code{mreal} xd=@code{1}, @code{mreal} yd=@code{0}) +@deftypefnx {C function} @code{void} mgl_shearplot (@code{HMGL} gr, @code{int} num, @code{int} ind, @code{mreal} sx, @code{mreal} sy, @code{mreal} xd, @code{mreal} yd) +@end ifclear +Puts further plotting in @var{ind}-th cell of stick with @var{num} cells. At this, cell is sheared on values @var{sx}, @var{sy}. Stick direction is specified be @var{xd} and @var{yd}. The position is relative to previous @ref{subplot} (or @ref{inplot} with @var{rel}=@code{false}). +@end deftypefn + + @anchor{title} @deftypefn {MGL command} {} title 'title' ['stl'='' @code{size=-2}] @ifclear UDAV @@ -1102,6 +1121,15 @@ Rotates a further plotting around vector @{@var{x}, @var{y}, @var{z}@} on angle @var{Tet}. @end deftypefn +@anchor{shear} +@deftypefn {MGL command} {} shear @code{sx sy} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Shear (@code{mreal} sx, @code{mreal} sy) +@deftypefnx {C function} @code{void} mgl_shear (@code{HMGL} gr, @code{mreal} sx, @code{mreal} sy) +@end ifclear +Shears a further plotting on values @var{sx}, @var{sy}. +@end deftypefn + @anchor{aspect} @deftypefn {MGL command} {} aspect @code{ax ay [az=1]} @ifclear UDAV @@ -1178,12 +1206,14 @@ Sets size of picture in pixels. This function @strong{should be} called before any other plotting because it completely remove picture contents if @var{clear}=@code{true}. Function just clear pixels and scale all primitives if @var{clear}=@code{false}. @end deftypefn +@anchor{setsizescl} +@deftypefn {MGL command} {} setsizescl @code{factor} @ifclear UDAV -@deftypefn {Method on @code{mglGraph}} @code{void} SetSizeScl (@code{double} factor) +@deftypefnx {Method on @code{mglGraph}} @code{void} SetSizeScl (@code{double} factor) @deftypefnx {C function} @code{void} mgl_set_size_scl (@code{HMGL} gr, @code{double} factor) +@end ifclear Set factor for width and height in all further calls of @ref{setsize}. @end deftypefn -@end ifclear @anchor{quality} @deftypefn {MGL command} {} quality [@code{val}=2] @@ -3181,6 +3211,8 @@ @item @samp{#} for starting threads from edges only; @item +@samp{*} for starting threads from a 2D array of points inside the data; +@item @samp{v} for drawing arrows on the threads; @item @samp{x}, @samp{z} for drawing tapes of normals in x-y and y-z planes correspondingly. diff -Nru mathgl-2.3.4/texinfo/core_ru.texi mathgl-2.3.5.1/texinfo/core_ru.texi --- mathgl-2.3.4/texinfo/core_ru.texi 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/core_ru.texi 2016-06-19 17:06:39.000000000 +0000 @@ -473,6 +473,15 @@ @end deftypefn @end ifclear +@anchor{gray} +@deftypefn {Команда MGL} {} gray @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Gray (@code{bool} enable) +@deftypefnx {Функция С} @code{void} mgl_set_gray (@code{HMGL} gr, @code{int} enable) +@end ifclear +Включает/выключает вывод графика в оттенках серого. +@end deftypefn + @c ================================================================== @external{} @node Masks, Error handling, Palette and colors, Graphics setup @@ -966,7 +975,7 @@ @cindex Push @cindex Pop -Эти функции контролируют где и как график будет расположен. Существует определенный порядок вызова этих функций для лучшего вида графика. Вначале должны вызываться функции @ref{subplot}, @ref{multiplot} или @ref{inplot} для указания местоположения вывода. После них -- функции вращения @ref{rotate} и @ref{aspect}. И наконец любые другие функции для рисования графика. Вместо вращения графика можно вызвать функцию @ref{columnplot}, @ref{gridplot}, @ref{stickplot} или относительную @ref{inplot} для расположения графиков в столбец одного над другим без зазора между осями. @sref{Subplots} +Эти функции контролируют где и как график будет расположен. Существует определенный порядок вызова этих функций для лучшего вида графика. Вначале должны вызываться функции @ref{subplot}, @ref{multiplot} или @ref{inplot} для указания местоположения вывода. После них -- функции вращения @ref{rotate}, @ref{shear} и @ref{aspect}. И наконец любые другие функции для рисования графика. Вместо вращения графика можно вызвать функцию @ref{columnplot}, @ref{gridplot}, @ref{stickplot}, @ref{shearplot} или относительную @ref{inplot} для расположения графиков в столбец одного над другим без зазора между осями. @sref{Subplots} @anchor{subplot} @deftypefn {Команда MGL} {} subplot @code{nx ny m ['stl'='<>_^' dx=0 dy=0]} @@ -1026,6 +1035,15 @@ Помещает последующий вывод в @var{ind}-ую ячейку "бруска" из @var{num} ячеек. При этом сам брусок повернут на углы @var{tet}, @var{phi}. Положение выбирается относительно последнего вызова @ref{subplot} (или @ref{inplot} с @var{rel}=@code{false}). @end deftypefn +@anchor{shearplot} +@deftypefn {Команда MGL} {} shearplot @code{num ind sx sy [xd yd]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ShearPlot (@code{int} num, @code{int} ind, @code{mreal} sx, @code{mreal} sy, @code{mreal} xd=@code{1}, @code{mreal} yd=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_shearplot (@code{HMGL} gr, @code{int} num, @code{int} ind, @code{mreal} sx, @code{mreal} sy, @code{mreal} xd, @code{mreal} yd) +@end ifclear +Помещает последующий вывод в @var{ind}-ую ячейку "бруска" из @var{num} ячеек. При этом сама ячейка скошена на @var{sx}, @var{sy}. Направление бруска задается переменными @var{xd} и @var{yd}. Положение выбирается относительно последнего вызова @ref{subplot} (или @ref{inplot} с @var{rel}=@code{false}). +@end deftypefn + @anchor{title} @deftypefn {Команда MGL} {} title 'title' ['stl'='' @code{size=-2}] @ifclear UDAV @@ -1054,6 +1072,17 @@ Вращает систему координат относительно вектора @{@var{x}, @var{y}, @var{z}@} на угол @var{Tet}. @end deftypefn + +@anchor{shear} +@deftypefn {Команда MGL} {} shear @code{sx sy} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Shear (@code{mreal} sx, @code{mreal} sy) +@deftypefnx {Функция С} @code{void} mgl_shear (@code{HMGL} gr, @code{mreal} sx, @code{mreal} sy) +@end ifclear +Сдвигает (скашивает) систему координат на значения @var{sx}, @var{sy}. +@end deftypefn + + @anchor{aspect} @deftypefn {Команда MGL} {} aspect @code{ax ay [az=1]} @ifclear UDAV @@ -1132,12 +1161,14 @@ @end deftypefn +@anchor{setsizescl} +@deftypefn {Команда MGL} {} setsizescl @code{factor} @ifclear UDAV -@deftypefn {Метод класса @code{mglGraph}} @code{void} SetSizeScl (@code{double} factor) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetSizeScl (@code{double} factor) @deftypefnx {Функция С} @code{void} mgl_set_size_scl (@code{HMGL} gr, @code{double} factor) +@end ifclear Задает множитель для высоты и ширины во всех последующих вызовах @ref{setsize}. @end deftypefn -@end ifclear @anchor{quality} @@ -3093,6 +3124,8 @@ @item @samp{#} для использования нитей, начинающихся только на границе; @item +@samp{*} для использования нитей, начинающихся с двумерной сетки внутри данных; +@item @samp{v} для рисования стрелок на нитях; @item @samp{x}, @samp{z} для рисования лент нормалей, начинающихся в плоскостях x-y и y-z соответственно. diff -Nru mathgl-2.3.4/texinfo/data_en.texi mathgl-2.3.5.1/texinfo/data_en.texi --- mathgl-2.3.4/texinfo/data_en.texi 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/data_en.texi 2016-06-19 17:06:39.000000000 +0000 @@ -1132,10 +1132,38 @@ Find envelop for data values along direction @var{dir}. @end deftypefn +@anchor{diffract} +@deftypefn {MGL command} {} diffract dat 'how' @code{q} +@ifclear UDAV +@deftypefnx {Method on @code{mglDataC}} @code{void} Diffraction (@code{const char *}how, @code{mreal} q) +@deftypefnx {C function} @code{void} mgl_datac_diffr (@code{HADT} dat, @code{const char *}how, @code{mreal} q) +@end ifclear +Calculates one step of diffraction by finite-difference method with parameter @var{q}=@math{\delta t/\delta x^2} using method with 3-d order of accuracy. Parameter @var{how} may contain: +@itemize @bullet + @item @samp{xyz} for calculations along x-,y-,z-directions correspondingly; +@item + @samp{r} for using axial symmetric Laplace operator for x-direction; +@item + @samp{0} for zero boundary conditions; +@item + @samp{1} for constant boundary conditions; +@item + @samp{2} for linear boundary conditions; +@item + @samp{3} for parabolic boundary conditions; +@item + @samp{4} for exponential boundary conditions; +@item + @samp{5} for gaussian boundary conditions. +@end itemize +@end deftypefn + + @anchor{norm} @deftypefn {MGL command} {} norm dat @code{v1 v2 [sym=off dim=0]} @ifclear UDAV -@deftypefnx {Method on @code{mglData}} @code{void} Norm (@code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{bool} sym=@code{false}, @code{int} dim=@code{0}) +@deftypefnx {Method on @code{mglData}} @code{void} Norm (@code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{bool} sym=@code{false}, @code{long} dim=@code{0}) +@deftypefnx {C function} @code{void} mgl_data_norm (@code{HMDT} dat, @code{mreal} v1, @code{mreal} v2, @code{int} sym, @code{long} dim) @end ifclear Normalizes the data to range [@var{v1},@var{v2}]. If flag @var{sym}=@code{true} then symmetrical interval [-max(|v1|,|v2|), max(|v1|,|v2|)] is used. Modification will be applied only for slices >=@var{dim}. @end deftypefn @@ -1155,6 +1183,17 @@ @end ifnottex @end deftypefn +@anchor{limit} +@deftypefn {MGL command} {} limit dat @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Limit (@code{mreal} val) +@deftypefnx {Method on @code{mglDataC}} @code{void} Limit (@code{mreal} val) +@deftypefnx {C function} @code{void} mgl_data_limit (@code{HMDT} dat, @code{mreal} val) +@deftypefnx {C function} @code{void} mgl_datac_limit (@code{HADT} dat, @code{mreal} val) +@end ifclear +Limits the data values to be inside the range [-@var{val},@var{val}], keeping the original sign of the value (phase for complex numbers). This is equivalent to operation @code{a[i] *= abs(a[i])=@var{dim}. @end deftypefn @@ -1141,6 +1168,17 @@ @end ifnottex @end deftypefn +@anchor{limit} +@deftypefn {Команда MGL} {} limit dat @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Limit (@code{mreal} val) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Limit (@code{mreal} val) +@deftypefnx {Функция С} @code{void} mgl_data_limit (@code{HMDT} dat, @code{mreal} val) +@deftypefnx {Функция С} @code{void} mgl_datac_limit (@code{HADT} dat, @code{mreal} val) +@end ifclear +Ограничивает амплитуду данных диапазоном [-@var{val},@var{val}]. При этом сохраняется исходный знак (фаза для комплексных чисел). Эквивалентно операции @code{a[i] *= abs(a[i])Rotate(50,60); gr->Box(); gr->SubPlot(2,2,2); gr->Title("Rotate and Aspect"); gr->Rotate(50,60); gr->Aspect(1,1,2); gr->Box(); - gr->SubPlot(2,2,3); gr->Title("Aspect in other direction"); - gr->Rotate(50,60); gr->Aspect(1,2,2); gr->Box(); + gr->SubPlot(2,2,3); gr->Title("Shear"); + gr->Box("c"); gr->Shear(0.2,0.1); gr->Box(); return 0; } @end verbatim @@ -735,7 +735,10 @@ gr->GridPlot(2, 2, 3); gr->Box("m"); gr->Puts(mglPoint(0),"3","m"); gr->SubPlot(3,2,5,""); gr->Title("InPlot"); gr->Box(); gr->InPlot(0.4, 1, 0.6, 1, true); gr->Box("r"); - gr->MultiPlot(3,2,1, 2, 1,""); gr->Title("MultiPlot"); gr->Box(); + gr->MultiPlot(3,2,1, 2, 1,""); gr->Title("MultiPlot and ShearPlot"); gr->Box(); + gr->ShearPlot(3, 0, 0.2, 0.1); gr->Box("r"); gr->Puts(mglPoint(0),"0","r"); + gr->ShearPlot(3, 1, 0.2, 0.1); gr->Box("g"); gr->Puts(mglPoint(0),"1","g"); + gr->ShearPlot(3, 2, 0.2, 0.1); gr->Box("b"); gr->Puts(mglPoint(0),"2","b"); return 0; } @end verbatim @@ -3916,7 +3919,7 @@ mglData in(9), arg(99), e, s; gr->Fill(in,"x^3/1.1"); gr->Fill(arg,"4*x+4"); gr->Plot(in,"ko "); gr->Box(); - e = in.Evaluate(arg); gr->Plot(e,"b.","legend 'Evaluate'"); + e = in.Evaluate(arg,false); gr->Plot(e,"b.","legend 'Evaluate'"); s = in.SubData(arg); gr->Plot(s,"r.","legend 'SubData'"); gr->Legend(2); } diff -Nru mathgl-2.3.4/texinfo/example_ru.texi mathgl-2.3.5.1/texinfo/example_ru.texi --- mathgl-2.3.4/texinfo/example_ru.texi 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/example_ru.texi 2016-06-19 17:06:39.000000000 +0000 @@ -706,8 +706,8 @@ gr->Rotate(50,60); gr->Box(); gr->SubPlot(2,2,2); gr->Title("Rotate and Aspect"); gr->Rotate(50,60); gr->Aspect(1,1,2); gr->Box(); - gr->SubPlot(2,2,3); gr->Title("Aspect in other direction"); - gr->Rotate(50,60); gr->Aspect(1,2,2); gr->Box(); + gr->SubPlot(2,2,3); gr->Title("Shear"); + gr->Box("c"); gr->Shear(0.2,0.1); gr->Box(); return 0; } @end verbatim @@ -734,7 +734,10 @@ gr->GridPlot(2, 2, 3); gr->Box("m"); gr->Puts(mglPoint(0),"3","m"); gr->SubPlot(3,2,5,""); gr->Title("InPlot"); gr->Box(); gr->InPlot(0.4, 1, 0.6, 1, true); gr->Box("r"); - gr->MultiPlot(3,2,1, 2, 1,""); gr->Title("MultiPlot"); gr->Box(); + gr->MultiPlot(3,2,1, 2, 1,""); gr->Title("MultiPlot and ShearPlot"); gr->Box(); + gr->ShearPlot(3, 0, 0.2, 0.1); gr->Box("r"); gr->Puts(mglPoint(0),"0","r"); + gr->ShearPlot(3, 1, 0.2, 0.1); gr->Box("g"); gr->Puts(mglPoint(0),"1","g"); + gr->ShearPlot(3, 2, 0.2, 0.1); gr->Box("b"); gr->Puts(mglPoint(0),"2","b"); return 0; } @end verbatim @@ -3899,7 +3902,7 @@ mglData in(9), arg(99), e, s; gr->Fill(in,"x^3/1.1"); gr->Fill(arg,"4*x+4"); gr->Plot(in,"ko "); gr->Box(); - e = in.Evaluate(arg); gr->Plot(e,"b.","legend 'Evaluate'"); + e = in.Evaluate(arg,false); gr->Plot(e,"b.","legend 'Evaluate'"); s = in.SubData(arg); gr->Plot(s,"r.","legend 'SubData'"); gr->Legend(2); } diff -Nru mathgl-2.3.4/texinfo/ex_mgl_en.texi mathgl-2.3.5.1/texinfo/ex_mgl_en.texi --- mathgl-2.3.4/texinfo/ex_mgl_en.texi 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/ex_mgl_en.texi 2016-06-19 17:06:39.000000000 +0000 @@ -126,7 +126,7 @@ @verbatim subplot 2 2 0 box:text -1 1.1 'Just box' ':L' -inplot 0.2 0.5 0.7 off +inplot 0.2 0.5 0.7 1 off box:text 0 1.2 'InPlot example' subplot 2 2 1:title 'Rotate only' @@ -135,8 +135,8 @@ subplot 2 2 2:title 'Rotate and Aspect' rotate 50 60:aspect 1 1 2:box -subplot 2 2 3:title 'Aspect in other direction' -rotate 50 60:aspect 1 2 2:box +subplot 2 2 3:title 'Shear' +box 'c':shear 0.2 0.1:box @end verbatim Here I used function @code{Puts} for printing the text in arbitrary position of picture (see @ref{Text printing}). Text coordinates and size are connected with axes. However, text coordinates may be everywhere, including the outside the bounding box. I'll show its features later in @ref{Text features}. @@ -147,9 +147,9 @@ More complicated sample show how to use most of positioning functions: @verbatim subplot 3 2 0:title 'StickPlot' -stickplot 3 0 20 30:box 'r':text 0 0 '0' 'r' -stickplot 3 1 20 30:box 'g':text 0 0 '1' 'g' -stickplot 3 2 20 30:box 'b':text 0 0 '2' 'b' +stickplot 3 0 20 30:box 'r':text 0 0 0 '0' 'r' +stickplot 3 1 20 30:box 'g':text 0 0 0 '1' 'g' +stickplot 3 2 20 30:box 'b':text 0 0 0 '2' 'b' subplot 3 2 3 '':title 'ColumnPlot' columnplot 3 0:box 'r':text 0 0 '0' 'r' @@ -165,7 +165,10 @@ subplot 3 2 5 '':title 'InPlot':box inplot 0.4 1 0.6 1 on:box 'r' -multiplot 3 2 1 2 1 '':title 'MultiPlot':box +multiplot 3 2 1 2 1 '':title 'MultiPlot and ShearPlot':box +shearplot 3 0 0.2 0.1:box 'r':text 0 0 '0' 'r' +shearplot 3 1 0.2 0.1:box 'g':text 0 0 '1' 'g' +shearplot 3 2 0.2 0.1:box 'b':text 0 0 '2' 'b' @end verbatim @pfig{inplot, Example for most of positioning functions.} @@ -2695,7 +2698,7 @@ subplot 1 1 0 '':title 'SubData vs Evaluate' new in 9 'x^3/1.1':plot in 'ko ':box new arg 99 '4*x+4' -evaluate e in arg:plot e 'b.'; legend 'Evaluate' +evaluate e in arg off:plot e 'b.'; legend 'Evaluate' subdata s in arg:plot s 'r.';legend 'SubData' legend 2 @end verbatim diff -Nru mathgl-2.3.4/texinfo/ex_mgl_ru.texi mathgl-2.3.5.1/texinfo/ex_mgl_ru.texi --- mathgl-2.3.4/texinfo/ex_mgl_ru.texi 2016-02-13 19:03:44.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/ex_mgl_ru.texi 2016-06-19 17:06:30.000000000 +0000 @@ -126,7 +126,7 @@ @verbatim subplot 2 2 0 box:text -1 1.1 'Just box' ':L' -inplot 0.2 0.5 0.7 off +inplot 0.2 0.5 0.7 1 off box:text 0 1.2 'InPlot example' subplot 2 2 1:title 'Rotate only' @@ -135,8 +135,8 @@ subplot 2 2 2:title 'Rotate and Aspect' rotate 50 60:aspect 1 1 2:box -subplot 2 2 3:title 'Aspect in other direction' -rotate 50 60:aspect 1 2 2:box +subplot 2 2 3:title 'Shear' +box 'c':shear 0.2 0.1:box @end verbatim Here I used function @code{Puts} for printing the text in arbitrary position of picture (see @ref{Text printing}). Text coordinates and size are connected with axes. However, text coordinates may be everywhere, including the outside the bounding box. I'll show its features later in @ref{Text features}. @@ -147,9 +147,9 @@ More complicated sample show how to use most of positioning functions: @verbatim subplot 3 2 0:title 'StickPlot' -stickplot 3 0 20 30:box 'r':text 0 0 '0' 'r' -stickplot 3 1 20 30:box 'g':text 0 0 '1' 'g' -stickplot 3 2 20 30:box 'b':text 0 0 '2' 'b' +stickplot 3 0 20 30:box 'r':text 0 0 0 '0' 'r' +stickplot 3 1 20 30:box 'g':text 0 0 0 '1' 'g' +stickplot 3 2 20 30:box 'b':text 0 0 0 '2' 'b' subplot 3 2 3 '':title 'ColumnPlot' columnplot 3 0:box 'r':text 0 0 '0' 'r' @@ -165,7 +165,10 @@ subplot 3 2 5 '':title 'InPlot':box inplot 0.4 1 0.6 1 on:box 'r' -multiplot 3 2 1 2 1 '':title 'MultiPlot':box +multiplot 3 2 1 2 1 '':title 'MultiPlot and ShearPlot':box +shearplot 3 0 0.2 0.1:box 'r':text 0 0 '0' 'r' +shearplot 3 1 0.2 0.1:box 'g':text 0 0 '1' 'g' +shearplot 3 2 0.2 0.1:box 'b':text 0 0 '2' 'b' @end verbatim @pfig{inplot, Example for most of positioning functions.} @@ -2695,7 +2698,7 @@ subplot 1 1 0 '':title 'SubData vs Evaluate' new in 9 'x^3/1.1':plot in 'ko ':box new arg 99 '4*x+4' -evaluate e in arg:plot e 'b.'; legend 'Evaluate' +evaluate e in arg off:plot e 'b.'; legend 'Evaluate' subdata s in arg:plot s 'r.';legend 'SubData' legend 2 @end verbatim diff -Nru mathgl-2.3.4/texinfo/formats_en.texi mathgl-2.3.5.1/texinfo/formats_en.texi --- mathgl-2.3.4/texinfo/formats_en.texi 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/formats_en.texi 2016-06-19 17:06:39.000000000 +0000 @@ -6,6 +6,7 @@ * Font files:: * MGLD format:: * JSON format:: +* IFS format:: @end menu @c ------------------------------------------------------------------ @@ -75,7 +76,7 @@ @c ------------------------------------------------------------------ @external{} -@node JSON format, , MGLD format, File formats +@node JSON format, IFS format, MGLD format, File formats @section JSON format @nav{} @@ -97,7 +98,7 @@ @item nprim number of primitives; @item prim -array of primitives, each element is array in form [type, n1, n2, n3, n4, id, s, w, p, z, color]. +array of primitives, each element is array in form [type, n1, n2, n3, n4, id, s, w, p, z, color]. Here @var{type} is kind of primitive (0 - mark, 1 - line, 2 - triangle, 3 - quadrangle, 4 - glyph), @var{n1}...@var{n4} is index of point for vertexes and @var{n2} can be index of glyph coordinate, @var{s} and @var{w} are size and width if applicable, @var{z} is average z-coordinate, @var{id} is primitive identification number, @var{p} is scaling factor for glyphs. @@ -112,4 +113,29 @@ array of glyph descriptions, each element is array in form @code{[nL, [xP0, yP0, xP1, yP1 ...]]}. Here @code{nL} is the number of line vertexes; and @code{xP, yP, xQ, yQ} are coordinates of lines. Line coordinate xP=0x3fff, yP=0x3fff denote line breaking. @end table + +@c ------------------------------------------------------------------ +@external{} +@node IFS format, , JSON format, File formats +@section IFS format +@nav{} + +MathGL can read IFS fractal parameters (see @ref{ifsfile}) from a IFS file. Let remind IFS file format. File may contain several records. Each record contain the name of fractal (@samp{binary} in the example below) and the body of fractal, which is enclosed in curly braces @{@}. Symbol @samp{;} start the comment. If the name of fractal contain @samp{(3D)} or @samp{(3d)} then the 3d IFS fractal is specified. The sample below contain two fractals: @samp{binary} -- usual 2d fractal, and @samp{3dfern (3D)} -- 3d fractal. + +@verbatim + binary + { ; comment allowed here + ; and here + .5 .0 .0 .5 -2.563477 -0.000003 .333333 ; also comment allowed here + .5 .0 .0 .5 2.436544 -0.000003 .333333 + .0 -.5 .5 .0 4.873085 7.563492 .333333 + } + + 3dfern (3D) { + .00 .00 0 .0 .18 .0 0 0.0 0.00 0 0.0 0 .01 + .85 .00 0 .0 .85 .1 0 -0.1 0.85 0 1.6 0 .85 + .20 -.20 0 .2 .20 .0 0 0.0 0.30 0 0.8 0 .07 + -.20 .20 0 .2 .20 .0 0 0.0 0.30 0 0.8 0 .07 + } +@end verbatim @external{} diff -Nru mathgl-2.3.4/texinfo/formats_ru.texi mathgl-2.3.5.1/texinfo/formats_ru.texi --- mathgl-2.3.4/texinfo/formats_ru.texi 2016-02-13 19:03:44.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/formats_ru.texi 2016-06-19 17:06:30.000000000 +0000 @@ -6,6 +6,7 @@ * Font files:: * MGLD format:: * JSON format:: +* IFS format:: @end menu @c ------------------------------------------------------------------ @@ -75,7 +76,7 @@ @c ------------------------------------------------------------------ @external{} -@node JSON format, , MGLD format, File formats +@node JSON format, IFS format, MGLD format, File formats @section JSON format @nav{} @@ -97,7 +98,7 @@ @item nprim number of primitives; @item prim -array of primitives, each element is array in form [type, n1, n2, n3, n4, id, s, w, p, z, color]. +array of primitives, each element is array in form [type, n1, n2, n3, n4, id, s, w, p, z, color]. Here @var{type} is kind of primitive (0 - mark, 1 - line, 2 - triangle, 3 - quadrangle, 4 - glyph), @var{n1}...@var{n4} is index of point for vertexes and @var{n2} can be index of glyph coordinate, @var{s} and @var{w} are size and width if applicable, @var{z} is average z-coordinate, @var{id} is primitive identification number, @var{p} is scaling factor for glyphs. @@ -112,4 +113,29 @@ array of glyph descriptions, each element is array in form @code{[nL, [xP0, yP0, xP1, yP1 ...]]}. Here @code{nL} is the number of line vertexes; and @code{xP, yP, xQ, yQ} are coordinates of lines. Line coordinate xP=0x3fff, yP=0x3fff denote line breaking. @end table + +@c ------------------------------------------------------------------ +@external{} +@node IFS format, , JSON format, File formats +@section IFS format +@nav{} + +MathGL can read IFS fractal parameters (see @ref{ifsfile}) from a IFS file. Let remind IFS file format. File may contain several records. Each record contain the name of fractal (@samp{binary} in the example below) and the body of fractal, which is enclosed in curly braces @{@}. Symbol @samp{;} start the comment. If the name of fractal contain @samp{(3D)} or @samp{(3d)} then the 3d IFS fractal is specified. The sample below contain two fractals: @samp{binary} -- usual 2d fractal, and @samp{3dfern (3D)} -- 3d fractal. + +@verbatim + binary + { ; comment allowed here + ; and here + .5 .0 .0 .5 -2.563477 -0.000003 .333333 ; also comment allowed here + .5 .0 .0 .5 2.436544 -0.000003 .333333 + .0 -.5 .5 .0 4.873085 7.563492 .333333 + } + + 3dfern (3D) { + .00 .00 0 .0 .18 .0 0 0.0 0.00 0 0.0 0 .01 + .85 .00 0 .0 .85 .1 0 -0.1 0.85 0 1.6 0 .85 + .20 -.20 0 .2 .20 .0 0 0.0 0.30 0 0.8 0 .07 + -.20 .20 0 .2 .20 .0 0 0.0 0.30 0 0.8 0 .07 + } +@end verbatim @external{} diff -Nru mathgl-2.3.4/texinfo/parse_en.texi mathgl-2.3.5.1/texinfo/parse_en.texi --- mathgl-2.3.4/texinfo/parse_en.texi 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/parse_en.texi 2016-06-19 17:06:39.000000000 +0000 @@ -24,7 +24,7 @@ @section MGL definition @nav{} -MGL script language is rather simple. Each string is a command. First word of string is the name of command. Other words are command arguments. Command may have up to 1000 arguments (at least for now). Words are separated from each other by space or tabulation symbol. The upper or lower case of words is important, i.e. variables @var{a} and @var{A} are different variables. Symbol @samp{#} starts the comment (all characters after # will be ignored). The exception is situation when @samp{#} is a part of some string. Also options can be specified after symbol @samp{;} (@pxref{Command options}). Symbol @samp{:} starts new command (like new line character) if it is not placed inside a string or inside brackets. +MGL script language is rather simple. Each string is a command. First word of string is the name of command. Other words are command arguments. Words are separated from each other by space or tabulation symbol. The upper or lower case of words is important, i.e. variables @var{a} and @var{A} are different variables. Symbol @samp{#} starts the comment (all characters after # will be ignored). The exception is situation when @samp{#} is a part of some string. Also options can be specified after symbol @samp{;} (@pxref{Command options}). Symbol @samp{:} starts new command (like new line character) if it is not placed inside a string or inside brackets. If string contain references to external parameters (substrings @samp{$0}, @samp{$1} ... @samp{$9}) or definitions (substrings @samp{$a}, @samp{$b} ... @samp{$z}) then before execution the values of parameter/definition will be substituted instead of reference. It allows to use the same MGL script for different parameters (filenames, paths, condition and so on). @@ -60,6 +60,13 @@ Command may have several set of possible arguments (for example, @code{plot ydat} and @code{plot xdat ydat}). All command arguments for a selected set must be specified. However, some arguments can have default values. These argument are printed in [], like @code{text ydat ['stl'='']} or @code{text x y 'txt' ['fnt'='' size=-1]}. At this, the record @code{[arg1 arg2 arg3 ...]} means @code{[arg1 [arg2 [arg3 ...]]]}, i.e. you can omit only tailing arguments if you agree with its default values. For example, @code{text x y 'txt' '' 1} or @code{text x y 'txt' ''} is correct, but @code{text x y 'txt' 1} is incorrect (argument @code{'fnt'} is missed). +You can provide several variants of arguments for a command by using @samp{?} symbol for separating them. The actual argument being used is set by @ref{variant}. At this, the last argument is used if the value of @ref{variant} is large than the number of provided variants. By default the first argument is used (i.e. as for @code{variant 0}). For example, the first plot will be drawn by blue (default is the first argument @samp{b}), but the plot after @code{variant 1} will be drawn by red dash (the second is @samp{r|}): +@verbatim +fplot 'x' 'b'?'r' +variant 1 +fplot 'x^3' 'b'?'r|' +@end verbatim + @c ------------------------------------------------------------------ @external{} @@ -181,6 +188,12 @@ Terminate execution. @end deftypefn +@cindex variant +@anchor{variant} +@deftypefn {MGL command} {} variant @code{val} +Set variant of argument(s) separated by @samp{?} symbol to be used in further commands. +@end deftypefn + @cindex rkstep @anchor{rkstep} @@ -434,6 +447,11 @@ Sends stop signal which terminate execution at next command. @end deftypefn +@deftypefn {Method on @code{mglParse}} @code{void} SetVariant (@code{int} var=@code{0}) +@deftypefnx {C function} @code{void} mgl_parser_variant (@code{HMPR} p, @code{int} var=@code{0}) +Sets variant of argument(s) separated by @samp{?} symbol to be used in further commands. +@end deftypefn + @deftypefn {Method on @code{mglParse}} @code{long} GetCmdNum () @deftypefnx {C function} @code{long} mgl_parser_cmd_num (@code{HMPR} p) diff -Nru mathgl-2.3.4/texinfo/parse_ru.texi mathgl-2.3.5.1/texinfo/parse_ru.texi --- mathgl-2.3.4/texinfo/parse_ru.texi 2016-02-13 19:03:44.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/parse_ru.texi 2016-06-19 17:06:30.000000000 +0000 @@ -61,6 +61,13 @@ Команды могут иметь несколько наборов аргументов (например, @code{plot ydat} и @code{plot xdat ydat}). Все аргументы команды для выбранного набора должны быть указаны, однако часть из них могут иметь значения по умолчанию. Такие аргументы в описании команд будут помещены в квадратные скобки [], например @code{plot ydat ['stl'='' zval=nan]}. При этом запись @code{[arg1 arg2 arg3 ...]} подразумевает @code{[arg1 [arg2 [arg3 ...]]]}, т.е. опускать можно только аргументы с конца, если вы согласны с их значениями по умолчанию. Например, @code{plot ydat '' 1} или @code{plot ydat ''} правильно, а @code{plot ydat 1} не правильно (аргумент @code{'stl'} пропущен). +Можно предоставить несколько вариантов аргументов комманд при использовании символа @samp{?} для их разделения. Конкретный вариант аргумента, используемый при выполнении команды, задается значением команды @ref{variant}. При этом будет использован последний вариант, если задано слишком большое значение. По умолчанию используется первый вариант (т.е. как при @code{variant 0}). Например в следующем коде будет сначала нарисован график синим цветом (первый аргумент @samp{b}), а затем красным пунктиром -- после @code{variant 1} будет использован второй аргумент @samp{r|}: +@verbatim +fplot 'x' 'b'?'r' +variant 1 +fplot 'x^3' 'b'?'r|' +@end verbatim + @c TODO Translate it! @@ -75,80 +82,80 @@ @cindex chdir @anchor{chdir} -@deftypefn {MGL command} {} chdir 'path' +@deftypefn {Команда MGL} {} chdir 'path' Переходит в папку @var{path}. @end deftypefn @cindex ask @anchor{ask} -@deftypefn {MGL command} {} ask $N 'question' +@deftypefn {Команда MGL} {} ask $N 'question' Задает @var{N}-ый аргумент скрипта равным ответу пользователя на вопрос @var{question}. Обычно команда показывает диалог с вопросом и полем ввода текста ответа. Здесь @var{N} это цифра (0...9) или буква (a...z). @end deftypefn @cindex define @anchor{define} -@deftypefn {MGL command} {} define $N smth +@deftypefn {Команда MGL} {} define $N smth Задает @var{N}-ый аргумент скрипта равным @var{smth}. Отмечу, что @var{smth} используется как есть (с символами @samp{'} если присутствуют). Выполняется только подстановка других макроопределений $0...$9, $a...$z. Здесь @var{N} это цифра (0...9) или буква (a...z). @end deftypefn -@deftypefn {MGL command} {} define name smth +@deftypefn {Команда MGL} {} define name smth Определяет константу (скаляр) с именем @code{name} и числовым значением @code{smth}. Позднее она может быть использована как обычное число. @end deftypefn @cindex defchr @anchor{defchr} -@deftypefn {MGL command} {} defchr $N smth +@deftypefn {Команда MGL} {} defchr $N smth Задает @var{N}-ый аргумент скрипта равным символу с UTF кодом @var{smth}. Здесь @var{N} это цифра (0...9) или буква (a...z). @end deftypefn @cindex defnum @anchor{defnum} -@deftypefn {MGL command} {} defnum $N smth +@deftypefn {Команда MGL} {} defnum $N smth Задает @var{N}-ый аргумент скрипта равным числовому значению @var{smth}. Здесь @var{N} это цифра (0...9) или буква (a...z). @end deftypefn @comment @cindex defpal @comment @anchor{defpal} -@comment @deftypefn {MGL command} {} defpal $N smth +@comment @deftypefn {Команда MGL} {} defpal $N smth @comment Задает @var{N}-ый аргумент скрипта равным символу палитры с индексом, найденным из @var{smth}. Здесь @var{N} это цифра (0...9) или буква (a...z). @comment @end deftypefn @cindex call @anchor{call} -@deftypefn {MGL command} {} call 'fname' [ARG1 ARG2 ... ARG9] +@deftypefn {Команда MGL} {} call 'fname' [ARG1 ARG2 ... ARG9] Переходит к выполнению (вызывает) подпрограммы @var{fname} (или внешнего скрипта, если функция не была найдена). Опциональные аргументы передаются в подпрограмму. См. также @ref{func}. @end deftypefn @cindex func @anchor{func} -@deftypefn {MGL command} {} func 'fname' [narg=0] +@deftypefn {Команда MGL} {} func 'fname' [narg=0] Определяет подпрограмму с именем @var{fname} и задает число требуемых аргументов. Аргументы будут помещены в параметры скрипта $1, $2, ... $9. Отмечу, что выполнение основной программы будет остановлено при встрече @code{func} -- действует аналогично комманде @ref{stop}. См. также @ref{return}. @end deftypefn @cindex return @anchor{return} -@deftypefn {MGL command} {} return +@deftypefn {Команда MGL} {} return Возвращается из подпрограммы. См. также @ref{func}. @end deftypefn @cindex load @anchor{load} -@deftypefn {MGL command} {} load 'filename' +@deftypefn {Команда MGL} {} load 'filename' Загружает дополнительные команды MGL из внешней динамической библиотеки @var{filename}. Данная библиотека должна содержать массив с именем @code{mgl_cmd_extra} типа @code{mglCommand}, который содержит описание новых комманд. @end deftypefn @cindex if @anchor{if} -@deftypefn {MGL command} {} if dat 'cond' +@deftypefn {Команда MGL} {} if dat 'cond' Начинает блок команд, выполняемый если каждый элемент @var{dat} удовлетворяет условию @var{cond}. @end deftypefn -@deftypefn {MGL command} {} if @code{val} +@deftypefn {Команда MGL} {} if @code{val} Начинает блок команд, выполняемый если @code{val} не ноль. @end deftypefn @cindex elseif @anchor{elseif} -@deftypefn {MGL command} {} elseif dat 'cond' +@deftypefn {Команда MGL} {} elseif dat 'cond' Начинает блок команд, выполняемый если предыдущий @code{if} или @code{elseif} не был выполнен и каждый элемент @var{dat} удовлетворяет условию @var{cond}. @end deftypefn -@deftypefn {MGL command} {} elseif @code{val} +@deftypefn {Команда MGL} {} elseif @code{val} Начинает блок команд, выполняемый если предыдущий @code{if} или @code{elseif} не был выполнен и @code{val} не ноль. @end deftypefn @cindex else @@ -164,7 +171,7 @@ @cindex for @anchor{for} -@deftypefn {MGL command} {} for $N @code{v1 v2 [dv=1]} +@deftypefn {Команда MGL} {} for $N @code{v1 v2 [dv=1]} Начинает блок команд, выполняемый в цикле с $@var{N}-ым аргументом изменяющимся от @var{v1} до @var{v2} с шагом @var{dv}. Здесь @var{N} это цифра (0...9) или буква (a...z). @end deftypefn @deftypefn {Команда MGL} {} for $N dat @@ -178,18 +185,27 @@ @cindex once @anchor{once} -@deftypefn {MGL command} {} once @code{val} +@deftypefn {Команда MGL} {} once @code{val} Определяет код (между @code{once on} и @code{once off}) который будет выполнен только один раз. Полезно для работы с большими данными в программах типа UDAV. @end deftypefn @cindex stop @anchor{stop} -@deftypefn {MGL command} {} stop +@deftypefn {Команда MGL} {} stop Останавливает выполнение скрипта. @end deftypefn + +@cindex variant +@anchor{variant} +@deftypefn {Команда MGL} {} variant @code{val} +Задает вариант аргумента(ов), разделенных символом @samp{?}, для всех последующих комманд. +@end deftypefn + + + @cindex rkstep @anchor{rkstep} -@deftypefn {MGL command} {} rkstep eq1;... var1;... [@code{dt=1}] +@deftypefn {Команда MGL} {} rkstep eq1;... var1;... [@code{dt=1}] Выполняет один шаг решения системы обыкновенных дифференциальных уравнений @{var1' = eq1, ... @} с временным шагом @var{dt}. Здесь переменные @samp{var1}, ... -- переменные, определенные в MGL скрипте ранее. При решении используется метод Рунге-Кутта 4-го порядка. @end deftypefn @@ -443,6 +459,11 @@ Посылает сигнал завершения выполнения для следующей команды. @end deftypefn +@deftypefn {Метод класса @code{mglParse}} @code{void} SetVariant (@code{int} var=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_parser_variant (@code{HMPR} p, @code{int} var=@code{0}) +Задает вариант аргумента(ов), разделенных символом @samp{?}, для всех последующих комманд. +@end deftypefn + @deftypefn {Метод класса @code{mglParse}} @code{long} GetCmdNum () @deftypefnx {Функция С} @code{long} mgl_parser_cmd_num (@code{HMPR} p) @@ -469,10 +490,10 @@ Возвращает описание команды MGL с именем @var{name}. @end deftypefn -@deftypefn {Method on @code{mglParse}} @code{void} RK_Step (@code{const char *}eqs, @code{const char *}vars, @code{mreal} dt=@code{1}) -@deftypefnx {Method on @code{mglParse}} @code{void} RK_Step (@code{const wchar_t *}eqs, @code{const wchar_t *}vars, @code{mreal} dt=@code{1}) -@deftypefnx {C function} @code{void} mgl_rk_step (@code{HMPR} p, @code{const char *}eqs, @code{const char *}vars, @code{mreal} dt) -@deftypefnx {C function} @code{void} mgl_rk_step_w (@code{HMPR} p, @code{const wchar_t *}eqs, @code{const wchar_t *}vars, @code{mreal} dt) +@deftypefn {Метод класса @code{mglParse}} @code{void} RK_Step (@code{const char *}eqs, @code{const char *}vars, @code{mreal} dt=@code{1}) +@deftypefnx {Метод класса @code{mglParse}} @code{void} RK_Step (@code{const wchar_t *}eqs, @code{const wchar_t *}vars, @code{mreal} dt=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_rk_step (@code{HMPR} p, @code{const char *}eqs, @code{const char *}vars, @code{mreal} dt) +@deftypefnx {Функция С} @code{void} mgl_rk_step_w (@code{HMPR} p, @code{const wchar_t *}eqs, @code{const wchar_t *}vars, @code{mreal} dt) Make one step for ordinary differential equation(s) @{var1' = eq1, ... @} with time-step @var{dt}. Here strings @var{eqs} and @var{vars} contain the equations and variable names separated by symbol @samp{;}. The variable(s) @samp{var1}, ... are the ones, defined in MGL script previously. The Runge-Kutta 4-th order method is used. @end deftypefn diff -Nru mathgl-2.3.4/texinfo/symbols_en.texi mathgl-2.3.5.1/texinfo/symbols_en.texi --- mathgl-2.3.4/texinfo/symbols_en.texi 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/symbols_en.texi 2016-06-19 17:06:39.000000000 +0000 @@ -70,6 +70,8 @@ one of mask for face filling (see @ref{Color scheme}); +set to start flow threads from 2d array inside data (see @ref{flow}); + operation in @ref{Textual formulas}. @item + @@ -112,14 +114,16 @@ stop color scheme parsing (see @ref{Color scheme}); -range operation in @ref{MGL scripts}. +range operation in @ref{MGL scripts}; + +separator of commands in @ref{MGL scripts}. @item ; line dashing style (see @ref{Line styles}); one of mask for face filling (see @ref{Color scheme}); -end of an option in @ref{MGL scripts} or in @ref{Command options}. +start of an option in @ref{MGL scripts} or in @ref{Command options}. @item < one of marks (see @ref{Line styles}); @@ -176,7 +180,9 @@ set to draw filled boxes for @ref{boxs}; -reduce text size inside a string (see @ref{Font styles}). +reduce text size inside a string (see @ref{Font styles}); + +operation in @ref{Textual formulas}. @item ^ one of marks (see @ref{Line styles}); diff -Nru mathgl-2.3.4/texinfo/symbols_ru.texi mathgl-2.3.5.1/texinfo/symbols_ru.texi --- mathgl-2.3.4/texinfo/symbols_ru.texi 2016-02-13 19:03:44.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/symbols_ru.texi 2016-06-19 17:06:30.000000000 +0000 @@ -70,6 +70,8 @@ one of mask for face filling (see @ref{Color scheme}); +set to start flow threads from 2d array inside data (see @ref{flow}); + operation in @ref{Textual formulas}. @item + @@ -112,14 +114,16 @@ stop color scheme parsing (see @ref{Color scheme}); -range operation in @ref{MGL scripts}. +range operation in @ref{MGL scripts}; + +separator of commands in @ref{MGL scripts}. @item ; line dashing style (see @ref{Line styles}); one of mask for face filling (see @ref{Color scheme}); -end of an option in @ref{MGL scripts} or in @ref{Command options}. +start of an option in @ref{MGL scripts} or in @ref{Command options}. @item < one of marks (see @ref{Line styles}); @@ -176,7 +180,9 @@ set to draw filled boxes for @ref{boxs}; -reduce text size inside a string (see @ref{Font styles}). +reduce text size inside a string (see @ref{Font styles}); + +operation in @ref{Textual formulas}. @item ^ one of marks (see @ref{Line styles}); diff -Nru mathgl-2.3.4/texinfo/version_hist.txt mathgl-2.3.5.1/texinfo/version_hist.txt --- mathgl-2.3.4/texinfo/version_hist.txt 2016-02-13 19:03:44.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/version_hist.txt 2016-06-19 17:06:30.000000000 +0000 @@ -1,3 +1,5 @@ +2.3.5.1 Released 30 May 2015 +2.3.5 Released 16 May 2015 2.3.4 Released 11 February 2015 2.3.3 Released 01 June 2015 2.3.2 Released 2 February 2015 diff -Nru mathgl-2.3.4/texinfo/version.texi.in mathgl-2.3.5.1/texinfo/version.texi.in --- mathgl-2.3.4/texinfo/version.texi.in 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/version.texi.in 2016-06-19 17:06:39.000000000 +0000 @@ -1,4 +1,4 @@ @set VERSION ${MathGL_VERSION_MAJOR}.${MathGL_VERSION_MINOR} @set MINVER -@c @set MINVER .1 +@set MINVER .1 @set NIGHT ${MGL_NIGHT} diff -Nru mathgl-2.3.4/texinfo/web_en.texi mathgl-2.3.5.1/texinfo/web_en.texi --- mathgl-2.3.4/texinfo/web_en.texi 2016-02-13 19:03:44.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/web_en.texi 2016-06-19 17:06:30.000000000 +0000 @@ -52,8 +52,12 @@ @strong{Latest news} @itemize -@item @emph{13 February 2016.} -New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes, which denoted @ref{News, here}. + +@item @strong{20 June 2016.} +New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes and bugfixes. @strong{NOTE}: there is incompatible change -- the library libmgl-qt is removed. You need to use libmgl-qt4 or libmgl-qt5 explicitly to reduce the possible error of wrong Qt libs linking. + +@item @emph{16 May 2016.} +New version (v.2.3.5) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes, which denoted @ref{News, here}. @item @emph{7 August 2014.} New version (v.2.3) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are many major improvements for both MathGL core and for UDAV, which denoted @ref{News, here}. @end itemize @@ -75,6 +79,123 @@ @itemize +@item @strong{20 June 2016.} +New version (v.2.3.5.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes and bugfixes. @strong{INCOMPATIBLE}: the library libmgl-qt is removed. You need to use libmgl-qt4 or libmgl-qt5 explicitly to reduce the possible error of wrong Qt libs linking. + +@item @strong{16 May 2016.} +New version (v.2.3.5) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes: +@itemize @bullet +@item Update @ref{LaTeX package} (thanks to Diego Sejas Viscarra) + +@itemize @bullet +@item +@code{\MGL@@codes}: Bugfix: category code for tabulators is changed too +@item +@code{\MGL@@quality}: 9 is accepted as quality value now +@item +@code{\MGL@@scale}: Now accepts any positive value +@item +@code{\MGL@@test@@switch}: New command to verify and validate switching arguments +@item +@code{\mglTeX}: Add a small negative space in the logo, between the "mgl" and "TEX" +@item +@code{\mglTeX}: Declared now as robust command +@item +@code{\mglcomments}: Now accepts arguments 0 (equivalent to @code{off}) and 1 (equivalent to @code{on}), besides the usual @code{off} and @code{on} +@item +@code{\mglgraphics}: New command options: @code{gray, mglscale, quality, variant} +@item +@code{\mglname}: Now writes the MGL code line @samp{setsize 600 400} to the main script +@item +@code{\mglplot}: Added @code{\bgroup} and @code{\egroup} in order to keep changes private +@item +New command options: @code{gray, mglscale, quality, variant} +@item +@code{\mglsettings}: Added options @code{gray} and @code{variant} +@item +Now calls the @code{\mglswitch} and @code{\mglcomments} commands for the switch and comments options, respectively +@item +@code{\mglswitch}: Now accepts arguments 0 (equivalent to @code{off}) and 1 (equivalent to @code{on}), besides the usual @code{off} and @code{on} +@item +mglTeX now depends on the ifpdf package +@item +Change definition of @code{\mglcommentname} from MGL comment to mglTEX comment +@item +Introduce the concept of global, local and private settings in the documentation +@item +New commands: @code{\mglgray} (to activate/deactivate) gray-scale mode locally, and @code{\mglvariant} (to set variant of arguments in MGL scripts locally) +@item +New package option @code{9q} for setting quality to 9 (for testing purposes of the author) +@item +New package options @code{0v, 1v, 2v} to select variant of arguments in MGL scripts +@item +New package options @code{gray, color} to activate/deactivate gray-scale mode for graphics +@item +Remove the @code{\MGL@@setkeys} command, since it isn’t needed as first thought +@item +Rename @code{\MGL@@document@@scripts} to @code{\MGL@@doc@@scripts} +@item +Rename @code{\MGL@@script@@name} to @code{\MGL@@script} +@item +Rename command @code{\MGL@@graph@@ext} to @code{\MGL@@imgext} +@item +Rename command @code{\mglcommonscriptname} to @code{\mglsetupscriptname} +@item +Rename environment @code{mglcommon} to @code{mglsetupscript} (@code{mglcommon} is still available, but deprecated) +@item +Rename family @code{MGL@@keys} as @code{MGL@@gr@@keys} for consistency +@item +Reorganize and update documentation +@item +Some minor bugfixes +@item +The MGL code line @samp{setsize 600 400} is now automatically written to the main script in order for the scaling options and commands to work +@item +@code{mgl}: New environment options: gray, mglscale, quality, variant +@item +@code{\mglcode}: New environment options: gray, mglscale, quality, variant +@end itemize + +@item +Add MGL command @ref{variant} to select proper variant of arguments (like @samp{var1?var2?var3?...}) in MGL commands. +@item +Remove limitation of maximal number (was 1000) of arguments for MGL commands. This is actual for 'list' command. +@item +Add mglWnd::Widget() for accessing widget which is used for drawing. +@item +Add @ref{gray} for producing gray-scaled image. +@item +Add MGL command @ref{setsizescl} for scaling all further @ref{setsize}. +@item +Add @ref{shear} for shearing plot. +@item +Add @ref{shearplot} for placing plots side-by-side with some shearing. +@item +Add @ref{limit} for limit maximal absolute value of data. +@item +Add @ref{tridmat} for tridiagonal matrix algorithm. +@item +Add MGL command @ref{diffract} for single step diffraction calculation. +@item +Add @ref{ifsfile} for reading IFS fractal parameters from *.ifs file. +@item +Add style @samp{*} for 2d versions of @ref{flow} to draw threads from points inside axis range. +@item +Add @samp{norm()} to the list of known functions +@item +Compatibility changes for MS VisualStudio, MacOS, Win64. +@item +Bugfix for legend export into EPS and SVG. +@item +Bugfix for importing data from std::vector. +@item +Improve Surf3*() drawing. +@item +Force NAN if divided by 0 in formulas. +@item +Option "-S" of mglconv now perform scaling in any cases +@end itemize + @item @strong{13 February 2016.} New version (v.2.3.4) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes: @itemize @bullet diff -Nru mathgl-2.3.4/texinfo/web_ru.texi mathgl-2.3.5.1/texinfo/web_ru.texi --- mathgl-2.3.4/texinfo/web_ru.texi 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/web_ru.texi 2016-06-19 17:06:39.000000000 +0000 @@ -52,8 +52,10 @@ @strong{Latest news} @itemize -@item @emph{13 February 2016.} -New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes, which denoted @ref{News, here}. +@item @strong{20 June 2016.} +New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes and bugfixes. @strong{NOTE}: there is incompatible change -- the library libmgl-qt is removed. You need to use libmgl-qt4 or libmgl-qt5 explicitly to reduce the possible error of wrong Qt libs linking. +@item @emph{16 May 2016.} +New version (v.2.3.5) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes, which denoted @ref{News, here}. @item @emph{7 August 2014.} New version (v.2.3) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are many major improvements for both MathGL core and for UDAV, which denoted @ref{News, here}. @end itemize @@ -75,6 +77,123 @@ @itemize +@item @strong{20 June 2016.} +New version (v.2.3.5.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes and bugfixes. @strong{INCOMPATIBLE}: the library libmgl-qt is removed. You need to use libmgl-qt4 or libmgl-qt5 explicitly to reduce the possible error of wrong Qt libs linking. + +@item @strong{16 May 2016.} +New version (v.2.3.5) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes: +@itemize @bullet +@item Update @ref{LaTeX package} (thanks to Diego Sejas Viscarra) + +@itemize @bullet +@item +@code{\MGL@@codes}: Bugfix: category code for tabulators is changed too +@item +@code{\MGL@@quality}: 9 is accepted as quality value now +@item +@code{\MGL@@scale}: Now accepts any positive value +@item +@code{\MGL@@test@@switch}: New command to verify and validate switching arguments +@item +@code{\mglTeX}: Add a small negative space in the logo, between the "mgl" and "TEX" +@item +@code{\mglTeX}: Declared now as robust command +@item +@code{\mglcomments}: Now accepts arguments 0 (equivalent to @code{off}) and 1 (equivalent to @code{on}), besides the usual @code{off} and @code{on} +@item +@code{\mglgraphics}: New command options: @code{gray, mglscale, quality, variant} +@item +@code{\mglname}: Now writes the MGL code line @samp{setsize 600 400} to the main script +@item +@code{\mglplot}: Added @code{\bgroup} and @code{\egroup} in order to keep changes private +@item +New command options: @code{gray, mglscale, quality, variant} +@item +@code{\mglsettings}: Added options @code{gray} and @code{variant} +@item +Now calls the @code{\mglswitch} and @code{\mglcomments} commands for the switch and comments options, respectively +@item +@code{\mglswitch}: Now accepts arguments 0 (equivalent to @code{off}) and 1 (equivalent to @code{on}), besides the usual @code{off} and @code{on} +@item +mglTeX now depends on the ifpdf package +@item +Change definition of @code{\mglcommentname} from MGL comment to mglTEX comment +@item +Introduce the concept of global, local and private settings in the documentation +@item +New commands: @code{\mglgray} (to activate/deactivate) gray-scale mode locally, and @code{\mglvariant} (to set variant of arguments in MGL scripts locally) +@item +New package option @code{9q} for setting quality to 9 (for testing purposes of the author) +@item +New package options @code{0v, 1v, 2v} to select variant of arguments in MGL scripts +@item +New package options @code{gray, color} to activate/deactivate gray-scale mode for graphics +@item +Remove the @code{\MGL@@setkeys} command, since it isn’t needed as first thought +@item +Rename @code{\MGL@@document@@scripts} to @code{\MGL@@doc@@scripts} +@item +Rename @code{\MGL@@script@@name} to @code{\MGL@@script} +@item +Rename command @code{\MGL@@graph@@ext} to @code{\MGL@@imgext} +@item +Rename command @code{\mglcommonscriptname} to @code{\mglsetupscriptname} +@item +Rename environment @code{mglcommon} to @code{mglsetupscript} (@code{mglcommon} is still available, but deprecated) +@item +Rename family @code{MGL@@keys} as @code{MGL@@gr@@keys} for consistency +@item +Reorganize and update documentation +@item +Some minor bugfixes +@item +The MGL code line @samp{setsize 600 400} is now automatically written to the main script in order for the scaling options and commands to work +@item +@code{mgl}: New environment options: gray, mglscale, quality, variant +@item +@code{\mglcode}: New environment options: gray, mglscale, quality, variant +@end itemize + +@item +Add MGL command @ref{variant} to select proper variant of arguments (like @samp{var1?var2?var3?...}) in MGL commands. +@item +Remove limitation of maximal number (was 1000) of arguments for MGL commands. This is actual for 'list' command. +@item +Add mglWnd::Widget() for accessing widget which is used for drawing. +@item +Add @ref{gray} for producing gray-scaled image. +@item +Add MGL command @ref{setsizescl} for scaling all further @ref{setsize}. +@item +Add @ref{shear} for shearing plot. +@item +Add @ref{shearplot} for placing plots side-by-side with some shearing. +@item +Add @ref{limit} for limit maximal absolute value of data. +@item +Add @ref{tridmat} for tridiagonal matrix algorithm. +@item +Add MGL command @ref{diffract} for single step diffraction calculation. +@item +Add @ref{ifsfile} for reading IFS fractal parameters from *.ifs file. +@item +Add style @samp{*} for 2d versions of @ref{flow} to draw threads from points inside axis range. +@item +Add @samp{norm()} to the list of known functions +@item +Compatibility changes for MS VisualStudio, MacOS, Win64. +@item +Bugfix for legend export into EPS and SVG. +@item +Bugfix for importing data from std::vector. +@item +Improve Surf3*() drawing. +@item +Force NAN if divided by 0 in formulas. +@item +Option "-S" of mglconv now perform scaling in any cases +@end itemize + @item @strong{13 February 2016.} New version (v.2.3.4) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new functions, plot types and styles, improvement in MGL scripts and in mgltex, some speeding up and bugfixes: @itemize @bullet diff -Nru mathgl-2.3.4/texinfo/widget_en.texi mathgl-2.3.5.1/texinfo/widget_en.texi --- mathgl-2.3.4/texinfo/widget_en.texi 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/widget_en.texi 2016-06-19 17:06:39.000000000 +0000 @@ -176,6 +176,12 @@ Gets last position of mouse click. @end deftypefn +@deftypefn {Method on @code{mglWnd}} @code{void *} Widget () +@deftypefnx {C function} @code{void *} mgl_fltk_widget (@code{HMGL} gr) +@deftypefnx {C function} @code{void *} mgl_qt_widget (@code{HMGL} gr) +Return pointer to widget (@ref{Fl_MathGL class} or @ref{QMathGL class}) used for plotting. +@end deftypefn + @c ------------------------------------------------------------------ @external{} diff -Nru mathgl-2.3.4/texinfo/widget_ru.texi mathgl-2.3.5.1/texinfo/widget_ru.texi --- mathgl-2.3.4/texinfo/widget_ru.texi 2016-02-13 19:03:50.000000000 +0000 +++ mathgl-2.3.5.1/texinfo/widget_ru.texi 2016-06-19 17:06:39.000000000 +0000 @@ -177,6 +177,12 @@ Возвращает положение щелчка мыши. @end deftypefn +@deftypefn {Method on @code{mglWnd}} @code{void *} Widget () +@deftypefnx {C function} @code{void *} mgl_fltk_widget (@code{HMGL} gr) +@deftypefnx {C function} @code{void *} mgl_qt_widget (@code{HMGL} gr) +Возвращает указатель на виджет (@ref{Fl_MathGL class} or @ref{QMathGL class}), используемый для рисования. +@end deftypefn + @c ------------------------------------------------------------------ @external{} @node mglDraw class, Fl_MathGL class, mglWnd class, Widget classes diff -Nru mathgl-2.3.4/todo.txt mathgl-2.3.5.1/todo.txt --- mathgl-2.3.4/todo.txt 2016-02-13 19:01:07.000000000 +0000 +++ mathgl-2.3.5.1/todo.txt 2016-06-19 17:01:14.000000000 +0000 @@ -47,19 +47,23 @@ 11. Iris plot -- https://en.wikipedia.org/wiki/Iris_flower_data_set 12. Parallel drawing in QMathGL. +17. Speed up QMathGL + option to whole redraw instead of view + ZZ. Update *.i for new functions {before release!!!} ============= DOCUMENTATION ============= -A. Paper about MathGL!!! 6099610006 +A. Paper about MathGL!!! B. Add chapter with real samples C. Translate to Russian everything D. Docs about JS interface -6. Update Qt and UDAV figures - -YY. Sample like http://pyxplot.org.uk/examples/05ap/02hlines/index.html using Stem() +1. Update Qt and UDAV figures +2. Sample about PDE -- add 'tridmat' + 'diffract' +3. Replace mgl-qt!!! +4. Step_xy() now can have x.nx>y.nx -- same as Bars() +5. Docs about 'flame2d' ============= UDAV ============= diff -Nru mathgl-2.3.4/udav/anim_dlg.h mathgl-2.3.5.1/udav/anim_dlg.h --- mathgl-2.3.4/udav/anim_dlg.h 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/anim_dlg.h 2016-06-19 17:05:50.000000000 +0000 @@ -21,6 +21,9 @@ #define ANIMPARAM_H //----------------------------------------------------------------------------- #include +#if defined(_MSC_VER) +#include +#endif //----------------------------------------------------------------------------- class QLineEdit; class QTextEdit; diff -Nru mathgl-2.3.4/udav/CMakeLists.txt mathgl-2.3.5.1/udav/CMakeLists.txt --- mathgl-2.3.4/udav/CMakeLists.txt 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/CMakeLists.txt 2016-06-19 17:05:50.000000000 +0000 @@ -18,16 +18,6 @@ set(udav_src ${udav_src} udav.rc) endif(WIN32) -if(MGL_HAVE_HDF5) -# target_link_libraries(mgl ${HDF5_LIBRARIES}) - include_directories(${HDF5_INCLUDE_DIR}) -endif(MGL_HAVE_HDF5) - -if(MGL_HAVE_GSL) -# target_link_libraries(mgl ${GSL_LIB} ${GSL_CBLAS_LIB} ) - include_directories(${GSL_INCLUDE_DIR}) -endif(MGL_HAVE_GSL) - if(enable-qt5) include(../cmake-qt5.txt) qt5_add_resources(udav_rc_src ${udav_rc} ) @@ -38,11 +28,9 @@ add_executable(udav ${udav_src} ${udav_moc_hdr} ${udav_rc_src}) #set_target_properties(udav PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -pthread") if(enable-qt5) - target_link_libraries(udav mgl-qt5) - qt5_use_modules(udav ${MGL_QT5_LIBS}) + target_link_libraries(udav mgl-qt5 ${MGL_QT5_LIBS}) else(enable-qt5) - target_link_libraries(udav mgl-qt4) - qt4_use_modules(udav ${MGL_QT4_LIBS}) + target_link_libraries(udav mgl-qt4 ${MGL_QT4_LIBS}) endif(enable-qt5) if(MGL_HAVE_PTHREAD) diff -Nru mathgl-2.3.4/udav/data_dlg.cpp mathgl-2.3.5.1/udav/data_dlg.cpp --- mathgl-2.3.4/udav/data_dlg.cpp 2016-02-13 19:03:19.000000000 +0000 +++ mathgl-2.3.5.1/udav/data_dlg.cpp 2016-06-19 17:05:48.000000000 +0000 @@ -132,7 +132,7 @@ for(i=0;iaddItem(QString::fromStdWString(v->s)); + if(v) name->addItem(QString::fromWCharArray(v->s.c_str())); } } //----------------------------------------------------------------------------- diff -Nru mathgl-2.3.4/udav/dat_pnl.cpp mathgl-2.3.5.1/udav/dat_pnl.cpp --- mathgl-2.3.4/udav/dat_pnl.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/dat_pnl.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -145,7 +145,7 @@ nx = ny = nz = kz = 0; if(v) { - QString s = QString::fromStdWString(v->s); + QString s = QString::fromWCharArray(v->s.c_str()); v->o = this; v->func = deleteDat; refresh(); setWindowTitle(s + tr(" - UDAV variable")); @@ -211,7 +211,7 @@ if(s=="nan") f=NAN; else if(s=="inf") f=INFINITY; else if(s=="-inf") f=-INFINITY; - else g = mgl_str2dual(s.toStdString().c_str()); //f = s.toDouble(); + else g = mgl_str2dual(s.toLocal8Bit().constData()); //f = s.toDouble(); f = real(g); mglDataC *cc = dynamic_cast(var); if(cc) @@ -251,15 +251,15 @@ { bool ok; QString s = QInputDialog::getText(this, tr("UDAV - Export to PNG"), tr("Enter color scheme for picture"), QLineEdit::Normal, MGL_DEF_SCH, &ok); - if(ok) var->Export(fn.toStdString().c_str(), s.toStdString().c_str()); + if(ok) var->Export(fn.toLocal8Bit().constData(), s.toLocal8Bit().constData()); } else if(ext=="h5" || ext=="hdf") { bool ok; - QString s = QInputDialog::getText(this, tr("UDAV - Save to HDF"), tr("Enter data name"), QLineEdit::Normal, QString::fromStdWString(var->s), &ok); - if(ok) var->SaveHDF(fn.toStdString().c_str(), s.toStdString().c_str()); + QString s = QInputDialog::getText(this, tr("UDAV - Save to HDF"), tr("Enter data name"), QLineEdit::Normal, QString::fromWCharArray(var->s.c_str()), &ok); + if(ok) var->SaveHDF(fn.toLocal8Bit().constData(), s.toLocal8Bit().constData()); } - else var->Save(fn.toStdString().c_str()); + else var->Save(fn.toLocal8Bit().constData()); } //----------------------------------------------------------------------------- void DatPanel::load() @@ -273,15 +273,15 @@ { bool ok; QString s = QInputDialog::getText(this, tr("UDAV - Import PNG"), tr("Enter color scheme for picture"), QLineEdit::Normal, MGL_DEF_SCH, &ok); - if(ok) d->Import(fn.toStdString().c_str(), s.toStdString().c_str()); + if(ok) d->Import(fn.toLocal8Bit().constData(), s.toLocal8Bit().constData()); } else if(ext=="h5" || ext=="hdf") { bool ok; - QString s = QInputDialog::getText(this, tr("UDAV - Read from HDF"), tr("Enter data name"), QLineEdit::Normal, QString::fromStdWString(var->s), &ok); - if(ok) d->ReadHDF(fn.toStdString().c_str(), s.toStdString().c_str()); + QString s = QInputDialog::getText(this, tr("UDAV - Read from HDF"), tr("Enter data name"), QLineEdit::Normal, QString::fromWCharArray(var->s.c_str()), &ok); + if(ok) d->ReadHDF(fn.toLocal8Bit().constData(), s.toLocal8Bit().constData()); } - else d->Read(fn.toStdString().c_str()); + else d->Read(fn.toLocal8Bit().constData()); refresh(); } //----------------------------------------------------------------------------- @@ -465,7 +465,7 @@ bool res = d->exec(); if(res && !v1->text().isEmpty() && !v2->text().isEmpty() && !id->text().isEmpty()) { - mglData *vv = dynamic_cast(parser.AddVar(id->text().toStdString().c_str())); + mglData *vv = dynamic_cast(parser.AddVar(id->text().toLocal8Bit().constData())); if(vv) vv->Set(mgl_data_hist(var, nm->value(), v1->text().toDouble(), v2->text().toDouble(),0)); updateDataItems(); } @@ -558,7 +558,7 @@ bool res = d->exec(); QString val = f1->text(), mgl; int k = c->currentIndex(); - QString self = QString::fromStdWString(var->s); + QString self = QString::fromWCharArray(var->s.c_str()); if(res) { if(k<0) @@ -594,7 +594,7 @@ if(!mgl.isEmpty()) { mglGraph gr; - parser.Execute(&gr,mgl.toStdString().c_str()); + parser.Execute(&gr,mgl.toLocal8Bit().constData()); if(k>=6) opers += mgl+"\n"; updateDataItems(); } @@ -635,7 +635,7 @@ bool res = d->exec(); QString val = f1->text(), mgl; int k = c->currentIndex(); - QString self = QString::fromStdWString(var->s); + QString self = QString::fromWCharArray(var->s.c_str()); if(res) { if(k<0) @@ -665,7 +665,7 @@ if(!mgl.isEmpty()) { mglGraph gr; - parser.Execute(&gr,mgl.toStdString().c_str()); + parser.Execute(&gr,mgl.toLocal8Bit().constData()); opers += mgl+"\n"; updateDataItems(); } @@ -836,5 +836,5 @@ bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); } //----------------------------------------------------------------------------- -QString DatPanel::dataName() { return QString::fromStdWString(var->s); } +QString DatPanel::dataName() { return QString::fromWCharArray(var->s.c_str()); } //----------------------------------------------------------------------------- diff -Nru mathgl-2.3.4/udav/files_dlg.h mathgl-2.3.5.1/udav/files_dlg.h --- mathgl-2.3.4/udav/files_dlg.h 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/files_dlg.h 2016-06-19 17:05:50.000000000 +0000 @@ -21,6 +21,9 @@ #define FILES_DLG_H //----------------------------------------------------------------------------- #include +#if defined(_MSC_VER) +#include +#endif class QLineEdit; class QComboBox; class QRadioButton; diff -Nru mathgl-2.3.4/udav/find_dlg.h mathgl-2.3.5.1/udav/find_dlg.h --- mathgl-2.3.4/udav/find_dlg.h 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/find_dlg.h 2016-06-19 17:05:50.000000000 +0000 @@ -24,6 +24,9 @@ class QCheckBox; class QLineEdit; class QPushButton; +#if defined(_MSC_VER) +#include +#endif //----------------------------------------------------------------------------- /// Dialog for finding something in text class FindDialog : public QDialog diff -Nru mathgl-2.3.4/udav/help_pnl.h mathgl-2.3.5.1/udav/help_pnl.h --- mathgl-2.3.4/udav/help_pnl.h 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/help_pnl.h 2016-06-19 17:05:50.000000000 +0000 @@ -21,6 +21,9 @@ #define HELP_PNL_H //----------------------------------------------------------------------------- #include +#if defined(_MSC_VER) +#include +#endif class QTextBrowser; class QLineEdit; //----------------------------------------------------------------------------- diff -Nru mathgl-2.3.4/udav/hint_dlg.cpp mathgl-2.3.5.1/udav/hint_dlg.cpp --- mathgl-2.3.4/udav/hint_dlg.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/hint_dlg.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -24,37 +24,33 @@ #include "hint_dlg.h" #include "mgl2/data_cf.h" //----------------------------------------------------------------------------- -#define qtr HintDialog::tr -QString hints[] = { - qtr("You can shift axis range by pressing middle button and moving mouse. Also, you can zoom in/out axis range by using mouse wheel."), - qtr("You can rotate/shift/zoom whole plot by mouse. Just press 'Rotate' toolbutton, click image and hold a mouse button: left button for rotation, right button for zoom/perspective, middle button for shift."), - qtr("You may quickly draw the data from file. Just use: udav 'filename.dat' in command line."), - qtr("You can copy the current image to clipboard by pressing Ctrl-Shift-C. Later you can paste it directly into yours document or presentation."), - qtr("You can export image into a set of format (EPS, SVG, PNG, JPEG) by pressing right mouse button inside image and selecting 'Export as ...'."), - qtr("You can setup colors for script highlighting in Property dialog. Just select menu item 'Settings/Properties'."), - qtr("You can save the parameter of animation inside MGL script by using comment started from '##a ' or '##c ' for loops."), - qtr("New drawing never clears things drawn already. For example, you can make a surface with contour lines by calling commands 'surf' and 'cont' one after another (in any order). "), - qtr("You can put several plots in the same image by help of commands 'subplot' or 'inplot'."), - qtr("All indexes (of data arrays, subplots and so on) are always start from 0."), - qtr("You can edit MGL file in any text editor. Also you can run it in console by help of commands: mglconv, mglview."), - qtr("You can use command 'once on|off' for marking the block which should be executed only once. For example, this can be the block of large data reading/creating/handling. Press F9 (or menu item 'Graphics/Reload') to re-execute this block."), - qtr("You can use command 'stop' for terminating script parsing. It is useful if you don't want to execute a part of script."), - qtr("You can type arbitrary expression as input argument for data or number. In last case (for numbers), the first value of data array is used."), - qtr("There is powerful calculator with a lot of special functions. You can use buttons or keyboard to type the expression. Also you can use existed variables in the expression."), - qtr("The calculator can help you to put complex expression in the script. Just type the expression (which may depend on coordinates x,y,z and so on) and put it into the script."), - qtr("You can easily insert file or folder names, last fitted formula or numerical value of selection by using menu Edit|Insert."), - qtr("The special dialog (Edit|Insert|New Command) help you select the command, fill its arguments and put it into the script."), - qtr("You can put several plotting commands in the same line or in separate function, for highlighting all of them simultaneously."), - qtr("") -}; -//----------------------------------------------------------------------------- // // Hint dialog // //----------------------------------------------------------------------------- HintDialog::HintDialog(QWidget *parent) : QDialog(parent) { - for(numHints=0;!hints[numHints].isEmpty();numHints++); + hints.append(tr("You can shift axis range by pressing middle button and moving mouse. Also, you can zoom in/out axis range by using mouse wheel.")); + hints.append(tr("You can rotate/shift/zoom whole plot by mouse. Just press 'Rotate' toolbutton, click image and hold a mouse button: left button for rotation, right button for zoom/perspective, middle button for shift.")); + hints.append(tr("You may quickly draw the data from file. Just use: udav 'filename.dat' in command line.")); + hints.append(tr("You can copy the current image to clipboard by pressing Ctrl-Shift-C. Later you can paste it directly into yours document or presentation.")); + hints.append(tr("You can export image into a set of format (EPS, SVG, PNG, JPEG) by pressing right mouse button inside image and selecting 'Export as ...'.")); + hints.append(tr("You can setup colors for script highlighting in Property dialog. Just select menu item 'Settings/Properties'.")); + hints.append(tr("You can save the parameter of animation inside MGL script by using comment started from '##a ' or '##c ' for loops.")); + hints.append(tr("New drawing never clears things drawn already. For example, you can make a surface with contour lines by calling commands 'surf' and 'cont' one after another (in any order). ")); + hints.append(tr("You can put several plots in the same image by help of commands 'subplot' or 'inplot'.")); + hints.append(tr("All indexes (of data arrays, subplots and so on) are always start from 0.")); + hints.append(tr("You can edit MGL file in any text editor. Also you can run it in console by help of commands: mglconv, mglview.")); + hints.append(tr("You can use command 'once on|off' for marking the block which should be executed only once. For example, this can be the block of large data reading/creating/handling. Press F9 (or menu item 'Graphics/Reload') to re-execute this block.")); + hints.append(tr("You can use command 'stop' for terminating script parsing. It is useful if you don't want to execute a part of script.")); + hints.append(tr("You can type arbitrary expression as input argument for data or number. In last case (for numbers), the first value of data array is used.")); + hints.append(tr("There is powerful calculator with a lot of special functions. You can use buttons or keyboard to type the expression. Also you can use existed variables in the expression.")); + hints.append(tr("The calculator can help you to put complex expression in the script. Just type the expression (which may depend on coordinates x,y,z and so on) and put it into the script.")); + hints.append(tr("You can easily insert file or folder names, last fitted formula or numerical value of selection by using menu Edit|Insert.")); + hints.append(tr("The special dialog (Edit|Insert|New Command) help you select the command, fill its arguments and put it into the script.")); + hints.append(tr("You can put several plotting commands in the same line or in separate function, for highlighting all of them simultaneously.")); + + numHints=hints.size(); cur = int(mgl_rnd()*numHints); setWindowTitle(tr("UDAV - Hint")); QHBoxLayout *a; diff -Nru mathgl-2.3.4/udav/hint_dlg.h mathgl-2.3.5.1/udav/hint_dlg.h --- mathgl-2.3.4/udav/hint_dlg.h 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/hint_dlg.h 2016-06-19 17:05:50.000000000 +0000 @@ -23,7 +23,6 @@ #include #include class QCheckBox; -extern QString hints[]; //----------------------------------------------------------------------------- /// Dialog for showing hints class HintDialog : public QDialog @@ -42,6 +41,7 @@ private: int cur; int numHints; + QVector hints; QTextEdit *text; QCheckBox *start; }; diff -Nru mathgl-2.3.4/udav/info_dlg.cpp mathgl-2.3.5.1/udav/info_dlg.cpp --- mathgl-2.3.4/udav/info_dlg.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/info_dlg.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -63,7 +63,7 @@ { if(!var || (!force && (!allowRefresh || !isVisible()))) return; QString text, name, sub; - name = QString::fromStdWString(var->s); + name = QString::fromWCharArray(var->s.c_str()); sub = "(:,:,"+QString::number(kz)+")\n"; int i = kind->currentIndex(); if(i<1) text = "yrange "+name+"\nplot "+name + sub; diff -Nru mathgl-2.3.4/udav/mem_pnl.cpp mathgl-2.3.5.1/udav/mem_pnl.cpp --- mathgl-2.3.4/udav/mem_pnl.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/mem_pnl.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -83,7 +83,7 @@ QString name = QInputDialog::getText(this, tr("UDAV - New variable"), tr("Enter name for new variable"), QLineEdit::Normal, "", &ok); if(!ok || name.isEmpty()) return; - mglDataA *v = parser.AddVar(name.toStdString().c_str()); + mglDataA *v = parser.AddVar(name.toLocal8Bit().constData()); QWidget *t; if(v->o) t = (QWidget *)v->o; else t = newDataWnd(infoDlg,wnd,v); @@ -96,7 +96,7 @@ if(tab->rowCount()<1) return; if(n<0) n = tab->currentRow(); if(n<0) n = 0; - mglDataA *v = parser.FindVar(tab->item(n,0)->text().toStdString().c_str()); + mglDataA *v = parser.FindVar(tab->item(n,0)->text().toLocal8Bit().constData()); if(!v) return; QWidget *t; if(v->o) t = (QWidget *)v->o; @@ -109,9 +109,9 @@ if(tab->rowCount()<1) return; int n = tab->currentRow(); if(n<0) n = 0; - mglDataA *v = parser.FindVar(tab->item(n,0)->text().toStdString().c_str()); + mglDataA *v = parser.FindVar(tab->item(n,0)->text().toLocal8Bit().constData()); if(!v && v->o) ((QWidget *)v->o)->close(); - parser.DeleteVar(tab->item(n,0)->text().toStdString().c_str()); + parser.DeleteVar(tab->item(n,0)->text().toLocal8Bit().constData()); refresh(); } //----------------------------------------------------------------------------- @@ -128,10 +128,10 @@ if(tab->rowCount()<1) return; int n = tab->currentRow(); if(n<0) n = 0; - mglDataA *v = parser.FindVar(tab->item(n,0)->text().toStdString().c_str()); + mglDataA *v = parser.FindVar(tab->item(n,0)->text().toLocal8Bit().constData()); if(!v) return; infoDlg->setVar(v); - QString s = QString::fromStdWString(v->s); + QString s = QString::fromWCharArray(v->s.c_str()); infoDlg->setWindowTitle(s + tr(" - UDAV preview")); infoDlg->refresh(); infoDlg->show(); @@ -149,7 +149,7 @@ { mglDataA *v = parser.GetVar(i); if(!v) continue; - s = QString::fromStdWString(v->s); + s = QString::fromWCharArray(v->s.c_str()); it = new QTableWidgetItem(s); tab->setItem(m,0,it); it->setFlags(flags); s.sprintf("%ld * %ld * %ld", v->GetNx(), v->GetNy(), v->GetNz()); diff -Nru mathgl-2.3.4/udav/newcmd_dlg.cpp mathgl-2.3.5.1/udav/newcmd_dlg.cpp --- mathgl-2.3.4/udav/newcmd_dlg.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/newcmd_dlg.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -248,10 +248,12 @@ // clear old kind->clear(); kinds.clear(); for(k=0;ksetText(QString::fromLocal8Bit(parser.CmdDesc(n.toStdString().c_str()))); + QByteArray qcmd = n.toLatin1(); + const char *cmd = qcmd.constData(); + if(!parser.CmdType(cmd)) return; + info->setText(parser.CmdDesc(cmd)); - par = QString::fromLocal8Bit(parser.CmdFormat(n.toStdString().c_str())); + par = parser.CmdFormat(cmd); int i0 = par.indexOf(' '); // first space if present if(i0<0) { kind->addItem(par); return; } // no arguments // parse kind of arguments diff -Nru mathgl-2.3.4/udav/open_dlg.cpp mathgl-2.3.5.1/udav/open_dlg.cpp --- mathgl-2.3.4/udav/open_dlg.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/open_dlg.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -116,29 +116,29 @@ // prepare unique value of name for next time char buf[32]; snprintf(buf,32,"mgl_%d",numDataOpened); buf[31]=0; name->setText(buf); - mglData *v = dynamic_cast(parser.AddVar(data.toStdString().c_str())); + mglData *v = dynamic_cast(parser.AddVar(data.toLocal8Bit().constData())); if(!v) return; int dd=0; if(rA->isChecked()) // auto sizes { - setlocale(LC_NUMERIC, "C"); v->Read(file.toStdString().c_str()); setlocale(LC_NUMERIC, ""); + setlocale(LC_NUMERIC, "C"); v->Read(file.toLocal8Bit().constData()); setlocale(LC_NUMERIC, ""); if(v->nx==1) { v->nx = v->ny; v->ny = v->nz; } code=QString("#read %1 '%2'\n").arg(data).arg(file); } else if(rM->isChecked()) // manual sizes { int x=nx->text().toInt(), y=ny->text().toInt(), z=nz->text().toInt(); - setlocale(LC_NUMERIC, "C"); v->Read(file.toStdString().c_str(),x,y,z); setlocale(LC_NUMERIC, ""); + setlocale(LC_NUMERIC, "C"); v->Read(file.toLocal8Bit().constData(),x,y,z); setlocale(LC_NUMERIC, ""); code=QString("#read %1 '%2' %3 %4 %5\n").arg(data).arg(file).arg(x).arg(y).arg(z); } else if(r2->isChecked()) // matrix { - setlocale(LC_NUMERIC, "C"); v->ReadMat(file.toStdString().c_str()); setlocale(LC_NUMERIC, ""); + setlocale(LC_NUMERIC, "C"); v->ReadMat(file.toLocal8Bit().constData()); setlocale(LC_NUMERIC, ""); code=QString("#readmat %1 '%2'\n").arg(data).arg(file); dd=1; } else if(r3->isChecked()) // 3d-data { - setlocale(LC_NUMERIC, "C"); v->ReadMat(file.toStdString().c_str(),3); setlocale(LC_NUMERIC, ""); + setlocale(LC_NUMERIC, "C"); v->ReadMat(file.toLocal8Bit().constData(),3); setlocale(LC_NUMERIC, ""); code=QString("#readmat %1 '%2' 3\n").arg(data).arg(file); dd=2; } if(scr->lineEdit()->text().isEmpty() || scr->lineEdit()->text()==tr("default")) @@ -173,7 +173,7 @@ void DataOpenDialog::setFile(const QString &fname) { file=fname; - mglData d(file.toStdString().c_str()); + mglData d(file.toLocal8Bit().constData()); rA->setText(tr("Auto detect data sizes (%1 x %2 x %3)").arg(d.nx).arg(d.ny).arg(d.nz)); } //----------------------------------------------------------------------------- diff -Nru mathgl-2.3.4/udav/opt_dlg.h mathgl-2.3.5.1/udav/opt_dlg.h --- mathgl-2.3.4/udav/opt_dlg.h 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/opt_dlg.h 2016-06-19 17:05:50.000000000 +0000 @@ -21,6 +21,9 @@ #define OPTION_DLG_H //----------------------------------------------------------------------------- #include +#if defined(_MSC_VER) +#include +#endif class QLineEdit; class QComboBox; class QRadioButton; diff -Nru mathgl-2.3.4/udav/setup_dlg.h mathgl-2.3.5.1/udav/setup_dlg.h --- mathgl-2.3.4/udav/setup_dlg.h 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/setup_dlg.h 2016-06-19 17:05:50.000000000 +0000 @@ -21,6 +21,9 @@ #define SETUPDIALOG_H //----------------------------------------------------------------------------- #include +#if defined(_MSC_VER) +#include +#endif class QLineEdit; class QCheckBox; class QComboBox; diff -Nru mathgl-2.3.4/udav/style_dlg.cpp mathgl-2.3.5.1/udav/style_dlg.cpp --- mathgl-2.3.4/udav/style_dlg.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/style_dlg.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -451,7 +451,7 @@ else result += col[i-1]; } i = width->value(); if(i>1) result += char('0'+i); - gr.Plot(x,y,result.toStdString().c_str()); + gr.Plot(x,y,result.toLocal8Bit().constData()); break; case 1: // color sceheme case 3: // manual mask @@ -492,7 +492,7 @@ i = axial->currentIndex(); if(i>0) result = result+':'+char('x'+i-1); - gr.Surf(a,result.toStdString().c_str()); + gr.Surf(a,result.toLocal8Bit().constData()); break; case 2: // text style if(font_sch->isChecked()) for(j=0;j<7;j++) @@ -518,7 +518,7 @@ if(rbL->isChecked()) result += 'L'; if(rbC->isChecked()) result += 'C'; if(rbR->isChecked()) result += 'R'; - gr.Puts(mglPoint(0,-0.5),"Font test",result.toStdString().c_str(),-10); + gr.Puts(mglPoint(0,-0.5),"Font test",result.toLocal8Bit().constData(),-10); break; } result = "'" + result + "'"; diff -Nru mathgl-2.3.4/udav/subplot_dlg.cpp mathgl-2.3.5.1/udav/subplot_dlg.cpp --- mathgl-2.3.4/udav/subplot_dlg.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/subplot_dlg.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -231,6 +231,7 @@ { static mglGraph gr; gr.SetSize(pic->width(),pic->height()); mglParse par; + wchar_t *wcmd; setlocale(LC_NUMERIC, "C"); QString stl="'"; // style for subplot @@ -255,7 +256,11 @@ { cmd += ":title '"+title->text()+"'"; if(!fmt.isEmpty()) cmd += fmt; } if(Tet || Phi) cmd += ":rotate "+QString::number(Tet)+" "+QString::number(Phi); if(Ax!=1 || Ay!=1) cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay); - par.Execute(&gr, cmd.toStdWString().c_str()); gr.Box(); + wcmd = new wchar_t[cmd.size()+1]; + cmd.toWCharArray(wcmd); + wcmd[cmd.size()] = 0; + par.Execute(&gr, wcmd); gr.Box(); + delete[] wcmd; res->setText(cmd); } else if(cm->isChecked()) // multiplot @@ -267,7 +272,11 @@ { cmd += ":title '"+title->text()+"'"; if(!fmt.isEmpty()) cmd += fmt; } if(Tet || Phi) cmd += ":rotate "+QString::number(Tet)+" "+QString::number(Phi); if(Ax!=1 || Ay!=1) cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay); - par.Execute(&gr, cmd.toStdWString().c_str()); gr.Box(); + wcmd = new wchar_t[cmd.size() + 1]; + cmd.toWCharArray(wcmd); + wcmd[cmd.size()] = 0; + par.Execute(&gr, wcmd); gr.Box(); + delete[] wcmd; res->setText(cmd); } else if(cg->isChecked()) // gridplot @@ -277,7 +286,11 @@ for(int i=0;isetText(cmd); } else if(cs->isChecked()) // stickplot @@ -286,7 +299,11 @@ for(int i=0;isetText(cmd); } else if(cc->isChecked()) // columnplot // TODO add angles @@ -297,7 +314,11 @@ cmd = "columnplot "+QString::number(n)+" "+QString::number(k)+" "+QString::number(d); if(Tet || Phi) cmd += ":rotate "+QString::number(Tet)+" "+QString::number(Phi); if(Ax!=1 || Ay!=1) cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay); - par.Execute(&gr, cmd.toStdWString().c_str()); gr.Box(); + wcmd = new wchar_t[cmd.size() + 1]; + cmd.toWCharArray(wcmd); + wcmd[cmd.size()] = 0; + par.Execute(&gr, wcmd); gr.Box(); + delete[] wcmd; res->setText(cmd); } else if(ci->isChecked()) // inplot @@ -308,7 +329,11 @@ { cmd += ":title '"+title->text()+"'"; if(!fmt.isEmpty()) cmd += fmt; } if(Tet || Phi) cmd += ":rotate "+QString::number(Tet)+" "+QString::number(Phi); if(Ax!=1 || Ay!=1) cmd += ":aspect "+QString::number(Ax)+" "+QString::number(Ay); - par.Execute(&gr, cmd.toStdWString().c_str()); gr.Box(); + wcmd = new wchar_t[cmd.size() + 1]; + cmd.toWCharArray(wcmd); + wcmd[cmd.size()] = 0; + par.Execute(&gr, wcmd); gr.Box(); + delete[] wcmd; res->setText(cmd); } setlocale(LC_NUMERIC, ""); diff -Nru mathgl-2.3.4/udav/textedit.cpp mathgl-2.3.5.1/udav/textedit.cpp --- mathgl-2.3.4/udav/textedit.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/textedit.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -305,7 +305,8 @@ void TextEdit::setErrMessage(const QString &mess) { err.clear(); - const char *s = mess.toStdString().c_str(); + QByteArray qs = mess.toLatin1(); + const char *s = qs.constData(); s = strstr(s,"in line "); while(s) { diff -Nru mathgl-2.3.4/udav/textedit.h mathgl-2.3.5.1/udav/textedit.h --- mathgl-2.3.4/udav/textedit.h 2016-02-13 19:03:19.000000000 +0000 +++ mathgl-2.3.5.1/udav/textedit.h 2016-06-19 17:05:48.000000000 +0000 @@ -41,6 +41,9 @@ #define TEXTEDIT_H //----------------------------------------------------------------------------- #include +#if defined(_MSC_VER) +#include +#endif //----------------------------------------------------------------------------- class QCompleter; class Numb; diff -Nru mathgl-2.3.4/udav/text_pnl.cpp mathgl-2.3.5.1/udav/text_pnl.cpp --- mathgl-2.3.4/udav/text_pnl.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/text_pnl.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -63,7 +63,7 @@ if(!files_dlg) files_dlg= new FilesDialog; register int i,n=parser.GetCmdNum(); - for(i=0;is.length()>2) vars<s); + if(v && v->s.length()>2) vars<s.c_str()); } setCompleter(mglCompleter); } @@ -293,7 +293,7 @@ hid_t hf,hg,hd,hs,ht; hsize_t dims[3]; long rank; - hf = H5Fopen(fileName.toStdString().c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); + hf = H5Fopen(fileName.toLocal8Bit().constData(), H5F_ACC_RDONLY, H5P_DEFAULT); if(!hf) return; hg = H5Gopen(hf, "/"); hsize_t num, nx, ny, nz, i; @@ -359,7 +359,7 @@ long rank = 3; H5Eset_auto(0,0); - hf = H5Fcreate(fileName.toStdString().c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + hf = H5Fcreate(fileName.toLocal8Bit().constData(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if(hf<0) { setStatus(tr("Could not write to %1").arg(fileName)); @@ -372,7 +372,7 @@ txt += edit->toPlainText(); dims[0] = txt.length()+1; char *buf = new char[dims[0]+1]; - memcpy(buf, txt.toStdString().c_str(), dims[0]); + memcpy(buf, txt.toLocal8Bit().constData(), dims[0]); buf[dims[0]]=0; hs = H5Screate_simple(1, dims, 0); hd = H5Dcreate(hf, "mgl_script", H5T_C_S1, hs, H5P_DEFAULT); diff -Nru mathgl-2.3.4/udav/udav_wnd.cpp mathgl-2.3.5.1/udav/udav_wnd.cpp --- mathgl-2.3.4/udav/udav_wnd.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/udav/udav_wnd.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -424,9 +424,11 @@ for(i=0;imgl->getGraph(), fileName.toStdString().c_str()); + mgl_set_plotid(graph->mgl->getGraph(), fileName.toLocal8Bit().constData()); edit->setModified(false); if(filename.isEmpty()) setWindowTitle(tr("untitled - UDAV")); diff -Nru mathgl-2.3.4/utils/CMakeLists.txt mathgl-2.3.5.1/utils/CMakeLists.txt --- mathgl-2.3.4/utils/CMakeLists.txt 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/utils/CMakeLists.txt 2016-06-19 17:05:50.000000000 +0000 @@ -1,15 +1,19 @@ -include_directories(${GSL_INCLUDE_DIR}) add_executable(make_pas make_pas.cpp) add_executable(mglconv mglconv.cpp) -target_link_libraries(mglconv mgl) +if(MSVC) +set(link_type -static) +else(MSVC) +set(link_type) +endif(MSVC) +target_link_libraries(mglconv mgl${link_type} ${getopt_lib-static}) install( TARGETS mglconv RUNTIME DESTINATION bin ) add_executable(mgl.cgi mglcgi.cpp) -target_link_libraries(mgl.cgi mgl) +target_link_libraries(mgl.cgi mgl${link_type}) install( TARGETS mgl.cgi # should be /usr/lib/cgi-bin/ @@ -20,12 +24,10 @@ add_executable(mglview mglview.cpp) if(enable-qt5) include(../cmake-qt5.txt) - target_link_libraries(mglview mgl-qt5) - qt5_use_modules(mglview ${MGL_QT5_LIBS}) + target_link_libraries(mglview mgl-qt5${link_type} ${getopt_lib-static} ${MGL_QT5_LIBS}) else(enable-qt5) include(../cmake-qt4.txt) - target_link_libraries(mglview mgl-qt4) - qt4_use_modules(mglview ${MGL_QT4_LIBS}) + target_link_libraries(mglview mgl-qt4${link_type} ${getopt_lib-static} ${MGL_QT4_LIBS}) endif(enable-qt5) install( diff -Nru mathgl-2.3.4/utils/make_pas.cpp mathgl-2.3.5.1/utils/make_pas.cpp --- mathgl-2.3.4/utils/make_pas.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/utils/make_pas.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -1,5 +1,7 @@ #include #include +#include + const char *files[] = { diff -Nru mathgl-2.3.4/utils/mglcgi.cpp mathgl-2.3.5.1/utils/mglcgi.cpp --- mathgl-2.3.4/utils/mglcgi.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/utils/mglcgi.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * mglcgi.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/utils/mglconv.cpp mathgl-2.3.5.1/utils/mglconv.cpp --- mathgl-2.3.4/utils/mglconv.cpp 2016-02-13 19:03:22.000000000 +0000 +++ mathgl-2.3.5.1/utils/mglconv.cpp 2016-06-19 17:05:50.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * mglconv.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -20,6 +20,12 @@ #include #include #include "mgl2/mgl.h" + +#ifdef _MSC_VER +#define mnpos (std::basic_string::size_type)-1 +#else +#define mnpos std::wstring::npos +#endif void mgl_error_print(const char *Message, void *par); void mgl_ask_gets(const wchar_t *quest, wchar_t *res); //----------------------------------------------------------------------------- @@ -35,7 +41,7 @@ while(1) { - int ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:hno:L:C:A:s:S:q:"); + int ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:hno:L:C:A:s:S:q:v:g:"); if(ch>='1' && ch<='9') p.AddParam(ch-'0', optarg); else if(ch=='s') { @@ -52,10 +58,12 @@ else if(ch=='L') setlocale(LC_CTYPE, optarg); else if(ch=='S') mgl_set_size_scl(atof(optarg)); else if(ch=='q') gr.SetQuality(atoi(optarg)); + else if(ch=='v') p.SetVariant(atoi(optarg)); + else if(ch=='g') gr.Gray(atoi(optarg)); else if(ch=='A') { std::wstring str; - for(long i=0;optarg[i];i++) str.push_back(optarg[i]); + for(size_t i=0;optarg[i];i++) str.push_back(optarg[i]); var.push_back(str); } else if(ch=='C') @@ -82,6 +90,8 @@ "\t-s fname set MGL script for setting up the plot\n" "\t-S val set scaling factor for images\n" "\t-q val set quality for output (val=0...9)\n" + "\t-g val set gray-scale mode (val=0|1)\n" + "\t-v val set variant of arguments\n" "\t-o name set output file name\n" "\t-n no default output (script should save results by itself)\n" "\t-A val add animation value val\n" @@ -107,16 +117,16 @@ while(!feof(fp) && size_t(cw=fgetwc(fp))!=WEOF) str.push_back(cw); if(*iname) fclose(fp); - unsigned long n; - for(long i=0;;) // collect exact values + size_t n; + for(size_t i=0;;) // collect exact values { n = str.find(L"##a ",i); - if(n==std::string::npos) break; + if (n == mnpos) break; i = n+4; var.push_back(str.substr(i,str.find('\n',i))); } n = str.find(L"##c "); - if(n!=std::string::npos) - { + if (n != mnpos) + { double v1,v2,dv,v; wscanf(str.c_str()+n+4,L"%lg%lg%lg",&v1,&v2,&dv); wchar_t ss[64]; @@ -124,18 +134,19 @@ { mglprintf(ss,64,L"%g",v); var.push_back(ss); } } bool gif = !strcmp(oname+strlen(oname)-4,".gif"); + gr.SetSize(600,400); // specially call for "S" option if(var.size()>1) // there is animation { if(gif) gr.StartGIF(oname); - for(unsigned long i=0;i * + * Copyright (C) 2007-2016 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 * @@ -22,13 +22,10 @@ #include "mgl2/mgl.h" #include "mgl2/qt.h" +#include "mgl2/parser.h" //----------------------------------------------------------------------------- std::wstring str, opt; mglParse p(true); -void mgl_error_print(const char *Message, void *par); -void mgl_ask_fltk(const wchar_t *quest, wchar_t *res); -void mgl_ask_qt(const wchar_t *quest, wchar_t *res); -void mgl_ask_gets(const wchar_t *quest, wchar_t *res); //----------------------------------------------------------------------------- int show(mglGraph *gr) { @@ -41,9 +38,10 @@ { char iname[256]=""; mgl_suppress_warn(true); + bool gray = false; while(1) { - int ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:hL:s:"); + int ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:hL:s:g:v:"); if(ch>='1' && ch<='9') p.AddParam(ch-'0', optarg); else if(ch=='s') { @@ -56,6 +54,8 @@ fclose(fp); } } + else if(ch=='v') p.SetVariant(atoi(optarg)); + else if(ch=='g') gray= atoi(optarg); else if(ch=='L') setlocale(LC_CTYPE, optarg); else if(ch=='h' || (ch==-1 && optind>=argc)) { @@ -65,6 +65,8 @@ "\t-1 str set str as argument $1 for script\n" "\t... ...\n" "\t-9 str set str as argument $9 for script\n" + "\t-g val set gray-scale mode (val=0|1)\n" + "\t-v val set variant of arguments\n" "\t-s opt set MGL script for setting up the plot\n" "\t-L loc set locale to loc\n" "\t- get script from standard input\n" @@ -93,6 +95,8 @@ mgl_ask_func = mgl_ask_gets; mgl_ask_func = mgl_ask_qt; mglQT gr(mgld?NULL:show, *iname?iname:"mglview"); + if(gray) gr.Gray(gray); + if(mgld) { gr.Setup(false); diff -Nru mathgl-2.3.4/widgets/CMakeLists.txt mathgl-2.3.5.1/widgets/CMakeLists.txt --- mathgl-2.3.4/widgets/CMakeLists.txt 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/widgets/CMakeLists.txt 2016-06-19 17:06:02.000000000 +0000 @@ -1,11 +1,11 @@ include(GenerateExportHeader) -add_compiler_export_flags() if(MGL_HAVE_FLTK) mgl_add_lib(fltk fltk.cpp ../include/mgl2/fltk.h) target_include_directories(mgl-fltk SYSTEM PUBLIC ${FLTK_INCLUDE_DIR}) target_include_directories(mgl-fltk-static SYSTEM PUBLIC ${FLTK_INCLUDE_DIR}) target_link_libraries(mgl-fltk mgl ${FLTK_LIBRARIES}) + target_link_libraries(mgl-fltk-static mgl-static ${FLTK_LIBRARIES}) endif(MGL_HAVE_FLTK) if(MGL_HAVE_GLUT) @@ -13,13 +13,14 @@ target_include_directories(mgl-glut SYSTEM PUBLIC ${GLUT_INCLUDE_DIR}) target_include_directories(mgl-glut-static SYSTEM PUBLIC ${GLUT_INCLUDE_DIR}) target_link_libraries(mgl-glut mgl ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) + target_link_libraries(mgl-glut-static mgl-static ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) endif(MGL_HAVE_GLUT) if(MGL_HAVE_WX) mgl_add_lib(wx wx.cpp ../include/mgl2/wx.h) include(${wxWidgets_USE_FILE}) - target_link_libraries(mgl-wx mgl) - target_link_libraries(mgl-wx ${wxWidgets_LIBRARIES}) + target_link_libraries(mgl-wx mgl ${wxWidgets_LIBRARIES}) + target_link_libraries(mgl-wx-static mgl-static ${wxWidgets_LIBRARIES}) endif(MGL_HAVE_WX) add_subdirectory( qt4 ) diff -Nru mathgl-2.3.4/widgets/fltk.cpp mathgl-2.3.5.1/widgets/fltk.cpp --- mathgl-2.3.4/widgets/fltk.cpp 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/widgets/fltk.cpp 2016-06-19 17:06:02.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * fltk.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -175,6 +175,14 @@ const char *buf = mgl_get_mess(gr); if(*buf) fl_message("%s",buf); } + else if(mgl_get_num_frame(gr)>0) + { + mgl_set_alpha(gr,flag&1); mgl_set_light(gr,flag&2); + if(tet_val) tet = tet_val->value(); + if(phi_val) phi = phi_val->value(); + mgl_zoom(gr,x1,y1,x2,y2); mgl_view(gr,-phi,-tet,0); + mgl_get_frame(gr,0); + } if(mgl_get_width(gr)!=w() || mgl_get_height(gr)!=h()) size(mgl_get_width(gr), mgl_get_height(gr)); gr->AskStop(false); redraw(); @@ -349,8 +357,8 @@ } if(mutex) { - if(pauseC) pthread_mutex_lock(mutex); - else pthread_mutex_unlock(mutex); + pthread_mutex_trylock(mutex); + if(!pauseC) pthread_mutex_unlock(mutex); } #endif } @@ -764,6 +772,11 @@ g->Window(0,0,draw,title,par,load); return g; } +void* mgl_fltk_widget(HMGL gr) +{ + mglCanvasFL *g = dynamic_cast(gr); + return g?g->mgl:NULL; +} int MGL_EXPORT mgl_fltk_run() { return Fl::run(); } //----------------------------------------------------------------------------- uintptr_t MGL_EXPORT mgl_create_graph_fltk_(const char *title, int l) diff -Nru mathgl-2.3.4/widgets/glut.cpp mathgl-2.3.5.1/widgets/glut.cpp --- mathgl-2.3.4/widgets/glut.cpp 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/widgets/glut.cpp 2016-06-19 17:06:02.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * glut.cpp is part of Math Graphic Library - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * diff -Nru mathgl-2.3.4/widgets/qt4/CMakeLists.txt mathgl-2.3.5.1/widgets/qt4/CMakeLists.txt --- mathgl-2.3.4/widgets/qt4/CMakeLists.txt 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/widgets/qt4/CMakeLists.txt 2016-06-19 17:06:02.000000000 +0000 @@ -1,29 +1,22 @@ include(GenerateExportHeader) -add_compiler_export_flags() if(enable-qt4) include(../../cmake-qt4.txt) set(MGL_QT4_FILES ../qt.cpp ../../include/mgl2/qt.h ../../include/mgl2/qmathgl.h) mgl_add_lib(qt4 ${MGL_QT4_FILES}) - qt4_use_modules(mgl-qt4 ${MGL_QT4_LIBS}) - qt4_use_modules(mgl-qt4-static ${MGL_QT4_LIBS}) - target_link_libraries(mgl-qt4 mgl) - target_link_libraries(mgl-qt4-static mgl) - if(NOT enable-qt5asqt) + target_link_libraries(mgl-qt4 mgl ${MGL_QT4_LIBS}) + target_link_libraries(mgl-qt4-static mgl-static ${MGL_QT4_LIBS}) + if(enable-qt4asqt) mgl_add_lib(qt ${MGL_QT4_FILES}) - qt4_use_modules(mgl-qt ${MGL_QT4_LIBS}) - qt4_use_modules(mgl-qt-static ${MGL_QT4_LIBS}) - target_link_libraries(mgl-qt mgl) - target_link_libraries(mgl-qt-static mgl) - endif(NOT enable-qt5asqt) + target_link_libraries(mgl-qt mgl ${MGL_QT4_LIBS}) + target_link_libraries(mgl-qt-static mgl-static ${MGL_QT4_LIBS}) + endif(enable-qt4asqt) if(MGL_HAVE_FLTK AND NOT enable-qt5) mgl_add_lib(wnd ${MGL_QT4_FILES} ../fltk.cpp ../../include/mgl2/fltk.h) target_include_directories(mgl-wnd SYSTEM PUBLIC ${FLTK_INCLUDE_DIR}) target_include_directories(mgl-wnd-static SYSTEM PUBLIC ${FLTK_INCLUDE_DIR}) - qt4_use_modules(mgl-wnd ${MGL_QT4_LIBS}) - qt4_use_modules(mgl-wnd-static ${MGL_QT4_LIBS}) - target_link_libraries(mgl-wnd mgl ${FLTK_LIBRARIES}) - target_link_libraries(mgl-wnd-static mgl ${FLTK_LIBRARIES}) + target_link_libraries(mgl-wnd mgl ${FLTK_LIBRARIES} ${MGL_QT4_LIBS}) + target_link_libraries(mgl-wnd-static mgl-static ${FLTK_LIBRARIES} ${MGL_QT4_LIBS}) endif(MGL_HAVE_FLTK AND NOT enable-qt5) endif(enable-qt4) diff -Nru mathgl-2.3.4/widgets/qt5/CMakeLists.txt mathgl-2.3.5.1/widgets/qt5/CMakeLists.txt --- mathgl-2.3.4/widgets/qt5/CMakeLists.txt 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/widgets/qt5/CMakeLists.txt 2016-06-19 17:06:02.000000000 +0000 @@ -1,28 +1,21 @@ include(GenerateExportHeader) -add_compiler_export_flags() if(enable-qt5) include(../../cmake-qt5.txt) set(MGL_QT5_FILES ../qt.cpp ../../include/mgl2/qt.h ../../include/mgl2/qmathgl.h) mgl_add_lib(qt5 ${MGL_QT5_FILES}) - qt5_use_modules(mgl-qt5 ${MGL_QT5_LIBS}) - qt5_use_modules(mgl-qt5-static ${MGL_QT5_LIBS}) - target_link_libraries(mgl-qt5 mgl) - target_link_libraries(mgl-qt5-static mgl) + target_link_libraries(mgl-qt5 mgl ${MGL_QT5_LIBS}) + target_link_libraries(mgl-qt5-static mgl-static ${MGL_QT5_LIBS}) if(enable-qt5asqt) mgl_add_lib(qt ${MGL_QT5_FILES}) - qt5_use_modules(mgl-qt ${MGL_QT5_LIBS}) - qt5_use_modules(mgl-qt-static ${MGL_QT5_LIBS}) - target_link_libraries(mgl-qt mgl) - target_link_libraries(mgl-qt-static mgl) + target_link_libraries(mgl-qt mgl ${MGL_QT5_LIBS}) + target_link_libraries(mgl-qt-static mgl-static ${MGL_QT5_LIBS}) endif(enable-qt5asqt) if(MGL_HAVE_FLTK) mgl_add_lib(wnd ${MGL_QT5_FILES} ../fltk.cpp ../../include/mgl2/fltk.h) target_include_directories(mgl-wnd SYSTEM PUBLIC ${FLTK_INCLUDE_DIR}) target_include_directories(mgl-wnd-static SYSTEM PUBLIC ${FLTK_INCLUDE_DIR}) - qt5_use_modules(mgl-wnd ${MGL_QT5_LIBS}) - qt5_use_modules(mgl-wnd-static ${MGL_QT5_LIBS}) - target_link_libraries(mgl-wnd mgl ${FLTK_LIBRARIES}) - target_link_libraries(mgl-wnd-static mgl ${FLTK_LIBRARIES}) + target_link_libraries(mgl-wnd mgl ${FLTK_LIBRARIES} ${MGL_QT5_LIBS}) + target_link_libraries(mgl-wnd-static mgl-static ${FLTK_LIBRARIES} ${MGL_QT5_LIBS}) endif(MGL_HAVE_FLTK) endif(enable-qt5) diff -Nru mathgl-2.3.4/widgets/qt.cpp mathgl-2.3.5.1/widgets/qt.cpp --- mathgl-2.3.4/widgets/qt.cpp 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/widgets/qt.cpp 2016-06-19 17:06:02.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * qt.cpp is part of Math Graphic Library * - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -330,8 +330,15 @@ else if(draw) { mglGraph g(gr); draw->Draw(&g); } if(mgl_is_frames(gr)) mgl_end_frame(gr); setlocale(LC_NUMERIC, ""); - gr->AskStop(false); afterPlot(); + gr->AskStop(false); } + else if(mgl_get_num_frame(gr)>0) + { + mgl_set_alpha(gr,alpha); mgl_set_light(gr,light); +// mgl_zoom(gr,x1,y1,x2,y2); mgl_view(gr,-phi,-tet,0); + mgl_get_frame(gr,0); + } + afterPlot(); } //----------------------------------------------------------------------------- void QMathGL::afterPlot() @@ -359,7 +366,7 @@ { mgl_set_obj_id(gr,i+MGL_MAX_LINES); QString tst = primitives.section('\n',i,i); - pr.Parse(&gg,primitives.section('\n',i,i).toStdString().c_str(),i+MGL_MAX_LINES); + pr.Parse(&gg,primitives.section('\n',i,i).toLocal8Bit().constData(),i+MGL_MAX_LINES); } gg.SetRanges(ox1,ox2); gg.Pop(); setlocale(LC_NUMERIC, ""); } @@ -671,7 +678,7 @@ if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); else #if MGL_HAVE_GIF - mgl_write_gif(gr,setExtension(fname,"png").toStdString().c_str(), appName.toStdString().c_str()); + mgl_write_gif(gr,setExtension(fname,"png").toLocal8Bit().constData(), appName.toLocal8Bit().constData()); #else img.save(setExtension(fname,"gif")); #endif @@ -683,7 +690,7 @@ if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); else #if MGL_HAVE_PNG - mgl_write_png(gr,setExtension(fname,"png").toStdString().c_str(), appName.toStdString().c_str()); + mgl_write_png(gr,setExtension(fname,"png").toLocal8Bit().constData(), appName.toLocal8Bit().constData()); #else img.save(setExtension(fname,"png")); #endif @@ -695,7 +702,7 @@ if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); else #if MGL_HAVE_PNG - mgl_write_png_solid(gr,setExtension(fname,"png").toStdString().c_str(), appName.toStdString().c_str()); + mgl_write_png_solid(gr,setExtension(fname,"png").toLocal8Bit().constData(), appName.toLocal8Bit().constData()); #else img.save(setExtension(fname,"png")); #endif @@ -707,7 +714,7 @@ if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); else #if MGL_HAVE_JPEG - mgl_write_jpg(gr,setExtension(fname,"jpg").toStdString().c_str(), appName.toStdString().c_str()); + mgl_write_jpg(gr,setExtension(fname,"jpg").toLocal8Bit().constData(), appName.toLocal8Bit().constData()); #else img.save(setExtension(fname,"jpg")); #endif @@ -720,7 +727,7 @@ else { setlocale(LC_NUMERIC, "C"); - mgl_write_bps(gr,setExtension(fname,"eps").toStdString().c_str(), appName.toStdString().c_str()); + mgl_write_bps(gr,setExtension(fname,"eps").toLocal8Bit().constData(), appName.toLocal8Bit().constData()); setlocale(LC_NUMERIC, ""); } } @@ -732,7 +739,7 @@ else { setlocale(LC_NUMERIC, "C"); - mgl_write_eps(gr,setExtension(fname,"eps").toStdString().c_str(), appName.toStdString().c_str()); + mgl_write_eps(gr,setExtension(fname,"eps").toLocal8Bit().constData(), appName.toLocal8Bit().constData()); setlocale(LC_NUMERIC, ""); } } @@ -744,7 +751,7 @@ else { setlocale(LC_NUMERIC, "C"); - mgl_write_svg(gr,setExtension(fname,"svg").toStdString().c_str(), appName.toStdString().c_str()); + mgl_write_svg(gr,setExtension(fname,"svg").toLocal8Bit().constData(), appName.toLocal8Bit().constData()); setlocale(LC_NUMERIC, ""); } } @@ -756,7 +763,7 @@ else { setlocale(LC_NUMERIC, "C"); - mgl_write_xyz(gr,setExtension(fname,"xyz").toStdString().c_str(), appName.toStdString().c_str()); + mgl_write_xyz(gr,setExtension(fname,"xyz").toLocal8Bit().constData(), appName.toLocal8Bit().constData()); setlocale(LC_NUMERIC, ""); } } @@ -768,7 +775,7 @@ else { setlocale(LC_NUMERIC, "C"); - mgl_write_tex(gr,setExtension(fname,"tex").toStdString().c_str(), appName.toStdString().c_str()); + mgl_write_tex(gr,setExtension(fname,"tex").toLocal8Bit().constData(), appName.toLocal8Bit().constData()); setlocale(LC_NUMERIC, ""); } } @@ -780,7 +787,7 @@ else { setlocale(LC_NUMERIC, "C"); - mgl_write_off(gr,setExtension(fname,"off").toStdString().c_str(), appName.toStdString().c_str(),0); + mgl_write_off(gr,setExtension(fname,"off").toLocal8Bit().constData(), appName.toLocal8Bit().constData(),0); setlocale(LC_NUMERIC, ""); } } @@ -792,7 +799,7 @@ else { setlocale(LC_NUMERIC, "C"); - mgl_write_obj(gr,setExtension(fname,"obj").toStdString().c_str(), appName.toStdString().c_str(),1); + mgl_write_obj(gr,setExtension(fname,"obj").toLocal8Bit().constData(), appName.toLocal8Bit().constData(),1); setlocale(LC_NUMERIC, ""); } } @@ -804,7 +811,7 @@ else { setlocale(LC_NUMERIC, "C"); - mgl_write_stl(gr,setExtension(fname,"stl").toStdString().c_str(), appName.toStdString().c_str()); + mgl_write_stl(gr,setExtension(fname,"stl").toLocal8Bit().constData(), appName.toLocal8Bit().constData()); setlocale(LC_NUMERIC, ""); } } @@ -816,7 +823,7 @@ else { setlocale(LC_NUMERIC, "C"); - mgl_write_x3d(gr,setExtension(fname,"x3d").toStdString().c_str(), appName.toStdString().c_str()); + mgl_write_x3d(gr,setExtension(fname,"x3d").toLocal8Bit().constData(), appName.toLocal8Bit().constData()); setlocale(LC_NUMERIC, ""); } }*/ @@ -828,7 +835,7 @@ else { setlocale(LC_NUMERIC, "C"); - mgl_write_tga(gr,setExtension(fname,"tga").toStdString().c_str(), appName.toStdString().c_str()); + mgl_write_tga(gr,setExtension(fname,"tga").toLocal8Bit().constData(), appName.toLocal8Bit().constData()); setlocale(LC_NUMERIC, ""); } } @@ -840,7 +847,7 @@ else { setlocale(LC_NUMERIC, "C"); - mgl_write_prc(gr,setExtension(fname,"prc").toStdString().c_str(), appName.toStdString().c_str(),1); + mgl_write_prc(gr,setExtension(fname,"prc").toLocal8Bit().constData(), appName.toLocal8Bit().constData(),1); setlocale(LC_NUMERIC, ""); } } @@ -852,7 +859,7 @@ else { setlocale(LC_NUMERIC, "C"); - mgl_export_mgld(gr,setExtension(fname,"mgld").toStdString().c_str(), appName.toStdString().c_str()); + mgl_export_mgld(gr,setExtension(fname,"mgld").toLocal8Bit().constData(), appName.toLocal8Bit().constData()); setlocale(LC_NUMERIC, ""); } } @@ -884,7 +891,7 @@ //----------------------------------------------------------------------------- void QMathGL::setMGLFont(QString path) { if(path.isEmpty()) mgl_restore_font(gr); - else mgl_load_font(gr,path.toStdString().c_str(),0); } + else mgl_load_font(gr,path.toLocal8Bit().constData(),0); } //----------------------------------------------------------------------------- void QMathGL::setSize(int w, int h) { @@ -1324,6 +1331,11 @@ g->Window(0,0,draw,title,par,load); return g; } +void* mgl_qt_widget(HMGL gr) +{ + mglCanvasQT *g = dynamic_cast(gr); + return g?g->QMGL:NULL; +} int MGL_EXPORT mgl_qt_run() { return (qApp)?qApp->exec():-1; } //----------------------------------------------------------------------------- uintptr_t MGL_EXPORT mgl_create_graph_qt_(const char *title, int l) diff -Nru mathgl-2.3.4/widgets/wx.cpp mathgl-2.3.5.1/widgets/wx.cpp --- mathgl-2.3.4/widgets/wx.cpp 2016-02-13 19:03:30.000000000 +0000 +++ mathgl-2.3.5.1/widgets/wx.cpp 2016-06-19 17:06:02.000000000 +0000 @@ -1,6 +1,6 @@ /*************************************************************************** * wx.cpp is part of Math Graphic Library * - * Copyright (C) 2007-2014 Alexey Balakin * + * Copyright (C) 2007-2016 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 * @@ -202,6 +202,12 @@ dlg.ShowModal(); } } + else if(mgl_get_num_frame(gr)>0) + { + mgl_set_alpha(gr,alpha); mgl_set_light(gr,light); +// mgl_zoom(gr,x1,y1,x2,y2); mgl_view(gr,-phi,-tet,0); + mgl_get_frame(gr,0); + } MousePos.Empty(); Repaint(); } //----------------------------------------------------------------------------- @@ -313,7 +319,7 @@ { static char *buf=0; if(buf) delete []buf; - long i, n=str.Len(); + size_t i, n=str.Len(); buf = new char[n+1]; buf[n]=0; for(i=0;i