diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index 9f82627161..85c9fba4af 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -203,7 +203,7 @@ void RimSummaryCurve::setSummaryAddress(const RifEclipseSummaryAddress& address) //-------------------------------------------------------------------------------------------------- std::string RimSummaryCurve::unitName() { - RifSummaryReaderInterface* reader = summaryReader(); + RifSummaryReaderInterface* reader = yValuesSummaryReader(); if (reader) return reader->unitName(this->summaryAddress()); return ""; @@ -216,7 +216,7 @@ std::vector RimSummaryCurve::yValues() const { std::vector values; - RifSummaryReaderInterface* reader = summaryReader(); + RifSummaryReaderInterface* reader = yValuesSummaryReader(); if ( !reader ) return values; @@ -226,13 +226,31 @@ std::vector RimSummaryCurve::yValues() const return values; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryCurve::xValues() const +{ + std::vector values; + + if (m_xValuesSummaryCase() && m_xValuesSummaryCase()->summaryReader()) + { + RifSummaryReaderInterface* reader = m_xValuesSummaryCase()->summaryReader(); + + RifEclipseSummaryAddress addr = m_xValuesCurveVariable()->address(); + reader->values(addr, &values); + } + + return values; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- const std::vector& RimSummaryCurve::timeSteps() const { static std::vector emptyVector; - RifSummaryReaderInterface* reader = summaryReader(); + RifSummaryReaderInterface* reader = yValuesSummaryReader(); if ( !reader ) return emptyVector; @@ -331,39 +349,62 @@ void RimSummaryCurve::onLoadDataAndUpdate(bool updateParentPlot) if (isCurveVisible()) { std::vector dateTimes = this->timeSteps(); - std::vector values = this->yValues(); + std::vector yValues = this->yValues(); RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfType(plot); bool isLogCurve = plot->isLogarithmicScaleEnabled(this->yAxis()); - if (dateTimes.size() > 0 && dateTimes.size() == values.size()) + bool shouldPopulateViewWithEmptyData = false; + + if (m_isCrossPlot()) { - if (plot->timeAxisProperties()->timeMode() == RimSummaryTimeAxisProperties::DATE) + std::vector xValues = this->xValues(); + + if (!yValues.empty() && yValues.size() == xValues.size()) { - m_qwtPlotCurve->setSamplesFromTimeTAndYValues(dateTimes, values, isLogCurve); + m_qwtPlotCurve->setSamplesFromXValuesAndYValues(xValues, yValues, isLogCurve); } else { - double timeScale = plot->timeAxisProperties()->fromTimeTToDisplayUnitScale(); - - std::vector times; - if ( dateTimes.size() ) - { - time_t startDate = dateTimes[0]; - for ( time_t& date: dateTimes ) - { - times.push_back(timeScale*(date - startDate)); - } - } - - m_qwtPlotCurve->setSamplesFromXValuesAndYValues(times, values, isLogCurve); + shouldPopulateViewWithEmptyData = true; } - } else { - m_qwtPlotCurve->setSamplesFromTimeTAndYValues(std::vector(), std::vector(), isLogCurve); + if (dateTimes.size() > 0 && dateTimes.size() == yValues.size()) + { + if (plot->timeAxisProperties()->timeMode() == RimSummaryTimeAxisProperties::DATE) + { + m_qwtPlotCurve->setSamplesFromTimeTAndYValues(dateTimes, yValues, isLogCurve); + } + else + { + double timeScale = plot->timeAxisProperties()->fromTimeTToDisplayUnitScale(); + + std::vector times; + if ( dateTimes.size() ) + { + time_t startDate = dateTimes[0]; + for ( time_t& date: dateTimes ) + { + times.push_back(timeScale*(date - startDate)); + } + } + + m_qwtPlotCurve->setSamplesFromXValuesAndYValues(times, yValues, isLogCurve); + } + + } + else + { + shouldPopulateViewWithEmptyData = true; + } + } + + if (shouldPopulateViewWithEmptyData) + { + m_qwtPlotCurve->setSamplesFromXValuesAndYValues(std::vector(), std::vector(), isLogCurve); } if ( updateParentPlot && m_parentQwtPlot) @@ -533,34 +574,13 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifSummaryReaderInterface* RimSummaryCurve::summaryReader() const +RifSummaryReaderInterface* RimSummaryCurve::yValuesSummaryReader() const { if (!m_yValuesSummaryCase()) return nullptr; return m_yValuesSummaryCase()->summaryReader(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RimSummaryCurve::curveData(std::vector* timeSteps, std::vector* values) const -{ - CVF_ASSERT(timeSteps && values); - - RifSummaryReaderInterface* reader = summaryReader(); - - if (!reader) return false; - - RifEclipseSummaryAddress addr = m_yValuesCurveVariable()->address(); - - std::vector times = reader->timeSteps(addr); - *timeSteps = RifReaderEclipseSummary::fromTimeT(times); - - if (!times.size()) return false; - - return reader->values(addr, values); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.h index 00f2aa4a45..2b2018e2f4 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.h @@ -61,6 +61,7 @@ public: std::string unitName(); std::vector yValues() const; + std::vector xValues() const; const std::vector& timeSteps() const; void setYAxis(RiaDefines::PlotAxis plotAxis); @@ -77,8 +78,7 @@ protected: virtual void onLoadDataAndUpdate(bool updateParentPlot) override; private: - RifSummaryReaderInterface* summaryReader() const; - bool curveData(std::vector* timeSteps, std::vector* values) const; + RifSummaryReaderInterface* yValuesSummaryReader() const; void calculateCurveInterpolationFromAddress();