1 // Copyright (C) 2017-2022 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: PartSet_CenterPrs.cpp
21 // Created: 25 April 2017
22 // Author: Vitaly SMETANNIKOV
24 #include "PartSet_CenterPrs.h"
26 #include <ModuleBase_Tools.h>
27 #include <Geom_CartesianPoint.hxx>
28 #include <Prs3d_PointAspect.hxx>
29 #include <Graphic3d_AspectMarker3d.hxx>
30 #include <Graphic3d_ArrayOfPoints.hxx>
31 #include <AIS_InteractiveContext.hxx>
34 IMPLEMENT_STANDARD_RTTIEXT(PartSet_CenterPrs, AIS_Point)
37 PartSet_CenterPrs::PartSet_CenterPrs(const ObjectPtr& theObject,
38 const GeomEdgePtr& theEdge,
39 const gp_Pnt& theCenter,
40 ModelAPI_AttributeSelection::CenterType theType)
41 : AIS_Point(new Geom_CartesianPoint(theCenter)),
46 SetAutoHilight(Standard_False);
49 void PartSet_CenterPrs::drawPoint(const Handle(Prs3d_Presentation)& thePrs,
50 Quantity_Color theColor)
52 Handle(Prs3d_Drawer) aDrawer = HilightAttributes();
54 Handle(Prs3d_PointAspect) aPntAspect = aDrawer->PointAspect();
56 Handle(Graphic3d_AspectMarker3d) PtA = aPntAspect->Aspect();
57 PtA->SetType(Aspect_TOM_RING1);
58 PtA->SetColor(theColor);
60 Handle(Geom_Point) aPnt = Component();
61 Handle(Graphic3d_Group) TheGroup = thePrs->CurrentGroup();
62 TheGroup->SetPrimitivesAspect(PtA);
64 Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
65 aPoint->AddVertex(aPnt->X(),aPnt->Y(),aPnt->Z());
66 TheGroup->AddPrimitiveArray(aPoint);
68 PtA = new Graphic3d_AspectMarker3d();
69 PtA->SetType(Aspect_TOM_POINT);
71 PtA->SetColor(theColor);
72 TheGroup->SetPrimitivesAspect(PtA);
73 TheGroup->AddPrimitiveArray (aPoint);
76 void PartSet_CenterPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& PM,
77 const SelectMgr_SequenceOfOwner& /*Seq*/)
79 Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( PM );
80 aSelectionPrs->Clear();
82 drawPoint(aSelectionPrs, GetContext()->SelectionStyle()->Color());
84 aSelectionPrs->SetDisplayPriority(9);
85 aSelectionPrs->Display();
86 PM->Color(this, GetContext()->SelectionStyle());
89 void PartSet_CenterPrs::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM,
90 const Handle(Prs3d_Drawer)& theStyle,
91 const Handle(SelectMgr_EntityOwner)& /*theOwner*/)
93 Handle( Prs3d_Presentation ) aHilightPrs = GetHilightPresentation( thePM );
96 thePM->Color(this, theStyle);
97 drawPoint(aHilightPrs, theStyle->Color());
99 aHilightPrs->SetZLayer(Graphic3d_ZLayerId_Topmost);
101 if (thePM->IsImmediateModeOn())
102 thePM->AddToImmediateList(aHilightPrs);