From f82a9bc2556561838b08e0d320eba7d0fe3945c8 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 20 Dec 2016 18:26:23 +0300 Subject: [PATCH] Provide selection with color --- src/SketcherPrs/SketcherPrs_SymbolPrs.cpp | 43 ++++++++++------------- src/SketcherPrs/SketcherPrs_SymbolPrs.h | 4 +-- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp index be1fef2d0..37841f4b1 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp @@ -33,12 +33,7 @@ #include #include #include -#include -//#include -#include -//#include #include -#include #ifdef WIN32 # define FSEP "\\" @@ -52,10 +47,10 @@ static const double MyDist = 0.02; //************************************************************** //! Redefinition of OpenGl_Element -class SketcherPrs_Element: public OpenGl_PrimitiveArray +class SketcherPrs_SymbolArray: public OpenGl_PrimitiveArray { public: - SketcherPrs_Element(const OpenGl_GraphicDriver* theDriver, + SketcherPrs_SymbolArray(const OpenGl_GraphicDriver* theDriver, const Handle(SketcherPrs_SymbolPrs)& theObj) :OpenGl_PrimitiveArray(theDriver, theObj->myPntArray->Type(), theObj->myPntArray->Indices(), theObj->myPntArray->Attributes(), theObj->myPntArray->Bounds()), myObj(theObj) {} @@ -173,6 +168,8 @@ void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, std::shared_ptr aPnt1 = aEdge->firstPoint(); std::shared_ptr aPnt2 = aEdge->lastPoint(); + gp_Pnt aP1 = aPnt1->impl(); + gp_Pnt aP2 = aPnt2->impl(); // Draw line by two points Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments(2, 1); @@ -183,32 +180,30 @@ void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, //********************************************************************************* void SketcherPrs_SymbolPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, - const SelectMgr_SequenceOfOwner& theOwners) + const SelectMgr_SequenceOfOwner& theOwners) { Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( thePM ); aSelectionPrs->Clear(); - drawLines(aSelectionPrs, Quantity_NOC_WHITE); + drawLines(aSelectionPrs, GetContext()->SelectionStyle()->Color()); aSelectionPrs->SetDisplayPriority(9); aSelectionPrs->Display(); - // PORTING_TO_SALOME_8 - //thePM->Highlight(this); + thePM->Color(this, GetContext()->SelectionStyle()); } //********************************************************************************* void SketcherPrs_SymbolPrs::HilightOwnerWithColor( - const Handle(PrsMgr_PresentationManager3d)& thePM, - const Handle(Graphic3d_HighlightStyle)& theStyle, - const Handle(SelectMgr_EntityOwner)& theOwner) + const Handle(PrsMgr_PresentationManager3d)& thePM, + const Handle(Graphic3d_HighlightStyle)& theStyle, + const Handle(SelectMgr_EntityOwner)& theOwner) { - // PORTING_TO_SALOME_8 - thePM->Color(this, theStyle); Handle( Prs3d_Presentation ) aHilightPrs = GetHilightPresentation( thePM ); aHilightPrs->Clear(); drawLines(aHilightPrs, theStyle->Color()); + aHilightPrs->SetZLayer (Graphic3d_ZLayerId_Topmost); if (thePM->IsImmediateModeOn()) thePM->AddToImmediateList(aHilightPrs); @@ -216,9 +211,9 @@ void SketcherPrs_SymbolPrs::HilightOwnerWithColor( //********************************************************************************* void SketcherPrs_SymbolPrs::Compute( - const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, - const Handle(Prs3d_Presentation)& thePresentation, - const Standard_Integer theMode) + const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode) { // Create an icon prepareAspect(); @@ -260,8 +255,8 @@ void SketcherPrs_SymbolPrs::Compute( } // Pint the group with custom procedure (see Render) - SketcherPrs_Element* aElem = - new SketcherPrs_Element((OpenGl_GraphicDriver*)aDriver->This(), this); + SketcherPrs_SymbolArray* aElem = + new SketcherPrs_SymbolArray((OpenGl_GraphicDriver*)aDriver->This(), this); aGroup->AddElement(aElem); // Disable frustum culling for this object by marking it as mutable @@ -334,8 +329,8 @@ void SketcherPrs_SymbolPrs::drawShape(const std::shared_ptr& theS //********************************************************************************* void SketcherPrs_SymbolPrs::drawListOfShapes( - const std::shared_ptr& theListAttr, - const Handle(Prs3d_Presentation)& thePrs) const + const std::shared_ptr& theListAttr, + const Handle(Prs3d_Presentation)& thePrs) const { int aNb = theListAttr->size(); if (aNb == 0) @@ -351,7 +346,7 @@ void SketcherPrs_SymbolPrs::drawListOfShapes( } //********************************************************************************* -void SketcherPrs_SymbolPrs::BoundingBox (Bnd_Box& theBndBox) +void SketcherPrs_SymbolPrs::BoundingBox(Bnd_Box& theBndBox) { Select3D_BndBox3d aTmpBox; for (Select3D_EntitySequenceIter aPntIter (mySPoints); aPntIter.More(); aPntIter.Next()) { diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.h b/src/SketcherPrs/SketcherPrs_SymbolPrs.h index 91ab4a27c..affd9d074 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.h +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.h @@ -29,7 +29,7 @@ class OpenGl_Context; DEFINE_STANDARD_HANDLE(SketcherPrs_SymbolPrs, AIS_InteractiveObject) -class SketcherPrs_Element; +class SketcherPrs_SymbolArray; /** * \ingroup GUI * A base class of constraint presentation which is represented by an icon @@ -153,7 +153,7 @@ private: Handle(Image_AlienPixMap) myErrorIcon; Handle(Graphic3d_MarkerImage) myErrorImage; - friend class SketcherPrs_Element; + friend class SketcherPrs_SymbolArray; }; #endif \ No newline at end of file -- 2.39.2