mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#339) Added RicCloseCaseFeature
This commit is contained in:
parent
5defe45209
commit
9c4766a262
@ -5,7 +5,7 @@ if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
|
||||
endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseCloseFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseExecuteScriptFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.h
|
||||
@ -47,7 +47,7 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseCloseFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseExecuteScriptFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.cpp
|
||||
|
171
ApplicationCode/Commands/RicCloseCaseFeature.cpp
Normal file
171
ApplicationCode/Commands/RicCloseCaseFeature.cpp
Normal file
@ -0,0 +1,171 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicCloseCaseFeature.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimEclipseCaseCollection.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimGeoMechModels.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafPdmFieldHandle.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicCloseCaseFeature, "RicCloseCaseFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCloseCaseFeature::isCommandEnabled()
|
||||
{
|
||||
return selectedEclipseCase() != NULL || selectedGeoMechCase() != NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCloseCaseFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimEclipseCase* eclipseCase = selectedEclipseCase();
|
||||
RimGeoMechCase* geoMechCase = selectedGeoMechCase();
|
||||
if (eclipseCase)
|
||||
{
|
||||
deleteEclipseCase(eclipseCase);
|
||||
}
|
||||
else if (geoMechCase)
|
||||
{
|
||||
deleteGeoMechCase(geoMechCase);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCloseCaseFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Close");
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseCase* RicCloseCaseFeature::selectedEclipseCase() const
|
||||
{
|
||||
std::vector<RimEclipseCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() > 0)
|
||||
{
|
||||
return selection[0];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechCase* RicCloseCaseFeature::selectedGeoMechCase() const
|
||||
{
|
||||
std::vector<RimGeoMechCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() > 0)
|
||||
{
|
||||
return selection[0];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCloseCaseFeature::removeCaseFromAllGroups(RimEclipseCase* eclipseCase)
|
||||
{
|
||||
CVF_ASSERT(eclipseCase);
|
||||
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
RimOilField* activeOilField = proj ? proj->activeOilField() : NULL;
|
||||
RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL;
|
||||
if (analysisModels)
|
||||
{
|
||||
analysisModels->removeCaseFromAllGroups(eclipseCase);
|
||||
analysisModels->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCloseCaseFeature::deleteEclipseCase(RimEclipseCase* eclipseCase)
|
||||
{
|
||||
CVF_ASSERT(eclipseCase);
|
||||
|
||||
RimCaseCollection* caseCollection = eclipseCase->parentCaseCollection();
|
||||
if (caseCollection)
|
||||
{
|
||||
if (RimIdenticalGridCaseGroup::isStatisticsCaseCollection(caseCollection))
|
||||
{
|
||||
RimIdenticalGridCaseGroup* caseGroup = caseCollection->parentCaseGroup();
|
||||
CVF_ASSERT(caseGroup);
|
||||
|
||||
caseGroup->statisticsCaseCollection()->reservoirs.removeChildObject(eclipseCase);
|
||||
caseGroup->updateConnectedEditors();
|
||||
}
|
||||
else
|
||||
{
|
||||
removeCaseFromAllGroups(eclipseCase);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
removeCaseFromAllGroups(eclipseCase);
|
||||
}
|
||||
|
||||
delete eclipseCase;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCloseCaseFeature::deleteGeoMechCase(RimGeoMechCase* geoMechCase)
|
||||
{
|
||||
CVF_ASSERT(geoMechCase);
|
||||
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
RimOilField* activeOilField = proj ? proj->activeOilField() : NULL;
|
||||
RimGeoMechModels* models = (activeOilField) ? activeOilField->geoMechModels() : NULL;
|
||||
if (models)
|
||||
{
|
||||
models->cases.removeChildObject(geoMechCase);
|
||||
models->updateConnectedEditors();
|
||||
}
|
||||
|
||||
delete geoMechCase;
|
||||
}
|
@ -21,11 +21,13 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimEclipseCase;
|
||||
class RimGeoMechCase;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicEclipseCaseCloseFeature : public caf::CmdFeature
|
||||
class RicCloseCaseFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
@ -34,6 +36,14 @@ protected:
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
private:
|
||||
RimEclipseCase* selectedEclipseCase() const;
|
||||
RimGeoMechCase* selectedGeoMechCase() const;
|
||||
|
||||
void removeCaseFromAllGroups(RimEclipseCase* eclipseCase);
|
||||
void deleteEclipseCase(RimEclipseCase* eclipseCase);
|
||||
void deleteGeoMechCase(RimGeoMechCase* geoMechCase);
|
||||
};
|
||||
|
||||
|
@ -1,65 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicEclipseCaseCloseFeature.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicEclipseCaseCloseFeature, "RicEclipseCaseCloseFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicEclipseCaseCloseFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEclipseCaseCloseFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
// TODO
|
||||
assert(false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEclipseCaseCloseFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Close");
|
||||
}
|
||||
|
||||
|
@ -575,7 +575,7 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
||||
commandIds << "RicPasteEclipseCasesFeature";
|
||||
commandIds << "RicPasteEclipseViewsFeature";
|
||||
|
||||
//commandIds << "RicEclipseCaseClose";
|
||||
commandIds << "RicCloseCaseFeature";
|
||||
commandIds << "RicNewViewFeature";
|
||||
commandIds << "RicEclipseCaseNewGroupFeature";
|
||||
//commandIds << "RicEclipseCaseExecuteScript";
|
||||
@ -583,8 +583,8 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
||||
else if (dynamic_cast<RimGeoMechCase*>(uiItem))
|
||||
{
|
||||
commandIds << "RicPasteGeoMechViewsFeature";
|
||||
//commandIds << "RicEclipseCaseClose";
|
||||
commandIds << "RicNewViewFeature";
|
||||
commandIds << "RicCloseCaseFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem))
|
||||
{
|
||||
|
@ -937,6 +937,7 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// OBSOLETE - See RicCloseCaseFeature
|
||||
void RimUiTreeView::slotCloseCase()
|
||||
{
|
||||
QModelIndexList miList;
|
||||
@ -1546,6 +1547,7 @@ void RimUiTreeView::selectedUiItems(std::vector<caf::PdmUiItem*>& objects)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// OBSOLETE - See RicCloseCaseFeature
|
||||
void RimUiTreeView::slotCloseGeomechCase()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
|
Loading…
Reference in New Issue
Block a user