Skip to content

Commit

Permalink
DXF export preserve dashed line style
Browse files Browse the repository at this point in the history
We do not (yet) support an option to guarantee stroked parts at corners.
So also do not set this flag in the DXF export.
  • Loading branch information
m-kuhn committed Nov 29, 2019
1 parent 23fb486 commit f81b680
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
11 changes: 11 additions & 0 deletions python/core/auto_additions/qgsdxfexport.py
Expand Up @@ -24,3 +24,14 @@
QgsDxfExport.HAlign.Undefined.__doc__ = "Undefined"
QgsDxfExport.HAlign.__doc__ = 'Horizontal alignments.\n\n' + '* ``HLeft``: ' + QgsDxfExport.HAlign.HLeft.__doc__ + '\n' + '* ``HCenter``: ' + QgsDxfExport.HAlign.HCenter.__doc__ + '\n' + '* ``HRight``: ' + QgsDxfExport.HAlign.HRight.__doc__ + '\n' + '* ``HAligned``: ' + QgsDxfExport.HAlign.HAligned.__doc__ + '\n' + '* ``HMiddle``: ' + QgsDxfExport.HAlign.HMiddle.__doc__ + '\n' + '* ``HFit``: ' + QgsDxfExport.HAlign.HFit.__doc__ + '\n' + '* ``Undefined``: ' + QgsDxfExport.HAlign.Undefined.__doc__
# --
# monkey patching scoped based enum
QgsDxfExport.DxfPolylineFlag.Closed.__doc__ = "This is a closed polyline (or a polygon mesh closed in the M direction)"
QgsDxfExport.DxfPolylineFlag.Curve.__doc__ = "Curve-fit vertices have been added"
QgsDxfExport.DxfPolylineFlag.Spline.__doc__ = ""
QgsDxfExport.DxfPolylineFlag.Is3DPolyline.__doc__ = "This is a 3D polyline"
QgsDxfExport.DxfPolylineFlag.Is3DPolygonMesh.__doc__ = "This is a 3D polygon mesh"
QgsDxfExport.DxfPolylineFlag.PolygonMesh.__doc__ = "The polygon mesh is closed in the N direction"
QgsDxfExport.DxfPolylineFlag.PolyfaceMesh.__doc__ = "The polyline is a polyface mesh"
QgsDxfExport.DxfPolylineFlag.ContinuousPattern.__doc__ = "The linetype pattern is generated continuously around the vertices of this polyline"
QgsDxfExport.DxfPolylineFlag.__doc__ = '\n\n' + '* ``Closed``: ' + QgsDxfExport.DxfPolylineFlag.Closed.__doc__ + '\n' + '* ``Curve``: ' + QgsDxfExport.DxfPolylineFlag.Curve.__doc__ + '\n' + '* ``Spline``: ' + QgsDxfExport.DxfPolylineFlag.Spline.__doc__ + '\n' + '* ``Is3DPolyline``: ' + QgsDxfExport.DxfPolylineFlag.Is3DPolyline.__doc__ + '\n' + '* ``Is3DPolygonMesh``: ' + QgsDxfExport.DxfPolylineFlag.Is3DPolygonMesh.__doc__ + '\n' + '* ``PolygonMesh``: ' + QgsDxfExport.DxfPolylineFlag.PolygonMesh.__doc__ + '\n' + '* ``PolyfaceMesh``: ' + QgsDxfExport.DxfPolylineFlag.PolyfaceMesh.__doc__ + '\n' + '* ``ContinuousPattern``: ' + QgsDxfExport.DxfPolylineFlag.ContinuousPattern.__doc__
# --
16 changes: 16 additions & 0 deletions python/core/auto_generated/dxf/qgsdxfexport.sip.in
Expand Up @@ -13,6 +13,7 @@




class QgsDxfExport
{

Expand Down Expand Up @@ -91,6 +92,21 @@ unique value.
Undefined
};

enum class DxfPolylineFlag
{
Closed,
Curve,
Spline,
Is3DPolyline,
Is3DPolygonMesh,
PolygonMesh,
PolyfaceMesh,
ContinuousPattern,
};

typedef QFlags<QgsDxfExport::DxfPolylineFlag> DxfPolylineFlags;


QgsDxfExport();
%Docstring
Constructor for QgsDxfExport.
Expand Down
12 changes: 11 additions & 1 deletion src/core/dxf/qgsdxfexport.cpp
Expand Up @@ -1097,7 +1097,17 @@ void QgsDxfExport::writePolyline( const QgsCurve &curve, const QString &layer, c
writeGroup( color );

writeGroup( 90, points.size() );
writeGroup( 70, ( curve.isClosed() ? 1 : 0 ) | ( curve.hasCurvedSegments() ? 2 : 0 ) );
QgsDxfExport::DxfPolylineFlags polylineFlags;
if ( curve.isClosed() )
polylineFlags.setFlag( QgsDxfExport::DxfPolylineFlag::Closed );
if ( curve.hasCurvedSegments() )
polylineFlags.setFlag( QgsDxfExport::DxfPolylineFlag::Curve );

// Might need to conditional once this feature is implemented
// https://github.com/qgis/QGIS/issues/32468
polylineFlags.setFlag( QgsDxfExport::DxfPolylineFlag::ContinuousPattern );

writeGroup( 70, static_cast<int>( polylineFlags ) );
writeGroup( 43, width );

for ( int i = 0; i < points.size(); i++ )
Expand Down
15 changes: 15 additions & 0 deletions src/core/dxf/qgsdxfexport.h
Expand Up @@ -49,6 +49,7 @@ namespace pal // SIP_SKIP
class LabelPosition;
}


/**
* \ingroup core
* \class QgsDxfExport
Expand Down Expand Up @@ -142,6 +143,20 @@ class CORE_EXPORT QgsDxfExport
Undefined = 9999 //!< Undefined
};

enum class DxfPolylineFlag : int
{
Closed = 1, //!< This is a closed polyline (or a polygon mesh closed in the M direction)
Curve = 2, //!< Curve-fit vertices have been added
Spline = 4, //! < Spline-fit vertices have been added
Is3DPolyline = 8, //!< This is a 3D polyline
Is3DPolygonMesh = 16, //!< This is a 3D polygon mesh
PolygonMesh = 32, //!< The polygon mesh is closed in the N direction
PolyfaceMesh = 64, //!< The polyline is a polyface mesh
ContinuousPattern = 128, //!< The linetype pattern is generated continuously around the vertices of this polyline
};

Q_DECLARE_FLAGS( DxfPolylineFlags, DxfPolylineFlag )

/**
* Constructor for QgsDxfExport.
*/
Expand Down

0 comments on commit f81b680

Please sign in to comment.