VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtElementData.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2022 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 #include <vrvCore/DtElementEntry.h>
14 
15 #include <vrvUtil/signalslib.h>
16 #include <unordered_map>
17 #include <unordered_set>
18 
19 namespace makVrv
20 {
21  class DtElementChanges;
22  class DtElementEntry;
23  class DtElementAttribute;
24  class DtDe;
25  class DtSceneObject;
26  class DtElementAttributeManager;
27 
31  {
32  public:
33 
35 
38  using SceneObjectIdList = std::vector<DtUniqueID>;
39 
41  using ElementEntryMap = std::unordered_map<DtElementID, DtElementEntry*> ;
42 
44  using ElementToSceneObjectMap = std::unordered_map<DtElementID, SceneObjectIdList> ;
45 
47  typedef std::vector<DtElementEntry*> ElementList;
48 
49  typedef std::vector<DtElementID> UniqueIdList; // deprecated (but still widely used)
50 
54  typedef std::vector<DtElementID> ElementIdList;
56 
58  DtElementData(DtDe& de);
59 
61  virtual ~DtElementData();
62 
64  void applyChanges(const DtElementChanges& changes);
65 
67  const ElementEntryMap& elements() const;
68 
70  const ElementToSceneObjectMap& elementToSceneObjectMap() const;
71 
73  DtElementEntry* findElement(DtElementID id );
74 
77  void findAll(DtElementEntry::ElementType type,
78  ElementList& outVector, bool sort = true);
79 
82  void findAll(const std::vector<DtElementEntry::ElementType>& types,
83  ElementList& outVector, bool sort = true);
84 
87  void findAll(ElementList& outVector, bool sort = true);
88 
89 
92  virtual void addElementID( const DtElementID& elementID,
93  const DtUniqueID& sceneObjectID, DtModelSetId modelSet );
94 
98  virtual void addElementID( const DtElementID& elementID,
99  const DtUniqueID& sceneObjectID );
100 
103  virtual void removeElementID( const DtElementID& elementID,
104  const DtUniqueID& sceneObjectID, DtModelSetId modelSet );
105 
108  virtual void removeElementID(const DtElementID& elementID,
109  const DtUniqueID& sceneObjectID);
110 
114  virtual void getSceneObjectIds( const DtElementID& elementID,
115  SceneObjectIdList& outputList, DtModelSetId modelSet = DtModelSetId::Unspecified /* all modelSets */ ) const;
116 
124  DtSceneObject* findSceneObjectFromElementId(DtElementID elementId, DtModelSetId modelSet = DtModelSetId::Models3D );
125 
128  DtSceneObject* findSceneObjectFromSceneObjectId(DtUniqueID sceneObjId);
129 
132  virtual DtElementID elementIdFromSceneObjectId( const DtUniqueID& sceneObjectID ) const;
133 
135  virtual const DtElementAttributeManager& attributeManager() const;
136 
138  virtual DtElementAttributeManager& attributeManager();
139 
141  boost::signalslib::signal< void (const ElementList&) > signal_elementsAdded;
142 
151  boost::signalslib::signal< void (const ElementIdList&) > signal_elementsInitialized;
152 
154  boost::signalslib::signal< void (const ElementIdList&) > signal_elementsToBeRemoved;
155 
159  boost::signalslib::signal< void(const ElementIdList&) > signal_sceneObjectsAdded;
160 
161  private:
163  DtElementData();
164 
166  DtElementData(const DtElementData& orig);
167 
169  DtElementData& operator=(const DtElementData& rhs);
170 
171  protected:
172 
174  virtual void slot_preTick();
175 
176  protected:
177 
178  using ModelSetToElementSceneObjectMap = std::unordered_map<DtModelSetId, ElementToSceneObjectMap>;
179 
180  using SceneObjectToElementMap = std::unordered_map<DtUniqueID, DtElementID>;
181 
184 
185  // map to go from element ID to scene object IDs
187 
188  // map to go from element ID and model set to scene object id(s)
190 
191  // map to go from scene object id to element id
193 
194  // List of elements that were added last frame OR that had scene objects added
195  // last frame.
196  std::unordered_set<DtElementID> myElementsAddedLastFrame;
197 
199  };
200 }
ElementToSceneObjectMap myElementToSceneObjectMap
Definition: DtElementData.h:186
std::vector< DtElementID > ElementIdList
Type definition for a vector of DtElementIDs. DtElementIDs ARE DtUniqueIDs, but not all DtUniqueIDs a...
Definition: DtElementData.h:54
ElementEntryMap myElements
Definition: DtElementData.h:183
The element data is all the information about all elements in the scene.
Definition: DtElementData.h:30
DtElementEntry holds the non-simulation-specific data about an element, including its element type an...
Definition: DtElementEntry.h:22
DtUniqueID DtElementID
The ElementID is a specific type of unique ID used to represent VR-Vantage uniquely defined elements...
Definition: DtUniqueID.h:23
DtElementChanges is used to communicate changes in element data between drivers and the main applicat...
Definition: DtElementChanges.h:25
The element attribute manager is used to provide access to element attribute data. It includes maps between the display name attribute and element id to make it easier to find an element by name. However, note that these maps only valid if display names are unique (and that is not the case internally for the VRF GUI). The DtElementData class creates and owns this manager using the.
Definition: DtElementAttributeManager.h:36
boost::signalslib::signal< void(const ElementIdList &) > signal_elementsInitialized
When the signal_elementsAdded signal is raised, none of the element attributes (like displayName...
Definition: DtElementData.h:151
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
std::vector< DtUniqueID > SceneObjectIdList
Public Type Definitions.
Definition: DtElementData.h:38
boost::signalslib::signal< void(const ElementList &) > signal_elementsAdded
Signal that elements have been added.
Definition: DtElementData.h:141
ElementType
Definition: DtElementEntry.h:26
DtElementAttributeManager * myElementAttributeManager
Definition: DtElementData.h:198
boost::signalslib::signal< void(const ElementIdList &) > signal_elementsToBeRemoved
Signal elements to be removed.
Definition: DtElementData.h:154
ModelSetToElementSceneObjectMap myModelSetToElementSceneObjectMap
Definition: DtElementData.h:189
unsigned long long DtUniqueID
Definition: DtUniqueID.h:19
std::vector< DtElementEntry * > ElementList
Type definition for a vector of DtElementEntry pointers.
Definition: DtElementData.h:47
DtDe & myDe
Definition: DtElementData.h:182
std::unordered_map< DtElementID, DtElementEntry * > ElementEntryMap
Type definition for an unordered map of element ids to DtElementEntry pointers.
Definition: DtElementData.h:41
A DtSceneObject represents an object that can be positioned in the scene by (possibly) attaching it t...
Definition: DtSceneObject.h:44
std::vector< DtElementID > UniqueIdList
Public Type Definitions.
Definition: DtElementData.h:49
Contains makVrv::DtElementAttributes class.
boost::signalslib::signal< void(const ElementIdList &) > signal_sceneObjectsAdded
Signal a list of elements that have had scene objects added. This can be used in place of signal_elem...
Definition: DtElementData.h:159
std::unordered_set< DtElementID > myElementsAddedLastFrame
Definition: DtElementData.h:196
std::unordered_map< DtUniqueID, DtElementID > SceneObjectToElementMap
Definition: DtElementData.h:180
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
std::unordered_map< DtElementID, SceneObjectIdList > ElementToSceneObjectMap
Type definition for an unordered map of element ids to SceneObjectIdList.
Definition: DtElementData.h:44
DtModelSetId
Definition: DtModelSetEnums.h:19
std::unordered_map< DtModelSetId, ElementToSceneObjectMap > ModelSetToElementSceneObjectMap
Definition: DtElementData.h:178
SceneObjectToElementMap mySceneObjectToElementMap
Definition: DtElementData.h:192
Contains makVrv::DtElementEntry class.
Contains various enum classes relating to model sets.

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)