summaryrefslogtreecommitdiff
path: root/src/Select3D/Select3D_SensitiveEntity.cxx
blob: 1303a5a8d354d4800544880546cba50bd4cf5118 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234

// Copyright: 	Matra-Datavision 1995
// File:	Select3D_SensitiveEntity.cxx
// Created:	Mon Mar 13 17:55:29 1995
// Author:	Robert COUBLANC
//		<rob>



#include <Select3D_SensitiveEntity.ixx>
#include <Precision.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <Select3D_Macro.hxx>

//=======================================================================
//function : Select3D_SensitiveEntity
//purpose  : 
//=======================================================================

Select3D_SensitiveEntity::Select3D_SensitiveEntity(const Handle(SelectBasics_EntityOwner)& OwnerId):
SelectBasics_SensitiveEntity(OwnerId),
mylastprj(),
mylastdepth(ShortRealLast())
{}

//=======================================================================
//function : Project
//purpose  : 
//=======================================================================

void Select3D_SensitiveEntity::Project(const Handle(Select3D_Projector)& aPrj)
{
  mylastprj = aPrj;
}

//=======================================================================
//function : Matches
//purpose  : 
//=======================================================================

Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real X,
						   const Standard_Real Y,
						   const Standard_Real aTol,
						   Standard_Real&  DMin)
{
  if (!mylastprj.IsNull())
  {
    gp_Lin L = mylastprj->Shoot (X, Y);
    SetLastDepth (ComputeDepth (L));
    return (mylastdepth > mylastprj->DepthMin()) && (mylastdepth < mylastprj->DepthMax());
  }
  else
  {
    SetLastDepth (ComputeDepth (gp_Lin())); // how we determine depth without eyeline here?
    return (mylastdepth > ShortRealFirst()) && (mylastdepth < ShortRealLast());
  }
}

//=======================================================================
//function : Matches
//purpose  : 
//=======================================================================

Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real XMin,
						   const Standard_Real YMin,
						   const Standard_Real XMax,
						   const Standard_Real YMax,
						   const Standard_Real aTol)
{
  return Standard_False;
}

//=======================================================================
//function : Matches
//purpose  : 
//=======================================================================

Standard_Boolean Select3D_SensitiveEntity::Matches(const TColgp_Array1OfPnt2d& aPoly,
						   const Bnd_Box2d& aBox,
						   const Standard_Real aTol)
{
  return Standard_False;
}

//=======================================================================
//function : Dump
//purpose  : 
//=======================================================================

void Select3D_SensitiveEntity::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
{
  S<<"\tSensitive Entity 3D"<<endl;
}

//=======================================================================
//function : DumpBox
//purpose  : 
//=======================================================================

void Select3D_SensitiveEntity::DumpBox(Standard_OStream& S,const Bnd_Box2d& b2d) 
{
  if(!b2d.IsVoid()){
    Standard_Real xmin,ymin,xmax,ymax;
    b2d.Get(xmin,ymin,xmax,ymax);
    S<<"\t\t\tBox2d: PMIN ["<<xmin<<" , "<<ymin<<"]"<<endl;
    S<<"\t\t\t       PMAX ["<<xmax<<" , "<<ymax<<"]"<<endl;
  }
  
}

//=======================================================================
//function : ResetLocation
//purpose  : 
//=======================================================================

void Select3D_SensitiveEntity::ResetLocation()
{
}

//=======================================================================
//function : SetLocation
//purpose  : 
//=======================================================================

void Select3D_SensitiveEntity::SetLocation(const TopLoc_Location&)
{
}

//=======================================================================
//function : UpdateLocation
//purpose  : 
//=======================================================================

void Select3D_SensitiveEntity::UpdateLocation(const TopLoc_Location& aLoc)
{
  if(aLoc.IsIdentity() || aLoc == Location()) return;
  if(!HasLocation())
    SetLocation(aLoc);
  else {
    TopLoc_Location compLoc = aLoc * Location();
    SetLocation(compLoc);}
}

//=======================================================================
//function : Location
//purpose  : 
//=======================================================================

const TopLoc_Location& Select3D_SensitiveEntity::Location() const 
{
  static TopLoc_Location anIdentity;	
  Handle(SelectBasics_EntityOwner) anOwner = OwnerId();
  return anOwner.IsNull() ? anIdentity : anOwner->Location();
}

//=======================================================================
//function : HasLocation
//purpose  : 
//=======================================================================

Standard_Boolean Select3D_SensitiveEntity::HasLocation() const
{ 
  Handle(SelectBasics_EntityOwner) anOwner = OwnerId();
  return (!anOwner.IsNull() && anOwner->HasLocation());
}

//=======================================================================
//function : Is3D
//purpose  : 
//=======================================================================

Standard_Boolean Select3D_SensitiveEntity::Is3D() const
{return Standard_True;}

//=======================================================================
//function : Depth
//purpose  : 
//=======================================================================

Standard_Real Select3D_SensitiveEntity::Depth() const
{return mylastdepth;}

//=======================================================================
//function : GetEyeLine
//purpose  : 
//=======================================================================

gp_Lin Select3D_SensitiveEntity::GetEyeLine(const Standard_Real X,
					    const Standard_Real Y) const
{
  gp_Lin L;
  if (!mylastprj.IsNull())
  {
    L = mylastprj->Shoot (X, Y);
  }
  return L;
}

//=======================================================================
//function : MaxBoxes
//purpose  : 
//=======================================================================

Standard_Integer Select3D_SensitiveEntity::MaxBoxes() const 
{return 1;}

//=======================================================================
//function : SetLastPrj
//purpose  : 
//=======================================================================

void Select3D_SensitiveEntity::SetLastPrj(const Handle(Select3D_Projector)& aprj)
{ mylastprj = aprj; }


//=======================================================================
//function : GetConnected
//purpose  : 
//=======================================================================

Handle(Select3D_SensitiveEntity) Select3D_SensitiveEntity::GetConnected(const TopLoc_Location&)  
{
  Handle(Select3D_SensitiveEntity) NiouEnt;
  return NiouEnt;
}

//=======================================================================
//function : GetConnected
//purpose  : 
//=======================================================================
void Select3D_SensitiveEntity::SetLastDepth(const Standard_Real aDepth)
{
  mylastdepth = DToF(aDepth);
}