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)
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;
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;
141 TopLoc_Location compLoc = aLoc * Location();
142 SetLocation(compLoc);
146 //=======================================================================
147 //function : Location
149 //=======================================================================
151 const TopLoc_Location& Select3D_SensitiveEntity::Location() const
153 static TopLoc_Location anIdentity;
154 Handle(SelectBasics_EntityOwner) anOwner = OwnerId();
155 return anOwner.IsNull() ? anIdentity : anOwner->Location();
158 //=======================================================================
159 //function : HasLocation
161 //=======================================================================
163 Standard_Boolean Select3D_SensitiveEntity::HasLocation() const
165 Handle(SelectBasics_EntityOwner) anOwner = OwnerId();
166 return (!anOwner.IsNull() && anOwner->HasLocation());
169 //=======================================================================
172 //=======================================================================
174 Standard_Boolean Select3D_SensitiveEntity::Is3D() const
175 {return Standard_True;}
177 //=======================================================================
180 //=======================================================================
182 Standard_Real Select3D_SensitiveEntity::Depth() const
183 {return mylastdepth;}
185 //=======================================================================
186 //function : GetEyeLine
188 //=======================================================================
190 gp_Lin Select3D_SensitiveEntity::GetEyeLine(const Standard_Real X,
191 const Standard_Real Y) const
194 if (!mylastprj.IsNull())
196 L = mylastprj->Shoot (X, Y);
201 //=======================================================================
202 //function : MaxBoxes
204 //=======================================================================
206 Standard_Integer Select3D_SensitiveEntity::MaxBoxes() const
209 //=======================================================================
210 //function : SetLastPrj
212 //=======================================================================
214 void Select3D_SensitiveEntity::SetLastPrj(const Handle(Select3D_Projector)& aprj)
215 { mylastprj = aprj; }
218 //=======================================================================
219 //function : GetConnected
221 //=======================================================================
223 Handle(Select3D_SensitiveEntity) Select3D_SensitiveEntity::GetConnected(const TopLoc_Location&)
225 Handle(Select3D_SensitiveEntity) NiouEnt;
229 //=======================================================================
230 //function : SetLastDepth
232 //=======================================================================
233 void Select3D_SensitiveEntity::SetLastDepth(const Standard_Real aDepth)
235 mylastdepth = DToF(aDepth);