mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
(#383) Added RicAddEclipseInputPropertyFeature
This commit is contained in:
parent
28547513c6
commit
7044f3c627
@ -41,6 +41,7 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewExec.h
|
||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceIFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicAddEclipseInputPropertyFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
|
||||
@ -96,6 +97,7 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewExec.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceIFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicAddEclipseInputPropertyFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
|
||||
|
103
ApplicationCode/Commands/RicAddEclipseInputPropertyFeature.cpp
Normal file
103
ApplicationCode/Commands/RicAddEclipseInputPropertyFeature.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicAddEclipseInputPropertyFeature.h"
|
||||
|
||||
#include "RimEclipseInputPropertyCollection.h"
|
||||
#include "RimEclipseInputCase.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
#include <QStringList>
|
||||
#include <QFileInfo>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicAddEclipseInputPropertyFeature, "RicAddEclipseInputPropertyFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicAddEclipseInputPropertyFeature::isCommandEnabled()
|
||||
{
|
||||
return selectedInputPropertyCollection() != NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAddEclipseInputPropertyFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString defaultDir = app->defaultFileDialogDirectory("INPUT_FILES");
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Select Eclipse Input Property Files", defaultDir, "All Files (*.* *)");
|
||||
|
||||
if (fileNames.isEmpty()) return;
|
||||
|
||||
// Remember the directory to next time
|
||||
defaultDir = QFileInfo(fileNames.last()).absolutePath();
|
||||
app->setDefaultFileDialogDirectory("INPUT_FILES", defaultDir);
|
||||
|
||||
RimEclipseInputPropertyCollection* inputPropertyCollection = selectedInputPropertyCollection();
|
||||
if (inputPropertyCollection)
|
||||
{
|
||||
addEclipseInputProperty(fileNames, inputPropertyCollection);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAddEclipseInputPropertyFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Add Input Property");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseInputPropertyCollection* RicAddEclipseInputPropertyFeature::selectedInputPropertyCollection() const
|
||||
{
|
||||
std::vector<RimEclipseInputPropertyCollection*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
return selection.size() > 0 ? selection[0] : NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAddEclipseInputPropertyFeature::addEclipseInputProperty(const QStringList& fileNames, RimEclipseInputPropertyCollection* inputPropertyCollection)
|
||||
{
|
||||
CVF_ASSERT(inputPropertyCollection);
|
||||
|
||||
RimEclipseInputCase* inputReservoir = dynamic_cast<RimEclipseInputCase*>(inputPropertyCollection->parentField()->ownerObject());
|
||||
CVF_ASSERT(inputReservoir);
|
||||
if (inputReservoir)
|
||||
{
|
||||
inputReservoir->openDataFileSet(fileNames);
|
||||
}
|
||||
|
||||
inputPropertyCollection->updateConnectedEditors();
|
||||
}
|
||||
|
||||
|
45
ApplicationCode/Commands/RicAddEclipseInputPropertyFeature.h
Normal file
45
ApplicationCode/Commands/RicAddEclipseInputPropertyFeature.h
Normal file
@ -0,0 +1,45 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimEclipseInputPropertyCollection;
|
||||
class QStringList;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicAddEclipseInputPropertyFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
private:
|
||||
RimEclipseInputPropertyCollection* selectedInputPropertyCollection() const;
|
||||
static void addEclipseInputProperty(const QStringList& fileNames, RimEclipseInputPropertyCollection* inputPropertyCollection);
|
||||
};
|
||||
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "RimEclipseStatisticsCaseCollection.h"
|
||||
#include "RimEclipseStatisticsCase.h"
|
||||
#include "RimEclipseInputProperty.h"
|
||||
#include "RimEclipseInputPropertyCollection.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -636,6 +637,10 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
||||
{
|
||||
commandIds << "RicSaveEclipseResultAsInputPropertyFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimEclipseInputPropertyCollection*>(uiItem))
|
||||
{
|
||||
commandIds << "RicAddEclipseInputPropertyFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimEclipseInputProperty*>(uiItem))
|
||||
{
|
||||
commandIds << "RicSaveEclipseInputPropertyFeature";
|
||||
|
Loading…
Reference in New Issue
Block a user