VR-Forces 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) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
14 
16 
18 
19 #include <matrix/vlMath.h>
20 
21 #include <vector>
22 #include <map>
23 #include <unordered_map>
24 
25 namespace makVrv
26 {
27  class DtDe;
28  class DtBufferObject;
29  class DtFlat2DLineRenderer;
30  class DtLineSegmentProxy;
31  class DtLineSegmentProxyGroup;
32  class DtOverlayResourceProvider;
33  class DtProjected2DLineEffect;
34  struct DtObserverRenderData;
35  struct DtOverlayRenderData;
36 
39 
42 
44  template <>
45  inline const char* creatorTypeName<DtLineRenderer>(void) { return "DtLineRendererCreator"; }
46 
50  {
52  friend class DtLineSegmentProxy;
53 
54  public:
55 
57  {
60  };
61 
62  const static unsigned short NoStipple = 0xFFFF;
63  const static unsigned short NoLine = 0x0;
64 
65  public:
66 
67  virtual ~DtLineRenderer();
68 
70  DtLineRenderer() = delete;
71 
74  const DtLineRenderer &other) = delete;
75 
77  DtLineRenderer &operator=(
78  const DtLineRenderer &other) = delete;
79 
80  public:
81 
83  virtual int numberOfPrimitives() const;
84 
86  virtual void render(const DtOverlayRenderData& overlayRenderData,
87  const DtObserverRenderData& observerRenderData,
88  const double projectionMatrix[16], bool picking);
89 
91  virtual void releaseResources();
92 
94  virtual bool isRenderModeSupported(int mode);
95 
97  virtual DtLineSegmentProxy* allocateNewSegment();
98 
101  virtual void initLineVertex(DtLineVertex& p);
102 
103  protected:
104 
105  typedef std::vector<LineSegmentPrimitive> LineSegments;
106  typedef std::vector<DtLineSegmentProxy*> LineSegmentProxyList;
107 
109  {
113 
116 
117  LineSegmentSets();
118 
119  LineSegments& segmentsByIndex(unsigned int index)
120  {
121  if (index == 0)
122  return mySimpleLines;
123  else
124  return myStippledLines;
125  }
126 
128  {
129  if (index == 0)
130  return mySimpleProxies;
131  else
132  return myStippledProxies;
133  }
134 
135  void deleteToBeRenderedBuffer(void);
136 
137  void updateRenderData(double cameraAltitude);
138  void releaseResources(void);
139 
142 
144  };
145 
146  typedef std::unordered_map<float, LineSegmentSets> LineMap;
147 
148  protected:
149 
153 
154  // Called when a proxy modified data.
155  virtual void dirty(DtLineSegmentProxy*);
156 
157  //Called in proxy destructor.
158  virtual void deallocateProxy(const DtLineSegmentProxy&);
159 
160  // Move Segment from one list to another.
161  virtual int moveSegmentToOtherList(
162  const float currentWidth,
163  const int currentSegmentIndex,
164  const int currentPrimativeIndex,
165  const float desiredWidth,
166  const int desiredSegmentIndex);
167 
168  virtual void setAltitudeBasedConfigurationsForProxy(
170  virtual bool getAltitudeBasedConfigurationsForProxy(const DtLineSegmentProxy*, DtLineSegmentInterface::DtLineSegmentAltitudeBasedConfigurationCollection&) const;
171  virtual void clearAltitudeBasedConfigurationsForProxy(DtLineSegmentProxy*);
172 
173  virtual void renderUsingVertexBufferObjects(DtFlat2DLineRenderer& renderer);
174  virtual void renderStippledLineArrays(DtFlat2DLineRenderer& renderer, LineSegmentSets& lss);
175  virtual void updateRenderData(double altitude);
176  virtual void sortByStipple();
177 
178  protected:
179 
181  std::map<const DtLineSegmentProxy*, DtLineSegmentProxyGroup*> myLineSegmentProxyToGroupMap;
182  std::vector<DtLineSegmentProxyGroup*> myLineSegmentProxyGroups;
185  unsigned int myPrimitiveCount;
186  };
187 
192  {
193  friend class DtLineRenderer;
194  public:
195  ~DtLineSegmentProxy();
196 
197  const DtLineRenderer::LineSegmentPrimitive& mapReadOnly() const;
198  DtLineRenderer::LineSegmentPrimitive& mapReadWrite();
199 
201  void enableStipple();
202 
204  void disableStipple();
205 
209  void setLodOutAltitude(double lodOutAltitude);
210 
212  double lodOutAltitude() const;
213 
216  void setIsLodOutAltitudeEnabled(bool isLodOutAltitudeEnabled);
217 
219  bool isLodOutAltitudeEnabled() const;
220 
222  void setWidth(float w);
223 
225  float width() const;
226 
229  void setAltitudeBasedLineLengths(
231 
234  void clearAltitudeBasedLineLengths();
235 
242  void setIsUseForcedAltitudeEnabled(bool enabled);
243 
245  bool isUseForcedAltitudeEnabled() const;
246 
250  void setForcedAltitudeToUse(double minimumAltitudeForUse);
251 
254  double forcedAltitudeToUse() const;
255 
257  void setGroup(float group);
258 
260  float group() const;
261 
262  //Needed for sorting.
263  static inline void swap(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
264  {
265  //Swap what they point to
266  std::swap(v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex],
267  v2->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex]);
268  //Swap their indices
269  std::swap(v1->myIndex,v2->myIndex);
270  //Swap themselves
271  std::swap(v1,v2);
272  }
273 
274  //Needed for sorting.
275  static inline bool less(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
276  {
278  v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex];
280  v2->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex];
281 
282  return (((unsigned int)line1.p1.lineParams[0]) << 16 |
283  (unsigned int)(line1.p1.lineParams[1]))
284  <
285  (((unsigned int)line2.p1.lineParams[0]) << 16 |
286  (unsigned int)(line2.p1.lineParams[1]));
287  }
288 
289  //Needed for sorting.
290  static inline bool equal(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
291  {
293  v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex];
295  v2->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex];
296 
297  return (((unsigned int)line1.p1.lineParams[0]) << 16 |
298  (unsigned int)(line1.p1.lineParams[1]))
299  ==
300  (((unsigned int)line2.p1.lineParams[0]) << 16 |
301  (unsigned int)(line2.p1.lineParams[1]));
302  }
303 
304  protected:
305  DtLineSegmentProxy(DtLineRenderer& parent,int index);
307 
310  int myIndex;
311  float myWidth;
314 
317  };
318 
324  {
325  friend class DtLineRenderer;
326 
327  public:
328  typedef std::vector<DtLineSegmentProxy*> DtLineSegmentProxyList;
329 
330  public:
333 
334  public:
337  void updateRenderData(double cameraMSLAltitude);
338 
339  protected:
341 
343 
344  };
345 
346 }
std::unordered_map< float, LineSegmentSets > LineMap
Definition: DtLineRenderer.h:146
std::vector< DtLineSegmentProxy * > DtLineSegmentProxyList
Definition: DtLineRenderer.h:328
friend DtLineRendererCreator
Definition: DtLineRenderer.h:51
DtLineSegmentProxyList myProxies
Definition: DtLineRenderer.h:340
A line segment proxy is a flyweight class for controlling a single line segment.
Definition: DtLineRenderer.h:191
int myIndex
Definition: DtLineRenderer.h:310
LineSegmentProxyList myDirtyList
Definition: DtLineRenderer.h:184
int mySegmentIndex
Definition: DtLineRenderer.h:309
A class the wraps a OpenGL Array Buffer object.
Definition: DtBufferObject.h:17
bool myIsLodOutAltitudeEnabled
Definition: DtLineRenderer.h:313
std::vector< DtLineSegmentProxyGroup * > myLineSegmentProxyGroups
Definition: DtLineRenderer.h:182
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
DtProjected2DLineEffect * myEffect
Definition: DtLineRenderer.h:183
DtVirtualBaseClassCreator< DtLineRenderer, DtOverlayResourceProvider & > DtLineRendererCreator
creator
Definition: DtLineRenderer.h:38
static bool equal(DtLineSegmentProxy *&v1, DtLineSegmentProxy *&v2)
Definition: DtLineRenderer.h:290
std::map< const DtLineSegmentProxy *, DtLineSegmentProxyGroup * > myLineSegmentProxyToGroupMap
Definition: DtLineRenderer.h:181
unsigned int myRenderedSimpleLineCount
Definition: DtLineRenderer.h:143
Definition: DtLineRenderer.h:108
LineSegmentProxyList myStippledProxies
Definition: DtLineRenderer.h:112
LineSegments & segmentsByIndex(unsigned int index)
Definition: DtLineRenderer.h:119
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:22
The overlay resource provider class provides resources for overlay drawing classes.
Definition: DtOverlayResourceProvider.h:28
Definition: DtLineRenderer.h:56
static bool less(DtLineSegmentProxy *&v1, DtLineSegmentProxy *&v2)
Definition: DtLineRenderer.h:275
float myWidth
Definition: DtLineRenderer.h:311
#define DT_DLL_VRVGRAPHICS
Contains DLL export macros.
Definition: vrvGraphics.h:19
Contains the makVrv::DtLineSegmentInterface class declaration.
bool myDirtyFlag
Definition: DtLineRenderer.h:308
std::vector< LineSegmentPrimitive > LineSegments
Definition: DtLineRenderer.h:105
DtLineSegmentInterface::DtLineSegmentAltitudeBasedConfigurationCollection myAltitudeBasedConfigurations
Definition: DtLineRenderer.h:342
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:185
double myForcedAltitudeToUse
Definition: DtLineRenderer.h:316
DtLineRenderer * myParent
Definition: DtLineRenderer.h:306
std::vector< DtLineSegmentAltitudeBasedConfiguration > DtLineSegmentAltitudeBasedConfigurationCollection
A collection of altitude-based configurations.
Definition: DtLineSegmentInterface.h:76
A structure to hold rendering information for overlays. This is used to pass to various overlay rende...
Definition: DtCommonRenderData.h:42
LineSegments myStippledLines
Definition: DtLineRenderer.h:115
DtLineVertex p2
Definition: DtLineRenderer.h:59
DtBufferObject * myBufferObjectStippleLines
Definition: DtLineRenderer.h:141
float lineParams[2]
Definition: DtFlat2DLineRenderer.h:35
LineSegmentProxyList mySimpleProxies
Definition: DtLineRenderer.h:111
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:43
bool myIsForcedAltitudeEnabled
Definition: DtLineRenderer.h:315
DtBufferObject * myBufferObjectSimpleLines
Definition: DtLineRenderer.h:140
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:72
LineSegments mySimpleLines
Definition: DtLineRenderer.h:114
LineSegmentProxyList & proxiesByIndex(unsigned int index)
Definition: DtLineRenderer.h:127
DtLineVertex p1
Definition: DtLineRenderer.h:58
A group of line segment proxy objects that all share the same altitude-based configurations - allowin...
Definition: DtLineRenderer.h:323
LineMap myLines
Definition: DtLineRenderer.h:180
static void swap(DtLineSegmentProxy *&v1, DtLineSegmentProxy *&v2)
Definition: DtLineRenderer.h:263
Definition: DtCommonRenderData.h:32
const char * creatorTypeName< DtLineRenderer >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtLineRenderer.h:45
Contains makVrv::DtFlat2DLineRenderer class.
A class responsible for rendering lines.
Definition: DtLineRenderer.h:49
uint8_t * myToBeRenderedBuffer
Definition: DtLineRenderer.h:110
std::vector< DtLineSegmentProxy * > LineSegmentProxyList
Definition: DtLineRenderer.h:106
double myLodOutAltitude
Definition: DtLineRenderer.h:312

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)