0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[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
0ef04197 26class Select3D_SensitiveEntity;
f751596e 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.
0ef04197 78 Standard_EXPORT void Add (const Handle(Select3D_SensitiveEntity)& theSensitive);
f751596e 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
f751596e 95 //! Returns the flag UpdateFlag.
96 //! This flage gives the update status of this framework
97 //! in a ViewerSelector object:
98 //! - full
99 //! - partial, or
100 //! - none.
b5cce1ab 101 SelectMgr_TypeOfUpdate UpdateStatus() const { return myUpdateStatus; }
f751596e 102
b5cce1ab 103 void UpdateStatus (const SelectMgr_TypeOfUpdate theStatus) { myUpdateStatus = theStatus; }
f751596e 104
b5cce1ab 105 void UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus) { myBVHUpdateStatus = theStatus; }
f751596e 106
b5cce1ab 107 SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const { return myBVHUpdateStatus; }
f751596e 108
109 //! Returns status of selection
b5cce1ab 110 SelectMgr_StateOfSelection GetSelectionState() const { return mySelectionState; }
f751596e 111
112 //! Sets status of selection
b5cce1ab 113 void SetSelectionState (const SelectMgr_StateOfSelection theState) const { mySelectionState = theState; }
f751596e 114
115 //! Returns sensitivity of the selection
b5cce1ab 116 Standard_Integer Sensitivity() const { return mySensFactor; }
f751596e 117
8a1170ad 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);
122
bc73b006 123 //! Dumps the content of me into the stream
124 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
125
f751596e 126private:
127
b5cce1ab 128 NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> myEntities;
b5cce1ab 129 Standard_Integer myMode;
130 SelectMgr_TypeOfUpdate myUpdateStatus;
131 mutable SelectMgr_StateOfSelection mySelectionState;
132 mutable SelectMgr_TypeOfBVHUpdate myBVHUpdateStatus;
133 Standard_Integer mySensFactor;
134 Standard_Boolean myIsCustomSens;
f751596e 135};
136
25e59720 137DEFINE_STANDARD_HANDLE(SelectMgr_Selection, Standard_Transient)
f751596e 138
f751596e 139#endif