diff --git a/ApplicationLibCode/Application/RiaPreferencesSummary.cpp b/ApplicationLibCode/Application/RiaPreferencesSummary.cpp index 82b228e174..0a53be9110 100644 --- a/ApplicationLibCode/Application/RiaPreferencesSummary.cpp +++ b/ApplicationLibCode/Application/RiaPreferencesSummary.cpp @@ -21,6 +21,7 @@ #include "PlotTemplateCommands/RicSummaryPlotTemplateTools.h" #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RiaPreferences.h" #include "PlotTemplates/RimPlotTemplateFileItem.h" @@ -174,11 +175,13 @@ RiaPreferencesSummary::RiaPreferencesSummary() CAF_PDM_InitField( &m_curveColorByPhase, "curveColorByPhase", true, "Curve Color By Phase" ); caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_curveColorByPhase ); - CAF_PDM_InitField( &m_appendHistoryVectorForDragDrop, - "appendHistoryVectorForDragDrop", - false, - "Append History Vector for Drag/Drop" ); - caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_appendHistoryVectorForDragDrop ); + CAF_PDM_InitField( &m_appendHistoryVectors, "appendHistoryVectorForDragDrop", false, "Append History Vectors" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_appendHistoryVectors ); + + CAF_PDM_InitField( &m_historyCurveContrastColor, + "historyCurveContrastColor", + RiaColorTables::historyCurveContrastColor(), + "History Curve Contrast Color" ); } //-------------------------------------------------------------------------------------------------- @@ -278,8 +281,10 @@ void RiaPreferencesSummary::appendItemsToPlottingGroup( caf::PdmUiOrdering& uiOr } uiOrdering.add( &m_defaultSummaryHistoryCurveStyle ); + uiOrdering.add( &m_curveColorByPhase ); - uiOrdering.add( &m_appendHistoryVectorForDragDrop ); + uiOrdering.add( &m_appendHistoryVectors ); + uiOrdering.add( &m_historyCurveContrastColor, false ); uiOrdering.add( &m_showSummaryTimeAsLongString ); @@ -356,9 +361,9 @@ bool RiaPreferencesSummary::colorCurvesByPhase() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiaPreferencesSummary::appendHistoryVectorForDragDrop() const +bool RiaPreferencesSummary::appendHistoryVectors() const { - return m_appendHistoryVectorForDragDrop(); + return m_appendHistoryVectors(); } //-------------------------------------------------------------------------------------------------- @@ -522,6 +527,14 @@ RiaDefines::RowCount RiaPreferencesSummary::defaultMultiPlotRowCount() const return m_defaultRowsPerPage(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaPreferencesSummary::historyCurveContrastColor() const +{ + return m_historyCurveContrastColor(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferencesSummary.h b/ApplicationLibCode/Application/RiaPreferencesSummary.h index d8e75690dd..c4611e7f81 100644 --- a/ApplicationLibCode/Application/RiaPreferencesSummary.h +++ b/ApplicationLibCode/Application/RiaPreferencesSummary.h @@ -25,7 +25,11 @@ #include "RiaDefines.h" +// Include to make Pdm work for cvf::Color +#include "cafPdmFieldCvfColor.h" + #include + #include //-------------------------------------------------------------------------------------------------- @@ -101,13 +105,15 @@ public: SummaryRestartFilesImportMode summaryEnsembleImportMode() const; QString defaultSummaryCurvesTextFilter() const; bool colorCurvesByPhase() const; - bool appendHistoryVectorForDragDrop() const; + bool appendHistoryVectors() const; SummaryHistoryCurveStyleMode defaultSummaryHistoryCurveStyle() const; RiaDefines::ColumnCount defaultMultiPlotColumnCount() const; RiaDefines::RowCount defaultMultiPlotRowCount() const; + cvf::Color3f historyCurveContrastColor() const; + void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; @@ -130,7 +136,7 @@ private: caf::PdmField m_defaultSummaryCurvesTextFilter; caf::PdmField m_defaultSummaryHistoryCurveStyle; caf::PdmField m_curveColorByPhase; - caf::PdmField m_appendHistoryVectorForDragDrop; + caf::PdmField m_appendHistoryVectors; caf::PdmField m_showSummaryTimeAsLongString; caf::PdmField m_useMultipleThreadsWhenLoadingSummaryCases; @@ -145,4 +151,6 @@ private: caf::PdmField m_defaultColumnCount; caf::PdmField m_defaultRowsPerPage; + + caf::PdmField m_historyCurveContrastColor; }; diff --git a/ApplicationLibCode/Application/Tools/RiaColorTables.cpp b/ApplicationLibCode/Application/Tools/RiaColorTables.cpp index 4522989faa..bdb9912a42 100644 --- a/ApplicationLibCode/Application/Tools/RiaColorTables.cpp +++ b/ApplicationLibCode/Application/Tools/RiaColorTables.cpp @@ -682,6 +682,16 @@ cvf::Color3f RiaColorTables::phaseColor( RiaDefines::PhaseType phase ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaColorTables::historyCurveContrastColor() +{ + auto unsignedColor = cvf::Color3ub( 248, 0, 170 ); // Magenta + + return cvf::Color3f( unsignedColor ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaColorTables.h b/ApplicationLibCode/Application/Tools/RiaColorTables.h index aa2db4a804..509447f787 100644 --- a/ApplicationLibCode/Application/Tools/RiaColorTables.h +++ b/ApplicationLibCode/Application/Tools/RiaColorTables.h @@ -81,6 +81,8 @@ public: static std::map phaseColors(); static cvf::Color3f phaseColor( RiaDefines::PhaseType phase ); + static cvf::Color3f historyCurveContrastColor(); + private: static std::vector categoryColors(); static std::vector contrastCategoryColors(); diff --git a/ApplicationLibCode/Application/Tools/RiaColorTools.cpp b/ApplicationLibCode/Application/Tools/RiaColorTools.cpp index 9c333b3423..04bdce0935 100644 --- a/ApplicationLibCode/Application/Tools/RiaColorTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaColorTools.cpp @@ -184,6 +184,26 @@ QColor RiaColorTools::blendQColors( const QColor& color1, const QColor& color2, ( color1.blue() * weight1 + color2.blue() * weight2 ) / weightsum ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaColorTools::makeLighter( const cvf::Color3f& color, float normalizedScalingFactor ) +{ + auto qColor = toQColor( color ); + + double h = 0.0; + double s = 0.0; + double l = 0.0; + qColor.getHslF( &h, &s, &l ); + + l = l + ( 1.0 - l ) * normalizedScalingFactor; + l = std::min( 1.0, l ); + + qColor.setHslF( h, s, l ); + + return fromQColorTo3f( qColor ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaColorTools.h b/ApplicationLibCode/Application/Tools/RiaColorTools.h index 2030cc233b..7c7b4e2ebe 100644 --- a/ApplicationLibCode/Application/Tools/RiaColorTools.h +++ b/ApplicationLibCode/Application/Tools/RiaColorTools.h @@ -49,6 +49,8 @@ public: blendCvfColors( const cvf::Color3f& color1, const cvf::Color3f& color2, int weight1 = 1, int weight2 = 1 ); static QColor blendQColors( const QColor& color1, const QColor& color2, int weight1 = 1, int weight2 = 1 ); + static cvf::Color3f makeLighter( const cvf::Color3f& color1, float normalizedScalingFactor ); + // Factor > 1 increases saturation, a factor < 1 decreases saturation static QColor modifySaturation( const QColor& color, double factor ); diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp index 52382ff43b..cef51ed269 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicNewSummaryMultiPlotFromDataVectorFeature.cpp @@ -18,13 +18,16 @@ #include "RicNewSummaryMultiPlotFromDataVectorFeature.h" +#include "RiaPreferencesSummary.h" #include "RiaSummaryTools.h" + #include "RimSummaryAddress.h" #include "RimSummaryPlot.h" #include "RicSummaryPlotBuilder.h" #include "RifEclipseSummaryAddress.h" +#include "RifReaderEclipseSummary.h" #include "cafSelectionManagerTools.h" #include "cvfAssert.h" @@ -97,6 +100,21 @@ void RicNewSummaryMultiPlotFromDataVectorFeature::onActionTriggered( bool isChec } } + if ( RiaPreferencesSummary::current()->appendHistoryVectors() ) + { + auto sourceAddresses = eclipseAddresses; + + for ( const auto& addr : sourceAddresses ) + { + if ( !addr.isHistoryVector() ) + { + auto historyAddr = addr; + historyAddr.setVectorName( addr.vectorName() + RifReaderEclipseSummary::historyIdentifier() ); + eclipseAddresses.insert( historyAddr ); + } + } + } + auto newPlot = RicSummaryPlotBuilder::createPlot( eclipseAddresses, selectedCases, selectedEnsembles ); std::vector plots{ newPlot }; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp index 1e96749245..785ee478fb 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -34,6 +34,7 @@ #include "RimProject.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCurve.h" +#include "RimSummaryCurveAppearanceCalculator.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlot.h" @@ -80,7 +81,10 @@ std::vector // Use same counting as RicNewSummaryCurveFeature::onActionTriggered auto colorIndex = plot->singleColorCurveCount(); - curveSet->setColor( RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( colorIndex ) ); + + curveSet->setColor( + RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( addr, + static_cast( colorIndex ) ) ); curveSet->legendConfig()->setColorLegend( RimRegularLegendConfig::mapToColorLegend( RimEnsembleCurveSetColorManager::cycledEnsembleColorRange( static_cast( colorIndex ) ) ) ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index fa6f2fe872..0e971cb309 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -1702,7 +1702,14 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vectorsetSummaryCaseY( sumCase ); curve->setSummaryAddressYAndApplyInterpolation( addr->address() ); curve->setResampling( m_resampling() ); - curve->setLineThickness( 1 ); + + int lineThickness = 1; + if ( addr->address().isHistoryVector() ) + { + lineThickness = 2; + curve->setCurveAppearanceFromCaseType(); + } + curve->setLineThickness( lineThickness ); addCurve( curve ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp index ba878fef63..6539a32574 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp @@ -19,6 +19,7 @@ #include "RimSummaryCurveAppearanceCalculator.h" #include "RiaColorTables.h" +#include "RiaColorTools.h" #include "RiaPreferencesSummary.h" #include "RiaSummaryCurveDefinition.h" @@ -387,6 +388,29 @@ cvf::Color3f RimSummaryCurveAppearanceCalculator::assignColorByPhase( const RifE return cycledNoneRGBBrColor( 0 ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( const RifEclipseSummaryAddress& address, + int colorIndex ) +{ + bool usePhaseColor = RiaPreferencesSummary::current()->colorCurvesByPhase(); + + cvf::Color3f curveColor; + if ( usePhaseColor ) + { + curveColor = RimSummaryCurveAppearanceCalculator::assignColorByPhase( address ); + } + else + { + curveColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( colorIndex ); + } + + float scalingFactor = 0.25; + curveColor = RiaColorTools::makeLighter( curveColor, scalingFactor ); + return curveColor; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h index a50b85ee35..61592713b5 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h @@ -61,8 +61,7 @@ public: void setupCurveLook( RimSummaryCurve* curve ); static cvf::Color3f assignColorByPhase( const RifEclipseSummaryAddress& address ); - - void assignColorByPhase( RimSummaryCurve* curve, int colorIndex ); + static cvf::Color3f computeTintedCurveColorForAddress( const RifEclipseSummaryAddress& address, int colorIndex ); static cvf::Color3f cycledPaletteColor( int colorIndex ); static cvf::Color3f cycledNoneRGBBrColor( int colorIndex ); @@ -84,6 +83,7 @@ private: float gradient( size_t totalCount, int index ); cvf::Color3f gradeColor( const cvf::Color3f& color, float factor ); + void assignColorByPhase( RimSummaryCurve* curve, int colorIndex ); static std::set getAllSummaryCaseNames(); static std::set getAllSummaryWellNames(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index b4519fd1a0..cdbaaed199 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -776,20 +776,12 @@ void RimSummaryPlot::applyDefaultCurveAppearances() { if ( curveSet->colorMode() != RimEnsembleCurveSet::ColorMode::SINGLE_COLOR ) continue; - cvf::Color3f curveColor; - if ( RiaPreferencesSummary::current()->colorCurvesByPhase() ) - { - curveColor = RimSummaryCurveAppearanceCalculator::assignColorByPhase( curveSet->summaryAddress() ); - } - else - { - curveColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( colorIndex++ ); - } + cvf::Color3f curveColor = + RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( curveSet->summaryAddress(), + colorIndex++ ); - int weightBaseColor = 10; - int weightWhite = 25; - - curveColor = RiaColorTools::blendCvfColors( curveColor, cvf::Color3f::WHITE, weightBaseColor, weightWhite ); + auto adr = curveSet->summaryAddress(); + if ( adr.isHistoryVector() ) curveColor = RiaPreferencesSummary::current()->historyCurveContrastColor(); curveSet->setColor( curveColor ); } @@ -1991,17 +1983,6 @@ std::pair> RimSummaryPlot::handleSummaryCaseD { const auto addr = curve->summaryAddressY(); dataVectorMap[addr].insert( curve->summaryCaseY() ); - - if ( !addr.isHistoryVector() && RiaPreferencesSummary::current()->appendHistoryVectorForDragDrop() ) - { - auto historyAddr = addr; - historyAddr.setVectorName( addr.vectorName() + RifReaderEclipseSummary::historyIdentifier() ); - - if ( summaryCase->summaryReader() && summaryCase->summaryReader()->hasAddress( historyAddr ) ) - { - dataVectorMap[historyAddr].insert( curve->summaryCaseY() ); - } - } } for ( const auto& [addr, cases] : dataVectorMap ) @@ -2083,7 +2064,7 @@ std::pair> { newCurveDefsWithObjectNames[newCurveDef].insert( objectIdentifierString ); const auto& addr = curveDef.summaryAddress(); - if ( !addr.isHistoryVector() && RiaPreferencesSummary::current()->appendHistoryVectorForDragDrop() ) + if ( !addr.isHistoryVector() && RiaPreferencesSummary::current()->appendHistoryVectors() ) { auto historyAddr = addr; historyAddr.setVectorName( addr.vectorName() + RifReaderEclipseSummary::historyIdentifier() ); @@ -2133,7 +2114,7 @@ std::pair> RimSummaryPlot::handleSummaryAddre std::vector newCurveAddresses; newCurveAddresses.push_back( summaryAddr->address() ); - if ( !summaryAddr->address().isHistoryVector() && RiaPreferencesSummary::current()->appendHistoryVectorForDragDrop() ) + if ( !summaryAddr->address().isHistoryVector() && RiaPreferencesSummary::current()->appendHistoryVectors() ) { auto historyAddr = summaryAddr->address(); historyAddr.setVectorName( summaryAddr->address().vectorName() + RifReaderEclipseSummary::historyIdentifier() ); @@ -2294,18 +2275,15 @@ void RimSummaryPlot::addNewEnsembleCurveY( const RifEclipseSummaryAddress& addre curveSet->setSummaryCaseCollection( ensemble ); curveSet->setSummaryAddress( address ); - cvf::Color3f curveColor; - if ( RiaPreferencesSummary::current()->colorCurvesByPhase() ) - { - auto basePhaseColor = RimSummaryCurveAppearanceCalculator::assignColorByPhase( curveSet->summaryAddress() ); + cvf::Color3f curveColor = + RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( curveSet->summaryAddress(), + static_cast( + ensembleCurveSetCollection() + ->curveSetCount() ) ); + + auto adr = curveSet->summaryAddress(); + if ( adr.isHistoryVector() ) curveColor = RiaPreferencesSummary::current()->historyCurveContrastColor(); - curveColor = RiaColorTools::blendCvfColors( basePhaseColor, cvf::Color3f::WHITE, 1, 3 ); - } - else - { - curveColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( - ensembleCurveSetCollection()->curveSetCount() ); - } curveSet->setColor( curveColor ); ensembleCurveSetCollection()->addCurveSet( curveSet );