mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-27 00:07:16 -05:00
Merge pull request #33162 from m-kuhn/dxf_dash_beautify
DXF export preserve dashed line style
This commit is contained in:
commit
c01f8042f8
@ -24,3 +24,14 @@ QgsDxfExport.HAlign.HFit.__doc__ = "Fit into point = (5) (if VAlign==0)"
|
|||||||
QgsDxfExport.HAlign.Undefined.__doc__ = "Undefined"
|
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__
|
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__ = 'Flags for polylines\n\n.. versionadded:: 3.12\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__
|
||||||
|
# --
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class QgsDxfExport
|
class QgsDxfExport
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -91,6 +92,21 @@ unique value.
|
|||||||
Undefined
|
Undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class DxfPolylineFlag
|
||||||
|
{
|
||||||
|
Closed,
|
||||||
|
Curve,
|
||||||
|
Spline,
|
||||||
|
Is3DPolyline,
|
||||||
|
Is3DPolygonMesh,
|
||||||
|
PolygonMesh,
|
||||||
|
PolyfaceMesh,
|
||||||
|
ContinuousPattern,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef QFlags<QgsDxfExport::DxfPolylineFlag> DxfPolylineFlags;
|
||||||
|
|
||||||
|
|
||||||
QgsDxfExport();
|
QgsDxfExport();
|
||||||
%Docstring
|
%Docstring
|
||||||
Constructor for QgsDxfExport.
|
Constructor for QgsDxfExport.
|
||||||
|
|||||||
@ -1097,7 +1097,17 @@ void QgsDxfExport::writePolyline( const QgsCurve &curve, const QString &layer, c
|
|||||||
writeGroup( color );
|
writeGroup( color );
|
||||||
|
|
||||||
writeGroup( 90, points.size() );
|
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 );
|
writeGroup( 43, width );
|
||||||
|
|
||||||
for ( int i = 0; i < points.size(); i++ )
|
for ( int i = 0; i < points.size(); i++ )
|
||||||
|
|||||||
@ -49,6 +49,7 @@ namespace pal // SIP_SKIP
|
|||||||
class LabelPosition;
|
class LabelPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \ingroup core
|
* \ingroup core
|
||||||
* \class QgsDxfExport
|
* \class QgsDxfExport
|
||||||
@ -142,6 +143,25 @@ class CORE_EXPORT QgsDxfExport
|
|||||||
Undefined = 9999 //!< Undefined
|
Undefined = 9999 //!< Undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flags for polylines
|
||||||
|
*
|
||||||
|
* \since QGIS 3.12
|
||||||
|
*/
|
||||||
|
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.
|
* Constructor for QgsDxfExport.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -742,7 +742,8 @@ void TestQgsDxfExport::testCurveExport()
|
|||||||
QCOMPARE( d.writeToFile( &dxfFile, QStringLiteral( "CP1252" ) ), QgsDxfExport::ExportResult::Success );
|
QCOMPARE( d.writeToFile( &dxfFile, QStringLiteral( "CP1252" ) ), QgsDxfExport::ExportResult::Success );
|
||||||
dxfFile.close();
|
dxfFile.close();
|
||||||
|
|
||||||
QVERIFY( fileContainsText( file, dxfText ) );
|
QString debugInfo;
|
||||||
|
QVERIFY2( fileContainsText( file, dxfText, &debugInfo ), debugInfo.toUtf8().constData() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsDxfExport::testCurveExport_data()
|
void TestQgsDxfExport::testCurveExport_data()
|
||||||
@ -775,7 +776,7 @@ void TestQgsDxfExport::testCurveExport_data()
|
|||||||
" 90\n"
|
" 90\n"
|
||||||
" 2\n"
|
" 2\n"
|
||||||
" 70\n"
|
" 70\n"
|
||||||
" 2\n"
|
" 130\n"
|
||||||
" 43\n"
|
" 43\n"
|
||||||
"-1.0\n"
|
"-1.0\n"
|
||||||
" 10\n"
|
" 10\n"
|
||||||
@ -815,7 +816,7 @@ void TestQgsDxfExport::testCurveExport_data()
|
|||||||
" 90\n"
|
" 90\n"
|
||||||
" 5\n"
|
" 5\n"
|
||||||
" 70\n"
|
" 70\n"
|
||||||
" 3\n"
|
" 131\n"
|
||||||
" 43\n"
|
" 43\n"
|
||||||
"-1.0\n"
|
"-1.0\n"
|
||||||
" 10\n"
|
" 10\n"
|
||||||
@ -934,7 +935,7 @@ void TestQgsDxfExport::testDashedLine()
|
|||||||
" 90\n"
|
" 90\n"
|
||||||
" 6\n"
|
" 6\n"
|
||||||
" 70\n"
|
" 70\n"
|
||||||
" 0\n"
|
" 128\n"
|
||||||
" 43\n"
|
" 43\n"
|
||||||
"0.11\n"
|
"0.11\n"
|
||||||
" 10\n"
|
" 10\n"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user