Skip to content

Commit

Permalink
dxf export: make encoding configurable (fixes #11578)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 15, 2015
1 parent 957f1ac commit d9a1654
Show file tree
Hide file tree
Showing 8 changed files with 259 additions and 100 deletions.
24 changes: 12 additions & 12 deletions python/core/dxf/qgsdxfexport.sip
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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 );

};
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -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 );
}
Expand Down
8 changes: 8 additions & 0 deletions src/app/qgsdxfexportdialog.cpp
Expand Up @@ -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() ) );
}


Expand Down Expand Up @@ -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();
}
1 change: 1 addition & 0 deletions src/app/qgsdxfexportdialog.h
Expand Up @@ -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 */
Expand Down

0 comments on commit d9a1654

Please sign in to comment.