0026886: Visualization, TKV3d - eliminate global variables
[occt.git] / src / AIS / AIS_Point.cxx
CommitLineData
b311480e 1// Created on: 1995-08-09
2// Created by: Arnaud BOUZY/Odile Olivier
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
18#include <AIS_InteractiveContext.hxx>
19#include <AIS_Point.hxx>
7fd59977 20#include <Aspect_TypeOfLine.hxx>
42cf5bc1 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>
7fd59977 28#include <Prs3d_Drawer.hxx>
29#include <Prs3d_PointAspect.hxx>
42cf5bc1 30#include <Prs3d_Presentation.hxx>
31#include <Prs3d_Projector.hxx>
7fd59977 32#include <Quantity_Color.hxx>
7fd59977 33#include <Select3D_SensitivePoint.hxx>
42cf5bc1 34#include <SelectBasics_EntityOwner.hxx>
35#include <SelectMgr_EntityOwner.hxx>
36#include <Standard_Type.hxx>
7fd59977 37#include <StdPrs_Point.hxx>
42cf5bc1 38#include <TopoDS_Vertex.hxx>
7fd59977 39
92efcf78 40IMPLEMENT_STANDARD_RTTIEXT(AIS_Point,AIS_InteractiveObject)
41
7fd59977 42//=======================================================================
43//function : AIS_Point
44//purpose :
45//=======================================================================
46AIS_Point::AIS_Point(const Handle(Geom_Point)& aComponent):
47myComponent(aComponent),
48myHasTOM(Standard_False),
49myTOM(Aspect_TOM_PLUS)
50{
51 myHilightMode=-99;
52}
53
54//=======================================================================
55//function : Component
56//purpose :
57//=======================================================================
58
59Handle(Geom_Point) AIS_Point::Component()
60{
61 return myComponent;
62}
63
64//=======================================================================
65//function : SetComponent
66//purpose :
67//=======================================================================
68
69 void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
70{
71 myComponent = aComponent;
72}
73
74//=======================================================================
75//function : Compute
76//purpose :
77//=======================================================================
78void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
79 const Handle(Prs3d_Presentation)& aPresentation,
80 const Standard_Integer aMode)
81{
82 aPresentation->Clear();
83
84 aPresentation->SetInfiniteState(myInfiniteState);
85
86 if (aMode==0)
87 StdPrs_Point::Add(aPresentation,myComponent,myDrawer);
88 else if (aMode== -99)
89 {
016e5959 90 Handle(Graphic3d_AspectMarker3d) PtA = new Graphic3d_AspectMarker3d ();
7fd59977 91 PtA->SetType(Aspect_TOM_PLUS);
92 PtA->SetScale(3.);
93 Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
94 TheGroup->SetPrimitivesAspect(PtA);
a577aaab 95 Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
96 aPoint->AddVertex (myComponent->X(),myComponent->Y(),myComponent->Z());
97 TheGroup->AddPrimitiveArray (aPoint);
7fd59977 98 }
99
100}
101
102//=======================================================================
103//function : Compute
104//purpose :
105//=======================================================================
106
857ffd5e 107void AIS_Point::Compute(const Handle(Prs3d_Projector)& aProjector,
108 const Handle(Geom_Transformation)& aTransformation,
109 const Handle(Prs3d_Presentation)& aPresentation)
7fd59977 110{
857ffd5e 111// Standard_NotImplemented::Raise("AIS_Point::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
7fd59977 112 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
113}
114
115//=======================================================================
116//function : ComputeSelection
117//purpose :
118//=======================================================================
119void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
120 const Standard_Integer /*aMode*/)
121{
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,
125 myComponent->Pnt());
126 aSelection->Add(sp);
127}
128
129//=======================================================================
130//function : SetColor
131//purpose :
132//=======================================================================
133
134void AIS_Point::SetColor(const Quantity_NameOfColor aCol)
7fd59977 135{
136 SetColor(Quantity_Color(aCol));
137}
138
139void AIS_Point::SetColor(const Quantity_Color &aCol)
7fd59977 140{
141 hasOwnColor=Standard_True;
142 myOwnColor=aCol;
143 UpdatePointValues();
144}
145
146//=======================================================================
147//function : UnsetColor
148//purpose :
149//=======================================================================
150void AIS_Point::UnsetColor()
151{
152 hasOwnColor=Standard_False;
153 UpdatePointValues();
154}
155
156
157//=======================================================================
158//function : Vertex
159//purpose :
160//=======================================================================
161TopoDS_Vertex AIS_Point::Vertex() const
162{
163 gp_Pnt P = myComponent->Pnt();
164 return BRepBuilderAPI_MakeVertex(P);
165}
166
128cc8df 167
7fd59977 168//=======================================================================
169//function : Compute
170//purpose : to avoid warning
171//=======================================================================
172void AIS_Point::Compute(const Handle(Prs3d_Projector)&,
173 const Handle(Prs3d_Presentation)&)
174{
175}
176
177//=======================================================================
178//function : SetMarker
179//purpose :
180//=======================================================================
181
182void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
183{
184 myTOM = aTOM;
185 myHasTOM = Standard_True;
186 UpdatePointValues();
187}
188
189//=======================================================================
190//function : UnsetMarker
191//purpose :
192//=======================================================================
193void AIS_Point::UnsetMarker()
194{
195 myHasTOM = Standard_False;
196 UpdatePointValues();
197}
198
199//=======================================================================
200//function : AcceptDisplayMode
201//purpose :
202//=======================================================================
203
204 Standard_Boolean AIS_Point::
205AcceptDisplayMode(const Standard_Integer aMode) const
206{return aMode == 0;}
207
208
209//=======================================================================
210//function : UpdatePointValues
211//purpose :
212//=======================================================================
213
214void AIS_Point::UpdatePointValues()
215{
216
6262338c 217 if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM)
218 {
219 myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
7fd59977 220 return;
221 }
7fd59977 222 Quantity_Color aCol;
7fd59977 223 Quantity_Color QCO;
224 Aspect_TypeOfMarker aTOM;
225 Standard_Real aScale;
226
227 if(myDrawer->HasLink()){
228 myDrawer->Link()->PointAspect()->Aspect()->Values(QCO,aTOM,aScale);
229 aCol = QCO.Name();
230 }
231 else{
232 aCol = Quantity_NOC_YELLOW;
233 aTOM = Aspect_TOM_PLUS;
234 aScale = 1;
235 }
236 if(hasOwnColor) aCol = myOwnColor;
237 if(myOwnWidth!=0.0) aScale = myOwnWidth;
238 if(myHasTOM) aTOM = myTOM;
239
240
6262338c 241 if(myDrawer->HasOwnPointAspect()){
7fd59977 242 // CLE
243 // const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
244 Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
245 // ENDCLE
246 PA->SetColor(aCol);
247 PA->SetTypeOfMarker(aTOM);
248 PA->SetScale(aScale);
249 }
250 else
251 myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale));
252}
253