58 int QgsDxfExport::sDxfColors[][3] =
318 const char *QgsDxfExport::DXF_ENCODINGS[][2] =
321 {
"8859_1",
"ISO-8859-1" },
322 {
"8859_2",
"ISO-8859-2" },
323 {
"8859_3",
"ISO-8859-3" },
324 {
"8859_4",
"ISO-8859-4" },
325 {
"8859_5",
"ISO-8859-5" },
326 {
"8859_6",
"ISO-8859-6" },
327 {
"8859_7",
"ISO-8859-7" },
328 {
"8859_8",
"ISO-8859-8" },
329 {
"8859_9",
"ISO-8859-9" },
331 {
"DOS850",
"CP850" },
342 {
"MACINTOSH",
"MacRoman" },
344 {
"KSC5601",
"ksc5601.1987-0" },
346 {
"DOS866",
"CP866" },
347 {
"ANSI_1250",
"CP1250" },
348 {
"ANSI_1251",
"CP1251" },
349 {
"ANSI_1252",
"CP1252" },
350 {
"GB2312",
"GB2312" },
351 {
"ANSI_1253",
"CP1253" },
352 {
"ANSI_1254",
"CP1254" },
353 {
"ANSI_1255",
"CP1255" },
354 {
"ANSI_1256",
"CP1256" },
355 {
"ANSI_1257",
"CP1257" },
356 {
"ANSI_874",
"CP874" },
357 {
"ANSI_932",
"Shift_JIS" },
358 {
"ANSI_936",
"CP936" },
359 {
"ANSI_949",
"CP949" },
360 {
"ANSI_950",
"CP950" },
363 {
"ANSI_1258",
"CP1258" },
373 mMapSettings = dxfExport.mMapSettings;
374 mLayerNameAttribute = dxfExport.mLayerNameAttribute;
375 mSymbologyScale = dxfExport.mSymbologyScale;
376 mSymbologyExport = dxfExport.mSymbologyExport;
377 mMapUnits = dxfExport.mMapUnits;
378 mLayerTitleAsName = dxfExport.mLayerTitleAsName;
379 mSymbolLayerCounter = 0;
383 mFactor = dxfExport.mFactor;
384 mForce2d = dxfExport.mForce2d;
390 mMapSettings = settings;
405 QList<QgsMapLayer *> layerList;
407 mLayerNameAttribute.clear();
409 QList< DxfLayer >::const_iterator layerIt = layers.constBegin();
410 for ( ; layerIt != layers.constEnd(); ++layerIt )
412 layerList << layerIt->layer();
413 if ( layerIt->layerOutputAttributeIndex() >= 0 )
414 mLayerNameAttribute.insert( layerIt->layer()->id(), layerIt->layerOutputAttributeIndex() );
442 if ( !mForce2d && p.
is3D() && std::isfinite( p.
z() ) )
449 int minDist = std::numeric_limits<int>::max();
451 for (
int i = 1; i < static_cast< int >(
sizeof( sDxfColors ) /
sizeof( *sDxfColors ) ) && minDist > 0; ++i )
453 int dist = color_distance( color.rgba(), i );
454 if ( dist >= minDist )
461 if ( minDist == 0 && minDistAt != 7 )
465 if ( color.alpha() == 255 )
469 int c = ( color.red() & 0xff ) * 0x10000 + ( color.green() & 0xff ) * 0x100 + ( color.blue() & 0xff );
471 if ( transparencyCode != -1 && color.alpha() < 255 )
472 writeGroup( transparencyCode, 0x2000000 | color.alpha() );
477 mTextStream << QStringLiteral(
"%1\n" ).arg( code, 3, 10, QChar(
' ' ) );
482 mTextStream << QStringLiteral(
"%1\n" ).arg( i, 6, 10, QChar(
' ' ) );
488 if ( !s.contains(
'.' ) )
489 s += QLatin1String(
".0" );
490 mTextStream << s <<
'\n';
495 mTextStream << s <<
'\n';
505 if ( !d->isOpen() && !d->open( QIODevice::WriteOnly | QIODevice::Truncate ) )
510 mTextStream.setDevice( d );
511 mTextStream.setCodec( encoding.toLocal8Bit() );
518 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
533 mExtent = layerExtent;
564 void QgsDxfExport::writeHeader(
const QString &codepage )
566 writeGroup( 999, QStringLiteral(
"DXF created from QGIS" ) );
572 writeGroup( 9, QStringLiteral(
"$ACADVER" ) );
584 writeGroup( 9, QStringLiteral(
"$LTSCALE" ) );
596 writeGroup( 9, QStringLiteral(
"$PSLTSCALE" ) );
599 writeGroup( 9, QStringLiteral(
"$HANDSEED" ) );
602 writeGroup( 9, QStringLiteral(
"$DWGCODEPAGE" ) );
611 handle = mNextHandleId++;
613 Q_ASSERT_X( handle <
DXF_HANDMAX,
"QgsDxfExport::writeHandle(int, int)",
"DXF handle too large" );
615 writeGroup( code, QStringLiteral(
"%1" ).arg( handle, 0, 16 ) );
619 void QgsDxfExport::writeTables()
626 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > slList;
629 slList = symbolLayers( context );
637 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
640 writeDefaultLinetypes();
643 QList< QPair< QgsSymbolLayer *, QgsSymbol *> >::const_iterator slIt = slList.constBegin();
644 for ( ; slIt != slList.constEnd(); ++slIt )
646 writeSymbolLayerLinetype( slIt->first );
653 writeGroup( 2, QStringLiteral(
"BLOCK_RECORD" ) );
656 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
659 const QStringList blockStrings = QStringList() << QStringLiteral(
"*Model_Space" ) << QStringLiteral(
"*Paper_Space" ) << QStringLiteral(
"*Paper_Space0" );
660 for (
const QString &block : blockStrings )
662 writeGroup( 0, QStringLiteral(
"BLOCK_RECORD" ) );
664 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
665 writeGroup( 100, QStringLiteral(
"AcDbBlockTableRecord" ) );
670 slIt = slList.constBegin();
671 for ( ; slIt != slList.constEnd(); ++slIt )
677 if ( hasDataDefinedProperties( ml, slIt->second ) )
680 QString name = QStringLiteral(
"symbolLayer%1" ).arg( i++ );
681 writeGroup( 0, QStringLiteral(
"BLOCK_RECORD" ) );
683 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
684 writeGroup( 100, QStringLiteral(
"AcDbBlockTableRecord" ) );
694 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
698 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
699 writeGroup( 100, QStringLiteral(
"AcDbRegAppTableRecord" ) );
708 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
716 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
724 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
728 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
729 writeGroup( 100, QStringLiteral(
"AcDbViewportTableRecord" ) );
768 writeGroup( 2, QStringLiteral(
"DIMSTYLE" ) );
770 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
771 writeGroup( 100, QStringLiteral(
"AcDbDimStyleTable" ) );
775 QSet<QString> layerNames;
776 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
779 if ( !layerIsScaleBasedVisible( ml ) )
786 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
793 const QSet<QVariant> values = vl->
uniqueValues( attrIdx );
794 for (
const QVariant &v : values )
806 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
811 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
812 writeGroup( 100, QStringLiteral(
"AcDbLayerTableRecord" ) );
816 writeGroup( 6, QStringLiteral(
"CONTINUOUS" ) );
819 for (
const QString &
layerName : qgis::as_const( layerNames ) )
823 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
824 writeGroup( 100, QStringLiteral(
"AcDbLayerTableRecord" ) );
828 writeGroup( 6, QStringLiteral(
"CONTINUOUS" ) );
837 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
843 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
844 writeGroup( 100, QStringLiteral(
"AcDbTextStyleTableRecord" ) );
845 writeGroup( 2, QStringLiteral(
"STANDARD" ) );
852 writeGroup( 3, QStringLiteral(
"romans.shx" ) );
860 void QgsDxfExport::writeBlocks()
865 const QStringList blockStrings = QStringList() << QStringLiteral(
"*Model_Space" ) << QStringLiteral(
"*Paper_Space" ) << QStringLiteral(
"*Paper_Space0" );
866 for (
const QString &block : blockStrings )
870 writeGroup( 330, QStringLiteral(
"%1" ).arg( mBlockHandles[ block ], 0, 16 ) );
871 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
873 writeGroup( 100, QStringLiteral(
"AcDbBlockBegin" ) );
881 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
883 writeGroup( 100, QStringLiteral(
"AcDbBlockEnd" ) );
889 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > slList;
892 slList = symbolLayers( ct );
895 QList< QPair< QgsSymbolLayer *, QgsSymbol * > >::const_iterator slIt = slList.constBegin();
896 for ( ; slIt != slList.constEnd(); ++slIt )
907 if ( hasDataDefinedProperties( ml, slIt->second ) )
913 QString block( QStringLiteral(
"symbolLayer%1" ).arg( mBlockCounter++ ) );
914 mBlockHandle = QStringLiteral(
"%1" ).arg( mBlockHandles[ block ], 0, 16 );
919 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
921 writeGroup( 100, QStringLiteral(
"AcDbBlockBegin" ) );
934 ml->
writeDxf( *
this,
mapUnitScaleFactor( mSymbologyScale, ml->
sizeUnit(), mMapUnits, ctx.renderContext().mapToPixel().mapUnitsPerPixel() ), QStringLiteral(
"0" ), ctx );
938 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
940 writeGroup( 100, QStringLiteral(
"AcDbBlockEnd" ) );
942 mPointSymbolBlocks.insert( ml, block );
949 void QgsDxfExport::writeEntities()
952 writeGroup( 2, QStringLiteral(
"ENTITIES" ) );
954 mBlockHandle = QStringLiteral(
"%1" ).arg( mBlockHandles[ QStringLiteral(
"*Model_Space" )], 0, 16 );
956 QImage image( 10, 10, QImage::Format_ARGB32_Premultiplied );
957 image.setDotsPerMeterX( 96 / 25.4 * 1000 );
958 image.setDotsPerMeterY( 96 / 25.4 * 1000 );
959 QPainter painter( &image );
968 mExtent.
height() * mFactor, 0 ) );
978 const QList< QgsMapLayer *> layers = mMapSettings.
layers();
982 if ( !vl || !layerIsScaleBasedVisible( vl ) )
990 QgsDebugMsg( QStringLiteral(
"%1: apply override style" ).arg( vl->
id() ) );
995 QgsDebugMsg( QStringLiteral(
"%1: no override style" ).arg( vl->
id() ) );
1012 std::unique_ptr< QgsFeatureRenderer > renderer( vl->
renderer()->
clone() );
1013 renderer->startRender( ctx, vl->
fields() );
1015 QSet<QString> attributes = renderer->usedAttributes( ctx );
1016 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
1020 attributes << layerAttr;
1026 if (
const QgsRuleBasedLabeling *rbl = dynamic_cast<const QgsRuleBasedLabeling *>( labeling ) )
1032 if ( !rblp->
prepare( ctx, attributes ) )
1038 else if ( labeling )
1044 if ( !lp->
prepare( ctx, attributes ) )
1053 renderer->usingSymbolLevels() )
1055 writeEntitiesSymbolLevels( vl );
1056 renderer->stopRender( ctx );
1076 if ( !renderer->willRenderFeature( fet, ctx ) )
1081 addFeature( sctx, ct, lName,
nullptr,
nullptr );
1085 QgsSymbolList symbolList = renderer->symbolsForFeature( fet, ctx );
1086 bool hasSymbology = symbolList.size() > 0;
1090 QgsSymbolList::iterator symbolIt = symbolList.begin();
1091 for ( ; symbolIt != symbolList.end(); ++symbolIt )
1093 int nSymbolLayers = ( *symbolIt )->symbolLayerCount();
1094 for (
int i = 0; i < nSymbolLayers; ++i )
1102 bool isGeometryGenerator = ( sl->
layerType() == QLatin1String(
"GeometryGenerator" ) );
1103 if ( isGeometryGenerator )
1105 addGeometryGeneratorSymbolLayer( sctx, ct, lName, sl,
true );
1109 addFeature( sctx, ct, lName, sl, *symbolIt );
1114 else if ( hasSymbology )
1125 addGeometryGeneratorSymbolLayer( sctx, ct, lName, s->
symbolLayer( 0 ), false );
1129 addFeature( sctx, ct, lName, s->
symbolLayer( 0 ), s );
1144 renderer->stopRender( ctx );
1152 void QgsDxfExport::writeEntitiesSymbolLevels(
QgsVectorLayer *layer )
1164 std::unique_ptr< QgsFeatureRenderer > renderer( layer->
renderer()->
clone() );
1165 QHash< QgsSymbol *, QList<QgsFeature> > features;
1170 renderer->startRender( ctx, layer->
fields() );
1189 featureSymbol = renderer->symbolForFeature( fet, ctx );
1190 if ( !featureSymbol )
1195 QHash< QgsSymbol *, QList<QgsFeature> >::iterator it = features.find( featureSymbol );
1196 if ( it == features.end() )
1198 it = features.insert( featureSymbol, QList<QgsFeature>() );
1200 it.value().append( fet );
1206 for (
int i = 0; i < symbols.count(); i++ )
1212 if ( level < 0 || level >= 1000 )
1215 while ( level >= levels.count() )
1217 levels[level].append( item );
1224 for (
int l = 0; l < levels.count(); l++ )
1227 for (
int i = 0; i < level.count(); i++ )
1230 QHash< QgsSymbol *, QList<QgsFeature> >::iterator levelIt = features.find( item.
symbol() );
1231 if ( levelIt == features.end() )
1233 QgsDebugMsg( QStringLiteral(
"No feature found for symbol on %1 %2.%3" ).arg( layer->
id() ).arg( l ).arg( i ) );
1237 int llayer = item.
layer();
1238 QList<QgsFeature> &featureList = levelIt.value();
1239 QList<QgsFeature>::iterator featureIt = featureList.begin();
1240 for ( ; featureIt != featureList.end(); ++featureIt )
1243 addFeature( sctx, ct, layer->
name(), levelIt.key()->symbolLayer( llayer ), levelIt.key() );
1247 renderer->stopRender( ctx );
1250 void QgsDxfExport::writeEndFile()
1277 ACAD_MLEADERSTYLE\n\ 1285 ACAD_PLOTSETTINGS\n\ 1289 ACAD_PLOTSTYLENAME\n\ 1397 ACDBDICTIONARYWDFLT\n\ 1417 AcDbDictionaryWithDefault\n\ 1613 1.000000000000000E+20\n\ 1615 1.000000000000000E+20\n\ 1617 1.000000000000000E+20\n\ 1619 -1.000000000000000E+20\n\ 1621 -1.000000000000000E+20\n\ 1623 -1.000000000000000E+20\n\ 1885 163.1318914119703\n\ 2053 AcDbSavedByObjectVersion\n\ 2143 AcDbSavedByObjectVersion\n\ 2233 AcDbSavedByObjectVersion\n\ 2323 AcDbSavedByObjectVersion\n\ 2413 AcDbSavedByObjectVersion\n\ 2505 AcDbSavedByObjectVersion\n\ 2595 AcDbSavedByObjectVersion\n\ 2685 AcDbSavedByObjectVersion\n\ 2775 AcDbSavedByObjectVersion\n\ 2865 AcDbSavedByObjectVersion\n\ 2955 AcDbSavedByObjectVersion\n\ 3045 AcDbSavedByObjectVersion\n\ 3135 AcDbSavedByObjectVersion\n\ 3225 AcDbSavedByObjectVersion\n\ 3317 AcDbSavedByObjectVersion\n\ 3407 AcDbSavedByObjectVersion\n\ 3417 void QgsDxfExport::startSection()
3419 writeGroup( 0, QStringLiteral(
"SECTION" ) );
3422 void QgsDxfExport::endSection()
3435 msl->
sizeUnit(), mMapUnits ) / 2.0;
3447 QHash< const QgsSymbolLayer *, QString >::const_iterator blockIt = mPointSymbolBlocks.constFind( symbolLayer );
3448 if ( !symbolLayer || blockIt == mPointSymbolBlocks.constEnd() )
3452 if ( msl && symbol )
3466 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3467 writeGroup( 100, QStringLiteral(
"AcDbBlockReference" ) );
3477 int n = line.size();
3480 QgsDebugMsg( QStringLiteral(
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3486 QgsDebugMsg( QStringLiteral(
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3490 if ( mForce2d || !line.at( 0 ).is3D() )
3492 bool polygon = line[0] == line[ line.size() - 1 ];
3496 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
3499 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3500 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
3508 for (
int i = 0; i < n; i++ )
3513 writeGroup( 0, QStringLiteral(
"POLYLINE" ) );
3516 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3520 writeGroup( 100, QStringLiteral(
"AcDb3dPolyline" ) );
3524 for (
int i = 0; i < n; i++ )
3529 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3532 writeGroup( 100, QStringLiteral(
"AcDbVertex" ) );
3533 writeGroup( 100, QStringLiteral(
"AcDb3dPolylineVertex" ) );
3541 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3552 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3555 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
3561 writeGroup( 70, hatchPattern == QLatin1String(
"SOLID" ) );
3565 for (
int i = 0; i < polygon.size(); ++i )
3572 for (
int j = 0; j < polygon[i].size(); ++j )
3595 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3596 writeGroup( 100, QStringLiteral(
"AcDbPoint" ) );
3607 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3610 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
3641 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
3645 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3646 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
3665 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3666 writeGroup( 100, QStringLiteral(
"AcDbText" ) );
3673 writeGroup( 7, QStringLiteral(
"STANDARD" ) );
3674 writeGroup( 100, QStringLiteral(
"AcDbText" ) );
3679 if ( !mTextStream.codec()->canEncode( text ) )
3682 QgsDebugMsg( QStringLiteral(
"could not encode:%1" ).arg( text ) );
3688 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3689 writeGroup( 100, QStringLiteral(
"AcDbMText" ) );
3696 while ( t.length() > 250 )
3712 writeGroup( 7, QStringLiteral(
"STANDARD" ) );
3734 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
3736 penColor = colorFromSymbolLayer( symbolLayer, ctx );
3740 Qt::PenStyle penStyle( Qt::SolidLine );
3741 Qt::BrushStyle brushStyle( Qt::NoBrush );
3743 double offset = 0.0;
3745 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
3747 width = symbolLayer->
dxfWidth( *
this, ctx );
3748 offset = symbolLayer->
dxfOffset( *
this, ctx );
3749 angle = symbolLayer->
dxfAngle( ctx );
3757 QString lineStyleName = QStringLiteral(
"CONTINUOUS" );
3760 lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
3766 writePoint( geom.constGet()->coordinateSequence().at( 0 ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol,
angle );
3773 for (
int i = 0; i < cs.size(); i++ )
3775 writePoint( cs.at( i ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol,
angle );
3780 if ( penStyle != Qt::NoPen )
3783 std::unique_ptr< QgsAbstractGeometry > tempGeom;
3789 tempGeom.reset( geom.constGet()->segmentize() );
3790 sourceGeom = tempGeom.get();
3798 tempGeom.reset( geos.
offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 ) );
3800 sourceGeom = tempGeom.get();
3802 sourceGeom = geom.constGet();
3810 tempGeom.reset( geom.constGet()->segmentize() );
3813 sourceGeom = tempGeom.get();
3820 tempGeom.reset( geos.
offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 ) );
3822 sourceGeom = tempGeom.get();
3824 sourceGeom = geom.constGet();
3828 for (
int i = 0; i < cs.size(); i++ )
3830 writePolyline( cs.at( i ).at( 0 ), layer, lineStyleName, penColor, width );
3837 tempGeom.reset( geom.constGet()->segmentize() );
3840 sourceGeom = tempGeom.get();
3847 tempGeom.reset( geos.
buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 ) );
3849 sourceGeom = tempGeom.get();
3851 sourceGeom = geom.constGet();
3855 for (
int i = 0; i < cs.at( 0 ).size(); i++ )
3857 writePolyline( cs.at( 0 ).at( i ), layer, lineStyleName, penColor, width );
3864 tempGeom.reset( geom.constGet()->segmentize() );
3867 sourceGeom = tempGeom.get();
3874 tempGeom.reset( geos.
buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 ) );
3876 sourceGeom = tempGeom.get();
3878 sourceGeom = geom.constGet();
3882 for (
int i = 0; i < cs.size(); i++ )
3883 for (
int j = 0; j < cs.at( i ).size(); j++ )
3884 writePolyline( cs.at( i ).at( j ), layer, lineStyleName, penColor, width );
3895 if ( brushStyle != Qt::NoBrush )
3898 std::unique_ptr< QgsAbstractGeometry > tempGeom;
3903 tempGeom.reset( geom.constGet()->segmentize() );
3906 sourceGeom = tempGeom.get();
3913 tempGeom.reset( geom.constGet()->segmentize() );
3916 sourceGeom = tempGeom.get();
3921 for (
int i = 0; i < cs.size(); i++ )
3923 writePolygon( cs.at( i ), layer, QStringLiteral(
"SOLID" ), brushColor );
3940 return symbolLayer->
dxfColor( ctx );
3943 QString QgsDxfExport::lineStyleFromSymbolLayer(
const QgsSymbolLayer *symbolLayer )
3945 QString lineStyleName = QStringLiteral(
"CONTINUOUS" );
3948 return lineStyleName;
3951 QHash< const QgsSymbolLayer *, QString >::const_iterator lineTypeIt = mLineStyles.constFind( symbolLayer );
3952 if ( lineTypeIt != mLineStyles.constEnd() )
3954 lineStyleName = lineTypeIt.value();
3955 return lineStyleName;
3959 return lineNameFromPenStyle( symbolLayer->
dxfPenStyle() );
3966 int current_distance = std::numeric_limits<int>::max();
3967 for (
int i = 1; i < static_cast< int >(
sizeof( sDxfColors ) /
sizeof( *sDxfColors ) ); ++i )
3969 int dist = color_distance( pixel, i );
3970 if ( dist < current_distance )
3972 current_distance = dist;
3981 int QgsDxfExport::color_distance( QRgb p1,
int index )
3983 if ( index > 255 || index < 0 )
3988 double redDiff = qRed( p1 ) - sDxfColors[index][0];
3989 double greenDiff = qGreen( p1 ) - sDxfColors[index][1];
3990 double blueDiff = qBlue( p1 ) - sDxfColors[index][2];
3992 QgsDebugMsg( QStringLiteral(
"color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
3993 .arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
3995 .arg( mDxfColors[index][0] )
3996 .arg( mDxfColors[index][1] )
3997 .arg( mDxfColors[index][2] )
3998 .arg( redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff ) );
4000 return redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff;
4003 QRgb QgsDxfExport::createRgbEntry( qreal r, qreal g, qreal b )
4005 return QColor::fromRgbF( r, g, b ).rgb();
4027 return mapUnitsPerPixel;
4041 double minSizeMU = std::numeric_limits<double>::lowest();
4044 minSizeMU = scale.
minSizeMM * pixelToMMFactor * mapUnitsPerPixel;
4048 minSizeMU = std::max( minSizeMU, value );
4050 value = std::max( value, minSizeMU );
4052 double maxSizeMU = std::numeric_limits<double>::max();
4055 maxSizeMU = scale.
maxSizeMM * pixelToMMFactor * mapUnitsPerPixel;
4059 maxSizeMU = std::min( maxSizeMU, value );
4061 value = std::min( value, maxSizeMU );
4064 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > QgsDxfExport::symbolLayers(
QgsRenderContext &context )
4066 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > symbolLayers;
4068 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
4086 QgsSymbolList::iterator symbolIt = symbols.begin();
4087 for ( ; symbolIt != symbols.end(); ++symbolIt )
4089 int maxSymbolLayers = ( *symbolIt )->symbolLayerCount();
4092 maxSymbolLayers = 1;
4094 for (
int i = 0; i < maxSymbolLayers; ++i )
4096 symbolLayers.append( qMakePair( ( *symbolIt )->symbolLayer( i ), *symbolIt ) );
4101 return symbolLayers;
4104 void QgsDxfExport::writeDefaultLinetypes()
4107 const QStringList blockStrings = QStringList() << QStringLiteral(
"ByLayer" ) << QStringLiteral(
"ByBlock" ) << QStringLiteral(
"CONTINUOUS" );
4108 for (
const QString <ype : blockStrings )
4112 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
4113 writeGroup( 100, QStringLiteral(
"AcDbLinetypeTableRecord" ) );
4116 writeGroup( 3, QStringLiteral(
"Defaultstyle" ) );
4122 double das = dashSize();
4123 double dss = dashSeparatorSize();
4124 double dos = dotSize();
4126 QVector<qreal> dashVector( 2 );
4127 dashVector[0] = das;
4128 dashVector[1] = dss;
4131 QVector<qreal> dotVector( 2 );
4136 QVector<qreal> dashDotVector( 4 );
4137 dashDotVector[0] = das;
4138 dashDotVector[1] = dss;
4139 dashDotVector[2] = dos;
4140 dashDotVector[3] = dss;
4143 QVector<qreal> dashDotDotVector( 6 );
4144 dashDotDotVector[0] = das;
4145 dashDotDotVector[1] = dss;
4146 dashDotDotVector[2] = dos;
4147 dashDotDotVector[3] = dss;
4148 dashDotDotVector[4] = dos;
4149 dashDotDotVector[5] = dss;
4153 void QgsDxfExport::writeSymbolLayerLinetype(
const QgsSymbolLayer *symbolLayer )
4162 if ( !customLinestyle.isEmpty() )
4164 QString name = QStringLiteral(
"symbolLayer%1" ).arg( mSymbolLayerCounter++ );
4165 writeLinetype( name, customLinestyle, unit );
4166 mLineStyles.insert( symbolLayer, name );
4170 int QgsDxfExport::nLineTypes(
const QList< QPair< QgsSymbolLayer *, QgsSymbol * > > &symbolLayers )
4173 QList< QPair< QgsSymbolLayer *, QgsSymbol *> >::const_iterator slIt = symbolLayers.constBegin();
4174 for ( ; slIt != symbolLayers.constEnd(); ++slIt )
4188 void QgsDxfExport::writeLinetype(
const QString &styleName,
const QVector<qreal> &pattern,
QgsUnitTypes::RenderUnit u )
4191 QVector<qreal>::const_iterator dashIt = pattern.constBegin();
4192 for ( ; dashIt != pattern.constEnd(); ++dashIt )
4200 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
4201 writeGroup( 100, QStringLiteral(
"AcDbLinetypeTableRecord" ) );
4209 dashIt = pattern.constBegin();
4211 for ( ; dashIt != pattern.constEnd(); ++dashIt )
4214 double segmentLength = ( isGap ? -*dashIt : *dashIt );
4240 geomExpr.
prepare( &expressionContext );
4248 symbolExpressionContextScope->
setFeature( f );
4253 for (
int i = 0; i < nSymbolLayers; ++i )
4255 addFeature( ctx, ct, layer, symbol->
symbolLayer( i ), symbol );
4264 if ( !sl || !symbol )
4277 double QgsDxfExport::dashSize()
const 4279 double size = mSymbologyScale * 0.002;
4280 return sizeToMapUnits( size );
4283 double QgsDxfExport::dotSize()
const 4285 double size = mSymbologyScale * 0.0006;
4286 return sizeToMapUnits( size );
4289 double QgsDxfExport::dashSeparatorSize()
const 4291 double size = mSymbologyScale * 0.0006;
4292 return sizeToMapUnits( size );
4295 double QgsDxfExport::sizeToMapUnits(
double s )
const 4301 QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
4306 return QStringLiteral(
"DASH" );
4308 return QStringLiteral(
"DOT" );
4309 case Qt::DashDotLine:
4310 return QStringLiteral(
"DASHDOT" );
4311 case Qt::DashDotDotLine:
4312 return QStringLiteral(
"DASHDOTDOT" );
4315 return QStringLiteral(
"CONTINUOUS" );
4321 if ( name.isEmpty() )
4322 return QStringLiteral(
"0" );
4330 layerName.replace(
'<',
'_' );
4331 layerName.replace(
'>',
'_' );
4332 layerName.replace(
'/',
'_' );
4333 layerName.replace(
'\\',
'_' );
4334 layerName.replace(
'\"',
'_' );
4335 layerName.replace(
':',
'_' );
4336 layerName.replace(
';',
'_' );
4337 layerName.replace(
'?',
'_' );
4338 layerName.replace(
'*',
'_' );
4339 layerName.replace(
'|',
'_' );
4340 layerName.replace(
'=',
'_' );
4341 layerName.replace(
'\'',
'_' );
4344 layerName.replace( QLatin1String(
"\r\n" ), QLatin1String(
"_" ) );
4345 layerName.replace(
'\r',
'_' );
4346 layerName.replace(
'\n',
'_' );
4348 return layerName.trimmed();
4351 bool QgsDxfExport::layerIsScaleBasedVisible(
const QgsMapLayer *layer )
const 4364 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
4368 if ( vl && vl->
id() == id )
4370 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
4375 return QStringLiteral(
"0" );
4380 const QList< QByteArray > codecs = QTextCodec::availableCodecs();
4381 for (
const QByteArray &codec : codecs )
4383 if ( name != codec )
4387 for ( i = 0; i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) && name != DXF_ENCODINGS[i][1]; ++i )
4390 if ( i == static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) )
4393 return DXF_ENCODINGS[i][0];
4402 const QList< QByteArray > codecs = QTextCodec::availableCodecs();
4403 for (
const QByteArray &codec : codecs )
4406 for ( i = 0; i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) && strcmp( codec.data(), DXF_ENCODINGS[i][1] ) != 0; ++i )
4409 if ( i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) )
4410 encodings << codec.data();
4418 return mLayerTitleAsName && !vl->
title().isEmpty() ? vl->
title() : vl->
name();
4423 Q_UNUSED( context );
4436 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues = lf->
dataDefinedValues();
4441 QgsDebugMsgLevel( QStringLiteral(
"PAL font definedFont: %1, Style: %2" ).arg( dFont.toString(), dFont.styleName() ), 4 );
4471 QgsPalLabeling::dataDefinedTextStyle( tmpLyr, ddValues );
4474 QgsPalLabeling::dataDefinedTextBuffer( tmpLyr, ddValues );
4477 QgsPalLabeling::dataDefinedTextFormatting( tmpLyr, ddValues );
4483 QString dxfLayer = mDxfLayerNames[layerId][fid];
4485 QString wrapchr = tmpLyr.
wrapChar.isEmpty() ? QStringLiteral(
"\n" ) : tmpLyr.
wrapChar;
4490 bool prependSymb =
false;
4508 prependSymb =
false;
4516 symb = symb + wrapchr;
4520 prependSymb =
false;
4521 symb = wrapchr + symb;
4526 txt.prepend( symb );
4540 txt = txt.replace( wrapchr, QLatin1String(
"\\P" ) );
4541 txt.replace(
" ",
"\\~" );
4545 txt.prepend(
"\\L" ).append(
"\\l" );
4550 txt.prepend(
"\\O" ).append(
"\\o" );
4555 txt.prepend(
"\\K" ).append(
"\\k" );
4558 txt.prepend( QStringLiteral(
"\\f%1|i%2|b%3;\\H%4;" )
4560 .arg( tmpLyr.
format().
font().italic() ? 1 : 0 )
4561 .arg( tmpLyr.
format().
font().bold() ? 1 : 0 )
4562 .arg( label->
getHeight() / ( 1 + txt.count( QStringLiteral(
"\\P" ) ) ) * 0.75 ) );
4570 if ( !mDxfLayerNames.contains( layerId ) )
4571 mDxfLayerNames[ layerId ] = QMap<QgsFeatureId, QString>();
4573 mDxfLayerNames[layerId][fid] =
layerName;
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
Class for parsing and evaluation of expressions (formerly called "search strings").
QgsDxfExport()=default
Constructor for QgsDxfExport.
Wrapper for iterator of features from vector data provider or vector layer.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
A rectangle specified with double values.
Base class for all map layer types.
void setExtent(const QgsRectangle &rect, bool magnified=true)
Set coordinates of the rectangle which should be rendered.
double minSizeMM
The minimum size in millimeters, or 0.0 if unset.
QString leftDirectionSymbol
String to use for left direction arrows.
bool isEmpty() const
Returns true if the rectangle is empty.
void writeLine(const QgsPoint &pt1, const QgsPoint &pt2, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Write line (as a polyline)
void addProvider(QgsAbstractLabelProvider *provider)
Add provider of label features. Takes ownership of the provider.
QString geometryExpression() const
Gets the expression to generate this geometry.
QFont font() const
Returns the font used for rendering text.
virtual Qt::PenStyle dxfPenStyle() const
Gets pen style.
void removeProvider(QgsAbstractLabelProvider *provider)
Remove provider if the provider's initialization failed. Provider instance is deleted.
Abstract base class for all rendered symbols.
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
QgsLabelFeature * feature()
Returns the parent feature.
QgsPointXY layerToMapCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from layer's CRS to output CRS
Restore overridden layer style on destruction.
void writeGroup(int code, int i)
Write a tuple of group code and integer value.
void writePolyline(const QgsPointSequence &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE)
QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
Place direction symbols on below label.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QVector< QgsRingSequence > QgsCoordinateSequence
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
Export text as TEXT elements. If not set, text will be exported as MTEXT elements.
virtual QgsSymbolList symbols(QgsRenderContext &context) const
Returns list of symbols used by the renderer.
void startRender(QgsSymbolRenderContext &context) override
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
virtual double dxfOffset(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets offset.
Implements a derived label provider for rule based labels internally used for DXF export...
double size() const
Returns the symbol size.
void setRendererScale(double scale)
Sets the renderer map scale.
void setFont(const QFont &font)
Sets the font used for rendering text.
QgsAbstractGeometry * buffer(double distance, int segments, QString *errorMsg=nullptr) const override
void setOutputDpi(double dpi)
Sets DPI used for conversion between real world units (e.g. mm) and pixels.
void registerDxfLayer(const QString &layerId, QgsFeatureId fid, const QString &layer)
Register name of layer for feature.
static int closestColorMatch(QRgb color)
Gets DXF palette index of nearest entry for given color.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
Class that adds extra information to QgsLabelFeature for text labels.
QMap< QString, QString > layerStyleOverrides() const
Gets map of map layer style overrides (key: layer ID, value: style name) where a different style shou...
static QStringList encodings()
Returns list of available DXF encodings.
bool addDirectionSymbol
If true, '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will be ...
void setMapSettings(const QgsMapSettings &mapSettings)
Associate map settings instance.
void registerDxfFeature(QgsFeature &feature, QgsRenderContext &context, const QString &dxfLayerName)
Registration method that keeps track of DXF layer names of individual features.
A geometry is the spatial representation of a feature.
bool drawLabels
Whether to draw labels for this layer.
const QgsMapToPixel & mapToPixel() const
QgsUnitTypes::DistanceUnit mapUnits
QgsDxfExport::Flags flags() const
Returns the export flags.
virtual QVector< qreal > dxfCustomDashPattern(QgsUnitTypes::RenderUnit &unit) const
Gets dash pattern.
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS
MultiLineAlign multilineAlign
Horizontal alignment of multi-line labels.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc...
FeaturePart * getFeaturePart()
Returns the feature corresponding to this labelposition.
QColor color() const
Returns the color that text will be rendered in.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsCoordinateTransform layerTransform(const QgsMapLayer *layer) const
Returns the coordinate transform from layer's CRS to destination CRS.
const QgsCoordinateReferenceSystem & crs
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
void clipValueToMapUnitScale(double &value, const QgsMapUnitScale &scale, double pixelToMMFactor) const
Clips value to scale minimum/maximum.
void setExtent(const QgsRectangle &extent)
When rendering a map layer, calling this method sets the "clipping" extent for the layer (in the laye...
Rotation of symbol may be changed during rendering and symbol should not be cached.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
bool reverseDirectionSymbol
True if direction symbols should be reversed.
double maxScale
The maximum scale, or 0.0 if unset.
void setFlags(QgsDxfExport::Flags flags)
Sets the export flags.
void writeInt(int i)
Write an integer value.
bool minSizeMMEnabled
Whether the minimum size in mm should be respected.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
void writePolygon(const QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
QList< QgsSymbolLevel > QgsSymbolLevelOrder
The QgsMapSettings class contains configuration for rendering of the map.
void setMapSettings(const QgsMapSettings &settings)
Set map settings and assign layer name attributes.
void writeString(const QString &s)
Write a string value.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
void reinit(QgsVectorLayer *layer)
Reinitialize the subproviders with QgsDxfLabelProviders.
int writeToFile(QIODevice *d, const QString &codec)
Export to a dxf file in the given encoding.
Perform transforms between map coordinates and device coordinates.
void writePoint(const QString &layer, const QColor &color, const QgsPoint &pt)
Write point.
bool exists(int i) const
Returns if a field index is valid.
virtual QColor dxfBrushColor(QgsSymbolRenderContext &context) const
Gets brush/fill color.
Type
The WKB type describes the number of dimensions a geometry has.
QgsUnitTypes::DistanceUnit mapUnits() const
Retrieve map units.
QList< QgsSymbol * > QgsSymbolList
void setOutputSize(QSize size)
Sets the size of the resulting map image.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
bool prepare(const QgsRenderContext &context, QSet< QString > &attributeNames) override
Prepare for registration of features.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
virtual bool prepare(const QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination CRS, or an invalid CRS if no reprojection will be done.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
Set destination CRS.
virtual QgsPalLayerSettings settings(const QString &providerId=QString()) const =0
Gets associated label settings.
#define QgsDebugMsgLevel(str, level)
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
Quadrant getQuadrant() const
void writeGroupCode(int code)
Write a group code.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > & dataDefinedValues() const
Gets data-defined values.
double getY(int i=0) const
Returns the down-left y coordinate.
QgsPointXY center() const
Returns the center point of the rectangle.
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
bool useCustomDashPattern() const
QgsSymbolRenderContext * symbolRenderContext()
Returns the symbol render context.
double mapUnitsPerPixel() const
Returns current map units per pixel.
int renderingPass() const
QgsFeatureRenderer * renderer()
Returns renderer.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
Single scope for storing variables and functions for use within a QgsExpressionContext.
Abstract base class for all geometries.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
Does vector analysis using the geos library and handles import, export, exception handling*...
void writeText(const QString &layer, const QString &text, const QgsPoint &pt, double size, double angle, const QColor &color)
Write text (TEXT)
double getX(int i=0) const
Returns the down-left x coordinate.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
QgsSymbolLayer * symbolLayer(int layer)
Returns a specific symbol layer contained in the symbol.
Point geometry type, with support for z-dimension and m-values.
static QString dxfEncoding(const QString &name)
Returns DXF encoding for Qt encoding.
QgsRectangle extent() const FINAL
Returns the extent of the layer.
Contains geos related utilities and functions.
Place direction symbols on above label.
void drawLabel(const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings)
Output the label.
Rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
QgsExpressionContext & expressionContext()
Gets the expression context.
double getAlpha() const
Returns the angle to rotate text (in rad).
DistanceUnit
Units of distance.
QVector< QgsPoint > QgsPointSequence
void setFeature(const QgsFeature *f)
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle...
QString wrapChar
Wrapping character string.
virtual QgsCoordinateSequence coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
static QString dxfLayerName(const QString &name)
Returns cleaned layer name for use in DXF.
QVector< QgsPointSequence > QgsRingSequence
QgsAbstractGeometry * offsetCurve(double distance, int segments, int joinStyle, double miterLimit, QString *errorMsg=nullptr) const override
QString rightDirectionSymbol
String to use for right direction arrows.
The QgsLabelingEngine class provides map labeling functionality.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
void run(QgsRenderContext &context)
compute the labeling with given map settings and providers
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
Contains information about the context of a rendering operation.
Abstract base class for marker symbol layers.
void writeCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width)
Write circle (as polyline)
QFont definedFont()
Font to be used for rendering.
virtual double dxfAngle(QgsSymbolRenderContext &context) const
Gets angle.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
double maxSizeMM
The maximum size in millimeters, or 0.0 if unset.
QList< QgsSymbolLevelItem > QgsSymbolLevel
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const FINAL
Calculates a list of unique values contained within an attribute in the layer.
Struct for storing maximum and minimum scales for measurements in map units.
virtual void stopRender(QgsSymbolRenderContext &context)=0
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
RenderHints renderHints() const
Returns the rendering hint flags for the symbol.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
static QgsProject * instance()
Returns the QgsProject singleton instance.
This class represents a coordinate reference system (CRS).
void writeDouble(double d)
Write a floating point value.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
const QgsFeature * feature() const
Current feature being rendered - may be null.
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets line width.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
LabelPosition is a candidate feature label position.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
void registerDxfFeature(QgsFeature &feature, QgsRenderContext &context, const QString &dxfLayerName)
Registration method that keeps track of DXF layer names of individual features.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request.
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
bool nextFeature(QgsFeature &f)
Implements a derived label provider internally used for DXF export.
#define DXF_HANDPLOTSTYLE
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
void setOverrideStyle(const QString &style)
Temporarily apply a different style to the layer.
Container for all settings relating to text rendering.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
int writeHandle(int code=5, int handle=0)
Write a tuple of group code and a handle.
static Q_INVOKABLE double fromUnitToUnitFactor(QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
double width() const
Returns the width of the rectangle.
Represents a vector layer which manages a vector based data sets.
double minScale
The minimum scale, or 0.0 if unset.
static Type flatType(Type type)
Returns the flat type for a WKB type.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected.
QString labelText() const
Text of the label.
void writeMText(const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, const QColor &color)
Write mtext (MTEXT)
void addLayers(const QList< QgsDxfExport::DxfLayer > &layers)
Add layers to export.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
QString layerName(const QString &id, const QgsFeature &f) const
Gets layer name for feature.
QgsDxfExport & operator=(const QgsDxfExport &dxfExport)
virtual Qt::BrushStyle dxfBrushStyle() const
Gets brush/fill style.
RenderUnit
Rendering size units.
double height() const
Returns the height of the rectangle.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
virtual QColor dxfColor(QgsSymbolRenderContext &context) const
Gets color.
virtual QString layerType() const =0
Returns a string that represents this layer type.
void setLayers(const QList< QgsMapLayer * > &layers)
Set list of layers for map rendering.
QgsFeatureId featureId() const
Returns the unique ID of the feature.
DirectionSymbols placeDirectionSymbol
Placement option for direction symbols.
Exports one feature per symbol layer (considering symbol levels)
QgsExpressionContextScope * expressionContextScope()
This scope is always available when a symbol of this type is being rendered.