VR-Forces 4.8 Class Documentation
 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) 2010 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
6 
7 #pragma once
8 
11 
12 #include <vector>
13 #include <boost/unordered_map.hpp>
14 
15 namespace makVrv
16 {
17  class DtBufferObject;
18  class DtFlat2DLineRenderer;
19  class DtLineSegmentProxy;
20  class DtOverlayResourceProvider;
21  class DtProjected2DLineEffect;
22 
26  {
27  friend class DtLineSegmentProxy;
28  public:
29 
31  {
34  };
35 
36  const static unsigned short NoStipple = 0xFFFF;
37  const static unsigned short NoLine = 0x0;
38 
40 
41  virtual ~DtLineRenderer();
42 
44  virtual int numberOfPrimitives() const;
45 
47  virtual void render(bool geocentric, float geocentricAlpha,
48  const double cameraLocation[3],
49  const double positionMatrix[16],
50  const double projectionMatrix[16],
51  bool picking);
52 
54  virtual void releaseResources();
55 
57  virtual bool isRenderModeSupported(int mode);
58 
60  DtLineSegmentProxy* allocateNewSegment();
61 
62  protected:
63 
64  // Called when a proxy modified data.
65  void dirty(DtLineSegmentProxy*);
66 
67  //Called in proxy destructor.
68  void deallocateProxy(const DtLineSegmentProxy&);
69 
70  // Move Segment from one list to another.
71  int moveSegmentToOtherList(
72  const float currentWidth,
73  const int currentSegmentIndex,
74  const int currentPrimativeIndex,
75  const float desiredWidth,
76  const int desiredSegmentIndex);
77 
78  private:
79 
80  typedef std::vector<LineSegmentPrimitive> LineSegments;
81  typedef std::vector<DtLineSegmentProxy*> LineSegmentProxyList;
82 
84  {
87 
90 
92 
93  LineSegments& segmentsByIndex(unsigned int index)
94  {
95  if(index == 0)
96  return mySimpleLines;
97  else
98  return myStippledLines;
99  }
100 
102  {
103  if(index == 0)
104  return mySimpleProxies;
105  else
106  return myStippledProxies;
107  }
108 
109  void updateRenderData(void);
110  void releaseResources(void);
111 
114  };
115 
116  typedef boost::unordered_map<float,LineSegmentSets> LineMap;
117 
118  void renderUsingVertexBufferObjects(DtFlat2DLineRenderer& renderer);
119  void renderStippledLineArrays(DtFlat2DLineRenderer& renderer, LineSegmentSets& lss);
120  void updateRenderData();
121  void sortByStipple();
122 
126  unsigned int myPrimitiveCount;
127  };
128 
133  {
134  friend class DtLineRenderer;
135  public:
136  ~DtLineSegmentProxy();
137 
138  const DtLineRenderer::LineSegmentPrimitive& mapReadOnly() const;
139  DtLineRenderer::LineSegmentPrimitive& mapReadWrite();
140 
142  void enableStipple();
143 
145  void disableStipple();
146 
148  void setWidth(float w);
149 
151  float width() const;
152 
154  void setGroup(float group);
155 
157  float group() const;
158 
159  //Needed for sorting.
160  static inline void swap(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
161  {
162  //Swap what they point to
163  std::swap(v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex],
164  v2->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex]);
165  //Swap their indices
166  std::swap(v1->myIndex,v2->myIndex);
167  //Swap themselves
168  std::swap(v1,v2);
169  }
170 
171  //Needed for sorting.
172  static inline bool less(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
173  {
175  v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex];
177  v2->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex];
178 
179  return (((unsigned int)line1.p1.lineParams[0]) << 16 |
180  (unsigned int)(line1.p1.lineParams[1]))
181  <
182  (((unsigned int)line2.p1.lineParams[0]) << 16 |
183  (unsigned int)(line2.p1.lineParams[1]));
184  }
185 
186  //Needed for sorting.
187  static inline bool equal(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
188  {
190  v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex];
192  v2->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex];
193 
194  return (((unsigned int)line1.p1.lineParams[0]) << 16 |
195  (unsigned int)(line1.p1.lineParams[1]))
196  ==
197  (((unsigned int)line2.p1.lineParams[0]) << 16 |
198  (unsigned int)(line2.p1.lineParams[1]));
199  }
200 
201  protected:
202  DtLineSegmentProxy(DtLineRenderer& parent,int index);
204 
207  int myIndex;
208  float myWidth;
209 
210  };
211 
212 }
A line segment proxy is a flyweight class for controlling a single line segment.
Definition: DtLineRenderer.h:132
int myIndex
Definition: DtLineRenderer.h:207
LineSegmentProxyList myDirtyList
Definition: DtLineRenderer.h:125
int mySegmentIndex
Definition: DtLineRenderer.h:206
A class the wraps a OpenGL Array Buffer object.
Definition: DtBufferObject.h:17
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
DtProjected2DLineEffect * myEffect
Definition: DtLineRenderer.h:124
static bool equal(DtLineSegmentProxy *&v1, DtLineSegmentProxy *&v2)
Definition: DtLineRenderer.h:187
Definition: DtLineRenderer.h:83
LineSegmentProxyList myStippledProxies
Definition: DtLineRenderer.h:86
LineSegments & segmentsByIndex(unsigned int index)
Definition: DtLineRenderer.h:93
The overlay resource provider class provies resources for overlay drawing classes.
Definition: DtOverlayResourceProvider.h:23
Definition: DtLineRenderer.h:30
static bool less(DtLineSegmentProxy *&v1, DtLineSegmentProxy *&v2)
Definition: DtLineRenderer.h:172
float myWidth
Definition: DtLineRenderer.h:208
#define DT_DLL_VRVGRAPHICS
Contains DLL export macros.
Definition: vrvGraphics.h:19
bool myDirtyFlag
Definition: DtLineRenderer.h:205
std::vector< LineSegmentPrimitive > LineSegments
Definition: DtLineRenderer.h:80
Abstract primitive rendering base class.
Definition: DtPrimitiveRenderer.h:18
A vertex element used for rendering a line.
Definition: DtFlat2DLineRenderer.h:23
unsigned int myPrimitiveCount
Definition: DtLineRenderer.h:126
DtLineRenderer * myParent
Definition: DtLineRenderer.h:203
boost::unordered_map< float, LineSegmentSets > LineMap
Definition: DtLineRenderer.h:116
LineSegments myStippledLines
Definition: DtLineRenderer.h:89
DtLineVertex p2
Definition: DtLineRenderer.h:33
DtBufferObject * myBufferObjectStippleLines
Definition: DtLineRenderer.h:113
float lineParams[2]
Definition: DtFlat2DLineRenderer.h:37
LineSegmentProxyList mySimpleProxies
Definition: DtLineRenderer.h:85
An effect for rendering 2D projected lines Has support for direction and length information per verte...
Definition: DtProjected2DLineEffect.h:22
const char int mode
Definition: ioapi.h:38
A Renderer which renders 2D lines with only a color.
Definition: DtFlat2DLineRenderer.h:44
DtBufferObject * myBufferObjectSimpleLines
Definition: DtLineRenderer.h:112
LineSegments mySimpleLines
Definition: DtLineRenderer.h:88
LineSegmentProxyList & proxiesByIndex(unsigned int index)
Definition: DtLineRenderer.h:101
DtLineVertex p1
Definition: DtLineRenderer.h:32
LineMap myLines
Definition: DtLineRenderer.h:123
static void swap(DtLineSegmentProxy *&v1, DtLineSegmentProxy *&v2)
Definition: DtLineRenderer.h:160
Contains makVrv::DtFlat2DLineRenderer class.
A class responsible for rendering lines.
Definition: DtLineRenderer.h:25
std::vector< DtLineSegmentProxy * > LineSegmentProxyList
Definition: DtLineRenderer.h:81

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)