#1820 Observed data: Add close command of observed data

This commit is contained in:
Rebecca Cox
2017-09-27 15:07:27 +02:00
parent 4f238a74b0
commit faf5f59be6
4 changed files with 150 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseInCollectionFeature.h
${CEE_CURRENT_LIST_DIR}RicCloseObservedDataFeature.h
${CEE_CURRENT_LIST_DIR}RicCreateSummaryCaseCollectionFeature.h
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.h
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.h
@@ -77,6 +78,7 @@ set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseInCollectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicCloseObservedDataFeature.cpp
${CEE_CURRENT_LIST_DIR}RicCreateSummaryCaseCollectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.cpp
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.cpp

View File

@@ -0,0 +1,106 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil 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 "RicCloseObservedDataFeature.h"
#include "RiaApplication.h"
#include "RimMainPlotCollection.h"
#include "RimObservedData.h"
#include "RimObservedDataCollection.h"
#include "RimProject.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicCloseObservedDataFeature, "RicCloseObservedDataFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCloseObservedDataFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Close");
actionToSetup->setIcon(QIcon(":/Erase.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCloseObservedDataFeature::deleteObservedData(const std::vector<RimObservedData*>& data)
{
RimSummaryPlotCollection* summaryPlotColl = RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
CVF_ASSERT(summaryPlotColl);
for (RimObservedData* observedData : data)
{
for (RimSummaryPlot* summaryPlot : summaryPlotColl->summaryPlots)
{
summaryPlot->deleteCurvesAssosiatedWithCase(observedData);
}
summaryPlotColl->updateConnectedEditors();
RimObservedDataCollection* observedDataCollection = nullptr;
observedData->firstAncestorOrThisOfTypeAsserted(observedDataCollection);
observedDataCollection->removeObservedData(observedData);
delete observedData;
observedDataCollection->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCloseObservedDataFeature::isCommandEnabled()
{
std::vector<RimObservedData*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
if (selection.size() == 0)
{
return false;
}
for (RimObservedData* data : selection)
{
if (!data->isObservedData())
{
return false;
}
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCloseObservedDataFeature::onActionTriggered(bool isChecked)
{
std::vector<RimObservedData*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
CVF_ASSERT(selection.size() > 0);
RicCloseObservedDataFeature::deleteObservedData(selection);
}

View File

@@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil 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 "cafCmdFeature.h"
#include <vector>
class RimObservedData;
//==================================================================================================
///
//==================================================================================================
class RicCloseObservedDataFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void deleteObservedData(const std::vector<RimObservedData*>& data);
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
};

View File

@@ -458,6 +458,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
commandIds << "RicCloseSummaryCaseFeature";
commandIds << "RicCloseSummaryCaseInCollectionFeature";
commandIds << "RicDeleteSummaryCaseCollectionFeature";
commandIds << "RicCloseObservedDataFeature";
// Fracture commands
#ifdef USE_PROTOTYPE_FEATURE_FRACTURES