#4003 Refactoring to prepare for preferences based default summary plot curves

This commit is contained in:
Jacob Støren
2019-08-09 09:54:55 +02:00
parent 4ed30ad4af
commit e915c8e18c
13 changed files with 163 additions and 91 deletions

View File

@@ -141,6 +141,8 @@ RiaPreferences::RiaPreferences(void)
CAF_PDM_InitField(&gridImportMode, "gridImportMode", SummaryRestartFilesImportModeType(RiaPreferences::NOT_IMPORT), "Default Grid Import Option", "", "", "");
CAF_PDM_InitField(&summaryEnsembleImportMode, "summaryEnsembleImportMode", SummaryRestartFilesImportModeType(RiaPreferences::IMPORT), "Default Ensemble Summary Import Option", "", "", "");
CAF_PDM_InitField(&defaultSummaryCurvesTextFilter, "defaultSummaryCurvesTextFilter", QString("FOPT"), "Default Summary Curves", "", "Semicolon separated list of filters used to create curves in new summary plots", "");
CAF_PDM_InitFieldNoDefault(&m_holoLensExportFolder, "holoLensExportFolder", "HoloLens Export Folder", "", "", "");
m_holoLensExportFolder.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
m_holoLensExportFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
@@ -283,6 +285,11 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
caf::PdmUiGroup* group = restartBehaviourGroup->addNewGroup("Origin Ensemble Summary Files");
group->add(&summaryEnsembleImportMode);
}
{
caf::PdmUiGroup* summaryPlotsGroup = uiOrdering.addNewGroup("Summary Plots");
summaryPlotsGroup->add(&defaultSummaryCurvesTextFilter);
}
}
else if (uiConfigName == m_tabNames[2])
{

View File

@@ -110,6 +110,8 @@ public: // Pdm Fields
caf::PdmField<SummaryRestartFilesImportModeType> gridImportMode;
caf::PdmField<SummaryRestartFilesImportModeType> summaryEnsembleImportMode;
caf::PdmField<QString> defaultSummaryCurvesTextFilter;
caf::PdmField<bool> holoLensDisableCertificateVerification;
caf::PdmField<QString> csvTextExportFieldSeparator;

View File

@@ -22,6 +22,7 @@
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
#include "SummaryPlotCommands/RicNewSummaryCurveFeature.h"
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
#include "RiaApplication.h"
#include "RiaGuiApplication.h"
@@ -165,7 +166,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& file
{
RimSummaryPlotCollection* summaryPlotColl = project->mainPlotCollection()->summaryPlotCollection();
RicNewSummaryCurveFeature::ensureAtLeastOnePlot(summaryPlotColl, newSumCases.front());
RicSummaryPlotFeatureImpl::ensureAtLeastOnePlot(summaryPlotColl, newSumCases.front());
RiuPlotMainWindowTools::setExpanded(newSumCases.front());
}

View File

@@ -44,6 +44,7 @@
#include "SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h"
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
#include "cafProgressInfo.h"
#include "cafSelectionManagerTools.h"
@@ -83,7 +84,7 @@ void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked)
addSummaryCases(cases);
if (!cases.empty())
{
createNewPlot(cases.front());
RicSummaryPlotFeatureImpl::createDefaultSummaryPlot(cases.front());
}
addCasesToGroupIfRelevant(cases);
@@ -132,7 +133,7 @@ bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(const QStri
addSummaryCases(*cases);
if (!cases->empty())
{
createNewPlot(cases->back());
RicSummaryPlotFeatureImpl::createDefaultSummaryPlot(cases->back());
}
RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow();
@@ -232,17 +233,6 @@ void RicImportSummaryCasesFeature::addCasesToGroupIfRelevant(const std::vector<R
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicImportSummaryCasesFeature::createNewPlot(RimSummaryCase* summaryCase)
{
RiaApplication* app = RiaApplication::instance();
RimProject* proj = app->project();
RicNewSummaryCurveFeature::createNewPlot(proj->mainPlotCollection->summaryPlotCollection(), summaryCase);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -42,7 +42,6 @@ public:
static bool createSummaryCasesFromFiles(const QStringList& fileName, std::vector<RimSummaryCase*>* newCases, bool ensembleOrGroup = false);
static void addSummaryCases(const std::vector<RimSummaryCase*> cases);
static void addCasesToGroupIfRelevant(const std::vector<RimSummaryCase*> cases);
static void createNewPlot(RimSummaryCase* summaryCase);
static QStringList runRecursiveSummaryCaseFileSearchDialog(const QString& dialogTitle, const QString& pathCacheName);

View File

@@ -3,6 +3,7 @@ set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotFeatureImpl.h
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotFeature.h
@@ -46,6 +47,7 @@ set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotFeatureImpl.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotFeature.cpp

View File

@@ -38,69 +38,10 @@
#include <QAction>
#include "RiuPlotMainWindowTools.h"
#include "RicSummaryPlotFeatureImpl.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->addCurveNoUpdate(newCurve);
if (summaryCase)
{
newCurve->setSummaryCaseY(summaryCase);
}
newCurve->setSummaryAddressYAndApplyInterpolation(RifEclipseSummaryAddress::fieldAddress("FOPT"));
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);
}
}
//--------------------------------------------------------------------------------------------------
///
@@ -128,7 +69,7 @@ void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked)
defaultCase = project->activeOilField()->summaryCaseMainCollection()->summaryCase(0);
}
RimSummaryCurve* newCurve = addCurveToPlot(plot, defaultCase);
RimSummaryCurve* newCurve = RicSummaryPlotFeatureImpl::addDefaultCurveToPlot(plot, defaultCase);
plot->loadDataAndUpdate();
plot->updateConnectedEditors();

View File

@@ -35,9 +35,6 @@ 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

View File

@@ -145,11 +145,16 @@ void RicNewSummaryPlotFeature::setupActionLook(QAction* actionToSetup)
actionToSetup->setIcon(QIcon(":/SummaryPlotLight16x16.png"));
}
//==================================================================================================
///
//==================================================================================================
#include "RiuPlotMainWindowTools.h"
#include "RicNewSummaryCurveFeature.h"
#include "RimMainPlotCollection.h"
#include "RicSummaryPlotFeatureImpl.h"
CAF_CMD_SOURCE_INIT(RicNewSummaryPlotDirectFeature, "RicNewSummaryPlotDirectFeature");
CAF_CMD_SOURCE_INIT(RicNewDefaultSummaryPlotFeature, "RicNewDefaultSummaryPlotFeature");
std::pair<RimSummaryPlotCollection*, std::vector<RimSummaryCase*>> extractSumPlotCollectionOrSelectedSumCasesFromSelection()
@@ -177,7 +182,7 @@ std::pair<RimSummaryPlotCollection*, std::vector<RimSummaryCase*>> extractSumPlo
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewSummaryPlotDirectFeature::isCommandEnabled()
bool RicNewDefaultSummaryPlotFeature::isCommandEnabled()
{
auto sumPlotSumCasesPair = extractSumPlotCollectionOrSelectedSumCasesFromSelection();
@@ -187,7 +192,7 @@ bool RicNewSummaryPlotDirectFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryPlotDirectFeature::onActionTriggered(bool isChecked)
void RicNewDefaultSummaryPlotFeature::onActionTriggered(bool isChecked)
{
auto sumPlotSumCasesPair = extractSumPlotCollectionOrSelectedSumCasesFromSelection();
@@ -203,7 +208,7 @@ void RicNewSummaryPlotDirectFeature::onActionTriggered(bool isChecked)
if (sumCaseVector.size())
{
RicNewSummaryCurveFeature::addCurveToPlot(newPlot, sumCaseVector[0]);
RicSummaryPlotFeatureImpl::addDefaultCurveToPlot(newPlot, sumCaseVector[0]);
}
}
else if (sumPlotSumCasesPair.second.size())
@@ -212,7 +217,7 @@ void RicNewSummaryPlotDirectFeature::onActionTriggered(bool isChecked)
for (RimSummaryCase* sumCase : sumPlotSumCasesPair.second)
{
RicNewSummaryCurveFeature::addCurveToPlot(newPlot, sumCase);
RicSummaryPlotFeatureImpl::addDefaultCurveToPlot(newPlot, sumCase);
}
}
@@ -230,7 +235,7 @@ void RicNewSummaryPlotDirectFeature::onActionTriggered(bool isChecked)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryPlotDirectFeature::setupActionLook(QAction* actionToSetup)
void RicNewDefaultSummaryPlotFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("New Summary Plot");
actionToSetup->setIcon(QIcon(":/SummaryPlotLight16x16.png"));

View File

@@ -41,7 +41,7 @@ protected:
//==================================================================================================
///
//==================================================================================================
class RicNewSummaryPlotDirectFeature : public caf::CmdFeature
class RicNewDefaultSummaryPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

View File

@@ -0,0 +1,95 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor 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 "RicSummaryPlotFeatureImpl.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RimProject.h"
#include "RimMainPlotCollection.h"
#include "RiuPlotMainWindowTools.h"
#include "RiaApplication.h"
#include "RiaColorTables.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCurve* RicSummaryPlotFeatureImpl::addDefaultCurveToPlot(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->addCurveNoUpdate(newCurve);
if (summaryCase)
{
newCurve->setSummaryCaseY(summaryCase);
}
newCurve->setSummaryAddressYAndApplyInterpolation(RifEclipseSummaryAddress::fieldAddress("FOPT"));
return newCurve;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotFeatureImpl::ensureAtLeastOnePlot(RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase)
{
if (summaryPlotCollection && summaryCase)
{
if (summaryPlotCollection->summaryPlots.empty())
{
createDefaultSummaryPlot(summaryCase);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( RimSummaryCase* summaryCase)
{
RimSummaryPlotCollection* summaryPlotCollection = RiaApplication::instance()->project()->mainPlotCollection->summaryPlotCollection();
if (summaryPlotCollection && summaryCase)
{
auto plot = summaryPlotCollection->createSummaryPlotWithAutoTitle();
auto curve = RicSummaryPlotFeatureImpl::addDefaultCurveToPlot(plot, summaryCase);
plot->loadDataAndUpdate();
summaryPlotCollection->updateConnectedEditors();
RiuPlotMainWindowTools::setExpanded(curve);
RiuPlotMainWindowTools::selectAsCurrentItem(curve);
}
}

View File

@@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor 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
class RimSummaryCurve;
class RimSummaryPlot;
class RimSummaryCase;
class RimSummaryPlotCollection;
class RicSummaryPlotFeatureImpl
{
public:
static RimSummaryCurve* addDefaultCurveToPlot(RimSummaryPlot* plot, RimSummaryCase* summaryCase);
static void ensureAtLeastOnePlot(RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase);
static void createDefaultSummaryPlot(RimSummaryCase* summaryCase);
};

View File

@@ -477,7 +477,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicPasteAsciiDataToSummaryPlotFeature";
menuBuilder << "Separator";
menuBuilder << "RicNewSummaryPlotFeature";
menuBuilder << "RicNewSummaryPlotDirectFeature";
menuBuilder << "RicNewDefaultSummaryPlotFeature";
menuBuilder << "Separator";
menuBuilder << "RicShowSummaryCurveCalculatorFeature";
}
@@ -543,7 +543,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "Separator";
menuBuilder << "RicEditSummaryPlotFeature";
menuBuilder << "RicNewSummaryPlotFeature";
menuBuilder << "RicNewSummaryPlotDirectFeature";
menuBuilder << "RicNewDefaultSummaryPlotFeature";
menuBuilder << "RicDuplicateSummaryPlotFeature";
menuBuilder << "RicNewSummaryCurveFeature";
menuBuilder << "RicNewSummaryEnsembleCurveSetFeature";
@@ -623,7 +623,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder.addSeparator();
menuBuilder << "RicNewDerivedEnsembleFeature";
menuBuilder << "RicNewSummaryPlotFeature";
menuBuilder << "RicNewSummaryPlotDirectFeature";
menuBuilder << "RicNewDefaultSummaryPlotFeature";
menuBuilder << "RicNewSummaryCrossPlotFeature";
menuBuilder.addSeparator();
menuBuilder << "RicConvertGroupToEnsembleFeature";
@@ -639,7 +639,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder.subMenuEnd();
menuBuilder.addSeparator();
menuBuilder << "RicNewSummaryPlotFeature";
menuBuilder << "RicNewSummaryPlotDirectFeature";
menuBuilder << "RicNewDefaultSummaryPlotFeature";
menuBuilder << "RicNewSummaryCrossPlotFeature";
menuBuilder.addSeparator();
@@ -824,7 +824,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicNewDerivedEnsembleFeature";
menuBuilder << "RicNewSummaryPlotFeature";
menuBuilder << "RicNewSummaryPlotDirectFeature";
menuBuilder << "RicNewDefaultSummaryPlotFeature";
menuBuilder << "RicNewSummaryCrossPlotFeature";
menuBuilder << "RicSummaryCurveSwitchAxisFeature";
menuBuilder.addSeparator();