diff --git a/Fltk/Draw.cpp b/Fltk/Draw.cpp index 579062a7fdf94694bbfaee97260055ff31263028..c4a3070193593880cce8125404de132515c66c18 100644 --- a/Fltk/Draw.cpp +++ b/Fltk/Draw.cpp @@ -173,32 +173,6 @@ void Draw_String(std::string s, double style) } } -void Draw_OnScreenMessages(int index) -{ - if(!GUI::available()) return; - - glColor4ubv((GLubyte *) & CTX.color.text); - gl_font(CTX.gl_font_enum, CTX.gl_fontsize); - double h = gl_height(); - - if(index >= 0 && index < GUI::instance()->graph.size()){ - drawContext *ctx = GUI::instance()->graph[index]->gl->getDrawContext(); - - if(strlen(GUI::instance()->onscreen_buffer[0])){ - double w = gl_width(GUI::instance()->onscreen_buffer[0]); - glRasterPos2d(ctx->viewport[2] / 2. - w / 2., - ctx->viewport[3] - 1.2 * h); - gl_draw(GUI::instance()->onscreen_buffer[0]); - } - if(strlen(GUI::instance()->onscreen_buffer[1])){ - double w = gl_width(GUI::instance()->onscreen_buffer[1]); - glRasterPos2d(ctx->viewport[2] / 2. - w / 2., - ctx->viewport[3] - 2.4 * h); - gl_draw(GUI::instance()->onscreen_buffer[1]); - } - } -} - void GetStoredViewport(int viewport[4], int index) { if(!GUI::available()) return; diff --git a/Fltk/Draw.h b/Fltk/Draw.h index d6d8463407680945bce148b0656a1227da31a51f..1e171a44fae1dcdce87ff981d1eb27b0ba397266 100644 --- a/Fltk/Draw.h +++ b/Fltk/Draw.h @@ -19,7 +19,6 @@ void Draw_String(std::string); void Draw_String(std::string, double style); void Draw_String_Center(std::string); void Draw_String_Right(std::string); -void Draw_OnScreenMessages(int index=0); void GetStoredViewport(int viewport[4], int index=0); void Viewport2World(double win[3], double xyz[3]); diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 507202b7550de6b7c9e10e50b771939ace97c15a..6ace1a0aff2162e36f9c04407d58e53394143313 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -49,10 +49,6 @@ static int globalShortcut(int event) GUI::GUI(int argc, char **argv) { - // initialize on-screen message buffer - onscreen_buffer[0][0] = '\0'; - onscreen_buffer[1][0] = '\0'; - // set X display if(strlen(CTX.display)) Fl::display(CTX.display); @@ -554,6 +550,24 @@ void GUI::resetVisibility() visibility_cb(NULL, NULL); } +int GUI::getLastGraphIndex() +{ + unsigned int index = 0; + if(graph.size() > 1) + for(Fl_Window *w = Fl::first_window(); w; w = Fl::next_window(w)) + for(index = 0; index < GUI::instance()->graph.size(); index++) + if(w == graph[index]->win || w == graph[index]->gl) + return index; + return 0; +} + +char GUI::selectEntity(int type) +{ + return graph[getLastGraphIndex()]->gl->selectEntity + (type, selectedVertices, selectedEdges, selectedFaces, selectedRegions, + selectedElements); +} + void GUI::setStatus(const char *msg, int num) { if(num == 0 || num == 1){ @@ -566,15 +580,17 @@ void GUI::setStatus(const char *msg, int num) } } else if(num == 2){ + int index = getLastGraphIndex(); int n = strlen(msg); int i = 0; while(i < n) if(msg[i++] == '\n') break; - strncpy(onscreen_buffer[0], msg, sizeof(onscreen_buffer[0]) - 1); + graph[index]->gl->screenMessage[0] = std::string(msg); + if(i) + graph[index]->gl->screenMessage[0].resize(i - 1); if(i < n) - strncpy(onscreen_buffer[1], &msg[i], sizeof(onscreen_buffer[1]) - 1); + graph[index]->gl->screenMessage[1] = std::string(&msg[i]); else - onscreen_buffer[1][0] = '\0'; - onscreen_buffer[0][i-1] = '\0'; + graph[index]->gl->screenMessage[1].clear(); Draw(); } } @@ -621,20 +637,6 @@ void GUI::callForSolverPlugin(int dim) if(sp) sp->popupPropertiesForPhysicalEntity(dim); } -char GUI::selectEntity(int type) -{ - unsigned int index = 0; - if(graph.size() > 1) - for(Fl_Window *w = Fl::first_window(); w; w = Fl::next_window(w)) - for(index = 0; index < GUI::instance()->graph.size(); index++) - if(w == graph[index]->win || w == graph[index]->gl) - goto done; - done: - return graph[index]->gl->selectEntity - (type, selectedVertices, selectedEdges, selectedFaces, selectedRegions, - selectedElements); -} - // Callbacks void hide_cb(Fl_Widget *w, void *data) diff --git a/Fltk/GUI.h b/Fltk/GUI.h index bcbb0109db3a93c7519c344d1eb91522b7e51455..23cc1828959e2cb3fd55a0f459b8a7871ebb4670 100644 --- a/Fltk/GUI.h +++ b/Fltk/GUI.h @@ -43,7 +43,6 @@ class GUI{ int _fontsize; static GUI *_instance; public: - char onscreen_buffer[2][256]; std::vector<GVertex*> selectedVertices; std::vector<GEdge*> selectedEdges; std::vector<GFace*> selectedFaces; @@ -97,12 +96,14 @@ class GUI{ void resetVisibility(); // store current window positions and sizes in CTX void storeCurrentWindowsInfo(); + // get the index of the last graphic window that received an event + int getLastGraphIndex(); + // select an entity in the most recent graphic window + char selectEntity(int type); // display status message void setStatus(const char *msg, int num); // create the window for physical context dependant definitions void callForSolverPlugin(int dim); - // select an entity in the most recent graphic window - char selectEntity(int type); }; // callbacks diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp index 3be33213a3a535d2548dc488f55fc9c939c8c845..ade588802727c739959a00c9123bb14d5b0dc77a 100644 --- a/Fltk/menuWindow.cpp +++ b/Fltk/menuWindow.cpp @@ -1230,7 +1230,8 @@ static void action_point_line_surface_volume(int action, int mode, const char *w add_physical(what, List1, CTX.filename); break; case 8: - add_charlength(List1, CTX.filename, GUI::instance()->meshContext->input[0]->value()); + add_charlength(List1, CTX.filename, + GUI::instance()->meshContext->input[0]->value()); break; case 9: add_recosurf(List1, CTX.filename); diff --git a/Fltk/openglWindow.cpp b/Fltk/openglWindow.cpp index 455f17bbc67d108517a61480bdf4d96fcff9eb2b..674d6f872e14d48b09727c9ae24d69b9703fa00e 100644 --- a/Fltk/openglWindow.cpp +++ b/Fltk/openglWindow.cpp @@ -86,6 +86,31 @@ openglWindow::~openglWindow() delete _ctx; } +void openglWindow::drawScreenMessage() +{ + if(screenMessage[0].empty() && screenMessage[1].empty()) + return; + + glColor4ubv((GLubyte *) & CTX.color.text); + gl_font(CTX.gl_font_enum, CTX.gl_fontsize); + double h = gl_height(); + + if(screenMessage[0].size()){ + const char *txt = screenMessage[0].c_str(); + double w = gl_width(txt); + glRasterPos2d(_ctx->viewport[2] / 2. - w / 2., + _ctx->viewport[3] - 1.2 * h); + gl_draw(txt); + } + if(screenMessage[1].size()){ + const char *txt = screenMessage[1].c_str(); + double w = gl_width(txt); + glRasterPos2d(_ctx->viewport[2] / 2. - w / 2., + _ctx->viewport[3] - 2.4 * h); + gl_draw(txt); + } +} + void openglWindow::draw() { static int locked = 0; @@ -163,6 +188,7 @@ void openglWindow::draw() glVertex3d(_point[0], _point[1], _point[2]); glEnd(); _ctx->draw2d(); + drawScreenMessage(); CTX.mesh.draw = 1; CTX.post.draw = 1; } @@ -171,6 +197,7 @@ void openglWindow::draw() ClearOpengl(); _ctx->draw3d(); _ctx->draw2d(); + drawScreenMessage(); } locked = 0; diff --git a/Fltk/openglWindow.h b/Fltk/openglWindow.h index 730b3935677e8ec9d9cca61c80d3a3406f8e40dd..e8d88c559e303254e06aa1e5639e422f3b85239e 100644 --- a/Fltk/openglWindow.h +++ b/Fltk/openglWindow.h @@ -7,6 +7,7 @@ #define _OPENGL_WINDOW_H_ #include <vector> +#include <string> #include <FL/Fl_Gl_Window.H> #include <FL/Fl_Box.H> #include "drawContext.h" @@ -47,8 +48,7 @@ class openglWindow : public Fl_Gl_Window { drawContext *_ctx; double _point[3]; int _selection, _trySelection, _trySelectionXYWH[4]; - void draw(); - int handle(int); + void drawScreenMessage(); bool processSelectionBuffer(int type, bool multipleSelection, bool meshSelection, int x, int y, int w, int h, @@ -57,9 +57,12 @@ class openglWindow : public Fl_Gl_Window { std::vector<GFace*> &faces, std::vector<GRegion*> ®ions, std::vector<MElement*> &elements); + void draw(); + int handle(int); public: bool addPointMode, lassoMode, selectionMode; int endSelection, undoSelection, invertSelection, quitSelection; + std::string screenMessage[2]; openglWindow(int x, int y, int w, int h, const char *l=0); ~openglWindow(); drawContext *getDrawContext(){ return _ctx; } diff --git a/Graphics/drawContext.cpp b/Graphics/drawContext.cpp index 29956737927e4447cc96b13b69c12c45cd35426e..1be038183c1be4c8138a2a6e39707988ae0c3126 100644 --- a/Graphics/drawContext.cpp +++ b/Graphics/drawContext.cpp @@ -199,7 +199,6 @@ void drawContext::draw2d() drawGraph2d(); drawText2d(); - Draw_OnScreenMessages(); if(CTX.post.draw) drawScales(); if(CTX.small_axes)