VR-Forces 5.0.1 Developer's Guide
 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) 2022 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 
21 
22 #include <osg/Vec2>
23 #include <osg/Vec2d>
24 
25 #include <boost/unordered_set.hpp>
26 
27 namespace makVrv
28 {
29  class DtDe;
30  class DtOsgChannel;
31  class DtOverlayRenderer;
32  class DtLineSegment;
33  class DtTextProxy;
34  class DtBoundingBox;
35  class DtCoordinateSystem;
36 
41  {
42  public:
43 
46 
48  virtual ~DtProjectedGridLinesDrawer();
49 
51  virtual void drawGridLines();
52 
54  virtual void setMaxGridLines( int maxGridLines );
55 
58  virtual void setWindowDimensions( double startWindowX, double startWindowY,
59  double endWindowX, double endWindowY );
60 
62  virtual void setCenter( const osg::Vec2d& center );
63 
65  virtual void setHeading( double heading );
66 
68  virtual void setScale( double scale );
69 
71  virtual void destroyGridLines();
72 
73  protected:
75  virtual void reloadTextFonts();
76 
78  enum LabelPosition { Bottom, Left, Top, Right, Indeterminate };
79 
80  // \brief Draw the north/south grid lines and labels based on current geometry
81  virtual void drawNorthSouthGridLinesAndLabels();
82 
83  // \brief Draw the east/west grid lines and labels based on current geometry
84  virtual void drawEastWestGridLinesAndLabels();
85 
88  virtual void findSpacing();
89 
93  virtual void anchorAndOffsetLines();
94 
99  virtual DtUnicode createLabel( const double& xMeters, const double& yMeters, bool isNorthSouth );
100 
101  virtual bool labelGridBox( double nsValue, double ewValue, int labelIndex );
102 
105  void convertDegreeSpacingToMeters( double gridSpacing, double& xSpacing, double& ySpacing ) const;
106 
108  virtual DtFont::TextAlignement offsetLabel( double xSrc, double ySrc,
109  double& xOffset, double& yOffset, DtBoundingBox& bbox ) const;
110 
112  virtual DtFont::TextAlignement offsetGridBoxLabel( double xSrc, double ySrc,
113  double& xOffset, double& yOffset, DtBoundingBox& bbox ) const;
114 
116  virtual LabelPosition calcLabelPosition( double x, double y ) const;
117 
119  virtual void calcDesiredLabelPosition();
120 
123  double degreesLatitudeToMeters( double x, double y ) const;
124 
125  double convertToMetersOrDegrees( double value ) const;
126 
129  virtual double degreesLongitudeToMeters() const;
130 
133  virtual double fixedSpacingAmount() const;
134 
137  virtual double xOffset() const;
138 
141  virtual double yOffset() const;
142 
143  struct GridLine
144  {
145  public:
148  double value;
149  // If an east west label, the start and end x values; else
150  // start and end y values;
151  double start;
152  double end;
153  };
154 
155  typedef std::vector<GridLine> GridLineVector;
156 
157  // Array grid box labels
158  typedef std::vector<DtTextProxy*> GridBoxLabelArray;
159 
160  virtual void clearUnusedLinesAndLabels( int index, GridLineVector& lines );
161 
162  virtual void clearUnusedGridBoxLabels( int index );
163 
164  virtual bool drawGridLineAndLabel( double startX, double startY,
165  double endX, double endY, GridLine& gridLine, float* lineColor,
166  LabelPosition labelPosition, float* labelColor, bool isNorthSouth );
167 
169  virtual void slot_coordinateSystemChanged();
170 
171  protected:
172 
176  virtual void labelGridBoxes();
177 
179  typedef std::vector<float> VertexList;
180 
182  static void rotate(const DtProjectedGridLinesDrawer::VertexList& in,
183  double rad, DtProjectedGridLinesDrawer::VertexList& out );
184 
186  static void translate( const DtProjectedGridLinesDrawer::VertexList& in,
187  const osg::Vec2& translation, DtProjectedGridLinesDrawer::VertexList& out );
188 
190  static void scale( const DtProjectedGridLinesDrawer::VertexList& in,
192 
193  private:
194 
197 
200 
201  protected:
202  typedef boost::unordered_set<DtUnicode> UsedGridLabels;
203 
207 
209 
210  double myHeading;
211  osg::Vec2d myCenter;
214  double myEndWindowX;
215  double myEndWindowY;
216  double myScale;
217 
222  double myXSpacing;
223  double myYSpacing;
226 
227 
229 
232  DtCoordinateSystem* myCoordinateSystem = nullptr;
233 
234  };
235 
236 }
double myAnchoredMinY
Definition: DtProjectedGridLinesDrawer.h:219
boost::unordered_set< DtUnicode > UsedGridLabels
Definition: DtProjectedGridLinesDrawer.h:202
A unicode string. DtUnicode stores a UTF-16 encoded unicode string. Code Point, a Unicode character...
Definition: DtUnicode.h:33
LabelPosition
Represent an screen edge to place a label on.
Definition: DtProjectedGridLinesDrawer.h:78
double end
Definition: DtProjectedGridLinesDrawer.h:152
LabelPosition myNorthSouthLabelPosition
Definition: DtProjectedGridLinesDrawer.h:224
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
double myAnchoredMaxX
Definition: DtProjectedGridLinesDrawer.h:220
double myEndWindowX
Definition: DtProjectedGridLinesDrawer.h:214
std::vector< float > VertexList
his type can be used to provide a list of vertices to the polygon objects
Definition: DtProjectedGridLinesDrawer.h:179
A class for controlling text owned by the TextRenderer.
Definition: DtTextRenderer.h:197
osg::Vec2d myCenter
Definition: DtProjectedGridLinesDrawer.h:211
GridLineVector myEastWestLines
Definition: DtProjectedGridLinesDrawer.h:204
GridBoxLabelArray myGridBoxLabels
Definition: DtProjectedGridLinesDrawer.h:206
double myAnchoredMinX
Definition: DtProjectedGridLinesDrawer.h:218
vrvGraphics-based implementation of 2D Grid Lines on projected databases \ingroup vrvOsg ...
Definition: DtProjectedGridLinesDrawer.h:40
TextAlignement
Definition: DtFont.h:33
DtLineSegment * line
Definition: DtProjectedGridLinesDrawer.h:146
double myXSpacing
Definition: DtProjectedGridLinesDrawer.h:222
std::vector< DtTextProxy * > GridBoxLabelArray
Definition: DtProjectedGridLinesDrawer.h:158
A class which represents a single line segment.
Definition: DtLineSegment.h:22
double myAnchoredMaxY
Definition: DtProjectedGridLinesDrawer.h:221
UsedGridLabels myUsedGridLabels
Definition: DtProjectedGridLinesDrawer.h:208
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
DtSignalConnectionManager myConnections
Definition: DtProjectedGridLinesDrawer.h:228
double myYSpacing
Definition: DtProjectedGridLinesDrawer.h:223
double value
Definition: DtProjectedGridLinesDrawer.h:148
LabelPosition myEastWestLabelPosition
Definition: DtProjectedGridLinesDrawer.h:225
double myHeading
Definition: DtProjectedGridLinesDrawer.h:210
Contains the DtGridLinesSettingsRecord class declaration.
The DtCoordinateSystem is used to manage the current coordinate system of the scene.
Definition: DtCoordinateSystem.h:41
GridLineVector myNorthSouthLines
Definition: DtProjectedGridLinesDrawer.h:205
DtTextProxy * label
Definition: DtProjectedGridLinesDrawer.h:147
std::vector< GridLine > GridLineVector
Definition: DtProjectedGridLinesDrawer.h:155
Base class to provide boost signal/slot management.
double myStartWindowX
Definition: DtProjectedGridLinesDrawer.h:212
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. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
double start
Definition: DtProjectedGridLinesDrawer.h:151
double myScale
Definition: DtProjectedGridLinesDrawer.h:216
double myStartWindowY
Definition: DtProjectedGridLinesDrawer.h:213
double myEndWindowY
Definition: DtProjectedGridLinesDrawer.h:215
Definition: DtProjectedGridLinesDrawer.h:78
Definition: DtProjectedGridLinesDrawer.h:143
A simple bounding box.
Definition: DtBoundingBox.h:101

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)