From 18e2606a5b4ae3b3d6d82cb495e9d842a4cab48f Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 13 Apr 2020 13:30:39 +0300 Subject: [PATCH] Issue #3182: Show/Hide sketcher plane --- src/PartSet/PartSet_WidgetSketchLabel.cpp | 38 +++++++++++++++++------ src/PartSet/PartSet_WidgetSketchLabel.h | 20 ++++++++---- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index ac02f684c..9df9fad5a 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -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( + 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> PartSet_WidgetSketchLabel::findCircularEdgesInPlane() +QList PartSet_WidgetSketchLabel::findCircularEdgesInPlane() { QList> aResult; XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop); @@ -764,7 +770,7 @@ QList> 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 aPrs, aResult) { + foreach(ModuleBase_ViewerPrsPtr aPrs, aResult) { GeomAPI_Edge aUsedEdge(aPrs->shape()); if (aUsedEdge.isEqual(aEdgeShape)) { isContains = true; @@ -772,8 +778,7 @@ QList> PartSet_WidgetSketchLabel::findCirc } } if (!isContains) { - std::shared_ptr - 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(myWorkshop->module()); + if (toShow) { + CompositeFeaturePtr aSketch = std::dynamic_pointer_cast(myFeature); + aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop); + } + else { + aModule->sketchMgr()->previewSketchPlane()->eraseSketchPlane(myWorkshop, false); + } + myWorkshop->viewer()->update(); +} diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 635332dc9..16f880993 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -26,6 +26,7 @@ #include #include +#include #include @@ -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& 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& 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>& theValues, + bool setSelectionInternal(const QList& theValues, const bool theToValidate); /// Erase preview planes, disconnect widget, change the view projection /// \param thePrs a selected presentation - void updateByPlaneSelected(const std::shared_ptr& 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& 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> findCircularEdgesInPlane(); + QList findCircularEdgesInPlane(); private: /// class to show/hide preview planes PartSet_PreviewPlanes* myPreviewPlanes; QCheckBox* myViewInverted; + QCheckBox* myViewVisible; QCheckBox* myRemoveExternal; QCheckBox* myShowPoints; QCheckBox* myAutoConstraints; -- 2.39.2