55 #define DXF_HANDSEED 100    56 #define DXF_HANDMAX 9999999    57 #define DXF_HANDPLOTSTYLE 0xf    60 int QgsDxfExport::mDxfColors[][3] =
   320 const char *QgsDxfExport::mDxfEncodings[][2] =
   323   { 
"8859_1", 
"ISO-8859-1" },
   324   { 
"8859_2", 
"ISO-8859-2" },
   325   { 
"8859_3", 
"ISO-8859-3" },
   326   { 
"8859_4", 
"ISO-8859-4" },
   327   { 
"8859_5", 
"ISO-8859-5" },
   328   { 
"8859_6", 
"ISO-8859-6" },
   329   { 
"8859_7", 
"ISO-8859-7" },
   330   { 
"8859_8", 
"ISO-8859-8" },
   331   { 
"8859_9", 
"ISO-8859-9" },
   333   { 
"DOS850", 
"CP850" },
   344   { 
"MACINTOSH", 
"MacRoman" },
   346   { 
"KSC5601", 
"ksc5601.1987-0" },
   348   { 
"DOS866", 
"CP866" },
   349   { 
"ANSI_1250", 
"CP1250" },
   350   { 
"ANSI_1251", 
"CP1251" },
   351   { 
"ANSI_1252", 
"CP1252" },
   352   { 
"GB2312", 
"GB2312" },
   353   { 
"ANSI_1253", 
"CP1253" },
   354   { 
"ANSI_1254", 
"CP1254" },
   355   { 
"ANSI_1255", 
"CP1255" },
   356   { 
"ANSI_1256", 
"CP1256" },
   357   { 
"ANSI_1257", 
"CP1257" },
   358   { 
"ANSI_874", 
"CP874" },
   359   { 
"ANSI_932", 
"Shift_JIS" },
   360   { 
"ANSI_936", 
"CP936" },
   361   { 
"ANSI_949", 
"cp949" },
   362   { 
"ANSI_950", 
"CP950" },
   365   { 
"ANSI_1258", 
"CP1258" },
   369     : mSymbologyScaleDenominator( 1.0 )
   370     , mSymbologyExport( NoSymbology )
   371     , mMapUnits( 
QGis::Meters )
   372     , mLayerTitleAsName( false )
   373     , mSymbolLayerCounter( 0 )
   388   mMapSettings = dxfExport.mMapSettings;
   389   mLayerNameAttribute = dxfExport.mLayerNameAttribute;
   390   mSymbologyScaleDenominator = dxfExport.mSymbologyScaleDenominator;
   391   mSymbologyExport = dxfExport.mSymbologyExport;
   392   mMapUnits = dxfExport.mMapUnits;
   393   mLayerTitleAsName = dxfExport.mLayerTitleAsName;
   394   mSymbolLayerCounter = 0; 
   407   mMapSettings = settings;
   414   mLayerNameAttribute.
clear();
   417   for ( ; layerIt != layers.
constEnd(); ++layerIt )
   419     layerList << layerIt->layer()->id();
   420     if ( layerIt->layerOutputAttributeIndex() >= 0 )
   421       mLayerNameAttribute.
insert( layerIt->layer()->id(), layerIt->layerOutputAttributeIndex() );
   449   if ( !mForce2d && !skipz )
   457   if ( !mForce2d && p.
is3D() && qIsFinite( p.
z() ) )
   464   int minDist = INT_MAX;
   466   for ( 
int i = 1; i < static_cast< int >( 
sizeof( mDxfColors ) / 
sizeof( *mDxfColors ) ) && minDist > 0; ++i )
   468     int dist = color_distance( color.
rgba(), i );
   469     if ( dist >= minDist )
   476   if ( minDist == 0 && minDistAt != 7 )
   480     if ( color.
alpha() == 255 )
   484   int c = ( color.
red() & 0xff ) * 0x10000 + ( color.
green() & 0xff ) * 0x100 + ( color.
blue() & 0xff );
   486   if ( transparencyCode != -1 && color.
alpha() < 255 )
   505   mTextStream << s << 
'\n';
   510   mTextStream << s << 
'\n';
   520   if ( !d->
isOpen() && !d->
open( QIODevice::WriteOnly ) )
   545         mExtent = layerExtent;
   571 void QgsDxfExport::writeHeader( 
const QString& codepage )
   618     handle = mNextHandleId++;
   620   Q_ASSERT_X( handle < 
DXF_HANDMAX, 
"QgsDxfExport::writeHandle(int, int)", 
"DXF handle too large" );
   626 void QgsDxfExport::writeTables()
   636     slList = symbolLayers( context );
   647   writeDefaultLinetypes();
   651   for ( ; slIt != slList.
constEnd(); ++slIt )
   653     writeSymbolLayerLinetype( slIt->
first );
   666   Q_FOREACH ( 
const QString& block, 
QStringList() << 
"*Model_Space" << 
"*Paper_Space" << 
"*Paper_Space0" )
   677   for ( ; slIt != slList.
constEnd(); ++slIt )
   683     if ( hasDataDefinedProperties( ml, slIt->second ) )
   785     if ( !vl || !layerIsScaleBasedVisible( vl ) )
   788     int attrIdx = mLayerNameAttribute.
value( vl->
id(), -1 );
   797       Q_FOREACH ( 
const QVariant& v, values )
   847   writeGroup( 100, 
"AcDbTextStyleTableRecord" );
   863 void QgsDxfExport::writeBlocks()
   868   Q_FOREACH ( 
const QString& block, 
QStringList() << 
"*Model_Space" << 
"*Paper_Space" << 
"*Paper_Space0" )
   894     slList = symbolLayers( ct );
   898   for ( ; slIt != slList.
constEnd(); ++slIt )
   909     if ( hasDataDefinedProperties( ml, slIt->second ) )
   915     QString block( 
QString( 
"symbolLayer%1" ).arg( mBlockCounter++ ) );
   916     mBlockHandle = 
QString( 
"%1" ).
arg( mBlockHandles[ block ], 0, 16 );
   944     mPointSymbolBlocks.
insert( ml, block );
   951 void QgsDxfExport::writeEntities()
   956   mBlockHandle = 
QString( 
"%1" ).
arg( mBlockHandles[ 
"*Model_Space" ], 0, 16 );
   958   QImage image( 10, 10, QImage::Format_ARGB32_Premultiplied );
   983     if ( !vl || !layerIsScaleBasedVisible( vl ) )
   989     if ( hasStyleOverride )
  1003       if ( hasStyleOverride )
  1010     int attrIdx = mLayerNameAttribute.
value( vl->
id(), -1 );
  1014       if ( !attributes.
contains( layerAttr ) )
  1015         attributes << layerAttr;
  1027       if ( !rblp->
prepare( ctx, attributes ) )
  1038       if ( !lp->
prepare( ctx, attributes ) )
  1049       writeEntitiesSymbolLevels( vl );
  1052       if ( hasStyleOverride )
  1074         addFeature( sctx, ct, lName, 
nullptr, 
nullptr ); 
  1079         bool hasSymbology = symbolList.
size() > 0;
  1084           for ( ; symbolIt != symbolList.
end(); ++symbolIt )
  1086             int nSymbolLayers = ( *symbolIt )->symbolLayerCount();
  1087             for ( 
int i = 0; i < nSymbolLayers; ++i )
  1095               bool isGeometryGenerator = ( sl->
layerType() == 
"GeometryGenerator" );
  1097               if ( isGeometryGenerator )
  1099                 addGeometryGeneratorSymbolLayer( sctx, ct, lName, sl, 
true );
  1103                 addFeature( sctx, ct, lName, sl, *symbolIt );
  1108         else if ( hasSymbology )
  1119             addGeometryGeneratorSymbolLayer( sctx, ct, lName, s->
symbolLayer( 0 ), false );
  1123             addFeature( sctx, ct, lName, s->
symbolLayer( 0 ), s );
  1140     if ( hasStyleOverride )
  1149 void QgsDxfExport::writeEntitiesSymbolLevels( 
QgsVectorLayer* layer )
  1190     if ( !featureSymbol )
  1196     if ( it == features.
end() )
  1200     it.
value().append( fet );
  1206   for ( 
int i = 0; i < symbols.
count(); i++ )
  1212       if ( level < 0 || level >= 1000 ) 
  1215       while ( level >= levels.
count() ) 
  1217       levels[level].
append( item );
  1224   for ( 
int l = 0; l < levels.
count(); l++ )
  1227     for ( 
int i = 0; i < level.
count(); i++ )
  1231       if ( levelIt == features.
end() )
  1237       int llayer = item.
layer();
  1240       for ( ; featureIt != featureList.
end(); ++featureIt )
  1243         addFeature( sctx, ct, layer->
name(), levelIt.
key()->symbolLayer( llayer ), levelIt.
key() );
  1250 void QgsDxfExport::writeEndFile()
  1277 ACAD_MLEADERSTYLE\n\  1285 ACAD_PLOTSETTINGS\n\  1289 ACAD_PLOTSTYLENAME\n\  1397 ACDBDICTIONARYWDFLT\n\  1417 AcDbDictionaryWithDefault\n\  1613 1.000000000000000E+20\n\  1615 1.000000000000000E+20\n\  1617 1.000000000000000E+20\n\  1619 -1.000000000000000E+20\n\  1621 -1.000000000000000E+20\n\  1623 -1.000000000000000E+20\n\  1885 163.1318914119703\n\  2053 AcDbSavedByObjectVersion\n\  2143 AcDbSavedByObjectVersion\n\  2233 AcDbSavedByObjectVersion\n\  2323 AcDbSavedByObjectVersion\n\  2413 AcDbSavedByObjectVersion\n\  2505 AcDbSavedByObjectVersion\n\  2595 AcDbSavedByObjectVersion\n\  2685 AcDbSavedByObjectVersion\n\  2775 AcDbSavedByObjectVersion\n\  2865 AcDbSavedByObjectVersion\n\  2955 AcDbSavedByObjectVersion\n\  3045 AcDbSavedByObjectVersion\n\  3135 AcDbSavedByObjectVersion\n\  3225 AcDbSavedByObjectVersion\n\  3317 AcDbSavedByObjectVersion\n\  3407 AcDbSavedByObjectVersion\n\  3417 void QgsDxfExport::startSection()
  3422 void QgsDxfExport::endSection()
  3435                       msl->
sizeUnit(), mMapUnits ) / 2.0;
  3448   if ( !symbolLayer || blockIt == mPointSymbolBlocks.
constEnd() )
  3452     if ( msl && symbol )
  3478   Q_FOREACH ( 
const QgsPoint& p, line )
  3485   int n = line.
size();
  3488     QgsDebugMsg( 
QString( 
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
  3492   bool polygon = line[0] == line[ line.
size() - 1 ];
  3497     QgsDebugMsg( 
QString( 
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
  3501   if ( mForce2d || !line.
at( 0 ).is3D() )
  3515     for ( 
int i = 0; i < n; i++ )
  3531     for ( 
int i = 0; i < n; i++ )
  3588   for ( 
int i = 0; i < polygon.
size(); ++i )
  3595     for ( 
int j = 0; j < polygon[i].
size(); ++j )
  3748   while ( t.
length() > 250 )
  3774     p << QgsPointV2( pt3 );
  3775   p << QgsPointV2( pt1 );
  3791     geom->transform( *ct );
  3800     penColor = colorFromSymbolLayer( symbolLayer, ctx );
  3804   Qt::PenStyle penStyle( Qt::SolidLine );
  3805   Qt::BrushStyle brushStyle( Qt::NoBrush );
  3807   double offset = 0.0;
  3809   if ( mSymbologyExport != 
NoSymbology && symbolLayer )
  3811     width = symbolLayer->
dxfWidth( *
this, ctx );
  3812     offset = symbolLayer->
dxfOffset( *
this, ctx );
  3813     angle = symbolLayer->
dxfAngle( ctx );
  3821   QString lineStyleName = 
"CONTINUOUS";
  3824     lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
  3830     writePoint( geom->coordinateSequence().at( 0 ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol, 
angle );
  3837     for ( 
int i = 0; i < cs.
size(); i++ )
  3839       writePoint( cs.
at( i ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol, 
angle );
  3844   if ( penStyle != Qt::NoPen )
  3860           if ( tempGeom != geom.data() )
  3862           tempGeom = geos.
offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 );
  3864             tempGeom = geom.data();
  3881           if ( tempGeom != geom.data() )
  3883           tempGeom = geos.
offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 );
  3885             tempGeom = geom.data();
  3889         for ( 
int i = 0; i < cs.
size(); i++ )
  3891           writePolyline( cs.
at( i ).at( 0 ), layer, lineStyleName, penColor, width );
  3907           if ( tempGeom != geom.data() )
  3909           tempGeom = geos.
buffer( offset, 0,  GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
  3911             tempGeom = geom.data();
  3915         for ( 
int i = 0; i < cs.
at( 0 ).size(); i++ )
  3917           writePolyline( cs.
at( 0 ).at( i ), layer, lineStyleName, penColor, width );
  3928           if ( tempGeom != geom.data() )
  3930           tempGeom = geos.
buffer( offset, 0,  GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
  3932             tempGeom = geom.data();
  3936         for ( 
int i = 0; i < cs.
size(); i++ )
  3937           for ( 
int j = 0; j < cs.
at( i ).size(); j++ )
  3938             writePolyline( cs.
at( i ).at( j ), layer, lineStyleName, penColor, width );
  3947     if ( tempGeom != geom.data() )
  3951   if ( brushStyle != Qt::NoBrush )
  3969         for ( 
int i = 0; i < cs.
size(); i++ )
  3981     if ( tempGeom != geom.data() )
  4004   geomExpr.
prepare( &expressionContext );
  4017     symbolExpressionContextScope->
setFeature( f );
  4022     for ( 
int i = 0; i < nSymbolLayers; ++i )
  4024       addFeature( ctx, ct, layer, symbol->
symbolLayer( i ), symbol );
  4036   return symbolLayer->
dxfColor( ctx );
  4041   QString lineStyleName = 
"CONTINUOUS";
  4044     return lineStyleName;
  4048   if ( lineTypeIt != mLineStyles.
constEnd() )
  4050     lineStyleName = lineTypeIt.
value();
  4051     return lineStyleName;
  4055     return lineNameFromPenStyle( symbolLayer->
dxfPenStyle() );
  4062   int current_distance = INT_MAX;
  4063   for ( 
int i = 1; i < static_cast< int >( 
sizeof( mDxfColors ) / 
sizeof( *mDxfColors ) ); ++i )
  4065     int dist = color_distance( pixel, i );
  4066     if ( dist < current_distance )
  4068       current_distance = dist;
  4077 int QgsDxfExport::color_distance( QRgb p1, 
int index )
  4079   if ( index > 255 || index < 0 )
  4084   double redDiff = qRed( p1 ) - mDxfColors[
index][0];
  4085   double greenDiff = qGreen( p1 ) - mDxfColors[
index][1];
  4086   double blueDiff = qBlue( p1 ) - mDxfColors[
index][2];
  4088   QgsDebugMsg( 
QString( 
"color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
  4089                .arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
  4091                .arg( mDxfColors[index][0] )
  4092                .arg( mDxfColors[index][1] )
  4093                .arg( mDxfColors[index][2] )
  4094                .arg( redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff ) );
  4096   return redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff;
  4099 QRgb QgsDxfExport::createRgbEntry( qreal r, qreal g, qreal b )
  4123     return mapUnitsPerPixel;
  4137   double minSizeMU = -DBL_MAX;
  4140     minSizeMU = scale.
minSizeMM * pixelToMMFactor * mapUnitsPerPixel;
  4144     minSizeMU = qMax( minSizeMU, value );
  4146   value = qMax( value, minSizeMU );
  4148   double maxSizeMU = DBL_MAX;
  4151     maxSizeMU = scale.
maxSizeMM * pixelToMMFactor * mapUnitsPerPixel;
  4155     maxSizeMU = qMin( maxSizeMU, value );
  4157   value = qMin( value, maxSizeMU );
  4182     for ( ; symbolIt != symbols.
end(); ++symbolIt )
  4184       int maxSymbolLayers = ( *symbolIt )->symbolLayerCount();
  4187         maxSymbolLayers = 1;
  4189       for ( 
int i = 0; i < maxSymbolLayers; ++i )
  4191         symbolLayers.
append( qMakePair(( *symbolIt )->symbolLayer( i ), *symbolIt ) );
  4196   return symbolLayers;
  4199 void QgsDxfExport::writeDefaultLinetypes()
  4202   Q_FOREACH ( 
const QString& ltype, 
QStringList() << 
"ByLayer" << 
"ByBlock" << 
"CONTINUOUS" )
  4207     writeGroup( 100, 
"AcDbLinetypeTableRecord" );
  4216   double das = dashSize();
  4217   double dss = dashSeparatorSize();
  4218   double dos = dotSize();
  4221   dashVector[0] = das;
  4222   dashVector[1] = dss;
  4231   dashDotVector[0] = das;
  4232   dashDotVector[1] = dss;
  4233   dashDotVector[2] = dos;
  4234   dashDotVector[3] = dss;
  4238   dashDotDotVector[0] = das;
  4239   dashDotDotVector[1] = dss;
  4240   dashDotDotVector[2] = dos;
  4241   dashDotDotVector[3] = dss;
  4242   dashDotDotVector[4] = dos;
  4243   dashDotDotVector[5] = dss;
  4247 void QgsDxfExport::writeSymbolLayerLinetype( 
const QgsSymbolLayerV2* symbolLayer )
  4256   if ( !customLinestyle.
isEmpty() )
  4259     writeLinetype( name, customLinestyle, unit );
  4260     mLineStyles.
insert( symbolLayer, name );
  4268   for ( ; slIt != symbolLayers.constEnd(); ++slIt )
  4286   for ( ; dashIt != pattern.
constEnd(); ++dashIt )
  4295   writeGroup( 100, 
"AcDbLinetypeTableRecord" );
  4305   for ( ; dashIt != pattern.
constEnd(); ++dashIt )
  4308     double segmentLength = ( isGap ? -*dashIt : *dashIt );
  4318   if ( !sl || !symbol )
  4332 double QgsDxfExport::dashSize()
 const  4334   double size = mSymbologyScaleDenominator * 0.002;
  4335   return sizeToMapUnits( size );
  4338 double QgsDxfExport::dotSize()
 const  4340   double size = mSymbologyScaleDenominator * 0.0006;
  4341   return sizeToMapUnits( size );
  4344 double QgsDxfExport::dashSeparatorSize()
 const  4346   double size = mSymbologyScaleDenominator * 0.0006;
  4347   return sizeToMapUnits( size );
  4350 double QgsDxfExport::sizeToMapUnits( 
double s )
 const  4356 QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
  4364     case Qt::DashDotLine:
  4366     case Qt::DashDotDotLine:
  4367       return "DASHDOTDOT";
  4370       return "CONTINUOUS";
  4385   layerName.
replace( 
'<', 
'_' );
  4386   layerName.
replace( 
'>', 
'_' );
  4387   layerName.
replace( 
'/', 
'_' );
  4388   layerName.
replace( 
'\\', 
'_' );
  4389   layerName.
replace( 
'\"', 
'_' );
  4390   layerName.
replace( 
':', 
'_' );
  4391   layerName.
replace( 
';', 
'_' );
  4392   layerName.
replace( 
'?', 
'_' );
  4393   layerName.
replace( 
'*', 
'_' );
  4394   layerName.
replace( 
'|', 
'_' );
  4395   layerName.
replace( 
'=', 
'_' );
  4396   layerName.
replace( 
'\'', 
'_' );
  4399   layerName.
replace( 
"\r\n", 
"_" );
  4400   layerName.
replace( 
'\r', 
'_' );
  4401   layerName.
replace( 
'\n', 
'_' );
  4406 bool QgsDxfExport::layerIsScaleBasedVisible( 
const QgsMapLayer* layer )
 const  4422     if ( vl && vl->
id() == id )
  4424       int attrIdx = mLayerNameAttribute.
value( vl->
id(), -1 );
  4436     if ( name != codec )
  4440     for ( i = 0; i < static_cast< int >( 
sizeof( mDxfEncodings ) / 
sizeof( *mDxfEncodings ) ) && name != mDxfEncodings[i][1]; ++i )
  4443     if ( i == static_cast< int >( 
sizeof( mDxfEncodings ) / 
sizeof( *mDxfEncodings ) ) )
  4446     return mDxfEncodings[i][0];
  4449   return QString::null;
  4458     for ( i = 0; i < static_cast< int >( 
sizeof( mDxfEncodings ) / 
sizeof( *mDxfEncodings ) ) && strcmp( codec.
data(), mDxfEncodings[i][1] ) != 0; ++i )
  4461     if ( i < static_cast< int >( 
sizeof( mDxfEncodings ) / 
sizeof( *mDxfEncodings ) ) )
  4462       encodings << codec.
data();
  4475   Q_UNUSED( context );
  4532   QString dxfLayer = mDxfLayerNames[layerId][fid];
  4539     bool prependSymb = 
false;
  4557         prependSymb = 
false;
  4565       symb = symb + wrapchr;
  4569       prependSymb = 
false;
  4570       symb = wrapchr + symb;
  4583   txt = txt.
replace( wrapchr, 
"\\P" );
  4609   double maxAscent = -textBoundingRect.
y();
  4610   double maxDescent = textBoundingRect.
height() - maxAscent;
  4618   double labelY = label->
getY();
  4620   int nLines = txt.
count( 
"\\P" ) + 1;
  4629   if ( !mDxfLayerNames.
contains( layerId ) )
  4632   mDxfLayerNames[layerId][fid] = 
layerName;
 bool restoreOverrideStyle()
Restore the original store after a call to setOverrideStyle() 
 
void setDestinationCrs(long crs)
Set destination CRS. 
 
void setCodec(QTextCodec *codec)
 
static double mapUnitScaleFactor(double scaleDenominator, QgsSymbolV2::OutputUnit symbolUnits, QGis::UnitType mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units. 
 
Class for parsing and evaluation of expressions (formerly called "search strings"). 
 
Wrapper for iterator of features from vector data provider or vector layer. 
 
Q_DECL_DEPRECATED void writeSolid(const QString &layer, const QColor &color, const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, const QgsPoint &pt4)
Draw dxf filled polygon (SOLID) 
 
QString labelText() const
Text of the label. 
 
virtual Qt::BrushStyle dxfBrushStyle() const
get brush/fill style 
 
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system 
 
A rectangle specified with double values. 
 
Base class for all map layer types. 
 
void setDotsPerMeterX(int x)
 
void setDotsPerMeterY(int y)
 
void setExtent(const QgsRectangle &rect, bool magnified=true)
Set coordinates of the rectangle which should be rendered. 
 
QGis::WkbType wkbType() const
Returns the WKBType or WKBUnknown in case of error. 
 
double minSizeMM
The minimum size in millimeters, or 0.0 if unset. 
 
QgsPoint center() const
Center point of the rectangle. 
 
QString & append(QChar ch)
 
QString leftDirectionSymbol
 
iterator insert(const Key &key, const T &value)
 
OutputUnit
The unit of the output. 
 
Q_DECL_DEPRECATED 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. 
 
static void dataDefinedTextStyle(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
 
bool contains(const Key &key) const
 
QgsFeatureId featureId() const
Returns the unique ID of the feature. 
 
const Key key(const T &value) const
 
QRectF tightBoundingRect(const QString &text) const
 
virtual QgsCoordinateSequenceV2 coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes. 
 
virtual Qt::PenStyle dxfPenStyle() const
get pen style 
 
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames) override
Prepare for registration of features. 
 
QgsLabelFeature * feature()
Returns the parent feature. 
 
virtual QColor dxfColor(QgsSymbolV2RenderContext &context) const
get color 
 
rendering with symbol levels (i.e. implements symbols(), symbolForFeature()) 
 
void writeGroup(int code, int i)
Write a tuple of group code and integer value. 
 
QgsSymbolV2::OutputUnit sizeUnit() const
Returns the units for the symbol's size. 
 
Q_DECL_DEPRECATED bool prepare(const QgsFields &fields)
Get the expression ready for evaluation - find out column indexes. 
 
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. 
 
double size() const
Returns the symbol size. 
 
void uniqueValues(int index, QList< QVariant > &uniqueValues, int limit=-1)
Calculates a list of unique values contained within an attribute in the layer. 
 
QgsMapLayer * mapLayer(const QString &theLayerId) const
Retrieve a pointer to a registered layer by layer ID. 
 
double getY(int i=0) const
get the down-left y coordinate 
 
QString & prepend(QChar ch)
 
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request. 
 
Implements a derived label provider for rule based labels internally used for DXF export...
 
void addProvider(QgsAbstractLabelProvider *provider)
Add provider of label features. Takes ownership of the provider. 
 
const_iterator constEnd() const
 
The output shall be in pixels. 
 
void setRendererScale(double scale)
 
const T & at(int i) const
 
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > & dataDefinedValues() const
Get data-defined values. 
 
void setOutputDpi(double dpi)
Set DPI used for conversion between real world units (e.g. mm) and pixels. 
 
virtual QColor dxfBrushColor(QgsSymbolV2RenderContext &context) const
get brush/fill color 
 
bool contains(const QString &str, Qt::CaseSensitivity cs) const
 
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. 
 
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set 
 
virtual bool hasDataDefinedProperties() const
Checks whether the layer has any associated data defined properties. 
 
Class that adds extra information to QgsLabelFeature for text labels. 
 
static QStringList encodings()
return list of available DXF encodings 
 
The QgsLabelingEngineV2 class provides map labeling functionality. 
 
Abstract base class for all geometries. 
 
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale. 
 
void registerDxfFeature(QgsFeature &feature, QgsRenderContext &context, const QString &dxfLayerName)
Registration method that keeps track of DXF layer names of individual features. 
 
A geometry is the spatial representation of a feature. 
 
bool drawLabels
Whether to draw labels for this layer. 
 
const_iterator constFind(const Key &key) const
 
qreal lineSpacing() const
 
virtual QgsSymbolV2 * subSymbol() override
 
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature. 
 
const QgsFeature * feature() const
Current feature being rendered - may be null. 
 
MultiLineAlign multilineAlign
 
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF 
 
QGis::UnitType mapUnits() const
Retrieve map units. 
 
The QGis class provides global constants for use throughout the application. 
 
virtual QList< QString > usedAttributes()=0
Returns a set of attributes required for this renderer. 
 
FeaturePart * getFeaturePart()
return the feature corresponding to this labelposition 
 
void readSettingsFromProject()
Read configuration of the labeling engine from the current project file. 
 
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
 
double z() const
Returns the point's z-coordinate. 
 
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
 
double y() const
Returns the point's y-coordinate. 
 
void setLayers(const QStringList &layers)
Set list of layer IDs for map rendering. 
 
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features. 
 
void setExtent(const QgsRectangle &extent)
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference) 
 
bool reverseDirectionSymbol
 
double maxScale
The maximum scale, or 0.0 if unset. 
 
void writeInt(int i)
Write an integer value. 
 
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1) 
 
bool minSizeMMEnabled
Whether the minimum size in mm should be respected. 
 
double y() const
Get the y value of the point. 
 
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started. 
 
QgsFields fields() const
Returns the list of fields of this layer. 
 
The QgsMapSettings class contains configuration for rendering of the map. 
 
QString styleName() const
 
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up. 
 
QgsMapLayerStyleManager * styleManager() const
Get access to the layer's style manager. 
 
void removeProvider(QgsAbstractLabelProvider *provider)
Remove provider if the provider's initialization failed. Provider instance is deleted. 
 
void setMapSettings(const QgsMapSettings &settings)
Set map settings and assign layer name attributes. 
 
void writeString(const QString &s)
Write a string value. 
 
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. 
 
int renderingPass() const
 
Perform transforms between map coordinates and device coordinates. 
 
Q_DECL_DEPRECATED void writePoint(const QString &layer, const QColor &color, const QgsPoint &pt)
Write point. 
 
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object. 
 
QgsFeatureRendererV2 * rendererV2()
Return renderer V2. 
 
The output shall be in millimeters. 
 
int count(const T &value) const
 
virtual Q_DECL_DEPRECATED QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
To be overridden. 
 
void append(const T &value)
 
void drawLabel(QString layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings)
Output the label. 
 
void setOutputSize(QSize size)
Set the size of the resulting map image. 
 
static void dataDefinedTextBuffer(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
 
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
 
void setScaleFactor(double factor)
 
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry. 
 
QgsRectangle extent() override
Return the extent of the layer. 
 
const_iterator constEnd() const
 
long destinationCrs()
Set destination CRS. 
 
void setDevice(QIODevice *device)
 
#define QgsDebugMsgLevel(str, level)
 
bool isEmpty() const
test if rectangle is empty. 
 
void setMapUnits(QGis::UnitType u)
Set units of map's geographical coordinates - used for scale calculation. 
 
void writeGroupCode(int code)
Write a group code. 
 
double width() const
Width of the rectangle. 
 
Point geometry type, with support for z-dimension and m-values. 
 
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...
 
virtual QgsAbstractGeometryV2 * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves. 
 
The output shall be in map unitx. 
 
This class wraps a request for features to a vector layer (or directly its vector data provider)...
 
bool useCustomDashPattern() const
 
Quadrant getQuadrant() const
 
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol. 
 
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
 
void setPainter(QPainter *p)
 
double x() const
Returns the point's x-coordinate. 
 
Q_DECL_DEPRECATED void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch) 
 
QgsFeatureRequest & setFlags(const QgsFeatureRequest::Flags &flags)
Set flags that affect how features will be fetched. 
 
virtual QVector< qreal > dxfCustomDashPattern(QgsSymbolV2::OutputUnit &unit) const
get dash pattern 
 
bool usingSymbolLevels() const
 
const QgsCoordinateTransform * layerTransform(QgsMapLayer *layer) const
Return coordinate transform from layer's CRS to destination CRS. 
 
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration. 
 
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels. 
 
void setFeature(const QgsFeature *f)
 
Single scope for storing variables and functions for use within a QgsExpressionContext. 
 
double mapUnitsPerPixel() const
Return 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*...
 
Q_DECL_DEPRECATED void writeText(const QString &layer, const QString &text, const QgsPoint &pt, double size, double angle, const QColor &color)
Write text (TEXT) 
 
QTextCodec * codec() const
 
A class to represent a point. 
 
const QgsMapToPixel & mapToPixel() const
 
static QString dxfEncoding(const QString &name)
return DXF encoding for Qt encoding 
 
QList< QgsPointSequenceV2 > QgsRingSequenceV2
 
Q_DECL_DEPRECATED void writePolyline(const QgsPolyline &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE) 
 
static double fromUnitToUnitFactor(QGis::UnitType fromUnit, QGis::UnitType toUnit)
Returns the conversion factor between the specified distance units. 
 
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) 
 
QString layerName(const QString &id, const QgsFeature &f) const
Get layer name for feature. 
 
const T value(const Key &key) const
 
QByteArray toLocal8Bit() const
 
iterator find(const Key &key)
 
QString title() const
Get the title of the layer used by QGIS Server in GetCapabilities request. 
 
bool contains(QChar ch, Qt::CaseSensitivity cs) const
 
QColor fromRgbF(qreal r, qreal g, qreal b, qreal a)
 
void setMapSettings(const QgsMapSettings &mapSettings)
Associate map settings instance. 
 
virtual QString layerType() const =0
Returns a string that represents this layer type. 
 
double yMinimum() const
Get the y minimum value (bottom side of rectangle) 
 
virtual double dxfOffset(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const
get offset 
 
QgsExpressionContext & expressionContext()
Gets the expression context. 
 
void run(QgsRenderContext &context)
compute the labeling with given map settings and providers 
 
double xMaximum() const
Get the x maximum value (right side of rectangle) 
 
void combineExtentWith(const QgsRectangle &rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
 
void startRender(QgsSymbolV2RenderContext &context) override
 
static QString dxfLayerName(const QString &name)
Return cleaned layer name for use in DXF. 
 
QString rightDirectionSymbol
 
QString & replace(int position, int n, QChar after)
 
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
 
const_iterator constBegin() const
 
QgsExpressionContextScope * expressionContextScope()
This scope is always available when a symbol of this type is being rendered. 
 
QList< QByteArray > availableCodecs()
 
Contains information about the context of a rendering operation. 
 
Q_DECL_DEPRECATED 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...
 
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call. 
 
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store. 
 
QgsPoint layerToMapCoordinates(QgsMapLayer *theLayer, QgsPoint point) const
transform point coordinates from layer's CRS to output CRS 
 
const QgsMapToPixel & mapToPixel() const
 
QString mid(int position, int n) const
 
double maxSizeMM
The maximum size in millimeters, or 0.0 if unset. 
 
double getAlpha() const
get alpha 
 
Struct for storing maximum and minimum scales for measurements in map units. 
 
QgsPoint mapToLayerCoordinates(QgsMapLayer *theLayer, QgsPoint point) const
transform point coordinates from output CRS to layer's CRS 
 
double getX(int i=0) const
get the down-left x coordinate 
 
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
Returns list of symbols used for rendering the feature. 
 
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const
get line width 
 
#define DXF_HANDPLOTSTYLE
 
QgsRenderContext & renderContext()
 
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context. 
 
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...
 
Q_DECL_DEPRECATED void writePolygon(const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH) 
 
LabelPosition is a candidate feature label position. 
 
bool canEncode(QChar ch) const
 
UnitType
Map units that qgis supports. 
 
double xMinimum() const
Get the x minimum value (left side of rectangle) 
 
QString left(int n) const
 
void registerDxfFeature(QgsFeature &feature, QgsRenderContext &context, const QString &dxfLayerName)
Registration method that keeps track of DXF layer names of individual features. 
 
virtual double dxfAngle(QgsSymbolV2RenderContext &context) const
get angle 
 
static Type flatType(Type type)
Returns the flat type for a WKB type. 
 
double yMaximum() const
Get the y maximum value (top side of rectangle) 
 
QString name
Read property of QString layerName. 
 
Abstract base class for marker symbol layers. 
 
bool setOverrideStyle(const QString &styleDef)
Temporarily apply a different style to the layer. 
 
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
 
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol. 
 
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer. 
 
const_iterator constEnd() const
 
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer 
 
bool nextFeature(QgsFeature &f)
 
const_iterator constBegin() const
 
QStringList layers() const
Get list of layer IDs for map rendering The layers are stored in the reverse order of how they are re...
 
Implements a derived label provider internally used for DXF export. 
 
virtual QgsAbstractGeometryV2 * clone() const =0
Clones the geometry by performing a deep copy. 
 
QFontMetricsF * labelFontMetrics()
Metrics of the font for 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. 
 
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. 
 
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
 
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
 
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected. 
 
static QgsCRSCache * instance()
Returns a pointer to the QgsCRSCache singleton. 
 
QgsAbstractGeometryV2 * offsetCurve(double distance, int segments, int joinStyle, double mitreLimit, QString *errorMsg=nullptr) const override
 
Q_DECL_DEPRECATED 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. 
 
QgsFeatureRequest & setFilterRect(const QgsRectangle &rect)
Set rectangle from which features will be taken. 
 
QgsSymbolV2RenderContext * symbolRenderContext()
Returns the symbol render context. 
 
double x() const
Get the x value of the point. 
 
QgsDxfExport & operator=(const QgsDxfExport &dxfExport)
 
bool is3D() const
Returns true if the geometry is 3D and contains a z-value. 
 
void registerDxfLayer(QString layerId, QgsFeatureId fid, QString layer)
Register name of layer for feature. 
 
QgsAbstractGeometryV2 * buffer(double distance, int segments, QString *errorMsg=nullptr) const override
 
double height() const
Height of the rectangle. 
 
QList< QgsPointV2 > QgsPointSequenceV2
 
void setCrsTransformEnabled(bool enabled)
sets whether to use projections for this layer set 
 
const T value(const Key &key) const
 
DirectionSymbols placeDirectionSymbol
 
QString geometryExpression() const
Get the expression to generate this geometry. 
 
static void dataDefinedTextFormatting(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)