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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _SelectMgr_Selection_HeaderFile
18 #define _SelectMgr_Selection_HeaderFile
20 #include <NCollection_Vector.hxx>
22 #include <Standard.hxx>
23 #include <Standard_Type.hxx>
24 #include <Standard_Type.hxx>
26 #include <SelectMgr_TypeOfUpdate.hxx>
27 #include <MMgt_TShared.hxx>
28 #include <SelectMgr_SensitiveEntity.hxx>
29 #include <SelectMgr_StateOfSelection.hxx>
30 #include <SelectMgr_TypeOfBVHUpdate.hxx>
32 class Standard_NullObject;
33 class SelectBasics_SensitiveEntity;
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:
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.
70 class SelectMgr_Selection : public MMgt_TShared
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);
79 Standard_EXPORT ~SelectMgr_Selection();
81 Standard_EXPORT void Destroy();
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);
88 //! empties the selection from all the stored entities
89 Standard_EXPORT void Clear();
91 //! returns true if no sensitive entity is stored.
92 Standard_EXPORT Standard_Boolean IsEmpty() const;
94 //! returns the selection mode represented by this selection
95 Standard_Integer Mode() const;
97 //! Begins an iteration scanning for sensitive primitives.
100 //! Continues the iteration scanning for sensitive
101 //! primitives with the mode defined in this framework.
102 Standard_Boolean More() const;
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.
109 //! Returns any sensitive primitive in this framework.
110 const Handle(SelectMgr_SensitiveEntity)& Sensitive() const;
112 //! Returns the flag UpdateFlag.
113 //! This flage gives the update status of this framework
114 //! in a ViewerSelector object:
118 SelectMgr_TypeOfUpdate UpdateStatus() const;
120 void UpdateStatus (const SelectMgr_TypeOfUpdate theStatus);
122 void UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus);
124 SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const;
126 //! Returns status of selection
127 Standard_EXPORT const SelectMgr_StateOfSelection GetSelectionState() const;
129 //! Sets status of selection
130 Standard_EXPORT void SetSelectionState (const SelectMgr_StateOfSelection theState) const;
132 //! Returns sensitivity of the selection
133 Standard_EXPORT Standard_Integer Sensitivity() const;
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);
140 DEFINE_STANDARD_RTTI (SelectMgr_Selection, MMgt_TShared)
144 //! Returns sensitive entity stored by index theIdx in entites vector
145 Standard_EXPORT Handle(SelectMgr_SensitiveEntity)& GetEntityById (const Standard_Integer theIdx);
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;
155 Standard_Integer mySensFactor;
156 Standard_Boolean myIsCustomSens;
159 DEFINE_STANDARD_HANDLE(SelectMgr_Selection, MMgt_TShared)
161 #include <SelectMgr_Selection.lxx>