Skip to content
Permalink
Browse files

Add Dialog to select datum transformation

  • Loading branch information
mhugent committed Oct 21, 2013
1 parent a2e0a1a commit 162d8abc81dd25a71d168e76c2c8aeba2d4da207
@@ -59,6 +59,7 @@ const QgsCoordinateTransform* QgsCoordinateTransformCache::transform( const QStr
QgsCoordinateTransform* ct = new QgsCoordinateTransform( srcCrs, destCrs );
ct->setSourceDatumTransform( srcDatumTransform );
ct->setDestinationDatumTransform( destDatumTransform );
ct->initialise();
mTransforms.insertMulti( qMakePair( srcAuthId, destAuthId ), ct );
return ct;
}
@@ -655,7 +655,7 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
{
QgsRectangle r1 = mExtent;
split = splitLayersExtent( ml, r1, r2 );
ct = new QgsCoordinateTransform( ml->crs(), *mDestCRS );
ct = tr( ml );
mRenderContext.setExtent( r1 );
}
else
@@ -69,6 +69,7 @@ qgscomposerview.cpp
qgscomposerruler.cpp
qgscursors.cpp
qgsdatadefinedbutton.cpp
qgsdatumtransformdialog.cpp
qgsdetaileditemdelegate.cpp
qgsdetaileditemwidget.cpp
qgsdetaileditemdata.cpp
@@ -195,6 +196,7 @@ qgscharacterselectdialog.h
qgscolordialog.h
qgscomposerview.h
qgsdatadefinedbutton.h
qgsdatumtransformdialog.h
qgsdetaileditemdelegate.h
qgsdetaileditemwidget.h
qgsdialog.h
@@ -0,0 +1,51 @@
#include "qgsdatumtransformdialog.h"

QgsDatumTransformDialog::QgsDatumTransformDialog( const QList< QList< int > >& dt, QWidget* parent, Qt::WindowFlags f ): QDialog( parent, f )
{
setupUi( this );
QList< QList< int > >::const_iterator it = dt.constBegin();
for ( ; it != dt.constEnd(); ++it )
{
QTreeWidgetItem* item = new QTreeWidgetItem();
QString itemText;
for ( int i = 0; i < 2; ++i )
{
itemText = QString::number( it->at( i ) );
if ( itemText.compare( "-1" ) != 0 )
{
item->setText( i, itemText );
}
}
mDatumTransformTreeWidget->addTopLevelItem( item );
}
}

QgsDatumTransformDialog::~QgsDatumTransformDialog()
{
}

QgsDatumTransformDialog::QgsDatumTransformDialog(): QDialog()
{
setupUi( this );
}

QList< int > QgsDatumTransformDialog::selectedDatumTransform()
{
QList<int> list;
QTreeWidgetItem * item = mDatumTransformTreeWidget->currentItem();
if ( item )
{
for ( int i = 0; i < 2; ++i )
{
bool conversionOk = false;
QString itemText = item->text( i );
int transformNr = itemText.toInt( &conversionOk );
if ( !itemText.isEmpty() && conversionOk )
{
list << transformNr;
}
}
}

return list;
}
@@ -0,0 +1,17 @@
#ifndef QGSDATUMTRANSFORMDIALOG_H
#define QGSDATUMTRANSFORMDIALOG_H

#include "ui_qgsdatumtransformdialogbase.h"

class QgsDatumTransformDialog: public QDialog, private Ui::QgsDatumTransformDialogBase
{
public:
QgsDatumTransformDialog( const QList< QList< int > >& dt, QWidget * parent = 0, Qt::WindowFlags f = 0 );
~QgsDatumTransformDialog();

QList< int > selectedDatumTransform();
private:
QgsDatumTransformDialog();
};

#endif // QGSDATUMTRANSFORMDIALOG_H
@@ -39,6 +39,7 @@ email : sherman at mrcc.com
#include "qgis.h"
#include "qgsapplication.h"
#include "qgscrscache.h"
#include "qgsdatumtransformdialog.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgsmapcanvasmap.h"
@@ -1566,18 +1567,22 @@ void QgsMapCanvas::getDatumTransformInfo( QgsMapLayer* ml, const QString& srcAut
}

//if several possibilities: present dialog
//QgsDatumTransformDialog d( dt );
//if( d.exec() == QDialog::Accepted )
//{
// int srcTransform = -1;
// int destTransform = -1;
// QList<int> t = d.selectedDatumTransform();
// if( t.size() > 0 )
// {
// srcTransform = t.at( 0 );
// }
// QgsMapRenderer::addLayerCoordinateTransform( ml->id(), const QString& srcAuthId, const QString& destAuthId, int srcTransform = -1, int destTransform = -1 )
//}
QgsDatumTransformDialog d( dt );
if ( mMapRenderer && ( d.exec() == QDialog::Accepted ) )
{
int srcTransform = -1;
int destTransform = -1;
QList<int> t = d.selectedDatumTransform();
if ( t.size() > 0 )
{
srcTransform = t.at( 0 );
}
mMapRenderer->addLayerCoordinateTransform( ml->id(), srcAuthId, destAuthId, srcTransform, destTransform );
}
else
{
mMapRenderer->addLayerCoordinateTransform( ml->id(), srcAuthId, destAuthId, -1, -1 );
}
}

void QgsMapCanvas::zoomByFactor( double scaleFactor )
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsDatumTransformDialogBase</class>
<widget class="QDialog" name="QgsDatumTransformDialogBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>346</width>
<height>237</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTreeWidget" name="mDatumTransformTreeWidget">
<column>
<property name="text">
<string/>
</property>
</column>
<column>
<property name="text">
<string/>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QgsDatumTransformDialogBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QgsDatumTransformDialogBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

0 comments on commit 162d8ab

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