56 int QgsDxfExport::sDxfColors[][3] =
316 const char *QgsDxfExport::DXF_ENCODINGS[][2] =
319 {
"8859_1",
"ISO-8859-1" },
320 {
"8859_2",
"ISO-8859-2" },
321 {
"8859_3",
"ISO-8859-3" },
322 {
"8859_4",
"ISO-8859-4" },
323 {
"8859_5",
"ISO-8859-5" },
324 {
"8859_6",
"ISO-8859-6" },
325 {
"8859_7",
"ISO-8859-7" },
326 {
"8859_8",
"ISO-8859-8" },
327 {
"8859_9",
"ISO-8859-9" },
329 {
"DOS850",
"CP850" },
340 {
"MACINTOSH",
"MacRoman" },
342 {
"KSC5601",
"ksc5601.1987-0" },
344 {
"DOS866",
"CP866" },
345 {
"ANSI_1250",
"CP1250" },
346 {
"ANSI_1251",
"CP1251" },
347 {
"ANSI_1252",
"CP1252" },
348 {
"GB2312",
"GB2312" },
349 {
"ANSI_1253",
"CP1253" },
350 {
"ANSI_1254",
"CP1254" },
351 {
"ANSI_1255",
"CP1255" },
352 {
"ANSI_1256",
"CP1256" },
353 {
"ANSI_1257",
"CP1257" },
354 {
"ANSI_874",
"CP874" },
355 {
"ANSI_932",
"Shift_JIS" },
356 {
"ANSI_936",
"CP936" },
357 {
"ANSI_949",
"cp949" },
358 {
"ANSI_950",
"CP950" },
361 {
"ANSI_1258",
"CP1258" },
371 mMapSettings = dxfExport.mMapSettings;
372 mLayerNameAttribute = dxfExport.mLayerNameAttribute;
373 mSymbologyScale = dxfExport.mSymbologyScale;
374 mSymbologyExport = dxfExport.mSymbologyExport;
375 mMapUnits = dxfExport.mMapUnits;
376 mLayerTitleAsName = dxfExport.mLayerTitleAsName;
377 mSymbolLayerCounter = 0;
381 mFactor = dxfExport.mFactor;
382 mForce2d = dxfExport.mForce2d;
388 mMapSettings = settings;
403 QList<QgsMapLayer *> layerList;
405 mLayerNameAttribute.clear();
407 QList< DxfLayer >::const_iterator layerIt = layers.constBegin();
408 for ( ; layerIt != layers.constEnd(); ++layerIt )
410 layerList << layerIt->layer();
411 if ( layerIt->layerOutputAttributeIndex() >= 0 )
412 mLayerNameAttribute.insert( layerIt->layer()->id(), layerIt->layerOutputAttributeIndex() );
440 if ( !mForce2d && p.
is3D() && std::isfinite( p.
z() ) )
447 int minDist = INT_MAX;
449 for (
int i = 1; i < static_cast< int >(
sizeof( sDxfColors ) /
sizeof( *sDxfColors ) ) && minDist > 0; ++i )
451 int dist = color_distance( color.rgba(), i );
452 if ( dist >= minDist )
459 if ( minDist == 0 && minDistAt != 7 )
463 if ( color.alpha() == 255 )
467 int c = ( color.red() & 0xff ) * 0x10000 + ( color.green() & 0xff ) * 0x100 + ( color.blue() & 0xff );
469 if ( transparencyCode != -1 && color.alpha() < 255 )
470 writeGroup( transparencyCode, 0x2000000 | color.alpha() );
475 mTextStream << QStringLiteral(
"%1\n" ).arg( code, 3, 10, QChar(
' ' ) );
480 mTextStream << QStringLiteral(
"%1\n" ).arg( i, 6, 10, QChar(
' ' ) );
486 if ( !s.contains(
'.' ) )
487 s += QLatin1String(
".0" );
488 mTextStream << s <<
'\n';
493 mTextStream << s <<
'\n';
503 if ( !d->isOpen() && !d->open( QIODevice::WriteOnly | QIODevice::Truncate ) )
508 mTextStream.setDevice( d );
509 mTextStream.setCodec( encoding.toLocal8Bit() );
516 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
531 mExtent = layerExtent;
562 void QgsDxfExport::writeHeader(
const QString &codepage )
564 writeGroup( 999, QStringLiteral(
"DXF created from QGIS" ) );
570 writeGroup( 9, QStringLiteral(
"$ACADVER" ) );
582 writeGroup( 9, QStringLiteral(
"$LTSCALE" ) );
594 writeGroup( 9, QStringLiteral(
"$PSLTSCALE" ) );
597 writeGroup( 9, QStringLiteral(
"$HANDSEED" ) );
600 writeGroup( 9, QStringLiteral(
"$DWGCODEPAGE" ) );
609 handle = mNextHandleId++;
611 Q_ASSERT_X( handle <
DXF_HANDMAX,
"QgsDxfExport::writeHandle(int, int)",
"DXF handle too large" );
613 writeGroup( code, QStringLiteral(
"%1" ).arg( handle, 0, 16 ) );
617 void QgsDxfExport::writeTables()
624 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > slList;
627 slList = symbolLayers( context );
635 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
638 writeDefaultLinetypes();
641 QList< QPair< QgsSymbolLayer *, QgsSymbol *> >::const_iterator slIt = slList.constBegin();
642 for ( ; slIt != slList.constEnd(); ++slIt )
644 writeSymbolLayerLinetype( slIt->first );
651 writeGroup( 2, QStringLiteral(
"BLOCK_RECORD" ) );
654 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
657 const QStringList blockStrings = QStringList() << QStringLiteral(
"*Model_Space" ) << QStringLiteral(
"*Paper_Space" ) << QStringLiteral(
"*Paper_Space0" );
658 for (
const QString &block : blockStrings )
660 writeGroup( 0, QStringLiteral(
"BLOCK_RECORD" ) );
662 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
663 writeGroup( 100, QStringLiteral(
"AcDbBlockTableRecord" ) );
668 slIt = slList.constBegin();
669 for ( ; slIt != slList.constEnd(); ++slIt )
675 if ( hasDataDefinedProperties( ml, slIt->second ) )
678 QString name = QStringLiteral(
"symbolLayer%1" ).arg( i++ );
679 writeGroup( 0, QStringLiteral(
"BLOCK_RECORD" ) );
681 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
682 writeGroup( 100, QStringLiteral(
"AcDbBlockTableRecord" ) );
692 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
696 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
697 writeGroup( 100, QStringLiteral(
"AcDbRegAppTableRecord" ) );
706 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
714 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
722 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
726 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
727 writeGroup( 100, QStringLiteral(
"AcDbViewportTableRecord" ) );
766 writeGroup( 2, QStringLiteral(
"DIMSTYLE" ) );
768 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
769 writeGroup( 100, QStringLiteral(
"AcDbDimStyleTable" ) );
773 QSet<QString> layerNames;
774 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
777 if ( !layerIsScaleBasedVisible( ml ) )
784 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
791 const QSet<QVariant> values = vl->
uniqueValues( attrIdx );
792 for (
const QVariant &v : values )
804 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
809 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
810 writeGroup( 100, QStringLiteral(
"AcDbLayerTableRecord" ) );
814 writeGroup( 6, QStringLiteral(
"CONTINUOUS" ) );
817 for (
const QString &
layerName : qgis::as_const( layerNames ) )
821 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
822 writeGroup( 100, QStringLiteral(
"AcDbLayerTableRecord" ) );
826 writeGroup( 6, QStringLiteral(
"CONTINUOUS" ) );
835 writeGroup( 100, QStringLiteral(
"AcDbSymbolTable" ) );
841 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
842 writeGroup( 100, QStringLiteral(
"AcDbTextStyleTableRecord" ) );
843 writeGroup( 2, QStringLiteral(
"STANDARD" ) );
850 writeGroup( 3, QStringLiteral(
"romans.shx" ) );
858 void QgsDxfExport::writeBlocks()
863 const QStringList blockStrings = QStringList() << QStringLiteral(
"*Model_Space" ) << QStringLiteral(
"*Paper_Space" ) << QStringLiteral(
"*Paper_Space0" );
864 for (
const QString &block : blockStrings )
868 writeGroup( 330, QStringLiteral(
"%1" ).arg( mBlockHandles[ block ], 0, 16 ) );
869 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
871 writeGroup( 100, QStringLiteral(
"AcDbBlockBegin" ) );
879 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
881 writeGroup( 100, QStringLiteral(
"AcDbBlockEnd" ) );
887 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > slList;
890 slList = symbolLayers( ct );
893 QList< QPair< QgsSymbolLayer *, QgsSymbol * > >::const_iterator slIt = slList.constBegin();
894 for ( ; slIt != slList.constEnd(); ++slIt )
905 if ( hasDataDefinedProperties( ml, slIt->second ) )
911 QString block( QStringLiteral(
"symbolLayer%1" ).arg( mBlockCounter++ ) );
912 mBlockHandle = QStringLiteral(
"%1" ).arg( mBlockHandles[ block ], 0, 16 );
917 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
919 writeGroup( 100, QStringLiteral(
"AcDbBlockBegin" ) );
936 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
938 writeGroup( 100, QStringLiteral(
"AcDbBlockEnd" ) );
940 mPointSymbolBlocks.insert( ml, block );
947 void QgsDxfExport::writeEntities()
950 writeGroup( 2, QStringLiteral(
"ENTITIES" ) );
952 mBlockHandle = QStringLiteral(
"%1" ).arg( mBlockHandles[ QStringLiteral(
"*Model_Space" )], 0, 16 );
954 QImage image( 10, 10, QImage::Format_ARGB32_Premultiplied );
955 image.setDotsPerMeterX( 96 / 25.4 * 1000 );
956 image.setDotsPerMeterY( 96 / 25.4 * 1000 );
957 QPainter painter( &image );
966 mExtent.
height() * mFactor, 0 ) );
973 const QList< QgsMapLayer *> layers = mMapSettings.
layers();
977 if ( !vl || !layerIsScaleBasedVisible( vl ) )
983 if ( hasStyleOverride )
985 QgsDebugMsg( QString(
"%1: apply override style" ).arg( vl->
id() ) );
990 QgsDebugMsg( QString(
"%1: not override style" ).arg( vl->
id() ) );
996 if ( hasStyleOverride )
1001 std::unique_ptr< QgsFeatureRenderer > renderer( vl->
renderer()->
clone() );
1002 renderer->startRender( ctx, vl->
fields() );
1004 QSet<QString> attributes = renderer->usedAttributes( ctx );
1005 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
1009 attributes << layerAttr;
1015 if (
const QgsRuleBasedLabeling *rbl = dynamic_cast<const QgsRuleBasedLabeling *>( labeling ) )
1021 if ( !rblp->
prepare( ctx, attributes ) )
1027 else if ( labeling )
1033 if ( !lp->
prepare( ctx, attributes ) )
1042 renderer->usingSymbolLevels() )
1044 writeEntitiesSymbolLevels( vl );
1045 renderer->stopRender( ctx );
1047 if ( hasStyleOverride )
1069 addFeature( sctx, ct, lName,
nullptr,
nullptr );
1073 QgsSymbolList symbolList = renderer->symbolsForFeature( fet, ctx );
1074 bool hasSymbology = symbolList.size() > 0;
1078 QgsSymbolList::iterator symbolIt = symbolList.begin();
1079 for ( ; symbolIt != symbolList.end(); ++symbolIt )
1081 int nSymbolLayers = ( *symbolIt )->symbolLayerCount();
1082 for (
int i = 0; i < nSymbolLayers; ++i )
1084 addFeature( sctx, ct, lName, ( *symbolIt )->symbolLayer( i ), *symbolIt );
1088 else if ( hasSymbology )
1096 addFeature( sctx, ct, lName, s->
symbolLayer( 0 ), s );
1110 renderer->stopRender( ctx );
1112 if ( hasStyleOverride )
1121 void QgsDxfExport::writeEntitiesSymbolLevels(
QgsVectorLayer *layer )
1133 std::unique_ptr< QgsFeatureRenderer > renderer( layer->
renderer()->
clone() );
1134 QHash< QgsSymbol *, QList<QgsFeature> > features;
1139 renderer->startRender( ctx, layer->
fields() );
1158 featureSymbol = renderer->symbolForFeature( fet, ctx );
1159 if ( !featureSymbol )
1164 QHash< QgsSymbol *, QList<QgsFeature> >::iterator it = features.find( featureSymbol );
1165 if ( it == features.end() )
1167 it = features.insert( featureSymbol, QList<QgsFeature>() );
1169 it.value().append( fet );
1175 for (
int i = 0; i < symbols.count(); i++ )
1181 if ( level < 0 || level >= 1000 )
1184 while ( level >= levels.count() )
1186 levels[level].append( item );
1193 for (
int l = 0; l < levels.count(); l++ )
1196 for (
int i = 0; i < level.count(); i++ )
1199 QHash< QgsSymbol *, QList<QgsFeature> >::iterator levelIt = features.find( item.
symbol() );
1200 if ( levelIt == features.end() )
1202 QgsDebugMsg( QString(
"No feature found for symbol on %1 %2.%3" ).arg( layer->
id() ).arg( l ).arg( i ) );
1206 int llayer = item.
layer();
1207 QList<QgsFeature> &featureList = levelIt.value();
1208 QList<QgsFeature>::iterator featureIt = featureList.begin();
1209 for ( ; featureIt != featureList.end(); ++featureIt )
1212 addFeature( sctx, ct, layer->
name(), levelIt.key()->symbolLayer( llayer ), levelIt.key() );
1216 renderer->stopRender( ctx );
1219 void QgsDxfExport::writeEndFile()
1246 ACAD_MLEADERSTYLE\n\ 1254 ACAD_PLOTSETTINGS\n\ 1258 ACAD_PLOTSTYLENAME\n\ 1366 ACDBDICTIONARYWDFLT\n\ 1386 AcDbDictionaryWithDefault\n\ 1582 1.000000000000000E+20\n\ 1584 1.000000000000000E+20\n\ 1586 1.000000000000000E+20\n\ 1588 -1.000000000000000E+20\n\ 1590 -1.000000000000000E+20\n\ 1592 -1.000000000000000E+20\n\ 1854 163.1318914119703\n\ 2022 AcDbSavedByObjectVersion\n\ 2112 AcDbSavedByObjectVersion\n\ 2202 AcDbSavedByObjectVersion\n\ 2292 AcDbSavedByObjectVersion\n\ 2382 AcDbSavedByObjectVersion\n\ 2474 AcDbSavedByObjectVersion\n\ 2564 AcDbSavedByObjectVersion\n\ 2654 AcDbSavedByObjectVersion\n\ 2744 AcDbSavedByObjectVersion\n\ 2834 AcDbSavedByObjectVersion\n\ 2924 AcDbSavedByObjectVersion\n\ 3014 AcDbSavedByObjectVersion\n\ 3104 AcDbSavedByObjectVersion\n\ 3194 AcDbSavedByObjectVersion\n\ 3286 AcDbSavedByObjectVersion\n\ 3376 AcDbSavedByObjectVersion\n\ 3386 void QgsDxfExport::startSection()
3388 writeGroup( 0, QStringLiteral(
"SECTION" ) );
3391 void QgsDxfExport::endSection()
3404 msl->
sizeUnit(), mMapUnits ) / 2.0;
3416 QHash< const QgsSymbolLayer *, QString >::const_iterator blockIt = mPointSymbolBlocks.constFind( symbolLayer );
3417 if ( !symbolLayer || blockIt == mPointSymbolBlocks.constEnd() )
3421 if ( msl && symbol )
3435 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3436 writeGroup( 100, QStringLiteral(
"AcDbBlockReference" ) );
3446 int n = line.size();
3449 QgsDebugMsg( QString(
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3453 bool polygon = line[0] == line[ line.size() - 1 ];
3458 QgsDebugMsg( QString(
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3462 if ( mForce2d || !line.at( 0 ).is3D() )
3464 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
3467 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3468 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
3476 for (
int i = 0; i < n; i++ )
3481 writeGroup( 0, QStringLiteral(
"POLYLINE" ) );
3484 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3488 writeGroup( 100, QStringLiteral(
"AcDb3dPolyline" ) );
3492 for (
int i = 0; i < n; i++ )
3497 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3500 writeGroup( 100, QStringLiteral(
"AcDbVertex" ) );
3501 writeGroup( 100, QStringLiteral(
"AcDb3dPolylineVertex" ) );
3509 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3520 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3523 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
3529 writeGroup( 70, hatchPattern == QLatin1String(
"SOLID" ) );
3533 for (
int i = 0; i < polygon.size(); ++i )
3540 for (
int j = 0; j < polygon[i].size(); ++j )
3563 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3564 writeGroup( 100, QStringLiteral(
"AcDbPoint" ) );
3575 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3578 writeGroup( 100, QStringLiteral(
"AcDbHatch" ) );
3609 writeGroup( 0, QStringLiteral(
"LWPOLYLINE" ) );
3613 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3614 writeGroup( 100, QStringLiteral(
"AcDbPolyline" ) );
3633 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3634 writeGroup( 100, QStringLiteral(
"AcDbText" ) );
3641 writeGroup( 7, QStringLiteral(
"STANDARD" ) );
3642 writeGroup( 100, QStringLiteral(
"AcDbText" ) );
3647 if ( !mTextStream.codec()->canEncode( text ) )
3650 QgsDebugMsg( QString(
"could not encode:%1" ).arg( text ) );
3656 writeGroup( 100, QStringLiteral(
"AcDbEntity" ) );
3657 writeGroup( 100, QStringLiteral(
"AcDbMText" ) );
3664 while ( t.length() > 250 )
3680 writeGroup( 7, QStringLiteral(
"STANDARD" ) );
3695 geom->transform( ct );
3702 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
3704 penColor = colorFromSymbolLayer( symbolLayer, ctx );
3708 Qt::PenStyle penStyle( Qt::SolidLine );
3709 Qt::BrushStyle brushStyle( Qt::NoBrush );
3711 double offset = 0.0;
3713 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
3715 width = symbolLayer->
dxfWidth( *
this, ctx );
3716 offset = symbolLayer->
dxfOffset( *
this, ctx );
3717 angle = symbolLayer->
dxfAngle( ctx );
3725 QString lineStyleName = QStringLiteral(
"CONTINUOUS" );
3728 lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
3734 writePoint( geom->coordinateSequence().at( 0 ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol,
angle );
3741 for (
int i = 0; i < cs.size(); i++ )
3743 writePoint( cs.at( i ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol,
angle );
3748 if ( penStyle != Qt::NoPen )
3764 if ( tempGeom != geom.get() )
3766 tempGeom = geos.
offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 );
3768 tempGeom = geom.get();
3785 if ( tempGeom != geom.get() )
3787 tempGeom = geos.
offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 );
3789 tempGeom = geom.get();
3793 for (
int i = 0; i < cs.size(); i++ )
3795 writePolyline( cs.at( i ).at( 0 ), layer, lineStyleName, penColor, width );
3811 if ( tempGeom != geom.get() )
3813 tempGeom = geos.
buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3815 tempGeom = geom.get();
3819 for (
int i = 0; i < cs.at( 0 ).size(); i++ )
3821 writePolyline( cs.at( 0 ).at( i ), layer, lineStyleName, penColor, width );
3832 if ( tempGeom != geom.get() )
3834 tempGeom = geos.
buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3836 tempGeom = geom.get();
3840 for (
int i = 0; i < cs.size(); i++ )
3841 for (
int j = 0; j < cs.at( i ).size(); j++ )
3842 writePolyline( cs.at( i ).at( j ), layer, lineStyleName, penColor, width );
3851 if ( tempGeom != geom.get() )
3855 if ( brushStyle != Qt::NoBrush )
3873 for (
int i = 0; i < cs.size(); i++ )
3875 writePolygon( cs.at( i ), layer, QStringLiteral(
"SOLID" ), brushColor );
3885 if ( tempGeom != geom.get() )
3895 return symbolLayer->
dxfColor( ctx );
3898 QString QgsDxfExport::lineStyleFromSymbolLayer(
const QgsSymbolLayer *symbolLayer )
3900 QString lineStyleName = QStringLiteral(
"CONTINUOUS" );
3903 return lineStyleName;
3906 QHash< const QgsSymbolLayer *, QString >::const_iterator lineTypeIt = mLineStyles.constFind( symbolLayer );
3907 if ( lineTypeIt != mLineStyles.constEnd() )
3909 lineStyleName = lineTypeIt.value();
3910 return lineStyleName;
3914 return lineNameFromPenStyle( symbolLayer->
dxfPenStyle() );
3921 int current_distance = INT_MAX;
3922 for (
int i = 1; i < static_cast< int >(
sizeof( sDxfColors ) /
sizeof( *sDxfColors ) ); ++i )
3924 int dist = color_distance( pixel, i );
3925 if ( dist < current_distance )
3927 current_distance = dist;
3936 int QgsDxfExport::color_distance( QRgb p1,
int index )
3938 if ( index > 255 || index < 0 )
3943 double redDiff = qRed( p1 ) - sDxfColors[index][0];
3944 double greenDiff = qGreen( p1 ) - sDxfColors[index][1];
3945 double blueDiff = qBlue( p1 ) - sDxfColors[index][2];
3947 QgsDebugMsg( QString(
"color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
3948 .arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
3950 .arg( mDxfColors[index][0] )
3951 .arg( mDxfColors[index][1] )
3952 .arg( mDxfColors[index][2] )
3953 .arg( redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff ) );
3955 return redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff;
3958 QRgb QgsDxfExport::createRgbEntry( qreal r, qreal g, qreal b )
3960 return QColor::fromRgbF( r, g, b ).rgb();
3980 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > QgsDxfExport::symbolLayers(
QgsRenderContext &context )
3982 QList< QPair< QgsSymbolLayer *, QgsSymbol * > > symbolLayers;
3984 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
4002 QgsSymbolList::iterator symbolIt = symbols.begin();
4003 for ( ; symbolIt != symbols.end(); ++symbolIt )
4005 int maxSymbolLayers = ( *symbolIt )->symbolLayerCount();
4008 maxSymbolLayers = 1;
4010 for (
int i = 0; i < maxSymbolLayers; ++i )
4012 symbolLayers.append( qMakePair( ( *symbolIt )->symbolLayer( i ), *symbolIt ) );
4017 return symbolLayers;
4020 void QgsDxfExport::writeDefaultLinetypes()
4023 const QStringList blockStrings = QStringList() << QStringLiteral(
"ByLayer" ) << QStringLiteral(
"ByBlock" ) << QStringLiteral(
"CONTINUOUS" );
4024 for (
const QString <ype : blockStrings )
4028 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
4029 writeGroup( 100, QStringLiteral(
"AcDbLinetypeTableRecord" ) );
4032 writeGroup( 3, QStringLiteral(
"Defaultstyle" ) );
4038 double das = dashSize();
4039 double dss = dashSeparatorSize();
4040 double dos = dotSize();
4042 QVector<qreal> dashVector( 2 );
4043 dashVector[0] = das;
4044 dashVector[1] = dss;
4047 QVector<qreal> dotVector( 2 );
4052 QVector<qreal> dashDotVector( 4 );
4053 dashDotVector[0] = das;
4054 dashDotVector[1] = dss;
4055 dashDotVector[2] = dos;
4056 dashDotVector[3] = dss;
4059 QVector<qreal> dashDotDotVector( 6 );
4060 dashDotDotVector[0] = das;
4061 dashDotDotVector[1] = dss;
4062 dashDotDotVector[2] = dos;
4063 dashDotDotVector[3] = dss;
4064 dashDotDotVector[4] = dos;
4065 dashDotDotVector[5] = dss;
4069 void QgsDxfExport::writeSymbolLayerLinetype(
const QgsSymbolLayer *symbolLayer )
4078 if ( !customLinestyle.isEmpty() )
4080 QString name = QStringLiteral(
"symbolLayer%1" ).arg( mSymbolLayerCounter++ );
4081 writeLinetype( name, customLinestyle, unit );
4082 mLineStyles.insert( symbolLayer, name );
4086 int QgsDxfExport::nLineTypes(
const QList< QPair< QgsSymbolLayer *, QgsSymbol * > > &symbolLayers )
4089 QList< QPair< QgsSymbolLayer *, QgsSymbol *> >::const_iterator slIt = symbolLayers.constBegin();
4090 for ( ; slIt != symbolLayers.constEnd(); ++slIt )
4104 void QgsDxfExport::writeLinetype(
const QString &styleName,
const QVector<qreal> &pattern,
QgsUnitTypes::RenderUnit u )
4107 QVector<qreal>::const_iterator dashIt = pattern.constBegin();
4108 for ( ; dashIt != pattern.constEnd(); ++dashIt )
4116 writeGroup( 100, QStringLiteral(
"AcDbSymbolTableRecord" ) );
4117 writeGroup( 100, QStringLiteral(
"AcDbLinetypeTableRecord" ) );
4125 dashIt = pattern.constBegin();
4127 for ( ; dashIt != pattern.constEnd(); ++dashIt )
4130 double segmentLength = ( isGap ? -*dashIt : *dashIt );
4140 if ( !sl || !symbol )
4153 double QgsDxfExport::dashSize()
const 4155 double size = mSymbologyScale * 0.002;
4156 return sizeToMapUnits( size );
4159 double QgsDxfExport::dotSize()
const 4161 double size = mSymbologyScale * 0.0006;
4162 return sizeToMapUnits( size );
4165 double QgsDxfExport::dashSeparatorSize()
const 4167 double size = mSymbologyScale * 0.0006;
4168 return sizeToMapUnits( size );
4171 double QgsDxfExport::sizeToMapUnits(
double s )
const 4177 QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
4182 return QStringLiteral(
"DASH" );
4184 return QStringLiteral(
"DOT" );
4185 case Qt::DashDotLine:
4186 return QStringLiteral(
"DASHDOT" );
4187 case Qt::DashDotDotLine:
4188 return QStringLiteral(
"DASHDOTDOT" );
4191 return QStringLiteral(
"CONTINUOUS" );
4197 if ( name.isEmpty() )
4198 return QStringLiteral(
"0" );
4206 layerName.replace(
'<',
'_' );
4207 layerName.replace(
'>',
'_' );
4208 layerName.replace(
'/',
'_' );
4209 layerName.replace(
'\\',
'_' );
4210 layerName.replace(
'\"',
'_' );
4211 layerName.replace(
':',
'_' );
4212 layerName.replace(
';',
'_' );
4213 layerName.replace(
'?',
'_' );
4214 layerName.replace(
'*',
'_' );
4215 layerName.replace(
'|',
'_' );
4216 layerName.replace(
'=',
'_' );
4217 layerName.replace(
'\'',
'_' );
4220 layerName.replace( QLatin1String(
"\r\n" ), QLatin1String(
"_" ) );
4221 layerName.replace(
'\r',
'_' );
4222 layerName.replace(
'\n',
'_' );
4224 return layerName.trimmed();
4227 bool QgsDxfExport::layerIsScaleBasedVisible(
const QgsMapLayer *layer )
const 4240 const QList< QgsMapLayer * > layers = mMapSettings.
layers();
4244 if ( vl && vl->
id() == id )
4246 int attrIdx = mLayerNameAttribute.value( vl->
id(), -1 );
4251 return QStringLiteral(
"0" );
4256 const QList< QByteArray > codecs = QTextCodec::availableCodecs();
4257 for (
const QByteArray &codec : codecs )
4259 if ( name != codec )
4263 for ( i = 0; i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) && name != DXF_ENCODINGS[i][1]; ++i )
4266 if ( i == static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) )
4269 return DXF_ENCODINGS[i][0];
4278 const QList< QByteArray > codecs = QTextCodec::availableCodecs();
4279 for (
const QByteArray &codec : codecs )
4282 for ( i = 0; i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) && strcmp( codec.data(), DXF_ENCODINGS[i][1] ) != 0; ++i )
4285 if ( i < static_cast< int >(
sizeof( DXF_ENCODINGS ) /
sizeof( *DXF_ENCODINGS ) ) )
4286 encodings << codec.data();
4294 return mLayerTitleAsName && !vl->
title().isEmpty() ? vl->
title() : vl->
name();
4299 Q_UNUSED( context );
4312 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues = lf->
dataDefinedValues();
4317 QgsDebugMsgLevel( QString(
"PAL font definedFont: %1, Style: %2" ).arg( dFont.toString(), dFont.styleName() ), 4 );
4347 QgsPalLabeling::dataDefinedTextStyle( tmpLyr, ddValues );
4350 QgsPalLabeling::dataDefinedTextBuffer( tmpLyr, ddValues );
4353 QgsPalLabeling::dataDefinedTextFormatting( tmpLyr, ddValues );
4359 QString dxfLayer = mDxfLayerNames[layerId][fid];
4361 QString wrapchr = tmpLyr.
wrapChar.isEmpty() ? QStringLiteral(
"\n" ) : tmpLyr.
wrapChar;
4366 bool prependSymb =
false;
4384 prependSymb =
false;
4392 symb = symb + wrapchr;
4396 prependSymb =
false;
4397 symb = wrapchr + symb;
4402 txt.prepend( symb );
4416 txt = txt.replace( wrapchr, QLatin1String(
"\\P" ) );
4417 txt.replace(
" ",
"\\~" );
4421 txt.prepend(
"\\L" ).append(
"\\l" );
4426 txt.prepend(
"\\O" ).append(
"\\o" );
4431 txt.prepend(
"\\K" ).append(
"\\k" );
4434 txt.prepend( QStringLiteral(
"\\f%1|i%2|b%3;\\H%4;" )
4436 .arg( tmpLyr.
format().
font().italic() ? 1 : 0 )
4437 .arg( tmpLyr.
format().
font().bold() ? 1 : 0 )
4438 .arg( label->
getHeight() / ( 1 + txt.count( QStringLiteral(
"\\P" ) ) ) * 0.75 ) );
4446 if ( !mDxfLayerNames.contains( layerId ) )
4447 mDxfLayerNames[ layerId ] = QMap<QgsFeatureId, QString>();
4449 mDxfLayerNames[layerId][fid] =
layerName;
bool restoreOverrideStyle()
Restore the original store after a call to setOverrideStyle()
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
QgsDxfExport()=default
Constructor for QgsDxfExport.
virtual QVector< qreal > dxfCustomDashPattern(QgsUnitTypes::RenderUnit &unit) const
get 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.
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 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
get offset
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
Return if a field index is valid.
QVector< QgsRingSequence > QgsCoordinateSequence
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits)
Calculates a scaling factor to convert from map units to a specified symbol unit. ...
Export text as TEXT elements. If not set, text will be exported as MTEXT elements.
double getY(int i=0) const
get the down-left y coordinate
void startRender(QgsSymbolRenderContext &context) override
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
Get data-defined values.
QgsAbstractGeometry * buffer(double distance, int segments, QString *errorMsg=nullptr) const override
void setOutputDpi(double dpi)
Set 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)
Get 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()
return 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.
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
get line width
FeaturePart * getFeaturePart()
return the feature corresponding to this labelposition
QList< QgsMapLayer * > layers() const
Get list of layers for map rendering The layers are stored in the reverse order of how they are rende...
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.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
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.
void setFlags(QgsDxfExport::Flags flags)
Sets the export flags.
void writeInt(int i)
Write an integer value.
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
Get field at particular index (must be in range 0..N-1)
QList< QgsSymbolLevel > QgsSymbolLevelOrder
The QgsMapSettings class contains configuration for rendering of the map.
QgsMapLayerStyleManager * styleManager() const
Get access to the layer's style manager.
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
Return coordinate transform from layer's CRS to destination CRS.
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)
Set the size of the resulting map image.
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
Get 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.
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
get brush/fill style
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)
QgsFeatureRenderer * renderer()
Return 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
Abstract base class for all geometries.
QgsGeometry geometry() const
Returns the geometry associated with this feature.
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)
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.
static QString dxfEncoding(const QString &name)
return 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
Get layer name for feature.
virtual QColor dxfBrushColor(QgsSymbolRenderContext &context) const
get 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)
Expand the rectangle so that covers both the original rectangle and the given rectangle.
QString wrapChar
Wrapping character string.
virtual Qt::PenStyle dxfPenStyle() const
get pen style
virtual QgsCoordinateSequence coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
static QString dxfLayerName(const QString &name)
Return cleaned layer name for use in DXF.
virtual QgsSymbolList symbols(QgsRenderContext &context)
Returns list of symbols used by the renderer.
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
Get map of map layer style overrides (key: layer ID, value: style name) where a different style shoul...
QList< QgsSymbolLevelItem > QgsSymbolLevel
double getAlpha() const
get alpha
virtual void stopRender(QgsSymbolRenderContext &context)=0
virtual double dxfAngle(QgsSymbolRenderContext &context) const
get angle
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
double getX(int i=0) const
get the down-left x coordinate
QgsPointXY layerToMapCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from layer's CRS to output CRS
virtual QColor dxfColor(QgsSymbolRenderContext &context) const
get color
RenderHints renderHints() const
Returns the rendering hint flags for the symbol.
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 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...
bool setOverrideStyle(const QString &styleDef)
Temporarily apply a different style to the layer.
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.
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
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.
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.
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)
Set flags that affect how features will be fetched.
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)