0023024: Update headers of OCCT files
[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
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22#define GER61351 //GG_171199 Enable to set an object RGB color
23// instead a restricted object NameOfColor.
24
25#include <AIS_Point.ixx>
26#include <Aspect_TypeOfLine.hxx>
27#include <Prs3d_Drawer.hxx>
28#include <Prs3d_PointAspect.hxx>
29#include <Graphic3d_Structure.hxx>
30#include <Graphic3d_Group.hxx>
31#include <Quantity_Color.hxx>
32#include <Graphic3d_Vertex.hxx>
33#include <Graphic3d_AspectMarker3d.hxx>
34#include <SelectMgr_EntityOwner.hxx>
35#include <SelectBasics_EntityOwner.hxx>
36#include <Select3D_SensitivePoint.hxx>
37#include <StdPrs_Point.hxx>
38#include <Geom_Point.hxx>
39#include <BRepBuilderAPI_MakeVertex.hxx>
40#include <AIS_Drawer.hxx>
41
42#include <AIS_InteractiveContext.hxx>
43//=======================================================================
44//function : AIS_Point
45//purpose :
46//=======================================================================
47AIS_Point::AIS_Point(const Handle(Geom_Point)& aComponent):
48myComponent(aComponent),
49myHasTOM(Standard_False),
50myTOM(Aspect_TOM_PLUS)
51{
52 myHilightMode=-99;
53}
54
55//=======================================================================
56//function : Component
57//purpose :
58//=======================================================================
59
60Handle(Geom_Point) AIS_Point::Component()
61{
62 return myComponent;
63}
64
65//=======================================================================
66//function : SetComponent
67//purpose :
68//=======================================================================
69
70 void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
71{
72 myComponent = aComponent;
73}
74
75//=======================================================================
76//function : Compute
77//purpose :
78//=======================================================================
79void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
80 const Handle(Prs3d_Presentation)& aPresentation,
81 const Standard_Integer aMode)
82{
83 aPresentation->Clear();
84
85 aPresentation->SetInfiniteState(myInfiniteState);
86
87 if (aMode==0)
88 StdPrs_Point::Add(aPresentation,myComponent,myDrawer);
89 else if (aMode== -99)
90 {
91 // Beeurk.. a revoir - rob-25/04/97
92 static Handle(Graphic3d_AspectMarker3d) PtA =
93 new Graphic3d_AspectMarker3d ();
94 PtA->SetType(Aspect_TOM_PLUS);
95 PtA->SetScale(3.);
96 Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
97 TheGroup->SetPrimitivesAspect(PtA);
98 Graphic3d_Vertex Vtx(myComponent->X(),myComponent->Y(),myComponent->Z());
99 TheGroup->Marker(Vtx);
100 }
101
102}
103
104//=======================================================================
105//function : Compute
106//purpose :
107//=======================================================================
108
109void AIS_Point::Compute(const Handle_Prs3d_Projector& aProjector,
110 const Handle_Geom_Transformation& aTransformation,
111 const Handle_Prs3d_Presentation& aPresentation)
112{
113// Standard_NotImplemented::Raise("AIS_Point::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
114 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
115}
116
117//=======================================================================
118//function : ComputeSelection
119//purpose :
120//=======================================================================
121void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
122 const Standard_Integer /*aMode*/)
123{
124 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10);
125// eown -> SelectBasics_EntityOwner::Set(5);
126 Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown,
127 myComponent->Pnt());
128 aSelection->Add(sp);
129}
130
131//=======================================================================
132//function : SetColor
133//purpose :
134//=======================================================================
135
136void AIS_Point::SetColor(const Quantity_NameOfColor aCol)
137#ifdef GER61351
138{
139 SetColor(Quantity_Color(aCol));
140}
141
142void AIS_Point::SetColor(const Quantity_Color &aCol)
143#endif
144{
145 hasOwnColor=Standard_True;
146 myOwnColor=aCol;
147 UpdatePointValues();
148}
149
150//=======================================================================
151//function : UnsetColor
152//purpose :
153//=======================================================================
154void AIS_Point::UnsetColor()
155{
156 hasOwnColor=Standard_False;
157 UpdatePointValues();
158}
159
160
161//=======================================================================
162//function : Vertex
163//purpose :
164//=======================================================================
165TopoDS_Vertex AIS_Point::Vertex() const
166{
167 gp_Pnt P = myComponent->Pnt();
168 return BRepBuilderAPI_MakeVertex(P);
169}
170
171//=======================================================================
172//function : Compute
173//purpose : to avoid warning
174//=======================================================================
175void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager2d)&,
176 const Handle(Graphic2d_GraphicObject)&,
177 const Standard_Integer)
178{
179}
180//=======================================================================
181//function : Compute
182//purpose : to avoid warning
183//=======================================================================
184void AIS_Point::Compute(const Handle(Prs3d_Projector)&,
185 const Handle(Prs3d_Presentation)&)
186{
187}
188
189//=======================================================================
190//function : SetMarker
191//purpose :
192//=======================================================================
193
194void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
195{
196 myTOM = aTOM;
197 myHasTOM = Standard_True;
198 UpdatePointValues();
199}
200
201//=======================================================================
202//function : UnsetMarker
203//purpose :
204//=======================================================================
205void AIS_Point::UnsetMarker()
206{
207 myHasTOM = Standard_False;
208 UpdatePointValues();
209}
210
211//=======================================================================
212//function : AcceptDisplayMode
213//purpose :
214//=======================================================================
215
216 Standard_Boolean AIS_Point::
217AcceptDisplayMode(const Standard_Integer aMode) const
218{return aMode == 0;}
219
220
221//=======================================================================
222//function : UpdatePointValues
223//purpose :
224//=======================================================================
225
226void AIS_Point::UpdatePointValues()
227{
228
229 if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM){
230 myDrawer->PointAspect().Nullify();
231 return;
232 }
233#ifdef GER61351
234 Quantity_Color aCol;
235#else
236 Quantity_NameOfColor aCol;
237#endif
238 Quantity_Color QCO;
239 Aspect_TypeOfMarker aTOM;
240 Standard_Real aScale;
241
242 if(myDrawer->HasLink()){
243 myDrawer->Link()->PointAspect()->Aspect()->Values(QCO,aTOM,aScale);
244 aCol = QCO.Name();
245 }
246 else{
247 aCol = Quantity_NOC_YELLOW;
248 aTOM = Aspect_TOM_PLUS;
249 aScale = 1;
250 }
251 if(hasOwnColor) aCol = myOwnColor;
252 if(myOwnWidth!=0.0) aScale = myOwnWidth;
253 if(myHasTOM) aTOM = myTOM;
254
255
256 if(myDrawer->HasPointAspect()){
257 // CLE
258 // const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
259 Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
260 // ENDCLE
261 PA->SetColor(aCol);
262 PA->SetTypeOfMarker(aTOM);
263 PA->SetScale(aScale);
264 }
265 else
266 myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale));
267}
268