18 #ifndef QGSDXFEXPORT_H
19 #define QGSDXFEXPORT_H
21 #include "qgis_core.h"
30 #include <QTextStream>
44 #define DXF_HANDSEED 100
45 #define DXF_HANDMAX 9999999
46 #define DXF_HANDPLOTSTYLE 0xf
76 , mLayerOutputAttributeIndex( layerOutputAttributeIndex )
95 QString splitLayerAttribute()
const;
99 int mLayerOutputAttributeIndex = -1;
112 FlagNoMText = 1 << 1,
114 Q_DECLARE_FLAGS( Flags, Flag )
125 DeviceNotWritableError,
164 Is3DPolygonMesh = 16,
167 ContinuousPattern = 128,
170 Q_DECLARE_FLAGS( DxfPolylineFlags, DxfPolylineFlag )
212 ExportResult writeToFile( QIODevice *d, const QString &codec );
220 void setSymbologyScale(
double scale ) { mSymbologyScale = scale; }
309 static int closestColorMatch( QRgb color );
317 QString layerName(
const QString &
id,
const QgsFeature &f )
const;
333 void writeGroup(
int code,
int i )
SIP_PYNAME( writeGroupInt );
341 void writeGroup(
int code,
long long i )
SIP_PYNAME( writeGroupLong );
349 void writeGroup(
int code,
double d )
SIP_PYNAME( writeGroupDouble );
356 void writeGroup(
int code,
const QString &s );
375 void writeGroup(
const QColor &color,
int exactMatch = 62,
int rgbCode = 420,
int transparencyCode = 440 );
381 void writeGroupCode(
int code );
387 void writeInt(
int i );
393 void writeDouble(
double d );
399 void writeString(
const QString &s );
407 int writeHandle(
int code = 5,
int handle = 0 );
419 void writePolyline(
const QgsPointSequence &line,
const QString &layer,
const QString &lineStyleName,
const QColor &color,
double width = -1 )
SIP_SKIP;
431 void writePolyline( const
QgsCurve &curve, const QString &layer, const QString &lineStyleName, const QColor &color,
double width = -1 )
SIP_SKIP;
442 void writePolygon( const
QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color )
SIP_SKIP;
453 void writePolygon( const
QgsCurvePolygon &polygon, const QString &layer, const QString &hatchPattern, const QColor &color )
SIP_SKIP;
459 void writeLine( const
QgsPoint &pt1, const
QgsPoint &pt2, const QString &layer, const QString &lineStyleName, const QColor &color,
double width = -1 );
466 void writePoint( const QString &layer, const QColor &color, const
QgsPoint &pt )
SIP_PYNAME( writePointV2 );
473 void writeFilledCircle( const QString &layer, const QColor &color, const
QgsPoint &pt,
double radius )
SIP_PYNAME( writeFillCircleV2 );
480 void writeCircle( const QString &layer, const QColor &color, const
QgsPoint &pt,
double radius, const QString &lineStyleName,
double width )
SIP_PYNAME( writeCircleV2 );
494 void writeMText( const QString &layer, const QString &text, const
QgsPoint &pt,
double width,
double angle, const QColor &color );
503 static
double mapUnitScaleFactor(
double scale,
QgsUnitTypes::RenderUnit symbolUnits,
QgsUnitTypes::DistanceUnit mapUnits,
double mapUnitsPerPixel = 1.0 );
511 void clipValueToMapUnitScale(
double &value, const
QgsMapUnitScale &scale,
double pixelToMMFactor ) const;
514 static QString dxfLayerName( const QString &name );
517 static QString dxfEncoding( const QString &name );
520 static QStringList encodings();
537 Q_DECL_DEPRECATED
void registerDxfLayer( const QString &layerId,
QgsFeatureId fid, const QString &layer );
548 double mSymbologyScale = 1.0;
549 SymbologyExport mSymbologyExport = NoSymbology;
551 bool mLayerTitleAsName =
false;
553 QTextStream mTextStream;
555 int mSymbolLayerCounter = 0;
557 int mBlockCounter = 0;
559 QHash< const QgsSymbolLayer *, QString > mLineStyles;
560 QHash< const QgsSymbolLayer *, QString > mPointSymbolBlocks;
563 void writeHeader(
const QString &codepage );
564 void prepareRenderers();
567 void writeEntities();
568 void writeEntitiesSymbolLevels(
DxfLayerJob *job );
569 void stopRenderers();
576 void writeDefaultLinetypes();
577 void writeSymbolLayerLinetype(
const QgsSymbolLayer *symbolLayer );
609 QString lineStyleFromSymbolLayer(
const QgsSymbolLayer *symbolLayer );
612 static int color_distance( QRgb p1,
int index );
613 static QRgb createRgbEntry( qreal r, qreal g, qreal b );
618 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > symbolLayers(
QgsRenderContext &context );
619 static int nLineTypes(
const QList< QPair< QgsSymbolLayer *, QgsSymbol *> > &symbolLayers );
621 double dashSize()
const;
622 double dotSize()
const;
623 double dashSeparatorSize()
const;
624 double sizeToMapUnits(
double s )
const;
625 static QString lineNameFromPenStyle( Qt::PenStyle style );
626 bool layerIsScaleBasedVisible(
const QgsMapLayer *layer )
const;
628 QHash<QString, int> mBlockHandles;
629 QString mBlockHandle;
632 QMap< QString, QMap<QgsFeatureId, QString> > mDxfLayerNames;
635 QHash<QString, int> mLayerNameAttribute;
636 double mFactor = 1.0;
637 bool mForce2d =
false;
639 QgsDxfExport::Flags mFlags = QgsDxfExport::Flags();
641 void appendCurve(
const QgsCurve &
c, QVector<QgsPoint> &points, QVector<double> &bulges );
642 void appendLineString(
const QgsLineString &ls, QVector<QgsPoint> &points, QVector<double> &bulges );
643 void appendCircularString(
const QgsCircularString &cs, QVector<QgsPoint> &points, QVector<double> &bulges );
644 void appendCompoundCurve(
const QgsCompoundCurve &cc, QVector<QgsPoint> &points, QVector<double> &bulges );
648 QList<DxfLayerJob *> mJobs;
649 std::unique_ptr<QgsLabelingEngine> mLabelingEngine;
Circular string geometry type.
Compound curve geometry type.
This class represents a coordinate reference system (CRS).
Curve polygon geometry type.
Abstract base class for curved geometry type.
Exports QGIS layers to the DXF format.
void setForce2d(bool force2d)
Force 2d output (eg.
ExportResult
The result of an export as dxf operation.
@ FeatureSymbology
Keeps the number of features and export symbology per feature (using the first symbol level)
void setSymbologyExport(QgsDxfExport::SymbologyExport e)
Set symbology export mode.
bool layerTitleAsName()
Retrieve whether layer title (where set) instead of name shall be use.
QgsRectangle extent() const
Gets extent of area to export.
HAlign
Horizontal alignments.
bool force2d()
Retrieve whether the output should be forced to 2d.
void setExtent(const QgsRectangle &r)
Set extent of area to export.
double symbologyScale() const
Returns the reference scale for output.
VAlign
Vertical alignments.
QgsDxfExport::SymbologyExport symbologyExport() const
Gets symbology export mode.
DxfPolylineFlag
Flags for polylines.
void setLayerTitleAsName(bool layerTitleAsName)
Enable use of title (where set) instead of layer name, when attribute index of corresponding layer in...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Abstract base class that can be used to intercept rendered labels from a labeling / rendering job.
Line string geometry type, with support for z-dimension and m-values.
Base class for all map layer types.
The QgsMapSettings class contains configuration for rendering of the map.
Struct for storing maximum and minimum scales for measurements in map units.
Contains settings for how a map layer will be labeled.
A class to represent a 2D point.
Point geometry type, with support for z-dimension and m-values.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
Abstract base class for all rendered symbols.
Helper functions for various unit types.
DistanceUnit
Units of distance.
RenderUnit
Rendering size units.
Represents a vector layer which manages a vector based data sets.
LabelPosition is a candidate feature label position.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QVector< QgsPointSequence > QgsRingSequence
QVector< QgsPoint > QgsPointSequence
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
const QgsCoordinateReferenceSystem & crs
Holds information about each layer in a DXF job.
Layers and optional attribute index to split into multiple layers using attribute value as layer name...
DxfLayer(QgsVectorLayer *vl, int layerOutputAttributeIndex=-1)
QgsVectorLayer * layer() const
Returns the layer.
int layerOutputAttributeIndex() const
Returns the attribute index used to split into multiple layers.