42 #define DXF_HANDSEED 100 43 #define DXF_HANDMAX 9999999 44 #define DXF_HANDPLOTSTYLE 0xf 47 int QgsDxfExport::mDxfColors[][3] =
307 const char *QgsDxfExport::mDxfEncodings[][2] =
310 {
"8859_1",
"ISO-8859-1" },
311 {
"8859_2",
"ISO-8859-2" },
312 {
"8859_3",
"ISO-8859-3" },
313 {
"8859_4",
"ISO-8859-4" },
314 {
"8859_5",
"ISO-8859-5" },
315 {
"8859_6",
"ISO-8859-6" },
316 {
"8859_7",
"ISO-8859-7" },
317 {
"8859_8",
"ISO-8859-8" },
318 {
"8859_9",
"ISO-8859-9" },
320 {
"DOS850",
"CP850" },
331 {
"MACINTOSH",
"MacRoman" },
333 {
"KSC5601",
"ksc5601.1987-0" },
335 {
"DOS866",
"CP866" },
336 {
"ANSI_1250",
"CP1250" },
337 {
"ANSI_1251",
"CP1251" },
338 {
"ANSI_1252",
"CP1252" },
339 {
"GB2312",
"GB2312" },
340 {
"ANSI_1253",
"CP1253" },
341 {
"ANSI_1254",
"CP1254" },
342 {
"ANSI_1255",
"CP1255" },
343 {
"ANSI_1256",
"CP1256" },
344 {
"ANSI_1257",
"CP1257" },
345 {
"ANSI_874",
"CP874" },
346 {
"ANSI_932",
"Shift_JIS" },
347 {
"ANSI_936",
"CP936" },
348 {
"ANSI_949",
"cp949" },
349 {
"ANSI_950",
"CP950" },
352 {
"ANSI_1258",
"CP1258" },
356 : mSymbologyScaleDenominator( 1.0 )
357 , mSymbologyExport( NoSymbology )
358 , mMapUnits(
QGis::Meters )
359 , mSymbolLayerCounter( 0 )
372 mLayers = dxfExport.mLayers;
373 mSymbologyScaleDenominator = dxfExport.mSymbologyScaleDenominator;
374 mSymbologyExport = dxfExport.mSymbologyExport;
375 mMapUnits = dxfExport.mMapUnits;
376 mSymbolLayerCounter = 0;
420 int minDist = INT_MAX;
422 for (
int i = 1; i < ( int )(
sizeof( mDxfColors ) /
sizeof( *mDxfColors ) ) && minDist > 0; ++i )
424 int dist = color_distance( color.rgba(), i );
425 if ( dist >= minDist )
432 if ( minDist == 0 && color.alpha() == 255 && minDistAt != 7 )
439 int c = ( color.red() & 0xff ) * 0x10000 + ( color.green() & 0xff ) * 0x100 + ( color.blue() & 0xff );
441 if ( transparencyCode != -1 && color.alpha() < 255 )
442 writeGroup( transparencyCode, 0x2000000 | color.alpha() );
447 mTextStream << QString(
"%1\n" ).arg( code, 3, 10, QChar(
' ' ) );
452 mTextStream << QString(
"%1\n" ).arg( i, 6, 10, QChar(
' ' ) );
458 if ( !s.contains(
"." ) )
460 mTextStream << s <<
"\n";
465 mTextStream << s <<
"\n";
475 if ( !d->isOpen() && !d->open( QIODevice::WriteOnly ) )
480 mTextStream.setDevice( d );
481 mTextStream.setCodec( encoding.toLocal8Bit() );
492 void QgsDxfExport::writeHeader( QString codepage )
504 if ( !ext.isEmpty() )
543 handle = mNextHandleId++;
545 Q_ASSERT_X( handle <
DXF_HANDMAX,
"QgsDxfExport::writeHandle(int, int)",
"DXF handle too large" );
547 writeGroup( code, QString(
"%1" ).arg( handle, 0, 16 ) );
551 void QgsDxfExport::writeTables()
557 QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > > slList;
560 slList = symbolLayers();
571 writeDefaultLinetypes();
574 QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2*> >::const_iterator slIt = slList.constBegin();
575 for ( ; slIt != slList.constEnd(); ++slIt )
577 writeSymbolLayerLinetype( slIt->first );
590 foreach ( QString block, QStringList() <<
"*Model_Space" <<
"*Paper_Space" <<
"*Paper_Space0" )
600 slIt = slList.constBegin();
601 for ( ; slIt != slList.constEnd(); ++slIt )
607 if ( hasDataDefinedProperties( ml, slIt->second ) )
610 QString name = QString(
"symbolLayer%1" ).arg( i++ );
707 QList< QPair<QgsVectorLayer*, int> >::const_iterator layerIt = mLayers.constBegin();
708 QSet<QString> layerNames;
709 for ( ; layerIt != mLayers.constEnd(); ++layerIt )
711 if ( !layerIsScaleBasedVisible( layerIt->first ) )
714 if ( layerIt->first )
716 if ( layerIt->second < 0 )
722 QList<QVariant> values;
723 layerIt->first->uniqueValues( layerIt->second, values );
724 foreach ( QVariant v, values )
750 foreach ( QString
layerName, layerNames )
775 writeGroup( 100,
"AcDbTextStyleTableRecord" );
791 void QgsDxfExport::writeBlocks()
796 foreach ( QString block, QStringList() <<
"*Model_Space" <<
"*Paper_Space" <<
"*Paper_Space0" )
800 writeGroup( 330, QString(
"%1" ).arg( mBlockHandles[ block ], 0, 16 ) );
817 QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > > slList;
820 slList = symbolLayers();
823 QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > >::const_iterator slIt = slList.constBegin();
824 for ( ; slIt != slList.constEnd(); ++slIt )
836 if ( hasDataDefinedProperties( ml, slIt->second ) )
842 QString block( QString(
"symbolLayer%1" ).arg( mBlockCounter++ ) );
843 mBlockHandle = QString(
"%1" ).arg( mBlockHandles[ block ], 0, 16 );
871 mPointSymbolBlocks.insert( ml, block );
877 void QgsDxfExport::writeEntities()
882 mBlockHandle = QString(
"%1" ).arg( mBlockHandles[
"*Model_Space" ], 0, 16 );
885 QgsDxfPalLabeling labelEngine(
this, mExtent.
isEmpty() ? dxfExtent() : mExtent, mSymbologyScaleDenominator, mMapUnits );
889 QList< QPair< QgsVectorLayer*, int > >::iterator layerIt = mLayers.begin();
890 for ( ; layerIt != mLayers.end(); ++layerIt )
893 if ( !vl || !layerIsScaleBasedVisible( vl ) )
910 if ( !attributes.contains( layerAttr ) )
911 attributes << layerAttr;
914 bool labelLayer = labelEngine.prepareLayer( vl, attributes, ctx ) != 0;
920 writeEntitiesSymbolLevels( vl );
940 addFeature( sctx, layerName, 0, 0 );
945 if ( symbolList.size() < 1 )
952 QgsSymbolV2List::iterator symbolIt = symbolList.begin();
953 for ( ; symbolIt != symbolList.end(); ++symbolIt )
955 int nSymbolLayers = ( *symbolIt )->symbolLayerCount();
956 for (
int i = 0; i < nSymbolLayers; ++i )
958 addFeature( sctx, layerName, ( *symbolIt )->symbolLayer( i ), *symbolIt );
970 addFeature( sctx, layerName, s->
symbolLayer( 0 ), s );
975 labelEngine.registerFeature( vl->
id(), fet, ctx,
layerName );
983 labelEngine.drawLabeling( ctx );
987 void QgsDxfExport::writeEntitiesSymbolLevels(
QgsVectorLayer* layer )
1000 QHash< QgsSymbolV2*, QList<QgsFeature> > features;
1025 if ( !featureSymbol )
1030 QHash< QgsSymbolV2*, QList<QgsFeature> >::iterator it = features.find( featureSymbol );
1031 if ( it == features.end() )
1033 it = features.insert( featureSymbol, QList<QgsFeature>() );
1035 it.value().append( fet );
1041 for (
int i = 0; i < symbols.count(); i++ )
1047 if ( level < 0 || level >= 1000 )
1050 while ( level >= levels.count() )
1052 levels[level].append( item );
1057 for (
int l = 0; l < levels.count(); l++ )
1060 for (
int i = 0; i < level.count(); i++ )
1063 QHash< QgsSymbolV2*, QList<QgsFeature> >::iterator levelIt = features.find( item.
symbol() );
1064 if ( levelIt == features.end() )
1066 QgsDebugMsg( QString(
"No feature found for symbol on %1 %2.%3" ).arg( layer->
id() ).arg( l ).arg( i ) );
1070 int llayer = item.
layer();
1071 QList<QgsFeature>& featureList = levelIt.value();
1072 QList<QgsFeature>::iterator featureIt = featureList.begin();
1073 for ( ; featureIt != featureList.end(); ++featureIt )
1076 addFeature( sctx, layer->
name(), levelIt.key()->symbolLayer( llayer ), levelIt.key() );
1083 void QgsDxfExport::writeEndFile()
1110 ACAD_MLEADERSTYLE\n\ 1118 ACAD_PLOTSETTINGS\n\ 1122 ACAD_PLOTSTYLENAME\n\ 1230 ACDBDICTIONARYWDFLT\n\ 1250 AcDbDictionaryWithDefault\n\ 1446 1.000000000000000E+20\n\ 1448 1.000000000000000E+20\n\ 1450 1.000000000000000E+20\n\ 1452 -1.000000000000000E+20\n\ 1454 -1.000000000000000E+20\n\ 1456 -1.000000000000000E+20\n\ 1718 163.1318914119703\n\ 1886 AcDbSavedByObjectVersion\n\ 1976 AcDbSavedByObjectVersion\n\ 2066 AcDbSavedByObjectVersion\n\ 2156 AcDbSavedByObjectVersion\n\ 2246 AcDbSavedByObjectVersion\n\ 2338 AcDbSavedByObjectVersion\n\ 2428 AcDbSavedByObjectVersion\n\ 2518 AcDbSavedByObjectVersion\n\ 2608 AcDbSavedByObjectVersion\n\ 2698 AcDbSavedByObjectVersion\n\ 2788 AcDbSavedByObjectVersion\n\ 2878 AcDbSavedByObjectVersion\n\ 2968 AcDbSavedByObjectVersion\n\ 3058 AcDbSavedByObjectVersion\n\ 3150 AcDbSavedByObjectVersion\n\ 3240 AcDbSavedByObjectVersion\n\ 3250 void QgsDxfExport::startSection()
3255 void QgsDxfExport::endSection()
3268 msl->
sizeUnit(), mMapUnits ) / 2.0;
3280 QHash< const QgsSymbolLayerV2*, QString >::const_iterator blockIt = mPointSymbolBlocks.find( symbolLayer );
3281 if ( !symbolLayer || blockIt == mPointSymbolBlocks.constEnd() )
3285 if ( msl && symbol )
3310 double width,
bool )
3312 int n = line.size();
3315 QgsDebugMsg( QString(
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer ).arg( lineStyleName ) );
3319 bool polygon = line[0] == line[ line.size() - 1 ];
3324 QgsDebugMsg( QString(
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer ).arg( lineStyleName ) );
3340 for (
int i = 0; i < n; i++ )
3362 for (
int i = 0; i < polygon.size(); ++i )
3369 for (
int j = 0; j < polygon[i].size(); ++j )
3388 writePolyline( line, layer, lineStyleName, color, width,
false );
3481 if ( !mTextStream.codec()->canEncode( text ) )
3497 while ( t.length() > 250 )
3522 p[0].resize( pt3 != pt4 ? 5 : 4 );
3526 if ( p[0].size() == 5 )
3533 void QgsDxfExport::writeVertex(
const QgsPoint& pt,
const QString& layer )
3547 QList< QPair<QgsVectorLayer*, int> >::const_iterator layerIt = mLayers.constBegin();
3548 for ( ; layerIt != mLayers.constEnd(); ++layerIt )
3550 if ( layerIt->first )
3554 extent = layerIt->first->extent();
3582 penColor = colorFromSymbolLayer( symbolLayer, ctx );
3586 Qt::PenStyle penStyle( Qt::SolidLine );
3587 Qt::BrushStyle brushStyle( Qt::NoBrush );
3589 double offset = 0.0;
3590 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
3592 width = symbolLayer->
dxfWidth( *
this, ctx );
3593 offset = symbolLayer->
dxfOffset( *
this, ctx );
3601 QString lineStyleName =
"CONTINUOUS";
3604 lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
3618 QgsMultiPoint::const_iterator it = multiPoint.constBegin();
3619 for ( ; it != multiPoint.constEnd(); ++it )
3621 writePoint( *it, layer, penColor, fet, symbolLayer, symbol );
3627 if ( penStyle != Qt::NoPen )
3638 if ( offsetLine != geom )
3650 QgsMultiPolyline::const_iterator lIt = multiLine.constBegin();
3651 for ( ; lIt != multiLine.constEnd(); ++lIt )
3653 writePolyline( *lIt, layer, lineStyleName, penColor, width,
false );
3656 if ( offsetLine != geom )
3663 QgsGeometry *offsetPolygon = offset == 0.0 ? geom : geom->
buffer( -offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3664 if ( !offsetPolygon )
3665 offsetPolygon = geom;
3668 QgsPolygon::const_iterator polyIt = polygon.constBegin();
3669 for ( ; polyIt != polygon.constEnd(); ++polyIt )
3671 writePolyline( *polyIt, layer, lineStyleName, penColor, width,
false );
3674 if ( offsetPolygon != geom )
3675 delete offsetPolygon;
3681 QgsGeometry *offsetPolygon = offset == 0.0 ? geom : geom->
buffer( -offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3682 if ( !offsetPolygon )
3683 offsetPolygon = geom;
3686 QgsMultiPolygon::const_iterator mpIt = mp.constBegin();
3687 for ( ; mpIt != mp.constEnd(); ++mpIt )
3689 QgsPolygon::const_iterator polyIt = mpIt->constBegin();
3690 for ( ; polyIt != mpIt->constEnd(); ++polyIt )
3692 writePolyline( *polyIt, layer, lineStyleName, penColor, width,
true );
3696 if ( offsetPolygon != geom )
3697 delete offsetPolygon;
3701 if ( brushStyle != Qt::NoBrush )
3714 QgsMultiPolygon::const_iterator mpIt = mp.constBegin();
3715 for ( ; mpIt != mp.constEnd(); ++mpIt )
3728 return symbolLayer->
dxfColor( ctx );
3731 QString QgsDxfExport::lineStyleFromSymbolLayer(
const QgsSymbolLayerV2* symbolLayer )
3733 QString lineStyleName =
"CONTINUOUS";
3736 return lineStyleName;
3739 QHash< const QgsSymbolLayerV2*, QString >::const_iterator lineTypeIt = mLineStyles.find( symbolLayer );
3740 if ( lineTypeIt != mLineStyles.constEnd() )
3742 lineStyleName = lineTypeIt.value();
3743 return lineStyleName;
3747 return lineNameFromPenStyle( symbolLayer->
dxfPenStyle() );
3754 int current_distance = INT_MAX;
3755 for (
size_t i = 1; i <
sizeof( mDxfColors ) /
sizeof( *mDxfColors ); ++i )
3757 int dist = color_distance( pixel, i );
3758 if ( dist < current_distance )
3760 current_distance = dist;
3769 int QgsDxfExport::color_distance( QRgb p1,
int index )
3771 if ( index > 255 || index < 0 )
3776 double redDiff = qRed( p1 ) - mDxfColors[
index][0];
3777 double greenDiff = qGreen( p1 ) - mDxfColors[
index][1];
3778 double blueDiff = qBlue( p1 ) - mDxfColors[
index][2];
3780 QgsDebugMsg( QString(
"color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
3781 .arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
3783 .arg( mDxfColors[index][0] )
3784 .arg( mDxfColors[index][1] )
3785 .arg( mDxfColors[index][2] )
3786 .arg( redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff ) );
3788 return redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff;
3791 QRgb QgsDxfExport::createRgbEntry( qreal r, qreal g, qreal b )
3793 return QColor::fromRgbF( r, g, b ).rgb();
3813 QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > > QgsDxfExport::symbolLayers()
3815 QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > > symbolLayers;
3817 QList< QPair< QgsVectorLayer*, int> >::iterator lIt = mLayers.begin();
3818 for ( ; lIt != mLayers.end(); ++lIt )
3836 QgsSymbolV2List::iterator symbolIt = symbols.begin();
3837 for ( ; symbolIt != symbols.end(); ++symbolIt )
3839 int maxSymbolLayers = ( *symbolIt )->symbolLayerCount();
3842 maxSymbolLayers = 1;
3844 for (
int i = 0; i < maxSymbolLayers; ++i )
3846 symbolLayers.append( qMakePair(( *symbolIt )->symbolLayer( i ), *symbolIt ) );
3851 return symbolLayers;
3854 void QgsDxfExport::writeDefaultLinetypes()
3857 foreach ( QString ltype, QStringList() <<
"ByLayer" <<
"ByBlock" <<
"CONTINUOUS" )
3862 writeGroup( 100,
"AcDbLinetypeTableRecord" );
3871 double das = dashSize();
3872 double dss = dashSeparatorSize();
3873 double dos = dotSize();
3875 QVector<qreal> dashVector( 2 );
3876 dashVector[0] = das;
3877 dashVector[1] = dss;
3880 QVector<qreal> dotVector( 2 );
3885 QVector<qreal> dashDotVector( 4 );
3886 dashDotVector[0] = das;
3887 dashDotVector[1] = dss;
3888 dashDotVector[2] = dos;
3889 dashDotVector[3] = dss;
3892 QVector<qreal> dashDotDotVector( 6 );
3893 dashDotDotVector[0] = das;
3894 dashDotDotVector[1] = dss;
3895 dashDotDotVector[2] = dos;
3896 dashDotDotVector[3] = dss;
3897 dashDotDotVector[4] = dos;
3898 dashDotDotVector[5] = dss;
3902 void QgsDxfExport::writeSymbolLayerLinetype(
const QgsSymbolLayerV2* symbolLayer )
3911 if ( customLinestyle.size() > 0 )
3913 QString name = QString(
"symbolLayer%1" ).arg( mSymbolLayerCounter++ );
3914 writeLinetype( name, customLinestyle, unit );
3915 mLineStyles.insert( symbolLayer, name );
3919 int QgsDxfExport::nLineTypes(
const QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > >& symbolLayers )
3922 QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2*> >::const_iterator slIt = symbolLayers.constBegin();
3923 for ( ; slIt != symbolLayers.constEnd(); ++slIt )
3937 void QgsDxfExport::writeLinetype(
const QString& styleName,
const QVector<qreal>& pattern,
QgsSymbolV2::OutputUnit u )
3940 QVector<qreal>::const_iterator dashIt = pattern.constBegin();
3941 for ( ; dashIt != pattern.constEnd(); ++dashIt )
3943 length += ( *dashIt *
mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits ) );
3950 writeGroup( 100,
"AcDbLinetypeTableRecord" );
3958 dashIt = pattern.constBegin();
3960 for ( ; dashIt != pattern.constEnd(); ++dashIt )
3963 double segmentLength = ( isGap ? -*dashIt : *dashIt );
3973 if ( !sl || !symbol )
3987 double QgsDxfExport::dashSize()
const 3989 double size = mSymbologyScaleDenominator * 0.002;
3990 return sizeToMapUnits( size );
3993 double QgsDxfExport::dotSize()
const 3995 double size = mSymbologyScaleDenominator * 0.0006;
3996 return sizeToMapUnits( size );
3999 double QgsDxfExport::dashSeparatorSize()
const 4001 double size = mSymbologyScaleDenominator * 0.0006;
4002 return sizeToMapUnits( size );
4005 double QgsDxfExport::sizeToMapUnits(
double s )
const 4011 QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
4019 case Qt::DashDotLine:
4021 case Qt::DashDotDotLine:
4022 return "DASHDOTDOT";
4025 return "CONTINUOUS";
4031 if ( name.isEmpty() )
4040 layerName.replace(
"<",
"_" );
4041 layerName.replace(
">",
"_" );
4042 layerName.replace(
"/",
"_" );
4043 layerName.replace(
"\\",
"_" );
4044 layerName.replace(
"\"",
"_" );
4045 layerName.replace(
":",
"_" );
4046 layerName.replace(
";",
"_" );
4047 layerName.replace(
"?",
"_" );
4048 layerName.replace(
"*",
"_" );
4049 layerName.replace(
"|",
"_" );
4050 layerName.replace(
"=",
"_" );
4051 layerName.replace(
"\'",
"_" );
4053 return layerName.trimmed();
4056 bool QgsDxfExport::layerIsScaleBasedVisible(
const QgsMapLayer* layer )
const 4064 return layer->
minimumScale() < mSymbologyScaleDenominator &&
4070 QList< QPair<QgsVectorLayer*, int> >::const_iterator layerIt = mLayers.constBegin();
4071 for ( ; layerIt != mLayers.constEnd(); ++layerIt )
4073 if ( layerIt->first && layerIt->first->id() == id )
4074 return dxfLayerName( layerIt->second < 0 ? layerIt->first->name() : f.
attribute( layerIt->second ).toString() );
4082 foreach ( QByteArray codec, QTextCodec::availableCodecs() )
4084 if ( name != codec )
4088 for ( i = 0; i < ( int )(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) && name != mDxfEncodings[i][1]; ++i )
4091 if ( i == (
int )(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) )
4094 return mDxfEncodings[i][0];
4097 return QString::null;
4103 foreach ( QByteArray codec, QTextCodec::availableCodecs() )
4106 for ( i = 0; i < ( int )(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) && strcmp( codec.data(), mDxfEncodings[i][1] ) != 0; ++i )
4109 if ( i < (
int )(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) )
4110 encodings << codec.data();
static double mapUnitScaleFactor(double scaleDenominator, QgsSymbolV2::OutputUnit symbolUnits, QGis::UnitType mapUnits)
const QString & name() const
Gets the name of the field.
Wrapper for iterator of features from vector data provider or vector layer.
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
void writePoint(const QString &layer, QColor color, const QgsPoint &pt)
Write point.
A rectangle specified with double values.
Base class for all map layer types.
bool isEmpty() const
test if rectangle is empty.
virtual Qt::PenStyle dxfPenStyle() const
virtual double dxfWidth(const QgsDxfExport &e, const QgsSymbolV2RenderContext &context) const
virtual double dxfOffset(const QgsDxfExport &e, const QgsSymbolV2RenderContext &context) const
QList< QgsSymbolV2 * > QgsSymbolV2List
void addLayers(const QList< QPair< QgsVectorLayer *, int > > &layers)
void writeGroup(int code, int i)
void writePolygon(const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, QColor color)
Draw dxf polygon (HATCH)
QgsMultiPolyline asMultiPolyline() const
return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
QVector< QgsPoint > QgsPolyline
polyline is represented as a vector of points
bool useCustomDashPattern() const
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
QgsPolygon asPolygon() const
return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list ...
void writeSolid(const QString &layer, QColor color, const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, const QgsPoint &pt4)
Draw solid.
QGis::UnitType mapUnits() const
void setRendererScale(double scale)
float minimumScale() const
Returns the minimum scale denominator at which the layer is visible.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
static QStringList encodings()
return list of available DXF encodings
WkbType
Used for symbology operations.
QgsSymbolV2::OutputUnit sizeUnit() const
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
The QGis class provides global constants for use throughout the application.
virtual QList< QString > usedAttributes()=0
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
static int closestColorMatch(QRgb pixel)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
void writeCircle(const QString &layer, QColor color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width)
Write circle (as polyline)
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
QgsMultiPolygon asMultiPolygon() const
return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
QGis::WkbType wkbType() const
Returns the WKBType or WKBUnknown in case of error.
virtual void stopRender(QgsRenderContext &context)=0
QgsGeometry * offsetCurve(double distance, int segments, int joinStyle, double mitreLimit)
Returns an offset line at a given distance and side from an input line.
void writeString(const QString &s)
const QString & name() const
Get the display name of the layer.
virtual QgsSymbolV2List symbols()=0
for symbol levels
QgsRectangle extent() const
bool exists(int i) const
Return if a field index is valid.
void combineExtentWith(QgsRectangle *rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
const QgsFeature * feature() const
Current feature being rendered - may be null.
QgsGeometry * buffer(double distance, int segments)
Returns a buffer region around this geometry having the given width and with a specified number of se...
virtual QVector< qreal > dxfCustomDashPattern(QgsSymbolV2::OutputUnit &unit) const
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
float maximumScale() const
Returns the maximum scale denominator at which the layer is visible.
void writeGroupCode(int code)
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QVector< QgsPolygon > QgsMultiPolygon
a collection of QgsPolygons that share a common collection of attributes
QVector< QgsPoint > QgsMultiPoint
a collection of QgsPoints that share a common collection of attributes
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
QGis::WkbType wkbType() const
Returns type of wkb (point / linestring / polygon etc.)
void writeLine(const QgsPoint &pt1, const QgsPoint &pt2, const QString &layer, const QString &lineStyleName, QColor color, double width=-1)
Write line (as a polyline)
int writeToFile(QIODevice *d, QString codec)
void writePolyline(const QgsPolyline &line, const QString &layer, const QString &lineStyleName, QColor color, double width=-1, bool unusedPolygonFlag=false)
draw dxf primitives
QVector< QgsPolyline > QgsPolygon
polygon: first item of the list is outer ring, inner rings (if any) start from second item ...
void setFeature(const QgsFeature *f)
virtual QColor dxfBrushColor(const QgsSymbolV2RenderContext &context) const
bool hasDataDefinedProperties() const
A class to represent a point.
static QString dxfEncoding(const QString &name)
return DXF encoding for Qt encoding
virtual QColor dxfColor(const QgsSymbolV2RenderContext &context) const
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, const QgsSymbolV2RenderContext *context, const QgsFeature *f, const QPointF &shift=QPointF(0.0, 0.0)) const
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
A class to represent a vector.
QList< QgsSymbolV2LevelItem > QgsSymbolV2Level
QString qgsDoubleToString(const double &a, const int &precision=17)
int renderingPass() const
QVector< QgsPolyline > QgsMultiPolyline
a collection of QgsPolylines that share a common collection of attributes
void startRender(QgsSymbolV2RenderContext &context) override
static QString dxfLayerName(const QString &name)
Return cleaned layer name for use in DXF.
QgsPolyline asPolyline() const
return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list ...
Contains information about the context of a rendering operation.
virtual Qt::BrushStyle dxfBrushStyle() const
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QList< QPolygonF > offsetLine(QPolygonF polyline, double dist, QGis::GeometryType geometryType)
calculate geometry shifted by a specified distance
virtual QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
return list of symbols used for rendering the feature.
#define DXF_HANDPLOTSTYLE
QgsMultiPoint asMultiPoint() const
return contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty list...
bool usingSymbolLevels() const
void writeFilledCircle(const QString &layer, QColor color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
void writeDouble(double d)
static double fromUnitToUnitFactor(QGis::UnitType fromUnit, QGis::UnitType toUnit)
Returns the conversion factor between the specified units.
UnitType
Map units that qgis supports.
QList< QgsSymbolV2Level > QgsSymbolV2LevelOrder
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
bool nextFeature(QgsFeature &f)
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 handle.
QgsPoint asPoint() const
return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
Represents a vector layer which manages a vector based data sets.
virtual QgsSymbolV2 * symbolForFeature(QgsFeature &feature)=0
to be overridden
QgsFeatureRequest & setFlags(Flags flags)
Set flags that affect how features will be fetched.
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
void writeMText(const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, QColor color)
Write mtext (MTEXT)
QgsFeatureRequest & setFilterRect(const QgsRectangle &rect)
Set rectangle from which features will be taken.
QString layerName(const QString &id, const QgsFeature &f) const
QgsDxfExport & operator=(const QgsDxfExport &dxfExport)
void writeText(const QString &layer, const QString &text, const QgsPoint &pt, double size, double angle, QColor color)
Write text (TEXT)