QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsclassificationmethodregistry.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsclassificationmethodregistry.h
3  ---------------------
4  begin : September 2019
5  copyright : (C) 2019 by Denis Rouzaud
6  email : [email protected]
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 <QIcon>
17 
19 
20 // classification methods
24 #include "qgsclassificationjenks.h"
29 
31 {
39 }
40 
42 {
43  qDeleteAll( mMethods );
44 }
45 
47 {
48  if ( mMethods.contains( method->id() ) )
49  return false;
50 
51  mMethods.insert( method->id(), method );
52  return true;
53 }
54 
56 {
57  QgsClassificationMethod *method = mMethods.value( id, new QgsClassificationCustom() );
58  return method->clone();
59 }
60 
61 QMap<QString, QString> QgsClassificationMethodRegistry::methodNames() const
62 {
63  QMap<QString, QString> methods;
64  for ( const QgsClassificationMethod *method : std::as_const( mMethods ) )
65  methods.insert( method->name(), method->id() );
66  return methods;
67 }
68 
69 QIcon QgsClassificationMethodRegistry::icon( const QString &id ) const
70 {
71  QgsClassificationMethod *method = mMethods.value( id, nullptr );
72  if ( method )
73  return method->icon();
74  else
75  return QIcon();
76 }
77 
QgsClassificationMethod
QgsClassificationMethod is an abstract class for implementations of classification methods.
Definition: qgsclassificationmethod.h:88
qgsclassificationstandarddeviation.h
qgsclassificationcustom.h
QgsClassificationPrettyBreaks
QgsClassificationPrettyBreaks is an implementation of QgsClassificationMethod for pretty breaks.
Definition: qgsclassificationprettybreaks.h:28
QgsClassificationMethod::icon
virtual QIcon icon() const
The icon of the method.
Definition: qgsclassificationmethod.h:153
QgsClassificationMethodRegistry::method
QgsClassificationMethod * method(const QString &id)
Returns a new instance of the method for the given id.
Definition: qgsclassificationmethodregistry.cpp:55
qgsclassificationlogarithmic.h
qgsclassificationprettybreaks.h
QgsClassificationMethodRegistry::~QgsClassificationMethodRegistry
~QgsClassificationMethodRegistry()
Definition: qgsclassificationmethodregistry.cpp:41
QgsClassificationMethodRegistry::methodNames
QMap< QString, QString > methodNames() const
Returns a map <name, id> of all registered methods.
Definition: qgsclassificationmethodregistry.cpp:61
QgsClassificationEqualInterval
QgsClassificationEqualInterval is an implementation of QgsClassificationMethod for equal intervals.
Definition: qgsclassificationequalinterval.h:28
QgsClassificationQuantile
QgsClassificationQuantile is an implementation of QgsClassificationMethod based on quantiles.
Definition: qgsclassificationquantile.h:29
QgsClassificationMethod::clone
virtual QgsClassificationMethod * clone() const =0
Returns a clone of the method.
QgsClassificationCustom
QgsClassificationCustom is a dummy implementation of QgsClassification which does not compute any bre...
Definition: qgsclassificationcustom.h:28
QgsClassificationMethod::id
virtual QString id() const =0
The id of the method as saved in the project, must be unique in registry.
qgsclassificationjenks.h
QgsClassificationMethodRegistry::icon
QIcon icon(const QString &id) const
Returns the icon for a given method id.
Definition: qgsclassificationmethodregistry.cpp:69
QgsClassificationFixedInterval
Implementation of a fixed interval classification.
Definition: qgsclassificationfixedinterval.h:28
QgsClassificationMethodRegistry::addMethod
bool addMethod(QgsClassificationMethod *method)
Adds a method to the registry Returns false if a method with same id already exists.
Definition: qgsclassificationmethodregistry.cpp:46
qgsclassificationequalinterval.h
qgsclassificationfixedinterval.h
QgsClassificationLogarithmic
Implementation of a logarithmic scale method.
Definition: qgsclassificationlogarithmic.h:28
QgsClassificationJenks
QgsClassificationJenks is an implementation of QgsClassificationMethod for natural breaks based on Je...
Definition: qgsclassificationjenks.h:28
QgsClassificationStandardDeviation
QgsClassificationCustom is an implementation of QgsClassificationMethod based on standard deviation.
Definition: qgsclassificationstandarddeviation.h:28
qgsclassificationquantile.h
QgsClassificationMethodRegistry::QgsClassificationMethodRegistry
QgsClassificationMethodRegistry()
Definition: qgsclassificationmethodregistry.cpp:30
qgsclassificationmethodregistry.h
QgsClassificationMethod::name
virtual QString name() const =0
The readable and translate name of the method.