0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / AIS / AIS_Selection.hxx
1 // Created on: 1995-03-21
2 // Created by: Jean-Louis Frenkel
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 _AIS_Selection_HeaderFile
18 #define _AIS_Selection_HeaderFile
19
20 #include <AIS_NListOfEntityOwner.hxx>
21 #include <AIS_SelectStatus.hxx>
22 #include <Standard.hxx>
23 #include <Standard_Type.hxx>
24
25 //! Class holding the list of selected owners.
26 class AIS_Selection : public Standard_Transient
27 {
28   DEFINE_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
29 public:
30
31   //! creates a new selection.
32   Standard_EXPORT AIS_Selection();
33   
34   //! removes all the object of the selection.
35   Standard_EXPORT virtual void Clear();
36   
37   //! if the object is not yet in the selection, it will be added.
38   //! if the object is already in the selection, it will be removed.
39   Standard_EXPORT virtual AIS_SelectStatus Select (const Handle(SelectMgr_EntityOwner)& theObject);
40   
41   //! the object is always add int the selection.
42   //! faster when the number of objects selected is great.
43   Standard_EXPORT virtual AIS_SelectStatus AddSelect (const Handle(SelectMgr_EntityOwner)& theObject);
44
45   //! clears the selection and adds the object in the selection.
46   virtual void ClearAndSelect (const Handle(SelectMgr_EntityOwner)& theObject)
47   {
48     Clear();
49     Select (theObject);
50   }
51
52   //! checks if the object is in the selection.
53   Standard_Boolean IsSelected (const Handle(SelectMgr_EntityOwner)& theObject) const { return myResultMap.IsBound (theObject); }
54
55   //! Return the list of selected objects.
56   const AIS_NListOfEntityOwner& Objects() const { return myresult; }
57
58   //! Return the number of selected objects.
59   Standard_Integer Extent() const { return myresult.Size(); }
60
61   //! Return true if list of selected objects is empty.
62   Standard_Boolean IsEmpty() const { return myresult.IsEmpty(); }
63
64 public:
65
66   //! Start iteration through selected objects.
67   void Init() { myIterator = AIS_NListOfEntityOwner::Iterator(myresult); }
68
69   //! Return true if iterator points to selected object.
70   Standard_Boolean More() const { return myIterator.More(); }
71
72   //! Continue iteration through selected objects.
73   void Next() { myIterator.Next(); }
74
75   //! Return selected object at iterator position.
76   const Handle(SelectMgr_EntityOwner)& Value() const { return myIterator.Value(); }
77
78 private:
79
80   AIS_NListOfEntityOwner myresult;
81   AIS_NListOfEntityOwner::Iterator myIterator;
82   NCollection_DataMap<Handle(SelectMgr_EntityOwner), AIS_NListOfEntityOwner::Iterator> myResultMap;
83
84 };
85
86 DEFINE_STANDARD_HANDLE(AIS_Selection, Standard_Transient)
87
88 #endif // _AIS_Selection_HeaderFile