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_NArray1OfEntityOwner.hxx>
21 #include <AIS_NListOfEntityOwner.hxx>
22 #include <AIS_SelectionScheme.hxx>
23 #include <AIS_SelectStatus.hxx>
24 #include <Standard.hxx>
25 #include <Standard_Type.hxx>
27 class SelectMgr_Filter;
29 //! Class holding the list of selected owners.
30 class AIS_Selection : public Standard_Transient
32 DEFINE_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
35 //! creates a new selection.
36 Standard_EXPORT AIS_Selection();
38 //! removes all the object of the selection.
39 Standard_EXPORT virtual void Clear();
41 //! if the object is not yet in the selection, it will be added.
42 //! if the object is already in the selection, it will be removed.
43 Standard_EXPORT virtual AIS_SelectStatus Select (const Handle(SelectMgr_EntityOwner)& theObject);
45 //! the object is always add int the selection.
46 //! faster when the number of objects selected is great.
47 Standard_EXPORT virtual AIS_SelectStatus AddSelect (const Handle(SelectMgr_EntityOwner)& theObject);
49 //! clears the selection and adds the object in the selection.
50 virtual void ClearAndSelect (const Handle(SelectMgr_EntityOwner)& theObject)
56 //! checks if the object is in the selection.
57 Standard_Boolean IsSelected (const Handle(SelectMgr_EntityOwner)& theObject) const { return myResultMap.IsBound (theObject); }
59 //! Return the list of selected objects.
60 const AIS_NListOfEntityOwner& Objects() const { return myresult; }
62 //! Return the number of selected objects.
63 Standard_Integer Extent() const { return myresult.Size(); }
65 //! Return true if list of selected objects is empty.
66 Standard_Boolean IsEmpty() const { return myresult.IsEmpty(); }
70 //! Start iteration through selected objects.
71 void Init() { myIterator = AIS_NListOfEntityOwner::Iterator(myresult); }
73 //! Return true if iterator points to selected object.
74 Standard_Boolean More() const { return myIterator.More(); }
76 //! Continue iteration through selected objects.
77 void Next() { myIterator.Next(); }
79 //! Return selected object at iterator position.
80 const Handle(SelectMgr_EntityOwner)& Value() const { return myIterator.Value(); }
82 //! Select or deselect owners depending on the selection scheme.
83 //! @param theOwners [in] elements to change selection state
84 //! @param theSelScheme [in] selection scheme, defines how owner is selected
85 //! @param theToAllowSelOverlap [in] selection flag, if true - overlapped entities are allowed
86 //! @param theFilter [in] context filter to skip not acceptable owners
87 Standard_EXPORT virtual void SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwners,
88 const AIS_SelectionScheme theSelScheme,
89 const Standard_Boolean theToAllowSelOverlap,
90 const Handle(SelectMgr_Filter)& theFilter);
94 //! Append the owner into the current selection if filter is Ok.
95 //! @param theOwner [in] element to change selection state
96 //! @param theFilter [in] context filter to skip not acceptable owners
97 //! @return result of selection
98 Standard_EXPORT virtual AIS_SelectStatus appendOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
99 const Handle(SelectMgr_Filter)& theFilter);
103 AIS_NListOfEntityOwner myresult;
104 AIS_NListOfEntityOwner::Iterator myIterator;
105 NCollection_DataMap<Handle(SelectMgr_EntityOwner), AIS_NListOfEntityOwner::Iterator> myResultMap;
109 DEFINE_STANDARD_HANDLE(AIS_Selection, Standard_Transient)
111 #endif // _AIS_Selection_HeaderFile