]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #75 - reported by Hervé Legrand: sketch - color of planes displayed in 3D viewer...
authornds <natalia.donis@opencascade.com>
Mon, 2 Jun 2014 08:19:49 +0000 (12:19 +0400)
committernds <natalia.donis@opencascade.com>
Mon, 2 Jun 2014 08:19:49 +0000 (12:19 +0400)
the color correction for sketch plane.

src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h

index 99cab29e5c2a2be1f1c3660db3f475f92ec16c61..abf5d270d184351d7647f298cbb4c648cd5d75b5 100644 (file)
@@ -391,8 +391,15 @@ void PartSet_Module::visualizePreview(boost::shared_ptr<ModelAPI_Feature> theFea
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   if (isDisplay) {
     boost::shared_ptr<GeomAPI_Shape> aPreview = aPreviewOp->preview(theFeature);
-    aDisplayer->Redisplay(theFeature,
-                          aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), false);
+    bool isAISCreated = aDisplayer->Redisplay(theFeature, aPreview ?
+                                           aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), false);
+    if (isAISCreated) {
+      PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
+      if (aSketchOp) {
+        Handle(AIS_InteractiveObject) anAIS = aDisplayer->GetAISObject(theFeature);
+        aSketchOp->correctPresentation(anAIS);
+      }
+    }
   }
   else
     aDisplayer->Erase(theFeature, false);
index 7deb0ef54c44d670e467ac214ba58afb10d74a8a..ece04ed94168608362b88e0e2fab1eb2a4f5f3d8 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <AIS_Shape.hxx>
 #include <AIS_ListOfInteractive.hxx>
+#include <AIS_InteractiveObject.hxx>
 #include <V3d_View.hxx>
 
 #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()) {
index 9c76414e9f7b5ce2b9cce0c008afe8d3b12cbeac..f3b2e77314a8f0d8750a12360be4d29dc47e494f 100644 (file)
@@ -10,6 +10,8 @@
 #include <PartSet_OperationSketchBase.h>
 #include <QObject>
 
+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
index d81b6e59fd9a7129ba18ca76e80406769247ed01..dd763359d7883e4098b9963236dd2edf8e574648 100644 (file)
@@ -117,9 +117,10 @@ void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
     UpdateViewer();
 }
 
-void XGUI_Displayer::Redisplay(boost::shared_ptr<ModelAPI_Feature> theFeature,
+bool XGUI_Displayer::Redisplay(boost::shared_ptr<ModelAPI_Feature> 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<ModelAPI_Feature> 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<ModelAPI_Feature> theFeature,
index 6606ebf06fcd0b91d3cd353299a3ed6709f51b4e..dd3ccb4dc016637b6280c2b3e1a53d1080dac886 100644 (file)
@@ -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<ModelAPI_Feature> theFeature,
+  /// \returns true if the presentation is created
+  bool Redisplay(boost::shared_ptr<ModelAPI_Feature> 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<ModelAPI_Feature>) const;
+  Handle(AIS_InteractiveObject) GetAISObject(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
 
 protected:
   /// Searches the feature by interactive object