@@ -877,26 +877,26 @@ void QgsGraduatedSymbolRendererWidget::updateMethodParameters()
877
877
clearParameterWidgets ();
878
878
879
879
const QString methodId = cboGraduatedMode->currentData ().toString ();
880
- std::unique_ptr< QgsClassificationMethod > method = QgsApplication::classificationMethodRegistry ()->method ( methodId );
881
- Q_ASSERT ( method );
880
+ mClassificationMethod = QgsApplication::classificationMethodRegistry ()->method ( methodId );
881
+ Q_ASSERT ( mClassificationMethod . get () );
882
882
883
883
// need more context?
884
884
QgsProcessingContext context;
885
885
886
- for ( const QgsProcessingParameterDefinition *def : method ->parameterDefinitions () )
886
+ for ( const QgsProcessingParameterDefinition *def : mClassificationMethod ->parameterDefinitions () )
887
887
{
888
888
QgsAbstractProcessingParameterWidgetWrapper *ppww = QgsGui::processingGuiRegistry ()->createParameterWidgetWrapper ( def, QgsProcessingGui::Standard );
889
889
mParametersLayout ->addRow ( ppww->createWrappedLabel (), ppww->createWrappedWidget ( context ) );
890
890
891
- QVariant value = method ->parameterValues ().value ( def->name (), def->defaultValueForGui () );
891
+ QVariant value = mClassificationMethod ->parameterValues ().value ( def->name (), def->defaultValueForGui () );
892
892
ppww->setParameterValue ( value, context );
893
893
894
894
connect ( ppww, &QgsAbstractProcessingParameterWidgetWrapper::widgetValueHasChanged, this , &QgsGraduatedSymbolRendererWidget::classifyGraduated );
895
895
896
896
mParameterWidgetWrappers .push_back ( std::unique_ptr<QgsAbstractProcessingParameterWidgetWrapper>( ppww ) );
897
897
}
898
898
899
- spinGraduatedClasses->setEnabled ( !( method ->flags () & QgsClassificationMethod::MethodProperty::IgnoresClassCount ) );
899
+ spinGraduatedClasses->setEnabled ( !( mClassificationMethod ->flags () & QgsClassificationMethod::MethodProperty::IgnoresClassCount ) );
900
900
}
901
901
902
902
void QgsGraduatedSymbolRendererWidget::toggleMethodWidgets ( MethodMode mode )
@@ -1041,17 +1041,13 @@ void QgsGraduatedSymbolRendererWidget::classifyGraduated()
1041
1041
1042
1042
void QgsGraduatedSymbolRendererWidget::classifyGraduatedImpl ()
1043
1043
{
1044
- if ( mBlockUpdates )
1044
+ if ( mBlockUpdates || ! mClassificationMethod )
1045
1045
return ;
1046
1046
1047
1047
QgsTemporaryCursorOverride override ( Qt::WaitCursor );
1048
1048
QString attrName = mExpressionWidget ->currentField ();
1049
1049
int nclasses = spinGraduatedClasses->value ();
1050
1050
1051
- const QString methodId = cboGraduatedMode->currentData ().toString ();
1052
- std::unique_ptr< QgsClassificationMethod > method = QgsApplication::classificationMethodRegistry ()->method ( methodId );
1053
- Q_ASSERT ( method );
1054
-
1055
1051
int attrNum = mLayer ->fields ().lookupField ( attrName );
1056
1052
1057
1053
QVariant minVal;
@@ -1064,29 +1060,29 @@ void QgsGraduatedSymbolRendererWidget::classifyGraduatedImpl()
1064
1060
mSymmetryPointValidator ->setTop ( maximum );
1065
1061
mSymmetryPointValidator ->setMaxDecimals ( spinPrecision->value () );
1066
1062
1067
- if ( method ->id () == QgsClassificationEqualInterval::METHOD_ID || method ->id () == QgsClassificationStandardDeviation::METHOD_ID )
1063
+ if ( mClassificationMethod ->id () == QgsClassificationEqualInterval::METHOD_ID || mClassificationMethod ->id () == QgsClassificationStandardDeviation::METHOD_ID )
1068
1064
{
1069
1065
// knowing that spinSymmetryPointForOtherMethods->value() is automatically put at minimum when out of min-max
1070
1066
// using "(maximum-minimum)/100)" to avoid direct comparison of doubles
1071
1067
double currentValue = QgsDoubleValidator::toDouble ( cboSymmetryPoint->currentText () );
1072
1068
if ( currentValue < ( minimum + ( maximum - minimum ) / 100 . ) || currentValue > ( maximum - ( maximum - minimum ) / 100 . ) )
1073
- cboSymmetryPoint->setItemText ( cboSymmetryPoint->currentIndex (), QLocale ().toString ( minimum + ( maximum - minimum ) / 2 ., ' f' , method ->labelPrecision () + 2 ) );
1069
+ cboSymmetryPoint->setItemText ( cboSymmetryPoint->currentIndex (), QLocale ().toString ( minimum + ( maximum - minimum ) / 2 ., ' f' , mClassificationMethod ->labelPrecision () + 2 ) );
1074
1070
}
1075
1071
1076
1072
if ( mGroupBoxSymmetric ->isChecked () )
1077
1073
{
1078
1074
double symmetryPoint = QgsDoubleValidator::toDouble ( cboSymmetryPoint->currentText () );
1079
1075
bool astride = cbxAstride->isChecked ();
1080
- method ->setSymmetricMode ( true , symmetryPoint, astride );
1076
+ mClassificationMethod ->setSymmetricMode ( true , symmetryPoint, astride );
1081
1077
}
1082
1078
1083
1079
QVariantMap parameterValues;
1084
1080
for ( const auto &ppww : std::as_const ( mParameterWidgetWrappers ) )
1085
1081
parameterValues.insert ( ppww->parameterDefinition ()->name (), ppww->parameterValue () );
1086
- method ->setParameterValues ( parameterValues );
1082
+ mClassificationMethod ->setParameterValues ( parameterValues );
1087
1083
1088
1084
// set method to renderer
1089
- mRenderer ->setClassificationMethod ( method .release () );
1085
+ mRenderer ->setClassificationMethod ( mClassificationMethod -> clone () .release () );
1090
1086
1091
1087
// create and set new renderer
1092
1088
mRenderer ->setClassAttribute ( attrName );
0 commit comments