mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
[FEATURE]: add option to export all lines with minimal width in dxf export
This commit is contained in:
parent
6dc910c1e7
commit
37efb0b7af
@ -1,6 +1,7 @@
|
||||
# The following has been generated automatically from src/core/dxf/qgsdxfexport.h
|
||||
QgsDxfExport.FlagNoMText = QgsDxfExport.Flag.FlagNoMText
|
||||
QgsDxfExport.FlagOnlySelectedFeatures = QgsDxfExport.Flag.FlagOnlySelectedFeatures
|
||||
QgsDxfExport.FlagHairlineWidthExport = QgsDxfExport.Flag.FlagHairlineWidthExport
|
||||
QgsDxfExport.Flags = lambda flags=0: QgsDxfExport.Flag(flags)
|
||||
# monkey patching scoped based enum
|
||||
QgsDxfExport.ExportResult.Success.__doc__ = "Successful export"
|
||||
|
@ -82,6 +82,7 @@ Returns the overridden layer name to be used in the exported DXF.
|
||||
{
|
||||
FlagNoMText,
|
||||
FlagOnlySelectedFeatures,
|
||||
FlagHairlineWidthExport
|
||||
};
|
||||
typedef QFlags<QgsDxfExport::Flag> Flags;
|
||||
|
||||
|
@ -82,6 +82,7 @@ Returns the overridden layer name to be used in the exported DXF.
|
||||
{
|
||||
FlagNoMText,
|
||||
FlagOnlySelectedFeatures,
|
||||
FlagHairlineWidthExport
|
||||
};
|
||||
typedef QFlags<QgsDxfExport::Flag> Flags;
|
||||
|
||||
|
@ -6871,6 +6871,8 @@ void QgisApp::dxfExport()
|
||||
flags = flags | QgsDxfExport::FlagNoMText;
|
||||
if ( d.selectedFeaturesOnly() )
|
||||
flags = flags | QgsDxfExport::FlagOnlySelectedFeatures;
|
||||
if ( d.hairlineWidthExport() )
|
||||
flags = flags | QgsDxfExport::FlagHairlineWidthExport;
|
||||
dxfExport.setFlags( flags );
|
||||
|
||||
if ( auto *lMapCanvas = mapCanvas() )
|
||||
|
@ -804,6 +804,7 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f )
|
||||
mSelectedFeaturesOnly->setChecked( QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfSelectedFeaturesOnly" ), settings.value( QStringLiteral( "qgis/lastDxfSelectedFeaturesOnly" ), "false" ).toString() ) != QLatin1String( "false" ) );
|
||||
mMTextCheckBox->setChecked( QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfUseMText" ), settings.value( QStringLiteral( "qgis/lastDxfUseMText" ), "true" ).toString() ) != QLatin1String( "false" ) );
|
||||
mForce2d->setChecked( QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfForce2d" ), settings.value( QStringLiteral( "qgis/lastDxfForce2d" ), "false" ).toString() ) != QLatin1String( "false" ) );
|
||||
mHairlineWidthExportCheckBox->setChecked( QgsProject::instance()->readEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfHairlineWidthExport" ), settings.value( QStringLiteral( "qgis/lastDxfHairlineWidthExport" ), "false" ).toString() ) != QLatin1String( "false" ) );
|
||||
|
||||
QStringList ids = QgsProject::instance()->mapThemeCollection()->mapThemes();
|
||||
ids.prepend( QString() );
|
||||
@ -1054,6 +1055,11 @@ bool QgsDxfExportDialog::loadSettingsFromXML( QDomDocument &doc, QString &errorM
|
||||
if ( !value.isNull() )
|
||||
mSelectedFeaturesOnly->setChecked( value == true );
|
||||
|
||||
element = dxfElement.namedItem( QStringLiteral( "hairline_width_export" ) ).toElement();
|
||||
value = QgsXmlUtils::readVariant( element.firstChildElement() );
|
||||
if ( !value.isNull() )
|
||||
mHairlineWidthExportCheckBox->setChecked( value == true );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1177,6 +1183,11 @@ void QgsDxfExportDialog::saveSettingsToXML( QDomDocument &doc ) const
|
||||
selectedFeatures.appendChild( QgsXmlUtils::writeVariant( selectedFeaturesOnly(), doc ) );
|
||||
dxfElement.appendChild( selectedFeatures );
|
||||
|
||||
QDomElement hairlineWidthExportElem = domDocument.createElement( QStringLiteral( "hairline_width_export" ) );
|
||||
hairlineWidthExportElem.appendChild( QgsXmlUtils::writeVariant( hairlineWidthExport(), doc ) );
|
||||
dxfElement.appendChild( hairlineWidthExportElem );
|
||||
|
||||
|
||||
doc = domDocument;
|
||||
}
|
||||
|
||||
@ -1252,6 +1263,11 @@ bool QgsDxfExportDialog::useMText() const
|
||||
return mMTextCheckBox->isChecked();
|
||||
}
|
||||
|
||||
bool QgsDxfExportDialog::hairlineWidthExport() const
|
||||
{
|
||||
return mHairlineWidthExportCheckBox->isChecked();
|
||||
}
|
||||
|
||||
void QgsDxfExportDialog::saveSettings()
|
||||
{
|
||||
QgsSettings settings;
|
||||
@ -1266,6 +1282,7 @@ void QgsDxfExportDialog::saveSettings()
|
||||
settings.setValue( QStringLiteral( "qgis/lastDxfCrs" ), QString::number( mCRS.srsid() ) );
|
||||
settings.setValue( QStringLiteral( "qgis/lastDxfUseMText" ), mMTextCheckBox->isChecked() );
|
||||
settings.setValue( QStringLiteral( "qgis/lastDxfForce2d" ), mForce2d->isChecked() );
|
||||
settings.setValue( QStringLiteral( "qgis/lastDxfHairlineWidthExport" ), mHairlineWidthExportCheckBox->isChecked() );
|
||||
|
||||
QgsProject::instance()->writeEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfSymbologyMode" ), mSymbologyModeComboBox->currentIndex() );
|
||||
QgsProject::instance()->writeEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastSymbologyExportScale" ), mScaleWidget->scale() != 0 ? 1.0 / mScaleWidget->scale() : 0 );
|
||||
@ -1277,6 +1294,7 @@ void QgsDxfExportDialog::saveSettings()
|
||||
QgsProject::instance()->writeEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfCrs" ), QString::number( mCRS.srsid() ) );
|
||||
QgsProject::instance()->writeEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfUseMText" ), mMTextCheckBox->isChecked() );
|
||||
QgsProject::instance()->writeEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfForce2d" ), mForce2d->isChecked() );
|
||||
QgsProject::instance()->writeEntry( QStringLiteral( "dxf" ), QStringLiteral( "/lastDxfHairlineWidthExport" ), mHairlineWidthExportCheckBox->isChecked() );
|
||||
|
||||
mModel->saveLayersOutputAttribute( mModel->rootGroup() );
|
||||
}
|
||||
|
@ -119,6 +119,7 @@ class QgsDxfExportDialog : public QDialog, private Ui::QgsDxfExportDialogBase
|
||||
bool layerTitleAsName() const;
|
||||
bool force2d() const;
|
||||
bool useMText() const;
|
||||
bool hairlineWidthExport() const;
|
||||
QString mapTheme() const;
|
||||
QString encoding() const;
|
||||
QgsCoordinateReferenceSystem crs() const;
|
||||
|
@ -1763,6 +1763,11 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext &ctx, const QgsCoordinateT
|
||||
offset = 0.0;
|
||||
}
|
||||
|
||||
if ( mFlags & FlagHairlineWidthExport )
|
||||
{
|
||||
width = 0;
|
||||
}
|
||||
|
||||
QString lineStyleName = QStringLiteral( "CONTINUOUS" );
|
||||
if ( mSymbologyExport != Qgis::FeatureSymbologyExport::NoSymbology )
|
||||
{
|
||||
|
@ -147,6 +147,7 @@ class CORE_EXPORT QgsDxfExport : public QgsLabelSink
|
||||
{
|
||||
FlagNoMText = 1 << 1, //!< Export text as TEXT elements. If not set, text will be exported as MTEXT elements.
|
||||
FlagOnlySelectedFeatures = 1 << 2, //!< Use only selected features for the export.
|
||||
FlagHairlineWidthExport = 1 << 3 //!Export all lines with minimum width and don't fill polygons. Since QGIS 3.38
|
||||
};
|
||||
Q_DECLARE_FLAGS( Flags, Flag )
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QgsFileWidget" name="mFileName"/>
|
||||
<widget class="QgsFileWidget" name="mFileName" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="mSymbologyModeLabel">
|
||||
@ -62,11 +62,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QgsScaleWidget" name="mScaleWidget">
|
||||
<widget class="QgsScaleWidget" name="mScaleWidget" native="true">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="showCurrentScaleButton">
|
||||
<property name="showCurrentScaleButton" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
@ -101,7 +101,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QgsProjectionSelectionWidget" name="mCrsSelector">
|
||||
<widget class="QgsProjectionSelectionWidget" name="mCrsSelector" native="true">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
@ -123,114 +123,121 @@
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="mVisibilityPresets"/>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QWidget" name="mTreeViewContainer">
|
||||
<layout class="QHBoxLayout" name="mTreeViewLayout"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="mSelectAllButton">
|
||||
<property name="text">
|
||||
<string>Select All Layers</string>
|
||||
</property>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QWidget" name="mTreeViewContainer">
|
||||
<layout class="QHBoxLayout" name="mTreeViewLayout"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="mDeselectAllButton">
|
||||
<property name="text">
|
||||
<string>Deselect All Layers</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="mSelectAllButton">
|
||||
<property name="text">
|
||||
<string>Select All Layers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="mDeselectAllButton">
|
||||
<property name="text">
|
||||
<string>Deselect All Layers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="mSelectDataDefinedBlocks">
|
||||
<property name="text">
|
||||
<string>Select Data Defined Blocks</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="mDeselectDataDefinedBlocks">
|
||||
<property name="text">
|
||||
<string>Deselect Data Defined Blocks</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="mSelectDataDefinedBlocks">
|
||||
<property name="text">
|
||||
<string>Select Data Defined Blocks</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="11" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="mMapExtentCheckBox">
|
||||
<property name="text">
|
||||
<string>Export features intersecting the current map extent</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="mLayerTitleAsName">
|
||||
<property name="toolTip">
|
||||
<string>If no attribute is chosen and layer name is not being overridden, prefer layer title (set in layer properties) to layer name.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use layer title as name if set</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="mForce2d">
|
||||
<property name="text">
|
||||
<string>Force 2d output (eg. to support polyline width)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="mMTextCheckBox">
|
||||
<property name="text">
|
||||
<string>Export labels as MTEXT elements</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="mSelectedFeaturesOnly">
|
||||
<property name="text">
|
||||
<string>Use only selected features</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="mHairlineWidthExportCheckBox">
|
||||
<property name="text">
|
||||
<string>Export minimum line width</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="mDeselectDataDefinedBlocks">
|
||||
<property name="text">
|
||||
<string>Deselect Data Defined Blocks</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="11" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="mMapExtentCheckBox">
|
||||
<property name="text">
|
||||
<string>Export features intersecting the current map extent</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="mLayerTitleAsName">
|
||||
<property name="toolTip">
|
||||
<string>If no attribute is chosen and layer name is not being overridden, prefer layer title (set in layer properties) to layer name.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use layer title as name if set</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="mForce2d">
|
||||
<property name="text">
|
||||
<string>Force 2d output (eg. to support polyline width)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="mMTextCheckBox">
|
||||
<property name="text">
|
||||
<string>Export labels as MTEXT elements</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<item row="15" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="mSelectedFeaturesOnly">
|
||||
<property name="text">
|
||||
<string>Use only selected features</string>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="15" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
x
Reference in New Issue
Block a user