0024856: CLang warnings -Wunused-private-field
[occt.git] / src / AIS / AIS_Point.cxx
... / ...
CommitLineData
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
5//
6// This file is part of Open CASCADE Technology software library.
7//
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#define GER61351 //GG_171199 Enable to set an object RGB color
18// instead a restricted object NameOfColor.
19
20#include <AIS_Point.ixx>
21#include <Aspect_TypeOfLine.hxx>
22#include <Prs3d_Drawer.hxx>
23#include <Prs3d_PointAspect.hxx>
24#include <Graphic3d_Structure.hxx>
25#include <Graphic3d_Group.hxx>
26#include <Quantity_Color.hxx>
27#include <Graphic3d_ArrayOfPoints.hxx>
28#include <Graphic3d_AspectMarker3d.hxx>
29#include <SelectMgr_EntityOwner.hxx>
30#include <SelectBasics_EntityOwner.hxx>
31#include <Select3D_SensitivePoint.hxx>
32#include <StdPrs_Point.hxx>
33#include <Geom_Point.hxx>
34#include <BRepBuilderAPI_MakeVertex.hxx>
35#include <AIS_Drawer.hxx>
36
37#include <AIS_InteractiveContext.hxx>
38//=======================================================================
39//function : AIS_Point
40//purpose :
41//=======================================================================
42AIS_Point::AIS_Point(const Handle(Geom_Point)& aComponent):
43myComponent(aComponent),
44myHasTOM(Standard_False),
45myTOM(Aspect_TOM_PLUS)
46{
47 myHilightMode=-99;
48}
49
50//=======================================================================
51//function : Component
52//purpose :
53//=======================================================================
54
55Handle(Geom_Point) AIS_Point::Component()
56{
57 return myComponent;
58}
59
60//=======================================================================
61//function : SetComponent
62//purpose :
63//=======================================================================
64
65 void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
66{
67 myComponent = aComponent;
68}
69
70//=======================================================================
71//function : Compute
72//purpose :
73//=======================================================================
74void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
75 const Handle(Prs3d_Presentation)& aPresentation,
76 const Standard_Integer aMode)
77{
78 aPresentation->Clear();
79
80 aPresentation->SetInfiniteState(myInfiniteState);
81
82 if (aMode==0)
83 StdPrs_Point::Add(aPresentation,myComponent,myDrawer);
84 else if (aMode== -99)
85 {
86 // Beeurk.. a revoir - rob-25/04/97
87 static Handle(Graphic3d_AspectMarker3d) PtA =
88 new Graphic3d_AspectMarker3d ();
89 PtA->SetType(Aspect_TOM_PLUS);
90 PtA->SetScale(3.);
91 Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
92 TheGroup->SetPrimitivesAspect(PtA);
93 Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
94 aPoint->AddVertex (myComponent->X(),myComponent->Y(),myComponent->Z());
95 TheGroup->AddPrimitiveArray (aPoint);
96 }
97
98}
99
100//=======================================================================
101//function : Compute
102//purpose :
103//=======================================================================
104
105void AIS_Point::Compute(const Handle_Prs3d_Projector& aProjector,
106 const Handle_Geom_Transformation& aTransformation,
107 const Handle_Prs3d_Presentation& aPresentation)
108{
109// Standard_NotImplemented::Raise("AIS_Point::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
110 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
111}
112
113//=======================================================================
114//function : ComputeSelection
115//purpose :
116//=======================================================================
117void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
118 const Standard_Integer /*aMode*/)
119{
120 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10);
121// eown -> SelectBasics_EntityOwner::Set(5);
122 Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown,
123 myComponent->Pnt());
124 aSelection->Add(sp);
125}
126
127//=======================================================================
128//function : SetColor
129//purpose :
130//=======================================================================
131
132void AIS_Point::SetColor(const Quantity_NameOfColor aCol)
133#ifdef GER61351
134{
135 SetColor(Quantity_Color(aCol));
136}
137
138void AIS_Point::SetColor(const Quantity_Color &aCol)
139#endif
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
167
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
217 if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM){
218 myDrawer->PointAspect().Nullify();
219 return;
220 }
221#ifdef GER61351
222 Quantity_Color aCol;
223#else
224 Quantity_NameOfColor aCol;
225#endif
226 Quantity_Color QCO;
227 Aspect_TypeOfMarker aTOM;
228 Standard_Real aScale;
229
230 if(myDrawer->HasLink()){
231 myDrawer->Link()->PointAspect()->Aspect()->Values(QCO,aTOM,aScale);
232 aCol = QCO.Name();
233 }
234 else{
235 aCol = Quantity_NOC_YELLOW;
236 aTOM = Aspect_TOM_PLUS;
237 aScale = 1;
238 }
239 if(hasOwnColor) aCol = myOwnColor;
240 if(myOwnWidth!=0.0) aScale = myOwnWidth;
241 if(myHasTOM) aTOM = myTOM;
242
243
244 if(myDrawer->HasPointAspect()){
245 // CLE
246 // const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
247 Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
248 // ENDCLE
249 PA->SetColor(aCol);
250 PA->SetTypeOfMarker(aTOM);
251 PA->SetScale(aScale);
252 }
253 else
254 myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale));
255}
256