From: nds Date: Mon, 2 Jun 2014 08:19:49 +0000 (+0400) Subject: refs #75 - reported by Hervé Legrand: sketch - color of planes displayed in 3D viewer... X-Git-Tag: V_0.4.4~331^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e5b85749a0da284a2aa797576a5f65488aea0b3f;p=modules%2Fshaper.git refs #75 - reported by Hervé Legrand: sketch - color of planes displayed in 3D viewer should be changed the color correction for sketch plane. --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 99cab29e5..abf5d270d 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -391,8 +391,15 @@ void PartSet_Module::visualizePreview(boost::shared_ptr theFea XGUI_Displayer* aDisplayer = myWorkshop->displayer(); if (isDisplay) { boost::shared_ptr aPreview = aPreviewOp->preview(theFeature); - aDisplayer->Redisplay(theFeature, - aPreview ? aPreview->impl() : TopoDS_Shape(), false); + bool isAISCreated = aDisplayer->Redisplay(theFeature, aPreview ? + aPreview->impl() : TopoDS_Shape(), false); + if (isAISCreated) { + PartSet_OperationSketch* aSketchOp = dynamic_cast(aPreviewOp); + if (aSketchOp) { + Handle(AIS_InteractiveObject) anAIS = aDisplayer->GetAISObject(theFeature); + aSketchOp->correctPresentation(anAIS); + } + } } else aDisplayer->Erase(theFeature, false); diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 7deb0ef54..ece04ed94 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #ifdef _DEBUG @@ -31,6 +32,9 @@ using namespace std; +const Quantity_NameOfColor SKETCH_PLANE_COLOR = Quantity_NOC_CHOCOLATE; /// the plane edge color +const int SKETCH_WIDTH = 4; /// the plane edge width + PartSet_OperationSketch::PartSet_OperationSketch(const QString& theId, QObject* theParent) : PartSet_OperationSketchBase(theId, theParent) @@ -142,6 +146,17 @@ bool PartSet_OperationSketch::isNestedOperationsEnabled() const return hasSketchPlane(); } +void PartSet_OperationSketch::correctPresentation(Handle(AIS_InteractiveObject) thePresentation) +{ + Handle(AIS_Shape) anAIS = Handle(AIS_Shape)::DownCast(thePresentation); + if (anAIS.IsNull()) + return; + + anAIS->SetColor(Quantity_Color(SKETCH_PLANE_COLOR)); + anAIS->SetWidth(SKETCH_WIDTH); + anAIS->Redisplay(); +} + void PartSet_OperationSketch::startOperation() { if (!feature()) { diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index 9c76414e9..f3b2e7731 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -10,6 +10,8 @@ #include #include +class Handle_AIS_InteractiveObject; + /*! \class PartSet_OperationSketch * \brief The operation for the sketch feature creation @@ -73,6 +75,10 @@ public: /// \return enabled state virtual bool isNestedOperationsEnabled() const; + /// Corrects the presentation settings by the operation + /// thePresentation an operation presentation + void correctPresentation(Handle_AIS_InteractiveObject thePresentation); + signals: /// signal about the sketch plane is selected /// \param theX the value in the X direction of the plane diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index d81b6e59f..dd763359d 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -117,9 +117,10 @@ void XGUI_Displayer::Erase(boost::shared_ptr theFeature, UpdateViewer(); } -void XGUI_Displayer::Redisplay(boost::shared_ptr theFeature, +bool XGUI_Displayer::Redisplay(boost::shared_ptr theFeature, const TopoDS_Shape& theShape, const bool isUpdateViewer) { + bool isCreated = false; Handle(AIS_InteractiveContext) aContext = AISContext(); // Open local context if there is no one if (!aContext->HasOpenedContext()) { @@ -148,9 +149,12 @@ void XGUI_Displayer::Redisplay(boost::shared_ptr theFeature, anAIS = new AIS_Shape(theShape); myFeature2AISObjectMap[theFeature] = anAIS; aContext->Display(anAIS, false); + isCreated = true; } if (isUpdateViewer) UpdateViewer(); + + return isCreated; } void XGUI_Displayer::ActivateInLocalContext(boost::shared_ptr theFeature, diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 6606ebf06..dd3ccb4dc 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -73,7 +73,8 @@ public: /// \param theShape a shape /// \param theMode a local selection mode /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - void Redisplay(boost::shared_ptr theFeature, + /// \returns true if the presentation is created + bool Redisplay(boost::shared_ptr theFeature, const TopoDS_Shape& theShape, const bool isUpdateViewer = true); /// Display the shape and activate selection of sub-shapes @@ -117,9 +118,9 @@ public: void UpdateViewer(); /// Searches the interactive object by feature - /// \param feature the feature or NULL if it not visualized + /// \param theFeature the feature or NULL if it not visualized /// \return theIO an interactive object - Handle(AIS_InteractiveObject) GetAISObject(boost::shared_ptr) const; + Handle(AIS_InteractiveObject) GetAISObject(boost::shared_ptr theFeature) const; protected: /// Searches the feature by interactive object