From c3a3579c798e8f055fc9e2b684656529a9c66c3c Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Mon, 7 Apr 2014 21:26:56 +0000 Subject: [PATCH] New PGF file format contributed by Sebastian Eiser --- Fltk/fileDialogs.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++++ Fltk/fileDialogs.h | 1 + 2 files changed, 82 insertions(+) diff --git a/Fltk/fileDialogs.cpp b/Fltk/fileDialogs.cpp index 2326e95fdb..10e48d1761 100644 --- a/Fltk/fileDialogs.cpp +++ b/Fltk/fileDialogs.cpp @@ -5,6 +5,7 @@ // // Contributor(s): // Stephen Guzik +// Sebastian Eiser // #include <limits> @@ -312,6 +313,86 @@ int genericBitmapFileDialog(const char *name, const char *title, int format) return 0; } +// pgf dialog + +int pgfBitmapFileDialog(const char *name, const char *title, int format) +{ + struct _pgfBitmapFileDialog{ + Fl_Window *window; + Fl_Value_Slider *s[2]; + Fl_Check_Button *b[3]; + Fl_Value_Input *v[2]; + Fl_Button *ok, *cancel; + }; + static _pgfBitmapFileDialog *dialog = NULL; + + if(!dialog){ + dialog = new _pgfBitmapFileDialog; + int h = 3 * WB + 5 * BH, w = 2 * BB + 3 * WB, y = WB; + dialog->window = new Fl_Double_Window(w, h); + dialog->window->box(GMSH_WINDOW_BOX); + dialog->window->set_modal(); + dialog->b[0] = new Fl_Check_Button + (WB, y, 2 * BB + WB, BH, "Flat graphics"); y += BH; + dialog->b[0]->type(FL_TOGGLE_BUTTON); + dialog->b[1] = new Fl_Check_Button + (WB, y, 2 * BB + WB, BH, "Export axis (for entire fig)"); y += BH; + dialog->b[1]->type(FL_TOGGLE_BUTTON); + dialog->b[2] = new Fl_Check_Button + (WB, y, 2 * BB + WB, BH, "Horizontal colorbar"); y += BH; + dialog->b[2]->type(FL_TOGGLE_BUTTON); + dialog->v[0] = new Fl_Value_Input + (WB, y, BB / 2, BH); + dialog->v[0]->minimum(-1); + dialog->v[0]->maximum(5000); + dialog->v[0]->step(1); + dialog->v[1] = new Fl_Value_Input + (WB + BB / 2, y, BB - BB / 2, BH, "Dimensions"); y += BH; + dialog->v[1]->minimum(-1); + dialog->v[1]->maximum(5000); + dialog->v[1]->step(1); + dialog->v[1]->align(FL_ALIGN_RIGHT); + 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(); + dialog->window->hotspot(dialog->window); + } + + dialog->window->label(title); + dialog->b[0]->value(CTX::instance()->print.pgfTwoDim); + dialog->b[1]->value(CTX::instance()->print.pgfExportAxis); + dialog->b[2]->value(CTX::instance()->print.pgfHorizBar); + dialog->v[0]->value(CTX::instance()->print.width); + dialog->v[1]->value(CTX::instance()->print.height); + dialog->window->show(); + + while(dialog->window->shown()){ + Fl::wait(); + for (;;) { + Fl_Widget* o = Fl::readqueue(); + if (!o) break; + if (o == dialog->ok) { + opt_print_text(0, GMSH_SET | GMSH_GUI, 0); // never print any text + opt_print_pgf_two_dim(0, GMSH_SET | GMSH_GUI, (int)dialog->b[0]->value()); + opt_print_background(0, GMSH_SET | GMSH_GUI, 0); // never print background + opt_print_pgf_export_axis(0, GMSH_SET | GMSH_GUI, (int)dialog->b[1]->value()); + opt_print_pgf_horiz_bar(0, GMSH_SET | GMSH_GUI, (int)dialog->b[2]->value()); + opt_print_composite_windows(0, GMSH_SET | GMSH_GUI, 0); // never do compositing print + opt_print_width(0, GMSH_SET | GMSH_GUI, (int)dialog->v[0]->value()); + opt_print_height(0, GMSH_SET | GMSH_GUI, (int)dialog->v[1]->value()); + CreateOutputFile(name, format); + dialog->window->hide(); + return 1; + } + if (o == dialog->window || o == dialog->cancel){ + dialog->window->hide(); + return 0; + } + } + } + return 0; +} + // TeX dialog int latexFileDialog(const char *name) diff --git a/Fltk/fileDialogs.h b/Fltk/fileDialogs.h index c9cdf6bb2c..b8a7291f5c 100644 --- a/Fltk/fileDialogs.h +++ b/Fltk/fileDialogs.h @@ -25,6 +25,7 @@ int mpegFileDialog(const char *filename); int gifFileDialog(const char *filename); int geoFileDialog(const char *filename); int genericBitmapFileDialog(const char *filename, const char *title, int format); +int pgfBitmapFileDialog(const char *filename, const char *title, int format); int genericMeshFileDialog(const char *filename, const char *title, int format, bool binary_support, bool element_tag_support); int posFileDialog(const char *name); -- GitLab