• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • examples
  • cpp
  • marbleQuick2
examples/cpp/marbleQuick2/main.cpp
Go to the documentation of this file.
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"
QApplication
QPointF
MarbleQuickItem.h
MarbleMap.h
This file contains the headers for MarbleMap.
QDeclarativeView
QObject::installEventFilter
void installEventFilter(QObject *filterObj)
QtConcurrent::map
QFuture< void > map(Sequence &sequence, MapFunction function)
QColor
QUrl
QApplication::exec
int exec()
QDeclarativeItem
main
int main(int argc, char *argv[])
Definition: examples/cpp/marbleQuick2/main.cpp:99
Marble::MarbleQuickItem
Definition: MarbleQuickItem.h:26
Marble::Spherical
Spherical projection.
Definition: MarbleGlobal.h:45
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal