forked from yvt/terravox
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathterrainview.h
More file actions
104 lines (84 loc) · 2.4 KB
/
terrainview.h
File metadata and controls
104 lines (84 loc) · 2.4 KB
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
#ifndef TERRAINVIEW_H
#define TERRAINVIEW_H
#include <QWidget>
#include <QPointer>
#include <memory>
#include <QVector>
#include <QSharedPointer>
#include <QScopedPointer>
class Terrain;
class TerrainViewOptionsWindow;
class TerrainViewDrawingContext
{
protected:
TerrainViewDrawingContext() { }
virtual ~TerrainViewDrawingContext() { }
public:
virtual void projectBitmap(QImage&, const QPointF &origin, const QSizeF &size, bool additive) = 0;
};
struct TerrainViewOptions
{
bool showEdges;
bool colorizeAltitude;
bool ambientOcclusion;
float ambientOcclusionStrength;
bool axises;
TerrainViewOptions() :
showEdges(true),
colorizeAltitude(false),
ambientOcclusion(true),
ambientOcclusionStrength(0.5f),
axises(true)
{ }
};
class TerrainView : public QWidget
{
Q_OBJECT
struct Coordinate
{
short x, y;
Coordinate() = default;
Coordinate(short x, short y) :
x(x), y(y) { }
};
public:
explicit TerrainView(QWidget *parent = 0);
~TerrainView();
QPoint rayCast(const QPoint&);
void setTerrain(QSharedPointer<Terrain>);
QSharedPointer<Terrain> terrain();
void setViewOptions(const TerrainViewOptions&);
const TerrainViewOptions &viewOptions();
void addCursorOverride(QCursor *);
void removeCursorOverride(QCursor *);
protected:
void paintEvent(QPaintEvent *) override;
void mousePressEvent(QMouseEvent *) override;
void mouseReleaseEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *) override;
void wheelEvent(QWheelEvent *) override;
void enterEvent(QEvent *) override;
void leaveEvent(QEvent *) override;
signals:
void clientMousePressed(QMouseEvent *);
void clientMouseReleased(QMouseEvent *);
void clientMouseMoved(QMouseEvent *);
void clientPaint(QPaintEvent *);
void clientEnter(QEvent *);
void clientLeave(QEvent *);
void terrainPaint(TerrainViewDrawingContext *);
void viewOptionsChanged(TerrainViewOptions);
public slots:
void showOptionsWindow();
void terrainUpdate(const QRect &);
private:
struct SceneDefinition;
class TerrainViewPrivate;
TerrainViewPrivate *d_ptr;
QScopedPointer<TerrainViewOptionsWindow> optionsWindow;
QCursor *cursorOverride = nullptr;
Q_DECLARE_PRIVATE(TerrainView)
private slots:
void optionsWindowClosed();
};
#endif // TERRAINVIEW_H