18 #ifndef QGSDXFEXPORT_H
19 #define QGSDXFEXPORT_H
21 #include "qgis_core.h"
31 #include <QTextStream>
46 #define DXF_HANDSEED 100
47 #define DXF_HANDMAX 9999999
48 #define DXF_HANDPLOTSTYLE 0xf
76 DxfLayer(
QgsVectorLayer *vl,
int layerOutputAttributeIndex = -1,
bool buildDDBlocks =
false,
int ddBlocksMaxNumberOfClasses = -1 )
78 , mLayerOutputAttributeIndex( layerOutputAttributeIndex )
79 , mBuildDDBlocks( buildDDBlocks )
80 , mDDBlocksMaxNumberOfClasses( ddBlocksMaxNumberOfClasses )
99 QString splitLayerAttribute()
const;
117 int mLayerOutputAttributeIndex = -1;
122 bool mBuildDDBlocks =
false;
127 int mDDBlocksMaxNumberOfClasses = -1;
133 FlagNoMText = 1 << 1,
134 FlagOnlySelectedFeatures = 1 << 2,
147 DeviceNotWritableError,
186 Is3DPolygonMesh = 16,
189 ContinuousPattern = 128,
232 ExportResult writeToFile( QIODevice *d, const QString &codec );
238 const QString feedbackMessage()
const {
return mFeedbackMessage; }
331 static int closestColorMatch( QRgb color );
339 QString layerName(
const QString &
id,
const QgsFeature &f )
const;
355 void writeGroup(
int code,
int i )
SIP_PYNAME( writeGroupInt );
363 void writeGroup(
int code,
long long i )
SIP_PYNAME( writeGroupLong );
371 void writeGroup(
int code,
double d )
SIP_PYNAME( writeGroupDouble );
378 void writeGroup(
int code,
const QString &s );
396 void writeGroup(
const QColor &color,
int exactMatch = 62,
int rgbCode = 420,
int transparencyCode = 440 );
402 void writeGroupCode(
int code );
408 void writeInt(
int i );
414 void writeDouble(
double d );
420 void writeString(
const QString &s );
428 int writeHandle(
int code = 5,
int handle = 0 );
439 void writePolyline(
const QgsPointSequence &line,
const QString &layer,
const QString &lineStyleName,
const QColor &color,
double width = -1 )
SIP_SKIP;
451 void writePolyline( const
QgsCurve &curve, const QString &layer, const QString &lineStyleName, const QColor &color,
double width = -1 )
SIP_SKIP;
461 void writePolygon( const
QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color )
SIP_SKIP;
472 void writePolygon( const
QgsCurvePolygon &polygon, const QString &layer, const QString &hatchPattern, const QColor &color )
SIP_SKIP;
477 void writeLine( const
QgsPoint &pt1, const
QgsPoint &pt2, const QString &layer, const QString &lineStyleName, const QColor &color,
double width = -1 );
483 void writePoint( const QString &layer, const QColor &color, const
QgsPoint &pt )
SIP_PYNAME( writePointV2 );
489 void writeFilledCircle( const QString &layer, const QColor &color, const
QgsPoint &pt,
double radius )
SIP_PYNAME( writeFillCircleV2 );
495 void writeCircle( const QString &layer, const QColor &color, const
QgsPoint &pt,
double radius, const QString &lineStyleName,
double width )
SIP_PYNAME( writeCircleV2 );
507 void writeMText( const QString &layer, const QString &text, const
QgsPoint &pt,
double width,
double angle, const QColor &color );
516 static
double mapUnitScaleFactor(
double scale,
Qgis::RenderUnit symbolUnits,
Qgis::DistanceUnit mapUnits,
double mapUnitsPerPixel = 1.0 );
524 void clipValueToMapUnitScale(
double &value, const
QgsMapUnitScale &scale,
double pixelToMMFactor ) const;
527 static QString dxfLayerName( const QString &name );
530 static QString dxfEncoding( const QString &name );
533 static QStringList encodings();
550 Q_DECL_DEPRECATED
void registerDxfLayer( const QString &layerId,
QgsFeatureId fid, const QString &layer );
559 struct DataDefinedBlockInfo
570 double mSymbologyScale = 1.0;
573 bool mLayerTitleAsName =
false;
575 QTextStream mTextStream;
577 int mSymbolLayerCounter = 0;
579 int mBlockCounter = 0;
581 QHash< const QgsSymbolLayer *, QString > mLineStyles;
582 QHash< const QgsSymbolLayer *, QString > mPointSymbolBlocks;
583 QHash< const QgsSymbolLayer *, double > mPointSymbolBlockSizes;
584 QHash< const QgsSymbolLayer *, double > mPointSymbolBlockAngles;
586 QHash< const QgsSymbolLayer *, QHash <uint, DataDefinedBlockInfo> > mDataDefinedBlockInfo;
589 void createDDBlockInfo();
590 void writeHeader(
const QString &codepage );
591 void prepareRenderers();
594 void writeEntities();
595 void writeEntitiesSymbolLevels(
DxfLayerJob *job );
596 void stopRenderers();
603 void writeDefaultLinetypes();
604 void writeSymbolLayerLinetype(
const QgsSymbolLayer *symbolLayer );
605 void writeLinetype(
const QString &styleName,
const QVector<qreal> &pattern,
Qgis::RenderUnit u );
636 QString lineStyleFromSymbolLayer(
const QgsSymbolLayer *symbolLayer );
639 static int color_distance( QRgb p1,
int index );
640 static QRgb createRgbEntry( qreal r, qreal g, qreal b );
645 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > symbolLayers(
QgsRenderContext &context );
646 static int nLineTypes(
const QList< QPair< QgsSymbolLayer *, QgsSymbol *> > &symbolLayers );
648 void writeSymbolTableBlockRef(
const QString &blockName );
653 double dashSize()
const;
654 double dotSize()
const;
655 double dashSeparatorSize()
const;
656 double sizeToMapUnits(
double s )
const;
657 static QString lineNameFromPenStyle( Qt::PenStyle style );
658 bool layerIsScaleBasedVisible(
const QgsMapLayer *layer )
const;
660 QHash<QString, int> mBlockHandles;
661 QString mBlockHandle;
664 QMap< QString, QMap<QgsFeatureId, QString> > mDxfLayerNames;
667 QList<QgsMapLayer *> mLayerList;
668 QHash<QString, int> mLayerNameAttribute;
669 QHash<QString, int> mLayerDDBlockMaxNumberOfClasses;
670 double mFactor = 1.0;
671 bool mForce2d =
false;
675 void appendCurve(
const QgsCurve &
c, QVector<QgsPoint> &points, QVector<double> &bulges );
676 void appendLineString(
const QgsLineString &ls, QVector<QgsPoint> &points, QVector<double> &bulges );
677 void appendCircularString(
const QgsCircularString &cs, QVector<QgsPoint> &points, QVector<double> &bulges );
678 void appendCompoundCurve(
const QgsCompoundCurve &cc, QVector<QgsPoint> &points, QVector<double> &bulges );
682 QList<DxfLayerJob *> mJobs;
683 std::unique_ptr<QgsLabelingEngine> mLabelingEngine;
685 QString mFeedbackMessage;
The Qgis class provides global constants for use throughout the application.
DistanceUnit
Units of distance.
RenderUnit
Rendering size units.
FeatureSymbologyExport
Options for exporting features considering their symbology.
@ NoSymbology
Export only data.
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.
Qgis::FeatureSymbologyExport symbologyExport() const
Gets 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.
void setSymbologyScale(double scale)
Set reference scale for output.
bool force2d()
Retrieve whether the output should be forced to 2d.
QFlags< DxfPolylineFlag > DxfPolylineFlags
void setExtent(const QgsRectangle &r)
Set extent of area to export.
double symbologyScale() const
Returns the reference scale for output.
VAlign
Vertical alignments.
void setSymbologyExport(Qgis::FeatureSymbologyExport e)
Set 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.
Abstract base class for marker symbol layers.
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 grouped map of multiple QgsProperty objects, each referenced by a integer key value.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
Abstract base class for all rendered symbols.
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
#define SIP_ENUM_BASETYPE(type)
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(QgsTextRendererUtils::CurvedTextFlags)
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...
bool buildDataDefinedBlocks() const
Flag if data defined point block symbols should be created.
int dataDefinedBlocksMaximumNumberOfClasses() const
Returns the maximum number of data defined symbol classes for which blocks are created.
QgsVectorLayer * layer() const
Returns the layer.
DxfLayer(QgsVectorLayer *vl, int layerOutputAttributeIndex=-1, bool buildDDBlocks=false, int ddBlocksMaxNumberOfClasses=-1)
int layerOutputAttributeIndex() const
Returns the attribute index used to split into multiple layers.