0026641: Visualization, TKOpenGl - handle correctly transformation persistence within...
[occt.git] / src / SelectMgr / SelectMgr_Selection.hxx
CommitLineData
f751596e 1// Created on: 1995-02-16
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_Selection_HeaderFile
18#define _SelectMgr_Selection_HeaderFile
19
f751596e 20#include <NCollection_Vector.hxx>
21
22#include <Standard.hxx>
23#include <Standard_Type.hxx>
ec357c5c 24#include <Standard_Type.hxx>
f751596e 25
26#include <SelectMgr_TypeOfUpdate.hxx>
27#include <MMgt_TShared.hxx>
f751596e 28#include <SelectMgr_SensitiveEntity.hxx>
29#include <SelectMgr_StateOfSelection.hxx>
30#include <SelectMgr_TypeOfBVHUpdate.hxx>
31
32class Standard_NullObject;
33class SelectBasics_SensitiveEntity;
34
f751596e 35//! Represents the state of a given selection mode for a
36//! Selectable Object. Contains all the sensitive entities available for this mode.
37//! An interactive object can have an indefinite number of
38//! modes of selection, each representing a
39//! "decomposition" into sensitive primitives; each
40//! primitive has an Owner (SelectMgr_EntityOwner)
41//! which allows us to identify the exact entity which has
42//! been detected. Each Selection mode is identified by
43//! an index. The set of sensitive primitives which
44//! correspond to a given mode is stocked in a
45//! SelectMgr_Selection object. By Convention, the
46//! default selection mode which allows us to grasp the
47//! Interactive object in its entirety will be mode 0.
48//! AIS_Trihedron : 4 selection modes
49//! - mode 0 : selection of a trihedron
50//! - mode 1 : selection of the origin of the trihedron
51//! - mode 2 : selection of the axes
52//! - mode 3 : selection of the planes XOY, YOZ, XOZ
53//! when you activate one of modes 1 2 3 4 , you pick AIS objects of type:
54//! - AIS_Point
55//! - AIS_Axis (and information on the type of axis)
56//! - AIS_Plane (and information on the type of plane).
57//! AIS_PlaneTrihedron offers 3 selection modes:
58//! - mode 0 : selection of the whole trihedron
59//! - mode 1 : selection of the origin of the trihedron
60//! - mode 2 : selection of the axes - same remarks as for the Trihedron.
61//! AIS_Shape : 7 maximum selection modes, depending
62//! on the complexity of the shape :
63//! - mode 0 : selection of the AIS_Shape
64//! - mode 1 : selection of the vertices
65//! - mode 2 : selection of the edges
66//! - mode 3 : selection of the wires
67//! - mode 4 : selection of the faces
68//! - mode 5 : selection of the shells
69//! - mode 6 : selection of the constituent solids.
70class SelectMgr_Selection : public MMgt_TShared
71{
72
73public:
74
75 //! Constructs a selection object defined by the selection mode IdMode.
76 //! The default setting 0 is the selection mode for a shape in its entirety.
77 Standard_EXPORT SelectMgr_Selection (const Standard_Integer theModeIdx = 0);
78
1f3913c6 79 Standard_EXPORT ~SelectMgr_Selection();
f751596e 80
81 Standard_EXPORT void Destroy();
82
83 //! Adds the sensitive primitive aprimitive to the list of
84 //! stored entities in this object.
85 //! Raises NullObject if the primitive is a null handle.
86 Standard_EXPORT void Add (const Handle(SelectBasics_SensitiveEntity)& theSensitive);
87
88 //! empties the selection from all the stored entities
89 Standard_EXPORT void Clear();
90
91 //! returns true if no sensitive entity is stored.
92 Standard_EXPORT Standard_Boolean IsEmpty() const;
93
94 //! returns the selection mode represented by this selection
95 Standard_Integer Mode() const;
96
97 //! Begins an iteration scanning for sensitive primitives.
98 void Init();
99
100 //! Continues the iteration scanning for sensitive
101 //! primitives with the mode defined in this framework.
102 Standard_Boolean More() const;
103
104 //! Returns the next sensitive primitive found in the
105 //! iteration. This is a scan for entities with the mode
106 //! defined in this framework.
107 void Next();
108
109 //! Returns any sensitive primitive in this framework.
7ab15952 110 const Handle(SelectMgr_SensitiveEntity)& Sensitive() const;
f751596e 111
112 //! Returns the flag UpdateFlag.
113 //! This flage gives the update status of this framework
114 //! in a ViewerSelector object:
115 //! - full
116 //! - partial, or
117 //! - none.
118 SelectMgr_TypeOfUpdate UpdateStatus() const;
119
120 void UpdateStatus (const SelectMgr_TypeOfUpdate theStatus);
121
122 void UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus);
123
124 SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const;
125
126 //! Returns status of selection
487bf1ce 127 Standard_EXPORT SelectMgr_StateOfSelection GetSelectionState() const;
f751596e 128
129 //! Sets status of selection
130 Standard_EXPORT void SetSelectionState (const SelectMgr_StateOfSelection theState) const;
131
132 //! Returns sensitivity of the selection
3bf9a45f 133 Standard_EXPORT Standard_Integer Sensitivity() const;
f751596e 134
8a1170ad 135 //! Changes sensitivity of the selection and all its entities to the given value.
136 //! IMPORTANT: This method does not update any outer selection structures, so for
137 //! proper updates use SelectMgr_SelectionManager::SetSelectionSensitivity method.
138 Standard_EXPORT void SetSensitivity (const Standard_Integer theNewSens);
139
92efcf78 140 DEFINE_STANDARD_RTTIEXT(SelectMgr_Selection,MMgt_TShared)
f751596e 141
142protected:
143
144 //! Returns sensitive entity stored by index theIdx in entites vector
1f3913c6 145 Standard_EXPORT Handle(SelectMgr_SensitiveEntity)& GetEntityById (const Standard_Integer theIdx);
f751596e 146
147private:
148
7ab15952 149 NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> myEntities;
150 NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator myEntityIter;
151 Standard_Integer myMode;
152 SelectMgr_TypeOfUpdate myUpdateStatus;
153 mutable SelectMgr_StateOfSelection mySelectionState;
154 mutable SelectMgr_TypeOfBVHUpdate myBVHUpdateStatus;
3bf9a45f 155 Standard_Integer mySensFactor;
8a1170ad 156 Standard_Boolean myIsCustomSens;
f751596e 157};
158
159DEFINE_STANDARD_HANDLE(SelectMgr_Selection, MMgt_TShared)
160
161#include <SelectMgr_Selection.lxx>
162
163#endif