mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#11768 Show current time step in result plot
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
#include "RiuQwtPlotWheelZoomer.h"
|
||||
#include "RiuQwtPlotZoomer.h"
|
||||
#include "RiuQwtSymbol.h"
|
||||
#include "RiuResultQwtPlot.h"
|
||||
|
||||
#include "cvfColor3.h"
|
||||
|
||||
|
@@ -27,7 +27,6 @@
|
||||
|
||||
class RimFlowCharacteristicsPlot;
|
||||
class RiuNightchartsWidget;
|
||||
class RiuResultQwtPlot;
|
||||
class RiuQwtPlotCurve;
|
||||
|
||||
class QLabel;
|
||||
|
@@ -42,7 +42,9 @@
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_plot_grid.h"
|
||||
#include "qwt_plot_layout.h"
|
||||
#include "qwt_plot_marker.h"
|
||||
#include "qwt_scale_engine.h"
|
||||
#include "qwt_text.h"
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
@@ -80,7 +82,7 @@ void RiuResultQwtPlot::addCurve( const RimCase* rimCase,
|
||||
return;
|
||||
}
|
||||
|
||||
RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve( nullptr, "Curve 1" );
|
||||
auto plotCurve = new RiuQwtPlotCurve( nullptr, "Curve 1" );
|
||||
|
||||
plotCurve->setSamplesFromDatesAndYValues( dateTimes, timeHistoryValues, false );
|
||||
plotCurve->setTitle( curveName );
|
||||
@@ -88,7 +90,7 @@ void RiuResultQwtPlot::addCurve( const RimCase* rimCase,
|
||||
plotCurve->setPen( QPen( QColor( curveColor.rByte(), curveColor.gByte(), curveColor.bByte() ) ) );
|
||||
|
||||
plotCurve->attach( this );
|
||||
m_plotCurves.push_back( plotCurve );
|
||||
m_plotItems.push_back( plotCurve );
|
||||
|
||||
setAxisScale( QwtAxis::XTop, QwtDate::toDouble( dateTimes.front() ), QwtDate::toDouble( dateTimes.back() ) );
|
||||
applyFontSizes( false );
|
||||
@@ -124,18 +126,41 @@ void RiuResultQwtPlot::addCurve( const RimCase* rimCase,
|
||||
addCurve( rimCase, curveName, curveColor, dateTimes, timeHistoryValues );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuResultQwtPlot::showTimeStep( const QDateTime& dateTime )
|
||||
{
|
||||
if ( !dateTime.isValid() ) return;
|
||||
|
||||
auto lineMarker = new QwtPlotMarker;
|
||||
|
||||
QPen pen;
|
||||
pen.setStyle( Qt::DashLine );
|
||||
lineMarker->setLinePen( pen );
|
||||
|
||||
lineMarker->setXValue( QwtDate::toDouble( dateTime ) );
|
||||
lineMarker->setLineStyle( QwtPlotMarker::VLine );
|
||||
lineMarker->setLabel( QString( "Time Step" ) );
|
||||
lineMarker->setLabelAlignment( Qt::AlignTop | Qt::AlignRight );
|
||||
lineMarker->setLabelOrientation( Qt::Vertical );
|
||||
lineMarker->attach( this );
|
||||
|
||||
m_plotItems.push_back( lineMarker );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuResultQwtPlot::deleteAllCurves()
|
||||
{
|
||||
for ( size_t i = 0; i < m_plotCurves.size(); i++ )
|
||||
for ( size_t i = 0; i < m_plotItems.size(); i++ )
|
||||
{
|
||||
m_plotCurves[i]->detach();
|
||||
delete m_plotCurves[i];
|
||||
m_plotItems[i]->detach();
|
||||
delete m_plotItems[i];
|
||||
}
|
||||
|
||||
m_plotCurves.clear();
|
||||
m_plotItems.clear();
|
||||
|
||||
m_caseNames.clear();
|
||||
m_curveNames.clear();
|
||||
|
@@ -58,6 +58,8 @@ public:
|
||||
const std::vector<double>& frameTimes,
|
||||
const std::vector<double>& timeHistoryValues );
|
||||
|
||||
void showTimeStep( const QDateTime& dateTime );
|
||||
|
||||
void deleteAllCurves();
|
||||
|
||||
protected:
|
||||
@@ -74,7 +76,7 @@ private slots:
|
||||
void slotCurrentPlotDataInTextDialog();
|
||||
|
||||
private:
|
||||
std::vector<QwtPlotCurve*> m_plotCurves;
|
||||
std::vector<QwtPlotItem*> m_plotItems;
|
||||
|
||||
std::map<int, QString> m_caseNames;
|
||||
std::map<int, std::vector<QDateTime>> m_timeSteps;
|
||||
|
@@ -188,6 +188,11 @@ void RiuSelectionChangedHandler::addResultCurveFromSelectionItem( const RiuEclip
|
||||
eclipseSelectionItem->m_color,
|
||||
timeStepDates,
|
||||
timeHistoryValues );
|
||||
|
||||
if ( eclipseSelectionItem->m_timestepIdx < timeStepDates.size() )
|
||||
{
|
||||
RiuMainWindow::instance()->resultPlot()->showTimeStep( timeStepDates[eclipseSelectionItem->m_timestepIdx] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user