|
|
|||
File indexing completed on 2026-09-13 09:17:41
0001 // Created on: 1995-02-20 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_SelectableObject_HeaderFile 0018 #define _SelectMgr_SelectableObject_HeaderFile 0019 0020 #include <PrsMgr_PresentableObject.hxx> 0021 #include <NCollection_IndexedMap.hxx> 0022 #include <NCollection_Shared.hxx> 0023 #include <NCollection_Sequence.hxx> 0024 #include <SelectMgr_Selection.hxx> 0025 0026 class SelectMgr_EntityOwner; 0027 0028 //! A framework to supply the structure of the object to be selected. 0029 //! At the first pick, this structure is created by calling the appropriate algorithm and retaining 0030 //! this framework for further picking. This abstract framework is inherited in Application 0031 //! Interactive Services (AIS), notably in AIS_InteractiveObject. Consequently, 3D selection should 0032 //! be handled by the relevant daughter classes and their member functions in AIS. This is 0033 //! particularly true in the creation of new interactive objects. 0034 //! 0035 //! Key interface methods to be implemented by every Selectable Object: 0036 //! * Presentable Object (PrsMgr_PresentableObject) 0037 //! Consider defining an enumeration of supported Display Mode indexes for particular Interactive 0038 //! Object or class of Interactive Objects. 0039 //! - AcceptDisplayMode() accepting display modes implemented by this object; 0040 //! - Compute() computing presentation for the given display mode index; 0041 //! * Selectable Object (SelectMgr_SelectableObject) 0042 //! Consider defining an enumeration of supported Selection Mode indexes for particular 0043 //! Interactive Object or class of Interactive Objects. 0044 //! - ComputeSelection() computing selectable entities for the given selection mode index. 0045 class SelectMgr_SelectableObject : public PrsMgr_PresentableObject 0046 { 0047 DEFINE_STANDARD_RTTIEXT(SelectMgr_SelectableObject, PrsMgr_PresentableObject) 0048 friend class SelectMgr_SelectionManager; 0049 0050 public: 0051 //! Clears all selections of the object 0052 Standard_EXPORT ~SelectMgr_SelectableObject() override; 0053 0054 //! Computes sensitive primitives for the given selection mode - key interface method of 0055 //! Selectable Object. 0056 //! @param theSelection selection to fill 0057 //! @param theMode selection mode to create sensitive primitives 0058 virtual void ComputeSelection(const occ::handle<SelectMgr_Selection>& theSelection, 0059 const int theMode) = 0; 0060 0061 //! Informs the graphic context that the interactive Object may be decomposed into sub-shapes for 0062 //! dynamic selection. The most used Interactive Object is AIS_Shape. 0063 virtual bool AcceptShapeDecomposition() const { return false; } 0064 0065 //! Re-computes the sensitive primitives for all modes. IMPORTANT: Do not use 0066 //! this method to update selection primitives except implementing custom selection manager! 0067 //! This method does not take into account necessary BVH updates, but may invalidate the pointers 0068 //! it refers to. TO UPDATE SELECTION properly from outside classes, use method UpdateSelection. 0069 Standard_EXPORT void RecomputePrimitives(); 0070 0071 //! Re-computes the sensitive primitives which correspond to the <theMode>th selection mode. 0072 //! IMPORTANT: Do not use this method to update selection primitives except implementing custom 0073 //! selection manager! selection manager! This method does not take into account necessary BVH 0074 //! updates, but may invalidate the pointers it refers to. TO UPDATE SELECTION properly from 0075 //! outside classes, use method UpdateSelection. 0076 Standard_EXPORT void RecomputePrimitives(const int theMode); 0077 0078 //! Adds the selection aSelection with the selection mode 0079 //! index aMode to this framework. 0080 Standard_EXPORT void AddSelection(const occ::handle<SelectMgr_Selection>& aSelection, 0081 const int aMode); 0082 0083 //! Empties all the selections in the SelectableObject 0084 //! <update> parameter defines whether all object's 0085 //! selections should be flagged for further update or not. 0086 //! This improved method can be used to recompute an 0087 //! object's selection (without redisplaying the object 0088 //! completely) when some selection mode is activated not for the first time. 0089 Standard_EXPORT void ClearSelections(const bool update = false); 0090 0091 //! Returns the selection having specified selection mode or NULL. 0092 Standard_EXPORT const occ::handle<SelectMgr_Selection>& Selection(const int theMode) const; 0093 0094 //! Returns true if a selection corresponding to the selection mode theMode was computed for this 0095 //! object. 0096 bool HasSelection(const int theMode) const { return !Selection(theMode).IsNull(); } 0097 0098 //! Return the sequence of selections. 0099 const NCollection_Sequence<occ::handle<SelectMgr_Selection>>& Selections() const 0100 { 0101 return myselections; 0102 } 0103 0104 Standard_EXPORT void ResetTransformation() override; 0105 0106 //! Recomputes the location of the selection aSelection. 0107 Standard_EXPORT void UpdateTransformation() override; 0108 0109 //! Updates locations in all sensitive entities from <aSelection> 0110 //! and in corresponding entity owners. 0111 Standard_EXPORT virtual void UpdateTransformations( 0112 const occ::handle<SelectMgr_Selection>& aSelection); 0113 0114 //! Method which draws selected owners ( for fast presentation draw ) 0115 Standard_EXPORT virtual void HilightSelected( 0116 const occ::handle<PrsMgr_PresentationManager>& thePrsMgr, 0117 const NCollection_Sequence<occ::handle<SelectMgr_EntityOwner>>& theSeq); 0118 0119 //! Method which clear all selected owners belonging 0120 //! to this selectable object ( for fast presentation draw ) 0121 Standard_EXPORT virtual void ClearSelected(); 0122 0123 //! Method that needs to be implemented when the object 0124 //! manages selection and dynamic highlighting on its own. 0125 //! Clears or invalidates dynamic highlight presentation. 0126 //! By default it clears immediate draw of given presentation 0127 //! manager. 0128 Standard_EXPORT virtual void ClearDynamicHighlight( 0129 const occ::handle<PrsMgr_PresentationManager>& theMgr); 0130 0131 //! Method which hilight an owner belonging to 0132 //! this selectable object (for fast presentation draw) 0133 Standard_EXPORT virtual void HilightOwnerWithColor( 0134 const occ::handle<PrsMgr_PresentationManager>& thePM, 0135 const occ::handle<Prs3d_Drawer>& theStyle, 0136 const occ::handle<SelectMgr_EntityOwner>& theOwner); 0137 0138 //! If returns True, the old mechanism for highlighting selected objects is used (HilightSelected 0139 //! Method may be empty). If returns False, the HilightSelected method will be fully responsible 0140 //! for highlighting selected entity owners belonging to this selectable object. 0141 virtual bool IsAutoHilight() const { return myAutoHilight; } 0142 0143 //! Set AutoHilight property to true or false. 0144 virtual void SetAutoHilight(const bool theAutoHilight) { myAutoHilight = theAutoHilight; } 0145 0146 //! Creates or returns existing presentation for highlighting detected object. 0147 //! @param thePrsMgr presentation manager to create new presentation 0148 //! @return existing or newly created presentation (when thePrsMgr is not NULL) 0149 Standard_EXPORT occ::handle<Prs3d_Presentation> GetHilightPresentation( 0150 const occ::handle<PrsMgr_PresentationManager>& thePrsMgr); 0151 0152 //! Creates or returns existing presentation for highlighting selected object. 0153 //! @param thePrsMgr presentation manager to create new presentation 0154 //! @return existing or newly created presentation (when thePrsMgr is not NULL) 0155 Standard_EXPORT occ::handle<Prs3d_Presentation> GetSelectPresentation( 0156 const occ::handle<PrsMgr_PresentationManager>& thePrsMgr); 0157 0158 //! Removes presentations returned by GetHilightPresentation() and GetSelectPresentation(). 0159 Standard_EXPORT virtual void ErasePresentations(bool theToRemove); 0160 0161 //! Set Z layer ID and update all presentations of the selectable object. 0162 //! The layers mechanism allows drawing objects in higher layers in overlay of objects in lower 0163 //! layers. 0164 Standard_EXPORT void SetZLayer(const Graphic3d_ZLayerId theLayerId) override; 0165 0166 //! Sets update status FULL to selections of the object. Must be used as the only method of 0167 //! UpdateSelection from outer classes to prevent BVH structures from being outdated. 0168 void UpdateSelection(const int theMode = -1) { updateSelection(theMode); } 0169 0170 //! Sets common entity owner for assembly sensitive object entities 0171 Standard_EXPORT void SetAssemblyOwner(const occ::handle<SelectMgr_EntityOwner>& theOwner, 0172 const int theMode = -1); 0173 0174 //! Returns a bounding box of sensitive entities with the owners given if they are a part of 0175 //! activated selection 0176 Standard_EXPORT Bnd_Box BndBoxOfSelected( 0177 const occ::handle< 0178 NCollection_Shared<NCollection_IndexedMap<occ::handle<SelectMgr_EntityOwner>>>>& theOwners); 0179 0180 //! Returns the mode for selection of object as a whole; 0 by default. 0181 int GlobalSelectionMode() const { return myGlobalSelMode; } 0182 0183 //! Returns the owner of mode for selection of object as a whole 0184 Standard_EXPORT virtual occ::handle<SelectMgr_EntityOwner> GlobalSelOwner() const; 0185 0186 //! Returns common entity owner if the object is an assembly 0187 Standard_EXPORT virtual const occ::handle<SelectMgr_EntityOwner>& GetAssemblyOwner() const; 0188 0189 //! Dumps the content of me into the stream 0190 Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override; 0191 0192 protected: 0193 //! Protected empty constructor. 0194 Standard_EXPORT SelectMgr_SelectableObject( 0195 const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); 0196 0197 //! Override global selection mode. 0198 void setGlobalSelMode(const int theMode) { myGlobalSelMode = theMode > 0 ? theMode : 0; } 0199 0200 //! Update clipping planes state. 0201 Standard_EXPORT void UpdateClipping() override; 0202 0203 //! Sets update status FULL to selections of the object. 0204 //! Must be used as the only method of UpdateSelection from outer classes to prevent BVH 0205 //! structures from being outdated. 0206 Standard_EXPORT virtual void updateSelection(const int theMode); 0207 0208 protected: 0209 NCollection_Sequence<occ::handle<SelectMgr_Selection>> myselections; //!< list of selections 0210 // clang-format off 0211 occ::handle<Prs3d_Presentation> mySelectionPrs; //!< optional presentation for highlighting selected object 0212 occ::handle<Prs3d_Presentation> myHilightPrs; //!< optional presentation for highlighting detected object 0213 // clang-format on 0214 int myGlobalSelMode; //!< global selection mode 0215 bool myAutoHilight; //!< auto-highlighting flag defining 0216 }; 0217 0218 #endif // _SelectMgr_SelectableObject_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|