#1387 Command to delete existing sour sim data from ResInsight

This commit is contained in:
Bjørnar Grip Fjær 2017-08-11 15:37:46 +02:00
parent 2ec68d08fb
commit 63bb85b998
5 changed files with 120 additions and 0 deletions

View File

@ -44,6 +44,8 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.h
${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.h
${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.h
${CEE_CURRENT_LIST_DIR}RicDeleteSourSimDataFeature.h
${CEE_CURRENT_LIST_DIR}RicCommandFeature.h
${CEE_CURRENT_LIST_DIR}RicReloadCaseFeature.h
@ -86,6 +88,8 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.cpp
${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicDeleteSourSimDataFeature.cpp
${CEE_CURRENT_LIST_DIR}RicReloadCaseFeature.cpp
)

View File

@ -0,0 +1,67 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicDeleteSourSimDataFeature.h"
#include "RimEclipseResultCase.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicDeleteSourSimDataFeature, "RicDeleteSourSimDataFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicDeleteSourSimDataFeature::isCommandEnabled()
{
return getSelectedEclipseCase() != nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDeleteSourSimDataFeature::onActionTriggered(bool isChecked)
{
RimEclipseResultCase* eclipseCase = getSelectedEclipseCase();
if (eclipseCase == nullptr) return;
eclipseCase->setSourSimFileName(QString());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDeleteSourSimDataFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Delete SourSim Data");
actionToSetup->setIcon(QIcon(":/Erase.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseResultCase* RicDeleteSourSimDataFeature::getSelectedEclipseCase()
{
caf::PdmUiItem* selectedItem = caf::SelectionManager::instance()->selectedItem();
RimEclipseResultCase* eclipseCase = dynamic_cast<RimEclipseResultCase*>(selectedItem);
return eclipseCase;
}

View File

@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
class RimEclipseResultCase;
//==================================================================================================
///
//==================================================================================================
class RicDeleteSourSimDataFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
private:
static RimEclipseResultCase* getSelectedEclipseCase();
};

View File

@ -458,6 +458,14 @@ void RifReaderEclipseOutput::setHdf5FileName(const QString& fileName)
RigCaseCellResultsData* matrixModelResults = m_eclipseCase->results(RifReaderInterface::MATRIX_RESULTS);
CVF_ASSERT(matrixModelResults);
if (fileName.isEmpty())
{
RiaLogging::info("HDF: Removing all existing Sour Sim data ...");
matrixModelResults->eraseAllSourSimData();
return;
}
RiaLogging::info(QString("HDF: Start import of data from : ").arg(fileName));
RiaLogging::info("HDF: Removing all existing Sour Sim data ...");

View File

@ -410,6 +410,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
{
commandIds << "RicReloadCaseFeature";
commandIds << "RicExecuteScriptForCasesFeature";
commandIds << "RicDeleteSourSimDataFeature";
}
else if (dynamic_cast<RimSummaryPlot*>(uiItem))
{