1 -- Created on: 1995-02-10
2 -- Created by: Mister rmi
3 -- Copyright (c) 1995-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
6 -- The content of this file is subject to the Open CASCADE Technology Public
7 -- License Version 6.5 (the "License"). You may not use the content of this file
8 -- except in compliance with the License. Please obtain a copy of the License
9 -- at http://www.opencascade.org and read it completely before using this file.
11 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 -- The Original Code and all software distributed under the License is
15 -- distributed on an "AS IS" basis, without warranty of any kind, and the
16 -- Initial Developer hereby disclaims all such warranties, including without
17 -- limitation, any warranties of merchantability, fitness for a particular
18 -- purpose or non-infringement. Please see the License for the specific terms
19 -- and conditions governing the rights and limitations under the License.
21 --modified by rob -FEB 01 1996
22 -- -JUL 23 1997 : optimize recompute of selections...
23 -- insert real sleep/awake option....
24 -- -APR 02 1998 : improvment of selection.
25 -- Sort with new Criterions
26 -- (depth + size +...)
27 -- store detected in a best way...
30 deferred class ViewerSelector from SelectMgr inherits TShared from MMgt
32 ---Purpose: A framework to define finding, sorting the sensitive
33 -- primitives in a view. Services are also provided to
34 -- define the return of the owners of those primitives
35 -- selected. The primitives are sorted by criteria such
36 -- as priority of the primitive or its depth in the view
37 -- relative to that of other primitives.
38 -- This framework is undefined for either 2D or 3D,
39 -- and is consequently used by both
40 -- StdSelect_ViewerSelector2d and
41 -- StdSelect_ViewerSelector3d, which inherit it, and
42 -- which in turn, return 2D and 3D owners of sensitive
43 -- primitives respectively.
44 -- Note that in 3D, the inheriting framework
45 -- StdSelect_ViewerSelector3d is only to be used
46 -- if you do not want to use the services provided by
47 -- AIS. In 2D, you will, however, need the services
48 -- provided by the StdSelect_ViewerSelector2d.
49 -- Two tools are available to find and select objects
50 -- found at a given position in the view. If you want to
51 -- select the owners of all the objects detected at
52 -- point x,y, you use the Init - More - Next - Picked
53 -- loop. If, on the other hand, you want to select only
54 -- one object detected at that point, you use the Init -
55 -- More - OnePicked loop. In this iteration, More is
56 -- used to see if an object was picked and
57 -- OnePicked, to get the object closest to the pick position.
58 -- Viewer selectors are driven by
59 -- SelectMgr_SelectionManager, and manipulate
60 -- the SelectMgr_Selection objects given to them by
61 -- the selection manager.
64 AsciiString from TCollection,
65 SelectableObject from SelectMgr,
66 DataMapOfIntegerSensitive from SelectMgr,
67 DataMapOfSelectionActivation from SelectMgr,
68 Selection from SelectMgr,
70 HArray1OfInteger from TColStd,
71 ListOfInteger from TColStd,
72 SequenceOfInteger from TColStd,
73 MapOfTransient from TColStd,
74 IndexedMapOfInteger from TColStd,
75 IndexedDataMapOfOwnerCriterion from SelectMgr,
76 SensitiveEntity from SelectBasics,
77 SortAlgo from SelectBasics,
78 EntityOwner from SelectMgr,
79 StateOfSelection from SelectMgr,
80 Array1OfPnt2d from TColgp
89 Convert (me:mutable;aSelection : mutable Selection from SelectMgr) is virtual;
91 ---Purpose: to be redefined if conversion is necessary for SensitiveEntities...
95 ---Category: Activation/Desactivation Of Selection For Objects
96 -- No general method like "activate a mode (integer) " is possible
97 -- here because objects inside the selection view are of different type
101 Activate (me : mutable;
102 aSelection : Selection from SelectMgr;
103 AutomaticProj : Boolean = Standard_True)
110 ---Category: Management Methods . Some following methods are private
111 -- because they owed to be called only through The Selection Manager !!
113 Clear(me:mutable) is static;
115 ---Purpose: Empties all the tables, removes all selections...
117 UpdateConversion(me :mutable) is static;
119 ---Purpose: converts all the sensitive entities ;
121 Deactivate (me : mutable;
122 aSelection : Selection from SelectMgr)
126 Sleep (me:mutable) is static private;
128 ---Purpose: Desactivates all the objects of the view;
129 -- no object in this view will be selectable;
131 Awake (me :mutable;AutomaticProj : Boolean = Standard_True) is static private;
133 ---Purpose: reactivates all the selection which were sleeping....
136 anObject : SelectableObject from SelectMgr) is static private;
139 anObject : SelectableObject from SelectMgr;
140 AutomaticProj : Boolean = Standard_True) is static private;
143 Remove(me:mutable ; aSelection: Selection from SelectMgr) is static private;
145 ---Purpose: removes a Selection from the Selector
149 ---Category: SELECTION OPERATIONS
150 ------------=====================
152 SetSensitivity (me : mutable ; aTol:Real) is static;
154 ---Purpose: changes the Sensitivity of picking
155 -- Input value is Real.
157 Sensitivity (me) returns Real from Standard;
159 ---Purpose: returns the Sensitivity of picking
162 SetClipping(me:mutable ; Xc,Yc,Height,Width:Real) is static;
164 ---Purpose: sets the clipping limits of dynamic picking
165 -- input value are Real
167 SetClipping(me:mutable ; aRectangle : Box2d from Bnd) is static;
169 ---Purpose: sets the clipping limits of dynamic picking
170 -- input value are Real
175 InitSelect (me : mutable ; Xr,Yr : Real) is static;
177 ---Purpose: Performs a pick action. Xr, Yr are the real 2D mouse
178 -- coordinates in the view. The selector looks for areas
179 -- and owners that are touched.
181 InitSelect (me : mutable ; aRect: Box2d from Bnd) is static;
183 ---Purpose: Performs a pick action. aRect is a Box2d (real
184 -- coordinates) for the selection. The selector looks for
185 -- areas and owners that are touched.
187 InitSelect (me : mutable ; Xmin,Ymin,Xmax,Ymax: Real) is static;
188 ---Purpose: Performs a pick action
189 -- - Xmin, Ymin define the coordinates of the minimum
190 -- point in the lower left hand corner of the selection
191 -- box, and XMax, YMax define the coordinates of
192 -- the maximum point in the upper right hand corner
193 -- of the selection box. The selector looks for areas
194 -- and owners that are touched.
196 InitSelect (me : mutable ; Polyline:Array1OfPnt2d from TColgp) is static;
198 ---Purpose: pick action - input values of a polyline selection for selection.
203 ---Category: RESULT OF SELECTION...
204 -- 2 Methods : *all the detected objects are given
205 -- (use More - Next - Picked loop)
206 -- *only one is wanted :
207 -- (use More to know if something was picked and OnePicked
208 -- to get the closest object of pick position).
212 SortResult(me:mutable) is virtual;
213 ---Purpose: Sorts the detected entites by priority and distance.
214 -- to be redefined if other criterion are used...
216 Init(me:mutable) is static;
217 ---Purpose: Begins an iteration scanning for the owners detected at a position in the view.
220 More(me:mutable) returns Boolean from Standard is static;
221 ---Purpose: Continues the interation scanning for the owners
222 -- detected at a position in the view, or
223 -- - continues the iteration scanning for the owner
224 -- closest to the position in the view.
226 Next(me:mutable) is static;
227 ---Purpose: Returns the next owner found in the iteration. This is
228 -- a scan for the owners detected at a position in the view.
232 Picked(me) returns any EntityOwner is static;
234 ---Purpose: Returns the current selected entity detected by the selector;
237 OnePicked(me:mutable) returns any EntityOwner is static;
238 ---Purpose: Returns the picked element with the highest priority,
239 -- and which is the closest to the last successful mouse position.
241 SetPickClosest(me: mutable; preferClosest: Boolean);
242 ---Purpose: Set preference of selecting one object for OnePicked() method:
243 -- - If True, objects with less depth (distance fron the view plane) are
244 -- preferred regardless of priority (priority is used then to choose among
245 -- objects with similar depth),
246 -- - If False, objects with higher priority are preferred regardless of the
247 -- depth which is used to choose among objects of the same priority.
251 NbPicked(me) returns Integer from Standard;
252 ---Purpose: Returns the number of owners found at a position in
253 -- the view by the Init - More - Next - Picked iteration.
255 Picked(me;aRank:Integer from Standard)
256 returns any EntityOwner from SelectMgr;
257 ---Purpose: Returns the entity which is at rank <aRank>
258 -- in the list of stored ones.
261 HasStored (me:mutable) returns Boolean is static;
263 ---Purpose: Returns True if a successful pick was stored,
264 -- i.e. LastPosition method means something...
266 LastPosition (me; Xr,Yr : out Real ) is static;
268 ---Purpose: Gives the last successful pick position;
269 -- is useful to get objects really picked
275 ---Category: INFORMATION ABOUT OBJECTS IN THE VIEWER SELECTOR
278 Contains (me;aSelectableObject: SelectableObject from SelectMgr)
279 returns Boolean is static;
283 aSelectableObject:SelectableObject from SelectMgr;
284 ModeList : in out ListOfInteger from TColStd;
285 WantedState : StateOfSelection from SelectMgr = SelectMgr_SOS_Any) returns Boolean;
286 ---Purpose: Returns the list of selection modes ModeList found in
287 -- this selector for the selectable object aSelectableObject.
288 -- Returns true if aSelectableObject is referenced inside
289 -- this selector; returns false if the object is not present
292 IsActive (me;aSelectableObject:SelectableObject;aMode:Integer) returns Boolean is static ;
293 ---Purpose: Returns true if the selectable object
294 -- aSelectableObject having the selection mode aMode
295 -- is active in this selector.
297 IsInside (me;aSelectableObject:SelectableObject;aMode:Integer) returns Boolean is static ;
298 ---Purpose: Returns true if the selectable object
299 -- aSelectableObject having the selection mode aMode
300 -- is in this selector.
302 Status (me;aSelection :Selection from SelectMgr) returns StateOfSelection from SelectMgr;
303 ---Purpose: Returns the selection status Status of the selection aSelection.
305 Dump(me;S : in out OStream from Standard);
308 Status (me;aSelectableObject:SelectableObject) returns AsciiString from TCollection is static;
310 Status (me) returns AsciiString from TCollection is static;
312 ---Purpose: gives general information about the Selector
320 ---Category: Internal Methods
323 NbBoxes(me:mutable) returns Integer is static private;
326 UpdateSort (me:mutable) is static;
329 LoadResult (me:mutable) is virtual protected;
332 LoadResult (me:mutable;aBox:Box2d from Bnd) is virtual protected;
335 LoadResult (me:mutable;Polyline:Array1OfPnt2d from TColgp) is virtual protected;
340 Primitive(me;Rank:Integer from Standard)
341 returns SensitiveEntity from SelectBasics;
345 returns DataMapOfIntegerSensitive from SelectMgr;
348 ---C++: return const&
350 SetUpdateSortPossible( me: mutable; possible : Boolean from Standard );
351 IsUpdateSortPossible( me ) returns Boolean from Standard;
357 myentities : DataMapOfIntegerSensitive is protected;
358 myselections : DataMapOfSelectionActivation is protected;
359 toupdate : Boolean is protected;
360 tosort : Boolean is protected;
361 preferclosest: Boolean is protected;
363 mytolerance : Real is protected;
364 myselector : SortAlgo from SelectBasics is protected;
365 myclip : Box2d from Bnd is protected;
366 myactivenb : Integer;
367 --after selection -results... we sort the list of indexes not the map...
368 mystored : IndexedDataMapOfOwnerCriterion from SelectMgr is protected;
369 myIndexes : HArray1OfInteger from TColStd;
370 myprim : SequenceOfInteger from TColStd; -- for debug only
371 myCurRank : Integer from Standard;
376 myUpdateSortPossible : Boolean from Standard;
379 class SelectionManager from SelectMgr