#3801 Postpone assignment of old selectedTracer-field to producers and injectors

* initAfterRead is too soon as the solver hasn't been set up yet.
* wait until onEditorWidgetsCreated()
This commit is contained in:
Gaute Lindkvist 2018-11-30 11:25:56 +01:00 committed by Magne Sjaastad
parent d119f3d146
commit 4bdab329e1
2 changed files with 46 additions and 37 deletions

View File

@ -49,6 +49,7 @@
#include "cafPdmUiTreeSelectionEditor.h"
#include "cafUtils.h"
#include <QDebug>
#include <QList>
namespace caf
@ -861,6 +862,11 @@ bool RimEclipseResultDefinition::hasDynamicResult() const
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition::initAfterRead()
{
if (m_flowSolution() == nullptr)
{
assignFlowSolutionFromCase();
}
m_porosityModelUiField = m_porosityModel;
m_resultTypeUiField = m_resultType;
m_resultVariableUiField = m_resultVariable;
@ -868,42 +874,6 @@ void RimEclipseResultDefinition::initAfterRead()
m_flowSolutionUiField = m_flowSolution();
m_selectedInjectorTracersUiField = m_selectedInjectorTracers;
if (m_flowSolution() == nullptr)
{
assignFlowSolutionFromCase();
}
if (m_flowSolution())
{
std::vector<QString> selectedInjectorTracers;
std::vector<QString> selectedProducerTracers;
for (const QString& tracerName : m_selectedTracers_OBSOLETE())
{
RimFlowDiagSolution::TracerStatusType tracerStatus = m_flowSolution()->tracerStatusOverall(tracerName);
if (tracerStatus == RimFlowDiagSolution::INJECTOR)
{
selectedInjectorTracers.push_back(tracerName);
}
else if (tracerStatus == RimFlowDiagSolution::PRODUCER)
{
selectedProducerTracers.push_back(tracerName);
}
else if (tracerStatus == RimFlowDiagSolution::VARYING || tracerStatus == RimFlowDiagSolution::UNDEFINED)
{
selectedInjectorTracers.push_back(tracerName);
selectedProducerTracers.push_back(tracerName);
}
}
if (!selectedInjectorTracers.empty())
{
setSelectedInjectorTracers(selectedInjectorTracers);
}
if (!selectedProducerTracers.empty())
{
setSelectedProducerTracers(selectedProducerTracers);
}
}
this->updateUiIconFromToggleField();
}
@ -1159,6 +1129,43 @@ void RimEclipseResultDefinition::defineEditorAttribute(const caf::PdmFieldHandle
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition::onEditorWidgetsCreated()
{
if (m_flowSolution() && !m_selectedTracers_OBSOLETE().empty())
{
std::vector<QString> selectedTracers;
selectedTracers.swap(m_selectedTracers_OBSOLETE.v());
std::set<QString, TracerComp> allInjectorTracers = setOfTracersOfType(true);
std::set<QString, TracerComp> allProducerTracers = setOfTracersOfType(false);
std::vector<QString> selectedInjectorTracers;
std::vector<QString> selectedProducerTracers;
for (const QString& tracerName : selectedTracers)
{
if (allInjectorTracers.count(tracerName))
{
selectedInjectorTracers.push_back(tracerName);
}
if (allProducerTracers.count(tracerName))
{
selectedProducerTracers.push_back(tracerName);
}
}
if (!selectedInjectorTracers.empty())
{
setSelectedInjectorTracers(selectedInjectorTracers);
}
if (!selectedProducerTracers.empty())
{
setSelectedProducerTracers(selectedProducerTracers);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -123,6 +123,7 @@ protected:
void initAfterRead() override;
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
void onEditorWidgetsCreated() override;
protected:
caf::PdmField< caf::AppEnum< RiaDefines::ResultCatType > > m_resultType;
@ -174,6 +175,7 @@ private:
QList<caf::PdmOptionItemInfo> calcOptionsForVariableUiFieldStandard();
QList<caf::PdmOptionItemInfo> calcOptionsForSelectedTracerField(bool injector);
QString timeOfFlightString(bool shorter) const;
QString maxFractionTracerString(bool shorter) const;