VR-Vantage API Documentation
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 
12 
13 #include <vector>
14 #include <boost/unordered_map.hpp>
15 
16 namespace makVrv
17 {
18  class DtBufferObject;
19  class DtFlat2DLineRenderer;
20  class DtLineSegmentProxy;
21  class DtOverlayResourceProvider;
22  class DtProjected2DLineEffect;
23 
27  {
28  friend class DtLineSegmentProxy;
29  public:
30 
32  {
35  };
36 
37  const static unsigned short NoStipple = 0xFFFF;
38  const static unsigned short NoLine = 0x0;
39 
41 
42  virtual ~DtLineRenderer();
43 
45  virtual int numberOfPrimitives() const;
46 
48  virtual void render(bool geocentric, float geocentricAlpha,
49  const double cameraLocation[3],
50  const double positionMatrix[16], bool picking);
51 
53  virtual void releaseResources();
54 
56  virtual bool isRenderModeSupported(int mode);
57 
59  DtLineSegmentProxy* allocateNewSegment();
60 
61  protected:
62 
63  // Called when a proxy modified data.
64  void dirty(DtLineSegmentProxy*);
65 
66  //Called in proxy destructor.
67  void deallocateProxy(const DtLineSegmentProxy&);
68 
69  // Move Segment from one list to another.
70  int moveSegmentToOtherList(
71  const float currentWidth,
72  const int currentSegmentIndex,
73  const int currentPrimativeIndex,
74  const float desiredWidth,
75  const int desiredSegmentIndex);
76 
77  private:
78 
79  typedef std::vector<LineSegmentPrimitive> LineSegments;
80  typedef std::vector<DtLineSegmentProxy*> LineSegmentProxyList;
81 
83  {
86 
89 
90  LineSegments& segmentsByIndex(unsigned int index)
91  {
92  if(index == 0)
93  return mySimpleLines;
94  else
95  return myStippledLines;
96  }
97 
98  LineSegmentProxyList& proxiesByIndex(unsigned int index)
99  {
100  if(index == 0)
101  return mySimpleProxies;
102  else
103  return myStippledProxies;
104  }
105  };
106 
107  typedef boost::unordered_map<float,LineSegmentSets> LineMap;
108 
109  void renderUsingVertexArrays(DtFlat2DLineRenderer& renderer);
110  void renderStippledLineArrays(DtFlat2DLineRenderer& renderer,
111  DtLineVertex* ptr, LineSegments& segments);
112  void updateRenderData();
113  void sortByStipple();
114 
119  unsigned int myPrimativeCount;
120  };
121 
126  {
127  friend class DtLineRenderer;
128  public:
129  ~DtLineSegmentProxy();
130 
131  const DtLineRenderer::LineSegmentPrimitive& mapReadOnly() const;
132  DtLineRenderer::LineSegmentPrimitive& mapReadWrite();
133 
135  void enableStipple();
136 
138  void disableStipple();
139 
141  void setWidth(float w);
142 
144  float width() const;
145 
147  void setGroup(float group);
148 
150  float group() const;
151 
152  //Needed for sorting.
153  static inline void swap(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
154  {
155  //Swap what they point to
156  std::swap(v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex],
157  v2->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex]);
158  //Swap their indices
159  std::swap(v1->myIndex,v2->myIndex);
160  //Swap themselves
161  std::swap(v1,v2);
162  }
163 
164  //Needed for sorting.
165  static inline bool less(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
166  {
168  v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex];
170  v1->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex];
171 
172  return (((unsigned int)line1.p1.lineParams[0]) << 16 |
173  (unsigned int)(line1.p1.lineParams[1]))
174  <
175  (((unsigned int)line2.p1.lineParams[0]) << 16 |
176  (unsigned int)(line2.p1.lineParams[1]));
177  }
178 
179  //Needed for sorting.
180  static inline bool equal(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
181  {
183  v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex];
185  v1->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex];
186 
187  return (((unsigned int)line1.p1.lineParams[0]) << 16 |
188  (unsigned int)(line1.p1.lineParams[1]))
189  ==
190  (((unsigned int)line2.p1.lineParams[0]) << 16 |
191  (unsigned int)(line2.p1.lineParams[1]));
192  }
193 
194  protected:
195  DtLineSegmentProxy(DtLineRenderer& parent,int index);
197 
200  int myIndex;
201  float myWidth;
202 
203  };
204 
205 }


Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)