QGIS API Documentation  3.6.0-Noosa (5873452)
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 
21 QgsLegendSymbolItem::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 
66 bool 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 }
QgsLegendSymbolItem()=default
Constructor for QgsLegendSymbolItem.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
QgsLegendSymbolItem & operator=(const QgsLegendSymbolItem &other)
void setSymbol(QgsSymbol *s)
Sets the symbol of the item.
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.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
bool isScaleOK(double scale) const
Determine whether given scale is within the scale range. Returns true if scale or scale range is inva...
Object that keeps configuration of appearance of marker symbol&#39;s data-defined size in legend...
void setDataDefinedSizeLegendSettings(QgsDataDefinedSizeLegend *settings)
Sets extra information about data-defined size.