mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add multi selection for Correlation Cross Plot and fix label font sizes for Tornado plots
This commit is contained in:
@@ -417,7 +417,6 @@ void RimAnalysisPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
dlg.enableIndividualEnsembleCaseSelection( true );
|
||||
|
||||
dlg.setCurveSelection( this->curveDefinitionsWithoutEnsembleReference() );
|
||||
dlg.setCaseAndAddress( nullptr, RifEclipseSummaryAddress() );
|
||||
|
||||
if ( dlg.exec() == QDialog::Accepted )
|
||||
{
|
||||
|
||||
@@ -56,6 +56,8 @@ RimAbstractCorrelationPlot::RimAbstractCorrelationPlot()
|
||||
CAF_PDM_InitFieldNoDefault( &m_axisTitleFontSize, "AxisTitleFontSize", "Axis Title Font Size", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_axisValueFontSize, "AxisValueFontSize", "Axis Value Font Size", "", "", "" );
|
||||
m_axisValueFontSize = caf::FontTools::RelativeSize::XSmall;
|
||||
|
||||
m_legendFontSize = caf::FontTools::RelativeSize::XSmall;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -101,7 +103,6 @@ void RimAbstractCorrelationPlot::fieldChangedByUi( const caf::PdmFieldHandle* ch
|
||||
dlg.enableMultiSelect( true );
|
||||
}
|
||||
|
||||
dlg.setCaseAndAddress( nullptr, RifEclipseSummaryAddress() );
|
||||
dlg.setCurveSelection( curveDefinitions() );
|
||||
|
||||
if ( dlg.exec() == QDialog::Accepted )
|
||||
@@ -134,7 +135,7 @@ void RimAbstractCorrelationPlot::fieldChangedByUi( const caf::PdmFieldHandle* ch
|
||||
this->updatePlotTitle();
|
||||
}
|
||||
else if ( changedField == &m_labelFontSize || changedField == &m_axisTitleFontSize ||
|
||||
changedField == &m_axisValueFontSize )
|
||||
changedField == &m_axisValueFontSize || changedField == &m_legendFontSize || changedField == &m_titleFontSize )
|
||||
{
|
||||
this->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
@@ -246,6 +246,8 @@ void RimCorrelationMatrixPlot::defineUiOrdering( QString uiConfigName, caf::PdmU
|
||||
plotGroup->add( &m_description );
|
||||
m_description.uiCapability()->setUiReadOnly( m_useAutoPlotTitle() );
|
||||
RimPlot::defineUiOrdering( uiConfigName, *plotGroup );
|
||||
|
||||
plotGroup->add( &m_titleFontSize );
|
||||
plotGroup->add( &m_labelFontSize );
|
||||
plotGroup->add( &m_axisTitleFontSize );
|
||||
plotGroup->add( &m_axisValueFontSize );
|
||||
|
||||
@@ -126,6 +126,7 @@ void RimCorrelationPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder
|
||||
plotGroup->add( &m_useAutoPlotTitle );
|
||||
plotGroup->add( &m_description );
|
||||
RimPlot::defineUiOrdering( uiConfigName, *plotGroup );
|
||||
plotGroup->add( &m_titleFontSize );
|
||||
plotGroup->add( &m_axisTitleFontSize );
|
||||
plotGroup->add( &m_axisValueFontSize );
|
||||
|
||||
@@ -168,6 +169,7 @@ void RimCorrelationPlot::onLoadDataAndUpdate()
|
||||
addDataToChartBuilder( chartBuilder );
|
||||
|
||||
chartBuilder.addBarChartToPlot( m_plotWidget, Qt::Horizontal );
|
||||
chartBuilder.setLabelFontSize( labelFontSize() );
|
||||
|
||||
m_plotWidget->insertLegend( nullptr );
|
||||
m_plotWidget->updateLegend();
|
||||
@@ -275,7 +277,7 @@ void RimCorrelationPlot::addDataToChartBuilder( RiuGroupedBarChartBuilder& chart
|
||||
correlationResults.push_back( std::make_pair( parameterValuesPair.first, correlation ) );
|
||||
}
|
||||
|
||||
QString timestepString = m_timeStep().toString( Qt::ISODate );
|
||||
QString timestepString = m_timeStep().toString( RiaPreferences::current()->dateTimeFormat() );
|
||||
|
||||
for ( auto parameterCorrPair : correlationResults )
|
||||
{
|
||||
|
||||
@@ -315,6 +315,7 @@ void RimCorrelationReportPlot::onLoadDataAndUpdate()
|
||||
m_correlationPlot->setAxisValueFontSize( m_axisValueFontSize() );
|
||||
|
||||
m_parameterResultCrossPlot->setLabelFontSize( m_labelFontSize() );
|
||||
m_parameterResultCrossPlot->setLegendFontSize( m_legendFontSize() );
|
||||
m_parameterResultCrossPlot->setAxisTitleFontSize( m_axisTitleFontSize() );
|
||||
m_parameterResultCrossPlot->setAxisValueFontSize( m_axisValueFontSize() );
|
||||
|
||||
@@ -339,6 +340,7 @@ void RimCorrelationReportPlot::defineUiOrdering( QString uiConfigName, caf::PdmU
|
||||
plotGroup->add( &m_titleFontSize );
|
||||
plotGroup->add( &m_subTitleFontSize );
|
||||
plotGroup->add( &m_labelFontSize );
|
||||
plotGroup->add( &m_legendFontSize );
|
||||
plotGroup->add( &m_axisTitleFontSize );
|
||||
plotGroup->add( &m_axisValueFontSize );
|
||||
m_correlationMatrixPlot->legendConfig()->uiOrdering( "ColorsOnly", *plotGroup );
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
#include "qwt_legend.h"
|
||||
#include "qwt_plot_curve.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <set>
|
||||
@@ -61,6 +63,10 @@ RimParameterResultCrossPlot::RimParameterResultCrossPlot()
|
||||
|
||||
CAF_PDM_InitField( &m_ensembleParameter, "EnsembleParameter", QString( "" ), "Ensemble Parameter", "", "", "" );
|
||||
m_ensembleParameter.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
|
||||
|
||||
m_selectMultipleVectors = true;
|
||||
|
||||
m_legendFontSize = caf::FontTools::RelativeSize::XSmall;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -115,6 +121,10 @@ void RimParameterResultCrossPlot::defineUiOrdering( QString uiConfigName, caf::P
|
||||
plotGroup->add( &m_useAutoPlotTitle );
|
||||
plotGroup->add( &m_description );
|
||||
RimPlot::defineUiOrdering( uiConfigName, *plotGroup );
|
||||
plotGroup->add( &m_titleFontSize );
|
||||
plotGroup->add( &m_legendFontSize );
|
||||
plotGroup->add( &m_axisTitleFontSize );
|
||||
plotGroup->add( &m_axisValueFontSize );
|
||||
|
||||
m_description.uiCapability()->setUiReadOnly( m_useAutoPlotTitle() );
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
@@ -152,10 +162,11 @@ void RimParameterResultCrossPlot::onLoadDataAndUpdate()
|
||||
|
||||
if ( m_plotWidget && m_analyserOfSelectedCurveDefs )
|
||||
{
|
||||
m_plotWidget->insertLegend( nullptr );
|
||||
m_plotWidget->updateLegend();
|
||||
|
||||
createPoints();
|
||||
QwtLegend* legend = new QwtLegend( m_plotWidget );
|
||||
m_plotWidget->insertLegend( legend, QwtPlot::RightLegend );
|
||||
m_plotWidget->setLegendFontSize( legendFontSize() );
|
||||
m_plotWidget->updateLegend();
|
||||
|
||||
this->updateAxes();
|
||||
this->updatePlotTitle();
|
||||
@@ -195,54 +206,73 @@ void RimParameterResultCrossPlot::createPoints()
|
||||
if ( ensembles().empty() ) return;
|
||||
if ( addresses().empty() ) return;
|
||||
|
||||
auto ensemble = *ensembles().begin();
|
||||
auto address = *addresses().begin();
|
||||
EnsembleParameter parameter = ensembleParameter( m_ensembleParameter );
|
||||
if ( !( parameter.isNumeric() && parameter.isValid() ) ) return;
|
||||
bool showEnsembleName = ensembles().size() > 1u;
|
||||
bool showAddressName = addresses().size() > 1u;
|
||||
|
||||
for ( size_t caseIdx = 0u; caseIdx < ensemble->allSummaryCases().size(); ++caseIdx )
|
||||
int ensembleIdx = 0;
|
||||
for ( auto ensemble : ensembles() )
|
||||
{
|
||||
std::vector<double> caseValuesAtTimestep;
|
||||
std::vector<double> parameterValues;
|
||||
|
||||
auto summaryCase = ensemble->allSummaryCases()[caseIdx];
|
||||
|
||||
RifSummaryReaderInterface* reader = summaryCase->summaryReader();
|
||||
if ( !reader ) continue;
|
||||
|
||||
if ( !summaryCase->caseRealizationParameters() ) continue;
|
||||
|
||||
std::vector<double> values;
|
||||
|
||||
double closestValue = std::numeric_limits<double>::infinity();
|
||||
time_t closestTimeStep = 0;
|
||||
if ( reader->values( address, &values ) )
|
||||
int addressIdx = 0;
|
||||
for ( auto address : addresses() )
|
||||
{
|
||||
const std::vector<time_t>& timeSteps = reader->timeSteps( address );
|
||||
for ( size_t i = 0; i < timeSteps.size(); ++i )
|
||||
EnsembleParameter parameter = ensembleParameter( m_ensembleParameter );
|
||||
if ( !( parameter.isNumeric() && parameter.isValid() ) ) return;
|
||||
|
||||
for ( size_t caseIdx = 0u; caseIdx < ensemble->allSummaryCases().size(); ++caseIdx )
|
||||
{
|
||||
if ( timeDiff( timeSteps[i], selectedTimestep ) < timeDiff( selectedTimestep, closestTimeStep ) )
|
||||
std::vector<double> caseValuesAtTimestep;
|
||||
std::vector<double> parameterValues;
|
||||
|
||||
auto summaryCase = ensemble->allSummaryCases()[caseIdx];
|
||||
|
||||
RifSummaryReaderInterface* reader = summaryCase->summaryReader();
|
||||
if ( !reader ) continue;
|
||||
|
||||
if ( !summaryCase->caseRealizationParameters() ) continue;
|
||||
|
||||
std::vector<double> values;
|
||||
|
||||
double closestValue = std::numeric_limits<double>::infinity();
|
||||
time_t closestTimeStep = 0;
|
||||
if ( reader->values( address, &values ) )
|
||||
{
|
||||
closestValue = values[i];
|
||||
closestTimeStep = timeSteps[i];
|
||||
const std::vector<time_t>& timeSteps = reader->timeSteps( address );
|
||||
for ( size_t i = 0; i < timeSteps.size(); ++i )
|
||||
{
|
||||
if ( timeDiff( timeSteps[i], selectedTimestep ) < timeDiff( selectedTimestep, closestTimeStep ) )
|
||||
{
|
||||
closestValue = values[i];
|
||||
closestTimeStep = timeSteps[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( closestValue != std::numeric_limits<double>::infinity() )
|
||||
{
|
||||
caseValuesAtTimestep.push_back( closestValue );
|
||||
double paramValue = parameter.values[caseIdx].toDouble();
|
||||
parameterValues.push_back( paramValue );
|
||||
|
||||
RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve;
|
||||
plotCurve->setSamples( parameterValues.data(), caseValuesAtTimestep.data(), (int)parameterValues.size() );
|
||||
plotCurve->setStyle( QwtPlotCurve::NoCurve );
|
||||
RiuQwtSymbol* symbol =
|
||||
new RiuQwtSymbol( RiuQwtSymbol::cycledSymbolStyle( ensembleIdx, addressIdx ), "" );
|
||||
symbol->setSize( legendFontSize(), legendFontSize() );
|
||||
symbol->setColor( colorTable.cycledQColor( caseIdx ) );
|
||||
plotCurve->setSymbol( symbol );
|
||||
QStringList curveName;
|
||||
if ( showEnsembleName ) curveName += ensemble->name();
|
||||
curveName += summaryCase->displayCaseName();
|
||||
if ( showAddressName ) curveName += QString::fromStdString( address.uiText() );
|
||||
|
||||
plotCurve->setTitle( curveName.join( " - " ) );
|
||||
|
||||
plotCurve->attach( m_plotWidget );
|
||||
}
|
||||
}
|
||||
addressIdx++;
|
||||
}
|
||||
if ( closestValue != std::numeric_limits<double>::infinity() )
|
||||
{
|
||||
caseValuesAtTimestep.push_back( closestValue );
|
||||
double paramValue = parameter.values[caseIdx].toDouble();
|
||||
parameterValues.push_back( paramValue );
|
||||
|
||||
QwtPlotCurve* plotCurve = new QwtPlotCurve;
|
||||
plotCurve->setSamples( parameterValues.data(), caseValuesAtTimestep.data(), (int)parameterValues.size() );
|
||||
plotCurve->setStyle( QwtPlotCurve::NoCurve );
|
||||
RiuQwtSymbol* symbol = new RiuQwtSymbol( RiuQwtSymbol::SYMBOL_DIAMOND, "" );
|
||||
symbol->setSize( 12, 12 );
|
||||
symbol->setColor( colorTable.cycledQColor( caseIdx ) );
|
||||
plotCurve->setSymbol( symbol );
|
||||
plotCurve->attach( m_plotWidget );
|
||||
}
|
||||
ensembleIdx++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -154,6 +154,14 @@ int RimPlotWindow::legendFontSize() const
|
||||
return caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), m_legendFontSize() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotWindow::setLegendFontSize( caf::FontTools::RelativeSize fontSize )
|
||||
{
|
||||
m_legendFontSize = fontSize;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -62,6 +62,8 @@ public:
|
||||
int titleFontSize() const;
|
||||
int legendFontSize() const;
|
||||
|
||||
void setLegendFontSize( caf::FontTools::RelativeSize fontSize );
|
||||
|
||||
void updateLayout();
|
||||
void updateParentLayout();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user