10214 ensemble appearance

* Regression Analysis: Use only positive values for Power Fit regression.

* Add visible tag short cut for changning curve color.
* #10214 Ensemble Curve Set: Fix color mode text.
* #10214 Ensemble: Switch P10 and P90 symbols to point towards mean.
* Cache hit rects for tree item tags.
* #10214 Ensemble curve set: allow reordering with tree view tag
* #10214 Keep curve legend text when ensemble curves are hidden
This commit is contained in:
Kristian Bendiksen
2023-05-23 08:10:35 +02:00
committed by GitHub
parent 329a199863
commit 94f7bd3c1a
10 changed files with 92 additions and 46 deletions

View File

@@ -32,13 +32,16 @@
#include "RimSummaryCurveCollection.h"
#include "RimSummaryPlot.h"
#include "RiuGuiTheme.h"
#include "RiuPlotCurve.h"
#include "RiuPlotCurveSymbol.h"
#include "RiuPlotMainWindowTools.h"
#include "RiuPlotWidget.h"
#include "cafAssert.h"
#include "cafPdmUiColorEditor.h"
#include "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiTreeAttributes.h"
#include "cafPdmUiTreeSelectionEditor.h"
#include <QPen>
@@ -1243,3 +1246,48 @@ QString RimPlotCurve::curveExportDescription( const RifEclipseSummaryAddress& ad
{
return m_curveName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
if ( auto* treeItemAttribute = dynamic_cast<caf::PdmUiTreeViewItemAttribute*>( attribute ) )
{
treeItemAttribute->tags.clear();
auto tag = caf::PdmUiTreeViewItemAttribute::Tag::create();
// Blend with background for a nice look
auto backgroundColor = RiuGuiTheme::getColorByVariableName( "backgroundColor1" );
auto color = RiaColorTools::toQColor( m_curveAppearance->color() );
auto sourceWeight = 100;
double transparency = 0.3;
int backgroundWeight = std::max( 1, static_cast<int>( sourceWeight * 10 * transparency ) );
auto blendedColor = RiaColorTools::blendQColors( backgroundColor, color, backgroundWeight, sourceWeight );
tag->bgColor = blendedColor;
tag->fgColor = RiaColorTools::toQColor( m_curveAppearance->color() );
tag->text = "---";
tag->clicked.connect( this, &RimPlotCurve::onColorTagClicked );
treeItemAttribute->tags.push_back( std::move( tag ) );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::onColorTagClicked( const SignalEmitter* emitter, size_t index )
{
QColor sourceColor = RiaColorTools::toQColor( m_curveAppearance->color() );
QColor newColor = caf::PdmUiColorEditor::getColor( sourceColor );
if ( newColor.isValid() && newColor != sourceColor )
{
auto myColor = RiaColorTools::fromQColorTo3f( newColor );
m_curveAppearance->setColor( myColor );
updateCurveAppearance();
replotParentPlot();
}
}

View File

@@ -185,6 +185,10 @@ protected:
virtual void updateAxisInPlot( RiuPlotAxis plotAxis );
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void onColorTagClicked( const SignalEmitter* emitter, size_t index );
private:
bool isCurveNameTemplateSupported() const;

View File

@@ -1777,7 +1777,6 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vector<RimSummaryCase
auto plot = firstAncestorOrThisOfTypeAsserted<RimSummaryPlot>();
deleteEnsembleCurves();
if ( m_plotCurveForLegendText ) m_plotCurveForLegendText->detach();
deleteStatisticsCurves();
if ( m_statistics->hideEnsembleCurves() ) return;
@@ -2187,8 +2186,8 @@ RiuPlotCurveSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifE
{
auto qName = QString::fromStdString( address.vectorName() );
if ( qName.contains( ENSEMBLE_STAT_P10_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_TRIANGLE;
if ( qName.contains( ENSEMBLE_STAT_P90_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE;
if ( qName.contains( ENSEMBLE_STAT_P10_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE;
if ( qName.contains( ENSEMBLE_STAT_P90_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_TRIANGLE;
if ( qName.contains( ENSEMBLE_STAT_P50_QUANTITY_NAME ) ) return RiuPlotCurveSymbol::SYMBOL_DIAMOND;
return RiuPlotCurveSymbol::SYMBOL_ELLIPSE;
}

View File

@@ -31,6 +31,8 @@
#include "RiuPlotCurve.h"
#include "cafPdmFieldReorderCapability.h"
CAF_PDM_SOURCE_INIT( RimEnsembleCurveSetCollection, "RimEnsembleCurveSetCollection" );
//--------------------------------------------------------------------------------------------------
@@ -43,6 +45,7 @@ RimEnsembleCurveSetCollection::RimEnsembleCurveSetCollection()
CAF_PDM_InitFieldNoDefault( &m_curveSets, "EnsembleCurveSets", "Ensemble Curve Sets" );
m_curveSets.uiCapability()->setUiTreeHidden( true );
m_curveSets.uiCapability()->setUiTreeChildrenHidden( false );
caf::PdmFieldReorderCapability::addToFieldWithCallback( &m_curveSets, this, &RimEnsembleCurveSetCollection::onCurveSetsReordered );
CAF_PDM_InitField( &m_showCurves, "IsActive", true, "Show Curves" );
m_showCurves.uiCapability()->setUiHidden( true );
@@ -339,3 +342,10 @@ void RimEnsembleCurveSetCollection::onChildDeleted( caf::PdmChildArrayFieldHandl
auto plot = firstAncestorOrThisOfType<RimSummaryPlot>();
if ( plot ) plot->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSetCollection::onCurveSetsReordered( const SignalEmitter* emitter )
{
}

View File

@@ -76,6 +76,8 @@ private:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void onCurveSetsReordered( const SignalEmitter* emitter );
private:
caf::PdmField<bool> m_showCurves;
caf::PdmChildArrayField<RimEnsembleCurveSet*> m_curveSets;

View File

@@ -39,7 +39,7 @@ template <>
void AppEnum<RimEnsembleCurveSetColorManager::ColorMode>::setUp()
{
addItem( RimEnsembleCurveSetColorManager::ColorMode::SINGLE_COLOR, "SINGLE_COLOR", "Single Color" );
addItem( RimEnsembleCurveSetColorManager::ColorMode::SINGLE_COLOR_WITH_ALPHA, "SINGLE_COLOR_WITH_ALPHA", "Single Color with alpha" );
addItem( RimEnsembleCurveSetColorManager::ColorMode::SINGLE_COLOR_WITH_ALPHA, "SINGLE_COLOR_WITH_ALPHA", "Single Color with Transparency" );
addItem( RimEnsembleCurveSetColorManager::ColorMode::BY_ENSEMBLE_PARAM, "BY_ENSEMBLE_PARAM", "By Ensemble Parameter" );
addItem( RimEnsembleCurveSetColorManager::ColorMode::BY_OBJECTIVE_FUNCTION, "BY_OBJECTIVE_FUNCTION", "By Objective Function" );
addItem( RimEnsembleCurveSetColorManager::ColorMode::BY_CUSTOM_OBJECTIVE_FUNCTION,

View File

@@ -26,6 +26,7 @@
#include "PowerFitRegression.hpp"
#include <cmath>
#include <vector>
CAF_PDM_SOURCE_INIT( RimSummaryRegressionAnalysisCurve, "RegressionAnalysisCurve" );
@@ -149,8 +150,23 @@ std::tuple<std::vector<time_t>, std::vector<double>, QString>
}
else if ( m_regressionType == RegressionType::POWER_FIT )
{
auto filterValues = []( const std::vector<double>& timeSteps, const std::vector<double>& values )
{
std::vector<double> filteredTimeSteps;
std::vector<double> filteredValues;
for ( size_t i = 0; i < timeSteps.size(); i++ )
{
if ( timeSteps[i] > 0.0 && values[i] > 0.0 )
{
filteredTimeSteps.push_back( timeSteps[i] );
filteredValues.push_back( values[i] );
}
}
return std::make_pair( filteredTimeSteps, filteredValues );
};
auto [filteredTimeSteps, filteredValues] = filterValues( timeStepsD, values );
regression::PowerFitRegression powerFitRegression;
powerFitRegression.fit( timeStepsD, values );
powerFitRegression.fit( filteredTimeSteps, filteredValues );
std::vector<double> predictedValues = powerFitRegression.predict( timeStepsD );
return { timeSteps, predictedValues, generateRegressionText( powerFitRegression ) };
}

View File

@@ -892,8 +892,8 @@ void RimEnsembleWellLogCurveSet::updateStatisticsCurves( const std::vector<RimWe
auto statisticsCurveSymbolFromStatistics = []( RimEnsembleWellLogStatistics::StatisticsType statisticsType )
{
if ( statisticsType == RimEnsembleWellLogStatistics::StatisticsType::P10 ) return RiuPlotCurveSymbol::SYMBOL_TRIANGLE;
if ( statisticsType == RimEnsembleWellLogStatistics::StatisticsType::P90 ) return RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE;
if ( statisticsType == RimEnsembleWellLogStatistics::StatisticsType::P10 ) return RiuPlotCurveSymbol::SYMBOL_DOWN_TRIANGLE;
if ( statisticsType == RimEnsembleWellLogStatistics::StatisticsType::P90 ) return RiuPlotCurveSymbol::SYMBOL_TRIANGLE;
if ( statisticsType == RimEnsembleWellLogStatistics::StatisticsType::P50 ) return RiuPlotCurveSymbol::SYMBOL_DIAMOND;
return RiuPlotCurveSymbol::SYMBOL_ELLIPSE;
};