42cf5bc1 |
1 | // Created on: 1996-12-18 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1996-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _AIS_InteractiveContext_HeaderFile |
18 | #define _AIS_InteractiveContext_HeaderFile |
19 | |
42cf5bc1 |
20 | #include <AIS_DataMapOfILC.hxx> |
14c4193d |
21 | #include <AIS_DataMapOfIOStatus.hxx> |
22 | #include <AIS_DisplayMode.hxx> |
42cf5bc1 |
23 | #include <AIS_DisplayStatus.hxx> |
14c4193d |
24 | #include <AIS_ClearMode.hxx> |
42cf5bc1 |
25 | #include <AIS_KindOfInteractive.hxx> |
14c4193d |
26 | #include <AIS_ListOfInteractive.hxx> |
27 | #include <AIS_Selection.hxx> |
42cf5bc1 |
28 | #include <AIS_StatusOfDetection.hxx> |
29 | #include <AIS_StatusOfPick.hxx> |
14c4193d |
30 | #include <AIS_TypeOfIso.hxx> |
31 | #include <Aspect_TypeOfFacingModel.hxx> |
14c4193d |
32 | #include <Prs3d_Drawer.hxx> |
33 | #include <Prs3d_TypeOfHighlight.hxx> |
34 | #include <PrsMgr_PresentationManager3d.hxx> |
42cf5bc1 |
35 | #include <SelectMgr_IndexedMapOfOwner.hxx> |
42cf5bc1 |
36 | #include <SelectMgr_ListOfFilter.hxx> |
14c4193d |
37 | #include <SelectMgr_PickingStrategy.hxx> |
38 | #include <Standard.hxx> |
39 | #include <Standard_Type.hxx> |
40 | #include <StdSelect_ViewerSelector3d.hxx> |
41 | #include <TCollection_AsciiString.hxx> |
42 | #include <TColgp_Array1OfPnt2d.hxx> |
43 | #include <TColStd_ListOfInteger.hxx> |
44 | #include <TopAbs_ShapeEnum.hxx> |
45 | #include <Quantity_Color.hxx> |
46 | |
42cf5bc1 |
47 | class SelectMgr_SelectionManager; |
48 | class V3d_Viewer; |
49 | class AIS_InteractiveObject; |
50 | class SelectMgr_OrFilter; |
51 | class V3d_View; |
52 | class AIS_LocalContext; |
53 | class TopLoc_Location; |
42cf5bc1 |
54 | class TCollection_ExtendedString; |
55 | class Prs3d_LineAspect; |
56 | class Prs3d_BasicAspect; |
42cf5bc1 |
57 | class SelectMgr_EntityOwner; |
42cf5bc1 |
58 | class SelectMgr_Filter; |
59 | class TCollection_AsciiString; |
60 | |
d21ddc4f |
61 | //! The Interactive Context allows you to manage graphic behavior and selection of Interactive Objects in one or more viewers. |
62 | //! Class methods make this highly transparent. |
63 | //! It is essential to remember that an Interactive Object which is already known by the Interactive Context must be modified using Context methods. |
64 | //! You can only directly call the methods available for an Interactive Object if it has not been loaded into an Interactive Context. |
65 | //! |
66 | //! Each selectable object must specify the selection mode that is |
67 | //! responsible for selection of object as a whole (global selection mode). |
68 | //! Interactive context itself supports decomposed object selection with selection filters support. |
69 | //! By default, global selection mode is equal to 0, but it might be redefined if needed. |
2ec85268 |
70 | class AIS_InteractiveContext : public Standard_Transient |
42cf5bc1 |
71 | { |
2ec85268 |
72 | friend class AIS_LocalContext; |
73 | DEFINE_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient) |
d21ddc4f |
74 | public: //! @name object display management |
42cf5bc1 |
75 | |
d21ddc4f |
76 | //! Constructs the interactive context object defined by the principal viewer MainViewer. |
42cf5bc1 |
77 | Standard_EXPORT AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer); |
2ec85268 |
78 | |
79 | //! Destructor. |
80 | Standard_EXPORT virtual ~AIS_InteractiveContext(); |
81 | |
d21ddc4f |
82 | //! Returns the display status of the entity anIobj. |
83 | //! This will be one of the following: |
84 | //! - AIS_DS_Displayed displayed in main viewer |
85 | //! - AIS_DS_Erased hidden in main viewer |
86 | //! - AIS_DS_Temporary temporarily displayed |
87 | //! - AIS_DS_None nowhere displayed. |
88 | Standard_EXPORT AIS_DisplayStatus DisplayStatus (const Handle(AIS_InteractiveObject)& anIobj) const; |
14c4193d |
89 | |
d21ddc4f |
90 | //! Returns the status of the Interactive Context for the view of the Interactive Object. |
91 | Standard_EXPORT void Status (const Handle(AIS_InteractiveObject)& anObj, TCollection_ExtendedString& astatus) const; |
92 | |
93 | //! Returns true if Object is displayed in the interactive context. |
94 | Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(AIS_InteractiveObject)& anIobj) const; |
95 | |
96 | Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(AIS_InteractiveObject)& aniobj, const Standard_Integer aMode) const; |
97 | |
98 | //! Enable or disable automatic activation of default selection mode while displaying the object. |
99 | void SetAutoActivateSelection (const Standard_Boolean theIsAuto) { myIsAutoActivateSelMode = theIsAuto; } |
14c4193d |
100 | |
d21ddc4f |
101 | //! Manages displaying the new object should also automatically activate default selection mode; TRUE by default. |
102 | Standard_Boolean GetAutoActivateSelection() const { return myIsAutoActivateSelMode; } |
103 | |
104 | //! Displays the object in this Context using default Display Mode. |
105 | //! This will be the object's default display mode, if there is one. Otherwise, it will be the context mode. |
106 | //! The Interactive Object's default selection mode is activated if GetAutoActivateSelection() is TRUE. In general, this is 0. |
0577ae8c |
107 | Standard_EXPORT void Display (const Handle(AIS_InteractiveObject)& theIObj, |
108 | const Standard_Boolean theToUpdateViewer); |
d21ddc4f |
109 | |
110 | //! Sets status, display mode and selection mode for specified Object |
111 | //! If theSelectionMode equals -1, theIObj will not be activated: it will be displayed but will not be selectable. |
0577ae8c |
112 | Standard_EXPORT void Display (const Handle(AIS_InteractiveObject)& theIObj, |
113 | const Standard_Integer theDispMode, |
114 | const Standard_Integer theSelectionMode, |
115 | const Standard_Boolean theToUpdateViewer, |
116 | const Standard_Boolean theToAllowDecomposition = Standard_True, |
117 | const AIS_DisplayStatus theDispStatus = AIS_DS_None); |
d21ddc4f |
118 | |
119 | //! Allows you to load the Interactive Object with a given selection mode, |
120 | //! and/or with the desired decomposition option, whether the object is visualized or not. |
121 | //! If AllowDecomp = Standard_True and, if the interactive object is of the "Shape" type, |
122 | //! these "standard" selection modes will be automatically activated as a function of the modes present in the Local Context. |
123 | //! The loaded objects will be selectable but displayable in highlighting only when detected by the Selector. |
42cf5bc1 |
124 | //! This method is available only when Local Contexts are open. |
125 | Standard_EXPORT void Load (const Handle(AIS_InteractiveObject)& aniobj, const Standard_Integer SelectionMode = -1, const Standard_Boolean AllowDecomp = Standard_False); |
d21ddc4f |
126 | |
127 | //! Hides the object. The object's presentations are simply flagged as invisible and therefore excluded from redrawing. |
42cf5bc1 |
128 | //! To show hidden objects, use Display(). |
0577ae8c |
129 | Standard_EXPORT void Erase (const Handle(AIS_InteractiveObject)& theIObj, |
130 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
131 | |
d21ddc4f |
132 | //! Hides all objects. The object's presentations are simply flagged as invisible and therefore excluded from redrawing. |
42cf5bc1 |
133 | //! To show all hidden objects, use DisplayAll(). |
0577ae8c |
134 | Standard_EXPORT void EraseAll (const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
135 | |
136 | //! Displays all hidden objects. |
0577ae8c |
137 | Standard_EXPORT void DisplayAll (const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
138 | |
d21ddc4f |
139 | //! Hides selected objects. The object's presentations are simply flagged as invisible and therefore excluded from redrawing. |
42cf5bc1 |
140 | //! To show hidden objects, use Display(). |
0577ae8c |
141 | Standard_EXPORT void EraseSelected (const Standard_Boolean theToUpdateViewer); |
d21ddc4f |
142 | |
143 | //! Displays current objects. |
0577ae8c |
144 | Standard_EXPORT void DisplaySelected (const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
145 | |
d21ddc4f |
146 | //! Empties the graphic presentation of the mode indexed by aMode. |
147 | //! Warning! Removes theIObj. theIObj is still active if it was previously activated. |
0577ae8c |
148 | Standard_EXPORT void ClearPrs (const Handle(AIS_InteractiveObject)& theIObj, |
149 | const Standard_Integer theMode, |
150 | const Standard_Boolean theToUpdateViewer); |
d21ddc4f |
151 | |
152 | //! Removes Object from every viewer. |
0577ae8c |
153 | Standard_EXPORT void Remove (const Handle(AIS_InteractiveObject)& theIObj, |
154 | const Standard_Boolean theToUpdateViewer); |
d21ddc4f |
155 | |
156 | //! Removes all the objects from all opened Local Contexts and from the Neutral Point. |
0577ae8c |
157 | Standard_EXPORT void RemoveAll (const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
158 | |
d21ddc4f |
159 | //! Recomputes the seen parts presentation of the Object. |
160 | //! If theAllModes equals true, all presentations are present in the object even if unseen. |
161 | Standard_EXPORT void Redisplay (const Handle(AIS_InteractiveObject)& theIObj, |
162 | const Standard_Boolean theToUpdateViewer, |
163 | const Standard_Boolean theAllModes = Standard_False); |
164 | |
165 | //! Recomputes the Prs/Selection of displayed objects of a given type and a given signature. |
166 | //! if signature = -1 doesn't take signature criterion. |
167 | Standard_EXPORT void Redisplay (const AIS_KindOfInteractive theTypeOfObject, |
168 | const Standard_Integer theSignature, |
169 | const Standard_Boolean theToUpdateViewer); |
170 | |
171 | //! Recomputes the displayed presentations, flags the others. |
172 | //! Doesn't update presentations. |
173 | Standard_EXPORT void RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj, |
174 | const Standard_Boolean theToUpdateViewer, |
175 | const Standard_Boolean theAllModes = Standard_False); |
176 | |
177 | //! Recomputes the active selections, flags the others. |
178 | //! Doesn't update presentations. |
179 | Standard_EXPORT void RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& anIObj); |
180 | |
181 | //! Updates displayed interactive object by checking and recomputing its flagged as "to be recomputed" presentation and selection structures. |
182 | //! This method does not force any recomputation on its own. |
183 | //! The method recomputes selections even if they are loaded without activation in particular selector. |
184 | Standard_EXPORT void Update (const Handle(AIS_InteractiveObject)& theIObj, |
185 | const Standard_Boolean theUpdateViewer); |
186 | |
187 | public: //! @name highlighting management |
188 | |
189 | //! Returns highlight style settings. |
190 | const Handle(Prs3d_Drawer)& HighlightStyle (const Prs3d_TypeOfHighlight theStyleType) const { return myStyles[theStyleType]; } |
191 | |
192 | //! Setup highlight style settings. |
193 | void SetHighlightStyle (const Prs3d_TypeOfHighlight theStyleType, |
194 | const Handle(Prs3d_Drawer)& theStyle) { myStyles[theStyleType] = theStyle; } |
195 | |
196 | //! Returns current dynamic highlight style settings. |
197 | //! By default: |
198 | //! - the color of dynamic highlight is Quantity_NOC_CYAN1; |
199 | //! - the presentation for dynamic highlight is completely opaque; |
200 | //! - the type of highlight is Aspect_TOHM_COLOR. |
201 | const Handle(Prs3d_Drawer)& HighlightStyle() const |
202 | { |
203 | return myStyles[Prs3d_TypeOfHighlight_Dynamic]; |
204 | } |
205 | |
206 | //! Setup the style of dynamic highlighting. |
207 | void SetHighlightStyle (const Handle(Prs3d_Drawer)& theStyle) { myStyles[Prs3d_TypeOfHighlight_Dynamic] = theStyle; } |
208 | |
209 | //! Returns current selection style settings. |
210 | //! By default: |
211 | //! - the color of selection is Quantity_NOC_GRAY80; |
212 | //! - the presentation for selection is completely opaque; |
213 | //! - the type of highlight is Aspect_TOHM_COLOR. |
214 | const Handle(Prs3d_Drawer)& SelectionStyle() const |
215 | { |
216 | return myStyles[Prs3d_TypeOfHighlight_Selected]; |
217 | } |
218 | |
219 | //! Setup the style of selection highlighting. |
220 | void SetSelectionStyle (const Handle(Prs3d_Drawer)& theStyle) { myStyles[Prs3d_TypeOfHighlight_Selected] = theStyle; } |
221 | |
222 | //! Returns highlight style of the object if it is marked as highlighted via global status |
223 | //! @param theObj [in] the object to check |
224 | Standard_EXPORT Standard_Boolean HighlightStyle (const Handle(AIS_InteractiveObject)& theObj, |
225 | Handle(Prs3d_Drawer)& theStyle) const; |
226 | |
227 | //! Returns highlight style of the owner if it is selected |
228 | //! @param theOwner [in] the owner to check |
229 | Standard_EXPORT Standard_Boolean HighlightStyle (const Handle(SelectMgr_EntityOwner)& theOwner, |
230 | Handle(Prs3d_Drawer)& theStyle) const; |
231 | |
232 | //! Returns true if the object is marked as highlighted via its global status |
233 | //! @param theObj [in] the object to check |
234 | Standard_EXPORT Standard_Boolean IsHilighted (const Handle(AIS_InteractiveObject)& theObj) const; |
235 | |
236 | //! Returns true if the owner is marked as selected |
237 | //! @param theOwner [in] the owner to check |
238 | Standard_EXPORT Standard_Boolean IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner) const; |
239 | |
240 | //! Updates the display in the viewer to take dynamic detection into account. |
241 | //! On dynamic detection by the mouse cursor, sensitive primitives are highlighted. |
242 | //! The highlight color of entities detected by mouse movement is white by default. |
8e5fb5ea |
243 | Standard_DEPRECATED("Deprecated method Hilight()") |
0577ae8c |
244 | void Hilight (const Handle(AIS_InteractiveObject)& theObj, |
245 | const Standard_Boolean theIsToUpdateViewer) |
8e5fb5ea |
246 | { |
f838dac4 |
247 | return HilightWithColor (theObj, myStyles[Prs3d_TypeOfHighlight_Dynamic], theIsToUpdateViewer); |
8e5fb5ea |
248 | } |
42cf5bc1 |
249 | |
d21ddc4f |
250 | //! Changes the color of all the lines of the object in view. |
8e5fb5ea |
251 | Standard_EXPORT void HilightWithColor (const Handle(AIS_InteractiveObject)& theObj, |
0577ae8c |
252 | const Handle(Prs3d_Drawer)& theStyle, |
253 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
254 | |
d21ddc4f |
255 | //! Removes hilighting from the Object. |
0577ae8c |
256 | Standard_EXPORT void Unhilight (const Handle(AIS_InteractiveObject)& theIObj, |
257 | const Standard_Boolean theToUpdateViewer); |
d21ddc4f |
258 | |
259 | public: //! @name object presence management (View affinity, Layer, Priority) |
260 | |
261 | //! Returns the display priority of the Object. |
262 | Standard_EXPORT Standard_Integer DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const; |
263 | |
264 | //! Sets the display priority of the seen parts presentation of the Object. |
265 | Standard_EXPORT void SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj, const Standard_Integer thePriority); |
266 | |
267 | //! Get Z layer id set for displayed interactive object. |
268 | Standard_EXPORT Standard_Integer GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const; |
269 | |
42cf5bc1 |
270 | //! Set Z layer id for interactive object. |
271 | //! The Z layers can be used to display temporarily presentations of some object in front of the other objects in the scene. |
272 | //! The ids for Z layers are generated by V3d_Viewer. |
273 | Standard_EXPORT void SetZLayer (const Handle(AIS_InteractiveObject)& theIObj, const Standard_Integer theLayerId); |
d21ddc4f |
274 | |
275 | //! Setup object visibility in specified view. |
276 | //! Has no effect if object is not displayed in this context. |
277 | Standard_EXPORT void SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj, const Handle(V3d_View)& theView, const Standard_Boolean theIsVisible); |
278 | |
279 | public: //! @name Display Mode management |
280 | |
281 | //! Returns the Display Mode setting to be used by default. |
282 | Standard_Integer DisplayMode() const { return myDefaultDrawer->DisplayMode(); } |
283 | |
284 | //! Sets the display mode of seen Interactive Objects (which have no overridden Display Mode). |
285 | Standard_EXPORT void SetDisplayMode (const Standard_Integer theMode, |
286 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
287 | |
288 | //! Sets the display mode of seen Interactive Objects. |
d21ddc4f |
289 | //! theMode provides the display mode index of the entity theIObj. |
0577ae8c |
290 | Standard_EXPORT void SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj, |
291 | const Standard_Integer theMode, |
292 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
293 | |
294 | //! Unsets the display mode of seen Interactive Objects. |
0577ae8c |
295 | Standard_EXPORT void UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj, |
296 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
297 | |
d21ddc4f |
298 | public: //! @name object local transformation management |
299 | |
300 | //! Puts the location on the initial graphic representation and the selection for the Object. |
301 | Standard_EXPORT void SetLocation (const Handle(AIS_InteractiveObject)& theObject, const TopLoc_Location& theLocation); |
302 | |
303 | //! Puts the Object back into its initial position. |
304 | Standard_EXPORT void ResetLocation (const Handle(AIS_InteractiveObject)& theObject); |
305 | |
306 | //! Returns true if the Object has a location. |
307 | Standard_EXPORT Standard_Boolean HasLocation (const Handle(AIS_InteractiveObject)& theObject) const; |
308 | |
309 | //! Returns the location of the Object. |
310 | Standard_EXPORT TopLoc_Location Location (const Handle(AIS_InteractiveObject)& theObject) const; |
311 | |
312 | //! Sets transform persistence. |
313 | Standard_EXPORT void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject, |
314 | const Handle(Graphic3d_TransformPers)& theTrsfPers); |
315 | |
316 | Standard_DEPRECATED("This method is deprecated - SetTransformPersistence() taking Graphic3d_TransformPers should be called instead") |
317 | void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObj, |
318 | const Graphic3d_TransModeFlags& theFlag, |
319 | const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0)) |
320 | { |
321 | SetTransformPersistence (theObj, Graphic3d_TransformPers::FromDeprecatedParams (theFlag, thePoint)); |
322 | } |
323 | |
324 | public: //! @name mouse picking logic (detection and dynamic highlighting of entities under cursor) |
325 | |
51004f1c |
326 | //! Setup pixel tolerance for MoveTo() operation. |
d21ddc4f |
327 | //! @sa MoveTo(). |
51004f1c |
328 | Standard_EXPORT void SetPixelTolerance (const Standard_Integer thePrecision = 2); |
329 | |
330 | //! Returns the pixel tolerance, default is 2. |
331 | //! Pixel Tolerance extends sensitivity within MoveTo() operation (picking by point) |
332 | //! and can be adjusted by application based on user input precision (e.g. screen pixel density, input device precision, etc.). |
3bf9a45f |
333 | Standard_EXPORT Standard_Integer PixelTolerance() const; |
8a1170ad |
334 | |
335 | //! Allows to manage sensitivity of a particular selection of interactive object theObject |
336 | //! and changes previous sensitivity value of all sensitive entities in selection with theMode |
337 | //! to the given theNewSensitivity. |
338 | Standard_EXPORT void SetSelectionSensitivity (const Handle(AIS_InteractiveObject)& theObject, |
339 | const Standard_Integer theMode, |
340 | const Standard_Integer theNewSensitivity); |
42cf5bc1 |
341 | |
d21ddc4f |
342 | //! Relays mouse position in pixels theXPix and theYPix to the interactive context selectors. |
343 | //! This is done by the view theView passing this position to the main viewer and updating it. |
344 | //! Functions in both Neutral Point and local contexts. |
345 | //! If theToRedrawOnUpdate is set to false, callee should call RedrawImmediate() to highlight detected object. |
346 | //! @sa PickingStrategy() |
347 | Standard_EXPORT AIS_StatusOfDetection MoveTo (const Standard_Integer theXPix, |
348 | const Standard_Integer theYPix, |
349 | const Handle(V3d_View)& theView, |
350 | const Standard_Boolean theToRedrawOnUpdate); |
42cf5bc1 |
351 | |
d21ddc4f |
352 | //! Returns true if there is a mouse-detected entity in context. |
353 | //! @sa DetectedOwner()/HasNextDetected()/HilightPreviousDetected()/HilightNextDetected(). |
354 | Standard_EXPORT Standard_Boolean HasDetected() const; |
42cf5bc1 |
355 | |
d21ddc4f |
356 | //! Returns the owner of the detected sensitive primitive which is currently dynamically highlighted. |
357 | //! WARNING! This method is irrelevant to InitDetected()/MoreDetected()/NextDetected(). |
358 | //! @sa HasDetected()/HasNextDetected()/HilightPreviousDetected()/HilightNextDetected(). |
359 | Standard_EXPORT Handle(SelectMgr_EntityOwner) DetectedOwner() const; |
42cf5bc1 |
360 | |
d21ddc4f |
361 | //! Returns the interactive objects last detected in context. |
362 | //! In general this is just a wrapper for Handle(AIS_InteractiveObject)::DownCast(DetectedOwner()->Selectable()). |
363 | //! @sa DetectedOwner() |
364 | Standard_EXPORT Handle(AIS_InteractiveObject) DetectedInteractive() const; |
42cf5bc1 |
365 | |
d21ddc4f |
366 | //! Returns true if there is a detected shape in local context. |
367 | //! @sa HasDetected()/DetectedShape() |
368 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
369 | Standard_EXPORT Standard_Boolean HasDetectedShape() const; |
42cf5bc1 |
370 | |
d21ddc4f |
371 | //! Returns the shape detected in local context. |
372 | //! @sa DetectedOwner() |
373 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
374 | Standard_EXPORT const TopoDS_Shape& DetectedShape() const; |
42cf5bc1 |
375 | |
d21ddc4f |
376 | //! returns True if other entities were detected in the last mouse detection |
377 | //! @sa HilightPreviousDetected()/HilightNextDetected(). |
378 | Standard_EXPORT Standard_Boolean HasNextDetected() const; |
42cf5bc1 |
379 | |
d21ddc4f |
380 | //! If more than 1 object is detected by the selector, only the "best" owner is hilighted at the mouse position. |
381 | //! This Method allows the user to hilight one after another the other detected entities. |
382 | //! If The method select is called, the selected entity will be the hilighted one! |
383 | //! WARNING: Loop Method. When all the detected entities have been hilighted, the next call will hilight the first one again. |
384 | //! @return the Rank of hilighted entity |
385 | //! @sa HasNextDetected()/HilightPreviousDetected(). |
386 | Standard_EXPORT Standard_Integer HilightNextDetected (const Handle(V3d_View)& theView, const Standard_Boolean theToRedrawImmediate = Standard_True); |
42cf5bc1 |
387 | |
d21ddc4f |
388 | //! Same as previous methods in reverse direction. |
389 | //! @sa HasNextDetected()/HilightNextDetected(). |
390 | Standard_EXPORT Standard_Integer HilightPreviousDetected (const Handle(V3d_View)& theView, const Standard_Boolean theToRedrawImmediate = Standard_True); |
42cf5bc1 |
391 | |
d21ddc4f |
392 | public: //! @name iteration through detected entities |
42cf5bc1 |
393 | |
d21ddc4f |
394 | //! Initialization for iteration through mouse-detected objects in |
395 | //! interactive context or in local context if it is opened. |
396 | //! @sa DetectedCurrentOwner()/MoreDetected()/NextDetected(). |
397 | Standard_EXPORT void InitDetected(); |
398 | |
399 | //! Return TRUE if there is more mouse-detected objects after the current one |
400 | //! during iteration through mouse-detected interactive objects. |
401 | //! @sa DetectedCurrentOwner()/InitDetected()/NextDetected(). |
402 | Standard_EXPORT Standard_Boolean MoreDetected() const; |
403 | |
404 | //! Gets next current object during iteration through mouse-detected interactive objects. |
405 | //! @sa DetectedCurrentOwner()/InitDetected()/MoreDetected(). |
406 | Standard_EXPORT void NextDetected(); |
407 | |
408 | //! Returns the owner from detected list pointed by current iterator position. |
409 | //! WARNING! This method is irrelevant to DetectedOwner() which returns last picked Owner regardless of iterator position! |
410 | //! @sa InitDetected()/MoreDetected()/NextDetected(). |
411 | Standard_EXPORT Handle(SelectMgr_EntityOwner) DetectedCurrentOwner() const; |
412 | |
413 | public: //! @name Selection management |
414 | |
415 | //! Sets the graphic basic aspect to the current presentation of ALL selected objects. |
416 | Standard_EXPORT void SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect, |
417 | const Standard_Boolean theToUpdateViewer); |
418 | |
419 | //! Adds object in the selection. |
420 | Standard_EXPORT AIS_StatusOfPick AddSelect (const Handle(SelectMgr_EntityOwner)& theObject); |
421 | |
422 | //! Adds object in the selection. |
423 | AIS_StatusOfPick AddSelect (const Handle(AIS_InteractiveObject)& theObject) |
424 | { |
425 | return AddSelect (theObject->GlobalSelOwner()); |
426 | } |
427 | |
428 | //! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view. |
429 | //! The objects detected are passed to the main viewer, which is then updated. |
430 | Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin, |
431 | const Standard_Integer theYPMin, |
432 | const Standard_Integer theXPMax, |
433 | const Standard_Integer theYPMax, |
434 | const Handle(V3d_View)& theView, |
435 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
436 | |
d21ddc4f |
437 | //! polyline selection; clears the previous picked list |
438 | Standard_EXPORT AIS_StatusOfPick Select (const TColgp_Array1OfPnt2d& thePolyline, |
439 | const Handle(V3d_View)& theView, |
440 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
441 | |
d21ddc4f |
442 | //! Stores and hilights the previous detected; Unhilights the previous picked. |
443 | //! @sa MoveTo(). |
444 | Standard_EXPORT AIS_StatusOfPick Select (const Standard_Boolean theToUpdateViewer); |
445 | |
446 | //! Adds the last detected to the list of previous picked. |
447 | //! If the last detected was already declared as picked, removes it from the Picked List. |
448 | //! @sa MoveTo(). |
449 | Standard_EXPORT AIS_StatusOfPick ShiftSelect (const Standard_Boolean theToUpdateViewer); |
450 | |
451 | //! Adds the last detected to the list of previous picked. |
452 | //! If the last detected was already declared as picked, removes it from the Picked List. |
453 | Standard_EXPORT AIS_StatusOfPick ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline, |
454 | const Handle(V3d_View)& theView, |
455 | const Standard_Boolean theToUpdateViewer); |
456 | |
457 | //! Rectangle of selection; adds new detected entities into the picked list, |
458 | //! removes the detected entities that were already stored. |
459 | Standard_EXPORT AIS_StatusOfPick ShiftSelect (const Standard_Integer theXPMin, |
460 | const Standard_Integer theYPMin, |
461 | const Standard_Integer theXPMax, |
462 | const Standard_Integer theYPMax, |
463 | const Handle(V3d_View)& theView, |
464 | const Standard_Boolean theToUpdateViewer); |
465 | |
466 | //! Fits the view correspondingly to the bounds of selected objects. |
467 | //! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true. |
468 | Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView, |
469 | const Standard_Real theMargin, |
470 | const Standard_Boolean theToUpdate); |
471 | |
472 | //! Fits the view correspondingly to the bounds of selected objects. |
473 | //! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true. |
474 | Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView); |
475 | |
476 | //! Specify whether selected object must be hilighted when mouse cursor is moved above it (in MoveTo method). |
477 | //! By default this value is false and selected object is not hilighted in this case. |
478 | void SetToHilightSelected (const Standard_Boolean toHilight) { myToHilightSelected = toHilight; } |
479 | |
480 | //! Return value specified whether selected object must be hilighted when mouse cursor is moved above it |
481 | Standard_Boolean ToHilightSelected() const { return myToHilightSelected; } |
482 | |
483 | //! Unhighlights previously selected owners and marks them as not selected. |
484 | //! Marks owner given as selected and highlights it. |
485 | //! Performs selection filters check. |
486 | Standard_EXPORT void SetSelected (const Handle(SelectMgr_EntityOwner)& theOwners, |
487 | const Standard_Boolean theToUpdateViewer); |
488 | |
489 | //! Puts the interactive object aniObj in the list of selected objects. |
490 | //! Performs selection filters check. |
491 | Standard_EXPORT void SetSelected (const Handle(AIS_InteractiveObject)& theObject, |
492 | const Standard_Boolean theToUpdateViewer); |
493 | |
494 | //! Allows to highlight or unhighlight the owner given depending on its selection status |
495 | Standard_EXPORT void AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject, |
496 | const Standard_Boolean theToUpdateViewer); |
497 | |
498 | //! Highlights selected objects. |
499 | Standard_EXPORT void HilightSelected (const Standard_Boolean theToUpdateViewer); |
500 | |
501 | //! Removes highlighting from selected objects. |
502 | Standard_EXPORT void UnhilightSelected (const Standard_Boolean theToUpdateViewer); |
503 | |
504 | //! Updates the list of selected objects: |
505 | //! i.e. highlights the newely selected ones and unhighlights previously selected objects. |
506 | //! @sa HilightSelected(). |
507 | Standard_EXPORT void UpdateSelected (const Standard_Boolean theToUpdateViewer); |
508 | |
509 | //! Empties previous selected objects in order to get the selected objects detected by the selector using UpdateSelected. |
510 | Standard_EXPORT void ClearSelected (const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
511 | |
d21ddc4f |
512 | //! No right to Add a selected Shape (Internal Management of shape Selection). |
513 | //! A Previous selected shape may only be removed. |
514 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
515 | Standard_EXPORT void AddOrRemoveSelected (const TopoDS_Shape& theShape, |
516 | const Standard_Boolean theToUpdateViewer); |
517 | |
518 | //! Allows to highlight or unhighlight the owner given depending on its selection status |
519 | Standard_EXPORT void AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner, |
520 | const Standard_Boolean theToUpdateViewer); |
521 | |
522 | //! Returns true is the owner given is selected |
523 | Standard_EXPORT Standard_Boolean IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const; |
524 | |
525 | //! Returns true is the object given is selected |
526 | Standard_EXPORT Standard_Boolean IsSelected (const Handle(AIS_InteractiveObject)& theObj) const; |
527 | |
528 | //! Returns the first selected object in the list of current selected. |
529 | Standard_EXPORT Handle(AIS_InteractiveObject) FirstSelectedObject(); |
530 | |
531 | //! Count a number of selected entities using InitSelected()+MoreSelected()+NextSelected() iterator. |
532 | //! @sa SelectedOwner()/InitSelected()/MoreSelected()/NextSelected(). |
533 | Standard_EXPORT Standard_Integer NbSelected(); |
534 | |
535 | //! Initializes a scan of the selected objects. |
536 | //! @sa SelectedOwner()/MoreSelected()/NextSelected(). |
537 | Standard_EXPORT void InitSelected(); |
538 | |
539 | //! Returns true if there is another object found by the scan of the list of selected objects. |
540 | //! @sa SelectedOwner()/InitSelected()/NextSelected(). |
541 | Standard_EXPORT Standard_Boolean MoreSelected() const; |
542 | |
543 | //! Continues the scan to the next object in the list of selected objects. |
544 | //! @sa SelectedOwner()/InitSelected()/MoreSelected(). |
545 | Standard_EXPORT void NextSelected(); |
546 | |
547 | //! Returns the owner of the selected entity. |
548 | //! @sa InitSelected()/MoreSelected()/NextSelected(). |
549 | Standard_EXPORT Handle(SelectMgr_EntityOwner) SelectedOwner() const; |
550 | |
551 | //! Return Handle(AIS_InteractiveObject)::DownCast (SelectedOwner()->Selectable()). |
552 | //! @sa SelectedOwner(). |
553 | Standard_EXPORT Handle(AIS_InteractiveObject) SelectedInteractive() const; |
554 | |
555 | //! Returns TRUE if the interactive context has a shape selected. |
556 | //! @sa SelectedShape(). |
557 | Standard_EXPORT Standard_Boolean HasSelectedShape() const; |
558 | |
559 | //! Returns the selected shape. |
560 | //! Basically it is just a shape returned stored by StdSelect_BRepOwner with graphic transformation being applied: |
561 | //! @code |
562 | //! const Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast (SelectedOwner()); |
563 | //! TopoDS_Shape aSelShape = aBRepOwner->Shape(); |
564 | //! TopoDS_Shape aLocatedShape = aSelShape.Located (aBRepOwner->Location() * aSelShape.Location()); |
565 | //! @endcode |
566 | //! @sa SelectedOwner()/HasSelectedShape(). |
567 | Standard_EXPORT TopoDS_Shape SelectedShape() const; |
568 | |
569 | //! Returns SelectedInteractive()->HasOwner(). |
570 | //! @sa SelectedOwner(). |
571 | Standard_EXPORT Standard_Boolean HasApplicative() const; |
572 | |
573 | //! Returns SelectedInteractive()->GetOwner(). |
574 | //! @sa SelectedOwner(). |
575 | Standard_EXPORT Handle(Standard_Transient) Applicative() const; |
576 | |
577 | public: //! @name immediate mode rendering |
578 | |
579 | //! initializes the list of presentations to be displayed |
580 | //! returns False if no local context is opened. |
581 | Standard_EXPORT Standard_Boolean BeginImmediateDraw(); |
42cf5bc1 |
582 | |
d21ddc4f |
583 | //! returns True if <anIObj> has been stored in the list. |
584 | Standard_EXPORT Standard_Boolean ImmediateAdd (const Handle(AIS_InteractiveObject)& theObj, const Standard_Integer theMode = 0); |
42cf5bc1 |
585 | |
d21ddc4f |
586 | //! returns True if the immediate display has been done. |
587 | Standard_EXPORT Standard_Boolean EndImmediateDraw (const Handle(V3d_View)& theView); |
42cf5bc1 |
588 | |
d21ddc4f |
589 | //! Uses the First Active View of Main Viewer! |
590 | //! returns True if the immediate display has been done. |
591 | Standard_EXPORT Standard_Boolean EndImmediateDraw(); |
592 | |
593 | Standard_EXPORT Standard_Boolean IsImmediateModeOn() const; |
594 | |
595 | //! Redraws immediate structures in all views of the viewer given taking into account its visibility. |
596 | Standard_EXPORT void RedrawImmediate (const Handle(V3d_Viewer)& theViewer); |
597 | |
598 | public: //! @name management of active Selection Modes |
599 | |
600 | //! Activates the selection mode aMode whose index is given, for the given interactive entity anIobj. |
601 | Standard_EXPORT void Activate (const Handle(AIS_InteractiveObject)& anIobj, const Standard_Integer aMode = 0, const Standard_Boolean theIsForce = Standard_False); |
602 | |
603 | //! Activates the given selection mode for the all displayed objects. |
604 | Standard_EXPORT void Activate (const Standard_Integer theMode, |
605 | const Standard_Boolean theIsForce = Standard_False); |
42cf5bc1 |
606 | |
d21ddc4f |
607 | //! Deactivates all the activated selection modes of an object. |
608 | Standard_EXPORT void Deactivate (const Handle(AIS_InteractiveObject)& anIObj); |
c3282ec1 |
609 | |
d21ddc4f |
610 | //! Deactivates all the activated selection modes of the interactive object anIobj with a given selection mode aMode. |
611 | Standard_EXPORT void Deactivate (const Handle(AIS_InteractiveObject)& anIobj, const Standard_Integer aMode); |
8e5fb5ea |
612 | |
d21ddc4f |
613 | //! Deactivates the given selection mode for all displayed objects. |
614 | Standard_EXPORT void Deactivate (const Standard_Integer theMode); |
8e5fb5ea |
615 | |
d21ddc4f |
616 | //! Deactivates all the activated selection mode at all displayed objects. |
617 | Standard_EXPORT void Deactivate(); |
8e5fb5ea |
618 | |
d21ddc4f |
619 | //! Returns the list of activated selection modes in an open context. |
620 | Standard_EXPORT void ActivatedModes (const Handle(AIS_InteractiveObject)& anIobj, TColStd_ListOfInteger& theList) const; |
621 | |
622 | //! Returns a collection containing all entity owners created for the interactive object in specified selection mode (in all active modes if the Mode == -1) |
623 | Standard_EXPORT void EntityOwners (Handle(SelectMgr_IndexedMapOfOwner)& theOwners, |
624 | const Handle(AIS_InteractiveObject)& theIObj, |
625 | const Standard_Integer theMode = -1) const; |
626 | |
627 | public: //! @name Selection Filters management |
628 | |
629 | //! Returns the list of filters active in a local context. |
630 | Standard_EXPORT const SelectMgr_ListOfFilter& Filters() const; |
631 | |
632 | //! Allows you to add the filter. |
633 | Standard_EXPORT void AddFilter (const Handle(SelectMgr_Filter)& theFilter); |
634 | |
635 | //! Removes a filter from context. |
636 | Standard_EXPORT void RemoveFilter (const Handle(SelectMgr_Filter)& theFilter); |
637 | |
638 | //! Remove all filters from context. |
639 | Standard_EXPORT void RemoveFilters(); |
640 | |
641 | //! Return picking strategy; SelectMgr_PickingStrategy_FirstAcceptable by default. |
642 | //! @sa MoveTo()/Filters() |
643 | SelectMgr_PickingStrategy PickingStrategy() const { return myPickingStrategy; } |
644 | |
645 | //! Setup picking strategy - which entities detected by picking line will be accepted, considering Selection Filters. |
646 | //! By default (SelectMgr_PickingStrategy_FirstAcceptable), Selection Filters reduce the list of entities |
647 | //! so that the context accepts topmost in remaining. |
648 | //! |
649 | //! This means that entities behind non-selectable (by filters) parts can be picked by user. |
650 | //! If this behavior is undesirable, and user wants that non-selectable (by filters) parts |
651 | //! should remain an obstacle for picking, SelectMgr_PickingStrategy_OnlyTopmost can be set instead. |
652 | //! |
653 | //! Notice, that since Selection Manager operates only objects registered in it, |
654 | //! SelectMgr_PickingStrategy_OnlyTopmost will NOT prevent picking entities behind |
655 | //! visible by unregistered in Selection Manager presentations (e.g. deactivated). |
656 | //! Hence, SelectMgr_PickingStrategy_OnlyTopmost changes behavior only with Selection Filters enabled. |
657 | void SetPickingStrategy (const SelectMgr_PickingStrategy theStrategy) |
658 | { |
659 | myPickingStrategy = theStrategy; |
660 | } |
661 | |
662 | public: //! @name common properties |
663 | |
664 | //! Returns the default attribute manager. |
665 | //! This contains all the color and line attributes which can be used by interactive objects which do not have their own attributes. |
666 | const Handle(Prs3d_Drawer)& DefaultDrawer() const { return myDefaultDrawer; } |
667 | |
668 | //! Returns the current viewer. |
669 | const Handle(V3d_Viewer)& CurrentViewer() const { return myMainVwr; } |
670 | |
671 | const Handle(SelectMgr_SelectionManager)& SelectionManager() const { return mgrSelector; } |
672 | |
673 | const Handle(PrsMgr_PresentationManager3d)& MainPrsMgr() const { return myMainPM; } |
674 | |
675 | const Handle(StdSelect_ViewerSelector3d)& MainSelector() const { return myMainSel; } |
676 | |
677 | //! Updates the current viewer. |
678 | Standard_EXPORT void UpdateCurrentViewer(); |
679 | |
680 | //! Returns the list of displayed objects of a particular Type WhichKind and Signature WhichSignature. |
681 | //! By Default, WhichSignature equals -1. This means that there is a check on type only. |
682 | Standard_EXPORT void DisplayedObjects (AIS_ListOfInteractive& aListOfIO, const Standard_Boolean OnlyFromNeutral = Standard_False) const; |
683 | |
684 | //! gives the list of displayed objects of a particular Type and signature. |
685 | //! by Default, <WhichSignature> = -1 means control only on <WhichKind>. |
686 | Standard_EXPORT void DisplayedObjects (const AIS_KindOfInteractive WhichKind, const Standard_Integer WhichSignature, AIS_ListOfInteractive& aListOfIO, const Standard_Boolean OnlyFromNeutral = Standard_False) const; |
42cf5bc1 |
687 | |
d21ddc4f |
688 | //! Returns the list theListOfIO of erased objects (hidden objects) particular Type WhichKind and Signature WhichSignature. |
689 | //! By Default, WhichSignature equals 1. This means that there is a check on type only. |
690 | Standard_EXPORT void ErasedObjects (AIS_ListOfInteractive& theListOfIO) const; |
691 | |
692 | //! gives the list of erased objects (hidden objects) |
693 | //! Type and signature by Default, <WhichSignature> = -1 means control only on <WhichKind>. |
694 | Standard_EXPORT void ErasedObjects (const AIS_KindOfInteractive WhichKind, const Standard_Integer WhichSignature, AIS_ListOfInteractive& theListOfIO) const; |
695 | |
696 | //! Returns the list theListOfIO of objects with indicated display status particular Type WhichKind and Signature WhichSignature. |
697 | //! By Default, WhichSignature equals 1. This means that there is a check on type only. |
698 | Standard_EXPORT void ObjectsByDisplayStatus (const AIS_DisplayStatus theStatus, AIS_ListOfInteractive& theListOfIO) const; |
699 | |
700 | //! gives the list of objects with indicated display status |
701 | //! Type and signature by Default, <WhichSignature> = -1 means control only on <WhichKind>. |
702 | Standard_EXPORT void ObjectsByDisplayStatus (const AIS_KindOfInteractive WhichKind, const Standard_Integer WhichSignature, const AIS_DisplayStatus theStatus, AIS_ListOfInteractive& theListOfIO) const; |
42cf5bc1 |
703 | |
d21ddc4f |
704 | //! fills <aListOfIO> with objects of a particular Type and Signature with no consideration of display status. |
705 | //! by Default, <WhichSignature> = -1 means control only on <WhichKind>. |
706 | //! if <WhichKind> = AIS_KOI_None and <WhichSignature> = -1, all the objects are put into the list. |
707 | Standard_EXPORT void ObjectsInside (AIS_ListOfInteractive& aListOfIO, const AIS_KindOfInteractive WhichKind = AIS_KOI_None, const Standard_Integer WhichSignature = -1) const; |
42cf5bc1 |
708 | |
d21ddc4f |
709 | //! Rebuilds 1st level of BVH selection forcibly |
710 | Standard_EXPORT void RebuildSelectionStructs(); |
711 | |
712 | //! Disconnects theObjToDisconnect from theAssembly and removes dependent selection structures |
713 | Standard_EXPORT void Disconnect (const Handle(AIS_InteractiveObject)& theAssembly, const Handle(AIS_InteractiveObject)& theObjToDisconnect = NULL); |
714 | |
715 | //! Query objects visible or hidden in specified view due to affinity mask. |
716 | Standard_EXPORT void ObjectsForView (AIS_ListOfInteractive& theListOfIO, const Handle(V3d_View)& theView, const Standard_Boolean theIsVisibleInView, const AIS_DisplayStatus theStatus = AIS_DS_None) const; |
717 | |
718 | //! Clears all the structures which don't belong to objects displayed at neutral point |
719 | //! only effective when no Local Context is opened... |
720 | //! returns the number of removed structures from the viewers. |
721 | Standard_EXPORT Standard_Integer PurgeDisplay(); |
722 | |
723 | public: //! @name debug visualization |
724 | |
725 | //! Visualization of sensitives - for debugging purposes! |
726 | Standard_EXPORT void DisplayActiveSensitive (const Handle(V3d_View)& aView); |
727 | |
728 | //! Clear visualization of sensitives. |
729 | Standard_EXPORT void ClearActiveSensitive (const Handle(V3d_View)& aView); |
730 | |
731 | //! Visualization of sensitives - for debugging purposes! |
732 | Standard_EXPORT void DisplayActiveSensitive (const Handle(AIS_InteractiveObject)& anObject, const Handle(V3d_View)& aView); |
733 | |
734 | public: //! @name common object display attributes |
735 | |
736 | //! Sets the graphic attributes of the interactive object, such as visualization mode, color, and material. |
737 | Standard_EXPORT void SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj, |
738 | const Handle(Prs3d_Drawer)& theDrawer, |
739 | const Standard_Boolean theToUpdateViewer); |
740 | |
741 | //! Removes the settings for local attributes of the Object and returns to defaults. |
742 | Standard_EXPORT void UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj, |
743 | const Standard_Boolean theToUpdateViewer); |
744 | |
745 | //! change the current facing model apply on polygons for SetColor(), SetTransparency(), SetMaterial() methods default facing model is Aspect_TOFM_TWO_SIDE. |
746 | //! This mean that attributes is applying both on the front and back face. |
747 | Standard_EXPORT void SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& aniobj, const Aspect_TypeOfFacingModel aModel = Aspect_TOFM_BOTH_SIDE); |
748 | |
749 | //! Returns true if a view of the Interactive Object has color. |
42cf5bc1 |
750 | Standard_EXPORT Standard_Boolean HasColor (const Handle(AIS_InteractiveObject)& aniobj) const; |
42cf5bc1 |
751 | |
d21ddc4f |
752 | //! Returns the color of the Object in the interactive context. |
42cf5bc1 |
753 | Standard_EXPORT void Color (const Handle(AIS_InteractiveObject)& aniobj, Quantity_Color& acolor) const; |
42cf5bc1 |
754 | |
d21ddc4f |
755 | //! Sets the color of the selected entity. |
756 | Standard_EXPORT void SetColor (const Handle(AIS_InteractiveObject)& theIObj, |
757 | const Quantity_Color& theColor, |
758 | const Standard_Boolean theToUpdateViewer); |
759 | |
760 | //! Removes the color selection for the selected entity. |
761 | Standard_EXPORT void UnsetColor (const Handle(AIS_InteractiveObject)& theIObj, |
762 | const Standard_Boolean theToUpdateViewer); |
763 | |
764 | //! Returns the width of the Interactive Object in the interactive context. |
42cf5bc1 |
765 | Standard_EXPORT virtual Standard_Real Width (const Handle(AIS_InteractiveObject)& aniobj) const; |
42cf5bc1 |
766 | |
d21ddc4f |
767 | //! Sets the width of the Object. |
768 | Standard_EXPORT virtual void SetWidth (const Handle(AIS_InteractiveObject)& theIObj, |
769 | const Standard_Real theValue, |
770 | const Standard_Boolean theToUpdateViewer); |
771 | |
772 | //! Removes the width setting of the Object. |
773 | Standard_EXPORT virtual void UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj, |
774 | const Standard_Boolean theToUpdateViewer); |
775 | |
776 | //! Provides the type of material setting for the view of the Object. |
777 | Standard_EXPORT void SetMaterial (const Handle(AIS_InteractiveObject)& theIObj, |
778 | const Graphic3d_MaterialAspect& theMaterial, |
779 | const Standard_Boolean theToUpdateViewer); |
780 | |
781 | //! Removes the type of material setting for viewing the Object. |
782 | Standard_EXPORT void UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj, |
783 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
784 | |
d21ddc4f |
785 | //! Provides the transparency settings for viewing the Object. |
786 | //! The transparency value aValue may be between 0.0, opaque, and 1.0, fully transparent. |
787 | Standard_EXPORT void SetTransparency (const Handle(AIS_InteractiveObject)& theIObj, |
788 | const Standard_Real theValue, |
789 | const Standard_Boolean theToUpdateViewer); |
778cd667 |
790 | |
d21ddc4f |
791 | //! Removes the transparency settings for viewing the Object. |
792 | Standard_EXPORT void UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj, |
793 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
794 | |
d21ddc4f |
795 | //! Sets up polygon offsets for the given AIS_InteractiveObject. |
796 | //! It simply calls AIS_InteractiveObject::SetPolygonOffsets(). |
797 | Standard_EXPORT void SetPolygonOffsets (const Handle(AIS_InteractiveObject)& theIObj, |
798 | const Standard_Integer theMode, |
799 | const Standard_ShortReal theFactor, |
800 | const Standard_ShortReal theUnits, |
801 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
802 | |
d21ddc4f |
803 | //! Simply calls AIS_InteractiveObject::HasPolygonOffsets(). |
804 | Standard_EXPORT Standard_Boolean HasPolygonOffsets (const Handle(AIS_InteractiveObject)& anObj) const; |
f838dac4 |
805 | |
d21ddc4f |
806 | //! Retrieves current polygon offsets settings for Object. |
807 | Standard_EXPORT void PolygonOffsets (const Handle(AIS_InteractiveObject)& anObj, Standard_Integer& aMode, Standard_ShortReal& aFactor, Standard_ShortReal& aUnits) const; |
f838dac4 |
808 | |
d21ddc4f |
809 | public: //! @name trihedron display attributes |
42cf5bc1 |
810 | |
d21ddc4f |
811 | //! Sets the size aSize of the trihedron. |
812 | //! Is used to change the default value 100 mm for display of trihedra. |
813 | //! Use of this function in one of your own interactive objects requires a call to the Compute function of the new class. |
814 | //! This will recalculate the presentation for every trihedron displayed. |
815 | Standard_EXPORT void SetTrihedronSize (const Standard_Real theSize, |
816 | const Standard_Boolean theToUpdateViewer); |
8e5fb5ea |
817 | |
d21ddc4f |
818 | //! returns the current value of trihedron size. |
819 | Standard_EXPORT Standard_Real TrihedronSize() const; |
8e5fb5ea |
820 | |
d21ddc4f |
821 | public: //! @name plane display attributes |
8e5fb5ea |
822 | |
d21ddc4f |
823 | //! Sets the plane size defined by the length in the X direction XSize and that in the Y direction YSize. |
824 | Standard_EXPORT void SetPlaneSize (const Standard_Real theSizeX, |
825 | const Standard_Real theSizeY, |
826 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
827 | |
d21ddc4f |
828 | //! Sets the plane size aSize. |
829 | Standard_EXPORT void SetPlaneSize (const Standard_Real theSize, |
830 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
831 | |
d21ddc4f |
832 | //! Returns true if the length in the X direction XSize is the same as that in the Y direction YSize. |
833 | Standard_EXPORT Standard_Boolean PlaneSize (Standard_Real& XSize, Standard_Real& YSize) const; |
42cf5bc1 |
834 | |
d21ddc4f |
835 | public: //! @name tessellation deviation properties for automatic triangulation |
42cf5bc1 |
836 | |
d21ddc4f |
837 | //! Sets the deviation coefficient theCoefficient. |
838 | //! Drawings of curves or patches are made with respect to a maximal chordal deviation. |
839 | //! A Deviation coefficient is used in the shading display mode. |
840 | //! The shape is seen decomposed into triangles. |
841 | //! These are used to calculate reflection of light from the surface of the object. |
842 | //! The triangles are formed from chords of the curves in the shape. |
843 | //! The deviation coefficient theCoefficient gives the highest value of the angle with which a chord can deviate from a tangent to a curve. |
42cf5bc1 |
844 | //! If this limit is reached, a new triangle is begun. |
d21ddc4f |
845 | //! This deviation is absolute and is set through the method: SetMaximalChordialDeviation. |
846 | //! The default value is 0.001. |
847 | //! In drawing shapes, however, you are allowed to ask for a relative deviation. |
848 | //! This deviation will be: SizeOfObject * DeviationCoefficient. |
0577ae8c |
849 | Standard_EXPORT void SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj, |
850 | const Standard_Real theCoefficient, |
851 | const Standard_Boolean theToUpdateViewer); |
d21ddc4f |
852 | |
0577ae8c |
853 | Standard_EXPORT void SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj, |
854 | const Standard_Real theAngle, |
855 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
856 | |
d21ddc4f |
857 | //! Calls the AIS_Shape SetAngleAndDeviation to set both Angle and Deviation coefficients |
0577ae8c |
858 | Standard_EXPORT void SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj, |
859 | const Standard_Real theAngle, |
860 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
861 | |
862 | |
d21ddc4f |
863 | //! Sets the deviation coefficient aCoefficient for removal of hidden lines created by different viewpoints in different presentations. |
864 | //! The Default value is 0.02. |
0577ae8c |
865 | Standard_EXPORT void SetHLRDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj, |
866 | const Standard_Real theCoefficient, |
867 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
868 | |
0577ae8c |
869 | Standard_EXPORT void SetHLRDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj, |
870 | const Standard_Real theAngle, |
871 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
872 | |
d21ddc4f |
873 | //! Computes a HLRAngle and a HLRDeviationCoefficient by means of the angle anAngle |
874 | //! and sets the corresponding methods in the default drawing tool with these values. |
0577ae8c |
875 | Standard_EXPORT void SetHLRAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj, |
876 | const Standard_Real theAngle, |
877 | const Standard_Boolean theToUpdateViewer); |
d21ddc4f |
878 | |
879 | //! Sets the deviation coefficient theCoefficient. |
880 | //! Drawings of curves or patches are made with respect to a maximal chordal deviation. |
881 | //! A Deviation coefficient is used in the shading display mode. |
882 | //! The shape is seen decomposed into triangles. |
883 | //! These are used to calculate reflection of light from the surface of the object. |
884 | //! The triangles are formed from chords of the curves in the shape. |
885 | //! The deviation coefficient theCoefficient gives the highest value of the angle with which a chord can deviate from a tangent to a curve. |
42cf5bc1 |
886 | //! If this limit is reached, a new triangle is begun. |
d21ddc4f |
887 | //! This deviation is absolute and is set through the method: SetMaximalChordialDeviation. |
888 | //! The default value is 0.001. |
889 | //! In drawing shapes, however, you are allowed to ask for a relative deviation. |
890 | //! This deviation will be: SizeOfObject * DeviationCoefficient. |
891 | Standard_EXPORT void SetDeviationCoefficient (const Standard_Real theCoefficient); |
42cf5bc1 |
892 | |
893 | //! Returns the deviation coefficient. |
d21ddc4f |
894 | //! Drawings of curves or patches are made with respect to a maximal chordal deviation. |
895 | //! A Deviation coefficient is used in the shading display mode. |
896 | //! The shape is seen decomposed into triangles. |
897 | //! These are used to calculate reflection of light from the surface of the object. |
898 | //! The triangles are formed from chords of the curves in the shape. |
899 | //! The deviation coefficient gives the highest value of the angle with which a chord can deviate from a tangent to a curve. |
900 | //! If this limit is reached, a new triangle is begun. |
901 | //! This deviation is absolute and is set through Prs3d_Drawer::SetMaximalChordialDeviation. |
902 | //! The default value is 0.001. |
903 | //! In drawing shapes, however, you are allowed to ask for a relative deviation. |
904 | //! This deviation will be: SizeOfObject * DeviationCoefficient. |
42cf5bc1 |
905 | Standard_EXPORT Standard_Real DeviationCoefficient() const; |
d21ddc4f |
906 | |
02f5c89d |
907 | //! default 12 degrees |
42cf5bc1 |
908 | Standard_EXPORT void SetDeviationAngle (const Standard_Real anAngle); |
d21ddc4f |
909 | |
42cf5bc1 |
910 | Standard_EXPORT Standard_Real DeviationAngle() const; |
911 | |
d21ddc4f |
912 | //! Sets the deviation coefficient aCoefficient for removal of hidden lines created by different viewpoints in different presentations. |
913 | //! The Default value is 0.02. |
42cf5bc1 |
914 | Standard_EXPORT void SetHLRDeviationCoefficient (const Standard_Real aCoefficient); |
42cf5bc1 |
915 | |
d21ddc4f |
916 | //! Returns the real number value of the hidden line removal deviation coefficient. |
917 | //! A Deviation coefficient is used in the shading display mode. |
918 | //! The shape is seen decomposed into triangles. |
919 | //! These are used to calculate reflection of light from the surface of the object. |
920 | //! The triangles are formed from chords of the curves in the shape. |
921 | //! The deviation coefficient give the highest value of the angle with which a chord can deviate from a tangent to a curve. |
922 | //! If this limit is reached, a new triangle is begun. |
923 | //! To find the hidden lines, hidden line display mode entails recalculation of the view at each different projector perspective. |
924 | //! Because hidden lines entail calculations of more than usual complexity to decompose them into these triangles, |
925 | //! a deviation coefficient allowing greater tolerance is used. |
926 | //! This increases efficiency in calculation. |
42cf5bc1 |
927 | //! The Default value is 0.02. |
928 | Standard_EXPORT Standard_Real HLRDeviationCoefficient() const; |
42cf5bc1 |
929 | |
d21ddc4f |
930 | //! Sets the HLR angle. |
931 | Standard_EXPORT void SetHLRAngle (const Standard_Real theAngle); |
932 | |
933 | //! Returns the real number value of the deviation angle in hidden line removal views in this interactive context. |
42cf5bc1 |
934 | //! The default value is 20*PI/180. |
935 | Standard_EXPORT Standard_Real HLRAngle() const; |
d21ddc4f |
936 | |
937 | //! compute with theAngle a HLRAngle and a HLRDeviationCoefficient |
938 | //! and set them in myHLRAngle and in myHLRDeviationCoefficient of myDefaultDrawer; |
939 | //! theAngle is in radian; ( 1 deg < angle in deg < 20 deg) |
940 | Standard_EXPORT void SetHLRAngleAndDeviation (const Standard_Real theAngle); |
941 | |
942 | public: //! @name HLR (Hidden Line Removal) display attributes |
943 | |
42cf5bc1 |
944 | //! Initializes hidden line aspect in the default drawing tool, or Drawer. |
945 | //! The default values are: |
946 | //! Color: Quantity_NOC_YELLOW |
947 | //! Type of line: Aspect_TOL_DASH |
948 | //! Width: 1. |
949 | Standard_EXPORT Handle(Prs3d_LineAspect) HiddenLineAspect() const; |
42cf5bc1 |
950 | |
951 | //! Sets the hidden line aspect anAspect. |
d21ddc4f |
952 | //! Aspect defines display attributes for hidden lines in HLR projections. |
42cf5bc1 |
953 | Standard_EXPORT void SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& anAspect) const; |
d21ddc4f |
954 | |
42cf5bc1 |
955 | //! returns Standard_True if the hidden lines are to be drawn. |
956 | //! By default the hidden lines are not drawn. |
957 | Standard_EXPORT Standard_Boolean DrawHiddenLine() const; |
d21ddc4f |
958 | |
42cf5bc1 |
959 | Standard_EXPORT void EnableDrawHiddenLine() const; |
d21ddc4f |
960 | |
42cf5bc1 |
961 | Standard_EXPORT void DisableDrawHiddenLine() const; |
d21ddc4f |
962 | |
963 | public: //! @name iso-line display attributes |
964 | |
42cf5bc1 |
965 | //! Sets the number of U and V isoparameters displayed. |
966 | Standard_EXPORT void SetIsoNumber (const Standard_Integer NbIsos, const AIS_TypeOfIso WhichIsos = AIS_TOI_Both); |
967 | |
968 | //! Returns the number of U and V isoparameters displayed. |
d21ddc4f |
969 | Standard_EXPORT Standard_Integer IsoNumber (const AIS_TypeOfIso WhichIsos = AIS_TOI_Both); |
42cf5bc1 |
970 | |
d21ddc4f |
971 | //! Returns True if drawing isoparameters on planes is enabled. |
972 | Standard_EXPORT void IsoOnPlane (const Standard_Boolean SwitchOn); |
42cf5bc1 |
973 | |
d21ddc4f |
974 | //! Returns True if drawing isoparameters on planes is enabled. |
975 | //! if <forUIsos> = False, |
976 | Standard_EXPORT Standard_Boolean IsoOnPlane() const; |
42cf5bc1 |
977 | |
d21ddc4f |
978 | //! Enables or disables on-triangulation build for isolines for a particular object. |
979 | //! In case if on-triangulation builder is disabled, default on-plane builder will compute isolines for the object given. |
980 | Standard_EXPORT void IsoOnTriangulation (const Standard_Boolean theIsEnabled, |
981 | const Handle(AIS_InteractiveObject)& theObject); |
42cf5bc1 |
982 | |
d21ddc4f |
983 | //! Enables or disables on-triangulation build for isolines for default drawer. |
984 | //! In case if on-triangulation builder is disabled, default on-plane builder will compute isolines for the object given. |
985 | Standard_EXPORT void IsoOnTriangulation (const Standard_Boolean theToSwitchOn); |
42cf5bc1 |
986 | |
d21ddc4f |
987 | //! Returns true if drawing isolines on triangulation algorithm is enabled. |
988 | Standard_EXPORT Standard_Boolean IsoOnTriangulation() const; |
42cf5bc1 |
989 | |
d21ddc4f |
990 | public: //! @name Local Context management (deprecated) |
42cf5bc1 |
991 | |
d21ddc4f |
992 | //! Returns true if there is an open context. |
993 | Standard_Boolean HasOpenedContext() const { return myCurLocalIndex != 0; } |
42cf5bc1 |
994 | |
d21ddc4f |
995 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
996 | Standard_EXPORT Standard_Integer HighestIndex() const; |
42cf5bc1 |
997 | |
d21ddc4f |
998 | //! For advanced usage! You should use other (non-internal) methods of class AIS_InteractiveContext without trying to obtain an instance of AIS_LocalContext. |
999 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1000 | Handle(AIS_LocalContext) LocalContext() const { return myCurLocalIndex > 0 ? myLocalContexts (myCurLocalIndex) : Handle(AIS_LocalContext)(); } |
1001 | |
1002 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1003 | Standard_EXPORT Handle(StdSelect_ViewerSelector3d) LocalSelector() const; |
42cf5bc1 |
1004 | |
d21ddc4f |
1005 | //! Opens local contexts and specifies how this is to be done. |
1006 | //! The options listed above function in the following manner: |
1007 | //! - UseDisplayedObjects - allows you to load or not load the interactive objects visualized at Neutral Point in the local context which you open. |
1008 | //! If false, the local context is empty after being opened. If true, the objects at Neutral Point are loaded by their default selection mode. |
1009 | //! - AllowShapeDecomposition - AIS_Shape allows or prevents decomposition in standard shape location mode of objects at Neutral Point which are type-"privileged". |
1010 | //! This Flag is only taken into account when UseDisplayedObjects is true. |
1011 | //! - AcceptEraseOfObjects - authorises other local contexts to erase the interactive objects present in this context. This option is rarely used. |
1012 | //! - BothViewers - Has no use currently defined. |
1013 | //! This method returns the index of the created local context. |
1014 | //! It should be kept and used to close the context. |
1015 | //! Opening a local context allows you to prepare an environment for temporary presentations and selections which will disappear once the local context is closed. |
1016 | //! You can open several local contexts, but only the last one will be active. |
404c8936 |
1017 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
42cf5bc1 |
1018 | Standard_EXPORT Standard_Integer OpenLocalContext (const Standard_Boolean UseDisplayedObjects = Standard_True, const Standard_Boolean AllowShapeDecomposition = Standard_True, const Standard_Boolean AcceptEraseOfObjects = Standard_False, const Standard_Boolean BothViewers = Standard_False); |
d21ddc4f |
1019 | |
1020 | //! Allows you to close local contexts. For greater security, you should close the context with the index Index given on opening. |
1021 | //! When you close a local context, the one before, which is still on the stack, reactivates. |
1022 | //! If none is left, you return to Neutral Point. |
1023 | //! If a local context is open and if updateviewer equals Standard_False, the presentation of the Interactive Object activates the selection mode; |
1024 | //! the object is displayed but no viewer will be updated. |
42cf5bc1 |
1025 | //! Warning |
d21ddc4f |
1026 | //! When the index isn't specified, the current context is closed. |
1027 | //! This option can be dangerous, as other Interactive Functions can open local contexts without necessarily warning the user. |
404c8936 |
1028 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
0577ae8c |
1029 | Standard_EXPORT void CloseLocalContext (const Standard_Integer theIndex = -1, |
1030 | const Standard_Boolean theToUpdateViewer = Standard_True); |
d21ddc4f |
1031 | |
42cf5bc1 |
1032 | //! returns -1 if no opened local context. |
404c8936 |
1033 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
42cf5bc1 |
1034 | Standard_EXPORT Standard_Integer IndexOfCurrentLocal() const; |
42cf5bc1 |
1035 | |
d21ddc4f |
1036 | //! Allows you to close all local contexts at one go and return to Neutral Point. |
1037 | //! If a local context is open and if updateviewer equals Standard_False, the presentation of the Interactive Object activates the selection mode; |
1038 | //! the object is displayed but no viewer will be updated. |
404c8936 |
1039 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
0577ae8c |
1040 | Standard_EXPORT void CloseAllContexts (const Standard_Boolean theToUpdateViewer); |
d21ddc4f |
1041 | |
1042 | //! to be used only with no opened local context.. |
1043 | //! displays and activates objects in their original state before local contexts were opened... |
0577ae8c |
1044 | Standard_EXPORT void ResetOriginalState (const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
1045 | |
404c8936 |
1046 | //! clears Objects/Filters/Activated Modes list in the current opened local context. |
1047 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
42cf5bc1 |
1048 | Standard_EXPORT void ClearLocalContext (const AIS_ClearMode TheMode = AIS_CM_All); |
404c8936 |
1049 | |
1050 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
42cf5bc1 |
1051 | Standard_EXPORT void UseDisplayedObjects(); |
d21ddc4f |
1052 | |
1053 | //! when a local Context is opened, one is able to use/not use the displayed objects at neutral point at anytime. |
404c8936 |
1054 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
42cf5bc1 |
1055 | Standard_EXPORT void NotUseDisplayedObjects(); |
42cf5bc1 |
1056 | |
42cf5bc1 |
1057 | //! to be Used only with opened local context and |
1058 | //! if <anIobj> is of type shape... |
1059 | //! if <aStatus> = True <anIobj> will be sensitive to |
1060 | //! shape selection modes activation. |
d21ddc4f |
1061 | //! = False, <anIobj> will not be sensitive any more. |
404c8936 |
1062 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
42cf5bc1 |
1063 | Standard_EXPORT void SetShapeDecomposition (const Handle(AIS_InteractiveObject)& anIobj, const Standard_Boolean aStatus); |
1064 | |
1065 | |
d21ddc4f |
1066 | //! Sets the temporary graphic attributes of the entity anObj. |
1067 | //! These are provided by the attribute manager aDrawer and are valid for a particular local context only. |
1068 | //! If a local context is open and if updateviewer equals Standard_False, the presentation of the Interactive Object activates the selection mode; |
1069 | //! the object is displayed but no viewer will be updated. |
404c8936 |
1070 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
0577ae8c |
1071 | Standard_EXPORT void SetTemporaryAttributes (const Handle(AIS_InteractiveObject)& theIObj, |
1072 | const Handle(Prs3d_Drawer)& theDrawer, |
1073 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
1074 | |
d21ddc4f |
1075 | //! Provides an alternative to the Display methods when activating specific selection modes. |
1076 | //! This has the effect of activating the corresponding selection mode aStandardActivation for all objects |
1077 | //! in Local Context which accept decomposition into sub-shapes. |
1078 | //! Every new Object which has been loaded into the interactive context and which answers these decomposition criteria |
1079 | //! is automatically activated according to these modes. |
42cf5bc1 |
1080 | //! Warning |
d21ddc4f |
1081 | //! If you have opened a local context by loading an object with the default options (<AllowShapeDecomposition >= Standard_True), |
1082 | //! all objects of the "Shape" type are also activated with the same modes. |
1083 | //! You can act on the state of these "Standard" objects by using SetShapeDecomposition(Status). |
404c8936 |
1084 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
42cf5bc1 |
1085 | Standard_EXPORT void ActivateStandardMode (const TopAbs_ShapeEnum aStandardActivation); |
42cf5bc1 |
1086 | |
d21ddc4f |
1087 | //! Provides an alternative to the Display methods when deactivating specific selection modes. |
1088 | //! This has the effect of deactivating the corresponding selection mode aStandardActivation for all objects |
1089 | //! in Local Context which accept decomposition into sub-shapes. |
404c8936 |
1090 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
42cf5bc1 |
1091 | Standard_EXPORT void DeactivateStandardMode (const TopAbs_ShapeEnum aStandardActivation); |
42cf5bc1 |
1092 | |
d21ddc4f |
1093 | //! Returns the list of activated standard selection modes available in a local context. |
404c8936 |
1094 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
42cf5bc1 |
1095 | Standard_EXPORT const TColStd_ListOfInteger& ActivatedStandardModes() const; |
42cf5bc1 |
1096 | |
d21ddc4f |
1097 | //! returns if possible, the first local context where the object is seen |
1098 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1099 | Standard_EXPORT Standard_Boolean IsInLocal (const Handle(AIS_InteractiveObject)& anObject, Standard_Integer& TheIndex) const; |
42cf5bc1 |
1100 | |
d21ddc4f |
1101 | //! Sets the highlighting status aStatus of detected and selected entities. |
1102 | //! Whether you are in Neutral Point or local context, this is automatically managed by the Interactive Context. |
1103 | //! This function allows you to disconnect the automatic mode. |
1104 | Standard_EXPORT void SetAutomaticHilight (const Standard_Boolean aStatus); |
f838dac4 |
1105 | |
d21ddc4f |
1106 | //! Returns true if the automatic highlight mode is active in an open context. |
1107 | Standard_EXPORT Standard_Boolean AutomaticHilight() const; |
f838dac4 |
1108 | |
d21ddc4f |
1109 | //! Changes the status of a temporary object. |
1110 | //! It will be kept at the neutral point, i.e. put in the list of displayed objects along with its temporary attributes. |
1111 | //! These include display mode and selection mode, for example. |
1112 | //! Returns true if done. |
1113 | //! inWhichLocal gives the local context in which anIObj is displayed. |
1114 | //! By default, the index -1 refers to the last Local Context opened. |
1115 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1116 | Standard_EXPORT Standard_Boolean KeepTemporary (const Handle(AIS_InteractiveObject)& anIObj, const Standard_Integer InWhichLocal = -1); |
42cf5bc1 |
1117 | |
d21ddc4f |
1118 | public: |
42cf5bc1 |
1119 | |
d21ddc4f |
1120 | //! Updates the view of the current object in open context. |
1121 | //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects. |
1122 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1123 | Standard_EXPORT void SetCurrentObject (const Handle(AIS_InteractiveObject)& theIObj, |
1124 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
1125 | |
d21ddc4f |
1126 | //! Allows to add or remove the object given to the list of current and highlight/unhighlight it correspondingly. |
1127 | //! Is valid for global context only; for local context use method AddOrRemoveSelected. |
1128 | //! Since this method makes sence only for neutral point selection of a whole object, |
1129 | //! if 0 selection of the object is empty this method simply does nothing. |
404c8936 |
1130 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
d21ddc4f |
1131 | Standard_EXPORT void AddOrRemoveCurrentObject (const Handle(AIS_InteractiveObject)& theObj, |
1132 | const Standard_Boolean theIsToUpdateViewer); |
f838dac4 |
1133 | |
d21ddc4f |
1134 | //! Updates the list of current objects, i.e. hilights new current objects, removes hilighting from former current objects. |
1135 | //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects. |
1136 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1137 | Standard_EXPORT void UpdateCurrent(); |
f838dac4 |
1138 | |
d21ddc4f |
1139 | //! Returns true if there is a non-null interactive object in Neutral Point. |
1140 | //! Objects selected when there is no open local context are called current objects; |
1141 | //! those selected in open local context, selected objects. |
1142 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1143 | Standard_EXPORT Standard_Boolean IsCurrent (const Handle(AIS_InteractiveObject)& theObject) const; |
f838dac4 |
1144 | |
d21ddc4f |
1145 | //! Initializes a scan of the current selected objects in Neutral Point. |
1146 | //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects. |
404c8936 |
1147 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
d21ddc4f |
1148 | Standard_EXPORT void InitCurrent(); |
1149 | |
1150 | //! Returns true if there is another object found by the scan of the list of current objects. |
1151 | //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects. |
404c8936 |
1152 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
d21ddc4f |
1153 | Standard_EXPORT Standard_Boolean MoreCurrent() const; |
42cf5bc1 |
1154 | |
d21ddc4f |
1155 | //! Continues the scan to the next object in the list of current objects. |
1156 | //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects. |
1157 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1158 | Standard_EXPORT void NextCurrent(); |
0577ae8c |
1159 | |
d21ddc4f |
1160 | //! Returns the current interactive object. |
1161 | //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects. |
404c8936 |
1162 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
d21ddc4f |
1163 | Standard_EXPORT Handle(AIS_InteractiveObject) Current() const; |
1164 | |
1165 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1166 | Standard_EXPORT Standard_Integer NbCurrents(); |
1167 | |
1168 | //! Highlights current objects. |
1169 | //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects. |
1170 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1171 | Standard_EXPORT void HilightCurrents (const Standard_Boolean theToUpdateViewer); |
1172 | |
1173 | //! Removes highlighting from current objects. |
1174 | //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects. |
1175 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1176 | Standard_EXPORT void UnhilightCurrents (const Standard_Boolean theToUpdateViewer); |
1177 | |
1178 | //! Empties previous current objects in order to get the current objects detected by the selector using UpdateCurrent. |
1179 | //! Objects selected when there is no open local context are called current objects; those selected in open local context, selected objects. |
1180 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1181 | Standard_EXPORT void ClearCurrents (const Standard_Boolean theToUpdateViewer); |
1182 | |
1183 | //! @return current mouse-detected shape or empty (null) shape, if current interactive object |
1184 | //! is not a shape (AIS_Shape) or there is no current mouse-detected interactive object at all. |
1185 | //! @sa DetectedCurrentOwner()/InitDetected()/MoreDetected()/NextDetected(). |
1186 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1187 | Standard_EXPORT const TopoDS_Shape& DetectedCurrentShape() const; |
42cf5bc1 |
1188 | |
d21ddc4f |
1189 | //! @return current mouse-detected interactive object or null object, if there is no currently detected interactives |
1190 | //! @sa DetectedCurrentOwner()/InitDetected()/MoreDetected()/NextDetected(). |
1191 | Standard_DEPRECATED ("Local Context is deprecated - local selection should be used without Local Context") |
1192 | Standard_EXPORT Handle(AIS_InteractiveObject) DetectedCurrentObject() const; |
42cf5bc1 |
1193 | |
d21ddc4f |
1194 | public: //! @name sub-intensity management (deprecated) |
1195 | |
1196 | //! Sub-intensity allows temporary highlighting of particular objects with specified color in a manner of selection highlight, |
1197 | //! but without actual selection (e.g., global status and owner's selection state will not be updated). |
1198 | //! The method returns the color of such highlighting. |
1199 | //! By default, it is Quantity_NOC_GRAY40. |
1200 | const Quantity_Color& SubIntensityColor() const |
1201 | { |
1202 | return myStyles[Prs3d_TypeOfHighlight_SubIntensity]->Color(); |
1203 | } |
1204 | |
1205 | //! Sub-intensity allows temporary highlighting of particular objects with specified color in a manner of selection highlight, |
1206 | //! but without actual selection (e.g., global status and owner's selection state will not be updated). |
1207 | //! The method sets up the color for such highlighting. |
1208 | //! By default, this is Quantity_NOC_GRAY40. |
1209 | void SetSubIntensityColor (const Quantity_Color& theColor) |
1210 | { |
1211 | myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetColor (theColor); |
1212 | } |
1213 | |
1214 | //! Highlights, and removes highlights from, the displayed object which is displayed at Neutral Point with subintensity color. |
1215 | //! Available only for active local context. |
1216 | //! There is no effect if there is no local context. |
1217 | //! If a local context is open, the presentation of the Interactive Object activates the selection mode. |
1218 | Standard_EXPORT void SubIntensityOn (const Handle(AIS_InteractiveObject)& theIObj, |
1219 | const Standard_Boolean theToUpdateViewer); |
1220 | |
1221 | //! Removes the subintensity option for the entity. |
1222 | //! If a local context is open, the presentation of the Interactive Object activates the selection mode. |
1223 | Standard_EXPORT void SubIntensityOff (const Handle(AIS_InteractiveObject)& theIObj, |
1224 | const Standard_Boolean theToUpdateViewer); |
1225 | |
1226 | //! hilights/unhilights displayed objects which are displayed at neutral state with subintensity color. |
1227 | //! Available only for active local context. |
1228 | //! No effect if no local context. |
1229 | Standard_EXPORT void SubIntensityOn (const Standard_Boolean theToUpdateViewer); |
1230 | |
1231 | //! Removes subintensity option for all objects. |
1232 | Standard_EXPORT void SubIntensityOff (const Standard_Boolean theToUpdateViewer); |
c3282ec1 |
1233 | |
d21ddc4f |
1234 | protected: //! @name internal methods |
42cf5bc1 |
1235 | |
42cf5bc1 |
1236 | Standard_EXPORT void GetDefModes (const Handle(AIS_InteractiveObject)& anIobj, Standard_Integer& Dmode, Standard_Integer& HiMod, Standard_Integer& SelMode) const; |
1237 | |
0577ae8c |
1238 | Standard_EXPORT void EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj, |
1239 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
1240 | |
0577ae8c |
1241 | Standard_EXPORT void ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj, |
1242 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
1243 | |
0577ae8c |
1244 | Standard_EXPORT void ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theObj, |
1245 | const Standard_Integer theMode, |
1246 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
1247 | |
1248 | Standard_EXPORT void InitAttributes(); |
1249 | |
1250 | Standard_EXPORT Standard_Integer PurgeViewer (const Handle(V3d_Viewer)& Vwr); |
1251 | |
1252 | //! UNKNOWN |
0577ae8c |
1253 | Standard_EXPORT void redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj, |
1254 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
1255 | |
1256 | //! UNKNOWN |
0577ae8c |
1257 | Standard_EXPORT void redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj, |
1258 | const Standard_Boolean theToUpdateViewer); |
42cf5bc1 |
1259 | |
c3282ec1 |
1260 | //! Helper function to unhighlight all entity owners currently highlighted with seleciton color. |
e5b8456d |
1261 | Standard_EXPORT void unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject); |
c3282ec1 |
1262 | |
8e5fb5ea |
1263 | //! Helper function that highlights the owner given with <theStyle> without |
c3282ec1 |
1264 | //! performing AutoHighlight checks, e.g. is used for dynamic highlight. |
e5b8456d |
1265 | Standard_EXPORT void highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner, |
e5b8456d |
1266 | const Handle(V3d_Viewer)& theViewer = NULL); |
c3282ec1 |
1267 | |
8e5fb5ea |
1268 | //! Helper function that highlights the owner given with <theStyle> with check |
c3282ec1 |
1269 | //! for AutoHighlight, e.g. is used for selection. |
8e5fb5ea |
1270 | Standard_EXPORT void highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner); |
1271 | |
1272 | //! Helper function that highlights global owner of the object given with <theStyle> with check |
1273 | //! for AutoHighlight, e.g. is used for selection. |
1274 | //! If global owner is null, it simply highlights the whole object |
1275 | Standard_EXPORT void highlightGlobal (const Handle(AIS_InteractiveObject)& theObj, |
f838dac4 |
1276 | const Handle(Prs3d_Drawer)& theStyle, |
1277 | const Standard_Integer theDispMode) const; |
c3282ec1 |
1278 | |
b4006117 |
1279 | //! Helper function that unhighlights all owners that are stored in current AIS_Selection. |
1280 | //! The function updates global status and selection state of owner and interactive object. |
1281 | //! If the parameter <theIsToHilightSubIntensity> is set to true, interactive objects with sub-intensity |
1282 | //! switched on in AIS_GlobalStatus will be highlighted with context's sub-intensity color. |
e5b8456d |
1283 | Standard_EXPORT void unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity = Standard_False); |
1284 | |
8e5fb5ea |
1285 | //! Helper function that unhighlights global selection owner of given interactive. |
1286 | //! The function does not perform any updates of global or owner status |
f838dac4 |
1287 | Standard_EXPORT void unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) const; |
8e5fb5ea |
1288 | |
1289 | //! Helper function that turns on sub-intensity in global status and highlights |
1290 | //! given objects with sub-intensity color |
1291 | //! @param theObject [in] the object. If NULL is given, than sub-intensity will be turned on for |
1292 | //! all inveractive objects of the context |
1293 | //! @param theDispMode [in] display mode. If -1 is given, sub-intensity will be turned on for |
1294 | //! all display modes in global status's list of modes |
1295 | //! @param theIsDisplayedOnly [in] is true if sub-intensity should be applied only to objects with |
1296 | //! status AIS_DS_Displayed |
1297 | Standard_EXPORT void turnOnSubintensity (const Handle(AIS_InteractiveObject)& theObject = NULL, |
1298 | const Standard_Integer theDispMode = -1, |
1299 | const Standard_Boolean theIsDisplayedOnly = Standard_True) const; |
1300 | |
1301 | //! Helper function that highlights the object with sub-intensity color without any checks |
1302 | //! @param theObject [in] the object that will be highlighted |
1303 | //! @param theMode [in] display mode |
1304 | Standard_EXPORT void highlightWithSubintensity (const Handle(AIS_InteractiveObject)& theObject, |
1305 | const Standard_Integer theMode) const; |
1306 | |
1307 | //! Helper function that highlights the owner with sub-intensity color without any checks |
1308 | //! @param theOwner [in] the owner that will be highlighted |
1309 | //! @param theMode [in] display mode |
1310 | Standard_EXPORT void highlightWithSubintensity (const Handle(SelectMgr_EntityOwner)& theOwner, |
1311 | const Standard_Integer theMode) const; |
1312 | |
1313 | //! Helper function that returns correct dynamic highlight style for the object: |
1314 | //! if custom style is defined via object's highlight drawer, it will be used. Otherwise, |
1315 | //! dynamic highlight style of interactive context will be returned. |
1316 | //! @param theObj [in] the object to check |
f838dac4 |
1317 | const Handle(Prs3d_Drawer)& getHiStyle (const Handle(AIS_InteractiveObject)& theObj, |
1318 | const Handle(SelectMgr_EntityOwner)& theOwner) const |
8e5fb5ea |
1319 | { |
f838dac4 |
1320 | const Handle(Prs3d_Drawer)& aHiDrawer = theObj->DynamicHilightAttributes(); |
1321 | if (!aHiDrawer.IsNull()) |
1322 | { |
1323 | return aHiDrawer; |
1324 | } |
1325 | |
1326 | return myStyles[!theOwner.IsNull() && theOwner->ComesFromDecomposition() ? Prs3d_TypeOfHighlight_LocalDynamic : Prs3d_TypeOfHighlight_Dynamic]; |
8e5fb5ea |
1327 | } |
1328 | |
1329 | //! Helper function that returns correct selection style for the object: |
1330 | //! if custom style is defined via object's highlight drawer, it will be used. Otherwise, |
1331 | //! selection style of interactive context will be returned. |
1332 | //! @param theObj [in] the object to check |
f838dac4 |
1333 | const Handle(Prs3d_Drawer)& getSelStyle (const Handle(AIS_InteractiveObject)& theObj, |
1334 | const Handle(SelectMgr_EntityOwner)& theOwner) const |
8e5fb5ea |
1335 | { |
1336 | const Handle(Prs3d_Drawer)& aHiDrawer = theObj->HilightAttributes(); |
f838dac4 |
1337 | if (!aHiDrawer.IsNull()) |
1338 | { |
1339 | return aHiDrawer; |
1340 | } |
1341 | |
1342 | return myStyles[!theOwner.IsNull() && theOwner->ComesFromDecomposition() ? Prs3d_TypeOfHighlight_LocalSelected : Prs3d_TypeOfHighlight_Selected]; |
8e5fb5ea |
1343 | } |
1344 | |
2ec85268 |
1345 | //! Assign the context to the object or throw exception if object was already assigned to another context. |
1346 | void setContextToObject (const Handle(AIS_InteractiveObject)& theObj) |
1347 | { |
1348 | if (theObj->HasInteractiveContext()) |
1349 | { |
1350 | if (theObj->myCTXPtr != this) |
1351 | { |
9775fa61 |
1352 | throw Standard_ProgramError("AIS_InteractiveContext - object has been already displayed in another context!"); |
2ec85268 |
1353 | } |
1354 | } |
1355 | else |
1356 | { |
1357 | theObj->SetContext (this); |
1358 | } |
1359 | } |
1360 | |
f838dac4 |
1361 | //! Return display mode for highlighting. |
1362 | Standard_Integer getHilightMode (const Handle(AIS_InteractiveObject)& theObj, |
1363 | const Handle(Prs3d_Drawer)& theStyle, |
1364 | const Standard_Integer theDispMode) const |
1365 | { |
1366 | if (!theStyle.IsNull() |
1367 | && theStyle->DisplayMode() != -1 |
1368 | && theObj->AcceptDisplayMode (theStyle->DisplayMode())) |
1369 | { |
1370 | return theStyle->DisplayMode(); |
1371 | } |
1372 | else if (theDispMode != -1) |
1373 | { |
1374 | return theDispMode; |
1375 | } |
1376 | else if (theObj->HasDisplayMode()) |
1377 | { |
1378 | return theObj->DisplayMode(); |
1379 | } |
1380 | return myDefaultDrawer->DisplayMode(); |
1381 | } |
1382 | |
731c9b5b |
1383 | //! Removes dynamic highlight draw |
1384 | void clearDynamicHighlight() const |
1385 | { |
1386 | if (myLastinMain.IsNull()) |
1387 | return; |
1388 | |
1389 | if (myLastinMain->IsAutoHilight()) |
1390 | { |
1391 | myMainPM->ClearImmediateDraw(); |
1392 | } |
1393 | else |
1394 | { |
1395 | myLastinMain->Selectable()->ClearDynamicHighlight (myMainPM); |
1396 | } |
1397 | } |
1398 | |
d21ddc4f |
1399 | protected: //! @name internal fields |
b4006117 |
1400 | |
42cf5bc1 |
1401 | AIS_DataMapOfIOStatus myObjects; |
1402 | Handle(SelectMgr_SelectionManager) mgrSelector; |
1403 | Handle(PrsMgr_PresentationManager3d) myMainPM; |
1404 | Handle(V3d_Viewer) myMainVwr; |
1405 | Handle(StdSelect_ViewerSelector3d) myMainSel; |
c3282ec1 |
1406 | Handle(SelectMgr_EntityOwner) myLastPicked; |
1407 | Handle(SelectMgr_EntityOwner) myLastinMain; |
42cf5bc1 |
1408 | Standard_Boolean myWasLastMain; |
42cf5bc1 |
1409 | Standard_Boolean myToHilightSelected; |
f838dac4 |
1410 | Handle(AIS_Selection) mySelection; |
42cf5bc1 |
1411 | Handle(SelectMgr_OrFilter) myFilters; |
1412 | Handle(Prs3d_Drawer) myDefaultDrawer; |
f838dac4 |
1413 | Handle(Prs3d_Drawer) myStyles[Prs3d_TypeOfHighlight_NB]; |
42cf5bc1 |
1414 | AIS_DataMapOfILC myLocalContexts; |
1415 | Standard_Integer myCurLocalIndex; |
f0cddd16 |
1416 | TColStd_SequenceOfInteger myDetectedSeq; |
1417 | Standard_Integer myCurDetected; |
1418 | Standard_Integer myCurHighlighted; |
14c4193d |
1419 | SelectMgr_PickingStrategy myPickingStrategy; //!< picking strategy to be applied within MoveTo() |
42cf5bc1 |
1420 | Standard_Boolean myIsAutoActivateSelMode; |
1421 | |
42cf5bc1 |
1422 | }; |
1423 | |
2ec85268 |
1424 | DEFINE_STANDARD_HANDLE(AIS_InteractiveContext, Standard_Transient) |
42cf5bc1 |
1425 | |
42cf5bc1 |
1426 | #endif // _AIS_InteractiveContext_HeaderFile |