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 | |
20 | Select3D_SensitiveEntity::Select3D_SensitiveEntity(const Handle(SelectBasics_EntityOwner)& OwnerId): |
21 | SelectBasics_SensitiveEntity(OwnerId), |
4952a30a |
22 | mylastprj(), |
23 | mylastdepth(ShortRealLast()) |
7fd59977 |
24 | {} |
25 | |
26 | //======================================================================= |
27 | //function : Project |
28 | //purpose : |
29 | //======================================================================= |
30 | |
4952a30a |
31 | void 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 | |
41 | Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real X, |
42 | const Standard_Real Y, |
43 | const Standard_Real aTol, |
44 | Standard_Real& DMin) |
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 | |
64 | Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real XMin, |
65 | const Standard_Real YMin, |
66 | const Standard_Real XMax, |
67 | const Standard_Real YMax, |
68 | const Standard_Real aTol) |
69 | { |
70 | return Standard_False; |
71 | } |
72 | |
73 | //======================================================================= |
74 | //function : Matches |
75 | //purpose : |
76 | //======================================================================= |
77 | |
78 | Standard_Boolean Select3D_SensitiveEntity::Matches(const TColgp_Array1OfPnt2d& aPoly, |
79 | const Bnd_Box2d& aBox, |
80 | const Standard_Real aTol) |
81 | { |
82 | return Standard_False; |
83 | } |
84 | |
85 | //======================================================================= |
86 | //function : Dump |
87 | //purpose : |
88 | //======================================================================= |
89 | |
90 | void 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 | |
100 | void Select3D_SensitiveEntity::DumpBox(Standard_OStream& S,const Bnd_Box2d& b2d) |
101 | { |
102 | if(!b2d.IsVoid()){ |
103 | Standard_Real xmin,ymin,xmax,ymax; |
104 | b2d.Get(xmin,ymin,xmax,ymax); |
105 | S<<"\t\t\tBox2d: PMIN ["<<xmin<<" , "<<ymin<<"]"<<endl; |
106 | S<<"\t\t\t PMAX ["<<xmax<<" , "<<ymax<<"]"<<endl; |
107 | } |
108 | |
109 | } |
110 | |
111 | //======================================================================= |
112 | //function : ResetLocation |
113 | //purpose : |
114 | //======================================================================= |
115 | |
116 | void Select3D_SensitiveEntity::ResetLocation() |
117 | { |
118 | } |
119 | |
120 | //======================================================================= |
121 | //function : SetLocation |
122 | //purpose : |
123 | //======================================================================= |
124 | |
125 | void Select3D_SensitiveEntity::SetLocation(const TopLoc_Location&) |
126 | { |
127 | } |
128 | |
129 | //======================================================================= |
130 | //function : UpdateLocation |
131 | //purpose : |
132 | //======================================================================= |
133 | |
134 | void Select3D_SensitiveEntity::UpdateLocation(const TopLoc_Location& aLoc) |
135 | { |
136 | if(aLoc.IsIdentity() || aLoc == Location()) return; |
137 | if(!HasLocation()) |
138 | SetLocation(aLoc); |
139 | else { |
140 | TopLoc_Location compLoc = aLoc * Location(); |
141 | SetLocation(compLoc);} |
142 | } |
143 | |
144 | //======================================================================= |
145 | //function : Location |
146 | //purpose : |
147 | //======================================================================= |
148 | |
149 | const TopLoc_Location& Select3D_SensitiveEntity::Location() const |
150 | { |
151 | static TopLoc_Location anIdentity; |
152 | Handle(SelectBasics_EntityOwner) anOwner = OwnerId(); |
153 | return anOwner.IsNull() ? anIdentity : anOwner->Location(); |
154 | } |
155 | |
156 | //======================================================================= |
157 | //function : HasLocation |
158 | //purpose : |
159 | //======================================================================= |
160 | |
161 | Standard_Boolean Select3D_SensitiveEntity::HasLocation() const |
162 | { |
163 | Handle(SelectBasics_EntityOwner) anOwner = OwnerId(); |
164 | return (!anOwner.IsNull() && anOwner->HasLocation()); |
165 | } |
166 | |
167 | //======================================================================= |
168 | //function : Is3D |
169 | //purpose : |
170 | //======================================================================= |
171 | |
172 | Standard_Boolean Select3D_SensitiveEntity::Is3D() const |
173 | {return Standard_True;} |
174 | |
175 | //======================================================================= |
176 | //function : Depth |
177 | //purpose : |
178 | //======================================================================= |
179 | |
180 | Standard_Real Select3D_SensitiveEntity::Depth() const |
181 | {return mylastdepth;} |
182 | |
183 | //======================================================================= |
184 | //function : GetEyeLine |
185 | //purpose : |
186 | //======================================================================= |
187 | |
188 | gp_Lin Select3D_SensitiveEntity::GetEyeLine(const Standard_Real X, |
189 | const Standard_Real Y) const |
190 | { |
191 | gp_Lin L; |
4952a30a |
192 | if (!mylastprj.IsNull()) |
193 | { |
194 | L = mylastprj->Shoot (X, Y); |
195 | } |
7fd59977 |
196 | return L; |
197 | } |
198 | |
199 | //======================================================================= |
200 | //function : MaxBoxes |
201 | //purpose : |
202 | //======================================================================= |
203 | |
204 | Standard_Integer Select3D_SensitiveEntity::MaxBoxes() const |
205 | {return 1;} |
206 | |
207 | //======================================================================= |
208 | //function : SetLastPrj |
209 | //purpose : |
210 | //======================================================================= |
211 | |
4952a30a |
212 | void Select3D_SensitiveEntity::SetLastPrj(const Handle(Select3D_Projector)& aprj) |
213 | { mylastprj = aprj; } |
7fd59977 |
214 | |
215 | |
216 | //======================================================================= |
217 | //function : GetConnected |
218 | //purpose : |
219 | //======================================================================= |
220 | |
221 | Handle(Select3D_SensitiveEntity) Select3D_SensitiveEntity::GetConnected(const TopLoc_Location&) |
222 | { |
223 | Handle(Select3D_SensitiveEntity) NiouEnt; |
224 | return NiouEnt; |
225 | } |
226 | |
227 | //======================================================================= |
228 | //function : GetConnected |
229 | //purpose : |
230 | //======================================================================= |
231 | void Select3D_SensitiveEntity::SetLastDepth(const Standard_Real aDepth) |
232 | { |
233 | mylastdepth = DToF(aDepth); |
234 | } |