From 60cc7bdf598ddc615db122ad2e8c5163c70594b3 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 18 Feb 2016 22:15:45 +0000 Subject: [PATCH] fix spurious setChanged(true, Gmsh) when merging model-based post-processing datasets --- Common/GmshMessage.cpp | 6 ++++-- Common/GmshMessage.h | 6 ++++-- Common/OpenFile.cpp | 10 +++++++--- Common/OpenFile.h | 2 +- Geo/GModel.cpp | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index ee37940fd3..935d53311e 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -742,7 +742,7 @@ bool Msg::UseOnelab() } void Msg::SetOnelabNumber(std::string name, double val, bool visible, - bool persistent, bool readOnly) + bool persistent, bool readOnly, bool neverChanged) { #if defined(HAVE_ONELAB) if(_onelabClient){ @@ -756,13 +756,14 @@ void Msg::SetOnelabNumber(std::string name, double val, bool visible, numbers[0].setVisible(visible); if(persistent) numbers[0].setAttribute("Persistent", "1"); numbers[0].setReadOnly(readOnly); + numbers[0].setNeverChanged(neverChanged); _onelabClient->set(numbers[0]); } #endif } void Msg::SetOnelabString(std::string name, std::string val, bool visible, - bool persistent, bool readOnly) + bool persistent, bool readOnly, bool neverChanged) { #if defined(HAVE_ONELAB) if(_onelabClient){ @@ -776,6 +777,7 @@ void Msg::SetOnelabString(std::string name, std::string val, bool visible, strings[0].setVisible(visible); if(persistent) strings[0].setAttribute("Persistent", "1"); strings[0].setReadOnly(readOnly); + strings[0].setNeverChanged(neverChanged); _onelabClient->set(strings[0]); } #endif diff --git a/Common/GmshMessage.h b/Common/GmshMessage.h index 3f5550c2e4..4f13a6dc24 100644 --- a/Common/GmshMessage.h +++ b/Common/GmshMessage.h @@ -117,9 +117,11 @@ class Msg { static void FinalizeOnelab(); static bool UseOnelab(); static void SetOnelabNumber(std::string name, double val, bool visible=true, - bool persistent=false, bool readOnly=false); + bool persistent=false, bool readOnly=false, + bool neverChanged=false); static void SetOnelabString(std::string name, std::string val, bool visible=true, - bool persistent=false, bool readOnly=false); + bool persistent=false, bool readOnly=false, + bool neverChanged=false); static double GetOnelabNumber(std::string name, double defaultValue=0., bool errorIfMissing=false); static std::string GetOnelabString(std::string name, const std::string &defaultValue="", diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp index bec1b6d8ac..5726a2c7fc 100644 --- a/Common/OpenFile.cpp +++ b/Common/OpenFile.cpp @@ -291,7 +291,8 @@ static int defineSolver(const std::string &name) return NUM_SOLVERS - 1; } -int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingBox) +int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingBox, + bool importPhysicalsInOnelab) { // added 'b' for pure Windows programs, since some of these files // contain binary data @@ -508,7 +509,7 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingB CTX::instance()->geom.draw = 1; CTX::instance()->mesh.changed = ENT_ALL; - Msg::ImportPhysicalGroupsInOnelab(); + if(importPhysicalsInOnelab) Msg::ImportPhysicalGroupsInOnelab(); #if defined(HAVE_FLTK) && defined(HAVE_POST) if(FlGui::available()){ @@ -575,7 +576,10 @@ int MergePostProcessingFile(const std::string &fileName, int showViews, GModel *m = new GModel(); GModel::setCurrent(m); } - int ret = MergeFile(fileName, warnIfMissing, old->bounds().empty() ? true : false); + // FIXME: disabled onelab physical group import for now, as the number of + // groups in mesh-bases post-pro files can be different from the # in the + // model, which will trigger setChanged(Gmsh), leading undesirable remeshing + int ret = MergeFile(fileName, warnIfMissing, old->bounds().empty() ? true : false, false); GModel::setCurrent(old); old->setVisibility(1); diff --git a/Common/OpenFile.h b/Common/OpenFile.h index 4a4ada8979..2d4908d655 100644 --- a/Common/OpenFile.h +++ b/Common/OpenFile.h @@ -13,7 +13,7 @@ void ParseString(const std::string &str, bool inCurrentModelDir=false); void OpenProject(const std::string &filename); void OpenProjectMacFinder(const char *fileName); int MergeFile(const std::string &fileName, bool warnIfMissing=false, - bool setBoundingBox=true); + bool setBoundingBox=true, bool importPhysicalsInOnelab=true); int MergePostProcessingFile(const std::string &fileName, int showViews=2, bool showLastStep=false, bool warnIfMissing=false); void ClearProject(); diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index b7f751eaeb..c3bbcf9022 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -122,7 +122,7 @@ void GModel::setFileName(std::string fileName) { _fileName = fileName; _fileNames.insert(fileName); - Msg::SetOnelabString("Gmsh/Model name", fileName, false, false, true); + Msg::SetOnelabString("Gmsh/Model name", fileName, false, false, true, true); Msg::SetWindowTitle(fileName); } -- GitLab