QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
Exports QGIS layers to the DXF format. More...
#include <qgsdxfexport.h>
Classes | |
struct | DxfLayer |
Layers and optional attribute index to split into multiple layers using attribute value as layer name. More... | |
Public Types | |
enum | DxfPolylineFlag { Closed = 1 , Curve = 2 , Spline = 4 , Is3DPolyline = 8 , Is3DPolygonMesh = 16 , PolygonMesh = 32 , PolyfaceMesh = 64 , ContinuousPattern = 128 } |
Flags for polylines. More... | |
typedef QFlags< DxfPolylineFlag > | DxfPolylineFlags |
enum class | ExportResult { Success = 0 , InvalidDeviceError , DeviceNotWritableError , EmptyExtentError } |
The result of an export as dxf operation. More... | |
enum | Flag { FlagNoMText = 1 << 1 , FlagOnlySelectedFeatures = 1 << 2 , FlagHairlineWidthExport = 1 << 3 } |
Export flags. More... | |
typedef QFlags< Flag > | Flags |
enum class | HAlign : int { HLeft = 0 , HCenter = 1 , HRight = 2 , HAligned = 3 , HMiddle = 4 , HFit = 5 , Undefined = 9999 } |
Horizontal alignments. More... | |
enum class | VAlign : int { VBaseLine = 0 , VBottom = 1 , VMiddle = 2 , VTop = 3 , Undefined = 9999 } |
Vertical alignments. More... | |
Public Member Functions | |
QgsDxfExport () | |
Constructor for QgsDxfExport. | |
~QgsDxfExport () override | |
void | addLayers (const QList< QgsDxfExport::DxfLayer > &layers) |
Add layers to export. | |
void | clipValueToMapUnitScale (double &value, const QgsMapUnitScale &scale, double pixelToMMFactor) const |
Clips value to scale minimum/maximum. | |
QgsCoordinateReferenceSystem | destinationCrs () const |
Returns the destination CRS, or an invalid CRS if no reprojection will be done. | |
void | drawLabel (const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings) override |
Add a label to the dxf output. | |
QgsRectangle | extent () const |
Gets extent of area to export. | |
const QString | feedbackMessage () const |
Returns any feedback message produced while export to dxf file. | |
QgsDxfExport::Flags | flags () const |
Returns the export flags. | |
bool | force2d () |
Retrieve whether the output should be forced to 2d. | |
QString | layerName (const QString &id, const QgsFeature &f) const |
Gets layer name for feature. | |
QString | layerName (QgsVectorLayer *vl) const |
Gets name for layer respecting the use layer title as layer name mode. | |
bool | layerTitleAsName () |
Retrieve whether layer title (where set) instead of name shall be use. | |
Qgis::DistanceUnit | mapUnits () const |
Retrieve map units. | |
Q_DECL_DEPRECATED void | registerDxfLayer (const QString &layerId, QgsFeatureId fid, const QString &layer) |
Register name of layer for feature. | |
void | setDestinationCrs (const QgsCoordinateReferenceSystem &crs) |
Set destination CRS. | |
void | setExtent (const QgsRectangle &r) |
Set extent of area to export. | |
void | setFlags (QgsDxfExport::Flags flags) |
Sets the export flags. | |
void | setForce2d (bool force2d) |
Force 2d output (eg. | |
void | setLayerTitleAsName (bool layerTitleAsName) |
Enable use of title (where set) instead of layer name, when attribute index of corresponding layer index is -1. | |
void | setMapSettings (const QgsMapSettings &settings) |
Set map settings and assign layer name attributes. | |
void | setSymbologyExport (Qgis::FeatureSymbologyExport e) |
Set symbology export mode. | |
void | setSymbologyScale (double scale) |
Set reference scale for output. | |
Qgis::FeatureSymbologyExport | symbologyExport () const |
Gets symbology export mode. | |
double | symbologyScale () const |
Returns the reference scale for output. | |
void | writeCircle (const QString &layer, const QColor &color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width) |
Write circle (as polyline) | |
void | writeDouble (double d) |
Write a floating point value. | |
void | writeFilledCircle (const QString &layer, const QColor &color, const QgsPoint &pt, double radius) |
Write filled circle (as hatch) | |
void | writeGroup (const QColor &color, int exactMatch=62, int rgbCode=420, int transparencyCode=440) |
Write a group code with color value. | |
void | writeGroup (int code, const QgsPoint &p) |
Write a group code with a point. | |
void | writeGroup (int code, const QString &s) |
Write a group code with a string value. | |
void | writeGroup (int code, double d) |
Write a group code with a floating point value. | |
void | writeGroup (int code, int i) |
Write a tuple of group code and integer value. | |
void | writeGroup (int code, long long i) |
Write a tuple of group code and long value. | |
void | writeGroupCode (int code) |
Write a group code. | |
int | writeHandle (int code=5, int handle=0) |
Write a tuple of group code and a handle. | |
void | writeInt (int i) |
Write an integer value. | |
void | writeLine (const QgsPoint &pt1, const QgsPoint &pt2, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1) |
Write line (as a polyline) | |
void | writeMText (const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, const QColor &color) |
Write mtext (MTEXT) | |
void | writePoint (const QString &layer, const QColor &color, const QgsPoint &pt) |
Write point. | |
void | writePolygon (const QgsCurvePolygon &polygon, const QString &layer, const QString &hatchPattern, const QColor &color) |
Draw dxf curved filled polygon (HATCH) | |
void | writePolygon (const QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color) |
Draw dxf filled polygon (HATCH) | |
void | writePolyline (const QgsCurve &curve, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1) |
Draw dxf primitives (LWPOLYLINE) | |
void | writePolyline (const QgsPointSequence &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1) |
Draw dxf primitives (LWPOLYLINE) | |
void | writeString (const QString &s) |
Write a string value. | |
void | writeText (const QString &layer, const QString &text, const QgsPoint &pt, double size, double angle, const QColor &color, QgsDxfExport::HAlign hali=QgsDxfExport::HAlign::Undefined, QgsDxfExport::VAlign vali=QgsDxfExport::VAlign::Undefined) |
Write text (TEXT) | |
ExportResult | writeToFile (QIODevice *d, const QString &codec) |
Export to a dxf file in the given encoding. | |
Public Member Functions inherited from QgsLabelSink | |
virtual | ~QgsLabelSink ()=default |
virtual void | drawUnplacedLabel (const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings) |
The drawLabel method is called for each unplaced label. | |
Static Public Member Functions | |
static int | closestColorMatch (QRgb color) |
Gets DXF palette index of nearest entry for given color. | |
static QString | dxfEncoding (const QString &name) |
Returns DXF encoding for Qt encoding. | |
static QString | dxfLayerName (const QString &name) |
Returns cleaned layer name for use in DXF. | |
static QStringList | encodings () |
Returns list of available DXF encodings. | |
static double | mapUnitScaleFactor (double scale, Qgis::RenderUnit symbolUnits, Qgis::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0) |
Returns scale factor for conversion to map units. | |
Exports QGIS layers to the DXF format.
Definition at line 68 of file qgsdxfexport.h.
typedef QFlags< DxfPolylineFlag > QgsDxfExport::DxfPolylineFlags |
Definition at line 208 of file qgsdxfexport.h.
typedef QFlags< Flag > QgsDxfExport::Flags |
Definition at line 152 of file qgsdxfexport.h.
Flags for polylines.
Definition at line 196 of file qgsdxfexport.h.
|
strong |
The result of an export as dxf operation.
Definition at line 159 of file qgsdxfexport.h.
enum QgsDxfExport::Flag |
Export flags.
Enumerator | |
---|---|
FlagNoMText | Export text as TEXT elements. If not set, text will be exported as MTEXT elements. |
FlagOnlySelectedFeatures | Use only selected features for the export. |
FlagHairlineWidthExport |
Definition at line 146 of file qgsdxfexport.h.
|
strong |
Horizontal alignments.
Enumerator | |
---|---|
HLeft | Left (0) |
HCenter | Centered (1) |
HRight | Right (2) |
HAligned | Aligned = (3) (if VAlign==0) |
HMiddle | Middle = (4) (if VAlign==0) |
HFit | Fit into point = (5) (if VAlign==0) |
Undefined | Undefined. |
Definition at line 180 of file qgsdxfexport.h.
|
strong |
Vertical alignments.
Enumerator | |
---|---|
VBaseLine | Top (0) |
VBottom | Bottom (1) |
VMiddle | Middle (2) |
VTop | Top (3) |
Undefined | Undefined. |
Definition at line 170 of file qgsdxfexport.h.
|
default |
Constructor for QgsDxfExport.
|
override |
Definition at line 68 of file qgsdxfexport.cpp.
void QgsDxfExport::addLayers | ( | const QList< QgsDxfExport::DxfLayer > & | layers | ) |
Add layers to export.
layers | list of layers and corresponding attribute indexes that determine the layer name (-1 for original layer name or title) |
Definition at line 88 of file qgsdxfexport.cpp.
void QgsDxfExport::clipValueToMapUnitScale | ( | double & | value, |
const QgsMapUnitScale & | scale, | ||
double | pixelToMMFactor | ||
) | const |
Clips value to scale minimum/maximum.
value | the value to clip |
scale | the scale dependent minimum/maximum values |
pixelToMMFactor | pixels per mm |
Definition at line 2020 of file qgsdxfexport.cpp.
|
static |
Gets DXF palette index of nearest entry for given color.
color |
Definition at line 1953 of file qgsdxfexport.cpp.
QgsCoordinateReferenceSystem QgsDxfExport::destinationCrs | ( | ) | const |
Returns the destination CRS, or an invalid CRS if no reprojection will be done.
Definition at line 2583 of file qgsdxfexport.cpp.
|
overridevirtual |
Add a label to the dxf output.
Implements QgsLabelSink.
Definition at line 2413 of file qgsdxfexport.cpp.
|
static |
Returns DXF encoding for Qt encoding.
Definition at line 2355 of file qgsdxfexport.cpp.
|
static |
Returns cleaned layer name for use in DXF.
Definition at line 2293 of file qgsdxfexport.cpp.
|
static |
Returns list of available DXF encodings.
Definition at line 2376 of file qgsdxfexport.cpp.
|
inline |
Gets extent of area to export.
Definition at line 312 of file qgsdxfexport.h.
|
inline |
Returns any feedback message produced while export to dxf file.
Definition at line 254 of file qgsdxfexport.h.
QgsDxfExport::Flags QgsDxfExport::flags | ( | ) | const |
|
inline |
Retrieve whether the output should be forced to 2d.
Definition at line 341 of file qgsdxfexport.h.
QString QgsDxfExport::layerName | ( | const QString & | id, |
const QgsFeature & | f | ||
) | const |
Gets layer name for feature.
id | layer id of layer |
f | feature of layer |
Definition at line 2339 of file qgsdxfexport.cpp.
QString QgsDxfExport::layerName | ( | QgsVectorLayer * | vl | ) | const |
Gets name for layer respecting the use layer title as layer name mode.
vl | the vector layer |
Definition at line 2396 of file qgsdxfexport.cpp.
|
inline |
Retrieve whether layer title (where set) instead of name shall be use.
Definition at line 327 of file qgsdxfexport.h.
Qgis::DistanceUnit QgsDxfExport::mapUnits | ( | ) | const |
|
static |
Returns scale factor for conversion to map units.
scale | the map scale denominator |
symbolUnits | the symbol output units |
mapUnits | the map units |
mapUnitsPerPixel | Map units per pixel |
Definition at line 2003 of file qgsdxfexport.cpp.
void QgsDxfExport::registerDxfLayer | ( | const QString & | layerId, |
QgsFeatureId | fid, | ||
const QString & | layer | ||
) |
Register name of layer for feature.
layerId | id of layer |
fid | id of feature |
layer | dxf layer of feature |
Definition at line 2569 of file qgsdxfexport.cpp.
void QgsDxfExport::setDestinationCrs | ( | const QgsCoordinateReferenceSystem & | crs | ) |
|
inline |
Set extent of area to export.
r | area to export |
Definition at line 305 of file qgsdxfexport.h.
void QgsDxfExport::setFlags | ( | QgsDxfExport::Flags | flags | ) |
|
inline |
Force 2d output (eg.
to support linewidth in polylines)
force2d | flag |
Definition at line 334 of file qgsdxfexport.h.
|
inline |
Enable use of title (where set) instead of layer name, when attribute index of corresponding layer index is -1.
layerTitleAsName | flag |
Definition at line 320 of file qgsdxfexport.h.
void QgsDxfExport::setMapSettings | ( | const QgsMapSettings & | settings | ) |
Set map settings and assign layer name attributes.
settings | map settings to apply |
Definition at line 73 of file qgsdxfexport.cpp.
|
inline |
|
inline |
Set reference scale for output.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
Definition at line 261 of file qgsdxfexport.h.
|
inline |
Gets symbology export mode.
Definition at line 299 of file qgsdxfexport.h.
|
inline |
Returns the reference scale for output.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
Definition at line 268 of file qgsdxfexport.h.
void QgsDxfExport::writeCircle | ( | const QString & | layer, |
const QColor & | color, | ||
const QgsPoint & | pt, | ||
double | radius, | ||
const QString & | lineStyleName, | ||
double | width | ||
) |
Write circle (as polyline)
Definition at line 1636 of file qgsdxfexport.cpp.
void QgsDxfExport::writeDouble | ( | double | d | ) |
Write a floating point value.
d | floating point value |
Definition at line 184 of file qgsdxfexport.cpp.
void QgsDxfExport::writeFilledCircle | ( | const QString & | layer, |
const QColor & | color, | ||
const QgsPoint & | pt, | ||
double | radius | ||
) |
Write filled circle (as hatch)
Definition at line 1599 of file qgsdxfexport.cpp.
void QgsDxfExport::writeGroup | ( | const QColor & | color, |
int | exactMatch = 62 , |
||
int | rgbCode = 420 , |
||
int | transparencyCode = 440 |
||
) |
Write a group code with color value.
color | color |
exactMatch | group code to use if the color has an exact match in the dxf palette |
rgbCode | group code to use if the color doesn't have an exact match or has a transparency component |
transparencyCode | group code to use for transparency component |
Definition at line 145 of file qgsdxfexport.cpp.
void QgsDxfExport::writeGroup | ( | int | code, |
const QgsPoint & | p | ||
) |
Write a group code with a point.
code | group code |
p | point value |
Definition at line 137 of file qgsdxfexport.cpp.
void QgsDxfExport::writeGroup | ( | int | code, |
const QString & | s | ||
) |
Write a group code with a string value.
code | group code |
s | string value |
Definition at line 131 of file qgsdxfexport.cpp.
void QgsDxfExport::writeGroup | ( | int | code, |
double | d | ||
) |
Write a group code with a floating point value.
code | group code |
d | floating point value |
Definition at line 125 of file qgsdxfexport.cpp.
void QgsDxfExport::writeGroup | ( | int | code, |
int | i | ||
) |
Write a tuple of group code and integer value.
code | group code |
i | integer value |
Definition at line 113 of file qgsdxfexport.cpp.
void QgsDxfExport::writeGroup | ( | int | code, |
long long | i | ||
) |
Write a tuple of group code and long value.
code | group code |
i | integer value |
Definition at line 119 of file qgsdxfexport.cpp.
void QgsDxfExport::writeGroupCode | ( | int | code | ) |
Write a group code.
code | group code value |
Definition at line 174 of file qgsdxfexport.cpp.
int QgsDxfExport::writeHandle | ( | int | code = 5 , |
int | handle = 0 |
||
) |
Write a tuple of group code and a handle.
code | group code to use |
handle | handle to use (0 generates a new handle) |
Definition at line 357 of file qgsdxfexport.cpp.
void QgsDxfExport::writeInt | ( | int | i | ) |
void QgsDxfExport::writeLine | ( | const QgsPoint & | pt1, |
const QgsPoint & | pt2, | ||
const QString & | layer, | ||
const QString & | lineStyleName, | ||
const QColor & | color, | ||
double | width = -1 |
||
) |
Write line (as a polyline)
Definition at line 1463 of file qgsdxfexport.cpp.
void QgsDxfExport::writeMText | ( | const QString & | layer, |
const QString & | text, | ||
const QgsPoint & | pt, | ||
double | width, | ||
double | angle, | ||
const QColor & | color | ||
) |
Write mtext (MTEXT)
Definition at line 1684 of file qgsdxfexport.cpp.
void QgsDxfExport::writePoint | ( | const QString & | layer, |
const QColor & | color, | ||
const QgsPoint & | pt | ||
) |
Write point.
Definition at line 1588 of file qgsdxfexport.cpp.
void QgsDxfExport::writePolygon | ( | const QgsCurvePolygon & | polygon, |
const QString & | layer, | ||
const QString & | hatchPattern, | ||
const QColor & | color | ||
) |
Draw dxf curved filled polygon (HATCH)
polygon | polygon (including curves) |
layer | layer name to use |
hatchPattern | hatchPattern to use |
color | color to use |
Definition at line 1398 of file qgsdxfexport.cpp.
void QgsDxfExport::writePolygon | ( | const QgsRingSequence & | polygon, |
const QString & | layer, | ||
const QString & | hatchPattern, | ||
const QColor & | color | ||
) |
Draw dxf filled polygon (HATCH)
polygon | polygon |
layer | layer name to use |
hatchPattern | hatchPattern to use |
color | color to use |
Definition at line 1359 of file qgsdxfexport.cpp.
void QgsDxfExport::writePolyline | ( | const QgsCurve & | curve, |
const QString & | layer, | ||
const QString & | lineStyleName, | ||
const QColor & | color, | ||
double | width = -1 |
||
) |
Draw dxf primitives (LWPOLYLINE)
curve | polyline (including curved) |
layer | layer name to use |
lineStyleName | line type to use |
color | color to use |
width | line width to use |
Definition at line 1271 of file qgsdxfexport.cpp.
void QgsDxfExport::writePolyline | ( | const QgsPointSequence & | line, |
const QString & | layer, | ||
const QString & | lineStyleName, | ||
const QColor & | color, | ||
double | width = -1 |
||
) |
Draw dxf primitives (LWPOLYLINE)
line | polyline |
layer | layer name to use |
lineStyleName | line type to use |
color | color to use |
width | line width to use |
Definition at line 1133 of file qgsdxfexport.cpp.
void QgsDxfExport::writeString | ( | const QString & | s | ) |
void QgsDxfExport::writeText | ( | const QString & | layer, |
const QString & | text, | ||
const QgsPoint & | pt, | ||
double | size, | ||
double | angle, | ||
const QColor & | color, | ||
QgsDxfExport::HAlign | hali = QgsDxfExport::HAlign::Undefined , |
||
QgsDxfExport::VAlign | vali = QgsDxfExport::VAlign::Undefined |
||
) |
Write text (TEXT)
Definition at line 1658 of file qgsdxfexport.cpp.
QgsDxfExport::ExportResult QgsDxfExport::writeToFile | ( | QIODevice * | d, |
const QString & | codec | ||
) |
Export to a dxf file in the given encoding.
d | device |
codec | encoding |
Definition at line 197 of file qgsdxfexport.cpp.