Skip to content
Permalink
Browse files

dxf export: allow forcing to 2d to support polyline width (fixes #17049)

(backported from commit 12e69d0)
  • Loading branch information
jef-n committed Aug 29, 2017
1 parent c550e82 commit 238a119f57ec2f1ac6c10ea91466dbb609cadd2b
@@ -129,6 +129,20 @@ class QgsDxfExport
*/
bool layerTitleAsName();

/**
* Force 2d output (eg. to support linewidth in polylines)
* \param force2d flag
* \see force2d
*/
void setForce2d( bool force2d );

/**
* Retrieve whether the output should be forced to 2d
* \returns flag
* \see setForce2d
*/
bool force2d();

/**
* Get DXF palette index of nearest entry for given color
* @param color
@@ -5116,6 +5116,7 @@ void QgisApp::dxfExport()
dxfExport.setSymbologyExport( d.symbologyMode() );
dxfExport.setLayerTitleAsName( d.layerTitleAsName() );
dxfExport.setDestinationCrs( d.crs() );
dxfExport.setForce2d( d.force2d() );
if ( mapCanvas() )
{
dxfExport.setMapUnits( mapCanvas()->mapUnits() );
@@ -52,7 +52,6 @@ QWidget *FieldSelectorDelegate::createEditor( QWidget *parent, const QStyleOptio
if ( !vl )
return nullptr;


QgsFieldComboBox *w = new QgsFieldComboBox( parent );
w->setLayer( vl );
return w;
@@ -603,6 +602,11 @@ bool QgsDxfExportDialog::layerTitleAsName() const
return mLayerTitleAsName->isChecked();
}

bool QgsDxfExportDialog::force2d() const
{
return mForce2d->isChecked();
}

void QgsDxfExportDialog::saveSettings()
{
QSettings s;
@@ -87,6 +87,7 @@ class QgsDxfExportDialog : public QDialog, private Ui::QgsDxfExportDialogBase
QString saveFile() const;
bool exportMapExtent() const;
bool layerTitleAsName() const;
bool force2d() const;
QString mapTheme() const;
QString encoding() const;
long crs() const;
@@ -373,6 +373,7 @@ QgsDxfExport::QgsDxfExport()
, mNextHandleId( DXF_HANDSEED )
, mBlockCounter( 0 )
, mCrs( -1 )
, mForce2d( false )
{
}

@@ -444,15 +445,15 @@ void QgsDxfExport::writeGroup( int code, const QgsPoint &p, double z, bool skipz
{
writeGroup( code + 10, p.x() );
writeGroup( code + 20, p.y() );
if ( !skipz )
if ( !mForce2d && !skipz )
writeGroup( code + 30, z );
}

void QgsDxfExport::writeGroup( int code, const QgsPointV2 &p )
{
writeGroup( code + 10, p.x() );
writeGroup( code + 20, p.y() );
if ( p.is3D() && qIsFinite( p.z() ) )
if ( !mForce2d && p.is3D() && qIsFinite( p.z() ) )
writeGroup( code + 30, p.z() );
}

@@ -3472,7 +3473,7 @@ void QgsDxfExport::writePolyline( const QgsPointSequenceV2 &line, const QString&
return;
}

if ( !line.at( 0 ).is3D() )
if ( mForce2d || !line.at( 0 ).is3D() )
{
writeGroup( 0, "LWPOLYLINE" );
writeHandle();
@@ -153,6 +153,20 @@ class CORE_EXPORT QgsDxfExport
*/
bool layerTitleAsName() { return mLayerTitleAsName; }

/**
* Force 2d output (eg. to support linewidth in polylines)
* \param force2d flag
* \see force2d
*/
void setForce2d( bool force2d ) { mForce2d = force2d; }

/**
* Retrieve whether the output should be forced to 2d
* \returns flag
* \see setForce2d
*/
bool force2d() { return mForce2d; }

/**
* Get DXF palette index of nearest entry for given color
* @param color
@@ -465,6 +479,7 @@ class CORE_EXPORT QgsDxfExport
QgsMapSettings mMapSettings;
QHash<QString, int> mLayerNameAttribute;
double mFactor;
bool mForce2d;
};

#endif // QGSDXFEXPORT_H
@@ -14,6 +14,13 @@
<string>DXF export</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QLabel" name="mSymbologyScaleLabel">
<property name="text">
<string>Symbology scale</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="mFileSelectionButton">
<property name="text">
@@ -54,13 +61,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mSymbologyScaleLabel">
<property name="text">
<string>Symbology scale</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="QgsLayerTreeView" name="mTreeView">
<property name="selectionMode">
@@ -122,7 +122,7 @@
</property>
</widget>
</item>
<item row="12" column="0" colspan="3">
<item row="13" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -170,6 +170,13 @@
</property>
</widget>
</item>
<item row="12" column="0" colspan="3">
<widget class="QCheckBox" name="mForce2d">
<property name="text">
<string>Force 2d output (eg. to support polyline width)</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
@@ -195,12 +202,14 @@
<tabstop>mFileSelectionButton</tabstop>
<tabstop>mSymbologyModeComboBox</tabstop>
<tabstop>mEncoding</tabstop>
<tabstop>mScaleWidget</tabstop>
<tabstop>mVisibilityPresets</tabstop>
<tabstop>mTreeView</tabstop>
<tabstop>mSelectAllButton</tabstop>
<tabstop>mUnSelectAllButton</tabstop>
<tabstop>mLayerTitleAsName</tabstop>
<tabstop>mMapExtentCheckBox</tabstop>
<tabstop>mForce2d</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>

0 comments on commit 238a119

Please sign in to comment.
You can’t perform that action at this time.