Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-27 10:39:23

0001 // Created on: 1995-02-16
0002 // Created by: Mister rmi
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 _SelectMgr_Selection_HeaderFile
0018 #define _SelectMgr_Selection_HeaderFile
0019 
0020 #include <SelectMgr_SensitiveEntity.hxx>
0021 #include <SelectMgr_StateOfSelection.hxx>
0022 #include <SelectMgr_TypeOfBVHUpdate.hxx>
0023 #include <SelectMgr_TypeOfUpdate.hxx>
0024 
0025 class Select3D_SensitiveEntity;
0026 
0027 //! Represents the state of a given selection mode for a
0028 //! Selectable Object. Contains all the sensitive entities available for this mode.
0029 //! An interactive object can have an indefinite number of
0030 //! modes of selection, each representing a
0031 //! "decomposition" into sensitive primitives; each
0032 //! primitive has an Owner (SelectMgr_EntityOwner)
0033 //! which allows us to identify the exact entity which has
0034 //! been detected. Each Selection mode is identified by
0035 //! an index. The set of sensitive primitives which
0036 //! correspond to a given mode is stocked in a
0037 //! SelectMgr_Selection object. By Convention, the
0038 //! default selection mode which allows us to grasp the
0039 //! Interactive object in its entirety will be mode 0.
0040 //! AIS_Trihedron : 4 selection modes
0041 //! -   mode 0 : selection of a trihedron
0042 //! -   mode 1 : selection of the origin of the trihedron
0043 //! -   mode 2 : selection of the axes
0044 //! -   mode 3 : selection of the planes XOY, YOZ, XOZ
0045 //! when you activate one of modes 1 2 3 4 , you pick AIS objects of type:
0046 //! -   AIS_Point
0047 //! -   AIS_Axis (and information on the type of axis)
0048 //! -   AIS_Plane (and information on the type of plane).
0049 //!   AIS_PlaneTrihedron offers 3 selection modes:
0050 //! -   mode 0 : selection of the whole trihedron
0051 //! -   mode 1 : selection of the origin of the trihedron
0052 //! -   mode 2 : selection of the axes - same remarks as for the Trihedron.
0053 //! AIS_Shape : 7 maximum selection modes, depending
0054 //! on the complexity of the shape :
0055 //! -   mode 0 : selection of the AIS_Shape
0056 //! -   mode 1 : selection of the vertices
0057 //! -   mode 2 : selection of the edges
0058 //! -   mode 3 : selection of the wires
0059 //! -   mode 4 : selection of the faces
0060 //! -   mode 5 : selection of the shells
0061 //! -   mode 6 : selection of the constituent solids.
0062 class SelectMgr_Selection : public Standard_Transient
0063 {
0064   DEFINE_STANDARD_RTTIEXT(SelectMgr_Selection, Standard_Transient)
0065 public:
0066   //! Constructs a selection object defined by the selection mode IdMode.
0067   //! The default setting 0 is the selection mode for a shape in its entirety.
0068   Standard_EXPORT SelectMgr_Selection(const int theModeIdx = 0);
0069 
0070   Standard_EXPORT ~SelectMgr_Selection() override;
0071 
0072   Standard_EXPORT void Destroy();
0073 
0074   //! Adds the sensitive primitive to the list of stored entities in this object.
0075   //! Raises NullObject if the primitive is a null handle.
0076   Standard_EXPORT void Add(const occ::handle<Select3D_SensitiveEntity>& theSensitive);
0077 
0078   //! empties the selection from all the stored entities
0079   Standard_EXPORT void Clear();
0080 
0081   //! returns true if no sensitive entity is stored.
0082   bool IsEmpty() const { return myEntities.IsEmpty(); }
0083 
0084   //! returns the selection mode represented by this selection
0085   int Mode() const { return myMode; }
0086 
0087   //! Return entities.
0088   const NCollection_DynamicArray<occ::handle<SelectMgr_SensitiveEntity>>& Entities() const
0089   {
0090     return myEntities;
0091   }
0092 
0093   //! Return entities.
0094   NCollection_DynamicArray<occ::handle<SelectMgr_SensitiveEntity>>& ChangeEntities()
0095   {
0096     return myEntities;
0097   }
0098 
0099   //! Returns the flag UpdateFlag.
0100   //! This flag gives the update status of this framework
0101   //! in a ViewerSelector object:
0102   //! -   full
0103   //! -   partial, or
0104   //! -   none.
0105   SelectMgr_TypeOfUpdate UpdateStatus() const { return myUpdateStatus; }
0106 
0107   void UpdateStatus(const SelectMgr_TypeOfUpdate theStatus) { myUpdateStatus = theStatus; }
0108 
0109   void UpdateBVHStatus(const SelectMgr_TypeOfBVHUpdate theStatus) { myBVHUpdateStatus = theStatus; }
0110 
0111   SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const { return myBVHUpdateStatus; }
0112 
0113   //! Returns status of selection
0114   SelectMgr_StateOfSelection GetSelectionState() const { return mySelectionState; }
0115 
0116   //! Sets status of selection
0117   void SetSelectionState(const SelectMgr_StateOfSelection theState) const
0118   {
0119     mySelectionState = theState;
0120   }
0121 
0122   //! Returns sensitivity of the selection
0123   int Sensitivity() const { return mySensFactor; }
0124 
0125   //! Changes sensitivity of the selection and all its entities to the given value.
0126   //! IMPORTANT: This method does not update any outer selection structures, so for
0127   //! proper updates use SelectMgr_SelectionManager::SetSelectionSensitivity method.
0128   Standard_EXPORT void SetSensitivity(const int theNewSens);
0129 
0130   //! Dumps the content of me into the stream
0131   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const;
0132 
0133 private:
0134   NCollection_DynamicArray<occ::handle<SelectMgr_SensitiveEntity>> myEntities;
0135   int                                                              myMode;
0136   SelectMgr_TypeOfUpdate                                           myUpdateStatus;
0137   mutable SelectMgr_StateOfSelection                               mySelectionState;
0138   mutable SelectMgr_TypeOfBVHUpdate                                myBVHUpdateStatus;
0139   int                                                              mySensFactor;
0140   bool                                                             myIsCustomSens;
0141 };
0142 
0143 #endif