1 // Copyright (C) 2017-2019 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 <Prs3d_Root.hxx>
31 #include <Graphic3d_ArrayOfPoints.hxx>
32 #include <AIS_InteractiveContext.hxx>
35 IMPLEMENT_STANDARD_RTTIEXT(PartSet_CenterPrs, AIS_Point)
38 PartSet_CenterPrs::PartSet_CenterPrs(const ObjectPtr& theObject,
39 const GeomEdgePtr& theEdge,
40 const gp_Pnt& theCenter,
41 ModelAPI_AttributeSelection::CenterType theType)
42 : AIS_Point(new Geom_CartesianPoint(theCenter)),
47 SetAutoHilight(Standard_False);
50 void PartSet_CenterPrs::drawPoint(const Handle(Prs3d_Presentation)& thePrs,
51 Quantity_Color theColor)
53 Handle(Prs3d_Drawer) aDrawer = HilightAttributes();
55 Handle(Prs3d_PointAspect) aPntAspect = aDrawer->PointAspect();
57 Handle(Graphic3d_AspectMarker3d) PtA = aPntAspect->Aspect();
58 PtA->SetType(Aspect_TOM_RING1);
59 PtA->SetColor(theColor);
61 Handle(Geom_Point) aPnt = Component();
62 Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(thePrs);
63 TheGroup->SetPrimitivesAspect(PtA);
65 Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
66 aPoint->AddVertex(aPnt->X(),aPnt->Y(),aPnt->Z());
67 TheGroup->AddPrimitiveArray(aPoint);
69 PtA = new Graphic3d_AspectMarker3d();
70 PtA->SetType(Aspect_TOM_POINT);
72 PtA->SetColor(theColor);
73 TheGroup->SetPrimitivesAspect(PtA);
74 TheGroup->AddPrimitiveArray (aPoint);
77 void PartSet_CenterPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& PM,
78 const SelectMgr_SequenceOfOwner& Seq)
80 Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( PM );
81 aSelectionPrs->Clear();
83 drawPoint(aSelectionPrs, GetContext()->SelectionStyle()->Color());
85 aSelectionPrs->SetDisplayPriority(9);
86 aSelectionPrs->Display();
87 PM->Color(this, GetContext()->SelectionStyle());
90 void PartSet_CenterPrs::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM,
91 const Handle(Prs3d_Drawer)& theStyle,
92 const Handle(SelectMgr_EntityOwner)& theOwner)
94 Handle( Prs3d_Presentation ) aHilightPrs = GetHilightPresentation( thePM );
97 thePM->Color(this, theStyle);
98 drawPoint(aHilightPrs, theStyle->Color());
100 aHilightPrs->SetZLayer(Graphic3d_ZLayerId_Topmost);
102 if (thePM->IsImmediateModeOn())
103 thePM->AddToImmediateList(aHilightPrs);