mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
Improve history curve color and symbols
This commit is contained in:
parent
cb1c94630b
commit
e5cf5f4cf3
@ -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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -25,7 +25,11 @@
|
||||
|
||||
#include "RiaDefines.h"
|
||||
|
||||
// Include to make Pdm work for cvf::Color
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <vector>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -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<QString> m_defaultSummaryCurvesTextFilter;
|
||||
caf::PdmField<SummaryHistoryCurveStyleModeType> m_defaultSummaryHistoryCurveStyle;
|
||||
caf::PdmField<bool> m_curveColorByPhase;
|
||||
caf::PdmField<bool> m_appendHistoryVectorForDragDrop;
|
||||
caf::PdmField<bool> m_appendHistoryVectors;
|
||||
|
||||
caf::PdmField<bool> m_showSummaryTimeAsLongString;
|
||||
caf::PdmField<bool> m_useMultipleThreadsWhenLoadingSummaryCases;
|
||||
@ -145,4 +151,6 @@ private:
|
||||
|
||||
caf::PdmField<ColumnCountEnum> m_defaultColumnCount;
|
||||
caf::PdmField<RowCountEnum> m_defaultRowsPerPage;
|
||||
|
||||
caf::PdmField<cvf::Color3f> m_historyCurveContrastColor;
|
||||
};
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -81,6 +81,8 @@ public:
|
||||
static std::map<RiaDefines::PhaseType, caf::ColorTable> phaseColors();
|
||||
static cvf::Color3f phaseColor( RiaDefines::PhaseType phase );
|
||||
|
||||
static cvf::Color3f historyCurveContrastColor();
|
||||
|
||||
private:
|
||||
static std::vector<cvf::Color3ub> categoryColors();
|
||||
static std::vector<cvf::Color3ub> contrastCategoryColors();
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -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<RimSummaryPlot*> plots{ newPlot };
|
||||
|
@ -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<RimEnsembleCurveSet*>
|
||||
|
||||
// Use same counting as RicNewSummaryCurveFeature::onActionTriggered
|
||||
auto colorIndex = plot->singleColorCurveCount();
|
||||
curveSet->setColor( RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( colorIndex ) );
|
||||
|
||||
curveSet->setColor(
|
||||
RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( addr,
|
||||
static_cast<int>( colorIndex ) ) );
|
||||
curveSet->legendConfig()->setColorLegend( RimRegularLegendConfig::mapToColorLegend(
|
||||
RimEnsembleCurveSetColorManager::cycledEnsembleColorRange( static_cast<int>( colorIndex ) ) ) );
|
||||
|
||||
|
@ -1702,7 +1702,14 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vector<RimSummaryCase
|
||||
curve->setSummaryCaseY( 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 );
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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<std::string> getAllSummaryCaseNames();
|
||||
static std::set<std::string> getAllSummaryWellNames();
|
||||
|
@ -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<int, std::vector<RimSummaryCurve*>> 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<int, std::vector<RimSummaryCurve*>>
|
||||
{
|
||||
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<int, std::vector<RimSummaryCurve*>> RimSummaryPlot::handleSummaryAddre
|
||||
|
||||
std::vector<RifEclipseSummaryAddress> 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<int>(
|
||||
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 );
|
||||
|
Loading…
Reference in New Issue
Block a user