~ubuntu-branches/ubuntu/wily/marble/wily-proposed

« back to all changes in this revision

Viewing changes to examples/cpp/marbleQuick2/main.cpp

  • Committer: Package Import Robot
  • Author(s): Scarlett Clark, Jonathan Riddell, Scarlett Clark
  • Date: 2014-07-24 23:38:32 UTC
  • mfrom: (1.5.2)
  • Revision ID: package-import@ubuntu.com-20140724233832-7v4421t4khrhw487
Tags: 4:4.13.90-0ubuntu1
[ Jonathan Riddell ]
* Switch to libmarblewidget19 for new soversion

[ Scarlett Clark ]
* New upstream beta release
* Update: do_not_install_private_headers. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// This file is part of the Marble Virtual Globe.
 
3
//
 
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
 
6
// the source code.
 
7
//
 
8
// Copyright 2014      Adam Dabrowski <adamdbrw@gmail.com>
 
9
//
 
10
 
 
11
#include <QApplication>
 
12
#include <QtQuick/QQuickView>
 
13
#include <QFileInfo>
 
14
 
 
15
#include <marble/MarbleQuickItem.h>
 
16
#include <marble/MarbleMap.h>
 
17
 
 
18
using namespace Marble;
 
19
 
 
20
class MarbleDemoItem : public MarbleQuickItem
 
21
{
 
22
Q_OBJECT
 
23
 
 
24
public:
 
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);
 
40
    }
 
41
 
 
42
    void componentComplete()
 
43
    {
 
44
        QQuickItem *pinch = findChild<QQuickItem*>("pinchArea");
 
45
        if (pinch)
 
46
        {
 
47
            pinch->installEventFilter(getEventFilter());
 
48
        }
 
49
    }
 
50
 
 
51
public slots:
 
52
 
 
53
    void handlePinchStart(QPointF center)
 
54
    {
 
55
        makePinch(center, Qt::GestureStarted);
 
56
    }
 
57
 
 
58
    void handlePinchUpdate(QPointF center, qreal scale)
 
59
    {
 
60
        makePinch(center, Qt::GestureUpdated, scale);
 
61
    }
 
62
 
 
63
    void handlePinchEnd(QPointF center, bool canceled)
 
64
    {
 
65
        makePinch(center, canceled ? Qt::GestureCanceled : Qt::GestureFinished);
 
66
    }
 
67
 
 
68
private:
 
69
    void makePinch(QPointF center, Qt::GestureState state, qreal scale = 1)
 
70
    {
 
71
        scale = sqrt(sqrt(scale));
 
72
        scale = qBound(0.5, scale, 2.0);
 
73
        pinch(center, scale, state);
 
74
    }
 
75
};
 
76
 
 
77
class MapTestWrap : public QQuickView
 
78
{
 
79
public:
 
80
    void start()
 
81
    {
 
82
        qmlRegisterType<MarbleDemoItem>("MarbleItem", 1, 0, "MarbleItem");
 
83
        setSource(QUrl("qrc:/main.qml"));
 
84
 
 
85
        if(status()!=QQuickView::Ready)
 
86
            qDebug("can't initialise view");
 
87
 
 
88
        QSurfaceFormat format;
 
89
        format.setAlphaBufferSize(8);
 
90
        setFormat(format);
 
91
        setClearBeforeRendering(true);
 
92
        setColor(QColor(Qt::transparent));
 
93
        setTitle("Marble in QML 2.0 demo");
 
94
 
 
95
        show();
 
96
    }
 
97
};
 
98
 
 
99
int main(int argc, char *argv[])
 
100
{
 
101
    QApplication app(argc, argv);
 
102
 
 
103
    MapTestWrap test;
 
104
    test.start();
 
105
 
 
106
    return app.exec();
 
107
}
 
108
 
 
109
#include "main.moc"