mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4003 Use the preferences settings when creating default summary plots.
Refactored to make assigning default curve appearance easier.
This commit is contained in:
@@ -28,6 +28,9 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTables.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
#include "RimSummaryCase.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -36,6 +39,27 @@ RimSummaryCurve* RicSummaryPlotFeatureImpl::addDefaultCurveToPlot(RimSummaryPlot
|
||||
{
|
||||
if (plot)
|
||||
{
|
||||
RifEclipseSummaryAddress defaultAddressToUse;
|
||||
|
||||
QString curvesTextFilter = RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter;
|
||||
QStringList curveFilters = curvesTextFilter.split(";", QString::SkipEmptyParts);
|
||||
|
||||
if ( curveFilters.size() )
|
||||
{
|
||||
const std::set<RifEclipseSummaryAddress>& addrs = summaryCase->summaryReader()->allResultAddresses();
|
||||
|
||||
for ( const auto & addr : addrs )
|
||||
{
|
||||
const QString& filter = curveFilters[0];
|
||||
{
|
||||
if ( addr.isUiTextMatchingFilterText(filter) )
|
||||
{
|
||||
defaultAddressToUse = addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RimSummaryCurve* newCurve = new RimSummaryCurve();
|
||||
|
||||
// Use same counting as RicNewSummaryEnsembleCurveSetFeature::onActionTriggered
|
||||
@@ -49,7 +73,7 @@ RimSummaryCurve* RicSummaryPlotFeatureImpl::addDefaultCurveToPlot(RimSummaryPlot
|
||||
newCurve->setSummaryCaseY(summaryCase);
|
||||
}
|
||||
|
||||
newCurve->setSummaryAddressYAndApplyInterpolation(RifEclipseSummaryAddress::fieldAddress("FOPT"));
|
||||
newCurve->setSummaryAddressYAndApplyInterpolation(defaultAddressToUse);
|
||||
|
||||
return newCurve;
|
||||
}
|
||||
@@ -57,6 +81,45 @@ RimSummaryCurve* RicSummaryPlotFeatureImpl::addDefaultCurveToPlot(RimSummaryPlot
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCurve*> RicSummaryPlotFeatureImpl::addDefaultCurvesToPlot(RimSummaryPlot* plot, RimSummaryCase* summaryCase)
|
||||
{
|
||||
std::vector<RimSummaryCurve*> defaultCurves;
|
||||
|
||||
QString curvesTextFilter = RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter;
|
||||
QStringList curveFilters = curvesTextFilter.split(";", QString::SkipEmptyParts);
|
||||
|
||||
const std::set<RifEclipseSummaryAddress>& addrs = summaryCase->summaryReader()->allResultAddresses();
|
||||
std::vector<RifEclipseSummaryAddress> curveAddressesToUse;
|
||||
|
||||
for (const auto & addr : addrs)
|
||||
{
|
||||
for (const QString& filter: curveFilters)
|
||||
{
|
||||
if ( addr.isUiTextMatchingFilterText(filter) )
|
||||
{
|
||||
curveAddressesToUse.push_back(addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto & addr : curveAddressesToUse)
|
||||
{
|
||||
RimSummaryCurve* newCurve = new RimSummaryCurve();
|
||||
plot->addCurveNoUpdate(newCurve);
|
||||
if (summaryCase)
|
||||
{
|
||||
newCurve->setSummaryCaseY(summaryCase);
|
||||
}
|
||||
newCurve->setSummaryAddressYAndApplyInterpolation(addr);
|
||||
defaultCurves.push_back(newCurve);
|
||||
}
|
||||
|
||||
return defaultCurves;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -82,13 +145,18 @@ void RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( RimSummaryCase* summar
|
||||
{
|
||||
auto plot = summaryPlotCollection->createSummaryPlotWithAutoTitle();
|
||||
|
||||
auto curve = RicSummaryPlotFeatureImpl::addDefaultCurveToPlot(plot, summaryCase);
|
||||
std::vector<RimSummaryCurve*> curves = RicSummaryPlotFeatureImpl::addDefaultCurvesToPlot(plot, summaryCase);
|
||||
|
||||
plot->applyDefaultCurveAppearances();
|
||||
plot->loadDataAndUpdate();
|
||||
|
||||
summaryPlotCollection->updateConnectedEditors();
|
||||
|
||||
RiuPlotMainWindowTools::setExpanded(curve);
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(curve);
|
||||
caf::PdmObject* itemToSelect = plot;
|
||||
if (curves.size()) itemToSelect = curves[0];
|
||||
|
||||
RiuPlotMainWindowTools::setExpanded(itemToSelect);
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(itemToSelect);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user