mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3456 ExportProperty. Use information from views when needed
This commit is contained in:
parent
116b36bbc8
commit
e01456f40b
@ -55,7 +55,6 @@ RicfExportProperty::RicfExportProperty()
|
|||||||
RICF_InitField(&m_type, "type", caf::AppEnum<RiaDefines::ResultCatType>(RiaDefines::UNDEFINED), "Property type", "", "", "");
|
RICF_InitField(&m_type, "type", caf::AppEnum<RiaDefines::ResultCatType>(RiaDefines::UNDEFINED), "Property type", "", "", "");
|
||||||
RICF_InitField(&m_eclipseKeyword, "eclipseKeyword", QString(), "Eclipse Keyword", "", "", "");
|
RICF_InitField(&m_eclipseKeyword, "eclipseKeyword", QString(), "Eclipse Keyword", "", "", "");
|
||||||
RICF_InitField(&m_undefinedValue, "undefinedValue", 0.0, "Undefined Value", "", "", "");
|
RICF_InitField(&m_undefinedValue, "undefinedValue", 0.0, "Undefined Value", "", "", "");
|
||||||
RICF_InitField(&m_path, "exportFile", QString(), "Export File", "", "", "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -83,49 +82,62 @@ void RicfExportProperty::execute()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool fullySpecified = m_caseId >= 0 && m_timeStepIndex >= 0 && !m_propertyName().isEmpty();
|
||||||
|
bool anyViewsFound = false;
|
||||||
|
for (Rim3dView* v : eclipseCase->views())
|
||||||
|
{
|
||||||
|
RimEclipseView* view = dynamic_cast<RimEclipseView*>(v);
|
||||||
|
if (!view) continue;
|
||||||
|
anyViewsFound = true;
|
||||||
|
|
||||||
|
auto timeStepIndex = m_timeStepIndex >= 0 ? m_timeStepIndex : view->currentTimeStep();
|
||||||
|
auto propertyName = !m_propertyName().isEmpty() ? m_propertyName : view->cellResult()->resultVariable();
|
||||||
|
auto propertyType = !m_propertyName().isEmpty() ? m_type() : view->cellResult()->resultType();
|
||||||
|
|
||||||
QString filePath = m_path;
|
QString filePath = m_path;
|
||||||
if (filePath.isNull())
|
if (filePath.isNull())
|
||||||
{
|
{
|
||||||
QDir propertiesDir(RicfCommandFileExecutor::instance()->getExportPath(RicfCommandFileExecutor::PROPERTIES));
|
QDir propertiesDir(RicfCommandFileExecutor::instance()->getExportPath(RicfCommandFileExecutor::PROPERTIES));
|
||||||
QString fileName = QString("%1-%2").arg(eclipseCase->caseUserDescription()).arg(m_propertyName);
|
QString fileName;
|
||||||
|
|
||||||
|
if (fullySpecified) fileName = QString("%1-T%2-%3").arg(eclipseCase->caseUserDescription()).arg(timeStepIndex).arg(propertyName);
|
||||||
|
else fileName = QString("%1-%2-T%3-%4").arg(eclipseCase->caseUserDescription()).arg(view->name()).arg(timeStepIndex).arg(propertyName);
|
||||||
|
|
||||||
fileName = caf::Utils::makeValidFileBasename(fileName);
|
fileName = caf::Utils::makeValidFileBasename(fileName);
|
||||||
filePath = propertiesDir.filePath(fileName);
|
filePath = propertiesDir.filePath(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME : Select correct view?
|
auto eclipseKeyword = m_eclipseKeyword();
|
||||||
RimEclipseView* view = nullptr;
|
if (m_eclipseKeyword().isNull())
|
||||||
for (Rim3dView* v : eclipseCase->views())
|
|
||||||
{
|
{
|
||||||
view = dynamic_cast<RimEclipseView*>(v);
|
eclipseKeyword = propertyName;
|
||||||
if (view) break;
|
|
||||||
}
|
}
|
||||||
if (!view)
|
|
||||||
|
auto resultAccessor = findResult(view, timeStepIndex, propertyType, propertyName);
|
||||||
|
if (!resultAccessor.isNull())
|
||||||
|
{
|
||||||
|
RifEclipseInputFileTools::writeResultToTextFile(filePath, eclipseCase->eclipseCaseData(), resultAccessor, eclipseKeyword, m_undefinedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fullySpecified) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!anyViewsFound)
|
||||||
{
|
{
|
||||||
RiaLogging::error(QString("exportProperty: Could not find a view for case with ID %1").arg(m_caseId()));
|
RiaLogging::error(QString("exportProperty: Could not find a view for case with ID %1").arg(m_caseId()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_eclipseKeyword().isNull())
|
|
||||||
{
|
|
||||||
m_eclipseKeyword = m_propertyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto resultAccessor = findResult(view, eclipseCase, m_timeStepIndex, m_type(), m_propertyName);
|
|
||||||
if (!resultAccessor.isNull())
|
|
||||||
{
|
|
||||||
RifEclipseInputFileTools::writeResultToTextFile(filePath, eclipseCase->eclipseCaseData(), resultAccessor, m_eclipseKeyword, m_undefinedValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
cvf::ref<RigResultAccessor> RicfExportProperty::findResult(RimEclipseView* view,
|
cvf::ref<RigResultAccessor> RicfExportProperty::findResult(RimEclipseView* view,
|
||||||
RimEclipseCase* eclipseCase,
|
|
||||||
size_t timeStep,
|
size_t timeStep,
|
||||||
RiaDefines::ResultCatType resultType,
|
RiaDefines::ResultCatType resultType,
|
||||||
const QString& property)
|
const QString& property)
|
||||||
{
|
{
|
||||||
|
auto eclipseCase = view->eclipseCase();
|
||||||
size_t resultIndex = cvf::UNDEFINED_SIZE_T;
|
size_t resultIndex = cvf::UNDEFINED_SIZE_T;
|
||||||
|
|
||||||
if (resultType == RiaDefines::UNDEFINED)
|
if (resultType == RiaDefines::UNDEFINED)
|
||||||
|
@ -47,7 +47,6 @@ public:
|
|||||||
virtual void execute() override;
|
virtual void execute() override;
|
||||||
|
|
||||||
cvf::ref<RigResultAccessor> findResult(RimEclipseView* view,
|
cvf::ref<RigResultAccessor> findResult(RimEclipseView* view,
|
||||||
RimEclipseCase* eclipseCase,
|
|
||||||
size_t timeStep,
|
size_t timeStep,
|
||||||
RiaDefines::ResultCatType resultType,
|
RiaDefines::ResultCatType resultType,
|
||||||
const QString& property);
|
const QString& property);
|
||||||
|
Loading…
Reference in New Issue
Block a user