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
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 _AIS_Selection_HeaderFile
18 #define _AIS_Selection_HeaderFile
20 #include <AIS_NListOfEntityOwner.hxx>
21 #include <AIS_SelectStatus.hxx>
22 #include <Standard.hxx>
23 #include <Standard_Type.hxx>
25 //! Class holding the list of selected owners.
26 class AIS_Selection : public Standard_Transient
28 DEFINE_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
31 //! creates a new selection.
32 Standard_EXPORT AIS_Selection();
34 //! removes all the object of the selection.
35 Standard_EXPORT virtual void Clear();
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);
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);
45 //! clears the selection and adds the object in the selection.
46 virtual void ClearAndSelect (const Handle(SelectMgr_EntityOwner)& theObject)
52 //! checks if the object is in the selection.
53 Standard_Boolean IsSelected (const Handle(SelectMgr_EntityOwner)& theObject) const { return myResultMap.IsBound (theObject); }
55 //! Return the list of selected objects.
56 const AIS_NListOfEntityOwner& Objects() const { return myresult; }
58 //! Return the number of selected objects.
59 Standard_Integer Extent() const { return myresult.Size(); }
61 //! Return true if list of selected objects is empty.
62 Standard_Boolean IsEmpty() const { return myresult.IsEmpty(); }
66 //! Start iteration through selected objects.
67 void Init() { myIterator = AIS_NListOfEntityOwner::Iterator(myresult); }
69 //! Return true if iterator points to selected object.
70 Standard_Boolean More() const { return myIterator.More(); }
72 //! Continue iteration through selected objects.
73 void Next() { myIterator.Next(); }
75 //! Return selected object at iterator position.
76 const Handle(SelectMgr_EntityOwner)& Value() const { return myIterator.Value(); }
80 AIS_NListOfEntityOwner myresult;
81 AIS_NListOfEntityOwner::Iterator myIterator;
82 NCollection_DataMap<Handle(SelectMgr_EntityOwner), AIS_NListOfEntityOwner::Iterator> myResultMap;
86 DEFINE_STANDARD_HANDLE(AIS_Selection, Standard_Transient)
88 #endif // _AIS_Selection_HeaderFile