mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
There is new "filter" button in layers panel that toggles this functionality and in composer legend widget. Related feature is that layer tree now shows symbols in map units with correct size (even when filtering is not enabled) so as the map view changes the legend node icons are updated too (if they use map units). GetLegendGraphics in WMS server ------------------------------- This is an extension of standard GetLegendGraphics request according to MapServer RFC 101. See the document for more details: http://mapserver.org/development/rfc/ms-rfc-101.html In summary, clients need to add BBOX and CRS/SRS parameters to get appropriate legend based on the given map view. Parameters WIDTH and HEIGHT are also taken into account as they specify map view image size for correct calculation of size of legend symbols (if they are based on map units). -- This software has been commissioned by Tuscany Region (Italy), co-funded by the European Commission and developed under the project LIFE12 ENV/IT/001054 LIFE + IMAGINE. The software has been realized by Gis3W s.a.s. Questo software è stato commissionato da Regione Toscana (Italia), cofinanziato dalla Commissione Europea e sviluppato nell'ambito del progetto LIFE12 ENV/IT/001054 LIFE + IMAGINE. Il software è stato realizzato da Gis3W s.a.s.
156 lines
4.7 KiB
Plaintext
156 lines
4.7 KiB
Plaintext
|
|
/** \ingroup MapComposer
|
|
* Item model implementation based on layer tree model for composer legend.
|
|
* Overrides some functionality of QgsLayerTreeModel to better fit the needs of composer legend.
|
|
*
|
|
* @note added in 2.6
|
|
*/
|
|
class QgsLegendModelV2 : QgsLayerTreeModel
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qgscomposerlegend.h>
|
|
%End
|
|
|
|
public:
|
|
QgsLegendModelV2( QgsLayerTreeGroup* rootNode, QObject *parent /TransferThis/ = 0 );
|
|
|
|
QVariant data( const QModelIndex& index, int role ) const;
|
|
|
|
Qt::ItemFlags flags( const QModelIndex &index ) const;
|
|
};
|
|
|
|
|
|
/** \ingroup MapComposer
|
|
* A legend that can be placed onto a map composition
|
|
*/
|
|
class QgsComposerLegend : QgsComposerItem
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qgscomposerlegend.h>
|
|
#include <qgscomposerlegendstyle.h>
|
|
%End
|
|
|
|
public:
|
|
QgsComposerLegend( QgsComposition* composition /TransferThis/);
|
|
~QgsComposerLegend();
|
|
|
|
/** return correct graphics item type. Added in v1.7 */
|
|
virtual int type() const;
|
|
|
|
/** \brief Reimplementation of QCanvasItem::paint*/
|
|
void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
|
|
|
|
/**Paints the legend and calculates its size. If painter is 0, only size is calculated*/
|
|
QSizeF paintAndDetermineSize( QPainter* painter );
|
|
|
|
/**Sets item box to the whole content*/
|
|
void adjustBoxSize();
|
|
|
|
/**Returns pointer to the legend model*/
|
|
//! @note deprecated in 2.6 - use modelV2()
|
|
QgsLegendModel* model() /Deprecated/;
|
|
|
|
//! @note added in 2.6
|
|
QgsLegendModelV2* modelV2();
|
|
|
|
//! @note added in 2.6
|
|
void setAutoUpdateModel( bool autoUpdate );
|
|
//! @note added in 2.6
|
|
bool autoUpdateModel() const;
|
|
|
|
//! Set whether legend items should be filtered to show just the ones visible in the associated map
|
|
//! @note added in 2.6
|
|
void setLegendFilterByMapEnabled( bool enabled );
|
|
//! Find out whether legend items are filtered to show just the ones visible in the associated map
|
|
//! @note added in 2.6
|
|
bool legendFilterByMapEnabled() const;
|
|
|
|
//setters and getters
|
|
void setTitle( const QString& t );
|
|
QString title() const;
|
|
|
|
/**Returns the alignment of the legend title
|
|
* @returns Qt::AlignmentFlag for the legend title
|
|
* @note added in 2.3
|
|
* @see setTitleAlignment
|
|
*/
|
|
Qt::AlignmentFlag titleAlignment() const;
|
|
/**Sets the alignment of the legend title
|
|
* @param alignment Text alignment for drawing the legend title
|
|
* @note added in 2.3
|
|
* @see titleAlignment
|
|
*/
|
|
void setTitleAlignment( Qt::AlignmentFlag alignment );
|
|
|
|
/** Returns reference to modifiable style */
|
|
QgsComposerLegendStyle & rstyle( QgsComposerLegendStyle::Style s );
|
|
/** Returns style */
|
|
QgsComposerLegendStyle style( QgsComposerLegendStyle::Style s ) const;
|
|
void setStyle( QgsComposerLegendStyle::Style s, const QgsComposerLegendStyle style );
|
|
|
|
QFont styleFont( QgsComposerLegendStyle::Style s ) const;
|
|
/** Set style font */
|
|
void setStyleFont( QgsComposerLegendStyle::Style s, const QFont& f );
|
|
|
|
/** Set style margin*/
|
|
void setStyleMargin( QgsComposerLegendStyle::Style s, double margin );
|
|
void setStyleMargin( QgsComposerLegendStyle::Style s, QgsComposerLegendStyle::Side side, double margin );
|
|
|
|
double boxSpace() const;
|
|
void setBoxSpace( double s );
|
|
|
|
double columnSpace() const;
|
|
void setColumnSpace( double s );
|
|
|
|
QColor fontColor() const;
|
|
void setFontColor( const QColor& c );
|
|
|
|
double symbolWidth() const;
|
|
void setSymbolWidth( double w );
|
|
|
|
double symbolHeight() const;
|
|
void setSymbolHeight( double h );
|
|
|
|
double wmsLegendWidth() const;
|
|
void setWmsLegendWidth( double w );
|
|
|
|
double wmsLegendHeight() const;
|
|
void setWmsLegendHeight( double h );
|
|
|
|
void setWrapChar( const QString& t );
|
|
QString wrapChar() const;
|
|
|
|
int columnCount() const;
|
|
void setColumnCount( int c );
|
|
|
|
int splitLayer() const;
|
|
void setSplitLayer( bool s );
|
|
|
|
int equalColumnWidth() const;
|
|
void setEqualColumnWidth( bool s );
|
|
|
|
void setComposerMap( const QgsComposerMap* map );
|
|
const QgsComposerMap* composerMap() const;
|
|
|
|
/**Updates the model and all legend entries*/
|
|
void updateLegend();
|
|
|
|
/** stores state in Dom node
|
|
* @param elem is Dom element corresponding to 'Composer' tag
|
|
* @param doc Dom document
|
|
*/
|
|
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
|
|
|
|
/** sets state from Dom document
|
|
* @param itemElem is Dom node corresponding to item tag
|
|
* @param doc is Dom document
|
|
*/
|
|
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
|
|
|
|
public slots:
|
|
/**Data changed*/
|
|
void synchronizeWithModel();
|
|
/**Sets mCompositionMap to 0 if the map is deleted*/
|
|
void invalidateCurrentMap();
|
|
};
|