Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:27:01

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 <NCollection_Array1.hxx>
0021 #include <SelectMgr_EntityOwner.hxx>
0022 #include <NCollection_List.hxx>
0023 #include <AIS_SelectionScheme.hxx>
0024 #include <AIS_SelectStatus.hxx>
0025 #include <Standard.hxx>
0026 #include <Standard_Type.hxx>
0027 
0028 class SelectMgr_Filter;
0029 
0030 //! Class holding the list of selected owners.
0031 class AIS_Selection : public Standard_Transient
0032 {
0033   DEFINE_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
0034 public:
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(
0049     const occ::handle<SelectMgr_EntityOwner>& theOwner,
0050     const occ::handle<SelectMgr_Filter>&      theFilter,
0051     const AIS_SelectionScheme                 theSelScheme,
0052     const bool                                theIsDetected);
0053 
0054   //! the object is always add int the selection.
0055   //! faster when the number of objects selected is great.
0056   Standard_EXPORT virtual AIS_SelectStatus AddSelect(
0057     const occ::handle<SelectMgr_EntityOwner>& theObject);
0058 
0059   //! clears the selection and adds the object in the selection.
0060   //! @param[in] theObject element to change selection state
0061   //! @param[in] theFilter context filter
0062   //! @param[in] theIsDetected flag of object detection
0063   virtual void ClearAndSelect(const occ::handle<SelectMgr_EntityOwner>& theObject,
0064                               const occ::handle<SelectMgr_Filter>&      theFilter,
0065                               const bool                                theIsDetected)
0066   {
0067     Clear();
0068     Select(theObject, theFilter, AIS_SelectionScheme_Add, theIsDetected);
0069   }
0070 
0071   //! checks if the object is in the selection.
0072   bool IsSelected(const occ::handle<SelectMgr_EntityOwner>& theObject) const
0073   {
0074     return myResultMap.IsBound(theObject);
0075   }
0076 
0077   //! Return the list of selected objects.
0078   const NCollection_List<occ::handle<SelectMgr_EntityOwner>>& Objects() const { return myresult; }
0079 
0080   //! Return the number of selected objects.
0081   int Extent() const { return myresult.Length(); }
0082 
0083   //! Return true if list of selected objects is empty.
0084   bool IsEmpty() const { return myresult.IsEmpty(); }
0085 
0086 public:
0087   //! Start iteration through selected objects.
0088   void Init()
0089   {
0090     myIterator = NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator(myresult);
0091   }
0092 
0093   //! Return true if iterator points to selected object.
0094   bool More() const { return myIterator.More(); }
0095 
0096   //! Continue iteration through selected objects.
0097   void Next() { myIterator.Next(); }
0098 
0099   //! Return selected object at iterator position.
0100   const occ::handle<SelectMgr_EntityOwner>& Value() const { return myIterator.Value(); }
0101 
0102   //! Select or deselect owners depending on the selection scheme.
0103   //! @param[in] thePickedOwners elements to change selection state
0104   //! @param[in] theSelScheme selection scheme, defines how owner is selected
0105   //! @param[in] theToAllowSelOverlap selection flag, if true - overlapped entities are allowed
0106   //! @param[in] theFilter context filter to skip not acceptable owners
0107   Standard_EXPORT virtual void SelectOwners(
0108     const NCollection_Array1<occ::handle<SelectMgr_EntityOwner>>& thePickedOwners,
0109     const AIS_SelectionScheme                                     theSelScheme,
0110     const bool                                                    theToAllowSelOverlap,
0111     const occ::handle<SelectMgr_Filter>&                          theFilter);
0112 
0113 protected:
0114   //! Append the owner into the current selection if filter is Ok.
0115   //! @param[in] theOwner  element to change selection state
0116   //! @param[in] theFilter  context filter to skip not acceptable owners
0117   //! @return result of selection
0118   Standard_EXPORT virtual AIS_SelectStatus appendOwner(
0119     const occ::handle<SelectMgr_EntityOwner>& theOwner,
0120     const occ::handle<SelectMgr_Filter>&      theFilter);
0121 
0122 protected:
0123   NCollection_List<occ::handle<SelectMgr_EntityOwner>>           myresult;
0124   NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator myIterator;
0125   NCollection_DataMap<occ::handle<SelectMgr_EntityOwner>,
0126                       NCollection_List<occ::handle<SelectMgr_EntityOwner>>::Iterator>
0127     myResultMap;
0128 };
0129 
0130 #endif // _AIS_Selection_HeaderFile