mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Summary context menu cleanup and fixes (#9165)
* Make summary plot ctx menu items show up for the plot you right-click on, not the one selected in the project tree.
This commit is contained in:
parent
eedebd71a5
commit
c3f538c1dd
@ -20,6 +20,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicExportObjectAndFieldKeywordsFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSaveProjectNoGlobalPathsFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowClassNamesFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataCtxFeature.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@ -44,6 +45,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicExportObjectAndFieldKeywordsFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSaveProjectNoGlobalPathsFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowClassNamesFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataCtxFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
@ -0,0 +1,29 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022 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 "RicShowPlotDataCtxFeature.h"
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicShowPlotDataCtxFeature, "RicShowPlotDataCtxFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicShowPlotDataCtxFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022 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 "RicShowPlotDataFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicShowPlotDataCtxFeature : public RicShowPlotDataFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
};
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "RimGridCrossPlot.h"
|
||||
#include "RimGridCrossPlotCurve.h"
|
||||
#include "RimPlot.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCrossPlot.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
@ -173,30 +174,26 @@ bool RicShowPlotDataFeature::isCommandEnabled()
|
||||
return true;
|
||||
}
|
||||
|
||||
auto selectedSummaryPlots = caf::selectedObjectsByType<RimSummaryPlot*>();
|
||||
if ( selectedSummaryPlots.size() > 0 )
|
||||
std::vector<RimPlot*> selection;
|
||||
getSelection( selection );
|
||||
|
||||
int validPlots = 0;
|
||||
|
||||
for ( auto plot : selection )
|
||||
{
|
||||
for ( auto c : selectedSummaryPlots )
|
||||
if ( dynamic_cast<RimSummaryCrossPlot*>( plot ) )
|
||||
{
|
||||
if ( dynamic_cast<RimSummaryCrossPlot*>( c ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
if ( dynamic_cast<RimSummaryPlot*>( plot ) != nullptr ||
|
||||
( dynamic_cast<RimWellLogPlot*>( plot ) != nullptr || dynamic_cast<RimGridCrossPlot*>( plot ) != nullptr ||
|
||||
dynamic_cast<RimVfpPlot*>( plot ) != nullptr ) )
|
||||
{
|
||||
validPlots++;
|
||||
}
|
||||
}
|
||||
|
||||
auto wellLogPlots = caf::selectedObjectsByType<RimWellLogPlot*>();
|
||||
if ( wellLogPlots.size() > 0 ) return true;
|
||||
|
||||
auto gridCrossPlots = caf::selectedObjectsByType<RimGridCrossPlot*>();
|
||||
if ( gridCrossPlots.size() > 0 ) return true;
|
||||
|
||||
auto vfpPlots = caf::selectedObjectsByType<RimVfpPlot*>();
|
||||
if ( vfpPlots.size() > 0 ) return true;
|
||||
|
||||
return false;
|
||||
return ( validPlots > 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -220,10 +217,45 @@ void RicShowPlotDataFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
this->disableModelChangeContribution();
|
||||
|
||||
std::vector<RimSummaryPlot*> selectedSummaryPlots = caf::selectedObjectsByType<RimSummaryPlot*>();
|
||||
std::vector<RimWellLogPlot*> wellLogPlots = caf::selectedObjectsByType<RimWellLogPlot*>();
|
||||
std::vector<RimGridCrossPlot*> crossPlots = caf::selectedObjectsByType<RimGridCrossPlot*>();
|
||||
std::vector<RimVfpPlot*> vfpPlots = caf::selectedObjectsByType<RimVfpPlot*>();
|
||||
std::vector<RimPlot*> selection;
|
||||
getSelection( selection );
|
||||
|
||||
std::vector<RimSummaryPlot*> selectedSummaryPlots;
|
||||
std::vector<RimWellLogPlot*> wellLogPlots;
|
||||
std::vector<RimGridCrossPlot*> crossPlots;
|
||||
std::vector<RimVfpPlot*> vfpPlots;
|
||||
|
||||
for ( auto plot : selection )
|
||||
{
|
||||
auto sumPlot = dynamic_cast<RimSummaryPlot*>( plot );
|
||||
if ( sumPlot )
|
||||
{
|
||||
selectedSummaryPlots.push_back( sumPlot );
|
||||
continue;
|
||||
}
|
||||
|
||||
auto wellPlot = dynamic_cast<RimWellLogPlot*>( plot );
|
||||
if ( wellPlot )
|
||||
{
|
||||
wellLogPlots.push_back( wellPlot );
|
||||
continue;
|
||||
}
|
||||
|
||||
auto xPlot = dynamic_cast<RimGridCrossPlot*>( plot );
|
||||
if ( xPlot )
|
||||
{
|
||||
crossPlots.push_back( xPlot );
|
||||
continue;
|
||||
}
|
||||
|
||||
auto vfpPlot = dynamic_cast<RimVfpPlot*>( plot );
|
||||
if ( vfpPlot )
|
||||
{
|
||||
vfpPlots.push_back( vfpPlot );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ( selectedSummaryPlots.empty() && wellLogPlots.empty() && crossPlots.empty() && vfpPlots.empty() )
|
||||
{
|
||||
CVF_ASSERT( false );
|
||||
@ -303,3 +335,24 @@ void RicShowPlotDataFeature::showTextWindow( const QString& title, const QString
|
||||
|
||||
plotwindow->addToTemporaryWidgets( textWiget );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicShowPlotDataFeature::getSelection( std::vector<RimPlot*>& selection )
|
||||
{
|
||||
if ( sender() )
|
||||
{
|
||||
QVariant userData = this->userData();
|
||||
if ( !userData.isNull() && userData.canConvert<void*>() )
|
||||
{
|
||||
RimPlot* plot = static_cast<RimPlot*>( userData.value<void*>() );
|
||||
if ( plot ) selection.push_back( plot );
|
||||
}
|
||||
}
|
||||
|
||||
if ( selection.empty() )
|
||||
{
|
||||
caf::SelectionManager::instance()->objectsByType( &selection );
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,10 @@
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
class RiuTabbedTextProvider;
|
||||
class RimPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -36,6 +38,9 @@ protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
void getSelection( std::vector<RimPlot*>& selection );
|
||||
|
||||
public:
|
||||
static void showTabbedTextWindow( RiuTabbedTextProvider* textProvider );
|
||||
static void showTextWindow( const QString& title, const QString& text );
|
||||
|
@ -46,7 +46,7 @@ bool RicSplitMultiPlotFeature::isCommandEnabled()
|
||||
return ( ( plot->summaryCurves().size() > 1 ) || ( plot->curveSets().size() > 1 ) );
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -44,6 +44,8 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewPlotAxisPropertiesFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowSummaryPlotManagerFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryMultiPlotFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteSubPlotCtxFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryPlotCtxFeature.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@ -92,6 +94,8 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewPlotAxisPropertiesFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowSummaryPlotManagerFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryMultiPlotFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteSubPlotCtxFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryPlotCtxFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
@ -0,0 +1,29 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022 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 "RicDeleteSubPlotCtxFeature.h"
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicDeleteSubPlotCtxFeature, "RicDeleteSubPlotCtxFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicDeleteSubPlotCtxFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022 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 "WellLogCommands/RicDeleteSubPlotFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicDeleteSubPlotCtxFeature : public RicDeleteSubPlotFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
};
|
@ -0,0 +1,29 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022 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 "RicEditSummaryPlotCtxFeature.h"
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicEditSummaryPlotCtxFeature, "RicEditSummaryPlotCtxFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicEditSummaryPlotCtxFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022 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 "RicEditSummaryPlotFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicEditSummaryPlotCtxFeature : public RicEditSummaryPlotFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
};
|
@ -133,6 +133,16 @@ RimSummaryPlot* RicEditSummaryPlotFeature::selectedSummaryPlot()
|
||||
{
|
||||
RimSummaryPlot* sumPlot = nullptr;
|
||||
|
||||
if ( sender() )
|
||||
{
|
||||
QVariant userData = this->userData();
|
||||
if ( !userData.isNull() && userData.canConvert<void*>() )
|
||||
{
|
||||
RimSummaryPlot* plot = static_cast<RimSummaryPlot*>( userData.value<void*>() );
|
||||
if ( plot ) return plot;
|
||||
}
|
||||
}
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( selObj )
|
||||
{
|
||||
|
@ -43,5 +43,5 @@ protected:
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
static RimSummaryPlot* selectedSummaryPlot();
|
||||
RimSummaryPlot* selectedSummaryPlot();
|
||||
};
|
||||
|
@ -44,29 +44,10 @@ bool RicDeleteSubPlotFeature::isCommandEnabled()
|
||||
{
|
||||
if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return false;
|
||||
|
||||
std::vector<caf::PdmObject*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType( &selection );
|
||||
std::vector<RimPlot*> selection;
|
||||
getSelection( selection );
|
||||
|
||||
if ( selection.size() > 0 )
|
||||
{
|
||||
if ( dynamic_cast<RimMultiPlot*>( selection.front() ) ) return false;
|
||||
|
||||
size_t plotsSelected = 0;
|
||||
for ( caf::PdmObject* object : selection )
|
||||
{
|
||||
RimMultiPlot* multiPlot = nullptr;
|
||||
RimWellLogPlot* wellLogPlot = nullptr;
|
||||
object->firstAncestorOrThisOfType( multiPlot );
|
||||
object->firstAncestorOrThisOfType( wellLogPlot );
|
||||
if ( dynamic_cast<RimPlotWindow*>( object ) && ( multiPlot || wellLogPlot ) )
|
||||
{
|
||||
plotsSelected++;
|
||||
}
|
||||
}
|
||||
return plotsSelected == selection.size();
|
||||
}
|
||||
|
||||
return false;
|
||||
return ( selection.size() > 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -59,7 +59,17 @@ void RiuSummaryPlot::showContextMenu( QPoint pos )
|
||||
QMenu menu;
|
||||
caf::CmdFeatureMenuBuilder menuBuilder;
|
||||
|
||||
menuBuilder << "RicShowPlotDataFeature";
|
||||
RimSummaryPlot* plot = dynamic_cast<RimSummaryPlot*>( plotWidget()->plotDefinition() );
|
||||
if ( plot )
|
||||
{
|
||||
QVariant plotVariant( QVariant::fromValue( static_cast<void*>( plot ) ) );
|
||||
menuBuilder.addCmdFeatureWithUserData( "RicShowPlotDataCtxFeature", "Show Plot Data", plotVariant );
|
||||
menuBuilder.addCmdFeatureWithUserData( "RicEditSummaryPlotCtxFeature", "Edit Plot", plotVariant );
|
||||
menuBuilder.addCmdFeatureWithUserData( "RicSplitMultiPlotFeature", "Split into Multiple Plots", plotVariant );
|
||||
menuBuilder.addSeparator();
|
||||
menuBuilder.addCmdFeatureWithUserData( "RicDeleteSubPlotCtxFeature", "Delete Plot", plotVariant );
|
||||
}
|
||||
menuBuilder.addSeparator();
|
||||
|
||||
double distanceFromClick = std::numeric_limits<double>::infinity();
|
||||
|
||||
@ -192,16 +202,6 @@ void RiuSummaryPlot::showContextMenu( QPoint pos )
|
||||
}
|
||||
}
|
||||
|
||||
menuBuilder.addSeparator();
|
||||
|
||||
RimSummaryPlot* plot = dynamic_cast<RimSummaryPlot*>( plotWidget()->plotDefinition() );
|
||||
if ( plot )
|
||||
{
|
||||
QVariant plotVariant( QVariant::fromValue( static_cast<void*>( plot ) ) );
|
||||
menuBuilder.addCmdFeatureWithUserData( "RicSplitMultiPlotFeature", "Split into Multiple Plots", plotVariant );
|
||||
menuBuilder.addCmdFeatureWithUserData( "RicDeleteSubPlotFeature", "Delete Plot", plotVariant );
|
||||
}
|
||||
|
||||
menuBuilder.appendToMenu( &menu );
|
||||
|
||||
if ( !menu.actions().empty() )
|
||||
|
Loading…
Reference in New Issue
Block a user