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 <SelectMgr_EntityOwner.hxx>
35 #include <Standard_Type.hxx>
36 #include <StdPrs_Point.hxx>
37 #include <TopoDS_Vertex.hxx>
39 IMPLEMENT_STANDARD_RTTIEXT(AIS_Point,AIS_InteractiveObject)
41 //=======================================================================
42 //function : AIS_Point
44 //=======================================================================
45 AIS_Point::AIS_Point(const Handle(Geom_Point)& aComponent):
46 myComponent(aComponent),
47 myHasTOM(Standard_False),
48 myTOM(Aspect_TOM_PLUS)
50 myHilightDrawer = new Prs3d_Drawer();
51 myHilightDrawer->SetDisplayMode (-99);
52 myHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_GRAY80, 3.0));
53 myHilightDrawer->SetColor (Quantity_NOC_GRAY80);
54 myHilightDrawer->SetZLayer (Graphic3d_ZLayerId_UNKNOWN);
55 myDynHilightDrawer = new Prs3d_Drawer();
56 myDynHilightDrawer->SetDisplayMode (-99);
57 myDynHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 3.0));
58 myDynHilightDrawer->SetColor (Quantity_NOC_CYAN1);
59 myDynHilightDrawer->SetZLayer (Graphic3d_ZLayerId_Top);
62 //=======================================================================
63 //function : Component
65 //=======================================================================
67 Handle(Geom_Point) AIS_Point::Component()
72 //=======================================================================
73 //function : SetComponent
75 //=======================================================================
77 void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
79 myComponent = aComponent;
82 //=======================================================================
85 //=======================================================================
86 void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
87 const Handle(Prs3d_Presentation)& aPresentation,
88 const Standard_Integer aMode)
90 aPresentation->SetInfiniteState(myInfiniteState);
93 StdPrs_Point::Add(aPresentation,myComponent,myDrawer);
96 Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
97 TheGroup->SetPrimitivesAspect (myHilightDrawer->PointAspect()->Aspect());
98 Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
99 aPoint->AddVertex (myComponent->X(),myComponent->Y(),myComponent->Z());
100 TheGroup->AddPrimitiveArray (aPoint);
105 //=======================================================================
108 //=======================================================================
110 void AIS_Point::Compute(const Handle(Prs3d_Projector)& aProjector,
111 const Handle(Geom_Transformation)& aTransformation,
112 const Handle(Prs3d_Presentation)& aPresentation)
114 // throw Standard_NotImplemented("AIS_Point::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
115 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
118 //=======================================================================
119 //function : ComputeSelection
121 //=======================================================================
122 void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
123 const Standard_Integer /*aMode*/)
125 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10);
126 Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown,
131 //=======================================================================
132 //function : SetColor
134 //=======================================================================
135 void AIS_Point::SetColor (const Quantity_Color& theCol)
137 hasOwnColor=Standard_True;
138 myDrawer->SetColor (theCol);
142 //=======================================================================
143 //function : UnsetColor
145 //=======================================================================
146 void AIS_Point::UnsetColor()
148 hasOwnColor=Standard_False;
153 //=======================================================================
156 //=======================================================================
157 TopoDS_Vertex AIS_Point::Vertex() const
159 gp_Pnt P = myComponent->Pnt();
160 return BRepBuilderAPI_MakeVertex(P);
164 //=======================================================================
166 //purpose : to avoid warning
167 //=======================================================================
168 void AIS_Point::Compute(const Handle(Prs3d_Projector)&,
169 const Handle(Prs3d_Presentation)&)
173 //=======================================================================
174 //function : SetMarker
176 //=======================================================================
178 void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
181 myHasTOM = Standard_True;
185 //=======================================================================
186 //function : UnsetMarker
188 //=======================================================================
189 void AIS_Point::UnsetMarker()
191 myHasTOM = Standard_False;
195 //=======================================================================
196 //function : AcceptDisplayMode
198 //=======================================================================
200 Standard_Boolean AIS_Point::AcceptDisplayMode (const Standard_Integer theMode) const
206 //=======================================================================
207 //function : replaceWithNewPointAspect
209 //=======================================================================
210 void AIS_Point::replaceWithNewPointAspect (const Handle(Prs3d_PointAspect)& theAspect)
212 if (!myDrawer->HasLink())
214 myDrawer->SetPointAspect (theAspect);
218 const Handle(Graphic3d_AspectMarker3d) anAspectOld = myDrawer->PointAspect()->Aspect();
219 const Handle(Graphic3d_AspectMarker3d) anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->PointAspect()->Aspect();
220 if (anAspectNew != anAspectOld)
222 myDrawer->SetPointAspect (theAspect);
223 Graphic3d_MapOfAspectsToAspects aReplaceMap;
224 aReplaceMap.Bind (anAspectOld, anAspectNew);
225 replaceAspects (aReplaceMap);
229 //=======================================================================
230 //function : UpdatePointValues
232 //=======================================================================
234 void AIS_Point::UpdatePointValues()
237 && myOwnWidth == 0.0f
240 replaceWithNewPointAspect (Handle(Prs3d_PointAspect)());
244 Quantity_Color aCol (Quantity_NOC_YELLOW);
245 Aspect_TypeOfMarker aTOM = Aspect_TOM_PLUS;
246 Standard_Real aScale = 1.0;
247 if (myDrawer->HasLink())
249 aCol = myDrawer->Link()->PointAspect()->Aspect()->Color();
250 aTOM = myDrawer->Link()->PointAspect()->Aspect()->Type();
251 aScale = myDrawer->Link()->PointAspect()->Aspect()->Scale();
254 if(hasOwnColor) aCol = myDrawer->Color();
255 if(myOwnWidth != 0.0f) aScale = myOwnWidth;
256 if(myHasTOM) aTOM = myTOM;
258 if(myDrawer->HasOwnPointAspect())
260 Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
262 PA->SetTypeOfMarker(aTOM);
263 PA->SetScale(aScale);
264 SynchronizeAspects();
268 replaceWithNewPointAspect (new Prs3d_PointAspect (aTOM, aCol, aScale));