2 // Copyright: Matra-Datavision 1995
3 // File: Select3D_SensitiveEntity.cxx
4 // Created: Mon Mar 13 17:55:29 1995
5 // Author: Robert COUBLANC
10 #include <Select3D_SensitiveEntity.ixx>
11 #include <Precision.hxx>
12 #include <SelectBasics_EntityOwner.hxx>
13 #include <Select3D_Macro.hxx>
15 //=======================================================================
16 //function : Select3D_SensitiveEntity
18 //=======================================================================
20 Select3D_SensitiveEntity::Select3D_SensitiveEntity(const Handle(SelectBasics_EntityOwner)& OwnerId):
21 SelectBasics_SensitiveEntity(OwnerId),
23 mylastdepth(ShortRealLast())
26 //=======================================================================
29 //=======================================================================
31 void Select3D_SensitiveEntity::Project(const Handle(Select3D_Projector)& aPrj)
36 //=======================================================================
39 //=======================================================================
41 Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real X,
42 const Standard_Real Y,
43 const Standard_Real aTol,
46 if (!mylastprj.IsNull())
48 gp_Lin L = mylastprj->Shoot (X, Y);
49 SetLastDepth (ComputeDepth (L));
50 return (mylastdepth > mylastprj->DepthMin()) && (mylastdepth < mylastprj->DepthMax());
54 SetLastDepth (ComputeDepth (gp_Lin())); // how we determine depth without eyeline here?
55 return (mylastdepth > ShortRealFirst()) && (mylastdepth < ShortRealLast());
59 //=======================================================================
62 //=======================================================================
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)
70 return Standard_False;
73 //=======================================================================
76 //=======================================================================
78 Standard_Boolean Select3D_SensitiveEntity::Matches(const TColgp_Array1OfPnt2d& aPoly,
79 const Bnd_Box2d& aBox,
80 const Standard_Real aTol)
82 return Standard_False;
85 //=======================================================================
88 //=======================================================================
90 void Select3D_SensitiveEntity::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
92 S<<"\tSensitive Entity 3D"<<endl;
95 //=======================================================================
98 //=======================================================================
100 void Select3D_SensitiveEntity::DumpBox(Standard_OStream& S,const Bnd_Box2d& b2d)
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;
111 //=======================================================================
112 //function : ResetLocation
114 //=======================================================================
116 void Select3D_SensitiveEntity::ResetLocation()
120 //=======================================================================
121 //function : SetLocation
123 //=======================================================================
125 void Select3D_SensitiveEntity::SetLocation(const TopLoc_Location&)
129 //=======================================================================
130 //function : UpdateLocation
132 //=======================================================================
134 void Select3D_SensitiveEntity::UpdateLocation(const TopLoc_Location& aLoc)
136 if(aLoc.IsIdentity() || aLoc == Location()) return;
140 TopLoc_Location compLoc = aLoc * Location();
141 SetLocation(compLoc);}
144 //=======================================================================
145 //function : Location
147 //=======================================================================
149 const TopLoc_Location& Select3D_SensitiveEntity::Location() const
151 static TopLoc_Location anIdentity;
152 Handle(SelectBasics_EntityOwner) anOwner = OwnerId();
153 return anOwner.IsNull() ? anIdentity : anOwner->Location();
156 //=======================================================================
157 //function : HasLocation
159 //=======================================================================
161 Standard_Boolean Select3D_SensitiveEntity::HasLocation() const
163 Handle(SelectBasics_EntityOwner) anOwner = OwnerId();
164 return (!anOwner.IsNull() && anOwner->HasLocation());
167 //=======================================================================
170 //=======================================================================
172 Standard_Boolean Select3D_SensitiveEntity::Is3D() const
173 {return Standard_True;}
175 //=======================================================================
178 //=======================================================================
180 Standard_Real Select3D_SensitiveEntity::Depth() const
181 {return mylastdepth;}
183 //=======================================================================
184 //function : GetEyeLine
186 //=======================================================================
188 gp_Lin Select3D_SensitiveEntity::GetEyeLine(const Standard_Real X,
189 const Standard_Real Y) const
192 if (!mylastprj.IsNull())
194 L = mylastprj->Shoot (X, Y);
199 //=======================================================================
200 //function : MaxBoxes
202 //=======================================================================
204 Standard_Integer Select3D_SensitiveEntity::MaxBoxes() const
207 //=======================================================================
208 //function : SetLastPrj
210 //=======================================================================
212 void Select3D_SensitiveEntity::SetLastPrj(const Handle(Select3D_Projector)& aprj)
213 { mylastprj = aprj; }
216 //=======================================================================
217 //function : GetConnected
219 //=======================================================================
221 Handle(Select3D_SensitiveEntity) Select3D_SensitiveEntity::GetConnected(const TopLoc_Location&)
223 Handle(Select3D_SensitiveEntity) NiouEnt;
227 //=======================================================================
228 //function : GetConnected
230 //=======================================================================
231 void Select3D_SensitiveEntity::SetLastDepth(const Standard_Real aDepth)
233 mylastdepth = DToF(aDepth);