1 // Created on: 1995-08-09
2 // Created by: Arnaud BOUZY/Odile Olivier
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <AIS_Point.hxx>
19 #include <AIS_InteractiveContext.hxx>
20 #include <Aspect_TypeOfLine.hxx>
21 #include <BRepBuilderAPI_MakeVertex.hxx>
22 #include <Geom_Point.hxx>
23 #include <Geom_Transformation.hxx>
24 #include <Graphic3d_ArrayOfPoints.hxx>
25 #include <Graphic3d_AspectMarker3d.hxx>
26 #include <Graphic3d_Group.hxx>
27 #include <Graphic3d_Structure.hxx>
28 #include <Prs3d_Drawer.hxx>
29 #include <Prs3d_PointAspect.hxx>
30 #include <Prs3d_Presentation.hxx>
31 #include <Prs3d_Projector.hxx>
32 #include <Quantity_Color.hxx>
33 #include <Select3D_SensitivePoint.hxx>
34 #include <SelectBasics_EntityOwner.hxx>
35 #include <SelectMgr_EntityOwner.hxx>
36 #include <Standard_Type.hxx>
37 #include <StdPrs_Point.hxx>
38 #include <TopoDS_Vertex.hxx>
40 IMPLEMENT_STANDARD_RTTIEXT(AIS_Point,AIS_InteractiveObject)
42 //=======================================================================
43 //function : AIS_Point
45 //=======================================================================
46 AIS_Point::AIS_Point(const Handle(Geom_Point)& aComponent):
47 myComponent(aComponent),
48 myHasTOM(Standard_False),
49 myTOM(Aspect_TOM_PLUS)
51 myHilightDrawer = new Prs3d_Drawer();
52 myHilightDrawer->SetDisplayMode (-99);
53 myHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_GRAY80, 3.0));
54 myHilightDrawer->SetColor (Quantity_NOC_GRAY80);
55 myHilightDrawer->SetZLayer (Graphic3d_ZLayerId_UNKNOWN);
56 myDynHilightDrawer = new Prs3d_Drawer();
57 myDynHilightDrawer->SetDisplayMode (-99);
58 myDynHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 3.0));
59 myDynHilightDrawer->SetColor (Quantity_NOC_CYAN1);
60 myDynHilightDrawer->SetZLayer (Graphic3d_ZLayerId_Top);
63 //=======================================================================
64 //function : Component
66 //=======================================================================
68 Handle(Geom_Point) AIS_Point::Component()
73 //=======================================================================
74 //function : SetComponent
76 //=======================================================================
78 void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
80 myComponent = aComponent;
83 //=======================================================================
86 //=======================================================================
87 void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
88 const Handle(Prs3d_Presentation)& aPresentation,
89 const Standard_Integer aMode)
91 aPresentation->SetInfiniteState(myInfiniteState);
94 StdPrs_Point::Add(aPresentation,myComponent,myDrawer);
97 Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
98 TheGroup->SetPrimitivesAspect (myHilightDrawer->PointAspect()->Aspect());
99 Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
100 aPoint->AddVertex (myComponent->X(),myComponent->Y(),myComponent->Z());
101 TheGroup->AddPrimitiveArray (aPoint);
106 //=======================================================================
109 //=======================================================================
111 void AIS_Point::Compute(const Handle(Prs3d_Projector)& aProjector,
112 const Handle(Geom_Transformation)& aTransformation,
113 const Handle(Prs3d_Presentation)& aPresentation)
115 // throw Standard_NotImplemented("AIS_Point::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
116 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
119 //=======================================================================
120 //function : ComputeSelection
122 //=======================================================================
123 void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
124 const Standard_Integer /*aMode*/)
126 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10);
127 // eown -> SelectBasics_EntityOwner::Set(5);
128 Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown,
133 //=======================================================================
134 //function : SetColor
136 //=======================================================================
137 void AIS_Point::SetColor (const Quantity_Color& theCol)
139 hasOwnColor=Standard_True;
140 myDrawer->SetColor (theCol);
144 //=======================================================================
145 //function : UnsetColor
147 //=======================================================================
148 void AIS_Point::UnsetColor()
150 hasOwnColor=Standard_False;
155 //=======================================================================
158 //=======================================================================
159 TopoDS_Vertex AIS_Point::Vertex() const
161 gp_Pnt P = myComponent->Pnt();
162 return BRepBuilderAPI_MakeVertex(P);
166 //=======================================================================
168 //purpose : to avoid warning
169 //=======================================================================
170 void AIS_Point::Compute(const Handle(Prs3d_Projector)&,
171 const Handle(Prs3d_Presentation)&)
175 //=======================================================================
176 //function : SetMarker
178 //=======================================================================
180 void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
183 myHasTOM = Standard_True;
187 //=======================================================================
188 //function : UnsetMarker
190 //=======================================================================
191 void AIS_Point::UnsetMarker()
193 myHasTOM = Standard_False;
197 //=======================================================================
198 //function : AcceptDisplayMode
200 //=======================================================================
202 Standard_Boolean AIS_Point::AcceptDisplayMode (const Standard_Integer theMode) const
208 //=======================================================================
209 //function : replaceWithNewPointAspect
211 //=======================================================================
212 void AIS_Point::replaceWithNewPointAspect (const Handle(Prs3d_PointAspect)& theAspect)
214 if (!myDrawer->HasLink())
216 myDrawer->SetPointAspect (theAspect);
220 const Handle(Graphic3d_AspectMarker3d) anAspectOld = myDrawer->PointAspect()->Aspect();
221 const Handle(Graphic3d_AspectMarker3d) anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->PointAspect()->Aspect();
222 if (anAspectNew != anAspectOld)
224 myDrawer->SetPointAspect (theAspect);
225 Graphic3d_MapOfAspectsToAspects aReplaceMap;
226 aReplaceMap.Bind (anAspectOld, anAspectNew);
227 replaceAspects (aReplaceMap);
231 //=======================================================================
232 //function : UpdatePointValues
234 //=======================================================================
236 void AIS_Point::UpdatePointValues()
239 && myOwnWidth == 0.0f
242 replaceWithNewPointAspect (Handle(Prs3d_PointAspect)());
246 Quantity_Color aCol (Quantity_NOC_YELLOW);
247 Aspect_TypeOfMarker aTOM = Aspect_TOM_PLUS;
248 Standard_Real aScale = 1.0;
249 if (myDrawer->HasLink())
251 aCol = myDrawer->Link()->PointAspect()->Aspect()->Color();
252 aTOM = myDrawer->Link()->PointAspect()->Aspect()->Type();
253 aScale = myDrawer->Link()->PointAspect()->Aspect()->Scale();
256 if(hasOwnColor) aCol = myDrawer->Color();
257 if(myOwnWidth != 0.0f) aScale = myOwnWidth;
258 if(myHasTOM) aTOM = myTOM;
260 if(myDrawer->HasOwnPointAspect())
262 Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
264 PA->SetTypeOfMarker(aTOM);
265 PA->SetScale(aScale);
266 SynchronizeAspects();
270 replaceWithNewPointAspect (new Prs3d_PointAspect (aTOM, aCol, aScale));