mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#383) Added RicSaveEclipseInputPropertyFeature
This commit is contained in:
parent
d2e3b0599a
commit
28547513c6
@ -41,6 +41,7 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewExec.h
|
|||||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceIFeature.h
|
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceIFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.h
|
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.h
|
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.h
|
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.h
|
||||||
@ -95,6 +96,7 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewExec.cpp
|
|||||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceIFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceIFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.cpp
|
||||||
|
140
ApplicationCode/Commands/RicSaveEclipseInputPropertyFeature.cpp
Normal file
140
ApplicationCode/Commands/RicSaveEclipseInputPropertyFeature.cpp
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RicSaveEclipseInputPropertyFeature.h"
|
||||||
|
|
||||||
|
#include "RimEclipseInputProperty.h"
|
||||||
|
#include "RimEclipseInputPropertyCollection.h"
|
||||||
|
#include "RimExportInputPropertySettings.h"
|
||||||
|
#include "RimEclipseInputCase.h"
|
||||||
|
|
||||||
|
#include "RifEclipseInputFileTools.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
#include "RiuMainWindow.h"
|
||||||
|
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
#include "cafPdmUiPropertyViewDialog.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT(RicSaveEclipseInputPropertyFeature, "RicSaveEclipseInputPropertyFeature");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicSaveEclipseInputPropertyFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
return selectedInputProperty() != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicSaveEclipseInputPropertyFeature::onActionTriggered(bool isChecked)
|
||||||
|
{
|
||||||
|
RimEclipseInputProperty* inputProperty = selectedInputProperty();
|
||||||
|
if (!inputProperty) return;
|
||||||
|
|
||||||
|
{
|
||||||
|
bool isResolved = false;
|
||||||
|
if (inputProperty->resolvedState == RimEclipseInputProperty::RESOLVED || inputProperty->resolvedState == RimEclipseInputProperty::RESOLVED_NOT_SAVED)
|
||||||
|
{
|
||||||
|
isResolved = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isResolved)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(RiuMainWindow::instance(), "Export failure", "Property is not resolved, and then it is not possible to export the property.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RimExportInputSettings exportSettings;
|
||||||
|
exportSettings.eclipseKeyword = inputProperty->eclipseKeyword;
|
||||||
|
|
||||||
|
// Find input reservoir for this property
|
||||||
|
RimEclipseInputCase* inputReservoir = NULL;
|
||||||
|
{
|
||||||
|
RimEclipseInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimEclipseInputPropertyCollection*>(inputProperty->parentField()->ownerObject());
|
||||||
|
if (!inputPropertyCollection) return;
|
||||||
|
|
||||||
|
inputReservoir = dynamic_cast<RimEclipseInputCase*>(inputPropertyCollection->parentField()->ownerObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inputReservoir) return;
|
||||||
|
|
||||||
|
{
|
||||||
|
QString projectFolder;
|
||||||
|
|
||||||
|
RiaApplication* app = RiaApplication::instance();
|
||||||
|
QString projectFileName = app->currentProjectFileName();
|
||||||
|
if (!projectFileName.isEmpty())
|
||||||
|
{
|
||||||
|
QFileInfo fi(projectFileName);
|
||||||
|
projectFolder = fi.absolutePath();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
projectFolder = inputReservoir->locationOnDisc();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString outputFileName = projectFolder + "/" + inputProperty->eclipseKeyword;
|
||||||
|
|
||||||
|
exportSettings.fileName = outputFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Eclipse Property to Text File", "");
|
||||||
|
if (propertyDialog.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
bool isOk = RifEclipseInputFileTools::writePropertyToTextFile(exportSettings.fileName, inputReservoir->reservoirData(), 0, inputProperty->resultName, exportSettings.eclipseKeyword);
|
||||||
|
if (isOk)
|
||||||
|
{
|
||||||
|
inputProperty->fileName = exportSettings.fileName;
|
||||||
|
inputProperty->eclipseKeyword = exportSettings.eclipseKeyword;
|
||||||
|
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
|
||||||
|
|
||||||
|
inputProperty->updateConnectedEditors();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicSaveEclipseInputPropertyFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("Save Property To File");
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RimEclipseInputProperty* RicSaveEclipseInputPropertyFeature::selectedInputProperty() const
|
||||||
|
{
|
||||||
|
std::vector<RimEclipseInputProperty*> selection;
|
||||||
|
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||||
|
|
||||||
|
return selection.size() > 0 ? selection[0] : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 RimEclipseInputProperty;
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicSaveEclipseInputPropertyFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Overrides
|
||||||
|
virtual bool isCommandEnabled();
|
||||||
|
virtual void onActionTriggered( bool isChecked );
|
||||||
|
virtual void setupActionLook( QAction* actionToSetup );
|
||||||
|
|
||||||
|
private:
|
||||||
|
RimEclipseInputProperty* selectedInputProperty() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
|||||||
#include "RicExecuteScriptForCasesFeature.h"
|
#include "RicExecuteScriptForCasesFeature.h"
|
||||||
#include "RimEclipseStatisticsCaseCollection.h"
|
#include "RimEclipseStatisticsCaseCollection.h"
|
||||||
#include "RimEclipseStatisticsCase.h"
|
#include "RimEclipseStatisticsCase.h"
|
||||||
|
#include "RimEclipseInputProperty.h"
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
|
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -628,16 +628,18 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
|||||||
commandIds << "RicPasteEclipseCasesFeature";
|
commandIds << "RicPasteEclipseCasesFeature";
|
||||||
commandIds << "RicDeleteItemFeature";
|
commandIds << "RicDeleteItemFeature";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (dynamic_cast<RimCaseCollection*>(uiItem))
|
else if (dynamic_cast<RimCaseCollection*>(uiItem))
|
||||||
{
|
{
|
||||||
commandIds << "RicPasteEclipseCasesFeature";
|
commandIds << "RicPasteEclipseCasesFeature";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (dynamic_cast<RimEclipseCellColors*>(uiItem))
|
else if (dynamic_cast<RimEclipseCellColors*>(uiItem))
|
||||||
{
|
{
|
||||||
commandIds << "RicSaveEclipseResultAsInputPropertyFeature";
|
commandIds << "RicSaveEclipseResultAsInputPropertyFeature";
|
||||||
}
|
}
|
||||||
|
else if (dynamic_cast<RimEclipseInputProperty*>(uiItem))
|
||||||
|
{
|
||||||
|
commandIds << "RicSaveEclipseInputPropertyFeature";
|
||||||
|
}
|
||||||
else if (dynamic_cast<RimCellRangeFilterCollection*>(uiItem))
|
else if (dynamic_cast<RimCellRangeFilterCollection*>(uiItem))
|
||||||
{
|
{
|
||||||
commandIds << "RicRangeFilterNewFeature";
|
commandIds << "RicRangeFilterNewFeature";
|
||||||
|
@ -812,6 +812,7 @@ void RimUiTreeView::slotDeleteObjectFromContainer()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
// OBSOLETE - see RicSaveEclipseInputPropertyFeature
|
||||||
void RimUiTreeView::slotWriteInputProperty()
|
void RimUiTreeView::slotWriteInputProperty()
|
||||||
{
|
{
|
||||||
QModelIndex index = currentIndex();
|
QModelIndex index = currentIndex();
|
||||||
|
Loading…
Reference in New Issue
Block a user