Skip to content

Commit

Permalink
Regression Curve: Clear and hide regression curve if no source data i…
Browse files Browse the repository at this point in the history
…s available
  • Loading branch information
magnesj committed Oct 17, 2023
1 parent 5ad8881 commit 4c0e1e6
Showing 1 changed file with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> xValues = m_sourceValuesX;
std::vector<double> yValues = m_sourceValuesY;
std::vector<time_t> timeStepsX = m_sourceTimeStepsX;
std::vector<time_t> 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<size_t> indicesToRemove;

if ( axisTypeX() == RiaDefines::HorizontalAxisType::SUMMARY_VECTOR )
Expand Down

0 comments on commit 4c0e1e6

Please sign in to comment.