|
| 1 | +/*************************************************************************** |
| 2 | + qgsmapcanvasdockwidget.cpp |
| 3 | + -------------------------- |
| 4 | + begin : February 2017 |
| 5 | + copyright : (C) 2017 by Nyall Dawson |
| 6 | + email : nyall dot dawson at gmail dot com |
| 7 | + *************************************************************************** |
| 8 | + * * |
| 9 | + * This program is free software; you can redistribute it and/or modify * |
| 10 | + * it under the terms of the GNU General Public License as published by * |
| 11 | + * the Free Software Foundation; either version 2 of the License, or * |
| 12 | + * (at your option) any later version. * |
| 13 | + * * |
| 14 | + ***************************************************************************/ |
| 15 | +#include "qgsmapcanvasdockwidget.h" |
| 16 | +#include "qgsmapcanvas.h" |
| 17 | +#include "qgsprojectionselectiondialog.h" |
| 18 | + |
| 19 | +QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *parent ) |
| 20 | + : QgsDockWidget( parent ) |
| 21 | +{ |
| 22 | + setupUi( this ); |
| 23 | + |
| 24 | + mContents->layout()->setContentsMargins( 0, 0, 0, 0 ); |
| 25 | + mContents->layout()->setMargin( 0 ); |
| 26 | + static_cast< QVBoxLayout * >( mContents->layout() )->setSpacing( 0 ); |
| 27 | + |
| 28 | + setWindowTitle( name ); |
| 29 | + mMapCanvas = new QgsMapCanvas( this ); |
| 30 | + |
| 31 | + mMainWidget->setLayout( new QVBoxLayout() ); |
| 32 | + mMainWidget->layout()->setContentsMargins( 0, 0, 0, 0 ); |
| 33 | + mMainWidget->layout()->setMargin( 0 ); |
| 34 | + |
| 35 | + mMainWidget->layout()->addWidget( mMapCanvas ); |
| 36 | + |
| 37 | + connect( mActionSetCrs, &QAction::triggered, this, &QgsMapCanvasDockWidget::setMapCrs ); |
| 38 | +} |
| 39 | + |
| 40 | +QgsMapCanvas *QgsMapCanvasDockWidget::mapCanvas() |
| 41 | +{ |
| 42 | + return mMapCanvas; |
| 43 | +} |
| 44 | + |
| 45 | +void QgsMapCanvasDockWidget::setMapCrs() |
| 46 | +{ |
| 47 | + QgsProjectionSelectionDialog dlg; |
| 48 | + dlg.setCrs( mMapCanvas->mapSettings().destinationCrs() ); |
| 49 | + |
| 50 | + if ( dlg.exec() ) |
| 51 | + { |
| 52 | + mMapCanvas->setDestinationCrs( dlg.crs() ); |
| 53 | + } |
| 54 | +} |
0 commit comments