VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:
76  virtual void reloadTextFonts();
77 
79  enum LabelPosition { Bottom, Left, Top, Right, Indeterminate };
80 
81  // \brief Draw the north/south grid lines and labels based on current geometry
82  virtual void drawNorthSouthGridLinesAndLabels();
83 
84  // \brief Draw the east/west grid lines and labels based on current geometry
85  virtual void drawEastWestGridLinesAndLabels();
86 
89  virtual void findSpacing();
90 
94  virtual void anchorAndOffsetLines();
95 
100  virtual DtUnicode createLabel( const double& xMeters, const double& yMeters, bool isNorthSouth );
101 
102  virtual bool labelGridBox( double nsValue, double ewValue, int labelIndex );
103 
106  void convertDegreeSpacingToMeters( double gridSpacing, double& xSpacing, double& ySpacing ) const;
107 
109  virtual DtFont::TextAlignement offsetLabel( double xSrc, double ySrc,
110  double& xOffset, double& yOffset, DtBoundingBox& bbox ) const;
111 
113  virtual DtFont::TextAlignement offsetGridBoxLabel( double xSrc, double ySrc,
114  double& xOffset, double& yOffset, DtBoundingBox& bbox ) const;
115 
117  virtual LabelPosition calcLabelPosition( double x, double y ) const;
118 
120  virtual void calcDesiredLabelPosition();
121 
124  double degreesLatitudeToMeters( double x, double y ) const;
125 
126  double convertToMetersOrDegrees( double value ) const;
127 
130  virtual double degreesLongitudeToMeters() const;
131 
134  virtual double fixedSpacingAmount() const;
135 
138  virtual double xOffset() const;
139 
142  virtual double yOffset() const;
143 
144  struct GridLine
145  {
146  public:
149  double value;
150  // If an east west label, the start and end x values; else
151  // start and end y values;
152  double start;
153  double end;
154  };
155 
156  typedef std::vector<GridLine> GridLineVector;
157 
158  // Array grid box labels
159  typedef std::vector<DtTextProxy*> GridBoxLabelArray;
160 
161  virtual void clearUnusedLinesAndLabels( int index, GridLineVector& lines );
162 
163  virtual void clearUnusedGridBoxLabels( int index );
164 
165  virtual bool drawGridLineAndLabel( double startX, double startY,
166  double endX, double endY, GridLine& gridLine, float* lineColor,
167  LabelPosition labelPosition, float* labelColor, bool isNorthSouth );
168 
169  protected:
170 
174  virtual void labelGridBoxes();
175 
177  typedef std::vector<float> VertexList;
178 
180  static void rotate(const DtProjectedGridLinesDrawer::VertexList& in,
181  double rad, DtProjectedGridLinesDrawer::VertexList& out );
182 
184  static void translate( const DtProjectedGridLinesDrawer::VertexList& in,
185  const osg::Vec2& translation, DtProjectedGridLinesDrawer::VertexList& out );
186 
188  static void scale( const DtProjectedGridLinesDrawer::VertexList& in,
190 
191  private:
192 
195 
198 
199  protected:
200  typedef boost::unordered_set<DtUnicode> UsedGridLabels;
201 
205 
207 
208  double myHeading;
209  osg::Vec2d myCenter;
212  double myEndWindowX;
213  double myEndWindowY;
214  double myScale;
215 
220  double myXSpacing;
221  double myYSpacing;
224 
225  };
226 
227 }
double myAnchoredMinY
Definition: DtProjectedGridLinesDrawer.h:217
boost::unordered_set< DtUnicode > UsedGridLabels
Definition: DtProjectedGridLinesDrawer.h:200
A unicode string.
Definition: DtUnicode.h:33
LabelPosition
Represent an screen edge to place a label on.
Definition: DtProjectedGridLinesDrawer.h:79
double end
Definition: DtProjectedGridLinesDrawer.h:153
LabelPosition myNorthSouthLabelPosition
Definition: DtProjectedGridLinesDrawer.h:222
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
double myAnchoredMaxX
Definition: DtProjectedGridLinesDrawer.h:218
double myEndWindowX
Definition: DtProjectedGridLinesDrawer.h:212
std::vector< float > VertexList
his type can be used to provide a list of vertices to the polygon objects
Definition: DtProjectedGridLinesDrawer.h:177
A class for controlling text owned by the TextRenderer.
Definition: DtTextRenderer.h:90
osg::Vec2d myCenter
Definition: DtProjectedGridLinesDrawer.h:209
GridLineVector myEastWestLines
Definition: DtProjectedGridLinesDrawer.h:202
GridBoxLabelArray myGridBoxLabels
Definition: DtProjectedGridLinesDrawer.h:204
double myAnchoredMinX
Definition: DtProjectedGridLinesDrawer.h:216
vrvGraphics-based implementation of 2D Grid Lines on projected databases \ingroup vrvOsg ...
Definition: DtProjectedGridLinesDrawer.h:41
TextAlignement
Definition: DtFont.h:33
DtLineSegment * line
Definition: DtProjectedGridLinesDrawer.h:147
double myXSpacing
Definition: DtProjectedGridLinesDrawer.h:220
std::vector< DtTextProxy * > GridBoxLabelArray
Definition: DtProjectedGridLinesDrawer.h:159
A class which represents a single line segment.
Definition: DtLineSegment.h:21
double myAnchoredMaxY
Definition: DtProjectedGridLinesDrawer.h:219
UsedGridLabels myUsedGridLabels
Definition: DtProjectedGridLinesDrawer.h:206
double myYSpacing
Definition: DtProjectedGridLinesDrawer.h:221
double value
Definition: DtProjectedGridLinesDrawer.h:149
LabelPosition myEastWestLabelPosition
Definition: DtProjectedGridLinesDrawer.h:223
double myHeading
Definition: DtProjectedGridLinesDrawer.h:208
Contains the DtGridLinesSettingsRecord class declaration.
GridLineVector myNorthSouthLines
Definition: DtProjectedGridLinesDrawer.h:203
DtTextProxy * label
Definition: DtProjectedGridLinesDrawer.h:148
std::vector< GridLine > GridLineVector
Definition: DtProjectedGridLinesDrawer.h:156
double myStartWindowX
Definition: DtProjectedGridLinesDrawer.h:210
Contains makVrv::DtFont class.
Base class with common data / methods for drawing grid lines on projected and geocentric databases \i...
Definition: DtGridLinesDrawer.h:35
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
double start
Definition: DtProjectedGridLinesDrawer.h:152
double myScale
Definition: DtProjectedGridLinesDrawer.h:214
double myStartWindowY
Definition: DtProjectedGridLinesDrawer.h:211
double myEndWindowY
Definition: DtProjectedGridLinesDrawer.h:213
Definition: DtProjectedGridLinesDrawer.h:79
Definition: DtProjectedGridLinesDrawer.h:144
A simple bounding box.
Definition: DtBoundingBox.h:101

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)