mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #8387 from OPM/qtcharts-summary-plots
Closes #8228 Major refactoring of summary plotting. Now possible to create plots both with Qwt and QtChart as plotting tool.
This commit is contained in:
committed by
GitHub
parent
d9bb82de91
commit
258fbddc10
@@ -34,6 +34,7 @@
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
#include "RiuPlotObjectPicker.h"
|
||||
#include "RiuPlotWidget.h"
|
||||
#include "RiuQwtPlotLegend.h"
|
||||
#include "RiuQwtPlotWidget.h"
|
||||
|
||||
@@ -133,7 +134,7 @@ RimPlotWindow* RiuMultiPlotPage::ownerPlotDefinition()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotPage::addPlot( RiuQwtPlotWidget* plotWidget )
|
||||
void RiuMultiPlotPage::addPlot( RiuPlotWidget* plotWidget )
|
||||
{
|
||||
// Insert the plot to the left of the scroll bar
|
||||
insertPlot( plotWidget, m_plotWidgets.size() );
|
||||
@@ -142,7 +143,7 @@ void RiuMultiPlotPage::addPlot( RiuQwtPlotWidget* plotWidget )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
|
||||
void RiuMultiPlotPage::insertPlot( RiuPlotWidget* plotWidget, size_t index )
|
||||
{
|
||||
m_plotWidgets.insert( static_cast<int>( index ), plotWidget );
|
||||
plotWidget->setVisible( false );
|
||||
@@ -166,9 +167,13 @@ void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
|
||||
legend->setMaxColumns( legendColumns );
|
||||
legend->horizontalScrollBar()->setVisible( false );
|
||||
legend->verticalScrollBar()->setVisible( false );
|
||||
legend->connect( plotWidget,
|
||||
SIGNAL( legendDataChanged( const QVariant&, const QList<QwtLegendData>& ) ),
|
||||
SLOT( updateLegend( const QVariant&, const QList<QwtLegendData>& ) ) );
|
||||
RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget );
|
||||
if ( qwtPlotWidget )
|
||||
{
|
||||
legend->connect( qwtPlotWidget->qwtPlot(),
|
||||
SIGNAL( legendDataChanged( const QVariant&, const QList<QwtLegendData>& ) ),
|
||||
SLOT( updateLegend( const QVariant&, const QList<QwtLegendData>& ) ) );
|
||||
}
|
||||
QObject::connect( legend, SIGNAL( legendUpdated() ), this, SLOT( onLegendUpdated() ) );
|
||||
|
||||
legend->contentsWidget()->layout()->setAlignment( Qt::AlignBottom | Qt::AlignHCenter );
|
||||
@@ -183,7 +188,7 @@ void RiuMultiPlotPage::insertPlot( RiuQwtPlotWidget* plotWidget, size_t index )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotPage::removePlot( RiuQwtPlotWidget* plotWidget )
|
||||
void RiuMultiPlotPage::removePlot( RiuPlotWidget* plotWidget )
|
||||
{
|
||||
if ( !plotWidget ) return;
|
||||
|
||||
@@ -215,7 +220,7 @@ void RiuMultiPlotPage::removePlot( RiuQwtPlotWidget* plotWidget )
|
||||
void RiuMultiPlotPage::removeAllPlots()
|
||||
{
|
||||
auto plotWidgets = m_plotWidgets;
|
||||
for ( RiuQwtPlotWidget* plotWidget : plotWidgets )
|
||||
for ( RiuPlotWidget* plotWidget : plotWidgets )
|
||||
{
|
||||
removePlot( plotWidget );
|
||||
}
|
||||
@@ -296,7 +301,7 @@ void RiuMultiPlotPage::setPagePreviewModeEnabled( bool previewMode )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuMultiPlotPage::indexOfPlotWidget( RiuQwtPlotWidget* plotWidget )
|
||||
int RiuMultiPlotPage::indexOfPlotWidget( RiuPlotWidget* plotWidget )
|
||||
{
|
||||
return m_plotWidgets.indexOf( plotWidget );
|
||||
}
|
||||
@@ -315,7 +320,7 @@ void RiuMultiPlotPage::scheduleUpdate()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMultiPlotPage::scheduleReplotOfAllPlots()
|
||||
{
|
||||
for ( RiuQwtPlotWidget* plotWidget : visiblePlotWidgets() )
|
||||
for ( RiuPlotWidget* plotWidget : visiblePlotWidgets() )
|
||||
{
|
||||
plotWidget->scheduleReplot();
|
||||
}
|
||||
@@ -517,7 +522,7 @@ void RiuMultiPlotPage::onSelectionManagerSelectionChanged( const std::set<int>&
|
||||
{
|
||||
if ( !m_plotDefinition ) return;
|
||||
|
||||
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
|
||||
for ( RiuPlotWidget* plotWidget : m_plotWidgets )
|
||||
{
|
||||
CAF_ASSERT( plotWidget );
|
||||
RimPlot* plot = plotWidget->plotDefinition();
|
||||
@@ -587,7 +592,7 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
|
||||
|
||||
QList<QPointer<QLabel>> subTitles = this->subTitlesForVisiblePlots();
|
||||
QList<QPointer<RiuQwtPlotLegend>> legends = this->legendsForVisiblePlots();
|
||||
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = this->visiblePlotWidgets();
|
||||
QList<QPointer<RiuPlotWidget>> plotWidgets = this->visiblePlotWidgets();
|
||||
|
||||
if ( !plotWidgets.empty() )
|
||||
{
|
||||
@@ -615,10 +620,10 @@ void RiuMultiPlotPage::reinsertPlotWidgets()
|
||||
subTitleFont.setPixelSize( m_subTitleFontPixelSize );
|
||||
subTitles[visibleIndex]->setFont( subTitleFont );
|
||||
|
||||
plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( QwtPlot::yLeft,
|
||||
plotWidgets[visibleIndex]->setAxisLabelsAndTicksEnabled( RiaDefines::PlotAxis::PLOT_AXIS_LEFT,
|
||||
showYAxis( row, column ),
|
||||
showYAxis( row, column ) );
|
||||
plotWidgets[visibleIndex]->setAxisTitleEnabled( QwtPlot::yLeft, showYAxis( row, column ) );
|
||||
plotWidgets[visibleIndex]->setAxisTitleEnabled( RiaDefines::PlotAxis::PLOT_AXIS_LEFT, showYAxis( row, column ) );
|
||||
plotWidgets[visibleIndex]->setAxesFontsAndAlignment( m_axisTitleFontSize, m_axisValueFontSize );
|
||||
|
||||
{
|
||||
@@ -679,7 +684,7 @@ int RiuMultiPlotPage::alignCanvasTops()
|
||||
{
|
||||
CVF_ASSERT( m_legends.size() == m_plotWidgets.size() );
|
||||
|
||||
QList<QPointer<RiuQwtPlotWidget>> plotWidgets = visiblePlotWidgets();
|
||||
QList<QPointer<RiuPlotWidget>> plotWidgets = visiblePlotWidgets();
|
||||
QList<QPointer<RiuQwtPlotLegend>> legends = legendsForVisiblePlots();
|
||||
if ( plotWidgets.empty() ) return 0;
|
||||
|
||||
@@ -689,22 +694,30 @@ int RiuMultiPlotPage::alignCanvasTops()
|
||||
|
||||
for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex )
|
||||
{
|
||||
int row = visibleIndex / rowAndColumnCount.second;
|
||||
if ( plotWidgets[visibleIndex]->axisEnabled( QwtPlot::xTop ) )
|
||||
RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidgets[visibleIndex].data() );
|
||||
if ( qwtPlotWidget )
|
||||
{
|
||||
QFont font = m_plotWidgets[visibleIndex]->axisFont( QwtPlot::xTop );
|
||||
maxExtents[row] =
|
||||
std::max( maxExtents[row], plotWidgets[visibleIndex]->axisScaleDraw( QwtPlot::xTop )->extent( font ) );
|
||||
int row = visibleIndex / rowAndColumnCount.second;
|
||||
if ( plotWidgets[visibleIndex]->axisEnabled( RiaDefines::PlotAxis::PLOT_AXIS_TOP ) )
|
||||
{
|
||||
QFont font = qwtPlotWidget->qwtPlot()->axisFont( QwtPlot::xTop );
|
||||
maxExtents[row] = std::max( maxExtents[row],
|
||||
qwtPlotWidget->qwtPlot()->axisScaleDraw( QwtPlot::xTop )->extent( font ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( int visibleIndex = 0; visibleIndex < plotWidgets.size(); ++visibleIndex )
|
||||
{
|
||||
int row = visibleIndex / rowAndColumnCount.second;
|
||||
plotWidgets[visibleIndex]->axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( maxExtents[row] );
|
||||
if ( legends[visibleIndex] )
|
||||
RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidgets[visibleIndex].data() );
|
||||
if ( qwtPlotWidget )
|
||||
{
|
||||
legends[visibleIndex]->adjustSize();
|
||||
int row = visibleIndex / rowAndColumnCount.second;
|
||||
qwtPlotWidget->qwtPlot()->axisScaleDraw( QwtPlot::xTop )->setMinimumExtent( maxExtents[row] );
|
||||
if ( legends[visibleIndex] )
|
||||
{
|
||||
legends[visibleIndex]->adjustSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
return maxExtents[0];
|
||||
@@ -740,10 +753,10 @@ void RiuMultiPlotPage::clearGridLayout()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<QPointer<RiuQwtPlotWidget>> RiuMultiPlotPage::visiblePlotWidgets() const
|
||||
QList<QPointer<RiuPlotWidget>> RiuMultiPlotPage::visiblePlotWidgets() const
|
||||
{
|
||||
QList<QPointer<RiuQwtPlotWidget>> plotWidgets;
|
||||
for ( QPointer<RiuQwtPlotWidget> plotWidget : m_plotWidgets )
|
||||
QList<QPointer<RiuPlotWidget>> plotWidgets;
|
||||
for ( QPointer<RiuPlotWidget> plotWidget : m_plotWidgets )
|
||||
{
|
||||
if ( plotWidget->isChecked() )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user