VR-Forces 4.1 Class Documentation
DtProjectedGridLinesDrawer.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2011 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 /*****************************************************************************
6  * $RCSfile: DtProjectedGridLinesDrawer.h,v $ $Revision: 1.17 $ $State: Exp $
7  *****************************************************************************/
8 
12 
13 #pragma once
14 
15 #include <vrvOsg/vrvOsg.h>
16 
18 
19 #include <vrvGraphics/DtFont.h>
20 
22 
23 #include <osg/Vec2>
24 #include <osg/Vec2d>
25 
26 #include <boost/unordered_set.hpp>
27 
28 namespace makVrv
29 {
30 
31  class DtDe;
32  class DtOsgChannel;
33  class DtOverlayRenderer;
34  class DtLineSegment;
35  class DtTextProxy;
36  class DtBoundingBox;
37 
42  {
43  public:
44 
47 
49  virtual ~DtProjectedGridLinesDrawer();
50 
52  virtual void drawGridLines();
53 
55  virtual void setMaxGridLines( int maxGridLines );
56 
59  virtual void setWindowDimensions( double startWindowX, double startWindowY,
60  double endWindowX, double endWindowY );
61 
63  virtual void setCenter( const osg::Vec2d& center );
64 
66  virtual void setHeading( double heading );
67 
69  virtual void setScale( double scale );
70 
72  virtual void destroyGridLines();
73 
74  protected:
75 
77  enum LabelPosition { Bottom, Left, Top, Right, Indeterminate };
78 
79  // \brief Draw the north/south grid lines and labels based on current geometry
80  virtual void drawNorthSouthGridLinesAndLabels();
81 
82  // \brief Draw the east/west grid lines and labels based on current geometry
83  virtual void drawEastWestGridLinesAndLabels();
84 
87  virtual void findSpacing();
88 
92  virtual void anchorAndOffsetLines();
93 
98  virtual DtUnicode createLabel( double& xMeters, double yMeters, bool isNorthSouth );
99 
100  virtual bool labelGridBox( double nsValue, double ewValue, int labelIndex );
101 
104  void convertDegreeSpacingToMeters( double gridSpacing, double& xSpacing, double& ySpacing ) const;
105 
107  virtual DtFont::TextAlignement offsetLabel( double xSrc, double ySrc,
108  double& xOffset, double& yOffset, DtBoundingBox& bbox ) const;
109 
111  virtual DtFont::TextAlignement offsetGridBoxLabel( double xSrc, double ySrc,
112  double& xOffset, double& yOffset, DtBoundingBox& bbox ) const;
113 
115  virtual LabelPosition calcLabelPosition( double x, double y ) const;
116 
118  virtual void calcDesiredLabelPosition();
119 
122  double degreesLatitudeToMeters( double x, double y ) const;
123 
124  double convertToMetersOrDegrees( double value ) const;
125 
128  virtual double degreesLongitudeToMeters() const;
129 
132  virtual double fixedSpacingAmount() const;
133 
136  virtual double xOffset() const;
137 
140  virtual double yOffset() const;
141 
142  struct GridLine
143  {
144  public:
147  double value;
148  // If an east west label, the start and end x values; else
149  // start and end y values;
150  double start;
151  double end;
152  };
153 
154  typedef std::vector<GridLine> GridLineVector;
155 
156  // Array grid box labels
157  typedef std::vector<DtTextProxy*> GridBoxLabelArray;
158 
159  virtual void clearUnusedLinesAndLabels( int index, GridLineVector& lines );
160 
161  virtual void clearUnusedGridBoxLabels( int index );
162 
163  virtual bool drawGridLineAndLabel( double startX, double startY,
164  double endX, double endY, GridLine& gridLine, float* lineColor,
165  LabelPosition labelPosition, float* labelColor, bool isNorthSouth );
166 
167  protected:
168 
172  virtual void labelGridBoxes();
173 
175  typedef std::vector<float> VertexList;
176 
178  static void rotate(const DtProjectedGridLinesDrawer::VertexList& in,
179  double rad, DtProjectedGridLinesDrawer::VertexList& out );
180 
182  static void translate( const DtProjectedGridLinesDrawer::VertexList& in,
183  const osg::Vec2& translation, DtProjectedGridLinesDrawer::VertexList& out );
184 
186  static void scale( const DtProjectedGridLinesDrawer::VertexList& in,
188 
189  private:
190 
193 
196 
197  protected:
198  typedef boost::unordered_set<DtUnicode> UsedGridLabels;
199 
203 
205 
206  double myHeading;
207  osg::Vec2d myCenter;
210  double myEndWindowX;
211  double myEndWindowY;
212  double myScale;
213 
218  double myXSpacing;
219  double myYSpacing;
222 
223  };
224 
225 }

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)