18 #ifndef QGSDXFEXPORT_H 
   19 #define QGSDXFEXPORT_H 
   21 #include "qgis_core.h" 
   31 #include <QTextStream> 
   44 #define DXF_HANDSEED 100 
   45 #define DXF_HANDMAX 9999999 
   46 #define DXF_HANDPLOTSTYLE 0xf 
   75           , mLayerOutputAttributeIndex( layerOutputAttributeIndex )
 
   94         QString splitLayerAttribute() 
const;
 
   98         int mLayerOutputAttributeIndex = -1;
 
  111       FlagNoMText = 1 << 1, 
 
  113     Q_DECLARE_FLAGS( Flags, Flag )
 
  124       DeviceNotWritableError, 
 
  163       Is3DPolygonMesh = 16, 
 
  166       ContinuousPattern = 128, 
 
  169     Q_DECLARE_FLAGS( DxfPolylineFlags, DxfPolylineFlag )
 
  189     void setFlags( QgsDxfExport::Flags flags );
 
  196     QgsDxfExport::Flags flags() 
const;
 
  203     void addLayers( 
const QList< QgsDxfExport::DxfLayer > &layers );
 
  211     ExportResult writeToFile( QIODevice *d, 
const QString &codec );  
 
  308     static int closestColorMatch( QRgb color );
 
  316     QString layerName( 
const QString &
id, 
const QgsFeature &f ) 
const;
 
  332     void writeGroup( 
int code, 
int i ) 
SIP_PYNAME( writeGroupInt );
 
  340     void writeGroup( 
int code, 
double d ) 
SIP_PYNAME( writeGroupDouble );
 
  347     void writeGroup( 
int code, 
const QString &s );
 
  366     void writeGroup( 
const QColor &color, 
int exactMatch = 62, 
int rgbCode = 420, 
int transparencyCode = 440 );
 
  372     void writeGroupCode( 
int code );
 
  378     void writeInt( 
int i );
 
  384     void writeDouble( 
double d );
 
  390     void writeString( 
const QString &s );
 
  398     int writeHandle( 
int code = 5, 
int handle = 0 );
 
  410     void writePolyline( 
const QgsPointSequence &line, 
const QString &layer, 
const QString &lineStyleName, 
const QColor &color, 
double width = -1 ) 
SIP_SKIP;
 
  422     void writePolyline( const 
QgsCurve &curve, const QString &layer, const QString &lineStyleName, const QColor &color, 
double width = -1 ) 
SIP_SKIP;
 
  433     void writePolygon( const 
QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color ) 
SIP_SKIP;
 
  444     void writePolygon( const 
QgsCurvePolygon &polygon, const QString &layer, const QString &hatchPattern, const QColor &color ) 
SIP_SKIP;
 
  450     void writeLine( const 
QgsPoint &pt1, const 
QgsPoint &pt2, const QString &layer, const QString &lineStyleName, const QColor &color, 
double width = -1 );
 
  457     void writePoint( const QString &layer, const QColor &color, const 
QgsPoint &pt ) 
SIP_PYNAME( writePointV2 );
 
  464     void writeFilledCircle( const QString &layer, const QColor &color, const 
QgsPoint &pt, 
double radius ) 
SIP_PYNAME( writeFillCircleV2 );
 
  471     void writeCircle( const QString &layer, const QColor &color, const 
QgsPoint &pt, 
double radius, const QString &lineStyleName, 
double width ) 
SIP_PYNAME( writeCircleV2 );
 
  485     void writeMText( const QString &layer, const QString &text, const 
QgsPoint &pt, 
double width, 
double angle, const QColor &color );
 
  494     static 
double mapUnitScaleFactor( 
double scale, 
QgsUnitTypes::RenderUnit symbolUnits, 
QgsUnitTypes::DistanceUnit mapUnits, 
double mapUnitsPerPixel = 1.0 );
 
  502     void clipValueToMapUnitScale( 
double &value, const 
QgsMapUnitScale &scale, 
double pixelToMMFactor ) const;
 
  505     static QString dxfLayerName( const QString &name );
 
  508     static QString dxfEncoding( const QString &name );
 
  511     static QStringList encodings();
 
  528     Q_DECL_DEPRECATED 
void registerDxfLayer( const QString &layerId, 
QgsFeatureId fid, const QString &layer );
 
  539     double mSymbologyScale = 1.0;
 
  540     SymbologyExport mSymbologyExport = NoSymbology;
 
  542     bool mLayerTitleAsName = 
false;
 
  544     QTextStream mTextStream;
 
  546     int mSymbolLayerCounter = 0; 
 
  548     int mBlockCounter = 0;
 
  550     QHash< const QgsSymbolLayer *, QString > mLineStyles; 
 
  551     QHash< const QgsSymbolLayer *, QString > mPointSymbolBlocks; 
 
  554     void writeHeader( 
const QString &codepage );
 
  555     void prepareRenderers();
 
  558     void writeEntities();
 
  559     void writeEntitiesSymbolLevels( 
DxfLayerJob *job );
 
  560     void stopRenderers();
 
  567     void writeDefaultLinetypes();
 
  568     void writeSymbolLayerLinetype( 
const QgsSymbolLayer *symbolLayer );
 
  590     QString lineStyleFromSymbolLayer( 
const QgsSymbolLayer *symbolLayer );
 
  593     static int color_distance( QRgb p1, 
int index );
 
  594     static QRgb createRgbEntry( qreal r, qreal g, qreal b );
 
  599     QList< QPair< QgsSymbolLayer *, QgsSymbol * > > symbolLayers( 
QgsRenderContext &context );
 
  600     static int nLineTypes( 
const QList< QPair< QgsSymbolLayer *, QgsSymbol *> > &symbolLayers );
 
  602     double dashSize() 
const;
 
  603     double dotSize() 
const;
 
  604     double dashSeparatorSize() 
const;
 
  605     double sizeToMapUnits( 
double s ) 
const;
 
  606     static QString lineNameFromPenStyle( Qt::PenStyle style );
 
  607     bool layerIsScaleBasedVisible( 
const QgsMapLayer *layer ) 
const;
 
  609     QHash<QString, int> mBlockHandles;
 
  610     QString mBlockHandle;
 
  613     QMap< QString, QMap<QgsFeatureId, QString> > mDxfLayerNames;
 
  616     QHash<QString, int> mLayerNameAttribute;
 
  617     double mFactor = 1.0;
 
  618     bool mForce2d = 
false;
 
  620     QgsDxfExport::Flags mFlags = 
nullptr;
 
  622     void appendCurve( 
const QgsCurve &
c, QVector<QgsPoint> &points, QVector<double> &bulges );
 
  623     void appendLineString( 
const QgsLineString &ls, QVector<QgsPoint> &points, QVector<double> &bulges );
 
  624     void appendCircularString( 
const QgsCircularString &cs, QVector<QgsPoint> &points, QVector<double> &bulges );
 
  625     void appendCompoundCurve( 
const QgsCompoundCurve &cc, QVector<QgsPoint> &points, QVector<double> &bulges );
 
  629     QList<DxfLayerJob *> mJobs;
 
  630     std::unique_ptr<QgsLabelingEngine> mLabelingEngine;
 
  633 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDxfExport::Flags )
 
  634 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDxfExport::DxfPolylineFlags )
 
  636 #endif // QGSDXFEXPORT_H