VR-Forces 4.0.4 Class Documentation
include/vrvOsg/DtProjectedGridLinesDrawer.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright (c) 2011 MAK Technologies, Inc.
00003  * All rights reserved.
00004  *****************************************************************************/
00005 /*****************************************************************************
00006  * $RCSfile: DtProjectedGridLinesDrawer.h,v $ $Revision: 1.17 $ $State: Exp $
00007  *****************************************************************************/
00008 
00012 
00013 #pragma once
00014 
00015 #include <vrvOsg/vrvOsg.h>
00016 
00017 #include <vrvOsg/DtGridLinesDrawer.h>
00018 
00019 #include <vrvGraphics/DtFont.h>
00020 
00021 #include <makArchives/DtGridLinesSettingsRecord.h>
00022 
00023 #include <osg/Vec2>
00024 #include <osg/Vec2d>
00025 
00026 #include <boost/unordered_set.hpp>
00027 
00028 namespace makVrv
00029 {
00030 
00031    class DtDe;
00032    class DtOsgChannel;
00033    class DtOverlayRenderer;
00034    class DtLineSegment;
00035    class DtTextProxy;
00036    class DtBoundingBox;
00037 
00041    class DT_DLL_VRVOSG DtProjectedGridLinesDrawer : public DtGridLinesDrawer
00042    {
00043    public:
00044 
00046       DtProjectedGridLinesDrawer( DtDe& de );
00047 
00049       virtual ~DtProjectedGridLinesDrawer();
00050 
00052       virtual void drawGridLines();
00053 
00055       virtual void setMaxGridLines( int maxGridLines );
00056 
00059       virtual void setWindowDimensions( double startWindowX, double startWindowY,
00060          double endWindowX, double endWindowY );
00061 
00063       virtual void setCenter( const osg::Vec2d& center );
00064 
00066       virtual void setHeading( double heading );
00067 
00069       virtual void setScale( double scale );
00070 
00072       virtual void destroyGridLines();
00073 
00074    protected:
00075 
00077       enum LabelPosition { Bottom, Left, Top, Right, Indeterminate };
00078 
00079       // \brief Draw the north/south grid lines and labels based on current geometry
00080       virtual void drawNorthSouthGridLinesAndLabels();
00081 
00082       // \brief Draw the east/west grid lines and labels based on current geometry
00083       virtual void drawEastWestGridLinesAndLabels();
00084 
00087       virtual void findSpacing();
00088 
00092       virtual void anchorAndOffsetLines();
00093 
00098       virtual DtUnicode createLabel( double& xMeters, double yMeters, bool isNorthSouth );
00099 
00100       virtual bool labelGridBox( double nsValue, double ewValue, int labelIndex );
00101 
00104       void convertDegreeSpacingToMeters( double gridSpacing, double& xSpacing, double& ySpacing ) const;
00105 
00107       virtual DtFont::TextAlignement offsetLabel( double xSrc, double ySrc,
00108          double& xOffset, double& yOffset, DtBoundingBox& bbox ) const;
00109 
00111       virtual DtFont::TextAlignement offsetGridBoxLabel( double xSrc, double ySrc,
00112          double& xOffset, double& yOffset, DtBoundingBox& bbox ) const;
00113 
00115       virtual LabelPosition calcLabelPosition( double x, double y ) const;
00116 
00118       virtual void calcDesiredLabelPosition();
00119 
00122       double degreesLatitudeToMeters( double x, double y ) const;
00123 
00124       double convertToMetersOrDegrees( double value ) const;
00125 
00128       virtual double degreesLongitudeToMeters() const;
00129 
00132       virtual double fixedSpacingAmount() const;
00133 
00136       virtual double xOffset() const;
00137 
00140       virtual double yOffset() const;
00141 
00142       struct GridLine
00143       {
00144       public:
00145          DtLineSegment* line;
00146          DtTextProxy* label;
00147          double value;
00148          // If an east west label, the start and end x values; else
00149          // start and end y values;
00150          double start;
00151          double end;
00152       };
00153 
00154       typedef std::vector<GridLine> GridLineVector;
00155 
00156       // Array grid box labels
00157       typedef std::vector<DtTextProxy*> GridBoxLabelArray;
00158 
00159       virtual void clearUnusedLinesAndLabels( int index, GridLineVector& lines );
00160 
00161       virtual void clearUnusedGridBoxLabels( int index );
00162 
00163       virtual bool drawGridLineAndLabel( double startX, double startY,
00164          double endX, double endY, GridLine& gridLine, float* lineColor,
00165          LabelPosition labelPosition, float* labelColor, bool isNorthSouth );
00166 
00167    protected:
00168 
00172       virtual void labelGridBoxes();
00173 
00175       typedef std::vector<float> VertexList;
00176 
00178       static void rotate(const DtProjectedGridLinesDrawer::VertexList& in,
00179          double rad, DtProjectedGridLinesDrawer::VertexList& out );
00180 
00182       static void translate( const DtProjectedGridLinesDrawer::VertexList& in,
00183          const osg::Vec2& translation, DtProjectedGridLinesDrawer::VertexList& out );
00184 
00186       static void scale( const DtProjectedGridLinesDrawer::VertexList& in,
00187          double s, DtProjectedGridLinesDrawer::VertexList& out );
00188 
00189    private:
00190 
00192       DtProjectedGridLinesDrawer( const DtProjectedGridLinesDrawer& orig );
00193 
00195       DtProjectedGridLinesDrawer& operator=( const DtProjectedGridLinesDrawer& rhs );
00196 
00197    protected:
00198       typedef boost::unordered_set<DtUnicode> UsedGridLabels;
00199 
00200       GridLineVector myEastWestLines;
00201       GridLineVector myNorthSouthLines;
00202       GridBoxLabelArray myGridBoxLabels;
00203 
00204       UsedGridLabels myUsedGridLabels;
00205 
00206       double myHeading;
00207       osg::Vec2d myCenter;
00208       double myStartWindowX;
00209       double myStartWindowY;
00210       double myEndWindowX;
00211       double myEndWindowY;
00212       double myScale;
00213 
00214       double myAnchoredMinX;
00215       double myAnchoredMinY;
00216       double myAnchoredMaxX;
00217       double myAnchoredMaxY;
00218       double myXSpacing;
00219       double myYSpacing;
00220       LabelPosition myNorthSouthLabelPosition;
00221       LabelPosition myEastWestLabelPosition;
00222 
00223    };
00224 
00225 }

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)