Salome HOME
Task 2.2 "Improvement of the wireframe visualization mode" from CEA specification
authorvsv <vsv@opencascade.com>
Fri, 29 Jun 2018 17:10:58 +0000 (20:10 +0300)
committervsv <vsv@opencascade.com>
Mon, 2 Jul 2018 07:22:05 +0000 (10:22 +0300)
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/ModuleBase/ModuleBase_ResultPrs.h

index cb422bf9a684ddafbe5dcdf03dcc8c557d4d5d52..f6e120df3a94d27fa835b1d37cbd5012ca52afb2 100755 (executable)
@@ -26,6 +26,7 @@
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_AttributeIntArray.h>
 
 #include "ModuleBase_Tools.h"
 #include "ModuleBase_BRepOwner.h"
@@ -69,7 +70,12 @@ ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
   std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
   TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
   Set(aShape);
+
+  // Set own free boundaries aspect in order to have free an unfree boundaries with different colors
   Handle(Prs3d_Drawer) aDrawer = Attributes();
+  Handle(Prs3d_LineAspect) aFreeBndAspect = new Prs3d_LineAspect(Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1);
+  aDrawer->SetFreeBoundaryAspect(aFreeBndAspect);
+
   if (aDrawer->HasOwnPointAspect())
     aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_PLUS);
   else
@@ -85,6 +91,9 @@ ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
   myHiddenSubShapesDrawer->SetShadingAspect(aShadingAspect);
 
   ModuleBase_Tools::setPointBallHighlighting(this);
+
+  // Define colors for wireframe mode
+  setEdgesDefaultColor();
 }
 
 //********************************************************************
@@ -98,8 +107,40 @@ void ModuleBase_ResultPrs::SetColor (const Quantity_Color& theColor)
 {
   ViewerData_AISShape::SetColor(theColor);
   myHiddenSubShapesDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
+  setEdgesDefaultColor();
+}
+
+void ModuleBase_ResultPrs::setEdgesDefaultColor()
+{
+  AttributeIntArrayPtr aColorAttr = myResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+  bool aHasColor = aColorAttr.get() && aColorAttr->isInitialized();
+
+  if (!aHasColor) {
+    Handle(Prs3d_Drawer) aDrawer = Attributes();
+    Handle(Prs3d_LineAspect) anAspect; // = aDrawer->LineAspect();
+    //anAspect->SetColor(Quantity_NOC_YELLOW);
+    //aDrawer->SetLineAspect(anAspect);
+
+    // - unfree boundaries color
+    anAspect = aDrawer->UnFreeBoundaryAspect();
+    anAspect->SetColor(Quantity_NOC_YELLOW);
+    aDrawer->SetUnFreeBoundaryAspect(anAspect);
+    aDrawer->SetUnFreeBoundaryDraw(true);
+
+    // - free boundaries color
+    anAspect = aDrawer->FreeBoundaryAspect();
+    anAspect->SetColor(Quantity_NOC_GREEN);
+    aDrawer->SetFreeBoundaryAspect(anAspect);
+    aDrawer->SetFreeBoundaryDraw(true);
+
+    // - standalone edges color
+    anAspect = aDrawer->WireAspect();
+    anAspect->SetColor(Quantity_NOC_RED);
+    aDrawer->SetWireAspect(anAspect);
+  }
 }
 
+
 //********************************************************************
 bool ModuleBase_ResultPrs::setSubShapeHidden(const NCollection_List<TopoDS_Shape>& theShapes)
 {
index 367d38232312888cf5c5d2e76df578cac2c79954..f22cfb1f85769a65bf861352c8d7e27dbc0ceee3 100644 (file)
@@ -141,6 +141,8 @@ private:
   void collectSubShapes(BRep_Builder& theBuilder, TopoDS_Shape& theCompound,
     const TopoDS_Shape& theShape, const NCollection_List<TopoDS_Shape>& theHiddenSubShapes);
 
+  void setEdgesDefaultColor();
+
 private:
   /// Reference to result object
   ResultPtr myResult;