2016-08-24 08:30:12 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2016- 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 "RicImportFormationNamesFeature.h"
|
|
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2017-10-20 14:34:56 +02:00
|
|
|
|
2017-10-20 16:10:45 +02:00
|
|
|
#include "RimCase.h"
|
|
|
|
|
#include "RimEclipseCase.h"
|
2017-10-20 14:34:56 +02:00
|
|
|
#include "RimFormationNames.h"
|
|
|
|
|
#include "RimFormationNamesCollection.h"
|
2017-10-20 16:10:45 +02:00
|
|
|
#include "RimGeoMechCase.h"
|
2016-08-24 08:30:12 +02:00
|
|
|
#include "RimOilField.h"
|
2017-10-20 14:34:56 +02:00
|
|
|
#include "RimProject.h"
|
2018-01-09 10:11:28 +01:00
|
|
|
#include "Rim3dView.h"
|
2017-10-20 16:10:45 +02:00
|
|
|
|
|
|
|
|
#include "RigEclipseCaseData.h"
|
|
|
|
|
#include "RigFemPartResultsCollection.h"
|
|
|
|
|
#include "RigGeoMechCaseData.h"
|
|
|
|
|
|
2018-02-27 16:37:06 +01:00
|
|
|
#include "Riu3DMainWindowTools.h"
|
2016-08-24 08:30:12 +02:00
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
|
2017-12-01 13:24:43 +01:00
|
|
|
|
2016-08-24 08:30:12 +02:00
|
|
|
CAF_CMD_SOURCE_INIT(RicImportFormationNamesFeature, "RicImportFormationNamesFeature");
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RicImportFormationNamesFeature::isCommandEnabled()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RicImportFormationNamesFeature::onActionTriggered(bool isChecked)
|
|
|
|
|
{
|
|
|
|
|
RiaApplication* app = RiaApplication::instance();
|
2016-09-21 09:46:17 +02:00
|
|
|
QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID");
|
2019-07-26 10:12:08 +02:00
|
|
|
QStringList fileNames = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Formation Names", defaultDir, "Formation Names description File (*.lyr);;FMU Layer Zone Table(layer_zone_table.txt);;All Files (*.*)");
|
2016-08-24 08:30:12 +02:00
|
|
|
|
|
|
|
|
if (fileNames.isEmpty()) return;
|
|
|
|
|
|
|
|
|
|
// Remember the path to next time
|
2016-09-21 09:46:17 +02:00
|
|
|
app->setLastUsedDialogDirectory("BINARY_GRID", QFileInfo(fileNames.last()).absolutePath());
|
2016-08-24 08:30:12 +02:00
|
|
|
|
|
|
|
|
// Find or create the FomationNamesCollection
|
|
|
|
|
|
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
|
RimFormationNamesCollection* fomNameColl = proj->activeOilField()->formationNamesCollection();
|
|
|
|
|
if (!fomNameColl)
|
|
|
|
|
{
|
|
|
|
|
fomNameColl = new RimFormationNamesCollection;
|
|
|
|
|
proj->activeOilField()->formationNamesCollection = fomNameColl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// For each file, find existing Formation names item, or create new
|
2017-10-20 14:34:56 +02:00
|
|
|
RimFormationNames* formationName = fomNameColl->importFiles(fileNames);
|
2017-10-20 16:10:45 +02:00
|
|
|
|
2017-12-01 15:38:29 +01:00
|
|
|
if (fileNames.size() > 1) return;
|
|
|
|
|
|
2017-10-20 16:10:45 +02:00
|
|
|
std::vector<RimCase*> cases;
|
|
|
|
|
proj->allCases(cases);
|
|
|
|
|
|
2017-12-01 13:24:43 +01:00
|
|
|
if (!cases.empty())
|
2017-10-20 16:10:45 +02:00
|
|
|
{
|
2018-01-09 10:11:28 +01:00
|
|
|
Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
|
2018-05-15 11:31:06 +02:00
|
|
|
if (activeView)
|
2017-10-20 16:10:45 +02:00
|
|
|
{
|
2018-05-15 11:31:06 +02:00
|
|
|
RimCase* ownerCase = activeView->ownerCase();
|
|
|
|
|
if (ownerCase)
|
|
|
|
|
{
|
|
|
|
|
ownerCase->setFormationNames(formationName);
|
2019-04-03 08:37:42 +02:00
|
|
|
ownerCase->updateConnectedEditors();
|
2018-05-15 11:31:06 +02:00
|
|
|
}
|
2017-10-20 16:10:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-03 08:37:42 +02:00
|
|
|
fomNameColl->updateConnectedEditors();
|
2017-10-20 14:34:56 +02:00
|
|
|
|
|
|
|
|
if (formationName)
|
|
|
|
|
{
|
2018-02-27 16:37:06 +01:00
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem(formationName);
|
2017-10-20 14:34:56 +02:00
|
|
|
}
|
2016-08-24 08:30:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RicImportFormationNamesFeature::setupActionLook(QAction* actionToSetup)
|
|
|
|
|
{
|
|
|
|
|
actionToSetup->setIcon(QIcon(":/FormationCollection16x16.png"));
|
|
|
|
|
actionToSetup->setText("Import Formation Names");
|
|
|
|
|
}
|