mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2714 Display a warning in origin summary import dialog when ecllib may fail to read origin files
This commit is contained in:
parent
a8fb4469b4
commit
7afa753d11
@ -23,6 +23,7 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaFilePathTools.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RifReaderEclipseSummary.h"
|
||||
#include "RifEclipseSummaryTools.h"
|
||||
@ -107,7 +108,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent)
|
||||
m_gridSeparateCasesBtn = new QRadioButton(this);
|
||||
m_gridNotReadBtn = new QRadioButton(this);
|
||||
m_applyToAllCheckBox = new QCheckBox(this);
|
||||
|
||||
m_warnings = new QListWidget(this);
|
||||
m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
||||
// Connect to signals
|
||||
@ -176,6 +177,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent)
|
||||
dialogLayout->addWidget(m_currentFilesGroup);
|
||||
dialogLayout->addWidget(summaryFilesGroup);
|
||||
dialogLayout->addWidget(m_gridFilesGroup);
|
||||
dialogLayout->addWidget(m_warnings);
|
||||
dialogLayout->addLayout(buttonsLayout);
|
||||
|
||||
setLayout(dialogLayout);
|
||||
@ -208,10 +210,11 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const
|
||||
}
|
||||
|
||||
RifReaderEclipseSummary reader;
|
||||
std::vector<RifRestartFileInfo> originFileInfos = reader.getRestartFiles(summaryHeaderFile);
|
||||
bool hasWarnings = false;
|
||||
std::vector<RifRestartFileInfo> originFileInfos = reader.getRestartFiles(summaryHeaderFile, &hasWarnings);
|
||||
|
||||
// If no restart files are found, do not show dialog
|
||||
if (originFileInfos.empty())
|
||||
// If no restart files are found and no warnings, do not show dialog
|
||||
if (originFileInfos.empty() &&!hasWarnings)
|
||||
{
|
||||
QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(summaryHeaderFile);
|
||||
return RicSummaryCaseRestartDialogResult(true, NOT_IMPORT, NOT_IMPORT, QStringList({ summaryHeaderFile }), QStringList({ gridCaseFile }), false);
|
||||
@ -223,6 +226,11 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const
|
||||
dialogResult = *lastResult;
|
||||
dialogResult.summaryFiles.clear();
|
||||
dialogResult.gridFiles.clear();
|
||||
|
||||
if (hasWarnings)
|
||||
{
|
||||
for (const QString& warning : reader.warnings()) RiaLogging::error(warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -282,6 +290,9 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const
|
||||
dialog.populateFileList(dialog.m_summaryFilesLayout, fileInfosNoRoot[1]);
|
||||
dialog.populateFileList(dialog.m_gridFilesLayout, fileInfosNoRoot[2]);
|
||||
|
||||
// Display warnings if any
|
||||
dialog.displayWarningsIfAny(reader.warnings());
|
||||
|
||||
// Set properties and show dialog
|
||||
dialog.setWindowTitle("Restart Files");
|
||||
dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget);
|
||||
@ -401,19 +412,23 @@ void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout* gridLa
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RifRestartFileInfo> RicSummaryCaseRestartDialog::getRestartFiles(const QString& summaryHeaderFile)
|
||||
RifRestartFileInfo RicSummaryCaseRestartDialog::getFileInfo(const QString& summaryHeaderFile)
|
||||
{
|
||||
RifReaderEclipseSummary reader;
|
||||
return reader.getRestartFiles(summaryHeaderFile);
|
||||
return reader.getFileInfo(summaryHeaderFile);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifRestartFileInfo RicSummaryCaseRestartDialog::getFileInfo(const QString& summaryHeaderFile)
|
||||
void RicSummaryCaseRestartDialog::displayWarningsIfAny(const QStringList& warnings)
|
||||
{
|
||||
RifReaderEclipseSummary reader;
|
||||
return reader.getFileInfo(summaryHeaderFile);
|
||||
m_warnings->setVisible(!warnings.isEmpty());
|
||||
for (const auto& warning : warnings)
|
||||
{
|
||||
QListWidgetItem* item = new QListWidgetItem(warning, m_warnings);
|
||||
item->setForeground(Qt::red);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -67,8 +67,8 @@ public:
|
||||
private:
|
||||
void populateFileList(QGridLayout* gridLayout, const std::vector<RifRestartFileInfo>& fileInfos);
|
||||
void appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo);
|
||||
std::vector<RifRestartFileInfo> getRestartFiles(const QString& summaryHeaderFile);
|
||||
RifRestartFileInfo getFileInfo(const QString& summaryHeaderFile);
|
||||
void displayWarningsIfAny(const QStringList& warnings);
|
||||
|
||||
private slots:
|
||||
void slotDialogOkClicked();
|
||||
@ -92,6 +92,8 @@ private:
|
||||
|
||||
QCheckBox* m_applyToAllCheckBox;
|
||||
QDialogButtonBox* m_buttons;
|
||||
|
||||
QListWidget* m_warnings;
|
||||
};
|
||||
|
||||
|
||||
|
@ -22,8 +22,6 @@
|
||||
#include "RifReaderEclipseOutput.h"
|
||||
#include "RifEclipseSummaryTools.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
|
||||
@ -137,10 +135,14 @@ bool RifReaderEclipseSummary::open(const QString& headerFileName, bool includeRe
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RifRestartFileInfo> RifReaderEclipseSummary::getRestartFiles(const QString& headerFileName)
|
||||
std::vector<RifRestartFileInfo> RifReaderEclipseSummary::getRestartFiles(const QString& headerFileName, bool* hasWarnings)
|
||||
{
|
||||
CVF_ASSERT(hasWarnings);
|
||||
|
||||
std::vector<RifRestartFileInfo> restartFiles;
|
||||
|
||||
m_warnings.clear();
|
||||
*hasWarnings = false;
|
||||
|
||||
RifRestartFileInfo currFile;
|
||||
currFile.fileName = headerFileName;
|
||||
while(!currFile.fileName.isEmpty())
|
||||
@ -152,10 +154,41 @@ std::vector<RifRestartFileInfo> RifReaderEclipseSummary::getRestartFiles(const Q
|
||||
// Fix to stop potential infinite loop
|
||||
if (currFile.fileName == prevFile)
|
||||
{
|
||||
RiaLogging::error("RifReaderEclipseSummary: Restart file reference loop detected");
|
||||
m_warnings.push_back("RifReaderEclipseSummary: Restart file reference loop detected");
|
||||
*hasWarnings = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Due to a weakness in libecl regarding restart summary header file selection,
|
||||
// do some extra checking
|
||||
{
|
||||
QString formattedHeaderExtension = ".FSMSPEC";
|
||||
QString nonformattedHeaderExtension = ".SMSPEC";
|
||||
QString formattedDataFileExtension = ".FUNSMRY";
|
||||
|
||||
if (currFile.fileName.endsWith(nonformattedHeaderExtension, Qt::CaseInsensitive))
|
||||
{
|
||||
QString formattedHeaderFile = currFile.fileName;
|
||||
formattedHeaderFile.replace(nonformattedHeaderExtension, formattedHeaderExtension, Qt::CaseInsensitive);
|
||||
QString formattedDateFile = currFile.fileName;
|
||||
formattedDateFile.replace(nonformattedHeaderExtension, formattedDataFileExtension, Qt::CaseInsensitive);
|
||||
|
||||
QFileInfo nonformattedHeaderFileInfo = QFileInfo(currFile.fileName);
|
||||
QFileInfo formattedHeaderFileInfo = QFileInfo(formattedHeaderFile);
|
||||
QFileInfo formattedDateFileInfo = QFileInfo(formattedDateFile);
|
||||
if (formattedHeaderFileInfo.lastModified() < nonformattedHeaderFileInfo.lastModified() &&
|
||||
formattedHeaderFileInfo.exists() && !formattedDateFileInfo.exists())
|
||||
{
|
||||
m_warnings.push_back(QString("RifReaderEclipseSummary: Formatted summary header file without an\n") +
|
||||
QString("associated data file detected.\n") +
|
||||
QString("This may cause a failure reading summary origin data.\n") +
|
||||
QString("To avoid this problem, please delete or rename the.FSMSPEC file."));
|
||||
*hasWarnings = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!currFile.fileName.isEmpty())
|
||||
restartFiles.push_back(currFile);
|
||||
}
|
||||
|
@ -22,13 +22,12 @@
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
class QStringList;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@ -59,7 +58,7 @@ public:
|
||||
|
||||
bool open(const QString& headerFileName, bool includeRestartFiles);
|
||||
|
||||
std::vector<RifRestartFileInfo> getRestartFiles(const QString& headerFileName);
|
||||
std::vector<RifRestartFileInfo> getRestartFiles(const QString& headerFileName, bool* hasWarnings);
|
||||
RifRestartFileInfo getFileInfo(const QString& headerFileName);
|
||||
|
||||
virtual const std::vector<time_t>& timeSteps(const RifEclipseSummaryAddress& resultAddress) const override;
|
||||
@ -67,6 +66,8 @@ public:
|
||||
virtual bool values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values) const override;
|
||||
virtual std::string unitName(const RifEclipseSummaryAddress& resultAddress) const override;
|
||||
|
||||
QStringList warnings() const { return m_warnings; }
|
||||
|
||||
private:
|
||||
int timeStepCount() const;
|
||||
int indexFromAddress(const RifEclipseSummaryAddress& resultAddress) const;
|
||||
@ -83,5 +84,7 @@ private:
|
||||
std::vector<time_t> m_timeSteps;
|
||||
|
||||
std::map<RifEclipseSummaryAddress, int> m_resultAddressToErtNodeIdx;
|
||||
|
||||
QStringList m_warnings;
|
||||
};
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaFilePathTools.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RicSummaryCaseRestartDialog.h"
|
||||
|
||||
@ -187,7 +188,8 @@ std::vector<RifSummaryCaseFileInfo> RifSummaryCaseRestartSelector::getFilesToImp
|
||||
filesToImport.push_back(RifSummaryCaseFileInfo(file, false));
|
||||
|
||||
RifReaderEclipseSummary reader;
|
||||
std::vector<RifRestartFileInfo> restartFileInfos = reader.getRestartFiles(file);
|
||||
bool hasWarnings = false;
|
||||
std::vector<RifRestartFileInfo> restartFileInfos = reader.getRestartFiles(file, &hasWarnings);
|
||||
for (const auto& rfi : restartFileInfos)
|
||||
{
|
||||
RifSummaryCaseFileInfo fi(rfi.fileName, false);
|
||||
@ -205,7 +207,8 @@ std::vector<RifSummaryCaseFileInfo> RifSummaryCaseRestartSelector::getFilesToImp
|
||||
if (m_defaultGridImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES)
|
||||
{
|
||||
RifReaderEclipseSummary reader;
|
||||
std::vector<RifRestartFileInfo> restartFileInfos = reader.getRestartFiles(file);
|
||||
bool hasWarnings = false;
|
||||
std::vector<RifRestartFileInfo> restartFileInfos = reader.getRestartFiles(file, &hasWarnings);
|
||||
for (const auto& rfi : restartFileInfos)
|
||||
{
|
||||
RifSummaryCaseFileInfo fi(RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(rfi.fileName), false);
|
||||
@ -214,6 +217,11 @@ std::vector<RifSummaryCaseFileInfo> RifSummaryCaseRestartSelector::getFilesToImp
|
||||
m_gridFiles.push_back(fi.fileName);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasWarnings)
|
||||
{
|
||||
for (const QString& warning : reader.warnings()) RiaLogging::error(warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user