Skip to content
Permalink
Browse files

Merge pull request #4198 from nyalldawson/canvas_api

Remove support for disabling OTF reprojection
  • Loading branch information
nyalldawson committed Mar 1, 2017
2 parents aeaa5fc + 081cf96 commit 1f7635ace77771b537e9597e6d89d4ebc2298e09
Showing with 887 additions and 1,239 deletions.
  1. +19 −1 doc/api_break.dox
  2. +0 −11 python/core/dxf/qgsdxfexport.sip
  3. +0 −7 python/core/qgsmapsettings.sip
  4. +0 −5 python/core/qgstracer.sip
  5. +0 −5 python/gui/layertree/qgslayertreemapcanvasbridge.sip
  6. +3 −39 python/gui/qgsmapcanvas.sip
  7. +0 −3 python/gui/qgsmapoverviewcanvas.sip
  8. +4 −0 python/gui/qgsprojectionselectiondialog.sip
  9. +7 −1 python/gui/qgsprojectionselectiontreewidget.sip
  10. +4 −3 python/plugins/db_manager/db_plugins/postgis/plugins/qgis_topoview/__init__.py
  11. +2 −2 python/plugins/db_manager/layer_preview.py
  12. +1 −2 python/plugins/processing/algs/qgis/FieldsCalculator.py
  13. +1 −2 python/plugins/processing/algs/qgis/FieldsMapper.py
  14. +1 −1 python/plugins/processing/algs/qgis/ServiceAreaFromLayer.py
  15. +1 −1 python/plugins/processing/algs/qgis/ServiceAreaFromPoint.py
  16. +1 −1 python/plugins/processing/algs/qgis/ShortestPathLayerToPoint.py
  17. +1 −1 python/plugins/processing/algs/qgis/ShortestPathPointToLayer.py
  18. +1 −1 python/plugins/processing/algs/qgis/ShortestPathPointToPoint.py
  19. +7 −10 src/app/openstreetmap/qgsosmdownloaddialog.cpp
  20. +42 −96 src/app/qgisapp.cpp
  21. +0 −1 src/app/qgisapp.h
  22. +2 −2 src/app/qgsdecorationgrid.cpp
  23. +1 −4 src/app/qgsmaptoollabel.cpp
  24. +6 −12 src/app/qgsmaptoolmovelabel.cpp
  25. +8 −14 src/app/qgsmaptoolpinlabels.cpp
  26. +36 −39 src/app/qgsmaptoolselectutils.cpp
  27. +11 −14 src/app/qgsmaptoolshowhidelabels.cpp
  28. +58 −7 src/app/qgsmeasuredialog.cpp
  29. +2 −0 src/app/qgsmeasuredialog.h
  30. +4 −4 src/app/qgsmeasuretool.cpp
  31. +0 −19 src/app/qgsoptions.cpp
  32. +92 −150 src/app/qgsprojectproperties.cpp
  33. +0 −17 src/app/qgsprojectproperties.h
  34. +1 −1 src/app/qgssnappingwidget.cpp
  35. +0 −2 src/core/composer/qgscomposermap.cpp
  36. +10 −5 src/core/dxf/qgsdxfexport.cpp
  37. +1 −8 src/core/dxf/qgsdxfexport.h
  38. 0 src/core/geometry/qgscompoundcurve.cpp
  39. 0 src/core/geometry/qgsgeometryutils.cpp
  40. 0 src/core/geometry/qgspointv2.cpp
  41. +16 −84 src/core/qgscoordinatereferencesystem.cpp
  42. +2 −5 src/core/qgsmaphittest.cpp
  43. +9 −12 src/core/qgsmaprendererjob.cpp
  44. +69 −120 src/core/qgsmapsettings.cpp
  45. +0 −8 src/core/qgsmapsettings.h
  46. +3 −0 src/core/qgsproject.cpp
  47. +3 −3 src/core/qgssnappingutils.cpp
  48. +0 −6 src/core/qgstolerance.cpp
  49. +3 −13 src/core/qgstracer.cpp
  50. +0 −7 src/core/qgstracer.h
  51. +5 −12 src/core/qgsvectorlayerdiagramprovider.cpp
  52. +6 −9 src/core/qgsvectorlayerlabelprovider.cpp
  53. +3 −34 src/gui/layertree/qgslayertreemapcanvasbridge.cpp
  54. +0 −6 src/gui/layertree/qgslayertreemapcanvasbridge.h
  55. +2 −3 src/gui/layertree/qgslayertreeviewdefaultactions.cpp
  56. +11 −13 src/gui/qgshighlight.cpp
  57. +9 −54 src/gui/qgsmapcanvas.cpp
  58. +31 −29 src/gui/qgsmapcanvas.h
  59. +0 −1 src/gui/qgsmapcanvastracer.cpp
  60. +0 −6 src/gui/qgsmapoverviewcanvas.cpp
  61. +0 −3 src/gui/qgsmapoverviewcanvas.h
  62. +1 −1 src/gui/qgsmaptoolidentify.cpp
  63. +10 −0 src/gui/qgsprojectionselectiondialog.cpp
  64. +16 −0 src/gui/qgsprojectionselectiondialog.h
  65. +33 −1 src/gui/qgsprojectionselectiontreewidget.cpp
  66. +26 −0 src/gui/qgsprojectionselectiontreewidget.h
  67. +2 −7 src/gui/qgsprojectionselectionwidget.cpp
  68. +1 −1 src/gui/symbology-ng/qgsellipsesymbollayerwidget.cpp
  69. +2 −2 src/gui/symbology-ng/qgssymbollayerwidget.cpp
  70. +1 −8 src/plugins/grass/qgsgrassmoduleoptions.cpp
  71. +12 −15 src/plugins/grass/qgsgrassregion.cpp
  72. +1 −3 src/plugins/spatialquery/qgsspatialquerydialog.cpp
  73. +13 −33 src/server/services/wms/qgswmsrenderer.cpp
  74. +118 −156 src/ui/qgsoptionsbase.ui
  75. +28 −28 src/ui/qgsprojectpropertiesbase.ui
  76. +0 −3 tests/bench/qgsbench.cpp
  77. +0 −2 tests/src/app/testqgsattributetable.cpp
  78. +0 −2 tests/src/app/testqgsfieldcalculator.cpp
  79. +0 −3 tests/src/app/testqgsmaptoolidentifyaction.cpp
  80. +28 −4 tests/src/app/testqgsmeasuretool.cpp
  81. +0 −1 tests/src/core/testqgscomposermap.cpp
  82. +0 −1 tests/src/core/testqgscomposermapgrid.cpp
  83. +3 −0 tests/src/core/testqgscoordinatereferencesystem.cpp
  84. 0 tests/src/core/testqgsgeometryimport.cpp
  85. +0 −2 tests/src/core/testqgsinvertedpolygonrenderer.cpp
  86. +33 −0 tests/src/core/testqgsmapsettings.cpp
  87. +4 −0 tests/src/core/testqgsrasterlayer.cpp
  88. +0 −1 tests/src/core/testqgstracer.cpp
  89. +0 −25 tests/src/gui/testprojectionissues.cpp
  90. +1 −1 tests/src/python/CMakeLists.txt
  91. +0 −1 tests/src/python/test_qgscomposerlabel.py
  92. +0 −4 tests/src/python/test_qgscomposerlegend.py
  93. +0 −1 tests/src/python/test_qgscomposermapgrid.py
  94. +1 −0 tests/src/python/test_qgsnoapplication.py
  95. +0 −4 tests/src/python/test_qgspallabeling_base.py
  96. +5 −0 tests/src/python/test_qgsproject.py
  97. +49 −8 tests/src/python/{test_qgsprojectionselectionwidget.py → test_qgsprojectionselectionwidgets.py}
  98. +0 −2 tests/src/python/utilities.py
@@ -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}
@@ -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}
-----------------

@@ -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}
----------------
@@ -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}
@@ -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}
@@ -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}
-----------------

@@ -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;

/**
@@ -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 );
@@ -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
@@ -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 );
@@ -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 );
@@ -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;
@@ -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
@@ -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 );
@@ -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();
@@ -18,6 +18,10 @@ class QgsProjectionSelectionDialog : QDialog //, private Ui::QgsGenericProjectio

void setMessage( const QString& message );

void setShowNoProjection( bool show );

bool showNoProjection() const;

public slots:


@@ -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 );
@@ -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()
@@ -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
@@ -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:
@@ -130,5 +130,5 @@ def _loadTablePreview(self, table, limit=False):

self.currentLayer = vl

self.setRenderFlag(True)
self.freeze(False)
QApplication.restoreOverrideCursor()
@@ -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)
@@ -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])

@@ -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...'))
@@ -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])
@@ -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...'))
@@ -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...'))
@@ -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])
@@ -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 );

0 comments on commit 1f7635a

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