Skip to content

Commit

Permalink
Merge pull request #4198 from nyalldawson/canvas_api
Browse files Browse the repository at this point in the history
Remove support for disabling OTF reprojection
  • Loading branch information
nyalldawson committed Mar 1, 2017
2 parents aeaa5fc + 081cf96 commit 1f7635a
Show file tree
Hide file tree
Showing 98 changed files with 887 additions and 1,239 deletions.
20 changes: 19 additions & 1 deletion doc/api_break.dox
Expand Up @@ -936,7 +936,7 @@ QgsDxfExport {#qgis_api_break_3_0_QgsDxfExport}
- writeSolid() was removed. Use writePolygon() instead.
- The signature for writeLine() has changed.
- writePoint(), writeFilledCircle(), writeCircle(), writeText() and writeMText() now take QgsPointV2 arguments

- setMapUnits() was removed. The map units are dictated by the units for the destination CRS.


QgsEditFormConfig {#qgis_api_break_3_0_QgsEditFormConfig}
Expand Down Expand Up @@ -1257,6 +1257,12 @@ QgsLayerTreeNode {#qgis_api_break_3_0_QgsLayerTreeNode}
- readXml() does not resolve layers from the layer IDs anymore. Call resolveReferences() or use readXml() override with QgsProject as the second argument.


QgsLayerTreeMapCanvasBridge {#qgis_api_break_3_0_QgsLayerTreeMapCanvasBridge}
-----------------

- setAutoEnableCrsTransform() and autoEnableCrsTransform() were removed. CRS transformation is now always enabled.


QgsLayerTreeModel {#qgis_api_break_3_0_QgsLayerTreeMode}
-----------------

Expand Down Expand Up @@ -1315,6 +1321,9 @@ QgsMapCanvas {#qgis_api_break_3_0_QgsMapCanvas}
- setProgress() signal has been removed. It was not emitted since 2.0.
- enableOverviewMode() and updateOverview() have been removed. Map canvas does not keep pointer to overview canvas anymore. Use QgsLayerTreeMapCanvasBridge::setOverviewCanvas() to set up updates of overview canvas together with main canvas.
- the duplicate mapToolSet signal with a single QgsMapTool argument has been removed. Use the signal with arguments for new and old map tool instead.
- setCrsTransformEnabled(), hasCrsTransformEnabled(), hasCrsTransformEnabledChanged() were removed. CRS transformation is now always enabled.
- setMapUnits() was removed. The map units are dictated by the units for the destination CRS.
- The mapUnitsChanged() signal was removed. Listen for the destinationCrsChanged() signal instead, as the destination CRS dictates the map units.

QgsMapCanvasItem {#qgis_api_break_3_0_QgsMapCanvasItem}
----------------
Expand Down Expand Up @@ -1354,6 +1363,7 @@ QgsMapOverviewCanvas {#qgis_api_break_3_0_QgsMapOverviewCanvas}

- layerSet() and setLayerSet() have been replaced by layers() and setLayers() which work with list of layers instead of layer IDs
- destinationSrsChanged() was renamed to destinationCrsChanged()
- hasCrsTransformEnabled() was removed. CRS transformation is now always enabled.


QgsMapRenderer {#qgis_api_break_3_0_QgsMapRenderer}
Expand Down Expand Up @@ -1421,6 +1431,8 @@ QgsMapSettings {#qgis_api_break_3_0_QgsMapSettings}
be returned instead of a null pointer if no transformation is required.
- destinationCrs() now returns a copy instead of a reference to the CRS. This has no effect on PyQGIS code, but c++
plugins calling this method will need to be updated.
- setCrsTransformEnabled() and hasCrsTransformEnabled() were removed. CRS transformation is now always enabled.
- setMapUnits() was removed. The map units are dictated by the units for the destination CRS.


QgsMarkerSymbolLayer {#qgis_api_break_3_0_QgsMarkerSymbolLayer}
Expand Down Expand Up @@ -1896,6 +1908,12 @@ QgsTolerance {#qgis_api_break_3_0_QgsTolerance}
- The MapUnits UnitType was removed. Use LayerUnits or ProjectUnits instead.


QgsTracer {#qgis_api_break_3_0_QgsTracer}
---------

- hasCrsTransformEnabled() and setCrsTransformEnabled() were removed. CRS transformation is now always enabled when required.


QgsTreeWidgetItem {#qgis_api_break_3_0_QgsTreeWidgetItem}
-----------------

Expand Down
11 changes: 0 additions & 11 deletions python/core/dxf/qgsdxfexport.sip
Expand Up @@ -65,17 +65,6 @@ class QgsDxfExport
*/
double symbologyScaleDenominator() const;

/**
* Set map units
* @param u unit
*/
void setMapUnits( QgsUnitTypes::DistanceUnit u );

/**
* Retrieve map units
* @returns unit
* @see setMapUnits
*/
QgsUnitTypes::DistanceUnit mapUnits() const;

/**
Expand Down
7 changes: 0 additions & 7 deletions python/core/qgsmapsettings.sip
Expand Up @@ -83,20 +83,13 @@ class QgsMapSettings
*/
void setCustomRenderFlags( const QString& customRenderFlags );

//! sets whether to use projections for this layer set
void setCrsTransformEnabled( bool enabled );
//! returns true if projections are enabled for this layer set
bool hasCrsTransformEnabled() const;

//! sets destination coordinate reference system
void setDestinationCrs( const QgsCoordinateReferenceSystem& crs );
//! returns CRS of destination coordinate reference system
QgsCoordinateReferenceSystem destinationCrs() const;

//! Get units of map's geographical coordinates - used for scale calculation
QgsUnitTypes::DistanceUnit mapUnits() const;
//! Set units of map's geographical coordinates - used for scale calculation
void setMapUnits( QgsUnitTypes::DistanceUnit u );

//! Set the background color of the map
void setBackgroundColor( const QColor& color );
Expand Down
5 changes: 0 additions & 5 deletions python/core/qgstracer.sip
Expand Up @@ -20,11 +20,6 @@ class QgsTracer : QObject
//! Set layers used for tracing
void setLayers( const QList<QgsVectorLayer*>& layers );

//! Return true if reprojection to destination CRS is enabled
bool hasCrsTransformEnabled() const;
//! Set whether to do reprojection to destination CRS
void setCrsTransformEnabled( bool enabled );

//! Get CRS used for tracing
QgsCoordinateReferenceSystem destinationCrs() const;
//! Set CRS used for tracing
Expand Down
5 changes: 0 additions & 5 deletions python/gui/layertree/qgslayertreemapcanvasbridge.sip
Expand Up @@ -45,11 +45,6 @@ class QgsLayerTreeMapCanvasBridge : QObject
void setAutoSetupOnFirstLayer( bool enabled );
bool autoSetupOnFirstLayer() const;

//! if enabled, will automatically turn on on-the-fly reprojection of layers if a layer
//! with different source CRS is added
void setAutoEnableCrsTransform( bool enabled );
bool autoEnableCrsTransform() const;

public slots:
void setHasCustomLayerOrder( bool state );
void setCustomLayerOrder( const QStringList& order );
Expand Down
42 changes: 3 additions & 39 deletions python/gui/qgsmapcanvas.sip
Expand Up @@ -36,10 +36,6 @@ class QgsMapCanvas : QGraphicsView
//! @note added in 2.4
const QgsMapSettings& mapSettings() const /KeepReference/;

//! sets whether to use projections for this layer set
//! @note added in 2.4
void setCrsTransformEnabled( bool enabled );

//! sets destination coordinate reference system
//! @note added in 2.4
void setDestinationCrs( const QgsCoordinateReferenceSystem& crs );
Expand Down Expand Up @@ -174,26 +170,9 @@ class QgsMapCanvas : QGraphicsView

//! return list of layers within map canvas.
QList<QgsMapLayer*> layers() const;

/**
* Freeze/thaw the map canvas. This is used to prevent the canvas from
* responding to events while layers are being added/removed etc.
* @param frz Boolean specifying if the canvas should be frozen (true) or
* thawed (false). Default is true.
*
* TODO remove in QGIS 3
*/
void freeze( bool frz = true );

/**
* Accessor for frozen status of canvas
*
* TODO remove in QGIS 3
*/
bool isFrozen();

//! Set map units (needed by project properties dialog)
void setMapUnits( QgsUnitTypes::DistanceUnit mapUnits );
void freeze( bool frozen = true );
bool isFrozen() const;
bool renderFlag() const;

//! Get the current canvas map units
QgsUnitTypes::DistanceUnit mapUnits() const;
Expand Down Expand Up @@ -354,14 +333,7 @@ class QgsMapCanvas : QGraphicsView

//! This slot is connected to the layer's CRS change
void layerCrsChange();

//! Whether to suppress rendering or not
void setRenderFlag( bool flag );
//! State of render suppression flag
bool renderFlag();

//! A simple helper method to find out if on the fly projections are enabled or not
bool hasCrsTransformEnabled();

//! stop rendering (if there is any right now)
//! @note added in 2.4
Expand Down Expand Up @@ -454,18 +426,10 @@ class QgsMapCanvas : QGraphicsView
//! Emitted when zoom next status changed
void zoomNextStatusChanged( bool );

//! Emitted when on-the-fly projection has been turned on/off
//! @note added in 2.4
void hasCrsTransformEnabledChanged( bool flag );

//! Emitted when map CRS has changed
//! @note added in 2.4
void destinationCrsChanged();

//! Emitted when map units are changed
//! @note added in 2.4
void mapUnitsChanged();

//! Emitted when the current layer is changed
//! @note added in 2.8
void currentLayerChanged( QgsMapLayer* layer );
Expand Down
3 changes: 0 additions & 3 deletions python/gui/qgsmapoverviewcanvas.sip
Expand Up @@ -32,9 +32,6 @@ class QgsMapOverviewCanvas : QWidget
//! used for overview canvas to reflect changed extent in main map canvas
void drawExtentRect();

// ### QGIS 3: rename so it does not look like getter, make protected
void hasCrsTransformEnabled( bool flag );

// ### QGIS 3: make protected
//! Should be called when the canvas destination CRS is changed
void destinationCrsChanged();
Expand Down
4 changes: 4 additions & 0 deletions python/gui/qgsprojectionselectiondialog.sip
Expand Up @@ -18,6 +18,10 @@ class QgsProjectionSelectionDialog : QDialog //, private Ui::QgsGenericProjectio

void setMessage( const QString& message );

void setShowNoProjection( bool show );

bool showNoProjection() const;

public slots:


Expand Down
8 changes: 7 additions & 1 deletion python/gui/qgsprojectionselectiontreewidget.sip
Expand Up @@ -5,12 +5,18 @@ class QgsProjectionSelectionTreeWidget : QWidget
%End

public:
QgsProjectionSelectionTreeWidget( QWidget* parent /TransferThis/ );
QgsProjectionSelectionTreeWidget( QWidget* parent /TransferThis/ = 0 );

~QgsProjectionSelectionTreeWidget();

QgsCoordinateReferenceSystem crs() const;

void setShowNoProjection( bool show );

bool showNoProjection() const;

bool hasValidSelection() const;

public slots:

void setCrs( const QgsCoordinateReferenceSystem& crs );
Expand Down
Expand Up @@ -99,8 +99,8 @@ def run(item, action, mainwindow):
template_dir = os.path.join(current_path, 'templates')

# do not refresh the canvas until all the layers are added
prevRenderFlagState = iface.mapCanvas().renderFlag()
iface.mapCanvas().setRenderFlag(False)
wasFrozen = iface.mapCanvas().isFrozen()
iface.mapCanvas().freeze()
try:
provider = db.dbplugin().providerName()
uri = db.uri()
Expand Down Expand Up @@ -264,6 +264,7 @@ def run(item, action, mainwindow):
canvas.setExtent(ext)

# restore canvas render flag
iface.mapCanvas().setRenderFlag(prevRenderFlagState)
if not wasFrozen:
iface.mapCanvas().freeze(False)

return True
4 changes: 2 additions & 2 deletions python/plugins/db_manager/layer_preview.py
Expand Up @@ -91,7 +91,7 @@ def _clear(self):
def _loadTablePreview(self, table, limit=False):
""" if has geometry column load to map canvas """
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
self.setRenderFlag(False)
self.freeze()
vl = None

if table and table.geomType:
Expand Down Expand Up @@ -130,5 +130,5 @@ def _loadTablePreview(self, table, limit=False):

self.currentLayer = vl

self.setRenderFlag(True)
self.freeze(False)
QApplication.restoreOverrideCursor()
3 changes: 1 addition & 2 deletions python/plugins/processing/algs/qgis/FieldsCalculator.py
Expand Up @@ -100,8 +100,7 @@ def processAlgorithm(self, feedback):

da = QgsDistanceArea()
da.setSourceCrs(layer.crs())
da.setEllipsoidalMode(
iface.mapCanvas().mapSettings().hasCrsTransformEnabled())
da.setEllipsoidalMode(True)
da.setEllipsoid(QgsProject.instance().readEntry(
'Measure', '/Ellipsoid', GEO_NONE)[0])
exp.setGeomCalculator(da)
Expand Down
3 changes: 1 addition & 2 deletions python/plugins/processing/algs/qgis/FieldsMapper.py
Expand Up @@ -104,8 +104,7 @@ def processAlgorithm(self, feedback):

da = QgsDistanceArea()
da.setSourceCrs(layer.crs())
da.setEllipsoidalMode(
iface.mapCanvas().mapSettings().hasCrsTransformEnabled())
da.setEllipsoidalMode(True)
da.setEllipsoid(QgsProject.instance().readEntry(
'Measure', '/Ellipsoid', GEO_NONE)[0])

Expand Down
Expand Up @@ -209,7 +209,7 @@ def processAlgorithm(self, feedback):

director.addStrategy(strategy)
builder = QgsGraphBuilder(iface.mapCanvas().mapSettings().destinationCrs(),
iface.mapCanvas().hasCrsTransformEnabled(),
True,
tolerance)

feedback.pushInfo(self.tr('Loading start points...'))
Expand Down
Expand Up @@ -192,7 +192,7 @@ def processAlgorithm(self, feedback):

director.addStrategy(strategy)
builder = QgsGraphBuilder(iface.mapCanvas().mapSettings().destinationCrs(),
iface.mapCanvas().hasCrsTransformEnabled(),
True,
tolerance)
feedback.pushInfo(self.tr('Building graph...'))
snappedPoints = director.makeGraph(builder, [startPoint])
Expand Down
Expand Up @@ -203,7 +203,7 @@ def processAlgorithm(self, feedback):

director.addStrategy(strategy)
builder = QgsGraphBuilder(iface.mapCanvas().mapSettings().destinationCrs(),
iface.mapCanvas().hasCrsTransformEnabled(),
True,
tolerance)

feedback.pushInfo(self.tr('Loading start points...'))
Expand Down
Expand Up @@ -203,7 +203,7 @@ def processAlgorithm(self, feedback):

director.addStrategy(strategy)
builder = QgsGraphBuilder(iface.mapCanvas().mapSettings().destinationCrs(),
iface.mapCanvas().hasCrsTransformEnabled(),
True,
tolerance)

feedback.pushInfo(self.tr('Loading end points...'))
Expand Down
Expand Up @@ -204,7 +204,7 @@ def processAlgorithm(self, feedback):

director.addStrategy(strategy)
builder = QgsGraphBuilder(iface.mapCanvas().mapSettings().destinationCrs(),
iface.mapCanvas().hasCrsTransformEnabled(),
True,
tolerance)
feedback.pushInfo(self.tr('Building graph...'))
snappedPoints = director.makeGraph(builder, [startPoint, endPoint])
Expand Down
17 changes: 7 additions & 10 deletions src/app/openstreetmap/qgsosmdownloaddialog.cpp
Expand Up @@ -101,17 +101,14 @@ void QgsOSMDownloadDialog::onExtentCanvas()
{
QgsRectangle r( QgisApp::instance()->mapCanvas()->extent() );

if ( QgisApp::instance()->mapCanvas()->hasCrsTransformEnabled() )
{
QgsCoordinateReferenceSystem dst = QgsCoordinateReferenceSystem::fromSrsId( GEOCRS_ID );
QgsCoordinateReferenceSystem dst = QgsCoordinateReferenceSystem::fromSrsId( GEOCRS_ID );

QgsCoordinateTransform ct( QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs(), dst );
r = ct.transformBoundingBox( r );
if ( !r.isFinite() )
{
QMessageBox::information( this, tr( "OpenStreetMap download" ), tr( "Could not transform canvas extent." ) );
return;
}
QgsCoordinateTransform ct( QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs(), dst );
r = ct.transformBoundingBox( r );
if ( !r.isFinite() )
{
QMessageBox::information( this, tr( "OpenStreetMap download" ), tr( "Could not transform canvas extent." ) );
return;
}

setRect( r );
Expand Down

0 comments on commit 1f7635a

Please sign in to comment.