VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
guiLocalObject.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 
11 
12 class DtRwProperties;
13 
14 namespace makVrf
15 {
16  class DtExternalNextFrameState;
17 
19  {
20  public:
26  explicit DtGuiLocalObject(makVrv::DtDe& de, DtStateDataManager* som, const DtEntityType&, bool addToSimObjectManager = false, const DtUUID& uuid = DtUUID::nullUUID());
27  explicit DtGuiLocalObject(makVrv::DtDe& de, const DtStateDataManager* simManager, const DtUUID& uuid) : DtGuiSimObject(simManager, uuid), myDe(de) {};
28  explicit DtGuiLocalObject(makVrv::DtDe& de, const DtStateDataManager* simManager, const DtEntityIdentifier& id) : DtGuiSimObject(simManager, id), myDe(de) {};
29 
30  virtual ~DtGuiLocalObject() override;
31 
33  {
34  return myStateDataManager;
35  }
36 
38  {
39  return myStateData;
40  }
41 
42  void setObjectName(const DtString& objectName);
43  void setSidc(const DtString& objectName);
44  const DtString& nextFrameObjectName();
45  void setEntityType(const DtEntityType& et);
46  void setEntityId(const DtEntityIdentifier&);
47  void setLabel(const DtString& objectName);
48  void setForceType(DtForceType);
49  void setWorldPosition(const DtVector&);
50  void setWorldOrientation(const DtTaitBryan&);
51  void setAppearance(int);
52  void setExtendedData(const DtString& key, const DtString& value);
53  void removeExtendedData(const DtString& key);
54  void setExtendedData(const std::map<std::string, std::string>&);
55  void setExtendedData(const std::map<DtString, DtString>&);
56  void setUserData(unsigned long long);
57  void setOverlay(const DtString&);
58  void addStateComponent(const DtFrameStateInterface*);
59  void removeStateComponent(const DtFrameStateInterface*);
60 
61  DtRwProperties& stateProperties();
62 
65  void setPenStyle(int);
66  void setColor(unsigned int);
67  void setFillStyle(int);
68  void setLineWidth(int);
69  void setPhysicalLineWidth(double);
70  void setPhysicalLineHeight(double);
71  void setUserData(const DtString&);
72  void setProjected(bool);
73  void setClosedFigure(bool);
75 
77  virtual DtSimObjectReference simObjectReference();
78  virtual std::shared_ptr<DtGuiLocalObject> guiLocalObjectReference();
79 
82  virtual void resetReference();
83 
85  template <typename T_Component>
86  T_Component* addStateComponent(bool checkWritable = false, bool isRemote = false)
87  {
88  if (checkValidity())
89  {
90  T_Component* comp = myExternalNextFrameState->addStateComponent<T_Component>(checkWritable, isRemote);
91 
92  if (comp)
93  {
94  if (myStateData)
95  {
96  makVrf::DtStateComponent* stateComponent = myStateData->getStateComponent<T_Component>(comp->id());
97 
98  if (stateComponent)
99  {
100  stateComponent->setIsRemoteComponent(false);
101  }
102  }
103  }
104 
105  return comp;
106  }
107  else
108  {
109  throw makVrf::DtUnimplementedMethod("The addStateComponent is not implemented for this class.");
110  }
111  }
112 
114 
116  void setHostId(const std::string&);
117  void setHostId(const DtUUID&);
118 
119  void setGlobalId(const DtString&);
120 
123  void setCapabilities(int);
124  void setGuise(const DtEntityType&);
126 
127  void setWorldVertices(const std::vector<DtVector>&);
128  void setLocalVertices(const std::vector<DtVector>&);
129 
130  template <typename T_Component>
131  bool hasStateComponent() const
132  {
133  if (myExternalNextFrameState)
134  {
135  return myExternalNextFrameState->hasStateComponent<T_Component>();
136  }
137 
138  return DtGuiSimObject::hasStateComponent<T_Component>();
139  }
140 
142  {
143  if (myNextFrameSimulatedObjectStateComponent)
144  {
145  return myNextFrameSimulatedObjectStateComponent;
146  }
147  else if (!myCachedComponents && hasStateComponent<DtSimulatedObjectStateComponent>())
148  {
149  return getNextFrameStateComponent<DtSimulatedObjectStateComponent>();
150  }
151  else
152  {
153  return nullptr;
154  }
155  }
156 
158  {
159  if (myNextFrameLocationStateComponent)
160  {
161  return myNextFrameLocationStateComponent;
162  }
163  else if (!myCachedComponents && hasStateComponent<DtLocationStateComponent>())
164  {
165  return getNextFrameStateComponent<DtLocationStateComponent>();
166  }
167  else
168  {
169  return nullptr;
170  }
171  }
172 
174  {
175  if (myNextFrameVrfStateComponent)
176  {
177  return myNextFrameVrfStateComponent;
178  }
179  else if (!myCachedComponents && hasStateComponent<DtVrfStateComponent>())
180  {
181  return getNextFrameStateComponent<DtVrfStateComponent>();
182  }
183  else
184  {
185  return nullptr;
186  }
187  }
188 
190  {
191  if (myNextFrameVrfGeometryStateComponent)
192  {
193  return myNextFrameVrfGeometryStateComponent;
194  }
195  else if (!myCachedComponents && hasStateComponent<DtVrfGeometryStateComponent>())
196  {
197  return getNextFrameStateComponent<DtVrfGeometryStateComponent>();
198  }
199  else
200  {
201  return nullptr;
202  }
203  }
204 
206  {
207  if (myNextFrameEnvironmentalStateComponent)
208  {
209  return myNextFrameEnvironmentalStateComponent;
210  }
211  else if (!myCachedComponents && hasStateComponent<DtEnvironmentalStateComponent>())
212  {
213  return getNextFrameStateComponent<DtEnvironmentalStateComponent>();
214  }
215  else
216  {
217  return nullptr;
218  }
219  }
220 
222  {
223  if (myNextFrameStatePropertiesStateComponent)
224  {
225  return myNextFrameStatePropertiesStateComponent;
226  }
227  else if (!myCachedComponents && hasStateComponent<DtStatePropertiesStateComponent>())
228  {
229  return getNextFrameStateComponent<DtStatePropertiesStateComponent>();
230  }
231  else
232  {
233  return nullptr;
234  }
235  }
236 
238  {
239  if (myNextFrameEntityStateComponent)
240  {
241  return myNextFrameEntityStateComponent;
242  }
243  else if (!myCachedComponents && hasStateComponent<DtEntityStateComponent>())
244  {
245  return getNextFrameStateComponent<DtEntityStateComponent>();
246  }
247  else
248  {
249  return nullptr;
250  }
251  }
252 
254  template <typename T_Component>
256  {
257  if (myExternalNextFrameState)
258  {
259  return myExternalNextFrameState->getStateComponent<T_Component>();
260  }
261 
262  return nullptr;
263  }
264 
266  template <typename T_Component>
267  const T_Component* getStateComponent() const
268  {
269  const T_Component* comp = DtGuiSimObject::getStateComponent<T_Component>();
270 
271  if (!comp)
272  {
273  comp = const_cast<DtGuiLocalObject*>(this)->getNextFrameStateComponent<T_Component>();
274  }
275 
276  return comp;
277  }
278  bool wantsModificationSignal(int comp) const
279  {
280  LocalObjectModifiedSignalMap::const_iterator iter = myLocalObjectModifiedSignalMap.find(comp);
281 
282  if (iter != myLocalObjectModifiedSignalMap.end())
283  {
284  return ((*iter->second.get()).num_slots() > 0);
285  }
286 
287  return false;
288  }
289 
290  typedef boost::signals2::signal<void (DtGuiLocalObject*)> LocalObjectModifiedSignal;
291  template <typename T_Component>
293  {
294  return signalWhenModified(T_Component::ComponentType());
295  }
296 
298  {
299  LocalObjectModifiedSignalMap::iterator iter = myLocalObjectModifiedSignalMap.find(comp);
300 
301  if (iter == myLocalObjectModifiedSignalMap.end())
302  {
303  myLocalObjectModifiedSignalMap[comp] = std::unique_ptr<LocalObjectModifiedSignal>(new LocalObjectModifiedSignal);
304  iter = myLocalObjectModifiedSignalMap.find(comp);
305  }
306 
307  return *(iter->second.get());
308  }
309 
310  boost::signals2::signal<void (DtGuiLocalObject*)> signal_localObjectAboutToBeRemoved;
311  boost::signals2::signal<void (DtGuiLocalObject*)> signal_stateDataDeleted;
312 
313  virtual void setUUID(const DtUUID&) override;
314 
315  protected:
316  virtual const DtStateData* stateDataFor(const DtUUID& uuid) const override;
317 
318  virtual void cacheComponents() override;
319  virtual void clearCachedComponents() override;
320  virtual void slot_localStateDataModified();
321  virtual void completeLocalStateModified(std::set<int> modifiedStateComponentTypes);
322  virtual void slot_stateDataDeleted();
323  virtual void slot_stateComponentAboutToBeDeleted(const DtFrameStateInterface*);
324 
325  protected:
326  DtSimulatedObjectStateComponent* myNextFrameSimulatedObjectStateComponent = nullptr;
327  DtVrfStateComponent* myNextFrameVrfStateComponent = nullptr;
328  DtLocationStateComponent* myNextFrameLocationStateComponent = nullptr;
329  DtEntityStateComponent* myNextFrameEntityStateComponent = nullptr;
330  DtVrfGeometryStateComponent* myNextFrameVrfGeometryStateComponent = nullptr;
331  DtEnvironmentalStateComponent* myNextFrameEnvironmentalStateComponent = nullptr;
332  DtStatePropertiesStateComponent* myNextFrameStatePropertiesStateComponent = nullptr;
335  typedef std::map<int, std::unique_ptr<LocalObjectModifiedSignal>> LocalObjectModifiedSignalMap;
337  boost::signals2::connection myPostTickConnection;
339  std::shared_ptr<DtGuiLocalObject> myGuiLocalObjectReference;
340  std::set<const DtFrameStateInterface*> myManagedStateComponents;
341  boost::signals2::scoped_connection myStateDataDeletedConnection;
342  boost::signals2::scoped_connection myStateDataModifiedConnection;
343 
344  protected:
346  };
347 
349  {
350  public:
351  DtGuiLocalObjectMarkingTextProvider(const DtGuiLocalObject& lo) : myGuiLocalObject(lo) {};
352  DtGuiLocalObjectMarkingTextProvider(const DtGuiLocalObjectMarkingTextProvider& rhs) : myGuiLocalObject(rhs.myGuiLocalObject) {};
353 
354  virtual DtString markingText() override { return myGuiLocalObject.objectName(); };
355  virtual DtUUIDMarkingTextProvider* clone() const override
356  { return new DtGuiLocalObjectMarkingTextProvider(*this); };
357 
358  protected:
359  const DtGuiLocalObject& myGuiLocalObject;
360  };
361 }
unsigned int StateComponentType
Definition: stateComponent.h:56
UUID is a unique ID wrapper class.
Definition: uuid.h:59
LocalObjectModifiedSignal & signalWhenModified() const
Definition: guiLocalObject.h:292
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: statePropertiesStateComponent.h:106
Exception thrown when a required method has not been implemented.
Definition: stateDataTypes.h:30
DtExternalNextFrameState * myExternalNextFrameState
Definition: guiLocalObject.h:333
DtEntityStateComponent * nextFrameEntityStateComponent()
Definition: guiLocalObject.h:237
boost::signals2::scoped_connection myStateDataDeletedConnection
Definition: guiLocalObject.h:341
The DtLocationStateComponent interface contains the interface that all DtLocationStateComponents can ...
Definition: locationStateComponent.h:25
virtual void setIsRemoteComponent(bool b)
Sets whether this component represents a remote (non-authoritative) entity.
Definition: stateComponent.h:151
Abstract base interface for the entity state component.
Definition: entityStateComponent.h:141
DtGuiLocalObject(makVrv::DtDe &de, const DtStateDataManager *simManager, const DtEntityIdentifier &id)
Definition: guiLocalObject.h:28
The DtSimulatedObjectStateComponent is an interface that all main components (those that are consider...
Definition: simulatedObjectStateComponent.h:21
DtSimObjectReference mySimObjectReference
Definition: guiLocalObject.h:338
Definition: guiSimObject.h:28
boost::signals2::signal< void(DtGuiLocalObject *)> LocalObjectModifiedSignal
Definition: guiLocalObject.h:290
DtLocationStateComponent * nextFrameLocationStateComponent()
Definition: guiLocalObject.h:157
boost::signals2::signal< void(DtGuiLocalObject *)> signal_localObjectAboutToBeRemoved
Definition: guiLocalObject.h:310
Write-access view of the next-frame state components within a DtStateData. Only the simulation (contr...
Definition: stateData.h:180
virtual DtString markingText() override
Definition: guiLocalObject.h:354
T_Component * getNextFrameStateComponent()
General call to get any component that does not have a method.
Definition: guiLocalObject.h:255
boost::signals2::scoped_connection myStateDataModifiedConnection
Definition: guiLocalObject.h:342
#define DT_DLL_VRFGUICORE
Contains DLL export macros.
Definition: vrfGuiCore.h:25
1) Define the interface class that will be used to represent the next and current frames...
Definition: vrfGeometryStateComponent.h:65
std::map< int, std::unique_ptr< LocalObjectModifiedSignal > > LocalObjectModifiedSignalMap
Definition: guiLocalObject.h:335
bool hasStateComponent() const
Definition: guiLocalObject.h:131
static const DtUUID & nullUUID()
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: vrfStateComponent.h:72
DtStateData * myStateData
Definition: guiLocalObject.h:345
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:513
boost::signals2::connection myPostTickConnection
Definition: guiLocalObject.h:337
std::shared_ptr< DtGuiLocalObject > myGuiLocalObjectReference
Definition: guiLocalObject.h:339
makVrv::DtDe & myDe
Definition: guiLocalObject.h:334
const T_Component * getStateComponent() const
General call to get any component that does not have a method.
Definition: guiLocalObject.h:267
std::set< const DtFrameStateInterface * > myManagedStateComponents
Definition: guiLocalObject.h:340
DtVrfStateComponent * nextFrameVrfStateComponent()
Definition: guiLocalObject.h:173
T_Component * addStateComponent(bool checkWritable=false, bool isRemote=false)
Adds the given state component by its intrinsic type.
Definition: guiLocalObject.h:86
LocalObjectModifiedSignalMap myLocalObjectModifiedSignalMap
Definition: guiLocalObject.h:336
Definition: guiLocalObject.h:18
Definition: stateComponent.h:52
DtVrfGeometryStateComponent * nextFrameVrfGeometryStateComponent()
Definition: guiLocalObject.h:189
DtStatePropertiesStateComponent * nextFrameStatePropertiesStateComponent()
Definition: guiLocalObject.h:221
DtEnvironmentalStateComponent * nextFrameEnvironmentalStateComponent()
Definition: guiLocalObject.h:205
virtual DtUUIDMarkingTextProvider * clone() const override
Definition: guiLocalObject.h:355
boost::signals2::signal< void(DtGuiLocalObject *)> signal_stateDataDeleted
Definition: guiLocalObject.h:311
DtStateData * stateData()
Definition: guiLocalObject.h:37
DtSimulatedObjectStateComponent * nextFrameSimulatedObjectStateComponent()
Definition: guiLocalObject.h:141
bool wantsModificationSignal(int comp) const
Definition: guiLocalObject.h:278
A list of properties. A DtPropertyInterface object that is a specialized version of DtRwVariableBindi...
Definition: rwProperties.h:122
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
DtGuiLocalObject(makVrv::DtDe &de, const DtStateDataManager *simManager, const DtUUID &uuid)
Definition: guiLocalObject.h:27
const DtStateDataManager * stateDataManager() const
Definition: guiLocalObject.h:32
DtGuiLocalObjectMarkingTextProvider(const DtGuiLocalObjectMarkingTextProvider &rhs)
Definition: guiLocalObject.h:352
LocalObjectModifiedSignal & signalWhenModified(int comp) const
Definition: guiLocalObject.h:297
Base interface for accessing current or next frame state in a double-buffered state component...
Definition: stateComponent.h:354
DtGuiLocalObjectMarkingTextProvider(const DtGuiLocalObject &lo)
Definition: guiLocalObject.h:351
To allow for faster marking text lookups, the DtUUIDMarkingTextProvider class wraps an object that wi...
Definition: uuid.h:30
Definition: guiLocalObject.h:348
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:122
This class holds the state data that represents each simulation object in the system.
Definition: stateDataManager.h:76

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)