#1402 Fixed Well Alloc plot case switching, and removed dependency on active view

This commit is contained in:
Jacob Støren
2017-04-06 14:12:24 +02:00
parent b4de373d2f
commit 26b85dedfc
6 changed files with 109 additions and 56 deletions

View File

@@ -317,44 +317,20 @@ RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusInTimeSte
//--------------------------------------------------------------------------------------------------
cvf::Color3f RimFlowDiagSolution::tracerColor(const QString& tracerName) const
{
RimEclipseResultCase* eclCase;
this->firstAncestorOrThisOfType(eclCase);
QString wellName = removeCrossFlowEnding(tracerName);
if ( eclCase )
{
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
if (activeView)
{
RimEclipseWell* well = activeView->wellCollection->findWell(wellName);
if (well)
{
return well->wellPipeColor();
}
}
else
{
// If we do not find a well color, use index in well result data to be able to get variation of tracer colors
// This can be the case if we do not have any views at all
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->eclipseCaseData()->wellResults();
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
{
if ( wellResults[wIdx]->m_wellName == wellName )
{
return RiaColorTables::wellsPaletteColors().cycledColor3f(wIdx);
}
}
}
}
if (wellName == RIG_FLOW_TOTAL_NAME) return cvf::Color3f::LIGHT_GRAY;
if (wellName == RIG_RESERVOIR_TRACER_NAME) return cvf::Color3f::LIGHT_GRAY;
if (wellName == RIG_TINY_TRACER_GROUP_NAME) return cvf::Color3f::DARK_GRAY;
RimEclipseResultCase* eclCase;
this->firstAncestorOrThisOfType(eclCase);
if ( eclCase )
{
return eclCase->defaultWellColor(wellName);
}
return cvf::Color3f::LIGHT_GRAY;
}

View File

@@ -538,16 +538,7 @@ QList<caf::PdmOptionItemInfo> RimWellAllocationPlot::calculateValueOptions(const
if (fieldNeedingOptions == &m_wellName)
{
std::set<QString> sortedWellNames;
if ( m_case && m_case->eclipseCaseData() )
{
const cvf::Collection<RigSingleWellResultsData>& wellRes = m_case->eclipseCaseData()->wellResults();
for ( size_t wIdx = 0; wIdx < wellRes.size(); ++wIdx )
{
sortedWellNames.insert(wellRes[wIdx]->m_wellName);
}
}
std::set<QString> sortedWellNames = this->findSortedWellNames();
QIcon simWellIcon(":/Well.png");
for ( const QString& wname: sortedWellNames )
@@ -649,8 +640,30 @@ void RimWellAllocationPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedF
{
updateWidgetTitleWindowTitle();
}
else if ( changedField == &m_case)
{
if ( m_flowDiagSolution && m_case )
{
m_flowDiagSolution = m_case->defaultFlowDiagSolution();
}
else
{
m_flowDiagSolution = nullptr;
}
if (!m_case) m_timeStep = 0;
else if (m_timeStep >= m_case->timeStepDates().size())
{
m_timeStep = std::max(0, ((int)m_case->timeStepDates().size()) - 1);
}
std::set<QString> sortedWellNames = findSortedWellNames();
if (!sortedWellNames.size()) m_wellName = "";
else if ( sortedWellNames.count(m_wellName()) == 0 ){ m_wellName = *sortedWellNames.begin();}
loadDataAndUpdate();
}
else if ( changedField == &m_wellName
|| changedField == &m_case
|| changedField == &m_timeStep
|| changedField == &m_flowDiagSolution
|| changedField == &m_groupSmallContributions
@@ -661,6 +674,25 @@ void RimWellAllocationPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedF
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<QString> RimWellAllocationPlot::findSortedWellNames()
{
std::set<QString> sortedWellNames;
if ( m_case && m_case->eclipseCaseData() )
{
const cvf::Collection<RigSingleWellResultsData>& wellRes = m_case->eclipseCaseData()->wellResults();
for ( size_t wIdx = 0; wIdx < wellRes.size(); ++wIdx )
{
sortedWellNames.insert(wellRes[wIdx]->m_wellName);
}
}
return sortedWellNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -80,6 +80,9 @@ protected:
// Overridden PDM methods
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
std::set<QString> findSortedWellNames();
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
virtual QImage snapshotWindowContent() override;

View File

@@ -21,12 +21,14 @@
#include "RimEclipseCase.h"
#include "RiaApplication.h"
#include "RiaColorTables.h"
#include "RiaPreferences.h"
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RigSingleWellResultsData.h"
#include "RimCaseCollection.h"
#include "RimCellEdgeColors.h"
@@ -133,6 +135,48 @@ const RigEclipseCaseData* RimEclipseCase::eclipseCaseData() const
return m_rigEclipseCase.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Color3f RimEclipseCase::defaultWellColor(const QString& wellName)
{
if ( m_wellToColorMap.empty() )
{
const caf::ColorTable& colorTable = RiaColorTables::wellsPaletteColors();
cvf::Color3ubArray wellColors = colorTable.color3ubArray();
cvf::Color3ubArray interpolatedWellColors = wellColors;
const cvf::Collection<RigSingleWellResultsData>& wellResults = this->eclipseCaseData()->wellResults();
if ( wellResults.size() > 1 )
{
interpolatedWellColors = caf::ColorTable::interpolateColorArray(wellColors, wellResults.size());
}
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
{
m_wellToColorMap[wellResults[wIdx]->m_wellName] = cvf::Color3f::BLACK;
}
size_t wIdx = 0;
for ( auto & wNameColorPair: m_wellToColorMap )
{
wNameColorPair.second = cvf::Color3f(interpolatedWellColors[wIdx]);
++wIdx;
}
}
auto nmColor = m_wellToColorMap.find(wellName);
if (nmColor != m_wellToColorMap.end())
{
return nmColor->second;
}
else
{
return cvf::Color3f::LIGHT_GRAY;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -31,6 +31,7 @@
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfColor3.h"
class QString;
@@ -69,6 +70,7 @@ public:
RigEclipseCaseData* eclipseCaseData();
const RigEclipseCaseData* eclipseCaseData() const;
cvf::Color3f defaultWellColor(const QString& wellName);
RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel);
@@ -115,6 +117,8 @@ private:
caf::PdmChildField<RimReservoirCellResultsStorage*> m_fractureModelResults;
QString m_timeStepFormatString;
std::map<QString , cvf::Color3f> m_wellToColorMap;
// Obsolete fields
protected:
caf::PdmField<QString> caseName;

View File

@@ -461,23 +461,17 @@ void RimEclipseWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang
//--------------------------------------------------------------------------------------------------
void RimEclipseWellCollection::assignDefaultWellColors()
{
const caf::ColorTable& colorTable = RiaColorTables::wellsPaletteColors();
cvf::Color3ubArray wellColors = colorTable.color3ubArray();
cvf::Color3ubArray interpolatedWellColors = wellColors;
if (wells.size() > 1)
{
interpolatedWellColors = caf::ColorTable::interpolateColorArray(wellColors, wells.size());
}
RimEclipseCase* ownerCase;
firstAncestorOrThisOfTypeAsserted(ownerCase);
for (size_t wIdx = 0; wIdx < wells.size(); ++wIdx)
{
RimEclipseWell* well = wells[wIdx];
if (well)
if (well && well->wellResults() )
{
cvf::Color3f col = cvf::Color3f(interpolatedWellColors[wIdx]);
well->wellPipeColor = col;
well->updateConnectedEditors();
well->wellPipeColor = ownerCase->defaultWellColor(well->wellResults()->m_wellName);
}
}