From 12d6d1654d395df93e2f4189eb377d4365b97930 Mon Sep 17 00:00:00 2001 From: dbv Date: Tue, 6 Nov 2018 16:48:32 +0300 Subject: [PATCH] Added geometrical selection flag to attribute selection list. --- src/Model/Model_AttributeSelection.cpp | 12 ++++++++---- src/Model/Model_AttributeSelectionList.cpp | 11 ++++++++++- src/Model/Model_AttributeSelectionList.h | 7 +++++++ src/ModelAPI/ModelAPI_AttributeSelectionList.h | 5 +++++ src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp | 1 + 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 4b9b6e97f..7bb436eee 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -447,7 +447,8 @@ bool Model_AttributeSelection::isInitialized() } Model_AttributeSelection::Model_AttributeSelection(TDF_Label& theLabel) - : myRef(theLabel) +: myRef(theLabel), + myIsGeometricalSelection(false) { myIsInitialized = myRef.isInitialized(); myParent = NULL; @@ -458,9 +459,12 @@ void Model_AttributeSelection::setID(const std::string theID) myRef.setID(theID); ModelAPI_AttributeSelection::setID(theID); FeaturePtr aFeature = std::dynamic_pointer_cast(owner()); - // TODO: check if parent list have geometrical selection flag. - myIsGeometricalSelection = - ModelAPI_Session::get()->validators()->isGeometricalSelection(aFeature->getKind(), id()); + if (myParent) { + myIsGeometricalSelection = myParent->isGeometricalSelection(); + } else { + myIsGeometricalSelection = + ModelAPI_Session::get()->validators()->isGeometricalSelection(aFeature->getKind(), id()); + } } ResultPtr Model_AttributeSelection::context() diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index c231bfd0e..f32fbcf63 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -371,8 +371,9 @@ bool Model_AttributeSelectionList::isInitialized() } Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel) +: myLab(theLabel), + myIsGeometricalSelection(false) { - myLab = theLabel; reinit(); } @@ -402,3 +403,11 @@ void Model_AttributeSelectionList::cashValues(const bool theEnabled) } } } + +void Model_AttributeSelectionList::setGeometricalSelection(const bool theIsGeometricalSelection) +{ + myIsGeometricalSelection = theIsGeometricalSelection; + // TODO: update list accodring to the flag: + // false - all objects with same geometry must be splited in separate. + // true - all objets with same geometry must be combined into single. +} diff --git a/src/Model/Model_AttributeSelectionList.h b/src/Model/Model_AttributeSelectionList.h index ef33f6b16..1870d95d4 100644 --- a/src/Model/Model_AttributeSelectionList.h +++ b/src/Model/Model_AttributeSelectionList.h @@ -113,6 +113,13 @@ public: /// during non-modification operations with this attribute) MODEL_EXPORT virtual void cashValues(const bool theEnabled); + MODEL_EXPORT virtual void setGeometricalSelection(const bool theIsGeometricalSelection) override; + + /// Returns true if is geometrical selection. + MODEL_EXPORT virtual bool isGeometricalSelection() const override { + return myIsGeometricalSelection; + }; + protected: /// Objects are created for features automatically MODEL_EXPORT Model_AttributeSelectionList(TDF_Label& theLabel); diff --git a/src/ModelAPI/ModelAPI_AttributeSelectionList.h b/src/ModelAPI/ModelAPI_AttributeSelectionList.h index fe432944a..6f2cafb18 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelectionList.h +++ b/src/ModelAPI/ModelAPI_AttributeSelectionList.h @@ -98,6 +98,11 @@ class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute /// during non-modification operations with this attribute) virtual void cashValues(const bool theEnabled) = 0; + virtual void setGeometricalSelection(const bool theIsGeometricalSelection) = 0; + + /// Returns true if is geometrical selection. + virtual bool isGeometricalSelection() const = 0; + /// Returns the type of this class of attributes static std::string typeId() { diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 6af9a7a9d..9a2007cd9 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -1059,6 +1059,7 @@ void ModuleBase_WidgetMultiSelector::onSameTopology(bool theOn) if (aType == ModelAPI_AttributeSelectionList::typeId()) { AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); //TODO: set same topology flag + aSelectionListAttr->setGeometricalSelection(theOn); updateObject(myFeature); } } -- 2.39.2