VR-Forces 4.7 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 
101  LineSegmentProxyList& proxiesByIndex(unsigned int index)
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 }

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)