]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/PartSet/PartSet_WidgetSketchLabel.cpp
Salome HOME
Issue #2923: Change sketch plane
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchLabel.cpp
index 7f4fcd8ae40db8fe0092621b4d602aeb30a95a3a..f8e8d39245c5747559aedd97d7981abad1187d92 100644 (file)
@@ -41,6 +41,7 @@
 #include <ModuleBase_ViewerPrs.h>
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_IModule.h>
+#include <ModuleBase_IPropertyPanel.h>
 
 #include <GeomAlgoAPI_FaceBuilder.h>
 #include <GeomAlgoAPI_ShapeTools.h>
@@ -84,7 +85,7 @@ 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)
+: ModuleBase_WidgetValidated(theParent, theWorkshop, theData), myOpenTransaction(false)
 {
   QVBoxLayout* aLayout = new QVBoxLayout(this);
   ModuleBase_Tools::zeroMargins(aLayout);
@@ -160,6 +161,11 @@ PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
       aShowConstraints->setChecked(toShowConstraints[aState]);
   }
 
+
+  QPushButton* aPlaneBtn = new QPushButton(tr("Change sketch plane"), aSecondWgt);
+  connect(aPlaneBtn, SIGNAL(clicked(bool)), SLOT(onChangePlane()));
+  aLayout->addWidget(aPlaneBtn);
+
   myStackWidget->addWidget(aSecondWgt);
   //setLayout(aLayout);
 
@@ -331,6 +337,11 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
   if (aModule)
     aModule->onViewTransformed();
 
+  if (myOpenTransaction) {
+    SessionPtr aMgr = ModelAPI_Session::get();
+    aMgr->finishOperation();
+    myOpenTransaction = false;
+  }
   // 3. Clear text in the label
   myStackWidget->setCurrentIndex(1);
   //myLabel->setText("");
@@ -643,3 +654,30 @@ QList<std::shared_ptr<ModuleBase_ViewerPrs>> PartSet_WidgetSketchLabel::findCirc
   }
   return aResult;
 }
+
+//******************************************************
+void PartSet_WidgetSketchLabel::onChangePlane()
+{
+  PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+  if (aModule) {
+    mySizeOfViewWidget->setVisible(false);
+    myStackWidget->setCurrentIndex(0);
+
+    CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+    PartSet_Tools::nullifySketchPlane(aSketch);
+
+    Handle(SelectMgr_Filter) aFilter = aModule->selectionFilter(SF_SketchPlaneFilter);
+    if (!aFilter.IsNull()) {
+      std::shared_ptr<GeomAPI_Pln> aPln;
+      Handle(ModuleBase_ShapeInPlaneFilter)::DownCast(aFilter)->setPlane(aPln);
+    }
+    XGUI_Workshop* aWorkshop = aModule->getWorkshop();
+
+    aWorkshop->selectionActivate()->updateSelectionFilters();
+    aWorkshop->selectionActivate()->updateSelectionModes();
+
+    SessionPtr aMgr = ModelAPI_Session::get();
+    aMgr->startOperation();
+    myOpenTransaction = true;
+  }
+}
\ No newline at end of file