2017-10-23 06:57:01 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-10-23 06:57:01 -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
|
|
|
//
|
2017-10-23 06:57:01 -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>
|
2017-10-23 06:57:01 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicDeletePltPlotFeature.h"
|
|
|
|
|
|
|
|
#include "RimPltPlotCollection.h"
|
|
|
|
#include "RimWellPltPlot.h"
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicDeletePltPlotFeature, "RicDeletePltPlotFeature" );
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-23 06:57:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicDeletePltPlotFeature::isCommandEnabled()
|
|
|
|
{
|
|
|
|
std::vector<RimWellPltPlot*> objects;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &objects );
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( objects.size() > 0 )
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-23 06:57:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicDeletePltPlotFeature::onActionTriggered( bool isChecked )
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
|
|
|
std::vector<RimWellPltPlot*> selectedPlots;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &selectedPlots );
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( selectedPlots.size() == 0 ) return;
|
2017-10-23 06:57:01 -05:00
|
|
|
|
|
|
|
RimWellPltPlot* firstPlot = selectedPlots[0];
|
|
|
|
|
|
|
|
RimPltPlotCollection* pltPlotCollection = nullptr;
|
2019-09-06 03:40:57 -05:00
|
|
|
firstPlot->firstAncestorOrThisOfType( pltPlotCollection );
|
|
|
|
if ( !pltPlotCollection ) return;
|
2017-10-23 06:57:01 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimWellPltPlot* plot : selectedPlots )
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
pltPlotCollection->removePlot( plot );
|
2017-10-23 06:57:01 -05:00
|
|
|
delete plot;
|
|
|
|
}
|
|
|
|
|
|
|
|
pltPlotCollection->uiCapability()->updateConnectedEditors();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-10-23 06:57:01 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicDeletePltPlotFeature::setupActionLook( QAction* actionToSetup )
|
2017-10-23 06:57:01 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Delete PLT Plot" );
|
|
|
|
actionToSetup->setIcon( QIcon( ":/Erase.png" ) );
|
2017-10-23 06:57:01 -05:00
|
|
|
}
|