mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-14 01:13:52 -06:00
#4208 Store last used folder when exporting Sector Model + warning for LGRs
This commit is contained in:
parent
677f42591b
commit
f8102797c1
@ -2054,6 +2054,7 @@ bool RiaApplication::openFile(const QString& fileName)
|
||||
|
||||
bool loadingSucceded = false;
|
||||
|
||||
QString lastUsedDialogTag;
|
||||
if (RiaApplication::hasValidProjectFileExtension(fileName))
|
||||
{
|
||||
loadingSucceded = loadProject(fileName);
|
||||
@ -2061,14 +2062,18 @@ bool RiaApplication::openFile(const QString& fileName)
|
||||
else if (fileName.contains(".egrid", Qt::CaseInsensitive) || fileName.contains(".grid", Qt::CaseInsensitive))
|
||||
{
|
||||
loadingSucceded = RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({fileName}));
|
||||
if (loadingSucceded) lastUsedDialogTag = "BINARY_GRID";
|
||||
}
|
||||
else if (fileName.contains(".grdecl", Qt::CaseInsensitive))
|
||||
{
|
||||
loadingSucceded = RicImportInputEclipseCaseFeature::openInputEclipseCaseFromFileNames(QStringList(fileName));
|
||||
if (loadingSucceded) lastUsedDialogTag = "INPUT_FILES";
|
||||
}
|
||||
else if (fileName.contains(".odb", Qt::CaseInsensitive))
|
||||
{
|
||||
loadingSucceded = openOdbCaseFromFile(fileName);
|
||||
if (loadingSucceded) lastUsedDialogTag = "GEOMECH_MODEL";
|
||||
|
||||
}
|
||||
else if (fileName.contains(".smspec", Qt::CaseInsensitive))
|
||||
{
|
||||
@ -2076,12 +2081,20 @@ bool RiaApplication::openFile(const QString& fileName)
|
||||
if (loadingSucceded)
|
||||
{
|
||||
getOrCreateAndShowMainPlotWindow();
|
||||
lastUsedDialogTag = "INPUT_FILES";
|
||||
}
|
||||
}
|
||||
|
||||
if (loadingSucceded && !RiaApplication::hasValidProjectFileExtension(fileName))
|
||||
if (loadingSucceded)
|
||||
{
|
||||
caf::PdmUiModelChangeDetector::instance()->setModelChanged();
|
||||
if (!lastUsedDialogTag.isEmpty())
|
||||
{
|
||||
RiaApplication::instance()->setLastUsedDialogDirectory(lastUsedDialogTag, QFileInfo(fileName).absolutePath());
|
||||
}
|
||||
if (!RiaApplication::hasValidProjectFileExtension(fileName))
|
||||
{
|
||||
caf::PdmUiModelChangeDetector::instance()->setModelChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return loadingSucceded;
|
||||
|
@ -99,6 +99,16 @@ void RicExportEclipseInputGridFeature::executeCommand(RimEclipseView* view,
|
||||
RiaLogging::error(
|
||||
QString("Unable to write grid to '%1'").arg(exportSettings.exportGridFilename));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (view->eclipseCase()->eclipseCaseData()->gridCount() > 1u)
|
||||
{
|
||||
RiaLogging::warning("Grid has LGRs but ResInsight only supports exporting the Main Grid");
|
||||
}
|
||||
|
||||
QFileInfo info(exportSettings.exportGridFilename());
|
||||
RiaApplication::instance()->setLastUsedDialogDirectory("EXPORT_INPUT_GRID", info.absolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
if (exportSettings.exportResults() != RicExportEclipseInputGridUi::EXPORT_NO_RESULTS)
|
||||
@ -115,12 +125,12 @@ void RicExportEclipseInputGridFeature::executeCommand(RimEclipseView* view,
|
||||
{
|
||||
QString fileName = dirPath.absoluteFilePath(keyword + ".GRDECL");
|
||||
bool worked = RifEclipseInputFileTools::exportKeywords(fileName,
|
||||
view->eclipseCase()->eclipseCaseData(),
|
||||
{keyword},
|
||||
fileWriteMode,
|
||||
min,
|
||||
max,
|
||||
refinement);
|
||||
view->eclipseCase()->eclipseCaseData(),
|
||||
{keyword},
|
||||
fileWriteMode,
|
||||
min,
|
||||
max,
|
||||
refinement);
|
||||
if (!worked)
|
||||
{
|
||||
RiaLogging::error(QString("Unable to write results to '%1'").arg(fileName));
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include <QFileInfo>
|
||||
#include <QIntValidator>
|
||||
|
||||
#include <set>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicExportEclipseInputGridUi, "RicExportEclipseInputGridUi");
|
||||
|
||||
namespace caf
|
||||
@ -41,9 +43,9 @@ namespace caf
|
||||
template<>
|
||||
void RicExportEclipseInputGridUi::ResultExportOptionsEnum::setUp()
|
||||
{
|
||||
addItem(RicExportEclipseInputGridUi::EXPORT_NO_RESULTS, "NO_RESULTS", "Do not export results");
|
||||
addItem(RicExportEclipseInputGridUi::EXPORT_TO_GRID_FILE, "TO_GRID_FILE", "Export to grid file");
|
||||
addItem(RicExportEclipseInputGridUi::EXPORT_TO_SINGLE_SEPARATE_FILE, "TO_SINGLE_RESULT_FILE", "Export to single results file");
|
||||
addItem(RicExportEclipseInputGridUi::EXPORT_NO_RESULTS, "NO_RESULTS", "Do not export");
|
||||
addItem(RicExportEclipseInputGridUi::EXPORT_TO_GRID_FILE, "TO_GRID_FILE", "Append to grid file");
|
||||
addItem(RicExportEclipseInputGridUi::EXPORT_TO_SINGLE_SEPARATE_FILE, "TO_SINGLE_RESULT_FILE", "Export to single file");
|
||||
addItem(RicExportEclipseInputGridUi::EXPORT_TO_SEPARATE_FILE_PER_RESULT, "TO_SEPARATE_RESULT_FILES", "Export to a separate file per result");
|
||||
|
||||
setDefault(RicExportEclipseInputGridUi::EXPORT_TO_GRID_FILE);
|
||||
@ -149,16 +151,17 @@ void RicExportEclipseInputGridUi::defineUiOrdering(QString uiConfigName, caf::Pd
|
||||
exportGridFilename.uiCapability()->setUiReadOnly(!exportGrid());
|
||||
|
||||
caf::PdmUiGroup* resultsGroup = uiOrdering.addNewGroup("Results and Faults Export");
|
||||
|
||||
resultsGroup->add(&exportResults);
|
||||
resultsGroup->add(&exportFaults);
|
||||
if (exportResults() != EXPORT_NO_RESULTS)
|
||||
{
|
||||
if (exportResults() == EXPORT_TO_SINGLE_SEPARATE_FILE)
|
||||
{
|
||||
resultsGroup->add(&exportResultsFilename);
|
||||
|
||||
resultsGroup->add(&exportMainKeywords);
|
||||
resultsGroup->add(&exportAdditionalKeywords);
|
||||
}
|
||||
}
|
||||
|
||||
resultsGroup->add(&exportFaults);
|
||||
if (exportFaults() != EXPORT_NO_RESULTS)
|
||||
{
|
||||
if (exportFaults() == EXPORT_TO_SINGLE_SEPARATE_FILE)
|
||||
@ -167,6 +170,12 @@ void RicExportEclipseInputGridUi::defineUiOrdering(QString uiConfigName, caf::Pd
|
||||
}
|
||||
}
|
||||
|
||||
if (exportResults() != EXPORT_NO_RESULTS)
|
||||
{
|
||||
resultsGroup->add(&exportMainKeywords);
|
||||
resultsGroup->add(&exportAdditionalKeywords);
|
||||
}
|
||||
|
||||
caf::PdmUiGroup* gridRefinement = uiOrdering.addNewGroup("Grid Refinement");
|
||||
gridRefinement->add(&cellCountI, { true, 2, 1 });
|
||||
gridRefinement->add(&cellCountJ, { false });
|
||||
@ -269,6 +278,14 @@ QList<caf::PdmOptionItemInfo>
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fieldNeedingOptions == &exportFaults)
|
||||
{
|
||||
std::set<ResultExportOptions> validFaultOptions = { EXPORT_NO_RESULTS, EXPORT_TO_GRID_FILE, EXPORT_TO_SINGLE_SEPARATE_FILE };
|
||||
for (ResultExportOptions option : validFaultOptions)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(ResultExportOptionsEnum::uiText(option), option));
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
@ -280,12 +297,29 @@ std::set<QString> RicExportEclipseInputGridUi::mainKeywords()
|
||||
return { "EQLNUM", "FIPNUM", "NTG", "PERMX", "PERMY", "PERMZ", "PORO", "PVTNUM", "SATNUM", "SWATINIT" };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicExportEclipseInputGridUi::defaultFolder() const
|
||||
{
|
||||
QString projectDirectory = RiaApplication::instance()->currentProjectPath();
|
||||
QString fallbackDirectory = projectDirectory;
|
||||
if (fallbackDirectory.isEmpty())
|
||||
{
|
||||
QString generalFallback = RiaApplication::instance()->lastUsedDialogDirectory("GENERAL_DATA");
|
||||
fallbackDirectory = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("BINARY_GRID", generalFallback);
|
||||
}
|
||||
return RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("EXPORT_INPUT_GRID", fallbackDirectory);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicExportEclipseInputGridUi::defaultGridFileName() const
|
||||
{
|
||||
QDir baseDir(RiaApplication::instance()->currentProjectPath());
|
||||
|
||||
QDir baseDir(defaultFolder());
|
||||
return baseDir.absoluteFilePath("GRID.GRDECL");
|
||||
}
|
||||
|
||||
@ -294,7 +328,7 @@ QString RicExportEclipseInputGridUi::defaultGridFileName() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicExportEclipseInputGridUi::defaultResultsFileName() const
|
||||
{
|
||||
QDir baseDir(RiaApplication::instance()->currentProjectPath());
|
||||
QDir baseDir(defaultFolder());
|
||||
return baseDir.absoluteFilePath("RESULTS.GRDECL");
|
||||
}
|
||||
|
||||
@ -303,6 +337,6 @@ QString RicExportEclipseInputGridUi::defaultResultsFileName() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicExportEclipseInputGridUi::defaultFaultsFileName() const
|
||||
{
|
||||
QDir baseDir(RiaApplication::instance()->currentProjectPath());
|
||||
QDir baseDir(defaultFolder());
|
||||
return baseDir.absoluteFilePath("FAULTS.GRDECL");
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ protected:
|
||||
bool* useOptionsOnly) override;
|
||||
|
||||
static std::set<QString> mainKeywords();
|
||||
QString defaultFolder() const;
|
||||
QString defaultGridFileName() const;
|
||||
QString defaultResultsFileName() const;
|
||||
QString defaultFaultsFileName() const;
|
||||
|
@ -91,14 +91,17 @@ void RicImportGeneralDataFeature::onActionTriggered(bool isChecked)
|
||||
if (!eclipseCaseFiles.empty())
|
||||
{
|
||||
RicImportEclipseCaseFeature::openEclipseCaseFromFileNames(eclipseCaseFiles);
|
||||
app->setLastUsedDialogDirectory("BINARY_GRID", defaultDir);
|
||||
}
|
||||
if (!eclipseInputFiles.empty())
|
||||
{
|
||||
RicImportInputEclipseCaseFeature::openInputEclipseCaseFromFileNames(eclipseInputFiles);
|
||||
app->setLastUsedDialogDirectory("INPUT_FILES", defaultDir);
|
||||
}
|
||||
if (!eclipseSummaryFiles.empty())
|
||||
{
|
||||
RicImportSummaryCaseFeature::openSummaryCaseFromFileNames(eclipseSummaryFiles);
|
||||
app->setLastUsedDialogDirectory("INPUT_FILES", defaultDir);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,9 +238,9 @@ bool RifEclipseInputFileTools::exportGrid(const QString& fileName,
|
||||
max = cvf::Vec3st(mainGrid->cellCountI() - 1, mainGrid->cellCountJ() - 1, mainGrid->cellCountK() - 1);
|
||||
}
|
||||
|
||||
int ecl_nx = static_cast<int>((max.x() - min.x() + 1) * refinement.x());
|
||||
int ecl_ny = static_cast<int>((max.y() - min.y() + 1) * refinement.y());
|
||||
int ecl_nz = static_cast<int>((max.z() - min.z() + 1) * refinement.z());
|
||||
int ecl_nx = static_cast<int>((max.x() - min.x()) * refinement.x() + 1);
|
||||
int ecl_ny = static_cast<int>((max.y() - min.y()) * refinement.y() + 1);
|
||||
int ecl_nz = static_cast<int>((max.z() - min.z()) * refinement.z() + 1);
|
||||
|
||||
CVF_ASSERT(ecl_nx > 0 && ecl_ny > 0 && ecl_nz > 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user