From 9d50fe053db25f771ea8ae9775b579d24f30d8ff Mon Sep 17 00:00:00 2001 From: cg246364 Date: Fri, 9 Jul 2021 14:21:05 +0200 Subject: [PATCH] First volume --- src/ModelAPI/ModelAPI_Events.cpp | 18 ++++++++++++++++++ src/ModelAPI/ModelAPI_Events.h | 7 +++++++ src/ModelAPI/ModelAPI_Feature.cpp | 15 +++++++++++++++ src/ModelAPI/ModelAPI_Feature.h | 7 +++++++ src/PartSet/PartSet_TreeNodes.cpp | 9 +++++++++ src/PartSet/PartSet_TreeNodes.h | 4 +++- src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp | 1 + 7 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/ModelAPI/ModelAPI_Events.cpp b/src/ModelAPI/ModelAPI_Events.cpp index 6b0ea3ef5..22b8aa12d 100644 --- a/src/ModelAPI/ModelAPI_Events.cpp +++ b/src/ModelAPI/ModelAPI_Events.cpp @@ -167,6 +167,16 @@ void ModelAPI_ParameterEvalMessage::setResults( myIsProcessed = true; } +void ModelAPI_ParameterEvalMessage::setVolumes( + const std::list >& theParamsList, + const double theResult, const std::string& theError) +{ + myParamsList = theParamsList; + myResult = theResult; + myError = theError; + myIsProcessed = true; +} + bool ModelAPI_ParameterEvalMessage::isProcessed() { return myIsProcessed; @@ -214,6 +224,14 @@ void ModelAPI_BuildEvalMessage::setResults( myError = theError; myIsProcessed = true; } +void ModelAPI_BuildEvalMessage::setVolumes( + const std::list >& theParamsList, + const std::string& theError) +{ + myParamsList = theParamsList; + myError = theError; + myIsProcessed = true; +} const std::list >& ModelAPI_BuildEvalMessage::params() const diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h index a5dc0dde9..c8d77349c 100644 --- a/src/ModelAPI/ModelAPI_Events.h +++ b/src/ModelAPI/ModelAPI_Events.h @@ -342,6 +342,9 @@ class ModelAPI_ParameterEvalMessage : public Events_Message MODELAPI_EXPORT void setResults( const std::list >& theParamsList, const double theResult, const std::string& theError); + MODELAPI_EXPORT void setVolumes( + const std::list >& theParamsList, + const double theResult, const std::string& theError); /// Returns true if the expression is processed MODELAPI_EXPORT bool isProcessed(); /// Returns the results of processing: list of parameters found in the expression @@ -395,6 +398,10 @@ class ModelAPI_BuildEvalMessage : public Events_Message MODELAPI_EXPORT void setResults( const std::list >& theParamsList, const std::string& theError); + /// Sets the results of processing + MODELAPI_EXPORT void setVolumes( + const std::list >& theParamsList, + const std::string& theError); /// Returns the results of processing: list of parameters found in the expression MODELAPI_EXPORT const std::list >& params() const; /// Returns true if the expression is processed diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp index 14397b0fe..f05ceaf70 100644 --- a/src/ModelAPI/ModelAPI_Feature.cpp +++ b/src/ModelAPI/ModelAPI_Feature.cpp @@ -87,6 +87,21 @@ void ModelAPI_Feature::setResult(const std::shared_ptr& theResu theResult->setDisabled(theResult, false); } +void ModelAPI_Feature::setVolume(const std::shared_ptr& theResult, + const int theIndex) +{ + std::list >::iterator aResIter = myVolumes.begin(); + for (int anIndex = 0; anIndex < theIndex; anIndex++) { + aResIter++; + } + if (aResIter == myVolumes.end()) { // append + myVolumes.push_back(theResult); + } else { // update + *aResIter = theResult; + } + theResult->setDisabled(theResult, false); +} + void ModelAPI_Feature::eraseResultFromList(const std::shared_ptr& theResult) { std::list >::iterator aResIter = myResults.begin(); diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index 235275f30..297579ba1 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -39,6 +39,7 @@ class ModelAPI_Feature : public ModelAPI_Object { ///< list of current results of this feature std::list > myResults; + std::list > myVolumes; ///< is feature disabled or not bool myIsDisabled; ///< is feature is stable (not editing) @@ -109,6 +110,12 @@ class ModelAPI_Feature : public ModelAPI_Object /// removes the result from the list of feature (not doing in disabled): normally this /// method is not used from features. only internally MODELAPI_EXPORT void eraseResultFromList(const std::shared_ptr& theResult); + + /// sets the alone volume + MODELAPI_EXPORT void setVolume(const std::shared_ptr& theResult); + /// sets the result by index (zero based), results before this must be set before + MODELAPI_EXPORT void setVolume(const std::shared_ptr& theResult, + const int theIndex); /// Returns true if result is persistent (stored in document) and on undo-redo, save-open /// it is not needed to recompute it. diff --git a/src/PartSet/PartSet_TreeNodes.cpp b/src/PartSet/PartSet_TreeNodes.cpp index dab816179..aea786b9d 100644 --- a/src/PartSet/PartSet_TreeNodes.cpp +++ b/src/PartSet/PartSet_TreeNodes.cpp @@ -439,6 +439,8 @@ QString PartSet_FolderNode::name() const return QObject::tr("Fields"); case GroupsFolder: return QObject::tr("Groups"); + case VolumesFolder: + return QObject::tr("Volumes"); } return "NoName"; } @@ -467,6 +469,8 @@ QVariant PartSet_FolderNode::data(int theColumn, int theRole) const return aConstrIco; case GroupsFolder: return aConstrIco; + case VolumesFolder: + return aConstrIco; } } } @@ -571,6 +575,8 @@ std::string PartSet_FolderNode::groupName() const return ModelAPI_ResultField::group(); case GroupsFolder: return ModelAPI_ResultGroup::group(); + case VolumesFolder: + return ModelAPI_ResultBody::group(); } return ""; } @@ -863,10 +869,12 @@ PartSet_PartRootNode::PartSet_PartRootNode(const ObjectPtr& theObj, ModuleBase_I myResultsFolder = new PartSet_FolderNode(this, PartSet_FolderNode::ResultsFolder); myFieldsFolder = new PartSet_FolderNode(this, PartSet_FolderNode::FieldsFolder); myGroupsFolder = new PartSet_FolderNode(this, PartSet_FolderNode::GroupsFolder); + myVolumesFolder = new PartSet_FolderNode(this, PartSet_FolderNode::VolumesFolder); myChildren.append(myParamsFolder); myChildren.append(myConstrFolder); myChildren.append(myResultsFolder); + myChildren.append(myVolumesFolder); update(); } @@ -894,6 +902,7 @@ void PartSet_PartRootNode::update() myResultsFolder->update(); myFieldsFolder->update(); myGroupsFolder->update(); + myVolumesFolder->update(); bool aHasFields = myFieldsFolder->childrenCount() > 0; bool aHasGroups = myGroupsFolder->childrenCount() > 0; diff --git a/src/PartSet/PartSet_TreeNodes.h b/src/PartSet/PartSet_TreeNodes.h index 599fe6ede..9d034cc0e 100644 --- a/src/PartSet/PartSet_TreeNodes.h +++ b/src/PartSet/PartSet_TreeNodes.h @@ -113,7 +113,8 @@ public: PartsFolder, ResultsFolder, FieldsFolder, - GroupsFolder + GroupsFolder, + VolumesFolder }; PartSet_FolderNode(ModuleBase_ITreeNode* theParent, FolderType theType); @@ -296,6 +297,7 @@ private: PartSet_FolderNode* myResultsFolder; PartSet_FolderNode* myFieldsFolder; PartSet_FolderNode* myGroupsFolder; + PartSet_FolderNode* myVolumesFolder; ObjectPtr myObject; }; diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp index feea6763d..906cd11f7 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp @@ -203,6 +203,7 @@ void PrimitivesPlugin_Box::createBoxByOnePointAndDims() ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex); loadNamingDS(aBoxAlgo, aResultBox); setResult(aResultBox, aResultIndex); + setVolume(aResultBox, aResultIndex); } //================================================================================================= -- 2.39.2