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  const DtString& nextFrameObjectName();
44  void setEntityType(const DtEntityType& et);
45  void setEntityId(const DtEntityIdentifier&);
46  void setLabel(const DtString& objectName);
47  void setForceType(DtForceType);
48  void setWorldPosition(const DtVector&);
49  void setWorldOrientation(const DtTaitBryan&);
50  void setAppearance(int);
51  void setExtendedData(const DtString& key, const DtString& value);
52  void removeExtendedData(const DtString& key);
53  void setExtendedData(const std::map<std::string, std::string>&);
54  void setExtendedData(const std::map<DtString, DtString>&);
55  void setUserData(unsigned long long);
56  void setOverlay(const DtString&);
57  void addStateComponent(const DtFrameStateInterface*);
58  void removeStateComponent(const DtFrameStateInterface*);
59 
60  DtRwProperties& stateProperties();
61 
64  void setPenStyle(int);
65  void setColor(unsigned int);
66  void setFillStyle(int);
67  void setLineWidth(int);
68  void setPhysicalLineWidth(double);
69  void setPhysicalLineHeight(double);
70  void setUserData(const DtString&);
71  void setProjected(bool);
72  void setClosedFigure(bool);
74 
76  virtual DtSimObjectReference simObjectReference();
77  virtual std::shared_ptr<DtGuiLocalObject> guiLocalObjectReference();
78 
81  virtual void resetReference();
82 
84  template <typename T_Component>
85  T_Component* addStateComponent(bool checkWritable = false, bool isRemote = false)
86  {
87  if (isValid())
88  {
89  T_Component* comp = myExternalNextFrameState->addStateComponent<T_Component>(checkWritable, isRemote);
90 
91  if (comp)
92  {
93  if (myStateData)
94  {
95  makVrf::DtStateComponent* stateComponent = myStateData->getStateComponent<T_Component>(comp->id());
96 
97  if (stateComponent)
98  {
99  stateComponent->setIsRemoteComponent(false);
100  }
101  }
102  }
103 
104  return comp;
105  }
106  else
107  {
108  throw makVrf::DtUnimplementedMethod("The addStateComponent is not implemented for this class.");
109  }
110  }
111 
113 
115  void setHostId(const std::string&);
116  void setHostId(const DtUUID&);
117 
118  void setGlobalId(const DtString&);
119 
122  void setCapabilities(int);
123  void setGuise(const DtEntityType&);
125 
126  void setWorldVertices(const std::vector<DtVector>&);
127  void setLocalVertices(const std::vector<DtVector>&);
128 
129  template <typename T_Component>
130  bool hasStateComponent() const
131  {
132  if (myExternalNextFrameState)
133  {
134  return myExternalNextFrameState->hasStateComponent<T_Component>();
135  }
136 
137  return DtGuiSimObject::hasStateComponent<T_Component>();
138  }
139 
141  {
142  if (myNextFrameSimulatedObjectStateComponent)
143  {
144  return myNextFrameSimulatedObjectStateComponent;
145  }
146  else if (!myCachedComponents && hasStateComponent<DtSimulatedObjectStateComponent>())
147  {
148  return getNextFrameStateComponent<DtSimulatedObjectStateComponent>();
149  }
150  else
151  {
152  return nullptr;
153  }
154  }
155 
157  {
158  if (myNextFrameLocationStateComponent)
159  {
160  return myNextFrameLocationStateComponent;
161  }
162  else if (!myCachedComponents && hasStateComponent<DtLocationStateComponent>())
163  {
164  return getNextFrameStateComponent<DtLocationStateComponent>();
165  }
166  else
167  {
168  return nullptr;
169  }
170  }
171 
173  {
174  if (myNextFrameVrfStateComponent)
175  {
176  return myNextFrameVrfStateComponent;
177  }
178  else if (!myCachedComponents && hasStateComponent<DtVrfStateComponent>())
179  {
180  return getNextFrameStateComponent<DtVrfStateComponent>();
181  }
182  else
183  {
184  return nullptr;
185  }
186  }
187 
189  {
190  if (myNextFrameVrfGeometryStateComponent)
191  {
192  return myNextFrameVrfGeometryStateComponent;
193  }
194  else if (!myCachedComponents && hasStateComponent<DtVrfGeometryStateComponent>())
195  {
196  return getNextFrameStateComponent<DtVrfGeometryStateComponent>();
197  }
198  else
199  {
200  return nullptr;
201  }
202  }
203 
205  {
206  if (myNextFrameEnvironmentalStateComponent)
207  {
208  return myNextFrameEnvironmentalStateComponent;
209  }
210  else if (!myCachedComponents && hasStateComponent<DtEnvironmentalStateComponent>())
211  {
212  return getNextFrameStateComponent<DtEnvironmentalStateComponent>();
213  }
214  else
215  {
216  return nullptr;
217  }
218  }
219 
221  template <typename T_Component>
223  {
224  if (myExternalNextFrameState)
225  {
226  return myExternalNextFrameState->getStateComponent<T_Component>();
227  }
228 
229  return nullptr;
230  }
231 
233  template <typename T_Component>
234  const T_Component* getStateComponent() const
235  {
236  const T_Component* comp = DtGuiSimObject::getStateComponent<T_Component>();
237 
238  if (!comp)
239  {
240  comp = const_cast<DtGuiLocalObject*>(this)->getNextFrameStateComponent<T_Component>();
241  }
242 
243  return comp;
244  }
245  bool wantsModificationSignal(int comp) const
246  {
247  LocalObjectModifiedSignalMap::const_iterator iter = myLocalObjectModifiedSignalMap.find(comp);
248 
249  if (iter != myLocalObjectModifiedSignalMap.end())
250  {
251  return ((*iter->second.get()).num_slots() > 0);
252  }
253 
254  return false;
255  }
256 
257  typedef boost::signals2::signal<void (DtGuiLocalObject*)> LocalObjectModifiedSignal;
258  template <typename T_Component>
260  {
261  return signalWhenModified(T_Component::ComponentType());
262  }
263 
265  {
266  LocalObjectModifiedSignalMap::iterator iter = myLocalObjectModifiedSignalMap.find(comp);
267 
268  if (iter == myLocalObjectModifiedSignalMap.end())
269  {
270  myLocalObjectModifiedSignalMap[comp] = std::unique_ptr<LocalObjectModifiedSignal>(new LocalObjectModifiedSignal);
271  iter = myLocalObjectModifiedSignalMap.find(comp);
272  }
273 
274  return *(iter->second.get());
275  }
276 
277  boost::signals2::signal<void (DtGuiLocalObject*)> signal_localObjectAboutToBeRemoved;
278  boost::signals2::signal<void (DtGuiLocalObject*)> signal_stateDataDeleted;
279 
280  protected:
281  virtual void setUUID(const DtUUID&) override;
282  virtual const DtStateData* stateDataFor(const DtUUID& uuid) const override;
283 
284  virtual void cacheComponents() override;
285  virtual void clearCachedComponents() override;
286  virtual void slot_localStateDataModified();
287  virtual void completeLocalStateModified(std::set<int> modifiedStateComponentTypes);
288  virtual void slot_stateDataDeleted();
289  virtual void slot_stateComponentAboutToBeDeleted(const DtFrameStateInterface*);
290 
291  protected:
292  DtSimulatedObjectStateComponent* myNextFrameSimulatedObjectStateComponent = nullptr;
293  DtVrfStateComponent* myNextFrameVrfStateComponent = nullptr;
294  DtLocationStateComponent* myNextFrameLocationStateComponent = nullptr;
295  DtEntityStateComponent* myNextFrameEntityStateComponent = nullptr;
296  DtVrfGeometryStateComponent* myNextFrameVrfGeometryStateComponent = nullptr;
297  DtEnvironmentalStateComponent* myNextFrameEnvironmentalStateComponent = nullptr;
298  DtStatePropertiesStateComponent* myNextFrameStatePropertiesStateComponent = nullptr;
301  typedef std::map<int, std::unique_ptr<LocalObjectModifiedSignal>> LocalObjectModifiedSignalMap;
303  boost::signals2::connection myPostTickConnection;
305  std::shared_ptr<DtGuiLocalObject> myGuiLocalObjectReference;
306  std::set<const DtFrameStateInterface*> myManagedStateComponents;
307  boost::signals2::scoped_connection myStateDataDeletedConnection;
308  boost::signals2::scoped_connection myStateDataModifiedConnection;
309 
310  protected:
312  };
313 
315  {
316  public:
317  DtGuiLocalObjectMarkingTextProvider(const DtGuiLocalObject& lo) : myGuiLocalObject(lo) {};
318  DtGuiLocalObjectMarkingTextProvider(const DtGuiLocalObjectMarkingTextProvider& rhs) : myGuiLocalObject(rhs.myGuiLocalObject) {};
319 
320  virtual DtString markingText() override { return myGuiLocalObject.objectName(); };
321  virtual DtUUIDMarkingTextProvider* clone() const override
322  { return new DtGuiLocalObjectMarkingTextProvider(*this); };
323 
324  protected:
325  const DtGuiLocalObject& myGuiLocalObject;
326  };
327 }
unsigned int StateComponentType
Definition: stateComponent.h:56
UUID is a unique ID wrapper class.
Definition: uuid.h:59
LocalObjectModifiedSignal & signalWhenModified() const
Definition: guiLocalObject.h:259
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:93
Definition: stateDataTypes.h:23
DtExternalNextFrameState * myExternalNextFrameState
Definition: guiLocalObject.h:299
boost::signals2::scoped_connection myStateDataDeletedConnection
Definition: guiLocalObject.h:307
The DtLocationStateComponent interface contains the interface that all DtLocationStateComponents can ...
Definition: locationStateComponent.h:25
virtual void setIsRemoteComponent(bool b)
Definition: stateComponent.h:136
1) Define the interface class that will be used to represent the next and current frames...
Definition: entityStateComponent.h:91
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:304
Definition: guiSimObject.h:28
boost::signals2::signal< void(DtGuiLocalObject *)> LocalObjectModifiedSignal
Definition: guiLocalObject.h:257
DtLocationStateComponent * nextFrameLocationStateComponent()
Definition: guiLocalObject.h:156
boost::signals2::signal< void(DtGuiLocalObject *)> signal_localObjectAboutToBeRemoved
Definition: guiLocalObject.h:277
Definition: stateData.h:139
virtual DtString markingText() override
Definition: guiLocalObject.h:320
T_Component * getNextFrameStateComponent()
General call to get any component that does not have a method.
Definition: guiLocalObject.h:222
boost::signals2::scoped_connection myStateDataModifiedConnection
Definition: guiLocalObject.h:308
#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 curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: vrfGeometryStateComponent.h:54
std::map< int, std::unique_ptr< LocalObjectModifiedSignal > > LocalObjectModifiedSignalMap
Definition: guiLocalObject.h:301
bool hasStateComponent() const
Definition: guiLocalObject.h:130
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:62
DtStateData * myStateData
Definition: guiLocalObject.h:311
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:398
boost::signals2::connection myPostTickConnection
Definition: guiLocalObject.h:303
std::shared_ptr< DtGuiLocalObject > myGuiLocalObjectReference
Definition: guiLocalObject.h:305
makVrv::DtDe & myDe
Definition: guiLocalObject.h:300
const T_Component * getStateComponent() const
General call to get any component that does not have a method.
Definition: guiLocalObject.h:234
std::set< const DtFrameStateInterface * > myManagedStateComponents
Definition: guiLocalObject.h:306
DtVrfStateComponent * nextFrameVrfStateComponent()
Definition: guiLocalObject.h:172
T_Component * addStateComponent(bool checkWritable=false, bool isRemote=false)
Adds the given state component by its intrinsic type.
Definition: guiLocalObject.h:85
LocalObjectModifiedSignalMap myLocalObjectModifiedSignalMap
Definition: guiLocalObject.h:302
Definition: guiLocalObject.h:18
Definition: stateComponent.h:52
DtVrfGeometryStateComponent * nextFrameVrfGeometryStateComponent()
Definition: guiLocalObject.h:188
DtEnvironmentalStateComponent * nextFrameEnvironmentalStateComponent()
Definition: guiLocalObject.h:204
virtual DtUUIDMarkingTextProvider * clone() const override
Definition: guiLocalObject.h:321
boost::signals2::signal< void(DtGuiLocalObject *)> signal_stateDataDeleted
Definition: guiLocalObject.h:278
DtStateData * stateData()
Definition: guiLocalObject.h:37
DtSimulatedObjectStateComponent * nextFrameSimulatedObjectStateComponent()
Definition: guiLocalObject.h:140
bool wantsModificationSignal(int comp) const
Definition: guiLocalObject.h:245
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:318
LocalObjectModifiedSignal & signalWhenModified(int comp) const
Definition: guiLocalObject.h:264
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:294
DtGuiLocalObjectMarkingTextProvider(const DtGuiLocalObject &lo)
Definition: guiLocalObject.h:317
To allow for faster marking text lookups, the DtUUIDMarkingTextProvider class wraps an object that wi...
Definition: uuid.h:30
Definition: guiLocalObject.h:314
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)