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 )
134 int writeToFile( QIODevice *d, const QString &codec );
142 void setSymbologyScale(
double scale ) { mSymbologyScale = scale; }
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 );
402 void clipValueToMapUnitScale(
double &value,
const QgsMapUnitScale &scale,
double pixelToMMFactor )
const;
405 static QString dxfLayerName(
const QString &name );
408 static QString dxfEncoding(
const QString &name );
411 static QStringList encodings();
429 void registerDxfLayer(
const QString &layerId,
QgsFeatureId fid,
const QString &layer );
435 double mSymbologyScale = 1.0;
438 bool mLayerTitleAsName =
false;
440 QTextStream mTextStream;
442 static int sDxfColors[][3];
443 static const char *DXF_ENCODINGS[][2];
445 int mSymbolLayerCounter = 0;
447 int mBlockCounter = 0;
449 QHash< const QgsSymbolLayer *, QString > mLineStyles;
450 QHash< const QgsSymbolLayer *, QString > mPointSymbolBlocks;
453 void writeHeader(
const QString &codepage );
456 void writeEntities();
464 void writeDefaultLinetypes();
465 void writeSymbolLayerLinetype(
const QgsSymbolLayer *symbolLayer );
482 QString lineStyleFromSymbolLayer(
const QgsSymbolLayer *symbolLayer );
485 static int color_distance( QRgb p1,
int index );
486 static QRgb createRgbEntry( qreal r, qreal g, qreal b );
491 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > symbolLayers(
QgsRenderContext &context );
492 static int nLineTypes(
const QList< QPair< QgsSymbolLayer *, QgsSymbol *> > &symbolLayers );
494 double dashSize()
const;
495 double dotSize()
const;
496 double dashSeparatorSize()
const;
497 double sizeToMapUnits(
double s )
const;
498 static QString lineNameFromPenStyle( Qt::PenStyle style );
499 bool layerIsScaleBasedVisible(
const QgsMapLayer *layer )
const;
501 QHash<QString, int> mBlockHandles;
502 QString mBlockHandle;
505 QMap< QString, QMap<QgsFeatureId, QString> > mDxfLayerNames;
508 QHash<QString, int> mLayerNameAttribute;
509 double mFactor = 1.0;
510 bool mForce2d =
false;
512 QgsDxfExport::Flags mFlags =
nullptr;
516 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDxfExport::Flags )
518 #endif // QGSDXFEXPORT_H A rectangle specified with double values.
Base class for all map layer types.
QgsVectorLayer * layer() const
Returns the layer.
DxfLayer(QgsVectorLayer *vl, int layerOutputAttributeIndex=-1)
double symbologyScale() const
Returns the reference scale for output.
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.
void setSymbologyExport(QgsDxfExport::SymbologyExport e)
Set symbology export mode.
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.
QgsRectangle extent() const
Gets extent of area to export.
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
Contains information about the context of a rendering operation.
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.
bool layerTitleAsName()
Retrieve whether layer title (where set) instead of name shall be use.
This class represents a coordinate reference system (CRS).
QgsDxfExport::SymbologyExport symbologyExport() const
Gets symbology export mode.
LabelPosition is a candidate feature label position.
int layerOutputAttributeIndex() const
Returns the attribute index used to split into multiple layers.
Represents a vector layer which manages a vector based data sets.
RenderUnit
Rendering size units.