diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp index 42e547abdc24a85b9fa9f910636bc5246292c109..18bb1e8c2bdf8ea05bb033e128af33c637474f9b 100644 --- a/Fltk/menuWindow.cpp +++ b/Fltk/menuWindow.cpp @@ -1790,6 +1790,63 @@ static void mesh_delete_parts_cb(Fl_Widget *w, void *data) Msg::StatusBar(3, false, ""); } +static std::vector<std::string> getInfoStrings(MElement *ele) +{ + std::vector<std::string> info; + { + std::ostringstream sstream; + sstream << "Element " << ele->getNum() << ":"; + info.push_back(sstream.str()); + } + { + std::ostringstream sstream; + const char *name; + MElement::getInfoMSH(ele->getTypeForMSH(), &name); + sstream << " " << name + << " (MSH type " << ele->getTypeForMSH() + << ", dimension "<< ele->getDim() + << ", order "<< ele->getPolynomialOrder() + << ", partition " << ele->getPartition() + << ")"; + info.push_back(sstream.str()); + } + { + std::ostringstream sstream; + sstream << " Vertices:"; + for(int i = 0; i < ele->getNumVertices(); i++) + sstream << " " << ele->getVertex(i)->getNum(); + info.push_back(sstream.str()); + } + { + std::ostringstream sstream; + SPoint3 pt = ele->barycenter(); + sstream << " Barycenter: (" << pt[0] << ", " << pt[1] << ", " << pt[2] << ")"; + info.push_back(sstream.str()); + } + { + std::ostringstream sstream; + sstream << " Quality: " + << "rho = " << ele->rhoShapeMeasure() << " " + << "gamma = " << ele->gammaShapeMeasure() << " " + << "eta = " << ele->etaShapeMeasure(); + info.push_back(sstream.str()); + } + { + std::ostringstream sstream; + double jmin, jmax; + ele->scaledJacRange(jmin, jmax); + sstream << " Scaled Jacobian range: " << jmin << " " << jmax; + info.push_back(sstream.str()); + } + { + std::ostringstream sstream; + sstream << " Inner / outer radius: " + << ele->getInnerRadius() << " / " << ele->getOuterRadius(); + info.push_back(sstream.str()); + } + return info; +} + static void mesh_inspect_cb(Fl_Widget *w, void *data) { CTX::instance()->pickElements = 1; @@ -1804,33 +1861,19 @@ static void mesh_inspect_cb(Fl_Widget *w, void *data) MElement *ele = FlGui::instance()->selectedElements[0]; GModel::current()->setSelection(0); ele->setVisibility(2); - Msg::Direct("Element %d:", ele->getNum()); - int type = ele->getTypeForMSH(); - const char *name; - MElement::getInfoMSH(type, &name); - Msg::Direct(" Type: %d ('%s')", type, name); - Msg::Direct(" Dimension: %d", ele->getDim()); - Msg::Direct(" Order: %d", ele->getPolynomialOrder()); - Msg::Direct(" Partition: %d", ele->getPartition()); - char tmp1[32], tmp2[512]; - sprintf(tmp2, " Vertices:"); - for(int i = 0; i < ele->getNumVertices(); i++){ - sprintf(tmp1, " %d", ele->getVertex(i)->getNum()); - strcat(tmp2, tmp1); - } - Msg::Direct(tmp2); - SPoint3 pt = ele->barycenter(); - Msg::Direct(" Barycenter: (%g,%g,%g)", pt[0], pt[1], pt[2]); - Msg::Direct(" Rho: %g", ele->rhoShapeMeasure()); - Msg::Direct(" Gamma: %g", ele->gammaShapeMeasure()); - Msg::Direct(" Eta: %g", ele->etaShapeMeasure()); - double jmin, jmax; ele->scaledJacRange(jmin, jmax); - Msg::Direct(" Scaled Jacobian Range: %g %g", jmin, jmax); - Msg::Direct(" Inner / outer radius: %g / %g", - ele->getInnerRadius(), ele->getOuterRadius()); CTX::instance()->mesh.changed = ENT_ALL; drawContext::global()->draw(); - FlGui::instance()->showMessages(); + std::vector<std::string> info = getInfoStrings(ele); + for(unsigned int i = 0; i < info.size(); i++) + Msg::Direct("%s", info[i].c_str()); + if(CTX::instance()->tooltips){ + std::string str; + for(unsigned int i = 0; i < info.size(); i++) + str += info[i] + "\n"; + FlGui::instance()->getCurrentOpenglWindow()->drawTooltip(str); + } + else + FlGui::instance()->showMessages(); } } if(ib == 'q') { diff --git a/Fltk/openglWindow.cpp b/Fltk/openglWindow.cpp index 923fa83a3386db92e73859df248edb8ba6f922c1..a767894aba8c18b95d09446dbffed42529a1ddd2 100644 --- a/Fltk/openglWindow.cpp +++ b/Fltk/openglWindow.cpp @@ -582,22 +582,13 @@ int openglWindow::handle(int event) else if(faces.size()) ge = faces[0]; else if(regions.size()) ge = regions[0]; MElement *me = elements.size() ? elements[0] : 0; - static char text[1024] = ""; - sprintf(text, "%s %s", ge ? ge->getInfoString().c_str() : "", - me ? me->getInfoString().c_str() : ""); - if(CTX::instance()->tooltips){ - Fl_Tooltip::exit(0); - double d1 = Fl_Tooltip::delay(); - double d2 = Fl_Tooltip::hoverdelay(); - Fl_Tooltip::delay(0); - Fl_Tooltip::hoverdelay(0); - if(strlen(text) > 3) - Fl_Tooltip::enter_area(this, _curr.win[0], _curr.win[1], 100, 50, text); - Fl_Tooltip::delay(d1); - Fl_Tooltip::hoverdelay(d2); - } + std::string text; + if(ge) text += ge->getInfoString(); + if(me) text += me->getInfoString(); + if(CTX::instance()->tooltips) + drawTooltip(text); else - Msg::StatusBar(2, false, text); + Msg::StatusBar(2, false, text.c_str()); } } _prev.set(_ctx, Fl::event_x(), Fl::event_y()); @@ -695,3 +686,20 @@ char openglWindow::selectEntity(int type, } } } + +void openglWindow::drawTooltip(const std::string &text) +{ + static char str[1024]; + strncpy(str, text.c_str(), sizeof(str)); + Fl_Tooltip::exit(0); + bool enabled = Fl_Tooltip::enabled(); + if(!enabled) Fl_Tooltip::enable(); + double d1 = Fl_Tooltip::delay(); + double d2 = Fl_Tooltip::hoverdelay(); + Fl_Tooltip::delay(0); + Fl_Tooltip::hoverdelay(0); + Fl_Tooltip::enter_area(this, _curr.win[0], _curr.win[1], 100, 50, str); + Fl_Tooltip::delay(d1); + Fl_Tooltip::hoverdelay(d2); + if(!enabled) Fl_Tooltip::disable(); +} diff --git a/Fltk/openglWindow.h b/Fltk/openglWindow.h index c4f25b0dfa2bc9161a5d4676c604ff9389331138..9344a1d2c6f905eb587d2f9be39579f93c10c3df 100644 --- a/Fltk/openglWindow.h +++ b/Fltk/openglWindow.h @@ -44,12 +44,13 @@ class openglWindow : public Fl_Gl_Window { openglWindow(int x, int y, int w, int h, const char *l=0); ~openglWindow(); drawContext *getDrawContext(){ return _ctx; } - char selectEntity(int type, + char selectEntity(int type, std::vector<GVertex*> &vertices, std::vector<GEdge*> &edges, std::vector<GFace*> &faces, std::vector<GRegion*> ®ions, std::vector<MElement*> &elements); static openglWindow *getLastHandled(){ return _lastHandled; } static void setLastHandled(openglWindow *w){ _lastHandled = w; } + void drawTooltip(const std::string &text); }; #endif