From 3be81f569596ca3793c48a7d595760f90200fc71 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 12 May 2017 10:09:49 +0200 Subject: [PATCH] add direct tickz (pgf) output through gl2ps + fix file dialog (incorrect activation of some options since background changes) --- Common/CreateFile.cpp | 6 +++++- Common/GmshDefines.h | 1 + Fltk/fileDialogs.cpp | 17 +++++++---------- Fltk/graphicWindow.cpp | 4 ++++ Graphics/drawGlyph.cpp | 3 ++- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Common/CreateFile.cpp b/Common/CreateFile.cpp index 721ba25721..f744e81f1e 100644 --- a/Common/CreateFile.cpp +++ b/Common/CreateFile.cpp @@ -71,6 +71,7 @@ int GetFileFormatFromExtension(const std::string &ext) else if(ext == ".pdf") return FORMAT_PDF; else if(ext == ".tex") return FORMAT_TEX; else if(ext == ".svg") return FORMAT_SVG; + else if(ext == ".tikz") return FORMAT_TIKZ; else if(ext == ".ppm") return FORMAT_PPM; else if(ext == ".yuv") return FORMAT_YUV; else if(ext == ".brep") return FORMAT_BREP; @@ -120,12 +121,13 @@ std::string GetDefaultFileName(int format) case FORMAT_JPEG: name += ".jpg"; break; case FORMAT_MPEG: name += ".mpg"; break; case FORMAT_PNG: name += ".png"; break; - case FORMAT_PGF: name += ".todo"; break; + case FORMAT_PGF: name += ".pgf"; break; case FORMAT_PS: name += ".ps"; break; case FORMAT_EPS: name += ".eps"; break; case FORMAT_PDF: name += ".pdf"; break; case FORMAT_TEX: name += ".tex"; break; case FORMAT_SVG: name += ".svg"; break; + case FORMAT_TIKZ: name += ".tikz"; break; case FORMAT_PPM: name += ".ppm"; break; case FORMAT_YUV: name += ".yuv"; break; case FORMAT_BREP: name += ".brep"; break; @@ -437,6 +439,7 @@ void CreateOutputFile(const std::string &fileName, int format, case FORMAT_EPS: case FORMAT_PDF: case FORMAT_SVG: + case FORMAT_TIKZ: { if(!FlGui::available()) break; @@ -460,6 +463,7 @@ void CreateOutputFile(const std::string &fileName, int format, (format == FORMAT_PDF) ? GL2PS_PDF : (format == FORMAT_PS) ? GL2PS_PS : (format == FORMAT_SVG) ? GL2PS_SVG : + (format == FORMAT_TIKZ) ? GL2PS_PGF : GL2PS_EPS; int pssort = (CTX::instance()->print.epsQuality == 3) ? GL2PS_NO_SORT : diff --git a/Common/GmshDefines.h b/Common/GmshDefines.h index e80216beef..630462e3fd 100644 --- a/Common/GmshDefines.h +++ b/Common/GmshDefines.h @@ -54,6 +54,7 @@ #define FORMAT_PVTU 45 #define FORMAT_X3D 46 #define FORMAT_TOCHNOG 47 +#define FORMAT_TIKZ 48 // Element types #define TYPE_PNT 1 diff --git a/Fltk/fileDialogs.cpp b/Fltk/fileDialogs.cpp index 2dda82b3a8..b0e7ce1e1c 100644 --- a/Fltk/fileDialogs.cpp +++ b/Fltk/fileDialogs.cpp @@ -688,26 +688,23 @@ static void activate_gl2ps_choices(int format, int quality, Fl_Check_Button *b[5 b[1]->deactivate(); b[2]->deactivate(); b[3]->deactivate(); - b[4]->deactivate(); break; case 1: // simple sort case 3: // unsorted b[1]->activate(); - b[2]->activate(); - b[3]->deactivate(); - if(format == FORMAT_PDF || format == FORMAT_SVG) - b[4]->deactivate(); + b[2]->deactivate(); + if(format == FORMAT_PS || format == FORMAT_EPS) + b[3]->activate(); else - b[4]->activate(); + b[3]->deactivate(); break; case 2: // bsp sort b[1]->activate(); b[2]->activate(); - b[3]->activate(); - if(format == FORMAT_PDF || format == FORMAT_SVG) - b[4]->deactivate(); + if(format == FORMAT_PS || format == FORMAT_EPS) + b[3]->activate(); else - b[4]->activate(); + b[3]->deactivate(); break; } } diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp index 7689c0d2ca..edc6401396 100644 --- a/Fltk/graphicWindow.cpp +++ b/Fltk/graphicWindow.cpp @@ -335,6 +335,8 @@ static int _save_ppm(const char *name){ return genericBitmapFileDialog (name, "PPM Options", FORMAT_PPM); } static int _save_svg(const char *name){ return gl2psFileDialog (name, "SVG Options", FORMAT_SVG); } +static int _save_tikz(const char *name){ return gl2psFileDialog + (name, "TIKZ Options", FORMAT_TIKZ); } static int _save_yuv(const char *name){ return genericBitmapFileDialog (name, "YUV Options", FORMAT_YUV); } static int _save_view_pos(const char *name){ return posFileDialog(name); } @@ -389,6 +391,7 @@ static int _save_auto(const char *name) case FORMAT_PS : return _save_ps(name); case FORMAT_PPM : return _save_ppm(name); case FORMAT_SVG : return _save_svg(name); + case FORMAT_TIKZ : return _save_tikz(name); case FORMAT_YUV : return _save_yuv(name); default : CreateOutputFile(name, FORMAT_AUTO); @@ -455,6 +458,7 @@ static void file_export_cb(Fl_Widget *w, void *data) {"Image - PostScript" TT "*.ps", _save_ps}, {"Image - PPM" TT "*.ppm", _save_ppm}, {"Image - SVG" TT "*.svg", _save_svg}, + {"Image - TIKZ" TT "*.tikz", _save_tikz}, {"Image - YUV" TT "*.yuv", _save_yuv}, #if defined(HAVE_MPEG_ENCODE) {"Movie - MPEG" TT "*.mpg", _save_mpeg}, diff --git a/Graphics/drawGlyph.cpp b/Graphics/drawGlyph.cpp index 5834e8934b..557e59f4e9 100644 --- a/Graphics/drawGlyph.cpp +++ b/Graphics/drawGlyph.cpp @@ -86,7 +86,8 @@ void drawContext::drawString(const std::string &s, double x, double y, double z, (CTX::instance()->print.fileFormat == FORMAT_PS || CTX::instance()->print.fileFormat == FORMAT_EPS || CTX::instance()->print.fileFormat == FORMAT_PDF || - CTX::instance()->print.fileFormat == FORMAT_SVG)){ + CTX::instance()->print.fileFormat == FORMAT_SVG || + CTX::instance()->print.fileFormat == FORMAT_TIKZ)){ gl2psText(s.c_str(), font_name.c_str(), font_size); } else{ -- GitLab