mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
#1728 Curves assisiated with closed summary case(s) are deleted
This commit is contained in:
parent
7455415f88
commit
1ae9978214
@ -1,6 +1,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016- Statoil ASA
|
||||
// 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
|
||||
@ -17,19 +17,29 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicCloseSummaryCaseFeature.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicCloseSummaryCaseFeature, "RicCloseSummaryCaseFeature");
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCloseSummaryCaseFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Close Summary Plot");
|
||||
@ -41,26 +51,11 @@ void RicCloseSummaryCaseFeature::setupActionLook(QAction* actionToSetup)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCloseSummaryCaseFeature::isCommandEnabled()
|
||||
{
|
||||
return selectedSummaryCase() != NULL;
|
||||
std::vector<RimSummaryCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
return (selection.size() > 0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCase* RicCloseSummaryCaseFeature::selectedSummaryCase() const
|
||||
{
|
||||
std::vector<RimSummaryCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() > 0)
|
||||
{
|
||||
return selection[0];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -68,16 +63,30 @@ void RicCloseSummaryCaseFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
std::vector<RimSummaryCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
assert(selection.size() > 0);
|
||||
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)
|
||||
{
|
||||
RimSummaryCaseCollection* summaryCaseCollection = NULL;
|
||||
summaryCase->firstAncestorOrThisOfType(summaryCaseCollection);
|
||||
CVF_ASSERT(summaryCaseCollection);
|
||||
for (RimSummaryPlot* summaryPlot : summaryPlotColl->summaryPlots)
|
||||
{
|
||||
summaryPlot->removeCurveAssosiatedWithCase(summaryCase);
|
||||
}
|
||||
summaryPlotColl->updateConnectedEditors();
|
||||
|
||||
RimSummaryCaseCollection* summaryCaseCollection = nullptr;
|
||||
summaryCase->firstAncestorOrThisOfTypeAsserted(summaryCaseCollection);
|
||||
|
||||
summaryCaseCollection->deleteCase(summaryCase);
|
||||
delete summaryCase;
|
||||
summaryCaseCollection->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,33 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimSummaryCase;
|
||||
class RimSummaryPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicCloseSummaryCaseFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
@ -11,10 +35,9 @@ public:
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered(bool isChecked);
|
||||
virtual void setupActionLook(QAction* actionToSetup);
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered(bool isChecked) override;
|
||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||
private:
|
||||
RimSummaryCase* selectedSummaryCase() const;
|
||||
};
|
||||
|
||||
|
@ -48,6 +48,8 @@
|
||||
#include "qwt_abstract_legend.h"
|
||||
#include "qwt_legend.h"
|
||||
|
||||
#include "vector"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimSummaryPlot, "SummaryPlot");
|
||||
|
||||
@ -759,6 +761,41 @@ void RimSummaryPlot::addCurve(RimSummaryCurve* curve)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::removeCurve(RimSummaryCurve* curve)
|
||||
{
|
||||
if (curve)
|
||||
{
|
||||
m_summaryCurves.removeChildObject(curve);
|
||||
delete curve;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::removeCurveAssosiatedWithCase(RimSummaryCase* summaryCase)
|
||||
{
|
||||
std::vector<RimSummaryCurve*> summaryCurvesToDelete;
|
||||
|
||||
for (RimSummaryCurve* summaryCurve : m_summaryCurves)
|
||||
{
|
||||
if (!summaryCurve) continue;
|
||||
if (!summaryCurve->summaryCase()) continue;
|
||||
|
||||
if (summaryCurve->summaryCase() == summaryCase)
|
||||
{
|
||||
summaryCurvesToDelete.push_back(summaryCurve);
|
||||
}
|
||||
}
|
||||
for (RimSummaryCurve* summaryCurve : summaryCurvesToDelete)
|
||||
{
|
||||
removeCurve(summaryCurve);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
class RiuSummaryQwtPlot;
|
||||
class RimSummaryCurve;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCurveFilter;
|
||||
class RimSummaryYAxisProperties;
|
||||
class RimSummaryTimeAxisProperties;
|
||||
@ -59,6 +60,8 @@ public:
|
||||
|
||||
void addCurve(RimSummaryCurve* curve);
|
||||
void addCurveFilter(RimSummaryCurveFilter* curveFilter);
|
||||
void removeCurve(RimSummaryCurve* curve);
|
||||
void removeCurveAssosiatedWithCase(RimSummaryCase* summaryCase);
|
||||
|
||||
void addGridTimeHistoryCurve(RimGridTimeHistoryCurve* curve);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user