From: vsv Date: Thu, 11 Jun 2015 14:22:43 +0000 (+0300) Subject: Provide abort of ExtrusionCut X-Git-Tag: V_1.3.0~249 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c3b31ae009442b80a19e96b2edfda91c21f01ceb;p=modules%2Fshaper.git Provide abort of ExtrusionCut --- diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index 66c3debd7..987b17491 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -154,4 +154,9 @@ bool ModuleBase_IModule::canActivateSelection(const ObjectPtr& theObject) const { ModuleBase_Operation* aOperation = myWorkshop->currentOperation(); return !aOperation || !aOperation->hasObject(theObject); -} \ No newline at end of file +} + +void ModuleBase_IModule::onOperationResumed(ModuleBase_Operation* theOperation) +{ + emit operationResumed(theOperation); +} diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 435d2c5b9..1d10eeb13 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -56,20 +56,21 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// Realizes some functionality by an operation start /// \param theOperation a started operation - virtual void operationStarted(ModuleBase_Operation* theOperation) {} + virtual void onOperationStarted(ModuleBase_Operation* theOperation) {} /// Realizes some functionality by an operation resume + /// By default it emits operationResumed signal /// \param theOperation a resumed operation - virtual void operationResumed(ModuleBase_Operation* theOperation) {} + virtual void onOperationResumed(ModuleBase_Operation* theOperation); /// Realizes some functionality by an operation stop - virtual void operationStopped(ModuleBase_Operation* theOperation) {} + virtual void onOperationStopped(ModuleBase_Operation* theOperation) {} /// Realizes some functionality by an operation commit - virtual void operationCommitted(ModuleBase_Operation* theOperation) {} + virtual void onOperationCommitted(ModuleBase_Operation* theOperation) {} /// Realizes some functionality by an operation abort - virtual void operationAborted(ModuleBase_Operation* theOperation) {} + virtual void onOperationAborted(ModuleBase_Operation* theOperation) {} /// Realizes some functionality by an operation start /// \param theOperation a started operation @@ -148,6 +149,8 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject signals: void operationLaunched(); + void operationResumed(ModuleBase_Operation* theOp); + public slots: /// Called on call of command corresponded to a feature virtual void onFeatureTriggered(); diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index ba23b886e..7722b9ee7 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -198,7 +198,6 @@ void ModuleBase_Operation::abort() myCurrentFeature = FeaturePtr(); } abortOperation(); - emit aborted(); stopOperation(); // is is necessary to deactivate current widgets before the model operation is aborted @@ -213,6 +212,8 @@ void ModuleBase_Operation::abort() new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED))); Events_Loop::loop()->send(aMsg); + + emit aborted(); } bool ModuleBase_Operation::commit() @@ -362,29 +363,6 @@ void ModuleBase_Operation::initSelection(ModuleBase_ISelection* theSelection, myPreSelection = aPreSelected; } -//void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget) -//{ -// //activateByPreselection(); -// //if (theWidget && myPropertyPanel) { -// // myPropertyPanel->activateNextWidget(); -// //// //emit activateNextWidget(myActiveWidget); -// //} -//} - -//bool ModuleBase_Operation::setWidgetValue(ObjectPtr theFeature, double theX, double theY) -//{ -// ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget(); -// if (!aActiveWgt) -// return false; -// ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature(); -// aValue->setObject(theFeature); -// aValue->setPoint(std::shared_ptr(new GeomAPI_Pnt2d(theX, theY))); -// bool isApplyed = aActiveWgt->setValue(aValue); -// -// delete aValue; -// myIsModified = (myIsModified || isApplyed); -// return isApplyed; -//} bool ModuleBase_Operation::getViewerPoint(ModuleBase_ViewerPrs thePrs, ModuleBase_IViewer* theViewer, diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index b6d90bd0c..a1908ff43 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -185,7 +185,7 @@ void PartSet_Module::registerProperties() Config_Prop::Integer, SKETCH_WIDTH); } -void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation) +void PartSet_Module::onOperationCommitted(ModuleBase_Operation* theOperation) { if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation)) { mySketchMgr->commitNestedSketch(theOperation); @@ -221,7 +221,7 @@ void PartSet_Module::breakOperationSequence() myRestartingMode = RM_None; } -void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation) +void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation) { breakOperationSequence(); } @@ -236,7 +236,7 @@ void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation) ModuleBase_IModule::sendOperation(theOperation); } -void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation) +void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation) { if (PartSet_SketcherMgr::isSketchOperation(theOperation)) { Handle(V3d_Viewer) aViewer = myWorkshop->viewer()->AISContext()->CurrentViewer(); @@ -248,7 +248,7 @@ void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation) } } -void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation) +void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation) { if (PartSet_SketcherMgr::isSketchOperation(theOperation)) { mySketchMgr->stopSketch(theOperation); @@ -834,4 +834,4 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex) aPart->activate(); } } -} \ No newline at end of file +} diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index aa57ecd8a..d711f072e 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -67,22 +67,22 @@ public: /// Realizes some functionality by an operation start /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters /// \param theOperation a started operation - virtual void operationStarted(ModuleBase_Operation* theOperation); + virtual void onOperationStarted(ModuleBase_Operation* theOperation); /// Realizes some functionality by an operation commit /// Restarts sketcher operation automatically of it is necessary /// \param theOperation a committed operation - virtual void operationCommitted(ModuleBase_Operation* theOperation); + virtual void onOperationCommitted(ModuleBase_Operation* theOperation); /// Realizes some functionality by an operation abort /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters /// \param theOperation an aborted operation - virtual void operationAborted(ModuleBase_Operation* theOperation); + virtual void onOperationAborted(ModuleBase_Operation* theOperation); /// Realizes some functionality by an operation stop /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters /// \param theOperation a stopped operation - virtual void operationStopped(ModuleBase_Operation* theOperation); + virtual void onOperationStopped(ModuleBase_Operation* theOperation); /// Returns current operation virtual ModuleBase_Operation* currentOperation() const; diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index a2d51b7cc..c0a43dbfd 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -115,6 +116,7 @@ void PartSet_WidgetSketchCreator::onStarted() ModuleBase_Operation* anOperation = myModule->createOperation("Sketch"); anOperation->setFeature(aSketch); myModule->sendOperation(anOperation); + //connect(anOperation, SIGNAL(aborted()), aWorkshop->operationMgr(), SLOT(abortAllOperations())); } else { // Break current operation QMessageBox::warning(this, tr("Extrusion Cut"), @@ -131,6 +133,11 @@ bool PartSet_WidgetSketchCreator::focusTo() if (aCompFeature->numberOfSubs() == 0) return ModuleBase_ModelWidget::focusTo(); + CompositeFeaturePtr aSketchFeature = + std::dynamic_pointer_cast(aCompFeature->subFeature(0)); + if (aSketchFeature->numberOfSubs() == 0) { + connect(myModule, SIGNAL(operationResumed(ModuleBase_Operation*)), SLOT(onResumed(ModuleBase_Operation*))); + } SessionPtr aMgr = ModelAPI_Session::get(); bool aIsOp = aMgr->isOperation(); // Open transaction if it was closed before @@ -139,4 +146,15 @@ bool PartSet_WidgetSketchCreator::focusTo() restoreValue(); return false; -} \ No newline at end of file +} + +void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp) +{ + // Abort operation + SessionPtr aMgr = ModelAPI_Session::get(); + bool aIsOp = aMgr->isOperation(); + // Close transaction + if (aIsOp) + aMgr->abortOperation(); + theOp->abort(); +} diff --git a/src/PartSet/PartSet_WidgetSketchCreator.h b/src/PartSet/PartSet_WidgetSketchCreator.h index 80e45b496..d90e4d7ce 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.h +++ b/src/PartSet/PartSet_WidgetSketchCreator.h @@ -51,6 +51,8 @@ protected: private slots: void onStarted(); + void onResumed(ModuleBase_Operation* theOp); + private: PartSet_Module* myModule; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 94ff9d955..828a42655 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -546,7 +546,7 @@ void XGUI_Workshop::onOperationStarted(ModuleBase_Operation* theOperation) } updateCommandStatus(); - myModule->operationStarted(theOperation); + myModule->onOperationStarted(theOperation); // the objects of the current operation should be deactivated QObjectPtrList anObjects; @@ -575,7 +575,7 @@ void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation) } updateCommandStatus(); - myModule->operationResumed(theOperation); + myModule->onOperationResumed(theOperation); } @@ -589,7 +589,7 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation) hidePropertyPanel(); myPropertyPanel->cleanContent(); - myModule->operationStopped(theOperation); + myModule->onOperationStopped(theOperation); // the deactivated objects of the current operation should be activated back. // They were deactivated on operation start or an object redisplay @@ -613,12 +613,12 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation) void XGUI_Workshop::onOperationCommitted(ModuleBase_Operation* theOperation) { - myModule->operationCommitted(theOperation); + myModule->onOperationCommitted(theOperation); } void XGUI_Workshop::onOperationAborted(ModuleBase_Operation* theOperation) { - myModule->operationAborted(theOperation); + myModule->onOperationAborted(theOperation); } void XGUI_Workshop::setNestedFeatures(ModuleBase_Operation* theOperation)