Create cross plot menu from list of addresses in preferences

This commit is contained in:
Magne Sjaastad 2023-10-09 13:26:14 +02:00
parent ececc3ae47
commit 51fe80b897
15 changed files with 467 additions and 72 deletions

View File

@ -111,6 +111,15 @@ RiaPreferencesSummary::RiaPreferencesSummary()
"" );
CAF_PDM_InitFieldNoDefault( &m_defaultSummaryPlot, "defaultSummaryPlot", "Create Plot On Summary Data Import" );
CAF_PDM_InitField( &m_crossPlotAddressCombinations,
"CrossPlotAddressCombinations",
QString( "FWIR FOPT;FGOR FOPT;FWCT FOPT;FGLIR FOPR" ),
"Cross Plot Addresses [Y-adr X-adr]",
"",
"Semicolon separated list used to create cross plot curves. Based on selection, the names will be changed to "
"corresponing well or group vector names",
"" );
CAF_PDM_InitField( &m_selectDefaultTemplates, "selectDefaultTemplate", false, "", "", "Select Default Templates" );
m_selectDefaultTemplates.xmlCapability()->disableIO();
m_selectDefaultTemplates.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
@ -282,6 +291,8 @@ void RiaPreferencesSummary::appendItemsToPlottingGroup( caf::PdmUiOrdering& uiOr
break;
}
uiOrdering.add( &m_crossPlotAddressCombinations );
auto historyCurveGroup = uiOrdering.addNewGroup( "History Vectors" );
historyCurveGroup->add( &m_defaultSummaryHistoryCurveStyle );
@ -369,6 +380,14 @@ bool RiaPreferencesSummary::appendHistoryVectors() const
return m_appendHistoryVectors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaPreferencesSummary::crossPlotAddressCombinations() const
{
return m_crossPlotAddressCombinations;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -107,6 +107,8 @@ public:
bool colorCurvesByPhase() const;
bool appendHistoryVectors() const;
QString crossPlotAddressCombinations() const;
SummaryHistoryCurveStyleMode defaultSummaryHistoryCurveStyle() const;
RiaDefines::ColumnCount defaultMultiPlotColumnCount() const;
@ -132,6 +134,7 @@ private:
caf::PdmField<SummaryRestartFilesImportModeType> m_summaryEnsembleImportMode;
caf::PdmField<QString> m_defaultSummaryCurvesTextFilter;
caf::PdmField<QString> m_crossPlotAddressCombinations;
caf::PdmField<SummaryHistoryCurveStyleModeType> m_defaultSummaryHistoryCurveStyle;
caf::PdmField<bool> m_curveColorByPhase;
caf::PdmField<bool> m_appendHistoryVectors;

View File

@ -22,6 +22,7 @@
#include "SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h"
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
#include "RiaPreferencesSummary.h"
#include "RiaSummaryAddressAnalyzer.h"
#include "RiaSummaryTools.h"
@ -29,7 +30,6 @@
#include "RifReaderEclipseSummary.h"
#include "RifSummaryReaderInterface.h"
#include "RiaPreferencesSummary.h"
#include "RimEnsembleCurveSet.h"
#include "RimEnsembleCurveSetCollection.h"
#include "RimMainPlotCollection.h"
@ -40,6 +40,7 @@
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveAppearanceCalculator.h"
#include "RimSummaryMultiPlot.h"
#include "RimSummaryMultiPlotCollection.h"
#include "RimSummaryPlot.h"
@ -619,6 +620,41 @@ RimSummaryPlot* RicSummaryPlotBuilder::createPlot( const std::set<RifEclipseSumm
return plot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot* RicSummaryPlotBuilder::createCrossPlot( const std::vector<RiaSummaryCurveAddress>& addresses,
const std::vector<RimSummaryCase*>& summaryCases,
const std::vector<RimSummaryCaseCollection*>& ensembles )
{
auto* summaryPlot = new RimSummaryPlot();
summaryPlot->enableAutoPlotTitle( true );
for ( const auto& addr : addresses )
{
for ( const auto ensemble : ensembles )
{
if ( !ensemble ) continue;
auto curveSet = addNewEnsembleCurve( summaryPlot, addr, ensemble );
curveSet->findOrAssignBottomAxisX( RiuPlotAxis::defaultBottomForSummaryVectors() );
}
for ( const auto summaryCase : summaryCases )
{
if ( !summaryCase ) continue;
addNewSummaryCurve( summaryPlot, addr, summaryCase );
}
}
summaryPlot->applyDefaultCurveAppearances();
summaryPlot->loadDataAndUpdate();
summaryPlot->zoomAll();
return summaryPlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -633,6 +669,7 @@ void RicSummaryPlotBuilder::appendCurvesToPlot( RimSummaryPlot*
{
auto curveSet = createCurveSet( ensemble, addr );
summaryPlot->ensembleCurveSetCollection()->addCurveSet( curveSet );
curveSet->setLeftOrRightAxisY( RiuPlotAxis::defaultLeft() );
}
for ( const auto summaryCase : summaryCases )
@ -642,3 +679,64 @@ void RicSummaryPlotBuilder::appendCurvesToPlot( RimSummaryPlot*
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEnsembleCurveSet* RicSummaryPlotBuilder::addNewEnsembleCurve( RimSummaryPlot* summaryPlot,
const RiaSummaryCurveAddress& curveAddress,
RimSummaryCaseCollection* ensemble )
{
auto* curveSet = new RimEnsembleCurveSet();
curveSet->setSummaryCaseCollection( ensemble );
curveSet->setCurveAddress( curveAddress );
cvf::Color3f curveColor =
RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( curveSet->summaryAddressY(),
static_cast<int>(
summaryPlot->ensembleCurveSetCollection()->curveSetCount() ) );
auto adr = curveSet->summaryAddressY();
if ( adr.isHistoryVector() ) curveColor = RiaPreferencesSummary::current()->historyCurveContrastColor();
curveSet->setColor( curveColor );
summaryPlot->ensembleCurveSetCollection()->addCurveSet( curveSet );
curveSet->setLeftOrRightAxisY( RiuPlotAxis::defaultLeft() );
curveSet->setBottomOrTopAxisX( RiuPlotAxis::defaultBottomForSummaryVectors() );
summaryPlot->curvesChanged.send();
return curveSet;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCurve* RicSummaryPlotBuilder::addNewSummaryCurve( RimSummaryPlot* summaryPlot,
const RiaSummaryCurveAddress& curveAddress,
RimSummaryCase* summaryCase )
{
auto curve = new RimSummaryCurve();
curve->setSummaryCaseY( summaryCase );
curve->setSummaryAddressY( curveAddress.summaryAddressY() );
curve->setSummaryCaseX( summaryCase );
curve->setSummaryAddressX( curveAddress.summaryAddressX() );
if ( curveAddress.summaryAddressX().category() != SummaryCategory::SUMMARY_TIME )
{
curve->setAxisTypeX( RiaDefines::HorizontalAxisType::SUMMARY_VECTOR );
}
summaryPlot->addCurveNoUpdate( curve );
if ( curveAddress.summaryAddressX().category() != SummaryCategory::SUMMARY_TIME )
{
summaryPlot->findOrAssignPlotAxisX( curve );
}
return curve;
}

View File

@ -27,6 +27,7 @@ class RimSummaryPlot;
class RimEnsembleCurveSet;
class RimSummaryCurve;
class RimSummaryMultiPlot;
class RiaSummaryCurveAddress;
namespace caf
{
@ -90,11 +91,21 @@ public:
const std::vector<RimSummaryCase*>& summaryCases,
const std::vector<RimSummaryCaseCollection*>& ensembles );
static RimSummaryPlot* createCrossPlot( const std::vector<RiaSummaryCurveAddress>& addresses,
const std::vector<RimSummaryCase*>& summaryCases,
const std::vector<RimSummaryCaseCollection*>& ensembles );
static void appendCurvesToPlot( RimSummaryPlot* summaryPlot,
const std::set<RifEclipseSummaryAddress>& addresses,
const std::vector<RimSummaryCase*>& summaryCases,
const std::vector<RimSummaryCaseCollection*>& ensembles );
static RimEnsembleCurveSet*
addNewEnsembleCurve( RimSummaryPlot* summaryPlot, const RiaSummaryCurveAddress& curveAddress, RimSummaryCaseCollection* ensemble );
static RimSummaryCurve*
addNewSummaryCurve( RimSummaryPlot* summaryPlot, const RiaSummaryCurveAddress& curveAddress, RimSummaryCase* summaryCase );
private:
std::set<RifEclipseSummaryAddress> m_addresses;
std::vector<RimSummaryCase*> m_summaryCases;

View File

@ -47,6 +47,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryTableFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateDeclineCurvesFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateRegressionAnalysisCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateCrossPlotFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -98,6 +99,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryTableFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateDeclineCurvesFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateRegressionAnalysisCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateCrossPlotFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -0,0 +1,209 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- 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 "RicCreateCrossPlotFeature.h"
#include "PlotBuilderCommands/RicSummaryPlotBuilder.h"
#include "RiaPreferencesSummary.h"
#include "RiaSummaryCurveAddress.h"
#include "RifEclipseSummaryAddress.h"
#include "RimSummaryAddress.h"
#include "RimSummaryAddressCollection.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "cafSelectionManagerTools.h"
#include <QAction>
#include <QMenu>
CAF_CMD_SOURCE_INIT( RicCreateCrossPlotFeature, "RicCreateCrossPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCreateCrossPlotFeature::isCommandEnabled() const
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateCrossPlotFeature::onActionTriggered( bool isChecked )
{
// Nothing to do here, the sub menus are handled by the onSubMenuActionTriggered
}
auto newCrossPlotText = []() -> QString { return "New Cross Plot"; };
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateCrossPlotFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Summary Cross Plot" );
actionToSetup->setIcon( QIcon( ":/SummaryXPlotLight16x16.png" ) );
auto subMenu = new QMenu( "Create Cross Plot" );
auto menuTexts = crossPlotAddressesBasedOnSelection();
menuTexts.append( newCrossPlotText() );
for ( const auto& crossPlotAddresses : menuTexts )
{
auto action = subMenu->addAction( crossPlotAddresses );
action->setIcon( QIcon( ":/SummaryXPlotLight16x16.png" ) );
connect( action, &QAction::triggered, this, &RicCreateCrossPlotFeature::onSubMenuActionTriggered );
}
actionToSetup->setMenu( subMenu );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateCrossPlotFeature::onSubMenuActionTriggered( bool isChecked )
{
QString addressX;
QString addressY;
if ( auto* action = qobject_cast<QAction*>( sender() ) )
{
auto text = action->text();
if ( text != newCrossPlotText() )
{
auto words = action->text().split( " " );
if ( !words.empty() ) addressY = words[0];
if ( words.size() > 1 ) addressX = words[1];
}
}
RifEclipseSummaryAddress adrX = RifEclipseSummaryAddress::fromEclipseTextAddress( addressX.toStdString() );
RifEclipseSummaryAddress adrY = RifEclipseSummaryAddress::fromEclipseTextAddress( addressY.toStdString() );
RiaSummaryCurveAddress curveAddress( adrX, adrY );
auto selectedCases = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryCase>();
auto selectedEnsembles = caf::firstAncestorOfTypeFromSelectedObject<RimSummaryCaseCollection>();
auto newPlot = RicSummaryPlotBuilder::createCrossPlot( { curveAddress }, { selectedCases }, { selectedEnsembles } );
RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( newPlot );
}
//--------------------------------------------------------------------------------------------------
// Returns a list of cross plot address combinations based on the current selection
// The vectors defined in preferences is given in field vectors
// If the selection is a field address, use the list from preferences
// If the selection is a well address, F is replaced with W and well name is appended
// If the selection is a group address, F is replaced with G and group name is appended
//--------------------------------------------------------------------------------------------------
QStringList RicCreateCrossPlotFeature::crossPlotAddressesBasedOnSelection()
{
auto text = RiaPreferencesSummary::current()->crossPlotAddressCombinations();
auto collectionContentType = RimSummaryAddressCollection::CollectionContentType::NOT_DEFINED;
std::string wellName;
std::string groupName;
if ( auto addr = dynamic_cast<RimSummaryAddress*>( caf::SelectionManager::instance()->selectedItem() ) )
{
wellName = addr->address().wellName();
groupName = addr->address().groupName();
}
if ( auto addrCollection = dynamic_cast<RimSummaryAddressCollection*>( caf::SelectionManager::instance()->selectedItem() ) )
{
collectionContentType = addrCollection->contentType();
if ( ( collectionContentType == RimSummaryAddressCollection::CollectionContentType::WELL ) && wellName.empty() )
{
auto addresses = addrCollection->descendantsOfType<RimSummaryAddress>();
if ( !addresses.empty() )
{
wellName = addresses.front()->address().wellName();
}
}
if ( ( collectionContentType == RimSummaryAddressCollection::CollectionContentType::GROUP ) && groupName.empty() )
{
auto addresses = addrCollection->descendantsOfType<RimSummaryAddress>();
if ( !addresses.empty() )
{
groupName = addresses.front()->address().groupName();
}
}
}
bool isWell = ( ( collectionContentType == RimSummaryAddressCollection::CollectionContentType::WELL ) || !wellName.empty() );
bool isGroup = ( ( collectionContentType == RimSummaryAddressCollection::CollectionContentType::GROUP ) || !groupName.empty() );
QStringList crossPlotAddressCombinations;
auto textList = text.split( ";" );
for ( const auto& inputText : textList )
{
auto modifiedString = inputText.toStdString();
if ( isWell )
{
std::string wellAddress;
auto words = inputText.split( " " );
for ( const auto& w : words )
{
auto tmp = w.toStdString().substr( 1 );
tmp = "W" + tmp + ":" + wellName;
if ( !wellAddress.empty() ) wellAddress += " ";
wellAddress += tmp;
}
modifiedString = wellAddress;
}
else if ( isGroup )
{
std::string groupAddress;
auto words = inputText.split( " " );
for ( const auto& w : words )
{
auto tmp = w.toStdString().substr( 1 );
tmp = "G" + tmp + ":" + groupName;
if ( !groupAddress.empty() ) groupAddress += " ";
groupAddress += tmp;
}
modifiedString = groupAddress;
}
crossPlotAddressCombinations.append( QString::fromStdString( modifiedString ) );
}
return crossPlotAddressCombinations;
}

View File

@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- 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
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicCreateCrossPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
void onSubMenuActionTriggered( bool isChecked );
static QStringList crossPlotAddressesBasedOnSelection();
};

View File

@ -32,6 +32,7 @@
#include "RiuPlotMainWindow.h"
#include "RiuPlotMainWindowTools.h"
#include "PlotBuilderCommands/RicSummaryPlotBuilder.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "cafSelectionManager.h"
@ -58,26 +59,21 @@ void RicNewSummaryCrossPlotCurveFeature::onActionTriggered( bool isChecked )
auto plot = selectedSummaryPlot();
if ( plot )
{
RimSummaryCurve* newCurve = new RimSummaryCurve();
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plot->curveCount() );
newCurve->setColor( curveColor );
RimSummaryCase* defaultCase = nullptr;
if ( project->activeOilField()->summaryCaseMainCollection()->summaryCaseCount() > 0 )
{
defaultCase = project->activeOilField()->summaryCaseMainCollection()->summaryCase( 0 );
newCurve->setSummaryCaseY( defaultCase );
newCurve->setSummaryAddressY( RifEclipseSummaryAddress::fieldAddress( "FOPT" ) );
newCurve->setAxisTypeX( RiaDefines::HorizontalAxisType::SUMMARY_VECTOR );
newCurve->setSummaryCaseX( defaultCase );
newCurve->setSummaryAddressX( RifEclipseSummaryAddress::fieldAddress( "FGOR" ) );
}
plot->addCurveAndUpdate( newCurve );
RiaSummaryCurveAddress addr( RifEclipseSummaryAddress::fieldAddress( "FOPT" ), RifEclipseSummaryAddress::fieldAddress( "FGOR" ) );
auto newCurve = RicSummaryPlotBuilder::addNewSummaryCurve( plot, addr, defaultCase );
newCurve->setColor( curveColor );
newCurve->loadDataAndUpdate( true );
plot->zoomAll();
plot->updateConnectedEditors();
RiuPlotMainWindowTools::onObjectAppended( newCurve );
@ -90,7 +86,7 @@ void RicNewSummaryCrossPlotCurveFeature::onActionTriggered( bool isChecked )
void RicNewSummaryCrossPlotCurveFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Summary Cross Plot Curve" );
actionToSetup->setIcon( QIcon( ":/SummaryCurve16x16.png" ) );
actionToSetup->setIcon( QIcon( ":/SummaryXPlotLight16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------

View File

@ -699,10 +699,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicDuplicateSummaryPlotFeature";
menuBuilder << "RicSplitMultiPlotFeature";
menuBuilder << "RicNewSummaryEnsembleCurveSetFeature";
menuBuilder << "RicNewSummaryCrossPlotCurveFeature";
menuBuilder << "Separator";
menuBuilder << "RicNewPlotAxisPropertiesFeature";
menuBuilder << "RicNewSummaryCurveFeature";
menuBuilder << "RicNewSummaryCrossPlotCurveFeature";
menuBuilder << "Separator";
menuBuilder << "RicAsciiExportSummaryPlotFeature";
menuBuilder << "RicShowSummaryCurveCalculatorFeature";
@ -1101,6 +1101,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
{
menuBuilder << "RicCreateMultiPlotFromSelectionFeature";
menuBuilder << "RicCreatePlotFromTemplateByShortcutFeature";
menuBuilder << "RicCreateCrossPlotFeature";
}
else if ( dynamic_cast<RimPlotAxisPropertiesInterface*>( firstUiItem ) )
{
@ -1288,6 +1289,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicAppendSummaryPlotsForSummaryAddressesFeature";
menuBuilder << "Separator";
menuBuilder << "RicNewSummaryTableFeature";
menuBuilder << "RicCreateCrossPlotFeature";
}
#ifdef USE_ODB_API
else if ( dynamic_cast<RimWellIASettings*>( firstUiItem ) )

View File

@ -156,6 +156,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()
CAF_PDM_InitFieldNoDefault( &m_xAddressSelector, "XAddressSelector", "" );
m_xAddressSelector = new RimSummaryAddressSelector;
m_xAddressSelector->setAxisOrientation( RimPlotAxisProperties::Orientation::HORIZONTAL );
m_xAddressSelector->setShowResampling( false );
m_xAddressSelector.uiCapability()->setUiTreeHidden( true );
m_xAddressSelector.uiCapability()->setUiTreeChildrenHidden( true );
@ -481,6 +482,27 @@ RiaDefines::HorizontalAxisType RimEnsembleCurveSet::xAxisType() const
return m_xAxisType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::findOrAssignBottomAxisX( RiuPlotAxis plotAxis )
{
auto plot = firstAncestorOrThisOfType<RimSummaryPlot>();
if ( !plot ) return;
if ( auto axis = plot->axisPropertiesForPlotAxis( plotAxis ) )
{
m_xAddressSelector->setPlotAxisProperties( axis );
}
else
{
RimPlotAxisProperties* newPlotAxisProperties = plot->addNewAxisProperties( plotAxis, "Bottom Axis" );
plot->updateConnectedEditors();
m_xAddressSelector->setPlotAxisProperties( newPlotAxisProperties );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -771,25 +793,14 @@ void RimEnsembleCurveSet::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
if ( !m_xAddressSelector->ensemble() )
{
m_xAddressSelector->setEnsemble( summaryCaseCollection() );
}
if ( !m_xAddressSelector->summaryAddress().isValid() )
{
m_xAddressSelector->setAddress( summaryAddressY() );
}
if ( !m_xAddressSelector->plotAxisProperties() )
{
RiuPlotAxis plotAxis = RiuPlotAxis::defaultBottomForSummaryVectors();
if ( auto axis = plot->axisPropertiesForPlotAxis( plotAxis ) )
{
m_xAddressSelector->setPlotAxisProperties( axis );
}
else
{
RimPlotAxisProperties* newPlotAxisProperties =
plot->addNewAxisProperties( RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM, "Bottom Axis" );
plot->updateConnectedEditors();
m_xAddressSelector->setPlotAxisProperties( newPlotAxisProperties );
}
}
findOrAssignBottomAxisX( RiuPlotAxis::defaultBottomForSummaryVectors() );
}
plot->updateAxes();
plot->updatePlotTitle();
@ -1053,6 +1064,9 @@ void RimEnsembleCurveSet::childFieldChangedByUi( const caf::PdmFieldHandle* chan
{
multiPlot->updatePlotTitles();
}
// Trigger update, as the axis object name might have changed. Will update the axis object of the curve set.
updateConnectedEditors();
}
}
@ -1068,7 +1082,13 @@ void RimEnsembleCurveSet::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde
curveDataGroup->add( &m_yValuesSummaryCaseCollection );
curveDataGroup->add( &m_yValuesSummaryAddressUiField );
curveDataGroup->add( &m_yPushButtonSelectSummaryAddress, { false, 1, 0 } );
if ( !isXAxisSummaryVector() )
{
// Resampling is automatic for cross plot curves
curveDataGroup->add( &m_resampling );
}
curveDataGroup->add( &m_yPlotAxisProperties );
}

View File

@ -195,6 +195,7 @@ public:
void setBottomOrTopAxisX( RiuPlotAxis plotAxis );
bool isXAxisSummaryVector() const;
RiaDefines::HorizontalAxisType xAxisType() const;
void findOrAssignBottomAxisX( RiuPlotAxis plotAxis );
protected:
void initAfterRead() override;

View File

@ -43,6 +43,9 @@ CAF_PDM_SOURCE_INIT( RimSummaryAddressSelector, "RimSummaryAddressSelector" );
//--------------------------------------------------------------------------------------------------
RimSummaryAddressSelector::RimSummaryAddressSelector()
: addressChanged( this )
, m_showDataSource( true )
, m_showResampling( true )
, m_plotAxisOrientation( RimPlotAxisProperties::Orientation::ANY )
{
CAF_PDM_InitFieldNoDefault( &m_summaryCase, "SummaryCase", "Case" );
@ -71,9 +74,6 @@ RimSummaryAddressSelector::RimSummaryAddressSelector()
m_summaryAddress = new RimSummaryAddress;
CAF_PDM_InitFieldNoDefault( &m_resamplingPeriod, "Resampling", "Resampling" );
m_showDataSource = true;
m_plotAxisOrientation = RimPlotAxisProperties::Orientation::ANY;
}
//--------------------------------------------------------------------------------------------------
@ -124,6 +124,14 @@ void RimSummaryAddressSelector::setShowDataSource( bool enable )
m_showDataSource = enable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryAddressSelector::setShowResampling( bool enable )
{
m_showResampling = enable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -344,7 +352,12 @@ void RimSummaryAddressSelector::defineUiOrdering( QString uiConfigName, caf::Pdm
uiOrdering.add( &m_summaryAddressUiField, { true, 2, 1 } );
uiOrdering.add( &m_pushButtonSelectSummaryAddress, { false, 1, 0 } );
if ( m_showResampling )
{
uiOrdering.add( &m_resamplingPeriod, { true, 3, 1 } );
}
uiOrdering.add( &m_plotAxisProperties, { true, 3, 1 } );
uiOrdering.skipRemainingFields( true );

View File

@ -50,9 +50,11 @@ public:
void setAddress( const RifEclipseSummaryAddress& address );
void setResamplingPeriod( RiaDefines::DateTimePeriodEnum resampling );
void setPlotAxisProperties( RimPlotAxisPropertiesInterface* plotAxisProperties );
void setShowDataSource( bool enable );
void setAxisOrientation( RimPlotAxisProperties::Orientation orientation );
void setShowDataSource( bool enable );
void setShowResampling( bool enable );
RimSummaryCase* summaryCase() const;
RimSummaryCaseCollection* ensemble() const;
RifEclipseSummaryAddress summaryAddress() const;
@ -77,6 +79,7 @@ private:
caf::PdmField<RiaDefines::DateTimePeriodEnum> m_resamplingPeriod;
bool m_showDataSource;
bool m_showResampling;
RimPlotAxisProperties::Orientation m_plotAxisOrientation;
};

View File

@ -1021,15 +1021,17 @@ QString RimSummaryCurve::curveExportDescription( const RifEclipseSummaryAddress&
auto group = curveSet ? curveSet->summaryCaseCollection() : nullptr;
auto addressUiText = addr.uiText();
if ( !m_yValuesSummaryCase() )
{
return QString::fromStdString( addressUiText );
}
if ( group && group->isEnsemble() )
{
return QString( "%1.%2.%3" ).arg( QString::fromStdString( addressUiText ) ).arg( m_yValuesSummaryCase->nativeCaseName() ).arg( group->name() );
}
else
{
return QString( "%1.%2" ).arg( QString::fromStdString( addressUiText ) ).arg( m_yValuesSummaryCase->nativeCaseName() );
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -39,6 +39,7 @@
#include "RicfCommandObject.h"
#include "PlotBuilderCommands/RicSummaryPlotBuilder.h"
#include "SummaryPlotCommands/RicSummaryPlotEditorUi.h"
#include "PlotTemplates/RimPlotTemplateFileItem.h"
@ -2379,7 +2380,7 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleEnsembleDrop( RimSummaryCaseColl
{
if ( ensembles.count( ensemble ) > 0 ) continue;
auto curveSet = addNewEnsembleCurve( addr, ensemble );
auto curveSet = RicSummaryPlotBuilder::addNewEnsembleCurve( this, addr, ensemble );
curveSetsToUpdate.push_back( curveSet );
newCurves++;
}
@ -2481,7 +2482,8 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleAddressCollectionDrop( RimSummar
auto addresses = curveDef.ensemble()->ensembleSummaryAddresses();
if ( addresses.find( curveDef.summaryAddressY() ) != addresses.end() )
{
curveSetsToUpdate.push_back( addNewEnsembleCurve( curveDef.summaryCurveAddress(), curveDef.ensemble() ) );
auto curveSet = RicSummaryPlotBuilder::addNewEnsembleCurve( this, curveDef.summaryCurveAddress(), curveDef.ensemble() );
curveSetsToUpdate.push_back( curveSet );
newCurves++;
}
}
@ -2551,8 +2553,13 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleSummaryAddressDrop( RimSummaryAd
if ( !skipAddress )
{
curveSetsToUpdate.push_back(
addNewEnsembleCurve( RiaSummaryCurveAddress( RifEclipseSummaryAddress::timeAddress(), droppedAddress ), ensemble ) );
auto curveSet =
RicSummaryPlotBuilder::addNewEnsembleCurve( this,
RiaSummaryCurveAddress( RifEclipseSummaryAddress::timeAddress(),
droppedAddress ),
ensemble );
curveSetsToUpdate.push_back( curveSet );
newCurves++;
}
}
@ -2671,35 +2678,6 @@ RimSummaryCurve* RimSummaryPlot::addNewCurve( const RifEclipseSummaryAddress& ad
return newCurve;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEnsembleCurveSet* RimSummaryPlot::addNewEnsembleCurve( const RiaSummaryCurveAddress& address, RimSummaryCaseCollection* ensemble )
{
auto* curveSet = new RimEnsembleCurveSet();
curveSet->setSummaryCaseCollection( ensemble );
curveSet->setSummaryAddressYAndStatisticsFlag( address.summaryAddressY() );
curveSet->setCurveAddress( address );
cvf::Color3f curveColor =
RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( curveSet->summaryAddressY(),
static_cast<int>(
ensembleCurveSetCollection()->curveSetCount() ) );
auto adr = curveSet->summaryAddressY();
if ( adr.isHistoryVector() ) curveColor = RiaPreferencesSummary::current()->historyCurveContrastColor();
curveSet->setColor( curveColor );
ensembleCurveSetCollection()->addCurveSet( curveSet );
curveSet->setLeftOrRightAxisY( RiuPlotAxis::defaultLeft() );
curveSet->setBottomOrTopAxisX( RiuPlotAxis::defaultBottomForSummaryVectors() );
return curveSet;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------