VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtLineRenderer.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2021 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
14 
16 
17 #include <matrix/vlMath.h>
18 
19 #include <vector>
20 #include <map>
21 #include <unordered_map>
22 
23 namespace makVrv
24 {
25  class DtDe;
26  class DtBufferObject;
27  class DtFlat2DLineRenderer;
28  class DtLineSegmentProxy;
29  class DtLineSegmentProxyGroup;
30  class DtOverlayResourceProvider;
31  class DtProjected2DLineEffect;
32 
35 
38 
40  template <>
41  inline const char* creatorTypeName<DtLineRenderer>(void) { return "DtLineRendererCreator"; }
42 
46  {
48  friend class DtLineSegmentProxy;
49 
50  public:
51 
54  {
55  public:
57  : myBaseMSLAltitude(std::numeric_limits<double>::min())
58  , myPointOneLength(1.0)
59  , myPointTwoLength(1.0)
60  {
61  // intentional noop
62  }
63 
64  DtLineSegmentAltitudeBasedConfiguration(double altitude, double pointOneLength, double pointTwoLength)
65  : myBaseMSLAltitude(altitude)
66  , myPointOneLength(pointOneLength)
67  , myPointTwoLength(pointTwoLength)
68  {
69  // intentional noop
70  }
71 
73  {
74  // intentional noop
75  }
76 
79  const DtLineSegmentAltitudeBasedConfiguration &other) = default;
80 
83  const DtLineSegmentAltitudeBasedConfiguration &other) = default;
84 
86 
87  public:
88 
90  {
91  return DtEq(myBaseMSLAltitude, config.myBaseMSLAltitude, DtEMilli)
92  && DtEq(myPointOneLength, config.myPointOneLength, DtEMilli)
93  && DtEq(myPointTwoLength, config.myPointTwoLength, DtEMilli);
94  }
95 
99  };
100 
102  typedef std::vector<DtLineSegmentAltitudeBasedConfiguration> DtLineSegmentAltitudeBasedConfigurationCollection;
103 
105  {
108  };
109 
110  const static unsigned short NoStipple = 0xFFFF;
111  const static unsigned short NoLine = 0x0;
112 
113  public:
114 
115  virtual ~DtLineRenderer();
116 
118  DtLineRenderer() = delete;
119 
122  const DtLineRenderer &other) = delete;
123 
125  DtLineRenderer &operator=(
126  const DtLineRenderer &other) = delete;
127 
128  public:
129 
131  virtual int numberOfPrimitives() const;
132 
134  virtual void render(bool geocentric, float geocentricAlpha,
135  const double cameraLocation[3],
136  double cameraAltitude,
137  const double positionMatrix[16],
138  const double projectionMatrix[16],
139  bool picking);
140 
142  virtual void releaseResources();
143 
145  virtual bool isRenderModeSupported(int mode);
146 
148  virtual DtLineSegmentProxy* allocateNewSegment();
149 
150  protected:
151 
152  typedef std::vector<LineSegmentPrimitive> LineSegments;
153  typedef std::vector<DtLineSegmentProxy*> LineSegmentProxyList;
154 
156  {
160 
163 
164  LineSegmentSets();
165 
166  LineSegments& segmentsByIndex(unsigned int index)
167  {
168  if (index == 0)
169  return mySimpleLines;
170  else
171  return myStippledLines;
172  }
173 
175  {
176  if (index == 0)
177  return mySimpleProxies;
178  else
179  return myStippledProxies;
180  }
181 
182  void deleteToBeRenderedBuffer(void);
183 
184  void updateRenderData(double cameraAltitude);
185  void releaseResources(void);
186 
189 
191  };
192 
193  typedef std::unordered_map<float, LineSegmentSets> LineMap;
194 
195  protected:
196 
200 
201  // Called when a proxy modified data.
202  virtual void dirty(DtLineSegmentProxy*);
203 
204  //Called in proxy destructor.
205  virtual void deallocateProxy(const DtLineSegmentProxy&);
206 
207  // Move Segment from one list to another.
208  virtual int moveSegmentToOtherList(
209  const float currentWidth,
210  const int currentSegmentIndex,
211  const int currentPrimativeIndex,
212  const float desiredWidth,
213  const int desiredSegmentIndex);
214 
215  virtual void setAltitudeBasedConfigurationsForProxy(
217  virtual bool getAltitudeBasedConfigurationsForProxy(const DtLineSegmentProxy*, DtLineSegmentAltitudeBasedConfigurationCollection&) const;
218  virtual void clearAltitudeBasedConfigurationsForProxy(DtLineSegmentProxy*);
219 
220  virtual void renderUsingVertexBufferObjects(DtFlat2DLineRenderer& renderer);
221  virtual void renderStippledLineArrays(DtFlat2DLineRenderer& renderer, LineSegmentSets& lss);
222  virtual void updateRenderData(double altitude);
223  virtual void sortByStipple();
224 
225  protected:
226 
228  std::map<const DtLineSegmentProxy*, DtLineSegmentProxyGroup*> myLineSegmentProxyToGroupMap;
229  std::vector<DtLineSegmentProxyGroup*> myLineSegmentProxyGroups;
232  unsigned int myPrimitiveCount;
233  };
234 
239  {
240  friend class DtLineRenderer;
241  public:
242  ~DtLineSegmentProxy();
243 
244  const DtLineRenderer::LineSegmentPrimitive& mapReadOnly() const;
245  DtLineRenderer::LineSegmentPrimitive& mapReadWrite();
246 
248  void enableStipple();
249 
251  void disableStipple();
252 
256  void setLodOutAltitude(double lodOutAltitude);
257 
259  double lodOutAltitude() const;
260 
263  void setIsLodOutAltitudeEnabled(bool isLodOutAltitudeEnabled);
264 
266  bool isLodOutAltitudeEnabled() const;
267 
269  void setWidth(float w);
270 
272  float width() const;
273 
276  void setAltitudeBasedLineLengths(
278 
281  void clearAltitudeBasedLineLengths();
282 
289  void setIsUseForcedAltitudeEnabled(bool enabled);
290 
292  bool isUseForcedAltitudeEnabled() const;
293 
297  void setForcedAltitudeToUse(double minimumAltitudeForUse);
298 
301  double forcedAltitudeToUse() const;
302 
304  void setGroup(float group);
305 
307  float group() const;
308 
309  //Needed for sorting.
310  static inline void swap(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
311  {
312  //Swap what they point to
313  std::swap(v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex],
314  v2->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex]);
315  //Swap their indices
316  std::swap(v1->myIndex,v2->myIndex);
317  //Swap themselves
318  std::swap(v1,v2);
319  }
320 
321  //Needed for sorting.
322  static inline bool less(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
323  {
325  v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex];
327  v2->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex];
328 
329  return (((unsigned int)line1.p1.lineParams[0]) << 16 |
330  (unsigned int)(line1.p1.lineParams[1]))
331  <
332  (((unsigned int)line2.p1.lineParams[0]) << 16 |
333  (unsigned int)(line2.p1.lineParams[1]));
334  }
335 
336  //Needed for sorting.
337  static inline bool equal(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
338  {
340  v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex];
342  v2->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex];
343 
344  return (((unsigned int)line1.p1.lineParams[0]) << 16 |
345  (unsigned int)(line1.p1.lineParams[1]))
346  ==
347  (((unsigned int)line2.p1.lineParams[0]) << 16 |
348  (unsigned int)(line2.p1.lineParams[1]));
349  }
350 
351  protected:
352  DtLineSegmentProxy(DtLineRenderer& parent,int index);
354 
357  int myIndex;
358  float myWidth;
361 
364  };
365 
371  {
372  friend class DtLineRenderer;
373 
374  public:
375  typedef std::vector<DtLineSegmentProxy*> DtLineSegmentProxyList;
376 
377  public:
380 
381  public:
384  void updateRenderData(double cameraMSLAltitude);
385 
386  protected:
388 
390 
391  };
392 
393 }
std::unordered_map< float, LineSegmentSets > LineMap
Definition: DtLineRenderer.h:193
std::vector< DtLineSegmentProxy * > DtLineSegmentProxyList
Definition: DtLineRenderer.h:375
friend DtLineRendererCreator
Definition: DtLineRenderer.h:47
DtLineSegmentProxyList myProxies
Definition: DtLineRenderer.h:387
A line segment proxy is a flyweight class for controlling a single line segment.
Definition: DtLineRenderer.h:238
int myIndex
Definition: DtLineRenderer.h:357
DtLineSegmentAltitudeBasedConfiguration()
Definition: DtLineRenderer.h:56
LineSegmentProxyList myDirtyList
Definition: DtLineRenderer.h:231
int mySegmentIndex
Definition: DtLineRenderer.h:356
A class the wraps a OpenGL Array Buffer object.
Definition: DtBufferObject.h:17
bool myIsLodOutAltitudeEnabled
Definition: DtLineRenderer.h:360
std::vector< DtLineSegmentProxyGroup * > myLineSegmentProxyGroups
Definition: DtLineRenderer.h:229
~DtLineSegmentAltitudeBasedConfiguration()
Definition: DtLineRenderer.h:72
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
DtProjected2DLineEffect * myEffect
Definition: DtLineRenderer.h:230
DtVirtualBaseClassCreator< DtLineRenderer, DtOverlayResourceProvider & > DtLineRendererCreator
creator
Definition: DtLineRenderer.h:34
static bool equal(DtLineSegmentProxy *&v1, DtLineSegmentProxy *&v2)
Definition: DtLineRenderer.h:337
std::map< const DtLineSegmentProxy *, DtLineSegmentProxyGroup * > myLineSegmentProxyToGroupMap
Definition: DtLineRenderer.h:228
DtLineSegmentAltitudeBasedConfiguration(double altitude, double pointOneLength, double pointTwoLength)
Definition: DtLineRenderer.h:64
double myPointTwoLength
Definition: DtLineRenderer.h:98
unsigned int myRenderedSimpleLineCount
Definition: DtLineRenderer.h:190
Definition: DtLineRenderer.h:155
LineSegmentProxyList myStippledProxies
Definition: DtLineRenderer.h:159
LineSegments & segmentsByIndex(unsigned int index)
Definition: DtLineRenderer.h:166
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:22
The overlay resource provider class provies resources for overlay drawing classes.
Definition: DtOverlayResourceProvider.h:23
Definition: DtLineRenderer.h:104
DtLineRenderer::DtLineSegmentAltitudeBasedConfigurationCollection myAltitudeBasedConfigurations
Definition: DtLineRenderer.h:389
static bool less(DtLineSegmentProxy *&v1, DtLineSegmentProxy *&v2)
Definition: DtLineRenderer.h:322
float myWidth
Definition: DtLineRenderer.h:358
#define DT_DLL_VRVGRAPHICS
Contains DLL export macros.
Definition: vrvGraphics.h:19
bool myDirtyFlag
Definition: DtLineRenderer.h:355
std::vector< LineSegmentPrimitive > LineSegments
Definition: DtLineRenderer.h:152
std::vector< DtLineSegmentAltitudeBasedConfiguration > DtLineSegmentAltitudeBasedConfigurationCollection
A collection of altitude-based configurations.
Definition: DtLineRenderer.h:102
Abstract primitive rendering base class.
Definition: DtPrimitiveRenderer.h:19
A vertex element used for rendering a line.
Definition: DtFlat2DLineRenderer.h:20
unsigned int myPrimitiveCount
Definition: DtLineRenderer.h:232
double myForcedAltitudeToUse
Definition: DtLineRenderer.h:363
DtLineRenderer * myParent
Definition: DtLineRenderer.h:353
double myBaseMSLAltitude
Definition: DtLineRenderer.h:96
LineSegments myStippledLines
Definition: DtLineRenderer.h:162
A class that defines an altitude-based configuration for a line segment proxy.
Definition: DtLineRenderer.h:53
DtLineVertex p2
Definition: DtLineRenderer.h:107
DtBufferObject * myBufferObjectStippleLines
Definition: DtLineRenderer.h:188
float lineParams[2]
Definition: DtFlat2DLineRenderer.h:34
LineSegmentProxyList mySimpleProxies
Definition: DtLineRenderer.h:158
An effect for rendering 2D projected lines Has support for direction and length information per verte...
Definition: DtProjected2DLineEffect.h:19
const char int mode
Definition: ioapi.h:38
A Renderer which renders 2D lines with only a color.
Definition: DtFlat2DLineRenderer.h:41
bool myIsForcedAltitudeEnabled
Definition: DtLineRenderer.h:362
DtBufferObject * myBufferObjectSimpleLines
Definition: DtLineRenderer.h:187
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:70
LineSegments mySimpleLines
Definition: DtLineRenderer.h:161
LineSegmentProxyList & proxiesByIndex(unsigned int index)
Definition: DtLineRenderer.h:174
DtLineVertex p1
Definition: DtLineRenderer.h:106
A group of line segment proxy objects that all share the same altitude-based configurations - allowin...
Definition: DtLineRenderer.h:370
LineMap myLines
Definition: DtLineRenderer.h:227
static void swap(DtLineSegmentProxy *&v1, DtLineSegmentProxy *&v2)
Definition: DtLineRenderer.h:310
const char * creatorTypeName< DtLineRenderer >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtLineRenderer.h:41
Contains makVrv::DtFlat2DLineRenderer class.
double myPointOneLength
Definition: DtLineRenderer.h:97
A class responsible for rendering lines.
Definition: DtLineRenderer.h:45
uint8_t * myToBeRenderedBuffer
Definition: DtLineRenderer.h:157
std::vector< DtLineSegmentProxy * > LineSegmentProxyList
Definition: DtLineRenderer.h:153
double myLodOutAltitude
Definition: DtLineRenderer.h:359
bool operator==(const DtLineSegmentAltitudeBasedConfiguration &config) const
Definition: DtLineRenderer.h:89

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)