VR-Forces 4.6 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtVrlinkEllipseVisualizers.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2015 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
12 
13 #pragma once
14 
15 #include <vrvVrl/vrvVrl.h>
22 
25 
26 #include <matrix/topoCoord.h>
27 
28 namespace makVrv
29 {
30  namespace DT_PROTOCOL_NAMESPACE
31  {
32  template <typename T>
33  class DtVrlinkEllipseVisualizer : public T
34  {
35  public:
38  int modelSet)
39  : T(simulation, listener, modelSet)
40  , myVrlinkConnection((dynamic_cast<DtVrlinkConnection&>(simulation)))
42  {
43  this->myConnections.manageConnection(
45  &DtVrlinkEllipseVisualizer::resetSpatial,
46  this ) ) );
47 
49  {
50  this->myConnections.manageConnection(myTacticalGraphicStateListener->signal_hostGlobalIdSet.connect(
52 
54  {
56 
57  if (this->myAttachedFlag)
58  {
59  this->setRelativeLocation(this->myTacticalGraphicStateListener->relativeLocation());
60  this->setOffsetPoints(this->myTacticalGraphicStateListener->offsetPoints());
61  }
62  }
63  }
64  }
65 
68  {
71  }
72 
74  void setPosition(int index, const DtVector& v)
75  {
76  DtVector local;
77 
79 
80  T::setPosition(index, local);
81  }
82 
85  void setColor(float r, float g, float b, float a)
86  {
87  if ((r == 0) && (g == 0) && (b == 0))
88  {
89  this->useDefaultColor();
90  }
91  else
92  {
93  T::setColor(r, g, b, a);
94  }
95  }
96 
97  void setHostGlobalId(const std::string& id)
98  {
99  // Make sure no previous setHostGlobalId calls leave connections to the
100  // entity listener lying around
103 
104  this->myHostToBeCreated = DtGlobalObjectDesignator(id.c_str());
105 
106  if(id.empty() || id == "0:0:0")
107  {
108  if(this->myAttachedFlag)
109  {
110  this->setAttached(0);
111  }
112  return;
113  }
114 
116  DtEntityVisualizerSet* hostVis = entityVis->findVisualizerSet(DtGlobalObjectDesignator(id.c_str()), this->myModelSet);
117  //If the host does not yet exist.
118  if (!hostVis)
119  {
120  //Disembark from current.
121  if (this->myAttachedFlag)
122  {
123  this->setAttached(0);
124  }
125  //Setup value to wait.
128  return;
129  }
130 
131  // The entity is embarking on an entity that's been created
132  this->setAttached(hostVis->uniqueID());
133  }
134 
135  protected:
136 
138  {
139  if (esl.esr().globalId() == myHostToBeCreated)
140  {
143  setHostGlobalId(this->myHostToBeCreated.string());
144  }
145  }
146 
148  {
149  T::setupEllipse(f);
150 
151  if (this->myAttachedFlag)
152  {
153  this->myOffsetPoints.clear();
154  this->myRelativeLocation = DtVector::zero();
155 
156  this->setRelativeLocation(this->myTacticalGraphicStateListener->relativeLocation());
157  this->setOffsetPoints(this->myTacticalGraphicStateListener->offsetPoints());
158  }
159  }
160 
161  void endAttached()
162  {
163  T::endAttached();
164  this->myOffsetPoints.clear();
165  }
166 
168  {
170 
171  this->myOffsetPoints.clear();
172 
173  if (this->myEllipse)
174  {
175  this->myEllipse->setOrigin(DtVector::zero());
176  }
177 
179  {
180  this->setRelativeLocation(this->myTacticalGraphicStateListener->relativeLocation());
181  this->setOffsetPoints(this->myTacticalGraphicStateListener->offsetPoints());
182  }
183  }
184 
185  protected:
188  std::vector<DtVector> myOffsetPoints;
190  };
191 
192  // @{
199  // @}
200  }
201 }

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)