From 98a92f25261843ffc2b391c7778791b2f97118ed Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Mon, 31 May 2010 05:57:01 +0000 Subject: [PATCH] opt for temp files --- Common/Context.h | 2 +- Common/CreateFile.cpp | 10 +++++----- Common/DefaultOptions.h | 3 +++ Common/Options.cpp | 7 +++++++ Common/Options.h | 1 + Fltk/fileDialogs.cpp | 10 ++++++++-- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Common/Context.h b/Common/Context.h index 45c61735ea..694e850e02 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -214,7 +214,7 @@ class CTX { int jpegQuality, jpegSmoothing, geoLabels, text, texAsEquation; int gifDither, gifSort, gifInterlace, gifTransparent; int posElementary, posElement, posGamma, posEta, posRho, posDisto; - int compositeWindows; + int compositeWindows, deleteTmpFiles; } print; // color options struct{ diff --git a/Common/CreateFile.cpp b/Common/CreateFile.cpp index f8a16b916a..1629b17a0b 100644 --- a/Common/CreateFile.cpp +++ b/Common/CreateFile.cpp @@ -479,14 +479,14 @@ void CreateOutputFile(std::string fileName, int format) char *args[] = {(char*)"gmsh", (char*)parFileName.c_str()}; try{ mpeg_encode_main(2, args); - UnlinkFile(parFileName); - for(unsigned int i = 0; i < frames.size(); i++) - UnlinkFile(CTX::instance()->homeDir + frames[i]); } catch (const char *error){ Msg::Error("mpeg_encode: %s", error); - Msg::Info("Temporary image were saved in: %s.gmsh-*.ppm", - CTX::instance()->homeDir.c_str()); + } + if(opt_print_delete_tmp_files(0, GMSH_GET, 0)){ + UnlinkFile(parFileName); + for(unsigned int i = 0; i < frames.size(); i++) + UnlinkFile(CTX::instance()->homeDir + frames[i]); } } break; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 8f0433905a..f1f8fdb039 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -1604,6 +1604,9 @@ StringXNumber PrintOptions_Number[] = { { F|O, "CompositeWindows" , opt_print_composite_windows , 0. , "Composite all window tiles in the same output image (for bitmap output only)" }, + { F|O, "DeleteTemporaryFiles" , opt_print_delete_tmp_files , 1. , + "Delete temporary files used during printing" }, + { F|O, "EpsBackground" , opt_print_eps_background , 1. , "Save image background in PostScript/PDF output" }, { F|O, "EpsBestRoot" , opt_print_eps_best_root , 1. , diff --git a/Common/Options.cpp b/Common/Options.cpp index bd1c63736a..36d156561f 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -8514,6 +8514,13 @@ double opt_print_composite_windows(OPT_ARGS_NUM) return CTX::instance()->print.compositeWindows; } +double opt_print_delete_tmp_files(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX::instance()->print.deleteTmpFiles = (int)val; + return CTX::instance()->print.deleteTmpFiles; +} + // Color option routines #if defined(HAVE_FLTK) diff --git a/Common/Options.h b/Common/Options.h index 58eccd97a9..0d1975287c 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -736,6 +736,7 @@ double opt_print_gif_transparent(OPT_ARGS_NUM); double opt_print_text(OPT_ARGS_NUM); double opt_print_tex_as_equation(OPT_ARGS_NUM); double opt_print_composite_windows(OPT_ARGS_NUM); +double opt_print_delete_tmp_files(OPT_ARGS_NUM); // COLORS diff --git a/Fltk/fileDialogs.cpp b/Fltk/fileDialogs.cpp index fff4053506..0013d9aed5 100644 --- a/Fltk/fileDialogs.cpp +++ b/Fltk/fileDialogs.cpp @@ -356,7 +356,7 @@ int mpegFileDialog(const char *name) struct _mpegFileDialog{ Fl_Window *window; Fl_Round_Button *b[2]; - Fl_Check_Button *c[1]; + Fl_Check_Button *c[2]; Fl_Value_Input *v[1]; Fl_Button *ok, *cancel; }; @@ -364,7 +364,7 @@ int mpegFileDialog(const char *name) if(!dialog){ dialog = new _mpegFileDialog; - int h = 3 * WB + 5 * BH, w = 2 * BB + 3 * WB, y = WB; + int h = 3 * WB + 6 * BH, w = 2 * BB + 3 * WB, y = WB; dialog->window = new Fl_Double_Window(w, h, "MPEG Options"); dialog->window->box(GMSH_WINDOW_BOX); dialog->window->set_modal(); @@ -390,6 +390,10 @@ int mpegFileDialog(const char *name) (WB, y, 2 * BB + WB, BH, "Composite all window tiles"); y += BH; dialog->c[0]->type(FL_TOGGLE_BUTTON); + dialog->c[1] = new Fl_Check_Button + (WB, y, 2 * BB + WB, BH, "Delete temporary files"); y += BH; + dialog->c[1]->type(FL_TOGGLE_BUTTON); + dialog->ok = new Fl_Return_Button(WB, y + WB, BB, BH, "OK"); dialog->cancel = new Fl_Button(2 * WB + BB, y + WB, BB, BH, "Cancel"); dialog->window->end(); @@ -400,6 +404,7 @@ int mpegFileDialog(const char *name) dialog->b[1]->value(CTX::instance()->post.animCycle); dialog->v[0]->value(CTX::instance()->post.animDelay); dialog->c[0]->value(CTX::instance()->print.compositeWindows); + dialog->c[1]->value(CTX::instance()->print.deleteTmpFiles); dialog->window->show(); while(dialog->window->shown()){ @@ -411,6 +416,7 @@ int mpegFileDialog(const char *name) opt_post_anim_cycle(0, GMSH_SET | GMSH_GUI, (int)dialog->b[1]->value()); opt_post_anim_delay(0, GMSH_SET | GMSH_GUI, dialog->v[0]->value()); opt_print_composite_windows(0, GMSH_SET | GMSH_GUI, (int)dialog->c[0]->value()); + opt_print_delete_tmp_files(0, GMSH_SET | GMSH_GUI, (int)dialog->c[1]->value()); CreateOutputFile(name, FORMAT_MPEG); dialog->window->hide(); return 1; -- GitLab