diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index 8ba2171ee72b7d61e46cc40eb99ed499279e2809..fca1fd8bd69d44271e4189d85c7311f4c70bfe12 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -509,6 +509,15 @@ void Msg::StatusGl(const char *fmt, ...) #endif } +void Msg::SetWindowTitle(const std::string &title) +{ +#if defined(HAVE_FLTK) + if(FlGui::available()){ + FlGui::instance()->setGraphicTitle(title); + } +#endif +} + void Msg::Debug(const char *fmt, ...) { if(_verbosity < 99) return; diff --git a/Common/GmshMessage.h b/Common/GmshMessage.h index 84b962ef27fa074b4ac221ee9e145f74f1b8cc46..7a453d17d239f466b67e4effdeba41d179147736 100644 --- a/Common/GmshMessage.h +++ b/Common/GmshMessage.h @@ -88,6 +88,7 @@ class Msg { static void Direct(const char *fmt, ...); static void StatusBar(bool log, const char *fmt, ...); static void StatusGl(const char *fmt, ...); + static void SetWindowTitle(const std::string &title); static void Debug(const char *fmt, ...); static void ProgressMeter(int n, int N, bool log, const char *fmt, ...); static void SetProgressMeterStep(int step){ _progressMeterStep = step; } diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp index 678d42eaed9ceb15cea1090ff0d9d107177bd4f3..a247574ea03e20744d91c9b94c41abf99c2ef923 100644 --- a/Common/OpenFile.cpp +++ b/Common/OpenFile.cpp @@ -291,14 +291,8 @@ static int defineSolver(const std::string &name) return NUM_SOLVERS - 1; } -int MergeFile(const std::string &fileName, bool warnIfMissing, bool setWindowTitle, - bool setBoundingBox) +int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingBox) { -#if defined(HAVE_FLTK) - if(FlGui::available() && setWindowTitle) - FlGui::instance()->setGraphicTitle(fileName); -#endif - // added 'b' for pure Windows programs, since some of these files // contain binary data gmshFILE fp = gmshopen(fileName.c_str(), "rb"); @@ -324,11 +318,11 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setWindowTit if(ext != ".geo" && ext != ".GEO" && ext != ".unv" && ext != ".UNV"){ if(doSystemUncompress(fileName, noExt)) - return MergeFile(noExt, false, setWindowTitle); + return MergeFile(noExt, false); } #else if(doSystemUncompress(fileName, noExt)) - return MergeFile(noExt, false, setWindowTitle); + return MergeFile(noExt, false); #endif } @@ -581,8 +575,7 @@ int MergePostProcessingFile(const std::string &fileName, int showViews, GModel *m = new GModel(); GModel::setCurrent(m); } - int ret = MergeFile(fileName, warnIfMissing, true, - old->bounds().empty() ? true : false); + int ret = MergeFile(fileName, warnIfMissing, old->bounds().empty() ? true : false); GModel::setCurrent(old); old->setVisibility(1); @@ -645,7 +638,6 @@ void ClearProject() GModel::current()->setName(""); #if defined(HAVE_FLTK) if(FlGui::available()){ - FlGui::instance()->setGraphicTitle(GModel::current()->getFileName()); FlGui::instance()->resetVisibility(); FlGui::instance()->updateViews(true, true); FlGui::instance()->updateFields(); @@ -655,7 +647,7 @@ void ClearProject() Msg::ResetErrorCounter(); } -void OpenProject(const std::string &fileName, bool setWindowTitle) +void OpenProject(const std::string &fileName) { if(CTX::instance()->lock) { Msg::Info("I'm busy! Ask me that later..."); @@ -695,7 +687,7 @@ void OpenProject(const std::string &fileName, bool setWindowTitle) ResetTemporaryBoundingBox(); // merge the file - MergeFile(fileName, false, setWindowTitle); + MergeFile(fileName, false); // fill recent opened file list std::vector<std::string> tmp = CTX::instance()->recentFiles; diff --git a/Common/OpenFile.h b/Common/OpenFile.h index cea05a87bb060e6120003c43c2d6498eef49bf8b..4a4ada89798e1d928009fb2529f3c89d259e4c8f 100644 --- a/Common/OpenFile.h +++ b/Common/OpenFile.h @@ -10,10 +10,10 @@ int ParseFile(const std::string &fileName, bool close, bool warnIfMissing=false); void ParseString(const std::string &str, bool inCurrentModelDir=false); -void OpenProject(const std::string &filename, bool setWindowTitle=true); +void OpenProject(const std::string &filename); void OpenProjectMacFinder(const char *fileName); int MergeFile(const std::string &fileName, bool warnIfMissing=false, - bool setWindowTitle=true, bool setBoundingBox=true); + bool setBoundingBox=true); int MergePostProcessingFile(const std::string &fileName, int showViews=2, bool showLastStep=false, bool warnIfMissing=false); void ClearProject(); diff --git a/Common/onelabUtils.cpp b/Common/onelabUtils.cpp index d0607fbeefb440816c7fb5e79ca7167a1a7c7c85..7b5b5f40c07295eb401b70536657e1e8a307f529 100644 --- a/Common/onelabUtils.cpp +++ b/Common/onelabUtils.cpp @@ -107,13 +107,14 @@ namespace onelabUtils { void guessModelName(onelab::client *c) { + std::string geo = GModel::current()->getFileName(); std::vector<onelab::number> n; c->get(n, c->getName() + "/Guess model name"); if(n.size() && n[0].getValue()){ std::vector<onelab::string> ps; c->get(ps, c->getName() + "/Model name"); if(ps.empty()){ - std::vector<std::string> split = SplitFileName(GModel::current()->getFileName()); + std::vector<std::string> split = SplitFileName(geo); std::string ext = ""; onelab::server::instance()->get(ps, c->getName() + "/File extension"); if(ps.size()) ext = ps[0].getValue(); @@ -122,8 +123,13 @@ namespace onelabUtils { o.setKind("file"); o.setAttribute("Persistent", "1"); c->set(o); + geo += std::string(" - ") + name; + } + else{ + geo += std::string(" - ") + ps[0].getValue(); } } + Msg::SetWindowTitle(geo); } void initializeLoop(const std::string &level) @@ -349,7 +355,7 @@ namespace onelabUtils { // if the model name has changed modelName = GModel::current()->getName(); redraw = true; - OpenProject(GModel::current()->getFileName(), false); + OpenProject(GModel::current()->getFileName()); } } else if(action == "compute"){ @@ -359,7 +365,7 @@ namespace onelabUtils { // have been modified or if the model name has changed modelName = GModel::current()->getName(); redraw = true; - OpenProject(GModel::current()->getFileName(), false); + OpenProject(GModel::current()->getFileName()); if(getFirstComputationFlag() && !StatFile(mshFileName) && meshAuto != 2){ Msg::Info("Skipping mesh generation: assuming '%s' is up-to-date " "(use Solver.AutoMesh=2 to force mesh generation)", diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp index 85aad3c9ae8bc13fdc5edff8aa1e385a4d767564..941934f6d661e956106ecbcb4323d92a500b5845 100644 --- a/Fltk/graphicWindow.cpp +++ b/Fltk/graphicWindow.cpp @@ -232,7 +232,6 @@ static void file_window_cb(Fl_Widget *w, void *data) graphicWindow *g1 = FlGui::instance()->graph.back(); graphicWindow *g2 = new graphicWindow(false, CTX::instance()->numTiles); FlGui::instance()->graph.push_back(g2); - FlGui::instance()->setGraphicTitle(GModel::current()->getFileName()); g2->getWindow()->resize(g1->getWindow()->x() + 10, g1->getWindow()->y() + 10, g1->getWindow()->w(), @@ -494,7 +493,6 @@ static void file_rename_cb(Fl_Widget *w, void *data) rename(GModel::current()->getFileName().c_str(), name.c_str()); GModel::current()->setFileName(name); GModel::current()->setName(SplitFileName(name)[1]); - FlGui::instance()->setGraphicTitle(GModel::current()->getFileName()); drawContext::global()->draw(); } } @@ -2465,7 +2463,7 @@ static void model_switch_cb(Fl_Widget* w, void *data) GModel::list[i]->setVisibility(0); GModel::current()->setVisibility(1); CTX::instance()->mesh.changed = ENT_ALL; - FlGui::instance()->setGraphicTitle(GModel::current()->getFileName()); + Msg::SetWindowTitle(GModel::current()->getFileName()); FlGui::instance()->resetVisibility(); drawContext::global()->draw(); } @@ -3105,6 +3103,7 @@ graphicWindow::graphicWindow(bool main, int numTiles, bool detachedMenu) if(CTX::instance()->menuSize[0] < minw) CTX::instance()->menuSize[0] = minw; _tile->position(twidth, 0, CTX::instance()->menuSize[0], 0); + _win->copy_label(GModel::current()->getFileName().c_str()); _win->position(CTX::instance()->glPosition[0], CTX::instance()->glPosition[1]); _win->end(); @@ -3141,8 +3140,7 @@ graphicWindow::~graphicWindow() void graphicWindow::setTitle(std::string str) { - _title = str; - _win->label(_title.c_str()); + _win->copy_label(str.c_str()); } void graphicWindow::detachMenu() diff --git a/Fltk/graphicWindow.h b/Fltk/graphicWindow.h index 52859e118f5d278d9893a106b7c233b0cd359f3b..5a6559396cdd3d33c385a2f0603b989bfe4a72fa 100644 --- a/Fltk/graphicWindow.h +++ b/Fltk/graphicWindow.h @@ -23,7 +23,6 @@ class graphicWindow{ private: - std::string _title; bool _autoScrollMessages; #if defined(__APPLE__) Fl_Sys_Menu_Bar *_sysbar; diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 33df446c3ed925c53b027d3b1640c648c5db982f..3046c1817e92af549bd9c878b49103adf0b7bb76 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -123,6 +123,7 @@ void GModel::setFileName(std::string fileName) _fileName = fileName; _fileNames.insert(fileName); Msg::SetOnelabString("Gmsh/Model name", fileName, false, false, true); + Msg::SetWindowTitle(fileName); } GModel *GModel::current(int index)