Skip to content

Commit 1076f70

Browse files
committed
backported dxf fixes:
* fix crash when not enabled layers are exported * fix handing of areas with holes when exporting SVGs * fix block, hatch and polyline ownership * fix support for data-defined properties in SVG export * remove drawRects and let it fallback to drawPath and drawPolygon * close arcs * replace writeSolid with writePolygon (backported b4fc413, 2798ab0, b3c2bd7 and 7031cfb)
1 parent 6a7b6da commit 1076f70

File tree

11 files changed

+329
-283
lines changed

11 files changed

+329
-283
lines changed

python/core/dxf/qgsdxfexport.sip

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,31 +63,45 @@ class QgsDxfExport
6363
void writeGroup( int code, const QgsPoint &p, double z = 0.0, bool skipz = false ) /PyName=writeGroupPoint/;
6464
void writeGroup( QColor color, int exactMatch = 62, int rgbCode = 420, int transparencyCode = 440 );
6565

66+
//! Write handle
6667
int writeHandle( int code = 5, int handle = 0 );
6768

68-
//draw dxf primitives
69+
//! Draw dxf primitives
6970
void writePolyline( const QgsPolyline &line, const QString &layer, const QString &lineStyleName, QColor color,
70-
double width = -1, bool polygon = false );
71+
double width = -1, bool unusedPolygonFlag = false );
7172

73+
//! Draw dxf polygon (HATCH)
7274
void writePolygon( const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, QColor color );
7375

76+
//! Draw solid
7477
void writeSolid( const QString &layer, QColor color, const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, const QgsPoint &pt4 );
7578

76-
//write line (as a polyline)
79+
//! Write line (as a polyline)
7780
void writeLine( const QgsPoint &pt1, const QgsPoint &pt2, const QString &layer, const QString &lineStyleName, QColor color, double width = -1 );
7881

82+
//! Write point
7983
void writePoint( const QString &layer, QColor color, const QgsPoint &pt );
8084

85+
//! Write filled circle (as hatch)
8186
void writeFilledCircle( const QString &layer, QColor color, const QgsPoint &pt, double radius );
8287

88+
//! Write circle (as polyline)
8389
void writeCircle( const QString &layer, QColor color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width );
8490

91+
//! Write text (TEXT)
8592
void writeText( const QString &layer, const QString &text, const QgsPoint &pt, double size, double angle, QColor color );
8693

94+
//! Write mtext (MTEXT)
8795
void writeMText( const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, QColor color );
8896

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

99+
//! Return cleaned layer name for use in DXF
91100
static QString dxfLayerName( const QString &name );
92101

102+
//! return DXF encoding for Qt encoding
103+
static QString dxfEncoding( const QString &name );
104+
105+
//! return list of available DXF encodings
106+
static QStringList encodings();
93107
};

python/core/symbology-ng/qgssvgcache.sip

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ class QgsSvgCache : QObject
8787
/**Get image data*/
8888
QByteArray getImageData( const QString &path ) const;
8989

90+
/**Get SVG content*/
91+
const QByteArray& svgContent( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
92+
double widthScaleFactor, double rasterScaleFactor );
93+
9094
signals:
9195
/** Emit a signal to be caught by qgisapp and display a msg on status bar */
9296
void statusChanged( const QString& theStatusQString );

src/app/qgsdxfexportdialog.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "qgis.h"
2626
#include "qgsfieldcombobox.h"
2727
#include "qgisapp.h"
28-
#include "qgsmapcanvas.h"
28+
#include "qgslayertreemapcanvasbridge.h"
2929
#include "qgsvisibilitypresets.h"
3030

3131
#include <QFileDialog>
@@ -254,7 +254,7 @@ bool QgsVectorLayerAndAttributeModel::setData( const QModelIndex &index, const Q
254254
QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers() const
255255
{
256256
QList< QPair<QgsVectorLayer *, int> > layers;
257-
QHash< QgsMapLayer *, int > layerIdx;
257+
QHash< QString, int > layerIdx;
258258

259259
foreach ( const QModelIndex &idx, mCheckedLeafs )
260260
{
@@ -265,9 +265,9 @@ QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers()
265265
{
266266
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( treeLayer->layer() );
267267
Q_ASSERT( vl );
268-
if ( !layerIdx.contains( vl ) )
268+
if ( !layerIdx.contains( vl->id() ) )
269269
{
270-
layerIdx.insert( vl, layers.size() );
270+
layerIdx.insert( vl->id(), layers.size() );
271271
layers << qMakePair<QgsVectorLayer *, int>( vl, mAttributeIdx.value( vl, -1 ) );
272272
}
273273
}
@@ -276,15 +276,16 @@ QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers()
276276
{
277277
QgsVectorLayer *vl = qobject_cast< QgsVectorLayer *>( QgsLayerTree::toLayer( node )->layer() );
278278
Q_ASSERT( vl );
279-
if ( !layerIdx.contains( vl ) )
279+
if ( !layerIdx.contains( vl->id() ) )
280280
{
281-
layerIdx.insert( vl, layers.size() );
281+
layerIdx.insert( vl->id(), layers.size() );
282282
layers << qMakePair<QgsVectorLayer *, int>( vl, mAttributeIdx.value( vl, -1 ) );
283283
}
284284
}
285285
}
286286

287-
QList<QgsMapLayer*> inDrawingOrder = QgisApp::instance()->mapCanvas()->layers();
287+
QgsLayerTreeMapCanvasBridge* bridge = QgisApp::instance()->layerTreeCanvasBridge();
288+
QStringList inDrawingOrder = bridge->hasCustomLayerOrder() ? bridge->customLayerOrder() : bridge->defaultLayerOrder();
288289
QList< QPair<QgsVectorLayer *, int> > layersInROrder;
289290

290291
for ( int i = inDrawingOrder.size() - 1; i >= 0; i-- )

0 commit comments

Comments
 (0)