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