43 #define DXF_HANDSEED 100 44 #define DXF_HANDMAX 9999999 45 #define DXF_HANDPLOTSTYLE 0xf 48 int QgsDxfExport::mDxfColors[][3] =
308 const char *QgsDxfExport::mDxfEncodings[][2] =
311 {
"8859_1",
"ISO-8859-1" },
312 {
"8859_2",
"ISO-8859-2" },
313 {
"8859_3",
"ISO-8859-3" },
314 {
"8859_4",
"ISO-8859-4" },
315 {
"8859_5",
"ISO-8859-5" },
316 {
"8859_6",
"ISO-8859-6" },
317 {
"8859_7",
"ISO-8859-7" },
318 {
"8859_8",
"ISO-8859-8" },
319 {
"8859_9",
"ISO-8859-9" },
321 {
"DOS850",
"CP850" },
332 {
"MACINTOSH",
"MacRoman" },
334 {
"KSC5601",
"ksc5601.1987-0" },
336 {
"DOS866",
"CP866" },
337 {
"ANSI_1250",
"CP1250" },
338 {
"ANSI_1251",
"CP1251" },
339 {
"ANSI_1252",
"CP1252" },
340 {
"GB2312",
"GB2312" },
341 {
"ANSI_1253",
"CP1253" },
342 {
"ANSI_1254",
"CP1254" },
343 {
"ANSI_1255",
"CP1255" },
344 {
"ANSI_1256",
"CP1256" },
345 {
"ANSI_1257",
"CP1257" },
346 {
"ANSI_874",
"CP874" },
347 {
"ANSI_932",
"Shift_JIS" },
348 {
"ANSI_936",
"CP936" },
349 {
"ANSI_949",
"cp949" },
350 {
"ANSI_950",
"CP950" },
353 {
"ANSI_1258",
"CP1258" },
357 : mSymbologyScaleDenominator( 1.0 )
358 , mSymbologyExport( NoSymbology )
359 , mMapUnits(
QGis::Meters )
360 , mLayerTitleAsName( false )
361 , mSymbolLayerCounter( 0 )
374 mLayers = dxfExport.mLayers;
375 mSymbologyScaleDenominator = dxfExport.mSymbologyScaleDenominator;
376 mSymbologyExport = dxfExport.mSymbologyExport;
377 mMapUnits = dxfExport.mMapUnits;
378 mLayerTitleAsName = dxfExport.mLayerTitleAsName;
379 mSymbolLayerCounter = 0;
423 int minDist = INT_MAX;
425 for (
int i = 1; i < static_cast< int >(
sizeof( mDxfColors ) /
sizeof( *mDxfColors ) ) && minDist > 0; ++i )
427 int dist = color_distance( color.
rgba(), i );
428 if ( dist >= minDist )
435 if ( minDist == 0 && color.
alpha() == 255 && minDistAt != 7 )
442 int c = ( color.
red() & 0xff ) * 0x10000 + ( color.
green() & 0xff ) * 0x100 + ( color.
blue() & 0xff );
444 if ( transparencyCode != -1 && color.
alpha() < 255 )
463 mTextStream << s <<
'\n';
468 mTextStream << s <<
'\n';
478 if ( !d->
isOpen() && !d->
open( QIODevice::WriteOnly ) )
495 void QgsDxfExport::writeHeader(
const QString& codepage )
507 if ( !ext.isEmpty() )
546 handle = mNextHandleId++;
548 Q_ASSERT_X( handle <
DXF_HANDMAX,
"QgsDxfExport::writeHandle(int, int)",
"DXF handle too large" );
554 void QgsDxfExport::writeTables()
564 slList = symbolLayers( context );
575 writeDefaultLinetypes();
579 for ( ; slIt != slList.
constEnd(); ++slIt )
581 writeSymbolLayerLinetype( slIt->
first );
594 Q_FOREACH (
const QString& block,
QStringList() <<
"*Model_Space" <<
"*Paper_Space" <<
"*Paper_Space0" )
605 for ( ; slIt != slList.
constEnd(); ++slIt )
611 if ( hasDataDefinedProperties( ml, slIt->second ) )
713 for ( ; layerIt != mLayers.
constEnd(); ++layerIt )
715 if ( !layerIsScaleBasedVisible( layerIt->
first ) )
718 if ( layerIt->
first )
720 if ( layerIt->second < 0 )
727 layerIt->
first->uniqueValues( layerIt->second, values );
728 Q_FOREACH (
const QVariant& v, values )
779 writeGroup( 100,
"AcDbTextStyleTableRecord" );
795 void QgsDxfExport::writeBlocks()
800 Q_FOREACH (
const QString& block,
QStringList() <<
"*Model_Space" <<
"*Paper_Space" <<
"*Paper_Space0" )
826 slList = symbolLayers( ct );
830 for ( ; slIt != slList.
constEnd(); ++slIt )
841 if ( hasDataDefinedProperties( ml, slIt->second ) )
847 QString block(
QString(
"symbolLayer%1" ).arg( mBlockCounter++ ) );
848 mBlockHandle =
QString(
"%1" ).
arg( mBlockHandles[ block ], 0, 16 );
876 mPointSymbolBlocks.
insert( ml, block );
883 void QgsDxfExport::writeEntities()
888 mBlockHandle =
QString(
"%1" ).
arg( mBlockHandles[
"*Model_Space" ], 0, 16 );
902 QImage image( 10, 10, QImage::Format_ARGB32_Premultiplied );
921 for ( ; layerIt != mLayers.
constEnd(); ++layerIt )
924 if ( !vl || !layerIsScaleBasedVisible( vl ) )
941 if ( !attributes.
contains( layerAttr ) )
942 attributes << layerAttr;
946 engine.addProvider( lp );
947 if ( !lp->
prepare( ctx, attributes ) )
949 engine.removeProvider( lp );
957 writeEntitiesSymbolLevels( vl );
978 addFeature( sctx, lName,
nullptr,
nullptr );
983 if ( symbolList.
size() < 1 )
991 for ( ; symbolIt != symbolList.
end(); ++symbolIt )
993 int nSymbolLayers = ( *symbolIt )->symbolLayerCount();
994 for (
int i = 0; i < nSymbolLayers; ++i )
996 addFeature( sctx, lName, ( *symbolIt )->symbolLayer( i ), *symbolIt );
1008 addFeature( sctx, lName, s->
symbolLayer( 0 ), s );
1026 void QgsDxfExport::writeEntitiesSymbolLevels(
QgsVectorLayer* layer )
1068 if ( !featureSymbol )
1074 if ( it == features.
end() )
1078 it.
value().append( fet );
1084 for (
int i = 0; i < symbols.
count(); i++ )
1090 if ( level < 0 || level >= 1000 )
1093 while ( level >= levels.
count() )
1095 levels[level].
append( item );
1100 for (
int l = 0; l < levels.
count(); l++ )
1103 for (
int i = 0; i < level.
count(); i++ )
1107 if ( levelIt == features.
end() )
1113 int llayer = item.
layer();
1116 for ( ; featureIt != featureList.
end(); ++featureIt )
1119 addFeature( sctx, layer->
name(), levelIt.
key()->symbolLayer( llayer ), levelIt.
key() );
1126 void QgsDxfExport::writeEndFile()
1153 ACAD_MLEADERSTYLE\n\ 1161 ACAD_PLOTSETTINGS\n\ 1165 ACAD_PLOTSTYLENAME\n\ 1273 ACDBDICTIONARYWDFLT\n\ 1293 AcDbDictionaryWithDefault\n\ 1489 1.000000000000000E+20\n\ 1491 1.000000000000000E+20\n\ 1493 1.000000000000000E+20\n\ 1495 -1.000000000000000E+20\n\ 1497 -1.000000000000000E+20\n\ 1499 -1.000000000000000E+20\n\ 1761 163.1318914119703\n\ 1929 AcDbSavedByObjectVersion\n\ 2019 AcDbSavedByObjectVersion\n\ 2109 AcDbSavedByObjectVersion\n\ 2199 AcDbSavedByObjectVersion\n\ 2289 AcDbSavedByObjectVersion\n\ 2381 AcDbSavedByObjectVersion\n\ 2471 AcDbSavedByObjectVersion\n\ 2561 AcDbSavedByObjectVersion\n\ 2651 AcDbSavedByObjectVersion\n\ 2741 AcDbSavedByObjectVersion\n\ 2831 AcDbSavedByObjectVersion\n\ 2921 AcDbSavedByObjectVersion\n\ 3011 AcDbSavedByObjectVersion\n\ 3101 AcDbSavedByObjectVersion\n\ 3193 AcDbSavedByObjectVersion\n\ 3283 AcDbSavedByObjectVersion\n\ 3293 void QgsDxfExport::startSection()
3298 void QgsDxfExport::endSection()
3311 msl->
sizeUnit(), mMapUnits ) / 2.0;
3324 if ( !symbolLayer || blockIt == mPointSymbolBlocks.
constEnd() )
3328 if ( msl && symbol )
3354 int n = line.
size();
3357 QgsDebugMsg(
QString(
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3361 bool polygon = line[0] == line[ line.
size() - 1 ];
3366 QgsDebugMsg(
QString(
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3382 for (
int i = 0; i < n; i++ )
3404 for (
int i = 0; i < polygon.
size(); ++i )
3411 for (
int j = 0; j < polygon[i].
size(); ++j )
3539 while ( t.
length() > 250 )
3564 p[0].
resize( pt3 != pt4 ? 5 : 4 );
3568 if ( p[0].size() == 5 )
3575 void QgsDxfExport::writeVertex(
const QgsPoint& pt,
const QString& layer )
3590 for ( ; layerIt != mLayers.
constEnd(); ++layerIt )
3592 if ( layerIt->
first )
3596 extent = layerIt->
first->extent();
3625 penColor = colorFromSymbolLayer( symbolLayer, ctx );
3629 Qt::PenStyle penStyle( Qt::SolidLine );
3630 Qt::BrushStyle brushStyle( Qt::NoBrush );
3632 double offset = 0.0;
3633 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
3635 width = symbolLayer->
dxfWidth( *
this, ctx );
3636 offset = symbolLayer->
dxfOffset( *
this, ctx );
3644 QString lineStyleName =
"CONTINUOUS";
3647 lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
3662 for ( ; it != multiPoint.
constEnd(); ++it )
3664 writePoint( *it, layer, penColor, fet, symbolLayer, symbol );
3670 if ( penStyle != Qt::NoPen )
3678 offsetLine = nonConstGeom;
3682 if ( offsetLine != nonConstGeom )
3684 delete nonConstGeom;
3693 offsetLine = nonConstGeom;
3697 for ( ; lIt != multiLine.
constEnd(); ++lIt )
3699 writePolyline( *lIt, layer, lineStyleName, penColor, width );
3702 if ( offsetLine != nonConstGeom )
3704 delete nonConstGeom;
3711 QgsGeometry *offsetPolygon = offset == 0.0 ? nonConstGeom : nonConstGeom->
buffer( -offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3712 if ( !offsetPolygon )
3713 offsetPolygon = nonConstGeom;
3717 for ( ; polyIt != polygon.
constEnd(); ++polyIt )
3719 writePolyline( *polyIt, layer, lineStyleName, penColor, width );
3722 if ( offsetPolygon != nonConstGeom )
3723 delete offsetPolygon;
3724 delete nonConstGeom;
3731 QgsGeometry *offsetPolygon = offset == 0.0 ? nonConstGeom : nonConstGeom->
buffer( -offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3732 if ( !offsetPolygon )
3733 offsetPolygon = nonConstGeom;
3737 for ( ; mpIt != mp.
constEnd(); ++mpIt )
3740 for ( ; polyIt != mpIt->constEnd(); ++polyIt )
3742 writePolyline( *polyIt, layer, lineStyleName, penColor, width );
3746 if ( offsetPolygon != nonConstGeom )
3747 delete offsetPolygon;
3748 delete nonConstGeom;
3752 if ( brushStyle != Qt::NoBrush )
3766 for ( ; mpIt != mp.
constEnd(); ++mpIt )
3779 return symbolLayer->
dxfColor( ctx );
3784 QString lineStyleName =
"CONTINUOUS";
3787 return lineStyleName;
3791 if ( lineTypeIt != mLineStyles.
constEnd() )
3793 lineStyleName = lineTypeIt.
value();
3794 return lineStyleName;
3798 return lineNameFromPenStyle( symbolLayer->
dxfPenStyle() );
3805 int current_distance = INT_MAX;
3806 for (
int i = 1; i < static_cast< int >(
sizeof( mDxfColors ) /
sizeof( *mDxfColors ) ); ++i )
3808 int dist = color_distance( pixel, i );
3809 if ( dist < current_distance )
3811 current_distance = dist;
3820 int QgsDxfExport::color_distance( QRgb p1,
int index )
3822 if ( index > 255 || index < 0 )
3827 double redDiff = qRed( p1 ) - mDxfColors[
index][0];
3828 double greenDiff = qGreen( p1 ) - mDxfColors[
index][1];
3829 double blueDiff = qBlue( p1 ) - mDxfColors[
index][2];
3831 QgsDebugMsg(
QString(
"color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
3832 .arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
3834 .arg( mDxfColors[index][0] )
3835 .arg( mDxfColors[index][1] )
3836 .arg( mDxfColors[index][2] )
3837 .arg( redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff ) );
3839 return redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff;
3842 QRgb QgsDxfExport::createRgbEntry( qreal r, qreal g, qreal b )
3869 for ( ; lIt != mLayers.
constEnd(); ++lIt )
3888 for ( ; symbolIt != symbols.
end(); ++symbolIt )
3890 int maxSymbolLayers = ( *symbolIt )->symbolLayerCount();
3893 maxSymbolLayers = 1;
3895 for (
int i = 0; i < maxSymbolLayers; ++i )
3897 symbolLayers.
append( qMakePair(( *symbolIt )->symbolLayer( i ), *symbolIt ) );
3902 return symbolLayers;
3905 void QgsDxfExport::writeDefaultLinetypes()
3908 Q_FOREACH (
const QString& ltype,
QStringList() <<
"ByLayer" <<
"ByBlock" <<
"CONTINUOUS" )
3913 writeGroup( 100,
"AcDbLinetypeTableRecord" );
3922 double das = dashSize();
3923 double dss = dashSeparatorSize();
3924 double dos = dotSize();
3927 dashVector[0] = das;
3928 dashVector[1] = dss;
3937 dashDotVector[0] = das;
3938 dashDotVector[1] = dss;
3939 dashDotVector[2] = dos;
3940 dashDotVector[3] = dss;
3944 dashDotDotVector[0] = das;
3945 dashDotDotVector[1] = dss;
3946 dashDotDotVector[2] = dos;
3947 dashDotDotVector[3] = dss;
3948 dashDotDotVector[4] = dos;
3949 dashDotDotVector[5] = dss;
3953 void QgsDxfExport::writeSymbolLayerLinetype(
const QgsSymbolLayerV2* symbolLayer )
3962 if ( !customLinestyle.
isEmpty() )
3965 writeLinetype( name, customLinestyle, unit );
3966 mLineStyles.
insert( symbolLayer, name );
3974 for ( ; slIt != symbolLayers.constEnd(); ++slIt )
3992 for ( ; dashIt != pattern.
constEnd(); ++dashIt )
3994 length += ( *dashIt *
mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits ) );
4001 writeGroup( 100,
"AcDbLinetypeTableRecord" );
4011 for ( ; dashIt != pattern.
constEnd(); ++dashIt )
4014 double segmentLength = ( isGap ? -*dashIt : *dashIt );
4024 if ( !sl || !symbol )
4038 double QgsDxfExport::dashSize()
const 4040 double size = mSymbologyScaleDenominator * 0.002;
4041 return sizeToMapUnits( size );
4044 double QgsDxfExport::dotSize()
const 4046 double size = mSymbologyScaleDenominator * 0.0006;
4047 return sizeToMapUnits( size );
4050 double QgsDxfExport::dashSeparatorSize()
const 4052 double size = mSymbologyScaleDenominator * 0.0006;
4053 return sizeToMapUnits( size );
4056 double QgsDxfExport::sizeToMapUnits(
double s )
const 4062 QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
4070 case Qt::DashDotLine:
4072 case Qt::DashDotDotLine:
4073 return "DASHDOTDOT";
4076 return "CONTINUOUS";
4091 layerName.
replace(
'<',
'_' );
4092 layerName.
replace(
'>',
'_' );
4093 layerName.
replace(
'/',
'_' );
4094 layerName.
replace(
'\\',
'_' );
4095 layerName.
replace(
'\"',
'_' );
4096 layerName.
replace(
':',
'_' );
4097 layerName.
replace(
';',
'_' );
4098 layerName.
replace(
'?',
'_' );
4099 layerName.
replace(
'*',
'_' );
4100 layerName.
replace(
'|',
'_' );
4101 layerName.
replace(
'=',
'_' );
4102 layerName.
replace(
'\'',
'_' );
4107 bool QgsDxfExport::layerIsScaleBasedVisible(
const QgsMapLayer* layer )
const 4115 return layer->
minimumScale() < mSymbologyScaleDenominator &&
4122 for ( ; layerIt != mLayers.
constEnd(); ++layerIt )
4124 if ( layerIt->
first && layerIt->
first->id() == id )
4137 if ( name != codec )
4141 for ( i = 0; i < static_cast< int >(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) && name != mDxfEncodings[i][1]; ++i )
4144 if ( i == static_cast< int >(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) )
4147 return mDxfEncodings[i][0];
4150 return QString::null;
4159 for ( i = 0; i < static_cast< int >(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) && strcmp( codec.
data(), mDxfEncodings[i][1] ) != 0; ++i )
4162 if ( i < static_cast< int >(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) )
4163 encodings << codec.
data();
static double mapUnitScaleFactor(double scaleDenominator, QgsSymbolV2::OutputUnit symbolUnits, QGis::UnitType mapUnits)
void setCodec(QTextCodec *codec)
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)
A rectangle specified with double values.
Base class for all map layer types.
void setDotsPerMeterX(int x)
void setDotsPerMeterY(int y)
bool isEmpty() const
test if rectangle is empty.
iterator insert(const Key &key, const T &value)
OutputUnit
The unit of the output.
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)
virtual Qt::PenStyle dxfPenStyle() const
const Key key(const T &value) const
QString name() const
Get the display name of the layer.
void addLayers(const QList< QPair< QgsVectorLayer *, int > > &layers)
Add layers to export.
void writeGroup(int code, int i)
Write a tuple of group code and integer value.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QgsFields fields() const
Returns the list of fields of this layer.
void setOutputDpi(int dpi)
Set DPI used for conversion between real world units (e.g. mm) and pixels.
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.
bool useCustomDashPattern() const
QgsPolygon asPolygon() const
Return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
QGis::UnitType mapUnits() const
Retrieve map units.
const_iterator constEnd() const
void setRendererScale(double scale)
float minimumScale() const
Returns the minimum scale denominator at which the layer is visible.
#define Q_NOWARN_DEPRECATED_PUSH
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.
QString title() const
Get the title of the layer used by QGIS Server in GetCapabilities request.
static QStringList encodings()
return list of available DXF encodings
The QgsLabelingEngineV2 class provides map labeling functionality.
A geometry is the spatial representation of a feature.
const_iterator constFind(const Key &key) const
WkbType
Used for symbology operations.
QgsSymbolV2::OutputUnit sizeUnit() const
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.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
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)
double x() const
Get the x value of the point.
void writeInt(int i)
Write an integer value.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
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.
The QgsMapSettings class contains configuration for rendering of the map.
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up.
void writeString(const QString &s)
Write a string value.
int writeToFile(QIODevice *d, const QString &codec)
Export to a dxf file in the given encoding.
Perform transforms between map coordinates and device coordinates.
QgsRectangle extent() const
Get extent of area to export.
void writePoint(const QString &layer, const QColor &color, const QgsPoint &pt)
Write point.
bool exists(int i) const
Return if a field index is valid.
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
The output shall be in millimeters.
int count(const T &value) const
void combineExtentWith(QgsRectangle *rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
virtual Q_DECL_DEPRECATED QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
To be overridden.
void append(const T &value)
void setOutputSize(QSize size)
Set the size of the resulting map image.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
void setScaleFactor(double factor)
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
const QgsFeature * feature() const
Current feature being rendered - may be null.
const_iterator constEnd() const
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
void setDevice(QIODevice *device)
virtual QVector< qreal > dxfCustomDashPattern(QgsSymbolV2::OutputUnit &unit) const
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
void setMapUnits(QGis::UnitType u)
Set units of map's geographical coordinates - used for scale calculation.
float maximumScale() const
Returns the maximum scale denominator at which the layer is visible.
void writeGroupCode(int code)
Write a group code.
QString name() const
Gets the name of the field.
QString qgsDoubleToString(double a, int precision=17)
The output shall be in map unitx.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
void setPainter(QPainter *p)
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
QgsFeatureRequest & setFlags(const QgsFeatureRequest::Flags &flags)
Set flags that affect how features will be fetched.
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels.
void setFeature(const QgsFeature *f)
void writeText(const QString &layer, const QString &text, const QgsPoint &pt, double size, double angle, const QColor &color)
Write text (TEXT)
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
virtual bool hasDataDefinedProperties() const
Checks whether the layer has any associated data defined properties.
QTextCodec * codec() const
QgsGeometry * buffer(double distance, int segments) const
Returns a buffer region around this geometry having the given width and with a specified number of se...
A class to represent a point.
static QString dxfEncoding(const QString &name)
return DXF encoding for Qt encoding
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)
const T value(const Key &key) const
QByteArray toLocal8Bit() const
A class to represent a vector.
iterator find(const Key &key)
bool contains(QChar ch, Qt::CaseSensitivity cs) const
QColor fromRgbF(qreal r, qreal g, qreal b, qreal a)
int renderingPass() const
void setMapSettings(const QgsMapSettings &mapSettings)
Associate map settings instance.
QgsExpressionContext & expressionContext()
Gets the expression context.
#define Q_NOWARN_DEPRECATED_POP
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...
QString & replace(int position, int n, QChar after)
const_iterator constBegin() const
QList< QByteArray > availableCodecs()
Contains information about the context of a rendering operation.
void writeCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width)
Write circle (as polyline)
virtual Qt::BrushStyle dxfBrushStyle() const
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QString mid(int position, int n) const
virtual QColor dxfBrushColor(QgsSymbolV2RenderContext &context) const
QList< QPolygonF > offsetLine(QPolygonF polyline, double dist, QGis::GeometryType geometryType)
calculate geometry shifted by a specified distance
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
Returns list of symbols used for rendering the feature.
QgsGeometry * offsetCurve(double distance, int segments, int joinStyle, double mitreLimit) const
Returns an offset line at a given distance and side from an input line.
#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 setExtent(const QgsRectangle &rect)
Set coordinates of the rectangle which should be rendered.
void writeDouble(double d)
Write a floating point value.
virtual QColor dxfColor(QgsSymbolV2RenderContext &context) const
void setMapToPixel(const QgsMapToPixel &mtp)
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
void writePolygon(const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
bool canEncode(QChar ch) const
UnitType
Map units that qgis supports.
QString left(int n) const
double y() const
Get the y value of the point.
void registerDxfFeature(QgsFeature &feature, QgsRenderContext &context, const QString &dxfLayerName)
registration method that keeps track of DXF layer names of individual features
virtual double dxfOffset(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext *context, const QgsFeature *f, QPointF shift=QPointF(0.0, 0.0)) const
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
Implements a derived label provider internally used for DXF export.
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.
double width() const
Width of the rectangle.
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.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
double xMinimum() const
Get the x minimum value (left side of rectangle)
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
void writeMText(const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, const 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
Get layer name for feature.
QgsDxfExport & operator=(const QgsDxfExport &dxfExport)
double height() const
Height of the rectangle.
void setCrsTransformEnabled(bool enabled)
sets whether to use projections for this layer set