diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp index 767ad2df54e..e8829bdb5e9 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryRegressionAnalysisCurve.cpp @@ -160,27 +160,46 @@ void RimSummaryRegressionAnalysisCurve::onLoadDataAndUpdate( bool updateParentPl extractSourceCurveData(); updateDefaultValues(); + // Clear derived data + m_valuesX.clear(); + m_valuesY.clear(); + m_timeStepsX.clear(); + m_timeStepsY.clear(); + m_expressionText = "Undefined"; + std::vector xValues = m_sourceValuesX; std::vector yValues = m_sourceValuesY; std::vector timeStepsX = m_sourceTimeStepsX; std::vector timeStepsY = m_sourceTimeStepsY; - if ( yValues.empty() ) return; + QString errorMessage; + + if ( yValues.empty() ) + { + errorMessage += "No Y values found for regression curve.\n"; + } if ( axisTypeX() == RiaDefines::HorizontalAxisType::SUMMARY_VECTOR ) { - if ( xValues.size() != yValues.size() ) return RiaLogging::error( "X value count and Y value count differs." ); - if ( xValues.size() != timeStepsX.size() ) return RiaLogging::error( "X value count and X time step count differs." ); - if ( xValues.size() != timeStepsY.size() ) return RiaLogging::error( "X value count and Y time step count differs." ); + if ( xValues.size() != yValues.size() ) errorMessage += "X value count and Y value count differs."; + if ( xValues.size() != timeStepsX.size() ) errorMessage += "X value count and X time step count differs."; + if ( xValues.size() != timeStepsY.size() ) errorMessage += "X value count and Y time step count differs."; if ( timeStepsX != timeStepsY ) { - return RiaLogging::error( - "Differences in time steps for X and Y axis detected. This is currently not supported. Make sure that the same " - "case is used for both axis." ); + errorMessage += "Differences in time steps for X and Y axis detected. This is currently not supported. Make sure that the same " + "case is used for both axis."; } } + if ( !errorMessage.isEmpty() ) + { + // Call parent class to make sure the curve is removed from the plot + RimSummaryCurve::onLoadDataAndUpdate( updateParentPlot ); + + return RiaLogging::error( errorMessage ); + } + std::vector indicesToRemove; if ( axisTypeX() == RiaDefines::HorizontalAxisType::SUMMARY_VECTOR )