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

@@ -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 } );
curveDataGroup->add( &m_resampling );
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 } );
uiOrdering.add( &m_resamplingPeriod, { true, 3, 1 } );
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() );
}
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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------