#3952 Summary : Create plot if no plot exists when loading summary case

This commit is contained in:
Magne Sjaastad 2019-01-14 13:54:19 +01:00
parent 9124610020
commit 791a896be4
6 changed files with 104 additions and 31 deletions

View File

@ -2019,8 +2019,6 @@ bool RiaApplication::openFile(const QString& fileName)
if (loadingSucceded)
{
getOrCreateAndShowMainPlotWindow();
m_project->updateConnectedEditors();
}
}

View File

@ -18,7 +18,8 @@
#include "RiaImportEclipseCaseTools.h"
#include "../SummaryPlotCommands/RicNewSummaryPlotFeature.h"
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
#include "SummaryPlotCommands/RicNewSummaryCurveFeature.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
@ -47,6 +48,7 @@
#include "RimSummaryCurve.h"
#include "RimSummaryCurveCollection.h"
#include "RimSummaryCurveFilter.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RiuMainWindow.h"
@ -153,7 +155,11 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file
if (!newSumCases.empty())
{
RiuPlotMainWindowTools::setExpanded(newSumCases.back());
RimSummaryPlotCollection* summaryPlotColl = project->mainPlotCollection()->summaryPlotCollection();
RicNewSummaryCurveFeature::ensureAtLeastOnePlot(summaryPlotColl, newSumCases.front());
RiuPlotMainWindowTools::setExpanded(newSumCases.front());
}
}
}

View File

@ -18,6 +18,8 @@
#include "RicImportSummaryCasesFeature.h"
#include "SummaryPlotCommands/RicNewSummaryCurveFeature.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaPreferences.h"
@ -187,6 +189,12 @@ void RicImportSummaryCasesFeature::addSummaryCases(const std::vector<RimSummaryC
RimProject* proj = app->project();
RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr;
sumCaseColl->addCases(cases);
if (!cases.empty())
{
RicNewSummaryCurveFeature::createNewPlot(proj->mainPlotCollection->summaryPlotCollection(), cases.front());
}
sumCaseColl->updateAllRequiredEditors();
}

View File

@ -21,10 +21,10 @@
#include "RiaApplication.h"
#include "RiaColorTables.h"
#include "RiaSummaryTools.h"
#include "RimMainPlotCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RiaSummaryTools.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
@ -37,10 +37,73 @@
#include "cvfAssert.h"
#include <QAction>
#include "RiuPlotMainWindowTools.h"
CAF_CMD_SOURCE_INIT(RicNewSummaryCurveFeature, "RicNewSummaryCurveFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCurve* RicNewSummaryCurveFeature::addCurveToPlot(RimSummaryPlot* plot, RimSummaryCase* summaryCase)
{
if (plot)
{
RimSummaryCurve* newCurve = new RimSummaryCurve();
// Use same counting as RicNewSummaryEnsembleCurveSetFeature::onActionTriggered
cvf::Color3f curveColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(plot->singleColorCurveCount());
newCurve->setColor(curveColor);
plot->addCurveAndUpdate(newCurve);
if (summaryCase)
{
newCurve->setSummaryCaseY(summaryCase);
}
newCurve->setSummaryAddressY(RifEclipseSummaryAddress::fieldAddress("FOPT"));
newCurve->loadDataAndUpdate(true);
return newCurve;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryCurveFeature::ensureAtLeastOnePlot(RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase)
{
if (summaryPlotCollection && summaryCase)
{
if (summaryPlotCollection->summaryPlots.empty())
{
createNewPlot(summaryPlotCollection, summaryCase);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryCurveFeature::createNewPlot(RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase)
{
if (summaryPlotCollection && summaryCase)
{
auto plot = summaryPlotCollection->createSummaryPlotWithAutoTitle();
auto curve = RicNewSummaryCurveFeature::addCurveToPlot(plot, summaryCase);
plot->loadDataAndUpdate();
summaryPlotCollection->updateConnectedEditors();
RiuPlotMainWindowTools::setExpanded(curve);
RiuPlotMainWindowTools::selectAsCurrentItem(curve);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -60,25 +123,14 @@ void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked)
RimSummaryPlot* plot = selectedSummaryPlot();
if (plot)
{
RimSummaryCurve* newCurve = new RimSummaryCurve();
// Use same counting as RicNewSummaryEnsembleCurveSetFeature::onActionTriggered
cvf::Color3f curveColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(plot->singleColorCurveCount());
newCurve->setColor(curveColor);
plot->addCurveAndUpdate(newCurve);
RimSummaryCase* defaultCase = nullptr;
if (project->activeOilField()->summaryCaseMainCollection()->summaryCaseCount() > 0)
{
defaultCase = project->activeOilField()->summaryCaseMainCollection()->summaryCase(0);
newCurve->setSummaryCaseY(defaultCase);
newCurve->setSummaryAddressY(RifEclipseSummaryAddress::fieldAddress("FOPT"));
newCurve->loadDataAndUpdate(true);
}
RimSummaryCurve* newCurve = addCurveToPlot(plot, defaultCase);
plot->updateConnectedEditors();
RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve);

View File

@ -23,6 +23,9 @@
#include <vector>
class RimSummaryPlot;
class RimSummaryCase;
class RimSummaryCurve;
class RimSummaryPlotCollection;
//==================================================================================================
///
@ -30,6 +33,12 @@ class RimSummaryPlot;
class RicNewSummaryCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static RimSummaryCurve* addCurveToPlot(RimSummaryPlot* plot, RimSummaryCase* summaryCase);
static void ensureAtLeastOnePlot(RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase);
static void createNewPlot(RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase);
protected:
// Overrides
bool isCommandEnabled() override;

View File

@ -1192,7 +1192,7 @@ void RimProject::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QS
if (uiConfigName == "PlotWindow")
{
{
auto itemCollection = uiTreeOrdering.add("Input case data", ":/Folder.png");
auto itemCollection = uiTreeOrdering.add("Cases", ":/Folder.png");
RimOilField* oilField = activeOilField();
if (oilField)
@ -1210,7 +1210,7 @@ void RimProject::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QS
if (mainPlotCollection)
{
auto itemCollection = uiTreeOrdering.add("Plot definitions", ":/Folder.png");
auto itemCollection = uiTreeOrdering.add("Plots", ":/Folder.png");
if (mainPlotCollection->summaryPlotCollection())
{
itemCollection->add(mainPlotCollection->summaryPlotCollection());