Skip to content
Permalink
Browse files

[FEATURE] dxf export: support reprojection

  • Loading branch information
jef-n committed Sep 19, 2016
1 parent 9264be8 commit 62ea90c59c22d679750126e2ab654643ff40e1fa
@@ -5083,6 +5083,7 @@ void QgisApp::dxfExport()
dxfExport.setSymbologyScaleDenominator( d.symbologyScale() );
dxfExport.setSymbologyExport( d.symbologyMode() );
dxfExport.setLayerTitleAsName( d.layerTitleAsName() );
dxfExport.setDestinationCrs( d.crs() );
if ( mapCanvas() )
{
dxfExport.setMapUnits( mapCanvas()->mapUnits() );
@@ -28,6 +28,8 @@
#include "qgslayertreemapcanvasbridge.h"
#include "qgsmapthemecollection.h"
#include "qgsmapcanvas.h"
#include "qgsgenericprojectionselector.h"
#include "qgscrscache.h"

#include <QFileDialog>
#include <QPushButton>
@@ -453,10 +455,21 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f )
QStringList ids = QgsProject::instance()->mapThemeCollection()->presets();
ids.prepend( "" );
mVisibilityPresets->addItems( ids );
mVisibilityPresets->setCurrentIndex( mVisibilityPresets->findText( QgsProject::instance()->readEntry( "dxf", "/lastVisibilityPreset", "" ) ) );
mVisibilityPresets->setCurrentIndex( mVisibilityPresets->findText( QgsProject::instance()->readEntry( "dxf", "/lastVisibliltyPreset", "" ) ) );

buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
restoreGeometry( s.value( "/Windows/DxfExport/geometry" ).toByteArray() );

mCRS = QgsProject::instance()->readEntry( "dxf", "/lastDxfCrs",
s.value( "qgis/lastDxfCrs", QString::number( QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs().srsid() ) ).toString()
).toLong();

QgsCoordinateReferenceSystem crs = QgsCRSCache::instance()->crsBySrsId( mCRS );

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Sep 19, 2016

Collaborator

QgsCRSCache is no more. All the caching is handled internally in QgsCoordinateReferenceSystem

mCrsSelector->setCrs( crs );
mCrsSelector->setLayerCrs( crs );
mCrsSelector->dialog()->setMessage( tr( "Select the coordinate reference system for the dxf file. "
"The data points will be transformed from the layer coordinate reference system." ) );

mEncoding->addItems( QgsDxfExport::encodings() );
mEncoding->setCurrentIndex( mEncoding->findText( QgsProject::instance()->readEntry( "dxf", "/lastDxfEncoding", s.value( "qgis/lastDxfEncoding", "CP1252" ).toString() ) ) );
}
@@ -600,17 +613,29 @@ void QgsDxfExportDialog::saveSettings()
s.setValue( "qgis/lastDxfMapRectangle", mMapExtentCheckBox->isChecked() );
s.setValue( "qgis/lastDxfLayerTitleAsName", mLayerTitleAsName->isChecked() );
s.setValue( "qgis/lastDxfEncoding", mEncoding->currentText() );
s.setValue( "qgis/lastDxfCrs", QString::number( mCRS ) );

QgsProject::instance()->writeEntry( "dxf", "/lastDxfSymbologyMode", mSymbologyModeComboBox->currentIndex() );
QgsProject::instance()->writeEntry( "dxf", "/lastSymbologyExportScale", mScaleWidget->scale() );
QgsProject::instance()->writeEntry( "dxf", "/lastDxfLayerTitleAsName", mLayerTitleAsName->isChecked() );
QgsProject::instance()->writeEntry( "dxf", "/lastDxfMapRectangle", mMapExtentCheckBox->isChecked() );
QgsProject::instance()->writeEntry( "dxf", "/lastDxfEncoding", mEncoding->currentText() );
QgsProject::instance()->writeEntry( "dxf", "/lastVisibilityPreset", mVisibilityPresets->currentText() );
QgsProject::instance()->writeEntry( "dxf", "/lastDxfCrs", QString::number( mCRS ) );
}


QString QgsDxfExportDialog::encoding() const
{
return mEncoding->currentText();
}

void QgsDxfExportDialog::on_mCrsSelector_crsChanged( const QgsCoordinateReferenceSystem &crs )
{
mCRS = crs.srsid();
}

long QgsDxfExportDialog::crs() const
{
return mCRS;
}
@@ -88,6 +88,7 @@ class QgsDxfExportDialog : public QDialog, private Ui::QgsDxfExportDialogBase
bool exportMapExtent() const;
bool layerTitleAsName() const;
QString encoding() const;
long crs() const;

public slots:
/** Change the selection of layers in the list */
@@ -99,11 +100,14 @@ class QgsDxfExportDialog : public QDialog, private Ui::QgsDxfExportDialogBase
void setOkEnabled();
void saveSettings();
void on_mVisibilityPresets_currentIndexChanged( int index );
void on_mCrsSelector_crsChanged( const QgsCoordinateReferenceSystem &crs );

private:
void cleanGroup( QgsLayerTreeNode *node );
QgsLayerTreeGroup *mLayerTreeGroup;
FieldSelectorDelegate *mFieldSelectorDelegate;

long mCRS;
};

#endif // QGSDXFEXPORTDIALOG_H

0 comments on commit 62ea90c

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