57 int QgsDxfExport::sDxfColors[][3] =
317 const char *QgsDxfExport::DXF_ENCODINGS[][2] =
320 {
"8859_1",
"ISO-8859-1" },
321 {
"8859_2",
"ISO-8859-2" },
322 {
"8859_3",
"ISO-8859-3" },
323 {
"8859_4",
"ISO-8859-4" },
324 {
"8859_5",
"ISO-8859-5" },
325 {
"8859_6",
"ISO-8859-6" },
326 {
"8859_7",
"ISO-8859-7" },
327 {
"8859_8",
"ISO-8859-8" },
328 {
"8859_9",
"ISO-8859-9" },
330 {
"DOS850",
"CP850" },
341 {
"MACINTOSH",
"MacRoman" },
343 {
"KSC5601",
"ksc5601.1987-0" },
345 {
"DOS866",
"CP866" },
346 {
"ANSI_1250",
"CP1250" },
347 {
"ANSI_1251",
"CP1251" },
348 {
"ANSI_1252",
"CP1252" },
349 {
"GB2312",
"GB2312" },
350 {
"ANSI_1253",
"CP1253" },
351 {
"ANSI_1254",
"CP1254" },
352 {
"ANSI_1255",
"CP1255" },
353 {
"ANSI_1256",
"CP1256" },
354 {
"ANSI_1257",
"CP1257" },
355 {
"ANSI_874",
"CP874" },
356 {
"ANSI_932",
"Shift_JIS" },
357 {
"ANSI_936",
"CP936" },
358 {
"ANSI_949",
"cp949" },
359 {
"ANSI_950",
"CP950" },
362 {
"ANSI_1258",
"CP1258" },
372 mMapSettings = dxfExport.mMapSettings;
373 mLayerNameAttribute = dxfExport.mLayerNameAttribute;
374 mSymbologyScale = dxfExport.mSymbologyScale;
375 mSymbologyExport = dxfExport.mSymbologyExport;
376 mMapUnits = dxfExport.mMapUnits;
377 mLayerTitleAsName = dxfExport.mLayerTitleAsName;
378 mSymbolLayerCounter = 0;
382 mFactor = dxfExport.mFactor;
383 mForce2d = dxfExport.mForce2d;
389 mMapSettings = settings;
404 QList<QgsMapLayer *> layerList;
406 mLayerNameAttribute.clear();
408 QList< DxfLayer >::const_iterator layerIt = layers.constBegin();
409 for ( ; layerIt != layers.constEnd(); ++layerIt )
411 layerList << layerIt->layer();
412 if ( layerIt->layerOutputAttributeIndex() >= 0 )
413 mLayerNameAttribute.insert( layerIt->layer()->id(), layerIt->layerOutputAttributeIndex() );
441 if ( !mForce2d && p.
is3D() && std::isfinite( p.
z() ) )
448 int minDist = std::numeric_limits<int>::max();
450 for (
int i = 1; i < static_cast< int >(
sizeof( sDxfColors ) /
sizeof( *sDxfColors ) ) && minDist > 0; ++i )
452 int dist = color_distance( color.rgba(), i );
453 if ( dist >= minDist )
460 if ( minDist == 0 && minDistAt != 7 )
464 if ( color.alpha() == 255 )
468 int c = ( color.red() & 0xff ) * 0x10000 + ( color.green() & 0xff ) * 0x100 + ( color.blue() & 0xff );
470 if ( transparencyCode != -1 && color.alpha() < 255 )
471 writeGroup( transparencyCode, 0x2000000 | color.alpha() );
476 mTextStream << QStringLiteral(
"%1\n" ).arg( code, 3, 10, QChar(
' ' ) );
481 mTextStream << QStringLiteral(
"%1\n" ).arg( i, 6, 10, QChar(
' ' ) );
487 if ( !s.contains(
'.' ) )
488 s += QLatin1String(
".0" );
489 mTextStream << s <<
'\n';
494 mTextStream << s <<
'\n';
504 if ( !d->isOpen() && !d->open( QIODevice::WriteOnly | QIODevice::Truncate ) )
509 mTextStream.setDevice( d );
510 mTextStream.setCodec( encoding.toLocal8Bit() );
517 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
532 mExtent = layerExtent;
563 void QgsDxfExport::writeHeader(
const QString &codepage )
565 writeGroup( 999, QStringLiteral(
"DXF created from QGIS" ) );
571 writeGroup( 9, QStringLiteral(
"$ACADVER" ) );
583 writeGroup( 9, QStringLiteral(
"$LTSCALE" ) );
595 writeGroup( 9, QStringLiteral(
"$PSLTSCALE" ) );
598 writeGroup( 9, QStringLiteral(
"$HANDSEED" ) );
601 writeGroup( 9, QStringLiteral(
"$DWGCODEPAGE" ) );
610 handle = mNextHandleId++;
612 Q_ASSERT_X( handle <
DXF_HANDMAX,
"QgsDxfExport::writeHandle(int, int)",
"DXF handle too large" );
614 writeGroup( code, QStringLiteral(
"%1" ).arg( handle, 0, 16 ) );
618 void QgsDxfExport::writeTables()
625 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > slList;
628 slList = symbolLayers( context );
636 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
639 writeDefaultLinetypes();
642 QList< QPair< QgsSymbolLayer *, QgsSymbol *> >::const_iterator slIt = slList.constBegin();
643 for ( ; slIt != slList.constEnd(); ++slIt )
645 writeSymbolLayerLinetype( slIt->first );
652 writeGroup( 2, QStringLiteral(
"BLOCK_RECORD" ) );
655 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
658 const QStringList blockStrings = QStringList() << QStringLiteral(
"*Model_Space" ) << QStringLiteral(
"*Paper_Space" ) << QStringLiteral(
"*Paper_Space0" );
659 for (
const QString &block : blockStrings )
661 writeGroup( 0, QStringLiteral(
"BLOCK_RECORD" ) );
663 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
664 writeGroup( 100, QStringLiteral(
"AcDbBlockTableRecord" ) );
669 slIt = slList.constBegin();
670 for ( ; slIt != slList.constEnd(); ++slIt )
676 if ( hasDataDefinedProperties( ml, slIt->second ) )
679 QString name = QStringLiteral(
"symbolLayer%1" ).arg( i++ );
680 writeGroup( 0, QStringLiteral(
"BLOCK_RECORD" ) );
682 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
683 writeGroup( 100, QStringLiteral(
"AcDbBlockTableRecord" ) );
693 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
697 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
698 writeGroup( 100, QStringLiteral(
"AcDbRegAppTableRecord" ) );
707 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
715 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
723 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
727 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
728 writeGroup( 100, QStringLiteral(
"AcDbViewportTableRecord" ) );
767 writeGroup( 2, QStringLiteral(
"DIMSTYLE" ) );
769 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
770 writeGroup( 100, QStringLiteral(
"AcDbDimStyleTable" ) );
774 QSet<QString> layerNames;
775 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
778 if ( !layerIsScaleBasedVisible( ml ) )
785 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
792 const QSet<QVariant> values = vl->
uniqueValues( attrIdx );
793 for (
const QVariant &v : values )
805 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
810 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
811 writeGroup( 100, QStringLiteral(
"AcDbLayerTableRecord" ) );
815 writeGroup( 6, QStringLiteral(
"CONTINUOUS" ) );
818 for (
const QString &
layerName : qgis::as_const( layerNames ) )
822 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
823 writeGroup( 100, QStringLiteral(
"AcDbLayerTableRecord" ) );
827 writeGroup( 6, QStringLiteral(
"CONTINUOUS" ) );
836 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
842 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
843 writeGroup( 100, QStringLiteral(
"AcDbTextStyleTableRecord" ) );
844 writeGroup( 2, QStringLiteral(
"STANDARD" ) );
851 writeGroup( 3, QStringLiteral(
"romans.shx" ) );
859 void QgsDxfExport::writeBlocks()
864 const QStringList blockStrings = QStringList() << QStringLiteral(
"*Model_Space" ) << QStringLiteral(
"*Paper_Space" ) << QStringLiteral(
"*Paper_Space0" );
865 for (
const QString &block : blockStrings )
869 writeGroup( 330, QStringLiteral(
"%1" ).arg( mBlockHandles[ block ], 0, 16 ) );
870 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
872 writeGroup( 100, QStringLiteral(
"AcDbBlockBegin" ) );
880 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
882 writeGroup( 100, QStringLiteral(
"AcDbBlockEnd" ) );
888 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > slList;
891 slList = symbolLayers( ct );
894 QList< QPair< QgsSymbolLayer *, QgsSymbol * > >::const_iterator slIt = slList.constBegin();
895 for ( ; slIt != slList.constEnd(); ++slIt )
906 if ( hasDataDefinedProperties( ml, slIt->second ) )
912 QString block( QStringLiteral(
"symbolLayer%1" ).arg( mBlockCounter++ ) );
913 mBlockHandle = QStringLiteral(
"%1" ).arg( mBlockHandles[ block ], 0, 16 );
918 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
920 writeGroup( 100, QStringLiteral(
"AcDbBlockBegin" ) );
933 ml->
writeDxf( *
this,
mapUnitScaleFactor( mSymbologyScale, ml->
sizeUnit(), mMapUnits, ctx.renderContext().mapToPixel().mapUnitsPerPixel() ), QStringLiteral(
"0" ), ctx );
937 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
939 writeGroup( 100, QStringLiteral(
"AcDbBlockEnd" ) );
941 mPointSymbolBlocks.insert( ml, block );
948 void QgsDxfExport::writeEntities()
951 writeGroup( 2, QStringLiteral(
"ENTITIES" ) );
953 mBlockHandle = QStringLiteral(
"%1" ).arg( mBlockHandles[ QStringLiteral(
"*Model_Space" )], 0, 16 );
955 QImage image( 10, 10, QImage::Format_ARGB32_Premultiplied );
956 image.setDotsPerMeterX( 96 / 25.4 * 1000 );
957 image.setDotsPerMeterY( 96 / 25.4 * 1000 );
958 QPainter painter( &image );
967 mExtent.
height() * mFactor, 0 ) );
977 const QList< QgsMapLayer *> layers = mMapSettings.
layers();
981 if ( !vl || !layerIsScaleBasedVisible( vl ) )
989 QgsDebugMsg( QString(
"%1: apply override style" ).arg( vl->
id() ) );
994 QgsDebugMsg( QString(
"%1: not override style" ).arg( vl->
id() ) );
1011 std::unique_ptr< QgsFeatureRenderer > renderer( vl->
renderer()->
clone() );
1012 renderer->startRender( ctx, vl->
fields() );
1014 QSet<QString> attributes = renderer->usedAttributes( ctx );
1015 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
1019 attributes << layerAttr;
1025 if (
const QgsRuleBasedLabeling *rbl = dynamic_cast<const QgsRuleBasedLabeling *>( labeling ) )
1031 if ( !rblp->
prepare( ctx, attributes ) )
1037 else if ( labeling )
1043 if ( !lp->
prepare( ctx, attributes ) )
1052 renderer->usingSymbolLevels() )
1054 writeEntitiesSymbolLevels( vl );
1055 renderer->stopRender( ctx );
1076 addFeature( sctx, ct, lName,
nullptr,
nullptr );
1080 QgsSymbolList symbolList = renderer->symbolsForFeature( fet, ctx );
1081 bool hasSymbology = symbolList.size() > 0;
1085 QgsSymbolList::iterator symbolIt = symbolList.begin();
1086 for ( ; symbolIt != symbolList.end(); ++symbolIt )
1088 int nSymbolLayers = ( *symbolIt )->symbolLayerCount();
1089 for (
int i = 0; i < nSymbolLayers; ++i )
1097 bool isGeometryGenerator = ( sl->
layerType() == QLatin1String(
"GeometryGenerator" ) );
1098 if ( isGeometryGenerator )
1100 addGeometryGeneratorSymbolLayer( sctx, ct, lName, sl,
true );
1104 addFeature( sctx, ct, lName, sl, *symbolIt );
1109 else if ( hasSymbology )
1120 addGeometryGeneratorSymbolLayer( sctx, ct, lName, s->
symbolLayer( 0 ), false );
1124 addFeature( sctx, ct, lName, s->
symbolLayer( 0 ), s );
1139 renderer->stopRender( ctx );
1147 void QgsDxfExport::writeEntitiesSymbolLevels(
QgsVectorLayer *layer )
1159 std::unique_ptr< QgsFeatureRenderer > renderer( layer->
renderer()->
clone() );
1160 QHash< QgsSymbol *, QList<QgsFeature> > features;
1165 renderer->startRender( ctx, layer->
fields() );
1184 featureSymbol = renderer->symbolForFeature( fet, ctx );
1185 if ( !featureSymbol )
1190 QHash< QgsSymbol *, QList<QgsFeature> >::iterator it = features.find( featureSymbol );
1191 if ( it == features.end() )
1193 it = features.insert( featureSymbol, QList<QgsFeature>() );
1195 it.value().append( fet );
1201 for (
int i = 0; i < symbols.count(); i++ )
1207 if ( level < 0 || level >= 1000 )
1210 while ( level >= levels.count() )
1212 levels[level].append( item );
1219 for (
int l = 0; l < levels.count(); l++ )
1222 for (
int i = 0; i < level.count(); i++ )
1225 QHash< QgsSymbol *, QList<QgsFeature> >::iterator levelIt = features.find( item.
symbol() );
1226 if ( levelIt == features.end() )
1228 QgsDebugMsg( QString(
"No feature found for symbol on %1 %2.%3" ).arg( layer->
id() ).arg( l ).arg( i ) );
1232 int llayer = item.
layer();
1233 QList<QgsFeature> &featureList = levelIt.value();
1234 QList<QgsFeature>::iterator featureIt = featureList.begin();
1235 for ( ; featureIt != featureList.end(); ++featureIt )
1238 addFeature( sctx, ct, layer->
name(), levelIt.key()->symbolLayer( llayer ), levelIt.key() );
1242 renderer->stopRender( ctx );
1245 void QgsDxfExport::writeEndFile()
1272 ACAD_MLEADERSTYLE\n\ 1280 ACAD_PLOTSETTINGS\n\ 1284 ACAD_PLOTSTYLENAME\n\ 1392 ACDBDICTIONARYWDFLT\n\ 1412 AcDbDictionaryWithDefault\n\ 1608 1.000000000000000E+20\n\ 1610 1.000000000000000E+20\n\ 1612 1.000000000000000E+20\n\ 1614 -1.000000000000000E+20\n\ 1616 -1.000000000000000E+20\n\ 1618 -1.000000000000000E+20\n\ 1880 163.1318914119703\n\ 2048 AcDbSavedByObjectVersion\n\ 2138 AcDbSavedByObjectVersion\n\ 2228 AcDbSavedByObjectVersion\n\ 2318 AcDbSavedByObjectVersion\n\ 2408 AcDbSavedByObjectVersion\n\ 2500 AcDbSavedByObjectVersion\n\ 2590 AcDbSavedByObjectVersion\n\ 2680 AcDbSavedByObjectVersion\n\ 2770 AcDbSavedByObjectVersion\n\ 2860 AcDbSavedByObjectVersion\n\ 2950 AcDbSavedByObjectVersion\n\ 3040 AcDbSavedByObjectVersion\n\ 3130 AcDbSavedByObjectVersion\n\ 3220 AcDbSavedByObjectVersion\n\ 3312 AcDbSavedByObjectVersion\n\ 3402 AcDbSavedByObjectVersion\n\ 3412 void QgsDxfExport::startSection()
3414 writeGroup( 0, QStringLiteral(
"SECTION" ) );
3417 void QgsDxfExport::endSection()
3430 msl->
sizeUnit(), mMapUnits ) / 2.0;
3442 QHash< const QgsSymbolLayer *, QString >::const_iterator blockIt = mPointSymbolBlocks.constFind( symbolLayer );
3443 if ( !symbolLayer || blockIt == mPointSymbolBlocks.constEnd() )
3447 if ( msl && symbol )
3461 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3462 writeGroup( 100, QStringLiteral(
"AcDbBlockReference" ) );
3472 int n = line.size();
3475 QgsDebugMsg( QString(
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3479 bool polygon = line[0] == line[ line.size() - 1 ];
3484 QgsDebugMsg( QString(
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3488 if ( mForce2d || !line.at( 0 ).is3D() )
3490 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
3493 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3494 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
3502 for (
int i = 0; i < n; i++ )
3507 writeGroup( 0, QStringLiteral(
"POLYLINE" ) );
3510 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3514 writeGroup( 100, QStringLiteral(
"AcDb3dPolyline" ) );
3518 for (
int i = 0; i < n; i++ )
3523 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3526 writeGroup( 100, QStringLiteral(
"AcDbVertex" ) );
3527 writeGroup( 100, QStringLiteral(
"AcDb3dPolylineVertex" ) );
3535 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3546 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3549 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
3555 writeGroup( 70, hatchPattern == QLatin1String(
"SOLID" ) );
3559 for (
int i = 0; i < polygon.size(); ++i )
3566 for (
int j = 0; j < polygon[i].size(); ++j )
3589 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3590 writeGroup( 100, QStringLiteral(
"AcDbPoint" ) );
3601 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3604 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
3635 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
3639 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3640 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
3659 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3660 writeGroup( 100, QStringLiteral(
"AcDbText" ) );
3667 writeGroup( 7, QStringLiteral(
"STANDARD" ) );
3668 writeGroup( 100, QStringLiteral(
"AcDbText" ) );
3673 if ( !mTextStream.codec()->canEncode( text ) )
3676 QgsDebugMsg( QString(
"could not encode:%1" ).arg( text ) );
3682 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3683 writeGroup( 100, QStringLiteral(
"AcDbMText" ) );
3690 while ( t.length() > 250 )
3706 writeGroup( 7, QStringLiteral(
"STANDARD" ) );
3721 geom->transform( ct );
3728 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
3730 penColor = colorFromSymbolLayer( symbolLayer, ctx );
3734 Qt::PenStyle penStyle( Qt::SolidLine );
3735 Qt::BrushStyle brushStyle( Qt::NoBrush );
3737 double offset = 0.0;
3739 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
3741 width = symbolLayer->
dxfWidth( *
this, ctx );
3742 offset = symbolLayer->
dxfOffset( *
this, ctx );
3743 angle = symbolLayer->
dxfAngle( ctx );
3751 QString lineStyleName = QStringLiteral(
"CONTINUOUS" );
3754 lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
3760 writePoint( geom->coordinateSequence().at( 0 ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol,
angle );
3767 for (
int i = 0; i < cs.size(); i++ )
3769 writePoint( cs.at( i ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol,
angle );
3774 if ( penStyle != Qt::NoPen )
3790 if ( tempGeom != geom.get() )
3792 tempGeom = geos.
offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 );
3794 tempGeom = geom.get();
3811 if ( tempGeom != geom.get() )
3813 tempGeom = geos.
offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 );
3815 tempGeom = geom.get();
3819 for (
int i = 0; i < cs.size(); i++ )
3821 writePolyline( cs.at( i ).at( 0 ), layer, lineStyleName, penColor, width );
3837 if ( tempGeom != geom.get() )
3839 tempGeom = geos.
buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3841 tempGeom = geom.get();
3845 for (
int i = 0; i < cs.at( 0 ).size(); i++ )
3847 writePolyline( cs.at( 0 ).at( i ), layer, lineStyleName, penColor, width );
3858 if ( tempGeom != geom.get() )
3860 tempGeom = geos.
buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3862 tempGeom = geom.get();
3866 for (
int i = 0; i < cs.size(); i++ )
3867 for (
int j = 0; j < cs.at( i ).size(); j++ )
3868 writePolyline( cs.at( i ).at( j ), layer, lineStyleName, penColor, width );
3877 if ( tempGeom != geom.get() )
3881 if ( brushStyle != Qt::NoBrush )
3899 for (
int i = 0; i < cs.size(); i++ )
3901 writePolygon( cs.at( i ), layer, QStringLiteral(
"SOLID" ), brushColor );
3911 if ( tempGeom != geom.get() )
3921 return symbolLayer->
dxfColor( ctx );
3924 QString QgsDxfExport::lineStyleFromSymbolLayer(
const QgsSymbolLayer *symbolLayer )
3926 QString lineStyleName = QStringLiteral(
"CONTINUOUS" );
3929 return lineStyleName;
3932 QHash< const QgsSymbolLayer *, QString >::const_iterator lineTypeIt = mLineStyles.constFind( symbolLayer );
3933 if ( lineTypeIt != mLineStyles.constEnd() )
3935 lineStyleName = lineTypeIt.value();
3936 return lineStyleName;
3940 return lineNameFromPenStyle( symbolLayer->
dxfPenStyle() );
3947 int current_distance = std::numeric_limits<int>::max();
3948 for (
int i = 1; i < static_cast< int >(
sizeof( sDxfColors ) /
sizeof( *sDxfColors ) ); ++i )
3950 int dist = color_distance( pixel, i );
3951 if ( dist < current_distance )
3953 current_distance = dist;
3962 int QgsDxfExport::color_distance( QRgb p1,
int index )
3964 if ( index > 255 || index < 0 )
3969 double redDiff = qRed( p1 ) - sDxfColors[index][0];
3970 double greenDiff = qGreen( p1 ) - sDxfColors[index][1];
3971 double blueDiff = qBlue( p1 ) - sDxfColors[index][2];
3973 QgsDebugMsg( QString(
"color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
3974 .arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
3976 .arg( mDxfColors[index][0] )
3977 .arg( mDxfColors[index][1] )
3978 .arg( mDxfColors[index][2] )
3979 .arg( redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff ) );
3981 return redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff;
3984 QRgb QgsDxfExport::createRgbEntry( qreal r, qreal g, qreal b )
3986 return QColor::fromRgbF( r, g, b ).rgb();
4008 return mapUnitsPerPixel;
4022 double minSizeMU = std::numeric_limits<double>::lowest();
4025 minSizeMU = scale.
minSizeMM * pixelToMMFactor * mapUnitsPerPixel;
4029 minSizeMU = std::max( minSizeMU, value );
4031 value = std::max( value, minSizeMU );
4033 double maxSizeMU = std::numeric_limits<double>::max();
4036 maxSizeMU = scale.
maxSizeMM * pixelToMMFactor * mapUnitsPerPixel;
4040 maxSizeMU = std::min( maxSizeMU, value );
4042 value = std::min( value, maxSizeMU );
4045 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > QgsDxfExport::symbolLayers(
QgsRenderContext &context )
4047 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > symbolLayers;
4049 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
4067 QgsSymbolList::iterator symbolIt = symbols.begin();
4068 for ( ; symbolIt != symbols.end(); ++symbolIt )
4070 int maxSymbolLayers = ( *symbolIt )->symbolLayerCount();
4073 maxSymbolLayers = 1;
4075 for (
int i = 0; i < maxSymbolLayers; ++i )
4077 symbolLayers.append( qMakePair( ( *symbolIt )->symbolLayer( i ), *symbolIt ) );
4082 return symbolLayers;
4085 void QgsDxfExport::writeDefaultLinetypes()
4088 const QStringList blockStrings = QStringList() << QStringLiteral(
"ByLayer" ) << QStringLiteral(
"ByBlock" ) << QStringLiteral(
"CONTINUOUS" );
4089 for (
const QString <ype : blockStrings )
4093 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
4094 writeGroup( 100, QStringLiteral(
"AcDbLinetypeTableRecord" ) );
4097 writeGroup( 3, QStringLiteral(
"Defaultstyle" ) );
4103 double das = dashSize();
4104 double dss = dashSeparatorSize();
4105 double dos = dotSize();
4107 QVector<qreal> dashVector( 2 );
4108 dashVector[0] = das;
4109 dashVector[1] = dss;
4112 QVector<qreal> dotVector( 2 );
4117 QVector<qreal> dashDotVector( 4 );
4118 dashDotVector[0] = das;
4119 dashDotVector[1] = dss;
4120 dashDotVector[2] = dos;
4121 dashDotVector[3] = dss;
4124 QVector<qreal> dashDotDotVector( 6 );
4125 dashDotDotVector[0] = das;
4126 dashDotDotVector[1] = dss;
4127 dashDotDotVector[2] = dos;
4128 dashDotDotVector[3] = dss;
4129 dashDotDotVector[4] = dos;
4130 dashDotDotVector[5] = dss;
4134 void QgsDxfExport::writeSymbolLayerLinetype(
const QgsSymbolLayer *symbolLayer )
4143 if ( !customLinestyle.isEmpty() )
4145 QString name = QStringLiteral(
"symbolLayer%1" ).arg( mSymbolLayerCounter++ );
4146 writeLinetype( name, customLinestyle, unit );
4147 mLineStyles.insert( symbolLayer, name );
4151 int QgsDxfExport::nLineTypes(
const QList< QPair< QgsSymbolLayer *, QgsSymbol * > > &symbolLayers )
4154 QList< QPair< QgsSymbolLayer *, QgsSymbol *> >::const_iterator slIt = symbolLayers.constBegin();
4155 for ( ; slIt != symbolLayers.constEnd(); ++slIt )
4169 void QgsDxfExport::writeLinetype(
const QString &styleName,
const QVector<qreal> &pattern,
QgsUnitTypes::RenderUnit u )
4172 QVector<qreal>::const_iterator dashIt = pattern.constBegin();
4173 for ( ; dashIt != pattern.constEnd(); ++dashIt )
4181 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
4182 writeGroup( 100, QStringLiteral(
"AcDbLinetypeTableRecord" ) );
4190 dashIt = pattern.constBegin();
4192 for ( ; dashIt != pattern.constEnd(); ++dashIt )
4195 double segmentLength = ( isGap ? -*dashIt : *dashIt );
4221 geomExpr.
prepare( &expressionContext );
4229 symbolExpressionContextScope->
setFeature( f );
4234 for (
int i = 0; i < nSymbolLayers; ++i )
4236 addFeature( ctx, ct, layer, symbol->
symbolLayer( i ), symbol );
4245 if ( !sl || !symbol )
4258 double QgsDxfExport::dashSize()
const 4260 double size = mSymbologyScale * 0.002;
4261 return sizeToMapUnits( size );
4264 double QgsDxfExport::dotSize()
const 4266 double size = mSymbologyScale * 0.0006;
4267 return sizeToMapUnits( size );
4270 double QgsDxfExport::dashSeparatorSize()
const 4272 double size = mSymbologyScale * 0.0006;
4273 return sizeToMapUnits( size );
4276 double QgsDxfExport::sizeToMapUnits(
double s )
const 4282 QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
4287 return QStringLiteral(
"DASH" );
4289 return QStringLiteral(
"DOT" );
4290 case Qt::DashDotLine:
4291 return QStringLiteral(
"DASHDOT" );
4292 case Qt::DashDotDotLine:
4293 return QStringLiteral(
"DASHDOTDOT" );
4296 return QStringLiteral(
"CONTINUOUS" );
4302 if ( name.isEmpty() )
4303 return QStringLiteral(
"0" );
4311 layerName.replace(
'<',
'_' );
4312 layerName.replace(
'>',
'_' );
4313 layerName.replace(
'/',
'_' );
4314 layerName.replace(
'\\',
'_' );
4315 layerName.replace(
'\"',
'_' );
4316 layerName.replace(
':',
'_' );
4317 layerName.replace(
';',
'_' );
4318 layerName.replace(
'?',
'_' );
4319 layerName.replace(
'*',
'_' );
4320 layerName.replace(
'|',
'_' );
4321 layerName.replace(
'=',
'_' );
4322 layerName.replace(
'\'',
'_' );
4325 layerName.replace( QLatin1String(
"\r\n" ), QLatin1String(
"_" ) );
4326 layerName.replace(
'\r',
'_' );
4327 layerName.replace(
'\n',
'_' );
4329 return layerName.trimmed();
4332 bool QgsDxfExport::layerIsScaleBasedVisible(
const QgsMapLayer *layer )
const 4345 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
4349 if ( vl && vl->
id() == id )
4351 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
4356 return QStringLiteral(
"0" );
4361 const QList< QByteArray > codecs = QTextCodec::availableCodecs();
4362 for (
const QByteArray &codec : codecs )
4364 if ( name != codec )
4368 for ( i = 0; i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) && name != DXF_ENCODINGS[i][1]; ++i )
4371 if ( i == static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) )
4374 return DXF_ENCODINGS[i][0];
4383 const QList< QByteArray > codecs = QTextCodec::availableCodecs();
4384 for (
const QByteArray &codec : codecs )
4387 for ( i = 0; i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) && strcmp( codec.data(), DXF_ENCODINGS[i][1] ) != 0; ++i )
4390 if ( i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) )
4391 encodings << codec.data();
4399 return mLayerTitleAsName && !vl->
title().isEmpty() ? vl->
title() : vl->
name();
4404 Q_UNUSED( context );
4417 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues = lf->
dataDefinedValues();
4422 QgsDebugMsgLevel( QString(
"PAL font definedFont: %1, Style: %2" ).arg( dFont.toString(), dFont.styleName() ), 4 );
4452 QgsPalLabeling::dataDefinedTextStyle( tmpLyr, ddValues );
4455 QgsPalLabeling::dataDefinedTextBuffer( tmpLyr, ddValues );
4458 QgsPalLabeling::dataDefinedTextFormatting( tmpLyr, ddValues );
4464 QString dxfLayer = mDxfLayerNames[layerId][fid];
4466 QString wrapchr = tmpLyr.
wrapChar.isEmpty() ? QStringLiteral(
"\n" ) : tmpLyr.
wrapChar;
4471 bool prependSymb =
false;
4489 prependSymb =
false;
4497 symb = symb + wrapchr;
4501 prependSymb =
false;
4502 symb = wrapchr + symb;
4507 txt.prepend( symb );
4521 txt = txt.replace( wrapchr, QLatin1String(
"\\P" ) );
4522 txt.replace(
" ",
"\\~" );
4526 txt.prepend(
"\\L" ).append(
"\\l" );
4531 txt.prepend(
"\\O" ).append(
"\\o" );
4536 txt.prepend(
"\\K" ).append(
"\\k" );
4539 txt.prepend( QStringLiteral(
"\\f%1|i%2|b%3;\\H%4;" )
4541 .arg( tmpLyr.
format().
font().italic() ? 1 : 0 )
4542 .arg( tmpLyr.
format().
font().bold() ? 1 : 0 )
4543 .arg( label->
getHeight() / ( 1 + txt.count( QStringLiteral(
"\\P" ) ) ) * 0.75 ) );
4551 if ( !mDxfLayerNames.contains( layerId ) )
4552 mDxfLayerNames[ layerId ] = QMap<QgsFeatureId, QString>();
4554 mDxfLayerNames[layerId][fid] =
layerName;
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
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.
virtual QVector< qreal > dxfCustomDashPattern(QgsUnitTypes::RenderUnit &unit) const
Gets dash pattern.
Wrapper for iterator of features from vector data provider or vector layer.
QString labelText() const
Text of the label.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
A rectangle specified with double values.
Base class for all map layer types.
void setExtent(const QgsRectangle &rect, bool magnified=true)
Set coordinates of the rectangle which should be rendered.
double minSizeMM
The minimum size in millimeters, or 0.0 if unset.
QString leftDirectionSymbol
String to use for left direction arrows.
void writeLine(const QgsPoint &pt1, const QgsPoint &pt2, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Write line (as a polyline)
void clipValueToMapUnitScale(double &value, const QgsMapUnitScale &scale, double pixelToMMFactor) const
Clips value to scale minimum/maximum.
void addProvider(QgsAbstractLabelProvider *provider)
Add provider of label features. Takes ownership of the provider.
QgsFeatureId featureId() const
Returns the unique ID of the feature.
void removeProvider(QgsAbstractLabelProvider *provider)
Remove provider if the provider's initialization failed. Provider instance is deleted.
QgsLabelFeature * feature()
Returns the parent feature.
virtual double dxfOffset(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets offset.
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)
Place direction symbols on below label.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
bool exists(int i) const
Returns if a field index is valid.
QVector< QgsRingSequence > QgsCoordinateSequence
QString geometryExpression() const
Gets the expression to generate this geometry.
Export text as TEXT elements. If not set, text will be exported as MTEXT elements.
double getY(int i=0) const
Returns the down-left y coordinate.
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)
Implements a derived label provider for rule based labels internally used for DXF export...
void setRendererScale(double scale)
Sets the renderer map scale.
void setFont(const QFont &font)
Sets the font used for rendering text.
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > & dataDefinedValues() const
Gets data-defined values.
QgsAbstractGeometry * buffer(double distance, int segments, QString *errorMsg=nullptr) const override
void setOutputDpi(double dpi)
Sets DPI used for conversion between real world units (e.g. mm) and pixels.
void registerDxfLayer(const QString &layerId, QgsFeatureId fid, const QString &layer)
Register name of layer for feature.
static int closestColorMatch(QRgb color)
Gets DXF palette index of nearest entry for given color.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QColor color() const
Returns the color that text will be rendered in.
Class that adds extra information to QgsLabelFeature for text labels.
static QStringList encodings()
Returns list of available DXF encodings.
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
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.
QgsDxfExport::Flags flags() const
Returns the export flags.
A geometry is the spatial representation of a feature.
bool drawLabels
Whether to draw labels for this layer.
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const override
Calculates a list of unique values contained within an attribute in the layer.
int symbolLayerCount() const
Returns total number of symbol layers contained in the symbol.
QgsUnitTypes::DistanceUnit mapUnits
MultiLineAlign multilineAlign
Horizontal alignment of multi-line labels.
QgsUnitTypes::DistanceUnit mapUnits() const
Retrieve map units.
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets line width.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
FeaturePart * getFeaturePart()
Returns the feature corresponding to this labelposition.
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
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.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
void setExtent(const QgsRectangle &extent)
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)
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
QList< QgsSymbolLevel > QgsSymbolLevelOrder
The QgsMapSettings class contains configuration for rendering of the map.
void setMapSettings(const QgsMapSettings &settings)
Set map settings and assign layer name attributes.
void writeString(const QString &s)
Write a string value.
QgsCoordinateTransform layerTransform(const QgsMapLayer *layer) const
Returns the coordinate transform from layer's CRS to destination CRS.
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
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.
int renderingPass() const
Type
The WKB type describes the number of dimensions a geometry has.
QList< QgsSymbol * > QgsSymbolList
void setOutputSize(QSize size)
Sets the size of the resulting map image.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
bool prepare(const QgsRenderContext &context, QSet< QString > &attributeNames) override
Prepare for registration of features.
virtual bool prepare(const QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
QgsFields fields() const override
Returns the list of fields of this layer.
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)
QgsRectangle extent() const override
Returns the extent of the layer.
bool isEmpty() const
Returns true if the rectangle is empty.
double size() const
Returns the symbol size.
void writeGroupCode(int code)
Write a group code.
double width() const
Returns the width of the rectangle.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsWkbTypes::Type wkbType() const override
Returns the WKBType or WKBUnknown in case of error.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides...
virtual Qt::BrushStyle dxfBrushStyle() const
Gets brush/fill style.
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Quadrant getQuadrant() const
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
QgsSymbolRenderContext * symbolRenderContext()
Returns the symbol render context.
QgsFeatureRenderer * renderer()
Returns renderer.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
bool useCustomDashPattern() const
Single scope for storing variables and functions for use within a QgsExpressionContext.
Abstract base class for all geometries.
QgsGeometry geometry() const
Returns the geometry associated with this feature.
double mapUnitsPerPixel() const
Returns current map units per pixel.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
Does vector analysis using the geos library and handles import, export, exception handling*...
void writeText(const QString &layer, const QString &text, const QgsPoint &pt, double size, double angle, const QColor &color)
Write text (TEXT)
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
QgsSymbolLayer * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination CRS, or an invalid CRS if no reprojection will be done.
Point geometry type, with support for z-dimension and m-values.
const QgsMapToPixel & mapToPixel() const
static QString dxfEncoding(const QString &name)
Returns DXF encoding for Qt encoding.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc...
QString layerName(const QString &id, const QgsFeature &f) const
Gets layer name for feature.
virtual QColor dxfBrushColor(QgsSymbolRenderContext &context) const
Gets brush/fill color.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
Contains geos related utilities and functions.
Place direction symbols on above label.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override
Query the layer for features specified in request.
void drawLabel(const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings)
Output the label.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
QgsExpressionContext & expressionContext()
Gets the expression context.
DistanceUnit
Units of distance.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QVector< QgsPoint > QgsPointSequence
void setFeature(const QgsFeature *f)
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle...
QString wrapChar
Wrapping character string.
virtual Qt::PenStyle dxfPenStyle() const
Gets pen style.
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.
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.
QMap< QString, QString > layerStyleOverrides() const
Gets map of map layer style overrides (key: layer ID, value: style name) where a different style shou...
const QgsMapToPixel & mapToPixel() const
double maxSizeMM
The maximum size in millimeters, or 0.0 if unset.
QList< QgsSymbolLevelItem > QgsSymbolLevel
double getAlpha() const
Returns the angle to rotate text (in rad).
Struct for storing maximum and minimum scales for measurements in map units.
virtual void stopRender(QgsSymbolRenderContext &context)=0
virtual double dxfAngle(QgsSymbolRenderContext &context) const
Gets angle.
virtual QgsSymbolList symbols(QgsRenderContext &context) const
Returns list of symbols used by the renderer.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
double getX(int i=0) const
Returns the down-left x coordinate.
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
QgsPointXY layerToMapCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from layer's CRS to output CRS
virtual QColor dxfColor(QgsSymbolRenderContext &context) const
Gets color.
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.
const QgsFeature * feature() const
Current feature being rendered - may be null.
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.
void setMapToPixel(const QgsMapToPixel &mtp)
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
LabelPosition is a candidate feature label position.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
void setLayers(const QList< QgsMapLayer *> &layers)
Set list of layers for map rendering.
void registerDxfFeature(QgsFeature &feature, QgsRenderContext &context, const QString &dxfLayerName)
Registration method that keeps track of DXF layer names of individual features.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
bool hasActiveProperties() const override
Returns true if the collection has any active properties, or false if all properties within the colle...
void appendScopes(const QList< QgsExpressionContextScope *> &scopes)
Appends a list of scopes to the end of the context.
QgsPointXY center() const
Returns the center point of the rectangle.
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.
bool nextFeature(QgsFeature &f)
Implements a derived label provider internally used for DXF export.
#define DXF_HANDPLOTSTYLE
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
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.
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS
Represents a vector layer which manages a vector based data sets.
double minScale
The minimum scale, or 0.0 if unset.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
static Type flatType(Type type)
Returns the flat type for a WKB type.
virtual QgsAbstractGeometry * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves.
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected.
QFont font() const
Returns the font used for rendering text.
void writeMText(const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, const QColor &color)
Write mtext (MTEXT)
void addLayers(const QList< QgsDxfExport::DxfLayer > &layers)
Add layers to export.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
QgsDxfExport & operator=(const QgsDxfExport &dxfExport)
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 QString layerType() const =0
Returns a string that represents this layer type.
DirectionSymbols placeDirectionSymbol
Placement option for direction symbols.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Exports one feature per symbol layer (considering symbol levels)
QgsExpressionContextScope * expressionContextScope()
This scope is always available when a symbol of this type is being rendered.