19 #include "diagram/qgsdiagram.h"
41 , mFields( layer->pendingFields() )
46 , mLayerTransparency( 0 )
66 QString markerTypeString = settings.value(
"/qgis/digitizing/marker_style",
"Cross" ).toString();
67 if ( markerTypeString ==
"Cross" )
71 else if ( markerTypeString ==
"SemiTransparentCircle" )
116 mErrors.append(
"No renderer for drawing." );
154 QgsDebugMsg( QString(
"Simplify - SourceTransformRect=%1" ).arg( sourceRect.
toString( 16 ) ) );
155 QgsDebugMsg( QString(
"Simplify - TargetTransformRect=%1" ).arg( targetRect.toString( 16 ) ) );
157 if ( !sourceRect.
isEmpty() && sourceRect.
isFinite() && !targetRect.isEmpty() && targetRect.isFinite() )
161 QgsPoint minimumDstPoint( targetRect.xMinimum(), targetRect.yMinimum() );
162 QgsPoint maximumDstPoint( targetRect.xMaximum(), targetRect.yMaximum() );
164 double sourceHypothenuse = sqrt( minimumSrcPoint.sqrDist( maximumSrcPoint ) );
165 double targetHypothenuse = sqrt( minimumDstPoint.sqrDist( maximumDstPoint ) );
167 QgsDebugMsg( QString(
"Simplify - SourceHypothenuse=%1" ).arg( sourceHypothenuse ) );
168 QgsDebugMsg( QString(
"Simplify - TargetHypothenuse=%1" ).arg( targetHypothenuse ) );
170 if ( targetHypothenuse != 0 )
171 map2pixelTol *= ( sourceHypothenuse / targetHypothenuse );
209 QColor transparentFillColor = QColor( 0, 0, 0, 255 - ( 255 *
mLayerTransparency / 100 ) );
211 mContext.
painter()->setCompositionMode( QPainter::CompositionMode_DestinationIn );
261 Q_UNUSED( rendered );
277 QgsDebugMsg( QString(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
278 .arg( fet.
id() ).arg( cse.
what() ) );
287 QHash< QgsSymbolV2*, QList<QgsFeature> > features;
307 qDebug(
"rendering stop!" );
318 if ( !features.contains( sym ) )
320 features.insert( sym, QList<QgsFeature>() );
322 features[sym].append( fet );
346 for (
int i = 0; i < symbols.count(); i++ )
352 if ( level < 0 || level >= 1000 )
355 while ( level >= levels.count() )
357 levels[level].append( item );
362 for (
int l = 0; l < levels.count(); l++ )
365 for (
int i = 0; i < level.count(); i++ )
368 if ( !features.contains( item.
symbol() ) )
373 int layer = item.
layer();
374 QList<QgsFeature>& lst = features[item.
symbol()];
375 QList<QgsFeature>::iterator fit;
376 for ( fit = lst.begin(); fit != lst.end(); ++fit )
395 QgsDebugMsg( QString(
"Failed to transform a point while drawing a feature with ID '%1'. Ignoring this feature. %2" )
396 .arg( fet.
id() ).arg( cse.
what() ) );
431 #if 0 // TODO: limit of labels, font not found
441 int nFeatsToLabel = 0;
453 mLabelFontNotFoundNotified =
true;
476 QList<QString>::const_iterator attIt = att.constBegin();
477 for ( ; attIt != att.constEnd(); ++attIt )
481 QStringList::const_iterator columnsIterator = columns.constBegin();
482 for ( ; columnsIterator != columns.constEnd(); ++columnsIterator )
484 if ( !attributeNames.contains( *columnsIterator ) )
485 attributeNames << *columnsIterator;
490 if ( linearlyInterpolatedDiagramRenderer != NULL )
496 QStringList::const_iterator columnsIterator = columns.constBegin();
497 for ( ; columnsIterator != columns.constEnd(); ++columnsIterator )
499 if ( !attributeNames.contains( *columnsIterator ) )
500 attributeNames << *columnsIterator;
506 if ( !attributeNames.contains( name ) )
507 attributeNames << name;
QgsFeatureId id() const
Get the feature id for this feature.
Class for parsing and evaluation of expressions (formerly called "search strings").
const QString & name() const
Gets the name of the field.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Wrapper for iterator of features from vector data provider or vector layer.
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
A rectangle specified with double values.
bool isEmpty() const
test if rectangle is empty.
float threshold() const
Gets the simplification threshold of the vector layer managed.
QgsSymbolV2 * symbol() const
virtual int prepareLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx)=0
called when starting rendering of a layer
QList< QgsSymbolV2 * > QgsSymbolV2List
void prepareDiagrams(QgsVectorLayer *layer, QStringList &attributeNames)
QColor selectionColor() const
Added in QGIS v2.0.
virtual QgsPalLayerSettings & layer(const QString &layerName)=0
returns PAL layer settings for a registered layer
virtual QString dump() const
for debugging
virtual QList< QString > diagramAttributes() const =0
Returns attribute indices needed for diagram rendering.
bool isFinite() const
Returns true if the rectangle has finite boundaries.
double yMaximum() const
Get the y maximum value (top side of rectangle)
QgsFeatureIds mSelectedFeatureIds
The geometries can be simplified using the current map2pixel context state.
QgsDiagram * diagram() const
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed.
void setGeometryCachePointer(QgsGeometryCache *cache)
where to save the cached geometries
virtual void registerFeature(const QString &layerID, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext())=0
called for every feature
QPainter::CompositionMode mFeatureBlendMode
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request)
void setVectorSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
QgsRenderContext & mContext
void prepareLabeling(QgsVectorLayer *layer, QStringList &attributeNames)
Registers label and diagram layer.
const QgsRectangle & extent() const
bool showSelection() const
Returns true if vector selections should be shown in the rendered map.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
virtual QList< QString > usedAttributes()=0
virtual int addDiagramLayer(QgsVectorLayer *layer, const QgsDiagramLayerSettings *s)
adds a diagram layer to the labeling engine
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
const QgsDiagramLayerSettings * diagramLayerSettings() const
const QgsCoordinateTransform * coordinateTransform() const
virtual void stopRender(QgsRenderContext &context)
void setCachedGeometriesRect(const QgsRectangle &extent)
QgsVectorSimplifyMethod mSimplifyMethod
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
static void logMessage(QString message, QString tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
Returns diagram settings for a feature.
QString layerID() const
Get access to the ID of the layer rendered by this class.
virtual void stopRender(QgsRenderContext &context)=0
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
virtual QgsSymbolV2List symbols()=0
for symbol levels
Perform transforms between map coordinates and device coordinates.
virtual bool renderFeature(QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
void setColor(const QColor &color)
Simplify using the map2pixel data to optimize the rendering of geometries.
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
No simplification can be applied.
virtual QgsFeatureRendererV2 * clone()=0
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
void stopRendererV2(QgsSingleSymbolRendererV2 *selRenderer)
Stop version 2 renderer and selected renderer (if required)
QPainter::CompositionMode featureBlendMode() const
Read blend mode for layer.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
QgsVectorLayerRenderer(QgsVectorLayer *layer, QgsRenderContext &context)
bool renderingStopped() const
bool mVertexMarkerOnlyForSelection
void setTolerance(double tolerance)
Sets the tolerance of simplification. Represents the maximum distance between two coordinates which c...
QStringList referencedColumns()
Get list of columns referenced by the expression.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsVectorLayerFeatureSource * mSource
QList< int > QgsAttributeList
double mapUnitsPerPixel() const
Return current map units per pixel.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
QgsFeatureRendererV2 * mRendererV2
const QgsDiagramRendererV2 * diagramRenderer() const
A class to represent a point geometry.
bool drawEditingInformation() const
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
QList< QgsSymbolV2LevelItem > QgsSymbolV2Level
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
int renderingPass() const
QgsFeatureRequest & setSimplifyMethod(const QgsSimplifyMethod &simplifyMethod)
Set a simplification method for geometries that will be fetched.
int layerTransparency() const
Read transparency for layer.
void drawRendererV2(QgsFeatureIterator &fit)
Draw layer with renderer V2.
int classificationAttribute() const
void setForceLocalOptimization(bool localOptimization)
Sets whether the simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries.
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
void drawRendererV2Levels(QgsFeatureIterator &fit)
Draw layer with renderer V2 using symbol levels.
static QgsSymbolV2 * defaultSymbol(QGis::GeometryType geomType)
return new default symbol for specified geometry type
QGis::GeometryType mGeometryType
void setMethodType(MethodType methodType)
Sets the simplification type.
void setVertexMarkerAppearance(int type, int size)
set type and size of editing vertex markers for subsequent rendering
bool usingSymbolLevels() const
bool classificationAttributeIsExpression() const
void cacheGeometry(QgsFeatureId fid, const QgsGeometry &geom)
store a geometry in the cache
const QgsMapToPixel & mapToPixel() const
QList< QgsSymbolV2Level > QgsSymbolV2LevelOrder
Base class for utility classes that encapsulate information necessary for rendering of map layers...
This class contains information about how to simplify geometries fetched from a QgsFeatureIterator.
Custom exception class for Coordinate Reference System related exceptions.
QgsSymbolLayerV2 * symbolLayer(int layer)
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
bool nextFeature(QgsFeature &f)
QString classificationAttributeExpression() const
virtual void registerDiagramFeature(const QString &layerID, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext())
called for every diagram feature
Represents a vector layer which manages a vector based data sets.
QgsGeometryCache * mCache
bool geographicFlag() const
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
virtual QgsSymbolV2 * symbolForFeature(QgsFeature &feature)=0
to be overridden
double xMinimum() const
Get the x minimum value (left side of rectangle)
QgsPoint center() const
Center point of the rectangle.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rect)
Set rectangle from which features will be taken.
~QgsVectorLayerRenderer()
QgsLabelingEngineInterface * labelingEngine() const
Added in QGIS v1.4.
virtual bool render()
Do the rendering (based on data stored in the class)