Skip to content
Permalink
Browse files

datum transformation selection:

* respect the 'auto enable otf' setting
* don't ask if otf is off or for layers without geometry
* ask when otf was switched on
* show more information in selection dialog
  • Loading branch information
jef-n committed Jun 9, 2014
1 parent 32a3f5c commit a715ce6d88a17986068d60ca9d6bf37fd2d21e8a
@@ -57,4 +57,17 @@ class QgsLayerTreeMapCanvasBridge : QObject
void hasCustomLayerOrderChanged( bool );
void customLayerOrderChanged( const QStringList& order );

protected:

void defaultLayerOrder( QgsLayerTreeNode* node, QStringList& order ) const;

void setCanvasLayers( QgsLayerTreeNode* node, QList<QgsMapCanvasLayer>& layers );

void deferredSetCanvasLayers();

protected slots:
void nodeAddedChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo );
void nodeRemovedChildren();
void nodeVisibilityChanged();
void nodeCustomPropertyChanged( QgsLayerTreeNode* node, QString key );
};
@@ -2318,6 +2318,10 @@ void QgisApp::initLayerTreeView()
connect( QgsProject::instance(), SIGNAL( writeProject( QDomDocument& ) ), mLayerTreeCanvasBridge, SLOT( writeProject( QDomDocument& ) ) );
connect( QgsProject::instance(), SIGNAL( readProject( QDomDocument ) ), mLayerTreeCanvasBridge, SLOT( readProject( QDomDocument ) ) );

bool otfTransformAutoEnable = QSettings().value( "/Projections/otfTransformAutoEnable", true ).toBool();
mLayerTreeCanvasBridge->setAutoEnableCrsTransform( otfTransformAutoEnable );
mLayerTreeCanvasBridge->setAutoSetupOnFirstLayer( otfTransformAutoEnable );

mMapLayerOrder = new QgsCustomLayerOrderWidget( mLayerTreeCanvasBridge, this );
mMapLayerOrder->setObjectName( "theMapLayerOrder" );

@@ -7286,6 +7290,10 @@ void QgisApp::showOptionsDialog( QWidget *parent, QString currentPage )
qobject_cast<QgsMeasureTool*>( mMapTools.mMeasureDist )->updateSettings();
qobject_cast<QgsMeasureTool*>( mMapTools.mMeasureArea )->updateSettings();
qobject_cast<QgsMapToolMeasureAngle*>( mMapTools.mMeasureAngle )->updateSettings();

bool otfTransformAutoEnable = mySettings.value( "/Projections/otfTransformAutoEnable", true ).toBool();
mLayerTreeCanvasBridge->setAutoEnableCrsTransform( otfTransformAutoEnable );
mLayerTreeCanvasBridge->setAutoSetupOnFirstLayer( otfTransformAutoEnable );
}

delete optionsDialog;
@@ -9601,11 +9609,18 @@ void QgisApp::readProject( const QDomDocument &doc )
projectChanged( doc );

// force update of canvas, without automatic changes to extent and OTF projections
bool autoEnableCrsTransform = mLayerTreeCanvasBridge->autoEnableCrsTransform();
bool autoSetupOnFirstLayer = mLayerTreeCanvasBridge->autoSetupOnFirstLayer();
mLayerTreeCanvasBridge->setAutoEnableCrsTransform( false );
mLayerTreeCanvasBridge->setAutoSetupOnFirstLayer( false );

mLayerTreeCanvasBridge->setCanvasLayers();
mLayerTreeCanvasBridge->setAutoEnableCrsTransform( true );
mLayerTreeCanvasBridge->setAutoSetupOnFirstLayer( true );

if ( autoEnableCrsTransform )
mLayerTreeCanvasBridge->setAutoEnableCrsTransform( true );

if ( autoSetupOnFirstLayer )
mLayerTreeCanvasBridge->setAutoSetupOnFirstLayer( true );
}

void QgisApp::showLayerProperties( QgsMapLayer *ml )
@@ -38,6 +38,9 @@ QgsDatumTransformDialog::QgsDatumTransformDialog( const QString& layerName, cons
mHideDeprecatedCheckBox->setChecked( settings.value( "/Windows/DatumTransformDialog/hideDeprecated", false ).toBool() );
mRememberSelectionCheckBox->setChecked( settings.value( "/Windows/DatumTransformDialog/rememberSelection", false ).toBool() );

mLabelSrcDescription->setText( "" );
mLabelDstDescription->setText( "" );

for ( int i = 0; i < 2; i++ )
{
mDatumTransformTreeWidget->setColumnWidth( i, settings.value( QString( "/Windows/DatumTransformDialog/columnWidths/%1" ).arg( i ), mDatumTransformTreeWidget->columnWidth( i ) ).toInt() );
@@ -225,10 +228,18 @@ void QgsDatumTransformDialog::on_mHideDeprecatedCheckBox_stateChanged( int )
load();
}

void QgsDatumTransformDialog::on_mDatumTransformTreeWidget_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
{
mLabelSrcDescription->setText( current->toolTip( 0 ) );
mLabelDstDescription->setText( current->toolTip( 1 ) );
}

void QgsDatumTransformDialog::updateTitle()
{
QString title = tr( "Select datum transformations for layer" ) + " " + mLayerName;
if ( !mSrcCRSauthId.isEmpty() && !mDestCRSauthId.isEmpty() )
title += QString( " (%1 -> %2)" ).arg( mSrcCRSauthId ).arg( mDestCRSauthId );
setWindowTitle( title );
mLabelLayer->setText( mLayerName );
QgsCoordinateReferenceSystem crs;
crs.createFromString( mSrcCRSauthId );
mLabelSrcCrs->setText( QString( "%1 - %2" ).arg( mSrcCRSauthId ).arg( crs.isValid() ? crs.description() : tr( "unknown" ) ) );
crs.createFromString( mDestCRSauthId );
mLabelDstCrs->setText( QString( "%1 - %2" ).arg( mDestCRSauthId ).arg( crs.isValid() ? crs.description() : tr( "unknown" ) ) );
}
@@ -36,6 +36,7 @@ class GUI_EXPORT QgsDatumTransformDialog: public QDialog, private Ui::QgsDatumTr

public slots:
void on_mHideDeprecatedCheckBox_stateChanged( int state );
void on_mDatumTransformTreeWidget_currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem * );

private:
QgsDatumTransformDialog();
@@ -480,6 +480,8 @@ void QgsMapCanvas::setCrsTransformEnabled( bool enabled )

mSettings.setCrsTransformEnabled( enabled );

updateDatumTransformEntries();

refresh();

emit hasCrsTransformEnabledChanged( enabled );
@@ -1555,13 +1557,20 @@ void QgsMapCanvas::connectNotify( const char * signal )

void QgsMapCanvas::updateDatumTransformEntries()
{
if ( !mSettings.hasCrsTransformEnabled() )
return;

QString destAuthId = mSettings.destinationCrs().authid();
foreach ( QString layerID, mSettings.layers() )
{
QgsMapLayer* layer = QgsMapLayerRegistry::instance()->mapLayer( layerID );
if ( !layer )
continue;

QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
if ( vl && vl->geometryType() == QGis::NoGeometry )
continue;

// if there are more options, ask the user which datum transform to use
if ( !mSettings.datumTransformStore().hasEntryForLayer( layer ) )
getDatumTransformInfo( layer, layer->crs().authid(), destAuthId );
@@ -6,15 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>569</width>
<height>237</height>
<width>547</width>
<height>285</height>
</rect>
</property>
<property name="windowTitle">
<string>Select datum transformations</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<item row="3" column="0" colspan="2">
<widget class="QTreeWidget" name="mDatumTransformTreeWidget">
<column>
<property name="text">
@@ -33,7 +33,7 @@
</column>
</widget>
</item>
<item row="1" column="0">
<item row="6" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="mRememberSelectionCheckBox">
@@ -65,6 +65,34 @@
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Destination CRS</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="mLabelSrcCrs">
<property name="text">
<string notr="true">Source CRS</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="mLabelDstCrs">
<property name="text">
<string notr="true">Destination CRS</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Source CRS</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -74,6 +102,46 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Layer</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="mLabelLayer">
<property name="text">
<string notr="true">layer name</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="mLabelDstDescription">
<property name="text">
<string notr="true">Description</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="mLabelSrcDescription">
<property name="text">
<string notr="true">Description</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>

0 comments on commit a715ce6

Please sign in to comment.