mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-23 23:13:39 -06:00
98 lines
3.4 KiB
C++
98 lines
3.4 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2016- 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 "RicNewSummaryPlotFeature.h"
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RimMainPlotCollection.h"
|
|
#include "RimProject.h"
|
|
#include "RimSummaryCurveFilter.h"
|
|
#include "RimSummaryPlot.h"
|
|
#include "RimSummaryPlotCollection.h"
|
|
|
|
#include "RiuMainPlotWindow.h"
|
|
|
|
#include <QAction>
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
CAF_CMD_SOURCE_INIT(RicNewSummaryPlotFeature, "RicNewSummaryPlotFeature");
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicNewSummaryPlotFeature::isCommandEnabled()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicNewSummaryPlotFeature::onActionTriggered(bool isChecked)
|
|
{
|
|
RimProject* project = RiaApplication::instance()->project();
|
|
CVF_ASSERT(project);
|
|
|
|
RimMainPlotCollection* mainPlotColl = project->mainPlotCollection();
|
|
CVF_ASSERT(mainPlotColl);
|
|
|
|
RimSummaryPlotCollection* summaryPlotColl = mainPlotColl->summaryPlotCollection();
|
|
CVF_ASSERT(summaryPlotColl);
|
|
|
|
std::vector<RimSummaryCase*> cases;
|
|
project->allSummaryCases(cases);
|
|
|
|
createNewSummaryPlot(summaryPlotColl, cases.size() > 0 ? cases[0] : NULL);
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicNewSummaryPlotFeature::setupActionLook(QAction* actionToSetup)
|
|
{
|
|
actionToSetup->setText("New Summary Plot");
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicNewSummaryPlotFeature::createNewSummaryPlot(RimSummaryPlotCollection* summaryPlotColl, RimSummaryCase* summaryCase)
|
|
{
|
|
RimSummaryPlot* plot = new RimSummaryPlot();
|
|
summaryPlotColl->m_summaryPlots().push_back(plot);
|
|
|
|
plot->setDescription(QString("Summary Plot %1").arg(summaryPlotColl->m_summaryPlots.size()));
|
|
|
|
RimSummaryCurveFilter* newCurveFilter = new RimSummaryCurveFilter();
|
|
|
|
if (summaryCase)
|
|
{
|
|
newCurveFilter->createCurves(summaryCase, "F*PT");
|
|
}
|
|
|
|
plot->addCurveFilter(newCurveFilter);
|
|
|
|
summaryPlotColl->updateConnectedEditors();
|
|
plot->loadDataAndUpdate();
|
|
|
|
RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurveFilter);
|
|
}
|