QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgslegendsymbolitem.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslegendsymbolitem.cpp
3 --------------------------------------
4 Date : August 2014
5 Copyright : (C) 2014 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgslegendsymbolitem.h"
17
19#include "qgssymbol.h"
20
21QgsLegendSymbolItem::QgsLegendSymbolItem( QgsSymbol *symbol, const QString &label, const QString &ruleKey, bool checkable, int scaleMinDenom, int scaleMaxDenom, int level, const QString &parentRuleKey )
22 : mSymbol( symbol ? symbol->clone() : nullptr )
23 , mLabel( label )
24 , mKey( ruleKey )
25 , mCheckable( checkable )
26 , mOriginalSymbolPointer( symbol )
27 , mScaleMinDenom( scaleMinDenom )
28 , mScaleMaxDenom( scaleMaxDenom )
29 , mLevel( level )
30 , mParentKey( parentRuleKey )
31{
32}
33
35{
36 *this = other;
37}
38
40{
41 delete mSymbol;
42 delete mDataDefinedSizeLegendSettings;
43}
44
46{
47 if ( this == &other )
48 return *this;
49
50 delete mSymbol;
51 mSymbol = other.mSymbol ? other.mSymbol->clone() : nullptr;
52 mLabel = other.mLabel;
53 mKey = other.mKey;
54 mCheckable = other.mCheckable;
55 delete mDataDefinedSizeLegendSettings;
56 mDataDefinedSizeLegendSettings = other.mDataDefinedSizeLegendSettings ? new QgsDataDefinedSizeLegend( *other.mDataDefinedSizeLegendSettings ) : nullptr;
57 mOriginalSymbolPointer = other.mOriginalSymbolPointer;
58 mScaleMinDenom = other.mScaleMinDenom;
59 mScaleMaxDenom = other.mScaleMaxDenom;
60 mLevel = other.mLevel;
61 mParentKey = other.mParentKey;
62
63 return *this;
64}
65
66bool QgsLegendSymbolItem::isScaleOK( double scale ) const
67{
68 if ( scale <= 0 )
69 return true;
70 if ( mScaleMinDenom <= 0 && mScaleMaxDenom <= 0 )
71 return true;
72 if ( mScaleMinDenom > 0 && mScaleMinDenom > scale )
73 return false;
74 if ( mScaleMaxDenom > 0 && mScaleMaxDenom < scale )
75 return false;
76 return true;
77}
78
80{
81 delete mSymbol;
82 mSymbol = s ? s->clone() : nullptr;
83 mOriginalSymbolPointer = s;
84}
85
87{
88 delete mDataDefinedSizeLegendSettings;
89 mDataDefinedSizeLegendSettings = settings;
90}
91
93{
94 return mDataDefinedSizeLegendSettings;
95}
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
QgsDataDefinedSizeLegend * dataDefinedSizeLegendSettings() const
Returns extra information for data-defined size legend rendering.
void setDataDefinedSizeLegendSettings(QgsDataDefinedSizeLegend *settings)
Sets extra information about data-defined size.
void setSymbol(QgsSymbol *s)
Sets the symbol of the item.
QgsLegendSymbolItem & operator=(const QgsLegendSymbolItem &other)
bool isScaleOK(double scale) const
Determine whether given scale is within the scale range. Returns true if scale or scale range is inva...
QgsLegendSymbolItem()=default
Constructor for QgsLegendSymbolItem.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:94
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.