Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:55

0001 // Created on: 1995-03-21
0002 // Created by: Jean-Louis Frenkel
0003 // Copyright (c) 1995-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _AIS_Selection_HeaderFile
0018 #define _AIS_Selection_HeaderFile
0019 
0020 #include <AIS_NArray1OfEntityOwner.hxx>
0021 #include <AIS_NListOfEntityOwner.hxx>
0022 #include <AIS_SelectionScheme.hxx>
0023 #include <AIS_SelectStatus.hxx>
0024 #include <Standard.hxx>
0025 #include <Standard_Type.hxx>
0026 
0027 class SelectMgr_Filter;
0028 
0029 //! Class holding the list of selected owners.
0030 class AIS_Selection : public Standard_Transient
0031 {
0032   DEFINE_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
0033 public:
0034 
0035   //! creates a new selection.
0036   Standard_EXPORT AIS_Selection();
0037 
0038   //! removes all the object of the selection.
0039   Standard_EXPORT virtual void Clear();
0040 
0041   //! if the object is not yet in the selection, it will be added.
0042   //! if the object is already in the selection, it will be removed.
0043   //! @param[in] theOwner element to change selection state
0044   //! @param[in] theFilter context filter
0045   //! @param[in] theSelScheme selection scheme
0046   //! @param[in] theIsDetected flag of object detection
0047   //! @return result of selection
0048   Standard_EXPORT virtual AIS_SelectStatus Select (const Handle(SelectMgr_EntityOwner)& theOwner,
0049                                                    const Handle(SelectMgr_Filter)& theFilter,
0050                                                    const AIS_SelectionScheme theSelScheme,
0051                                                    const Standard_Boolean theIsDetected);
0052 
0053   //! the object is always add int the selection.
0054   //! faster when the number of objects selected is great.
0055   Standard_EXPORT virtual AIS_SelectStatus AddSelect (const Handle(SelectMgr_EntityOwner)& theObject);
0056 
0057   //! clears the selection and adds the object in the selection.
0058   //! @param[in] theObject element to change selection state
0059   //! @param[in] theFilter context filter
0060   //! @param[in] theIsDetected flag of object detection
0061   virtual void ClearAndSelect (const Handle(SelectMgr_EntityOwner)& theObject,
0062                                const Handle(SelectMgr_Filter)& theFilter,
0063                                const Standard_Boolean theIsDetected)
0064   {
0065     Clear();
0066     Select (theObject, theFilter, AIS_SelectionScheme_Add, theIsDetected);
0067   }
0068 
0069   //! checks if the object is in the selection.
0070   Standard_Boolean IsSelected (const Handle(SelectMgr_EntityOwner)& theObject) const { return myResultMap.IsBound (theObject); }
0071 
0072   //! Return the list of selected objects.
0073   const AIS_NListOfEntityOwner& Objects() const { return myresult; }
0074 
0075   //! Return the number of selected objects.
0076   Standard_Integer Extent() const { return myresult.Size(); }
0077 
0078   //! Return true if list of selected objects is empty.
0079   Standard_Boolean IsEmpty() const { return myresult.IsEmpty(); }
0080 
0081 public:
0082 
0083   //! Start iteration through selected objects.
0084   void Init() { myIterator = AIS_NListOfEntityOwner::Iterator(myresult); }
0085 
0086   //! Return true if iterator points to selected object.
0087   Standard_Boolean More() const { return myIterator.More(); }
0088 
0089   //! Continue iteration through selected objects.
0090   void Next() { myIterator.Next(); }
0091 
0092   //! Return selected object at iterator position.
0093   const Handle(SelectMgr_EntityOwner)& Value() const { return myIterator.Value(); }
0094 
0095   //! Select or deselect owners depending on the selection scheme.
0096   //! @param[in] thePickedOwners elements to change selection state
0097   //! @param[in] theSelScheme selection scheme, defines how owner is selected
0098   //! @param[in] theToAllowSelOverlap selection flag, if true - overlapped entities are allowed
0099   //! @param[in] theFilter context filter to skip not acceptable owners
0100   Standard_EXPORT virtual void SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwners,
0101                                              const AIS_SelectionScheme theSelScheme,
0102                                              const Standard_Boolean theToAllowSelOverlap,
0103                                              const Handle(SelectMgr_Filter)& theFilter);
0104 
0105 protected:
0106 
0107   //! Append the owner into the current selection if filter is Ok.
0108   //! @param theOwner [in] element to change selection state
0109   //! @param theFilter [in] context filter to skip not acceptable owners
0110   //! @return result of selection
0111   Standard_EXPORT virtual AIS_SelectStatus appendOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
0112                                                         const Handle(SelectMgr_Filter)& theFilter);
0113 
0114 protected:
0115 
0116   AIS_NListOfEntityOwner myresult;
0117   AIS_NListOfEntityOwner::Iterator myIterator;
0118   NCollection_DataMap<Handle(SelectMgr_EntityOwner), AIS_NListOfEntityOwner::Iterator> myResultMap;
0119 
0120 };
0121 
0122 DEFINE_STANDARD_HANDLE(AIS_Selection, Standard_Transient)
0123 
0124 #endif // _AIS_Selection_HeaderFile