2018-03-15 08:23:48 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017- Statoil ASA
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicSummaryCaseRestartDialog.h"
|
|
|
|
#include "ExportCommands/RicSnapshotViewToClipboardFeature.h"
|
|
|
|
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
|
|
|
|
#include "ExportCommands/RicSnapshotFilenameGenerator.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2018-03-19 07:35:56 -05:00
|
|
|
#include "RiaFilePathTools.h"
|
2018-04-17 04:01:24 -05:00
|
|
|
#include "RiaLogging.h"
|
2018-03-15 08:23:48 -05:00
|
|
|
|
|
|
|
#include "RifReaderEclipseSummary.h"
|
2018-04-13 04:11:05 -05:00
|
|
|
#include "RifEclipseSummaryTools.h"
|
2018-03-15 08:23:48 -05:00
|
|
|
|
|
|
|
#include "RimEclipseView.h"
|
|
|
|
#include "Rim3dOverlayInfoConfig.h"
|
|
|
|
#include "RimTools.h"
|
|
|
|
|
|
|
|
#include "RiuMainPlotWindow.h"
|
|
|
|
#include "RiuSummaryQwtPlot.h"
|
|
|
|
#include "RiuTools.h"
|
|
|
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QTextEdit>
|
2018-03-16 03:02:28 -05:00
|
|
|
#include <QCheckBox>
|
2018-03-15 08:23:48 -05:00
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QToolBar>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QAbstractItemView>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QDateTime>
|
|
|
|
|
2018-04-16 07:11:31 -05:00
|
|
|
#include <cvfAssert.h>
|
|
|
|
|
2018-03-15 08:23:48 -05:00
|
|
|
#include <vector>
|
|
|
|
#include <time.h>
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
#define DEFAULT_DIALOG_WIDTH 550
|
|
|
|
#define DEFAULT_DIALOG_INIT_HEIGHT 150
|
|
|
|
|
|
|
|
|
2018-04-16 07:11:31 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Internal functions
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<std::vector<RifRestartFileInfo>> removeRootPath(const std::vector<std::vector<RifRestartFileInfo>>& fileInfoLists)
|
|
|
|
{
|
|
|
|
// Find common root path among all paths
|
|
|
|
QStringList allPaths;
|
|
|
|
for (const auto& fileInfoList : fileInfoLists)
|
|
|
|
{
|
|
|
|
for (const auto fi : fileInfoList) allPaths.push_back(fi.fileName);
|
|
|
|
}
|
|
|
|
QString commonRoot = RiaFilePathTools::commonRootPath(allPaths);
|
|
|
|
int commonRootSize = commonRoot.size();
|
|
|
|
|
|
|
|
// Build output lists
|
|
|
|
std::vector<std::vector<RifRestartFileInfo>> output;
|
|
|
|
for (const auto& fileInfoList : fileInfoLists)
|
|
|
|
{
|
|
|
|
std::vector<RifRestartFileInfo> currList;
|
|
|
|
|
|
|
|
for (auto& fi : fileInfoList)
|
|
|
|
{
|
|
|
|
RifRestartFileInfo newFi = fi;
|
|
|
|
newFi.fileName.remove(0, commonRootSize);
|
|
|
|
currList.push_back(newFi);
|
|
|
|
}
|
|
|
|
output.push_back(currList);
|
|
|
|
}
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2018-03-15 08:23:48 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent)
|
|
|
|
: QDialog(parent, RiuTools::defaultDialogFlags())
|
|
|
|
{
|
|
|
|
// Create widgets
|
2018-04-16 07:11:31 -05:00
|
|
|
m_currentFilesLayout = new QGridLayout();
|
2018-04-13 08:44:28 -05:00
|
|
|
m_summaryReadAllBtn = new QRadioButton(this);
|
|
|
|
m_summarySeparateCasesBtn = new QRadioButton(this);
|
|
|
|
m_summaryNotReadBtn = new QRadioButton(this);
|
|
|
|
m_gridSeparateCasesBtn = new QRadioButton(this);
|
|
|
|
m_gridNotReadBtn = new QRadioButton(this);
|
2018-03-16 03:02:28 -05:00
|
|
|
m_applyToAllCheckBox = new QCheckBox(this);
|
2018-04-17 04:01:24 -05:00
|
|
|
m_warnings = new QListWidget(this);
|
2018-03-15 08:23:48 -05:00
|
|
|
m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
|
|
|
|
|
|
|
// Connect to signals
|
|
|
|
connect(m_buttons, SIGNAL(accepted()), this, SLOT(slotDialogOkClicked()));
|
|
|
|
connect(m_buttons, SIGNAL(rejected()), this, SLOT(slotDialogCancelClicked()));
|
|
|
|
|
|
|
|
// Set widget properties
|
2018-04-13 08:44:28 -05:00
|
|
|
m_summaryReadAllBtn->setText("Unified");
|
|
|
|
m_summarySeparateCasesBtn->setText("Separate Cases");
|
|
|
|
m_summaryNotReadBtn->setText("Skip");
|
|
|
|
m_gridSeparateCasesBtn->setText("Separate Cases");
|
|
|
|
m_gridNotReadBtn->setText("Skip");
|
2018-04-26 02:51:35 -05:00
|
|
|
m_applyToAllCheckBox->setText("OK to All");
|
2018-04-16 07:11:31 -05:00
|
|
|
m_applyToAllCheckBox->setLayoutDirection(Qt::RightToLeft);
|
2018-03-16 03:02:28 -05:00
|
|
|
|
2018-03-15 08:23:48 -05:00
|
|
|
// Define layout
|
|
|
|
QVBoxLayout* dialogLayout = new QVBoxLayout();
|
|
|
|
|
2018-04-16 07:11:31 -05:00
|
|
|
m_currentFilesGroup = new QGroupBox("Current Summary File");
|
|
|
|
m_currentFilesLayout = new QGridLayout();
|
|
|
|
m_currentFilesGroup->setLayout(m_currentFilesLayout);
|
2018-03-15 09:10:02 -05:00
|
|
|
|
2018-04-13 08:44:28 -05:00
|
|
|
// Summary files
|
|
|
|
QGroupBox* summaryFilesGroup = new QGroupBox("Found Origin Summary Files");
|
|
|
|
{
|
|
|
|
QVBoxLayout* filesGroupLayout = new QVBoxLayout();
|
|
|
|
summaryFilesGroup->setLayout(filesGroupLayout);
|
|
|
|
|
|
|
|
m_summaryFilesLayout = new QGridLayout();
|
|
|
|
filesGroupLayout->addLayout(m_summaryFilesLayout);
|
|
|
|
m_summaryFilesLayout->setContentsMargins(0, 0, 0, 20);
|
|
|
|
|
|
|
|
QGroupBox* optionsGroup = new QGroupBox("Import Options");
|
|
|
|
QVBoxLayout* optionsLayout = new QVBoxLayout();
|
|
|
|
optionsGroup->setLayout(optionsLayout);
|
|
|
|
optionsLayout->addWidget(m_summaryReadAllBtn);
|
|
|
|
optionsLayout->addWidget(m_summarySeparateCasesBtn);
|
|
|
|
optionsLayout->addWidget(m_summaryNotReadBtn);
|
|
|
|
filesGroupLayout->addWidget(optionsGroup);
|
|
|
|
}
|
2018-03-15 08:23:48 -05:00
|
|
|
|
2018-04-13 08:44:28 -05:00
|
|
|
// Grid files
|
|
|
|
m_gridFilesGroup = new QGroupBox("Found Origin Grid Files");
|
|
|
|
{
|
|
|
|
QVBoxLayout* filesGroupLayout = new QVBoxLayout();
|
|
|
|
m_gridFilesGroup->setLayout(filesGroupLayout);
|
|
|
|
|
|
|
|
m_gridFilesLayout = new QGridLayout();
|
|
|
|
filesGroupLayout->addLayout(m_gridFilesLayout);
|
|
|
|
m_gridFilesLayout->setContentsMargins(0, 0, 0, 20);
|
|
|
|
|
|
|
|
QGroupBox* optionsGroup = new QGroupBox("Import Options");
|
|
|
|
QVBoxLayout* optionsLayout = new QVBoxLayout();
|
|
|
|
optionsGroup->setLayout(optionsLayout);
|
|
|
|
optionsLayout->addWidget(m_gridSeparateCasesBtn);
|
|
|
|
optionsLayout->addWidget(m_gridNotReadBtn);
|
|
|
|
filesGroupLayout->addWidget(optionsGroup);
|
|
|
|
}
|
2018-03-15 08:23:48 -05:00
|
|
|
|
2018-04-13 08:44:28 -05:00
|
|
|
// Apply to all checkbox and buttons
|
2018-03-16 03:02:28 -05:00
|
|
|
QHBoxLayout* buttonsLayout = new QHBoxLayout();
|
2018-04-16 07:11:31 -05:00
|
|
|
buttonsLayout->addStretch(1);
|
2018-03-16 03:02:28 -05:00
|
|
|
buttonsLayout->addWidget(m_applyToAllCheckBox);
|
|
|
|
buttonsLayout->addWidget(m_buttons);
|
|
|
|
|
2018-04-16 07:11:31 -05:00
|
|
|
dialogLayout->addWidget(m_currentFilesGroup);
|
2018-04-13 08:44:28 -05:00
|
|
|
dialogLayout->addWidget(summaryFilesGroup);
|
|
|
|
dialogLayout->addWidget(m_gridFilesGroup);
|
2018-04-17 04:01:24 -05:00
|
|
|
dialogLayout->addWidget(m_warnings);
|
2018-03-16 03:02:28 -05:00
|
|
|
dialogLayout->addLayout(buttonsLayout);
|
2018-03-15 08:23:48 -05:00
|
|
|
|
|
|
|
setLayout(dialogLayout);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RicSummaryCaseRestartDialog::~RicSummaryCaseRestartDialog()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-04-24 08:55:51 -05:00
|
|
|
RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const QString& initialSummaryFile,
|
|
|
|
const QString& initialGridFile,
|
|
|
|
bool failOnSummaryImportError,
|
|
|
|
bool showApplyToAllWidget,
|
|
|
|
ImportOptions defaultSummaryImportOption,
|
|
|
|
ImportOptions defaultGridImportOption,
|
|
|
|
RicSummaryCaseRestartDialogResult* lastResult,
|
|
|
|
QWidget* parent)
|
2018-03-15 08:23:48 -05:00
|
|
|
{
|
|
|
|
RicSummaryCaseRestartDialog dialog(parent);
|
2018-04-24 08:55:51 -05:00
|
|
|
bool handleSummaryFile = false;
|
|
|
|
|
|
|
|
RifRestartFileInfo currentFileInfo;
|
|
|
|
if (!initialSummaryFile.isEmpty())
|
|
|
|
{
|
|
|
|
currentFileInfo = dialog.getFileInfo(initialSummaryFile);
|
|
|
|
|
|
|
|
if (!currentFileInfo.valid())
|
|
|
|
{
|
|
|
|
if (failOnSummaryImportError)
|
|
|
|
{
|
2018-04-25 07:07:24 -05:00
|
|
|
return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::SUMMARY_ERROR);
|
2018-04-24 08:55:51 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
handleSummaryFile = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-20 01:27:42 -05:00
|
|
|
bool handleGridFile = !initialGridFile.isEmpty();
|
2018-03-15 08:23:48 -05:00
|
|
|
|
2018-04-20 01:27:42 -05:00
|
|
|
// If only grid file is present, return
|
2018-04-24 08:55:51 -05:00
|
|
|
if (!handleSummaryFile && !initialGridFile.isEmpty())
|
2018-04-20 01:27:42 -05:00
|
|
|
{
|
2018-04-25 07:07:24 -05:00
|
|
|
RicSummaryCaseRestartDialogResult::Status status = RicSummaryCaseRestartDialogResult::SUMMARY_OK;
|
2018-04-24 08:55:51 -05:00
|
|
|
if (!initialSummaryFile.isEmpty())
|
|
|
|
{
|
|
|
|
// We were meant to have a summary file but due to an error we don't.
|
2018-04-25 07:07:24 -05:00
|
|
|
status = RicSummaryCaseRestartDialogResult::SUMMARY_WARNING;
|
2018-04-24 08:55:51 -05:00
|
|
|
}
|
|
|
|
return RicSummaryCaseRestartDialogResult(status,
|
2018-04-20 01:27:42 -05:00
|
|
|
defaultSummaryImportOption,
|
|
|
|
defaultGridImportOption,
|
|
|
|
{},
|
|
|
|
QStringList({ initialGridFile }),
|
|
|
|
lastResult && lastResult->applyToAll);
|
|
|
|
}
|
|
|
|
|
2018-04-24 08:55:51 -05:00
|
|
|
|
2018-03-21 08:47:07 -05:00
|
|
|
|
2018-04-13 04:11:05 -05:00
|
|
|
RifReaderEclipseSummary reader;
|
2018-04-17 04:01:24 -05:00
|
|
|
bool hasWarnings = false;
|
2018-04-20 01:27:42 -05:00
|
|
|
std::vector<RifRestartFileInfo> originFileInfos = reader.getRestartFiles(initialSummaryFile, &hasWarnings);
|
2018-03-15 08:23:48 -05:00
|
|
|
|
2018-04-17 04:01:24 -05:00
|
|
|
// If no restart files are found and no warnings, do not show dialog
|
|
|
|
if (originFileInfos.empty() &&!hasWarnings)
|
2018-03-15 08:23:48 -05:00
|
|
|
{
|
2018-04-25 07:07:24 -05:00
|
|
|
return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::SUMMARY_OK, NOT_IMPORT, NOT_IMPORT, QStringList({ initialSummaryFile }), QStringList({ initialGridFile }), false);
|
2018-03-15 08:23:48 -05:00
|
|
|
}
|
|
|
|
|
2018-03-20 05:25:54 -05:00
|
|
|
RicSummaryCaseRestartDialogResult dialogResult;
|
|
|
|
if (lastResult && lastResult->applyToAll)
|
|
|
|
{
|
|
|
|
dialogResult = *lastResult;
|
2018-04-13 04:11:05 -05:00
|
|
|
dialogResult.summaryFiles.clear();
|
2018-04-13 08:44:28 -05:00
|
|
|
dialogResult.gridFiles.clear();
|
2018-04-17 04:01:24 -05:00
|
|
|
|
|
|
|
if (hasWarnings)
|
|
|
|
{
|
|
|
|
for (const QString& warning : reader.warnings()) RiaLogging::error(warning);
|
|
|
|
}
|
2018-03-20 05:25:54 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-16 07:11:31 -05:00
|
|
|
std::vector<RifRestartFileInfo> currentFileInfos;
|
|
|
|
std::vector<RifRestartFileInfo> originSummaryFileInfos;
|
|
|
|
std::vector<RifRestartFileInfo> originGridFileInfos;
|
|
|
|
|
2018-04-20 01:27:42 -05:00
|
|
|
// Grid file
|
|
|
|
if (handleGridFile)
|
2018-04-16 07:11:31 -05:00
|
|
|
{
|
|
|
|
dialog.m_currentFilesGroup->setTitle("Current Grid and Summary Files");
|
2018-04-20 01:27:42 -05:00
|
|
|
currentFileInfos.push_back(RifRestartFileInfo(initialGridFile, currentFileInfo.startDate, currentFileInfo.endDate));
|
2018-04-16 07:11:31 -05:00
|
|
|
|
|
|
|
for (const auto& ofi : originFileInfos)
|
|
|
|
{
|
|
|
|
QString gridFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(ofi.fileName);
|
|
|
|
if (QFileInfo(gridFile).exists())
|
|
|
|
{
|
|
|
|
originGridFileInfos.push_back(RifRestartFileInfo(gridFile, ofi.startDate, ofi.endDate));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-04-13 08:44:28 -05:00
|
|
|
|
2018-04-16 07:11:31 -05:00
|
|
|
currentFileInfos.push_back(currentFileInfo);
|
2018-04-13 08:44:28 -05:00
|
|
|
for (const auto& ofi : originFileInfos)
|
|
|
|
{
|
2018-04-16 07:11:31 -05:00
|
|
|
originSummaryFileInfos.push_back(ofi);
|
2018-04-13 08:44:28 -05:00
|
|
|
}
|
2018-04-13 04:11:05 -05:00
|
|
|
|
2018-04-16 07:11:31 -05:00
|
|
|
// Set default import options
|
2018-04-13 08:44:28 -05:00
|
|
|
switch (defaultSummaryImportOption)
|
2018-04-13 04:11:05 -05:00
|
|
|
{
|
2018-04-13 08:44:28 -05:00
|
|
|
case ImportOptions::IMPORT_ALL: dialog.m_summaryReadAllBtn->setChecked(true); break;
|
|
|
|
case ImportOptions::SEPARATE_CASES: dialog.m_summarySeparateCasesBtn->setChecked(true); break;
|
|
|
|
case ImportOptions::NOT_IMPORT: dialog.m_summaryNotReadBtn->setChecked(true); break;
|
2018-04-13 04:11:05 -05:00
|
|
|
}
|
|
|
|
|
2018-04-20 01:27:42 -05:00
|
|
|
if (handleGridFile)
|
2018-04-09 06:21:48 -05:00
|
|
|
{
|
2018-04-13 08:44:28 -05:00
|
|
|
switch (defaultGridImportOption)
|
|
|
|
{
|
|
|
|
case ImportOptions::SEPARATE_CASES: dialog.m_gridSeparateCasesBtn->setChecked(true); break;
|
|
|
|
case ImportOptions::NOT_IMPORT: dialog.m_gridNotReadBtn->setChecked(true); break;
|
|
|
|
}
|
2018-04-09 06:21:48 -05:00
|
|
|
}
|
2018-04-16 07:11:31 -05:00
|
|
|
|
|
|
|
// Remove common root path
|
|
|
|
std::vector<std::vector<RifRestartFileInfo>> fileInfosNoRoot = removeRootPath(
|
|
|
|
{
|
|
|
|
currentFileInfos, originSummaryFileInfos, originGridFileInfos
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// Populate file list widgets
|
|
|
|
dialog.populateFileList(dialog.m_currentFilesLayout, fileInfosNoRoot[0]);
|
|
|
|
dialog.populateFileList(dialog.m_summaryFilesLayout, fileInfosNoRoot[1]);
|
|
|
|
dialog.populateFileList(dialog.m_gridFilesLayout, fileInfosNoRoot[2]);
|
|
|
|
|
2018-04-17 04:01:24 -05:00
|
|
|
// Display warnings if any
|
|
|
|
dialog.displayWarningsIfAny(reader.warnings());
|
|
|
|
|
2018-04-16 07:11:31 -05:00
|
|
|
// Set properties and show dialog
|
|
|
|
dialog.setWindowTitle("Restart Files");
|
2018-03-20 05:25:54 -05:00
|
|
|
dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget);
|
|
|
|
dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT);
|
|
|
|
dialog.exec();
|
|
|
|
|
2018-04-25 07:07:24 -05:00
|
|
|
RicSummaryCaseRestartDialogResult::Status status = RicSummaryCaseRestartDialogResult::SUMMARY_OK;
|
2018-04-24 08:55:51 -05:00
|
|
|
|
2018-04-24 07:12:02 -05:00
|
|
|
if (dialog.result() == QDialog::Rejected)
|
|
|
|
{
|
2018-04-25 07:07:24 -05:00
|
|
|
status = RicSummaryCaseRestartDialogResult::SUMMARY_CANCELLED;
|
2018-04-24 07:12:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
dialogResult = RicSummaryCaseRestartDialogResult(status,
|
2018-04-13 08:44:28 -05:00
|
|
|
dialog.selectedSummaryImportOption(),
|
|
|
|
dialog.selectedGridImportOption(),
|
2018-03-20 05:25:54 -05:00
|
|
|
{},
|
2018-04-13 08:44:28 -05:00
|
|
|
{},
|
|
|
|
dialog.applyToAllSelected());
|
2018-03-20 05:25:54 -05:00
|
|
|
}
|
2018-03-19 05:02:22 -05:00
|
|
|
|
2018-04-25 07:07:24 -05:00
|
|
|
if (dialogResult.status != RicSummaryCaseRestartDialogResult::SUMMARY_OK)
|
2018-03-19 05:02:22 -05:00
|
|
|
{
|
2018-04-24 07:12:02 -05:00
|
|
|
return RicSummaryCaseRestartDialogResult(dialogResult.status, NOT_IMPORT, NOT_IMPORT, QStringList(), QStringList(), false);
|
2018-03-19 05:02:22 -05:00
|
|
|
}
|
|
|
|
|
2018-04-20 01:27:42 -05:00
|
|
|
dialogResult.summaryFiles.push_back(RiaFilePathTools::toInternalSeparator(initialSummaryFile));
|
2018-04-13 08:44:28 -05:00
|
|
|
if (dialogResult.summaryImportOption == SEPARATE_CASES)
|
2018-03-19 05:02:22 -05:00
|
|
|
{
|
2018-04-13 08:44:28 -05:00
|
|
|
for (const auto& ofi : originFileInfos)
|
2018-03-19 05:02:22 -05:00
|
|
|
{
|
2018-04-13 08:44:28 -05:00
|
|
|
dialogResult.summaryFiles.push_back(RiaFilePathTools::toInternalSeparator(ofi.fileName));
|
2018-04-13 04:11:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-20 01:27:42 -05:00
|
|
|
if (handleGridFile)
|
2018-04-13 04:11:05 -05:00
|
|
|
{
|
2018-04-20 01:27:42 -05:00
|
|
|
dialogResult.gridFiles.push_back(initialGridFile);
|
2018-04-13 04:11:05 -05:00
|
|
|
|
2018-04-13 08:44:28 -05:00
|
|
|
if (dialogResult.gridImportOption == SEPARATE_CASES)
|
2018-04-13 04:11:05 -05:00
|
|
|
{
|
2018-04-13 08:44:28 -05:00
|
|
|
for (const auto& ofi : originFileInfos)
|
|
|
|
{
|
|
|
|
QString gridFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(ofi.fileName);
|
2018-04-20 01:27:42 -05:00
|
|
|
if (handleGridFile) dialogResult.gridFiles.push_back(gridFile);
|
2018-04-13 08:44:28 -05:00
|
|
|
}
|
2018-03-19 05:02:22 -05:00
|
|
|
}
|
|
|
|
}
|
2018-03-20 05:25:54 -05:00
|
|
|
return dialogResult;
|
2018-03-15 08:23:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-04-13 08:44:28 -05:00
|
|
|
RicSummaryCaseRestartDialog::ImportOptions RicSummaryCaseRestartDialog::selectedSummaryImportOption() const
|
2018-03-15 08:23:48 -05:00
|
|
|
{
|
|
|
|
return
|
2018-04-13 08:44:28 -05:00
|
|
|
m_summaryReadAllBtn->isChecked() ? IMPORT_ALL :
|
|
|
|
m_summarySeparateCasesBtn->isChecked() ? SEPARATE_CASES :
|
2018-04-09 06:21:48 -05:00
|
|
|
NOT_IMPORT;
|
2018-03-15 08:23:48 -05:00
|
|
|
}
|
|
|
|
|
2018-03-16 03:02:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-04-13 08:44:28 -05:00
|
|
|
RicSummaryCaseRestartDialog::ImportOptions RicSummaryCaseRestartDialog::selectedGridImportOption() const
|
2018-03-16 03:02:28 -05:00
|
|
|
{
|
2018-04-13 08:44:28 -05:00
|
|
|
return
|
|
|
|
m_gridSeparateCasesBtn->isChecked() ? SEPARATE_CASES : NOT_IMPORT;
|
2018-03-16 03:02:28 -05:00
|
|
|
}
|
|
|
|
|
2018-04-13 04:11:05 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-04-13 08:44:28 -05:00
|
|
|
bool RicSummaryCaseRestartDialog::applyToAllSelected() const
|
2018-04-13 04:11:05 -05:00
|
|
|
{
|
2018-04-13 08:44:28 -05:00
|
|
|
return m_applyToAllCheckBox->isChecked();
|
2018-04-13 04:11:05 -05:00
|
|
|
}
|
|
|
|
|
2018-03-15 08:23:48 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-04-16 07:11:31 -05:00
|
|
|
void RicSummaryCaseRestartDialog::populateFileList(QGridLayout* gridLayout, const std::vector<RifRestartFileInfo>& fileInfos)
|
2018-03-15 08:23:48 -05:00
|
|
|
{
|
2018-04-16 07:11:31 -05:00
|
|
|
if (fileInfos.empty())
|
|
|
|
{
|
|
|
|
QWidget* parent = gridLayout->parentWidget();
|
|
|
|
if (parent) parent->setVisible(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto& fileInfo : fileInfos)
|
|
|
|
{
|
|
|
|
appendFileInfoToGridLayout(gridLayout, fileInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo)
|
|
|
|
{
|
|
|
|
CVF_ASSERT(gridLayout);
|
|
|
|
|
2018-03-15 08:23:48 -05:00
|
|
|
QDateTime startDate = QDateTime::fromTime_t(fileInfo.startDate);
|
|
|
|
QString startDateString = startDate.toString(RimTools::dateFormatString());
|
|
|
|
QDateTime endDate = QDateTime::fromTime_t(fileInfo.endDate);
|
|
|
|
QString endDateString = endDate.toString(RimTools::dateFormatString());
|
2018-04-16 07:11:31 -05:00
|
|
|
int rowCount = gridLayout->rowCount();
|
2018-03-15 08:23:48 -05:00
|
|
|
|
|
|
|
QLabel* fileNameLabel = new QLabel();
|
|
|
|
QLabel* dateLabel = new QLabel();
|
2018-04-16 07:11:31 -05:00
|
|
|
fileNameLabel->setText(fileInfo.fileName);
|
2018-03-15 08:23:48 -05:00
|
|
|
dateLabel->setText(startDateString + " - " + endDateString);
|
|
|
|
|
|
|
|
fileNameLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
2018-04-16 07:11:31 -05:00
|
|
|
gridLayout->addWidget(fileNameLabel, rowCount, 0);
|
|
|
|
gridLayout->addWidget(dateLabel, rowCount, 1);
|
2018-03-20 07:28:06 -05:00
|
|
|
|
|
|
|
// Full path in tooltip
|
|
|
|
fileNameLabel->setToolTip(fileInfo.fileName);
|
2018-03-15 08:23:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-04-17 04:01:24 -05:00
|
|
|
RifRestartFileInfo RicSummaryCaseRestartDialog::getFileInfo(const QString& summaryHeaderFile)
|
2018-03-15 08:23:48 -05:00
|
|
|
{
|
|
|
|
RifReaderEclipseSummary reader;
|
2018-04-17 04:01:24 -05:00
|
|
|
return reader.getFileInfo(summaryHeaderFile);
|
2018-03-15 08:23:48 -05:00
|
|
|
}
|
|
|
|
|
2018-03-20 07:28:06 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-04-17 04:01:24 -05:00
|
|
|
void RicSummaryCaseRestartDialog::displayWarningsIfAny(const QStringList& warnings)
|
2018-03-20 07:28:06 -05:00
|
|
|
{
|
2018-04-17 04:01:24 -05:00
|
|
|
m_warnings->setVisible(!warnings.isEmpty());
|
|
|
|
for (const auto& warning : warnings)
|
|
|
|
{
|
|
|
|
QListWidgetItem* item = new QListWidgetItem(warning, m_warnings);
|
|
|
|
item->setForeground(Qt::red);
|
|
|
|
}
|
2018-03-20 07:28:06 -05:00
|
|
|
}
|
|
|
|
|
2018-03-15 08:23:48 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicSummaryCaseRestartDialog::slotDialogOkClicked()
|
|
|
|
{
|
|
|
|
accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicSummaryCaseRestartDialog::slotDialogCancelClicked()
|
|
|
|
{
|
|
|
|
reject();
|
|
|
|
}
|
2018-03-19 05:02:22 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Internal functions
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|