#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;