From: mpv Date: Mon, 8 Jul 2019 12:33:50 +0000 (+0300) Subject: Support of Steps visualization from the data model level. X-Git-Tag: VEDF2019Lot4~103^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c150c9edee7377d8b228c7d707b561e1a7d9243c;p=modules%2Fshaper.git Support of Steps visualization from the data model level. --- diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 971f8a305..234817691 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -1877,7 +1877,9 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set& t } else if (aGroup->Get() == ModelAPI_ResultGroup::group().c_str()) { aNewBody = createGroup(theFeature->data(), aResIndex); } else if (aGroup->Get() == ModelAPI_ResultField::group().c_str()) { - aNewBody = createField(theFeature->data(), aResIndex); + ResultFieldPtr aField = createField(theFeature->data(), aResIndex); + aField->updateSteps(); // to refresh the internal data + aNewBody = aField; } else if (aGroup->Get() == ModelAPI_ResultParameter::group().c_str()) { theFeature->attributeChanged("expression"); // just produce a value } else { diff --git a/src/Model/Model_ResultField.cpp b/src/Model/Model_ResultField.cpp index f345f733f..67d46f058 100644 --- a/src/Model/Model_ResultField.cpp +++ b/src/Model/Model_ResultField.cpp @@ -150,4 +150,11 @@ std::shared_ptr Model_ResultField::ste } return NULL; } + +std::string Model_ResultField::Model_FieldStep::name() { + std::ostringstream aStream; + aStream<data()->name()<textLine(myId); + return aStream.str(); +} // LCOV_EXCL_STOP diff --git a/src/Model/Model_ResultField.h b/src/Model/Model_ResultField.h index 307861c34..ae66e9a10 100644 --- a/src/Model/Model_ResultField.h +++ b/src/Model/Model_ResultField.h @@ -39,7 +39,11 @@ public: { public: Model_FieldStep(ModelAPI_ResultField* theParent, int theId) - : ModelAPI_ResultField::ModelAPI_FieldStep(), myParent(theParent), myId(theId) {}; + : ModelAPI_ResultField::ModelAPI_FieldStep(), myParent(theParent), myId(theId) + { + setData(myParent->data()); // it is not needed to have special data for the temporary + // step object, but data must be "valid" for GUI checks + }; virtual ModelAPI_ResultField* field() const { return myParent; } @@ -47,12 +51,15 @@ public: virtual std::shared_ptr document() const { return myParent->document(); } + /// Returns a GUI name of this step + virtual std::string name(); + private: ModelAPI_ResultField* myParent; int myId; }; - /// Retuns the parameters of color definition in the resources config manager + /// Returns the parameters of color definition in the resources configuration manager MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName, std::string& theDefault); @@ -73,6 +80,9 @@ public: /// Removes the stored builders MODEL_EXPORT virtual ~Model_ResultField(); + /// To refresh the steps of a field + MODEL_EXPORT virtual void updateSteps(); + protected: /// Makes a body on the given feature data Model_ResultField(std::shared_ptr theOwnerData); @@ -80,7 +90,6 @@ protected: friend class Model_Objects; private: - void updateSteps(); std::vector mySteps; }; diff --git a/src/ModelAPI/ModelAPI_ResultField.h b/src/ModelAPI/ModelAPI_ResultField.h index 2393be2bf..09698048d 100644 --- a/src/ModelAPI/ModelAPI_ResultField.h +++ b/src/ModelAPI/ModelAPI_ResultField.h @@ -67,6 +67,9 @@ public: /// signal. MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay); + /// Returns a GUI name of this step + MODELAPI_EXPORT virtual std::string name() = 0; + protected: /// This method is called just after creation of the object: it must initialize /// all fields, normally initialized in the constructor @@ -104,6 +107,9 @@ public: /// Returns step object /// \param theId an id of the object virtual std::shared_ptr step(int theId) const = 0; + + /// To refresh the steps of a field + MODELAPI_EXPORT virtual void updateSteps() = 0; }; //! Pointer on feature object diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index bfca5d72c..b486fcd5e 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -158,7 +158,7 @@ void XGUI_SelectionMgr::onObjectBrowserSelection() aPrs->dataRange(aMin, aMax); aViewer->setColorScaleRange(aMin, aMax); } - aViewer->setColorScaleTitle("Step"); + aViewer->setColorScaleTitle(aStep->name().c_str()); aViewer->setColorScaleShown(true); } } diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index c58f65782..6de634520 100644 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -271,15 +271,8 @@ void XGUI_WorkshopListener:: ObjectPtr aObj = (*aIt); // Hide the object if it is invalid or concealed one - //bool aHide = !aObj->data() || !aObj->data()->isValid() || - // aObj->isDisabled() || (!aObj->isDisplayed()); - // TODO: Remove the Hide code as soon as a fields step will become as object - bool aHide = false; - if (aObj->groupName() == ModelAPI_ResultField::ModelAPI_FieldStep::group()) - aHide = !aObj->isDisplayed(); - else - aHide = !aObj->data() || !aObj->data()->isValid() || - aObj->isDisabled() || (!aObj->isDisplayed()); + bool aHide = !aObj->data() || !aObj->data()->isValid() || + aObj->isDisabled() || (!aObj->isDisplayed()); if (!aHide) { // check that this is not hidden result ResultPtr aRes = std::dynamic_pointer_cast(aObj);