mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#9369 Curve Probing: Show data from other curves in tooltip text
Optionally show data from other curves in tooltip text when hoovering over a curve point
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
|
||||
#include "cafAssert.h"
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
|
||||
#include <QPen>
|
||||
|
||||
@@ -126,6 +127,10 @@ RimPlotCurve::RimPlotCurve()
|
||||
m_curveAppearance->appearanceChanged.connect( this, &RimPlotCurve::onCurveAppearanceChanged );
|
||||
m_curveAppearance->fillColorChanged.connect( this, &RimPlotCurve::onFillColorChanged );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_additionalDataSources, "AdditionalDataSources", "Additional Data Sources" );
|
||||
m_additionalDataSources.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
|
||||
m_additionalDataSources.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
|
||||
m_plotCurve = nullptr;
|
||||
m_parentPlot = nullptr;
|
||||
}
|
||||
@@ -309,6 +314,27 @@ QList<caf::PdmOptionItemInfo> RimPlotCurve::calculateValueOptions( const caf::Pd
|
||||
RiaDefines::ObjectNamingMethod::TEMPLATE ) );
|
||||
}
|
||||
}
|
||||
else if ( fieldNeedingOptions == &m_additionalDataSources )
|
||||
{
|
||||
std::vector<RimPlotWindow*> parentPlots;
|
||||
|
||||
// Find all plot windows above this object upwards in the object hierarchy. Use the top most plot window as the
|
||||
// root to find all plot curves.
|
||||
this->allAncestorsOfType( parentPlots );
|
||||
|
||||
if ( !parentPlots.empty() )
|
||||
{
|
||||
std::vector<RimPlotCurve*> plotCurves;
|
||||
parentPlots.back()->descendantsOfType( plotCurves );
|
||||
|
||||
for ( auto p : plotCurves )
|
||||
{
|
||||
caf::PdmOptionItemInfo optionInfo( p->curveName(), p );
|
||||
|
||||
options.push_back( optionInfo );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
@@ -455,6 +481,16 @@ void RimPlotCurve::curveNameUiOrdering( caf::PdmUiOrdering& uiOrdering )
|
||||
uiOrdering.add( &m_curveName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotCurve::additionalDataSourcesUiOrdering( caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
auto group = uiOrdering.addNewGroup( RiaDefines::additionalDataSourcesGroupName() );
|
||||
group->add( &m_additionalDataSources );
|
||||
group->setCollapsedByDefault();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1069,6 +1105,22 @@ std::pair<double, double> RimPlotCurve::sample( int index ) const
|
||||
return m_plotCurve->sample( index );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimPlotCurve::closestYValueForX( double xValue ) const
|
||||
{
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimPlotCurve*> RimPlotCurve::additionalDataSources() const
|
||||
{
|
||||
return m_additionalDataSources.ptrReferencedObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrArrayField.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include <Qt>
|
||||
@@ -89,6 +90,7 @@ public:
|
||||
void setNamingMethod( RiaDefines::ObjectNamingMethod namingMethod );
|
||||
QString curveName() const;
|
||||
virtual QString curveExportDescription( const RifEclipseSummaryAddress& address = RifEclipseSummaryAddress() ) const;
|
||||
virtual QString createCurveNameFromTemplate( const QString& templateText );
|
||||
|
||||
void setCustomName( const QString& customName );
|
||||
void setLegendEntryText( const QString& legendEntryText );
|
||||
@@ -117,8 +119,10 @@ public:
|
||||
|
||||
virtual void setTitle( const QString& title );
|
||||
|
||||
int dataSize() const;
|
||||
std::pair<double, double> sample( int index ) const;
|
||||
int dataSize() const;
|
||||
std::pair<double, double> sample( int index ) const;
|
||||
virtual double closestYValueForX( double xValue ) const;
|
||||
std::vector<RimPlotCurve*> additionalDataSources() const;
|
||||
|
||||
void setParentPlotNoReplot( RiuPlotWidget* );
|
||||
void setParentPlotAndReplot( RiuPlotWidget* );
|
||||
@@ -132,8 +136,6 @@ public:
|
||||
protected:
|
||||
virtual QString createCurveAutoName() = 0;
|
||||
|
||||
// Override these two methods to show and use curve name template when assigning a name to the curve
|
||||
virtual QString createCurveNameFromTemplate( const QString& templateText );
|
||||
virtual QStringList supportedCurveNameVariables() const;
|
||||
|
||||
virtual void updateZoomInParentPlot() = 0;
|
||||
@@ -172,6 +174,7 @@ protected:
|
||||
|
||||
void appearanceUiOrdering( caf::PdmUiOrdering& uiOrdering );
|
||||
void curveNameUiOrdering( caf::PdmUiOrdering& uiOrdering );
|
||||
void additionalDataSourcesUiOrdering( caf::PdmUiOrdering& uiOrdering );
|
||||
|
||||
void onCurveAppearanceChanged( const caf::SignalEmitter* emitter );
|
||||
virtual void onFillColorChanged( const caf::SignalEmitter* emitter );
|
||||
@@ -200,6 +203,8 @@ protected:
|
||||
|
||||
caf::PdmChildField<RimPlotCurveAppearance*> m_curveAppearance;
|
||||
|
||||
caf::PdmPtrArrayField<RimPlotCurve*> m_additionalDataSources;
|
||||
|
||||
QPointer<RiuPlotWidget> m_parentPlot;
|
||||
RiuPlotCurve* m_plotCurve;
|
||||
|
||||
|
||||
@@ -157,3 +157,22 @@ void RimStackablePlotCurve::stackingUiOrdering( caf::PdmUiOrdering& uiOrdering )
|
||||
uiOrdering.add( &m_isStacked );
|
||||
if ( m_isStacked() ) uiOrdering.add( &m_isStackedWithPhaseColors );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStackablePlotCurve::defaultUiOrdering( caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
RimPlotCurve::additionalDataSourcesUiOrdering( uiOrdering );
|
||||
|
||||
caf::PdmUiGroup* stackingGroup = uiOrdering.addNewGroup( "Stacking" );
|
||||
RimStackablePlotCurve::stackingUiOrdering( *stackingGroup );
|
||||
|
||||
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( RiaDefines::appearanceGroupName() );
|
||||
RimPlotCurve::appearanceUiOrdering( *appearanceGroup );
|
||||
|
||||
caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( RiaDefines::curveNameGroupName() );
|
||||
nameGroup->setCollapsedByDefault();
|
||||
nameGroup->add( &m_showLegend );
|
||||
RimPlotCurve::curveNameUiOrdering( *nameGroup );
|
||||
}
|
||||
|
||||
@@ -37,7 +37,9 @@ public:
|
||||
|
||||
protected:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
|
||||
void stackingUiOrdering( caf::PdmUiOrdering& uiOrdering );
|
||||
void defaultUiOrdering( caf::PdmUiOrdering& uiOrdering );
|
||||
|
||||
void onFillColorChanged( const caf::SignalEmitter* emitter ) override;
|
||||
|
||||
|
||||
@@ -142,8 +142,6 @@ QString RimRftTopologyCurve::createCurveAutoName()
|
||||
if ( m_segmentBranchType() == RiaDefines::RftBranchType::RFT_TUBING ) text += "Tubing";
|
||||
}
|
||||
|
||||
text += QString( " (%1)" ).arg( m_segmentBranchIndex() );
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -166,16 +164,7 @@ void RimRftTopologyCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde
|
||||
curveDataGroup->add( &m_segmentBranchType );
|
||||
}
|
||||
|
||||
caf::PdmUiGroup* stackingGroup = uiOrdering.addNewGroup( "Stacking" );
|
||||
RimStackablePlotCurve::stackingUiOrdering( *stackingGroup );
|
||||
|
||||
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" );
|
||||
RimPlotCurve::appearanceUiOrdering( *appearanceGroup );
|
||||
|
||||
caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "Curve Name" );
|
||||
nameGroup->setCollapsedByDefault();
|
||||
nameGroup->add( &m_showLegend );
|
||||
RimPlotCurve::curveNameUiOrdering( *nameGroup );
|
||||
RimStackablePlotCurve::defaultUiOrdering( uiOrdering );
|
||||
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
@@ -187,7 +176,7 @@ QList<caf::PdmOptionItemInfo> RimRftTopologyCurve::calculateValueOptions( const
|
||||
{
|
||||
if ( !m_summaryCase ) return {};
|
||||
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
QList<caf::PdmOptionItemInfo> options = RimWellLogCurve::calculateValueOptions( fieldNeedingOptions );
|
||||
|
||||
auto reader = m_summaryCase->rftReader();
|
||||
|
||||
@@ -323,6 +312,14 @@ void RimRftTopologyCurve::onLoadDataAndUpdate( bool updateParentPlot )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimRftTopologyCurve::setAdditionalDataSources( const std::vector<RimPlotCurve*>& additionalDataSources )
|
||||
{
|
||||
m_additionalDataSources.setValue( additionalDataSources );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -74,4 +74,7 @@ private:
|
||||
caf::PdmField<caf::AppEnum<RiaDefines::RftBranchType>> m_segmentBranchType;
|
||||
|
||||
caf::PdmField<bool> m_isPackerCurve;
|
||||
|
||||
public:
|
||||
void setAdditionalDataSources( const std::vector<RimPlotCurve*>& additionalDataSources );
|
||||
};
|
||||
|
||||
@@ -295,6 +295,31 @@ void RimWellLogCurve::setOverrideCurveData( const std::vector<double>&
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimWellLogCurve::closestYValueForX( double xValue ) const
|
||||
{
|
||||
if ( m_curveData.isNull() ) return std::numeric_limits<double>::infinity();
|
||||
|
||||
auto depths = m_curveData->depths( RiaDefines::DepthTypeEnum::MEASURED_DEPTH );
|
||||
auto values = m_curveData->propertyValues();
|
||||
|
||||
if ( depths.empty() || values.empty() ) return std::numeric_limits<double>::infinity();
|
||||
|
||||
auto it = std::upper_bound( depths.begin(), depths.end(), xValue );
|
||||
if ( it == depths.begin() ) return values.front();
|
||||
if ( it == depths.end() ) return values.back();
|
||||
|
||||
auto index = std::distance( depths.begin(), it - 1 );
|
||||
|
||||
double firstDistance = std::abs( xValue - depths[index] );
|
||||
double secondDistance = std::abs( xValue - depths[index + 1] );
|
||||
|
||||
if ( firstDistance < secondDistance ) return values[index];
|
||||
return values[index + 1];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -61,6 +61,8 @@ public:
|
||||
const std::vector<double>& depthValues,
|
||||
const RiaCurveDataTools::CurveIntervals& curveIntervals );
|
||||
|
||||
double closestYValueForX( double xValue ) const override;
|
||||
|
||||
protected:
|
||||
void updateZoomInParentPlot() override;
|
||||
void updateLegendsInPlot() override;
|
||||
|
||||
@@ -787,19 +787,11 @@ void RimWellLogExtractionCurve::defineUiOrdering( QString uiConfigName, caf::Pdm
|
||||
curveDataGroup->add( &m_timeStep );
|
||||
}
|
||||
|
||||
caf::PdmUiGroup* stackingGroup = uiOrdering.addNewGroup( "Stacking" );
|
||||
RimStackablePlotCurve::stackingUiOrdering( *stackingGroup );
|
||||
|
||||
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" );
|
||||
RimPlotCurve::appearanceUiOrdering( *appearanceGroup );
|
||||
|
||||
caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "Curve Name" );
|
||||
nameGroup->setCollapsedByDefault();
|
||||
nameGroup->add( &m_showLegend );
|
||||
RimPlotCurve::curveNameUiOrdering( *nameGroup );
|
||||
RimStackablePlotCurve::defaultUiOrdering( uiOrdering );
|
||||
|
||||
if ( m_namingMethod == RiaDefines::ObjectNamingMethod::AUTO )
|
||||
{
|
||||
auto nameGroup = uiOrdering.findGroup( RiaDefines::curveNameGroupName() );
|
||||
nameGroup->add( &m_addWellNameToCurveName );
|
||||
nameGroup->add( &m_addCaseNameToCurveName );
|
||||
nameGroup->add( &m_addPropertyToCurveName );
|
||||
|
||||
@@ -337,15 +337,7 @@ void RimWellLogFileCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde
|
||||
curveDataGroup->add( &m_wellLogFile );
|
||||
curveDataGroup->add( &m_wellLogChannelName );
|
||||
|
||||
caf::PdmUiGroup* stackingGroup = uiOrdering.addNewGroup( "Stacking" );
|
||||
RimStackablePlotCurve::stackingUiOrdering( *stackingGroup );
|
||||
|
||||
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" );
|
||||
RimPlotCurve::appearanceUiOrdering( *appearanceGroup );
|
||||
|
||||
caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "Curve Name" );
|
||||
nameGroup->add( &m_showLegend );
|
||||
RimPlotCurve::curveNameUiOrdering( *nameGroup );
|
||||
RimStackablePlotCurve::defaultUiOrdering( uiOrdering );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -806,15 +806,7 @@ void RimWellLogRftCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder
|
||||
curveDataGroup->add( &m_curveColorByPhase );
|
||||
}
|
||||
|
||||
caf::PdmUiGroup* stackingGroup = uiOrdering.addNewGroup( "Stacking" );
|
||||
RimStackablePlotCurve::stackingUiOrdering( *stackingGroup );
|
||||
|
||||
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" );
|
||||
RimPlotCurve::appearanceUiOrdering( *appearanceGroup );
|
||||
|
||||
caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "Curve Name" );
|
||||
nameGroup->add( &m_showLegend );
|
||||
RimPlotCurve::curveNameUiOrdering( *nameGroup );
|
||||
RimStackablePlotCurve::defaultUiOrdering( uiOrdering );
|
||||
|
||||
uiOrdering.skipRemainingFields();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user