From c70d8fefba84e027b077f344aa69c1d6a972f355 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 27 Apr 2017 18:31:42 +0300 Subject: [PATCH] Fix colors of highlighting of symbol constraints --- src/SketcherPrs/SketcherPrs_Collinear.cpp | 2 +- src/SketcherPrs/SketcherPrs_Equal.cpp | 10 ++-------- src/SketcherPrs/SketcherPrs_HVDirection.cpp | 2 +- src/SketcherPrs/SketcherPrs_Middle.cpp | 6 +++--- src/SketcherPrs/SketcherPrs_Mirror.cpp | 6 +++--- src/SketcherPrs/SketcherPrs_Parallel.cpp | 2 +- src/SketcherPrs/SketcherPrs_Perpendicular.cpp | 2 +- src/SketcherPrs/SketcherPrs_Rigid.cpp | 7 +------ src/SketcherPrs/SketcherPrs_SymbolPrs.cpp | 20 +++++++++++++++---- src/SketcherPrs/SketcherPrs_SymbolPrs.h | 4 ++-- src/SketcherPrs/SketcherPrs_Tangent.cpp | 10 ++-------- .../SketcherPrs_Transformation.cpp | 8 +++----- 12 files changed, 36 insertions(+), 43 deletions(-) diff --git a/src/SketcherPrs/SketcherPrs_Collinear.cpp b/src/SketcherPrs/SketcherPrs_Collinear.cpp index ac28d6436..336ece321 100755 --- a/src/SketcherPrs/SketcherPrs_Collinear.cpp +++ b/src/SketcherPrs/SketcherPrs_Collinear.cpp @@ -63,7 +63,7 @@ bool SketcherPrs_Collinear::updateIfReadyToDisplay(double theStep, bool withColo void SketcherPrs_Collinear::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const { - Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePrs); Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2); diff --git a/src/SketcherPrs/SketcherPrs_Equal.cpp b/src/SketcherPrs/SketcherPrs_Equal.cpp index fde149687..9141b161f 100644 --- a/src/SketcherPrs/SketcherPrs_Equal.cpp +++ b/src/SketcherPrs/SketcherPrs_Equal.cpp @@ -64,24 +64,18 @@ bool SketcherPrs_Equal::updateIfReadyToDisplay(double theStep, bool withColor) c void SketcherPrs_Equal::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const { - Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); - - Handle(Graphic3d_AspectLine3d) aLineAspect = - new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2); - aGroup->SetPrimitivesAspect(aLineAspect); - // Draw first line ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A()); std::shared_ptr aLine = SketcherPrs_Tools::getShape(aObj); if (aLine.get() == NULL) return; - drawShape(aLine, thePrs); + drawShape(aLine, thePrs, theColor); // Draw second line aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B()); aLine = SketcherPrs_Tools::getShape(aObj); if (aLine.get() == NULL) return; - drawShape(aLine, thePrs); + drawShape(aLine, thePrs, theColor); } diff --git a/src/SketcherPrs/SketcherPrs_HVDirection.cpp b/src/SketcherPrs/SketcherPrs_HVDirection.cpp index 552da1a6c..6c2ea1e49 100644 --- a/src/SketcherPrs/SketcherPrs_HVDirection.cpp +++ b/src/SketcherPrs/SketcherPrs_HVDirection.cpp @@ -53,7 +53,7 @@ bool SketcherPrs_HVDirection::updateIfReadyToDisplay(double theStep, bool withCo void SketcherPrs_HVDirection::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const { - Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePrs); // Draw constrained object Handle(Graphic3d_AspectLine3d) aLineAspect = diff --git a/src/SketcherPrs/SketcherPrs_Middle.cpp b/src/SketcherPrs/SketcherPrs_Middle.cpp index df7590a1c..c072e1f82 100755 --- a/src/SketcherPrs/SketcherPrs_Middle.cpp +++ b/src/SketcherPrs/SketcherPrs_Middle.cpp @@ -80,7 +80,7 @@ bool SketcherPrs_Middle::updateIfReadyToDisplay(double theStep, bool withColor) void SketcherPrs_Middle::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const { - Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePrs); Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2); @@ -105,13 +105,13 @@ void SketcherPrs_Middle::drawLine(const Handle(Prs3d_Presentation)& thePrs, ResultPtr aResult = aResults.front(); std::shared_ptr aLine = SketcherPrs_Tools::getShape(aResult); if (aLine.get() != NULL) - drawShape(aLine, thePrs); + drawShape(aLine, thePrs, theColor); } } else { std::shared_ptr aLine = SketcherPrs_Tools::getShape(theObject); if (aLine.get() != NULL) - drawShape(aLine, thePrs); + drawShape(aLine, thePrs, theColor); } } diff --git a/src/SketcherPrs/SketcherPrs_Mirror.cpp b/src/SketcherPrs/SketcherPrs_Mirror.cpp index e78dc668e..55215e5ab 100644 --- a/src/SketcherPrs/SketcherPrs_Mirror.cpp +++ b/src/SketcherPrs/SketcherPrs_Mirror.cpp @@ -120,7 +120,7 @@ void SketcherPrs_Mirror::drawLines(const Handle(Prs3d_Presentation)& thePrs, if (aNb != anAttrC->size()) return; - Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePrs); // drawListOfShapes uses myDrawer for attributes definition Handle(Prs3d_LineAspect) aLnAspect = new Prs3d_LineAspect(theColor, Aspect_TOL_SOLID, 1); @@ -130,9 +130,9 @@ void SketcherPrs_Mirror::drawLines(const Handle(Prs3d_Presentation)& thePrs, addLine(aGroup, SketchPlugin_Constraint::ENTITY_A()); // Draw source objects - drawListOfShapes(anAttrB, thePrs); + drawListOfShapes(anAttrB, thePrs, theColor); // draw mirrored objects - drawListOfShapes(anAttrC, thePrs); + drawListOfShapes(anAttrC, thePrs, theColor); } diff --git a/src/SketcherPrs/SketcherPrs_Parallel.cpp b/src/SketcherPrs/SketcherPrs_Parallel.cpp index 770df4e2a..76879ab3c 100644 --- a/src/SketcherPrs/SketcherPrs_Parallel.cpp +++ b/src/SketcherPrs/SketcherPrs_Parallel.cpp @@ -64,7 +64,7 @@ bool SketcherPrs_Parallel::updateIfReadyToDisplay(double theStep, bool withColor void SketcherPrs_Parallel::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const { - Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePrs); Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2); diff --git a/src/SketcherPrs/SketcherPrs_Perpendicular.cpp b/src/SketcherPrs/SketcherPrs_Perpendicular.cpp index 54d263498..8903ce1c7 100644 --- a/src/SketcherPrs/SketcherPrs_Perpendicular.cpp +++ b/src/SketcherPrs/SketcherPrs_Perpendicular.cpp @@ -64,7 +64,7 @@ bool SketcherPrs_Perpendicular::updateIfReadyToDisplay(double theStep, bool with void SketcherPrs_Perpendicular::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const { - Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePrs); Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2); diff --git a/src/SketcherPrs/SketcherPrs_Rigid.cpp b/src/SketcherPrs/SketcherPrs_Rigid.cpp index 8b0ccb425..ba4e53f19 100644 --- a/src/SketcherPrs/SketcherPrs_Rigid.cpp +++ b/src/SketcherPrs/SketcherPrs_Rigid.cpp @@ -116,13 +116,8 @@ void SketcherPrs_Rigid::drawLines(const Handle(Prs3d_Presentation)& thePrs, if (aShape.get() == NULL) return; - Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); - Handle(Graphic3d_AspectLine3d) aLineAspect = - new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2); - aGroup->SetPrimitivesAspect(aLineAspect); - Handle(Prs3d_PointAspect) aPntAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, theColor, 1); myDrawer->SetPointAspect(aPntAspect); - drawShape(aShape, thePrs); + drawShape(aShape, thePrs, theColor); } diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp index 2dfcc68f3..195547813 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -194,7 +195,6 @@ void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, void SketcherPrs_SymbolPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, const SelectMgr_SequenceOfOwner& theOwners) { - Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( thePM ); aSelectionPrs->Clear(); drawLines(aSelectionPrs, GetContext()->SelectionStyle()->Color()); @@ -310,8 +310,17 @@ void SketcherPrs_SymbolPrs::SetCustomColor(const std::vector& theColor) //********************************************************************************* void SketcherPrs_SymbolPrs::drawShape(const std::shared_ptr& theShape, - const Handle(Prs3d_Presentation)& thePrs) const + const Handle(Prs3d_Presentation)& thePrs, + Quantity_Color theColor) const { + Handle(Graphic3d_AspectLine3d) aLineAspect = + new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2); + + Handle(Prs3d_LineAspect) aLinesStyle = myDrawer->LineAspect(); + Handle(Graphic3d_AspectLine3d) aOldStyle = aLinesStyle->Aspect(); + aLinesStyle->SetAspect(aLineAspect); + myDrawer->SetLineAspect(aLinesStyle); + if (theShape->isEdge()) { // The shape is edge std::shared_ptr aCurve = @@ -335,12 +344,15 @@ void SketcherPrs_SymbolPrs::drawShape(const std::shared_ptr& theS Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl()); StdPrs_Point::Add(thePrs, aPoint, myDrawer); } + + aLinesStyle->SetAspect(aOldStyle); + myDrawer->SetLineAspect(aLinesStyle); } //********************************************************************************* void SketcherPrs_SymbolPrs::drawListOfShapes( const std::shared_ptr& theListAttr, - const Handle(Prs3d_Presentation)& thePrs) const + const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const { int aNb = theListAttr->size(); if (aNb == 0) @@ -351,7 +363,7 @@ void SketcherPrs_SymbolPrs::drawListOfShapes( aObj = theListAttr->object(i); std::shared_ptr aShape = SketcherPrs_Tools::getShape(aObj); if (aShape.get() != NULL) - drawShape(aShape, thePrs); + drawShape(aShape, thePrs, theColor); } } diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.h b/src/SketcherPrs/SketcherPrs_SymbolPrs.h index c672b4ea7..83eba27ea 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.h +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.h @@ -117,13 +117,13 @@ protected: /// \param theShape the shape to draw /// \param thePrs the presentation scene void drawShape(const std::shared_ptr& theShape, - const Handle(Prs3d_Presentation)& thePrs) const; + const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const; /// Draw a list of shapes stored in a RefListAttribute /// \param theListAttr the attribute of reference3s list /// \param thePrs the presentation scene void drawListOfShapes(const std::shared_ptr& theListAttr, - const Handle(Prs3d_Presentation)& thePrs) const; + const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const; protected: /// Constraint feature diff --git a/src/SketcherPrs/SketcherPrs_Tangent.cpp b/src/SketcherPrs/SketcherPrs_Tangent.cpp index 7704d95cf..403fffee0 100644 --- a/src/SketcherPrs/SketcherPrs_Tangent.cpp +++ b/src/SketcherPrs/SketcherPrs_Tangent.cpp @@ -67,12 +67,6 @@ bool SketcherPrs_Tangent::updateIfReadyToDisplay(double theStep, bool withColor) void SketcherPrs_Tangent::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const { - Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); - - Handle(Graphic3d_AspectLine3d) aLineAspect = - new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2); - aGroup->SetPrimitivesAspect(aLineAspect); - ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A()); ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B()); @@ -81,7 +75,7 @@ void SketcherPrs_Tangent::drawLines(const Handle(Prs3d_Presentation)& thePrs, if ((aShape1.get() == NULL) || (aShape2.get() == NULL)) return; - drawShape(aShape1, thePrs); - drawShape(aShape2, thePrs); + drawShape(aShape1, thePrs, theColor); + drawShape(aShape2, thePrs, theColor); } diff --git a/src/SketcherPrs/SketcherPrs_Transformation.cpp b/src/SketcherPrs/SketcherPrs_Transformation.cpp index 9d6061e26..3ea06f9fa 100644 --- a/src/SketcherPrs/SketcherPrs_Transformation.cpp +++ b/src/SketcherPrs/SketcherPrs_Transformation.cpp @@ -117,13 +117,11 @@ void SketcherPrs_Transformation::drawLines(const Handle(Prs3d_Presentation)& the if (anAttrB.get() == NULL) return; - Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs); - // drawListOfShapes uses myDrawer for attributes definition - Handle(Prs3d_LineAspect) aLnAspect = new Prs3d_LineAspect(theColor, Aspect_TOL_SOLID, 1); - myDrawer->SetLineAspect(aLnAspect); + //Handle(Prs3d_LineAspect) aLnAspect = new Prs3d_LineAspect(theColor, Aspect_TOL_SOLID, 1); + //myDrawer->SetLineAspect(aLnAspect); - drawListOfShapes(anAttrB, thePrs); + drawListOfShapes(anAttrB, thePrs, theColor); if (myConstraint->getKind() == SketchPlugin_MultiTranslation::ID()) { // If it is translation AttributePoint2DPtr aStart = GeomDataAPI_Point2D::getPoint2D(aData, -- 2.39.2