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

0001 #include <QDebug>
0002 #include <QFileInfo>
0003 #include <QApplication>
0004 #include <QImage>
0005 
0006 #include <marble/MarbleWidget.h>
0007 #include <marble/GeoDataDocument.h>
0008 #include <marble/GeoDataGroundOverlay.h>
0009 #include <marble/GeoDataTreeModel.h>
0010 #include <marble/MarbleModel.h>
0011 
0012 using namespace Marble;
0013 
0014 int main(int argc, char** argv) {
0015 
0016     QApplication app(argc,argv);
0017 
0018     QFileInfo inputFile( app.arguments().last() );
0019     if ( app.arguments().size() < 2 || !inputFile.exists() ) {
0020         qWarning() << "Usage: " << app.arguments().first() << "file.png";
0021         return 1;
0022     }
0023 
0024     // Create a Marble QWidget without a parent
0025     MarbleWidget *mapWidget = new MarbleWidget();
0026 
0027     // Load the Satellite map
0028     mapWidget->setMapThemeId(QStringLiteral("earth/bluemarble/bluemarble.dgml"));
0029 
0030     // Create a bounding box from the given corner points
0031     GeoDataLatLonBox box( 55, 48, 14.5, 6, GeoDataCoordinates::Degree );
0032     box.setRotation( 0, GeoDataCoordinates::Degree );
0033 
0034     // Create an overlay and assign the image to render and its bounding box to it
0035     GeoDataGroundOverlay *overlay = new GeoDataGroundOverlay;
0036     overlay->setLatLonBox( box );
0037     overlay->setIcon( QImage( inputFile.absoluteFilePath() ) );
0038 
0039     // Create a document as a container for the overlay
0040     GeoDataDocument *document = new GeoDataDocument();
0041     document->append( overlay );
0042 
0043     // Add the document to MarbleWidget's tree model
0044     mapWidget->model()->treeModel()->addDocument( document );
0045 
0046     // Ensure we see our the image on start
0047     mapWidget->model()->setHome(box.center(), 1500);
0048     mapWidget->goHome();
0049 
0050     // Finally show the Marble widget
0051     mapWidget->show();
0052 
0053     return app.exec();
0054 }
0055