QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
QgsLegendRenderer Class Reference

The QgsLegendRenderer class handles automatic layout and rendering of legend. More...

#include <qgslegendrenderer.h>

Collaboration diagram for QgsLegendRenderer:
Collaboration graph
[legend]

Classes

class  Atom
 Atom is indivisible set (indivisible into more columns). More...
 
class  Nucleon
 Nucleon is either group title, layer title or layer child item. More...
 

Public Member Functions

 QgsLegendRenderer (QgsLayerTreeModel *legendModel, const QgsLegendSettings &settings)
 Construct legend renderer. More...
 
QSizeF minimumSize ()
 Run the layout algorithm and determine the size required for legend. More...
 
void setLegendSize (QSizeF s)
 Set the preferred resulting legend size. More...
 
QSizeF legendSize () const
 Find out preferred legend size set by the client. More...
 
void drawLegend (QPainter *painter)
 Draw the legend with given painter. More...
 

Static Public Member Functions

static void setNodeLegendStyle (QgsLayerTreeNode *node, QgsComposerLegendStyle::Style style)
 
static
QgsComposerLegendStyle::Style 
nodeLegendStyle (QgsLayerTreeNode *node, QgsLayerTreeModel *model)
 

Private Member Functions

QSizeF paintAndDetermineSize (QPainter *painter)
 
QList< AtomcreateAtomList (QgsLayerTreeGroup *parentGroup, bool splitLayer)
 Create list of atoms according to current layer splitting mode. More...
 
void setColumns (QList< Atom > &atomList)
 Divide atoms to columns and set columns on atoms. More...
 
QSizeF drawTitle (QPainter *painter=0, QPointF point=QPointF(), Qt::AlignmentFlag halignment=Qt::AlignLeft, double legendWidth=0)
 Draws title in the legend using the title font and the specified alignment If no painter is specified, function returns the required width/height to draw the title. More...
 
double spaceAboveAtom (Atom atom)
 
QSizeF drawAtom (Atom atom, QPainter *painter=0, QPointF point=QPointF())
 Draw atom and return its actual size, the atom is drawn with the space above it so that first atoms in column are all aligned to the same line regardles their style top space. More...
 
Nucleon drawSymbolItem (QgsLayerTreeModelLegendNode *symbolItem, QPainter *painter=0, QPointF point=QPointF(), double labelXOffset=0)
 
QSizeF drawLayerTitle (QgsLayerTreeLayer *nodeLayer, QPainter *painter=0, QPointF point=QPointF())
 Draws a layer item. More...
 
QSizeF drawGroupTitle (QgsLayerTreeGroup *nodeGroup, QPainter *painter=0, QPointF point=QPointF())
 Draws a group item. More...
 
QgsComposerLegendStyle::Style nodeLegendStyle (QgsLayerTreeNode *node)
 

Private Attributes

QgsLayerTreeModelmLegendModel
 
QgsLegendSettings mSettings
 
QSizeF mLegendSize
 

Detailed Description

The QgsLegendRenderer class handles automatic layout and rendering of legend.

The content is given by QgsLegendModel instance. Various layout properties can be configured within QgsLegendRenderer.

All spacing and sizes are in millimeters.

Note
added in 2.6

Definition at line 42 of file qgslegendrenderer.h.

Constructor & Destructor Documentation

QgsLegendRenderer::QgsLegendRenderer ( QgsLayerTreeModel legendModel,
const QgsLegendSettings settings 
)

Construct legend renderer.

The ownership of legend model does not change

Definition at line 32 of file qgslegendrenderer.cpp.

Member Function Documentation

QList< QgsLegendRenderer::Atom > QgsLegendRenderer::createAtomList ( QgsLayerTreeGroup parentGroup,
bool  splitLayer 
)
private
QSizeF QgsLegendRenderer::drawAtom ( Atom  atom,
QPainter *  painter = 0,
QPointF  point = QPointF() 
)
private
QSizeF QgsLegendRenderer::drawGroupTitle ( QgsLayerTreeGroup nodeGroup,
QPainter *  painter = 0,
QPointF  point = QPointF() 
)
private
QSizeF QgsLegendRenderer::drawLayerTitle ( QgsLayerTreeLayer nodeLayer,
QPainter *  painter = 0,
QPointF  point = QPointF() 
)
private
void QgsLegendRenderer::drawLegend ( QPainter *  painter)

Draw the legend with given painter.

It will occupy the area reported in legendSize(). Painter should be scaled beforehand so that units correspond to millimeters.

Definition at line 43 of file qgslegendrenderer.cpp.

References paintAndDetermineSize().

Referenced by QgsComposerLegend::paint(), and QgsComposerLegend::paintAndDetermineSize().

QgsLegendRenderer::Nucleon QgsLegendRenderer::drawSymbolItem ( QgsLayerTreeModelLegendNode symbolItem,
QPainter *  painter = 0,
QPointF  point = QPointF(),
double  labelXOffset = 0 
)
private
QSizeF QgsLegendRenderer::drawTitle ( QPainter *  painter = 0,
QPointF  point = QPointF(),
Qt::AlignmentFlag  halignment = Qt::AlignLeft,
double  legendWidth = 0 
)
private
QSizeF QgsLegendRenderer::legendSize ( ) const
inline

Find out preferred legend size set by the client.

If null, the legend will be drawn with the minimum size

Definition at line 55 of file qgslegendrenderer.h.

QSizeF QgsLegendRenderer::minimumSize ( )

Run the layout algorithm and determine the size required for legend.

Definition at line 38 of file qgslegendrenderer.cpp.

References paintAndDetermineSize().

Referenced by QgsComposerLegend::adjustBoxSize(), and QgsComposerLegend::paintAndDetermineSize().

QgsComposerLegendStyle::Style QgsLegendRenderer::nodeLegendStyle ( QgsLayerTreeNode node,
QgsLayerTreeModel model 
)
static
QgsComposerLegendStyle::Style QgsLegendRenderer::nodeLegendStyle ( QgsLayerTreeNode node)
private

Definition at line 598 of file qgslegendrenderer.cpp.

References mLegendModel, and nodeLegendStyle().

QSizeF QgsLegendRenderer::paintAndDetermineSize ( QPainter *  painter)
private
void QgsLegendRenderer::setColumns ( QList< Atom > &  atomList)
private
void QgsLegendRenderer::setLegendSize ( QSizeF  s)
inline

Set the preferred resulting legend size.

Definition at line 52 of file qgslegendrenderer.h.

Referenced by QgsComposerLegend::paint().

void QgsLegendRenderer::setNodeLegendStyle ( QgsLayerTreeNode node,
QgsComposerLegendStyle::Style  style 
)
static
double QgsLegendRenderer::spaceAboveAtom ( Atom  atom)
private

Member Data Documentation

QgsLayerTreeModel* QgsLegendRenderer::mLegendModel
private
QSizeF QgsLegendRenderer::mLegendSize
private

Definition at line 143 of file qgslegendrenderer.h.

Referenced by paintAndDetermineSize().

QgsLegendSettings QgsLegendRenderer::mSettings
private

The documentation for this class was generated from the following files: