summaryrefslogtreecommitdiffstats
path: root/src/datavis3d/engine/q3dmaps.cpp
blob: 3ff9bc7cad6c8e60632b99bb2bcc8c748b54c9c8 (plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the QtDataVis3D module.
**
** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
**
****************************************************************************/

#include "q3dmaps.h"
#include "q3dmaps_p.h"
#include "maps3dcontroller_p.h"

#include <QMouseEvent>

#include <QDebug>

QT_DATAVIS3D_BEGIN_NAMESPACE

/*!
 * \class Q3DMaps
 * \inmodule QtDataVis3D
 * \brief The Q3DMaps class provides methods for rendering 3D bars on maps or other planes.
 * \since 1.0.0
 *
 * This class enables developers to render bars or objects on maps or other planes in 3D and to
 * view them by rotating the scene freely. Methods are provided for changing object types, themes
 * and so on.
 *
 * See methods themselves for more complete description.
 *
 * \sa Q3DBars, {Qt Data Visualization 3D C++ Classes}
 */

/*!
 * Constructs Q3DMaps.
 */
Q3DMaps::Q3DMaps()
    : d_ptr(new Q3DMapsPrivate(this, geometry()))
{
    d_ptr->m_shared->initializeOpenGL();
}

/*!
 * Destructs Q3DMaps.
 */
Q3DMaps::~Q3DMaps()
{
}

/*!
 * \internal
 */
void Q3DMaps::render()
{
    d_ptr->m_shared->render();
}

#if defined(Q_OS_ANDROID)
/*!
 * \internal
 */
void Q3DMaps::mouseDoubleClickEvent(QMouseEvent *event)
{
    d_ptr->m_shared->mouseDoubleClickEvent(event);
}

/*!
 * \internal
 */
void Q3DMaps::touchEvent(QTouchEvent *event)
{
    d_ptr->m_shared->touchEvent(event);
}
#endif

/*!
 * \internal
 */
void Q3DMaps::mousePressEvent(QMouseEvent *event)
{
    d_ptr->m_shared->mousePressEvent(event, event->pos());
}

/*!
 * \internal
 */
void Q3DMaps::mouseReleaseEvent(QMouseEvent *event)
{
    d_ptr->m_shared->mouseReleaseEvent(event, event->pos());
}

/*!
 * \internal
 */
void Q3DMaps::mouseMoveEvent(QMouseEvent *event)
{
    d_ptr->m_shared->mouseMoveEvent(event, event->pos());
}

/*!
 * \internal
 */
void Q3DMaps::wheelEvent(QWheelEvent *event)
{
    d_ptr->m_shared->wheelEvent(event);
}

/*!
 * \internal
 */
void Q3DMaps::resizeEvent(QResizeEvent *event)
{
    Q_UNUSED(event);
    d_ptr->m_shared->setWidth(width());
    d_ptr->m_shared->setHeight(height());
    d_ptr->m_shared->resizeNotify();
}

// TODO: Document
// Size
void Q3DMaps::setWidth(const int width)
{
    d_ptr->m_shared->setWidth(width);
    QWindow::setWidth(width);
}

void Q3DMaps::setHeight(const int height)
{
    d_ptr->m_shared->setHeight(height);
    QWindow::setHeight(height);
}

void Q3DMaps::setBarSpecs(const QVector3D &thickness, AdjustmentDirection direction)
{
    d_ptr->m_shared->setBarSpecs(thickness, direction);
}

void Q3DMaps::setBarType(QDataVis::MeshStyle style, bool smooth)
{
    d_ptr->m_shared->setBarType(style, smooth);
}

void Q3DMaps::setMeshFileName(const QString &objFileName)
{
    d_ptr->m_shared->setMeshFileName(objFileName);
}

void Q3DMaps::setCameraPreset(QDataVis::CameraPreset preset)
{
    d_ptr->m_shared->setCameraPreset(preset);
}

void Q3DMaps::setCameraPosition(GLfloat horizontal, GLfloat vertical, GLint distance)
{
    d_ptr->m_shared->setCameraPosition(horizontal, vertical, distance);
}

void Q3DMaps::setTheme(QDataVis::ColorTheme theme)
{
    d_ptr->m_shared->setTheme(theme);
}

void Q3DMaps::setBarColor(const QColor &baseColor, const QColor &heightColor, bool uniform)
{
    d_ptr->m_shared->setBarColor(baseColor, heightColor, uniform);
}

void Q3DMaps::setAreaSpecs(const QRect &areaRect, const QImage &image)
{
    d_ptr->m_shared->setAreaSpecs(areaRect, image);
}

void Q3DMaps::setImage(const QImage &image)
{
    d_ptr->m_shared->setImage(image);
}

void Q3DMaps::setSelectionMode(QDataVis::SelectionMode mode)
{
    d_ptr->m_shared->setSelectionMode(mode);
}

QDataVis::SelectionMode Q3DMaps::selectionMode() const
{
    return d_ptr->m_shared->selectionMode();
}

void Q3DMaps::setFont(const QFont &font)
{
    d_ptr->m_shared->setFont(font);
}

QFont Q3DMaps::font() const
{
    return d_ptr->m_shared->font();
}

void Q3DMaps::setLabelTransparency(QDataVis::LabelTransparency transparency)
{
    d_ptr->m_shared->setLabelTransparency(transparency);
}

QDataVis::LabelTransparency Q3DMaps::labelTransparency() const
{
    return d_ptr->m_shared->labelTransparency();
}

QDataVis::ShadowQuality Q3DMaps::setShadowQuality(QDataVis::ShadowQuality quality)
{
    return d_ptr->m_shared->setShadowQuality(quality);
}

QDataVis::ShadowQuality Q3DMaps::shadowQuality() const
{
    return d_ptr->m_shared->shadowQuality();
}

void Q3DMaps::setDataProxy(QMapDataProxy *proxy)
{
    d_ptr->m_shared->setDataProxy(proxy);
}

QMapDataProxy *Q3DMaps::dataProxy()
{
    return d_ptr->m_shared->dataProxy();
}

Q3DMapsPrivate::Q3DMapsPrivate(Q3DMaps *q, const QRect &rect)
    : q_ptr(q),
      m_shared(new Maps3DController(rect))
{
}

Q3DMapsPrivate::~Q3DMapsPrivate()
{
    qDebug() << "Destroying Q3DMapsPrivate";
    delete m_shared;
}

QT_DATAVIS3D_END_NAMESPACE