Salome HOME
Make sub-group features presented correctly in he tree
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchCreator.cpp
index ba9f9f124ee448081ff3794d84bc114669215bd9..8daeb546d92511fab4e0af759018d5ddc860cb1a 100644 (file)
@@ -99,7 +99,7 @@ bool PartSet_WidgetSketchCreator::restoreValueCustom()
   return true;
 }
 
-bool PartSet_WidgetSketchCreator::storeValueCustom() const
+bool PartSet_WidgetSketchCreator::storeValueCustom()
 {
   return true;
 }
@@ -195,7 +195,8 @@ void PartSet_WidgetSketchCreator::setVisibleSelectionControl(const bool theSelec
 
   if (theSelectionControl) {
     bool aBodyIsVisualized = myPreviewPlanes->hasVisualizedBodies(myWorkshop);
-    if (!aBodyIsVisualized) {
+    bool aSketchIsVisualized = myPreviewPlanes->hasVisualizedSketch(myWorkshop);
+    if (!aBodyIsVisualized && !aSketchIsVisualized) {
       // We have to select a plane before any operation
       myPreviewPlanes->showPreviewPlanes(myWorkshop);
     }
@@ -207,7 +208,7 @@ void PartSet_WidgetSketchCreator::setVisibleSelectionControl(const bool theSelec
   }
 }
 
-QIntList PartSet_WidgetSketchCreator::getShapeTypes() const
+QIntList PartSet_WidgetSketchCreator::shapeTypes() const
 {
   QIntList aShapeTypes;
   foreach(QString aType, myShapeTypes) {
@@ -303,9 +304,17 @@ bool PartSet_WidgetSketchCreator::startSketchOperation(const QList<ModuleBase_Vi
     return aSketchStarted;
 
   ModuleBase_ViewerPrsPtr aValue = theValues.front();
-  if (!PartSet_WidgetSketchLabel::canFillSketch(aValue))
+  if (!aValue.get() || !PartSet_WidgetSketchLabel::canFillSketch(aValue))
     return aSketchStarted;
 
+  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aValue->object());
+  /// sketch should not started by object(face) selected as global. If Local face is selected,
+  /// sketch is started
+  if (aResult.get() && aValue->shape().get() && aResult->shape()->isEqual(aValue->shape())) {
+    ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aResult);
+    if (!aConstruction.get() || !aConstruction->isInfinite())
+      return aSketchStarted;
+  }
   aSketchStarted = true;
 
   // manually deactivation because the widget was not activated as has no focus acceptin controls
@@ -395,7 +404,7 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp)
       anObjects.append(aSketchFeature);
 
       XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
-      aWorkshop->deleteFeatures(anObjects, std::set<FeaturePtr>());
+      aWorkshop->deleteFeatures(anObjects);
 
       aMgr->finishOperation();
 #endif
@@ -414,11 +423,18 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp)
 
     // Update value in attribute selection list
     XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
-    XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
-    const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
+    XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
+    const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
+    ModuleBase_ModelWidget* aListWidget = 0;
     foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
-      if (aWidget->attributeID() == myAttributeListID)
-        aWidget->restoreValue();
+      if (aWidget->attributeID() == myAttributeListID) {
+        aListWidget = aWidget;
+        break;
+      }
+    }
+    if (aListWidget) {
+      aListWidget->restoreValue();
+      aPropertyPanel->activateNextWidget(aListWidget);
     }
 
     // Hide sketcher result