diff --git a/Box/Main.cpp b/Box/Main.cpp index 9937cb5b2b4bc965fe2e986173650f549244a737..1c4965cabe5607232e864413b6a3dd9fbdcb0b4c 100644 --- a/Box/Main.cpp +++ b/Box/Main.cpp @@ -1,4 +1,4 @@ -// $Id: Main.cpp,v 1.1 2001-02-17 22:08:53 geuzaine Exp $ +// $Id: Main.cpp,v 1.2 2001-02-20 18:32:58 geuzaine Exp $ #include <signal.h> @@ -10,6 +10,7 @@ #include "Views.h" #include "Parser.h" #include "Context.h" +#include "Options.h" #include "OpenFile.h" #include "GetOptions.h" #include "MinMax.h" @@ -34,7 +35,7 @@ void Info (int level, char *arg0){ case 0 : fprintf(stderr, "%s\n", gmsh_progname); fprintf(stderr, "%s\n", gmsh_copyright); - Print_Options(arg0); + Print_Usage(arg0); exit(1); case 1: fprintf(stderr, "%.2f\n", GMSH_VERSION); @@ -60,7 +61,10 @@ void Info (int level, char *arg0){ int main(int argc, char *argv[]){ int i, nbf; - Init_Context(0); + if(argc < 2) Info(0,argv[0]); + + Init_Options(0); + Get_Options(argc, argv, &nbf); signal(SIGINT, Signal); @@ -81,8 +85,8 @@ int main(int argc, char *argv[]){ else fprintf(stderr, ERROR_STR "Invalid BGM (no view)\n"); exit(1); } - if(CTX.interactive > 0){ - mai3d(THEM, CTX.interactive); + if(CTX.batch > 0){ + mai3d(THEM, CTX.batch); Print_Mesh(THEM,NULL,CTX.mesh.format); } exit(1); @@ -120,6 +124,10 @@ void Msg(int level, char *fmt, ...){ switch(level){ + case DIRECT : + vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); + break; + case FATAL : case FATAL1 : case FATAL2 : @@ -158,12 +166,18 @@ void Msg(int level, char *fmt, ...){ } break ; - case DIRECT : - vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); + case DEBUG : + case DEBUG1 : + case DEBUG2 : + case DEBUG3 : + if(CTX.verbosity > 2){ + fprintf(stderr, DEBUG_STR); + vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); + } break; default : - if(CTX.verbosity == 5){ + if(CTX.verbosity > 0){ fprintf(stderr, INFO_STR); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); } diff --git a/Common/Context.cpp b/Common/Context.cpp index 75521088e3ad032f6fbe121102eae5ffe6a3ceaa..7f12dd27322540dfe7efb73a05cd55f695016a4d 100644 --- a/Common/Context.cpp +++ b/Common/Context.cpp @@ -1,4 +1,4 @@ -// $Id: Context.cpp,v 1.38 2001-02-19 11:54:28 geuzaine Exp $ +// $Id: Context.cpp,v 1.39 2001-02-20 18:32:58 geuzaine Exp $ #include "Gmsh.h" #include "Const.h" @@ -12,346 +12,6 @@ extern Context_T CTX ; -// STRING OPTIONS - -StringXString * Get_StringOptionCategory(char * cat){ - if (!strcmp(cat,"General")) return GeneralOptions_String ; - else if(!strcmp(cat,"Geometry")) return GeometryOptions_String ; - else if(!strcmp(cat,"Mesh")) return MeshOptions_String ; - else if(!strcmp(cat,"PostProcessing")) return PostProcessingOptions_String ; - else if(!strcmp(cat,"View")) return ViewOptions_String ; - else if(!strcmp(cat,"Print")) return PrintOptions_String ; - else return NULL ; -} - -void Set_DefaultStringOptions(int num, StringXString s[]){ - int i = 0; - while(s[i].str){ - s[i].function(num, GMSH_SET, s[i].def) ; - i++; - } -} - -void Set_StringOptions_GUI(int num, StringXString s[]){ - int i = 0; - while(s[i].str){ - s[i].function(num, GMSH_GUI, 0) ; - i++; - } -} - -void * Get_StringOption(char *str, StringXString s[]){ - int i = 0; - while ((s[i].str != NULL) && (strcmp(s[i].str, str))) i++ ; - if(!s[i].str) - return NULL; - else - return (void*)s[i].function; -} - -void Print_StringOptions(int num, int level, StringXString s[], char *prefix, FILE *file){ - int i = 0; - char tmp[1024]; - while(s[i].str){ - if(s[i].level & level){ - sprintf(tmp, "%s%s = \"%s\";", prefix, s[i].str, s[i].function(num, GMSH_GET, NULL)) ; - if(file) fprintf(file, "%s\n", tmp); else Msg(DIRECT, "%s", tmp); - } - i++; - } -} - -// NUMBER OPTIONS - -StringXNumber * Get_NumberOptionCategory(char * cat){ - if (!strcmp(cat,"General")) return GeneralOptions_Number ; - else if(!strcmp(cat,"Geometry")) return GeometryOptions_Number ; - else if(!strcmp(cat,"Mesh")) return MeshOptions_Number ; - else if(!strcmp(cat,"PostProcessing")) return PostProcessingOptions_Number ; - else if(!strcmp(cat,"View")) return ViewOptions_Number ; - else if(!strcmp(cat,"Print")) return PrintOptions_Number ; - else return NULL ; -} - -void Set_DefaultNumberOptions(int num, StringXNumber s[]){ - int i = 0; - while(s[i].str){ - s[i].function(num, GMSH_SET, s[i].def) ; - i++; - } -} - -void Set_NumberOptions_GUI(int num, StringXNumber s[]){ - int i = 0; - while(s[i].str){ - s[i].function(num, GMSH_GUI, 0) ; - i++ ; - } -} - -void * Get_NumberOption(char *str, StringXNumber s[]){ - int i = 0; - - while ((s[i].str != NULL) && (strcmp(s[i].str, str))) i++ ; - if(!s[i].str) - return NULL; - else{ - return (void*)s[i].function; - } -} - -void Print_NumberOptions(int num, int level, StringXNumber s[], char *prefix, FILE *file){ - int i = 0; - char tmp[1024]; - while(s[i].str){ - if(s[i].level & level){ - sprintf(tmp, "%s%s = %g;", prefix, s[i].str, s[i].function(num, GMSH_GET, 0)); - if(file) fprintf(file, "%s\n", tmp); else Msg(DIRECT, tmp); - } - i++; - } -} - -// COLOR OPTIONS - -StringXColor * Get_ColorOptionCategory(char * cat){ - if (!strcmp(cat,"General")) return GeneralOptions_Color ; - else if(!strcmp(cat,"Geometry")) return GeometryOptions_Color ; - else if(!strcmp(cat,"Mesh")) return MeshOptions_Color ; - else if(!strcmp(cat,"PostProcessing")) return PostProcessingOptions_Color ; - else if(!strcmp(cat,"View")) return ViewOptions_Color ; - else if(!strcmp(cat,"Print")) return PrintOptions_Color ; - else return NULL ; -} - -void Set_DefaultColorOptions(int num, StringXColor s[], int scheme){ - int i = 0; - switch(scheme){ - case 0 : - while(s[i].str){ - s[i].function(num, GMSH_SET, s[i].def1) ; - i++; - } - break; - case 1 : - while(s[i].str){ - s[i].function(num, GMSH_SET, s[i].def2) ; - i++; - } - break; - case 2 : - while(s[i].str){ - s[i].function(num, GMSH_SET, s[i].def3) ; - i++; - } - break; - } -} - -void Set_ColorOptions_GUI(int num, StringXColor s[]){ - int i = 0; - while(s[i].str){ - s[i].function(num, GMSH_GUI, 0) ; - i++; - } -} - -void * Get_ColorOption(char *str, StringXColor s[]) { - int i = 0; - while ((s[i].str != NULL) && (strcmp(s[i].str, str))) i++ ; - if(!s[i].str) - return NULL; - else - return (void*)s[i].function; -} - -void Print_ColorOptions(int num, int level, StringXColor s[], char *prefix, FILE *file){ - int i = 0; - char tmp[1024]; - while(s[i].str){ - if(s[i].level & level){ - sprintf(tmp, "%sColor.%s = {%d,%d,%d};", - prefix, s[i].str, - UNPACK_RED (s[i].function(num, GMSH_GET, 0)), - UNPACK_GREEN(s[i].function(num, GMSH_GET, 0)), - UNPACK_BLUE (s[i].function(num, GMSH_GET, 0))); - if(file) fprintf(file, "%s\n", tmp); else Msg(DIRECT, tmp); - } - i++; - } -} - -int Get_ColorForString(StringX4Int SX4I[], int alpha, - char * str, int * FlagError) { - int i = 0 ; - while ((SX4I[i].str != NULL) && (strcmp(SX4I[i].str, str))) i++ ; - *FlagError = (SX4I[i].str == NULL)? 1 : 0 ; - if(alpha > 0) - return PACK_COLOR(SX4I[i].int1,SX4I[i].int2,SX4I[i].int3,alpha) ; - else - return PACK_COLOR(SX4I[i].int1,SX4I[i].int2,SX4I[i].int3,SX4I[i].int4) ; -} - - -/* ------------------------------------------------------------------------ */ -/* C o n t e x t */ -/* ------------------------------------------------------------------------ */ - -void Init_Context(int num){ - - // Reference view storing default options - Post_ViewReference = (Post_View*)Malloc(sizeof(Post_View)) ; - Post_ViewReference->CT.size = 255; - Post_ViewReference->CT.ipar[COLORTABLE_MODE] = COLORTABLE_RGB; - ColorTable_InitParam(1, &Post_ViewReference->CT, 1, 1); - ColorTable_Recompute(&Post_ViewReference->CT, 1, 1); - - // Default string options - Set_DefaultStringOptions(num, GeneralOptions_String); - Set_DefaultStringOptions(num, GeometryOptions_String); - Set_DefaultStringOptions(num, MeshOptions_String); - Set_DefaultStringOptions(num, PostProcessingOptions_String); - Set_DefaultStringOptions(num, ViewOptions_String); - Set_DefaultStringOptions(num, PrintOptions_String); - - // Default number options - Set_DefaultNumberOptions(num, GeneralOptions_Number); - Set_DefaultNumberOptions(num, GeometryOptions_Number); - Set_DefaultNumberOptions(num, MeshOptions_Number); - Set_DefaultNumberOptions(num, PostProcessingOptions_Number); - Set_DefaultNumberOptions(num, ViewOptions_Number); - Set_DefaultNumberOptions(num, PrintOptions_Number); - - // Default color options - Set_DefaultColorOptions(num, GeneralOptions_Color, CTX.color_scheme); - Set_DefaultColorOptions(num, GeometryOptions_Color, CTX.color_scheme); - Set_DefaultColorOptions(num, MeshOptions_Color, CTX.color_scheme); - Set_DefaultColorOptions(num, PostProcessingOptions_Color, CTX.color_scheme); - Set_DefaultColorOptions(num, ViewOptions_Color, CTX.color_scheme); - Set_DefaultColorOptions(num, PrintOptions_Color, CTX.color_scheme); - - // The following cannot be set by the user - CTX.expose = 0 ; - CTX.db = 1 ; // motif only - CTX.overlay = 1 ; // motif only - CTX.stream = TO_SCREEN ; - CTX.command_win = 0 ; // motif only - CTX.threads = 1 ; // motif only - CTX.threads_lock = 0 ; // motif only - CTX.gl_fontheight = 12; - CTX.gl_fontascent = 8; - CTX.font = "-*-helvetica-medium-r-*-*-*-*-*-*-*-*-*-*" ; // motif only - CTX.fixed_font = "fixed" ; // motif only - CTX.lc = 1.0 ; - CTX.viewport[0] = CTX.viewport[1] = 0 ; - CTX.min[0] = CTX.min[1] = CTX.min[2] = 0.0 ; - CTX.max[0] = CTX.max[1] = CTX.max[2] = 1.0 ; - CTX.range[0] = CTX.range[1] = CTX.range[2] = 1.0 ; - CTX.vxmin = CTX.vymin = CTX.vxmax = CTX.vymax = 0. ; - CTX.render_mode = GMSH_RENDER ; - CTX.pixel_equiv_x = CTX.pixel_equiv_y = 0. ; - CTX.geom.vis_type = 0 ; - CTX.geom.level = ELEMENTARY ; - CTX.mesh.vis_type = 0 ; - CTX.mesh.draw = 1 ; - CTX.post.draw = 1 ; -} - -void Init_Context_GUI(int num){ - Set_StringOptions_GUI(num, GeneralOptions_String); - Set_StringOptions_GUI(num, GeometryOptions_String); - Set_StringOptions_GUI(num, MeshOptions_String); - Set_StringOptions_GUI(num, PostProcessingOptions_String); - Set_StringOptions_GUI(num, PrintOptions_String); - - Set_NumberOptions_GUI(num, GeneralOptions_Number); - Set_NumberOptions_GUI(num, GeometryOptions_Number); - Set_NumberOptions_GUI(num, MeshOptions_Number); - Set_NumberOptions_GUI(num, PostProcessingOptions_Number); - Set_NumberOptions_GUI(num, PrintOptions_Number); - - Set_ColorOptions_GUI(num, GeneralOptions_Color); - Set_ColorOptions_GUI(num, GeometryOptions_Color); - Set_ColorOptions_GUI(num, MeshOptions_Color); - Set_ColorOptions_GUI(num, PostProcessingOptions_Color); - Set_ColorOptions_GUI(num, PrintOptions_Color); -} - -void Print_Context(int num, int level, char *filename){ - FILE *file; - char tmp[256]; - int i ; - - if(filename){ - file = fopen(filename,"w"); - if(!file){ - Msg(WARNING, "Unable to Open File '%s'", filename); - return; - } - } - else - file = NULL ; - - if((level & GMSH_SESSIONRC) && file){ - fprintf(file, "// Gmsh Session File\n"); - fprintf(file, "// This file takes session specific info (that is info\n"); - fprintf(file, "// you want to keep between two Gmsh sessions). You are\n"); - fprintf(file, "// not supposed to edit it manually, but of course you\n"); - fprintf(file, "// can do. This file will be entirely rewritten every time\n"); - fprintf(file, "// you quit Gmsh. If this file isn't found, defaults\n"); - fprintf(file, "// are used.\n"); - } - - if((level & GMSH_OPTIONSRC) && file){ - fprintf(file, "// Gmsh Option File\n"); - fprintf(file, "// This file takes configuration options that should\n"); - fprintf(file, "// be loaded each time Gmsh is launched. You can create\n"); - fprintf(file, "// this file by hand, or let Gmsh generate it for you (with\n"); - fprintf(file, "// the 'File->Save Options' menu button). If this file\n"); - fprintf(file, "// isn't found, defaults are used.\n"); - } - - Print_StringOptions(num, level, GeneralOptions_String, "General.", file); - Print_NumberOptions(num, level, GeneralOptions_Number, "General.", file); - Print_ColorOptions(num, level, GeneralOptions_Color, "General.", file); - Print_StringOptions(num, level, GeometryOptions_String, "Geometry.", file); - Print_NumberOptions(num, level, GeometryOptions_Number, "Geometry.", file); - Print_ColorOptions(num, level, GeometryOptions_Color, "Geometry.", file); - Print_StringOptions(num, level, MeshOptions_String, "Mesh.", file); - Print_NumberOptions(num, level, MeshOptions_Number, "Mesh.", file); - Print_ColorOptions(num, level, MeshOptions_Color, "Mesh.", file); - Print_StringOptions(num, level, PostProcessingOptions_String, "PostProcessing.", file); - Print_NumberOptions(num, level, PostProcessingOptions_Number, "PostProcessing.", file); - Print_ColorOptions(num, level, PostProcessingOptions_Color, "PostProcessing.", file); - if(level & GMSH_FULLRC){ - for(i=0; i<List_Nbr(Post_ViewList) ; i++){ - sprintf(tmp, "View[%d].", i); - Print_StringOptions(i, level, ViewOptions_String, tmp, file); - Print_NumberOptions(i, level, ViewOptions_Number, tmp, file); - Print_ColorOptions(i, level, ViewOptions_Color, tmp, file); - strcat(tmp, "ColorTable"); - Print_ColorTable(i, tmp, file); - } - } - else if(level & GMSH_OPTIONSRC){ - Print_StringOptions(num, level, ViewOptions_String, "View.", file); - Print_NumberOptions(num, level, ViewOptions_Number, "View.", file); - Print_ColorOptions(num, level, ViewOptions_Color, "View.", file); - Print_ColorTable(num, "View.ColorTable", file); - } - Print_StringOptions(num, level, PrintOptions_String, "Print.", file); - Print_NumberOptions(num, level, PrintOptions_Number, "Print.", file); - Print_ColorOptions(num, level, PrintOptions_Color, "Print.", file); - - if(filename){ - if((level & GMSH_OPTIONSRC) || (level & GMSH_FULLRC)){ - Msg(INFO, "Options Output Complete '%s'", filename); - Msg(STATUS2, "Wrote '%s'", filename); - } - fclose(file); - } -} - /* 3 rotations successives autour de x, y et z: diff --git a/Common/Context.h b/Common/Context.h index e9e4a4a5bf73f9c56a43008baa5a964eaec3d680..b963dcc2e29ae745039bd454976178a944d40ab2 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -45,7 +45,7 @@ public : int msg_size[2]; // size of the message window on the screen int center_windows; // center popup windows on the menu window - int interactive; // 0=full gfx; -1=just parse; 1,2,3=batch mesh + int batch; // 0=full gfx; -1=just parse; 1,2,3=batch 1D, 2D, 3D mesh int verbosity; // 0=silent -> 3=debug int expose; // 1 if everything is ready to expose and draw @@ -181,8 +181,4 @@ public : void addQuaternion (float p1x, float p1y, float p2x, float p2y); }; -void Init_Context (int num); -void Init_Context_GUI (int num); -void Print_Context(int num, int level, char *filename); - #endif diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 232f652686fe9ab1e74c527025789fe72ae676f8..72403fb3c2621342d9597fb1c697cffffb620bab 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -79,7 +79,11 @@ StringXNumber GeneralOptions_Number[] = { { F, "ScaleZ" , opt_general_scale2 , 1.0 }, { F|O, "Shininess" , opt_general_shine , 0.4 }, { F|O, "ColorScheme", opt_general_color_scheme , 0. }, +#ifdef _BLACKBOX + { F|O, "Verbosity" , opt_general_verbosity , 0. }, +#else { F|O, "Verbosity" , opt_general_verbosity , 2. }, +#endif #ifdef _FLTK { F|O, "Terminal" , opt_general_terminal , 0. }, #else diff --git a/Common/GetOptions.cpp b/Common/GetOptions.cpp index 2f06a9a3f5e7d4e580c5aa4707467ed6fe96a083..9e1a73bc3f78878eb7dc2b75887dbb4308603e26 100644 --- a/Common/GetOptions.cpp +++ b/Common/GetOptions.cpp @@ -1,4 +1,4 @@ -// $Id: GetOptions.cpp,v 1.11 2001-02-17 21:56:58 geuzaine Exp $ +// $Id: GetOptions.cpp,v 1.12 2001-02-20 18:32:58 geuzaine Exp $ #include "Gmsh.h" #include "GmshUI.h" @@ -28,7 +28,7 @@ char gmsh_url[] = "URL : http://www.geuz.org/gmsh/" ; char gmsh_email[] = "E-Mail : Christophe.Geuzaine@ulg.ac.be\n" " Remacle@scorec.rpi.edu" ; -void Print_Options(char *name){ +void Print_Usage(char *name){ Msg(DIRECT, "Usage: %s [options] [files]", name); Msg(DIRECT, "Geometry options:"); Msg(DIRECT, " -0 parse input files, output flattened geometry, and exit"); @@ -65,11 +65,7 @@ void Print_Options(char *name){ Msg(DIRECT, " -perspective set projection mode to perspective"); #endif Msg(DIRECT, "Other options:"); -#ifndef _BLACKBOX Msg(DIRECT, " -v int set verbosity level (default: 2)"); -#else - Msg(DIRECT, " -v be verbose"); -#endif #ifdef _MOTIF Msg(DIRECT, " -nothreads disable threads"); #endif @@ -82,11 +78,6 @@ void Print_Options(char *name){ void Get_Options (int argc, char *argv[], int *nbfiles) { int i=1; -#ifdef _BLACKBOX - void Info (int level, char *arg0); - if(argc < 2) Info(0,argv[0]); -#endif - // Parse session and option files ParseFile(CTX.sessionrc_filename); @@ -102,16 +93,16 @@ void Get_Options (int argc, char *argv[], int *nbfiles) { if (argv[i][0] == '-') { if(!strcmp(argv[i]+1, "0")){ - CTX.interactive = -1; i++; + CTX.batch = -1; i++; } else if(!strcmp(argv[i]+1, "1")){ - CTX.interactive = 1; i++; + CTX.batch = 1; i++; } else if(!strcmp(argv[i]+1, "2")){ - CTX.interactive = 2; i++; + CTX.batch = 2; i++; } else if(!strcmp(argv[i]+1, "3")){ - CTX.interactive = 3; i++; + CTX.batch = 3; i++; } else if(!strcmp(argv[i]+1, "bgm")){ i++; @@ -284,16 +275,9 @@ void Get_Options (int argc, char *argv[], int *nbfiles) { fprintf(stderr, "%s\n", gmsh_progname); fprintf(stderr, "%s\n", gmsh_copyright); CTX.terminal = 1 ; - Print_Options(argv[0]); + Print_Usage(argv[0]); exit(1); } - - -#ifdef _BLACKBOX - else if(!strcmp(argv[i]+1, "v")){ - CTX.verbosity = 5; i++; - } -#else else if(!strcmp(argv[i]+1, "v")){ i++; if(argv[i]!=NULL) CTX.verbosity = atoi(argv[i++]); @@ -302,6 +286,7 @@ void Get_Options (int argc, char *argv[], int *nbfiles) { exit(1); } } +#ifndef _BLACKBOX else if(!strcmp(argv[i]+1, "noterm")){ CTX.terminal = 0; i++; } @@ -411,13 +396,13 @@ void Get_Options (int argc, char *argv[], int *nbfiles) { exit(1); } } -#endif // _BLACKBOX +#endif // !_BLACKBOX else{ fprintf(stderr, "Unknown Option '%s'\n", argv[i]); CTX.terminal = 1 ; - Print_Options(argv[0]); + Print_Usage(argv[0]); exit(1); } } diff --git a/Common/GetOptions.h b/Common/GetOptions.h index cbac01cf89685befe28c40724df9696aabf23af8..ef63b0b98a0fccbbf812fbf6ee05bae0067a903d 100644 --- a/Common/GetOptions.h +++ b/Common/GetOptions.h @@ -6,9 +6,8 @@ extern char gmsh_date[], gmsh_host[], gmsh_packager[], gmsh_url[]; extern char gmsh_email[], gmsh_gui[]; extern char *TheFileNameTab[MAX_OPEN_FILES], *TheBgmFileName; -extern char ThePathForIncludes[NAME_STR_L]; -void Get_Options (int argc, char *argv[], int *nbfiles); -void Print_Options (char *name); +void Get_Options(int argc, char *argv[], int *nbfiles); +void Print_Usage(char *name); #endif diff --git a/Common/Options.cpp b/Common/Options.cpp index 12f8dc07f0da390fc9db0124abbf1dbb9b0c3dc7..ff2ee6da17dc8724e2df47f9b8dee9b64a57f329 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.2 2001-02-17 22:13:03 geuzaine Exp $ +// $Id: Options.cpp,v 1.3 2001-02-20 18:32:58 geuzaine Exp $ #include "Gmsh.h" #include "GmshUI.h" @@ -8,8 +8,6 @@ #include "Context.h" #include "Options.h" -// action is a combination of GMSH_SET, GMSH_GET, GMSH_GUI - extern Context_T CTX ; #ifdef _FLTK @@ -17,6 +15,350 @@ extern Context_T CTX ; extern GUI *WID ; #endif +// ************** General routines **************************************** + +void Init_Options(int num){ + + // Reference view storing default options + Post_ViewReference = (Post_View*)Malloc(sizeof(Post_View)) ; + Post_ViewReference->CT.size = 255; + Post_ViewReference->CT.ipar[COLORTABLE_MODE] = COLORTABLE_RGB; + ColorTable_InitParam(1, &Post_ViewReference->CT, 1, 1); + ColorTable_Recompute(&Post_ViewReference->CT, 1, 1); + + // Default string options + Set_DefaultStringOptions(num, GeneralOptions_String); + Set_DefaultStringOptions(num, GeometryOptions_String); + Set_DefaultStringOptions(num, MeshOptions_String); + Set_DefaultStringOptions(num, PostProcessingOptions_String); + Set_DefaultStringOptions(num, ViewOptions_String); + Set_DefaultStringOptions(num, PrintOptions_String); + + // Default number options + Set_DefaultNumberOptions(num, GeneralOptions_Number); + Set_DefaultNumberOptions(num, GeometryOptions_Number); + Set_DefaultNumberOptions(num, MeshOptions_Number); + Set_DefaultNumberOptions(num, PostProcessingOptions_Number); + Set_DefaultNumberOptions(num, ViewOptions_Number); + Set_DefaultNumberOptions(num, PrintOptions_Number); + + // Default color options + Set_DefaultColorOptions(num, GeneralOptions_Color, CTX.color_scheme); + Set_DefaultColorOptions(num, GeometryOptions_Color, CTX.color_scheme); + Set_DefaultColorOptions(num, MeshOptions_Color, CTX.color_scheme); + Set_DefaultColorOptions(num, PostProcessingOptions_Color, CTX.color_scheme); + Set_DefaultColorOptions(num, ViewOptions_Color, CTX.color_scheme); + Set_DefaultColorOptions(num, PrintOptions_Color, CTX.color_scheme); + + // The following defaults cannot be set by the user + CTX.batch = 0 ; + CTX.expose = 0 ; + CTX.db = 1 ; // motif only + CTX.overlay = 1 ; // motif only + CTX.stream = TO_SCREEN ; + CTX.command_win = 0 ; // motif only + CTX.threads = 1 ; // motif only + CTX.threads_lock = 0 ; // motif only + CTX.gl_fontheight = 12; + CTX.gl_fontascent = 8; + CTX.font = "-*-helvetica-medium-r-*-*-*-*-*-*-*-*-*-*" ; // motif only + CTX.fixed_font = "fixed" ; // motif only + CTX.lc = 1.0 ; + CTX.viewport[0] = CTX.viewport[1] = 0 ; + CTX.min[0] = CTX.min[1] = CTX.min[2] = 0.0 ; + CTX.max[0] = CTX.max[1] = CTX.max[2] = 1.0 ; + CTX.range[0] = CTX.range[1] = CTX.range[2] = 1.0 ; + CTX.vxmin = CTX.vymin = CTX.vxmax = CTX.vymax = 0. ; + CTX.render_mode = GMSH_RENDER ; + CTX.pixel_equiv_x = CTX.pixel_equiv_y = 0. ; + CTX.geom.vis_type = 0 ; + CTX.geom.level = ELEMENTARY ; + CTX.mesh.vis_type = 0 ; + CTX.mesh.draw = 1 ; + CTX.post.draw = 1 ; +} + +void Init_Options_GUI(int num){ + Set_StringOptions_GUI(num, GeneralOptions_String); + Set_StringOptions_GUI(num, GeometryOptions_String); + Set_StringOptions_GUI(num, MeshOptions_String); + Set_StringOptions_GUI(num, PostProcessingOptions_String); + Set_StringOptions_GUI(num, PrintOptions_String); + + Set_NumberOptions_GUI(num, GeneralOptions_Number); + Set_NumberOptions_GUI(num, GeometryOptions_Number); + Set_NumberOptions_GUI(num, MeshOptions_Number); + Set_NumberOptions_GUI(num, PostProcessingOptions_Number); + Set_NumberOptions_GUI(num, PrintOptions_Number); + + Set_ColorOptions_GUI(num, GeneralOptions_Color); + Set_ColorOptions_GUI(num, GeometryOptions_Color); + Set_ColorOptions_GUI(num, MeshOptions_Color); + Set_ColorOptions_GUI(num, PostProcessingOptions_Color); + Set_ColorOptions_GUI(num, PrintOptions_Color); +} + +void Print_Options(int num, int level, char *filename){ + FILE *file; + char tmp[256]; + int i ; + + if(filename){ + file = fopen(filename,"w"); + if(!file){ + Msg(WARNING, "Unable to Open File '%s'", filename); + return; + } + } + else + file = NULL ; + + if((level & GMSH_SESSIONRC) && file){ + fprintf(file, "// Gmsh Session File\n"); + fprintf(file, "// This file takes session specific info (that is info\n"); + fprintf(file, "// you want to keep between two Gmsh sessions). You are\n"); + fprintf(file, "// not supposed to edit it manually, but of course you\n"); + fprintf(file, "// can do. This file will be entirely rewritten every time\n"); + fprintf(file, "// you quit Gmsh. If this file isn't found, defaults\n"); + fprintf(file, "// are used.\n"); + } + + if((level & GMSH_OPTIONSRC) && file){ + fprintf(file, "// Gmsh Option File\n"); + fprintf(file, "// This file takes configuration options that should\n"); + fprintf(file, "// be loaded each time Gmsh is launched. You can create\n"); + fprintf(file, "// this file by hand, or let Gmsh generate it for you (with\n"); + fprintf(file, "// the 'File->Save Options' menu button). If this file\n"); + fprintf(file, "// isn't found, defaults are used.\n"); + } + + Print_StringOptions(num, level, GeneralOptions_String, "General.", file); + Print_NumberOptions(num, level, GeneralOptions_Number, "General.", file); + Print_ColorOptions(num, level, GeneralOptions_Color, "General.", file); + Print_StringOptions(num, level, GeometryOptions_String, "Geometry.", file); + Print_NumberOptions(num, level, GeometryOptions_Number, "Geometry.", file); + Print_ColorOptions(num, level, GeometryOptions_Color, "Geometry.", file); + Print_StringOptions(num, level, MeshOptions_String, "Mesh.", file); + Print_NumberOptions(num, level, MeshOptions_Number, "Mesh.", file); + Print_ColorOptions(num, level, MeshOptions_Color, "Mesh.", file); + Print_StringOptions(num, level, PostProcessingOptions_String, "PostProcessing.", file); + Print_NumberOptions(num, level, PostProcessingOptions_Number, "PostProcessing.", file); + Print_ColorOptions(num, level, PostProcessingOptions_Color, "PostProcessing.", file); + if(level & GMSH_FULLRC){ + for(i=0; i<List_Nbr(Post_ViewList) ; i++){ + sprintf(tmp, "View[%d].", i); + Print_StringOptions(i, level, ViewOptions_String, tmp, file); + Print_NumberOptions(i, level, ViewOptions_Number, tmp, file); + Print_ColorOptions(i, level, ViewOptions_Color, tmp, file); + strcat(tmp, "ColorTable"); + Print_ColorTable(i, tmp, file); + } + } + else if(level & GMSH_OPTIONSRC){ + Print_StringOptions(num, level, ViewOptions_String, "View.", file); + Print_NumberOptions(num, level, ViewOptions_Number, "View.", file); + Print_ColorOptions(num, level, ViewOptions_Color, "View.", file); + Print_ColorTable(num, "View.ColorTable", file); + } + Print_StringOptions(num, level, PrintOptions_String, "Print.", file); + Print_NumberOptions(num, level, PrintOptions_Number, "Print.", file); + Print_ColorOptions(num, level, PrintOptions_Color, "Print.", file); + + if(filename){ + if((level & GMSH_OPTIONSRC) || (level & GMSH_FULLRC)){ + Msg(INFO, "Options Output Complete '%s'", filename); + Msg(STATUS2, "Wrote '%s'", filename); + } + fclose(file); + } +} + +// ************** General routines for string options ************************ + +StringXString * Get_StringOptionCategory(char * cat){ + if (!strcmp(cat,"General")) return GeneralOptions_String ; + else if(!strcmp(cat,"Geometry")) return GeometryOptions_String ; + else if(!strcmp(cat,"Mesh")) return MeshOptions_String ; + else if(!strcmp(cat,"PostProcessing")) return PostProcessingOptions_String ; + else if(!strcmp(cat,"View")) return ViewOptions_String ; + else if(!strcmp(cat,"Print")) return PrintOptions_String ; + else return NULL ; +} + +void Set_DefaultStringOptions(int num, StringXString s[]){ + int i = 0; + while(s[i].str){ + s[i].function(num, GMSH_SET, s[i].def) ; + i++; + } +} + +void Set_StringOptions_GUI(int num, StringXString s[]){ + int i = 0; + while(s[i].str){ + s[i].function(num, GMSH_GUI, 0) ; + i++; + } +} + +void * Get_StringOption(char *str, StringXString s[]){ + int i = 0; + while ((s[i].str != NULL) && (strcmp(s[i].str, str))) i++ ; + if(!s[i].str) + return NULL; + else + return (void*)s[i].function; +} + +void Print_StringOptions(int num, int level, StringXString s[], char *prefix, FILE *file){ + int i = 0; + char tmp[1024]; + while(s[i].str){ + if(s[i].level & level){ + sprintf(tmp, "%s%s = \"%s\";", prefix, s[i].str, s[i].function(num, GMSH_GET, NULL)) ; + if(file) fprintf(file, "%s\n", tmp); else Msg(DIRECT, "%s", tmp); + } + i++; + } +} + +// ************** General routines for numeric options ************************ + +StringXNumber * Get_NumberOptionCategory(char * cat){ + if (!strcmp(cat,"General")) return GeneralOptions_Number ; + else if(!strcmp(cat,"Geometry")) return GeometryOptions_Number ; + else if(!strcmp(cat,"Mesh")) return MeshOptions_Number ; + else if(!strcmp(cat,"PostProcessing")) return PostProcessingOptions_Number ; + else if(!strcmp(cat,"View")) return ViewOptions_Number ; + else if(!strcmp(cat,"Print")) return PrintOptions_Number ; + else return NULL ; +} + +void Set_DefaultNumberOptions(int num, StringXNumber s[]){ + int i = 0; + while(s[i].str){ + s[i].function(num, GMSH_SET, s[i].def) ; + i++; + } +} + +void Set_NumberOptions_GUI(int num, StringXNumber s[]){ + int i = 0; + while(s[i].str){ + s[i].function(num, GMSH_GUI, 0) ; + i++ ; + } +} + +void * Get_NumberOption(char *str, StringXNumber s[]){ + int i = 0; + + while ((s[i].str != NULL) && (strcmp(s[i].str, str))) i++ ; + if(!s[i].str) + return NULL; + else{ + return (void*)s[i].function; + } +} + +void Print_NumberOptions(int num, int level, StringXNumber s[], char *prefix, FILE *file){ + int i = 0; + char tmp[1024]; + while(s[i].str){ + if(s[i].level & level){ + sprintf(tmp, "%s%s = %g;", prefix, s[i].str, s[i].function(num, GMSH_GET, 0)); + if(file) fprintf(file, "%s\n", tmp); else Msg(DIRECT, tmp); + } + i++; + } +} + +// ************** General routines for color options ************************ + +StringXColor * Get_ColorOptionCategory(char * cat){ + if (!strcmp(cat,"General")) return GeneralOptions_Color ; + else if(!strcmp(cat,"Geometry")) return GeometryOptions_Color ; + else if(!strcmp(cat,"Mesh")) return MeshOptions_Color ; + else if(!strcmp(cat,"PostProcessing")) return PostProcessingOptions_Color ; + else if(!strcmp(cat,"View")) return ViewOptions_Color ; + else if(!strcmp(cat,"Print")) return PrintOptions_Color ; + else return NULL ; +} + +void Set_DefaultColorOptions(int num, StringXColor s[], int scheme){ + int i = 0; + switch(scheme){ + case 0 : + while(s[i].str){ + s[i].function(num, GMSH_SET, s[i].def1) ; + i++; + } + break; + case 1 : + while(s[i].str){ + s[i].function(num, GMSH_SET, s[i].def2) ; + i++; + } + break; + case 2 : + while(s[i].str){ + s[i].function(num, GMSH_SET, s[i].def3) ; + i++; + } + break; + } +} + +void Set_ColorOptions_GUI(int num, StringXColor s[]){ + int i = 0; + while(s[i].str){ + s[i].function(num, GMSH_GUI, 0) ; + i++; + } +} + +void * Get_ColorOption(char *str, StringXColor s[]) { + int i = 0; + while ((s[i].str != NULL) && (strcmp(s[i].str, str))) i++ ; + if(!s[i].str) + return NULL; + else + return (void*)s[i].function; +} + +void Print_ColorOptions(int num, int level, StringXColor s[], char *prefix, FILE *file){ + int i = 0; + char tmp[1024]; + while(s[i].str){ + if(s[i].level & level){ + sprintf(tmp, "%sColor.%s = {%d,%d,%d};", + prefix, s[i].str, + UNPACK_RED (s[i].function(num, GMSH_GET, 0)), + UNPACK_GREEN(s[i].function(num, GMSH_GET, 0)), + UNPACK_BLUE (s[i].function(num, GMSH_GET, 0))); + if(file) fprintf(file, "%s\n", tmp); else Msg(DIRECT, tmp); + } + i++; + } +} + +int Get_ColorForString(StringX4Int SX4I[], int alpha, + char * str, int * FlagError) { + int i = 0 ; + while ((SX4I[i].str != NULL) && (strcmp(SX4I[i].str, str))) i++ ; + *FlagError = (SX4I[i].str == NULL)? 1 : 0 ; + if(alpha > 0) + return PACK_COLOR(SX4I[i].int1,SX4I[i].int2,SX4I[i].int3,alpha) ; + else + return PACK_COLOR(SX4I[i].int1,SX4I[i].int2,SX4I[i].int3,SX4I[i].int4) ; +} + + + + + +// ************** String option routines **************************** + #define GET_VIEW(error_val) \ Post_View *v; \ if(!Post_ViewList) \ @@ -42,8 +384,6 @@ extern GUI *WID ; else strcpy(path_val, ""); \ if(strlen(path_val)) strcat(path_val, SLASH); -//******************* Strings *********************************** - char * opt_general_display(OPT_ARGS_STR){ if(action & GMSH_SET) CTX.display = val; return CTX.display; @@ -137,7 +477,7 @@ char * opt_print_font(OPT_ARGS_STR){ } -//******************* Numbers *********************************** +// ************** Numeric option routines **************************** double opt_general_fontsize(OPT_ARGS_NUM){ @@ -1414,8 +1754,7 @@ double opt_print_font_size(OPT_ARGS_NUM){ return CTX.print.font_size; } - -//******************* Colors *********************************** +// ************** Color option routines **************************** #ifdef _FLTK #define CCC(col,but) \ diff --git a/Common/Options.h b/Common/Options.h index d2330c3865ffc98ec5e644d40e2eb8fcc8aaf22d..c9edaad2d0127f3f68e50404d2a4ba5073f2d10e 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -9,13 +9,12 @@ #define GMSH_OPTIONSRC (1<<1) #define GMSH_FULLRC (1<<2) +// action is a combination of GMSH_SET, GMSH_GET, GMSH_GUI + #define OPT_ARGS_STR int num, int action, char *val #define OPT_ARGS_NUM int num, int action, double val #define OPT_ARGS_COL int num, int action, unsigned int val -// Option Database (General, Geometry, Mesh, Post, View, Print), with -// default values - // STRINGS char * opt_general_display(OPT_ARGS_STR); @@ -291,6 +290,10 @@ typedef struct { unsigned int def1, def2, def3 ; } StringXColor ; +void Init_Options (int num); +void Init_Options_GUI (int num); +void Print_Options(int num, int level, char *filename); + StringXString * Get_StringOptionCategory(char * cat); StringXNumber * Get_NumberOptionCategory(char * cat); StringXColor * Get_ColorOptionCategory(char * cat); @@ -307,9 +310,9 @@ void * Get_StringOption(char *str, StringXString s[]); void * Get_NumberOption(char *str, StringXNumber s[]); void * Get_ColorOption(char *str, StringXColor s[]); -void Print_StringOptions(int num, StringXString s[], char *prefix, FILE *file); -void Print_NumberOptions(int num, StringXNumber s[], char *prefix, FILE *file); -void Print_ColorOptions(int num, StringXColor s[], char *prefix, FILE *file); +void Print_StringOptions(int num, int level, StringXString s[], char *prefix, FILE *file); +void Print_NumberOptions(int num, int level, StringXNumber s[], char *prefix, FILE *file); +void Print_ColorOptions(int num, int level, StringXColor s[], char *prefix, FILE *file); extern StringXString GeneralOptions_String[] ; extern StringXString GeometryOptions_String[] ; diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index f0fadcc04eae6f63634f59ca9bf194e1b33919b5..3aff8e7b09f3ef3c26afca0e2aadaaf0f22c1843 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.34 2001-02-19 21:55:42 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.35 2001-02-20 18:32:58 geuzaine Exp $ #include "Gmsh.h" #include "GmshUI.h" @@ -123,7 +123,7 @@ void status_xyz1p_cb(CALLBACK_ARGS){ Draw(); break; case 4 : - Print_Context(0,GMSH_FULLRC,NULL); + Print_Options(0,GMSH_FULLRC,NULL); WID->create_message_window(); break ; } @@ -187,7 +187,7 @@ void file_save_mesh_cb(CALLBACK_ARGS) { } void file_save_options_cb(CALLBACK_ARGS) { - Print_Context(0,GMSH_OPTIONSRC, CTX.optionsrc_filename); + Print_Options(0,GMSH_OPTIONSRC, CTX.optionsrc_filename); } void file_save_as_auto_cb(CALLBACK_ARGS) { @@ -205,7 +205,7 @@ void file_save_as_geo_cb(CALLBACK_ARGS) { void file_save_as_geo_options_cb(CALLBACK_ARGS) { char *newfile; if((newfile = fl_file_chooser("Save Options File", "*", NULL))) - Print_Context(0,GMSH_FULLRC, newfile); + Print_Options(0,GMSH_FULLRC, newfile); } void file_save_as_msh_cb(CALLBACK_ARGS) { @@ -505,7 +505,7 @@ void help_short_cb(CALLBACK_ARGS){ } void help_command_line_cb(CALLBACK_ARGS){ Msg(DIRECT, ""); - Print_Options("gmsh"); + Print_Usage("gmsh"); WID->create_message_window(); } void help_about_cb(CALLBACK_ARGS){ diff --git a/Fltk/Main.cpp b/Fltk/Main.cpp index 66065a496cf4b356837f0d85b180e2a886e4afc6..82555933d416debfb2f3d95c6a3202aae269b387 100644 --- a/Fltk/Main.cpp +++ b/Fltk/Main.cpp @@ -1,4 +1,4 @@ -// $Id: Main.cpp,v 1.17 2001-02-17 22:02:17 geuzaine Exp $ +// $Id: Main.cpp,v 1.18 2001-02-20 18:32:58 geuzaine Exp $ #include <signal.h> @@ -11,6 +11,7 @@ #include "Mesh.h" #include "Draw.h" #include "Context.h" +#include "Options.h" #include "ColorTable.h" #include "Parser.h" #include "Static.h" @@ -23,9 +24,9 @@ GUI *WID = NULL; int main(int argc, char *argv[]){ int i, nbf; - // Gmsh default context options + // Gmsh default options - Init_Context(0); + Init_Options(0); // Configuration files and command line options @@ -38,7 +39,7 @@ int main(int argc, char *argv[]){ // Always print info on terminal for non-interactive execution - if(CTX.interactive) + if(CTX.batch) CTX.terminal = 1; if(CTX.verbosity && CTX.terminal) @@ -66,7 +67,7 @@ int main(int argc, char *argv[]){ // Non-interactive Gmsh - if(CTX.interactive){ + if(CTX.batch){ OpenProblem(CTX.filename); if(yyerrorstate) exit(1); @@ -79,8 +80,8 @@ int main(int argc, char *argv[]){ else Msg(GERROR, "Invalid Background Mesh (no View)"); } - if(CTX.interactive > 0){ - mai3d(THEM, CTX.interactive); + if(CTX.batch > 0){ + mai3d(THEM, CTX.batch); Print_Mesh(THEM,NULL,CTX.mesh.format); } else @@ -92,7 +93,7 @@ int main(int argc, char *argv[]){ // Interactive Gmsh - CTX.interactive = -1 ; // The GUI is not ready yet for interactivity + CTX.batch = -1 ; // The GUI is not ready yet for interactivity // Create the GUI @@ -100,10 +101,11 @@ int main(int argc, char *argv[]){ // Set all previously defined options in the GUI - Init_Context_GUI(0); + Init_Options_GUI(0); // The GUI is ready - CTX.interactive = 0 ; + + CTX.batch = 0 ; // Say welcome! @@ -121,11 +123,11 @@ int main(int argc, char *argv[]){ WID->check(); - // Open input file + // Open project file OpenProblem(CTX.filename); - // Merge all Input Files + // Merge all other input files for(i=1;i<nbf;i++) MergeProblem(TheFileNameTab[i]); diff --git a/Fltk/Makefile b/Fltk/Makefile index c83cde542f91accbb5fc15944107f5a73a6df5f1..8c3a0f335ec897d9233c6af376b4d27d4054e3bb 100644 --- a/Fltk/Makefile +++ b/Fltk/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.11 2001-02-18 18:04:03 geuzaine Exp $ +# $Id: Makefile,v 1.12 2001-02-20 18:32:58 geuzaine Exp $ # # Makefile for "libFltk.a" # @@ -67,9 +67,9 @@ Main.o: Main.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \ ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Edge.h \ ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Graphics/Draw.h \ ../Common/Views.h ../Common/Const.h ../Common/ColorTable.h \ - ../Common/Context.h ../Parser/Parser.h ../Common/Static.h GUI.h \ - Opengl_Window.h Colorbar_Window.h ../Parser/OpenFile.h \ - ../Common/GetOptions.h + ../Common/Context.h ../Common/Options.h ../Parser/Parser.h \ + ../Common/Static.h GUI.h Opengl_Window.h Colorbar_Window.h \ + ../Parser/OpenFile.h ../Common/GetOptions.h Message.o: Message.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Common/GmshUI.h \ diff --git a/Fltk/Message.cpp b/Fltk/Message.cpp index e95a0b21061476ce96a9932d40eff1a905fcf244..4b73c083c6a3b17b6c6881f8862a266a1f663d83 100644 --- a/Fltk/Message.cpp +++ b/Fltk/Message.cpp @@ -1,4 +1,4 @@ -// $Id: Message.cpp,v 1.13 2001-02-17 22:02:18 geuzaine Exp $ +// $Id: Message.cpp,v 1.14 2001-02-20 18:32:58 geuzaine Exp $ #include <signal.h> #ifndef WIN32 @@ -140,7 +140,7 @@ void Msg(int level, char *fmt, ...){ /* ------------------------------------------------------------------------ */ void Exit(int level){ - if(WID && !CTX.interactive){ + if(WID && !CTX.batch){ if(CTX.session_save){ CTX.position[0] = WID->m_window->x(); CTX.position[1] = WID->m_window->y(); @@ -150,10 +150,10 @@ void Exit(int level){ CTX.msg_position[1] = WID->msg_window->y(); CTX.msg_size[0] = WID->msg_window->w(); CTX.msg_size[1] = WID->msg_window->h(); - Print_Context(0, GMSH_SESSIONRC, CTX.sessionrc_filename); + Print_Options(0, GMSH_SESSIONRC, CTX.sessionrc_filename); } if(CTX.options_save) - Print_Context(0, GMSH_OPTIONSRC, CTX.optionsrc_filename); + Print_Options(0, GMSH_OPTIONSRC, CTX.optionsrc_filename); } exit(level); } diff --git a/Makefile b/Makefile index ce993fc96faebf402571f1b7e639e49da4272375..3b8b49f21e3e828fcca9ff11c712d99e0bf2dc56 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.62 2001-02-19 15:58:30 geuzaine Exp $ +# $Id: Makefile,v 1.63 2001-02-20 18:32:58 geuzaine Exp $ # ---------------------------------------------------------------------- # Makefile for Gmsh # ---------------------------------------------------------------------- @@ -146,6 +146,7 @@ depend: for i in $(GMSH_DIR); \ do (cd $$i && $(MAKE) depend \ "CC=$(CC)" \ + "VERSION_FLAGS=-D_FLTK -D_XMOTIF" \ "GL_INCLUDE=$(OPENGL_INC)" \ "GUI_INCLUDE=$(MOTIF_INC) $(FLTK_INC)" \ ); done diff --git a/Motif/CbFile.cpp b/Motif/CbFile.cpp index 2a2184728663a509997ba610db63c16ca863520a..0a2b3de02755975853443471a2440858d5d3c77d 100644 --- a/Motif/CbFile.cpp +++ b/Motif/CbFile.cpp @@ -1,4 +1,4 @@ -// $Id: CbFile.cpp,v 1.6 2001-02-17 22:04:05 geuzaine Exp $ +// $Id: CbFile.cpp,v 1.7 2001-02-20 18:32:58 geuzaine Exp $ #include "Gmsh.h" #include "GmshUI.h" @@ -63,7 +63,7 @@ void FileCb(Widget w, XtPointer client_data, XtPointer call_data){ case FILE_LOAD_GEOM : OpenProblem(c); Draw(); break; case FILE_LOAD_POST : MergeProblem(c); ColorBarRedraw(); Draw(); break; case FILE_SAVE_AS : SaveToDisk(c, WID.ED.saveAsDialog, CreateOutputFile); break; - case FILE_SAVE_OPTIONS_AS : Print_Context(0,GMSH_FULLRC,c); break; + case FILE_SAVE_OPTIONS_AS : Print_Options(0,GMSH_FULLRC,c); break; default : Msg(WARNING, "Unknown event in FileCb : %d", (long int)client_data); break; diff --git a/Motif/CbOptions.cpp b/Motif/CbOptions.cpp index 9180a315aea6ce7cea6a834be6426b2273b8b8d1..faf6f021eba0d1a4eb152d4cb98ace8fe1f0bc12 100644 --- a/Motif/CbOptions.cpp +++ b/Motif/CbOptions.cpp @@ -1,4 +1,4 @@ -// $Id: CbOptions.cpp,v 1.8 2001-02-17 22:25:49 geuzaine Exp $ +// $Id: CbOptions.cpp,v 1.9 2001-02-20 18:32:58 geuzaine Exp $ #include "Gmsh.h" #include "GmshUI.h" @@ -120,7 +120,7 @@ void OptionsCb (Widget w, XtPointer client_data, XtPointer call_data){ CTX.r[0],CTX.r[1],CTX.r[2], CTX.t[0],CTX.t[1],CTX.t[2], CTX.s[0],CTX.s[1],CTX.s[2]); - Print_Context(0, GMSH_FULLRC, NULL); + Print_Options(0, GMSH_FULLRC, NULL); break ; /* save */ diff --git a/Motif/Main.cpp b/Motif/Main.cpp index 63feaae2c5edbb4c7b49aba970c69594a51cf2a0..3ec5335b9c9252c75de594deca2f13e6c2f566c1 100644 --- a/Motif/Main.cpp +++ b/Motif/Main.cpp @@ -1,4 +1,4 @@ -// $Id: Main.cpp,v 1.9 2001-02-12 17:38:03 geuzaine Exp $ +// $Id: Main.cpp,v 1.10 2001-02-20 18:32:58 geuzaine Exp $ #include <signal.h> @@ -10,6 +10,7 @@ #include "Mesh.h" #include "Draw.h" #include "Context.h" +#include "Options.h" #include "ColorTable.h" #include "Parser.h" #include "Views.h" @@ -46,7 +47,7 @@ int main(int argc, char *argv[]){ /* Gmsh default context options */ - Init_Context(0); + Init_Options(0); /* Command line options */ @@ -77,7 +78,7 @@ int main(int argc, char *argv[]){ /* Non-interactive Gmsh */ - if(CTX.interactive){ + if(CTX.batch){ OpenProblem(CTX.filename); if(yyerrorstate) exit(1); @@ -92,8 +93,8 @@ int main(int argc, char *argv[]){ else Msg(GERROR, "Invalid Background Mesh (no View)"); } - if(CTX.interactive > 0){ - mai3d(THEM, CTX.interactive); + if(CTX.batch > 0){ + mai3d(THEM, CTX.batch); Print_Mesh(THEM,NULL,CTX.mesh.format); } else @@ -105,7 +106,7 @@ int main(int argc, char *argv[]){ /* Interactive Gmsh */ - CTX.interactive = -1 ; /* The GUI is not ready yet for interactivity */ + CTX.batch = -1 ; /* The GUI is not ready yet for interactivity */ /* Text for about window */ @@ -372,7 +373,7 @@ int main(int argc, char *argv[]){ CTX.font_base+XCTX.xfont.helve->min_char_or_byte2); /* The GUI is ready */ - CTX.interactive = 0 ; + CTX.batch = 0 ; CTX.expose = 1 ; /* Say welcome! */ diff --git a/Motif/Makefile b/Motif/Makefile index 641c2bfc655dc0f86899ae2e1859dc9433db1ae1..065e4fbdfe77beb9b66e7525841d70df18f508c1 100644 --- a/Motif/Makefile +++ b/Motif/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.9 2001-02-18 18:04:03 geuzaine Exp $ +# $Id: Makefile,v 1.10 2001-02-20 18:32:58 geuzaine Exp $ # # Makefile for "libMotif.a" # @@ -77,10 +77,10 @@ Main.o: Main.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \ ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Edge.h \ ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Graphics/Draw.h \ ../Common/Views.h ../Common/Const.h ../Common/ColorTable.h \ - ../Common/Context.h ../Parser/Parser.h Widgets.h Pixmaps.h XColors.h \ - XContext.h XRessources.h CbContext.h CbGeom.h Register.h Geometry.h \ - ../Parser/OpenFile.h ../Common/GetOptions.h ../Common/Static.h \ - XStatic.h + ../Common/Context.h ../Common/Options.h ../Parser/Parser.h Widgets.h \ + Pixmaps.h XColors.h XContext.h XRessources.h CbContext.h CbGeom.h \ + Register.h Geometry.h ../Parser/OpenFile.h ../Common/GetOptions.h \ + ../Common/Static.h XStatic.h Widgets.o: Widgets.cpp ../Common/Gmsh.h ../Common/Message.h \ ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \ ../DataStr/avl.h ../DataStr/Tools.h ../Common/GmshUI.h ../Mesh/Mesh.h \ diff --git a/Motif/Message.cpp b/Motif/Message.cpp index a36cda5b63618295e038230e458df919445edcdd..2de5c03744dca8f92c3185a1958bef2ba69b48bd 100644 --- a/Motif/Message.cpp +++ b/Motif/Message.cpp @@ -1,4 +1,4 @@ -// $Id: Message.cpp,v 1.7 2001-02-17 22:04:05 geuzaine Exp $ +// $Id: Message.cpp,v 1.8 2001-02-20 18:32:58 geuzaine Exp $ #include <signal.h> #include <sys/resource.h> @@ -61,7 +61,7 @@ void Msg(int level, char *fmt, ...){ int nb, nbvis; if(level != FATAL && level != GERROR && level != PARSER_ERROR && - CTX.interactive && !CTX.verbosity) + CTX.batch && !CTX.verbosity) return ; va_start (args, fmt); @@ -78,7 +78,7 @@ void Msg(int level, char *fmt, ...){ abort = 1; break; case GERROR : - if(CTX.interactive || !CTX.command_win){ + if(CTX.batch || !CTX.command_win){ fprintf(stderr, ERROR_STR); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); @@ -88,7 +88,7 @@ void Msg(int level, char *fmt, ...){ } break; case WARNING : - if(CTX.interactive || !CTX.command_win){ + if(CTX.batch || !CTX.command_win){ if(CTX.verbosity > 0){ fprintf(stderr, WARNING_STR); vfprintf(stderr, fmt, args); @@ -100,7 +100,7 @@ void Msg(int level, char *fmt, ...){ } break; case INFO : - if(CTX.interactive || !CTX.command_win){ + if(CTX.batch || !CTX.command_win){ if(CTX.verbosity > 1){ fprintf(stderr, INFO_STR); vfprintf(stderr, fmt, args); @@ -113,7 +113,7 @@ void Msg(int level, char *fmt, ...){ break; case STATUS2 : case STATUS2N : - if(CTX.interactive){ + if(CTX.batch){ if(CTX.verbosity > 1){ fprintf(stderr, STATUS_STR); vfprintf(stderr, fmt, args); @@ -129,7 +129,7 @@ void Msg(int level, char *fmt, ...){ break; case STATUS1 : case STATUS1N : - if(CTX.interactive){ + if(CTX.batch){ if(CTX.verbosity > 1){ fprintf(stderr, STATUS_STR); vfprintf(stderr, fmt, args); @@ -145,7 +145,7 @@ void Msg(int level, char *fmt, ...){ break; case STATUS3 : case STATUS3N : - if(CTX.interactive){ + if(CTX.batch){ if(CTX.verbosity > 1){ fprintf(stderr, STATUS_STR); vfprintf(stderr, fmt, args); @@ -160,7 +160,7 @@ void Msg(int level, char *fmt, ...){ } break; case PARSER_ERROR : - if(CTX.interactive || !CTX.command_win){ + if(CTX.batch || !CTX.command_win){ if(CTX.verbosity > 0){ fprintf(stderr, PARSER_ERROR_STR); vfprintf(stderr, fmt, args); @@ -172,7 +172,7 @@ void Msg(int level, char *fmt, ...){ } break; case PARSER_INFO : - if(CTX.interactive || !CTX.command_win){ + if(CTX.batch || !CTX.command_win){ if(CTX.verbosity > 1){ fprintf(stderr, PARSER_INFO_STR); vfprintf(stderr, fmt, args); @@ -184,7 +184,7 @@ void Msg(int level, char *fmt, ...){ } break; case DEBUG : - if(CTX.interactive || !CTX.command_win){ + if(CTX.batch || !CTX.command_win){ if(CTX.verbosity > 2){ fprintf(stderr, DEBUG_STR); vfprintf(stderr, fmt, args); diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp index 9125052798bcbb9274c1ec2cd33bdd284462f473..63badeade6bbb96f93a0a0b5b02768bda901dac0 100644 --- a/Parser/Gmsh.tab.cpp +++ b/Parser/Gmsh.tab.cpp @@ -169,7 +169,7 @@ #line 1 "Gmsh.y" -// $Id: Gmsh.tab.cpp,v 1.73 2001-02-19 21:55:42 geuzaine Exp $ +// $Id: Gmsh.tab.cpp,v 1.74 2001-02-20 18:32:58 geuzaine Exp $ #include <stdarg.h> @@ -4232,7 +4232,7 @@ case 193: } else if(!strcmp(yyvsp[-2].c, "Print")){ - if(!CTX.interactive) CreateOutputFile(yyvsp[-1].c, CTX.print.format); + if(!CTX.batch) CreateOutputFile(yyvsp[-1].c, CTX.print.format); } else if(!strcmp(yyvsp[-2].c, "Save")){ CreateOutputFile(yyvsp[-1].c, CTX.mesh.format); @@ -4285,7 +4285,7 @@ case 195: case 196: #line 1456 "Gmsh.y" { - if(!CTX.interactive){ // we're in interactive mode + if(!CTX.batch){ // we're in interactive mode if(Tree_Nbr(THEM->Points) != Last_NumberOfPoints){ Last_NumberOfPoints = Tree_Nbr(THEM->Points); Replot(); diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y index a0c2656c6707d69e76cc08fa6f9da7e9a26d73f4..ac0254a05e69968319cc22b2a650a73b20df3086 100644 --- a/Parser/Gmsh.y +++ b/Parser/Gmsh.y @@ -1,6 +1,6 @@ %{ -// $Id: Gmsh.y,v 1.65 2001-02-19 21:55:42 geuzaine Exp $ +// $Id: Gmsh.y,v 1.66 2001-02-20 18:32:58 geuzaine Exp $ #include <stdarg.h> @@ -1407,7 +1407,7 @@ Command : } else if(!strcmp($1, "Print")){ - if(!CTX.interactive) CreateOutputFile($2, CTX.print.format); + if(!CTX.batch) CreateOutputFile($2, CTX.print.format); } else if(!strcmp($1, "Save")){ CreateOutputFile($2, CTX.mesh.format); @@ -1454,7 +1454,7 @@ Command : } | tDraw tEND { - if(!CTX.interactive){ // we're in interactive mode + if(!CTX.batch){ // we're in interactive mode if(Tree_Nbr(THEM->Points) != Last_NumberOfPoints){ Last_NumberOfPoints = Tree_Nbr(THEM->Points); Replot(); diff --git a/Parser/Gmsh.yy.cpp b/Parser/Gmsh.yy.cpp index 586d82bc9af1d7dc504fb1454b73cbb591809c71..23acca4083328ab0031dea8aa544ab71e8a198c4 100644 --- a/Parser/Gmsh.yy.cpp +++ b/Parser/Gmsh.yy.cpp @@ -2,7 +2,7 @@ /* A lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.73 2001-02-19 21:55:42 geuzaine Exp $ + * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.74 2001-02-20 18:32:58 geuzaine Exp $ */ #define FLEX_SCANNER @@ -978,7 +978,7 @@ char *yytext; #define INITIAL 0 #line 2 "Gmsh.l" -// $Id: Gmsh.yy.cpp,v 1.73 2001-02-19 21:55:42 geuzaine Exp $ +// $Id: Gmsh.yy.cpp,v 1.74 2001-02-20 18:32:58 geuzaine Exp $ #include <stdio.h> #include <stdlib.h> diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp index ee5a385c41d01460bd3084cee5b4729430d24f7e..0b10ba47f8749476ca6d2d93dd91730a54e2dfb9 100644 --- a/Parser/OpenFile.cpp +++ b/Parser/OpenFile.cpp @@ -1,4 +1,4 @@ -// $Id: OpenFile.cpp,v 1.6 2001-02-17 22:09:00 geuzaine Exp $ +// $Id: OpenFile.cpp,v 1.7 2001-02-20 18:32:58 geuzaine Exp $ #include "Gmsh.h" #include "Const.h" #include "Context.h" @@ -96,7 +96,7 @@ void OpenProblem(char *name){ strncpy(THEM->name, CTX.basefilename,NAME_STR_L); - if(!CTX.interactive){ + if(!CTX.batch){ #if _XMOTIF XtVaSetValues(WID.G.shell, XmNtitle, CTX.filename,