From 36f85c3197cc9dd82b0b5591889a878b79300178 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 22 Mar 2016 16:18:17 +0300 Subject: [PATCH] Issue #1343 Improvement of Extrusion and Revolution operations: preview planes visualization if there are not bodies in the viewer. --- src/Config/Config_Keywords.h | 5 - src/FeaturesPlugin/extrusion_widget.xml | 1 - src/FeaturesPlugin/extrusionsketch_widget.xml | 1 - .../revolutionsketch_widget.xml | 1 - src/PartSet/CMakeLists.txt | 2 + src/PartSet/PartSet_Module.cpp | 1 + src/PartSet/PartSet_PreviewPlanes.cpp | 102 +++++++++++++++++ src/PartSet/PartSet_PreviewPlanes.h | 71 ++++++++++++ src/PartSet/PartSet_WidgetSketchCreator.cpp | 69 ++++++------ src/PartSet/PartSet_WidgetSketchCreator.h | 7 +- src/PartSet/PartSet_WidgetSketchLabel.cpp | 105 +++--------------- src/PartSet/PartSet_WidgetSketchLabel.h | 34 +----- 12 files changed, 237 insertions(+), 162 deletions(-) create mode 100755 src/PartSet/PartSet_PreviewPlanes.cpp create mode 100755 src/PartSet/PartSet_PreviewPlanes.h diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index daacdbf8b..2e470119b 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -113,9 +113,4 @@ const static char* NODE_ICON = "icon"; const static char* SHOW_EMPTY = "show_empty"; const static char* LINK_ITEM = "from_result"; -/* - * Hardcoded xml entities for composite features - */ -const static char* USE_BODY = "use_body"; - #endif /* CONFIG_KEYWORDS_H_ */ diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index 6f0faf610..1cf80deb2 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -7,7 +7,6 @@ 2. An existing sketch face or contour. Extrusion will be filled with them. 3.A shape on existing result: wires/edge/vertices. Extrusion will be filled with them" icon=":icons/sketch.png" - use_body="false" tooltip="Create or edit a sketch" shape_types="face objects"> diff --git a/src/FeaturesPlugin/extrusionsketch_widget.xml b/src/FeaturesPlugin/extrusionsketch_widget.xml index a5c74f6d0..7394fd863 100644 --- a/src/FeaturesPlugin/extrusionsketch_widget.xml +++ b/src/FeaturesPlugin/extrusionsketch_widget.xml @@ -5,7 +5,6 @@ diff --git a/src/FeaturesPlugin/revolutionsketch_widget.xml b/src/FeaturesPlugin/revolutionsketch_widget.xml index 36d836a98..1af1dae90 100644 --- a/src/FeaturesPlugin/revolutionsketch_widget.xml +++ b/src/FeaturesPlugin/revolutionsketch_widget.xml @@ -5,7 +5,6 @@ diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 17b1fdedc..86da38c63 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -12,6 +12,7 @@ SET(PROJECT_HEADERS PartSet_Module.h PartSet_OperationPrs.h PartSet_OverconstraintListener.h + PartSet_PreviewPlanes.h PartSet_Tools.h PartSet_WidgetSketchLabel.h PartSet_Validators.h @@ -39,6 +40,7 @@ SET(PROJECT_SOURCES PartSet_Module.cpp PartSet_OperationPrs.cpp PartSet_OverconstraintListener.cpp + PartSet_PreviewPlanes.cpp PartSet_Tools.cpp PartSet_WidgetSketchLabel.cpp PartSet_Validators.cpp diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index fe337ef0b..9219dbaf0 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -4,6 +4,7 @@ #include "PartSet_WidgetSketchLabel.h" #include "PartSet_Validators.h" #include "PartSet_Tools.h" +#include "PartSet_PreviewPlanes.h" #include "PartSet_WidgetPoint2d.h" #include "PartSet_WidgetPoint2dDistance.h" #include "PartSet_WidgetPoint2DFlyout.h" diff --git a/src/PartSet/PartSet_PreviewPlanes.cpp b/src/PartSet/PartSet_PreviewPlanes.cpp new file mode 100755 index 000000000..f7735336a --- /dev/null +++ b/src/PartSet/PartSet_PreviewPlanes.cpp @@ -0,0 +1,102 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: PartSet_PreviewPlanes.cpp +// Created: 19 Jun 2015 +// Author: Natalia ERMOLAEVA + +#include "PartSet_PreviewPlanes.h" + +#include + +#include + +#include +#include +#include + +#include +#include + +#include + +PartSet_PreviewPlanes::PartSet_PreviewPlanes() + : myPreviewDisplayed(false) +{ +} + +bool PartSet_PreviewPlanes::hasVisualizedBodies(ModuleBase_IWorkshop* theWorkshop) +{ + bool aBodyIsVisualized = false; + + XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(theWorkshop); + XGUI_Displayer* aDisp = aWorkshop->displayer(); + QObjectPtrList aDisplayed = aDisp->displayedObjects(); + foreach (ObjectPtr anObj, aDisplayed) { + ResultPtr aResult = std::dynamic_pointer_cast(anObj); + if (aResult.get() != NULL) { + aBodyIsVisualized = aResult->groupName() == ModelAPI_ResultBody::group(); + if (aBodyIsVisualized) + break; + } + } + return aBodyIsVisualized; +} + +void PartSet_PreviewPlanes::erasePreviewPlanes(ModuleBase_IWorkshop* theWorkshop) +{ + if (myPreviewDisplayed) { + XGUI_Displayer* aDisp = XGUI_Tools::workshop(theWorkshop)->displayer(); + aDisp->eraseAIS(myYZPlane, false); + aDisp->eraseAIS(myXZPlane, false); + aDisp->eraseAIS(myXYPlane, false); + myPreviewDisplayed = false; + } +} + +void PartSet_PreviewPlanes::showPreviewPlanes(ModuleBase_IWorkshop* theWorkshop) +{ + if (myPreviewDisplayed) + return; + + if (!myYZPlane) { // If planes are not created + // Create Preview + std::shared_ptr anOrigin(new GeomAPI_Pnt(0, 0, 0)); + std::shared_ptr aYZDir(new GeomAPI_Dir(1, 0, 0)); + // -1, not 1 for correct internal sketch coords (issue 898) + std::shared_ptr aXZDir(new GeomAPI_Dir(0, -1, 0)); + std::shared_ptr aXYDir(new GeomAPI_Dir(0, 0, 1)); + + std::vector aYZRGB, aXZRGB, aXYRGB; + aYZRGB = Config_PropManager::color("Visualization", "yz_plane_color", + YZ_PLANE_COLOR); + aXZRGB = Config_PropManager::color("Visualization", "xz_plane_color", + XZ_PLANE_COLOR); + aXYRGB = Config_PropManager::color("Visualization", "xy_plane_color", + XY_PLANE_COLOR); + int aR[] = {aYZRGB[0], aYZRGB[1], aYZRGB[2]}; + int aG[] = {aXZRGB[0], aXZRGB[1], aXZRGB[2]}; + int aB[] = {aXYRGB[0], aXYRGB[1], aXYRGB[2]}; + + myYZPlane = createPreviewPlane(anOrigin, aYZDir, aR); + myXZPlane = createPreviewPlane(anOrigin, aXZDir, aG); + myXYPlane = createPreviewPlane(anOrigin, aXYDir, aB); + } + XGUI_Displayer* aDisp = XGUI_Tools::workshop(theWorkshop)->displayer(); + aDisp->displayAIS(myYZPlane, true, false); + aDisp->displayAIS(myXZPlane, true, false); + aDisp->displayAIS(myXYPlane, true, false); + myPreviewDisplayed = true; +} + +AISObjectPtr PartSet_PreviewPlanes::createPreviewPlane(std::shared_ptr theOrigin, + std::shared_ptr theNorm, + const int theRGB[3]) +{ + double aSize = Config_PropManager::integer("Sketch planes", "planes_size", PLANE_SIZE); + std::shared_ptr aFace = GeomAlgoAPI_FaceBuilder::square(theOrigin, theNorm, aSize); + AISObjectPtr aAIS = AISObjectPtr(new GeomAPI_AISObject()); + aAIS->createShape(aFace); + aAIS->setWidth(Config_PropManager::integer("Sketch planes", "planes_thickness", SKETCH_WIDTH)); + aAIS->setColor(theRGB[0], theRGB[1], theRGB[2]); + return aAIS; +} diff --git a/src/PartSet/PartSet_PreviewPlanes.h b/src/PartSet/PartSet_PreviewPlanes.h new file mode 100755 index 000000000..d64f10fbf --- /dev/null +++ b/src/PartSet/PartSet_PreviewPlanes.h @@ -0,0 +1,71 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: PartSet_PreviewPlanes.h +// Created: 22 Mar 2016 +// Author: Natalia ERMOLAEVA + +#ifndef PartSet_PreviewPlanes_H +#define PartSet_PreviewPlanes_H + +#include + +#include +#include +#include + +class ModuleBase_IWorkshop; + +/// the plane edge width +#define SKETCH_WIDTH "4" +/// face of the square-face displayed for selection of general plane +#define PLANE_SIZE "200" + +/** +* \class PartSet_PreviewPlanes +* \ingroup Modules +* A class to show/hide sketch preview planes +*/ +class PartSet_PreviewPlanes +{ +public: + /// Constructor + PartSet_PreviewPlanes(); + + ~PartSet_PreviewPlanes() {}; + + /// Returns true if there is body visualized in the viewer + /// \param theWorkshop the application workshop + /// \return boolean value + static bool hasVisualizedBodies(ModuleBase_IWorkshop* theWorkshop); + + /// Returns if the preview was displayed + /// \param theWorkshop the application workshop + /// \return boolean value + bool isPreviewDisplayed() const { return myPreviewDisplayed; } + + /// Erase preview planes + /// \param theWorkshop the application workshop + void erasePreviewPlanes(ModuleBase_IWorkshop* theWorkshop); + + /// Show preview planes + /// \param theWorkshop the application workshop + void showPreviewPlanes(ModuleBase_IWorkshop* theWorkshop); + +private: + /// Create preview of planes for sketch plane selection + /// \param theOrigin an origin of the plane + /// \param theNorm a normal vector of the plane + /// \param theRGB a color of plane presentation [r, g, b] array + AISObjectPtr createPreviewPlane(std::shared_ptr theOrigin, + std::shared_ptr theNorm, + const int theRGB[3]); + +private: + bool myPreviewDisplayed; + + AISObjectPtr myYZPlane; + AISObjectPtr myXZPlane; + AISObjectPtr myXYPlane; +}; + +#endif \ No newline at end of file diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index cecf69f4d..52e518297 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -7,6 +7,7 @@ #include "PartSet_WidgetSketchCreator.h" #include "PartSet_Module.h" #include "PartSet_WidgetSketchLabel.h" +#include "PartSet_PreviewPlanes.h" #include @@ -17,6 +18,7 @@ #include #include #include +#include #include @@ -48,7 +50,7 @@ PartSet_WidgetSketchCreator::PartSet_WidgetSketchCreator(QWidget* theParent, PartSet_Module* theModule, const Config_WidgetAPI* theData) : ModuleBase_WidgetSelector(theParent, theModule->workshop(), theData), - myModule(theModule), myUseBody(true) + myModule(theModule) { myAttributeListID = theData->getProperty("attribute_list_id"); @@ -76,15 +78,12 @@ PartSet_WidgetSketchCreator::PartSet_WidgetSketchCreator(QWidget* theParent, myLabel->setToolTip(aToolTip); - QString aUseBody = QString::fromStdString(theData->getProperty(USE_BODY)); - if(!aUseBody.isEmpty()) { - myUseBody = QVariant(aUseBody).toBool(); - } - aLayout->addRow(myLabel, myTextLine);*/ std::string aTypes = theData->getProperty("shape_types"); myShapeTypes = QString(aTypes.c_str()).split(' ', QString::SkipEmptyParts); + + myPreviewPlanes = new PartSet_PreviewPlanes(); } PartSet_WidgetSketchCreator::~PartSet_WidgetSketchCreator() @@ -132,6 +131,19 @@ void PartSet_WidgetSketchCreator::setVisibleSelectionControl(const bool theSelec aWidget->setVisible(true); } } + + if (theSelectionControl) { + bool aBodyIsVisualized = myPreviewPlanes->hasVisualizedBodies(myWorkshop); + if (!aBodyIsVisualized) { + // We have to select a plane before any operation + myPreviewPlanes->showPreviewPlanes(myWorkshop); + } + } else { + bool aHidePreview = myPreviewPlanes->isPreviewDisplayed(); + myPreviewPlanes->showPreviewPlanes(myWorkshop); + if (aHidePreview) + aWorkshop->viewer()->update(); + } } QIntList PartSet_WidgetSketchCreator::getShapeTypes() const @@ -214,6 +226,8 @@ bool PartSet_WidgetSketchCreator::startSketchOperation(const QListisPreviewDisplayed(); + myPreviewPlanes->erasePreviewPlanes(myWorkshop); // Launch Sketch operation CompositeFeaturePtr aCompFeature = @@ -309,33 +323,24 @@ void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp) // Add Selected body were created the sketcher to list of selected objects - if(myUseBody) { - std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::BOOLEAN_OBJECTS_ID(); - AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute); - if (aSelList.get()) { - DataPtr aData = aSketchFeature->data(); - AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast - (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); - ResultPtr aRes = aSelAttr.get() ? aSelAttr->context() : ResultPtr(); - if (aRes.get()) { - SessionPtr aMgr = ModelAPI_Session::get(); - ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute); - std::string aValidatorID, anError; - aSelList->append(aRes, GeomShapePtr()); - if (aFactory->validate(anAttribute, aValidatorID, anError)) - updateObject(aCompFeature); - else - aSelList->clear(); - } + std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::BOOLEAN_OBJECTS_ID(); + AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute); + if (aSelList.get()) { + DataPtr aData = aSketchFeature->data(); + AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast + (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); + ResultPtr aRes = aSelAttr.get() ? aSelAttr->context() : ResultPtr(); + if (aRes.get()) { + SessionPtr aMgr = ModelAPI_Session::get(); + ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); + AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute); + std::string aValidatorID, anError; + aSelList->append(aRes, GeomShapePtr()); + if (aFactory->validate(anAttribute, aValidatorID, anError)) + updateObject(aCompFeature); + else + aSelList->clear(); } } - else { - // this is a workarount to display the feature results in the operation selection mode - // if this is absent, sketch point/line local selection is available on extrusion cut result - static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); - ModelAPI_EventCreator::get()->sendUpdated(feature(), anUpdateEvent); - updateObject(feature()); - } } } diff --git a/src/PartSet/PartSet_WidgetSketchCreator.h b/src/PartSet/PartSet_WidgetSketchCreator.h index aa25800bd..011608ef0 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.h +++ b/src/PartSet/PartSet_WidgetSketchCreator.h @@ -15,7 +15,7 @@ class QLabel; class QLineEdit; class PartSet_Module; class ModuleBase_Operation; - +class PartSet_PreviewPlanes; /** * \ingroup Modules @@ -106,9 +106,8 @@ private: /// List of accepting shapes types QStringList myShapeTypes; - /// To check if we need to use body for composite feature or not - bool myUseBody; - + /// class to show/hide preview planes + PartSet_PreviewPlanes* myPreviewPlanes; }; #endif \ No newline at end of file diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 74697d45f..d109babee 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -7,6 +7,7 @@ #include "PartSet_WidgetSketchLabel.h" #include "PartSet_Tools.h" #include "PartSet_Module.h" +#include "PartSet_PreviewPlanes.h" #include "SketchPlugin_SketchEntity.h" @@ -16,6 +17,7 @@ #include #include #include +#include #include #include @@ -58,8 +60,7 @@ PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, const QMap& toShowConstraints) -: ModuleBase_WidgetValidated(theParent, theWorkshop, theData), - myPreviewDisplayed(false) +: ModuleBase_WidgetValidated(theParent, theWorkshop, theData) { QVBoxLayout* aLayout = new QVBoxLayout(this); ModuleBase_Tools::zeroMargins(aLayout); @@ -121,6 +122,8 @@ PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent, myStackWidget->addWidget(aSecondWgt); //setLayout(aLayout); + + myPreviewPlanes = new PartSet_PreviewPlanes(); } PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel() @@ -208,7 +211,7 @@ void PartSet_WidgetSketchLabel::blockAttribute(const bool& theToBlock, bool& isF void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs& thePrs) { // 1. hide main planes if they have been displayed - erasePreviewPlanes(); + myPreviewPlanes->erasePreviewPlanes(myWorkshop); // 2. if the planes were displayed, change the view projection TopoDS_Shape aShape = thePrs.shape(); std::shared_ptr aGShape; @@ -258,13 +261,14 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs myStackWidget->setCurrentIndex(1); //myLabel->setText(""); //myLabel->setToolTip(""); - disconnect(workshop()->selector(), SIGNAL(selectionChanged()), + XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop); + disconnect(aWorkshop->selector(), SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); // 4. deactivate face selection filter activateFilters(false); // 5. Clear selection mode and define sketching mode - //XGUI_Displayer* aDisp = workshop()->displayer(); + //XGUI_Displayer* aDisp = aWorkshop->displayer(); //aDisp->closeLocalContexts(); emit planeSelected(plane()); // after the plane is selected in the sketch, the sketch selection should be activated @@ -273,7 +277,7 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs activateSelection(true); // 6. Update sketcher actions - XGUI_ActionsMgr* anActMgr = workshop()->actionsMgr(); + XGUI_ActionsMgr* anActMgr = aWorkshop->actionsMgr(); myWorkshop->updateCommandStatus(); myWorkshop->viewer()->update(); } @@ -399,36 +403,26 @@ void PartSet_WidgetSketchLabel::activateCustom() } myStackWidget->setCurrentIndex(0); - bool aBodyIsVisualized = false; - XGUI_Displayer* aDisp = workshop()->displayer(); - QObjectPtrList aDisplayed = aDisp->displayedObjects(); - foreach (ObjectPtr anObj, aDisplayed) { - ResultPtr aResult = std::dynamic_pointer_cast(anObj); - if (aResult.get() != NULL) { - aBodyIsVisualized = aResult->groupName() == ModelAPI_ResultBody::group(); - if (aBodyIsVisualized) - break; - } - } - + bool aBodyIsVisualized = myPreviewPlanes->hasVisualizedBodies(myWorkshop); if (!aBodyIsVisualized) { // We have to select a plane before any operation - showPreviewPlanes(); + myPreviewPlanes->showPreviewPlanes(myWorkshop); } activateSelection(true); //myLabel->setText(myText); //myLabel->setToolTip(myTooltip); - connect(workshop()->selector(), SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); + connect(XGUI_Tools::workshop(myWorkshop)->selector(), SIGNAL(selectionChanged()), + this, SLOT(onSelectionChanged())); activateFilters(true); } void PartSet_WidgetSketchLabel::deactivate() { ModuleBase_ModelWidget::deactivate(); - bool aHidePreview = myPreviewDisplayed; - erasePreviewPlanes(); + bool aHidePreview = myPreviewPlanes->isPreviewDisplayed(); + myPreviewPlanes->erasePreviewPlanes(myWorkshop); activateSelection(false); activateFilters(false); @@ -453,66 +447,6 @@ void PartSet_WidgetSketchLabel::activateSelection(bool toActivate) } } -void PartSet_WidgetSketchLabel::erasePreviewPlanes() -{ - if (myPreviewDisplayed) { - XGUI_Displayer* aDisp = workshop()->displayer(); - aDisp->eraseAIS(myYZPlane, false); - aDisp->eraseAIS(myXZPlane, false); - aDisp->eraseAIS(myXYPlane, false); - myPreviewDisplayed = false; - } -} - -void PartSet_WidgetSketchLabel::showPreviewPlanes() -{ - if (myPreviewDisplayed) - return; - - if (!myYZPlane) { // If planes are not created - // Create Preview - std::shared_ptr anOrigin(new GeomAPI_Pnt(0, 0, 0)); - std::shared_ptr aYZDir(new GeomAPI_Dir(1, 0, 0)); - // -1, not 1 for correct internal sketch coords (issue 898) - std::shared_ptr aXZDir(new GeomAPI_Dir(0, -1, 0)); - std::shared_ptr aXYDir(new GeomAPI_Dir(0, 0, 1)); - - std::vector aYZRGB, aXZRGB, aXYRGB; - aYZRGB = Config_PropManager::color("Visualization", "yz_plane_color", - YZ_PLANE_COLOR); - aXZRGB = Config_PropManager::color("Visualization", "xz_plane_color", - XZ_PLANE_COLOR); - aXYRGB = Config_PropManager::color("Visualization", "xy_plane_color", - XY_PLANE_COLOR); - int aR[] = {aYZRGB[0], aYZRGB[1], aYZRGB[2]}; - int aG[] = {aXZRGB[0], aXZRGB[1], aXZRGB[2]}; - int aB[] = {aXYRGB[0], aXYRGB[1], aXYRGB[2]}; - - myYZPlane = createPreviewPlane(anOrigin, aYZDir, aR); - myXZPlane = createPreviewPlane(anOrigin, aXZDir, aG); - myXYPlane = createPreviewPlane(anOrigin, aXYDir, aB); - } - XGUI_Displayer* aDisp = workshop()->displayer(); - aDisp->displayAIS(myYZPlane, true, false); - aDisp->displayAIS(myXZPlane, true, false); - aDisp->displayAIS(myXYPlane, true, false); - myPreviewDisplayed = true; -} - - -AISObjectPtr PartSet_WidgetSketchLabel::createPreviewPlane(std::shared_ptr theOrigin, - std::shared_ptr theNorm, - const int theRGB[3]) -{ - double aSize = Config_PropManager::integer("Sketch planes", "planes_size", PLANE_SIZE); - std::shared_ptr aFace = GeomAlgoAPI_FaceBuilder::square(theOrigin, theNorm, aSize); - AISObjectPtr aAIS = AISObjectPtr(new GeomAPI_AISObject()); - aAIS->createShape(aFace); - aAIS->setWidth(Config_PropManager::integer("Sketch planes", "planes_thickness", SKETCH_WIDTH)); - aAIS->setColor(theRGB[0], theRGB[1], theRGB[2]); - return aAIS; -} - std::shared_ptr PartSet_WidgetSketchLabel::setSketchPlane(const FeaturePtr& theFeature, const TopoDS_Shape& theShape) @@ -563,13 +497,6 @@ std::shared_ptr PartSet_WidgetSketchLabel::setSketchPlane(const Fea return aDir; } -XGUI_Workshop* PartSet_WidgetSketchLabel::workshop() const -{ - XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); - return aConnector->workshop(); -} - - void PartSet_WidgetSketchLabel::onSetPlaneView() { std::shared_ptr aPlane = plane(); diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 956b06ee0..7ab807bd2 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -14,26 +14,20 @@ #include #include -#include #include -#include #include #include +class PartSet_PreviewPlanes; + class QLabel; class XGUI_OperationMgr; class XGUI_Workshop; class QCheckBox; class QStackedWidget; -/// the plane edge width -#define SKETCH_WIDTH "4" - -/// face of the square-face displayed for selection of general plane -#define PLANE_SIZE "200" - /** * \ingroup Modules * A model widget implementation for a label which provides specific behaviour @@ -155,33 +149,15 @@ protected: void onShowConstraint(bool theOn); private: - /// Create preview of planes for sketch plane selection - /// \param theOrigin an origin of the plane - /// \param theNorm a normal vector of the plane - /// \param theRGB a color of plane presentation [r, g, b] array - AISObjectPtr createPreviewPlane(std::shared_ptr theOrigin, - std::shared_ptr theNorm, - const int theRGB[3]); - - //! Returns workshop - XGUI_Workshop* workshop() const; - /// Set sketch plane by shape /// \param theShape a planar face static std::shared_ptr setSketchPlane(const FeaturePtr& theFeature, const TopoDS_Shape& theShape); - /// Erase preview planes - void erasePreviewPlanes(); - - /// Show preview planes - void showPreviewPlanes(); - - AISObjectPtr myYZPlane; - AISObjectPtr myXZPlane; - AISObjectPtr myXYPlane; - bool myPreviewDisplayed; +private: + /// class to show/hide preview planes + PartSet_PreviewPlanes* myPreviewPlanes; QCheckBox* myViewInverted; -- 2.39.2