0027860: Visualization - clean up Transformation Persistence API
[occt.git] / src / AIS / AIS_Selection.hxx
CommitLineData
42cf5bc1 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
02974a19 20#include <AIS_NListOfEntityOwner.hxx>
21#include <AIS_SelectStatus.hxx>
42cf5bc1 22#include <Standard.hxx>
23#include <Standard_Type.hxx>
24
02974a19 25//! Class holding the list of selected owners.
26class AIS_Selection : public Standard_Transient
42cf5bc1 27{
02974a19 28 DEFINE_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
42cf5bc1 29public:
30
016e5959 31 //! creates a new selection.
016e5959 32 Standard_EXPORT AIS_Selection();
42cf5bc1 33
016e5959 34 //! removes all the object of the selection.
02974a19 35 Standard_EXPORT void Clear();
42cf5bc1 36
016e5959 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.
02974a19 39 Standard_EXPORT AIS_SelectStatus Select (const Handle(SelectMgr_EntityOwner)& theObject);
42cf5bc1 40
41 //! the object is always add int the selection.
42 //! faster when the number of objects selected is great.
02974a19 43 Standard_EXPORT AIS_SelectStatus AddSelect (const Handle(SelectMgr_EntityOwner)& theObject);
44
42cf5bc1 45 //! clears the selection and adds the object in the selection.
02974a19 46 void ClearAndSelect (const Handle(SelectMgr_EntityOwner)& theObject)
47 {
48 Clear();
49 Select (theObject);
50 }
016e5959 51
52 //! checks if the object is in the selection.
02974a19 53 Standard_Boolean IsSelected (const Handle(SelectMgr_EntityOwner)& theObject) const { return myResultMap.IsBound (theObject); }
42cf5bc1 54
02974a19 55 //! Return the list of selected objects.
56 const AIS_NListOfEntityOwner& Objects() const { return myresult; }
42cf5bc1 57
02974a19 58 //! Return the number of selected objects.
59 Standard_Integer Extent() const { return myresult.Size(); }
42cf5bc1 60
02974a19 61 //! Return true if list of selected objects is empty.
62 Standard_Boolean IsEmpty() const { return myresult.IsEmpty(); }
42cf5bc1 63
02974a19 64public:
42cf5bc1 65
02974a19 66 //! Start iteration through selected objects.
67 void Init() { myIterator = AIS_NListOfEntityOwner::Iterator(myresult); }
42cf5bc1 68
02974a19 69 //! Return true if iterator points to selected object.
70 Standard_Boolean More() const { return myIterator.More(); }
42cf5bc1 71
02974a19 72 //! Continue iteration through selected objects.
73 void Next() { myIterator.Next(); }
42cf5bc1 74
02974a19 75 //! Return selected object at iterator position.
76 const Handle(SelectMgr_EntityOwner)& Value() const { return myIterator.Value(); }
42cf5bc1 77
02974a19 78private:
42cf5bc1 79
02974a19 80 AIS_NListOfEntityOwner myresult;
81 AIS_NListOfEntityOwner::Iterator myIterator;
82 NCollection_DataMap<Handle(SelectMgr_EntityOwner), AIS_NListOfEntityOwner::Iterator> myResultMap;
42cf5bc1 83
02974a19 84};
42cf5bc1 85
02974a19 86DEFINE_STANDARD_HANDLE(AIS_Selection, Standard_Transient)
42cf5bc1 87
88#endif // _AIS_Selection_HeaderFile