0024023: Revamp the OCCT Handle -- ambiguity
[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
7fd59977 17#include <AIS_Point.ixx>
18#include <Aspect_TypeOfLine.hxx>
19#include <Prs3d_Drawer.hxx>
20#include <Prs3d_PointAspect.hxx>
21#include <Graphic3d_Structure.hxx>
22#include <Graphic3d_Group.hxx>
23#include <Quantity_Color.hxx>
a577aaab 24#include <Graphic3d_ArrayOfPoints.hxx>
7fd59977 25#include <Graphic3d_AspectMarker3d.hxx>
26#include <SelectMgr_EntityOwner.hxx>
27#include <SelectBasics_EntityOwner.hxx>
28#include <Select3D_SensitivePoint.hxx>
29#include <StdPrs_Point.hxx>
30#include <Geom_Point.hxx>
31#include <BRepBuilderAPI_MakeVertex.hxx>
7fd59977 32
33#include <AIS_InteractiveContext.hxx>
34//=======================================================================
35//function : AIS_Point
36//purpose :
37//=======================================================================
38AIS_Point::AIS_Point(const Handle(Geom_Point)& aComponent):
39myComponent(aComponent),
40myHasTOM(Standard_False),
41myTOM(Aspect_TOM_PLUS)
42{
43 myHilightMode=-99;
44}
45
46//=======================================================================
47//function : Component
48//purpose :
49//=======================================================================
50
51Handle(Geom_Point) AIS_Point::Component()
52{
53 return myComponent;
54}
55
56//=======================================================================
57//function : SetComponent
58//purpose :
59//=======================================================================
60
61 void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
62{
63 myComponent = aComponent;
64}
65
66//=======================================================================
67//function : Compute
68//purpose :
69//=======================================================================
70void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
71 const Handle(Prs3d_Presentation)& aPresentation,
72 const Standard_Integer aMode)
73{
74 aPresentation->Clear();
75
76 aPresentation->SetInfiniteState(myInfiniteState);
77
78 if (aMode==0)
79 StdPrs_Point::Add(aPresentation,myComponent,myDrawer);
80 else if (aMode== -99)
81 {
82 // Beeurk.. a revoir - rob-25/04/97
83 static Handle(Graphic3d_AspectMarker3d) PtA =
84 new Graphic3d_AspectMarker3d ();
85 PtA->SetType(Aspect_TOM_PLUS);
86 PtA->SetScale(3.);
87 Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
88 TheGroup->SetPrimitivesAspect(PtA);
a577aaab 89 Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
90 aPoint->AddVertex (myComponent->X(),myComponent->Y(),myComponent->Z());
91 TheGroup->AddPrimitiveArray (aPoint);
7fd59977 92 }
93
94}
95
96//=======================================================================
97//function : Compute
98//purpose :
99//=======================================================================
100
857ffd5e 101void AIS_Point::Compute(const Handle(Prs3d_Projector)& aProjector,
102 const Handle(Geom_Transformation)& aTransformation,
103 const Handle(Prs3d_Presentation)& aPresentation)
7fd59977 104{
857ffd5e 105// Standard_NotImplemented::Raise("AIS_Point::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
7fd59977 106 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
107}
108
109//=======================================================================
110//function : ComputeSelection
111//purpose :
112//=======================================================================
113void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
114 const Standard_Integer /*aMode*/)
115{
116 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10);
117// eown -> SelectBasics_EntityOwner::Set(5);
118 Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown,
119 myComponent->Pnt());
120 aSelection->Add(sp);
121}
122
123//=======================================================================
124//function : SetColor
125//purpose :
126//=======================================================================
127
128void AIS_Point::SetColor(const Quantity_NameOfColor aCol)
7fd59977 129{
130 SetColor(Quantity_Color(aCol));
131}
132
133void AIS_Point::SetColor(const Quantity_Color &aCol)
7fd59977 134{
135 hasOwnColor=Standard_True;
136 myOwnColor=aCol;
137 UpdatePointValues();
138}
139
140//=======================================================================
141//function : UnsetColor
142//purpose :
143//=======================================================================
144void AIS_Point::UnsetColor()
145{
146 hasOwnColor=Standard_False;
147 UpdatePointValues();
148}
149
150
151//=======================================================================
152//function : Vertex
153//purpose :
154//=======================================================================
155TopoDS_Vertex AIS_Point::Vertex() const
156{
157 gp_Pnt P = myComponent->Pnt();
158 return BRepBuilderAPI_MakeVertex(P);
159}
160
128cc8df 161
7fd59977 162//=======================================================================
163//function : Compute
164//purpose : to avoid warning
165//=======================================================================
166void AIS_Point::Compute(const Handle(Prs3d_Projector)&,
167 const Handle(Prs3d_Presentation)&)
168{
169}
170
171//=======================================================================
172//function : SetMarker
173//purpose :
174//=======================================================================
175
176void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
177{
178 myTOM = aTOM;
179 myHasTOM = Standard_True;
180 UpdatePointValues();
181}
182
183//=======================================================================
184//function : UnsetMarker
185//purpose :
186//=======================================================================
187void AIS_Point::UnsetMarker()
188{
189 myHasTOM = Standard_False;
190 UpdatePointValues();
191}
192
193//=======================================================================
194//function : AcceptDisplayMode
195//purpose :
196//=======================================================================
197
198 Standard_Boolean AIS_Point::
199AcceptDisplayMode(const Standard_Integer aMode) const
200{return aMode == 0;}
201
202
203//=======================================================================
204//function : UpdatePointValues
205//purpose :
206//=======================================================================
207
208void AIS_Point::UpdatePointValues()
209{
210
6262338c 211 if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM)
212 {
213 myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
7fd59977 214 return;
215 }
7fd59977 216 Quantity_Color aCol;
7fd59977 217 Quantity_Color QCO;
218 Aspect_TypeOfMarker aTOM;
219 Standard_Real aScale;
220
221 if(myDrawer->HasLink()){
222 myDrawer->Link()->PointAspect()->Aspect()->Values(QCO,aTOM,aScale);
223 aCol = QCO.Name();
224 }
225 else{
226 aCol = Quantity_NOC_YELLOW;
227 aTOM = Aspect_TOM_PLUS;
228 aScale = 1;
229 }
230 if(hasOwnColor) aCol = myOwnColor;
231 if(myOwnWidth!=0.0) aScale = myOwnWidth;
232 if(myHasTOM) aTOM = myTOM;
233
234
6262338c 235 if(myDrawer->HasOwnPointAspect()){
7fd59977 236 // CLE
237 // const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
238 Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
239 // ENDCLE
240 PA->SetColor(aCol);
241 PA->SetTypeOfMarker(aTOM);
242 PA->SetScale(aScale);
243 }
244 else
245 myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale));
246}
247