#1728 Can close all summary cases within one collection

This commit is contained in:
Unknown 2017-09-05 15:48:06 +02:00 committed by Rebecca Cox
parent e1ab73da30
commit a4aa06b75c
6 changed files with 156 additions and 28 deletions

View File

@ -7,6 +7,7 @@ endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseCollectionFeature.h
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.h
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.h
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertExec.h
@ -70,6 +71,7 @@ endif()
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseCollectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.cpp
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.cpp
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertExec.cpp

View File

@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicCloseSummaryCaseCollectionFeature.h"
#include "RiaApplication.h"
#include "RicCloseSummaryCaseFeature.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
#include <vector>
CAF_CMD_SOURCE_INIT(RicCloseSummaryCaseCollectionFeature, "RicCloseSummaryCaseCollectionFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCloseSummaryCaseCollectionFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Close Sub Items");
actionToSetup->setIcon(QIcon(":/Erase.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCloseSummaryCaseCollectionFeature::isCommandEnabled()
{
std::vector<RimSummaryCaseCollection*> summaryCaseCollections;
caf::SelectionManager::instance()->objectsByType(&summaryCaseCollections);
return (summaryCaseCollections.size() > 0);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCloseSummaryCaseCollectionFeature::onActionTriggered(bool isChecked)
{
std::vector<RimSummaryCaseCollection*> summaryCaseCollections;
caf::SelectionManager::instance()->objectsByType(&summaryCaseCollections);
for (RimSummaryCaseCollection* summaryCaseCollection : summaryCaseCollections)
{
std::vector<RimSummaryCase*> summaryCasesFromCollection;
for (int i = 0; i < summaryCaseCollection->summaryCaseCount(); i++)
{
summaryCasesFromCollection.push_back(summaryCaseCollection->summaryCase(i));
}
RicCloseSummaryCaseFeature::deleteSummaryCases(summaryCasesFromCollection);
}
}

View File

@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
//==================================================================================================
///
//==================================================================================================
class RicCloseSummaryCaseCollectionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
};

View File

@ -34,6 +34,7 @@
#include <QAction>
CAF_CMD_SOURCE_INIT(RicCloseSummaryCaseFeature, "RicCloseSummaryCaseFeature");
@ -46,6 +47,37 @@ void RicCloseSummaryCaseFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setIcon(QIcon(":/Erase.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCloseSummaryCaseFeature::deleteSummaryCases(const std::vector<RimSummaryCase*>& cases)
{
RimProject* project = RiaApplication::instance()->project();
CVF_ASSERT(project);
RimMainPlotCollection* mainPlotColl = project->mainPlotCollection();
CVF_ASSERT(mainPlotColl);
RimSummaryPlotCollection* summaryPlotColl = mainPlotColl->summaryPlotCollection();
CVF_ASSERT(summaryPlotColl);
for (RimSummaryCase* summaryCase : cases)
{
for (RimSummaryPlot* summaryPlot : summaryPlotColl->summaryPlots)
{
summaryPlot->removeCurveAssosiatedWithCase(summaryCase);
}
summaryPlotColl->updateConnectedEditors();
RimSummaryCaseCollection* summaryCaseCollection = nullptr;
summaryCase->firstAncestorOrThisOfTypeAsserted(summaryCaseCollection);
summaryCaseCollection->deleteCase(summaryCase);
delete summaryCase;
summaryCaseCollection->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -53,6 +85,7 @@ bool RicCloseSummaryCaseFeature::isCommandEnabled()
{
std::vector<RimSummaryCase*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
return (selection.size() > 0);
}
@ -64,29 +97,6 @@ void RicCloseSummaryCaseFeature::onActionTriggered(bool isChecked)
std::vector<RimSummaryCase*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
CVF_ASSERT(selection.size() > 0);
RimProject* project = RiaApplication::instance()->project();
CVF_ASSERT(project);
RimMainPlotCollection* mainPlotColl = project->mainPlotCollection();
CVF_ASSERT(mainPlotColl);
RimSummaryPlotCollection* summaryPlotColl = mainPlotColl->summaryPlotCollection();
CVF_ASSERT(summaryPlotColl);
for (RimSummaryCase* summaryCase : selection)
{
for (RimSummaryPlot* summaryPlot : summaryPlotColl->summaryPlots)
{
summaryPlot->removeCurveAssosiatedWithCase(summaryCase);
}
summaryPlotColl->updateConnectedEditors();
RimSummaryCaseCollection* summaryCaseCollection = nullptr;
summaryCase->firstAncestorOrThisOfTypeAsserted(summaryCaseCollection);
summaryCaseCollection->deleteCase(summaryCase);
delete summaryCase;
summaryCaseCollection->updateConnectedEditors();
}
RicCloseSummaryCaseFeature::deleteSummaryCases(selection);
}

View File

@ -32,13 +32,11 @@ class RicCloseSummaryCaseFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void deleteSummaryCases(const std::vector<RimSummaryCase*>& cases);
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
private:
RimSummaryCase* selectedSummaryCase() const;
};

View File

@ -444,6 +444,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
commandIds << "RicFlyToObjectFeature";
commandIds << "RicExportCarfin";
commandIds << "RicCloseSummaryCaseFeature";
commandIds << "RicCloseSummaryCaseCollectionFeature";
// Fracture commands