48 #define DXF_HANDSEED 100 49 #define DXF_HANDMAX 9999999 50 #define DXF_HANDPLOTSTYLE 0xf 53 int QgsDxfExport::mDxfColors[][3] =
313 const char *QgsDxfExport::mDxfEncodings[][2] =
316 {
"8859_1",
"ISO-8859-1" },
317 {
"8859_2",
"ISO-8859-2" },
318 {
"8859_3",
"ISO-8859-3" },
319 {
"8859_4",
"ISO-8859-4" },
320 {
"8859_5",
"ISO-8859-5" },
321 {
"8859_6",
"ISO-8859-6" },
322 {
"8859_7",
"ISO-8859-7" },
323 {
"8859_8",
"ISO-8859-8" },
324 {
"8859_9",
"ISO-8859-9" },
326 {
"DOS850",
"CP850" },
337 {
"MACINTOSH",
"MacRoman" },
339 {
"KSC5601",
"ksc5601.1987-0" },
341 {
"DOS866",
"CP866" },
342 {
"ANSI_1250",
"CP1250" },
343 {
"ANSI_1251",
"CP1251" },
344 {
"ANSI_1252",
"CP1252" },
345 {
"GB2312",
"GB2312" },
346 {
"ANSI_1253",
"CP1253" },
347 {
"ANSI_1254",
"CP1254" },
348 {
"ANSI_1255",
"CP1255" },
349 {
"ANSI_1256",
"CP1256" },
350 {
"ANSI_1257",
"CP1257" },
351 {
"ANSI_874",
"CP874" },
352 {
"ANSI_932",
"Shift_JIS" },
353 {
"ANSI_936",
"CP936" },
354 {
"ANSI_949",
"cp949" },
355 {
"ANSI_950",
"CP950" },
358 {
"ANSI_1258",
"CP1258" },
362 : mSymbologyScaleDenominator( 1.0 )
363 , mSymbologyExport( NoSymbology )
364 , mMapUnits(
QGis::Meters )
365 , mLayerTitleAsName( false )
366 , mSymbolLayerCounter( 0 )
379 mLayers = dxfExport.mLayers;
380 mSymbologyScaleDenominator = dxfExport.mSymbologyScaleDenominator;
381 mSymbologyExport = dxfExport.mSymbologyExport;
382 mMapUnits = dxfExport.mMapUnits;
383 mLayerTitleAsName = dxfExport.mLayerTitleAsName;
384 mSymbolLayerCounter = 0;
428 int minDist = INT_MAX;
430 for (
int i = 1; i < static_cast< int >(
sizeof( mDxfColors ) /
sizeof( *mDxfColors ) ) && minDist > 0; ++i )
432 int dist = color_distance( color.
rgba(), i );
433 if ( dist >= minDist )
440 if ( minDist == 0 && color.
alpha() == 255 && minDistAt != 7 )
447 int c = ( color.
red() & 0xff ) * 0x10000 + ( color.
green() & 0xff ) * 0x100 + ( color.
blue() & 0xff );
449 if ( transparencyCode != -1 && color.
alpha() < 255 )
468 mTextStream << s <<
'\n';
473 mTextStream << s <<
'\n';
483 if ( !d->
isOpen() && !d->
open( QIODevice::WriteOnly ) )
500 void QgsDxfExport::writeHeader(
const QString& codepage )
512 if ( !ext.isEmpty() )
551 handle = mNextHandleId++;
553 Q_ASSERT_X( handle <
DXF_HANDMAX,
"QgsDxfExport::writeHandle(int, int)",
"DXF handle too large" );
559 void QgsDxfExport::writeTables()
569 slList = symbolLayers( context );
580 writeDefaultLinetypes();
584 for ( ; slIt != slList.
constEnd(); ++slIt )
586 writeSymbolLayerLinetype( slIt->
first );
599 Q_FOREACH (
const QString& block,
QStringList() <<
"*Model_Space" <<
"*Paper_Space" <<
"*Paper_Space0" )
610 for ( ; slIt != slList.
constEnd(); ++slIt )
616 if ( hasDataDefinedProperties( ml, slIt->second ) )
718 for ( ; layerIt != mLayers.
constEnd(); ++layerIt )
720 if ( !layerIsScaleBasedVisible( layerIt->
first ) )
723 if ( layerIt->
first )
725 if ( layerIt->second < 0 )
732 layerIt->
first->uniqueValues( layerIt->second, values );
733 Q_FOREACH (
const QVariant& v, values )
784 writeGroup( 100,
"AcDbTextStyleTableRecord" );
800 void QgsDxfExport::writeBlocks()
805 Q_FOREACH (
const QString& block,
QStringList() <<
"*Model_Space" <<
"*Paper_Space" <<
"*Paper_Space0" )
831 slList = symbolLayers( ct );
835 for ( ; slIt != slList.
constEnd(); ++slIt )
846 if ( hasDataDefinedProperties( ml, slIt->second ) )
852 QString block(
QString(
"symbolLayer%1" ).arg( mBlockCounter++ ) );
853 mBlockHandle =
QString(
"%1" ).
arg( mBlockHandles[ block ], 0, 16 );
881 mPointSymbolBlocks.
insert( ml, block );
888 void QgsDxfExport::writeEntities()
893 mBlockHandle =
QString(
"%1" ).
arg( mBlockHandles[
"*Model_Space" ], 0, 16 );
907 QImage image( 10, 10, QImage::Format_ARGB32_Premultiplied );
923 engine.setMapSettings( mapSettings );
927 for ( ; layerIt != mLayers.
constEnd(); ++layerIt )
930 if ( !vl || !layerIsScaleBasedVisible( vl ) )
947 if ( !attributes.
contains( layerAttr ) )
948 attributes << layerAttr;
954 if ( dynamic_cast<const QgsRuleBasedLabeling*>( labeling ) )
959 engine.addProvider( rblp );
961 if ( !rblp->
prepare( ctx, attributes ) )
963 engine.removeProvider( rblp );
970 engine.addProvider( lp );
972 if ( !lp->
prepare( ctx, attributes ) )
974 engine.removeProvider( lp );
983 writeEntitiesSymbolLevels( vl );
1004 addFeature( sctx, lName,
nullptr,
nullptr );
1009 if ( symbolList.
size() < 1 )
1017 for ( ; symbolIt != symbolList.
end(); ++symbolIt )
1019 int nSymbolLayers = ( *symbolIt )->symbolLayerCount();
1020 for (
int i = 0; i < nSymbolLayers; ++i )
1022 addFeature( sctx, lName, ( *symbolIt )->symbolLayer( i ), *symbolIt );
1034 addFeature( sctx, lName, s->
symbolLayer( 0 ), s );
1056 void QgsDxfExport::writeEntitiesSymbolLevels(
QgsVectorLayer* layer )
1098 if ( !featureSymbol )
1104 if ( it == features.
end() )
1108 it.
value().append( fet );
1114 for (
int i = 0; i < symbols.
count(); i++ )
1120 if ( level < 0 || level >= 1000 )
1123 while ( level >= levels.
count() )
1125 levels[level].
append( item );
1130 for (
int l = 0; l < levels.
count(); l++ )
1133 for (
int i = 0; i < level.
count(); i++ )
1137 if ( levelIt == features.
end() )
1143 int llayer = item.
layer();
1146 for ( ; featureIt != featureList.
end(); ++featureIt )
1149 addFeature( sctx, layer->
name(), levelIt.
key()->symbolLayer( llayer ), levelIt.
key() );
1156 void QgsDxfExport::writeEndFile()
1183 ACAD_MLEADERSTYLE\n\ 1191 ACAD_PLOTSETTINGS\n\ 1195 ACAD_PLOTSTYLENAME\n\ 1303 ACDBDICTIONARYWDFLT\n\ 1323 AcDbDictionaryWithDefault\n\ 1519 1.000000000000000E+20\n\ 1521 1.000000000000000E+20\n\ 1523 1.000000000000000E+20\n\ 1525 -1.000000000000000E+20\n\ 1527 -1.000000000000000E+20\n\ 1529 -1.000000000000000E+20\n\ 1791 163.1318914119703\n\ 1959 AcDbSavedByObjectVersion\n\ 2049 AcDbSavedByObjectVersion\n\ 2139 AcDbSavedByObjectVersion\n\ 2229 AcDbSavedByObjectVersion\n\ 2319 AcDbSavedByObjectVersion\n\ 2411 AcDbSavedByObjectVersion\n\ 2501 AcDbSavedByObjectVersion\n\ 2591 AcDbSavedByObjectVersion\n\ 2681 AcDbSavedByObjectVersion\n\ 2771 AcDbSavedByObjectVersion\n\ 2861 AcDbSavedByObjectVersion\n\ 2951 AcDbSavedByObjectVersion\n\ 3041 AcDbSavedByObjectVersion\n\ 3131 AcDbSavedByObjectVersion\n\ 3223 AcDbSavedByObjectVersion\n\ 3313 AcDbSavedByObjectVersion\n\ 3323 void QgsDxfExport::startSection()
3328 void QgsDxfExport::endSection()
3341 msl->
sizeUnit(), mMapUnits ) / 2.0;
3354 if ( !symbolLayer || blockIt == mPointSymbolBlocks.
constEnd() )
3358 if ( msl && symbol )
3383 int n = line.
size();
3386 QgsDebugMsg(
QString(
"writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3390 bool polygon = line[0] == line[ line.
size() - 1 ];
3395 QgsDebugMsg(
QString(
"writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3411 for (
int i = 0; i < n; i++ )
3433 for (
int i = 0; i < polygon.
size(); ++i )
3440 for (
int j = 0; j < polygon[i].
size(); ++j )
3568 while ( t.
length() > 250 )
3593 p[0].
resize( pt3 != pt4 ? 5 : 4 );
3597 if ( p[0].size() == 5 )
3604 void QgsDxfExport::writeVertex(
const QgsPoint& pt,
const QString& layer )
3619 for ( ; layerIt != mLayers.
constEnd(); ++layerIt )
3621 if ( layerIt->
first )
3625 extent = layerIt->
first->extent();
3654 penColor = colorFromSymbolLayer( symbolLayer, ctx );
3658 Qt::PenStyle penStyle( Qt::SolidLine );
3659 Qt::BrushStyle brushStyle( Qt::NoBrush );
3661 double offset = 0.0;
3663 if ( mSymbologyExport !=
NoSymbology && symbolLayer )
3665 width = symbolLayer->
dxfWidth( *
this, ctx );
3666 offset = symbolLayer->
dxfOffset( *
this, ctx );
3667 angle = symbolLayer->
dxfAngle( ctx );
3675 QString lineStyleName =
"CONTINUOUS";
3678 lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
3693 for ( ; it != multiPoint.
constEnd(); ++it )
3695 writePoint( *it, layer, penColor, ctx, symbolLayer, symbol, angle );
3701 if ( penStyle != Qt::NoPen )
3709 offsetLine = nonConstGeom;
3713 if ( offsetLine != nonConstGeom )
3715 delete nonConstGeom;
3724 offsetLine = nonConstGeom;
3728 for ( ; lIt != multiLine.
constEnd(); ++lIt )
3730 writePolyline( *lIt, layer, lineStyleName, penColor, width );
3733 if ( offsetLine != nonConstGeom )
3735 delete nonConstGeom;
3742 QgsGeometry *offsetPolygon = offset == 0.0 ? nonConstGeom : nonConstGeom->
buffer( -offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3743 if ( !offsetPolygon )
3744 offsetPolygon = nonConstGeom;
3748 for ( ; polyIt != polygon.
constEnd(); ++polyIt )
3750 writePolyline( *polyIt, layer, lineStyleName, penColor, width );
3753 if ( offsetPolygon != nonConstGeom )
3754 delete offsetPolygon;
3755 delete nonConstGeom;
3762 QgsGeometry *offsetPolygon = offset == 0.0 ? nonConstGeom : nonConstGeom->
buffer( -offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3763 if ( !offsetPolygon )
3764 offsetPolygon = nonConstGeom;
3768 for ( ; mpIt != mp.
constEnd(); ++mpIt )
3771 for ( ; polyIt != mpIt->constEnd(); ++polyIt )
3773 writePolyline( *polyIt, layer, lineStyleName, penColor, width );
3777 if ( offsetPolygon != nonConstGeom )
3778 delete offsetPolygon;
3779 delete nonConstGeom;
3783 if ( brushStyle != Qt::NoBrush )
3797 for ( ; mpIt != mp.
constEnd(); ++mpIt )
3810 return symbolLayer->
dxfColor( ctx );
3815 QString lineStyleName =
"CONTINUOUS";
3818 return lineStyleName;
3822 if ( lineTypeIt != mLineStyles.
constEnd() )
3824 lineStyleName = lineTypeIt.
value();
3825 return lineStyleName;
3829 return lineNameFromPenStyle( symbolLayer->
dxfPenStyle() );
3836 int current_distance = INT_MAX;
3837 for (
int i = 1; i < static_cast< int >(
sizeof( mDxfColors ) /
sizeof( *mDxfColors ) ); ++i )
3839 int dist = color_distance( pixel, i );
3840 if ( dist < current_distance )
3842 current_distance = dist;
3851 int QgsDxfExport::color_distance( QRgb p1,
int index )
3853 if ( index > 255 || index < 0 )
3858 double redDiff = qRed( p1 ) - mDxfColors[
index][0];
3859 double greenDiff = qGreen( p1 ) - mDxfColors[
index][1];
3860 double blueDiff = qBlue( p1 ) - mDxfColors[
index][2];
3862 QgsDebugMsg(
QString(
"color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
3863 .arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
3865 .arg( mDxfColors[index][0] )
3866 .arg( mDxfColors[index][1] )
3867 .arg( mDxfColors[index][2] )
3868 .arg( redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff ) );
3870 return redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff;
3873 QRgb QgsDxfExport::createRgbEntry( qreal r, qreal g, qreal b )
3900 for ( ; lIt != mLayers.
constEnd(); ++lIt )
3919 for ( ; symbolIt != symbols.
end(); ++symbolIt )
3921 int maxSymbolLayers = ( *symbolIt )->symbolLayerCount();
3924 maxSymbolLayers = 1;
3926 for (
int i = 0; i < maxSymbolLayers; ++i )
3928 symbolLayers.
append( qMakePair(( *symbolIt )->symbolLayer( i ), *symbolIt ) );
3933 return symbolLayers;
3936 void QgsDxfExport::writeDefaultLinetypes()
3939 Q_FOREACH (
const QString& ltype,
QStringList() <<
"ByLayer" <<
"ByBlock" <<
"CONTINUOUS" )
3944 writeGroup( 100,
"AcDbLinetypeTableRecord" );
3953 double das = dashSize();
3954 double dss = dashSeparatorSize();
3955 double dos = dotSize();
3958 dashVector[0] = das;
3959 dashVector[1] = dss;
3968 dashDotVector[0] = das;
3969 dashDotVector[1] = dss;
3970 dashDotVector[2] = dos;
3971 dashDotVector[3] = dss;
3975 dashDotDotVector[0] = das;
3976 dashDotDotVector[1] = dss;
3977 dashDotDotVector[2] = dos;
3978 dashDotDotVector[3] = dss;
3979 dashDotDotVector[4] = dos;
3980 dashDotDotVector[5] = dss;
3984 void QgsDxfExport::writeSymbolLayerLinetype(
const QgsSymbolLayerV2* symbolLayer )
3993 if ( !customLinestyle.
isEmpty() )
3996 writeLinetype( name, customLinestyle, unit );
3997 mLineStyles.
insert( symbolLayer, name );
4005 for ( ; slIt != symbolLayers.constEnd(); ++slIt )
4023 for ( ; dashIt != pattern.
constEnd(); ++dashIt )
4025 length += ( *dashIt *
mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits ) );
4032 writeGroup( 100,
"AcDbLinetypeTableRecord" );
4042 for ( ; dashIt != pattern.
constEnd(); ++dashIt )
4045 double segmentLength = ( isGap ? -*dashIt : *dashIt );
4055 if ( !sl || !symbol )
4069 double QgsDxfExport::dashSize()
const 4071 double size = mSymbologyScaleDenominator * 0.002;
4072 return sizeToMapUnits( size );
4075 double QgsDxfExport::dotSize()
const 4077 double size = mSymbologyScaleDenominator * 0.0006;
4078 return sizeToMapUnits( size );
4081 double QgsDxfExport::dashSeparatorSize()
const 4083 double size = mSymbologyScaleDenominator * 0.0006;
4084 return sizeToMapUnits( size );
4087 double QgsDxfExport::sizeToMapUnits(
double s )
const 4093 QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
4101 case Qt::DashDotLine:
4103 case Qt::DashDotDotLine:
4104 return "DASHDOTDOT";
4107 return "CONTINUOUS";
4122 layerName.
replace(
'<',
'_' );
4123 layerName.
replace(
'>',
'_' );
4124 layerName.
replace(
'/',
'_' );
4125 layerName.
replace(
'\\',
'_' );
4126 layerName.
replace(
'\"',
'_' );
4127 layerName.
replace(
':',
'_' );
4128 layerName.
replace(
';',
'_' );
4129 layerName.
replace(
'?',
'_' );
4130 layerName.
replace(
'*',
'_' );
4131 layerName.
replace(
'|',
'_' );
4132 layerName.
replace(
'=',
'_' );
4133 layerName.
replace(
'\'',
'_' );
4136 layerName.
replace(
"\r\n",
"_" );
4137 layerName.
replace(
'\r',
'_' );
4138 layerName.
replace(
'\n',
'_' );
4143 bool QgsDxfExport::layerIsScaleBasedVisible(
const QgsMapLayer* layer )
const 4151 return layer->
minimumScale() < mSymbologyScaleDenominator &&
4158 for ( ; layerIt != mLayers.
constEnd(); ++layerIt )
4160 if ( layerIt->
first && layerIt->
first->id() == id )
4173 if ( name != codec )
4177 for ( i = 0; i < static_cast< int >(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) && name != mDxfEncodings[i][1]; ++i )
4180 if ( i == static_cast< int >(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) )
4183 return mDxfEncodings[i][0];
4186 return QString::null;
4195 for ( i = 0; i < static_cast< int >(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) && strcmp( codec.
data(), mDxfEncodings[i][1] ) != 0; ++i )
4198 if ( i < static_cast< int >(
sizeof( mDxfEncodings ) /
sizeof( *mDxfEncodings ) ) )
4199 encodings << codec.
data();
4212 Q_UNUSED( context );
4269 QString dxfLayer = mDxfLayerNames[layerId][fid];
4276 bool prependSymb =
false;
4294 prependSymb =
false;
4302 symb = symb + wrapchr;
4306 prependSymb =
false;
4307 symb = wrapchr + symb;
4320 txt = txt.
replace( wrapchr,
"\\P" );
4341 .arg( label->
getHeight() / ( 1 + txt.
count(
"\\P" ) ) * 0.75 ) );
4348 if ( !mDxfLayerNames.
contains( layerId ) )
4351 mDxfLayerNames[layerId][fid] =
layerName;
QgsPolygon asPolygon() const
Return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
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)
QString labelText() const
Text of the label.
virtual Qt::BrushStyle dxfBrushStyle() const
QgsMultiPolyline asMultiPolyline() const
Return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list.
A rectangle specified with double values.
Base class for all map layer types.
void setDotsPerMeterX(int x)
void setDotsPerMeterY(int y)
QGis::WkbType wkbType() const
Returns the WKBType or WKBUnknown in case of error.
QString & append(QChar ch)
QString leftDirectionSymbol
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)
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
QgsPoint asPoint() const
Return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
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
virtual Qt::PenStyle dxfPenStyle() const
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
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.
QgsSymbolV2::OutputUnit sizeUnit() const
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.
void setOutputDpi(int dpi)
Set DPI used for conversion between real world units (e.g. mm) and pixels.
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...
const_iterator constEnd() const
void setRendererScale(double scale)
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > & dataDefinedValues() const
Get data-defined values.
virtual QColor dxfBrushColor(QgsSymbolV2RenderContext &context) const
#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.
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.
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
WkbType
Used for symbology operations.
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
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...
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)
bool reverseDirectionSymbol
QString name() const
Gets the name of the field.
void writeInt(int i)
Write an integer value.
QgsPolyline asPolyline() const
Return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list...
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
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.
void writeString(const QString &s)
Write a string value.
QgsMultiPoint asMultiPoint() const
Return contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty list...
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.
float maximumScale() const
Returns the maximum scale denominator at which the layer is visible.
void writePoint(const QString &layer, const QColor &color, const QgsPoint &pt)
Write point.
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 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...
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
void setScaleFactor(double factor)
const_iterator constEnd() const
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.
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...
double width() const
Width of the rectangle.
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)...
bool useCustomDashPattern() const
Quadrant getQuadrant() const
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
void setPainter(QPainter *p)
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
bool usingSymbolLevels() const
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
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)
QTextCodec * codec() const
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)
QString layerName(const QString &id, const QgsFeature &f) const
Get layer name for feature.
const T value(const Key &key) const
QByteArray toLocal8Bit() const
A class to represent a vector.
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)
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
virtual double dxfOffset(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const
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.
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
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)
QFont definedFont()
Font to be used for rendering.
QString name() const
Get the display name of the layer.
QString mid(int position, int n) const
QgsRectangle extent() const
Get extent of area to export.
double getAlpha() const
get alpha
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.
QList< QPolygonF > offsetLine(QPolygonF polyline, double dist, QGis::GeometryType geometryType)
calculate geometry shifted by a specified distance
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
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
QgsMultiPolygon asMultiPolygon() const
Return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
#define DXF_HANDPLOTSTYLE
void setExtent(const QgsRectangle &rect)
Set coordinates of the rectangle which should be rendered.
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...
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
float minimumScale() const
Returns the minimum scale denominator at which the layer is visible.
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)
Write a tuple of group code and a handle.
Represents a vector layer which manages a vector based data sets.
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
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.
double x() const
Get the x value of the point.
QgsDxfExport & operator=(const QgsDxfExport &dxfExport)
void registerDxfLayer(QString layerId, QgsFeatureId fid, QString layer)
Register name of layer for feature.
double height() const
Height of the rectangle.
void setCrsTransformEnabled(bool enabled)
sets whether to use projections for this layer set
DirectionSymbols placeDirectionSymbol
static void dataDefinedTextFormatting(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)