File indexing completed on 2024-04-21 03:48:25

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2012 Dennis Nienhüser <nienhueser@kde.org>
0004 //
0005 
0006 #include <QApplication>
0007 
0008 #include <QLayout>
0009 #include <QSlider>
0010 #include <QLabel>
0011 
0012 #include <marble/MarbleWidget.h>
0013 
0014 using namespace Marble;
0015 
0016 int main(int argc, char** argv)
0017 {
0018     QApplication app(argc,argv);
0019     QWidget *window = new QWidget;
0020 
0021     // Create a Marble QWidget without a parent
0022     MarbleWidget *mapWidget = new MarbleWidget();
0023 
0024     // Load the Plain map
0025     mapWidget->setMapThemeId(QStringLiteral("earth/plain/plain.dgml"));
0026 
0027     // Hide the FloatItems: OverviewMap, ScaleBar and Compass
0028     mapWidget->setShowOverviewMap(false);
0029     mapWidget->setShowScaleBar(false);
0030     mapWidget->setShowCompass(false);
0031 
0032     // Set the map quality to gain speed
0033     mapWidget->setMapQualityForViewContext( NormalQuality, Still );
0034     mapWidget->setMapQualityForViewContext( LowQuality, Animation );
0035 
0036     // Create a horizontal zoom slider and set the default zoom
0037     QSlider * zoomSlider = new QSlider(Qt::Horizontal);
0038     zoomSlider->setMinimum( 1000 );
0039     zoomSlider->setMaximum( 2400 );
0040 
0041     mapWidget->zoomView( zoomSlider->value() );
0042 
0043     // Create a label to show the geodetic position
0044     QLabel * positionLabel = new QLabel();
0045     positionLabel->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
0046 
0047     // Add all widgets to the vertical layout.
0048     QVBoxLayout *layout = new QVBoxLayout;
0049     layout->addWidget(mapWidget);
0050     layout->addWidget(zoomSlider);
0051     layout->addWidget(positionLabel);
0052 
0053     // Center the map onto a given position
0054     GeoDataCoordinates home(-60.0, -10.0, 0.0, GeoDataCoordinates::Degree);
0055     mapWidget->centerOn(home);
0056 
0057     // Connect the map widget to the position label.
0058     QObject::connect( mapWidget, SIGNAL(mouseMoveGeoPosition(QString)),
0059                       positionLabel, SLOT(setText(QString)) );
0060 
0061     // Connect the zoom slider to the map widget and vice versa.
0062     QObject::connect( zoomSlider, SIGNAL(valueChanged(int)),
0063                       mapWidget, SLOT(zoomView(int)) );
0064     QObject::connect( mapWidget, SIGNAL(zoomChanged(int)),
0065                       zoomSlider, SLOT(setValue(int)) );
0066 
0067     window->setLayout(layout);
0068     window->resize( 400, 300 );
0069 
0070     window->show();
0071 
0072     return app.exec();
0073 }