From: nds Date: Mon, 6 Jul 2015 09:43:40 +0000 (+0300) Subject: Issue #591 - Highlight of the first argument of constraints X-Git-Tag: V_1.3.0~103 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7f7d50e90b39e2075a8585ac5d517e340f8eb09e;p=modules%2Fshaper.git Issue #591 - Highlight of the first argument of constraints The operation preview presentation should not be shown for objects, which are not displayed in the viewer. --- diff --git a/src/PartSet/PartSet_OperationPrs.cpp b/src/PartSet/PartSet_OperationPrs.cpp index 1f9bd11b5..136901071 100755 --- a/src/PartSet/PartSet_OperationPrs.cpp +++ b/src/PartSet/PartSet_OperationPrs.cpp @@ -7,14 +7,21 @@ #include "PartSet_OperationPrs.h" #include "PartSet_Tools.h" +#include "XGUI_Workshop.h" +#include "XGUI_ModuleConnector.h" +#include "XGUI_Displayer.h" + #include #include #include #include #include #include + #include +#include + #include #include @@ -61,12 +68,16 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t const Standard_Integer theMode) { thePresentation->Clear(); + XGUI_Displayer* aDisplayer = workshop()->displayer(); // create presentations on the base of the shapes Handle(Prs3d_Drawer) aDrawer = Attributes(); QMap >::const_iterator anIt = myFeatureShapes.begin(), aLast = myFeatureShapes.end(); for (; anIt != aLast; anIt++) { + ObjectPtr anObject = anIt.key(); + if (!isVisible(aDisplayer, anObject)) + continue; QList aShapes = anIt.value(); QList::const_iterator aShIt = aShapes.begin(), aShLast = aShapes.end(); for (; aShIt != aShLast; aShIt++) { @@ -83,6 +94,26 @@ void PartSet_OperationPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a // the presentation is not used in the selection } +bool PartSet_OperationPrs::isVisible(XGUI_Displayer* theDisplayer, const ObjectPtr& theObject) +{ + bool aVisible = false; + GeomPresentablePtr aPrs = std::dynamic_pointer_cast(theObject); + ResultPtr aResult = std::dynamic_pointer_cast(theObject); + if (aPrs.get() || aResult.get()) + aVisible = theDisplayer->isVisible(theObject); + else { + // check if all results of the feature are visible + FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); + std::list aResults = aFeature->results(); + std::list::const_iterator aIt; + aVisible = !aResults.empty(); + for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { + aVisible = aVisible && theDisplayer->isVisible(*aIt); + } + } + return aVisible; +} + void addValue(const ObjectPtr& theObject, const GeomShapePtr& theShape, QMap >& theObjectShapes) { @@ -170,3 +201,9 @@ bool PartSet_OperationPrs::isSelectionAttribute(const AttributePtr& theAttribute anAttrType == ModelAPI_AttributeSelection::typeId() || anAttrType == ModelAPI_AttributeReference::typeId(); } + +XGUI_Workshop* PartSet_OperationPrs::workshop() const +{ + XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); + return aConnector->workshop(); +} diff --git a/src/PartSet/PartSet_OperationPrs.h b/src/PartSet/PartSet_OperationPrs.h index e296e7b1d..ea645140c 100755 --- a/src/PartSet/PartSet_OperationPrs.h +++ b/src/PartSet/PartSet_OperationPrs.h @@ -25,6 +25,9 @@ DEFINE_STANDARD_HANDLE(PartSet_OperationPrs, ViewerData_AISShape) +class XGUI_Workshop; +class XGUI_Displayer; + /** * \ingroup GUI * A redefinition of standard AIS Interactive Object in order to provide colored presentation of @@ -66,6 +69,13 @@ protected: Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) ; private: + /// Return true if the object is visible. If the object is feature, it returns true + /// if all results of the feature are shown + /// \param theDisplayer a displayer + /// \param theObject an object + /// \return a boolean value + bool isVisible(XGUI_Displayer* theDislayer, const ObjectPtr& theObject); + /// Fills the map by the feature object and shapes, which should be visuaziled /// Gets the feature attribute, collect objects to whom the attribute refers /// \param theObjectShape an output map of objects @@ -76,6 +86,10 @@ private: /// \return a boolean value static bool isSelectionAttribute(const AttributePtr& theAttribute); + /// Converts the current workshop to XGUI workshop + /// \return a workshop instance + XGUI_Workshop* workshop() const; + private: ModuleBase_IWorkshop* myWorkshop; FeaturePtr myFeature; /// Reference to a feature object