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>
21 #include <SelectMgr_SensitiveEntity.hxx>
22 #include <SelectMgr_StateOfSelection.hxx>
23 #include <SelectMgr_TypeOfBVHUpdate.hxx>
24 #include <SelectMgr_TypeOfUpdate.hxx>
26 class Select3D_SensitiveEntity;
28 //! Represents the state of a given selection mode for a
29 //! Selectable Object. Contains all the sensitive entities available for this mode.
30 //! An interactive object can have an indefinite number of
31 //! modes of selection, each representing a
32 //! "decomposition" into sensitive primitives; each
33 //! primitive has an Owner (SelectMgr_EntityOwner)
34 //! which allows us to identify the exact entity which has
35 //! been detected. Each Selection mode is identified by
36 //! an index. The set of sensitive primitives which
37 //! correspond to a given mode is stocked in a
38 //! SelectMgr_Selection object. By Convention, the
39 //! default selection mode which allows us to grasp the
40 //! Interactive object in its entirety will be mode 0.
41 //! AIS_Trihedron : 4 selection modes
42 //! - mode 0 : selection of a trihedron
43 //! - mode 1 : selection of the origin of the trihedron
44 //! - mode 2 : selection of the axes
45 //! - mode 3 : selection of the planes XOY, YOZ, XOZ
46 //! when you activate one of modes 1 2 3 4 , you pick AIS objects of type:
48 //! - AIS_Axis (and information on the type of axis)
49 //! - AIS_Plane (and information on the type of plane).
50 //! AIS_PlaneTrihedron offers 3 selection modes:
51 //! - mode 0 : selection of the whole trihedron
52 //! - mode 1 : selection of the origin of the trihedron
53 //! - mode 2 : selection of the axes - same remarks as for the Trihedron.
54 //! AIS_Shape : 7 maximum selection modes, depending
55 //! on the complexity of the shape :
56 //! - mode 0 : selection of the AIS_Shape
57 //! - mode 1 : selection of the vertices
58 //! - mode 2 : selection of the edges
59 //! - mode 3 : selection of the wires
60 //! - mode 4 : selection of the faces
61 //! - mode 5 : selection of the shells
62 //! - mode 6 : selection of the constituent solids.
63 class SelectMgr_Selection : public Standard_Transient
65 DEFINE_STANDARD_RTTIEXT(SelectMgr_Selection, Standard_Transient)
68 //! Constructs a selection object defined by the selection mode IdMode.
69 //! The default setting 0 is the selection mode for a shape in its entirety.
70 Standard_EXPORT SelectMgr_Selection (const Standard_Integer theModeIdx = 0);
72 Standard_EXPORT ~SelectMgr_Selection();
74 Standard_EXPORT void Destroy();
76 //! Adds the sensitive primitive to the list of stored entities in this object.
77 //! Raises NullObject if the primitive is a null handle.
78 Standard_EXPORT void Add (const Handle(Select3D_SensitiveEntity)& theSensitive);
80 //! empties the selection from all the stored entities
81 Standard_EXPORT void Clear();
83 //! returns true if no sensitive entity is stored.
84 Standard_Boolean IsEmpty() const { return myEntities.IsEmpty(); }
86 //! returns the selection mode represented by this selection
87 Standard_Integer Mode() const { return myMode; }
90 const NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>& Entities() const { return myEntities; }
93 NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>& ChangeEntities() { return myEntities; }
95 //! Returns the flag UpdateFlag.
96 //! This flage gives the update status of this framework
97 //! in a ViewerSelector object:
101 SelectMgr_TypeOfUpdate UpdateStatus() const { return myUpdateStatus; }
103 void UpdateStatus (const SelectMgr_TypeOfUpdate theStatus) { myUpdateStatus = theStatus; }
105 void UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus) { myBVHUpdateStatus = theStatus; }
107 SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const { return myBVHUpdateStatus; }
109 //! Returns status of selection
110 SelectMgr_StateOfSelection GetSelectionState() const { return mySelectionState; }
112 //! Sets status of selection
113 void SetSelectionState (const SelectMgr_StateOfSelection theState) const { mySelectionState = theState; }
115 //! Returns sensitivity of the selection
116 Standard_Integer Sensitivity() const { return mySensFactor; }
118 //! Changes sensitivity of the selection and all its entities to the given value.
119 //! IMPORTANT: This method does not update any outer selection structures, so for
120 //! proper updates use SelectMgr_SelectionManager::SetSelectionSensitivity method.
121 Standard_EXPORT void SetSensitivity (const Standard_Integer theNewSens);
125 NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> myEntities;
126 Standard_Integer myMode;
127 SelectMgr_TypeOfUpdate myUpdateStatus;
128 mutable SelectMgr_StateOfSelection mySelectionState;
129 mutable SelectMgr_TypeOfBVHUpdate myBVHUpdateStatus;
130 Standard_Integer mySensFactor;
131 Standard_Boolean myIsCustomSens;
134 DEFINE_STANDARD_HANDLE(SelectMgr_Selection, Standard_Transient)