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.
18 #include <AIS_InteractiveContext.hxx>
19 #include <AIS_Point.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)
54 //=======================================================================
55 //function : Component
57 //=======================================================================
59 Handle(Geom_Point) AIS_Point::Component()
64 //=======================================================================
65 //function : SetComponent
67 //=======================================================================
69 void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
71 myComponent = aComponent;
74 //=======================================================================
77 //=======================================================================
78 void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
79 const Handle(Prs3d_Presentation)& aPresentation,
80 const Standard_Integer aMode)
82 aPresentation->Clear();
84 aPresentation->SetInfiniteState(myInfiniteState);
87 StdPrs_Point::Add(aPresentation,myComponent,myDrawer);
90 Handle(Graphic3d_AspectMarker3d) PtA = new Graphic3d_AspectMarker3d ();
91 PtA->SetType(Aspect_TOM_PLUS);
93 Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
94 TheGroup->SetPrimitivesAspect(PtA);
95 Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
96 aPoint->AddVertex (myComponent->X(),myComponent->Y(),myComponent->Z());
97 TheGroup->AddPrimitiveArray (aPoint);
102 //=======================================================================
105 //=======================================================================
107 void AIS_Point::Compute(const Handle(Prs3d_Projector)& aProjector,
108 const Handle(Geom_Transformation)& aTransformation,
109 const Handle(Prs3d_Presentation)& aPresentation)
111 // Standard_NotImplemented::Raise("AIS_Point::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
112 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
115 //=======================================================================
116 //function : ComputeSelection
118 //=======================================================================
119 void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
120 const Standard_Integer /*aMode*/)
122 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10);
123 // eown -> SelectBasics_EntityOwner::Set(5);
124 Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown,
129 //=======================================================================
130 //function : SetColor
132 //=======================================================================
134 void AIS_Point::SetColor(const Quantity_NameOfColor aCol)
136 SetColor(Quantity_Color(aCol));
139 void AIS_Point::SetColor(const Quantity_Color &aCol)
141 hasOwnColor=Standard_True;
146 //=======================================================================
147 //function : UnsetColor
149 //=======================================================================
150 void AIS_Point::UnsetColor()
152 hasOwnColor=Standard_False;
157 //=======================================================================
160 //=======================================================================
161 TopoDS_Vertex AIS_Point::Vertex() const
163 gp_Pnt P = myComponent->Pnt();
164 return BRepBuilderAPI_MakeVertex(P);
168 //=======================================================================
170 //purpose : to avoid warning
171 //=======================================================================
172 void AIS_Point::Compute(const Handle(Prs3d_Projector)&,
173 const Handle(Prs3d_Presentation)&)
177 //=======================================================================
178 //function : SetMarker
180 //=======================================================================
182 void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
185 myHasTOM = Standard_True;
189 //=======================================================================
190 //function : UnsetMarker
192 //=======================================================================
193 void AIS_Point::UnsetMarker()
195 myHasTOM = Standard_False;
199 //=======================================================================
200 //function : AcceptDisplayMode
202 //=======================================================================
204 Standard_Boolean AIS_Point::
205 AcceptDisplayMode(const Standard_Integer aMode) const
209 //=======================================================================
210 //function : UpdatePointValues
212 //=======================================================================
214 void AIS_Point::UpdatePointValues()
217 if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM)
219 myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
224 Aspect_TypeOfMarker aTOM;
225 Standard_Real aScale;
227 if(myDrawer->HasLink()){
228 myDrawer->Link()->PointAspect()->Aspect()->Values(QCO,aTOM,aScale);
232 aCol = Quantity_NOC_YELLOW;
233 aTOM = Aspect_TOM_PLUS;
236 if(hasOwnColor) aCol = myOwnColor;
237 if(myOwnWidth!=0.0) aScale = myOwnWidth;
238 if(myHasTOM) aTOM = myTOM;
241 if(myDrawer->HasOwnPointAspect()){
243 // const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
244 Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
247 PA->SetTypeOfMarker(aTOM);
248 PA->SetScale(aScale);
251 myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale));