mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1230 Added infrastructure for loadAndUpdate of StimPlan data
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "RimFracture.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimStimPlanLegendConfig.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
@@ -48,7 +49,8 @@ RimStimPlanFractureTemplate::RimStimPlanFractureTemplate(void)
|
||||
|
||||
CAF_PDM_InitField(&wellPathDepthAtFracture, "WellPathDepthAtFracture", 0.0, "Depth of Well Path at Fracture", "", "", "");
|
||||
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_legendConfigurations, "LegendConfigurations", "", "", "", "");
|
||||
m_legendConfigurations.uiCapability()->setUiTreeHidden(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -67,12 +69,15 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch
|
||||
if (&m_stimPlanFileName == changedField)
|
||||
{
|
||||
updateUiTreeName();
|
||||
loadDataAndUpdate();
|
||||
/*
|
||||
QString errorMessage;
|
||||
readStimPlanXMLFile(&errorMessage);
|
||||
if (!errorMessage.isEmpty())
|
||||
{
|
||||
QMessageBox::warning(nullptr, "StimPlanFile", errorMessage);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if (&wellPathDepthAtFracture == changedField)
|
||||
@@ -141,8 +146,6 @@ QString RimStimPlanFractureTemplate::fileNameWithOutPath()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStimPlanFractureTemplate::readStimPlanXMLFile(QString * errorMessage)
|
||||
{
|
||||
|
||||
|
||||
m_stimPlanFractureDefinitionData = new RigStimPlanFractureDefinition;
|
||||
{
|
||||
QFile dataFile(m_stimPlanFileName());
|
||||
@@ -258,6 +261,52 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate()
|
||||
QString errorMessage;
|
||||
readStimPlanXMLFile(&errorMessage);
|
||||
qDebug() << errorMessage;
|
||||
|
||||
std::vector<QString> resultNames = m_stimPlanFractureDefinitionData->resultNames();
|
||||
|
||||
// Delete legends referencing results not present on file
|
||||
{
|
||||
std::vector<RimStimPlanLegendConfig*> toBeDeleted;
|
||||
for (RimStimPlanLegendConfig* legend : m_legendConfigurations)
|
||||
{
|
||||
QString legendName = legend->name();
|
||||
if (std::find(resultNames.begin(), resultNames.end(), legendName) == resultNames.end())
|
||||
{
|
||||
toBeDeleted.push_back(legend);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto legend : toBeDeleted)
|
||||
{
|
||||
m_legendConfigurations.removeChildObject(legend);
|
||||
|
||||
delete legend;
|
||||
}
|
||||
}
|
||||
|
||||
// Create legend for result if not already present
|
||||
for (auto resultName : resultNames)
|
||||
{
|
||||
bool foundResult = false;
|
||||
|
||||
for (RimStimPlanLegendConfig* legend : m_legendConfigurations)
|
||||
{
|
||||
if (legend->name().compare(resultName) == 0)
|
||||
{
|
||||
foundResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundResult)
|
||||
{
|
||||
RimStimPlanLegendConfig* legendConfig = new RimStimPlanLegendConfig();
|
||||
legendConfig->setName(resultName);
|
||||
|
||||
m_legendConfigurations.push_back(legendConfig);
|
||||
}
|
||||
}
|
||||
|
||||
updateConnectedEditors();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user