mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-01 03:37:15 -06:00
#2036. WellLogFile close command
This commit is contained in:
parent
4c223defec
commit
b3f77d1d70
@ -24,6 +24,7 @@ ${CEE_CURRENT_LIST_DIR}RicPasteWellLogPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeatureUi.h
|
||||
${CEE_CURRENT_LIST_DIR}RicAsciiExportWellLogPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicWellLogFileCloseFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -46,6 +47,7 @@ ${CEE_CURRENT_LIST_DIR}RicPasteWellLogPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeatureUi.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicAsciiExportWellLogPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicWellLogFileCloseFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,69 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicWellLogFileCloseFeature.h"
|
||||
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellLogFile.h"
|
||||
|
||||
#include "cafSelectionManagerTools.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicWellLogFileCloseFeature, "RicWellLogFileCloseFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicWellLogFileCloseFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimWellLogFile*> objects = caf::selectedObjectsByType<RimWellLogFile*>();
|
||||
return objects.size() > 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellLogFileCloseFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
std::vector<RimWellLogFile*> objects = caf::selectedObjectsByType<RimWellLogFile*>();
|
||||
|
||||
if (objects.size() == 0) return;
|
||||
|
||||
for (const auto& wellLogFile : objects)
|
||||
{
|
||||
RimWellPath* parentWellPath;
|
||||
wellLogFile->firstAncestorOrThisOfType(parentWellPath);
|
||||
|
||||
if (parentWellPath != nullptr)
|
||||
{
|
||||
parentWellPath->removeWellLogFile(wellLogFile);
|
||||
}
|
||||
parentWellPath->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellLogFileCloseFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Close Well Log File(s)");
|
||||
actionToSetup->setIcon(QIcon(":/Erase.png"));
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 RicWellLogFileCloseFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
protected:
|
||||
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered( bool isChecked ) override;
|
||||
virtual void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
@ -574,6 +574,14 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
commandIds << "RicWellPathDeleteFeature";
|
||||
}
|
||||
|
||||
if (caf::CmdFeatureManager::instance()->getCommandFeature("RicWellLogFileCloseFeature")->canFeatureBeExecuted())
|
||||
{
|
||||
// Special delete command for Well paths
|
||||
// Placed here to fit context menu location of general delete feature
|
||||
commandIds << "Separator";
|
||||
commandIds << "RicWellLogFileCloseFeature";
|
||||
}
|
||||
|
||||
if ( caf::CmdFeatureManager::instance()->getCommandFeature("RicCloseCaseFeature")->canFeatureBeExecuted() )
|
||||
{
|
||||
commandIds << "Separator";
|
||||
|
@ -650,6 +650,21 @@ void RimWellPath::addWellLogFile(RimWellLogFile* logFileInfo)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPath::removeWellLogFile(const RimWellLogFile* logFileInfo)
|
||||
{
|
||||
for (int i = 0; i < m_wellLogFiles.size(); i++)
|
||||
{
|
||||
if (m_wellLogFiles[i] == logFileInfo)
|
||||
{
|
||||
m_wellLogFiles.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
virtual ~RimWellPath();
|
||||
|
||||
void addWellLogFile(RimWellLogFile* logFileInfo);
|
||||
void removeWellLogFile(const RimWellLogFile* logFileInfo);
|
||||
|
||||
virtual caf::PdmFieldHandle* userDescriptionField();
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
|
Loading…
Reference in New Issue
Block a user