mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-05 13:47:06 -06:00
Merge pull request #12231 from OPM/improve-correlation-plot
Improve default settings correlation plot
This commit is contained in:
36 files changed
+169
-156
No files matched your search
@@ -79,13 +79,13 @@ RimAbstractCorrelationPlot::RimAbstractCorrelationPlot()
|
||||
CAF_PDM_InitField( &m_description, "PlotTitle", QString( "Correlation Plot" ), "Custom Plot Title" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_labelFontSize, "LabelFontSize", "Label Font Size" );
|
||||
m_labelFontSize = caf::FontTools::RelativeSize::XSmall;
|
||||
m_labelFontSize = caf::FontTools::RelativeSize::Small;
|
||||
|
||||
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_axisValueFontSize = caf::FontTools::RelativeSize::Small;
|
||||
|
||||
m_legendFontSize = caf::FontTools::RelativeSize::XSmall;
|
||||
m_legendFontSize = caf::FontTools::RelativeSize::Small;
|
||||
|
||||
CAF_PDM_InitField( &m_useCaseFilter, "UseCaseFilter", false, "Use Ensemble Filter" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_curveSetForFiltering, "CurveSetForFiltering", " Ensemble Filter" );
|
||||
|
||||
@@ -123,7 +123,7 @@ RimCorrelationMatrixPlot::RimCorrelationMatrixPlot()
|
||||
CAF_PDM_InitField( &m_sortByAbsoluteValues, "CorrelationAbsSorting", true, "Sort by Absolute Values" );
|
||||
CAF_PDM_InitField( &m_excludeParametersWithoutVariation, "ExcludeParamsWithoutVariation", true, "Exclude Parameters Without Variation" );
|
||||
CAF_PDM_InitField( &m_showOnlyTopNCorrelations, "ShowOnlyTopNCorrelations", true, "Show Only Top Correlations" );
|
||||
CAF_PDM_InitField( &m_topNFilterCount, "TopNFilterCount", 20, "Number rows/columns" );
|
||||
CAF_PDM_InitField( &m_topNFilterCount, "TopNFilterCount", 5, "Number rows/columns" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_selectedParametersList, "SelectedParameters", "Select Parameters" );
|
||||
m_selectedParametersList.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
|
||||
@@ -629,7 +629,7 @@ void RimCorrelationMatrixPlot::createMatrix()
|
||||
cvf::Color3f contrastColor = RiaColorTools::contrastColor( cvf::Color3f( color ) );
|
||||
textLabel.setColor( RiaColorTools::toQColor( contrastColor ) );
|
||||
QFont font = textLabel.font();
|
||||
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( labelFontSize() ) );
|
||||
font.setPointSize( labelFontSize() );
|
||||
textLabel.setFont( font );
|
||||
QwtPlotMarker* marker = new QwtPlotMarker();
|
||||
marker->setLabel( textLabel );
|
||||
|
||||
@@ -75,9 +75,9 @@ RimCorrelationReportPlot::RimCorrelationReportPlot()
|
||||
|
||||
m_titleFontSize = caf::FontTools::RelativeSize::XLarge;
|
||||
m_subTitleFontSize = caf::FontTools::RelativeSize::Large;
|
||||
m_labelFontSize = caf::FontTools::RelativeSize::XSmall;
|
||||
m_labelFontSize = caf::FontTools::RelativeSize::Small;
|
||||
m_axisTitleFontSize = caf::FontTools::RelativeSize::Small;
|
||||
m_axisValueFontSize = caf::FontTools::RelativeSize::XSmall;
|
||||
m_axisValueFontSize = caf::FontTools::RelativeSize::Small;
|
||||
|
||||
m_correlationMatrixPlot = new RimCorrelationMatrixPlot;
|
||||
m_correlationMatrixPlot->setLegendsVisible( false );
|
||||
|
||||
+77
-32
@@ -19,46 +19,33 @@
|
||||
#include "RimParameterResultCrossPlot.h"
|
||||
|
||||
#include "RiaColorTables.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaQDateTimeTools.h"
|
||||
#include "RiaTextStringTools.h"
|
||||
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include "RigEnsembleParameter.h"
|
||||
|
||||
#include "RimDeltaSummaryCase.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimMultiPlot.h"
|
||||
#include "RimPlotAxisProperties.h"
|
||||
#include "RimPlotAxisPropertiesInterface.h"
|
||||
#include "RimPlotDataFilterCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryAddress.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryEnsemble.h"
|
||||
#include "RimSummaryPlotAxisFormatter.h"
|
||||
|
||||
#include "RiuPlotCurve.h"
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
#include "RiuQwtPlotWidget.h"
|
||||
#include "RiuQwtSymbol.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
#include "RiuSummaryVectorSelectionDialog.h"
|
||||
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
|
||||
#include "qwt_legend.h"
|
||||
#include "qwt_picker_machine.h"
|
||||
#include "qwt_plot.h"
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_scale_engine.h"
|
||||
#include "qwt_plot_picker.h"
|
||||
#include "qwt_text.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimParameterResultCrossPlot, "ParameterResultCrossPlot" );
|
||||
@@ -76,10 +63,12 @@ RimParameterResultCrossPlot::RimParameterResultCrossPlot()
|
||||
|
||||
m_selectMultipleVectors = true;
|
||||
|
||||
m_legendFontSize = caf::FontTools::RelativeSize::XSmall;
|
||||
m_legendFontSize = caf::FontTools::RelativeSize::Small;
|
||||
|
||||
m_xRange = std::make_pair( std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity() );
|
||||
m_yRange = std::make_pair( std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity() );
|
||||
|
||||
m_showPlotLegends = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -164,14 +153,6 @@ void RimParameterResultCrossPlot::onLoadDataAndUpdate()
|
||||
if ( m_plotWidget && m_analyserOfSelectedCurveDefs )
|
||||
{
|
||||
createPoints();
|
||||
if ( m_showPlotLegends && !isSubPlot<RimMultiPlot>() )
|
||||
{
|
||||
QwtLegend* legend = new QwtLegend( m_plotWidget );
|
||||
m_plotWidget->qwtPlot()->insertLegend( legend, QwtPlot::RightLegend );
|
||||
m_plotWidget->setLegendFontSize( legendFontSize() );
|
||||
m_plotWidget->updateLegend();
|
||||
}
|
||||
|
||||
updateAxes();
|
||||
updatePlotTitle();
|
||||
m_plotWidget->scheduleReplot();
|
||||
@@ -234,7 +215,6 @@ void RimParameterResultCrossPlot::createPoints()
|
||||
if ( addresses().empty() ) return;
|
||||
|
||||
bool showEnsembleName = ensembles().size() > 1u;
|
||||
bool showAddressName = addresses().size() > 1u;
|
||||
|
||||
m_xRange = std::make_pair( std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity() );
|
||||
m_yRange = std::make_pair( std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity() );
|
||||
@@ -248,9 +228,6 @@ void RimParameterResultCrossPlot::createPoints()
|
||||
RigEnsembleParameter parameter = ensembleParameter( m_ensembleParameter );
|
||||
if ( !( parameter.isNumeric() && parameter.isValid() ) ) return;
|
||||
|
||||
QStringList caseNames = caseNamesOfValidEnsembleCases( ensemble );
|
||||
QString commonCaseRoot = RiaTextStringTools::commonRoot( caseNames );
|
||||
|
||||
std::set<RimSummaryCase*> activeCases = filterEnsembleCases( ensemble );
|
||||
|
||||
for ( size_t caseIdx = 0u; caseIdx < ensemble->allSummaryCases().size(); ++caseIdx )
|
||||
@@ -298,14 +275,15 @@ void RimParameterResultCrossPlot::createPoints()
|
||||
RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve;
|
||||
plotCurve->setSamplesValues( parameterValues, caseValuesAtTimestep );
|
||||
plotCurve->setStyle( QwtPlotCurve::NoCurve );
|
||||
|
||||
RiuQwtSymbol* symbol = new RiuQwtSymbol( RiuPlotCurveSymbol::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().replace( commonCaseRoot, "" );
|
||||
if ( showAddressName ) curveName += QString::fromStdString( address.uiText() );
|
||||
curveName += summaryCase->displayCaseName();
|
||||
|
||||
plotCurve->setTitle( curveName.join( " - " ) );
|
||||
|
||||
@@ -318,6 +296,73 @@ void RimParameterResultCrossPlot::createPoints()
|
||||
}
|
||||
}
|
||||
|
||||
namespace internal
|
||||
{
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class CurveTracker : public QwtPlotPicker
|
||||
{
|
||||
public:
|
||||
CurveTracker( QwtPlot* plot )
|
||||
: QwtPlotPicker( plot->canvas() )
|
||||
{
|
||||
setStateMachine( new QwtPickerTrackerMachine() );
|
||||
setRubberBand( QwtPicker::NoRubberBand );
|
||||
setTrackerMode( QwtPicker::AlwaysOn );
|
||||
}
|
||||
|
||||
protected:
|
||||
QwtText trackerText( const QPoint& pos ) const override
|
||||
{
|
||||
double minDistance = std::numeric_limits<double>::max();
|
||||
QString closestCurveLabel;
|
||||
|
||||
for ( QwtPlotItem* item : plot()->itemList() )
|
||||
{
|
||||
if ( item->rtti() == QwtPlotItem::Rtti_PlotCurve )
|
||||
{
|
||||
auto curve = static_cast<QwtPlotCurve*>( item );
|
||||
double distance = std::numeric_limits<double>::max();
|
||||
curve->closestPoint( pos, &distance );
|
||||
|
||||
if ( distance < minDistance )
|
||||
{
|
||||
minDistance = distance;
|
||||
closestCurveLabel = curve->title().text();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( minDistance < 20.0 )
|
||||
{
|
||||
QwtText text( closestCurveLabel );
|
||||
text.setBackgroundBrush( QBrush( Qt::white ) );
|
||||
text.setColor( Qt::black );
|
||||
return text;
|
||||
}
|
||||
|
||||
return QwtText();
|
||||
}
|
||||
};
|
||||
} // namespace internal
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuPlotWidget* RimParameterResultCrossPlot::doCreatePlotViewWidget( QWidget* mainWindowParent /*= nullptr */ )
|
||||
{
|
||||
RimAbstractCorrelationPlot::doCreatePlotViewWidget( mainWindowParent );
|
||||
|
||||
if ( m_plotWidget )
|
||||
{
|
||||
// Add a curve tracker to display the name of the realization when mouse is close to a sample in the cross plot
|
||||
new internal::CurveTracker( m_plotWidget->qwtPlot() );
|
||||
}
|
||||
|
||||
return m_plotWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -34,20 +34,17 @@ public:
|
||||
void setEnsembleParameter( const QString& ensembleParameter );
|
||||
|
||||
private:
|
||||
// Overridden PDM methods
|
||||
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
|
||||
RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
|
||||
|
||||
void onLoadDataAndUpdate() override;
|
||||
void updateAxes() override;
|
||||
QString asciiDataForPlotExport() const override;
|
||||
|
||||
// Private methods
|
||||
void updatePlotTitle() override;
|
||||
void createPoints();
|
||||
void updatePlotTitle() override;
|
||||
void createPoints();
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_ensembleParameter;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "RimWellRftEnsembleCurveSet.h"
|
||||
|
||||
#include "RifDataSourceForRftPltQMetaType.h"
|
||||
|
||||
#include "RiuPlotCurveSymbol.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "cafPdmPtrField.h"
|
||||
#include "cafSignal.h"
|
||||
|
||||
#include "cafFontTools.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfVec3d.h"
|
||||
|
||||
@@ -436,7 +436,7 @@ void RimStatisticsPlot::updatePlots()
|
||||
|
||||
// Set font of label equal axis value font
|
||||
QFont labelFont = QFont();
|
||||
labelFont.setPixelSize( fontScalingToMatchQwt * axisValueFontSize() );
|
||||
labelFont.setPointSize( fontScalingToMatchQwt * axisValueFontSize() );
|
||||
labelSeries->setPointLabelsFont( labelFont );
|
||||
|
||||
// Remove legend for dummy point
|
||||
@@ -446,23 +446,23 @@ void RimStatisticsPlot::updatePlots()
|
||||
|
||||
// Set axis value font
|
||||
QFont axisYValueFont = axisY->labelsFont();
|
||||
axisYValueFont.setPixelSize( fontScalingToMatchQwt * axisValueFontSize() );
|
||||
axisYValueFont.setPointSize( fontScalingToMatchQwt * axisValueFontSize() );
|
||||
axisY->setLabelsFont( axisYValueFont );
|
||||
QFont axisXValueFont = axisX->labelsFont();
|
||||
axisXValueFont.setPixelSize( fontScalingToMatchQwt * axisValueFontSize() );
|
||||
axisXValueFont.setPointSize( fontScalingToMatchQwt * axisValueFontSize() );
|
||||
axisX->setLabelsFont( axisXValueFont );
|
||||
|
||||
// Set axis title font
|
||||
QFont axisYTitleFont = axisY->titleFont();
|
||||
axisYTitleFont.setPixelSize( fontScalingToMatchQwt * axisTitleFontSize() );
|
||||
axisYTitleFont.setPointSize( fontScalingToMatchQwt * axisTitleFontSize() );
|
||||
axisY->setTitleFont( axisYTitleFont );
|
||||
QFont axisXTitleFont = axisX->titleFont();
|
||||
axisXTitleFont.setPixelSize( fontScalingToMatchQwt * axisTitleFontSize() );
|
||||
axisXTitleFont.setPointSize( fontScalingToMatchQwt * axisTitleFontSize() );
|
||||
axisX->setTitleFont( axisXTitleFont );
|
||||
|
||||
// Set plot title font
|
||||
QFont titleFont = chart->titleFont();
|
||||
titleFont.setPixelSize( fontScalingToMatchQwt * titleFontSize() );
|
||||
titleFont.setPointSize( fontScalingToMatchQwt * titleFontSize() );
|
||||
chart->setTitleFont( titleFont );
|
||||
|
||||
// Set legend font
|
||||
@@ -470,7 +470,7 @@ void RimStatisticsPlot::updatePlots()
|
||||
if ( legend )
|
||||
{
|
||||
QFont legendFont = legend->font();
|
||||
legendFont.setPixelSize( fontScalingToMatchQwt * legendFontSize() );
|
||||
legendFont.setPointSize( fontScalingToMatchQwt * legendFontSize() );
|
||||
legend->setFont( legendFont );
|
||||
legend->setVisible( legendsVisible() );
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ RimWellLogTrack::RimWellLogTrack()
|
||||
|
||||
CAF_PDM_InitField( &m_showRegionLabels, "ShowFormationLabels", true, "Show Labels" );
|
||||
|
||||
caf::FontTools::RelativeSizeEnum regionLabelFontSizeDefault = caf::FontTools::RelativeSize::XSmall;
|
||||
caf::FontTools::RelativeSizeEnum regionLabelFontSizeDefault = caf::FontTools::RelativeSize::Small;
|
||||
CAF_PDM_InitField( &m_regionLabelFontSize, "RegionLabelFontSize", regionLabelFontSizeDefault, "Font Size" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_formationSource, "FormationSource", "Source" );
|
||||
|
||||
Reference in new issue
Block a user