From ffd86d337630f48c2b41f6a70ab72ba5f83971c0 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 17 Jun 2004 21:16:58 +0000 Subject: [PATCH] create the default project file in the home directory if no "current" directory is defined (e.g. when double-clicking on the icon on Windows/MacOS) --- Common/CommandLine.cpp | 8 ++++---- Common/Context.h | 15 ++++++++------- Common/Options.cpp | 23 +++++++++++++---------- Fltk/Callbacks.cpp | 10 +++++----- Fltk/Message.cpp | 12 ++++++------ Geo/Geo.cpp | 14 +++++++------- Parser/OpenFile.cpp | 6 +++--- doc/VERSIONS | 8 +++++--- 8 files changed, 51 insertions(+), 45 deletions(-) diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index 87e4d52149..58d7c6ea2e 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -1,4 +1,4 @@ -// $Id: CommandLine.cpp,v 1.41 2004-05-31 18:36:20 geuzaine Exp $ +// $Id: CommandLine.cpp,v 1.42 2004-06-17 21:16:57 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -155,12 +155,12 @@ void Get_Options(int argc, char *argv[], int *nbfiles) // Parse session and option files - ParseFile(CTX.sessionrc_filename, 1, 1); - ParseFile(CTX.optionsrc_filename, 1, 1); + ParseFile(CTX.session_filename_fullpath, 1, 1); + ParseFile(CTX.options_filename_fullpath, 1, 1); // Get command line options - TheFileNameTab[0] = CTX.default_filename; + TheFileNameTab[0] = CTX.default_filename_fullpath; *nbfiles = 0; while(i < argc) { diff --git a/Common/Context.h b/Common/Context.h index 3c816514d5..d57781150a 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -50,14 +50,15 @@ public : char filename[256]; // the name of the currently opened file char base_filename[256]; // the same without the extension char *output_filename; // output file specified with command line option '-o' - char *default_filename; // the name of the default file - char *tmp_filename, tmprc_filename[256]; + char *default_filename, default_filename_fullpath[256]; + // the name of the default file + char *tmp_filename, tmp_filename_fullpath[256]; // the name of the temp file - char *session_filename, sessionrc_filename[256]; - // the name of the sessionrc configuration file - char *options_filename, optionsrc_filename[256]; - // the name of the optionrc configuration file - char *error_filename, errorrc_filename[256]; + char *session_filename, session_filename_fullpath[256]; + // the name of the session configuration file + char *options_filename, options_filename_fullpath[256]; + // the name of the option configuration file + char *error_filename, error_filename_fullpath[256]; // the name of the error file int session_save, options_save; // save session/option file on exit diff --git a/Common/Options.cpp b/Common/Options.cpp index d755fa0faa..c55ad6290b 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.166 2004-06-12 18:34:31 geuzaine Exp $ +// $Id: Options.cpp,v 1.167 2004-06-17 21:16:57 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -793,8 +793,11 @@ char *opt_general_display(OPT_ARGS_STR) char *opt_general_default_filename(OPT_ARGS_STR) { - if(action & GMSH_SET) + if(action & GMSH_SET){ CTX.default_filename = val; + strcpy(CTX.default_filename_fullpath, getenv("PWD") ? "" : CTX.home_dir); + strcat(CTX.default_filename_fullpath, CTX.default_filename); + } #if defined(HAVE_FLTK) if(WID && (action & GMSH_GUI)) WID->gen_input[0]->value(CTX.default_filename); @@ -806,8 +809,8 @@ char *opt_general_tmp_filename(OPT_ARGS_STR) { if(action & GMSH_SET){ CTX.tmp_filename = val; - strcpy(CTX.tmprc_filename, CTX.home_dir); - strcat(CTX.tmprc_filename, CTX.tmp_filename); + strcpy(CTX.tmp_filename_fullpath, CTX.home_dir); + strcat(CTX.tmp_filename_fullpath, CTX.tmp_filename); } return CTX.tmp_filename; } @@ -816,8 +819,8 @@ char *opt_general_error_filename(OPT_ARGS_STR) { if(action & GMSH_SET){ CTX.error_filename = val; - strcpy(CTX.errorrc_filename, CTX.home_dir); - strcat(CTX.errorrc_filename, CTX.error_filename); + strcpy(CTX.error_filename_fullpath, CTX.home_dir); + strcat(CTX.error_filename_fullpath, CTX.error_filename); } return CTX.error_filename; } @@ -826,8 +829,8 @@ char *opt_general_session_filename(OPT_ARGS_STR) { if(action & GMSH_SET) { CTX.session_filename = val; - strcpy(CTX.sessionrc_filename, CTX.home_dir); - strcat(CTX.sessionrc_filename, CTX.session_filename); + strcpy(CTX.session_filename_fullpath, CTX.home_dir); + strcat(CTX.session_filename_fullpath, CTX.session_filename); } return CTX.session_filename; } @@ -836,8 +839,8 @@ char *opt_general_options_filename(OPT_ARGS_STR) { if(action & GMSH_SET) { CTX.options_filename = val; - strcpy(CTX.optionsrc_filename, CTX.home_dir); - strcat(CTX.optionsrc_filename, CTX.options_filename); + strcpy(CTX.options_filename_fullpath, CTX.home_dir); + strcat(CTX.options_filename_fullpath, CTX.options_filename); } return CTX.options_filename; } diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 2520552ccb..eada8fae5c 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.247 2004-06-12 18:34:31 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.248 2004-06-17 21:16:57 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -775,14 +775,14 @@ void options_browser_cb(CALLBACK_ARGS) void options_save_cb(CALLBACK_ARGS) { - Print_Options(0, GMSH_OPTIONSRC, true, CTX.optionsrc_filename); + Print_Options(0, GMSH_OPTIONSRC, true, CTX.options_filename_fullpath); } void options_restore_defaults_cb(CALLBACK_ARGS) { // not sure if we have to remove the file... - unlink(CTX.sessionrc_filename); - unlink(CTX.optionsrc_filename); + unlink(CTX.session_filename_fullpath); + unlink(CTX.options_filename_fullpath); ReInit_Options(0); Init_Options_GUI(0); if(WID && WID->get_context() == 3) // hack to refresh the buttons @@ -864,7 +864,7 @@ void general_options_ok_cb(CALLBACK_ARGS) double sessionrc = opt_general_session_save(0, GMSH_GET, 0); opt_general_session_save(0, GMSH_SET, WID->gen_butt[8]->value()); if(sessionrc && !opt_general_session_save(0, GMSH_GET, 0)) - Print_Options(0, GMSH_SESSIONRC, true, CTX.sessionrc_filename); + Print_Options(0, GMSH_SESSIONRC, true, CTX.session_filename_fullpath); opt_general_options_save(0, GMSH_SET, WID->gen_butt[9]->value()); opt_general_orthographic(0, GMSH_SET | GMSH_GUI, WID->gen_butt[10]->value()); opt_general_tooltips(0, GMSH_SET, WID->gen_butt[13]->value()); diff --git a/Fltk/Message.cpp b/Fltk/Message.cpp index 673e138f6b..4750889d33 100644 --- a/Fltk/Message.cpp +++ b/Fltk/Message.cpp @@ -1,4 +1,4 @@ -// $Id: Message.cpp,v 1.55 2004-06-08 00:30:21 geuzaine Exp $ +// $Id: Message.cpp,v 1.56 2004-06-17 21:16:58 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -197,8 +197,8 @@ void Msg(int level, char *fmt, ...) if(abort) { Debug(); if(WID) { - WID->save_message(CTX.errorrc_filename); - WID->fatal_error(CTX.errorrc_filename); + WID->save_message(CTX.error_filename_fullpath); + WID->fatal_error(CTX.error_filename_fullpath); } Exit(1); } @@ -210,7 +210,7 @@ void Msg(int level, char *fmt, ...) void Exit(int level) { // delete the temp file - unlink(CTX.tmprc_filename); + unlink(CTX.tmp_filename_fullpath); if(level){ // in case of an abnormal exit, force the abort directly @@ -242,10 +242,10 @@ void Exit(int level) CTX.ctx_position[1] = WID->context_geometry_window->y(); CTX.solver_position[0] = WID->solver[0].window->x(); CTX.solver_position[1] = WID->solver[0].window->y(); - Print_Options(0, GMSH_SESSIONRC, false, CTX.sessionrc_filename); + Print_Options(0, GMSH_SESSIONRC, false, CTX.session_filename_fullpath); } if(CTX.options_save) - Print_Options(0, GMSH_OPTIONSRC, true, CTX.optionsrc_filename); + Print_Options(0, GMSH_OPTIONSRC, true, CTX.options_filename_fullpath); } exit(0); diff --git a/Geo/Geo.cpp b/Geo/Geo.cpp index caabd2c5f1..e1c9bf7511 100644 --- a/Geo/Geo.cpp +++ b/Geo/Geo.cpp @@ -1,4 +1,4 @@ -// $Id: Geo.cpp,v 1.40 2004-05-18 04:54:50 geuzaine Exp $ +// $Id: Geo.cpp,v 1.41 2004-06-17 21:16:58 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -47,8 +47,8 @@ double evaluate_scalarfunction(char *var, double val, char *funct) FILE *tempf; tempf = yyin; - if(!(yyin = fopen(CTX.tmprc_filename, "w"))) { - Msg(GERROR, "Unable to open temporary file '%s'", CTX.tmprc_filename); + if(!(yyin = fopen(CTX.tmp_filename_fullpath, "w"))) { + Msg(GERROR, "Unable to open temporary file '%s'", CTX.tmp_filename_fullpath); return 0.; } @@ -56,7 +56,7 @@ double evaluate_scalarfunction(char *var, double val, char *funct) fprintf(yyin, "%s = %.16g ;\n", var, val); fprintf(yyin, "ValeurTemporaire__ = %s ;\n", funct); fclose(yyin); - yyin = fopen(CTX.tmprc_filename, "r"); + yyin = fopen(CTX.tmp_filename_fullpath, "r"); while(!feof(yyin)) { yyparse(); } @@ -79,8 +79,8 @@ void add_infile(char *text, char *fich) { FILE *file; - if(!(yyin = fopen(CTX.tmprc_filename, "w"))) { - Msg(GERROR, "Unable to open temporary file '%s'", CTX.tmprc_filename); + if(!(yyin = fopen(CTX.tmp_filename_fullpath, "w"))) { + Msg(GERROR, "Unable to open temporary file '%s'", CTX.tmp_filename_fullpath); return; } if(!(file = fopen(fich, "a"))) { @@ -90,7 +90,7 @@ void add_infile(char *text, char *fich) fprintf(yyin, "%s\n", text); Msg(STATUS1, "%s", text); fclose(yyin); - yyin = fopen(CTX.tmprc_filename, "r"); + yyin = fopen(CTX.tmp_filename_fullpath, "r"); while(!feof(yyin)) { yyparse(); } diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp index 048a97c499..510408b0d5 100644 --- a/Parser/OpenFile.cpp +++ b/Parser/OpenFile.cpp @@ -1,4 +1,4 @@ -// $Id: OpenFile.cpp,v 1.58 2004-05-30 21:21:42 geuzaine Exp $ +// $Id: OpenFile.cpp,v 1.59 2004-06-17 21:16:58 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -155,10 +155,10 @@ void ParseString(char *str) FILE *fp; if(!str) return; - if((fp = fopen(CTX.tmprc_filename, "w"))) { + if((fp = fopen(CTX.tmp_filename_fullpath, "w"))) { fprintf(fp, "%s\n", str); fclose(fp); - ParseFile(CTX.tmprc_filename, 0, 1); + ParseFile(CTX.tmp_filename_fullpath, 0, 1); } } diff --git a/doc/VERSIONS b/doc/VERSIONS index c4131bc79f..41a8784377 100644 --- a/doc/VERSIONS +++ b/doc/VERSIONS @@ -1,9 +1,11 @@ -$Id: VERSIONS,v 1.224 2004-06-15 18:20:53 geuzaine Exp $ +$Id: VERSIONS,v 1.225 2004-06-17 21:16:58 geuzaine Exp $ New since 1.53: fixed UNV output; make Layers' region numbering consistent between lines/surfaces/volumes; fixed home directory -problem on Win98; new Plugin(CutParametric); small bug fixes and -cleanups. +problem on Win98; new Plugin(CutParametric); the default project file +is now created in the home directory if no current directory is +defined (e.g. when double-clicking on the icon on Windows/MacOS); +small bug fixes and cleanups. New in 1.53: completed support for second order elements in the mesh module (lines, triangles, quadrangles, tetrahedra, hexahedra, prisms -- GitLab