VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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], bool picking);
50 
52  virtual void releaseResources();
53 
55  virtual bool isRenderModeSupported(int mode);
56 
58  DtLineSegmentProxy* allocateNewSegment();
59 
60  protected:
61 
62  // Called when a proxy modified data.
63  void dirty(DtLineSegmentProxy*);
64 
65  //Called in proxy destructor.
66  void deallocateProxy(const DtLineSegmentProxy&);
67 
68  // Move Segment from one list to another.
69  int moveSegmentToOtherList(
70  const float currentWidth,
71  const int currentSegmentIndex,
72  const int currentPrimativeIndex,
73  const float desiredWidth,
74  const int desiredSegmentIndex);
75 
76  private:
77 
78  typedef std::vector<LineSegmentPrimitive> LineSegments;
79  typedef std::vector<DtLineSegmentProxy*> LineSegmentProxyList;
80 
82  {
85 
88 
89  LineSegments& segmentsByIndex(unsigned int index)
90  {
91  if(index == 0)
92  return mySimpleLines;
93  else
94  return myStippledLines;
95  }
96 
97  LineSegmentProxyList& proxiesByIndex(unsigned int index)
98  {
99  if(index == 0)
100  return mySimpleProxies;
101  else
102  return myStippledProxies;
103  }
104  };
105 
106  typedef boost::unordered_map<float,LineSegmentSets> LineMap;
107 
108  void renderUsingVertexArrays(DtFlat2DLineRenderer& renderer);
109  void renderStippledLineArrays(DtFlat2DLineRenderer& renderer,
110  DtLineVertex* ptr, LineSegments& segments);
111  void updateRenderData();
112  void sortByStipple();
113 
118  unsigned int myPrimativeCount;
119  };
120 
125  {
126  friend class DtLineRenderer;
127  public:
128  ~DtLineSegmentProxy();
129 
130  const DtLineRenderer::LineSegmentPrimitive& mapReadOnly() const;
131  DtLineRenderer::LineSegmentPrimitive& mapReadWrite();
132 
134  void enableStipple();
135 
137  void disableStipple();
138 
140  void setWidth(float w);
141 
143  float width() const;
144 
146  void setGroup(float group);
147 
149  float group() const;
150 
151  //Needed for sorting.
152  static inline void swap(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
153  {
154  //Swap what they point to
155  std::swap(v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex],
156  v2->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex]);
157  //Swap their indices
158  std::swap(v1->myIndex,v2->myIndex);
159  //Swap themselves
160  std::swap(v1,v2);
161  }
162 
163  //Needed for sorting.
164  static inline bool less(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
165  {
167  v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex];
169  v1->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex];
170 
171  return (((unsigned int)line1.p1.lineParams[0]) << 16 |
172  (unsigned int)(line1.p1.lineParams[1]))
173  <
174  (((unsigned int)line2.p1.lineParams[0]) << 16 |
175  (unsigned int)(line2.p1.lineParams[1]));
176  }
177 
178  //Needed for sorting.
179  static inline bool equal(DtLineSegmentProxy*& v1,DtLineSegmentProxy*& v2)
180  {
182  v1->myParent->myLines[v1->myWidth].segmentsByIndex(v1->mySegmentIndex)[v1->myIndex];
184  v1->myParent->myLines[v2->myWidth].segmentsByIndex(v2->mySegmentIndex)[v2->myIndex];
185 
186  return (((unsigned int)line1.p1.lineParams[0]) << 16 |
187  (unsigned int)(line1.p1.lineParams[1]))
188  ==
189  (((unsigned int)line2.p1.lineParams[0]) << 16 |
190  (unsigned int)(line2.p1.lineParams[1]));
191  }
192 
193  protected:
194  DtLineSegmentProxy(DtLineRenderer& parent,int index);
196 
199  int myIndex;
200  float myWidth;
201 
202  };
203 
204 }

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)