VR-Forces 4.10 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 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
15 
16 #include <vrvGraphics/DtFont.h>
17 
19 
20 #include <osg/Vec2>
21 #include <osg/Vec2d>
22 
23 #include <boost/unordered_set.hpp>
24 
25 namespace makVrv
26 {
27 
28  class DtDe;
29  class DtOsgChannel;
30  class DtOverlayRenderer;
31  class DtLineSegment;
32  class DtTextProxy;
33  class DtBoundingBox;
34 
39  {
40  public:
41 
44 
46  virtual ~DtProjectedGridLinesDrawer();
47 
49  virtual void drawGridLines();
50 
52  virtual void setMaxGridLines( int maxGridLines );
53 
56  virtual void setWindowDimensions( double startWindowX, double startWindowY,
57  double endWindowX, double endWindowY );
58 
60  virtual void setCenter( const osg::Vec2d& center );
61 
63  virtual void setHeading( double heading );
64 
66  virtual void setScale( double scale );
67 
69  virtual void destroyGridLines();
70 
71  protected:
73  virtual void reloadTextFonts();
74 
76  enum LabelPosition { Bottom, Left, Top, Right, Indeterminate };
77 
78  // \brief Draw the north/south grid lines and labels based on current geometry
79  virtual void drawNorthSouthGridLinesAndLabels();
80 
81  // \brief Draw the east/west grid lines and labels based on current geometry
82  virtual void drawEastWestGridLinesAndLabels();
83 
86  virtual void findSpacing();
87 
91  virtual void anchorAndOffsetLines();
92 
97  virtual DtUnicode createLabel( const double& xMeters, const double& yMeters, bool isNorthSouth );
98 
99  virtual bool labelGridBox( double nsValue, double ewValue, int labelIndex );
100 
103  void convertDegreeSpacingToMeters( double gridSpacing, double& xSpacing, double& ySpacing ) const;
104 
106  virtual DtFont::TextAlignement offsetLabel( double xSrc, double ySrc,
107  double& xOffset, double& yOffset, DtBoundingBox& bbox ) const;
108 
110  virtual DtFont::TextAlignement offsetGridBoxLabel( double xSrc, double ySrc,
111  double& xOffset, double& yOffset, DtBoundingBox& bbox ) const;
112 
114  virtual LabelPosition calcLabelPosition( double x, double y ) const;
115 
117  virtual void calcDesiredLabelPosition();
118 
121  double degreesLatitudeToMeters( double x, double y ) const;
122 
123  double convertToMetersOrDegrees( double value ) const;
124 
127  virtual double degreesLongitudeToMeters() const;
128 
131  virtual double fixedSpacingAmount() const;
132 
135  virtual double xOffset() const;
136 
139  virtual double yOffset() const;
140 
141  struct GridLine
142  {
143  public:
146  double value;
147  // If an east west label, the start and end x values; else
148  // start and end y values;
149  double start;
150  double end;
151  };
152 
153  typedef std::vector<GridLine> GridLineVector;
154 
155  // Array grid box labels
156  typedef std::vector<DtTextProxy*> GridBoxLabelArray;
157 
158  virtual void clearUnusedLinesAndLabels( int index, GridLineVector& lines );
159 
160  virtual void clearUnusedGridBoxLabels( int index );
161 
162  virtual bool drawGridLineAndLabel( double startX, double startY,
163  double endX, double endY, GridLine& gridLine, float* lineColor,
164  LabelPosition labelPosition, float* labelColor, bool isNorthSouth );
165 
166  protected:
167 
171  virtual void labelGridBoxes();
172 
174  typedef std::vector<float> VertexList;
175 
177  static void rotate(const DtProjectedGridLinesDrawer::VertexList& in,
178  double rad, DtProjectedGridLinesDrawer::VertexList& out );
179 
181  static void translate( const DtProjectedGridLinesDrawer::VertexList& in,
182  const osg::Vec2& translation, DtProjectedGridLinesDrawer::VertexList& out );
183 
185  static void scale( const DtProjectedGridLinesDrawer::VertexList& in,
187 
188  private:
189 
192 
195 
196  protected:
197  typedef boost::unordered_set<DtUnicode> UsedGridLabels;
198 
202 
204 
205  double myHeading;
206  osg::Vec2d myCenter;
209  double myEndWindowX;
210  double myEndWindowY;
211  double myScale;
212 
217  double myXSpacing;
218  double myYSpacing;
221 
222  };
223 
224 }
double myAnchoredMinY
Definition: DtProjectedGridLinesDrawer.h:214
boost::unordered_set< DtUnicode > UsedGridLabels
Definition: DtProjectedGridLinesDrawer.h:197
A unicode string.
Definition: DtUnicode.h:33
LabelPosition
Represent an screen edge to place a label on.
Definition: DtProjectedGridLinesDrawer.h:76
double end
Definition: DtProjectedGridLinesDrawer.h:150
LabelPosition myNorthSouthLabelPosition
Definition: DtProjectedGridLinesDrawer.h:219
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
double myAnchoredMaxX
Definition: DtProjectedGridLinesDrawer.h:215
double myEndWindowX
Definition: DtProjectedGridLinesDrawer.h:209
std::vector< float > VertexList
his type can be used to provide a list of vertices to the polygon objects
Definition: DtProjectedGridLinesDrawer.h:174
A class for controlling text owned by the TextRenderer.
Definition: DtTextRenderer.h:90
osg::Vec2d myCenter
Definition: DtProjectedGridLinesDrawer.h:206
GridLineVector myEastWestLines
Definition: DtProjectedGridLinesDrawer.h:199
GridBoxLabelArray myGridBoxLabels
Definition: DtProjectedGridLinesDrawer.h:201
double myAnchoredMinX
Definition: DtProjectedGridLinesDrawer.h:213
vrvGraphics-based implementation of 2D Grid Lines on projected databases \ingroup vrvOsg ...
Definition: DtProjectedGridLinesDrawer.h:38
TextAlignement
Definition: DtFont.h:33
DtLineSegment * line
Definition: DtProjectedGridLinesDrawer.h:144
double myXSpacing
Definition: DtProjectedGridLinesDrawer.h:217
std::vector< DtTextProxy * > GridBoxLabelArray
Definition: DtProjectedGridLinesDrawer.h:156
A class which represents a single line segment.
Definition: DtLineSegment.h:21
double myAnchoredMaxY
Definition: DtProjectedGridLinesDrawer.h:216
UsedGridLabels myUsedGridLabels
Definition: DtProjectedGridLinesDrawer.h:203
double myYSpacing
Definition: DtProjectedGridLinesDrawer.h:218
double value
Definition: DtProjectedGridLinesDrawer.h:146
LabelPosition myEastWestLabelPosition
Definition: DtProjectedGridLinesDrawer.h:220
double myHeading
Definition: DtProjectedGridLinesDrawer.h:205
Contains the DtGridLinesSettingsRecord class declaration.
GridLineVector myNorthSouthLines
Definition: DtProjectedGridLinesDrawer.h:200
DtTextProxy * label
Definition: DtProjectedGridLinesDrawer.h:145
std::vector< GridLine > GridLineVector
Definition: DtProjectedGridLinesDrawer.h:153
double myStartWindowX
Definition: DtProjectedGridLinesDrawer.h:207
Contains makVrv::DtFont class.
Base class with common data / methods for drawing grid lines on projected and geocentric databases \i...
Definition: DtGridLinesDrawer.h:32
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
double start
Definition: DtProjectedGridLinesDrawer.h:149
double myScale
Definition: DtProjectedGridLinesDrawer.h:211
double myStartWindowY
Definition: DtProjectedGridLinesDrawer.h:208
double myEndWindowY
Definition: DtProjectedGridLinesDrawer.h:210
Definition: DtProjectedGridLinesDrawer.h:76
Definition: DtProjectedGridLinesDrawer.h:141
A simple bounding box.
Definition: DtBoundingBox.h:101

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)