Salome HOME
Relaunch operation on end of previous sketch operation
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 21 Jul 2014 07:15:22 +0000 (11:15 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 21 Jul 2014 07:15:22 +0000 (11:15 +0400)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/XGUI_DocumentDataModel.cpp

index a5c40e7e80dffc669766d3de0bc923b31ed31def..ad4d263244ddf2490650a00f9cd90b54a5b2ef55 100644 (file)
@@ -293,10 +293,15 @@ void PartSet_Module::onFitAllView()
   myWorkshop->viewer()->fitAll();
 }
 
-void PartSet_Module::onLaunchOperation(std::string theName, FeaturePtr theFeature)
+void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theFeature)
 {
+  FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
+  if (!aFeature) {
+    qDebug("Warning! Restart operation without feature!");
+    return;
+  }
   ModuleBase_Operation* anOperation = createOperation(theName.c_str(),
-                                                      theFeature ? theFeature->getKind() : "");
+                                                      theFeature ? aFeature->getKind() : "");
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp)
   {
@@ -304,10 +309,10 @@ void PartSet_Module::onLaunchOperation(std::string theName, FeaturePtr theFeatur
     // Initialise operation with preliminary selection
     std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
     std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
-    aPreviewOp->initFeature(theFeature);
+    aPreviewOp->initFeature(aFeature);
     aPreviewOp->initSelection(aSelected, aHighlighted);
   } else {
-    anOperation->setEditingFeature(theFeature);
+    anOperation->setEditingFeature(aFeature);
   }
   sendOperation(anOperation);
   myWorkshop->actionsMgr()->updateCheckState();
@@ -435,8 +440,8 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
   if (aPreviewOp) {
     connect(aPreviewOp, SIGNAL(featureConstructed(FeaturePtr, int)),
             this, SLOT(onFeatureConstructed(FeaturePtr, int)));
-    connect(aPreviewOp, SIGNAL(launchOperation(std::string, FeaturePtr)),
-            this, SLOT(onLaunchOperation(std::string, FeaturePtr)));
+    connect(aPreviewOp, SIGNAL(launchOperation(std::string, ObjectPtr)),
+            this, SLOT(onLaunchOperation(std::string, ObjectPtr)));
     connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
             this, SLOT(onMultiSelectionEnabled(bool)));
 
index d95a75ebed77a62be1fea5b7629fd646df5827bc..49a41a9ecffd583e736c8a1d420a5c94edbba0db 100644 (file)
@@ -113,7 +113,7 @@ public slots:
   /// SLOT, to fit all current viewer
   void onFitAllView();
 
-  void onLaunchOperation(std::string theName, FeaturePtr theFeature);
+  void onLaunchOperation(std::string theName, ObjectPtr theFeature);
 
   /// SLOT, to switch on/off the multi selection in the viewer
   /// \param theEnabled the enabled state
index 7b4db23661673fcab2ffc55a5631e4f5bdbf3b50..43fe782d1a7e45b5c58d68c381a9e4fcc72b529f 100644 (file)
@@ -72,6 +72,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
         } else { // Update top groups (other except parts
           QModelIndex aIndex = myModel->findParent(aObject);
           int aStart = myModel->rowCount(aIndex) - 1;
+          if (aStart < 0) aStart = 0;
           aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
           insertRow(aStart, aIndex);
         }