Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/SelectMgr_Selection.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 Standard_Integer theModeIdx = 0);
0069 
0070   Standard_EXPORT ~SelectMgr_Selection();
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 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   Standard_Boolean IsEmpty() const { return myEntities.IsEmpty(); }
0083 
0084   //! returns the selection mode represented by this selection
0085   Standard_Integer Mode() const { return myMode; }
0086 
0087   //! Return entities.
0088   const NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>& Entities() const
0089   {
0090     return myEntities;
0091   }
0092 
0093   //! Return entities.
0094   NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>& ChangeEntities() { return myEntities; }
0095 
0096   //! Returns the flag UpdateFlag.
0097   //! This flag gives the update status of this framework
0098   //! in a ViewerSelector object:
0099   //! -   full
0100   //! -   partial, or
0101   //! -   none.
0102   SelectMgr_TypeOfUpdate UpdateStatus() const { return myUpdateStatus; }
0103 
0104   void UpdateStatus(const SelectMgr_TypeOfUpdate theStatus) { myUpdateStatus = theStatus; }
0105 
0106   void UpdateBVHStatus(const SelectMgr_TypeOfBVHUpdate theStatus) { myBVHUpdateStatus = theStatus; }
0107 
0108   SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const { return myBVHUpdateStatus; }
0109 
0110   //! Returns status of selection
0111   SelectMgr_StateOfSelection GetSelectionState() const { return mySelectionState; }
0112 
0113   //! Sets status of selection
0114   void SetSelectionState(const SelectMgr_StateOfSelection theState) const
0115   {
0116     mySelectionState = theState;
0117   }
0118 
0119   //! Returns sensitivity of the selection
0120   Standard_Integer Sensitivity() const { return mySensFactor; }
0121 
0122   //! Changes sensitivity of the selection and all its entities to the given value.
0123   //! IMPORTANT: This method does not update any outer selection structures, so for
0124   //! proper updates use SelectMgr_SelectionManager::SetSelectionSensitivity method.
0125   Standard_EXPORT void SetSensitivity(const Standard_Integer theNewSens);
0126 
0127   //! Dumps the content of me into the stream
0128   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0129                                         Standard_Integer  theDepth = -1) const;
0130 
0131 private:
0132   NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> myEntities;
0133   Standard_Integer                                      myMode;
0134   SelectMgr_TypeOfUpdate                                myUpdateStatus;
0135   mutable SelectMgr_StateOfSelection                    mySelectionState;
0136   mutable SelectMgr_TypeOfBVHUpdate                     myBVHUpdateStatus;
0137   Standard_Integer                                      mySensFactor;
0138   Standard_Boolean                                      myIsCustomSens;
0139 };
0140 
0141 DEFINE_STANDARD_HANDLE(SelectMgr_Selection, Standard_Transient)
0142 
0143 #endif