18 #ifndef QGSDXFEXPORT_H 19 #define QGSDXFEXPORT_H 21 #include "qgis_core.h" 30 #include <QTextStream> 43 #define DXF_HANDSEED 100 44 #define DXF_HANDMAX 9999999 45 #define DXF_HANDPLOTSTYLE 0xf 69 , mLayerOutputAttributeIndex( layerOutputAttributeIndex )
88 QString splitLayerAttribute()
const;
92 int mLayerOutputAttributeIndex = -1;
105 FlagNoMText = 1 << 1,
107 Q_DECLARE_FLAGS( Flags,
Flag )
118 DeviceNotWritableError,
157 Is3DPolygonMesh = 16,
160 ContinuousPattern = 128,
183 void setFlags( QgsDxfExport::Flags flags );
190 QgsDxfExport::Flags flags()
const;
197 void addLayers(
const QList< QgsDxfExport::DxfLayer > &layers );
205 ExportResult writeToFile( QIODevice *d,
const QString &codec );
302 static int closestColorMatch( QRgb color );
310 QString layerName(
const QString &
id,
const QgsFeature &f )
const;
326 void writeGroup(
int code,
int i )
SIP_PYNAME( writeGroupInt );
334 void writeGroup(
int code,
double d )
SIP_PYNAME( writeGroupDouble );
341 void writeGroup(
int code,
const QString &s );
360 void writeGroup(
const QColor &color,
int exactMatch = 62,
int rgbCode = 420,
int transparencyCode = 440 );
366 void writeGroupCode(
int code );
372 void writeInt(
int i );
378 void writeDouble(
double d );
384 void writeString(
const QString &s );
392 int writeHandle(
int code = 5,
int handle = 0 );
404 void writePolyline(
const QgsPointSequence &line,
const QString &layer,
const QString &lineStyleName,
const QColor &color,
double width = -1 )
SIP_SKIP;
416 void writePolyline(
const QgsCurve &curve,
const QString &layer,
const QString &lineStyleName,
const QColor &color,
double width = -1 )
SIP_SKIP;
427 void writePolygon(
const QgsRingSequence &polygon,
const QString &layer,
const QString &hatchPattern,
const QColor &color )
SIP_SKIP;
438 void writePolygon(
const QgsCurvePolygon &polygon,
const QString &layer,
const QString &hatchPattern,
const QColor &color )
SIP_SKIP;
444 void writeLine(
const QgsPoint &pt1,
const QgsPoint &pt2,
const QString &layer,
const QString &lineStyleName,
const QColor &color,
double width = -1 );
451 void writePoint(
const QString &layer,
const QColor &color,
const QgsPoint &pt )
SIP_PYNAME( writePointV2 );
458 void writeFilledCircle(
const QString &layer,
const QColor &color,
const QgsPoint &pt,
double radius )
SIP_PYNAME( writeFillCircleV2 );
465 void writeCircle(
const QString &layer,
const QColor &color,
const QgsPoint &pt,
double radius,
const QString &lineStyleName,
double width )
SIP_PYNAME( writeCircleV2 );
479 void writeMText(
const QString &layer,
const QString &text,
const QgsPoint &pt,
double width,
double angle,
const QColor &color );
496 void clipValueToMapUnitScale(
double &value,
const QgsMapUnitScale &scale,
double pixelToMMFactor )
const;
499 static QString dxfLayerName(
const QString &name );
502 static QString dxfEncoding(
const QString &name );
505 static QStringList encodings();
523 void registerDxfLayer(
const QString &layerId,
QgsFeatureId fid,
const QString &layer );
534 double mSymbologyScale = 1.0;
537 bool mLayerTitleAsName =
false;
539 QTextStream mTextStream;
541 int mSymbolLayerCounter = 0;
543 int mBlockCounter = 0;
545 QHash< const QgsSymbolLayer *, QString > mLineStyles;
546 QHash< const QgsSymbolLayer *, QString > mPointSymbolBlocks;
549 void writeHeader(
const QString &codepage );
550 void prepareRenderers();
553 void writeEntities();
554 void writeEntitiesSymbolLevels(
DxfLayerJob *job );
555 void stopRenderers();
562 void writeDefaultLinetypes();
563 void writeSymbolLayerLinetype(
const QgsSymbolLayer *symbolLayer );
585 QString lineStyleFromSymbolLayer(
const QgsSymbolLayer *symbolLayer );
588 static int color_distance( QRgb p1,
int index );
589 static QRgb createRgbEntry( qreal r, qreal g, qreal b );
594 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > symbolLayers(
QgsRenderContext &context );
595 static int nLineTypes(
const QList< QPair< QgsSymbolLayer *, QgsSymbol *> > &symbolLayers );
597 double dashSize()
const;
598 double dotSize()
const;
599 double dashSeparatorSize()
const;
600 double sizeToMapUnits(
double s )
const;
601 static QString lineNameFromPenStyle( Qt::PenStyle style );
602 bool layerIsScaleBasedVisible(
const QgsMapLayer *layer )
const;
604 QHash<QString, int> mBlockHandles;
605 QString mBlockHandle;
608 QMap< QString, QMap<QgsFeatureId, QString> > mDxfLayerNames;
611 QHash<QString, int> mLayerNameAttribute;
612 double mFactor = 1.0;
613 bool mForce2d =
false;
615 QgsDxfExport::Flags mFlags =
nullptr;
617 void appendCurve(
const QgsCurve &
c, QVector<QgsPoint> &points, QVector<double> &bulges );
618 void appendLineString(
const QgsLineString &ls, QVector<QgsPoint> &points, QVector<double> &bulges );
619 void appendCircularString(
const QgsCircularString &cs, QVector<QgsPoint> &points, QVector<double> &bulges );
620 void appendCompoundCurve(
const QgsCompoundCurve &cc, QVector<QgsPoint> &points, QVector<double> &bulges );
624 QList<DxfLayerJob *> mJobs;
625 std::unique_ptr<QgsLabelingEngine> mLabelingEngine;
628 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDxfExport::Flags )
629 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDxfExport::DxfPolylineFlags )
631 #endif // QGSDXFEXPORT_H A rectangle specified with double values.
Base class for all map layer types.
double symbologyScale() const
Returns the reference scale for output.
QgsDxfExport::SymbologyExport symbologyExport() const
Gets symbology export mode.
DxfLayer(QgsVectorLayer *vl, int layerOutputAttributeIndex=-1)
Abstract base class for all rendered symbols.
A class to represent a 2D point.
bool force2d()
Retrieve whether the output should be forced to 2d.
Curve polygon geometry type.
Holds information about each layer in a DXF job.
void setSymbologyExport(QgsDxfExport::SymbologyExport e)
Set symbology export mode.
QgsVectorLayer * layer() const
Returns the layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Layers and optional attribute index to split into multiple layers using attribute value as layer name...
const QgsCoordinateReferenceSystem & crs
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)
The QgsMapSettings class contains configuration for rendering of the map.
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
void setForce2d(bool force2d)
Force 2d output (eg.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Abstract base class for curved geometry type.
VAlign
Vertical alignments.
Keeps the number of features and export symbology per feature (using the first symbol level) ...
Point geometry type, with support for z-dimension and m-values.
DistanceUnit
Units of distance.
QVector< QgsPoint > QgsPointSequence
QVector< QgsPointSequence > QgsRingSequence
void setSymbologyScale(double scale)
Set reference scale for output.
Contains information about the context of a rendering operation.
HAlign
Horizontal alignments.
ExportResult
The result of an export as dxf operation.
QgsRectangle extent() const
Gets extent of area to export.
void setLayerTitleAsName(bool layerTitleAsName)
Enable use of title (where set) instead of layer name, when attribute index of corresponding layer in...
Struct for storing maximum and minimum scales for measurements in map units.
void setExtent(const QgsRectangle &r)
Set extent of area to export.
Line string geometry type, with support for z-dimension and m-values.
bool layerTitleAsName()
Retrieve whether layer title (where set) instead of name shall be use.
This class represents a coordinate reference system (CRS).
LabelPosition is a candidate feature label position.
Compound curve geometry type.
Circular string geometry type.
Represents a vector layer which manages a vector based data sets.
DxfPolylineFlag
Flags for polylines.
RenderUnit
Rendering size units.
int layerOutputAttributeIndex() const
Returns the attribute index used to split into multiple layers.