Salome HOME
Issue #1351: partition is not done
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchCreator.cpp
index 34762063035f07a42ddf357d035d7845ab6a4564..308dd965f0f544f8e1d579071a0bb958266e6715 100644 (file)
@@ -22,6 +22,7 @@
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Events.h>
 
 #include <SketchPlugin_SketchEntity.h>
 #include <FeaturesPlugin_CompositeBoolean.h>
@@ -32,6 +33,8 @@
 #include <ModuleBase_OperationFeature.h>
 #include <Config_WidgetAPI.h>
 
+#include <Events_Loop.h>
+
 #include <QLabel>
 #include <QLineEdit>
 #include <QFormLayout>
@@ -59,6 +62,8 @@ PartSet_WidgetSketchCreator::PartSet_WidgetSketchCreator(QWidget* theParent,
   myTextLine->setToolTip(aToolTip);
   myTextLine->installEventFilter(this);
 
+  myLabel->setToolTip(aToolTip);
+
   QString aUseBody = QString::fromStdString(theData->getProperty(USE_BODY));
   if(!aUseBody.isEmpty()) {
     myUseBody = QVariant(aUseBody).toBool();
@@ -127,8 +132,17 @@ void PartSet_WidgetSketchCreator::onStarted()
     // Launch Sketch operation
     CompositeFeaturePtr aCompFeature = 
       std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+
+    /// add sketch feature without current feature change.
+    /// it is important to do not change the current feature in order to
+    /// after sketch edition, the extrusion cut feature becomes current
+    SessionPtr aMgr = ModelAPI_Session::get();
+    DocumentPtr aDoc = aMgr->activeDocument();
+    FeaturePtr aPreviousCurrentFeature = aDoc->currentFeature(false);
     FeaturePtr aSketch = aCompFeature->addFeature("Sketch");
+    aDoc->setCurrentFeature(aPreviousCurrentFeature, false);
 
+    // start edit operation for the sketch
     ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                              (myModule->createOperation("Sketch"));
     if (aFOperation)
@@ -153,7 +167,7 @@ bool PartSet_WidgetSketchCreator::focusTo()
   if (aCompFeature->numberOfSubs() == 0)
     return ModuleBase_ModelWidget::focusTo(); 
 
-  connect(myModule, SIGNAL(operationResumed(ModuleBase_Operation*)), SLOT(onResumed(ModuleBase_Operation*)));
+  connect(myModule, SIGNAL(resumed(ModuleBase_Operation*)), SLOT(onResumed(ModuleBase_Operation*)));
   SessionPtr aMgr = ModelAPI_Session::get();
   // Open transaction that is general for the previous nested one: it will be closed on nested commit
   bool aIsOp = aMgr->isOperation();
@@ -217,5 +231,12 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp)
         }
       }
     }
+    else {
+      // this is a workarount to display the feature results in the operation selection mode
+      // if this is absent, sketch point/line local selection is available on extrusion cut result
+      static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+      ModelAPI_EventCreator::get()->sendUpdated(feature(), anUpdateEvent);
+      updateObject(feature());
+    }
   }
 }