Salome HOME
Provide abort of ExtrusionCut
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 11 Jun 2015 14:22:43 +0000 (17:22 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 11 Jun 2015 14:22:55 +0000 (17:22 +0300)
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_Operation.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_WidgetSketchCreator.cpp
src/PartSet/PartSet_WidgetSketchCreator.h
src/XGUI/XGUI_Workshop.cpp

index 66c3debd7c0695a4ecb4dcd2bcd3e24bc23b161d..987b17491ccee0cc076369008d3c567fc2c85368 100644 (file)
@@ -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);
+}
index 435d2c5b96939098c016fa8244b6bd89f4d9facb..1d10eeb1328242463f3579894b2c0c2cee55da41 100644 (file)
@@ -56,20 +56,21 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
 \r
   /// Realizes some functionality by an operation start\r
   /// \param theOperation a started operation\r
-  virtual void operationStarted(ModuleBase_Operation* theOperation) {}\r
+  virtual void onOperationStarted(ModuleBase_Operation* theOperation) {}\r
 \r
   /// Realizes some functionality by an operation resume\r
+  /// By default it emits operationResumed signal\r
   /// \param theOperation a resumed operation\r
-  virtual void operationResumed(ModuleBase_Operation* theOperation) {}\r
+  virtual void onOperationResumed(ModuleBase_Operation* theOperation);\r
 \r
   /// Realizes some functionality by an operation stop\r
-  virtual void operationStopped(ModuleBase_Operation* theOperation) {}\r
+  virtual void onOperationStopped(ModuleBase_Operation* theOperation) {}\r
 \r
   /// Realizes some functionality by an operation commit\r
-  virtual void operationCommitted(ModuleBase_Operation* theOperation) {}\r
+  virtual void onOperationCommitted(ModuleBase_Operation* theOperation) {}\r
 \r
   /// Realizes some functionality by an operation abort\r
-  virtual void operationAborted(ModuleBase_Operation* theOperation) {}\r
+  virtual void onOperationAborted(ModuleBase_Operation* theOperation) {}\r
 \r
   /// Realizes some functionality by an operation start\r
   /// \param theOperation a started operation\r
@@ -148,6 +149,8 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
 signals:\r
   void operationLaunched();\r
 \r
+  void operationResumed(ModuleBase_Operation* theOp);\r
+\r
 public slots:\r
   /// Called on call of command corresponded to a feature\r
   virtual void onFeatureTriggered();\r
index ba23b886ec12351780db210025bd967cd9b4c55e..7722b9ee72b6fc8f63cf0cc4bf1729de76cd4473 100644 (file)
@@ -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<GeomAPI_Pnt2d>(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,
index b6d90bd0c39f73f7552ca1a870370ee01dc9777b..a1908ff43b7395a8ade484b6377f20e88ad635cd 100644 (file)
@@ -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
+}
index aa57ecd8aee8b11a6d2a9ac52fd8734312ea60dc..d711f072e7ebc27372e2fb669f328998bfb7bf85 100644 (file)
@@ -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;
index a2d51b7ccf6b4a75c9ad067f2f4ebe13a9430580..c0a43dbfd229cad6e57ad6a93137e556227e891a 100644 (file)
@@ -11,6 +11,7 @@
 #include <XGUI_Workshop.h>
 #include <XGUI_Displayer.h>
 #include <XGUI_SelectionMgr.h>
+#include <XGUI_OperationMgr.h>
 
 #include <GeomAPI_Face.h>
 
@@ -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<ModelAPI_CompositeFeature>(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();
+}
index 80e45b496ffe85d3b688c6d7acff984c4de3ba4c..d90e4d7ce515aba1fdc3fb13a89f981d648b92b3 100644 (file)
@@ -51,6 +51,8 @@ protected:
 private slots:
   void onStarted();
 
+  void onResumed(ModuleBase_Operation* theOp);
+
 private:
 
   PartSet_Module* myModule;
index 94ff9d955d9a8502c12ebda6283eaebb87df6a51..828a4265505b365e13725ba224ab4ad90c943e4c 100644 (file)
@@ -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)