0026462: Visualization - selection does not adapt to line width change
[occt.git] / src / SelectMgr / SelectMgr_SelectionManager.hxx
CommitLineData
42cf5bc1 1// Created on: 1995-02-13
2// Created by: Mister rmi
3// Copyright (c) 1995-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 _SelectMgr_SelectionManager_HeaderFile
18#define _SelectMgr_SelectionManager_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <TColStd_MapOfTransient.hxx>
24#include <SelectMgr_DataMapOfObjectSelectors.hxx>
25#include <MMgt_TShared.hxx>
26#include <SelectMgr_ViewerSelector.hxx>
27#include <Standard_Boolean.hxx>
28#include <Standard_Integer.hxx>
29#include <SelectMgr_TypeOfUpdate.hxx>
30class SelectMgr_SelectableObject;
31
32
33class SelectMgr_SelectionManager;
34DEFINE_STANDARD_HANDLE(SelectMgr_SelectionManager, MMgt_TShared)
35
36//! A framework to manage selection from the point of
37//! view of viewer selectors. These can be added and
38//! removed, and selection modes can be activated and
39//! deactivated. In addition, objects may be known to all
40//! selectors or only to some.
41class SelectMgr_SelectionManager : public MMgt_TShared
42{
43
44public:
45
46
47 //! Constructs an empty selection manager object.
48 Standard_EXPORT SelectMgr_SelectionManager();
49
50 //! Adds the viewer selector theSelector to the list of known items.
51 Standard_EXPORT void Add (const Handle(SelectMgr_ViewerSelector)& theSelector);
52
53 //! Removes viewer selector theSelector from the list of known items.
54 Standard_EXPORT void Remove (const Handle(SelectMgr_ViewerSelector)& theSelector);
55
56 //! Returns true if the manager contains the viewer selector theSelector in a list of known items.
57 Standard_EXPORT Standard_Boolean Contains (const Handle(SelectMgr_ViewerSelector)& theSelector) const;
58
59 //! Returns true if the manager contains the selectable object theObject.
60 Standard_EXPORT Standard_Boolean Contains (const Handle(SelectMgr_SelectableObject)& theObject) const;
61
62 //! Loads and computes selection mode theMode (if it is not equal to -1) in global context and adds selectable
63 //! object to BVH tree. If the object theObject has an already calculated selection with mode theMode and it was removed,
64 //! the selection will be recalculated.
65 Standard_EXPORT void Load (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode = -1);
66
67 //! Loads and computes selection mode theMode (if it is not equal to -1) and adds selectable object to BVH tree.
68 //! Does not perform check of existance of theObject in global context before addition, but adds theSelector to local context.
69 Standard_EXPORT void Load (const Handle(SelectMgr_SelectableObject)& theObject, const Handle(SelectMgr_ViewerSelector)& theSelector, const Standard_Integer theMode = -1);
70
71 //! Removes selectable object theObject from all viewer selectors it was added to previously, removes it from all contexts
72 //! and clears all computed selections of theObject.
73 Standard_EXPORT void Remove (const Handle(SelectMgr_SelectableObject)& theObject);
74
75 //! Removes theObject from theSelector, does not clear selections and unbind theObject from context maps.
76 Standard_EXPORT void Remove (const Handle(SelectMgr_SelectableObject)& theObject, const Handle(SelectMgr_ViewerSelector)& theSelector);
77
78 //! Activates the selection mode theMode in the selector theSelector for the selectable object anObject.
79 //! By default, theMode is equal to 0. If theSelector is set to default (NULL), the selection with the mode theMode
80 //! will be activated in all the viewers available.
81 Standard_EXPORT void Activate (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode = 0, const Handle(SelectMgr_ViewerSelector)& theSelector = NULL);
82
83 //! Deactivates mode theMode of theObject in theSelector. If theMode value is set to default (-1), all
84 //! avtive selection modes will be deactivated. Likewise, if theSelector value is set to default (NULL), theMode
85 //! will be deactivated in all viewer selectors.
86 Standard_EXPORT void Deactivate (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode = -1, const Handle(SelectMgr_ViewerSelector)& theSelector = NULL);
87
88 //! Returns true if the selection with theMode is active for the selectable object theObject and selector theSelector.
89 //! If all parameters are set to default values, it returns it there is any active selection in any known viewer selector for
90 //! object theObject.
91 Standard_EXPORT Standard_Boolean IsActivated (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode = -1, const Handle(SelectMgr_ViewerSelector)& theSelector = NULL) const;
92
93 //! Removes sensitive entities from all viewer selectors
94 //! after method Clear() was called to the selection they belonged to
95 //! or it was recomputed somehow.
96 Standard_EXPORT void ClearSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj, const Standard_Integer theMode = -1, const Handle(SelectMgr_ViewerSelector)& theSelector = NULL);
97
98 //! Re-adds newely calculated sensitive entities of recomputed selection
99 //! defined by mode theMode to all viewer selectors contained that selection.
100 Standard_EXPORT void RestoreSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj, const Standard_Integer theMode = -1, const Handle(SelectMgr_ViewerSelector)& theSelector = NULL);
101
102 //! Recomputes activated selections of theObject for all known viewer selectors according to theMode specified.
103 //! If theMode is set to default (-1), then all activated selections will be recomputed. If theIsForce is set to true,
104 //! then selection mode theMode for object theObject will be recomputed regardless of its activation status.
105 Standard_EXPORT void RecomputeSelection (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Boolean theIsForce = Standard_False, const Standard_Integer theMode = -1);
106
107 //! Updates all selections of theObject in all viewer selectors according to its current update status.
108 //! If theIsForce is set to true, the call is equal to recomputation.
109 Standard_EXPORT void Update (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Boolean theIsForce = Standard_True);
110
111 //! Updates all selections of theObject in specified viewer selector according to its current update status.
112 //! If theIsForce is set to true, the call is equal to recomputation.
113 Standard_EXPORT void Update (const Handle(SelectMgr_SelectableObject)& theObject, const Handle(SelectMgr_ViewerSelector)& theSelector, const Standard_Boolean theIsForce = Standard_True);
114
115 //! Sets type of update of all selections of theObject to the given theType.
116 Standard_EXPORT void SetUpdateMode (const Handle(SelectMgr_SelectableObject)& theObject, const SelectMgr_TypeOfUpdate theType);
117
118 //! Sets type of update of selection with theMode of theObject to the given theType.
119 Standard_EXPORT void SetUpdateMode (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode, const SelectMgr_TypeOfUpdate theType);
120
8a1170ad 121 //! Allows to manage sensitivity of a particular selection of interactive object theObject and
122 //! changes previous sensitivity value of all sensitive entities in selection with theMode
123 //! to the given theNewSensitivity.
124 Standard_EXPORT void SetSelectionSensitivity (const Handle(SelectMgr_SelectableObject)& theObject,
125 const Standard_Integer theMode,
126 const Standard_Integer theNewSens);
42cf5bc1 127
128 DEFINE_STANDARD_RTTI(SelectMgr_SelectionManager,MMgt_TShared)
129
130protected:
131
132
133
134
135private:
136
137
138 //! Loads and creates selection structures for object theObject with mode theMode in specified
139 //! viewer selector theSelector. If theSelector is set to default value (NULL), the selection mode
140 //! created will be added to all known viewer selectors.
141 Standard_EXPORT void loadMode (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode, const Handle(SelectMgr_ViewerSelector)& theSelector = NULL);
142
143 //! Internal function that marks 1st level BVH of the object theObj as
144 //! outdated.
145 Standard_EXPORT void rebuildSelectionStructures (const Handle(SelectMgr_ViewerSelector)& theSelector = NULL);
146
147 TColStd_MapOfTransient mySelectors;
148 TColStd_MapOfTransient myGlobal;
149 SelectMgr_DataMapOfObjectSelectors myLocal;
150
151
152};
153
154
155
156
157
158
159
160#endif // _SelectMgr_SelectionManager_HeaderFile