From 27000dfa255fafe9e1f68dd6c763abfc2e453666 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 23 Aug 2006 19:53:39 +0000 Subject: [PATCH] simplify TeX printing --- Common/Context.h | 3 +- Common/DefaultOptions.h | 5 +- Common/GmshDefines.h | 4 -- Common/Options.cpp | 11 +++- Common/Options.h | 1 + Fltk/Callbacks.cpp | 63 ++++++---------------- Fltk/GUI.cpp | 12 ++--- Fltk/GUI_Extras.cpp | 105 +++++++++++++++++++++++++++++-------- Fltk/GUI_Extras.h | 5 +- Fltk/Opengl.cpp | 69 +++++++++++++----------- Geo/gmshFace.cpp | 36 ++++++------- Parser/CreateFile.cpp | 44 +++++----------- doc/texinfo/shortcuts.texi | 2 - 13 files changed, 190 insertions(+), 170 deletions(-) diff --git a/Common/Context.h b/Common/Context.h index 54fb93bddb..ed47ca53c3 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -136,6 +136,7 @@ public : int enable_mouse_selection; // enable selection using the mouse int expert_mode; // to disable some warnings for beginners + int printing; // dynamic: equal to 1 while gmsh is printing // geometry options struct{ @@ -216,7 +217,7 @@ public : double eps_line_width_factor, eps_point_size_factor; int jpeg_quality, jpeg_smoothing; int gif_dither, gif_sort, gif_interlace, gif_transparent; - int gl_fonts; + int text; } print; // color options diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index e2689e356d..a05b8a2712 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -1379,6 +1379,9 @@ StringXNumber PrintOptions_Number[] = { { F|O, "JpegSmoothing" , opt_print_jpeg_smoothing , 0. , "JPEG smoothing (between 0 and 100)" }, + { F|O, "Text" , opt_print_text , 1. , + "Print text strings?" }, + { 0, NULL , NULL , 0. } } ; @@ -1400,7 +1403,7 @@ StringXColor GeneralOptions_Color[] = { {255, 255, 255, 255}, {0, 0, 0, 255}, {0, 0, 0, 255}, "Text color" }, { F|O, "Axes" , opt_general_color_axes , - {255, 255, 255, 255}, {128, 128, 128, 255}, {0, 0, 0, 255}, + {255, 255, 255, 255}, {0, 0, 0, 255}, {0, 0, 0, 255}, "Axes color" }, { F|O, "SmallAxes" , opt_general_color_small_axes , {255, 255, 255, 255}, {0, 0, 0, 255}, {0, 0, 0, 255}, diff --git a/Common/GmshDefines.h b/Common/GmshDefines.h index 4920f3bdb7..f705b48418 100644 --- a/Common/GmshDefines.h +++ b/Common/GmshDefines.h @@ -18,15 +18,11 @@ #define FORMAT_SMS 14 #define FORMAT_OPT 15 #define FORMAT_VTK 16 -#define FORMAT_JPEGTEX 17 #define FORMAT_TEX 18 #define FORMAT_VRML 19 #define FORMAT_EPS 20 -#define FORMAT_EPSTEX 21 #define FORMAT_PNG 22 -#define FORMAT_PNGTEX 23 #define FORMAT_PDF 24 -#define FORMAT_PDFTEX 25 #define FORMAT_POS 26 #define FORMAT_STL 27 #define FORMAT_P3D 28 diff --git a/Common/Options.cpp b/Common/Options.cpp index cad50ef4f9..d2541538e3 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.302 2006-08-22 01:58:32 geuzaine Exp $ +// $Id: Options.cpp,v 1.303 2006-08-23 19:53:37 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -131,12 +131,12 @@ void Init_Options(int num) CTX.render_mode = GMSH_RENDER; CTX.pixel_equiv_x = CTX.pixel_equiv_y = 0.; CTX.polygon_offset = 0; + CTX.printing = 0; CTX.mesh_timer[0] = CTX.mesh_timer[1] = CTX.mesh_timer[2] = 0.; CTX.mesh.draw = 1; CTX.post.draw = 1; CTX.post.list = NULL; CTX.post.force_num = 0; - CTX.print.gl_fonts = 1; CTX.threads_lock = 0; // very primitive locking CTX.mesh.changed = 0; CTX.mesh.oldxtrude = CTX.mesh.oldxtrude_recombine = 0; // old extrusion mesh generator @@ -6990,6 +6990,13 @@ double opt_print_gif_transparent(OPT_ARGS_NUM) return CTX.print.gif_transparent; } +double opt_print_text(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX.print.text = (int)val; + return CTX.print.text; +} + // Color option routines #if defined(HAVE_FLTK) diff --git a/Common/Options.h b/Common/Options.h index cee5f195f7..0d741ac44c 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -637,6 +637,7 @@ double opt_print_gif_dither(OPT_ARGS_NUM); double opt_print_gif_sort(OPT_ARGS_NUM); double opt_print_gif_interlace(OPT_ARGS_NUM); double opt_print_gif_transparent(OPT_ARGS_NUM); +double opt_print_text(OPT_ARGS_NUM); // COLORS diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 354c0895b7..15d1a72f56 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.447 2006-08-22 01:58:32 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.448 2006-08-23 19:53:37 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -299,12 +299,14 @@ void activate_cb(CALLBACK_ARGS) WID->mesh_butt[18]->activate(); WID->mesh_butt[19]->activate(); WID->mesh_butt[20]->activate(); + WID->mesh_butt[0]->activate(); WID->mesh_value[18]->activate(); } else{ WID->mesh_butt[18]->deactivate(); WID->mesh_butt[19]->deactivate(); WID->mesh_butt[20]->deactivate(); + WID->mesh_butt[0]->deactivate(); WID->mesh_value[18]->deactivate(); } } @@ -472,7 +474,7 @@ void status_xyz1p_cb(CALLBACK_ARGS) else if(CTX.enable_mouse_selection){ // mouse does nothing opt_general_mouse_selection(0, GMSH_SET | GMSH_GUI, 0); - WID->g_opengl_window->cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE); + WID->g_opengl_window->cursor(FL_CURSOR_DEFAULT, FL_BLACK, FL_WHITE); } else{ // mouse hover and select for geometry, but mouse select only @@ -674,43 +676,22 @@ int _save_stl(char *name) int _save_ps(char *name) { - return gl2ps_dialog(name, "PS Options", 0, 0); + return gl2ps_dialog(name, "PS Options", FORMAT_PS); } int _save_eps(char *name) { - return gl2ps_dialog(name, "EPS Options", 1, 0); -} - -int _save_epstex(char *name) -{ - return gl2ps_dialog(name, "EPS Options", 1, 1); + return gl2ps_dialog(name, "EPS Options", FORMAT_EPS); } int _save_pdf(char *name) { - return gl2ps_dialog(name, "PDF Options", 2, 0); -} - -int _save_pdftex(char *name) -{ - return gl2ps_dialog(name, "PDF Options", 2, 1); + return gl2ps_dialog(name, "PDF Options", FORMAT_PDF); } int _save_svg(char *name) { - return gl2ps_dialog(name, "SVG Options", 3, 0); -} - -int _save_jpegtex(char *name) -{ - return jpeg_dialog(name, 1); -} - -int _save_pngtex(char *name) -{ - CreateOutputFile(name, FORMAT_PNGTEX); - return 1; + return gl2ps_dialog(name, "SVG Options", FORMAT_SVG); } int _save_tex(char *name) @@ -721,13 +702,12 @@ int _save_tex(char *name) int _save_jpeg(char *name) { - return jpeg_dialog(name, 0); + return jpeg_dialog(name); } int _save_png(char *name) { - CreateOutputFile(name, FORMAT_PNG); - return 1; + return generic_bitmap_dialog(name, "PNG Options", FORMAT_PNG); } int _save_gif(char *name) @@ -737,14 +717,12 @@ int _save_gif(char *name) int _save_ppm(char *name) { - CreateOutputFile(name, FORMAT_PPM); - return 1; + return generic_bitmap_dialog(name, "PPM Options", FORMAT_PPM); } int _save_yuv(char *name) { - CreateOutputFile(name, FORMAT_YUV); - return 1; + return generic_bitmap_dialog(name, "YUV Options", FORMAT_YUV); } int _save_auto(char *name) @@ -755,13 +733,13 @@ int _save_auto(char *name) case FORMAT_STL : return _save_stl(name); case FORMAT_PS : return _save_ps(name); case FORMAT_EPS : return _save_eps(name); - case FORMAT_EPSTEX : return _save_epstex(name); case FORMAT_PDF : return _save_pdf(name); - case FORMAT_PDFTEX : return _save_pdftex(name); case FORMAT_SVG : return _save_svg(name); - case FORMAT_JPEGTEX : return _save_jpegtex(name); case FORMAT_JPEG : return _save_jpeg(name); + case FORMAT_PNG : return _save_png(name); case FORMAT_GIF : return _save_gif(name); + case FORMAT_PPM : return _save_ppm(name); + case FORMAT_YUV : return _save_yuv(name); default : CreateOutputFile(name, FORMAT_AUTO); return 1; @@ -795,15 +773,7 @@ void file_save_as_cb(CALLBACK_ARGS) #if defined(HAVE_LIBJPEG) {"JPEG (*.jpg)", _save_jpeg}, #endif - {"LaTeX EPS part without text (*.eps)", _save_epstex}, -#if defined(HAVE_LIBJPEG) - {"LaTeX JPEG part without text (*.jpg)", _save_jpegtex}, -#endif - {"LaTeX PDF part without text (*.pdf)", _save_pdftex}, -#if defined(HAVE_LIBPNG) - {"LaTeX PNG part without text (*.png)", _save_pngtex}, -#endif - {"LaTeX text part (*.tex)", _save_tex}, + {"LaTeX (*.tex)", _save_tex}, {"PDF (*.pdf)", _save_pdf}, #if defined(HAVE_LIBPNG) {"PNG (*.png)", _save_png}, @@ -1600,7 +1570,6 @@ void help_short_cb(CALLBACK_ARGS) Msg(DIRECT, " Alt+b Hide/show bounding boxes"); Msg(DIRECT, " Alt+c Loop through predefined color schemes"); Msg(DIRECT, " Alt+f Change redraw mode (fast/full)"); - Msg(DIRECT, " Alt+g Loop through axes modes for visible post-processing views"); Msg(DIRECT, " Alt+h Hide/show all post-processing views"); Msg(DIRECT, " Alt+i Hide/show all post-processing view scales"); Msg(DIRECT, " Alt+l Hide/show geometry lines"); diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 442c406559..c7bd326894 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.534 2006-08-22 01:58:33 geuzaine Exp $ +// $Id: GUI.cpp,v 1.535 2006-08-23 19:53:37 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -688,6 +688,9 @@ int GUI::global_shortcuts(int event) else if(Fl::test_shortcut(FL_ALT + 'a')) { opt_general_axes(0, GMSH_SET | GMSH_GUI, opt_general_axes(0, GMSH_GET, 0) + 1); + for(i = 0; i < List_Nbr(CTX.post.list); i++) + if(opt_view_visible(i, GMSH_GET, 0)) + opt_view_axes(i, GMSH_SET | GMSH_GUI, opt_view_axes(i, GMSH_GET, 0)+1); redraw_opengl(); return 1; } @@ -784,13 +787,6 @@ int GUI::global_shortcuts(int event) redraw_opengl(); return 1; } - else if(Fl::test_shortcut(FL_ALT + 'g')) { - for(i = 0; i < List_Nbr(CTX.post.list); i++) - if(opt_view_visible(i, GMSH_GET, 0)) - opt_view_axes(i, GMSH_SET | GMSH_GUI, opt_view_axes(i, GMSH_GET, 0)+1); - redraw_opengl(); - return 1; - } else if(Fl::test_shortcut(FL_ALT + 'n')) { for(i = 0; i < List_Nbr(CTX.post.list); i++) if(opt_view_visible(i, GMSH_GET, 0)) diff --git a/Fltk/GUI_Extras.cpp b/Fltk/GUI_Extras.cpp index 5870e53324..b0e47af103 100644 --- a/Fltk/GUI_Extras.cpp +++ b/Fltk/GUI_Extras.cpp @@ -1,4 +1,4 @@ -// $Id: GUI_Extras.cpp,v 1.20 2006-08-19 18:48:06 geuzaine Exp $ +// $Id: GUI_Extras.cpp,v 1.21 2006-08-23 19:53:38 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -214,20 +214,21 @@ int perspective_editor() return 0; } -// jpeg dialog +// save jpeg dialog -int jpeg_dialog(char *name, int TeX) +int jpeg_dialog(char *name) { struct _jpeg_dialog{ Fl_Window *window; Fl_Value_Slider *s[2]; + Fl_Check_Button *b; Fl_Button *ok, *cancel; }; static _jpeg_dialog *dialog = NULL; if(!dialog){ dialog = new _jpeg_dialog; - int h = 3*10 + 25 + 2*25, y = 0; + int h = 3*10 + 25 + 3*25, y = 0; // not a "Dialog_Window" since it is modal dialog->window = new Fl_Double_Window(200, h, "JPEG Options"); y = 10; dialog->window->box(GMSH_WINDOW_BOX); @@ -243,6 +244,10 @@ int jpeg_dialog(char *name, int TeX) dialog->s[1]->minimum(0); dialog->s[1]->maximum(100); dialog->s[1]->step(1); + dialog->b = new Fl_Check_Button(10, y, 180, 25, "Print text strings"); y += 25; + dialog->b->type(FL_TOGGLE_BUTTON); + dialog->b->down_box(GMSH_TOGGLE_BOX); + dialog->b->selection_color(GMSH_TOGGLE_COLOR); dialog->ok = new Fl_Return_Button(10, y+10, 85, 25, "OK"); dialog->cancel = new Fl_Button(105, y+10, 85, 25, "Cancel"); dialog->window->set_modal(); @@ -252,6 +257,7 @@ int jpeg_dialog(char *name, int TeX) dialog->s[0]->value(CTX.print.jpeg_quality); dialog->s[1]->value(CTX.print.jpeg_smoothing); + dialog->b->value(CTX.print.text); dialog->window->show(); while(dialog->window->shown()){ @@ -262,7 +268,60 @@ int jpeg_dialog(char *name, int TeX) if (o == dialog->ok) { opt_print_jpeg_quality(0, GMSH_SET | GMSH_GUI, (int)dialog->s[0]->value()); opt_print_jpeg_smoothing(0, GMSH_SET | GMSH_GUI, (int)dialog->s[1]->value()); - CreateOutputFile(name, TeX ? FORMAT_JPEGTEX : FORMAT_JPEG); + opt_print_text(0, GMSH_SET | GMSH_GUI, (int)dialog->b->value()); + CreateOutputFile(name, FORMAT_JPEG); + dialog->window->hide(); + return 1; + } + if (o == dialog->window || o == dialog->cancel){ + dialog->window->hide(); + return 0; + } + } + } + return 0; +} + +// save generic bitmap dialog + +int generic_bitmap_dialog(char *name, char *title, int format) +{ + struct _generic_bitmap_dialog{ + Fl_Window *window; + Fl_Check_Button *b; + Fl_Button *ok, *cancel; + }; + static _generic_bitmap_dialog *dialog = NULL; + + if(!dialog){ + dialog = new _generic_bitmap_dialog; + int h = 3*10 + 25 + 1*25, y = 0; + // not a "Dialog_Window" since it is modal + dialog->window = new Fl_Double_Window(200, h); y = 10; + dialog->window->box(GMSH_WINDOW_BOX); + dialog->b = new Fl_Check_Button(10, y, 180, 25, "Print text strings"); y += 25; + dialog->b->type(FL_TOGGLE_BUTTON); + dialog->b->down_box(GMSH_TOGGLE_BOX); + dialog->b->selection_color(GMSH_TOGGLE_COLOR); + dialog->ok = new Fl_Return_Button(10, y+10, 85, 25, "OK"); + dialog->cancel = new Fl_Button(105, y+10, 85, 25, "Cancel"); + dialog->window->set_modal(); + dialog->window->end(); + dialog->window->hotspot(dialog->window); + } + + dialog->window->label(title); + dialog->b->value(CTX.print.text); + 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, (int)dialog->b->value()); + CreateOutputFile(name, format); dialog->window->hide(); return 1; } @@ -275,20 +334,20 @@ int jpeg_dialog(char *name, int TeX) return 0; } -// gif dialog +// save gif dialog int gif_dialog(char *name) { struct _gif_dialog{ Fl_Window *window; - Fl_Check_Button *b[4]; + Fl_Check_Button *b[5]; Fl_Button *ok, *cancel; }; static _gif_dialog *dialog = NULL; if(!dialog){ dialog = new _gif_dialog; - int h = 3*10 + 25 + 4*25, y = 0; + int h = 3*10 + 25 + 5*25, y = 0; // not a "Dialog_Window" since it is modal dialog->window = new Fl_Double_Window(200, h, "GIF Options"); y = 10; dialog->window->box(GMSH_WINDOW_BOX); @@ -296,7 +355,8 @@ int gif_dialog(char *name) dialog->b[1] = new Fl_Check_Button(10, y, 180, 25, "Interlace"); y += 25; dialog->b[2] = new Fl_Check_Button(10, y, 180, 25, "Sort colormap"); y += 25; dialog->b[3] = new Fl_Check_Button(10, y, 180, 25, "Transparent background"); y += 25; - for(int i = 0; i < 4; i++){ + dialog->b[4] = new Fl_Check_Button(10, y, 180, 25, "Print text strings"); y += 25; + for(int i = 0; i < 5; i++){ dialog->b[i]->type(FL_TOGGLE_BUTTON); dialog->b[i]->down_box(GMSH_TOGGLE_BOX); dialog->b[i]->selection_color(GMSH_TOGGLE_COLOR); @@ -312,6 +372,7 @@ int gif_dialog(char *name) dialog->b[1]->value(CTX.print.gif_interlace); dialog->b[2]->value(CTX.print.gif_sort); dialog->b[3]->value(CTX.print.gif_transparent); + dialog->b[4]->value(CTX.print.text); dialog->window->show(); while(dialog->window->shown()){ @@ -324,6 +385,7 @@ int gif_dialog(char *name) opt_print_gif_interlace(0, GMSH_SET | GMSH_GUI, dialog->b[1]->value()); opt_print_gif_sort(0, GMSH_SET | GMSH_GUI, dialog->b[2]->value()); opt_print_gif_transparent(0, GMSH_SET | GMSH_GUI, dialog->b[3]->value()); + opt_print_text(0, GMSH_SET | GMSH_GUI, dialog->b[4]->value()); CreateOutputFile(name, FORMAT_GIF); dialog->window->hide(); return 1; @@ -337,7 +399,7 @@ int gif_dialog(char *name) return 0; } -// ps/eps/pdf dialog +// save ps/eps/pdf dialog static void activate_gl2ps_choices(int format, int quality, Fl_Check_Button *b[5]) { @@ -358,7 +420,7 @@ static void activate_gl2ps_choices(int format, int quality, Fl_Check_Button *b[5 b[1]->activate(); b[2]->activate(); b[3]->deactivate(); - if(format == 2 || format == 3) // pdf or svg + if(format == FORMAT_PDF || format == FORMAT_SVG) b[4]->deactivate(); else b[4]->activate(); @@ -367,7 +429,7 @@ static void activate_gl2ps_choices(int format, int quality, Fl_Check_Button *b[5 b[1]->activate(); b[2]->activate(); b[3]->activate(); - if(format == 2 || format == 3) // pdf or svg + if(format == FORMAT_PDF || format == FORMAT_SVG) b[4]->deactivate(); else b[4]->activate(); @@ -375,11 +437,11 @@ static void activate_gl2ps_choices(int format, int quality, Fl_Check_Button *b[5 } } -int gl2ps_dialog(char *name, char *title, int format, int TeX) +int gl2ps_dialog(char *name, char *title, int format) { struct _gl2ps_dialog{ Fl_Window *window; - Fl_Check_Button *b[5]; + Fl_Check_Button *b[6]; Fl_Choice *c; Fl_Button *ok, *cancel; }; @@ -395,7 +457,7 @@ int gl2ps_dialog(char *name, char *title, int format, int TeX) if(!dialog){ dialog = new _gl2ps_dialog; - int h = 3*10 + 25 + 6*25, y = 0; + int h = 3*10 + 25 + 7*25, y = 0; // not a "Dialog_Window" since it is modal dialog->window = new Fl_Double_Window(200, h); y = 10; dialog->window->box(GMSH_WINDOW_BOX); @@ -407,7 +469,8 @@ int gl2ps_dialog(char *name, char *title, int format, int TeX) dialog->b[2] = new Fl_Check_Button(10, y, 180, 25, "Remove hidden primitives"); y += 25; dialog->b[3] = new Fl_Check_Button(10, y, 180, 25, "Optimize BSP tree"); y += 25; dialog->b[4] = new Fl_Check_Button(10, y, 180, 25, "Use level 3 shading"); y += 25; - for(int i = 0; i < 5; i++){ + dialog->b[5] = new Fl_Check_Button(10, y, 180, 25, "Print text strings"); y += 25; + for(int i = 0; i < 6; i++){ dialog->b[i]->type(FL_TOGGLE_BUTTON); dialog->b[i]->down_box(GMSH_TOGGLE_BOX); dialog->b[i]->selection_color(GMSH_TOGGLE_COLOR); @@ -426,6 +489,7 @@ int gl2ps_dialog(char *name, char *title, int format, int TeX) dialog->b[2]->value(CTX.print.eps_occlusion_culling); dialog->b[3]->value(CTX.print.eps_best_root); dialog->b[4]->value(CTX.print.eps_ps3shading); + dialog->b[5]->value(CTX.print.text); activate_gl2ps_choices(format, CTX.print.eps_quality, dialog->b); @@ -447,11 +511,8 @@ int gl2ps_dialog(char *name, char *title, int format, int TeX) opt_print_eps_occlusion_culling(0, GMSH_SET | GMSH_GUI, dialog->b[2]->value()); opt_print_eps_best_root(0, GMSH_SET | GMSH_GUI, dialog->b[3]->value()); opt_print_eps_ps3shading(0, GMSH_SET | GMSH_GUI, dialog->b[4]->value()); - CreateOutputFile(name, - (format == 3) ? FORMAT_SVG : - (format == 2) ? (TeX ? FORMAT_PDFTEX : FORMAT_PDF) : - (format == 1) ? (TeX ? FORMAT_EPSTEX : FORMAT_EPS) : - FORMAT_PS); + opt_print_text(0, GMSH_SET | GMSH_GUI, dialog->b[5]->value()); + CreateOutputFile(name, format); dialog->window->hide(); return 1; } @@ -464,7 +525,7 @@ int gl2ps_dialog(char *name, char *title, int format, int TeX) return 0; } -// gmsh options dialog +// save options dialog int options_dialog(char *name) { diff --git a/Fltk/GUI_Extras.h b/Fltk/GUI_Extras.h index 22ec826fc5..d4b161b97d 100644 --- a/Fltk/GUI_Extras.h +++ b/Fltk/GUI_Extras.h @@ -29,9 +29,10 @@ void file_chooser_get_position(int *x, int *y); int arrow_editor(char *title, double &a, double &b, double &c); int perspective_editor(); -int jpeg_dialog(char *filename, int TeX); +int jpeg_dialog(char *filename); int gif_dialog(char *filename); -int gl2ps_dialog(char *filename, char *title, int format, int TeX); +int generic_bitmap_dialog(char *filename, char *title, int format); +int gl2ps_dialog(char *filename, char *title, int format); int options_dialog(char *filename); int msh_dialog(char *filename); int stl_dialog(char *filename); diff --git a/Fltk/Opengl.cpp b/Fltk/Opengl.cpp index df8ee63ca5..0daf57d8a0 100644 --- a/Fltk/Opengl.cpp +++ b/Fltk/Opengl.cpp @@ -1,4 +1,4 @@ -// $Id: Opengl.cpp,v 1.66 2006-08-20 14:12:40 geuzaine Exp $ +// $Id: Opengl.cpp,v 1.67 2006-08-23 19:53:38 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -70,43 +70,40 @@ void SanitizeTeXString(char *in, char *out) void Draw_String(char *s, char *font_name, int font_enum, int font_size, int align) { - if(align > 0){ - // change the raster position only if not creating TeX files - if(CTX.print.gl_fonts || (CTX.print.format != FORMAT_TEX)){ - GLboolean valid; - glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid); - if(valid == GL_TRUE){ - GLdouble pos[4]; - glGetDoublev(GL_CURRENT_RASTER_POSITION, pos); - double x[3], w[3] = {pos[0], pos[1], pos[2]}; - gl_font(font_enum, font_size); - float width = gl_width(s); - float height = gl_height(); - switch(align){ - case 1: w[0] -= width/2.; break; // bottom center - case 2: w[0] -= width; break; // bottom right - case 3: w[1] -= height; break; // top left - case 4: w[0] -= width/2.; w[1] -= height; break; // top center - case 5: w[0] -= width; w[1] -= height; break; // top right - case 6: w[1] -= height/2.; break; // center left - case 7: w[0] -= width/2.; w[1] -= height/2.; break; // center center - case 8: w[0] -= width; w[1] -= height/2.; break; // center right - default: break; - } - Viewport2World(w, x); - glRasterPos3d(x[0], x[1], x[2]); + if(CTX.printing && !CTX.print.text) return; + + // change the raster position only if not creating TeX files + if(align > 0 && (!CTX.printing || CTX.print.format != FORMAT_TEX)){ + GLboolean valid; + glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid); + if(valid == GL_TRUE){ + GLdouble pos[4]; + glGetDoublev(GL_CURRENT_RASTER_POSITION, pos); + double x[3], w[3] = {pos[0], pos[1], pos[2]}; + gl_font(font_enum, font_size); + float width = gl_width(s); + float height = gl_height(); + switch(align){ + case 1: w[0] -= width/2.; break; // bottom center + case 2: w[0] -= width; break; // bottom right + case 3: w[1] -= height; break; // top left + case 4: w[0] -= width/2.; w[1] -= height; break; // top center + case 5: w[0] -= width; w[1] -= height; break; // top right + case 6: w[1] -= height/2.; break; // center left + case 7: w[0] -= width/2.; w[1] -= height/2.; break; // center center + case 8: w[0] -= width; w[1] -= height/2.; break; // center right + default: break; } + Viewport2World(w, x); + glRasterPos3d(x[0], x[1], x[2]); } } - if(CTX.print.gl_fonts) { + if(!CTX.printing){ gl_font(font_enum, font_size); gl_draw(s); } - else { // ps, pdf or *tex output - if(CTX.print.format == FORMAT_JPEGTEX || - CTX.print.format == FORMAT_PNGTEX) - return; + else{ if(CTX.print.format == FORMAT_TEX){ char tmp[1024]; SanitizeTeXString(s, tmp); @@ -124,8 +121,16 @@ void Draw_String(char *s, char *font_name, int font_enum, int font_size, int ali } gl2psTextOpt(tmp, font_name, font_size, opt, 0.); } - else + else if(CTX.print.eps_quality && (CTX.print.format == FORMAT_PS || + CTX.print.format == FORMAT_EPS || + CTX.print.format == FORMAT_PDF || + CTX.print.format == FORMAT_SVG)){ gl2psText(s, font_name, font_size); + } + else{ + gl_font(font_enum, font_size); + gl_draw(s); + } } } diff --git a/Geo/gmshFace.cpp b/Geo/gmshFace.cpp index 9b7b3efbdf..3aa0ff290f 100644 --- a/Geo/gmshFace.cpp +++ b/Geo/gmshFace.cpp @@ -1,4 +1,4 @@ -// $Id: gmshFace.cpp,v 1.15 2006-08-19 08:26:47 remacle Exp $ +// $Id: gmshFace.cpp,v 1.16 2006-08-23 19:53:39 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -50,26 +50,24 @@ gmshFace::gmshFace(GModel *m, Surface *face) // (simply using the bounding vertices) if(s->Typ == MSH_SURF_PLAN) computeMeanPlane(); - if (s->EmbeddedCurves) - { - for(int i = 0 ; i < List_Nbr(s->EmbeddedCurves); i++){ - Curve *c; - List_Read(s->EmbeddedCurves, i, &c); - GEdge *e = m->edgeByTag(abs(c->Num)); - if(!e) throw; - embedded_edges.push_back(e); - } + if(s->EmbeddedCurves){ + for(int i = 0 ; i < List_Nbr(s->EmbeddedCurves); i++){ + Curve *c; + List_Read(s->EmbeddedCurves, i, &c); + GEdge *e = m->edgeByTag(abs(c->Num)); + if(!e) throw; + embedded_edges.push_back(e); } - if (s->EmbeddedPoints) - { - for(int i = 0 ; i < List_Nbr(s->EmbeddedPoints); i++){ - Vertex *v; - List_Read(s->EmbeddedPoints, i, &v); - GVertex *gv = m->vertexByTag(v->Num); - if(!gv) throw; - embedded_vertices.push_back(gv); - } + } + if(s->EmbeddedPoints){ + for(int i = 0 ; i < List_Nbr(s->EmbeddedPoints); i++){ + Vertex *v; + List_Read(s->EmbeddedPoints, i, &v); + GVertex *gv = m->vertexByTag(v->Num); + if(!gv) throw; + embedded_vertices.push_back(gv); } + } } gmshFace::gmshFace(GModel *m, int num) diff --git a/Parser/CreateFile.cpp b/Parser/CreateFile.cpp index 2c7858a06a..a81a12a112 100644 --- a/Parser/CreateFile.cpp +++ b/Parser/CreateFile.cpp @@ -1,4 +1,4 @@ -// $Id: CreateFile.cpp,v 1.3 2006-08-19 18:48:06 geuzaine Exp $ +// $Id: CreateFile.cpp,v 1.4 2006-08-23 19:53:39 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -70,9 +70,6 @@ int GuessFileFormatFromFileName(char *name) else if(!strcmp(ext, ".eps")) return FORMAT_EPS; else if(!strcmp(ext, ".pdf")) return FORMAT_PDF; else if(!strcmp(ext, ".tex")) return FORMAT_TEX; - else if(!strcmp(ext, ".epstex")) return FORMAT_EPSTEX; - else if(!strcmp(ext, ".pdftex")) return FORMAT_PDFTEX; - else if(!strcmp(ext, ".jpegtex")) return FORMAT_JPEGTEX; else if(!strcmp(ext, ".svg")) return FORMAT_SVG; else if(!strcmp(ext, ".ppm")) return FORMAT_PPM; else if(!strcmp(ext, ".yuv")) return FORMAT_YUV; @@ -118,6 +115,7 @@ void CreateOutputFile(char *filename, int format) int oldformat = CTX.print.format; CTX.print.format = format; + CTX.printing = 1; #if defined(HAVE_FLTK) GLint viewport[4]; @@ -174,14 +172,12 @@ void CreateOutputFile(char *filename, int format) case FORMAT_YUV: case FORMAT_GIF: case FORMAT_JPEG: - case FORMAT_JPEGTEX: case FORMAT_PNG: - case FORMAT_PNGTEX: { FILE *fp; if(!(fp = fopen(name, "wb"))) { Msg(GERROR, "Unable to open file '%s'", name); - return; + break; } PixelBuffer buffer(width, height, GL_RGB, GL_UNSIGNED_BYTE); @@ -189,19 +185,16 @@ void CreateOutputFile(char *filename, int format) int old_bg_gradient = CTX.bg_gradient; if(format == FORMAT_GIF && CTX.print.gif_transparent) CTX.bg_gradient = 0; - if(format == FORMAT_JPEGTEX || format == FORMAT_PNGTEX) - CTX.print.gl_fonts = 0; buffer.Fill(CTX.batch); - CTX.print.gl_fonts = 1; CTX.bg_gradient = old_bg_gradient; if(format == FORMAT_PPM){ create_ppm(fp, &buffer); } - else if (format == FORMAT_YUV){ + else if(format == FORMAT_YUV){ create_yuv(fp, &buffer); } - else if (format == FORMAT_GIF){ + else if(format == FORMAT_GIF){ create_gif(fp, &buffer, CTX.print.gif_dither, CTX.print.gif_sort, @@ -211,7 +204,7 @@ void CreateOutputFile(char *filename, int format) CTX.UNPACK_GREEN(CTX.color.bg), CTX.UNPACK_BLUE(CTX.color.bg)); } - else if(format == FORMAT_JPEG || format == FORMAT_JPEGTEX){ + else if(format == FORMAT_JPEG){ create_jpeg(fp, &buffer, CTX.print.jpeg_quality, CTX.print.jpeg_smoothing); } else{ @@ -223,21 +216,18 @@ void CreateOutputFile(char *filename, int format) case FORMAT_PS: case FORMAT_EPS: - case FORMAT_EPSTEX: case FORMAT_PDF: - case FORMAT_PDFTEX: case FORMAT_SVG: { FILE *fp; if(!(fp = fopen(name, "wb"))) { Msg(GERROR, "Unable to open file '%s'", name); - return; + break; } int psformat; switch(format){ case FORMAT_PDF: - case FORMAT_PDFTEX: psformat = GL2PS_PDF; break; case FORMAT_PS: @@ -256,12 +246,8 @@ void CreateOutputFile(char *filename, int format) PixelBuffer buffer(width, height, GL_RGB, GL_FLOAT); - if(CTX.print.eps_quality == 0){ - if(format == FORMAT_EPSTEX || format == FORMAT_PDFTEX) - CTX.print.gl_fonts = 0; + if(CTX.print.eps_quality == 0) buffer.Fill(CTX.batch); - CTX.print.gl_fonts = 1; - } int pssort = (CTX.print.eps_quality == 3) ? GL2PS_NO_SORT : @@ -273,9 +259,7 @@ void CreateOutputFile(char *filename, int format) (CTX.print.eps_best_root ? GL2PS_BEST_ROOT : 0) | (CTX.print.eps_background ? GL2PS_DRAW_BACKGROUND : 0) | (CTX.print.eps_compress ? GL2PS_COMPRESS : 0) | - (CTX.print.eps_ps3shading ? 0 : GL2PS_NO_PS3_SHADING) | - (format == FORMAT_EPSTEX ? GL2PS_NO_TEXT : 0) | - (format == FORMAT_PDFTEX ? GL2PS_NO_TEXT : 0); + (CTX.print.eps_ps3shading ? 0 : GL2PS_NO_PS3_SHADING); GLint buffsize = 0; int res = GL2PS_OVERFLOW; @@ -302,9 +286,7 @@ void CreateOutputFile(char *filename, int format) glLoadMatrixd(modelview); } else{ - CTX.print.gl_fonts = 0; buffer.Fill(CTX.batch); - CTX.print.gl_fonts = 1; } res = gl2psEndPage(); } @@ -319,7 +301,7 @@ void CreateOutputFile(char *filename, int format) FILE *fp; if(!(fp = fopen(name, "w"))) { Msg(GERROR, "Unable to open file '%s'", name); - return; + break; } GLint buffsize = 0; int res = GL2PS_OVERFLOW; @@ -329,9 +311,10 @@ void CreateOutputFile(char *filename, int format) GL2PS_TEX, GL2PS_NO_SORT, GL2PS_NONE, GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fp, name); PixelBuffer buffer(width, height, GL_RGB, GL_UNSIGNED_BYTE); - CTX.print.gl_fonts = 0; + int oldtext = CTX.print.text; + CTX.print.text = 1; buffer.Fill(CTX.batch); - CTX.print.gl_fonts = 1; + CTX.print.text = oldtext; res = gl2psEndPage(); } fclose(fp); @@ -348,6 +331,7 @@ void CreateOutputFile(char *filename, int format) if(printEndMessage) Msg(STATUS2, "Wrote '%s'", name); CTX.print.format = oldformat; + CTX.printing = 0; #if defined(HAVE_FLTK) Draw(); diff --git a/doc/texinfo/shortcuts.texi b/doc/texinfo/shortcuts.texi index a67be5b784..9f73d22588 100644 --- a/doc/texinfo/shortcuts.texi +++ b/doc/texinfo/shortcuts.texi @@ -96,8 +96,6 @@ Hide/show bounding boxes Loop through predefined color schemes @item Alt+f Change redraw mode (fast/full) -@item Alt+g -Loop through grid modes for visible post-processing views @item Alt+h Hide/show all post-processing views @item Alt+i -- GitLab