2015-08-14 02:45:57 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
2015-08-12 13:59:38 -05:00
|
|
|
|
2015-08-12 14:09:03 -05:00
|
|
|
#include "RicWellPathsImportFileFeature.h"
|
2015-08-12 13:59:38 -05:00
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2017-10-20 05:40:06 -05:00
|
|
|
|
|
|
|
#include "RimOilField.h"
|
2015-08-12 13:59:38 -05:00
|
|
|
#include "RimProject.h"
|
2017-10-20 05:40:06 -05:00
|
|
|
#include "RimWellPath.h"
|
|
|
|
#include "RimWellPathCollection.h"
|
|
|
|
|
2018-02-27 09:37:06 -06:00
|
|
|
#include "Riu3DMainWindowTools.h"
|
2015-08-12 13:59:38 -05:00
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
2017-05-19 06:40:38 -05:00
|
|
|
CAF_CMD_SOURCE_INIT(RicWellPathsImportFileFeature, "RicWellPathsImportFileFeature");
|
2015-08-12 13:59:38 -05:00
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-08-12 14:09:03 -05:00
|
|
|
bool RicWellPathsImportFileFeature::isCommandEnabled()
|
2015-08-12 13:59:38 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-08-12 14:09:03 -05:00
|
|
|
void RicWellPathsImportFileFeature::onActionTriggered(bool isChecked)
|
2015-08-12 13:59:38 -05:00
|
|
|
{
|
|
|
|
// Open dialog box to select well path files
|
|
|
|
RiaApplication* app = RiaApplication::instance();
|
2018-11-02 02:16:47 -05:00
|
|
|
QString lastUsedGridFolder = app->lastUsedDialogDirectory("BINARY_GRID");
|
|
|
|
QString defaultDir = app->lastUsedDialogDirectoryWithFallback("WELLPATH_DIR", lastUsedGridFolder);
|
2018-02-27 09:37:06 -06:00
|
|
|
QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Well Paths", defaultDir, "Well Paths (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)");
|
2015-08-12 13:59:38 -05:00
|
|
|
|
|
|
|
if (wellPathFilePaths.size() < 1) return;
|
|
|
|
|
|
|
|
// Remember the path to next time
|
2016-09-21 02:46:17 -05:00
|
|
|
app->setLastUsedDialogDirectory("WELLPATH_DIR", QFileInfo(wellPathFilePaths.last()).absolutePath());
|
2015-08-12 13:59:38 -05:00
|
|
|
|
|
|
|
app->addWellPathsToModel(wellPathFilePaths);
|
2017-10-20 05:40:06 -05:00
|
|
|
|
|
|
|
RimProject* project = app->project();
|
|
|
|
|
|
|
|
if (project)
|
2015-08-12 13:59:38 -05:00
|
|
|
{
|
2018-09-11 05:41:45 -05:00
|
|
|
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
2017-10-20 05:40:06 -05:00
|
|
|
RimOilField* oilField = project->activeOilField();
|
|
|
|
|
|
|
|
if (!oilField) return;
|
|
|
|
|
2017-10-23 01:48:44 -05:00
|
|
|
if (oilField->wellPathCollection->wellPaths().size() > 0)
|
2017-10-20 05:40:06 -05:00
|
|
|
{
|
2018-01-29 04:24:12 -06:00
|
|
|
RimWellPath* wellPath = oilField->wellPathCollection->mostRecentlyUpdatedWellPath();
|
2017-11-12 14:57:25 -06:00
|
|
|
if (wellPath)
|
|
|
|
{
|
2018-02-27 09:37:06 -06:00
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem(wellPath);
|
2017-11-12 14:57:25 -06:00
|
|
|
}
|
2017-10-20 05:40:06 -05:00
|
|
|
}
|
2015-08-12 13:59:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-08-12 14:09:03 -05:00
|
|
|
void RicWellPathsImportFileFeature::setupActionLook(QAction* actionToSetup)
|
2015-08-12 13:59:38 -05:00
|
|
|
{
|
|
|
|
actionToSetup->setText("Import &Well Paths from File");
|
|
|
|
actionToSetup->setIcon(QIcon(":/Well.png"));
|
|
|
|
}
|