QGIS API Documentation  3.4.15-Madeira (e83d02e274)
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsDxfExport Class Reference

#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  Flag { FlagNoMText = 1 << 1 }
 Export flags. More...
 
enum  SymbologyExport { NoSymbology = 0, FeatureSymbology, SymbolLayerSymbology }
 

Public Member Functions

 QgsDxfExport ()=default
 Constructor for QgsDxfExport. More...
 
 QgsDxfExport (const QgsDxfExport &dxfExport)
 
void addLayers (const QList< QgsDxfExport::DxfLayer > &layers)
 Add layers to export. More...
 
void clipValueToMapUnitScale (double &value, const QgsMapUnitScale &scale, double pixelToMMFactor) const
 Clips value to scale minimum/maximum. More...
 
QgsCoordinateReferenceSystem destinationCrs () const
 Returns the destination CRS, or an invalid CRS if no reprojection will be done. More...
 
void drawLabel (const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings)
 Output the label. More...
 
QgsRectangle extent () const
 Gets extent of area to export. More...
 
QgsDxfExport::Flags flags () const
 Returns the export flags. More...
 
bool force2d ()
 Retrieve whether the output should be forced to 2d. More...
 
QString layerName (const QString &id, const QgsFeature &f) const
 Gets layer name for feature. More...
 
QString layerName (QgsVectorLayer *vl) const
 Gets name for layer respecting the use layer title as layer name mode. More...
 
bool layerTitleAsName ()
 Retrieve whether layer title (where set) instead of name shall be use. More...
 
QgsUnitTypes::DistanceUnit mapUnits () const
 Retrieve map units. More...
 
QgsDxfExportoperator= (const QgsDxfExport &dxfExport)
 
void registerDxfLayer (const QString &layerId, QgsFeatureId fid, const QString &layer)
 Register name of layer for feature. More...
 
void setDestinationCrs (const QgsCoordinateReferenceSystem &crs)
 Set destination CRS. More...
 
void setExtent (const QgsRectangle &r)
 Set extent of area to export. More...
 
void setFlags (QgsDxfExport::Flags flags)
 Sets the export flags. More...
 
void setForce2d (bool force2d)
 Force 2d output (eg. More...
 
void setLayerTitleAsName (bool layerTitleAsName)
 Enable use of title (where set) instead of layer name, when attribute index of corresponding layer index is -1. More...
 
void setMapSettings (const QgsMapSettings &settings)
 Set map settings and assign layer name attributes. More...
 
void setSymbologyExport (QgsDxfExport::SymbologyExport e)
 Set symbology export mode. More...
 
void setSymbologyScale (double scale)
 Set reference scale for output. More...
 
QgsDxfExport::SymbologyExport symbologyExport () const
 Gets symbology export mode. More...
 
double symbologyScale () const
 Returns the reference scale for output. More...
 
void writeCircle (const QString &layer, const QColor &color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width)
 Write circle (as polyline) More...
 
void writeDouble (double d)
 Write a floating point value. More...
 
void writeFilledCircle (const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
 Write filled circle (as hatch) More...
 
void writeGroup (int code, int i)
 Write a tuple of group code and integer value. More...
 
void writeGroup (int code, double d)
 Write a group code with a floating point value. More...
 
void writeGroup (int code, const QString &s)
 Write a group code with a string value. More...
 
void writeGroup (int code, const QgsPoint &p)
 Write a group code with a point. More...
 
void writeGroup (const QColor &color, int exactMatch=62, int rgbCode=420, int transparencyCode=440)
 Write a group code with color value. More...
 
void writeGroupCode (int code)
 Write a group code. More...
 
int writeHandle (int code=5, int handle=0)
 Write a tuple of group code and a handle. More...
 
void writeInt (int i)
 Write an integer value. More...
 
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) More...
 
void writeMText (const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, const QColor &color)
 Write mtext (MTEXT) More...
 
void writePoint (const QString &layer, const QColor &color, const QgsPoint &pt)
 Write point. More...
 
void writePolygon (const QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
 Draw dxf filled polygon (HATCH) More...
 
void writePolyline (const QgsPointSequence &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
 Draw dxf primitives (LWPOLYLINE) More...
 
void writeString (const QString &s)
 Write a string value. More...
 
void writeText (const QString &layer, const QString &text, const QgsPoint &pt, double size, double angle, const QColor &color)
 Write text (TEXT) More...
 
int writeToFile (QIODevice *d, const QString &codec)
 Export to a dxf file in the given encoding. More...
 

Static Public Member Functions

static int closestColorMatch (QRgb color)
 Gets DXF palette index of nearest entry for given color. More...
 
static QString dxfEncoding (const QString &name)
 Returns DXF encoding for Qt encoding. More...
 
static QString dxfLayerName (const QString &name)
 Returns cleaned layer name for use in DXF. More...
 
static QStringList encodings ()
 Returns list of available DXF encodings. More...
 
static double mapUnitScaleFactor (double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
 Returns scale factor for conversion to map units. More...
 

Detailed Description

Definition at line 51 of file qgsdxfexport.h.

Member Enumeration Documentation

Export flags.

Enumerator
FlagNoMText 

Export text as TEXT elements. If not set, text will be exported as MTEXT elements.

Definition at line 88 of file qgsdxfexport.h.

Enumerator
NoSymbology 

Export only data.

FeatureSymbology 

Keeps the number of features and export symbology per feature (using the first symbol level)

SymbolLayerSymbology 

Exports one feature per symbol layer (considering symbol levels)

Definition at line 80 of file qgsdxfexport.h.

Constructor & Destructor Documentation

QgsDxfExport::QgsDxfExport ( )
default

Constructor for QgsDxfExport.

QgsDxfExport::QgsDxfExport ( const QgsDxfExport dxfExport)

Definition at line 366 of file qgsdxfexport.cpp.

Member Function Documentation

void QgsDxfExport::addLayers ( const QList< QgsDxfExport::DxfLayer > &  layers)

Add layers to export.

Parameters
layerslist of layers and corresponding attribute indexes that determine the layer name (-1 for original layer name or title)
See also
setLayerTitleAsName

Definition at line 403 of file qgsdxfexport.cpp.

void QgsDxfExport::clipValueToMapUnitScale ( double &  value,
const QgsMapUnitScale scale,
double  pixelToMMFactor 
) const

Clips value to scale minimum/maximum.

Parameters
valuethe value to clip
scalethe scale dependent minimum/maximum values
pixelToMMFactorpixels per mm

Definition at line 4032 of file qgsdxfexport.cpp.

int QgsDxfExport::closestColorMatch ( QRgb  color)
static

Gets DXF palette index of nearest entry for given color.

Parameters
color

Definition at line 3963 of file qgsdxfexport.cpp.

QgsCoordinateReferenceSystem QgsDxfExport::destinationCrs ( ) const

Returns the destination CRS, or an invalid CRS if no reprojection will be done.

See also
setDestinationCrs()
Since
QGIS 3.0

Definition at line 4582 of file qgsdxfexport.cpp.

void QgsDxfExport::drawLabel ( const QString &  layerId,
QgsRenderContext context,
pal::LabelPosition label,
const QgsPalLayerSettings settings 
)

Output the label.

Parameters
layerIdid of the layer
contextrender context
labelposition of label
settingslabel settings
Note
not available in Python bindings

Definition at line 4421 of file qgsdxfexport.cpp.

QString QgsDxfExport::dxfEncoding ( const QString &  name)
static

Returns DXF encoding for Qt encoding.

Definition at line 4378 of file qgsdxfexport.cpp.

QString QgsDxfExport::dxfLayerName ( const QString &  name)
static

Returns cleaned layer name for use in DXF.

Definition at line 4319 of file qgsdxfexport.cpp.

QStringList QgsDxfExport::encodings ( )
static

Returns list of available DXF encodings.

Definition at line 4399 of file qgsdxfexport.cpp.

QgsRectangle QgsDxfExport::extent ( ) const
inline

Gets extent of area to export.

Returns
area to export
See also
setExtent

Definition at line 196 of file qgsdxfexport.h.

QgsDxfExport::Flags QgsDxfExport::flags ( ) const

Returns the export flags.

See also
setFlags()
Since
QGIS 3.0

Definition at line 398 of file qgsdxfexport.cpp.

bool QgsDxfExport::force2d ( )
inline

Retrieve whether the output should be forced to 2d.

Returns
flag
See also
setForce2d

Definition at line 225 of file qgsdxfexport.h.

QString QgsDxfExport::layerName ( const QString &  id,
const QgsFeature f 
) const

Gets layer name for feature.

Parameters
idlayer id of layer
ffeature of layer
Returns
layer name for feature

Definition at line 4362 of file qgsdxfexport.cpp.

QString QgsDxfExport::layerName ( QgsVectorLayer vl) const

Gets name for layer respecting the use layer title as layer name mode.

Parameters
vlthe vector layer
Returns
name of layer
See also
setLayerTitleAsName

Definition at line 4415 of file qgsdxfexport.cpp.

bool QgsDxfExport::layerTitleAsName ( )
inline

Retrieve whether layer title (where set) instead of name shall be use.

Returns
flag
See also
setLayerTitleAsName

Definition at line 211 of file qgsdxfexport.h.

QgsUnitTypes::DistanceUnit QgsDxfExport::mapUnits ( ) const

Retrieve map units.

Returns
unit

Definition at line 559 of file qgsdxfexport.cpp.

double QgsDxfExport::mapUnitScaleFactor ( double  scale,
QgsUnitTypes::RenderUnit  symbolUnits,
QgsUnitTypes::DistanceUnit  mapUnits,
double  mapUnitsPerPixel = 1.0 
)
static

Returns scale factor for conversion to map units.

Parameters
scalethe map scale denominator
symbolUnitsthe symbol output units
mapUnitsthe map units
mapUnitsPerPixelMap units per pixel

Definition at line 4015 of file qgsdxfexport.cpp.

QgsDxfExport & QgsDxfExport::operator= ( const QgsDxfExport dxfExport)

Definition at line 371 of file qgsdxfexport.cpp.

void QgsDxfExport::registerDxfLayer ( const QString &  layerId,
QgsFeatureId  fid,
const QString &  layer 
)

Register name of layer for feature.

Parameters
layerIdid of layer
fidid of feature
layerdxf layer of feature

Definition at line 4568 of file qgsdxfexport.cpp.

void QgsDxfExport::setDestinationCrs ( const QgsCoordinateReferenceSystem crs)

Set destination CRS.

See also
destinationCrs()
Since
QGIS 3.0

Definition at line 4576 of file qgsdxfexport.cpp.

void QgsDxfExport::setExtent ( const QgsRectangle r)
inline

Set extent of area to export.

Parameters
rarea to export

Definition at line 189 of file qgsdxfexport.h.

void QgsDxfExport::setFlags ( QgsDxfExport::Flags  flags)

Sets the export flags.

See also
flags()
Since
QGIS 3.0

Definition at line 393 of file qgsdxfexport.cpp.

void QgsDxfExport::setForce2d ( bool  force2d)
inline

Force 2d output (eg.

to support linewidth in polylines)

Parameters
force2dflag
See also
force2d

Definition at line 218 of file qgsdxfexport.h.

void QgsDxfExport::setLayerTitleAsName ( bool  layerTitleAsName)
inline

Enable use of title (where set) instead of layer name, when attribute index of corresponding layer index is -1.

Parameters
layerTitleAsNameflag
See also
addLayers

Definition at line 204 of file qgsdxfexport.h.

void QgsDxfExport::setMapSettings ( const QgsMapSettings settings)

Set map settings and assign layer name attributes.

Parameters
settingsmap settings to apply

Definition at line 388 of file qgsdxfexport.cpp.

void QgsDxfExport::setSymbologyExport ( QgsDxfExport::SymbologyExport  e)
inline

Set symbology export mode.

Parameters
ethe mode

Definition at line 176 of file qgsdxfexport.h.

void QgsDxfExport::setSymbologyScale ( double  scale)
inline

Set reference scale for output.

The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.

See also
symbologyScale()
Since
QGIS 3.0

Definition at line 142 of file qgsdxfexport.h.

QgsDxfExport::SymbologyExport QgsDxfExport::symbologyExport ( ) const
inline

Gets symbology export mode.

Returns
mode
See also
setSymbologyExport

Definition at line 183 of file qgsdxfexport.h.

double QgsDxfExport::symbologyScale ( ) const
inline

Returns the reference scale for output.

The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.

See also
setSymbologyScale()
Since
QGIS 3.0

Definition at line 150 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)

Note
available in Python bindings as writeCircleV2
Since
QGIS 2.15

Definition at line 3639 of file qgsdxfexport.cpp.

void QgsDxfExport::writeDouble ( double  d)

Write a floating point value.

Parameters
dfloating point value

Definition at line 485 of file qgsdxfexport.cpp.

void QgsDxfExport::writeFilledCircle ( const QString &  layer,
const QColor &  color,
const QgsPoint pt,
double  radius 
)

Write filled circle (as hatch)

Note
available in Python bindings as writePointV2
Since
QGIS 2.15

Definition at line 3602 of file qgsdxfexport.cpp.

void QgsDxfExport::writeGroup ( int  code,
int  i 
)

Write a tuple of group code and integer value.

Parameters
codegroup code
iinteger value
Note
available in Python bindings as writeGroupInt

Definition at line 420 of file qgsdxfexport.cpp.

void QgsDxfExport::writeGroup ( int  code,
double  d 
)

Write a group code with a floating point value.

Parameters
codegroup code
dfloating point value
Note
available in Python bindings as writeGroupDouble

Definition at line 426 of file qgsdxfexport.cpp.

void QgsDxfExport::writeGroup ( int  code,
const QString &  s 
)

Write a group code with a string value.

Parameters
codegroup code
sstring value

Definition at line 432 of file qgsdxfexport.cpp.

void QgsDxfExport::writeGroup ( int  code,
const QgsPoint p 
)

Write a group code with a point.

Parameters
codegroup code
ppoint value
Note
available in Python bindings as writeGroupPointV2
Since
QGIS 2.15

Definition at line 438 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.

Parameters
colorcolor
exactMatchgroup code to use if the color has an exact match in the dxf palette
rgbCodegroup code to use if the color doesn't have an exact match or has a transparency component
transparencyCodegroup code to use for transparency component
Note
available in Python bindings as writeGroupPoint

Definition at line 446 of file qgsdxfexport.cpp.

void QgsDxfExport::writeGroupCode ( int  code)

Write a group code.

Parameters
codegroup code value

Definition at line 475 of file qgsdxfexport.cpp.

int QgsDxfExport::writeHandle ( int  code = 5,
int  handle = 0 
)

Write a tuple of group code and a handle.

Parameters
codegroup code to use
handlehandle to use (0 generates a new handle)
Returns
the used handle

Definition at line 608 of file qgsdxfexport.cpp.

void QgsDxfExport::writeInt ( int  i)

Write an integer value.

Parameters
iinteger value

Definition at line 480 of file qgsdxfexport.cpp.

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)

Since
QGIS 2.15

Definition at line 3586 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)

Note
available in Python bindings as writeMTextV2
Since
QGIS 2.15

Definition at line 3677 of file qgsdxfexport.cpp.

void QgsDxfExport::writePoint ( const QString &  layer,
const QColor &  color,
const QgsPoint pt 
)

Write point.

Note
available in Python bindings as writePointV2
Since
QGIS 2.15

Definition at line 3591 of file qgsdxfexport.cpp.

void QgsDxfExport::writePolygon ( const QgsRingSequence polygon,
const QString &  layer,
const QString &  hatchPattern,
const QColor &  color 
)

Draw dxf filled polygon (HATCH)

Parameters
polygonpolygon
layerlayer name to use
hatchPatternhatchPattern to use
colorcolor to use
Note
not available in Python bindings
Since
QGIS 2.15

Definition at line 3547 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)

Parameters
linepolyline
layerlayer name to use
lineStyleNameline type to use
colorcolor to use
widthline width to use
Note
not available in Python bindings
Since
QGIS 2.15

Definition at line 3475 of file qgsdxfexport.cpp.

void QgsDxfExport::writeString ( const QString &  s)

Write a string value.

Parameters
sstring value

Definition at line 493 of file qgsdxfexport.cpp.

void QgsDxfExport::writeText ( const QString &  layer,
const QString &  text,
const QgsPoint pt,
double  size,
double  angle,
const QColor &  color 
)

Write text (TEXT)

Note
available in Python bindings as writeTextV2
Since
QGIS 2.15

Definition at line 3661 of file qgsdxfexport.cpp.

int QgsDxfExport::writeToFile ( QIODevice *  d,
const QString &  codec 
)

Export to a dxf file in the given encoding.

Parameters
ddevice
codecencoding
Returns
0 on success, 1 on invalid device, 2 when devices is not writable

Definition at line 498 of file qgsdxfexport.cpp.


The documentation for this class was generated from the following files: