mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Skeleton for toggling grouping of well paths
This commit is contained in:
parent
395398587a
commit
195bcf2817
@ -2,6 +2,7 @@
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportWellPaths.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportGroupedWellPaths.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicToggleWellPathGrouping.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewEditableWellPathFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowWellPlanFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathListTargetFeature.h
|
||||
@ -30,6 +31,7 @@ ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.h
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportWellPaths.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportGroupedWellPaths.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicToggleWellPathGrouping.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewEditableWellPathFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowWellPlanFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathListTargetFeature.cpp
|
||||
|
@ -0,0 +1,163 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- 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 "RicToggleWellPathGrouping.h"
|
||||
|
||||
#include "RigWellPath.h"
|
||||
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
RICF_SOURCE_INIT( RicToggleWellPathGrouping, "RicToggleWellPathGroupingFeature", "groupWellPaths" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicToggleWellPathGrouping::RicToggleWellPathGrouping()
|
||||
{
|
||||
CAF_PDM_InitScriptableField( &m_groupeWellPaths, "group", false, "", "", "", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_wellPaths, "wellPaths", "", "", "", "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmScriptResponse RicToggleWellPathGrouping::execute()
|
||||
{
|
||||
caf::PdmScriptResponse response;
|
||||
|
||||
auto wellPaths = m_wellPaths.ptrReferencedObjects();
|
||||
if ( wellPaths.empty() )
|
||||
{
|
||||
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_WARNING, "No well paths provided" );
|
||||
}
|
||||
|
||||
RimProject* project = RimProject::current();
|
||||
|
||||
if ( project )
|
||||
{
|
||||
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
RimOilField* oilField = project->activeOilField();
|
||||
|
||||
if ( oilField )
|
||||
{
|
||||
if ( m_groupeWellPaths() )
|
||||
{
|
||||
oilField->wellPathCollection->groupWellPaths( wellPaths );
|
||||
return caf::PdmScriptResponse();
|
||||
}
|
||||
else
|
||||
{
|
||||
oilField->wellPathCollection->ungroupWellPaths( wellPaths );
|
||||
return caf::PdmScriptResponse();
|
||||
}
|
||||
}
|
||||
}
|
||||
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, "No project open" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicToggleWellPathGrouping::isCommandEnabled()
|
||||
{
|
||||
auto wellPaths = selectedWellPaths();
|
||||
return wellPaths.size() > 1u && containsUngroupedWellPathsWithCommonGeometry( wellPaths );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicToggleWellPathGrouping::onActionTriggered( bool isChecked )
|
||||
{
|
||||
auto wellPaths = selectedWellPaths();
|
||||
|
||||
if ( containsUngroupedWellPathsWithCommonGeometry( wellPaths ) )
|
||||
{
|
||||
m_groupeWellPaths = true;
|
||||
}
|
||||
else if ( containsGroupedWellPaths( wellPaths ) )
|
||||
{
|
||||
m_groupeWellPaths = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_wellPaths.setValue( wellPaths );
|
||||
execute();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicToggleWellPathGrouping::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
auto wellPaths = selectedWellPaths();
|
||||
if ( containsUngroupedWellPathsWithCommonGeometry( wellPaths ) )
|
||||
{
|
||||
actionToSetup->setText( "Group the selected well paths into a Well Tree" );
|
||||
actionToSetup->setIcon( QIcon( ":/Well.png" ) );
|
||||
}
|
||||
else if ( containsGroupedWellPaths( wellPaths ) )
|
||||
{
|
||||
actionToSetup->setText( "Ungroup the selected well paths" );
|
||||
actionToSetup->setIcon( QIcon( ":/Well.png" ) );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimWellPath*> RicToggleWellPathGrouping::selectedWellPaths()
|
||||
{
|
||||
std::vector<RimWellPath*> wellPaths;
|
||||
caf::SelectionManager::instance()->objectsByTypeStrict( &wellPaths );
|
||||
return wellPaths;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicToggleWellPathGrouping::containsGroupedWellPaths( const std::vector<RimWellPath*>& wellPaths )
|
||||
{
|
||||
// TODO: add real check
|
||||
return std::any_of( wellPaths.begin(), wellPaths.end(), []( RimWellPath* wellPath ) { return true; } );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicToggleWellPathGrouping::containsUngroupedWellPathsWithCommonGeometry( const std::vector<RimWellPath*>& wellPaths )
|
||||
{
|
||||
// TODO: add check for whether the well paths are grouped.
|
||||
std::vector<const RigWellPath*> geometries;
|
||||
for ( auto wellPath : wellPaths )
|
||||
{
|
||||
geometries.push_back( wellPath->wellPathGeometry() );
|
||||
}
|
||||
RigWellPath commonGeometry = RigWellPath::commonGeometry( geometries );
|
||||
return !commonGeometry.wellPathPoints().empty();
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- 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 "CommandFileInterface/Core/RicfCommandObject.h"
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmPtrArrayField.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimWellPath;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicToggleWellPathGrouping : public caf::CmdFeature, public RicfCommandObject
|
||||
{
|
||||
RICF_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicToggleWellPathGrouping();
|
||||
caf::PdmScriptResponse execute() override;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
static std::vector<RimWellPath*> selectedWellPaths();
|
||||
static bool containsGroupedWellPaths( const std::vector<RimWellPath*>& wellPaths );
|
||||
static bool containsUngroupedWellPathsWithCommonGeometry( const std::vector<RimWellPath*>& wellPaths );
|
||||
|
||||
protected:
|
||||
caf::PdmField<bool> m_groupeWellPaths;
|
||||
caf::PdmPtrArrayField<RimWellPath*> m_wellPaths;
|
||||
};
|
@ -1158,6 +1158,12 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicMoveItemsToTopFeature";
|
||||
}
|
||||
|
||||
if ( caf::CmdFeatureManager::instance()->getCommandFeature( "RicToggleWellPathGroupingFeature" )->canFeatureBeExecuted() )
|
||||
{
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicToggleWellPathGroupingFeature";
|
||||
}
|
||||
|
||||
if ( caf::CmdFeatureManager::instance()->getCommandFeature( "RicDeleteItemFeature" )->canFeatureBeExecuted() )
|
||||
{
|
||||
menuBuilder << "Separator";
|
||||
|
@ -574,6 +574,22 @@ void RimWellPathCollection::deleteAllWellPaths()
|
||||
updateAllRequiredEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathCollection::groupWellPaths( const std::vector<RimWellPath*> wellPaths )
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathCollection::ungroupWellPaths( const std::vector<RimWellPath*> wellPaths )
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -97,6 +97,8 @@ public:
|
||||
std::vector<RimWellPath*> allWellPaths() const;
|
||||
void removeWellPath( RimWellPath* wellPath );
|
||||
void deleteAllWellPaths();
|
||||
void groupWellPaths( const std::vector<RimWellPath*> wellPaths );
|
||||
void ungroupWellPaths( const std::vector<RimWellPath*> wellPaths );
|
||||
|
||||
RimWellPath* mostRecentlyUpdatedWellPath();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user