VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtVrlinkSpiderWebVisualizers.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
12 
13 #pragma once
14 
17 
18 #include <vrvVrl/vrvVrl.h>
24 
26 
27 #include <matrix/topoCoord.h>
28 
29 namespace makVrv
30 {
31  namespace DT_PROTOCOL_NAMESPACE
32  {
33  template <typename T>
34  class DtVrlinkSpiderWebVisualizer : public T
35  {
36  public:
39  DtStateListener& listener, int modelSet)
40  : T(simulation, listener, modelSet)
41  , myVrlinkConnection((dynamic_cast<DtVrlinkConnection&>(simulation)))
43  {
44  this->myConnections.manageConnection(
46  &DtVrlinkSpiderWebVisualizer::resetSpatial,
47  this)));
48 
50  {
51  this->myConnections.manageConnection(myTacticalGraphicStateListener->signal_hostGlobalIdSet.connect(
53 
55  {
57 
58  if (this->myAttachedFlag)
59  {
60  this->setRelativeLocation(this->myTacticalGraphicStateListener->relativeLocation());
61  this->setOffsetPoints(this->myTacticalGraphicStateListener->offsetPoints());
62  }
63  }
64  }
65  }
66 
69  {
74  }
75 
77  void setPosition(int index, const DtVector& v)
78  {
79  DtVector local;
80 
82 
83  T::setPosition(index, local);
84  }
85 
88  void setColor(float r, float g, float b, float a)
89  {
90  if ((r == 0) && (g == 0) && (b == 0))
91  {
92  this->useDefaultColor();
93  }
94  else
95  {
96  T::setColor(r, g, b, a);
97  }
98  }
99 
100  void setHostGlobalId(const std::string& id)
101  {
102  // Make sure no previous setHostGlobalId calls leave connections to the
103  // entity listener lying around
108 
109  this->myHostToBeCreated = DtGlobalObjectDesignator(id.c_str());
110 
111  if (id.empty() || id == "0:0:0")
112  {
113  if (this->myAttachedFlag)
114  {
115  this->setAttached(0);
116  }
117  return;
118  }
119 
120  // Not sure if this is going to be an environmental or an entity, so, need to connect to both
122  DtEntityVisualizerSet* hostVis = entityVis->findVisualizerSet(DtGlobalObjectDesignator(id.c_str()), this->myModelSet);
123 
125  DtTacticalGraphicVisualizerSet* envHostVis = environmentalVis->findVisualizer(this->myModelSet, DtGlobalObjectDesignator(id.c_str()));
126 
127  //If the host does not yet exist.
128  if (!hostVis && !envHostVis)
129  {
130  //Disembark from current.
131  if (this->myAttachedFlag)
132  {
133  this->setAttached(0);
134  }
135  //Setup value to wait.
140  return;
141  }
142 
143  if (hostVis)
144  {
145  // The entity is embarking on an entity that's been created
146  this->setAttached(hostVis->uniqueID());
147  }
148  else if (envHostVis)
149  {
150  // The entity is embarking on an environmental that's been created
151  this->setAttached(envHostVis->uniqueID());
152  }
153  }
154 
155  protected:
156 
158  {
159  if (esl.esr().globalId() == myHostToBeCreated)
160  {
165  setHostGlobalId(this->myHostToBeCreated.string());
166  }
167  }
168 
170  {
172 #if DtHLA
173  gid = esl.cosr().globalId();
174 #else
175  gid = esl.cosr().environmentalProcessID();
176 #endif
177  if (gid == myHostToBeCreated)
178  {
183  setHostGlobalId(this->myHostToBeCreated.string());
184  }
185  }
186 
188  {
189  T::setupSpiderWeb(f);
190 
191  if (this->myAttachedFlag)
192  {
193  this->myOffsetPoints.clear();
194  this->myRelativeLocation = DtVector::zero();
195 
196  this->setRelativeLocation(this->myTacticalGraphicStateListener->relativeLocation());
197  this->setOffsetPoints(this->myTacticalGraphicStateListener->offsetPoints());
198  }
199  }
200 
201  void endAttached()
202  {
203  T::endAttached();
204  this->myOffsetPoints.clear();
205  }
206 
208  {
209  T::startAttached();
210 
211  this->myOffsetPoints.clear();
212 
213  if (this->mySpiderWeb)
214  {
215  this->mySpiderWeb->setPosition(0, DtVector::zero());
216  }
217 
219  {
220  this->setRelativeLocation(this->myTacticalGraphicStateListener->relativeLocation());
221  this->setOffsetPoints(this->myTacticalGraphicStateListener->offsetPoints());
222  }
223  }
224 
225  protected:
228  std::vector<DtVector> myOffsetPoints;
230 
231  private:
234 
237 
240  };
241 
242  // @{
247  // @}
248  }
249 }
DtStateVisualizerCreatorTemplate< DtVrlinkSpiderWebVisualizer< Dt2DSpiderWebVisualizer > > DtVrlink2DSpiderWebVisualizerCreator
Creators that replace vrvCore representation of classes to allow coordinate translation.
Definition: DtVrlinkSpiderWebVisualizers.h:246
void netToLocalPos(const DtVector &netpos, DtVector &localpos) const
All orientation conversions use radians Convert an entity&#39;s spatial information between network and d...
boost::signalslib::signal< void(DtVrlinkEntityStateListener &)> signal_entityDiscovered
Emitted whenever an entity is discovered.
Definition: DtEntityExistenceListener.h:119
boost::signalslib::signal< void(const std::string &)> signal_hostGlobalIdSet
Definition: DtTacticalGraphicStateListener.h:44
static DtEnvironmentalExistenceListener & instance(DtVrlinkConnection &sim)
Static instance accessor.
static DtEntityExistenceListener & instance(DtVrlinkConnection &conn)
Static instance accessor.
boost::signalslib::signal< void()> signal_coordinateSystemChanged
Emitted when the coordinate system changed.
Definition: DtConnection.h:190
Definition: DtStateVisualizer.h:322
DtEntityVisualizerSet * findVisualizerSet(const DtGlobalObjectDesignator &id, unsigned int modelSet)
Find a visualizer sets by it&#39;s simulation id and model set.
Contains makVrv::DtEntityElementProcessor class.
The DtBaseConnection is an abstract class.
Definition: DtBaseConnection.h:34
binderNoArgs< _Fn > bind(const _Fn &_Func, const _Ty &_Left)
Definition: DtSTLUtilities.h:76
This class manages the display of Tactical Graphics discovered via a connection.
Definition: DtTacticalGraphicElementProcessor.h:43
Contains the makVrv::DtSpiderWebFacadeBase class declaration.
A visualizer is created for each entity state listener which it will drive it.
Definition: DtTacticalGraphicVisualizerSet.h:36
static DtEntityElementProcessor * findInstance(DtVrlinkConnection &conn)
Find an instance registered with a connection.
boost::signalslib::signal< void(DtVrlinkEnvironmentalStateListenerInterface &)> signal_environmentalDiscovered
Emitted whenever an entity is discovered.
Definition: DtEnvironmentalExistenceListener.h:99
virtual const std::vector< DtVector > & offsetPoints() const
#define DT_PROTOCOL_NAMESPACE
Make VR-Vantage VRLink code export with library #ifdef DL_DLL_IGCONVRLINK #undef DL_DLL_IGCONVRLINK #...
Definition: export.h:32
virtual const DtVector & relativeLocation() const
Interface class for a Spider Web Facade.
Definition: DtSpiderWebFacadeBase.h:67
The DtEntityElementProcessor will connect to the DtEntityExistenceListener and handle the creation of...
Definition: DtEntityElementProcessor.h:44
This class is a set of entity visualizers, all of the visualizers in this set must support the entity...
Definition: DtEntityVisualizerSet.h:24
The DtStateListener is an abstract class.
Definition: DtStateListener.h:21
Contains DLL export macros.
Contains makVrv::DtEntityExistenceListener class.
static DtTacticalGraphicElementProcessor * findInstance(DtVrlinkConnection &simulation)
Find an instance registered with an de.
virtual DtUniqueID uniqueID() const
Returns unique id of mySceneObjectAgent, else 0.
const DtCoordinateSystem & coordinateSystem() const
Get the coordinate system.
DtTacticalGraphicVisualizerSet * findVisualizer(int modelSet, const DtGlobalObjectDesignator &id)
Find a state visualizer by it&#39;s simulation id for a specific model set.
virtual const DtGlobalObjectDesignator & hostGlobalId() const
Returns the parent this object might be attached to.

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)