2
// This file is part of the Marble Virtual Globe.
4
// This program is free software licensed under the GNU LGPL. You can
5
// find a copy of this license in LICENSE.txt in the top directory of
8
// Copyright 2014 Adam Dabrowski <adamdbrw@gmail.com>
11
#include <QApplication>
12
#include <QtQuick/QQuickView>
15
#include <marble/MarbleQuickItem.h>
16
#include <marble/MarbleMap.h>
18
using namespace Marble;
20
class MarbleDemoItem : public MarbleQuickItem
25
MarbleDemoItem(QQuickItem *parent = 0) : MarbleQuickItem(parent)
26
{ //TODO: setters -> properties
27
map()->setSize(width(), height());
28
map()->setShowFrameRate(false);
29
map()->setProjection(Spherical);
30
map()->setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
31
map()->setShowAtmosphere(false);
32
map()->setShowCompass(false);
33
map()->setShowClouds(false);
34
map()->setShowCrosshairs(false);
35
map()->setShowGrid(false);
36
map()->setShowOverviewMap(false);
37
map()->setShowOtherPlaces(false);
38
map()->setShowScaleBar(false);
39
map()->setShowBackground(false);
42
void componentComplete()
44
QQuickItem *pinch = findChild<QQuickItem*>("pinchArea");
47
pinch->installEventFilter(getEventFilter());
53
void handlePinchStart(QPointF center)
55
makePinch(center, Qt::GestureStarted);
58
void handlePinchUpdate(QPointF center, qreal scale)
60
makePinch(center, Qt::GestureUpdated, scale);
63
void handlePinchEnd(QPointF center, bool canceled)
65
makePinch(center, canceled ? Qt::GestureCanceled : Qt::GestureFinished);
69
void makePinch(QPointF center, Qt::GestureState state, qreal scale = 1)
71
scale = sqrt(sqrt(scale));
72
scale = qBound(0.5, scale, 2.0);
73
pinch(center, scale, state);
77
class MapTestWrap : public QQuickView
82
qmlRegisterType<MarbleDemoItem>("MarbleItem", 1, 0, "MarbleItem");
83
setSource(QUrl("qrc:/main.qml"));
85
if(status()!=QQuickView::Ready)
86
qDebug("can't initialise view");
88
QSurfaceFormat format;
89
format.setAlphaBufferSize(8);
91
setClearBeforeRendering(true);
92
setColor(QColor(Qt::transparent));
93
setTitle("Marble in QML 2.0 demo");
99
int main(int argc, char *argv[])
101
QApplication app(argc, argv);