• 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
  • map-controls
examples/cpp/map-controls/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 2012 Dennis Nienhüser <earthwings@gentoo.org>
9 //
10 
11 #include <QApplication>
12 
13 #include <QLayout>
14 #include <QSlider>
15 #include <QLabel>
16 
17 #include <marble/MarbleWidget.h>
18 
19 using namespace Marble;
20 
21 int main(int argc, char** argv)
22 {
23  QApplication app(argc,argv);
24  QWidget *window = new QWidget;
25 
26  // Create a Marble QWidget without a parent
27  MarbleWidget *mapWidget = new MarbleWidget();
28 
29  // Load the Plain map
30  mapWidget->setMapThemeId("earth/plain/plain.dgml");
31 
32  // Hide the FloatItems: OverviewMap, ScaleBar and Compass
33  mapWidget->setShowOverviewMap(false);
34  mapWidget->setShowScaleBar(false);
35  mapWidget->setShowCompass(false);
36 
37  // Set the map quality to gain speed
38  mapWidget->setMapQualityForViewContext( NormalQuality, Still );
39  mapWidget->setMapQualityForViewContext( LowQuality, Animation );
40 
41  // Create a horizontal zoom slider and set the default zoom
42  QSlider * zoomSlider = new QSlider(Qt::Horizontal);
43  zoomSlider->setMinimum( 1000 );
44  zoomSlider->setMaximum( 2400 );
45 
46  mapWidget->zoomView( zoomSlider->value() );
47 
48  // Create a label to show the geodetic position
49  QLabel * positionLabel = new QLabel();
50  positionLabel->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
51 
52  // Add all widgets to the vertical layout.
53  QVBoxLayout *layout = new QVBoxLayout;
54  layout->addWidget(mapWidget);
55  layout->addWidget(zoomSlider);
56  layout->addWidget(positionLabel);
57 
58  // Center the map onto a given position
59  GeoDataCoordinates home(-60.0, -10.0, 0.0, GeoDataCoordinates::Degree);
60  mapWidget->centerOn(home);
61 
62  // Connect the map widget to the position label.
63  QObject::connect( mapWidget, SIGNAL(mouseMoveGeoPosition(QString)),
64  positionLabel, SLOT(setText(QString)) );
65 
66  // Connect the zoom slider to the map widget and vice versa.
67  QObject::connect( zoomSlider, SIGNAL(valueChanged(int)),
68  mapWidget, SLOT(zoomView(int)) );
69  QObject::connect( mapWidget, SIGNAL(zoomChanged(int)),
70  zoomSlider, SLOT(setValue(int)) );
71 
72  window->setLayout(layout);
73  window->resize( 400, 300 );
74 
75  window->show();
76 
77  return app.exec();
78 }
Marble::GeoDataCoordinates
A 3d point representation.
Definition: GeoDataCoordinates.h:52
QWidget
main
int main(int argc, char **argv)
Definition: examples/cpp/map-controls/main.cpp:21
QApplication
QSlider
Marble::GeoDataCoordinates::Degree
Definition: GeoDataCoordinates.h:66
Marble::MarbleWidget
A widget class that displays a view of the earth.
Definition: MarbleWidget.h:104
Marble::LowQuality
Low resolution (e.g. interlaced)
Definition: MarbleGlobal.h:84
Marble::MarbleWidget::setMapThemeId
void setMapThemeId(const QString &maptheme)
Set a new map theme.
Definition: MarbleWidget.cpp:759
QWidget::resize
void resize(int w, int h)
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
Marble::Animation
animated view (e.g. while rotating the globe)
Definition: MarbleGlobal.h:76
QWidget::setLayout
void setLayout(QLayout *layout)
Marble::MarbleWidget::setShowOverviewMap
void setShowOverviewMap(bool visible)
Set whether the overview map overlay is visible.
Definition: MarbleWidget.cpp:795
Marble::Still
still image
Definition: MarbleGlobal.h:75
Marble::NormalQuality
Normal quality.
Definition: MarbleGlobal.h:85
QVBoxLayout
Marble::MarbleWidget::zoomView
void zoomView(int zoom, FlyToMode mode=Instant)
Definition: MarbleWidget.cpp:521
QString
QAbstractSlider::setMinimum
void setMinimum(int)
QWidget::setSizePolicy
void setSizePolicy(QSizePolicy)
Marble::MarbleWidget::centerOn
void centerOn(const qreal lon, const qreal lat, bool animated=false)
Center the view on a geographical point.
Definition: MarbleWidget.cpp:549
QAbstractSlider::value
value
Marble::MarbleWidget::setShowCompass
void setShowCompass(bool visible)
Set whether the compass overlay is visible.
Definition: MarbleWidget.cpp:809
Marble::MarbleWidget::setMapQualityForViewContext
void setMapQualityForViewContext(MapQuality quality, ViewContext viewContext)
Set the map quality for the specified view context.
Definition: MarbleWidget.cpp:1009
QApplication::exec
int exec()
MarbleWidget.h
This file contains the headers for MarbleWidget.
QWidget::show
void show()
QAbstractSlider::setMaximum
void setMaximum(int)
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QLabel
Marble::MarbleWidget::setShowScaleBar
void setShowScaleBar(bool visible)
Set whether the scale bar overlay is visible.
Definition: MarbleWidget.cpp:802
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