Salome HOME
Task 2.5. Combination operations on Groups (issue #2935)
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchLabel.cpp
index a32267f1a6d72bc230712f4b407776d920e6a0a5..231c512fa895b2770608c9b24c5c84b1e9240fd0 100644 (file)
@@ -85,7 +85,8 @@ PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
                         ModuleBase_IWorkshop* theWorkshop,
                         const Config_WidgetAPI* theData,
                         const QMap<PartSet_Tools::ConstraintVisibleState, bool>& toShowConstraints)
-: ModuleBase_WidgetValidated(theParent, theWorkshop, theData), myOpenTransaction(false)
+: ModuleBase_WidgetValidated(theParent, theWorkshop, theData), myOpenTransaction(false),
+myIsSelection(false)
 {
   QVBoxLayout* aLayout = new QVBoxLayout(this);
   ModuleBase_Tools::zeroMargins(aLayout);
@@ -166,7 +167,9 @@ PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
     if (toShowConstraints.contains(aState))
       aShowConstraints->setChecked(toShowConstraints[aState]);
   }
-
+  myShowPoints = new QCheckBox(tr("Show free points"), this);
+  connect(myShowPoints, SIGNAL(toggled(bool)), this, SIGNAL(showFreePoints(bool)));
+  aLayout->addWidget(myShowPoints);
 
   QPushButton* aPlaneBtn = new QPushButton(tr("Change sketch plane"), aSecondWgt);
   connect(aPlaneBtn, SIGNAL(clicked(bool)), SLOT(onChangePlane()));
@@ -281,8 +284,11 @@ bool PartSet_WidgetSketchLabel::setSelectionInternal(
   else {
     // it removes the processed value from the parameters list
     ModuleBase_ViewerPrsPtr aValue = theValues.first();//.takeFirst();
-    if (!theToValidate || isValidInFilters(aValue))
+    if (!theToValidate || isValidInFilters(aValue)) {
+      myIsSelection = true;
       aDone = setSelectionCustom(aValue);
+      myIsSelection = false;
+    }
   }
 
   return aDone;
@@ -308,11 +314,8 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
         isSetSizeOfView = false;
       }
     }
-    if (isSetSizeOfView)
-      aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, true);
+    aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, isSetSizeOfView);
     aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
-    if (isSetSizeOfView)
-      aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, false);
   }
   // 2. if the planes were displayed, change the view projection
 
@@ -340,9 +343,6 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
       }
     }
   }
-  if (aModule)
-    aModule->onViewTransformed();
-
   if (myOpenTransaction) {
     SessionPtr aMgr = ModelAPI_Session::get();
     aMgr->finishOperation();
@@ -362,6 +362,9 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
   myWorkshop->selectionActivate()->updateSelectionFilters();
   myWorkshop->selectionActivate()->updateSelectionModes();
 
+  if (aModule)
+    aModule->onViewTransformed();
+
   // 6. Update sketcher actions
   XGUI_ActionsMgr* anActMgr = aWorkshop->actionsMgr();
 
@@ -412,7 +415,7 @@ void PartSet_WidgetSketchLabel::restoreAttributeValue(const AttributePtr& theAtt
 
 bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
 {
-  if (myRemoveExternal->isVisible()) {
+  if (myIsSelection && myRemoveExternal->isVisible()) {
     if (myRemoveExternal->isChecked()) {
       myFeature->customAction(SketchPlugin_Sketch::ACTION_REMOVE_EXTERNAL());
     }
@@ -691,7 +694,14 @@ void PartSet_WidgetSketchLabel::onChangePlane()
     aWorkshop->selectionActivate()->updateSelectionModes();
 
     SessionPtr aMgr = ModelAPI_Session::get();
-    aMgr->startOperation();
+    aMgr->startOperation("Change Sketch plane");
     myOpenTransaction = true;
   }
-}
\ No newline at end of file
+}
+
+void PartSet_WidgetSketchLabel::setShowPointsState(bool theState)
+{
+  bool aBlock = myShowPoints->blockSignals(true);
+  myShowPoints->setChecked(theState);
+  myShowPoints->blockSignals(aBlock);
+}