QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgslegendsymbolitemv2.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgslegendsymbolitemv2.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 "qgslegendsymbolitemv2.h"
17 
18 #include "qgssymbolv2.h"
19 
21  : mSymbol( nullptr )
22  , mCheckable( false )
23  , mOriginalSymbolPointer( nullptr )
24  , mScaleMinDenom( -1 )
25  , mScaleMaxDenom( -1 )
26  , mLevel( 0 )
27 {
28 }
29 
31  : mSymbol( symbol ? symbol->clone() : nullptr )
32  , mLabel( label )
33  , mKey( ruleKey )
34  , mCheckable( checkable )
35  , mOriginalSymbolPointer( symbol )
36  , mScaleMinDenom( scaleMinDenom )
37  , mScaleMaxDenom( scaleMaxDenom )
38  , mLevel( level )
39  , mParentKey( parentRuleKey )
40 {
41 }
42 
44  : mSymbol( nullptr )
45  , mOriginalSymbolPointer( nullptr )
46 {
47  *this = other;
48 }
49 
51 {
52  delete mSymbol;
53 }
54 
56 {
57  if ( this == &other )
58  return *this;
59 
60  setSymbol( other.mSymbol );
61  mLabel = other.mLabel;
62  mKey = other.mKey;
63  mCheckable = other.mCheckable;
64  mOriginalSymbolPointer = other.mOriginalSymbolPointer;
65  mScaleMinDenom = other.mScaleMinDenom;
66  mScaleMaxDenom = other.mScaleMaxDenom;
67  mLevel = other.mLevel;
68  mParentKey = other.mParentKey;
69 
70  return *this;
71 }
72 
73 bool QgsLegendSymbolItemV2::isScaleOK( double scale ) const
74 {
75  if ( scale <= 0 )
76  return true;
77  if ( mScaleMinDenom <= 0 && mScaleMaxDenom <= 0 )
78  return true;
79  if ( mScaleMinDenom > 0 && mScaleMinDenom > scale )
80  return false;
81  if ( mScaleMaxDenom > 0 && mScaleMaxDenom < scale )
82  return false;
83  return true;
84 }
85 
87 {
88  delete mSymbol;
89  mSymbol = s ? s->clone() : nullptr;
90  mOriginalSymbolPointer = s;
91 }
int scaleMinDenom() const
Min scale denominator of the scale range.
virtual QgsSymbolV2 * clone() const =0
QString ruleKey() const
Return unique identifier of the rule for identification of the item within renderer.
bool isScaleOK(double scale) const
Determine whether given scale is within the scale range. Returns true if scale or scale range is inva...
QString parentRuleKey() const
Key of the parent legend node.
QString label() const
Return text label.
int scaleMaxDenom() const
Max scale denominator of the scale range.
QgsSymbolV2 * symbol() const
Return associated symbol. May be null.
QgsLegendSymbolItemV2 & operator=(const QgsLegendSymbolItemV2 &other)
int level() const
Identation level that tells how deep the item is in a hierarchy of items. For flat lists level is 0...
void setSymbol(QgsSymbolV2 *s)
Set symbol of the item. Takes ownership of symbol.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...