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 )
460 mTextStream << s <<
"\n";
465 mTextStream << s <<
"\n";
475 if ( !d->
isOpen() && !d->
open( QIODevice::WriteOnly ) )
492 void QgsDxfExport::writeHeader(
const QString& codepage )
504 if ( !ext.isEmpty() )
543 handle = mNextHandleId++;
545 Q_ASSERT_X( handle <
DXF_HANDMAX,
"QgsDxfExport::writeHandle(int, int)",
"DXF handle too large" );
551 void QgsDxfExport::writeTables()
561 slList = symbolLayers( context );
572 writeDefaultLinetypes();
576 for ( ; slIt != slList.
constEnd(); ++slIt )
578 writeSymbolLayerLinetype( slIt->
first );
591 Q_FOREACH (
const QString& block,
QStringList() <<
"*Model_Space" <<
"*Paper_Space" <<
"*Paper_Space0" )
602 for ( ; slIt != slList.
constEnd(); ++slIt )
608 if ( hasDataDefinedProperties( ml, slIt->second ) )
710 for ( ; layerIt != mLayers.
constEnd(); ++layerIt )
712 if ( !layerIsScaleBasedVisible( layerIt->
first ) )
715 if ( layerIt->
first )
717 if ( layerIt->second < 0 )
724 layerIt->
first->uniqueValues( layerIt->second, values );
725 Q_FOREACH (
const QVariant& v, values )
776 writeGroup( 100,
"AcDbTextStyleTableRecord" );
792 void QgsDxfExport::writeBlocks()
797 Q_FOREACH (
const QString& block,
QStringList() <<
"*Model_Space" <<
"*Paper_Space" <<
"*Paper_Space0" )
823 slList = symbolLayers( ct );
827 for ( ; slIt != slList.
constEnd(); ++slIt )
838 if ( hasDataDefinedProperties( ml, slIt->second ) )
844 QString block(
QString(
"symbolLayer%1" ).arg( mBlockCounter++ ) );
845 mBlockHandle =
QString(
"%1" ).
arg( mBlockHandles[ block ], 0, 16 );
873 mPointSymbolBlocks.
insert( ml, block );
880 void QgsDxfExport::writeEntities()
885 mBlockHandle =
QString(
"%1" ).
arg( mBlockHandles[
"*Model_Space" ], 0, 16 );
899 QImage image( 10, 10, QImage::Format_ARGB32_Premultiplied );
900 image.setDotsPerMeterX( 96 / 25.4 * 1000 );
901 image.setDotsPerMeterY( 96 / 25.4 * 1000 );
918 for ( ; layerIt != mLayers.
end(); ++layerIt )
921 if ( !vl || !layerIsScaleBasedVisible( vl ) )
938 if ( !attributes.
contains( layerAttr ) )
939 attributes << layerAttr;
943 engine.addProvider( lp );
944 if ( !lp->
prepare( ctx, attributes ) )
946 engine.removeProvider( lp );
954 writeEntitiesSymbolLevels( vl );
972 sctx.setFeature( &fet );
980 if ( symbolList.
size() < 1 )
988 for ( ; symbolIt != symbolList.
end(); ++symbolIt )
990 int nSymbolLayers = ( *symbolIt )->symbolLayerCount();
991 for (
int i = 0; i < nSymbolLayers; ++i )
993 addFeature( sctx,
layerName, ( *symbolIt )->symbolLayer( i ), *symbolIt );
1023 void QgsDxfExport::writeEntitiesSymbolLevels(
QgsVectorLayer* layer )
1065 if ( !featureSymbol )
1071 if ( it == features.
end() )
1075 it.
value().append( fet );
1081 for (
int i = 0; i < symbols.
count(); i++ )
1087 if ( level < 0 || level >= 1000 )
1090 while ( level >= levels.
count() )
1092 levels[level].
append( item );
1097 for (
int l = 0; l < levels.
count(); l++ )
1100 for (
int i = 0; i < level.
count(); i++ )
1104 if ( levelIt == features.
end() )
1110 int llayer = item.
layer();
1113 for ( ; featureIt != featureList.
end(); ++featureIt )
1115 sctx.setFeature( &*featureIt );
1116 addFeature( sctx, layer->
name(), levelIt.
key()->symbolLayer( llayer ), levelIt.
key() );
1123 void QgsDxfExport::writeEndFile()
1150 ACAD_MLEADERSTYLE\n\
1158 ACAD_PLOTSETTINGS\n\
1162 ACAD_PLOTSTYLENAME\n\
1270 ACDBDICTIONARYWDFLT\n\
1290 AcDbDictionaryWithDefault\n\
1486 1.000000000000000E+20\n\
1488 1.000000000000000E+20\n\
1490 1.000000000000000E+20\n\
1492 -1.000000000000000E+20\n\
1494 -1.000000000000000E+20\n\
1496 -1.000000000000000E+20\n\
1758 163.1318914119703\n\
1926 AcDbSavedByObjectVersion\n\
2016 AcDbSavedByObjectVersion\n\
2106 AcDbSavedByObjectVersion\n\
2196 AcDbSavedByObjectVersion\n\
2286 AcDbSavedByObjectVersion\n\
2378 AcDbSavedByObjectVersion\n\
2468 AcDbSavedByObjectVersion\n\
2558 AcDbSavedByObjectVersion\n\
2648 AcDbSavedByObjectVersion\n\
2738 AcDbSavedByObjectVersion\n\
2828 AcDbSavedByObjectVersion\n\
2918 AcDbSavedByObjectVersion\n\
3008 AcDbSavedByObjectVersion\n\
3098 AcDbSavedByObjectVersion\n\
3190 AcDbSavedByObjectVersion\n\
3280 AcDbSavedByObjectVersion\n\
3290 void QgsDxfExport::startSection()
3295 void QgsDxfExport::endSection()
3308 msl->
sizeUnit(), mMapUnits ) / 2.0;
3321 if ( !symbolLayer || blockIt == mPointSymbolBlocks.
constEnd() )
3325 if ( msl && symbol )
3351 int n = line.
size();
3354 QgsDebugMsg(
QString(
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3358 bool polygon = line[0] == line[ line.
size() - 1 ];
3363 QgsDebugMsg(
QString(
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3379 for (
int i = 0; i < n; i++ )
3401 for (
int i = 0; i < polygon.
size(); ++i )
3408 for (
int j = 0; j < polygon[i].
size(); ++j )
3536 while ( t.
length() > 250 )
3561 p[0].
resize( pt3 != pt4 ? 5 : 4 );
3565 if ( p[0].size() == 5 )
3572 void QgsDxfExport::writeVertex(
const QgsPoint& pt,
const QString& layer )
3587 for ( ; layerIt != mLayers.
constEnd(); ++layerIt )
3589 if ( layerIt->
first )
3593 extent = layerIt->
first->extent();
3622 penColor = colorFromSymbolLayer( symbolLayer, ctx );
3626 Qt::PenStyle penStyle( Qt::SolidLine );
3627 Qt::BrushStyle brushStyle( Qt::NoBrush );
3629 double offset = 0.0;
3630 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
3632 width = symbolLayer->
dxfWidth( *
this, ctx );
3633 offset = symbolLayer->
dxfOffset( *
this, ctx );
3641 QString lineStyleName =
"CONTINUOUS";
3644 lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
3659 for ( ; it != multiPoint.
constEnd(); ++it )
3661 writePoint( *it, layer, penColor, fet, symbolLayer, symbol );
3667 if ( penStyle != Qt::NoPen )
3675 offsetLine = nonConstGeom;
3679 if ( offsetLine != nonConstGeom )
3681 delete nonConstGeom;
3688 QgsGeometry *offsetLine = offset == 0.0 ? nonConstGeom : nonConstGeom->
offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 );
3690 offsetLine = nonConstGeom;
3694 for ( ; lIt != multiLine.
constEnd(); ++lIt )
3696 writePolyline( *lIt, layer, lineStyleName, penColor, width );
3699 if ( offsetLine != nonConstGeom )
3701 delete nonConstGeom;
3708 QgsGeometry *offsetPolygon = offset == 0.0 ? nonConstGeom : nonConstGeom->
buffer( -offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3709 if ( !offsetPolygon )
3710 offsetPolygon = nonConstGeom;
3714 for ( ; polyIt != polygon.
constEnd(); ++polyIt )
3716 writePolyline( *polyIt, layer, lineStyleName, penColor, width );
3719 if ( offsetPolygon != nonConstGeom )
3720 delete offsetPolygon;
3721 delete nonConstGeom;
3728 QgsGeometry *offsetPolygon = offset == 0.0 ? nonConstGeom : nonConstGeom->
buffer( -offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3729 if ( !offsetPolygon )
3730 offsetPolygon = nonConstGeom;
3734 for ( ; mpIt != mp.
constEnd(); ++mpIt )
3737 for ( ; polyIt != mpIt->constEnd(); ++polyIt )
3739 writePolyline( *polyIt, layer, lineStyleName, penColor, width );
3743 if ( offsetPolygon != nonConstGeom )
3744 delete offsetPolygon;
3745 delete nonConstGeom;
3749 if ( brushStyle != Qt::NoBrush )
3763 for ( ; mpIt != mp.
constEnd(); ++mpIt )
3776 return symbolLayer->
dxfColor( ctx );
3781 QString lineStyleName =
"CONTINUOUS";
3784 return lineStyleName;
3788 if ( lineTypeIt != mLineStyles.
constEnd() )
3790 lineStyleName = lineTypeIt.
value();
3791 return lineStyleName;
3795 return lineNameFromPenStyle( symbolLayer->
dxfPenStyle() );
3802 int current_distance = INT_MAX;
3803 for (
size_t i = 1; i <
sizeof( mDxfColors ) /
sizeof( *mDxfColors ); ++i )
3805 int dist = color_distance( pixel, i );
3806 if ( dist < current_distance )
3808 current_distance = dist;
3817 int QgsDxfExport::color_distance( QRgb p1,
int index )
3819 if ( index > 255 || index < 0 )
3824 double redDiff = qRed( p1 ) - mDxfColors[
index][0];
3825 double greenDiff = qGreen( p1 ) - mDxfColors[
index][1];
3826 double blueDiff = qBlue( p1 ) - mDxfColors[
index][2];
3828 QgsDebugMsg(
QString(
"color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
3829 .arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
3831 .arg( mDxfColors[index][0] )
3832 .arg( mDxfColors[index][1] )
3833 .arg( mDxfColors[index][2] )
3834 .arg( redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff ) );
3836 return redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff;
3839 QRgb QgsDxfExport::createRgbEntry( qreal r, qreal g, qreal b )
3866 for ( ; lIt != mLayers.
end(); ++lIt )
3885 for ( ; symbolIt != symbols.
end(); ++symbolIt )
3887 int maxSymbolLayers = ( *symbolIt )->symbolLayerCount();
3890 maxSymbolLayers = 1;
3892 for (
int i = 0; i < maxSymbolLayers; ++i )
3894 symbolLayers.
append( qMakePair(( *symbolIt )->symbolLayer( i ), *symbolIt ) );
3899 return symbolLayers;
3902 void QgsDxfExport::writeDefaultLinetypes()
3905 Q_FOREACH (
const QString& ltype,
QStringList() <<
"ByLayer" <<
"ByBlock" <<
"CONTINUOUS" )
3910 writeGroup( 100,
"AcDbLinetypeTableRecord" );
3919 double das = dashSize();
3920 double dss = dashSeparatorSize();
3921 double dos = dotSize();
3924 dashVector[0] = das;
3925 dashVector[1] = dss;
3934 dashDotVector[0] = das;
3935 dashDotVector[1] = dss;
3936 dashDotVector[2] = dos;
3937 dashDotVector[3] = dss;
3941 dashDotDotVector[0] = das;
3942 dashDotDotVector[1] = dss;
3943 dashDotDotVector[2] = dos;
3944 dashDotDotVector[3] = dss;
3945 dashDotDotVector[4] = dos;
3946 dashDotDotVector[5] = dss;
3950 void QgsDxfExport::writeSymbolLayerLinetype(
const QgsSymbolLayerV2* symbolLayer )
3959 if ( customLinestyle.
size() > 0 )
3962 writeLinetype( name, customLinestyle, unit );
3963 mLineStyles.
insert( symbolLayer, name );
3971 for ( ; slIt != symbolLayers.
constEnd(); ++slIt )
3989 for ( ; dashIt != pattern.
constEnd(); ++dashIt )
3991 length += ( *dashIt *
mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits ) );
3998 writeGroup( 100,
"AcDbLinetypeTableRecord" );
4008 for ( ; dashIt != pattern.
constEnd(); ++dashIt )
4011 double segmentLength = ( isGap ? -*dashIt : *dashIt );
4021 if ( !sl || !symbol )
4035 double QgsDxfExport::dashSize()
const
4037 double size = mSymbologyScaleDenominator * 0.002;
4038 return sizeToMapUnits( size );
4041 double QgsDxfExport::dotSize()
const
4043 double size = mSymbologyScaleDenominator * 0.0006;
4044 return sizeToMapUnits( size );
4047 double QgsDxfExport::dashSeparatorSize()
const
4049 double size = mSymbologyScaleDenominator * 0.0006;
4050 return sizeToMapUnits( size );
4053 double QgsDxfExport::sizeToMapUnits(
double s )
const
4059 QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
4067 case Qt::DashDotLine:
4069 case Qt::DashDotDotLine:
4070 return "DASHDOTDOT";
4073 return "CONTINUOUS";
4088 layerName.
replace(
"<",
"_" );
4089 layerName.
replace(
">",
"_" );
4090 layerName.
replace(
"/",
"_" );
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(
"\'",
"_" );
4104 bool QgsDxfExport::layerIsScaleBasedVisible(
const QgsMapLayer* layer )
const
4112 return layer->
minimumScale() < mSymbologyScaleDenominator &&
4119 for ( ; layerIt != mLayers.
constEnd(); ++layerIt )
4121 if ( layerIt->
first && layerIt->
first->id() == id )
4132 if ( name != codec )
4136 for ( i = 0; i < ( int )(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) && name != mDxfEncodings[i][1]; ++i )
4139 if ( i == (
int )(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) )
4142 return mDxfEncodings[i][0];
4145 return QString::null;
4154 for ( i = 0; i < ( int )(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) && strcmp( codec.
data(), mDxfEncodings[i][1] ) != 0; ++i )
4157 if ( i < (
int )(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) )
4158 encodings << codec.
data();
static double mapUnitScaleFactor(double scaleDenominator, QgsSymbolV2::OutputUnit symbolUnits, QGis::UnitType mapUnits)
void setCodec(QTextCodec *codec)
const QString & name() const
Gets the name of the field.
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 solid.
A rectangle specified with double values.
Base class for all map layer types.
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
void addLayers(const QList< QPair< QgsVectorLayer *, int > > &layers)
void writeGroup(int code, int i)
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.
UnitType
Map units that qgis supports.
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...
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
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
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.
QgsSymbolV2::OutputUnit sizeUnit() const
The QGis class provides global constants for use throughout the application.
virtual QList< QString > usedAttributes()=0
WkbType
Used for symbology operations.
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)
static int closestColorMatch(QRgb pixel)
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.
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
void writeString(const QString &s)
const QString & name() const
Get the display name of the layer.
int writeToFile(QIODevice *d, const QString &codec)
Perform transforms between map coordinates and device coordinates.
QgsRectangle extent() const
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)
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)
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 bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext *context, const QgsFeature *f, const QPointF &shift=QPointF(0.0, 0.0)) const
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
for symbol levels
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)
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)
QString qgsDoubleToString(const double &a, const int &precision=17)
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)
return list of symbols used for rendering the feature.
void setOutputSize(const QSize &size)
Set the size of the resulting map image.
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)
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.
static double fromUnitToUnitFactor(QGis::UnitType fromUnit, QGis::UnitType toUnit)
Returns the conversion factor between the specified units.
void writePolygon(const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf polygon (HATCH)
bool canEncode(QChar ch) const
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...
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)
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
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