74 mMapSettings = settings;
89 QList<QgsMapLayer *> layerList;
91 mLayerNameAttribute.clear();
93 layerList.reserve( layers.size() );
94 for (
const DxfLayer &dxfLayer : layers )
96 layerList << dxfLayer.layer();
97 if ( dxfLayer.layerOutputAttributeIndex() >= 0 )
98 mLayerNameAttribute.insert( dxfLayer.layer()->id(), dxfLayer.layerOutputAttributeIndex() );
132 if ( !mForce2d && p.
is3D() && std::isfinite( p.
z() ) )
139 int minDist = std::numeric_limits<int>::max();
141 for (
int i = 1; i < static_cast< int >(
sizeof( sDxfColors ) /
sizeof( *sDxfColors ) ) && minDist > 0; ++i )
143 int dist = color_distance( color.rgba(), i );
144 if ( dist >= minDist )
151 if ( minDist == 0 && minDistAt != 7 )
155 if ( color.alpha() == 255 )
159 int c = ( color.red() & 0xff ) * 0x10000 + ( color.green() & 0xff ) * 0x100 + ( color.blue() & 0xff );
161 if ( transparencyCode != -1 && color.alpha() < 255 )
162 writeGroup( transparencyCode, 0x2000000 | color.alpha() );
167 mTextStream << QStringLiteral(
"%1\n" ).arg( code, 3, 10, QChar(
' ' ) );
172 mTextStream << QStringLiteral(
"%1\n" ).arg( i, 6, 10, QChar(
' ' ) );
178 if ( !s.contains(
'.' ) )
179 s += QLatin1String(
".0" );
180 mTextStream << s <<
'\n';
185 mTextStream << s <<
'\n';
195 if ( !d->isOpen() && !d->open( QIODevice::WriteOnly | QIODevice::Truncate ) )
200 mTextStream.setDevice( d );
201 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
202 mTextStream.setCodec( encoding.toLocal8Bit() );
204 mTextStream.setEncoding( QStringConverter::encodingForName( encoding.toLocal8Bit() ).value_or( QStringConverter::Utf8 ) );
212 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
227 mExtent = layerExtent;
263 void QgsDxfExport::writeHeader(
const QString &codepage )
265 writeGroup( 999, QStringLiteral(
"DXF created from QGIS" ) );
271 writeGroup( 9, QStringLiteral(
"$ACADVER" ) );
283 writeGroup( 9, QStringLiteral(
"$LTSCALE" ) );
295 writeGroup( 9, QStringLiteral(
"$PSLTSCALE" ) );
298 writeGroup( 9, QStringLiteral(
"$HANDSEED" ) );
301 writeGroup( 9, QStringLiteral(
"$DWGCODEPAGE" ) );
310 handle = mNextHandleId++;
312 Q_ASSERT_X( handle <
DXF_HANDMAX,
"QgsDxfExport::writeHandle(int, int)",
"DXF handle too large" );
314 writeGroup( code, QString::number( handle, 16 ) );
318 void QgsDxfExport::writeTables()
325 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > slList;
328 slList = symbolLayers( context );
336 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
339 writeDefaultLinetypes();
342 for (
const auto &symbolLayer : std::as_const( slList ) )
344 writeSymbolLayerLinetype( symbolLayer.first );
351 writeGroup( 2, QStringLiteral(
"BLOCK_RECORD" ) );
354 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
357 const QStringList blockStrings = QStringList() << QStringLiteral(
"*Model_Space" ) << QStringLiteral(
"*Paper_Space" ) << QStringLiteral(
"*Paper_Space0" );
358 for (
const QString &block : blockStrings )
360 writeGroup( 0, QStringLiteral(
"BLOCK_RECORD" ) );
362 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
363 writeGroup( 100, QStringLiteral(
"AcDbBlockTableRecord" ) );
368 for (
const auto &symbolLayer : std::as_const( slList ) )
374 if ( hasDataDefinedProperties( ml, symbolLayer.second ) )
377 QString name = QStringLiteral(
"symbolLayer%1" ).arg( i++ );
378 writeGroup( 0, QStringLiteral(
"BLOCK_RECORD" ) );
380 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
381 writeGroup( 100, QStringLiteral(
"AcDbBlockTableRecord" ) );
391 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
395 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
396 writeGroup( 100, QStringLiteral(
"AcDbRegAppTableRecord" ) );
405 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
413 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
421 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
425 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
426 writeGroup( 100, QStringLiteral(
"AcDbViewportTableRecord" ) );
465 writeGroup( 2, QStringLiteral(
"DIMSTYLE" ) );
467 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
468 writeGroup( 100, QStringLiteral(
"AcDbDimStyleTable" ) );
472 QSet<QString> layerNames;
473 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
476 if ( !layerIsScaleBasedVisible( ml ) )
483 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
490 const QSet<QVariant> values = vl->
uniqueValues( attrIdx );
491 for (
const QVariant &v : values )
503 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
508 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
509 writeGroup( 100, QStringLiteral(
"AcDbLayerTableRecord" ) );
513 writeGroup( 6, QStringLiteral(
"CONTINUOUS" ) );
516 for (
const QString &
layerName : std::as_const( layerNames ) )
520 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
521 writeGroup( 100, QStringLiteral(
"AcDbLayerTableRecord" ) );
525 writeGroup( 6, QStringLiteral(
"CONTINUOUS" ) );
534 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
540 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
541 writeGroup( 100, QStringLiteral(
"AcDbTextStyleTableRecord" ) );
542 writeGroup( 2, QStringLiteral(
"STANDARD" ) );
549 writeGroup( 3, QStringLiteral(
"romans.shx" ) );
557 void QgsDxfExport::writeBlocks()
562 static const QStringList blockStrings = QStringList() << QStringLiteral(
"*Model_Space" ) << QStringLiteral(
"*Paper_Space" ) << QStringLiteral(
"*Paper_Space0" );
563 for (
const QString &block : blockStrings )
567 writeGroup( 330, QString::number( mBlockHandles[ block ], 16 ) );
568 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
570 writeGroup( 100, QStringLiteral(
"AcDbBlockBegin" ) );
578 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
580 writeGroup( 100, QStringLiteral(
"AcDbBlockEnd" ) );
586 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > slList;
589 slList = symbolLayers( ct );
592 for (
const auto &symbolLayer : std::as_const( slList ) )
602 if ( hasDataDefinedProperties( ml, symbolLayer.second ) )
607 QString block( QStringLiteral(
"symbolLayer%1" ).arg( mBlockCounter++ ) );
608 mBlockHandle = QString::number( mBlockHandles[ block ], 16 );
613 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
615 writeGroup( 100, QStringLiteral(
"AcDbBlockBegin" ) );
628 ml->
writeDxf( *
this,
mapUnitScaleFactor( mSymbologyScale, ml->
sizeUnit(), mMapUnits, ctx.renderContext().mapToPixel().mapUnitsPerPixel() ), QStringLiteral(
"0" ), ctx );
632 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
634 writeGroup( 100, QStringLiteral(
"AcDbBlockEnd" ) );
636 mPointSymbolBlocks.insert( ml, block );
642 void QgsDxfExport::writeEntities()
645 writeGroup( 2, QStringLiteral(
"ENTITIES" ) );
647 mBlockHandle = QString::number( mBlockHandles[ QStringLiteral(
"*Model_Space" )], 16 );
656 job->renderer->usingSymbolLevels() )
658 writeEntitiesSymbolLevels( job );
676 QString lName(
dxfLayerName( job->splitLayerAttribute.isNull() ? job->layerTitle : fet.
attribute( job->splitLayerAttribute ).toString() ) );
678 sctx.setFeature( &fet );
680 if ( !job->renderer->willRenderFeature( fet, mRenderContext ) )
685 addFeature( sctx, ct, lName,
nullptr,
nullptr );
689 const QgsSymbolList symbolList = job->renderer->symbolsForFeature( fet, mRenderContext );
690 bool hasSymbology = symbolList.size() > 0;
702 bool isGeometryGenerator = ( symbolLayer->layerType() == QLatin1String(
"GeometryGenerator" ) );
703 if ( isGeometryGenerator )
705 addGeometryGeneratorSymbolLayer( sctx, ct, lName, symbolLayer,
true );
709 addFeature( sctx, ct, lName, symbolLayer, symbol );
714 else if ( hasSymbology )
725 addGeometryGeneratorSymbolLayer( sctx, ct, lName, s->
symbolLayer( 0 ),
false );
729 addFeature( sctx, ct, lName, s->
symbolLayer( 0 ), s );
733 if ( job->labelProvider )
735 job->labelProvider->registerFeature( fet, mRenderContext );
740 else if ( job->ruleBasedLabelProvider )
742 job->ruleBasedLabelProvider->registerFeature( fet, mRenderContext );
751 QImage image( 10, 10, QImage::Format_ARGB32_Premultiplied );
752 image.setDotsPerMeterX( 96 / 25.4 * 1000 );
753 image.setDotsPerMeterY( 96 / 25.4 * 1000 );
754 QPainter painter( &image );
762 void QgsDxfExport::prepareRenderers()
764 Q_ASSERT( mJobs.empty() );
772 mExtent.
height() * mFactor, 0 ) );
778 mLabelingEngine = std::make_unique<QgsDefaultLabelingEngine>();
779 mLabelingEngine->setMapSettings( mMapSettings );
782 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
792 if ( !layerIsScaleBasedVisible( vl ) )
795 QString splitLayerAttribute;
796 int splitLayerAttributeIndex = mLayerNameAttribute.value( vl->
id(), -1 );
798 if ( splitLayerAttributeIndex >= 0 && splitLayerAttributeIndex < fields.
size() )
799 splitLayerAttribute = fields.
at( splitLayerAttributeIndex ).
name();
805 void QgsDxfExport::writeEntitiesSymbolLevels(
DxfLayerJob *job )
807 QHash< QgsSymbol *, QList<QgsFeature> > features;
829 featureSymbol = job->
renderer->symbolForFeature( fet, ctx );
830 if ( !featureSymbol )
835 QHash< QgsSymbol *, QList<QgsFeature> >::iterator it = features.find( featureSymbol );
836 if ( it == features.end() )
838 it = features.insert( featureSymbol, QList<QgsFeature>() );
840 it.value().append( fet );
848 for (
int j = 0; j < symbol->symbolLayerCount(); j++ )
850 int level = symbol->symbolLayer( j )->renderingPass();
851 if ( level < 0 || level >= 1000 )
854 while ( level >= levels.count() )
856 levels[level].append( item );
865 QHash< QgsSymbol *, QList<QgsFeature> >::iterator levelIt = features.find( item.symbol() );
866 if ( levelIt == features.end() )
871 int llayer = item.layer();
872 const QList<QgsFeature> &featureList = levelIt.value();
873 for (
const QgsFeature &feature : featureList )
875 sctx.setFeature( &feature );
876 addFeature( sctx, ct, job->
layerName, levelIt.key()->symbolLayer( llayer ), levelIt.key() );
882 void QgsDxfExport::stopRenderers()
888 void QgsDxfExport::writeEndFile()
895 void QgsDxfExport::startSection()
900 void QgsDxfExport::endSection()
925 QHash< const QgsSymbolLayer *, QString >::const_iterator blockIt = mPointSymbolBlocks.constFind( symbolLayer );
926 if ( !symbolLayer || blockIt == mPointSymbolBlocks.constEnd() )
944 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
945 writeGroup( 100, QStringLiteral(
"AcDbBlockReference" ) );
958 QgsDebugMsg( QStringLiteral(
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
964 QgsDebugMsg( QStringLiteral(
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
968 if ( mForce2d || !line.at( 0 ).is3D() )
970 bool polygon = line[0] == line[ line.size() - 1 ];
974 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
977 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
978 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
986 for (
int i = 0; i < n; i++ )
991 writeGroup( 0, QStringLiteral(
"POLYLINE" ) );
994 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
998 writeGroup( 100, QStringLiteral(
"AcDb3dPolyline" ) );
1002 for (
int i = 0; i < n; i++ )
1007 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1010 writeGroup( 100, QStringLiteral(
"AcDbVertex" ) );
1011 writeGroup( 100, QStringLiteral(
"AcDb3dPolylineVertex" ) );
1019 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1025 void QgsDxfExport::appendCurve(
const QgsCurve &
c, QVector<QgsPoint> &points, QVector<double> &bulges )
1030 appendLineString( *
dynamic_cast<const QgsLineString *
>( &
c ), points, bulges );
1034 appendCircularString( *
dynamic_cast<const QgsCircularString *
>( &
c ), points, bulges );
1038 appendCompoundCurve( *
dynamic_cast<const QgsCompoundCurve *
>( &
c ), points, bulges );
1042 QgsDebugMsg( QStringLiteral(
"Unexpected curve type %1" ).arg(
c.wktTypeStr() ) );
1047 void QgsDxfExport::appendLineString(
const QgsLineString &ls, QVector<QgsPoint> &points, QVector<double> &bulges )
1049 for (
int i = 0; i < ls.
numPoints(); i++ )
1052 if ( !points.isEmpty() && points.last() == p )
1060 void QgsDxfExport::appendCircularString(
const QgsCircularString &cs, QVector<QgsPoint> &points, QVector<double> &bulges )
1062 for (
int i = 0; i < cs.
numPoints() - 2; i += 2 )
1068 if ( points.isEmpty() || points.last() != p1 )
1070 else if ( !bulges.isEmpty() )
1071 bulges.removeLast();
1073 double a = ( M_PI - ( p1 - p2 ).
angle() + ( p3 - p2 ).
angle() ) / 2.0;
1074 bulges << sin( a ) / cos( a );
1081 void QgsDxfExport::appendCompoundCurve(
const QgsCompoundCurve &cc, QVector<QgsPoint> &points, QVector<double> &bulges )
1083 for (
int i = 0; i < cc.
nCurves(); i++ )
1087 appendCurve( *
c, points, bulges );
1096 QgsDebugMsg( QStringLiteral(
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
1102 QgsDebugMsg( QStringLiteral(
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
1106 QVector<QgsPoint> points;
1107 QVector<double> bulges;
1108 appendCurve( curve, points, bulges );
1110 if ( mForce2d || !curve.
is3D() )
1112 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
1115 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1116 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
1121 QgsDxfExport::DxfPolylineFlags polylineFlags;
1123 polylineFlags.setFlag( QgsDxfExport::DxfPolylineFlag::Closed );
1125 polylineFlags.setFlag( QgsDxfExport::DxfPolylineFlag::Curve );
1129 polylineFlags.setFlag( QgsDxfExport::DxfPolylineFlag::ContinuousPattern );
1131 writeGroup( 70,
static_cast<int>( polylineFlags ) );
1134 for (
int i = 0; i < points.size(); i++ )
1137 if ( bulges[i] != 0.0 )
1143 writeGroup( 0, QStringLiteral(
"POLYLINE" ) );
1146 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1150 writeGroup( 100, QStringLiteral(
"AcDb3dPolyline" ) );
1154 for (
int i = 0; i < points.size(); i++ )
1159 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1162 writeGroup( 100, QStringLiteral(
"AcDbVertex" ) );
1163 writeGroup( 100, QStringLiteral(
"AcDb3dPolylineVertex" ) );
1165 if ( bulges[i] != 0.0 )
1173 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1184 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1187 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
1193 writeGroup( 70, hatchPattern == QLatin1String(
"SOLID" ) );
1197 for (
int i = 0; i < polygon.size(); ++i )
1204 for (
int j = 0; j < polygon[i].size(); ++j )
1223 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1226 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
1232 writeGroup( 70, hatchPattern == QLatin1String(
"SOLID" ) );
1235 QVector<QVector<QgsPoint>> points;
1236 QVector<QVector<double>> bulges;
1239 points.reserve( ringCount + 1 );
1240 bulges.reserve( ringCount + 1 );
1242 points << QVector<QgsPoint>();
1243 bulges << QVector<double>();
1244 appendCurve( *polygon.
exteriorRing(), points.last(), bulges.last() );
1246 for (
int i = 0; i < ringCount; i++ )
1248 points << QVector<QgsPoint>();
1249 bulges << QVector<double>();
1250 appendCurve( *polygon.
interiorRing( i ), points.last(), bulges.last() );
1253 bool hasBulges =
false;
1254 for (
int i = 0; i < points.size() && !hasBulges; ++i )
1255 for (
int j = 0; j < points[i].size() && !hasBulges; ++j )
1256 hasBulges = bulges[i][j] != 0.0;
1260 for (
int i = 0; i < points.size(); ++i )
1267 for (
int j = 0; j < points[i].size(); ++j )
1291 double lblX = label->
getX();
1292 double lblY = label->
getY();
1301 if ( layerSettings.
placement == QgsPalLayerSettings::Placement::OverPoint )
1311 if ( !exprVal.isNull() )
1317 switch ( offsetQuad )
1319 case QgsPalLayerSettings::QuadrantPosition::QuadrantAboveLeft:
1323 case QgsPalLayerSettings::QuadrantPosition::QuadrantAbove:
1327 case QgsPalLayerSettings::QuadrantPosition::QuadrantAboveRight:
1331 case QgsPalLayerSettings::QuadrantPosition::QuadrantLeft:
1335 case QgsPalLayerSettings::QuadrantPosition::QuadrantOver:
1339 case QgsPalLayerSettings::QuadrantPosition::QuadrantRight:
1343 case QgsPalLayerSettings::QuadrantPosition::QuadrantBelowLeft:
1347 case QgsPalLayerSettings::QuadrantPosition::QuadrantBelow:
1351 case QgsPalLayerSettings::QuadrantPosition::QuadrantBelowRight:
1365 if ( !exprVal.isNull() )
1367 const QString haliString = exprVal.toString();
1368 if ( haliString.compare( QLatin1String(
"Center" ), Qt::CaseInsensitive ) == 0 )
1372 else if ( haliString.compare( QLatin1String(
"Right" ), Qt::CaseInsensitive ) == 0 )
1384 if ( !exprVal.isNull() )
1386 const QString valiString = exprVal.toString();
1387 if ( valiString.compare( QLatin1String(
"Bottom" ), Qt::CaseInsensitive ) != 0 )
1389 if ( valiString.compare( QLatin1String(
"Base" ), Qt::CaseInsensitive ) == 0 )
1393 else if ( valiString.compare( QLatin1String(
"Half" ), Qt::CaseInsensitive ) == 0 )
1412 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1413 writeGroup( 100, QStringLiteral(
"AcDbPoint" ) );
1424 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1427 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
1458 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
1462 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1463 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
1482 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1485 writeGroup( 100, QStringLiteral(
"AcDbText" ) );
1496 writeGroup( 7, QStringLiteral(
"STANDARD" ) );
1497 writeGroup( 100, QStringLiteral(
"AcDbText" ) );
1506 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1507 if ( !mTextStream.codec()->canEncode( text ) )
1510 QgsDebugMsg( QStringLiteral(
"could not encode:%1" ).arg( text ) );
1517 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1518 writeGroup( 100, QStringLiteral(
"AcDbMText" ) );
1525 while ( t.length() > 250 )
1541 writeGroup( 7, QStringLiteral(
"STANDARD" ) );
1556 geom.transform( ct );
1563 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
1565 penColor = colorFromSymbolLayer( symbolLayer, ctx );
1569 Qt::PenStyle penStyle( Qt::SolidLine );
1570 Qt::BrushStyle brushStyle( Qt::NoBrush );
1572 double offset = 0.0;
1574 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
1576 width = symbolLayer->
dxfWidth( *
this, ctx );
1577 offset = symbolLayer->
dxfOffset( *
this, ctx );
1586 QString lineStyleName = QStringLiteral(
"CONTINUOUS" );
1589 lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
1595 writePoint( geom.constGet()->coordinateSequence().at( 0 ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol,
angle );
1602 for (
int i = 0; i < cs.size(); i++ )
1604 writePoint( cs.at( i ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol,
angle );
1609 if ( penStyle != Qt::NoPen )
1612 std::unique_ptr< QgsAbstractGeometry > tempGeom;
1623 tempGeom.reset(
geos.offsetCurve( offset, 0, Qgis::JoinStyle::Miter, 2.0 ) );
1625 sourceGeom = tempGeom.get();
1627 sourceGeom = geom.constGet();
1633 writePolyline( *curve, layer, lineStyleName, penColor, width );
1648 tempGeom.reset(
geos.offsetCurve( offset, 0, Qgis::JoinStyle::Miter, 2.0 ) );
1650 sourceGeom = tempGeom.get();
1652 sourceGeom = geom.constGet();
1662 writePolyline( *curve, layer, lineStyleName, penColor, width );
1677 tempGeom.reset(
geos.buffer( offset, 0, Qgis::EndCapStyle::Flat, Qgis::JoinStyle::Miter, 2.0 ) );
1679 sourceGeom = tempGeom.get();
1681 sourceGeom = geom.constGet();
1685 Q_ASSERT( polygon );
1700 tempGeom.reset(
geos.buffer( offset, 0, Qgis::EndCapStyle::Flat, Qgis::JoinStyle::Miter, 2.0 ) );
1702 sourceGeom = tempGeom.get();
1704 sourceGeom = geom.constGet();
1713 Q_ASSERT( polygon );
1729 if ( brushStyle != Qt::NoBrush )
1732 std::unique_ptr< QgsAbstractGeometry > tempGeom;
1740 Q_ASSERT( polygon );
1741 writePolygon( *polygon, layer, QStringLiteral(
"SOLID" ), brushColor );
1754 Q_ASSERT( polygon );
1755 writePolygon( *polygon, layer, QStringLiteral(
"SOLID" ), brushColor );
1772 return symbolLayer->
dxfColor( ctx );
1775 QString QgsDxfExport::lineStyleFromSymbolLayer(
const QgsSymbolLayer *symbolLayer )
1777 QString lineStyleName = QStringLiteral(
"CONTINUOUS" );
1780 return lineStyleName;
1783 QHash< const QgsSymbolLayer *, QString >::const_iterator lineTypeIt = mLineStyles.constFind( symbolLayer );
1784 if ( lineTypeIt != mLineStyles.constEnd() )
1786 lineStyleName = lineTypeIt.value();
1787 return lineStyleName;
1791 return lineNameFromPenStyle( symbolLayer->
dxfPenStyle() );
1798 int current_distance = std::numeric_limits<int>::max();
1799 for (
int i = 1; i < static_cast< int >(
sizeof( sDxfColors ) /
sizeof( *sDxfColors ) ); ++i )
1801 int dist = color_distance( pixel, i );
1802 if ( dist < current_distance )
1804 current_distance = dist;
1813 int QgsDxfExport::color_distance( QRgb p1,
int index )
1815 if ( index > 255 || index < 0 )
1820 double redDiff = qRed( p1 ) - sDxfColors[index][0];
1821 double greenDiff = qGreen( p1 ) - sDxfColors[index][1];
1822 double blueDiff = qBlue( p1 ) - sDxfColors[index][2];
1824 QgsDebugMsg( QStringLiteral(
"color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
1825 .arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
1827 .arg( mDxfColors[index][0] )
1828 .arg( mDxfColors[index][1] )
1829 .arg( mDxfColors[index][2] )
1830 .arg( redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff ) );
1832 return redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff;
1835 QRgb QgsDxfExport::createRgbEntry( qreal r, qreal g, qreal b )
1837 return QColor::fromRgbF( r, g, b ).rgb();
1842 return mRenderContext;
1857 return mapUnitsPerPixel;
1871 double minSizeMU = std::numeric_limits<double>::lowest();
1874 minSizeMU = scale.
minSizeMM * pixelToMMFactor * mapUnitsPerPixel;
1878 minSizeMU = std::max( minSizeMU, value );
1880 value = std::max( value, minSizeMU );
1882 double maxSizeMU = std::numeric_limits<double>::max();
1885 maxSizeMU = scale.
maxSizeMM * pixelToMMFactor * mapUnitsPerPixel;
1889 maxSizeMU = std::min( maxSizeMU, value );
1891 value = std::min( value, maxSizeMU );
1894 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > QgsDxfExport::symbolLayers(
QgsRenderContext &context )
1896 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > symbolLayers;
1907 maxSymbolLayers = 1;
1909 for (
int i = 0; i < maxSymbolLayers; ++i )
1911 symbolLayers.append( qMakePair( symbol->
symbolLayer( i ), symbol ) );
1916 return symbolLayers;
1919 void QgsDxfExport::writeDefaultLinetypes()
1922 for (
const QString <ype : { QStringLiteral(
"ByLayer" ), QStringLiteral(
"ByBlock" ), QStringLiteral(
"CONTINUOUS" ) } )
1926 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
1927 writeGroup( 100, QStringLiteral(
"AcDbLinetypeTableRecord" ) );
1930 writeGroup( 3, QStringLiteral(
"Defaultstyle" ) );
1936 double das = dashSize();
1937 double dss = dashSeparatorSize();
1938 double dos = dotSize();
1940 QVector<qreal> dashVector( 2 );
1941 dashVector[0] = das;
1942 dashVector[1] = dss;
1945 QVector<qreal> dotVector( 2 );
1950 QVector<qreal> dashDotVector( 4 );
1951 dashDotVector[0] = das;
1952 dashDotVector[1] = dss;
1953 dashDotVector[2] = dos;
1954 dashDotVector[3] = dss;
1957 QVector<qreal> dashDotDotVector( 6 );
1958 dashDotDotVector[0] = das;
1959 dashDotDotVector[1] = dss;
1960 dashDotDotVector[2] = dos;
1961 dashDotDotVector[3] = dss;
1962 dashDotDotVector[4] = dos;
1963 dashDotDotVector[5] = dss;
1967 void QgsDxfExport::writeSymbolLayerLinetype(
const QgsSymbolLayer *symbolLayer )
1976 if ( !customLinestyle.isEmpty() )
1978 QString name = QStringLiteral(
"symbolLayer%1" ).arg( mSymbolLayerCounter++ );
1979 writeLinetype( name, customLinestyle, unit );
1980 mLineStyles.insert( symbolLayer, name );
1984 int QgsDxfExport::nLineTypes(
const QList< QPair< QgsSymbolLayer *, QgsSymbol * > > &symbolLayers )
1987 for (
const auto &symbolLayer : symbolLayers )
2001 void QgsDxfExport::writeLinetype(
const QString &styleName,
const QVector<qreal> &pattern,
QgsUnitTypes::RenderUnit u )
2004 for ( qreal size : pattern )
2012 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
2013 writeGroup( 100, QStringLiteral(
"AcDbLinetypeTableRecord" ) );
2022 for ( qreal size : pattern )
2025 double segmentLength = ( isGap ? -size : size );
2051 geomExpr.prepare( &expressionContext );
2059 symbolExpressionContextScope->
setFeature( f );
2064 for (
int i = 0; i < nSymbolLayers; ++i )
2066 addFeature( ctx, ct, layer, symbol->
symbolLayer( i ), symbol );
2075 if ( !sl || !symbol )
2088 double QgsDxfExport::dashSize()
const
2090 double size = mSymbologyScale * 0.002;
2091 return sizeToMapUnits( size );
2094 double QgsDxfExport::dotSize()
const
2096 double size = mSymbologyScale * 0.0006;
2097 return sizeToMapUnits( size );
2100 double QgsDxfExport::dashSeparatorSize()
const
2102 double size = mSymbologyScale * 0.0006;
2103 return sizeToMapUnits( size );
2106 double QgsDxfExport::sizeToMapUnits(
double s )
const
2112 QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
2117 return QStringLiteral(
"DASH" );
2119 return QStringLiteral(
"DOT" );
2120 case Qt::DashDotLine:
2121 return QStringLiteral(
"DASHDOT" );
2122 case Qt::DashDotDotLine:
2123 return QStringLiteral(
"DASHDOTDOT" );
2126 return QStringLiteral(
"CONTINUOUS" );
2132 if ( name.isEmpty() )
2133 return QStringLiteral(
"0" );
2155 layerName.replace( QLatin1String(
"\r\n" ), QLatin1String(
"_" ) );
2162 bool QgsDxfExport::layerIsScaleBasedVisible(
const QgsMapLayer *layer )
const
2176 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
2180 if ( vl && vl->
id() ==
id )
2182 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
2187 return QStringLiteral(
"0" );
2192 const QList< QByteArray > codecs = QTextCodec::availableCodecs();
2193 for (
const QByteArray &codec : codecs )
2195 if ( name != codec )
2199 for ( i = 0; i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) && name != DXF_ENCODINGS[i][1]; ++i )
2202 if ( i ==
static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) )
2205 return DXF_ENCODINGS[i][0];
2214 const QList< QByteArray > codecs = QTextCodec::availableCodecs();
2216 for (
const QByteArray &codec : codecs )
2219 for ( i = 0; i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) && strcmp( codec.data(), DXF_ENCODINGS[i][1] ) != 0; ++i )
2222 if ( i <
static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) )
2231 return mLayerTitleAsName && !vl->
title().isEmpty() ? vl->
title() : vl->
name();
2249 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues = lf->
dataDefinedValues();
2254 QgsDebugMsgLevel( QStringLiteral(
"PAL font definedFont: %1, Style: %2" ).arg( dFont.toString(), dFont.styleName() ), 4 );
2284 QgsPalLabeling::dataDefinedTextStyle( tmpLyr, ddValues );
2287 QgsPalLabeling::dataDefinedTextBuffer( tmpLyr, ddValues );
2290 QgsPalLabeling::dataDefinedTextFormatting( tmpLyr, ddValues );
2296 QString dxfLayer = mDxfLayerNames[layerId][fid];
2298 QString wrapchr = tmpLyr.
wrapChar.isEmpty() ? QStringLiteral(
"\n" ) : tmpLyr.
wrapChar;
2303 bool prependSymb =
false;
2321 prependSymb =
false;
2330 symb = symb + wrapchr;
2334 prependSymb =
false;
2335 symb = wrapchr + symb;
2344 txt.prepend( symb );
2354 txt.replace( QChar( QChar::LineFeed ),
' ' );
2355 txt.replace( QChar( QChar::CarriageReturn ),
' ' );
2360 txt.replace( QString( QChar( QChar::CarriageReturn ) ) + QString( QChar( QChar::LineFeed ) ), QStringLiteral(
"\\P" ) );
2361 txt.replace( QChar( QChar::CarriageReturn ), QStringLiteral(
"\\P" ) );
2362 txt = txt.replace( wrapchr, QLatin1String(
"\\P" ) );
2363 txt.replace( QLatin1String(
" " ), QLatin1String(
"\\~" ) );
2367 txt.prepend(
"\\L" ).append(
"\\l" );
2372 txt.prepend(
"\\O" ).append(
"\\o" );
2377 txt.prepend(
"\\K" ).append(
"\\k" );
2380 txt.prepend( QStringLiteral(
"\\f%1|i%2|b%3;\\H%4;" )
2382 .arg( tmpLyr.
format().
font().italic() ? 1 : 0 )
2383 .arg( tmpLyr.
format().
font().bold() ? 1 : 0 )
2384 .arg( label->
getHeight() / ( 1 + txt.count( QStringLiteral(
"\\P" ) ) ) * 0.75 ) );
2392 if ( !mDxfLayerNames.contains( layerId ) )
2393 mDxfLayerNames[ layerId ] = QMap<QgsFeatureId, QString>();
2395 mDxfLayerNames[layerId][fid] =
layerName;
2411 QString splitLayerFieldName;
2413 if ( mLayerOutputAttributeIndex >= 0 && mLayerOutputAttributeIndex < fields.
size() )
2415 splitLayerFieldName = fields.
at( mLayerOutputAttributeIndex ).
name();
2418 return splitLayerFieldName;
@ DynamicRotation
Rotation of symbol may be changed during rendering and symbol should not be cached.
Abstract base class for all geometries.
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
Circular string geometry type.
QgsPoint pointN(int i) const SIP_HOLDGIL
Returns the point at index i within the circular string.
int numPoints() const override SIP_HOLDGIL
Returns the number of points in the curve.
Compound curve geometry type.
const QgsCurve * curveAt(int i) const SIP_HOLDGIL
Returns the curve at the specified index.
int nCurves() const SIP_HOLDGIL
Returns the number of curves in the geometry.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Q_GADGET QgsUnitTypes::DistanceUnit mapUnits
Curve polygon geometry type.
const QgsCurve * interiorRing(int i) const SIP_HOLDGIL
Retrieves an interior ring from the curve polygon.
const QgsCurve * exteriorRing() const SIP_HOLDGIL
Returns the curve polygon's exterior ring.
int numInteriorRings() const SIP_HOLDGIL
Returns the number of interior rings contained with the curve polygon.
Abstract base class for curved geometry type.
QgsCoordinateSequence coordinateSequence() const override
Retrieves the sequence of geometries, rings and nodes.
virtual int numPoints() const =0
Returns the number of points in the curve.
virtual bool isClosed() const SIP_HOLDGIL
Returns true if the curve is closed.
void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
ExportResult
The result of an export as dxf operation.
@ DeviceNotWritableError
Device not writable error.
@ Success
Successful export.
@ EmptyExtentError
Empty extent, no extent given and no extent could be derived from layers.
@ InvalidDeviceError
Invalid device error.
@ SymbolLayerSymbology
Exports one feature per symbol layer (considering symbol levels)
@ NoSymbology
Export only data.
void writeCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width)
Write circle (as polyline)
ExportResult writeToFile(QIODevice *d, const QString &codec)
Export to a dxf file in the given encoding.
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)
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
void writeGroup(int code, int i)
Write a tuple of group code and integer value.
QString layerName(const QString &id, const QgsFeature &f) const
Gets layer name for feature.
void setFlags(QgsDxfExport::Flags flags)
Sets the export flags.
@ FlagNoMText
Export text as TEXT elements. If not set, text will be exported as MTEXT elements.
void writeInt(int i)
Write an integer value.
void writeMText(const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, const QColor &color)
Write mtext (MTEXT)
QgsDxfExport()
Constructor for QgsDxfExport.
QgsUnitTypes::DistanceUnit mapUnits() const
Retrieve map units.
int writeHandle(int code=5, int handle=0)
Write a tuple of group code and a handle.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination CRS, or an invalid CRS if no reprojection will be done.
HAlign
Horizontal alignments.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
Set destination CRS.
void addLayers(const QList< QgsDxfExport::DxfLayer > &layers)
Add layers to export.
static QString dxfLayerName(const QString &name)
Returns cleaned layer name for use in DXF.
void writeDouble(double d)
Write a floating point value.
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)
void writeString(const QString &s)
Write a string value.
void writePolygon(const QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
void drawLabel(const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings) override
Add a label to the dxf output.
static QString dxfEncoding(const QString &name)
Returns DXF encoding for Qt encoding.
static int closestColorMatch(QRgb color)
Gets DXF palette index of nearest entry for given color.
void writePoint(const QString &layer, const QColor &color, const QgsPoint &pt)
Write point.
Q_DECL_DEPRECATED void registerDxfLayer(const QString &layerId, QgsFeatureId fid, const QString &layer)
Register name of layer for feature.
QgsDxfExport::Flags flags() const
Returns the export flags.
VAlign
Vertical alignments.
void clipValueToMapUnitScale(double &value, const QgsMapUnitScale &scale, double pixelToMMFactor) const
Clips value to scale minimum/maximum.
void writePolyline(const QgsPointSequence &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE)
static QStringList encodings()
Returns list of available DXF encodings.
void setMapSettings(const QgsMapSettings &settings)
Set map settings and assign layer name attributes.
void writeGroupCode(int code)
Write a group code.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QList< QgsExpressionContextScope * > scopes()
Returns a list of scopes contained within the stack.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Class for parsing and evaluation of expressions (formerly called "search strings").
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
@ SymbolLevels
Rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Container of fields for a vector layer.
int size() const
Returns number of items.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
int numGeometries() const SIP_HOLDGIL
Returns the number of geometries within the collection.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
QString geometryExpression() const
Gets the expression to generate this geometry.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
A geometry is the spatial representation of a feature.
Does vector analysis using the geos library and handles import, export, exception handling*.
The QgsLabelFeature class describes a feature that should be used within the labeling engine.
QgsPointXY anchorPosition() const
In case of quadrand or aligned positioning, this is set to the anchor point.
QString labelText() const
Text of the label.
bool reverseDirectionSymbol() const
Returns true if direction symbols should be reversed.
DirectionSymbolPlacement directionSymbolPlacement() const
Returns the placement for direction symbols.
QString leftDirectionSymbol() const
Returns the string to use for left direction arrows.
@ SymbolLeftRight
Place direction symbols on left/right of label.
@ SymbolAbove
Place direction symbols on above label.
@ SymbolBelow
Place direction symbols on below label.
QString rightDirectionSymbol() const
Returns the string to use for right direction arrows.
bool addDirectionSymbol() const
Returns true if '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) w...
virtual void run(QgsRenderContext &context)=0
Runs the labeling job.
Line string geometry type, with support for z-dimension and m-values.
int numPoints() const override SIP_HOLDGIL
Returns the number of points in the curve.
QgsPoint pointN(int i) const
Returns the specified point from inside the line string.
Base class for all map layer types.
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
The QgsMapSettings class contains configuration for rendering of the map.
QgsPointXY layerToMapCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from layer's CRS to output CRS
void setLayers(const QList< QgsMapLayer * > &layers)
Sets the list of layers to render in the map.
void setOutputDpi(double dpi)
Sets the dpi (dots per inch) used for conversion between real world units (e.g.
void setExtent(const QgsRectangle &rect, bool magnified=true)
Sets the coordinates of the rectangle which should be rendered.
const QgsMapToPixel & mapToPixel() const
QList< QgsMapLayer * > layers() const
Returns the list of layers which will be rendered in the map.
QMap< QString, QString > layerStyleOverrides() const
Returns the map of map layer style overrides (key: layer ID, value: style name) where a different sty...
void setOutputSize(QSize size)
Sets the size of the resulting map image, in pixels.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
Sets the destination crs (coordinate reference system) for the map render.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
Perform transforms between map coordinates and device coordinates.
double mapUnitsPerPixel() const
Returns the current map units per pixel.
Struct for storing maximum and minimum scales for measurements in map units.
bool minSizeMMEnabled
Whether the minimum size in mm should be respected.
double maxScale
The maximum scale, or 0.0 if unset.
double minScale
The minimum scale, or 0.0 if unset.
double maxSizeMM
The maximum size in millimeters, or 0.0 if unset.
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected.
double minSizeMM
The minimum size in millimeters, or 0.0 if unset.
Abstract base class for marker symbol layers.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
double size() const
Returns the symbol size.
Contains settings for how a map layer will be labeled.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
QString wrapChar
Wrapping character string.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
bool drawLabels
Whether to draw labels for this layer.
QuadrantPosition quadOffset
Sets the quadrant in which to offset labels from feature.
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
MultiLineAlign multilineAlign
Horizontal alignment of multi-line labels.
@ Hali
Horizontal alignment for data defined label position (Left, Center, Right)
@ Vali
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
const QgsLabelLineSettings & lineSettings() const
Returns the label line settings, which contain settings related to how the label engine places and fo...
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
Point geometry type, with support for z-dimension and m-values.
static QgsProject * instance()
Returns the QgsProject singleton instance.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
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.
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
A rectangle specified with double values.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
double height() const SIP_HOLDGIL
Returns the height of the rectangle.
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle.
bool isEmpty() const
Returns true if the rectangle is empty.
QgsPointXY center() const SIP_HOLDGIL
Returns the center point of the rectangle.
Contains information about the context of a rendering operation.
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
QgsExpressionContext & expressionContext()
Gets the expression context.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
QgsLabelingEngine * labelingEngine() const
Gets access to new labeling engine (may be nullptr)
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
void setLabelingEngine(QgsLabelingEngine *engine)
Assign new labeling engine.
void setRendererScale(double scale)
Sets the renderer map scale.
A simple line symbol layer, which renders lines using a line in a variety of styles (e....
bool useCustomDashPattern() const
Returns true if the line uses a custom dash pattern.
virtual double dxfOffset(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets offset.
virtual QColor dxfBrushColor(QgsSymbolRenderContext &context) const
Gets brush/fill color.
virtual QVector< qreal > dxfCustomDashPattern(QgsUnitTypes::RenderUnit &unit) const
Gets dash pattern.
virtual Qt::PenStyle dxfPenStyle() const
Gets pen style.
virtual QColor dxfColor(QgsSymbolRenderContext &context) const
Gets color.
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets line width.
virtual double dxfAngle(QgsSymbolRenderContext &context) const
Gets angle.
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
virtual Qt::BrushStyle dxfBrushStyle() const
Gets brush/fill style.
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
const QgsFeature * feature() const
Returns the current feature being rendered.
QgsExpressionContextScope * expressionContextScope()
This scope is always available when a symbol of this type is being rendered.
void setFeature(const QgsFeature *f)
Abstract base class for all rendered symbols.
QgsSymbolRenderContext * symbolRenderContext()
Returns the symbol render context.
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
Qgis::SymbolRenderHints renderHints() const
Returns the rendering hint flags for the symbol.
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
Container for all settings relating to text rendering.
void setFont(const QFont &font)
Sets the font used for rendering text.
QColor color() const
Returns the color that text will be rendered in.
QFont font() const
Returns the font used for rendering text.
Class that adds extra information to QgsLabelFeature for text labels.
const QMap< QgsPalLayerSettings::Property, QVariant > & dataDefinedValues() const
Gets data-defined values.
QFont definedFont()
Font to be used for rendering.
DistanceUnit
Units of distance.
static Q_INVOKABLE double fromUnitToUnitFactor(QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
RenderUnit
Rendering size units.
@ RenderMillimeters
Millimeters.
@ RenderMapUnits
Map units.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) override
Gets an iterator for features matching the specified request.
QgsFields fields() const
Returns the fields that will be available for features that are retrieved from this source.
Represents a vector layer which manages a vector based data sets.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
QgsRectangle extent() const FINAL
Returns the extent of the layer.
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const FINAL
Calculates a list of unique values contained within an attribute in the layer.
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views.
Type
The WKB type describes the number of dimensions a geometry has.
static Type flatType(Type type) SIP_HOLDGIL
Returns the flat type for a WKB type.
QgsFeatureId featureId() const
Returns the unique ID of the feature.
QgsLabelFeature * feature()
Returns the parent feature.
LabelPosition is a candidate feature label position.
double getAlpha() const
Returns the angle to rotate text (in rad).
Quadrant getQuadrant() const
FeaturePart * getFeaturePart() const
Returns the feature corresponding to this labelposition.
double getX(int i=0) const
Returns the down-left x coordinate.
double getY(int i=0) const
Returns the down-left y coordinate.
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)
Contains geos related utilities and functions.
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 Q_NOWARN_DEPRECATED_POP
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
#define Q_NOWARN_DEPRECATED_PUSH
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QVector< QgsRingSequence > QgsCoordinateSequence
QVector< QgsPointSequence > QgsRingSequence
QVector< QgsPoint > QgsPointSequence
#define DXF_HANDPLOTSTYLE
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
#define QgsDebugMsgLevel(str, level)
QList< QgsSymbolLevel > QgsSymbolLevelOrder
QList< QgsSymbolLevelItem > QgsSymbolLevel
QList< QgsSymbol * > QgsSymbolList
QList< QgsSymbolLayer * > QgsSymbolLayerList
const QgsCoordinateReferenceSystem & crs
Holds information about each layer in a DXF job.
std::unique_ptr< QgsFeatureRenderer > renderer
QgsRenderContext renderContext
QgsCoordinateReferenceSystem crs
QgsVectorLayerFeatureSource featureSource
Layers and optional attribute index to split into multiple layers using attribute value as layer name...
QString splitLayerAttribute() const
If the split layer attribute is set, the vector layer will be split into several dxf layers,...