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, QString::number( handle, 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, QString::number( mBlockHandles[ block ], 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 = QString::number( mBlockHandles[ block ], 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 = QString::number( mBlockHandles[ QStringLiteral(
"*Model_Space" )], 16 );
644 job->renderer->usingSymbolLevels() )
646 writeEntitiesSymbolLevels( job );
662 QString lName(
dxfLayerName( job->splitLayerAttribute.isNull() ? job->layerTitle : fet.
attribute( job->splitLayerAttribute ).toString() ) );
664 sctx.setFeature( &fet );
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->registerFeature( fet, mRenderContext );
726 else if ( job->ruleBasedLabelProvider )
728 job->ruleBasedLabelProvider->registerFeature( fet, mRenderContext );
737 QImage image( 10, 10, QImage::Format_ARGB32_Premultiplied );
738 image.setDotsPerMeterX( 96 / 25.4 * 1000 );
739 image.setDotsPerMeterY( 96 / 25.4 * 1000 );
740 QPainter painter( &image );
748 void QgsDxfExport::prepareRenderers()
750 Q_ASSERT( mJobs.empty() );
758 mExtent.
height() * mFactor, 0 ) );
763 mLabelingEngine = qgis::make_unique<QgsDefaultLabelingEngine>();
764 mLabelingEngine->setMapSettings( mMapSettings );
767 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
777 if ( !layerIsScaleBasedVisible( vl ) )
780 QString splitLayerAttribute;
781 int splitLayerAttributeIndex = mLayerNameAttribute.value( vl->
id(), -1 );
783 if ( splitLayerAttributeIndex >= 0 && splitLayerAttributeIndex < fields.
size() )
784 splitLayerAttribute = fields.
at( splitLayerAttributeIndex ).
name();
790 void QgsDxfExport::writeEntitiesSymbolLevels(
DxfLayerJob *job )
792 QHash< QgsSymbol *, QList<QgsFeature> > features;
814 featureSymbol = job->
renderer->symbolForFeature( fet, ctx );
815 if ( !featureSymbol )
820 QHash< QgsSymbol *, QList<QgsFeature> >::iterator it = features.find( featureSymbol );
821 if ( it == features.end() )
823 it = features.insert( featureSymbol, QList<QgsFeature>() );
825 it.value().append( fet );
833 for (
int j = 0; j < symbol->symbolLayerCount(); j++ )
835 int level = symbol->symbolLayer( j )->renderingPass();
836 if ( level < 0 || level >= 1000 )
839 while ( level >= levels.count() )
841 levels[level].append( item );
850 QHash< QgsSymbol *, QList<QgsFeature> >::iterator levelIt = features.find( item.symbol() );
851 if ( levelIt == features.end() )
856 int llayer = item.layer();
857 const QList<QgsFeature> &featureList = levelIt.value();
858 for (
const QgsFeature &feature : featureList )
860 sctx.setFeature( &feature );
861 addFeature( sctx, ct, job->
layerName, levelIt.key()->symbolLayer( llayer ), levelIt.key() );
867 void QgsDxfExport::stopRenderers()
873 void QgsDxfExport::writeEndFile()
880 void QgsDxfExport::startSection()
885 void QgsDxfExport::endSection()
910 QHash< const QgsSymbolLayer *, QString >::const_iterator blockIt = mPointSymbolBlocks.constFind( symbolLayer );
911 if ( !symbolLayer || blockIt == mPointSymbolBlocks.constEnd() )
929 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
930 writeGroup( 100, QStringLiteral(
"AcDbBlockReference" ) );
943 QgsDebugMsg( QStringLiteral(
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
949 QgsDebugMsg( QStringLiteral(
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
953 if ( mForce2d || !line.at( 0 ).is3D() )
955 bool polygon = line[0] == line[ line.size() - 1 ];
959 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
962 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
963 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
971 for (
int i = 0; i < n; i++ )
976 writeGroup( 0, QStringLiteral(
"POLYLINE" ) );
979 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
983 writeGroup( 100, QStringLiteral(
"AcDb3dPolyline" ) );
987 for (
int i = 0; i < n; i++ )
992 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
995 writeGroup( 100, QStringLiteral(
"AcDbVertex" ) );
996 writeGroup( 100, QStringLiteral(
"AcDb3dPolylineVertex" ) );
1004 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1010 void QgsDxfExport::appendCurve(
const QgsCurve &
c, QVector<QgsPoint> &points, QVector<double> &bulges )
1015 appendLineString( *
dynamic_cast<const QgsLineString *
>( &
c ), points, bulges );
1019 appendCircularString( *
dynamic_cast<const QgsCircularString *
>( &
c ), points, bulges );
1023 appendCompoundCurve( *
dynamic_cast<const QgsCompoundCurve *
>( &
c ), points, bulges );
1027 QgsDebugMsg( QStringLiteral(
"Unexpected curve type %1" ).arg(
c.wktTypeStr() ) );
1032 void QgsDxfExport::appendLineString(
const QgsLineString &ls, QVector<QgsPoint> &points, QVector<double> &bulges )
1034 for (
int i = 0; i < ls.
numPoints(); i++ )
1037 if ( !points.isEmpty() && points.last() == p )
1045 void QgsDxfExport::appendCircularString(
const QgsCircularString &cs, QVector<QgsPoint> &points, QVector<double> &bulges )
1047 for (
int i = 0; i < cs.
numPoints() - 2; i += 2 )
1053 if ( points.isEmpty() || points.last() != p1 )
1055 else if ( !bulges.isEmpty() )
1056 bulges.removeLast();
1058 double a = ( M_PI - ( p1 - p2 ).
angle() + ( p3 - p2 ).
angle() ) / 2.0;
1059 bulges << sin( a ) / cos( a );
1066 void QgsDxfExport::appendCompoundCurve(
const QgsCompoundCurve &cc, QVector<QgsPoint> &points, QVector<double> &bulges )
1068 for (
int i = 0; i < cc.
nCurves(); i++ )
1072 appendCurve( *
c, points, bulges );
1081 QgsDebugMsg( QStringLiteral(
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
1087 QgsDebugMsg( QStringLiteral(
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
1091 QVector<QgsPoint> points;
1092 QVector<double> bulges;
1093 appendCurve( curve, points, bulges );
1095 if ( mForce2d || !curve.
is3D() )
1097 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
1100 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1101 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
1106 QgsDxfExport::DxfPolylineFlags polylineFlags;
1108 polylineFlags.setFlag( QgsDxfExport::DxfPolylineFlag::Closed );
1110 polylineFlags.setFlag( QgsDxfExport::DxfPolylineFlag::Curve );
1114 polylineFlags.setFlag( QgsDxfExport::DxfPolylineFlag::ContinuousPattern );
1116 writeGroup( 70,
static_cast<int>( polylineFlags ) );
1119 for (
int i = 0; i < points.size(); i++ )
1122 if ( bulges[i] != 0.0 )
1128 writeGroup( 0, QStringLiteral(
"POLYLINE" ) );
1131 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1135 writeGroup( 100, QStringLiteral(
"AcDb3dPolyline" ) );
1139 for (
int i = 0; i < points.size(); i++ )
1144 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1147 writeGroup( 100, QStringLiteral(
"AcDbVertex" ) );
1148 writeGroup( 100, QStringLiteral(
"AcDb3dPolylineVertex" ) );
1150 if ( bulges[i] != 0.0 )
1158 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1169 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1172 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
1178 writeGroup( 70, hatchPattern == QLatin1String(
"SOLID" ) );
1182 for (
int i = 0; i < polygon.size(); ++i )
1189 for (
int j = 0; j < polygon[i].size(); ++j )
1208 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1211 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
1217 writeGroup( 70, hatchPattern == QLatin1String(
"SOLID" ) );
1220 QVector<QVector<QgsPoint>> points;
1221 QVector<QVector<double>> bulges;
1223 points << QVector<QgsPoint>();
1224 bulges << QVector<double>();
1225 appendCurve( *polygon.
exteriorRing(), points.last(), bulges.last() );
1229 points << QVector<QgsPoint>();
1230 bulges << QVector<double>();
1231 appendCurve( *polygon.
interiorRing( i ), points.last(), bulges.last() );
1234 bool hasBulges =
false;
1235 for (
int i = 0; i < points.size() && !hasBulges; ++i )
1236 for (
int j = 0; j < points[i].size() && !hasBulges; ++j )
1237 hasBulges = bulges[i][j] != 0.0;
1241 for (
int i = 0; i < points.size(); ++i )
1248 for (
int j = 0; j < points[i].size(); ++j )
1272 double lblX = label->
getX();
1273 double lblY = label->
getY();
1282 if ( layerSettings.
placement == QgsPalLayerSettings::Placement::OverPoint )
1292 if ( exprVal.isValid() )
1298 switch ( offsetQuad )
1300 case QgsPalLayerSettings::QuadrantPosition::QuadrantAboveLeft:
1304 case QgsPalLayerSettings::QuadrantPosition::QuadrantAbove:
1308 case QgsPalLayerSettings::QuadrantPosition::QuadrantAboveRight:
1312 case QgsPalLayerSettings::QuadrantPosition::QuadrantLeft:
1316 case QgsPalLayerSettings::QuadrantPosition::QuadrantOver:
1320 case QgsPalLayerSettings::QuadrantPosition::QuadrantRight:
1324 case QgsPalLayerSettings::QuadrantPosition::QuadrantBelowLeft:
1328 case QgsPalLayerSettings::QuadrantPosition::QuadrantBelow:
1332 case QgsPalLayerSettings::QuadrantPosition::QuadrantBelowRight:
1350 if ( exprVal.isValid() )
1352 const QString haliString = exprVal.toString();
1353 if ( haliString.compare( QLatin1String(
"Center" ), Qt::CaseInsensitive ) == 0 )
1357 else if ( haliString.compare( QLatin1String(
"Right" ), Qt::CaseInsensitive ) == 0 )
1369 if ( exprVal.isValid() )
1371 const QString valiString = exprVal.toString();
1372 if ( valiString.compare( QLatin1String(
"Bottom" ), Qt::CaseInsensitive ) != 0 )
1374 if ( valiString.compare( QLatin1String(
"Base" ), Qt::CaseInsensitive ) == 0 )
1378 else if ( valiString.compare( QLatin1String(
"Half" ), Qt::CaseInsensitive ) == 0 )
1397 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1398 writeGroup( 100, QStringLiteral(
"AcDbPoint" ) );
1409 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1412 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
1443 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
1447 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1448 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
1467 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1470 writeGroup( 100, QStringLiteral(
"AcDbText" ) );
1481 writeGroup( 7, QStringLiteral(
"STANDARD" ) );
1482 writeGroup( 100, QStringLiteral(
"AcDbText" ) );
1491 if ( !mTextStream.codec()->canEncode( text ) )
1494 QgsDebugMsg( QStringLiteral(
"could not encode:%1" ).arg( text ) );
1500 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
1501 writeGroup( 100, QStringLiteral(
"AcDbMText" ) );
1508 while ( t.length() > 250 )
1524 writeGroup( 7, QStringLiteral(
"STANDARD" ) );
1539 geom.transform( ct );
1546 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
1548 penColor = colorFromSymbolLayer( symbolLayer, ctx );
1552 Qt::PenStyle penStyle( Qt::SolidLine );
1553 Qt::BrushStyle brushStyle( Qt::NoBrush );
1555 double offset = 0.0;
1557 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
1559 width = symbolLayer->
dxfWidth( *
this, ctx );
1560 offset = symbolLayer->
dxfOffset( *
this, ctx );
1569 QString lineStyleName = QStringLiteral(
"CONTINUOUS" );
1572 lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
1578 writePoint( geom.constGet()->coordinateSequence().at( 0 ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol,
angle );
1585 for (
int i = 0; i < cs.size(); i++ )
1587 writePoint( cs.at( i ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol,
angle );
1592 if ( penStyle != Qt::NoPen )
1595 std::unique_ptr< QgsAbstractGeometry > tempGeom;
1606 tempGeom.reset(
geos.offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 ) );
1608 sourceGeom = tempGeom.get();
1610 sourceGeom = geom.constGet();
1615 writePolyline( *curve, layer, lineStyleName, penColor, width );
1626 tempGeom.reset(
geos.offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 ) );
1628 sourceGeom = tempGeom.get();
1630 sourceGeom = geom.constGet();
1640 writePolyline( *curve, layer, lineStyleName, penColor, width );
1652 tempGeom.reset(
geos.buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 ) );
1654 sourceGeom = tempGeom.get();
1656 sourceGeom = geom.constGet();
1660 Q_ASSERT( polygon );
1675 tempGeom.reset(
geos.buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 ) );
1677 sourceGeom = tempGeom.get();
1679 sourceGeom = geom.constGet();
1688 Q_ASSERT( polygon );
1704 if ( brushStyle != Qt::NoBrush )
1707 std::unique_ptr< QgsAbstractGeometry > tempGeom;
1715 Q_ASSERT( polygon );
1716 writePolygon( *polygon, layer, QStringLiteral(
"SOLID" ), brushColor );
1729 Q_ASSERT( polygon );
1730 writePolygon( *polygon, layer, QStringLiteral(
"SOLID" ), brushColor );
1747 return symbolLayer->
dxfColor( ctx );
1750 QString QgsDxfExport::lineStyleFromSymbolLayer(
const QgsSymbolLayer *symbolLayer )
1752 QString lineStyleName = QStringLiteral(
"CONTINUOUS" );
1755 return lineStyleName;
1758 QHash< const QgsSymbolLayer *, QString >::const_iterator lineTypeIt = mLineStyles.constFind( symbolLayer );
1759 if ( lineTypeIt != mLineStyles.constEnd() )
1761 lineStyleName = lineTypeIt.value();
1762 return lineStyleName;
1766 return lineNameFromPenStyle( symbolLayer->
dxfPenStyle() );
1773 int current_distance = std::numeric_limits<int>::max();
1774 for (
int i = 1; i < static_cast< int >(
sizeof( sDxfColors ) /
sizeof( *sDxfColors ) ); ++i )
1776 int dist = color_distance( pixel, i );
1777 if ( dist < current_distance )
1779 current_distance = dist;
1788 int QgsDxfExport::color_distance( QRgb p1,
int index )
1790 if ( index > 255 || index < 0 )
1795 double redDiff = qRed( p1 ) - sDxfColors[index][0];
1796 double greenDiff = qGreen( p1 ) - sDxfColors[index][1];
1797 double blueDiff = qBlue( p1 ) - sDxfColors[index][2];
1799 QgsDebugMsg( QStringLiteral(
"color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
1800 .arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
1802 .arg( mDxfColors[index][0] )
1803 .arg( mDxfColors[index][1] )
1804 .arg( mDxfColors[index][2] )
1805 .arg( redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff ) );
1807 return redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff;
1810 QRgb QgsDxfExport::createRgbEntry( qreal r, qreal g, qreal b )
1812 return QColor::fromRgbF( r, g, b ).rgb();
1817 return mRenderContext;
1832 return mapUnitsPerPixel;
1846 double minSizeMU = std::numeric_limits<double>::lowest();
1849 minSizeMU = scale.
minSizeMM * pixelToMMFactor * mapUnitsPerPixel;
1853 minSizeMU = std::max( minSizeMU, value );
1855 value = std::max( value, minSizeMU );
1857 double maxSizeMU = std::numeric_limits<double>::max();
1860 maxSizeMU = scale.
maxSizeMM * pixelToMMFactor * mapUnitsPerPixel;
1864 maxSizeMU = std::min( maxSizeMU, value );
1866 value = std::min( value, maxSizeMU );
1869 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > QgsDxfExport::symbolLayers(
QgsRenderContext &context )
1871 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > symbolLayers;
1882 maxSymbolLayers = 1;
1884 for (
int i = 0; i < maxSymbolLayers; ++i )
1886 symbolLayers.append( qMakePair( symbol->
symbolLayer( i ), symbol ) );
1891 return symbolLayers;
1894 void QgsDxfExport::writeDefaultLinetypes()
1897 for (
const QString <ype : { QStringLiteral(
"ByLayer" ), QStringLiteral(
"ByBlock" ), QStringLiteral(
"CONTINUOUS" ) } )
1901 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
1902 writeGroup( 100, QStringLiteral(
"AcDbLinetypeTableRecord" ) );
1905 writeGroup( 3, QStringLiteral(
"Defaultstyle" ) );
1911 double das = dashSize();
1912 double dss = dashSeparatorSize();
1913 double dos = dotSize();
1915 QVector<qreal> dashVector( 2 );
1916 dashVector[0] = das;
1917 dashVector[1] = dss;
1920 QVector<qreal> dotVector( 2 );
1925 QVector<qreal> dashDotVector( 4 );
1926 dashDotVector[0] = das;
1927 dashDotVector[1] = dss;
1928 dashDotVector[2] = dos;
1929 dashDotVector[3] = dss;
1932 QVector<qreal> dashDotDotVector( 6 );
1933 dashDotDotVector[0] = das;
1934 dashDotDotVector[1] = dss;
1935 dashDotDotVector[2] = dos;
1936 dashDotDotVector[3] = dss;
1937 dashDotDotVector[4] = dos;
1938 dashDotDotVector[5] = dss;
1942 void QgsDxfExport::writeSymbolLayerLinetype(
const QgsSymbolLayer *symbolLayer )
1951 if ( !customLinestyle.isEmpty() )
1953 QString name = QStringLiteral(
"symbolLayer%1" ).arg( mSymbolLayerCounter++ );
1954 writeLinetype( name, customLinestyle, unit );
1955 mLineStyles.insert( symbolLayer, name );
1959 int QgsDxfExport::nLineTypes(
const QList< QPair< QgsSymbolLayer *, QgsSymbol * > > &symbolLayers )
1962 for (
const auto &symbolLayer : symbolLayers )
1976 void QgsDxfExport::writeLinetype(
const QString &styleName,
const QVector<qreal> &pattern,
QgsUnitTypes::RenderUnit u )
1979 for ( qreal size : pattern )
1987 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
1988 writeGroup( 100, QStringLiteral(
"AcDbLinetypeTableRecord" ) );
1997 for ( qreal size : pattern )
2000 double segmentLength = ( isGap ? -size : size );
2026 geomExpr.prepare( &expressionContext );
2034 symbolExpressionContextScope->
setFeature( f );
2039 for (
int i = 0; i < nSymbolLayers; ++i )
2041 addFeature( ctx, ct, layer, symbol->
symbolLayer( i ), symbol );
2050 if ( !sl || !symbol )
2063 double QgsDxfExport::dashSize()
const
2065 double size = mSymbologyScale * 0.002;
2066 return sizeToMapUnits( size );
2069 double QgsDxfExport::dotSize()
const
2071 double size = mSymbologyScale * 0.0006;
2072 return sizeToMapUnits( size );
2075 double QgsDxfExport::dashSeparatorSize()
const
2077 double size = mSymbologyScale * 0.0006;
2078 return sizeToMapUnits( size );
2081 double QgsDxfExport::sizeToMapUnits(
double s )
const
2087 QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
2092 return QStringLiteral(
"DASH" );
2094 return QStringLiteral(
"DOT" );
2095 case Qt::DashDotLine:
2096 return QStringLiteral(
"DASHDOT" );
2097 case Qt::DashDotDotLine:
2098 return QStringLiteral(
"DASHDOTDOT" );
2101 return QStringLiteral(
"CONTINUOUS" );
2107 if ( name.isEmpty() )
2108 return QStringLiteral(
"0" );
2130 layerName.replace( QLatin1String(
"\r\n" ), QLatin1String(
"_" ) );
2137 bool QgsDxfExport::layerIsScaleBasedVisible(
const QgsMapLayer *layer )
const
2151 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
2155 if ( vl && vl->
id() ==
id )
2157 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
2162 return QStringLiteral(
"0" );
2167 const QList< QByteArray > codecs = QTextCodec::availableCodecs();
2168 for (
const QByteArray &codec : codecs )
2170 if ( name != codec )
2174 for ( i = 0; i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) && name != DXF_ENCODINGS[i][1]; ++i )
2177 if ( i ==
static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) )
2180 return DXF_ENCODINGS[i][0];
2189 const QList< QByteArray > codecs = QTextCodec::availableCodecs();
2190 for (
const QByteArray &codec : codecs )
2193 for ( i = 0; i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) && strcmp( codec.data(), DXF_ENCODINGS[i][1] ) != 0; ++i )
2196 if ( i <
static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) )
2205 return mLayerTitleAsName && !vl->
title().isEmpty() ? vl->
title() : vl->
name();
2223 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues = lf->
dataDefinedValues();
2228 QgsDebugMsgLevel( QStringLiteral(
"PAL font definedFont: %1, Style: %2" ).arg( dFont.toString(), dFont.styleName() ), 4 );
2258 QgsPalLabeling::dataDefinedTextStyle( tmpLyr, ddValues );
2261 QgsPalLabeling::dataDefinedTextBuffer( tmpLyr, ddValues );
2264 QgsPalLabeling::dataDefinedTextFormatting( tmpLyr, ddValues );
2270 QString dxfLayer = mDxfLayerNames[layerId][fid];
2272 QString wrapchr = tmpLyr.
wrapChar.isEmpty() ? QStringLiteral(
"\n" ) : tmpLyr.
wrapChar;
2277 bool prependSymb =
false;
2295 prependSymb =
false;
2304 symb = symb + wrapchr;
2308 prependSymb =
false;
2309 symb = wrapchr + symb;
2318 txt.prepend( symb );
2328 txt.replace( QChar( QChar::LineFeed ),
' ' );
2329 txt.replace( QChar( QChar::CarriageReturn ),
' ' );
2334 txt.replace( QString( QChar( QChar::CarriageReturn ) ) + QString( QChar( QChar::LineFeed ) ), QStringLiteral(
"\\P" ) );
2335 txt.replace( QChar( QChar::CarriageReturn ), QStringLiteral(
"\\P" ) );
2336 txt = txt.replace( wrapchr, QLatin1String(
"\\P" ) );
2337 txt.replace(
" ",
"\\~" );
2341 txt.prepend(
"\\L" ).append(
"\\l" );
2346 txt.prepend(
"\\O" ).append(
"\\o" );
2351 txt.prepend(
"\\K" ).append(
"\\k" );
2354 txt.prepend( QStringLiteral(
"\\f%1|i%2|b%3;\\H%4;" )
2356 .arg( tmpLyr.
format().
font().italic() ? 1 : 0 )
2357 .arg( tmpLyr.
format().
font().bold() ? 1 : 0 )
2358 .arg( label->
getHeight() / ( 1 + txt.count( QStringLiteral(
"\\P" ) ) ) * 0.75 ) );
2366 if ( !mDxfLayerNames.contains( layerId ) )
2367 mDxfLayerNames[ layerId ] = QMap<QgsFeatureId, QString>();
2369 mDxfLayerNames[layerId][fid] =
layerName;
2385 QString splitLayerFieldName;
2387 if ( mLayerOutputAttributeIndex >= 0 && mLayerOutputAttributeIndex < fields.
size() )
2389 splitLayerFieldName = fields.
at( mLayerOutputAttributeIndex ).
name();
2392 return splitLayerFieldName;
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 * 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 id, geometry and a list of field/values...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
QVariant attribute(const QString &name) const
Lookup attribute value from 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
Gets 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 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.
@ DynamicRotation
Rotation of symbol may be changed during rendering and symbol should not be cached.
RenderHints 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.
QFont definedFont()
Font to be used for rendering.
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > & dataDefinedValues() const
Gets data-defined values.
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,...