#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) if (loadingSucceded)
{ {
getOrCreateAndShowMainPlotWindow(); getOrCreateAndShowMainPlotWindow();
m_project->updateConnectedEditors();
} }
} }

View File

@ -18,7 +18,8 @@
#include "RiaImportEclipseCaseTools.h" #include "RiaImportEclipseCaseTools.h"
#include "../SummaryPlotCommands/RicNewSummaryPlotFeature.h" #include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
#include "SummaryPlotCommands/RicNewSummaryCurveFeature.h"
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RiaLogging.h" #include "RiaLogging.h"
@ -47,6 +48,7 @@
#include "RimSummaryCurve.h" #include "RimSummaryCurve.h"
#include "RimSummaryCurveCollection.h" #include "RimSummaryCurveCollection.h"
#include "RimSummaryCurveFilter.h" #include "RimSummaryCurveFilter.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h" #include "RimSummaryPlotCollection.h"
#include "RiuMainWindow.h" #include "RiuMainWindow.h"
@ -153,7 +155,11 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file
if (!newSumCases.empty()) 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 "RicImportSummaryCasesFeature.h"
#include "SummaryPlotCommands/RicNewSummaryCurveFeature.h"
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RiaLogging.h" #include "RiaLogging.h"
#include "RiaPreferences.h" #include "RiaPreferences.h"
@ -187,6 +189,12 @@ void RicImportSummaryCasesFeature::addSummaryCases(const std::vector<RimSummaryC
RimProject* proj = app->project(); RimProject* proj = app->project();
RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr;
sumCaseColl->addCases(cases); sumCaseColl->addCases(cases);
if (!cases.empty())
{
RicNewSummaryCurveFeature::createNewPlot(proj->mainPlotCollection->summaryPlotCollection(), cases.front());
}
sumCaseColl->updateAllRequiredEditors(); sumCaseColl->updateAllRequiredEditors();
} }

View File

@ -1,17 +1,17 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2016- Statoil ASA // Copyright (C) 2016- Statoil ASA
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@ -21,10 +21,10 @@
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RiaColorTables.h" #include "RiaColorTables.h"
#include "RiaSummaryTools.h"
#include "RimMainPlotCollection.h" #include "RimMainPlotCollection.h"
#include "RimOilField.h" #include "RimOilField.h"
#include "RimProject.h" #include "RimProject.h"
#include "RiaSummaryTools.h"
#include "RimSummaryCaseMainCollection.h" #include "RimSummaryCaseMainCollection.h"
#include "RimSummaryCurve.h" #include "RimSummaryCurve.h"
#include "RimSummaryPlot.h" #include "RimSummaryPlot.h"
@ -37,20 +37,83 @@
#include "cvfAssert.h" #include "cvfAssert.h"
#include <QAction> #include <QAction>
#include "RiuPlotMainWindowTools.h"
CAF_CMD_SOURCE_INIT(RicNewSummaryCurveFeature, "RicNewSummaryCurveFeature"); 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);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewSummaryCurveFeature::isCommandEnabled() bool RicNewSummaryCurveFeature::isCommandEnabled()
{ {
return (selectedSummaryPlot()); return (selectedSummaryPlot());
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked) void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked)
{ {
@ -60,25 +123,14 @@ void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked)
RimSummaryPlot* plot = selectedSummaryPlot(); RimSummaryPlot* plot = selectedSummaryPlot();
if (plot) if (plot)
{ {
RimSummaryCurve* newCurve = new RimSummaryCurve(); RimSummaryCase* defaultCase = nullptr;
// 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) if (project->activeOilField()->summaryCaseMainCollection()->summaryCaseCount() > 0)
{ {
defaultCase = project->activeOilField()->summaryCaseMainCollection()->summaryCase(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(); plot->updateConnectedEditors();
RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve); RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve);
@ -89,7 +141,7 @@ void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked)
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicNewSummaryCurveFeature::setupActionLook(QAction* actionToSetup) void RicNewSummaryCurveFeature::setupActionLook(QAction* actionToSetup)
{ {
@ -98,13 +150,13 @@ void RicNewSummaryCurveFeature::setupActionLook(QAction* actionToSetup)
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimSummaryPlot* RicNewSummaryCurveFeature::selectedSummaryPlot() const RimSummaryPlot* RicNewSummaryCurveFeature::selectedSummaryPlot() const
{ {
RimSummaryPlot* sumPlot = nullptr; RimSummaryPlot* sumPlot = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem()); caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
if (selObj) if (selObj)
{ {
sumPlot = RiaSummaryTools::parentSummaryPlot(selObj); sumPlot = RiaSummaryTools::parentSummaryPlot(selObj);

View File

@ -23,6 +23,9 @@
#include <vector> #include <vector>
class RimSummaryPlot; class RimSummaryPlot;
class RimSummaryCase;
class RimSummaryCurve;
class RimSummaryPlotCollection;
//================================================================================================== //==================================================================================================
/// ///
@ -30,6 +33,12 @@ class RimSummaryPlot;
class RicNewSummaryCurveFeature : public caf::CmdFeature class RicNewSummaryCurveFeature : public caf::CmdFeature
{ {
CAF_CMD_HEADER_INIT; 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: protected:
// Overrides // Overrides
bool isCommandEnabled() override; bool isCommandEnabled() override;

View File

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