mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#859 Added time from start of simulation option
This commit is contained in:
@@ -71,8 +71,7 @@ void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vector<Q
|
||||
RigCurveDataTools::computePolyLineStartStopIndices(intervalsOfValidValues, &filteredIntervals);
|
||||
}
|
||||
|
||||
|
||||
for (size_t i = 0; i < filteredDateTimes.size(); i++)
|
||||
for ( size_t i = 0; i < filteredDateTimes.size(); i++ )
|
||||
{
|
||||
double milliSecSinceEpoch = QwtDate::toDouble(filteredDateTimes[i]);
|
||||
points << QPointF(milliSecSinceEpoch, filteredTimeHistoryValues[i]);
|
||||
@@ -83,6 +82,73 @@ void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vector<Q
|
||||
this->setLineSegmentStartStopIndices(filteredIntervals);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::setSamplesFromTimeTAndValues(const std::vector<time_t>& dateTimes, const std::vector<double>& timeHistoryValues, bool removeNegativeValues)
|
||||
{
|
||||
CVF_ASSERT(dateTimes.size() == timeHistoryValues.size());
|
||||
|
||||
QPolygonF points;
|
||||
std::vector< std::pair<size_t, size_t> > filteredIntervals;
|
||||
{
|
||||
std::vector<double> filteredTimeHistoryValues;
|
||||
std::vector<time_t> filteredDateTimes;
|
||||
|
||||
{
|
||||
std::vector< std::pair<size_t, size_t> > intervalsOfValidValues;
|
||||
RigCurveDataTools::calculateIntervalsOfValidValues(timeHistoryValues, &intervalsOfValidValues, removeNegativeValues);
|
||||
|
||||
RigCurveDataTools::getValuesByIntervals(timeHistoryValues, intervalsOfValidValues, &filteredTimeHistoryValues);
|
||||
RigCurveDataTools::getValuesByIntervals(dateTimes, intervalsOfValidValues, &filteredDateTimes);
|
||||
|
||||
RigCurveDataTools::computePolyLineStartStopIndices(intervalsOfValidValues, &filteredIntervals);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < filteredDateTimes.size(); i++)
|
||||
{
|
||||
double milliSecSinceEpoch = filteredDateTimes[i] * 1000; // This is kind of hack, as the c++ standard does not state what time_t is. "Almost always" secs since epoch according to cppreference.com
|
||||
points << QPointF(milliSecSinceEpoch, filteredTimeHistoryValues[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this->setSamples(points);
|
||||
this->setLineSegmentStartStopIndices(filteredIntervals);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuLineSegmentQwtPlotCurve::setSamplesFromTimeAndValues(const std::vector<double>& times, const std::vector<double>& timeHistoryValues, bool removeNegativeValues)
|
||||
{
|
||||
CVF_ASSERT(times.size() == timeHistoryValues.size());
|
||||
|
||||
QPolygonF points;
|
||||
std::vector< std::pair<size_t, size_t> > filteredIntervals;
|
||||
{
|
||||
std::vector<double> filteredTimeHistoryValues;
|
||||
std::vector<double> filteredTimes;
|
||||
|
||||
{
|
||||
std::vector< std::pair<size_t, size_t> > intervalsOfValidValues;
|
||||
RigCurveDataTools::calculateIntervalsOfValidValues(timeHistoryValues, &intervalsOfValidValues, removeNegativeValues);
|
||||
|
||||
RigCurveDataTools::getValuesByIntervals(timeHistoryValues, intervalsOfValidValues, &filteredTimeHistoryValues);
|
||||
RigCurveDataTools::getValuesByIntervals(times, intervalsOfValidValues, &filteredTimes);
|
||||
|
||||
RigCurveDataTools::computePolyLineStartStopIndices(intervalsOfValidValues, &filteredIntervals);
|
||||
}
|
||||
|
||||
for ( size_t i = 0; i < filteredTimes.size(); i++ )
|
||||
{
|
||||
points << QPointF(filteredTimes[i], filteredTimeHistoryValues[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this->setSamples(points);
|
||||
this->setLineSegmentStartStopIndices(filteredIntervals);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -48,6 +48,8 @@ public:
|
||||
virtual ~RiuLineSegmentQwtPlotCurve();
|
||||
|
||||
void setSamplesFromDateAndValues(const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues, bool removeNegativeValues);
|
||||
void setSamplesFromTimeTAndValues(const std::vector<time_t>& dateTimes, const std::vector<double>& timeHistoryValues, bool removeNegativeValues);
|
||||
void setSamplesFromTimeAndValues(const std::vector<double>& times, const std::vector<double>& timeHistoryValues, bool removeNegativeValues);
|
||||
|
||||
void setLineSegmentStartStopIndices(const std::vector< std::pair<size_t, size_t> >& lineSegmentStartStopIndices);
|
||||
|
||||
|
||||
@@ -331,12 +331,7 @@ void RiuSummaryQwtPlot::setDefaults()
|
||||
|
||||
plotLayout()->setAlignCanvasToScales(true);
|
||||
|
||||
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw(Qt::UTC);
|
||||
scaleDraw->setDateFormat(QwtDate::Year, QString("dd-MM-yyyy"));
|
||||
|
||||
QwtDateScaleEngine* scaleEngine = new QwtDateScaleEngine(Qt::UTC);
|
||||
setAxisScaleEngine(QwtPlot::xBottom, scaleEngine);
|
||||
setAxisScaleDraw(QwtPlot::xBottom, scaleDraw);
|
||||
useDateBasedTimeAxis();
|
||||
|
||||
QFont xAxisFont = axisFont(QwtPlot::xBottom);
|
||||
xAxisFont.setPixelSize(11);
|
||||
@@ -364,6 +359,30 @@ void RiuSummaryQwtPlot::setDefaults()
|
||||
this->insertLegend(legend, BottomLegend);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::useDateBasedTimeAxis()
|
||||
{
|
||||
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw(Qt::UTC);
|
||||
scaleDraw->setDateFormat(QwtDate::Year, QString("dd-MM-yyyy"));
|
||||
|
||||
QwtDateScaleEngine* scaleEngine = new QwtDateScaleEngine(Qt::UTC);
|
||||
setAxisScaleEngine(QwtPlot::xBottom, scaleEngine);
|
||||
setAxisScaleDraw(QwtPlot::xBottom, scaleDraw);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryQwtPlot::useTimeBasedTimeAxis()
|
||||
{
|
||||
setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine());
|
||||
setAxisScaleDraw(QwtPlot::xBottom, new QwtScaleDraw());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -46,6 +46,9 @@ public:
|
||||
|
||||
RimSummaryPlot* ownerPlotDefinition();
|
||||
|
||||
void useDateBasedTimeAxis();
|
||||
void useTimeBasedTimeAxis();
|
||||
|
||||
void currentVisibleWindow(QwtInterval* leftAxis,
|
||||
QwtInterval* rightAxis,
|
||||
QwtInterval* timeAxis) const;
|
||||
|
||||
Reference in New Issue
Block a user