QGIS API Documentation 3.41.0-Master (57ec4277f5e)
Loading...
Searching...
No Matches
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
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
29
40
45
47{
48 if ( mMethods.contains( method->id() ) )
49 return false;
50
51 mMethods.insert( method->id(), method );
52 return true;
53}
54
55std::unique_ptr< QgsClassificationMethod > QgsClassificationMethodRegistry::method( const QString &id )
56{
57 auto it = mMethods.constFind( id );
58 if ( it == mMethods.constEnd() )
59 return std::make_unique< QgsClassificationCustom >();
60 return it.value()->clone();
61}
62
64{
65 QMap<QString, QString> methods;
66 for ( const QgsClassificationMethod *method : std::as_const( mMethods ) )
67 methods.insert( method->name(), method->id() );
68 return methods;
69}
70
71QIcon QgsClassificationMethodRegistry::icon( const QString &id ) const
72{
73 QgsClassificationMethod *method = mMethods.value( id, nullptr );
74 if ( method )
75 return method->icon();
76 else
77 return QIcon();
78}
79
QgsClassificationEqualInterval is an implementation of QgsClassificationMethod for equal intervals.
Implementation of a fixed interval classification.
QgsClassificationJenks is an implementation of QgsClassificationMethod for natural breaks based on Je...
Implementation of a logarithmic scale method.
std::unique_ptr< QgsClassificationMethod > method(const QString &id)
Returns a new instance of the method for the given id.
bool addMethod(QgsClassificationMethod *method)
Adds a method to the registry Returns false if a method with same id already exists.
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.
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.