18 #ifndef QGSDXFEXPORT_H 19 #define QGSDXFEXPORT_H 21 #include "qgis_core.h" 30 #include <QTextStream> 38 #define DXF_HANDSEED 100 39 #define DXF_HANDMAX 9999999 40 #define DXF_HANDPLOTSTYLE 0xf 63 , mLayerOutputAttributeIndex( layerOutputAttributeIndex )
77 int mLayerOutputAttributeIndex = -1;
92 Q_DECLARE_FLAGS( Flags,
Flag )
112 void setFlags( QgsDxfExport::Flags flags );
119 QgsDxfExport::Flags flags()
const;
126 void addLayers(
const QList< QgsDxfExport::DxfLayer > &layers );
134 int writeToFile( QIODevice *d,
const QString &codec );
231 static int closestColorMatch( QRgb color );
239 QString layerName(
const QString &
id,
const QgsFeature &
f )
const;
255 void writeGroup(
int code,
int i )
SIP_PYNAME( writeGroupInt );
263 void writeGroup(
int code,
double d )
SIP_PYNAME( writeGroupDouble );
270 void writeGroup(
int code,
const QString &s );
289 void writeGroup(
const QColor &color,
int exactMatch = 62,
int rgbCode = 420,
int transparencyCode = 440 );
295 void writeGroupCode(
int code );
301 void writeInt(
int i );
307 void writeDouble(
double d );
313 void writeString(
const QString &s );
321 int writeHandle(
int code = 5,
int handle = 0 );
333 void writePolyline(
const QgsPointSequence &line,
const QString &layer,
const QString &lineStyleName,
const QColor &color,
double width = -1 )
SIP_SKIP;
344 void writePolygon(
const QgsRingSequence &polygon,
const QString &layer,
const QString &hatchPattern,
const QColor &color )
SIP_SKIP;
350 void writeLine(
const QgsPoint &pt1,
const QgsPoint &pt2,
const QString &layer,
const QString &lineStyleName,
const QColor &color,
double width = -1 );
357 void writePoint(
const QString &layer,
const QColor &color,
const QgsPoint &pt )
SIP_PYNAME( writePointV2 );
364 void writeFilledCircle(
const QString &layer,
const QColor &color,
const QgsPoint &pt,
double radius )
SIP_PYNAME( writeFillCircleV2 );
371 void writeCircle(
const QString &layer,
const QColor &color,
const QgsPoint &pt,
double radius,
const QString &lineStyleName,
double width )
SIP_PYNAME( writeCircleV2 );
378 void writeText(
const QString &layer,
const QString &text,
const QgsPoint &pt,
double size,
double angle,
const QColor &color )
SIP_PYNAME( writeTextV2 );
385 void writeMText(
const QString &layer,
const QString &text,
const QgsPoint &pt,
double width,
double angle,
const QColor &color );
394 static QString dxfLayerName(
const QString &name );
397 static QString dxfEncoding(
const QString &name );
400 static QStringList encodings();
418 void registerDxfLayer(
const QString &layerId,
QgsFeatureId fid,
const QString &layer );
424 double mSymbologyScale = 1.0;
427 bool mLayerTitleAsName =
false;
429 QTextStream mTextStream;
431 static int sDxfColors[][3];
432 static const char *DXF_ENCODINGS[][2];
434 int mSymbolLayerCounter = 0;
436 int mBlockCounter = 0;
438 QHash< const QgsSymbolLayer *, QString > mLineStyles;
439 QHash< const QgsSymbolLayer *, QString > mPointSymbolBlocks;
442 void writeHeader(
const QString &codepage );
445 void writeEntities();
453 void writeDefaultLinetypes();
454 void writeSymbolLayerLinetype(
const QgsSymbolLayer *symbolLayer );
461 QString lineStyleFromSymbolLayer(
const QgsSymbolLayer *symbolLayer );
464 static int color_distance( QRgb p1,
int index );
465 static QRgb createRgbEntry( qreal r, qreal g, qreal b );
470 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > symbolLayers(
QgsRenderContext &context );
471 static int nLineTypes(
const QList< QPair< QgsSymbolLayer *, QgsSymbol *> > &symbolLayers );
473 double dashSize()
const;
474 double dotSize()
const;
475 double dashSeparatorSize()
const;
476 double sizeToMapUnits(
double s )
const;
477 static QString lineNameFromPenStyle( Qt::PenStyle style );
478 bool layerIsScaleBasedVisible(
const QgsMapLayer *layer )
const;
480 QHash<QString, int> mBlockHandles;
481 QString mBlockHandle;
484 QMap< QString, QMap<QgsFeatureId, QString> > mDxfLayerNames;
487 QHash<QString, int> mLayerNameAttribute;
488 double mFactor = 1.0;
489 bool mForce2d =
false;
491 QgsDxfExport::Flags mFlags =
nullptr;
495 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDxfExport::Flags )
497 #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
Get symbology export mode.
DxfLayer(QgsVectorLayer *vl, int layerOutputAttributeIndex=-1)
A class to represent a 2D point.
bool force2d()
Retrieve whether the output should be forced to 2d.
void setSymbologyExport(QgsDxfExport::SymbologyExport e)
Set symbology export mode.
QgsVectorLayer * layer() const
Return 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...
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.
void setForce2d(bool force2d)
Force 2d output (eg.
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.
QgsRectangle extent() const
Get 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...
void setExtent(const QgsRectangle &r)
Set extent of area to export.
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.
Represents a vector layer which manages a vector based data sets.
RenderUnit
Rendering size units.
int layerOutputAttributeIndex() const
Return the attribute index used to split into multiple layers.