2015-09-21 08:55:55 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-09-21 08:55:55 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-09-21 08:55:55 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2015-09-21 08:55:55 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
#include "RicDeleteSubPlotFeature.h"
|
2017-02-09 01:34:28 -06:00
|
|
|
#include "RicWellLogPlotCurveFeatureImpl.h"
|
|
|
|
|
2019-05-06 03:36:05 -05:00
|
|
|
#include "RiaGuiApplication.h"
|
2019-12-19 04:37:40 -06:00
|
|
|
#include "RiuMultiPlotPage.h"
|
2018-07-03 05:54:51 -05:00
|
|
|
#include "RiuPlotMainWindow.h"
|
2019-10-11 08:54:19 -05:00
|
|
|
#include "RiuQwtPlotWidget.h"
|
2018-07-03 05:54:51 -05:00
|
|
|
|
2019-11-15 06:35:39 -06:00
|
|
|
#include "RimMultiPlotWindow.h"
|
2019-11-15 03:12:19 -06:00
|
|
|
#include "RimPlotWindow.h"
|
2019-10-31 07:48:40 -05:00
|
|
|
#include "RimWellLogTrack.h"
|
2015-09-21 08:55:55 -05:00
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2019-10-31 07:48:40 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicDeleteSubPlotFeature, "RicDeleteSubPlotFeature" );
|
2015-09-21 08:55:55 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-21 08:55:55 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-11 08:54:19 -05:00
|
|
|
bool RicDeleteSubPlotFeature::isCommandEnabled()
|
2015-09-21 08:55:55 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return false;
|
2017-02-09 01:34:28 -06:00
|
|
|
|
2019-10-11 08:54:19 -05:00
|
|
|
std::vector<caf::PdmObject*> selection;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &selection );
|
2015-09-21 08:55:55 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( selection.size() > 0 )
|
2015-09-21 08:55:55 -05:00
|
|
|
{
|
2019-10-31 07:48:40 -05:00
|
|
|
size_t plotsSelected = 0;
|
|
|
|
for ( caf::PdmObject* object : selection )
|
2015-09-21 08:55:55 -05:00
|
|
|
{
|
2019-11-15 06:35:39 -06:00
|
|
|
RimMultiPlotWindow* multiPlot = nullptr;
|
2019-11-13 05:22:50 -06:00
|
|
|
object->firstAncestorOrThisOfType( multiPlot );
|
2019-11-15 03:12:19 -06:00
|
|
|
if ( dynamic_cast<RimPlotWindow*>( object ) && multiPlot )
|
2019-10-31 07:48:40 -05:00
|
|
|
{
|
|
|
|
plotsSelected++;
|
|
|
|
}
|
2015-09-21 08:55:55 -05:00
|
|
|
}
|
2019-10-31 07:48:40 -05:00
|
|
|
return plotsSelected == selection.size();
|
2015-09-21 08:55:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-21 08:55:55 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-11 08:54:19 -05:00
|
|
|
void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked )
|
2015-09-21 08:55:55 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return;
|
2017-02-09 01:34:28 -06:00
|
|
|
|
2019-11-15 03:12:19 -06:00
|
|
|
std::vector<RimPlot*> selection;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &selection );
|
2019-11-15 06:35:39 -06:00
|
|
|
std::set<RimMultiPlotWindow*> alteredPlotWindows;
|
2015-09-21 08:55:55 -05:00
|
|
|
|
2019-11-15 03:12:19 -06:00
|
|
|
for ( RimPlot* plot : selection )
|
2015-09-21 08:55:55 -05:00
|
|
|
{
|
2019-11-15 06:35:39 -06:00
|
|
|
RimMultiPlotWindow* plotWindow = nullptr;
|
2019-11-15 03:12:19 -06:00
|
|
|
plot->firstAncestorOrThisOfType( plotWindow );
|
2019-10-31 07:48:40 -05:00
|
|
|
if ( plot && plotWindow )
|
2015-09-21 08:55:55 -05:00
|
|
|
{
|
2019-10-31 07:48:40 -05:00
|
|
|
alteredPlotWindows.insert( plotWindow );
|
|
|
|
plotWindow->removePlot( plot );
|
2019-11-15 03:12:19 -06:00
|
|
|
caf::SelectionManager::instance()->removeObjectFromAllSelections( plot );
|
2015-10-29 04:29:48 -05:00
|
|
|
|
2019-10-31 07:48:40 -05:00
|
|
|
plotWindow->updateConnectedEditors();
|
2019-10-11 08:54:19 -05:00
|
|
|
delete plot;
|
2015-09-21 08:55:55 -05:00
|
|
|
}
|
|
|
|
}
|
2018-07-03 05:54:51 -05:00
|
|
|
|
2019-11-15 06:35:39 -06:00
|
|
|
for ( RimMultiPlotWindow* plotWindow : alteredPlotWindows )
|
2018-07-03 05:54:51 -05:00
|
|
|
{
|
2019-10-31 07:48:40 -05:00
|
|
|
plotWindow->uiCapability()->updateConnectedEditors();
|
2018-07-03 05:54:51 -05:00
|
|
|
}
|
2015-09-21 08:55:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-09-21 08:55:55 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-10-11 08:54:19 -05:00
|
|
|
void RicDeleteSubPlotFeature::setupActionLook( QAction* actionToSetup )
|
2015-09-21 08:55:55 -05:00
|
|
|
{
|
2019-10-31 07:48:40 -05:00
|
|
|
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 );
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/Erase.png" ) );
|
|
|
|
applyShortcutWithHintToAction( actionToSetup, QKeySequence::Delete );
|
2015-09-21 08:55:55 -05:00
|
|
|
}
|