mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Allow deleting of the last sub plot and have nice visible drop targets
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "RimGridPlotWindow.h"
|
||||
#include "RimPlotInterface.h"
|
||||
#include "RimWellLogTrack.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
@@ -46,12 +47,17 @@ bool RicDeleteSubPlotFeature::isCommandEnabled()
|
||||
|
||||
if ( selection.size() > 0 )
|
||||
{
|
||||
RimGridPlotWindow* wellLogPlot = nullptr;
|
||||
selection[0]->firstAncestorOrThisOfType( wellLogPlot );
|
||||
if ( dynamic_cast<RimPlotInterface*>( selection[0] ) && wellLogPlot && wellLogPlot->plotCount() > 1 )
|
||||
size_t plotsSelected = 0;
|
||||
for ( caf::PdmObject* object : selection )
|
||||
{
|
||||
return true;
|
||||
RimGridPlotWindow* gridPlotWindow = nullptr;
|
||||
object->firstAncestorOrThisOfType( gridPlotWindow );
|
||||
if ( dynamic_cast<RimPlotInterface*>( object ) && gridPlotWindow )
|
||||
{
|
||||
plotsSelected++;
|
||||
}
|
||||
}
|
||||
return plotsSelected == selection.size();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -66,7 +72,6 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
std::vector<caf::PdmObject*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType( &selection );
|
||||
RiuPlotMainWindow* plotWindow = RiaGuiApplication::instance()->getOrCreateMainPlotWindow();
|
||||
std::set<RimGridPlotWindow*> alteredWellLogPlots;
|
||||
|
||||
for ( size_t i = 0; i < selection.size(); i++ )
|
||||
@@ -75,7 +80,7 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
RimGridPlotWindow* wellLogPlot = nullptr;
|
||||
selection[i]->firstAncestorOrThisOfType( wellLogPlot );
|
||||
if ( plot && wellLogPlot && wellLogPlot->plotCount() > 1 )
|
||||
if ( plot && wellLogPlot )
|
||||
{
|
||||
alteredWellLogPlots.insert( wellLogPlot );
|
||||
wellLogPlot->removePlot( plot );
|
||||
@@ -88,11 +93,6 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
for ( RimGridPlotWindow* wellLogPlot : alteredWellLogPlots )
|
||||
{
|
||||
RiuGridPlotWindow* viewWidget = dynamic_cast<RiuGridPlotWindow*>( wellLogPlot->viewWidget() );
|
||||
plotWindow->setWidthOfMdiWindow( viewWidget, viewWidget->preferredWidth() );
|
||||
// TODO: add back with virtual methods
|
||||
// wellLogPlot->calculateAvailableDepthRange();
|
||||
// wellLogPlot->updateDepthZoom();
|
||||
wellLogPlot->uiCapability()->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,32 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteSubPlotFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Delete Track" );
|
||||
QString actionText;
|
||||
std::vector<caf::PdmObject*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType( &selection );
|
||||
|
||||
size_t tracksSelected = 0u;
|
||||
for ( caf::PdmObject* object : selection )
|
||||
{
|
||||
if ( dynamic_cast<RimWellLogTrack*>( object ) )
|
||||
{
|
||||
tracksSelected++;
|
||||
}
|
||||
}
|
||||
if ( tracksSelected == selection.size() )
|
||||
{
|
||||
actionText = "Delete Track";
|
||||
}
|
||||
else
|
||||
{
|
||||
actionText = "Delete Plot";
|
||||
}
|
||||
if ( selection.size() > 1u )
|
||||
{
|
||||
actionText += "s";
|
||||
}
|
||||
|
||||
actionToSetup->setText( actionText );
|
||||
actionToSetup->setIcon( QIcon( ":/Erase.png" ) );
|
||||
applyShortcutWithHintToAction( actionToSetup, QKeySequence::Delete );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user