Qt Virtual Chart Table (QVCT)
CChart.hpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Qt Virtual Chart Table (QVCT)
5  * Copyright (C) 2012 Cedric Dufour <http://cedric.dufour.name>
6  * Author: Cedric Dufour <http://cedric.dufour.name>
7  *
8  * The Qt Virtual Chart Table (QVCT) is free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Qt Virtual Chart Table (QVCT) is distributed in the hope
13  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU General Public License for more details.
17  */
18 
19 #ifndef QVCT_CCHART_HPP
20 #define QVCT_CCHART_HPP
21 
22 // QT
23 #include <QDomElement> // QtXml module
24 #include <QPrinter>
25 #include <QRectF>
26 #include <QWidget>
27 #include <QXmlStreamWriter>
28 
29 // QVCT
30 #include "QVCT.hpp"
31 class CChartGDAL;
32 class CChartGDALRaster;
34 class CDataPosition;
35 
36 
38 
43 class CChart: public QWidget
44 {
45  Q_OBJECT
46 
47  //------------------------------------------------------------------------------
48  // FIELDS
49  //------------------------------------------------------------------------------
50 
51 private:
55 
58 
61 
64 
67 
68  double fdZoom;
70 
71  bool bZoomLock;
73 
75 
76 
77  //------------------------------------------------------------------------------
78  // CONSTRUCTORS / DESTRUCTOR
79  //------------------------------------------------------------------------------
80 
81 public:
82  CChart( const QString& _rqsFileName, QWidget* _pqParent = 0 );
83  virtual ~CChart();
84 
85 public:
87  void addElevation( const QString& _rqsFileName );
88 
89 
90  //------------------------------------------------------------------------------
91  // METHODS: QWidget (override)
92  //------------------------------------------------------------------------------
93 
94 protected:
95  virtual void paintEvent( QPaintEvent* _pqPaintEvent );
96 
97 
98  //------------------------------------------------------------------------------
99  // METHODS
100  //------------------------------------------------------------------------------
101 
102  // SETTERS
103 public:
105  void setDrawArea( QRectF _qRectFDrawArea ) { qRectFDrawArea = _qRectFDrawArea; };
107  void resetDrawArea();
109  void setGeoPosition( const CDataPosition& _roGeoPosition );
111  void lockPosition( bool _bLock ) { bPositionLock = _bLock; };
113  void setZoom( double _fdZoom ) { fdZoom = _fdZoom; };
115  void lockZoom( bool _bLock ) { bZoomLock = _bLock; };
117  void showElevation( bool _bShow );
118 
119  // GETTERS
120 public:
122 
123  QVCT::EStatus getStatus() const;
125  QString getFileName() const;
127  QRectF getDrawArea() const { return qRectFDrawArea; };
133  QPointF getDrawPositionCenter() const;
135  QPointF getDatPosition() const { return qPointFDatPosition; };
137  bool isPositionLocked() const { return bPositionLock; };
139  double getZoom() const { return fdZoom; };
141  double getZoomActual() const { return 1.0; };
143  double getZoomFit() const;
145  double getZoomArea( const CDataPosition& _roGeoPosition1, const CDataPosition& _roGeoPosition2 ) const;
147  bool isZoomLocked() const { return bZoomLock; };
149  bool hasElevation() const { return poChartGDALElevation; };
151  bool isElevationShowed() const { return bShowElevation; };
153  double getResolution() const;
154 
155  // OTHER
156 public:
158  CDataPosition toGeoPosition( const QPointF& _rqPointFDrawPosition ) const;
160  QPointF toDrawPosition( const CDataPosition& _roGeoPosition ) const;
162  void move( const QPointF& _rqPointFDrawPositionOffset );
163 
164 protected:
166  void draw();
167 
168 public:
170  void print( QPrinter* _pqPrinter );
171 
172 public:
174  void parseQVCT( const QDomElement& _rqDomElement );
176  void dumpQVCT( QXmlStreamWriter & _rqXmlStreamWriter ) const;
177 
178 };
179 
180 #endif // QVCT_CCHART_HPP
GDAL-based (elevation) chart.
GDAL-based (raster) chart.
Generic GDAL-based dataset.
Definition: CChartGDAL.hpp:53
[UI] Chart (view)
Definition: CChart.hpp:44
bool hasElevation() const
Returns whether this chart has been associated elevation model data.
Definition: CChart.hpp:149
QString getFileName() const
Returns the underlying chart (GDAL dataset) file name.
Definition: CChart.cpp:133
void dumpQVCT(QXmlStreamWriter &_rqXmlStreamWriter) const
Stores this object's content to the given QVCT destination (file)
Definition: CChart.cpp:309
void parseQVCT(const QDomElement &_rqDomElement)
Retrieves this object's content from the given QVCT source (file)
Definition: CChart.cpp:283
void lockZoom(bool _bLock)
Sets the zoom lock status.
Definition: CChart.hpp:115
bool isPositionLocked() const
Returns the position lock status.
Definition: CChart.hpp:137
bool isZoomLocked() const
Returns the zoom lock status.
Definition: CChart.hpp:147
double getZoomFit() const
Returns the zoom factor allowing to view the entire chart.
Definition: CChart.cpp:153
double getZoom() const
Returns the current zoom factor.
Definition: CChart.hpp:139
double getZoomActual() const
Returns the zoom factor corresponding to a 1:1 dataset/screen pixels ratio.
Definition: CChart.hpp:141
void print(QPrinter *_pqPrinter)
Prints the chart.
Definition: CChart.cpp:253
void draw()
Draws the chart (on screen)
Definition: CChart.cpp:203
CChartGDALElevation * poChartGDALElevation
GDAL data elevation model (dataset)
Definition: CChart.hpp:56
double fdZoom
Current zoom factor.
Definition: CChart.hpp:68
virtual ~CChart()
Definition: CChart.cpp:63
double getResolution() const
Returns the resolution of the chart at its current position, in meters per pixel [m/px].
Definition: CChart.cpp:176
void move(const QPointF &_rqPointFDrawPositionOffset)
Move the current (center) chart position by specified offset (in the draw area)
Definition: CChart.cpp:198
QPointF qPointFDatPosition
Current (center) position in the GDAL dataset.
Definition: CChart.hpp:62
bool isElevationShowed() const
Returns the elevation model show status.
Definition: CChart.hpp:151
bool bZoomLock
Zoom lock status.
Definition: CChart.hpp:71
QRectF getDrawArea() const
Returns the viewport draw area.
Definition: CChart.hpp:127
void setZoom(double _fdZoom)
Sets the current zoom factor.
Definition: CChart.hpp:113
QPointF getDatPosition() const
Returns the current (center) position (dataset coordinates) of the chart.
Definition: CChart.hpp:135
void setGeoPosition(const CDataPosition &_roGeoPosition)
Sets the current (center) position (geographical coordinates) of the chart.
Definition: CChart.cpp:105
virtual void paintEvent(QPaintEvent *_pqPaintEvent)
Definition: CChart.cpp:84
QVCT::EStatus getStatus() const
Returns the internal status of the object.
Definition: CChart.cpp:128
CDataPosition getGeoPosition() const
Returns the current (center) position (geographical coordinates) of the chart.
Definition: CChart.cpp:143
void lockPosition(bool _bLock)
Sets the position lock status.
Definition: CChart.hpp:111
CChart(const QString &_rqsFileName, QWidget *_pqParent=0)
Definition: CChart.cpp:44
void setDrawArea(QRectF _qRectFDrawArea)
Sets the viewport draw area.
Definition: CChart.hpp:105
bool bPositionLock
Position lock status.
Definition: CChart.hpp:65
void resetDrawArea()
Resets the viewport draw area (to the widget's area)
Definition: CChart.cpp:100
QPointF toDrawPosition(const CDataPosition &_roGeoPosition) const
Converts the given (geographical) position [long,lat,elev] to chart draw point [px].
Definition: CChart.cpp:192
CDataPosition toGeoPosition(const QPointF &_rqPointFDrawPosition) const
Converts the given chart draw position to geographical position.
Definition: CChart.cpp:185
CChartGDALRaster * poChartGDALRaster
GDAL chart (dataset)
Definition: CChart.hpp:53
void showElevation(bool _bShow)
Sets the elevation model show status.
Definition: CChart.cpp:110
QRectF qRectFDrawArea
Viewport draw area.
Definition: CChart.hpp:59
bool bShowElevation
Elevation model show status.
Definition: CChart.hpp:74
double getZoomArea(const CDataPosition &_roGeoPosition1, const CDataPosition &_roGeoPosition2) const
Returns the zoom factor allowing to view the given geographical area (defined by its opposite corners...
Definition: CChart.cpp:161
QPointF getDrawPositionCenter() const
Returns the viewport draw area's center position.
Definition: CChart.cpp:148
void addElevation(const QString &_rqsFileName)
Add elevation model data to chart.
Definition: CChart.cpp:69
CDataPosition getGeoPositionCenter() const
Returns the center position (geographical coordinates) of the chart.
Definition: CChart.cpp:138
(Geographical) Position data [long,lat,elev]
EStatus
Definition: QVCT.hpp:41