0022819: Redesign of OpenGl driver
[occt.git] / src / Select3D / Select3D_SensitiveEntity.cxx
CommitLineData
7fd59977 1
2// Copyright: Matra-Datavision 1995
3// File: Select3D_SensitiveEntity.cxx
4// Created: Mon Mar 13 17:55:29 1995
5// Author: Robert COUBLANC
6// <rob>
7
8
9
10#include <Select3D_SensitiveEntity.ixx>
11#include <Precision.hxx>
12#include <SelectBasics_EntityOwner.hxx>
13#include <Select3D_Macro.hxx>
14
15//=======================================================================
16//function : Select3D_SensitiveEntity
17//purpose :
18//=======================================================================
19
20Select3D_SensitiveEntity::Select3D_SensitiveEntity(const Handle(SelectBasics_EntityOwner)& OwnerId):
21SelectBasics_SensitiveEntity(OwnerId),
4952a30a 22mylastprj(),
23mylastdepth(ShortRealLast())
7fd59977 24{}
25
26//=======================================================================
27//function : Project
28//purpose :
29//=======================================================================
30
4952a30a 31void Select3D_SensitiveEntity::Project(const Handle(Select3D_Projector)& aPrj)
7fd59977 32{
4952a30a 33 mylastprj = aPrj;
7fd59977 34}
35
36//=======================================================================
37//function : Matches
38//purpose :
39//=======================================================================
40
41Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real X,
ac04d101
SA
42 const Standard_Real Y,
43 const Standard_Real aTol,
44 Standard_Real& DMin)
7fd59977 45{
4952a30a 46 if (!mylastprj.IsNull())
47 {
48 gp_Lin L = mylastprj->Shoot (X, Y);
49 SetLastDepth (ComputeDepth (L));
50 return (mylastdepth > mylastprj->DepthMin()) && (mylastdepth < mylastprj->DepthMax());
51 }
52 else
53 {
54 SetLastDepth (ComputeDepth (gp_Lin())); // how we determine depth without eyeline here?
55 return (mylastdepth > ShortRealFirst()) && (mylastdepth < ShortRealLast());
56 }
7fd59977 57}
58
59//=======================================================================
60//function : Matches
61//purpose :
62//=======================================================================
63
64Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real XMin,
ac04d101
SA
65 const Standard_Real YMin,
66 const Standard_Real XMax,
67 const Standard_Real YMax,
68 const Standard_Real aTol)
7fd59977 69{
70 return Standard_False;
71}
72
73//=======================================================================
74//function : Matches
75//purpose :
76//=======================================================================
77
78Standard_Boolean Select3D_SensitiveEntity::Matches(const TColgp_Array1OfPnt2d& aPoly,
ac04d101
SA
79 const Bnd_Box2d& aBox,
80 const Standard_Real aTol)
7fd59977 81{
82 return Standard_False;
83}
84
85//=======================================================================
86//function : Dump
87//purpose :
88//=======================================================================
89
90void Select3D_SensitiveEntity::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
91{
92 S<<"\tSensitive Entity 3D"<<endl;
93}
94
95//=======================================================================
96//function : DumpBox
97//purpose :
98//=======================================================================
99
100void Select3D_SensitiveEntity::DumpBox(Standard_OStream& S,const Bnd_Box2d& b2d)
101{
ac04d101
SA
102 if(!b2d.IsVoid())
103 {
7fd59977 104 Standard_Real xmin,ymin,xmax,ymax;
105 b2d.Get(xmin,ymin,xmax,ymax);
106 S<<"\t\t\tBox2d: PMIN ["<<xmin<<" , "<<ymin<<"]"<<endl;
107 S<<"\t\t\t PMAX ["<<xmax<<" , "<<ymax<<"]"<<endl;
108 }
7fd59977 109}
110
111//=======================================================================
112//function : ResetLocation
113//purpose :
114//=======================================================================
115
116void Select3D_SensitiveEntity::ResetLocation()
117{
118}
119
120//=======================================================================
121//function : SetLocation
122//purpose :
123//=======================================================================
124
125void Select3D_SensitiveEntity::SetLocation(const TopLoc_Location&)
126{
127}
128
129//=======================================================================
130//function : UpdateLocation
131//purpose :
132//=======================================================================
133
134void Select3D_SensitiveEntity::UpdateLocation(const TopLoc_Location& aLoc)
135{
136 if(aLoc.IsIdentity() || aLoc == Location()) return;
137 if(!HasLocation())
138 SetLocation(aLoc);
ac04d101
SA
139 else
140 {
7fd59977 141 TopLoc_Location compLoc = aLoc * Location();
ac04d101
SA
142 SetLocation(compLoc);
143 }
7fd59977 144}
145
146//=======================================================================
147//function : Location
148//purpose :
149//=======================================================================
150
151const TopLoc_Location& Select3D_SensitiveEntity::Location() const
152{
153 static TopLoc_Location anIdentity;
154 Handle(SelectBasics_EntityOwner) anOwner = OwnerId();
155 return anOwner.IsNull() ? anIdentity : anOwner->Location();
156}
157
158//=======================================================================
159//function : HasLocation
160//purpose :
161//=======================================================================
162
163Standard_Boolean Select3D_SensitiveEntity::HasLocation() const
164{
165 Handle(SelectBasics_EntityOwner) anOwner = OwnerId();
166 return (!anOwner.IsNull() && anOwner->HasLocation());
167}
168
169//=======================================================================
170//function : Is3D
171//purpose :
172//=======================================================================
173
174Standard_Boolean Select3D_SensitiveEntity::Is3D() const
175{return Standard_True;}
176
177//=======================================================================
178//function : Depth
179//purpose :
180//=======================================================================
181
182Standard_Real Select3D_SensitiveEntity::Depth() const
183{return mylastdepth;}
184
185//=======================================================================
186//function : GetEyeLine
187//purpose :
188//=======================================================================
189
190gp_Lin Select3D_SensitiveEntity::GetEyeLine(const Standard_Real X,
ac04d101 191 const Standard_Real Y) const
7fd59977 192{
193 gp_Lin L;
4952a30a 194 if (!mylastprj.IsNull())
195 {
196 L = mylastprj->Shoot (X, Y);
197 }
7fd59977 198 return L;
199}
200
201//=======================================================================
202//function : MaxBoxes
203//purpose :
204//=======================================================================
205
206Standard_Integer Select3D_SensitiveEntity::MaxBoxes() const
207{return 1;}
208
209//=======================================================================
210//function : SetLastPrj
211//purpose :
212//=======================================================================
213
4952a30a 214void Select3D_SensitiveEntity::SetLastPrj(const Handle(Select3D_Projector)& aprj)
215{ mylastprj = aprj; }
7fd59977 216
217
218//=======================================================================
219//function : GetConnected
220//purpose :
221//=======================================================================
222
223Handle(Select3D_SensitiveEntity) Select3D_SensitiveEntity::GetConnected(const TopLoc_Location&)
224{
225 Handle(Select3D_SensitiveEntity) NiouEnt;
226 return NiouEnt;
227}
228
229//=======================================================================
ac04d101 230//function : SetLastDepth
7fd59977 231//purpose :
232//=======================================================================
233void Select3D_SensitiveEntity::SetLastDepth(const Standard_Real aDepth)
234{
235 mylastdepth = DToF(aDepth);
236}