From: mpv Date: Wed, 19 Aug 2015 10:56:45 +0000 (+0300) Subject: Performance optimization: allow to put temporary objects into selection attributes... X-Git-Tag: V_1.4.0_beta4~348 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=54af887c1203416f38576cbdbcde6e539142a079;p=modules%2Fshaper.git Performance optimization: allow to put temporary objects into selection attributes to check validity and then remove them --- diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index f3f4d27a3..767e86331 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -76,8 +76,18 @@ Standard_GUID kPART_REF_ID("635eacb2-a1d6-4dec-8348-471fae17cb27"); // TDataStd_Integer - type of the selected shape (for construction) // TDF_Reference - from ReferenceAttribute, the context void Model_AttributeSelection::setValue(const ResultPtr& theContext, - const std::shared_ptr& theSubShape) + const std::shared_ptr& theSubShape, const bool theTemporarily) { + if (theTemporarily) { // just keep the stored without DF update + myTmpContext = theContext; + myTmpSubShape = theSubShape; + owner()->data()->sendAttributeUpdated(this); + return; + } else { + myTmpContext.reset(); + myTmpSubShape.reset(); + } + const std::shared_ptr& anOldShape = value(); bool isOldContext = theContext == myRef.value(); bool isOldShape = isOldContext && @@ -142,6 +152,10 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext, std::shared_ptr Model_AttributeSelection::value() { + if (myTmpContext.get() || myTmpSubShape.get()) { + return myTmpSubShape; + } + std::shared_ptr aResult; if (myRef.isInitialized()) { TDF_Label aSelLab = selectionLabel(); @@ -229,6 +243,10 @@ void Model_AttributeSelection::setID(const std::string theID) } ResultPtr Model_AttributeSelection::context() { + if (myTmpContext.get() || myTmpSubShape.get()) { + return myTmpContext; + } + ResultPtr aResult = std::dynamic_pointer_cast(myRef.value()); // for parts there could be same-data result, so take the last enabled if (aResult.get() && aResult->groupName() == ModelAPI_ResultPart::group()) { diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 91e77e6e8..1340a34d0 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -21,10 +21,19 @@ class Model_AttributeSelection : public ModelAPI_AttributeSelection { Model_AttributeReference myRef; ///< The reference functionality reusage TDF_LabelMap myScope; ///< the map of valid labels for naming selection solving + /// temporarily storages to avoid keeping in the data structure if not needed + ResultPtr myTmpContext; + /// temporarily storages to avoid keeping in the data structure if not needed + std::shared_ptr myTmpSubShape; public: /// Defines the result and its selected sub-shape + /// \param theContext object where the sub-shape was selected + /// \param theSubShape selected sub-shape (if null, the whole context is selected) + /// \param theTemporarily if it is true, do not store and name the added in the data framework + /// (used to remove immideately, without the following updates) MODEL_EXPORT virtual void setValue( - const ResultPtr& theContext, const std::shared_ptr& theSubShape); + const ResultPtr& theContext, const std::shared_ptr& theSubShape, + const bool theTemporarily = false); /// Returns the selected subshape MODEL_EXPORT virtual std::shared_ptr value(); diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 8191553d1..1d4725c22 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -21,7 +21,8 @@ using namespace std; void Model_AttributeSelectionList::append( - const ResultPtr& theContext, const std::shared_ptr& theSubShape) + const ResultPtr& theContext, const std::shared_ptr& theSubShape, + const bool theTemporarily) { // do not use the degenerated edge as a shape, a list is not incremented in this case if (theSubShape.get() && !theSubShape->isNull() && theSubShape->isEdge()) { @@ -41,7 +42,7 @@ void Model_AttributeSelectionList::append( } aNewAttr->setID(id()); mySize->Set(aNewTag); - aNewAttr->setValue(theContext, theSubShape); + aNewAttr->setValue(theContext, theSubShape, theTemporarily); owner()->data()->sendAttributeUpdated(this); } diff --git a/src/Model/Model_AttributeSelectionList.h b/src/Model/Model_AttributeSelectionList.h index e0eba6b71..676737116 100644 --- a/src/Model/Model_AttributeSelectionList.h +++ b/src/Model/Model_AttributeSelectionList.h @@ -26,8 +26,13 @@ class Model_AttributeSelectionList : public ModelAPI_AttributeSelectionList Handle(TDataStd_Comment) mySelectionType; ///< Contains current type name (same as selection attribute) public: /// Adds the new reference to the end of the list + /// \param theContext object where the sub-shape was selected + /// \param theSubShape selected sub-shape (if null, the whole context is selected) + /// \param theTemporarily if it is true, do not store and name the added in the data framework + /// (used to remove immideately, without the following updates) MODEL_EXPORT virtual void append( - const ResultPtr& theContext, const std::shared_ptr& theSubShape); + const ResultPtr& theContext, const std::shared_ptr& theSubShape, + const bool theTemporarily = false); /// Adds the new reference to the end of the list by the naming name of the selected shape /// The type of shape is taken from the current selection type diff --git a/src/ModelAPI/ModelAPI_AttributeSelection.h b/src/ModelAPI/ModelAPI_AttributeSelection.h index 71c850e59..eccafa5f6 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelection.h +++ b/src/ModelAPI/ModelAPI_AttributeSelection.h @@ -19,8 +19,13 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute { public: /// Defines the result and its selected sub-shape + /// \param theContext object where the sub-shape was selected + /// \param theSubShape selected sub-shape (if null, the whole context is selected) + /// \param theTemporarily if it is true, do not store and name the added in the data framework + /// (used to remove immideately, without the following updates) virtual void setValue( - const ResultPtr& theContext, const std::shared_ptr& theSubShape) = 0; + const ResultPtr& theContext, const std::shared_ptr& theSubShape, + const bool theTemporarily = false) = 0; /// Returns the selected subshape virtual std::shared_ptr value() = 0; diff --git a/src/ModelAPI/ModelAPI_AttributeSelectionList.h b/src/ModelAPI/ModelAPI_AttributeSelectionList.h index 68c7eed8e..b12aa518d 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelectionList.h +++ b/src/ModelAPI/ModelAPI_AttributeSelectionList.h @@ -20,8 +20,13 @@ class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute { public: /// Adds the new reference to the end of the list + /// \param theContext object where the sub-shape was selected + /// \param theSubShape selected sub-shape (if null, the whole context is selected) + /// \param theTemporarily if it is true, do not store and name the added in the data framework + /// (used to remove immideately, without the following updates) virtual void append(const ResultPtr& theContext, - const GeomShapePtr& theSubShape) = 0; + const GeomShapePtr& theSubShape, + const bool theTemporarily = false) = 0; /// Adds the new reference to the end of the list by the naming name of the selected shape /// The type of shape is taken from the current selection type