mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Fix log axis crash in Grid Cross Plot and refactor log axis range code
This commit is contained in:
@@ -406,6 +406,10 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
||||
RigEclipseCrossPlotResult result = RigEclipseCrossPlotDataExtractor::extract(
|
||||
eclipseCase->eclipseCaseData(), m_timeStep(), xAddress, yAddress, m_grouping(), groupAddress, timeStepCellVisibilityMap);
|
||||
|
||||
if (isXAxisLogarithmic() || isYAxisLogarithmic())
|
||||
{
|
||||
filterInvalidCurveValues(&result);
|
||||
}
|
||||
createCurves(result);
|
||||
|
||||
if (updateParentPlot)
|
||||
@@ -877,6 +881,26 @@ void RimGridCrossPlotCurveSet::exportFormattedData(RifEclipseDataTableFormatter&
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGridCrossPlotCurveSet::isXAxisLogarithmic() const
|
||||
{
|
||||
RimGridCrossPlot* parent = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(parent);
|
||||
return parent->isXAxisLogarithmic();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGridCrossPlotCurveSet::isYAxisLogarithmic() const
|
||||
{
|
||||
RimGridCrossPlot* parent = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(parent);
|
||||
return parent->isYAxisLogarithmic();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1001,6 +1025,42 @@ bool RimGridCrossPlotCurveSet::hasMultipleTimeSteps() const
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCrossPlotCurveSet::filterInvalidCurveValues(RigEclipseCrossPlotResult* result)
|
||||
{
|
||||
bool xLog = isXAxisLogarithmic();
|
||||
bool yLog = isYAxisLogarithmic();
|
||||
|
||||
if (xLog || yLog)
|
||||
{
|
||||
|
||||
RigEclipseCrossPlotResult validResult;
|
||||
for (size_t i = 0; i < result->xValues.size(); ++i)
|
||||
{
|
||||
double xValue = result->xValues[i];
|
||||
double yValue = result->yValues[i];
|
||||
bool invalid = (xLog && xValue <= 0.0) || (yLog && yValue <= 0.0);
|
||||
if (!invalid)
|
||||
{
|
||||
validResult.xValues.push_back(xValue);
|
||||
validResult.yValues.push_back(yValue);
|
||||
if (i < result->groupValuesContinuous.size())
|
||||
{
|
||||
validResult.groupValuesContinuous.push_back(result->groupValuesContinuous[i]);
|
||||
}
|
||||
if (i < result->groupValuesDiscrete.size())
|
||||
{
|
||||
validResult.groupValuesDiscrete.push_back(result->groupValuesDiscrete[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*result = validResult;
|
||||
}
|
||||
}
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimGridCrossPlotCurveSetNameConfig, "RimGridCrossPlotCurveSetNameConfig");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user