ResInsight/ApplicationCode/Commands/RicWellPathsImportFileFeature.cpp

74 lines
2.7 KiB
C++
Raw Normal View History

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"
#include "RimProject.h"
#include "RiuMainWindow.h"
#include <QAction>
#include <QFileDialog>
namespace caf
{
2015-08-12 14:09:03 -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();
QString defaultDir = app->defaultFileDialogDirectory("WELLPATH_DIR");
QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Paths", defaultDir, "Well Paths (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)");
if (wellPathFilePaths.size() < 1) return;
// Remember the path to next time
app->setDefaultFileDialogDirectory("WELLPATH_DIR", QFileInfo(wellPathFilePaths.last()).absolutePath());
app->addWellPathsToModel(wellPathFilePaths);
if (app->project())
{
app->project()->createDisplayModelAndRedrawAllViews();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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"));
}
} // end namespace caf