From 5511432e2894062974d33f608287fd421c49dbb1 Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 28 Mar 2016 15:52:47 +0300 Subject: [PATCH] #1371 Using auxilliary Sketch elements in any Feature: isSketchMode is removed from ModuleBase_ResultPrs. --- src/ModuleBase/ModuleBase_IModule.cpp | 5 +++++ src/ModuleBase/ModuleBase_IModule.h | 5 +++++ src/ModuleBase/ModuleBase_ResultPrs.h | 3 --- src/PartSet/PartSet_Module.cpp | 12 ++++++++++++ src/PartSet/PartSet_Module.h | 5 +++++ src/XGUI/XGUI_Displayer.cpp | 9 +++------ 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index bf95e40c5..adf2562bd 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -71,6 +71,11 @@ Handle(AIS_InteractiveObject) ModuleBase_IModule::createPresentation(const Resul return Handle(AIS_InteractiveObject)(); } +bool ModuleBase_IModule::canBeShaded(Handle(AIS_InteractiveObject) theAIS) const +{ + return true; +} + QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature) { return ModelAPI_Tools::getFeatureError(theFeature).c_str(); diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 8a25b2afb..5e33eecb5 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -236,6 +236,11 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject //! Returns data object by AIS virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0; + //! Returns true if the presentation can be shown in shading mode + //! \param theAIS presentation to be checked + //! \return boolean value + virtual bool canBeShaded(Handle(AIS_InteractiveObject) theAIS) const; + /// Update state of pop-up menu items in object browser /// \param theStdActions - a map of standard actions virtual void updateObjectBrowserMenu(const QMap& theStdActions) {} diff --git a/src/ModuleBase/ModuleBase_ResultPrs.h b/src/ModuleBase/ModuleBase_ResultPrs.h index 729d131aa..165406ec2 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.h +++ b/src/ModuleBase/ModuleBase_ResultPrs.h @@ -72,9 +72,6 @@ public: /// Returns result object Standard_EXPORT ResultPtr getResult() const { return myResult; } - /// Returns True if the presentation is in sketch mode - Standard_EXPORT bool isSketchMode() const { return false; } - DEFINE_STANDARD_RTTI(ModuleBase_ResultPrs) protected: /// Redefinition of virtual function diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 4b7c2b50b..d4c12268c 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -16,6 +16,7 @@ #include "PartSet_WidgetSketchCreator.h" #include "PartSet_SketcherMgr.h" #include "PartSet_SketcherReetntrantMgr.h" +#include "PartSet_ResultSketchPrs.h" #include "PartSet_MenuMgr.h" #include "PartSet_CustomPrs.h" #include "PartSet_IconFactory.h" @@ -1026,6 +1027,17 @@ ObjectPtr PartSet_Module::findPresentedObject(const AISObjectPtr& theAIS) const return anObject; } +bool PartSet_Module::canBeShaded(Handle(AIS_InteractiveObject) theAIS) const +{ + bool aCanBeShaged = true; + + Handle(PartSet_ResultSketchPrs) aPrs = Handle(PartSet_ResultSketchPrs)::DownCast(theAIS); + if (!aPrs.IsNull()) + aCanBeShaged = false; + + return aCanBeShaged; +} + void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const { QObjectPtrList aObjects = myWorkshop->selection()->selectedObjects(); diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index f4bf86f17..6806b90eb 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -253,6 +253,11 @@ public: //! Returns data object by AIS virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const; + //! Returns true if the presentation can be shown in shading mode + //! \param theAIS presentation to be checked + //! \return boolean value + virtual bool canBeShaded(Handle(AIS_InteractiveObject) theAIS) const; + /// Update state of pop-up menu items in viewer /// \param theStdActions - a map of standard actions virtual void updateViewerMenu(const QMap& theStdActions); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index cc5b92bba..37d8202c7 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -179,7 +179,7 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer) return aDisplayed; } -bool canBeShaded(Handle(AIS_InteractiveObject) theAIS) +bool canBeShaded(Handle(AIS_InteractiveObject) theAIS, ModuleBase_IModule* theModule) { Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(theAIS); if (!aShapePrs.IsNull()) { @@ -191,10 +191,7 @@ bool canBeShaded(Handle(AIS_InteractiveObject) theAIS) return false; else { // Check that the presentation is not a sketch - Handle(ModuleBase_ResultPrs) aPrs = Handle(ModuleBase_ResultPrs)::DownCast(theAIS); - if (!aPrs.IsNull()) - return !aPrs->isSketchMode(); - return true; + return theModule->canBeShaded(theAIS); } } return false; @@ -1068,7 +1065,7 @@ bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const return false; Handle(AIS_InteractiveObject) anAIS = aAISObj->impl(); - return ::canBeShaded(anAIS); + return ::canBeShaded(anAIS, myWorkshop->module()); } bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO, -- 2.39.2