2018-10-24 06:01:17 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-02-14 14:26:23 -06:00
|
|
|
//
|
2018-10-24 06:01:17 -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-02-14 14:26:23 -06:00
|
|
|
//
|
2018-10-24 06:01:17 -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-02-14 14:26:23 -06:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-10-24 06:01:17 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicDeleteTemporaryLgrsFeature.h"
|
|
|
|
|
2019-05-06 03:36:05 -05:00
|
|
|
#include "RiaGuiApplication.h"
|
2018-11-07 07:29:34 -06:00
|
|
|
|
2018-10-24 06:01:17 -05:00
|
|
|
#include "RimEclipseCase.h"
|
|
|
|
#include "RimGridCollection.h"
|
2019-02-14 14:26:23 -06:00
|
|
|
#include "RimReloadCaseTools.h"
|
2018-10-24 06:01:17 -05:00
|
|
|
|
|
|
|
#include "cafPdmObject.h"
|
|
|
|
#include "cafSelectionManagerTools.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
CAF_CMD_SOURCE_INIT(RicDeleteTemporaryLgrsFeature, "RicDeleteTemporaryLgrsFeature");
|
|
|
|
|
2018-11-07 00:46:33 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicDeleteTemporaryLgrsFeature::deleteAllTemporaryLgrs(RimEclipseCase* eclipseCase)
|
|
|
|
{
|
2019-05-06 03:36:05 -05:00
|
|
|
RiaGuiApplication::clearAllSelections();
|
2018-11-07 07:29:34 -06:00
|
|
|
|
2019-02-14 14:26:23 -06:00
|
|
|
if (eclipseCase)
|
|
|
|
{
|
|
|
|
RimReloadCaseTools::reloadAllEclipseGridData(eclipseCase);
|
|
|
|
}
|
2018-11-07 00:46:33 -06:00
|
|
|
}
|
|
|
|
|
2018-10-24 06:01:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-14 14:26:23 -06:00
|
|
|
///
|
2018-10-24 06:01:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicDeleteTemporaryLgrsFeature::isCommandEnabled()
|
|
|
|
{
|
|
|
|
std::vector<RimGridInfoCollection*> selGridInfos = caf::selectedObjectsByTypeStrict<RimGridInfoCollection*>();
|
2018-11-09 01:13:39 -06:00
|
|
|
if (selGridInfos.size() == 1 && selGridInfos.front()->uiName() == RimGridCollection::temporaryGridUiName())
|
|
|
|
{
|
|
|
|
return !selGridInfos[0]->gridInfos().empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2018-10-24 06:01:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-14 14:26:23 -06:00
|
|
|
///
|
2018-10-24 06:01:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicDeleteTemporaryLgrsFeature::onActionTriggered(bool isChecked)
|
|
|
|
{
|
|
|
|
std::vector<RimGridInfoCollection*> selGridInfos = caf::selectedObjectsByTypeStrict<RimGridInfoCollection*>();
|
2018-10-26 08:38:09 -05:00
|
|
|
if (selGridInfos.size() == 1 && selGridInfos.front()->uiName() == RimGridCollection::temporaryGridUiName())
|
2018-10-24 06:01:17 -05:00
|
|
|
{
|
|
|
|
RimEclipseCase* eclipseCase;
|
|
|
|
selGridInfos.front()->firstAncestorOrThisOfType(eclipseCase);
|
|
|
|
|
2018-11-07 00:46:33 -06:00
|
|
|
deleteAllTemporaryLgrs(eclipseCase);
|
2018-10-24 06:01:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-02-14 14:26:23 -06:00
|
|
|
///
|
2018-10-24 06:01:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicDeleteTemporaryLgrsFeature::setupActionLook(QAction* actionToSetup)
|
|
|
|
{
|
|
|
|
actionToSetup->setText("Delete Temporary LGRs");
|
|
|
|
actionToSetup->setIcon(QIcon(":/Erase.png"));
|
2019-03-27 06:01:22 -05:00
|
|
|
applyShortcutWithHintToAction(actionToSetup, QKeySequence::Delete);
|
2018-10-24 06:01:17 -05:00
|
|
|
}
|