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