mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3957 Add button to valve for creating new valve template or editing existing template
* Also added separate delete valve feature so we can clear the template and update the valves referencing it.
This commit is contained in:
@@ -8,6 +8,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalAtMeasuredDepthFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewValveFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewValveTemplateFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteValveTemplateFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportCompletionsFileFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportPerforationIntervalsFeature.h
|
||||
)
|
||||
@@ -21,6 +22,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewValveFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewValveTemplateFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteValveTemplateFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportCompletionsFileFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportPerforationIntervalsFeature.cpp
|
||||
)
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor 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 "RicDeleteValveTemplateFeature.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "RimValveTemplate.h"
|
||||
#include "RimValveTemplateCollection.h"
|
||||
#include "RimWellPathValve.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicDeleteValveTemplateFeature, "RicDeleteValveTemplateFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicDeleteValveTemplateFeature::isCommandEnabled()
|
||||
{
|
||||
if (caf::SelectionManager::instance()->selectedItemOfType<RimValveTemplate>())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteValveTemplateFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimValveTemplate* valveTemplate = caf::SelectionManager::instance()->selectedItemOfType<RimValveTemplate>();
|
||||
|
||||
if (valveTemplate)
|
||||
{
|
||||
RimProject* project = nullptr;
|
||||
valveTemplate->firstAncestorOrThisOfTypeAsserted(project);
|
||||
std::vector<RimWellPathValve*> valves;
|
||||
project->descendantsIncludingThisOfType(valves);
|
||||
for (RimWellPathValve* valve : valves)
|
||||
{
|
||||
if (valve->valveTemplate() == valveTemplate)
|
||||
{
|
||||
valve->setValveTemplate(nullptr);
|
||||
valve->updateAllRequiredEditors();
|
||||
}
|
||||
}
|
||||
|
||||
RimValveTemplateCollection* collection = nullptr;
|
||||
valveTemplate->firstAncestorOrThisOfTypeAsserted(collection);
|
||||
collection->removeAndDeleteValveTemplate(valveTemplate);
|
||||
collection->updateAllRequiredEditors();
|
||||
|
||||
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteValveTemplateFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Delete Valve Template");
|
||||
actionToSetup->setIcon(QIcon(":/Erase.png"));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor 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 RicDeleteValveTemplateFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered(bool isChecked) override;
|
||||
void setupActionLook(QAction* actionToSetup) override;
|
||||
};
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "RimValveTemplateCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimWellPathValve.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
@@ -39,12 +40,16 @@ CAF_CMD_SOURCE_INIT(RicNewValveTemplateFeature, "RicNewValveTemplateFeature");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewValveTemplateFeature::selectValveTemplateAndUpdate(RimValveTemplateCollection* templateCollection,
|
||||
RimValveTemplate* valveTemplate)
|
||||
void RicNewValveTemplateFeature::selectValveTemplateAndUpdate(RimValveTemplate* valveTemplate)
|
||||
{
|
||||
valveTemplate->loadDataAndUpdate();
|
||||
|
||||
templateCollection->updateConnectedEditors();
|
||||
RimValveTemplateCollection* templateCollection = nullptr;
|
||||
valveTemplate->firstAncestorOrThisOfType(templateCollection);
|
||||
if (templateCollection)
|
||||
{
|
||||
templateCollection->updateConnectedEditors();
|
||||
}
|
||||
|
||||
RimProject* project = RiaApplication::instance()->project();
|
||||
|
||||
@@ -65,26 +70,48 @@ void RicNewValveTemplateFeature::selectValveTemplateAndUpdate(RimValveTemplateCo
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewValveTemplateFeature::onActionTriggered(bool isChecked)
|
||||
void RicNewValveTemplateFeature::createNewValveTemplateForValveAndUpdate(RimWellPathValve* valve)
|
||||
{
|
||||
RimValveTemplate* valveTemplate = createNewValveTemplate();
|
||||
valve->setValveTemplate(valveTemplate);
|
||||
selectValveTemplateAndUpdate(valveTemplate);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimValveTemplate* RicNewValveTemplateFeature::createNewValveTemplate()
|
||||
{
|
||||
RimProject* project = RiaApplication::instance()->project();
|
||||
CVF_ASSERT(project);
|
||||
|
||||
RimOilField* oilfield = project->activeOilField();
|
||||
if (oilfield == nullptr) return;
|
||||
if (oilfield == nullptr) return nullptr;
|
||||
|
||||
RimValveTemplateCollection* valveTemplateColl = oilfield->valveTemplateCollection();
|
||||
|
||||
if (valveTemplateColl)
|
||||
{
|
||||
RimValveTemplate* valveTemplate = new RimValveTemplate();
|
||||
QString userLabel = QString("Valve Template #%1").arg(valveTemplateColl->valveTemplates().size() + 1);
|
||||
QString userLabel = QString("Valve Template #%1").arg(valveTemplateColl->valveTemplates().size() + 1);
|
||||
valveTemplate->setUserLabel(userLabel);
|
||||
valveTemplateColl->addValveTemplate(valveTemplate);
|
||||
valveTemplate->setUnitSystem(valveTemplateColl->defaultUnitSystemType());
|
||||
valveTemplate->setDefaultValuesFromUnits();
|
||||
return valveTemplate;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
selectValveTemplateAndUpdate(valveTemplateColl, valveTemplate);
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewValveTemplateFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimValveTemplate* valveTemplate = createNewValveTemplate();
|
||||
if (valveTemplate)
|
||||
{
|
||||
selectValveTemplateAndUpdate(valveTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
class RimValveTemplate;
|
||||
class RimValveTemplateCollection;
|
||||
class RimWellPathValve;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -33,10 +34,10 @@ class RicNewValveTemplateFeature : public caf::CmdFeature
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void selectValveTemplateAndUpdate(RimValveTemplateCollection* templateCollection,
|
||||
RimValveTemplate* valveTemplate);
|
||||
|
||||
static void selectValveTemplateAndUpdate(RimValveTemplate* valveTemplate);
|
||||
static void createNewValveTemplateForValveAndUpdate(RimWellPathValve* valve);
|
||||
protected:
|
||||
static RimValveTemplate* createNewValveTemplate();
|
||||
void onActionTriggered(bool isChecked) override;
|
||||
void setupActionLook(QAction* actionToSetup) override;
|
||||
bool isCommandEnabled() override;
|
||||
|
||||
Reference in New Issue
Block a user