Salome HOME
Issue #3182: Show/Hide sketcher plane
authorvsv <vsv@opencascade.com>
Mon, 13 Apr 2020 10:30:39 +0000 (13:30 +0300)
committervsv <vsv@opencascade.com>
Mon, 13 Apr 2020 10:30:39 +0000 (13:30 +0300)
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h

index ac02f684cd3cb96f67a2332a9c48cc274e8a2964..9df9fad5ade0b3fbe87819f67bc6c683c6f8c25f 100644 (file)
@@ -158,15 +158,20 @@ myIsSelection(false)
   ModuleBase_Tools::zeroMargins(aLayout);
 
   QGroupBox* aViewBox = new QGroupBox(tr("Sketcher plane"), this);
-  QVBoxLayout* aViewLayout = new QVBoxLayout(aViewBox);
+  QGridLayout* aViewLayout = new QGridLayout(aViewBox);
 
   myViewInverted = new QCheckBox(tr("Reversed"), aViewBox);
-  aViewLayout->addWidget(myViewInverted);
+  aViewLayout->addWidget(myViewInverted, 0, 0);
+
+  myViewVisible = new QCheckBox(tr("Visible"), aViewBox);
+  myViewVisible->setChecked(true);
+  aViewLayout->addWidget(myViewVisible, 0, 1, Qt::AlignRight);
+  connect(myViewVisible, SIGNAL(toggled(bool)), this, SLOT(onShowViewPlane(bool)));
 
   QPushButton* aSetViewBtn =
     new QPushButton(QIcon(":icons/plane_view.png"), tr("Set plane view"), aViewBox);
   connect(aSetViewBtn, SIGNAL(clicked(bool)), this, SLOT(onSetPlaneView()));
-  aViewLayout->addWidget(aSetViewBtn);
+  aViewLayout->addWidget(aSetViewBtn, 1, 0, 1, 2);
 
   aLayout->addWidget(aViewBox);
 
@@ -313,7 +318,7 @@ bool PartSet_WidgetSketchLabel::setSelectionInternal(
   bool aDone = false;
   if (theValues.empty()) {
     // In order to make reselection possible, set empty object and shape should be done
-    setSelectionCustom(std::shared_ptr<ModuleBase_ViewerPrs>(
+    setSelectionCustom(ModuleBase_ViewerPrsPtr(
                               new ModuleBase_ViewerPrs(ObjectPtr(), GeomShapePtr(), NULL)));
     aDone = false;
   }
@@ -359,7 +364,8 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
       }
     }
     aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, isSetSizeOfView);
-    aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
+    if (myViewVisible->isChecked())
+      aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
   }
   // 2. if the planes were displayed, change the view projection
 
@@ -742,7 +748,7 @@ void PartSet_WidgetSketchLabel::onSetPlaneView()
 
 
 //******************************************************
-QList<std::shared_ptr<ModuleBase_ViewerPrs>> PartSet_WidgetSketchLabel::findCircularEdgesInPlane()
+QList<ModuleBase_ViewerPrsPtr> PartSet_WidgetSketchLabel::findCircularEdgesInPlane()
 {
   QList<std::shared_ptr<ModuleBase_ViewerPrs>> aResult;
   XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
@@ -764,7 +770,7 @@ QList<std::shared_ptr<ModuleBase_ViewerPrs>> PartSet_WidgetSketchLabel::findCirc
             bool isContains = false;
             // Check that edge is not used.
             // It is possible that the same edge will be taken from different faces
-            foreach(std::shared_ptr<ModuleBase_ViewerPrs> aPrs, aResult) {
+            foreach(ModuleBase_ViewerPrsPtr aPrs, aResult) {
               GeomAPI_Edge aUsedEdge(aPrs->shape());
               if (aUsedEdge.isEqual(aEdgeShape)) {
                 isContains = true;
@@ -772,8 +778,7 @@ QList<std::shared_ptr<ModuleBase_ViewerPrs>> PartSet_WidgetSketchLabel::findCirc
               }
             }
             if (!isContains) {
-              std::shared_ptr<ModuleBase_ViewerPrs>
-                aPrs(new ModuleBase_ViewerPrs(aResObj, aEdgeShape));
+              ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs(aResObj, aEdgeShape));
               aResult.append(aPrs);
             }
           }
@@ -889,4 +894,17 @@ bool PartSet_WidgetSketchLabel::eventFilter(QObject* theObj, QEvent* theEvent)
       onShowPanel();
   }
   return ModuleBase_WidgetValidated::eventFilter(theObj, theEvent);
-}
\ No newline at end of file
+}
+
+void PartSet_WidgetSketchLabel::onShowViewPlane(bool toShow)
+{
+  PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+  if (toShow) {
+    CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+    aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
+  }
+  else {
+    aModule->sketchMgr()->previewSketchPlane()->eraseSketchPlane(myWorkshop, false);
+  }
+  myWorkshop->viewer()->update();
+}
index 635332dc9ab74f8834fdf7c2bde361e7bce536db..16f880993ba5e49d5ffa8adff581e34321f57ed5 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <ModuleBase_WidgetValidated.h>
 #include <ModuleBase_ViewerFilters.h>
+#include <ModuleBase_ViewerPrs.h>
 
 #include <GeomAPI_Dir.h>
 
@@ -110,7 +111,7 @@ public:
 
   /// Returns True if the selected presentation can be used for plane definition
   /// \param thePrs a presentation
-  static bool canFillSketch(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
+  static bool canFillSketch(const ModuleBase_ViewerPrsPtr& thePrs);
 
   /// If widgets has several panels then this method has to show a page which contains information
   /// for current feature. By default does nothing
@@ -152,7 +153,7 @@ protected:
 
   /// Fills the attribute with the value of the selected owner
   /// \param thePrs a selected owner
-  virtual bool setSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
+  virtual bool setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs);
 
   /// Saves the internal parameters to the given feature
   /// \return True in success
@@ -190,17 +191,17 @@ protected:
   /// It is redefined to do nothing if the plane of the sketch has been already set.
   /// \param theValues the wrapped selection values
   /// \param theToValidate a validation flag
-  bool setSelectionInternal(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
+  bool setSelectionInternal(const QList<ModuleBase_ViewerPrsPtr>& theValues,
                             const bool theToValidate);
 
   /// Erase preview planes, disconnect widget, change the view projection
   /// \param thePrs a selected presentation
-  void updateByPlaneSelected(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
+  void updateByPlaneSelected(const ModuleBase_ViewerPrsPtr& thePrs);
 
   /// Set sketch plane from selected object
   /// \param theFeature a feature of sketch
   /// \param thePrs a presentation
-  bool fillSketchPlaneBySelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
+  bool fillSketchPlaneBySelection(const ModuleBase_ViewerPrsPtr& thePrs);
 
   /// Redefinition of a virtual function
   virtual void showEvent(QShowEvent* theEvent);
@@ -219,12 +220,18 @@ private slots:
   /// \param theOn a flag show constraints or not
   void onShowConstraint(bool theOn);
 
+  /// A a slot called on "Change sketch plane" check box toggele
   void onChangePlane();
 
+  /// A a slot called on "Show remaining DOFs" check box toggele
   void onShowDOF();
 
+  ///  A a slot called on changing the panel visibility
   void onShowPanel();
 
+  /// A slot which is called on "Visible" plane checkbox toggle
+  void onShowViewPlane(bool);
+
 private:
   /// Set sketch plane by shape
   /// \param theShape a planar face
@@ -239,13 +246,14 @@ private:
   * (circles, arcs) which are in pane of of the given sketch
   * \param theSketch - the sketch
   */
-  QList<std::shared_ptr<ModuleBase_ViewerPrs>> findCircularEdgesInPlane();
+  QList<ModuleBase_ViewerPrsPtr> findCircularEdgesInPlane();
 
 private:
   /// class to show/hide preview planes
   PartSet_PreviewPlanes* myPreviewPlanes;
 
   QCheckBox* myViewInverted;
+  QCheckBox* myViewVisible;
   QCheckBox* myRemoveExternal;
   QCheckBox* myShowPoints;
   QCheckBox* myAutoConstraints;