0029938: Visualization - SelectMgr_ViewerSelector::PickedPoint() should return point...
[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>
f751596e 21#include <SelectMgr_SensitiveEntity.hxx>
22#include <SelectMgr_StateOfSelection.hxx>
23#include <SelectMgr_TypeOfBVHUpdate.hxx>
b5cce1ab 24#include <SelectMgr_TypeOfUpdate.hxx>
f751596e 25
f751596e 26class SelectBasics_SensitiveEntity;
27
f751596e 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:
47//! - AIS_Point
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.
25e59720 63class SelectMgr_Selection : public Standard_Transient
f751596e 64{
b5cce1ab 65 DEFINE_STANDARD_RTTIEXT(SelectMgr_Selection, Standard_Transient)
f751596e 66public:
67
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);
71
1f3913c6 72 Standard_EXPORT ~SelectMgr_Selection();
f751596e 73
74 Standard_EXPORT void Destroy();
75
b5cce1ab 76 //! Adds the sensitive primitive to the list of stored entities in this object.
f751596e 77 //! Raises NullObject if the primitive is a null handle.
78 Standard_EXPORT void Add (const Handle(SelectBasics_SensitiveEntity)& theSensitive);
79
80 //! empties the selection from all the stored entities
81 Standard_EXPORT void Clear();
82
83 //! returns true if no sensitive entity is stored.
b5cce1ab 84 Standard_Boolean IsEmpty() const { return myEntities.IsEmpty(); }
f751596e 85
86 //! returns the selection mode represented by this selection
b5cce1ab 87 Standard_Integer Mode() const { return myMode; }
88
89 //! Return entities.
90 const NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>& Entities() const { return myEntities; }
91
92 //! Return entities.
93 NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>& ChangeEntities() { return myEntities; }
f751596e 94
95 //! Begins an iteration scanning for sensitive primitives.
b5cce1ab 96 Standard_DEPRECATED("Deprecated method, Entities() should be used instead")
97 void Init() { myEntityIter = myEntities.Lower(); }
f751596e 98
99 //! Continues the iteration scanning for sensitive
100 //! primitives with the mode defined in this framework.
b5cce1ab 101 Standard_DEPRECATED("Deprecated method, Entities() should be used instead")
102 Standard_Boolean More() const { return myEntityIter <= myEntities.Upper(); }
f751596e 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.
b5cce1ab 107 Standard_DEPRECATED("Deprecated method, Entities() should be used instead")
108 void Next() { ++myEntityIter; }
f751596e 109
110 //! Returns any sensitive primitive in this framework.
b5cce1ab 111 Standard_DEPRECATED("Deprecated method, Entities() should be used instead")
112 const Handle(SelectMgr_SensitiveEntity)& Sensitive() const { return myEntities.Value (myEntityIter); }
f751596e 113
114 //! Returns the flag UpdateFlag.
115 //! This flage gives the update status of this framework
116 //! in a ViewerSelector object:
117 //! - full
118 //! - partial, or
119 //! - none.
b5cce1ab 120 SelectMgr_TypeOfUpdate UpdateStatus() const { return myUpdateStatus; }
f751596e 121
b5cce1ab 122 void UpdateStatus (const SelectMgr_TypeOfUpdate theStatus) { myUpdateStatus = theStatus; }
f751596e 123
b5cce1ab 124 void UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus) { myBVHUpdateStatus = theStatus; }
f751596e 125
b5cce1ab 126 SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const { return myBVHUpdateStatus; }
f751596e 127
128 //! Returns status of selection
b5cce1ab 129 SelectMgr_StateOfSelection GetSelectionState() const { return mySelectionState; }
f751596e 130
131 //! Sets status of selection
b5cce1ab 132 void SetSelectionState (const SelectMgr_StateOfSelection theState) const { mySelectionState = theState; }
f751596e 133
134 //! Returns sensitivity of the selection
b5cce1ab 135 Standard_Integer Sensitivity() const { return mySensFactor; }
f751596e 136
8a1170ad 137 //! Changes sensitivity of the selection and all its entities to the given value.
138 //! IMPORTANT: This method does not update any outer selection structures, so for
139 //! proper updates use SelectMgr_SelectionManager::SetSelectionSensitivity method.
140 Standard_EXPORT void SetSensitivity (const Standard_Integer theNewSens);
141
f751596e 142private:
143
b5cce1ab 144 NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> myEntities;
145 Standard_Integer myEntityIter;
146 Standard_Integer myMode;
147 SelectMgr_TypeOfUpdate myUpdateStatus;
148 mutable SelectMgr_StateOfSelection mySelectionState;
149 mutable SelectMgr_TypeOfBVHUpdate myBVHUpdateStatus;
150 Standard_Integer mySensFactor;
151 Standard_Boolean myIsCustomSens;
f751596e 152};
153
25e59720 154DEFINE_STANDARD_HANDLE(SelectMgr_Selection, Standard_Transient)
f751596e 155
f751596e 156#endif