-
Notifications
You must be signed in to change notification settings - Fork 0
/
qctimage.h
106 lines (95 loc) · 2.63 KB
/
qctimage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* > qctimage.h
* 1.00 arb
*/
#ifndef QCTIMAGE_H
#define QCTIMAGE_H
#include <qdatetime.h> // for QTime
#include <qscrollview.h> // base class
#include <qpixmap.h>
#include <qimage.h>
#include <qpointarray.h>
class QPainter;
class QCT;
class ArrowPlot
{
public:
ArrowPlot(int x, int y, float bearing, float length);
~ArrowPlot();
void plot(QPainter *);
QRect rect() const;
private:
// constant data could be made static to the class
int stemwidth;
bool filled;
// the array of transformed points and a quick-access bounding box
QPointArray points;
QRect boundingBox;
};
class TidePlot
{
public:
TidePlot(int x, int y, float min, float max, float currently);
~TidePlot();
void plot(QPainter *);
QRect rect() const;
private:
// constant data could be made static to the class
int dimension;
// the array of transformed points and a quick-access bounding box
QPointArray points;
QRect boundingBox;
};
class QCTImage : public QScrollView
{
Q_OBJECT
public:
QCTImage(QWidget *parent);
~QCTImage();
public:
// Load and unload a QCT
void unload();
bool load(QString filename, int scalefactor = 1);
// Save QCT as a PNG
bool save(QString filename, const char *fmt);
// The actual QCT object so it can be queried for name etc.
QCT *getQct() { return qct; }
// Plotting (only to be called when printing)
void render(QPainter *painter, int cx, int cy, int cw, int ch);
// Plotting arrows onto the image
void unplotArrows();
void plotArrow(float lat, float lon, float bearing, float length);
// Plotting arrows onto the image
void unplotTides();
void plotTide(float lat, float lon, float min, float max, float currently);
// Scrolling
bool scrollToLatLon(double lat, double lon);
bool latLonOfCenter(double *lat, double *lon);
signals:
void location(double lat, double lon, long val);
void mouseWheel(Qt::Orientation orient, int delta);
void contextMenu(double lat, double lon);
protected:
void drawContents(QPainter *painter, int cx, int cy, int cw, int ch);
void contentsContextMenuEvent(QContextMenuEvent *event);
void contentsMouseMoveEvent(QMouseEvent *event);
void contentsMousePressEvent(QMouseEvent *event);
void contentsMouseReleaseEvent(QMouseEvent *event);
void contentsWheelEvent(QWheelEvent *event);
void showEvent(QShowEvent*);
private slots:
void keepFloating();
private:
// To support panning:
bool dragging, floating;
QPoint dragStartMousePos, dragStartContentsPos, dragDelta;
QTime lastMoveTime;
// The image itself
QImage image;
QCT *qct;
// Initialisation only
int startx, starty;
// List of arrows to be overlaid
QPtrList<ArrowPlot> arrowList;
QPtrList<TidePlot> tideList;
};
#endif //!GDALIMAGE_H