Skip to content
Permalink
Browse files

More changes to use QgsMapSettings instead of QgsMapRenderer

  • Loading branch information
wonder-sk committed Nov 11, 2013
1 parent 1b7fcc2 commit 2d12aca3570e18bbe4f381e2b6d8872db0ecc473
@@ -891,11 +891,7 @@ void QgsComposerLegendWidget::updateLegend()
QgsMapCanvas* canvas = app->mapCanvas();
if ( canvas )
{
QgsMapRenderer* renderer = canvas->mapRenderer();
if ( renderer )
{
layerIdList = renderer->layerSet();
}
layerIdList = canvas->mapSettings().layers();
}

//and also group info
@@ -116,7 +116,7 @@ void QgsSelectedFeature::setSelectedFeature( QgsFeatureId featureId, QgsVectorLa
connect( mVlayer, SIGNAL( beforeRollBack() ), this, SLOT( beforeRollBack() ) );

// projection or extents changed
connect( canvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( updateVertexMarkersPosition() ) );
connect( canvas, SIGNAL( destinationSrsChanged() ), this, SLOT( updateVertexMarkersPosition() ) );
connect( canvas, SIGNAL( extentsChanged() ), this, SLOT( updateVertexMarkersPosition() ) );

// geometry was changed
@@ -29,7 +29,7 @@ QgsMapToolMeasureAngle::QgsMapToolMeasureAngle( QgsMapCanvas* canvas ): QgsMapTo
{
mSnapper.setMapCanvas( canvas );

connect( canvas->mapRenderer(), SIGNAL( destinationSrsChanged() ),
connect( canvas, SIGNAL( destinationSrsChanged() ),
this, SLOT( updateSettings() ) );
}

@@ -57,8 +57,7 @@ void QgsMapToolOffsetCurve::canvasPressEvent( QMouseEvent* e )
}


QgsMapRenderer* renderer = mCanvas->mapRenderer();
QgsSnapper snapper( renderer );
QgsSnapper snapper( mCanvas->mapSettings() );
configureSnapper( snapper );
QList<QgsSnappingResult> snapResults;
snapper.snapPoint( e->pos(), snapResults );
@@ -47,7 +47,7 @@ QgsMeasureTool::QgsMeasureTool( QgsMapCanvas* canvas, bool measureArea )
mDialog = new QgsMeasureDialog( this, Qt::WindowStaysOnTopHint );
mSnapper.setMapCanvas( canvas );

connect( canvas->mapRenderer(), SIGNAL( destinationSrsChanged() ),
connect( canvas, SIGNAL( destinationSrsChanged() ),
this, SLOT( updateSettings() ) );
}

@@ -1718,12 +1718,12 @@ void QgsRasterLayerProperties::toggleBuildPyramidsButton()

void QgsRasterLayerProperties::on_mMinimumScaleSetCurrentPushButton_clicked()
{
cbMinimumScale->setScale( 1.0 / QgisApp::instance()->mapCanvas()->mapRenderer()->scale() );
cbMinimumScale->setScale( 1.0 / QgisApp::instance()->mapCanvas()->mapSettings().scale() );
}

void QgsRasterLayerProperties::on_mMaximumScaleSetCurrentPushButton_clicked()
{
cbMaximumScale->setScale( 1.0 / QgisApp::instance()->mapCanvas()->mapRenderer()->scale() );
cbMaximumScale->setScale( 1.0 / QgisApp::instance()->mapCanvas()->mapSettings().scale() );
}

void QgsRasterLayerProperties::on_mResetColorRenderingBtn_clicked()
@@ -1060,10 +1060,10 @@ void QgsVectorLayerProperties::enableLabelOptions( bool theFlag )

void QgsVectorLayerProperties::on_mMinimumScaleSetCurrentPushButton_clicked()
{
cbMinimumScale->setScale( 1.0 / QgisApp::instance()->mapCanvas()->mapRenderer()->scale() );
cbMinimumScale->setScale( 1.0 / QgisApp::instance()->mapCanvas()->mapSettings().scale() );
}

void QgsVectorLayerProperties::on_mMaximumScaleSetCurrentPushButton_clicked()
{
cbMaximumScale->setScale( 1.0 / QgisApp::instance()->mapCanvas()->mapRenderer()->scale() );
cbMaximumScale->setScale( 1.0 / QgisApp::instance()->mapCanvas()->mapSettings().scale() );
}
@@ -85,7 +85,7 @@ void CoordinateCapture::initGui()
{
mCrs.createFromSrsId( GEOCRS_ID ); // initialize the CRS object

connect( mQGisIface->mapCanvas()->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( setSourceCrs() ) );
connect( mQGisIface->mapCanvas(), SIGNAL( destinationSrsChanged() ), this, SLOT( setSourceCrs() ) );
connect( mQGisIface, SIGNAL( currentThemeChanged( QString ) ), this, SLOT( setCurrentTheme( QString ) ) );

setSourceCrs(); //set up the source CRS
@@ -188,8 +188,8 @@ void CoordinateCapture::setCRS()

void CoordinateCapture::setSourceCrs()
{
mTransform.setSourceCrs( mQGisIface->mapCanvas()->mapRenderer()->destinationCrs() );
mCanvasDisplayPrecision = ( mQGisIface->mapCanvas()->mapRenderer()->destinationCrs().mapUnits() == QGis::Degrees ) ? 5 : 3; // for the map canvas coordinate display
mTransform.setSourceCrs( mQGisIface->mapCanvas()->mapSettings().destinationCrs() );
mCanvasDisplayPrecision = ( mQGisIface->mapCanvas()->mapSettings().destinationCrs().mapUnits() == QGis::Degrees ) ? 5 : 3; // for the map canvas coordinate display
}

void CoordinateCapture::mouseClicked( QgsPoint thePoint )
@@ -186,9 +186,7 @@ double QgsGCPCanvasItem::residualToScreenFactor() const
double mapUnitsPerScreenPixel = mMapCanvas->mapUnitsPerPixel();
double mapUnitsPerRasterPixel = 1.0;

if ( mMapCanvas->mapRenderer() )
{
QStringList canvasLayers = mMapCanvas->mapRenderer()->layerSet();
QStringList canvasLayers = mMapCanvas->mapSettings().layers();
if ( canvasLayers.size() > 0 )
{
QString layerId = canvasLayers.at( 0 );
@@ -202,7 +200,6 @@ double QgsGCPCanvasItem::residualToScreenFactor() const
}
}
}
}

return 1.0 / ( mapUnitsPerScreenPixel * mapUnitsPerRasterPixel );
}
@@ -1443,12 +1443,6 @@ bool QgsGeorefPluginGui::writePDFMapFile( const QString& fileName, const QgsGeor
return false;
}

QgsMapRenderer* canvasRenderer = mCanvas->mapRenderer();
if ( !canvasRenderer )
{
return false;
}

QgsRasterLayer *rlayer = ( QgsRasterLayer* ) mCanvas->layer( 0 );
if ( !rlayer )
{
@@ -1487,7 +1481,7 @@ bool QgsGeorefPluginGui::writePDFMapFile( const QString& fileName, const QgsGeor
QgsComposerMap* composerMap = new QgsComposerMap( composition, leftMargin, topMargin, contentWidth, contentHeight );
composerMap->setKeepLayerSet( true );
QStringList list;
list.append( canvasRenderer->layerSet()[0] );
list.append( mCanvas->mapSettings().layers()[0] );
composerMap->setLayerSet( list );

double xcenter = rlayer->extent().center().x();
@@ -1547,12 +1541,6 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
return false;
}

QgsMapRenderer* canvasRenderer = mCanvas->mapRenderer();
if ( !canvasRenderer )
{
return false;
}

QPrinter printer;
printer.setOutputFormat( QPrinter::PdfFormat );
printer.setOutputFileName( fileName );
@@ -1605,7 +1593,7 @@ bool QgsGeorefPluginGui::writePDFReportFile( const QString& fileName, const QgsG
}

QgsComposerMap* composerMap = new QgsComposerMap( composition, leftMargin, titleLabel->rect().bottom() + titleLabel->transform().dy(), mapWidthMM, mapHeightMM );
composerMap->setLayerSet( canvasRenderer->layerSet() );
composerMap->setLayerSet( mCanvas->mapSettings().layers() );
composerMap->setNewExtent( mCanvas->extent() );
composerMap->setMapCanvas( mCanvas );
composition->addItem( composerMap );
@@ -1022,7 +1022,7 @@ bool QgsGrassModuleStandardOptions::inputRegion( struct Cell_head *window, QgsCo
// TODO: warn if outside region
if ( mCanvas->hasCrsTransformEnabled() )
{
crs = mCanvas->mapRenderer()->destinationCrs();
crs = mCanvas->mapSettings().destinationCrs();
}
else
{
@@ -1035,8 +1035,8 @@ bool QgsGrassModuleStandardOptions::inputRegion( struct Cell_head *window, QgsCo
window->south = rect.yMinimum();
window->east = rect.xMaximum();
window->north = rect.yMaximum();
window->rows = ( int ) mCanvas->mapRenderer()->outputSize().height();
window->cols = ( int ) mCanvas->mapRenderer()->outputSize().width();
window->rows = ( int ) mCanvas->mapSettings().outputSize().height();
window->cols = ( int ) mCanvas->mapSettings().outputSize().width();

char* err = G_adjust_Cell_head( window, 1, 1 );
if ( err )
@@ -122,7 +122,7 @@ void QgsGrassPlugin::initGui()
mCanvas = qGisInterface->mapCanvas();
QWidget* qgis = qGisInterface->mainWindow();

connect( mCanvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( setTransform() ) );
connect( mCanvas, SIGNAL( destinationSrsChanged() ), this, SLOT( setTransform() ) );

// Connect project
connect( qgis, SIGNAL( projectRead() ), this, SLOT( projectRead() ) );
@@ -924,12 +924,12 @@ QIcon QgsGrassPlugin::getThemeIcon( const QString theName )

void QgsGrassPlugin::setTransform()
{
if ( mCrs.isValid() && mCanvas->mapRenderer()->destinationCrs().isValid() )
if ( mCrs.isValid() && mCanvas->mapSettings().destinationCrs().isValid() )
{
QgsDebugMsg( "srcCrs: " + mCrs.toWkt() );
QgsDebugMsg( "destCrs " + mCanvas->mapRenderer()->destinationCrs().toWkt() );
QgsDebugMsg( "destCrs " + mCanvas->mapSettings().destinationCrs().toWkt() );
mCoordinateTransform.setSourceCrs( mCrs );
mCoordinateTransform.setDestCRS( mCanvas->mapRenderer()->destinationCrs() );
mCoordinateTransform.setDestCRS( mCanvas->mapSettings().destinationCrs() );
}
}

@@ -45,7 +45,7 @@ QgsGrassRegionEdit::QgsGrassRegionEdit( QgsMapCanvas* canvas )
mCrs = QgsGrass::crs( gisdbase, location );
QgsDebugMsg( "mCrs: " + mCrs.toWkt() );
setTransform();
connect( canvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( setTransform() ) );
connect( canvas, SIGNAL( destinationSrsChanged() ), this, SLOT( setTransform() ) );
}

QgsGrassRegionEdit::~QgsGrassRegionEdit()
@@ -111,21 +111,21 @@ void QgsGrassRegionEdit::calcSrcRegion()
{
mSrcRectangle.set( mStartPoint, mEndPoint );

if ( mCanvas->mapRenderer()->hasCrsTransformEnabled() && mCrs.isValid() && mCanvas->mapRenderer()->destinationCrs().isValid() )
if ( mCanvas->hasCrsTransformEnabled() && mCrs.isValid() && mCanvas->mapSettings().destinationCrs().isValid() )
{
QgsCoordinateTransform coordinateTransform;
coordinateTransform.setSourceCrs( mCanvas->mapRenderer()->destinationCrs() );
coordinateTransform.setSourceCrs( mCanvas->mapSettings().destinationCrs() );
coordinateTransform.setDestCRS( mCrs );
mSrcRectangle = coordinateTransform.transformBoundingBox( mSrcRectangle );
}
}

void QgsGrassRegionEdit::setTransform()
{
if ( mCrs.isValid() && canvas()->mapRenderer()->destinationCrs().isValid() )
if ( mCrs.isValid() && canvas()->mapSettings().destinationCrs().isValid() )
{
mCoordinateTransform.setSourceCrs( mCrs );
mCoordinateTransform.setDestCRS( canvas()->mapRenderer()->destinationCrs() );
mCoordinateTransform.setDestCRS( canvas()->mapSettings().destinationCrs() );
}
}

@@ -134,7 +134,7 @@ void QgsGrassRegionEdit::transform( QgsMapCanvas *canvas, QVector<QgsPoint> &poi
QgsDebugMsg( "Entered" );

/** Coordinate transform */
if ( canvas->mapRenderer()->hasCrsTransformEnabled() )
if ( canvas->hasCrsTransformEnabled() )
{
//QgsDebugMsg ( "srcCrs = " + coordinateTransform->sourceCrs().toWkt() );
//QgsDebugMsg ( "destCrs = " + coordinateTransform->destCRS().toWkt() );
@@ -239,8 +239,8 @@ QgsGraph* RgShortestPathWidget::getPath( QgsPoint& p1, QgsPoint& p2 )
}

QgsGraphBuilder builder(
mPlugin->iface()->mapCanvas()->mapRenderer()->destinationCrs(),
mPlugin->iface()->mapCanvas()->mapRenderer()->hasCrsTransformEnabled(),
mPlugin->iface()->mapCanvas()->mapSettings().destinationCrs(),
mPlugin->iface()->mapCanvas()->mapSettings().hasCrsTransformEnabled(),
mPlugin->topologyToleranceFactor() );
{
const QgsGraphDirector *director = mPlugin->director();
@@ -371,7 +371,7 @@ void RgShortestPathWidget::exportPath()
if ( path == NULL )
return;

QgsCoordinateTransform ct( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationCrs(),
QgsCoordinateTransform ct( mPlugin->iface()->mapCanvas()->mapSettings().destinationCrs(),
vl->crs() );

int startVertexIdx = path->findVertex( p1 );
@@ -683,13 +683,13 @@ void QgsSpatialQueryDialog::zoomFeature( QgsVectorLayer* lyr, QgsFeatureId fid )
}
// Set system reference
QgsCoordinateReferenceSystem srsSource = lyr->dataProvider()->crs();
QgsCoordinateReferenceSystem srcMapcanvas = mIface->mapCanvas()->mapRenderer()->destinationCrs();
QgsCoordinateReferenceSystem srcMapcanvas = mIface->mapCanvas()->mapSettings().destinationCrs();
if ( ! srsSource.isValid() )
{
if ( hasMsg )
{
QString crsMapcanvas = srcMapcanvas.authid();
bool isFly = mIface->mapCanvas()->mapRenderer()->hasCrsTransformEnabled();
bool isFly = mIface->mapCanvas()->mapSettings().hasCrsTransformEnabled();
QString msgFly = tr( "Map \"%1\" \"on the fly\" transformation." ).arg( isFly ? tr( "enable" ) : tr( "disable" ) );
QString msg = tr( "Coordinate reference system(CRS) of\n\"%1\" is invalid(see CRS of provider)." ).arg( lyr->name() );
msg.append( tr( "\n\nCRS of map is %1.\n%2." ).arg( crsMapcanvas ).arg( msgFly ) );
@@ -73,8 +73,8 @@ void TestProjectionIssues::initTestCase()
//reproject to SWEDREF 99 TM
QgsCoordinateReferenceSystem destCRS;
destCRS.createFromId( 3006, QgsCoordinateReferenceSystem::EpsgCrsId );
mMapCanvas->mapRenderer()->setDestinationCrs( destCRS );
mMapCanvas->mapRenderer()->setProjectionsEnabled( true );
mMapCanvas->setDestinationCrs( destCRS );
mMapCanvas->setCrsTransformEnabled( true );

};

0 comments on commit 2d12aca

Please sign in to comment.
You can’t perform that action at this time.