Skip to content

Commit

Permalink
Merge pull request qgis#57016 from gacarrillor/dxf_overridden_name
Browse files Browse the repository at this point in the history
[dxf] Allow users to override the layer name to be exported to DXF
  • Loading branch information
nirvn committed Apr 19, 2024
2 parents 220abf7 + 82fb6cc commit d9677bc
Show file tree
Hide file tree
Showing 15 changed files with 427 additions and 114 deletions.
9 changes: 8 additions & 1 deletion python/PyQt6/core/auto_generated/dxf/qgsdxfexport.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Exports QGIS layers to the DXF format.

struct DxfLayer
{
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1, bool buildDDBlocks = true, int ddBlocksMaxNumberOfClasses = -1 );
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1, bool buildDDBlocks = true, int ddBlocksMaxNumberOfClasses = -1, QString overriddenName = QString() );

QgsVectorLayer *layer() const;
%Docstring
Expand Down Expand Up @@ -66,6 +66,13 @@ Returns the maximum number of data defined symbol classes for which blocks are c

:return:

.. versionadded:: 3.38
%End

QString overriddenName() const;
%Docstring
Returns the overridden layer name to be used in the exported DXF.

.. versionadded:: 3.38
%End

Expand Down
9 changes: 8 additions & 1 deletion python/core/auto_generated/dxf/qgsdxfexport.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Exports QGIS layers to the DXF format.

struct DxfLayer
{
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1, bool buildDDBlocks = true, int ddBlocksMaxNumberOfClasses = -1 );
DxfLayer( QgsVectorLayer *vl, int layerOutputAttributeIndex = -1, bool buildDDBlocks = true, int ddBlocksMaxNumberOfClasses = -1, QString overriddenName = QString() );

QgsVectorLayer *layer() const;
%Docstring
Expand Down Expand Up @@ -66,6 +66,13 @@ Returns the maximum number of data defined symbol classes for which blocks are c

:return:

.. versionadded:: 3.38
%End

QString overriddenName() const;
%Docstring
Returns the overridden layer name to be used in the exported DXF.

.. versionadded:: 3.38
%End

Expand Down
7 changes: 5 additions & 2 deletions src/analysis/processing/qgsalgorithmdxfexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ QString QgsDxfExportAlgorithm::groupId() const

QString QgsDxfExportAlgorithm::shortHelpString() const
{
return QObject::tr( "Exports layers to DXF file. For each layer, you can choose a field whose values are used to split features in generated destination layers in the DXF output." );
return QObject::tr( "Exports layers to DXF file. For each layer, you can choose a field whose values are used to split features in generated destination layers in the DXF output.\n\n"
"If no field is chosen, you can still override the output layer name by directly entering a new output layer name in the Configure Layer panel or by preferring layer title (set in layer properties) to layer name." );
}

QgsDxfExportAlgorithm *QgsDxfExportAlgorithm::createInstance() const
Expand All @@ -70,7 +71,9 @@ void QgsDxfExportAlgorithm::initAlgorithm( const QVariantMap & )
extentParam->setHelp( QObject::tr( "Limit exported features to those with geometries intersecting the provided extent" ) );
addParameter( extentParam.release() );
addParameter( new QgsProcessingParameterBoolean( QStringLiteral( "SELECTED_FEATURES_ONLY" ), QObject::tr( "Use only selected features" ), false ) );
addParameter( new QgsProcessingParameterBoolean( QStringLiteral( "USE_LAYER_TITLE" ), QObject::tr( "Use layer title as name" ), false ) );
std::unique_ptr<QgsProcessingParameterBoolean> useTitleParam = std::make_unique<QgsProcessingParameterBoolean>( QStringLiteral( "USE_LAYER_TITLE" ), QObject::tr( "Use layer title as name" ), false );
useTitleParam->setHelp( QObject::tr( "If no attribute is chosen and layer name is not being overridden, prefer layer title (set in layer properties) to layer name" ) );
addParameter( useTitleParam.release() );
addParameter( new QgsProcessingParameterBoolean( QStringLiteral( "FORCE_2D" ), QObject::tr( "Force 2D output" ), false ) );
addParameter( new QgsProcessingParameterBoolean( QStringLiteral( "MTEXT" ), QObject::tr( "Export labels as MTEXT elements" ), true ) );
addParameter( new QgsProcessingParameterFileDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "DXF" ), QObject::tr( "DXF Files" ) + " (*.dxf *.DXF)" ) );
Expand Down
Loading

0 comments on commit d9677bc

Please sign in to comment.