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_DefineHandle.hxx>
26 #include <SelectMgr_TypeOfUpdate.hxx>
27 #include <MMgt_TShared.hxx>
28 #include <Handle_SelectBasics_SensitiveEntity.hxx>
29 #include <SelectMgr_SensitiveEntity.hxx>
30 #include <SelectMgr_StateOfSelection.hxx>
31 #include <SelectMgr_TypeOfBVHUpdate.hxx>
33 class Standard_NullObject;
34 class SelectBasics_SensitiveEntity;
36 //! Represents the state of a given selection mode for a
37 //! Selectable Object. Contains all the sensitive entities available for this mode.
38 //! An interactive object can have an indefinite number of
39 //! modes of selection, each representing a
40 //! "decomposition" into sensitive primitives; each
41 //! primitive has an Owner (SelectMgr_EntityOwner)
42 //! which allows us to identify the exact entity which has
43 //! been detected. Each Selection mode is identified by
44 //! an index. The set of sensitive primitives which
45 //! correspond to a given mode is stocked in a
46 //! SelectMgr_Selection object. By Convention, the
47 //! default selection mode which allows us to grasp the
48 //! Interactive object in its entirety will be mode 0.
49 //! AIS_Trihedron : 4 selection modes
50 //! - mode 0 : selection of a trihedron
51 //! - mode 1 : selection of the origin of the trihedron
52 //! - mode 2 : selection of the axes
53 //! - mode 3 : selection of the planes XOY, YOZ, XOZ
54 //! when you activate one of modes 1 2 3 4 , you pick AIS objects of type:
56 //! - AIS_Axis (and information on the type of axis)
57 //! - AIS_Plane (and information on the type of plane).
58 //! AIS_PlaneTrihedron offers 3 selection modes:
59 //! - mode 0 : selection of the whole trihedron
60 //! - mode 1 : selection of the origin of the trihedron
61 //! - mode 2 : selection of the axes - same remarks as for the Trihedron.
62 //! AIS_Shape : 7 maximum selection modes, depending
63 //! on the complexity of the shape :
64 //! - mode 0 : selection of the AIS_Shape
65 //! - mode 1 : selection of the vertices
66 //! - mode 2 : selection of the edges
67 //! - mode 3 : selection of the wires
68 //! - mode 4 : selection of the faces
69 //! - mode 5 : selection of the shells
70 //! - mode 6 : selection of the constituent solids.
71 class SelectMgr_Selection : public MMgt_TShared
76 //! Constructs a selection object defined by the selection mode IdMode.
77 //! The default setting 0 is the selection mode for a shape in its entirety.
78 Standard_EXPORT SelectMgr_Selection (const Standard_Integer theModeIdx = 0);
80 ~SelectMgr_Selection();
82 Standard_EXPORT void Destroy();
84 //! Adds the sensitive primitive aprimitive to the list of
85 //! stored entities in this object.
86 //! Raises NullObject if the primitive is a null handle.
87 Standard_EXPORT void Add (const Handle(SelectBasics_SensitiveEntity)& theSensitive);
89 //! empties the selection from all the stored entities
90 Standard_EXPORT void Clear();
92 //! returns true if no sensitive entity is stored.
93 Standard_EXPORT Standard_Boolean IsEmpty() const;
95 //! returns the selection mode represented by this selection
96 Standard_Integer Mode() const;
98 //! Begins an iteration scanning for sensitive primitives.
101 //! Continues the iteration scanning for sensitive
102 //! primitives with the mode defined in this framework.
103 Standard_Boolean More() const;
105 //! Returns the next sensitive primitive found in the
106 //! iteration. This is a scan for entities with the mode
107 //! defined in this framework.
110 //! Returns any sensitive primitive in this framework.
111 const Handle(SelectMgr_SensitiveEntity)& Sensitive() const;
113 //! Returns the flag UpdateFlag.
114 //! This flage gives the update status of this framework
115 //! in a ViewerSelector object:
119 SelectMgr_TypeOfUpdate UpdateStatus() const;
121 void UpdateStatus (const SelectMgr_TypeOfUpdate theStatus);
123 void UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus);
125 SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const;
127 //! Returns status of selection
128 Standard_EXPORT const SelectMgr_StateOfSelection GetSelectionState() const;
130 //! Sets status of selection
131 Standard_EXPORT void SetSelectionState (const SelectMgr_StateOfSelection theState) const;
133 //! Returns sensitivity of the selection
134 Standard_EXPORT Standard_Real Sensitivity() const;
136 DEFINE_STANDARD_RTTI (SelectMgr_Selection)
140 //! Returns sensitive entity stored by index theIdx in entites vector
141 Handle(SelectMgr_SensitiveEntity)& GetEntityById (const Standard_Integer theIdx);
145 NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> myEntities;
146 NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator myEntityIter;
147 Standard_Integer myMode;
148 SelectMgr_TypeOfUpdate myUpdateStatus;
149 mutable SelectMgr_StateOfSelection mySelectionState;
150 mutable SelectMgr_TypeOfBVHUpdate myBVHUpdateStatus;
151 Standard_Real mySensFactor;
154 DEFINE_STANDARD_HANDLE(SelectMgr_Selection, MMgt_TShared)
156 #include <SelectMgr_Selection.lxx>