73 mMapSettings = settings;
88 QList<QgsMapLayer *> layerList;
90 mLayerNameAttribute.clear();
92 for (
const DxfLayer &dxfLayer : layers )
94 layerList << dxfLayer.layer();
95 if ( dxfLayer.layerOutputAttributeIndex() >= 0 )
96 mLayerNameAttribute.insert( dxfLayer.layer()->id(), dxfLayer.layerOutputAttributeIndex() );
124 if ( !mForce2d && p.
is3D() && std::isfinite( p.
z() ) )
131 int minDist = std::numeric_limits<int>::max();
133 for (
int i = 1; i < static_cast< int >(
sizeof( sDxfColors ) /
sizeof( *sDxfColors ) ) && minDist > 0; ++i )
135 int dist = color_distance( color.rgba(), i );
136 if ( dist >= minDist )
143 if ( minDist == 0 && minDistAt != 7 )
147 if ( color.alpha() == 255 )
151 int c = ( color.red() & 0xff ) * 0x10000 + ( color.green() & 0xff ) * 0x100 + ( color.blue() & 0xff );
153 if ( transparencyCode != -1 && color.alpha() < 255 )
154 writeGroup( transparencyCode, 0x2000000 | color.alpha() );
159 mTextStream << QStringLiteral(
"%1\n" ).arg( code, 3, 10, QChar(
' ' ) );
164 mTextStream << QStringLiteral(
"%1\n" ).arg( i, 6, 10, QChar(
' ' ) );
170 if ( !s.contains(
'.' ) )
171 s += QLatin1String(
".0" );
172 mTextStream << s <<
'\n';
177 mTextStream << s <<
'\n';
187 if ( !d->isOpen() && !d->open( QIODevice::WriteOnly | QIODevice::Truncate ) )
192 mTextStream.setDevice( d );
193 mTextStream.setCodec( encoding.toLocal8Bit() );
200 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
215 mExtent = layerExtent;
251 void QgsDxfExport::writeHeader(
const QString &codepage )
253 writeGroup( 999, QStringLiteral(
"DXF created from QGIS" ) );
259 writeGroup( 9, QStringLiteral(
"$ACADVER" ) );
271 writeGroup( 9, QStringLiteral(
"$LTSCALE" ) );
283 writeGroup( 9, QStringLiteral(
"$PSLTSCALE" ) );
286 writeGroup( 9, QStringLiteral(
"$HANDSEED" ) );
289 writeGroup( 9, QStringLiteral(
"$DWGCODEPAGE" ) );
298 handle = mNextHandleId++;
300 Q_ASSERT_X( handle <
DXF_HANDMAX,
"QgsDxfExport::writeHandle(int, int)",
"DXF handle too large" );
302 writeGroup( code, QStringLiteral(
"%1" ).arg( handle, 0, 16 ) );
306 void QgsDxfExport::writeTables()
313 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > slList;
316 slList = symbolLayers( context );
324 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
327 writeDefaultLinetypes();
330 for (
const auto &symbolLayer : qgis::as_const( slList ) )
332 writeSymbolLayerLinetype( symbolLayer.first );
339 writeGroup( 2, QStringLiteral(
"BLOCK_RECORD" ) );
342 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
345 const QStringList blockStrings = QStringList() << QStringLiteral(
"*Model_Space" ) << QStringLiteral(
"*Paper_Space" ) << QStringLiteral(
"*Paper_Space0" );
346 for (
const QString &block : blockStrings )
348 writeGroup( 0, QStringLiteral(
"BLOCK_RECORD" ) );
350 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
351 writeGroup( 100, QStringLiteral(
"AcDbBlockTableRecord" ) );
356 for (
const auto &symbolLayer : qgis::as_const( slList ) )
362 if ( hasDataDefinedProperties( ml, symbolLayer.second ) )
365 QString name = QStringLiteral(
"symbolLayer%1" ).arg( i++ );
366 writeGroup( 0, QStringLiteral(
"BLOCK_RECORD" ) );
368 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
369 writeGroup( 100, QStringLiteral(
"AcDbBlockTableRecord" ) );
379 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
383 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
384 writeGroup( 100, QStringLiteral(
"AcDbRegAppTableRecord" ) );
393 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
401 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
409 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
413 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
414 writeGroup( 100, QStringLiteral(
"AcDbViewportTableRecord" ) );
453 writeGroup( 2, QStringLiteral(
"DIMSTYLE" ) );
455 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
456 writeGroup( 100, QStringLiteral(
"AcDbDimStyleTable" ) );
460 QSet<QString> layerNames;
461 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
464 if ( !layerIsScaleBasedVisible( ml ) )
471 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
478 const QSet<QVariant> values = vl->
uniqueValues( attrIdx );
479 for (
const QVariant &v : values )
491 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
496 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
497 writeGroup( 100, QStringLiteral(
"AcDbLayerTableRecord" ) );
501 writeGroup( 6, QStringLiteral(
"CONTINUOUS" ) );
504 for (
const QString &
layerName : qgis::as_const( layerNames ) )
508 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
509 writeGroup( 100, QStringLiteral(
"AcDbLayerTableRecord" ) );
513 writeGroup( 6, QStringLiteral(
"CONTINUOUS" ) );
522 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
528 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
529 writeGroup( 100, QStringLiteral(
"AcDbTextStyleTableRecord" ) );
530 writeGroup( 2, QStringLiteral(
"STANDARD" ) );
537 writeGroup( 3, QStringLiteral(
"romans.shx" ) );
545 void QgsDxfExport::writeBlocks()
550 static const QStringList blockStrings = QStringList() << QStringLiteral(
"*Model_Space" ) << QStringLiteral(
"*Paper_Space" ) << QStringLiteral(
"*Paper_Space0" );
551 for (
const QString &block : blockStrings )
555 writeGroup( 330, QStringLiteral(
"%1" ).arg( mBlockHandles[ block ], 0, 16 ) );
556 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
558 writeGroup( 100, QStringLiteral(
"AcDbBlockBegin" ) );
566 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
568 writeGroup( 100, QStringLiteral(
"AcDbBlockEnd" ) );
574 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > slList;
577 slList = symbolLayers( ct );
580 for (
const auto &symbolLayer : qgis::as_const( slList ) )
590 if ( hasDataDefinedProperties( ml, symbolLayer.second ) )
595 QString block( QStringLiteral(
"symbolLayer%1" ).arg( mBlockCounter++ ) );
596 mBlockHandle = QStringLiteral(
"%1" ).arg( mBlockHandles[ block ], 0, 16 );
601 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
603 writeGroup( 100, QStringLiteral(
"AcDbBlockBegin" ) );
616 ml->
writeDxf( *
this,
mapUnitScaleFactor( mSymbologyScale, ml->
sizeUnit(), mMapUnits, ctx.renderContext().mapToPixel().mapUnitsPerPixel() ), QStringLiteral(
"0" ), ctx );
620 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
622 writeGroup( 100, QStringLiteral(
"AcDbBlockEnd" ) );
624 mPointSymbolBlocks.insert( ml, block );
630 void QgsDxfExport::writeEntities()
633 writeGroup( 2, QStringLiteral(
"ENTITIES" ) );
635 mBlockHandle = QStringLiteral(
"%1" ).arg( mBlockHandles[ QStringLiteral(
"*Model_Space" )], 0, 16 );
644 job->renderer->usingSymbolLevels() )
646 writeEntitiesSymbolLevels( job );
662 QString lName(
dxfLayerName( job->splitLayerAttribute.isNull() ? job->layerTitle : fet.
attribute( job->splitLayerAttribute ).toString() ) );
666 if ( !job->renderer->willRenderFeature( fet, mRenderContext ) )
671 addFeature( sctx, ct, lName,
nullptr,
nullptr );
675 const QgsSymbolList symbolList = job->renderer->symbolsForFeature( fet, mRenderContext );
676 bool hasSymbology = symbolList.size() > 0;
688 bool isGeometryGenerator = ( symbolLayer->layerType() == QLatin1String(
"GeometryGenerator" ) );
689 if ( isGeometryGenerator )
691 addGeometryGeneratorSymbolLayer( sctx, ct, lName, symbolLayer,
true );
695 addFeature( sctx, ct, lName, symbolLayer, symbol );
700 else if ( hasSymbology )
711 addGeometryGeneratorSymbolLayer( sctx, ct, lName, s->
symbolLayer( 0 ), false );
715 addFeature( sctx, ct, lName, s->
symbolLayer( 0 ), s );
719 if ( job->labelProvider )
721 job->labelProvider->registerDxfFeature( fet, mRenderContext, lName );
723 else if ( job->ruleBasedLabelProvider )
725 job->ruleBasedLabelProvider->registerDxfFeature( fet, mRenderContext, lName );
731 QImage image( 10, 10, QImage::Format_ARGB32_Premultiplied );
732 image.setDotsPerMeterX( 96 / 25.4 * 1000 );
733 image.setDotsPerMeterY( 96 / 25.4 * 1000 );
734 QPainter painter( &image );
742 void QgsDxfExport::prepareRenderers()
744 Q_ASSERT( mJobs.empty() );
747 mRenderContext.setRendererScale( mSymbologyScale );
748 mRenderContext.setExtent( mExtent );
750 mRenderContext.setScaleFactor( 96.0 / 25.4 );
752 mExtent.
height() * mFactor, 0 ) );
757 mLabelingEngine = qgis::make_unique<QgsDefaultLabelingEngine>();
758 mLabelingEngine->setMapSettings( mMapSettings );
759 mRenderContext.setLabelingEngine( mLabelingEngine.get() );
761 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
771 if ( !layerIsScaleBasedVisible( vl ) )
774 QString splitLayerAttribute;
775 int splitLayerAttributeIndex = mLayerNameAttribute.value( vl->
id(), -1 );
777 if ( splitLayerAttributeIndex >= 0 && splitLayerAttributeIndex < fields.
size() )
778 splitLayerAttribute = fields.
at( splitLayerAttributeIndex ).
name();
784 void QgsDxfExport::writeEntitiesSymbolLevels(
DxfLayerJob *job )
786 QHash< QgsSymbol *, QList<QgsFeature> > features;
808 featureSymbol = job->
renderer->symbolForFeature( fet, ctx );
809 if ( !featureSymbol )
814 QHash< QgsSymbol *, QList<QgsFeature> >::iterator it = features.find( featureSymbol );
815 if ( it == features.end() )
817 it = features.insert( featureSymbol, QList<QgsFeature>() );
819 it.value().append( fet );
827 for (
int j = 0; j < symbol->symbolLayerCount(); j++ )
829 int level = symbol->symbolLayer( j )->renderingPass();
830 if ( level < 0 || level >= 1000 )
833 while ( level >= levels.count() )
835 levels[level].append( item );
844 QHash< QgsSymbol *, QList<QgsFeature> >::iterator levelIt = features.find( item.symbol() );
845 if ( levelIt == features.end() )
850 int llayer = item.layer();
851 const QList<QgsFeature> &featureList = levelIt.value();
852 for (
const QgsFeature &feature : featureList )
855 addFeature( sctx, ct, job->
layerName, levelIt.key()->symbolLayer( llayer ), levelIt.key() );
861 void QgsDxfExport::stopRenderers()
867 void QgsDxfExport::writeEndFile()
874 void QgsDxfExport::startSection()
879 void QgsDxfExport::endSection()
904 QHash< const QgsSymbolLayer *, QString >::const_iterator blockIt = mPointSymbolBlocks.constFind( symbolLayer );
905 if ( !symbolLayer || blockIt == mPointSymbolBlocks.constEnd() )
923 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
924 writeGroup( 100, QStringLiteral(
"AcDbBlockReference" ) );
937 QgsDebugMsg( QStringLiteral(
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
943 QgsDebugMsg( QStringLiteral(
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
947 if ( mForce2d || !line.at( 0 ).is3D() )
949 bool polygon = line[0] == line[ line.size() - 1 ];
953 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
956 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
957 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
965 for (
int i = 0; i < n; i++ )
970 writeGroup( 0, QStringLiteral(
"POLYLINE" ) );
973 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
977 writeGroup( 100, QStringLiteral(
"AcDb3dPolyline" ) );
981 for (
int i = 0; i < n; i++ )
986 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
989 writeGroup( 100, QStringLiteral(
"AcDbVertex" ) );
990 writeGroup( 100, QStringLiteral(
"AcDb3dPolylineVertex" ) );
998 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1004 void QgsDxfExport::appendCurve(
const QgsCurve &
c, QVector<QgsPoint> &points, QVector<double> &bulges )
1009 appendLineString( *dynamic_cast<const QgsLineString *>( &c ), points, bulges );
1013 appendCircularString( *dynamic_cast<const QgsCircularString *>( &c ), points, bulges );
1017 appendCompoundCurve( *dynamic_cast<const QgsCompoundCurve *>( &c ), points, bulges );
1026 void QgsDxfExport::appendLineString(
const QgsLineString &ls, QVector<QgsPoint> &points, QVector<double> &bulges )
1028 for (
int i = 0; i < ls.
numPoints(); i++ )
1031 if ( !points.isEmpty() && points.last() == p )
1039 void QgsDxfExport::appendCircularString(
const QgsCircularString &cs, QVector<QgsPoint> &points, QVector<double> &bulges )
1041 for (
int i = 0; i < cs.
numPoints() - 2; i += 2 )
1047 if ( points.isEmpty() || points.last() != p1 )
1049 else if ( !bulges.isEmpty() )
1050 bulges.removeLast();
1052 double a = ( M_PI - ( p1 - p2 ).
angle() + ( p3 - p2 ).
angle() ) / 2.0;
1053 bulges << sin( a ) / cos( a );
1060 void QgsDxfExport::appendCompoundCurve(
const QgsCompoundCurve &cc, QVector<QgsPoint> &points, QVector<double> &bulges )
1062 for (
int i = 0; i < cc.
nCurves(); i++ )
1066 appendCurve( *c, points, bulges );
1075 QgsDebugMsg( QStringLiteral(
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
1081 QgsDebugMsg( QStringLiteral(
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
1085 QVector<QgsPoint> points;
1086 QVector<double> bulges;
1087 appendCurve( curve, points, bulges );
1089 if ( mForce2d || !curve.
is3D() )
1091 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
1094 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1095 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
1100 QgsDxfExport::DxfPolylineFlags polylineFlags;
1102 polylineFlags.setFlag( QgsDxfExport::DxfPolylineFlag::Closed );
1104 polylineFlags.setFlag( QgsDxfExport::DxfPolylineFlag::Curve );
1108 polylineFlags.setFlag( QgsDxfExport::DxfPolylineFlag::ContinuousPattern );
1110 writeGroup( 70, static_cast<int>( polylineFlags ) );
1113 for (
int i = 0; i < points.size(); i++ )
1116 if ( bulges[i] != 0.0 )
1122 writeGroup( 0, QStringLiteral(
"POLYLINE" ) );
1125 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1129 writeGroup( 100, QStringLiteral(
"AcDb3dPolyline" ) );
1133 for (
int i = 0; i < points.size(); i++ )
1138 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1141 writeGroup( 100, QStringLiteral(
"AcDbVertex" ) );
1142 writeGroup( 100, QStringLiteral(
"AcDb3dPolylineVertex" ) );
1144 if ( bulges[i] != 0.0 )
1152 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1163 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1166 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
1172 writeGroup( 70, hatchPattern == QLatin1String(
"SOLID" ) );
1176 for (
int i = 0; i < polygon.size(); ++i )
1183 for (
int j = 0; j < polygon[i].size(); ++j )
1202 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1205 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
1211 writeGroup( 70, hatchPattern == QLatin1String(
"SOLID" ) );
1214 QVector<QVector<QgsPoint>> points;
1215 QVector<QVector<double>> bulges;
1217 points << QVector<QgsPoint>();
1218 bulges << QVector<double>();
1219 appendCurve( *polygon.
exteriorRing(), points.last(), bulges.last() );
1223 points << QVector<QgsPoint>();
1224 bulges << QVector<double>();
1225 appendCurve( *polygon.
interiorRing( i ), points.last(), bulges.last() );
1228 bool hasBulges =
false;
1229 for (
int i = 0; i < points.size() && !hasBulges; ++i )
1230 for (
int j = 0; j < points[i].size() && !hasBulges; ++j )
1231 hasBulges = bulges[i][j] != 0.0;
1235 for (
int i = 0; i < points.size(); ++i )
1242 for (
int j = 0; j < points[i].size(); ++j )
1266 double lblX = label->
getX();
1267 double lblY = label->
getY();
1276 if ( layerSettings.
placement == QgsPalLayerSettings::Placement::OverPoint )
1286 if ( exprVal.isValid() )
1292 switch ( offsetQuad )
1294 case QgsPalLayerSettings::QuadrantPosition::QuadrantAboveLeft:
1298 case QgsPalLayerSettings::QuadrantPosition::QuadrantAbove:
1302 case QgsPalLayerSettings::QuadrantPosition::QuadrantAboveRight:
1306 case QgsPalLayerSettings::QuadrantPosition::QuadrantLeft:
1310 case QgsPalLayerSettings::QuadrantPosition::QuadrantOver:
1314 case QgsPalLayerSettings::QuadrantPosition::QuadrantRight:
1318 case QgsPalLayerSettings::QuadrantPosition::QuadrantBelowLeft:
1322 case QgsPalLayerSettings::QuadrantPosition::QuadrantBelow:
1326 case QgsPalLayerSettings::QuadrantPosition::QuadrantBelowRight:
1344 if ( exprVal.isValid() )
1346 const QString haliString = exprVal.toString();
1347 if ( haliString.compare( QLatin1String(
"Center" ), Qt::CaseInsensitive ) == 0 )
1351 else if ( haliString.compare( QLatin1String(
"Right" ), Qt::CaseInsensitive ) == 0 )
1363 if ( exprVal.isValid() )
1365 const QString valiString = exprVal.toString();
1366 if ( valiString.compare( QLatin1String(
"Bottom" ), Qt::CaseInsensitive ) != 0 )
1368 if ( valiString.compare( QLatin1String(
"Base" ), Qt::CaseInsensitive ) == 0 )
1372 else if ( valiString.compare( QLatin1String(
"Half" ), Qt::CaseInsensitive ) == 0 )
1391 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1392 writeGroup( 100, QStringLiteral(
"AcDbPoint" ) );
1403 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1406 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
1437 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
1441 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1442 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
1461 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1464 writeGroup( 100, QStringLiteral(
"AcDbText" ) );
1475 writeGroup( 7, QStringLiteral(
"STANDARD" ) );
1476 writeGroup( 100, QStringLiteral(
"AcDbText" ) );
1485 if ( !mTextStream.codec()->canEncode( text ) )
1488 QgsDebugMsg( QStringLiteral(
"could not encode:%1" ).arg( text ) );
1494 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1495 writeGroup( 100, QStringLiteral(
"AcDbMText" ) );
1502 while ( t.length() > 250 )
1518 writeGroup( 7, QStringLiteral(
"STANDARD" ) );
1540 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
1542 penColor = colorFromSymbolLayer( symbolLayer, ctx );
1546 Qt::PenStyle penStyle( Qt::SolidLine );
1547 Qt::BrushStyle brushStyle( Qt::NoBrush );
1549 double offset = 0.0;
1551 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
1553 width = symbolLayer->
dxfWidth( *
this, ctx );
1554 offset = symbolLayer->
dxfOffset( *
this, ctx );
1555 angle = symbolLayer->
dxfAngle( ctx );
1563 QString lineStyleName = QStringLiteral(
"CONTINUOUS" );
1566 lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
1572 writePoint( geom.constGet()->coordinateSequence().at( 0 ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol,
angle );
1579 for (
int i = 0; i < cs.size(); i++ )
1581 writePoint( cs.at( i ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol,
angle );
1586 if ( penStyle != Qt::NoPen )
1589 std::unique_ptr< QgsAbstractGeometry > tempGeom;
1600 tempGeom.reset( geos.
offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 ) );
1602 sourceGeom = tempGeom.get();
1604 sourceGeom = geom.constGet();
1609 writePolyline( *curve, layer, lineStyleName, penColor, width );
1620 tempGeom.reset( geos.
offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 ) );
1622 sourceGeom = tempGeom.get();
1624 sourceGeom = geom.constGet();
1634 writePolyline( *curve, layer, lineStyleName, penColor, width );
1646 tempGeom.reset( geos.
buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 ) );
1648 sourceGeom = tempGeom.get();
1650 sourceGeom = geom.constGet();
1654 Q_ASSERT( polygon );
1669 tempGeom.reset( geos.
buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 ) );
1671 sourceGeom = tempGeom.get();
1673 sourceGeom = geom.constGet();
1682 Q_ASSERT( polygon );
1698 if ( brushStyle != Qt::NoBrush )
1701 std::unique_ptr< QgsAbstractGeometry > tempGeom;
1709 Q_ASSERT( polygon );
1710 writePolygon( *polygon, layer, QStringLiteral(
"SOLID" ), brushColor );
1723 Q_ASSERT( polygon );
1724 writePolygon( *polygon, layer, QStringLiteral(
"SOLID" ), brushColor );
1741 return symbolLayer->
dxfColor( ctx );
1744 QString QgsDxfExport::lineStyleFromSymbolLayer(
const QgsSymbolLayer *symbolLayer )
1746 QString lineStyleName = QStringLiteral(
"CONTINUOUS" );
1749 return lineStyleName;
1752 QHash< const QgsSymbolLayer *, QString >::const_iterator lineTypeIt = mLineStyles.constFind( symbolLayer );
1753 if ( lineTypeIt != mLineStyles.constEnd() )
1755 lineStyleName = lineTypeIt.value();
1756 return lineStyleName;
1760 return lineNameFromPenStyle( symbolLayer->
dxfPenStyle() );
1767 int current_distance = std::numeric_limits<int>::max();
1768 for (
int i = 1; i < static_cast< int >(
sizeof( sDxfColors ) /
sizeof( *sDxfColors ) ); ++i )
1770 int dist = color_distance( pixel, i );
1771 if ( dist < current_distance )
1773 current_distance = dist;
1782 int QgsDxfExport::color_distance( QRgb p1,
int index )
1784 if ( index > 255 || index < 0 )
1789 double redDiff = qRed( p1 ) - sDxfColors[index][0];
1790 double greenDiff = qGreen( p1 ) - sDxfColors[index][1];
1791 double blueDiff = qBlue( p1 ) - sDxfColors[index][2];
1793 QgsDebugMsg( QStringLiteral(
"color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
1794 .arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
1796 .arg( mDxfColors[index][0] )
1797 .arg( mDxfColors[index][1] )
1798 .arg( mDxfColors[index][2] )
1799 .arg( redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff ) );
1801 return redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff;
1804 QRgb QgsDxfExport::createRgbEntry( qreal r, qreal g, qreal b )
1806 return QColor::fromRgbF( r, g, b ).rgb();
1811 return mRenderContext;
1826 return mapUnitsPerPixel;
1840 double minSizeMU = std::numeric_limits<double>::lowest();
1843 minSizeMU = scale.
minSizeMM * pixelToMMFactor * mapUnitsPerPixel;
1847 minSizeMU = std::max( minSizeMU, value );
1849 value = std::max( value, minSizeMU );
1851 double maxSizeMU = std::numeric_limits<double>::max();
1854 maxSizeMU = scale.
maxSizeMM * pixelToMMFactor * mapUnitsPerPixel;
1858 maxSizeMU = std::min( maxSizeMU, value );
1860 value = std::min( value, maxSizeMU );
1863 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > QgsDxfExport::symbolLayers(
QgsRenderContext &context )
1865 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > symbolLayers;
1876 maxSymbolLayers = 1;
1878 for (
int i = 0; i < maxSymbolLayers; ++i )
1880 symbolLayers.append( qMakePair( symbol->
symbolLayer( i ), symbol ) );
1885 return symbolLayers;
1888 void QgsDxfExport::writeDefaultLinetypes()
1891 for (
const QString <ype : { QStringLiteral(
"ByLayer" ), QStringLiteral(
"ByBlock" ), QStringLiteral(
"CONTINUOUS" ) } )
1895 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
1896 writeGroup( 100, QStringLiteral(
"AcDbLinetypeTableRecord" ) );
1899 writeGroup( 3, QStringLiteral(
"Defaultstyle" ) );
1905 double das = dashSize();
1906 double dss = dashSeparatorSize();
1907 double dos = dotSize();
1909 QVector<qreal> dashVector( 2 );
1910 dashVector[0] = das;
1911 dashVector[1] = dss;
1914 QVector<qreal> dotVector( 2 );
1919 QVector<qreal> dashDotVector( 4 );
1920 dashDotVector[0] = das;
1921 dashDotVector[1] = dss;
1922 dashDotVector[2] = dos;
1923 dashDotVector[3] = dss;
1926 QVector<qreal> dashDotDotVector( 6 );
1927 dashDotDotVector[0] = das;
1928 dashDotDotVector[1] = dss;
1929 dashDotDotVector[2] = dos;
1930 dashDotDotVector[3] = dss;
1931 dashDotDotVector[4] = dos;
1932 dashDotDotVector[5] = dss;
1936 void QgsDxfExport::writeSymbolLayerLinetype(
const QgsSymbolLayer *symbolLayer )
1945 if ( !customLinestyle.isEmpty() )
1947 QString name = QStringLiteral(
"symbolLayer%1" ).arg( mSymbolLayerCounter++ );
1948 writeLinetype( name, customLinestyle, unit );
1949 mLineStyles.insert( symbolLayer, name );
1953 int QgsDxfExport::nLineTypes(
const QList< QPair< QgsSymbolLayer *, QgsSymbol * > > &symbolLayers )
1956 for (
const auto &symbolLayer : symbolLayers )
1970 void QgsDxfExport::writeLinetype(
const QString &styleName,
const QVector<qreal> &pattern,
QgsUnitTypes::RenderUnit u )
1973 for ( qreal size : pattern )
1981 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
1982 writeGroup( 100, QStringLiteral(
"AcDbLinetypeTableRecord" ) );
1991 for ( qreal size : pattern )
1994 double segmentLength = ( isGap ? -size : size );
2020 geomExpr.
prepare( &expressionContext );
2028 symbolExpressionContextScope->
setFeature( f );
2033 for (
int i = 0; i < nSymbolLayers; ++i )
2035 addFeature( ctx, ct, layer, symbol->
symbolLayer( i ), symbol );
2044 if ( !sl || !symbol )
2057 double QgsDxfExport::dashSize()
const 2059 double size = mSymbologyScale * 0.002;
2060 return sizeToMapUnits( size );
2063 double QgsDxfExport::dotSize()
const 2065 double size = mSymbologyScale * 0.0006;
2066 return sizeToMapUnits( size );
2069 double QgsDxfExport::dashSeparatorSize()
const 2071 double size = mSymbologyScale * 0.0006;
2072 return sizeToMapUnits( size );
2075 double QgsDxfExport::sizeToMapUnits(
double s )
const 2081 QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
2086 return QStringLiteral(
"DASH" );
2088 return QStringLiteral(
"DOT" );
2089 case Qt::DashDotLine:
2090 return QStringLiteral(
"DASHDOT" );
2091 case Qt::DashDotDotLine:
2092 return QStringLiteral(
"DASHDOTDOT" );
2095 return QStringLiteral(
"CONTINUOUS" );
2101 if ( name.isEmpty() )
2102 return QStringLiteral(
"0" );
2110 layerName.replace(
'<',
'_' );
2111 layerName.replace(
'>',
'_' );
2112 layerName.replace(
'/',
'_' );
2113 layerName.replace(
'\\',
'_' );
2114 layerName.replace(
'\"',
'_' );
2115 layerName.replace(
':',
'_' );
2116 layerName.replace(
';',
'_' );
2117 layerName.replace(
'?',
'_' );
2118 layerName.replace(
'*',
'_' );
2119 layerName.replace(
'|',
'_' );
2120 layerName.replace(
'=',
'_' );
2121 layerName.replace(
'\'',
'_' );
2124 layerName.replace( QLatin1String(
"\r\n" ), QLatin1String(
"_" ) );
2125 layerName.replace(
'\r',
'_' );
2126 layerName.replace(
'\n',
'_' );
2128 return layerName.trimmed();
2131 bool QgsDxfExport::layerIsScaleBasedVisible(
const QgsMapLayer *layer )
const 2145 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
2149 if ( vl && vl->
id() == id )
2151 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
2156 return QStringLiteral(
"0" );
2161 const QList< QByteArray > codecs = QTextCodec::availableCodecs();
2162 for (
const QByteArray &codec : codecs )
2164 if ( name != codec )
2168 for ( i = 0; i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) && name != DXF_ENCODINGS[i][1]; ++i )
2171 if ( i == static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) )
2174 return DXF_ENCODINGS[i][0];
2183 const QList< QByteArray > codecs = QTextCodec::availableCodecs();
2184 for (
const QByteArray &codec : codecs )
2187 for ( i = 0; i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) && strcmp( codec.data(), DXF_ENCODINGS[i][1] ) != 0; ++i )
2190 if ( i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) )
2191 encodings << codec.data();
2199 return mLayerTitleAsName && !vl->
title().isEmpty() ? vl->
title() : vl->
name();
2217 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues = lf->
dataDefinedValues();
2222 QgsDebugMsgLevel( QStringLiteral(
"PAL font definedFont: %1, Style: %2" ).arg( dFont.toString(), dFont.styleName() ), 4 );
2252 QgsPalLabeling::dataDefinedTextStyle( tmpLyr, ddValues );
2255 QgsPalLabeling::dataDefinedTextBuffer( tmpLyr, ddValues );
2258 QgsPalLabeling::dataDefinedTextFormatting( tmpLyr, ddValues );
2264 QString dxfLayer = mDxfLayerNames[layerId][fid];
2266 QString wrapchr = tmpLyr.
wrapChar.isEmpty() ? QStringLiteral(
"\n" ) : tmpLyr.
wrapChar;
2271 bool prependSymb =
false;
2289 prependSymb =
false;
2297 symb = symb + wrapchr;
2301 prependSymb =
false;
2302 symb = wrapchr + symb;
2307 txt.prepend( symb );
2321 txt = txt.replace( wrapchr, QLatin1String(
"\\P" ) );
2322 txt.replace(
" ",
"\\~" );
2326 txt.prepend(
"\\L" ).append(
"\\l" );
2331 txt.prepend(
"\\O" ).append(
"\\o" );
2336 txt.prepend(
"\\K" ).append(
"\\k" );
2339 txt.prepend( QStringLiteral(
"\\f%1|i%2|b%3;\\H%4;" )
2341 .arg( tmpLyr.
format().
font().italic() ? 1 : 0 )
2342 .arg( tmpLyr.
format().
font().bold() ? 1 : 0 )
2343 .arg( label->
getHeight() / ( 1 + txt.count( QStringLiteral(
"\\P" ) ) ) * 0.75 ) );
2351 if ( !mDxfLayerNames.contains( layerId ) )
2352 mDxfLayerNames[ layerId ] = QMap<QgsFeatureId, QString>();
2354 mDxfLayerNames[layerId][fid] =
layerName;
2370 QString splitLayerFieldName;
2371 const QgsFields fields = mLayer->fields();
2372 if ( mLayerOutputAttributeIndex >= 0 && mLayerOutputAttributeIndex < fields.
size() )
2374 splitLayerFieldName = fields.
at( mLayerOutputAttributeIndex ).
name();
2377 return splitLayerFieldName;
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
Class for parsing and evaluation of expressions (formerly called "search strings").
virtual QVector< qreal > dxfCustomDashPattern(QgsUnitTypes::RenderUnit &unit) const
Gets dash pattern.
Wrapper for iterator of features from vector data provider or vector layer.
QString labelText() const
Text of the label.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
A rectangle specified with double values.
Base class for all map layer types.
void setExtent(const QgsRectangle &rect, bool magnified=true)
Set coordinates of the rectangle which should be rendered.
double minSizeMM
The minimum size in millimeters, or 0.0 if unset.
QString leftDirectionSymbol
String to use for left direction arrows.
void writeLine(const QgsPoint &pt1, const QgsPoint &pt2, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Write line (as a polyline)
void clipValueToMapUnitScale(double &value, const QgsMapUnitScale &scale, double pixelToMMFactor) const
Clips value to scale minimum/maximum.
int size() const
Returns number of items.
int numPoints() const override
Returns the number of points in the curve.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
QgsFeatureId featureId() const
Returns the unique ID of the feature.
Abstract base class for all rendered symbols.
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
QgsLabelFeature * feature()
Returns the parent feature.
virtual double dxfOffset(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets offset.
QgsLabelingEngine * labelingEngine() const
Gets access to new labeling engine (may be nullptr)
void writeGroup(int code, int i)
Write a tuple of group code and integer value.
void writePolyline(const QgsPointSequence &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE)
Place direction symbols on below label.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QVector< QgsRingSequence > QgsCoordinateSequence
QString geometryExpression() const
Gets the expression to generate this geometry.
Export text as TEXT elements. If not set, text will be exported as MTEXT elements.
double getY(int i=0) const
Returns the down-left y coordinate.
A simple line symbol layer, which renders lines using a line in a variety of styles (e...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) override
Gets an iterator for features matching the specified request.
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
void setFont(const QFont &font)
Sets the font used for rendering text.
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > & dataDefinedValues() const
Gets data-defined values.
QgsAbstractGeometry * buffer(double distance, int segments, QString *errorMsg=nullptr) const override
void setOutputDpi(double dpi)
Sets DPI used for conversion between real world units (e.g. mm) and pixels.
void registerDxfLayer(const QString &layerId, QgsFeatureId fid, const QString &layer)
Register name of layer for feature.
static int closestColorMatch(QRgb color)
Gets DXF palette index of nearest entry for given color.
QuadrantPosition quadOffset
Sets the quadrant in which to offset labels from feature.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QColor color() const
Returns the color that text will be rendered in.
Class that adds extra information to QgsLabelFeature for text labels.
Curve polygon geometry type.
static QStringList encodings()
Returns list of available DXF encodings.
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
Container of fields for a vector layer.
bool addDirectionSymbol
If true, '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will be ...
QgsDxfExport::Flags flags() const
Returns the export flags.
A geometry is the spatial representation of a feature.
bool drawLabels
Whether to draw labels for this layer.
Holds information about each layer in a DXF job.
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
QgsUnitTypes::DistanceUnit mapUnits
MultiLineAlign multilineAlign
Horizontal alignment of multi-line labels.
QgsUnitTypes::DistanceUnit mapUnits() const
Retrieve map units.
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets line width.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
QgsPointXY anchorPosition() const
In case of quadrand or aligned positioning, this is set to the anchor point.
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
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Rotation of symbol may be changed during rendering and symbol should not be cached.
QgsPoint pointN(int i) const
Returns the point at index i within the circular string.
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)
bool reverseDirectionSymbol
True if direction symbols should be reversed.
double maxScale
The maximum scale, or 0.0 if unset.
void setFlags(QgsDxfExport::Flags flags)
Sets the export flags.
void writeInt(int i)
Write an integer value.
bool minSizeMMEnabled
Whether the minimum size in mm should be respected.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
void writePolygon(const QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
int numPoints() const override
Returns the number of points in the curve.
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
QList< QgsSymbolLevel > QgsSymbolLevelOrder
The QgsMapSettings class contains configuration for rendering of the map.
QgsRenderContext renderContext
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
void setMapSettings(const QgsMapSettings &settings)
Set map settings and assign layer name attributes.
void writeString(const QString &s)
Write a string value.
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
QVariant value(int key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const override
Returns the calculated value of the property with the specified key from within the collection...
QString wktTypeStr() const
Returns the WKT type string of the geometry.
Perform transforms between map coordinates and device coordinates.
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
void writePoint(const QString &layer, const QColor &color, const QgsPoint &pt)
Write point.
QgsVectorLayerFeatureSource featureSource
Type
The WKB type describes the number of dimensions a geometry has.
QList< QgsSymbol * > QgsSymbolList
void setOutputSize(QSize size)
Sets the size of the resulting map image.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
FeaturePart * getFeaturePart() const
Returns the feature corresponding to this labelposition.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
Set destination CRS.
#define QgsDebugMsgLevel(str, level)
bool isEmpty() const
Returns true if the rectangle is empty.
QgsFields fields() const
Returns the fields that will be available for features that are retrieved from this source...
Empty extent, no extent given and no extent could be derived from layers.
double size() const
Returns the symbol size.
void writeGroupCode(int code)
Write a group code.
virtual void run(QgsRenderContext &context)=0
Runs the labeling job.
double width() const
Returns the width of the rectangle.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsCoordinateReferenceSystem crs
virtual Qt::BrushStyle dxfBrushStyle() const
Gets brush/fill style.
Horizontal alignment for data defined label position (Left, Center, Right)
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Quadrant getQuadrant() const
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
QList< QgsSymbolLayer * > QgsSymbolLayerList
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
QgsSymbolRenderContext * symbolRenderContext()
Returns the symbol render context.
QgsFeatureRenderer * renderer()
Returns renderer.
Abstract base class for curved geometry type.
VAlign
Vertical alignments.
ExportResult writeToFile(QIODevice *d, const QString &codec)
Export to a dxf file in the given encoding.
bool useCustomDashPattern() const
Returns true if the line uses a custom dash pattern.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Abstract base class for all geometries.
double mapUnitsPerPixel() const
Returns current map units per pixel.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
Does vector analysis using the geos library and handles import, export, exception handling*...
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination CRS, or an invalid CRS if no reprojection will be done.
Point geometry type, with support for z-dimension and m-values.
const QgsMapToPixel & mapToPixel() const
static QString dxfEncoding(const QString &name)
Returns DXF encoding for Qt encoding.
QgsRectangle extent() const FINAL
Returns the extent of the layer.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc...
QString layerName(const QString &id, const QgsFeature &f) const
Gets layer name for feature.
virtual QColor dxfBrushColor(QgsSymbolRenderContext &context) const
Gets brush/fill color.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
int numGeometries() const
Returns the number of geometries within the collection.
Contains geos related utilities and functions.
Place direction symbols on above label.
virtual bool isClosed() const
Returns true if the curve is closed.
void drawLabel(const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings)
Output the label.
QgsCoordinateSequence coordinateSequence() const override
Retrieves the sequence of geometries, rings and nodes.
Rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
int nCurves() const
Returns the number of curves in the geometry.
QgsExpressionContext & expressionContext()
Gets the expression context.
DistanceUnit
Units of distance.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QVector< QgsPoint > QgsPointSequence
void setFeature(const QgsFeature *f)
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle...
QString wrapChar
Wrapping character string.
virtual Qt::PenStyle dxfPenStyle() const
Gets pen style.
static QString dxfLayerName(const QString &name)
Returns cleaned layer name for use in DXF.
QVector< QgsPointSequence > QgsRingSequence
QgsAbstractGeometry * offsetCurve(double distance, int segments, int joinStyle, double miterLimit, QString *errorMsg=nullptr) const override
QString rightDirectionSymbol
String to use for right direction arrows.
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
std::unique_ptr< QgsFeatureRenderer > renderer
Contains information about the context of a rendering operation.
Abstract base class for marker symbol layers.
void writeCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width)
Write circle (as polyline)
QFont definedFont()
Font to be used for rendering.
QMap< QString, QString > layerStyleOverrides() const
Gets map of map layer style overrides (key: layer ID, value: style name) where a different style shou...
HAlign
Horizontal alignments.
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
ExportResult
The result of an export as dxf operation.
double maxSizeMM
The maximum size in millimeters, or 0.0 if unset.
QList< QgsSymbolLevelItem > QgsSymbolLevel
double getAlpha() const
Returns the angle to rotate text (in rad).
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const FINAL
Calculates a list of unique values contained within an attribute in the layer.
Struct for storing maximum and minimum scales for measurements in map units.
virtual double dxfAngle(QgsSymbolRenderContext &context) const
Gets angle.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
double getX(int i=0) const
Returns the down-left x coordinate.
void writeText(const QString &layer, const QString &text, const QgsPoint &pt, double size, double angle, const QColor &color, QgsDxfExport::HAlign hali=QgsDxfExport::HAlign::Undefined, QgsDxfExport::VAlign vali=QgsDxfExport::VAlign::Undefined)
Write text (TEXT)
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
QgsPointXY layerToMapCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from layer's CRS to output CRS
QgsDxfExport()
Constructor for QgsDxfExport.
virtual QColor dxfColor(QgsSymbolRenderContext &context) const
Gets color.
RenderHints renderHints() const
Returns the rendering hint flags for the symbol.
Line string geometry type, with support for z-dimension and m-values.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
static QgsProject * instance()
Returns the QgsProject singleton instance.
const QgsFeature * feature() const
Returns the current feature being rendered.
This class represents a coordinate reference system (CRS).
void writeDouble(double d)
Write a floating point value.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
const QgsCurve * curveAt(int i) const
Returns the curve at the specified index.
QgsPoint pointN(int i) const
Returns the specified point from inside the line string.
LabelPosition is a candidate feature label position.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
void setLayers(const QList< QgsMapLayer *> &layers)
Set list of layers for map rendering.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
Compound curve geometry type.
Circular string geometry type.
QgsPointXY center() const
Returns the center point of the rectangle.
bool nextFeature(QgsFeature &f)
#define DXF_HANDPLOTSTYLE
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
Container for all settings relating to text rendering.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
int writeHandle(int code=5, int handle=0)
Write a tuple of group code and a handle.
static Q_INVOKABLE double fromUnitToUnitFactor(QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
Represents a vector layer which manages a vector based data sets.
double minScale
The minimum scale, or 0.0 if unset.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
static Type flatType(Type type)
Returns the flat type for a WKB type.
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top) ...
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected.
virtual int numPoints() const =0
Returns the number of points in the curve.
QFont font() const
Returns the font used for rendering text.
void writeMText(const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, const QColor &color)
Write mtext (MTEXT)
void addLayers(const QList< QgsDxfExport::DxfLayer > &layers)
Add layers to export.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
QList< QgsExpressionContextScope *> scopes()
Returns a list of scopes contained within the stack.
RenderUnit
Rendering size units.
double height() const
Returns the height of the rectangle.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
QString splitLayerAttribute() const
If the split layer attribute is set, the vector layer will be split into several dxf layers...
virtual QString layerType() const =0
Returns a string that represents this layer type.
DirectionSymbols placeDirectionSymbol
Placement option for direction symbols.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Exports one feature per symbol layer (considering symbol levels)
Device not writable error.
QgsExpressionContextScope * expressionContextScope()
This scope is always available when a symbol of this type is being rendered.