VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
guiSimObject.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
14 #include <vrvCore/DtUniqueID.h>
16 
17 namespace makVrv
18 {
19  class DtDe;
20 }
21 
22 namespace makVrf
23 {
24  class DtEnvironmentalStateComponent;
25  class DtEntityLocationStateComponent;
26  class DtStateComponent;
27 
29  {
30  public:
31  explicit DtGuiSimObject(const DtStateDataManager* simManager, const DtUUID& uuid);
32  explicit DtGuiSimObject(const DtStateDataManager* simManager, const DtEntityIdentifier& id);
33  explicit DtGuiSimObject(const DtStateDataManager* simManager, const DtExternalCurrentFrameState*);
34  explicit DtGuiSimObject(const DtStateData*);
36 
37  DtGuiSimObject& operator=(const DtGuiSimObject&);
38 
40  makVrv::DtUniqueID id() const;
42 
44  mutable boost::signals2::signal<void (DtSimObjectReference)> signal_modified;
45 
47  mutable boost::signals2::signal<void (DtSimObjectReference)> signal_componentsAdded;
48  mutable boost::signals2::signal<void (DtSimObjectReference)> signal_componentsRemoved;
49 
52  const DtVector& worldAcceleration() const;
53  const DtVector& worldVelocity() const;
55 
58  int penStyle() const;
59  unsigned int color() const;
60  int fillStyle() const;
61  int lineWidth() const;
62  double physicalLineWidth() const;
63  double physicalLineHeight() const;
64  DtString userData() const;
65  bool projected() const;
66  bool closedFigure() const;
68 
69  bool isEnvironmental() const { return myCurrentFrameEnvironmentalStateComponent != nullptr; };
70 
71  std::vector<DtVector> worldVertices() const;
72  std::vector<DtVector> localVertices() const;
73  std::vector<DtVector> objectVertices() const;
74 
75  virtual void cacheComponents() override;
76  virtual void clearCachedComponents() override;
77 
78  bool wantsModificationSignal(int comp) const
79  {
80  ModifiedSignalMap::const_iterator iter = myModifiedSignalMap.find(comp);
81 
82  if (iter != myModifiedSignalMap.end())
83  {
84  return ((*iter->second.get()).num_slots() > 0);
85  }
86 
87  return false;
88  }
89 
90  typedef boost::signals2::signal<void (DtSimObjectReference)> ModifiedSignal;
91  template <typename T_Component>
93  {
94  return signalWhenModified(T_Component::ComponentType());
95  }
96 
98  {
99  ModifiedSignalMap::iterator iter = myModifiedSignalMap.find(comp);
100 
101  if (iter == myModifiedSignalMap.end())
102  {
103  myModifiedSignalMap[comp] = std::unique_ptr<ModifiedSignal>(new ModifiedSignal);
104  iter = myModifiedSignalMap.find(comp);
105  }
106 
107  return *(iter->second.get());
108  }
109 
110  protected:
111 
113  {
114  if (myCurrentFrameEnvironmentalStateComponent)
115  {
116  return myCurrentFrameEnvironmentalStateComponent;
117  }
118  else if (!myCachedComponents && hasStateComponent<DtEnvironmentalStateComponent>())
119  {
120  return getStateComponent<DtEnvironmentalStateComponent>();
121  }
122  else
123  {
124  return nullptr;
125  }
126  }
127 
129  {
130  if (myCurrentFrameEntityLocationStateComponent)
131  {
132  return myCurrentFrameEntityLocationStateComponent;
133  }
134  else if (!myCachedComponents && hasStateComponent<DtEntityLocationStateComponent>())
135  {
136  return getStateComponent<DtEntityLocationStateComponent>();
137  }
138  else
139  {
140  return nullptr;
141  }
142  }
143 
144  virtual void completeSetup() override;
145 
146  protected:
147  const DtEnvironmentalStateComponent* myCurrentFrameEnvironmentalStateComponent = nullptr;
148  const DtEntityLocationStateComponent* myCurrentFrameEntityLocationStateComponent = nullptr;
149 
150  typedef std::map<int, std::unique_ptr<ModifiedSignal>> ModifiedSignalMap;
153  };
154 
156 }
157 
158 template <>
159 struct std::hash<makVrf::DtSimObjectReference>
160 {
161  std::size_t operator()(const makVrf::DtSimObjectReference& s) const
162  {
163  return s.uuid().hashValue();
164  }
165 };
UUID is a unique ID wrapper class.
Definition: uuid.h:59
2) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: entityLocationStateComponent.h:116
Definition: guiSimObject.h:28
#define DT_DLL_VRFGUICORE
Contains DLL export macros.
Definition: vrfGuiCore.h:25
boost::signals2::signal< void(DtSimObjectReference)> signal_componentsAdded
Use this signal when components are added or removed.
Definition: guiSimObject.h:47
boost::signals2::signal< void(DtSimObjectReference)> signal_componentsRemoved
Definition: guiSimObject.h:48
makVrv::DtUniqueID myVantageId
Definition: guiSimObject.h:152
const DtUUID & uuid() const
DtSimObjectReferenceTemplate< DtGuiSimObject > DtSimObjectReference
Definition: guiSimObject.h:35
std::map< int, std::unique_ptr< ModifiedSignal > > ModifiedSignalMap
Definition: guiSimObject.h:150
const DtEntityLocationStateComponent * currentFrameEntityLocationStateComponent() const
Definition: guiSimObject.h:128
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:398
boost::signals2::signal< void(DtSimObjectReference)> signal_modified
Use this signal to signal that this item has been modified. Will not signal itself.
Definition: guiSimObject.h:44
bool wantsModificationSignal(int comp) const
Definition: guiSimObject.h:78
ModifiedSignal & signalWhenModified() const
Definition: guiSimObject.h:92
Definition: stateData.h:301
size_t hashValue() const
If the hashValue is 0 and this is a valid UUID, this will throw a std::runtime_exception.
unsigned long long DtUniqueID
Definition: DtUniqueID.h:19
const DtEnvironmentalStateComponent * currentFrameEnvironmentalStateComponent() const
Definition: guiSimObject.h:112
Represents a single simulation object in the exercise. Object may be VRF simulation, or non-VRF simulated, and may be simulated by the local sim engine, or by a remote sim engine. Only public (external) state of the object is available. All data is read-only. All access to data of the object is thread safe within the simulation frame.
Definition: stateDataWrapper.h:49
std::size_t operator()(const makVrf::DtSimObjectReference &s) const
Definition: guiSimObject.h:161
Contains makVrv::DtUniqueID type.
boost::signals2::signal< void(DtSimObjectReference)> ModifiedSignal
Definition: guiSimObject.h:90
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
bool isEnvironmental() const
Definition: guiSimObject.h:69
ModifiedSignal & signalWhenModified(int comp) const
Definition: guiSimObject.h:97
ModifiedSignalMap myModifiedSignalMap
Definition: guiSimObject.h:151
DtModelSetId
Definition: DtModelSetEnums.h:19
Contains various enum classes relating to model sets.
1) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: environmentalStateComponent.h:103
This class holds the state data that represents each simulation object in the system.
Definition: stateDataManager.h:73

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)