Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
jef-n committed Jun 30, 2015
1 parent 6a7b6da commit 1076f70
Show file tree
Hide file tree
Showing 11 changed files with 329 additions and 283 deletions.
20 changes: 17 additions & 3 deletions python/core/dxf/qgsdxfexport.sip
Expand Up @@ -63,31 +63,45 @@ class QgsDxfExport
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 );

//! Write handle
int writeHandle( int code = 5, int handle = 0 );

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

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

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

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

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

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

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

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

//! Write mtext (MTEXT)
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 );

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

//! return DXF encoding for Qt encoding
static QString dxfEncoding( const QString &name );

//! return list of available DXF encodings
static QStringList encodings();
};
4 changes: 4 additions & 0 deletions python/core/symbology-ng/qgssvgcache.sip
Expand Up @@ -87,6 +87,10 @@ class QgsSvgCache : QObject
/**Get image data*/
QByteArray getImageData( const QString &path ) const;

/**Get SVG content*/
const QByteArray& svgContent( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
double widthScaleFactor, double rasterScaleFactor );

signals:
/** Emit a signal to be caught by qgisapp and display a msg on status bar */
void statusChanged( const QString& theStatusQString );
Expand Down
15 changes: 8 additions & 7 deletions src/app/qgsdxfexportdialog.cpp
Expand Up @@ -25,7 +25,7 @@
#include "qgis.h"
#include "qgsfieldcombobox.h"
#include "qgisapp.h"
#include "qgsmapcanvas.h"
#include "qgslayertreemapcanvasbridge.h"
#include "qgsvisibilitypresets.h"

#include <QFileDialog>
Expand Down Expand Up @@ -254,7 +254,7 @@ bool QgsVectorLayerAndAttributeModel::setData( const QModelIndex &index, const Q
QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers() const
{
QList< QPair<QgsVectorLayer *, int> > layers;
QHash< QgsMapLayer *, int > layerIdx;
QHash< QString, int > layerIdx;

foreach ( const QModelIndex &idx, mCheckedLeafs )
{
Expand All @@ -265,9 +265,9 @@ QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers()
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( treeLayer->layer() );
Q_ASSERT( vl );
if ( !layerIdx.contains( vl ) )
if ( !layerIdx.contains( vl->id() ) )
{
layerIdx.insert( vl, layers.size() );
layerIdx.insert( vl->id(), layers.size() );
layers << qMakePair<QgsVectorLayer *, int>( vl, mAttributeIdx.value( vl, -1 ) );
}
}
Expand All @@ -276,15 +276,16 @@ QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers()
{
QgsVectorLayer *vl = qobject_cast< QgsVectorLayer *>( QgsLayerTree::toLayer( node )->layer() );
Q_ASSERT( vl );
if ( !layerIdx.contains( vl ) )
if ( !layerIdx.contains( vl->id() ) )
{
layerIdx.insert( vl, layers.size() );
layerIdx.insert( vl->id(), layers.size() );
layers << qMakePair<QgsVectorLayer *, int>( vl, mAttributeIdx.value( vl, -1 ) );
}
}
}

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

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

0 comments on commit 1076f70

Please sign in to comment.