From abe1d926c4a429737fea27a0d7afee02047c7dcf Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 29 Jun 2018 20:10:58 +0300 Subject: [PATCH] Task 2.2 "Improvement of the wireframe visualization mode" from CEA specification --- src/ModuleBase/ModuleBase_ResultPrs.cpp | 41 +++++++++++++++++++++++++ src/ModuleBase/ModuleBase_ResultPrs.h | 2 ++ 2 files changed, 43 insertions(+) diff --git a/src/ModuleBase/ModuleBase_ResultPrs.cpp b/src/ModuleBase/ModuleBase_ResultPrs.cpp index cb422bf9a..f6e120df3 100755 --- a/src/ModuleBase/ModuleBase_ResultPrs.cpp +++ b/src/ModuleBase/ModuleBase_ResultPrs.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "ModuleBase_Tools.h" #include "ModuleBase_BRepOwner.h" @@ -69,7 +70,12 @@ ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult) std::shared_ptr aShapePtr = ModelAPI_Tools::shape(theResult); TopoDS_Shape aShape = aShapePtr->impl(); 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& theShapes) { diff --git a/src/ModuleBase/ModuleBase_ResultPrs.h b/src/ModuleBase/ModuleBase_ResultPrs.h index 367d38232..f22cfb1f8 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.h +++ b/src/ModuleBase/ModuleBase_ResultPrs.h @@ -141,6 +141,8 @@ private: void collectSubShapes(BRep_Builder& theBuilder, TopoDS_Shape& theCompound, const TopoDS_Shape& theShape, const NCollection_List& theHiddenSubShapes); + void setEdgesDefaultColor(); + private: /// Reference to result object ResultPtr myResult; -- 2.39.2