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
|
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2012 Dennis Nienhüser <nienhueser@kde.org>
//
#include <QApplication>
#include <QLayout>
#include <QSlider>
#include <QLabel>
#include <marble/MarbleWidget.h>
using namespace Marble;
int main(int argc, char** argv)
{
QApplication app(argc,argv);
QWidget *window = new QWidget;
// Create a Marble QWidget without a parent
MarbleWidget *mapWidget = new MarbleWidget();
// Load the Plain map
mapWidget->setMapThemeId("earth/plain/plain.dgml");
// Hide the FloatItems: OverviewMap, ScaleBar and Compass
mapWidget->setShowOverviewMap(false);
mapWidget->setShowScaleBar(false);
mapWidget->setShowCompass(false);
// Set the map quality to gain speed
mapWidget->setMapQualityForViewContext( NormalQuality, Still );
mapWidget->setMapQualityForViewContext( LowQuality, Animation );
// Create a horizontal zoom slider and set the default zoom
QSlider * zoomSlider = new QSlider(Qt::Horizontal);
zoomSlider->setMinimum( 1000 );
zoomSlider->setMaximum( 2400 );
mapWidget->zoomView( zoomSlider->value() );
// Create a label to show the geodetic position
QLabel * positionLabel = new QLabel();
positionLabel->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
// Add all widgets to the vertical layout.
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(mapWidget);
layout->addWidget(zoomSlider);
layout->addWidget(positionLabel);
// Center the map onto a given position
GeoDataCoordinates home(-60.0, -10.0, 0.0, GeoDataCoordinates::Degree);
mapWidget->centerOn(home);
// Connect the map widget to the position label.
QObject::connect( mapWidget, SIGNAL(mouseMoveGeoPosition(QString)),
positionLabel, SLOT(setText(QString)) );
// Connect the zoom slider to the map widget and vice versa.
QObject::connect( zoomSlider, SIGNAL(valueChanged(int)),
mapWidget, SLOT(zoomView(int)) );
QObject::connect( mapWidget, SIGNAL(zoomChanged(int)),
zoomSlider, SLOT(setValue(int)) );
window->setLayout(layout);
window->resize( 400, 300 );
window->show();
return app.exec();
}
|