From: vsv Date: Mon, 1 Sep 2014 13:52:34 +0000 (+0400) Subject: Issue #101: Fixed editing of nested features X-Git-Tag: V_0.4.4~92^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dbe90044b0b96aa64dfe6609083413da2bdf08ec;p=modules%2Fshaper.git Issue #101: Fixed editing of nested features --- diff --git a/src/Config/Config_FeatureMessage.h b/src/Config/Config_FeatureMessage.h index 4c32b0b86..be79646a9 100644 --- a/src/Config/Config_FeatureMessage.h +++ b/src/Config/Config_FeatureMessage.h @@ -48,4 +48,4 @@ class Config_FeatureMessage : public Events_Message bool isInternal); }; -#endif // CONFIG_MESSAGE_H \ No newline at end of file +#endif // CONFIG_MESSAGE_H diff --git a/src/ModuleBase/ModuleBase_IOperation.cpp b/src/ModuleBase/ModuleBase_IOperation.cpp index f8aacb9c1..e873562e5 100644 --- a/src/ModuleBase/ModuleBase_IOperation.cpp +++ b/src/ModuleBase/ModuleBase_IOperation.cpp @@ -39,11 +39,6 @@ bool ModuleBase_IOperation::canBeCommitted() const return true; } -bool ModuleBase_IOperation::isGranted(ModuleBase_IOperation* /*theOperation*/) const -{ - return false; -} - /*void ModuleBase_IOperation::setModelWidgets(const std::string& theXmlRepresentation, QList theWidgets) { diff --git a/src/ModuleBase/ModuleBase_IOperation.h b/src/ModuleBase/ModuleBase_IOperation.h index 8d738763e..28822efa5 100644 --- a/src/ModuleBase/ModuleBase_IOperation.h +++ b/src/ModuleBase/ModuleBase_IOperation.h @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -56,14 +57,20 @@ Q_OBJECT /// /returns the instance of the description class ModuleBase_OperationDescription* getDescription() const; - /// Verifies whether this operator can be always started above any already running one - /// \return Returns TRUE if current operation must not be checked for ActiveOperation->IsValid( this ) - /// This method must be redefined in derived operation if operation of derived class - /// must be always can start above any launched one. Default impl returns FALSE, - /// so it is being checked for IsValid, but some operations may overload IsGranted() - /// In this case they will always start, no matter what operation is running. - /// \param theOperation the previous running operation - virtual bool isGranted(ModuleBase_IOperation* theOperation) const; + /** + * Must return true if this operation can be launched as nested for any current operation + * and it is not necessary to check this operation on validity. By default + * the operation is not granted. + * The method has to be redefined for granted operations. + */ + virtual bool isGranted() const { return false; } + + /** + * Must return True if the given opertation can be launched as nested to current one. + * By default it returns false and it has to be redefined for operations which expect + * launching of nested operations + */ + virtual bool isValid(ModuleBase_IOperation* theOperation) const { return false; } /// Sets a list of model widgets, according to the operation feature xml definition /// \param theXmlRepresentation an xml feature definition @@ -83,6 +90,12 @@ Q_OBJECT return myIsEditing; } + /// Returns list of nested features + QStringList nestedFeatures() const { return myNestedFeatures; } + + /// Sets list of nested features + void setNestedFeatures(const QStringList& theList) { myNestedFeatures = theList; } + signals: void started(); /// the operation is started void aborted(); /// the operation is aborted @@ -157,6 +170,8 @@ signals: private: ModuleBase_OperationDescription* myDescription; /// the container to have the operation description + + QStringList myNestedFeatures; }; #endif diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index a67347689..6a405901a 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -73,12 +73,6 @@ bool PartSet_OperationFeatureCreate::canBeCommitted() const return false; } -bool PartSet_OperationFeatureCreate::isGranted(ModuleBase_IOperation* theOperation) const -{ - return theOperation->getDescription()->operationId().toStdString() - == PartSet_OperationSketch::Type(); -} - std::list PartSet_OperationFeatureCreate::getSelectionModes(ObjectPtr theFeature) const { std::list aModes; diff --git a/src/PartSet/PartSet_OperationFeatureCreate.h b/src/PartSet/PartSet_OperationFeatureCreate.h index cedf301a7..a6e3aa877 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.h +++ b/src/PartSet/PartSet_OperationFeatureCreate.h @@ -39,11 +39,6 @@ Q_OBJECT /// Destructor virtual ~PartSet_OperationFeatureCreate(); - /// Returns that this operator can be started above already running one. - /// The runned operation should be the sketch feature modified operation - /// \param theOperation the previous running operation - virtual bool isGranted(ModuleBase_IOperation* theOperation) const; - /// Returns the operation local selection mode /// \param theFeature the feature object to get the selection mode /// \return the selection mode diff --git a/src/PartSet/PartSet_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp index b17524725..4d3edb9e9 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.cpp +++ b/src/PartSet/PartSet_OperationFeatureEdit.cpp @@ -49,12 +49,6 @@ PartSet_OperationFeatureEdit::~PartSet_OperationFeatureEdit() { } -bool PartSet_OperationFeatureEdit::isGranted(ModuleBase_IOperation* theOperation) const -{ - return theOperation->getDescription()->operationId().toStdString() - == PartSet_OperationSketch::Type(); -} - std::list PartSet_OperationFeatureEdit::getSelectionModes(ObjectPtr theFeature) const { return PartSet_OperationSketchBase::getSelectionModes(theFeature); diff --git a/src/PartSet/PartSet_OperationFeatureEdit.h b/src/PartSet/PartSet_OperationFeatureEdit.h index eadd73f10..3d73b3bd3 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.h +++ b/src/PartSet/PartSet_OperationFeatureEdit.h @@ -69,11 +69,6 @@ Q_OBJECT /// Destructor virtual ~PartSet_OperationFeatureEdit(); - /// Returns that this operator can be started above already running one. - /// The runned operation should be the sketch feature modified operation - /// \param theOperation the previous running operation - virtual bool isGranted(ModuleBase_IOperation* theOperation) const; - /// Returns the operation local selection mode /// \param theFeature the feature object to get the selection mode /// \return the selection mode diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp index 0c4a71697..cd0de8925 100644 --- a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp +++ b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp @@ -45,11 +45,6 @@ PartSet_OperationFeatureEditMulti::~PartSet_OperationFeatureEditMulti() { } -bool PartSet_OperationFeatureEditMulti::isGranted(ModuleBase_IOperation* theOperation) const -{ - return theOperation->getDescription()->operationId().toStdString() - == PartSet_OperationSketch::Type(); -} void PartSet_OperationFeatureEditMulti::initSelection( const std::list& theSelected, diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.h b/src/PartSet/PartSet_OperationFeatureEditMulti.h index f49d0480b..0f21f34ab 100644 --- a/src/PartSet/PartSet_OperationFeatureEditMulti.h +++ b/src/PartSet/PartSet_OperationFeatureEditMulti.h @@ -70,11 +70,6 @@ Q_OBJECT /// Destructor virtual ~PartSet_OperationFeatureEditMulti(); - /// Returns that this operator can be started above already running one. - /// The runned operation should be the sketch feature modified operation - /// \param theOperation the previous running operation - virtual bool isGranted(ModuleBase_IOperation* theOperation) const; - /// Initializes the operation with previously created feature. It is used in sequental operations virtual void initFeature(FeaturePtr theFeature); diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 4ff87cae1..ece230157 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -113,9 +113,16 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi /// It is empty and we have to use the process mouse release to start edition operation /// for these objects if (theSelected.size() == 1) { - ObjectPtr aFeature = theSelected.front().object(); - if (aFeature) - restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature); + ObjectPtr aObject = theSelected.front().object(); + if (aObject) { + FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); + if (aFeature) { + QStringList aNested = this->nestedFeatures(); + if ((!aNested.isEmpty()) && aNested.contains(QString(aFeature->getKind().c_str()))) { + restartOperation(PartSet_OperationFeatureEdit::Type(), aObject); + } + } + } } } } @@ -250,3 +257,10 @@ void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape) emit closeLocalContext(); emit planeSelected(aDir->x(), aDir->y(), aDir->z()); } + + +bool PartSet_OperationSketch::isValid(ModuleBase_IOperation* theOperation) const +{ + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(theOperation); + return aPreviewOp != NULL; +} \ No newline at end of file diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index 04604ef0c..cc1151877 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -37,6 +37,10 @@ Q_OBJECT /// Destructor virtual ~PartSet_OperationSketch(); + /// Returns True if the given operation is a Sketcher operation + virtual bool isValid(ModuleBase_IOperation* theOperation) const; + + /// Returns the operation local selection mode /// \param theFeature the feature object to get the selection mode /// \return the selection mode diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 57befeb24..7d397b196 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -170,7 +170,16 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, const std::list if (!aContext->HasOpenedContext()) { aContext->ClearCurrents(false); aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/); + //aContext->OpenLocalContext(); + //aContext->NotUseDisplayedObjects(); } + //!!! Test + //aContext->UseDisplayedObjects(); + //std::list::const_iterator anIt = theModes.begin(), aLast = theModes.end(); + //for (; anIt != aLast; anIt++) { + // aContext->ActivateStandardMode((TopAbs_ShapeEnum)(*anIt)); + //} + //!!! Test end // display or redisplay presentation Handle(AIS_InteractiveObject) anAIS; if (isVisible(theResult)) { diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 4a93b9d47..e6855819a 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -133,11 +133,15 @@ bool XGUI_OperationMgr::canStartOperation(ModuleBase_Operation* theOperation) { bool aCanStart = true; ModuleBase_Operation* aCurrentOp = currentOperation(); - if (aCurrentOp && !theOperation->isGranted(aCurrentOp)) { - if (canStopOperation()) { - aCurrentOp->abort(); - } else { - aCanStart = false; + if (aCurrentOp) { + if (!theOperation->isGranted()) { + if (!aCurrentOp->isValid(theOperation)) { + if (canStopOperation()) { + aCurrentOp->abort(); + } else { + aCanStart = false; + } + } } } return aCanStart; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index ad35f6f81..d91f4d98e 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -395,6 +395,7 @@ void XGUI_Workshop::onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theM void XGUI_Workshop::onOperationStarted() { ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); + aOperation->setNestedFeatures(myActionsMgr->nestedCommands(aOperation->id())); if (aOperation->getDescription()->hasXmlRepresentation()) { //!< No need for property panel connectWithOperation(aOperation);