/Common/Options.cpp
C++ | 8910 lines | 8124 code | 734 blank | 52 comment | 1668 complexity | 78163dd2f0ca41f1e2fcf4aef69c6c57 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, BSD-3-Clause
Large files files are truncated, but you can click here to view the full file
- // Gmsh - Copyright (C) 1997-2012 C. Geuzaine, J.-F. Remacle
- //
- // See the LICENSE.txt file for license information. Please report all
- // bugs and problems to <gmsh@geuz.org>.
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include "GmshConfig.h"
- #include "GmshDefines.h"
- #include "GmshMessage.h"
- #include "StringUtils.h"
- #include "GModel.h"
- #include "Context.h"
- #include "Options.h"
- #include "Colors.h"
- #include "DefaultOptions.h"
- #if defined(HAVE_MESH)
- #include "Generator.h"
- #include "Field.h"
- #include "BackgroundMesh.h"
- #endif
- #if defined(HAVE_PARSER)
- #include "Parser.h"
- #endif
- #if defined(HAVE_POST)
- #include "PView.h"
- #include "PViewOptions.h"
- #include "PViewData.h"
- #include "adaptiveData.h"
- #endif
- #if defined(HAVE_PLUGINS)
- #include "PluginManager.h"
- #include "Plugin.h"
- #endif
- #if defined(HAVE_FLTK)
- #include <FL/Fl_Tooltip.H>
- #include "FlGui.h"
- #include "graphicWindow.h"
- #include "optionWindow.h"
- #include "manipWindow.h"
- #include "contextWindow.h"
- #include "clippingWindow.h"
- #include "onelabGroup.h"
- #include "viewButton.h"
- #endif
- // General routines for string options
- bool StringOption(int action, const char *category, int num,
- const char *name, std::string &val)
- {
- StringXString *s = 0;
- if(!strcmp(category, "General"))
- s = GeneralOptions_String;
- else if(!strcmp(category, "Geometry"))
- s = GeometryOptions_String;
- else if(!strcmp(category, "Mesh"))
- s = MeshOptions_String;
- else if(!strcmp(category, "Solver"))
- s = SolverOptions_String;
- else if(!strcmp(category, "PostProcessing"))
- s = PostProcessingOptions_String;
- else if(!strcmp(category, "View"))
- s = ViewOptions_String;
- else if(!strcmp(category, "Print"))
- s = PrintOptions_String;
- else{
- Msg::Error("Unknown string option category '%s'", category);
- return false;
- }
- int i = 0;
- while(s[i].str && strcmp(s[i].str, name)) i++;
- if(!s[i].str){
- Msg::Error("Unknown string option '%s.%s'", category, name);
- return false;
- }
- val = s[i].function(num, action, val);
- return true;
- }
- static void SetDefaultStringOptions(int num, StringXString s[])
- {
- int i = 0;
- while(s[i].str) {
- s[i].function(num, GMSH_SET, s[i].def);
- i++;
- }
- }
- static void SetStringOptionsGUI(int num, StringXString s[])
- {
- int i = 0;
- while(s[i].str) {
- s[i].function(num, GMSH_GUI, "");
- i++;
- }
- }
- static void PrintStringOptions(int num, int level, int diff, int help,
- StringXString s[], const char *prefix, FILE *file)
- {
- int i = 0;
- while(s[i].str) {
- if(s[i].level & level) {
- if(!diff || s[i].function(num, GMSH_GET, "") != s[i].def){
- char tmp[1024];
- sprintf(tmp, "%s%s = \"%s\";%s%s", prefix,
- s[i].str, s[i].function(num, GMSH_GET, "").c_str(),
- help ? " // " : "", help ? s[i].help : "");
- if(file)
- fprintf(file, "%s\n", tmp);
- else{
- // remove \n, \t, \r
- for(unsigned int i = 0; i < strlen(tmp); i++)
- if(tmp[i] == '\n' || tmp[i] == '\t' || tmp[i] == '\r') tmp[i] = ' ';
- // Warning: must call Msg::Direct(level, ...) here, because
- // we cannot use tmp as a format string (it can contain %s!)
- Msg::Direct(3, "%s", tmp);
- }
- }
- }
- i++;
- }
- }
- static const char *GetOptionSaveLevel(int level)
- {
- if(level & GMSH_SESSIONRC){
- return "General.SessionFileName";
- }
- else if(level & GMSH_OPTIONSRC){
- return "General.OptionsFileName";
- }
- else{
- return "-";
- }
- }
- static void PrintStringOptionsDoc(StringXString s[], const char *prefix, FILE *file)
- {
- int i = 0;
- while(s[i].str) {
- fprintf(file, "@item %s%s\n", prefix, s[i].str);
- fprintf(file, "%s@*\n", s[i].help);
- // sanitize the string for texinfo
- std::string val = s[i].function(0, GMSH_GET, "");
- for(unsigned int j = 1; j < val.size(); j++){
- if(val[j] == '\n' && val[j - 1] == '\n')
- val[j - 1] = '.';
- }
- fprintf(file, "Default value: @code{\"%s\"}@*\n", val.c_str());
- fprintf(file, "Saved in: @code{%s}\n\n", GetOptionSaveLevel(s[i].level));
- i++;
- }
- }
- // General routines for numeric options
- bool NumberOption(int action, const char *category, int num,
- const char *name, double &val)
- {
- StringXNumber *s = 0;
- if(!strcmp(category, "General"))
- s = GeneralOptions_Number;
- else if(!strcmp(category, "Geometry"))
- s = GeometryOptions_Number;
- else if(!strcmp(category, "Mesh"))
- s = MeshOptions_Number;
- else if(!strcmp(category, "Solver"))
- s = SolverOptions_Number;
- else if(!strcmp(category, "PostProcessing"))
- s = PostProcessingOptions_Number;
- else if(!strcmp(category, "View"))
- s = ViewOptions_Number;
- else if(!strcmp(category, "Print"))
- s = PrintOptions_Number;
- else{
- Msg::Error("Unknown number option category '%s'", category);
- return false;
- }
- int i = 0;
- while(s[i].str && strcmp(s[i].str, name)) i++;
- if(!s[i].str){
- Msg::Error("Unknown number option '%s.%s'", category, name);
- return false;
- }
- val = s[i].function(num, action, val);
- return true;
- }
- static void SetDefaultNumberOptions(int num, StringXNumber s[])
- {
- int i = 0;
- while(s[i].str) {
- s[i].function(num, GMSH_SET, s[i].def);
- i++;
- }
- }
- static void SetNumberOptionsGUI(int num, StringXNumber s[])
- {
- int i = 0;
- while(s[i].str) {
- s[i].function(num, GMSH_GUI, 0);
- i++;
- }
- }
- static void PrintNumberOptions(int num, int level, int diff, int help,
- StringXNumber s[], const char *prefix, FILE * file)
- {
- int i = 0;
- char tmp[1024];
- while(s[i].str) {
- if(s[i].level & level) {
- if(!diff || (s[i].function(num, GMSH_GET, 0) != s[i].def)){
- sprintf(tmp, "%s%s = %.16g;%s%s", prefix,
- s[i].str, s[i].function(num, GMSH_GET, 0),
- help ? " // " : "", help ? s[i].help : "");
- if(file)
- fprintf(file, "%s\n", tmp);
- else
- Msg::Direct(tmp);
- }
- }
- i++;
- }
- }
- static void PrintNumberOptionsDoc(StringXNumber s[], const char *prefix, FILE * file)
- {
- int i = 0;
- while(s[i].str) {
- fprintf(file, "@item %s%s\n", prefix, s[i].str);
- fprintf(file, "%s@*\n", s[i].help);
- fprintf(file, "Default value: @code{%g}@*\n", s[i].function(0, GMSH_GET, 0));
- fprintf(file, "Saved in: @code{%s}\n\n", GetOptionSaveLevel(s[i].level));
- i++;
- }
- }
- // General routines for color options
- bool ColorOption(int action, const char *category, int num,
- const char *name, unsigned int &val)
- {
- StringXColor *s = 0;
- if(!strcmp(category, "General"))
- s = GeneralOptions_Color;
- else if(!strcmp(category, "Geometry"))
- s = GeometryOptions_Color;
- else if(!strcmp(category, "Mesh"))
- s = MeshOptions_Color;
- else if(!strcmp(category, "Solver"))
- s = SolverOptions_Color;
- else if(!strcmp(category, "PostProcessing"))
- s = PostProcessingOptions_Color;
- else if(!strcmp(category, "View"))
- s = ViewOptions_Color;
- else if(!strcmp(category, "Print"))
- s = PrintOptions_Color;
- else{
- Msg::Error("Unknown color option category '%s'", category);
- return false;
- }
- int i = 0;
- while(s[i].str && strcmp(s[i].str, name)) i++;
- if(!s[i].str){
- Msg::Error("Unknown color option '%s.%s'", category, name);
- return false;
- }
- val = s[i].function(num, action, val);
- return true;
- }
- int GetColorForString(int alpha, const char *str, int *FlagError)
- {
- int i = 0;
- while(ColorString[i].str && strcmp(ColorString[i].str, str))
- i++;
- *FlagError = !ColorString[i].str ? 1 : 0;
- if(alpha > 0)
- return CTX::instance()->packColor
- (ColorString[i].int1, ColorString[i].int2, ColorString[i].int3, alpha);
- else
- return CTX::instance()->packColor
- (ColorString[i].int1, ColorString[i].int2, ColorString[i].int3,
- ColorString[i].int4);
- }
- bool GetRGBForString(const char *str, int &r, int &g, int &b)
- {
- int i = 0;
- while(ColorString[i].str && strcmp(ColorString[i].str, str))
- i++;
- if(!ColorString[i].str){
- r = g = b = 0;
- return false;
- }
- r = ColorString[i].int1;
- g = ColorString[i].int2;
- b = ColorString[i].int3;
- return true;
- }
- static void SetDefaultColorOptions(int num, StringXColor s[])
- {
- int i = 0;
- // Warning: this assumes that CTX::instance()->color_scheme is set...
- switch (CTX::instance()->colorScheme) {
- case 1:
- while(s[i].str) {
- s[i].function(num, GMSH_SET, CTX::instance()->packColor
- (s[i].def2[0], s[i].def2[1], s[i].def2[2], s[i].def2[3]));
- i++;
- }
- break;
- case 2:
- while(s[i].str) {
- s[i].function(num, GMSH_SET, CTX::instance()->packColor
- (s[i].def3[0], s[i].def3[1], s[i].def3[2], s[i].def3[3]));
- i++;
- }
- break;
- default:
- while(s[i].str) {
- s[i].function(num, GMSH_SET, CTX::instance()->packColor
- (s[i].def1[0], s[i].def1[1], s[i].def1[2], s[i].def1[3]));
- i++;
- }
- break;
- }
- }
- static void SetColorOptionsGUI(int num, StringXColor s[])
- {
- int i = 0;
- while(s[i].str) {
- s[i].function(num, GMSH_GUI, 0);
- i++;
- }
- }
- static void PrintColorOptions(int num, int level, int diff, int help,
- StringXColor s[], const char *prefix, FILE * file)
- {
- int i = 0;
- char tmp[1024];
- while(s[i].str) {
- if(s[i].level & level) {
- unsigned int def;
- switch (CTX::instance()->colorScheme) {
- case 1:
- def = CTX::instance()->packColor
- (s[i].def2[0], s[i].def2[1], s[i].def2[2], s[i].def2[3]);
- break;
- case 2:
- def = CTX::instance()->packColor
- (s[i].def3[0], s[i].def3[1], s[i].def3[2], s[i].def3[3]);
- break;
- default:
- def = CTX::instance()->packColor
- (s[i].def1[0], s[i].def1[1], s[i].def1[2], s[i].def1[3]);
- break;
- }
- if(!diff || (s[i].function(num, GMSH_GET, 0) != def)){
- sprintf(tmp, "%sColor.%s = {%d,%d,%d};%s%s",
- prefix, s[i].str,
- CTX::instance()->unpackRed(s[i].function(num, GMSH_GET, 0)),
- CTX::instance()->unpackGreen(s[i].function(num, GMSH_GET, 0)),
- CTX::instance()->unpackBlue(s[i].function(num, GMSH_GET, 0)),
- help ? " // " : "", help ? s[i].help : "");
- if(file)
- fprintf(file, "%s\n", tmp);
- else
- Msg::Direct(tmp);
- }
- }
- i++;
- }
- }
- static void PrintColorOptionsDoc(StringXColor s[], const char *prefix, FILE * file)
- {
- int i = 0;
- while(s[i].str) {
- fprintf(file, "@item %sColor.%s\n", prefix, s[i].str);
- fprintf(file, "%s@*\n", s[i].help);
- fprintf(file, "Default value: @code{@{%d,%d,%d@}}@*\n",
- CTX::instance()->unpackRed(s[i].function(0, GMSH_GET, 0)),
- CTX::instance()->unpackGreen(s[i].function(0, GMSH_GET, 0)),
- CTX::instance()->unpackBlue(s[i].function(0, GMSH_GET, 0)));
- fprintf(file, "Saved in: @code{%s}\n\n", GetOptionSaveLevel(s[i].level));
- i++;
- }
- }
- // General routines
- void InitOptions(int num)
- {
- // Default string options
- SetDefaultStringOptions(num, GeneralOptions_String);
- SetDefaultStringOptions(num, GeometryOptions_String);
- SetDefaultStringOptions(num, MeshOptions_String);
- SetDefaultStringOptions(num, SolverOptions_String);
- SetDefaultStringOptions(num, PostProcessingOptions_String);
- SetDefaultStringOptions(num, ViewOptions_String);
- SetDefaultStringOptions(num, PrintOptions_String);
- // Default number options
- SetDefaultNumberOptions(num, GeneralOptions_Number);
- SetDefaultNumberOptions(num, GeometryOptions_Number);
- SetDefaultNumberOptions(num, MeshOptions_Number);
- SetDefaultNumberOptions(num, SolverOptions_Number);
- SetDefaultNumberOptions(num, PostProcessingOptions_Number);
- SetDefaultNumberOptions(num, ViewOptions_Number);
- SetDefaultNumberOptions(num, PrintOptions_Number);
- // Default color options
- SetDefaultColorOptions(num, GeneralOptions_Color);
- SetDefaultColorOptions(num, GeometryOptions_Color);
- SetDefaultColorOptions(num, MeshOptions_Color);
- SetDefaultColorOptions(num, SolverOptions_Color);
- SetDefaultColorOptions(num, PostProcessingOptions_Color);
- SetDefaultColorOptions(num, ViewOptions_Color);
- SetDefaultColorOptions(num, PrintOptions_Color);
- }
- void ReInitOptions(int num)
- {
- // horrible trick so that opt_view_XXX will act on the reference view
- #if defined(HAVE_POST)
- std::vector<PView*> tmp = PView::list;
- PView::list.clear();
- #endif
- InitOptions(num);
- #if defined(HAVE_POST)
- PView::list = tmp;
- for(unsigned int i = 0; i < PView::list.size(); i++)
- PView::list[i]->setOptions();
- #endif
- }
- void InitOptionsGUI(int num)
- {
- SetStringOptionsGUI(num, GeneralOptions_String);
- SetStringOptionsGUI(num, GeometryOptions_String);
- SetStringOptionsGUI(num, MeshOptions_String);
- SetStringOptionsGUI(num, SolverOptions_String);
- SetStringOptionsGUI(num, PostProcessingOptions_String);
- SetStringOptionsGUI(num, PrintOptions_String);
- SetNumberOptionsGUI(num, GeneralOptions_Number);
- SetNumberOptionsGUI(num, GeometryOptions_Number);
- SetNumberOptionsGUI(num, MeshOptions_Number);
- SetNumberOptionsGUI(num, SolverOptions_Number);
- SetNumberOptionsGUI(num, PostProcessingOptions_Number);
- SetNumberOptionsGUI(num, PrintOptions_Number);
- SetColorOptionsGUI(num, GeneralOptions_Color);
- SetColorOptionsGUI(num, GeometryOptions_Color);
- SetColorOptionsGUI(num, MeshOptions_Color);
- SetColorOptionsGUI(num, SolverOptions_Color);
- SetColorOptionsGUI(num, PostProcessingOptions_Color);
- SetColorOptionsGUI(num, PrintOptions_Color);
- }
- static void PrintOptionCategory(int level, int diff, int help, const char *cat,
- FILE *file)
- {
- if(diff || !help || !(level & GMSH_FULLRC))
- return;
- if(file) {
- fprintf(file, "//\n");
- fprintf(file, "// %s\n", cat);
- fprintf(file, "//\n");
- }
- else {
- Msg::Direct("//");
- Msg::Direct("// %s", cat);
- Msg::Direct("//");
- }
- }
- GmshColorTable *GetColorTable(int num)
- {
- #if defined(HAVE_POST)
- PViewOptions *opt;
- if(PView::list.empty() || num < 0 || num > (int)PView::list.size() - 1)
- opt = PViewOptions::reference();
- else{
- opt = PView::list[num]->getOptions();
- // assume that if we access the colortable we will change it
- PView::list[num]->setChanged(true);
- }
- return &opt->colorTable;
- #else
- return 0;
- #endif
- }
- static void PrintColorTable(int num, int diff, const char *prefix, FILE *file)
- {
- #if defined(HAVE_POST)
- PViewOptions *opt;
- if(PView::list.empty() || num < 0 || num > (int)PView::list.size() - 1)
- opt = PViewOptions::reference();
- else
- opt = PView::list[num]->getOptions();
- if(diff){
- // compare the current colormap with a vanilla colormap having the
- // parameters
- GmshColorTable ref;
- ColorTable_InitParam(opt->colorTable.ipar[COLORTABLE_NUMBER], &ref);
- for(int i = 0; i < COLORTABLE_NBMAX_PARAM; i++){
- ref.ipar[i] = opt->colorTable.ipar[i];
- ref.dpar[i] = opt->colorTable.dpar[i];
- }
- ColorTable_Recompute(&ref);
- if(!ColorTable_Diff(&ref, &opt->colorTable))
- return;
- }
- char tmp[1024];
- sprintf(tmp, "%s = {", prefix);
- if(file)
- fprintf(file, "%s\n", tmp);
- else
- Msg::Direct(tmp);
- ColorTable_Print(&opt->colorTable, file);
- sprintf(tmp, "};");
- if(file)
- fprintf(file, "%s\n", tmp);
- else
- Msg::Direct(tmp);
- #endif
- }
- void Sanitize_String_Texi(std::string &s)
- {
- int i = -1;
- while ((i = s.find('\n', i + 1)) >= 0){
- s.insert(i, "@*");
- i += 2;
- }
- i = -1;
- while ((i = s.find_first_of("{}", i + 1)) >= 0)
- s.insert(i++, "@");
- }
- void PrintOptions(int num, int level, int diff, int help, const char *filename)
- {
- #if defined(HAVE_FLTK)
- if(FlGui::available())
- FlGui::instance()->storeCurrentWindowsInfo();
- #endif
- FILE *file;
- if(filename) {
- file = fopen(filename, "w");
- if(!file) {
- Msg::Error("Unable to open file '%s'", filename);
- return;
- }
- }
- else
- file = 0;
- if((level & GMSH_SESSIONRC) && file) {
- fprintf(file, "// Gmsh Session File\n");
- fprintf(file, "//\n");
- fprintf(file, "// This file contains session specific info (that is info you\n");
- fprintf(file, "// want to keep between two Gmsh sessions). You are not supposed\n");
- fprintf(file, "// to edit it manually, but of course you can. This file will be\n");
- fprintf(file, "// entirely rewritten every time you quit Gmsh if the option \n");
- fprintf(file, "// 'General.SaveSession' is set.\n");
- fprintf(file, "//\n");
- }
- if((level & GMSH_OPTIONSRC) && file) {
- fprintf(file, "// Gmsh Option File\n");
- fprintf(file, "//\n");
- fprintf(file, "// This file contains configuration options (preferences) that\n");
- fprintf(file, "// are loaded each time Gmsh is launched. You can create this\n");
- fprintf(file, "// file by hand, or let Gmsh generate it for you (with\n");
- fprintf(file, "// 'File->Save Default Options'). This file can also be\n");
- fprintf(file, "// automatically saved every time you quit Gmsh if the option\n");
- fprintf(file, "// 'General.SaveOptions' is set.\n");
- fprintf(file, "//\n");
- }
- PrintOptionCategory(level, diff, help, "General options (strings)", file);
- PrintStringOptions(num, level, diff, help, GeneralOptions_String, "General.", file);
- PrintOptionCategory(level, diff, help, "General options (numbers)", file);
- PrintNumberOptions(num, level, diff, help, GeneralOptions_Number, "General.", file);
- PrintOptionCategory(level, diff, help, "General options (colors)", file);
- PrintColorOptions(num, level, diff, help, GeneralOptions_Color, "General.", file);
- PrintOptionCategory(level, diff, help, "Geometry options (strings)", file);
- PrintStringOptions(num, level, diff, help, GeometryOptions_String, "Geometry.", file);
- PrintOptionCategory(level, diff, help, "Geometry options (numbers)", file);
- PrintNumberOptions(num, level, diff, help, GeometryOptions_Number, "Geometry.", file);
- PrintOptionCategory(level, diff, help, "Geometry options (colors)", file);
- PrintColorOptions(num, level, diff, help, GeometryOptions_Color, "Geometry.", file);
- PrintOptionCategory(level, diff, help, "Mesh options (strings)", file);
- PrintStringOptions(num, level, diff, help, MeshOptions_String, "Mesh.", file);
- PrintOptionCategory(level, diff, help, "Mesh options (numbers)", file);
- PrintNumberOptions(num, level, diff, help, MeshOptions_Number, "Mesh.", file);
- PrintOptionCategory(level, diff, help, "Mesh options (colors)", file);
- PrintColorOptions(num, level, diff, help, MeshOptions_Color, "Mesh.", file);
- PrintOptionCategory(level, diff, help, "Solver options (strings)", file);
- PrintStringOptions(num, level, diff, help, SolverOptions_String, "Solver.", file);
- PrintOptionCategory(level, diff, help, "Solver options (numbers)", file);
- PrintNumberOptions(num, level, diff, help, SolverOptions_Number, "Solver.", file);
- PrintOptionCategory(level, diff, help, "Solver options (colors)", file);
- PrintColorOptions(num, level, diff, help, SolverOptions_Color, "Solver.", file);
- PrintOptionCategory(level, diff, help, "Post-processing options (strings)", file);
- PrintStringOptions(num, level, diff, help, PostProcessingOptions_String,
- "PostProcessing.", file);
- PrintOptionCategory(level, diff, help, "Post-processing options (numbers)", file);
- PrintNumberOptions(num, level, diff, help, PostProcessingOptions_Number,
- "PostProcessing.", file);
- PrintOptionCategory(level, diff, help, "Post-processing options (colors)", file);
- PrintColorOptions(num, level, diff, help, PostProcessingOptions_Color,
- "PostProcessing.", file);
- if(level & GMSH_FULLRC) {
- #if defined(HAVE_POST)
- for(unsigned int i = 0; i < PView::list.size(); i++) {
- char tmp[256];
- sprintf(tmp, "View[%d].", i);
- PrintOptionCategory(level, diff, help, "View options (strings)", file);
- PrintStringOptions(i, level, diff, help, ViewOptions_String, tmp, file);
- PrintOptionCategory(level, diff, help, "View options (numbers)", file);
- PrintNumberOptions(i, level, diff, help, ViewOptions_Number, tmp, file);
- PrintOptionCategory(level, diff, help, "View options (colors)", file);
- PrintColorOptions(i, level, diff, help, ViewOptions_Color, tmp, file);
- strcat(tmp, "ColorTable");
- PrintColorTable(i, diff, tmp, file);
- }
- #endif
- }
- else if(level & GMSH_OPTIONSRC) {
- PrintOptionCategory(level, diff, help, "View options (strings)", file);
- PrintStringOptions(num, level, diff, help, ViewOptions_String, "View.", file);
- PrintOptionCategory(level, diff, help, "View options (numbers)", file);
- PrintNumberOptions(num, level, diff, help, ViewOptions_Number, "View.", file);
- PrintOptionCategory(level, diff, help, "View options (colors)", file);
- PrintColorOptions(num, level, diff, help, ViewOptions_Color, "View.", file);
- PrintColorTable(num, diff, "View.ColorTable", file);
- }
- PrintOptionCategory(level, diff, help, "Print options (strings)", file);
- PrintStringOptions(num, level, diff, help, PrintOptions_String, "Print.", file);
- PrintOptionCategory(level, diff, help, "Print options (numbers)", file);
- PrintNumberOptions(num, level, diff, help, PrintOptions_Number, "Print.", file);
- PrintOptionCategory(level, diff, help, "Print options (colors)", file);
- PrintColorOptions(num, level, diff, help, PrintOptions_Color, "Print.", file);
- if(filename) fclose(file);
- }
- void PrintOptionsDoc()
- {
- const char *warn =
- "@c\n"
- "@c This file is generated automatically by running \"gmsh -doc\".\n"
- "@c Do not edit by hand!\n"
- "@c\n\n";
- FILE *file = fopen("opt_general.texi", "w");
- if(!file) {
- Msg::Error("Unable to open file 'opt_general.texi'");
- return;
- }
- fprintf(file, "%s@ftable @code\n", warn);
- PrintStringOptionsDoc(GeneralOptions_String, "General.", file);
- PrintNumberOptionsDoc(GeneralOptions_Number, "General.", file);
- PrintColorOptionsDoc(GeneralOptions_Color, "General.", file);
- fprintf(file, "@end ftable\n");
- fclose(file);
- file = fopen("opt_print.texi", "w");
- if(!file) {
- Msg::Error("Unable to open file 'opt_print.texi'");
- return;
- }
- fprintf(file, "%s@ftable @code\n", warn);
- PrintStringOptionsDoc(PrintOptions_String, "Print.", file);
- PrintNumberOptionsDoc(PrintOptions_Number, "Print.", file);
- PrintColorOptionsDoc(PrintOptions_Color, "Print.", file);
- fprintf(file, "@end ftable\n");
- fclose(file);
- file = fopen("opt_geometry.texi", "w");
- if(!file) {
- Msg::Error("Unable to open file 'opt_geometry.texi'");
- return;
- }
- fprintf(file, "%s@ftable @code\n", warn);
- PrintStringOptionsDoc(GeometryOptions_String, "Geometry.", file);
- PrintNumberOptionsDoc(GeometryOptions_Number, "Geometry.", file);
- PrintColorOptionsDoc(GeometryOptions_Color, "Geometry.", file);
- fprintf(file, "@end ftable\n");
- fclose(file);
- file = fopen("opt_mesh.texi", "w");
- if(!file) {
- Msg::Error("Unable to open file 'opt_mesh.texi'");
- return;
- }
- fprintf(file, "%s@ftable @code\n", warn);
- PrintStringOptionsDoc(MeshOptions_String, "Mesh.", file);
- PrintNumberOptionsDoc(MeshOptions_Number, "Mesh.", file);
- PrintColorOptionsDoc(MeshOptions_Color, "Mesh.", file);
- fprintf(file, "@end ftable\n");
- fclose(file);
- file = fopen("opt_solver.texi", "w");
- if(!file) {
- Msg::Error("Unable to open file 'opt_solver.texi'");
- return;
- }
- fprintf(file, "%s@ftable @code\n", warn);
- PrintStringOptionsDoc(SolverOptions_String, "Solver.", file);
- PrintNumberOptionsDoc(SolverOptions_Number, "Solver.", file);
- PrintColorOptionsDoc(SolverOptions_Color, "Solver.", file);
- fprintf(file, "@end ftable\n");
- fclose(file);
- file = fopen("opt_post.texi", "w");
- if(!file) {
- Msg::Error("Unable to open file 'opt_post.texi'");
- return;
- }
- fprintf(file, "%s@ftable @code\n", warn);
- PrintStringOptionsDoc(PostProcessingOptions_String, "PostProcessing.", file);
- PrintNumberOptionsDoc(PostProcessingOptions_Number, "PostProcessing.", file);
- PrintColorOptionsDoc(PostProcessingOptions_Color, "PostProcessing.", file);
- fprintf(file, "@end ftable\n");
- fclose(file);
- #if defined(HAVE_POST)
- file = fopen("opt_view.texi", "w");
- if(!file) {
- Msg::Error("Unable to open file 'opt_view.texi'");
- return;
- }
- fprintf(file, "%s@ftable @code\n", warn);
- PrintStringOptionsDoc(ViewOptions_String, "View.", file);
- PrintNumberOptionsDoc(ViewOptions_Number, "View.", file);
- PrintColorOptionsDoc(ViewOptions_Color, "View.", file);
- fprintf(file, "@item View.ColorTable\n");
- fprintf(file, "Color table used to draw the view@*\n");
- fprintf(file, "Saved in: @code{%s}\n\n",
- GetOptionSaveLevel(GMSH_FULLRC|GMSH_OPTIONSRC));
- fprintf(file, "@end ftable\n");
- fclose(file);
- #endif
- #if defined(HAVE_PLUGINS)
- file = fopen("opt_plugin.texi", "w");
- if(!file) {
- Msg::Error("Unable to open file 'opt_plugin.texi'");
- return;
- }
- fprintf(file, "%s@ftable @code\n", warn);
- for(std::map<std::string, GMSH_Plugin*>::iterator it = PluginManager::
- instance()->begin(); it != PluginManager::instance()->end(); ++it) {
- GMSH_Plugin *p = it->second;
- if(p->getType() == GMSH_Plugin::GMSH_POST_PLUGIN) {
- fprintf(file, "@item Plugin(%s)\n", p->getName().c_str());
- fprintf(file, "%s\n", p->getHelp().c_str());
- int m = p->getNbOptionsStr();
- if(m){
- fprintf(file, "String options:\n");
- fprintf(file, "@table @code\n");
- for(int i = 0; i < m; i++) {
- StringXString *sxs = p->getOptionStr(i);
- fprintf(file, "@item %s\n", sxs->str);
- fprintf(file, "Default value: @code{\"%s\"}\n", sxs->def.c_str());
- }
- fprintf(file, "@end table\n");
- }
- int n = p->getNbOptions();
- if(n){
- fprintf(file, "Numeric options:\n");
- fprintf(file, "@table @code\n");
- for(int i = 0; i < n; i++) {
- StringXNumber *sxn = p->getOption(i);
- fprintf(file, "@item %s\n", sxn->str);
- fprintf(file, "Default value: @code{%g}\n", sxn->def);
- }
- fprintf(file, "@end table\n");
- }
- }
- fprintf(file, "\n");
- }
- fprintf(file, "@end ftable\n");
- fclose(file);
- #endif
- #if defined(HAVE_MESH)
- file = fopen("opt_fields.texi", "w");
- if(!file) {
- Msg::Error("Unable to open file 'opt_fields.texi'");
- return;
- }
- fprintf(file, "%s@ftable @code\n", warn);
- FieldManager &fields = *GModel::current()->getFields();
- for(std::map<std::string, FieldFactory*>::iterator it = fields.map_type_name.begin();
- it != fields.map_type_name.end(); it++){
- fprintf(file, "@item %s\n", it->first.c_str());
- Field *f = (*it->second)();
- std::string field_description = f->getDescription();
- Sanitize_String_Texi(field_description);
- fprintf(file,"%s@*\n", field_description.c_str());
- if (!f->options.empty()) {
- fprintf(file, "Options:@*\n");
- fprintf(file, "@table @code\n");
- for(std::map<std::string, FieldOption*>::iterator it2 = f->options.begin();
- it2 != f->options.end(); it2++){
- fprintf(file, "@item %s\n", it2->first.c_str());
- std::string val;
- it2->second->getTextRepresentation(val);
- Sanitize_String_Texi(val);
- fprintf(file, "%s@*\ntype: %s@*\ndefault value: @code{%s}\n",
- it2->second->getDescription().c_str(),
- it2->second->getTypeName().c_str(), val.c_str());
- }
- fprintf(file, "@end table\n\n");
- }
- if (!f->callbacks.empty()) {
- fprintf(file, "Actions:@*\n");
- fprintf(file, "@table @code\n");
- for(std::map<std::string, FieldCallback*>::iterator it2 = f->callbacks.begin();
- it2 != f->callbacks.end(); it2++){
- fprintf(file, "@item %s\n", it2->first.c_str());
- fprintf(file, "%s@*\n", it2->second->getDescription().c_str());
- }
- fprintf(file, "@end table\n\n");
- }
- }
- fprintf(file, "@end ftable\n");
- fclose(file);
- #endif
- }
- #define GET_VIEW(error_val) \
- PView *view = 0; \
- PViewData *data = 0; \
- PViewOptions *opt; \
- if(PView::list.empty()) \
- opt = PViewOptions::reference(); \
- else{ \
- if(num < 0 || num >= (int)PView::list.size()){ \
- Msg::Warning("View[%d] does not exist", num); \
- return (error_val); \
- } \
- view = PView::list[num]; \
- data = view->getData(); \
- opt = view->getOptions(); \
- }
- #define GET_VIEWo(error_val) \
- PView *view = 0; \
- PViewOptions *opt; \
- if(PView::list.empty()) \
- opt = PViewOptions::reference(); \
- else{ \
- if(num < 0 || num >= (int)PView::list.size()){ \
- Msg::Warning("View[%d] does not exist", num); \
- return (error_val); \
- } \
- view = PView::list[num]; \
- opt = view->getOptions(); \
- }
- #define GET_VIEWd(error_val) \
- PView *view = 0; \
- PViewData *data = 0; \
- if(!PView::list.empty()){ \
- if(num < 0 || num >= (int)PView::list.size()){ \
- Msg::Warning("View[%d] does not exist", num); \
- return (error_val); \
- } \
- view = PView::list[num]; \
- data = view->getData(); \
- }
- // String option routines
- std::string opt_general_axes_label0(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->axesLabel[0] = val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.input[6]->value
- (CTX::instance()->axesLabel[0].c_str());
- #endif
- return CTX::instance()->axesLabel[0];
- }
- std::string opt_general_axes_label1(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->axesLabel[1] = val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.input[7]->value
- (CTX::instance()->axesLabel[1].c_str());
- #endif
- return CTX::instance()->axesLabel[1];
- }
- std::string opt_general_axes_label2(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->axesLabel[2] = val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.input[8]->value
- (CTX::instance()->axesLabel[2].c_str());
- #endif
- return CTX::instance()->axesLabel[2];
- }
- std::string opt_general_axes_format0(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->axesFormat[0] = val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.input[3]->value
- (CTX::instance()->axesFormat[0].c_str());
- #endif
- return CTX::instance()->axesFormat[0];
- }
- std::string opt_general_axes_format1(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->axesFormat[1] = val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.input[4]->value
- (CTX::instance()->axesFormat[1].c_str());
- #endif
- return CTX::instance()->axesFormat[1];
- }
- std::string opt_general_axes_format2(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->axesFormat[2] = val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.input[5]->value
- (CTX::instance()->axesFormat[2].c_str());
- #endif
- return CTX::instance()->axesFormat[2];
- }
- std::string opt_general_display(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->display = val;
- return CTX::instance()->display;
- }
- std::string opt_general_background_image_filename(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->bgImageFileName = val;
- return CTX::instance()->bgImageFileName;
- }
- std::string opt_general_filename(OPT_ARGS_STR)
- {
- return GModel::current()->getFileName();
- }
- std::string opt_general_default_filename(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->defaultFileName = val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.input[0]->value
- (CTX::instance()->defaultFileName.c_str());
- #endif
- return CTX::instance()->defaultFileName;
- }
- std::string opt_general_tmp_filename(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->tmpFileName = val;
- return CTX::instance()->tmpFileName;
- }
- std::string opt_general_error_filename(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->errorFileName = val;
- return CTX::instance()->errorFileName;
- }
- std::string opt_general_session_filename(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->sessionFileName = val;
- return CTX::instance()->sessionFileName;
- }
- std::string opt_general_options_filename(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->optionsFileName = val;
- return CTX::instance()->optionsFileName;
- }
- std::string opt_general_recent_file0(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->recentFiles[0] = val;
- return CTX::instance()->recentFiles[0];
- }
- std::string opt_general_recent_file1(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->recentFiles[1] = val;
- return CTX::instance()->recentFiles[1];
- }
- std::string opt_general_recent_file2(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->recentFiles[2] = val;
- return CTX::instance()->recentFiles[2];
- }
- std::string opt_general_recent_file3(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->recentFiles[3] = val;
- return CTX::instance()->recentFiles[3];
- }
- std::string opt_general_recent_file4(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->recentFiles[4] = val;
- return CTX::instance()->recentFiles[4];
- }
- std::string opt_general_editor(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->editor = val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.input[1]->value
- (CTX::instance()->editor.c_str());
- #endif
- return CTX::instance()->editor;
- }
- std::string opt_general_web_browser(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->webBrowser = val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.input[2]->value
- (CTX::instance()->webBrowser.c_str());
- #endif
- return CTX::instance()->webBrowser;
- }
- std::string opt_general_watch_file_pattern(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->watchFilePattern = val;
- return CTX::instance()->watchFilePattern;
- }
- std::string opt_general_gui_theme(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->guiTheme = val;
- return CTX::instance()->guiTheme;
- }
- std::string opt_general_graphics_font(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->glFont = val;
- #if defined(HAVE_FLTK)
- int index = drawContext::global()->getFontIndex(CTX::instance()->glFont.c_str());
- if(action & GMSH_SET){
- CTX::instance()->glFont = drawContext::global()->getFontName(index);
- CTX::instance()->glFontEnum = drawContext::global()->getFontEnum(index);
- }
- if(FlGui::available() && (action & GMSH_GUI)){
- FlGui::instance()->options->general.choice[1]->value(index);
- }
- #endif
- return CTX::instance()->glFont;
- }
- std::string opt_general_graphics_font_title(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->glFontTitle = val;
- #if defined(HAVE_FLTK)
- int index = drawContext::global()->getFontIndex(CTX::instance()->glFontTitle.c_str());
- if(action & GMSH_SET){
- CTX::instance()->glFontTitle = drawContext::global()->getFontName(index);
- CTX::instance()->glFontEnumTitle = drawContext::global()->getFontEnum(index);
- }
- if(FlGui::available() && (action & GMSH_GUI)){
- FlGui::instance()->options->general.choice[6]->value(index);
- }
- #endif
- return CTX::instance()->glFontTitle;
- }
- std::string opt_solver_socket_name(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->solver.socketName = val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->solver.input[0]->value
- (CTX::instance()->solver.socketName.c_str());
- #endif
- return CTX::instance()->solver.socketName;
- }
- std::string opt_solver_name(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->solver.name[num] = val;
- return CTX::instance()->solver.name[num];
- }
- std::string opt_solver_name0(OPT_ARGS_STR)
- {
- return opt_solver_name(0, action, val);
- }
- std::string opt_solver_name1(OPT_ARGS_STR)
- {
- return opt_solver_name(1, action, val);
- }
- std::string opt_solver_name2(OPT_ARGS_STR)
- {
- return opt_solver_name(2, action, val);
- }
- std::string opt_solver_name3(OPT_ARGS_STR)
- {
- return opt_solver_name(3, action, val);
- }
- std::string opt_solver_name4(OPT_ARGS_STR)
- {
- return opt_solver_name(4, action, val);
- }
- std::string opt_solver_executable(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->solver.executable[num] = val;
- return CTX::instance()->solver.executable[num];
- }
- std::string opt_solver_executable0(OPT_ARGS_STR)
- {
- return opt_solver_executable(0, action, val);
- }
- std::string opt_solver_executable1(OPT_ARGS_STR)
- {
- return opt_solver_executable(1, action, val);
- }
- std::string opt_solver_executable2(OPT_ARGS_STR)
- {
- return opt_solver_executable(2, action, val);
- }
- std::string opt_solver_executable3(OPT_ARGS_STR)
- {
- return opt_solver_executable(3, action, val);
- }
- std::string opt_solver_executable4(OPT_ARGS_STR)
- {
- return opt_solver_executable(4, action, val);
- }
- std::string opt_solver_remote_login(OPT_ARGS_STR)
- {
- if(action & GMSH_SET)
- CTX::instance()->solver.remoteLogin[num] = val;
- return CTX::instance()->solver.remoteLogin[num];
- }
- std::string opt_solver_remote_login0(OPT_ARGS_STR)
- {
- return opt_solver_remote_login(0, action, val);
- }
- std::string opt_solver_remote_login1(OPT_ARGS_STR)
- {
- return opt_solver_remote_login(1, action, val);
- }
- std::string opt_solver_remote_login2(OPT_ARGS_STR)
- {
- return opt_solver_remote_login(2, action, val);
- }
- std::string opt_solver_remote_login3(OPT_ARGS_STR)
- {
- return opt_solver_remote_login(3, action, val);
- }
- std::string opt_solver_remote_login4(OPT_ARGS_STR)
- {
- return opt_solver_remote_login(4, action, val);
- }
- #if defined(HAVE_FLTK)
- int _gui_action_valid(int action, int num)
- {
- if(!FlGui::available()) return 0;
- return (action & GMSH_GUI) && (num == FlGui::instance()->options->view.index);
- }
- #endif
- std::string opt_view_name(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWd("");
- if(!data) return "";
- if(action & GMSH_SET) {
- data->setName(val);
- #if defined(HAVE_FLTK)
- // change name in GUI for the view and its aliases
- if(FlGui::available()){
- for(int i = 0; i < (int)PView::list.size(); i++){
- if((i == num ||
- PView::list[i]->getAliasOf() == view->getNum() ||
- PView::list[i]->getNum() == view->getAliasOf()) &&
- FlGui::instance()->onelab->getViewButton(i)) {
- FlGui::instance()->onelab->getViewButton(i)->copy_label(data->getName());
- FlGui::instance()->onelab->getViewButton(i)->redraw();
- }
- }
- }
- #endif
- }
- #if defined(HAVE_FLTK)
- if(_gui_action_valid(action, num)) {
- FlGui::instance()->options->view.input[0]->value(data->getName().c_str());
- }
- #endif
- return data->getName();
- #else
- return "";
- #endif
- }
- std::string opt_view_format(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->format = val;
- }
- #if defined(HAVE_FLTK)
- if(_gui_action_valid(action, num))
- FlGui::instance()->options->view.input[1]->value(opt->format.c_str());
- #endif
- return opt->format;
- #else
- return "";
- #endif
- }
- std::string opt_view_filename(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWd("");
- if(!data) return "";
- return data->getFileName();
- #else
- return "";
- #endif
- }
- std::string opt_view_axes_label0(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->axesLabel[0] = val;
- }
- #if defined(HAVE_FLTK)
- if(_gui_action_valid(action, num))
- FlGui::instance()->options->view.input[10]->value(opt->axesLabel[0].c_str());
- #endif
- return opt->axesLabel[0];
- #else
- return "";
- #endif
- }
- std::string opt_view_axes_label1(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->axesLabel[1] = val;
- }
- #if defined(HAVE_FLTK)
- if(_gui_action_valid(action, num))
- FlGui::instance()->options->view.input[11]->value(opt->axesLabel[1].c_str());
- #endif
- return opt->axesLabel[1];
- #else
- return "";
- #endif
- }
- std::string opt_view_axes_label2(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->axesLabel[2] = val;
- }
- #if defined(HAVE_FLTK)
- if(_gui_action_valid(action, num))
- FlGui::instance()->options->view.input[12]->value(opt->axesLabel[2].c_str());
- #endif
- return opt->axesLabel[2];
- #else
- return "";
- #endif
- }
- std::string opt_view_axes_format0(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->axesFormat[0] = val;
- }
- #if defined(HAVE_FLTK)
- if(_gui_action_valid(action, num))
- FlGui::instance()->options->view.input[7]->value(opt->axesFormat[0].c_str());
- #endif
- return opt->axesFormat[0];
- #else
- return "";
- #endif
- }
- std::string opt_view_axes_format1(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->axesFormat[1] = val;
- }
- #if defined(HAVE_FLTK)
- if(_gui_action_valid(action, num))
- FlGui::instance()->options->view.input[8]->value(opt->axesFormat[1].c_str());
- #endif
- return opt->axesFormat[1];
- #else
- return "";
- #endif
- }
- std::string opt_view_axes_format2(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->axesFormat[2] = val;
- }
- #if defined(HAVE_FLTK)
- if(_gui_action_valid(action, num))
- FlGui::instance()->options->view.input[9]->value(opt->axesFormat[2].c_str());
- #endif
- return opt->axesFormat[2];
- #else
- return "";
- #endif
- }
- std::string opt_view_gen_raise0(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->genRaiseX = val;
- if(view) view->setChanged(true);
- }
- #if defined(HAVE_FLTK)
- if(_gui_action_valid(action, num))
- FlGui::instance()->options->view.input[4]->value(opt->genRaiseX.c_str());
- #endif
- return opt->genRaiseX;
- #else
- return "";
- #endif
- }
- std::string opt_view_gen_raise1(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->genRaiseY = val;
- if(view) view->setChanged(true);
- }
- #if defined(HAVE_FLTK)
- if(_gui_action_valid(action, num))
- FlGui::instance()->options->view.input[5]->value(opt->genRaiseY.c_str());
- #endif
- return opt->genRaiseY;
- #else
- return "";
- #endif
- }
- std::string opt_view_gen_raise2(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->genRaiseZ = val;
- if(view) view->setChanged(true);
- }
- #if defined(HAVE_FLTK)
- if(_gui_action_valid(action, num))
- FlGui::instance()->options->view.input[6]->value(opt->genRaiseZ.c_str());
- #endif
- return opt->genRaiseZ;
- #else
- return "";
- #endif
- }
- int _h2d(char c)
- {
- switch(c){
- case 'a': case 'A': return 10;
- case 'b': case 'B': return 11;
- case 'c': case 'C': return 12;
- case 'd': case 'D': return 13;
- case 'e': case 'E': return 14;
- case 'f': case 'F': return 15;
- default :
- if(c >= '0' && c <= '9')
- return c - '0';
- else
- return 0;
- }
- }
- void _string2stipple(std::string str, int &repeat, int &pattern)
- {
- // "n*0xabcd"
- if(str.size() < 8){
- repeat = 1;
- pattern = 0xFFFF;
- }
- else if(str[1] != '*' || str[2] != '0' || str[3] != 'x'){
- // bad format
- repeat = 1;
- pattern = 0xFFFF;
- }
- else{
- repeat = (int)str[0] - '0';
- pattern = 16 * 16 * 16 * _h2d(str[4]) + 16 * 16 * _h2d(str[5]) +
- 16 * _h2d(str[6]) + _h2d(str[7]);
- }
- }
- std::string opt_view_stipple0(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->stippleString[0] = val;
- _string2stipple(opt->stippleString[0], opt->stipple[0][0], opt->stipple[0][1]);
- }
- return opt->stippleString[0];
- #else
- return "";
- #endif
- }
- std::string opt_view_stipple1(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->stippleString[1] = val;
- _string2stipple(opt->stippleString[1], opt->stipple[1][0], opt->stipple[1][1]);
- }
- return opt->stippleString[1];
- #else
- return "";
- #endif
- }
- std::string opt_view_stipple2(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->stippleString[2] = val;
- _string2stipple(opt->stippleString[2], opt->stipple[2][0], opt->stipple[2][1]);
- }
- return opt->stippleString[2];
- #else
- return "";
- #endif
- }
- std::string opt_view_stipple3(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->stippleString[3] = val;
- _string2stipple(opt->stippleString[3], opt->stipple[3][0], opt->stipple[3][1]);
- }
- return opt->stippleString[3];
- #else
- return "";
- #endif
- }
- std::string opt_view_stipple4(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->stippleString[4] = val;
- _string2stipple(opt->stippleString[4], opt->stipple[4][0], opt->stipple[4][1]);
- }
- return opt->stippleString[4];
- #else
- return "";
- #endif
- }
- std::string opt_view_stipple5(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->stippleString[5] = val;
- _string2stipple(opt->stippleString[5], opt->stipple[5][0], opt->stipple[5][1]);
- }
- return opt->stippleString[5];
- #else
- return "";
- #endif
- }
- std::string opt_view_stipple6(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->stippleString[6] = val;
- _string2stipple(opt->stippleString[6], opt->stipple[6][0], opt->stipple[6][1]);
- }
- return opt->stippleString[6];
- #else
- return "";
- #endif
- }
- std::string opt_view_stipple7(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->stippleString[7] = val;
- _string2stipple(opt->stippleString[7], opt->stipple[7][0], opt->stipple[7][1]);
- }
- return opt->stippleString[7];
- #else
- return "";
- #endif
- }
- std::string opt_view_stipple8(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->stippleString[8] = val;
- _string2stipple(opt->stippleString[8], opt->stipple[8][0], opt->stipple[8][1]);
- }
- return opt->stippleString[8];
- #else
- return "";
- #endif
- }
- std::string opt_view_stipple9(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET) {
- opt->stippleString[9] = val;
- _string2stipple(opt->stippleString[9], opt->stipple[9][0], opt->stipple[9][1]);
- }
- return opt->stippleString[9];
- #else
- return "";
- #endif
- }
- std::string opt_view_attributes(OPT_ARGS_STR)
- {
- #if defined(HAVE_POST)
- GET_VIEWo("");
- if(action & GMSH_SET)
- opt->attributes = val;
- return opt->attributes;
- #else
- return "";
- #endif
- }
- // Numeric option routines
- double opt_general_initial_context(OPT_ARGS_NUM)
- {
- if(action & GMSH_SET)
- CTX::instance()->initialContext = (int)val;
- return CTX::instance()->initialContext;
- }
- double opt_general_fontsize(OPT_ARGS_NUM)
- {
- if(action & GMSH_SET)
- CTX::instance()->fontSize = (int)val;
- return CTX::instance()->fontSize;
- }
- double opt_general_graphics_fontsize(OPT_ARGS_NUM)
- {
- if(action & GMSH_SET)
- CTX::instance()->glFontSize = (int)val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.value[12]->value
- (CTX::instance()->glFontSize);
- #endif
- return CTX::instance()->glFontSize;
- }
- double opt_general_graphics_fontsize_title(OPT_ARGS_NUM)
- {
- if(action & GMSH_SET)
- CTX::instance()->glFontSizeTitle = (int)val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.value[28]->value
- (CTX::instance()->glFontSizeTitle);
- #endif
- return CTX::instance()->glFontSizeTitle;
- }
- double opt_general_polygon_offset_always(OPT_ARGS_NUM)
- {
- if(action & GMSH_SET)
- CTX::instance()->polygonOffsetAlways = (int)val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.butt[4]->value
- (CTX::instance()->polygonOffsetAlways);
- #endif
- return CTX::instance()->polygonOffsetAlways;
- }
- double opt_general_polygon_offset_factor(OPT_ARGS_NUM)
- {
- if(action & GMSH_SET)
- CTX::instance()->polygonOffsetFactor = val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.value[15]->value
- (CTX::instance()->polygonOffsetFactor);
- #endif
- return CTX::instance()->polygonOffsetFactor;
- }
- double opt_general_polygon_offset_units(OPT_ARGS_NUM)
- {
- if(action & GMSH_SET)
- CTX::instance()->polygonOffsetUnits = val;
- #if defined(HAVE_FLTK)
- if(FlGui::available() && (action & GMSH_GUI))
- FlGui::instance()->options->general.value[16]->value
- (CTX::instance()->polygonOffsetUnits);
- #endif
- return CTX::instance()->polygonOffsetUnits;
- }
- double opt_general_graphics_position0(OPT_ARGS_NUM)
- {
- if(action & GMSH_SET)
- CTX::instance()->glPosition[0] = (int)val;
- re…
Large files files are truncated, but you can click here to view the full file