QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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"
28 
30 {
37 }
38 
40 {
41  qDeleteAll( mMethods );
42 }
43 
45 {
46  if ( mMethods.contains( method->id() ) )
47  return false;
48 
49  mMethods.insert( method->id(), method );
50  return true;
51 }
52 
54 {
55  QgsClassificationMethod *method = mMethods.value( id, new QgsClassificationCustom() );
56  return method->clone();
57 }
58 
59 QMap<QString, QString> QgsClassificationMethodRegistry::methodNames() const
60 {
61  QMap<QString, QString> methods;
62  for ( const QgsClassificationMethod *method : std::as_const( mMethods ) )
63  methods.insert( method->name(), method->id() );
64  return methods;
65 }
66 
67 QIcon QgsClassificationMethodRegistry::icon( const QString &id ) const
68 {
69  QgsClassificationMethod *method = mMethods.value( id, nullptr );
70  if ( method )
71  return method->icon();
72  else
73  return QIcon();
74 }
75 
QgsClassificationCustom is a dummy implementation of QgsClassification which does not compute any bre...
QgsClassificationEqualInterval is an implementation of QgsClassificationMethod for equal intervals.
QgsClassificationJenks is an implementation of QgsClassificationMethod for natural breaks based on Je...
Implementation of a logarithmic scale method.
bool addMethod(QgsClassificationMethod *method)
Adds a method to the registry Returns false if a method with same id already exists.
QgsClassificationMethod * method(const QString &id)
Returns a new instance of the method for the given id.
QIcon icon(const QString &id) const
Returns the icon for a given method id.
QMap< QString, QString > methodNames() const
Returns a map <name, id> of all registered methods.
QgsClassificationMethod is an abstract class for implementations of classification methods.
virtual QString id() const =0
The id of the method as saved in the project, must be unique in registry.
virtual QgsClassificationMethod * clone() const =0
Returns a clone of the method.
virtual QString name() const =0
The readable and translate name of the method.
virtual QIcon icon() const
The icon of the method.
QgsClassificationPrettyBreaks is an implementation of QgsClassificationMethod for pretty breaks.
QgsClassificationQuantile is an implementation of QgsClassificationMethod based on quantiles.
QgsClassificationCustom is an implementation of QgsClassificationMethod based on standard deviation.