Skip to content
Permalink
Browse files

dxf export: make encoding configurable (fixes #11578)

  • Loading branch information
jef-n committed Feb 15, 2015
1 parent 957f1ac commit d9a1654501b6b1a0375e4f5a1ac85140d9b62490
@@ -32,7 +32,7 @@ class QgsDxfExport
~QgsDxfExport();

void addLayers( const QList< QPair<QgsVectorLayer *, int > > &layers );
int writeToFile( QIODevice* d ); //maybe add progress dialog? //other parameters (e.g. scale, dpi)?
int writeToFile( QIODevice *d, QString codec ); //maybe add progress dialog? other parameters (e.g. scale, dpi)?

void setSymbologyScaleDenominator( double d );
double symbologyScaleDenominator() const;
@@ -43,7 +43,7 @@ class QgsDxfExport
void setSymbologyExport( QgsDxfExport::SymbologyExport e );
QgsDxfExport::SymbologyExport symbologyExport() const;

void setExtent( const QgsRectangle& r );
void setExtent( const QgsRectangle &r );
QgsRectangle extent() const;

//get closest entry in dxf palette
@@ -55,39 +55,39 @@ class QgsDxfExport
void writeGroup( int code, int i ) /PyName=writeGroupInt/;
//! @note available in python bindings as writeGroupDouble
void writeGroup( int code, double d ) /PyName=writeGroupDouble/;
void writeGroup( int code, const QString& s );
void writeGroup( int code, const QString &s );
void writeGroupCode( int code );
void writeInt( int i );
void writeDouble( double d );
void writeString( const QString& s );
void writeString( const QString &s );
void writeGroup( int code, const QgsPoint &p, double z = 0.0, bool skipz = false ) /PyName=writeGroupPoint/;
void writeGroup( QColor color, int exactMatch = 62, int rgbCode = 420, int transparencyCode = 440 );

int writeHandle( int code = 5, int handle = 0 );

//draw dxf primitives
void writePolyline( const QgsPolyline& line, const QString& layer, const QString& lineStyleName, QColor color,
void writePolyline( const QgsPolyline &line, const QString &layer, const QString &lineStyleName, QColor color,
double width = -1, bool polygon = false );

void writePolygon( const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, QColor color );

void writeSolid( const QString& layer, QColor color, const QgsPoint& pt1, const QgsPoint& pt2, const QgsPoint& pt3, const QgsPoint& pt4 );
void writeSolid( const QString &layer, QColor color, const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, const QgsPoint &pt4 );

//write line (as a polyline)
void writeLine( const QgsPoint& pt1, const QgsPoint& pt2, const QString& layer, const QString& lineStyleName, QColor color, double width = -1 );
void writeLine( const QgsPoint &pt1, const QgsPoint &pt2, const QString &layer, const QString &lineStyleName, QColor color, double width = -1 );

void writePoint( const QString& layer, QColor color, const QgsPoint& pt );
void writePoint( const QString &layer, QColor color, const QgsPoint &pt );

void writeFilledCircle( const QString &layer, QColor color, const QgsPoint &pt, double radius );

void writeCircle( const QString& layer, QColor color, const QgsPoint& pt, double radius, const QString &lineStyleName, double width );
void writeCircle( const QString &layer, QColor color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width );

void writeText( const QString& layer, const QString& text, const QgsPoint& pt, double size, double angle, QColor color );
void writeText( const QString &layer, const QString &text, const QgsPoint &pt, double size, double angle, QColor color );

void writeMText( const QString& layer, const QString& text, const QgsPoint& pt, double width, double angle, QColor color );
void writeMText( const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, QColor color );

static double mapUnitScaleFactor( double scaleDenominator, QgsSymbolV2::OutputUnit symbolUnits, QGis::UnitType mapUnits );

static QString dxfLayerName( const QString& name );
static QString dxfLayerName( const QString &name );

};
@@ -4180,7 +4180,7 @@ void QgisApp::dxfExport()
fileName += ".dxf";
QFile dxfFile( fileName );
QApplication::setOverrideCursor( Qt::BusyCursor );
if ( dxfExport.writeToFile( &dxfFile ) == 0 )
if ( dxfExport.writeToFile( &dxfFile, d.encoding() ) == 0 )
{
messageBar()->pushMessage( tr( "DXF export completed" ), QgsMessageBar::INFO, 4 );
}
@@ -408,6 +408,8 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f )

buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
restoreGeometry( s.value( "/Windows/DxfExport/geometry" ).toByteArray() );
mEncoding->addItems( QgsDxfExport::encodings() );
mEncoding->setCurrentIndex( mEncoding->findText( s.value( "qgis/lastDxfEncoding", "CP1252" ).toString() ) );
}


@@ -541,4 +543,10 @@ void QgsDxfExportDialog::saveSettings()
s.setValue( "qgis/lastDxfSymbologyMode", mSymbologyModeComboBox->currentIndex() );
s.setValue( "qgis/lastSymbologyExportScale", mScaleWidget->scale() );
s.setValue( "qgis/lastDxfMapRectangle", mMapExtentCheckBox->isChecked() );
s.setValue( "qgis/lastDxfEncoding", mEncoding->currentText() );
}

QString QgsDxfExportDialog::encoding() const
{
return mEncoding->currentText();
}
@@ -85,6 +85,7 @@ class QgsDxfExportDialog : public QDialog, private Ui::QgsDxfExportDialogBase
QgsDxfExport::SymbologyExport symbologyMode() const;
QString saveFile() const;
bool exportMapExtent() const;
QString encoding() const;

public slots:
/** change the selection of layers in the list */

0 comments on commit d9a1654

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