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 <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <TCollection_AsciiString.hxx>
24 #include <AIS_NListTransient.hxx>
25 #include <AIS_NListIteratorOfListTransient.hxx>
26 #include <AIS_NDataMapOfTransientIteratorOfListTransient.hxx>
27 #include <Standard_Integer.hxx>
28 #include <MMgt_TShared.hxx>
29 #include <Standard_CString.hxx>
30 #include <Standard_Boolean.hxx>
31 #include <AIS_SelectStatus.hxx>
32 class Standard_NoSuchObject;
33 class Standard_MultiplyDefined;
34 class Standard_TypeMismatch;
35 class Standard_Transient;
39 DEFINE_STANDARD_HANDLE(AIS_Selection, MMgt_TShared)
42 class AIS_Selection : public MMgt_TShared
48 //! creates a new selection and make it current in the session.
49 //! the selection will be accessible later through its name
50 //! to make it again current.
52 //! Note that if a session has been created, a session with
53 //! the name "default" is created.
55 //! In this case, the is always a current selection which
56 //! is the last one created until SetCurrentSelection is used.
58 //! The class methods deals with the current selection.
60 //! Warning : Better Call AIS_Selection::CreateSelection.
61 Standard_EXPORT AIS_Selection(const Standard_CString aName);
63 Standard_EXPORT static void Remove (const Standard_CString aName);
65 //! returns True if a selection having this name exsits.
66 Standard_EXPORT static Standard_Boolean Find (const Standard_CString aName);
68 //! calls the private constructor and puts the new Selection
69 //! in the list of existing selections.
70 //! returns False if the selection exists.
71 Standard_EXPORT static Standard_Boolean CreateSelection (const Standard_CString aName);
73 Standard_EXPORT static Handle(AIS_Selection) Selection (const Standard_CString aName);
75 //! returns False if There is no selection of name <aName>
76 Standard_EXPORT static Standard_Boolean SetCurrentSelection (const Standard_CString aName);
78 Standard_EXPORT static Handle(AIS_Selection) CurrentSelection();
81 Standard_EXPORT static void ClearCurrentSelection();
83 //! removes all the object of the currentselection.
84 Standard_EXPORT static void Select();
86 //! if the object is not yet in the current selection, it will be added.
87 //! if the object is already in the current selection, it will be removed.
88 Standard_EXPORT static AIS_SelectStatus Select (const Handle(Standard_Transient)& anObject);
90 //! the object is always add int the selection.
91 //! faster when the number of objects selected is great.
92 Standard_EXPORT static AIS_SelectStatus AddSelect (const Handle(Standard_Transient)& anObject);
94 //! clears the selection and adds the object in the selection.
95 Standard_EXPORT static void ClearAndSelect (const Handle(Standard_Transient)& anObject);
97 Standard_EXPORT static Standard_Boolean IsSelected (const Handle(Standard_Transient)& anObject);
99 //! returns the number of objects selected.
100 Standard_EXPORT static Standard_Integer Extent();
102 //! returns the single object selected.
103 //! Warning: raises TypeMismatch from Standard if Extent is not equal to 1.
104 Standard_EXPORT static Handle(Standard_Transient) Single();
108 Standard_Boolean More() const;
112 const Handle(Standard_Transient)& Value() const;
114 Standard_Integer NbStored() const;
116 const AIS_NListTransient& Objects() const;
118 Standard_EXPORT static Standard_Integer Index (const Standard_CString aName);
123 DEFINE_STANDARD_RTTIEXT(AIS_Selection,MMgt_TShared)
133 TCollection_AsciiString myName;
134 AIS_NListTransient myresult;
135 AIS_NListIteratorOfListTransient myIterator;
136 AIS_NDataMapOfTransientIteratorOfListTransient myResultMap;
137 Standard_Integer myNb;
143 #include <AIS_Selection.lxx>
149 #endif // _AIS_Selection_HeaderFile