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