Make Well Allocation Plots work well again

This commit is contained in:
Gaute Lindkvist 2019-09-09 11:00:11 +02:00
parent 9fe021c6ca
commit 71c4642f13
8 changed files with 347 additions and 216 deletions

View File

@ -40,14 +40,13 @@
#include "RimTotalWellAllocationPlot.h" #include "RimTotalWellAllocationPlot.h"
#include "RimWellAllocationPlotLegend.h" #include "RimWellAllocationPlotLegend.h"
#include "RimWellFlowRateCurve.h" #include "RimWellFlowRateCurve.h"
#include "RimWellLogFile.h"
#include "RimWellLogPlot.h" #include "RimWellLogPlot.h"
#include "RimWellLogTrack.h" #include "RimWellLogTrack.h"
#include "RimWellPlotTools.h"
#include "RimWellLogFile.h"
#include "RimWellPlotTools.h"
#include "RiuPlotMainWindow.h" #include "RiuPlotMainWindow.h"
#include "RiuWellAllocationPlot.h" #include "RiuWellAllocationPlot.h"
#include "RiuWellLogPlot.h"
#include "RiuWellLogTrack.h" #include "RiuWellLogTrack.h"
CAF_PDM_SOURCE_INIT( RimWellAllocationPlot, "WellAllocationPlot" ); CAF_PDM_SOURCE_INIT( RimWellAllocationPlot, "WellAllocationPlot" );
@ -71,12 +70,13 @@ void AppEnum<RimWellAllocationPlot::FlowType>::setUp()
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimWellAllocationPlot::RimWellAllocationPlot() RimWellAllocationPlot::RimWellAllocationPlot()
: RimWellLogPlot()
{ {
CAF_PDM_InitObject( "Well Allocation Plot", ":/WellAllocPlot16x16.png", "", "" ); CAF_PDM_InitObject( "Well Allocation Plot", ":/WellAllocPlot16x16.png", "", "" );
CAF_PDM_InitField( &m_showPlotTitle_OBSOLETE, "ShowPlotTitle", true, "Show Plot Title", "", "", "" ); CAF_PDM_InitField( &m_userName, "PlotDescription", QString( "Flow Diagnostics Plot" ), "Name", "", "", "" );
m_showPlotTitle_OBSOLETE.xmlCapability()->setIOWritable( false ); m_userName.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "" );
CAF_PDM_InitField( &m_branchDetection, CAF_PDM_InitField( &m_branchDetection,
"BranchDetection", "BranchDetection",
@ -95,19 +95,13 @@ RimWellAllocationPlot::RimWellAllocationPlot()
CAF_PDM_InitFieldNoDefault( &m_flowType, "FlowType", "Flow Type", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_flowType, "FlowType", "Flow Type", "", "", "" );
CAF_PDM_InitField( &m_groupSmallContributions, "GroupSmallContributions", true, "Group Small Contributions", "", "", "" ); CAF_PDM_InitField( &m_groupSmallContributions, "GroupSmallContributions", true, "Group Small Contributions", "", "", "" );
CAF_PDM_InitField( &m_smallContributionsThreshold, "SmallContributionsThreshold", 0.005, "Threshold", "", "", "" ); CAF_PDM_InitField( &m_smallContributionsThreshold, "SmallContributionsThreshold", 0.005, "Threshold", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_accumulatedWellFlowPlot_OBSOLETE, CAF_PDM_InitFieldNoDefault( &m_accumulatedWellFlowPlot, "AccumulatedWellFlowPlot", "Accumulated Well Flow", "", "", "" );
"AccumulatedWellFlowPlot", m_accumulatedWellFlowPlot.uiCapability()->setUiHidden( true );
"Accumulated Well Flow", m_accumulatedWellFlowPlot = new RimWellLogPlot;
"", m_accumulatedWellFlowPlot->setDepthUnit( RiaDefines::UNIT_NONE );
"", m_accumulatedWellFlowPlot->setDepthType( RimWellLogPlot::CONNECTION_NUMBER );
"" ); m_accumulatedWellFlowPlot->setTrackLegendsVisible( false );
m_accumulatedWellFlowPlot_OBSOLETE.uiCapability()->setUiHidden( true ); m_accumulatedWellFlowPlot->uiCapability()->setUiIconFromResourceString( ":/WellFlowPlot16x16.png" );
m_accumulatedWellFlowPlot_OBSOLETE = new RimWellLogPlot;
m_accumulatedWellFlowPlot_OBSOLETE->setDepthUnit( RiaDefines::UNIT_NONE );
m_accumulatedWellFlowPlot_OBSOLETE->setDepthType( RimWellLogPlot::CONNECTION_NUMBER );
m_accumulatedWellFlowPlot_OBSOLETE->setTrackLegendsVisible( false );
m_accumulatedWellFlowPlot_OBSOLETE->uiCapability()->setUiIconFromResourceString( ":/WellFlowPlot16x16.png" );
m_accumulatedWellFlowPlot_OBSOLETE.xmlCapability()->setIOWritable( false );
CAF_PDM_InitFieldNoDefault( &m_totalWellAllocationPlot, "TotalWellFlowPlot", "Total Well Flow", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_totalWellAllocationPlot, "TotalWellFlowPlot", "Total Well Flow", "", "", "" );
m_totalWellAllocationPlot.uiCapability()->setUiHidden( true ); m_totalWellAllocationPlot.uiCapability()->setUiHidden( true );
@ -126,9 +120,11 @@ RimWellAllocationPlot::RimWellAllocationPlot()
m_tofAccumulatedPhaseFractionsPlot.uiCapability()->setUiHidden( true ); m_tofAccumulatedPhaseFractionsPlot.uiCapability()->setUiHidden( true );
m_tofAccumulatedPhaseFractionsPlot = new RimTofAccumulatedPhaseFractionsPlot; m_tofAccumulatedPhaseFractionsPlot = new RimTofAccumulatedPhaseFractionsPlot;
m_nameConfig->setCustomName( "Well Allocation Plot" );
this->setAsPlotMdiWindow(); this->setAsPlotMdiWindow();
m_accumulatedWellFlowPlot->setAvailableDepthUnits( {} );
m_accumulatedWellFlowPlot->setAvailableDepthTypes(
{RimWellLogPlot::CONNECTION_NUMBER, RimWellLogPlot::TRUE_VERTICAL_DEPTH, RimWellLogPlot::PSEUDO_LENGTH} );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -138,6 +134,7 @@ RimWellAllocationPlot::~RimWellAllocationPlot()
{ {
removeMdiWindowFromMdiArea(); removeMdiWindowFromMdiArea();
delete m_accumulatedWellFlowPlot();
delete m_totalWellAllocationPlot(); delete m_totalWellAllocationPlot();
delete m_tofAccumulatedPhaseFractionsPlot(); delete m_tofAccumulatedPhaseFractionsPlot();
@ -168,6 +165,18 @@ void RimWellAllocationPlot::setFromSimulationWell( RimSimWellInView* simWell )
onLoadDataAndUpdate(); onLoadDataAndUpdate();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::deleteViewWidget()
{
if ( m_wellAllocationPlotWidget )
{
m_wellAllocationPlotWidget->deleteLater();
m_wellAllocationPlotWidget = nullptr;
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -176,22 +185,22 @@ void RimWellAllocationPlot::updateFromWell()
// Delete existing tracks // Delete existing tracks
{ {
std::vector<RimWellLogTrack*> tracks; std::vector<RimWellLogTrack*> tracks;
descendantsIncludingThisOfType( tracks ); accumulatedWellFlowPlot()->descendantsIncludingThisOfType( tracks );
for ( RimWellLogTrack* t : tracks ) for ( RimWellLogTrack* t : tracks )
{ {
removeTrack( t ); accumulatedWellFlowPlot()->removeTrack( t );
delete t; delete t;
} }
} }
CVF_ASSERT( trackCount() == 0 ); CVF_ASSERT( accumulatedWellFlowPlot()->trackCount() == 0 );
QString description; QString description;
if ( m_flowType() == ACCUMULATED ) description = "Accumulated Flow"; if ( m_flowType() == ACCUMULATED ) description = "Accumulated Flow";
if ( m_flowType() == INFLOW ) description = "Inflow Rates"; if ( m_flowType() == INFLOW ) description = "Inflow Rates";
setDescription( description + " (" + m_wellName + ")" ); accumulatedWellFlowPlot()->setDescription( description + " (" + m_wellName + ")" );
if ( !m_case ) return; if ( !m_case ) return;
@ -243,7 +252,7 @@ void RimWellAllocationPlot::updateFromWell()
} }
} }
auto depthType = this->depthType(); auto depthType = accumulatedWellFlowPlot()->depthType();
if ( depthType == RimWellLogPlot::MEASURED_DEPTH ) return; if ( depthType == RimWellLogPlot::MEASURED_DEPTH ) return;
@ -261,7 +270,7 @@ void RimWellAllocationPlot::updateFromWell()
plotTrack->setFormationsForCaseWithSimWellOnly( true ); plotTrack->setFormationsForCaseWithSimWellOnly( true );
plotTrack->setFormationBranchIndex( (int)brIdx ); plotTrack->setFormationBranchIndex( (int)brIdx );
addTrack( plotTrack ); accumulatedWellFlowPlot()->addTrack( plotTrack );
const std::vector<double>& depthValues = depthType == RimWellLogPlot::CONNECTION_NUMBER const std::vector<double>& depthValues = depthType == RimWellLogPlot::CONNECTION_NUMBER
? wfCalculator->connectionNumbersFromTop( brIdx ) ? wfCalculator->connectionNumbersFromTop( brIdx )
@ -310,10 +319,7 @@ void RimWellAllocationPlot::updateFromWell()
/// Pie chart /// Pie chart
m_totalWellAllocationPlot->clearSlices(); m_totalWellAllocationPlot->clearSlices();
if ( allocationPlotWidget() ) if ( m_wellAllocationPlotWidget ) m_wellAllocationPlotWidget->clearLegend();
{
allocationPlotWidget()->clearLegend();
}
if ( wfCalculator ) if ( wfCalculator )
{ {
@ -330,19 +336,21 @@ void RimWellAllocationPlot::updateFromWell()
double tracerPercent = 100 * tracerVal.second; double tracerPercent = 100 * tracerVal.second;
m_totalWellAllocationPlot->addSlice( tracerVal.first, color, tracerPercent ); m_totalWellAllocationPlot->addSlice( tracerVal.first, color, tracerPercent );
if ( allocationPlotWidget() ) if ( m_wellAllocationPlotWidget )
allocationPlotWidget()->addLegendItem( tracerVal.first, color, tracerPercent ); m_wellAllocationPlotWidget->addLegendItem( tracerVal.first, color, tracerPercent );
} }
} }
if ( allocationPlotWidget() ) allocationPlotWidget()->showLegend( m_wellAllocationPlotLegend->isShowingLegend() ); if ( m_wellAllocationPlotWidget )
m_wellAllocationPlotWidget->showLegend( m_wellAllocationPlotLegend->isShowingLegend() );
m_totalWellAllocationPlot->updateConnectedEditors(); m_totalWellAllocationPlot->updateConnectedEditors();
updateConnectedEditors();
accumulatedWellFlowPlot()->updateConnectedEditors();
m_tofAccumulatedPhaseFractionsPlot->reloadFromWell(); m_tofAccumulatedPhaseFractionsPlot->reloadFromWell();
m_tofAccumulatedPhaseFractionsPlot->updateConnectedEditors(); m_tofAccumulatedPhaseFractionsPlot->updateConnectedEditors();
if ( allocationPlotWidget() ) allocationPlotWidget()->updateGeometry(); if ( m_wellAllocationPlotWidget ) m_wellAllocationPlotWidget->updateGeometry();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -466,6 +474,26 @@ void RimWellAllocationPlot::addStackedCurve( const QString& tracerNa
curve->loadDataAndUpdate( true ); curve->loadDataAndUpdate( true );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::updateWidgetTitleWindowTitle()
{
updateMdiWindowTitle();
if ( m_wellAllocationPlotWidget )
{
if ( m_showPlotTitle )
{
m_wellAllocationPlotWidget->showTitle( m_userName );
}
else
{
m_wellAllocationPlotWidget->hideTitle();
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -513,6 +541,30 @@ QString RimWellAllocationPlot::wellStatusTextForTimeStep( const QString&
return statusText; return statusText;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimWellAllocationPlot::viewWidget()
{
return m_wellAllocationPlotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::zoomAll()
{
m_accumulatedWellFlowPlot()->zoomAll();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlot* RimWellAllocationPlot::accumulatedWellFlowPlot()
{
return m_accumulatedWellFlowPlot();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -559,7 +611,7 @@ int RimWellAllocationPlot::timeStep()
QList<caf::PdmOptionItemInfo> QList<caf::PdmOptionItemInfo>
RimWellAllocationPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) RimWellAllocationPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{ {
QList<caf::PdmOptionItemInfo> options = RimWellLogPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_wellName ) if ( fieldNeedingOptions == &m_wellName )
{ {
@ -650,7 +702,7 @@ void RimWellAllocationPlot::removeFromMdiAreaAndDeleteViewWidget()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::showPlotLegend( bool doShow ) void RimWellAllocationPlot::showPlotLegend( bool doShow )
{ {
if ( allocationPlotWidget() ) allocationPlotWidget()->showLegend( doShow ); if ( m_wellAllocationPlotWidget ) m_wellAllocationPlotWidget->showLegend( doShow );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -662,7 +714,11 @@ void RimWellAllocationPlot::fieldChangedByUi( const caf::PdmFieldHandle* changed
{ {
RimViewWindow::fieldChangedByUi( changedField, oldValue, newValue ); RimViewWindow::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_case ) if ( changedField == &m_userName || changedField == &m_showPlotTitle )
{
updateWidgetTitleWindowTitle();
}
else if ( changedField == &m_case )
{ {
if ( m_flowDiagSolution && m_case ) if ( m_flowDiagSolution && m_case )
{ {
@ -717,11 +773,30 @@ std::set<QString> RimWellAllocationPlot::findSortedWellNames()
return sortedWellNames; return sortedWellNames;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QImage RimWellAllocationPlot::snapshotWindowContent()
{
QImage image;
if ( m_wellAllocationPlotWidget )
{
QPixmap pix = QPixmap::grabWidget( m_wellAllocationPlotWidget );
image = pix.toImage();
}
return image;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) void RimWellAllocationPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{ {
uiOrdering.add( &m_userName );
uiOrdering.add( &m_showPlotTitle );
caf::PdmUiGroup& dataGroup = *uiOrdering.addNewGroup( "Plot Data" ); caf::PdmUiGroup& dataGroup = *uiOrdering.addNewGroup( "Plot Data" );
dataGroup.add( &m_case ); dataGroup.add( &m_case );
dataGroup.add( &m_timeStep ); dataGroup.add( &m_timeStep );
@ -734,12 +809,24 @@ void RimWellAllocationPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOr
optionGroup.add( &m_groupSmallContributions ); optionGroup.add( &m_groupSmallContributions );
optionGroup.add( &m_smallContributionsThreshold ); optionGroup.add( &m_smallContributionsThreshold );
m_smallContributionsThreshold.uiCapability()->setUiReadOnly( !m_groupSmallContributions() ); m_smallContributionsThreshold.uiCapability()->setUiReadOnly( !m_groupSmallContributions() );
}
caf::PdmUiGroup* legendAndAxisGroup = uiOrdering.addNewGroup( "Legend and Axis" ); //--------------------------------------------------------------------------------------------------
legendAndAxisGroup->setCollapsedByDefault( true ); ///
uiOrderingForPlotSettings( *legendAndAxisGroup ); //--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::setDescription( const QString& description )
{
m_userName = description;
uiOrdering.skipRemainingFields( true ); updateWidgetTitleWindowTitle();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellAllocationPlot::description() const
{
return m_userName();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -749,37 +836,17 @@ void RimWellAllocationPlot::onLoadDataAndUpdate()
{ {
updateMdiWindowVisibility(); updateMdiWindowVisibility();
updateFromWell(); updateFromWell();
RimWellLogPlot::onLoadDataAndUpdate(); m_accumulatedWellFlowPlot->loadDataAndUpdate();
updateFormationNamesData(); updateFormationNamesData();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::initAfterRead()
{
if ( m_accumulatedWellFlowPlot_OBSOLETE )
{
RimWellLogPlot& wellLogPlot = dynamic_cast<RimWellLogPlot&>( *this );
wellLogPlot = std::move( *m_accumulatedWellFlowPlot_OBSOLETE.value() );
m_accumulatedWellFlowPlot_OBSOLETE = nullptr;
}
if ( m_showPlotTitle_OBSOLETE() && !m_showTitleInPlot() )
{
m_showTitleInPlot = m_showPlotTitle_OBSOLETE();
}
RimWellLogPlot::initAfterRead();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QWidget* RimWellAllocationPlot::createViewWidget( QWidget* mainWindowParent ) QWidget* RimWellAllocationPlot::createViewWidget( QWidget* mainWindowParent )
{ {
m_viewer = new RiuWellAllocationPlot( this, mainWindowParent ); m_wellAllocationPlotWidget = new RiuWellAllocationPlot( this, mainWindowParent );
return m_viewer; return m_wellAllocationPlotWidget;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -798,42 +865,9 @@ cvf::Color3f RimWellAllocationPlot::getTracerColor( const QString& tracerName )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::updateFormationNamesData() const void RimWellAllocationPlot::updateFormationNamesData() const
{ {
for ( size_t i = 0; i < trackCount(); ++i ) for ( size_t i = 0; i < m_accumulatedWellFlowPlot->trackCount(); ++i )
{ {
RimWellLogTrack* track = trackByIndex( i ); RimWellLogTrack* track = m_accumulatedWellFlowPlot->trackByIndex( i );
track->setAndUpdateSimWellFormationNamesData( m_case, m_wellName ); track->setAndUpdateSimWellFormationNamesData( m_case, m_wellName );
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RiaDefines::DepthUnitType> RimWellAllocationPlot::availableDepthUnits() const
{
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RimWellLogPlot::DepthTypeEnum> RimWellAllocationPlot::availableDepthTypes() const
{
return {TRUE_VERTICAL_DEPTH, PSEUDO_LENGTH, CONNECTION_NUMBER};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::onDepthTypeChanged()
{
loadDataAndUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuWellAllocationPlot* RimWellAllocationPlot::allocationPlotWidget() const
{
RiuWellAllocationPlot* plotWidget = dynamic_cast<RiuWellAllocationPlot*>( m_viewer.data() );
return plotWidget;
}

View File

@ -19,7 +19,6 @@
#pragma once #pragma once
#include "RimViewWindow.h" #include "RimViewWindow.h"
#include "RimWellLogPlot.h"
#include "cafPdmField.h" #include "cafPdmField.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
@ -34,7 +33,7 @@ class RimSimWellInView;
class RimTofAccumulatedPhaseFractionsPlot; class RimTofAccumulatedPhaseFractionsPlot;
class RimTotalWellAllocationPlot; class RimTotalWellAllocationPlot;
class RimWellAllocationPlotLegend; class RimWellAllocationPlotLegend;
class RimWellLogPlot;
class RimWellLogTrack; class RimWellLogTrack;
class RiuWellAllocationPlot; class RiuWellAllocationPlot;
@ -52,7 +51,7 @@ class PdmOptionItemInfo;
/// ///
/// ///
//================================================================================================== //==================================================================================================
class RimWellAllocationPlot : public RimWellLogPlot class RimWellAllocationPlot : public RimViewWindow
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
@ -69,6 +68,13 @@ public:
void setFromSimulationWell( RimSimWellInView* simWell ); void setFromSimulationWell( RimSimWellInView* simWell );
void setDescription( const QString& description );
QString description() const;
QWidget* viewWidget() override;
void zoomAll() override;
RimWellLogPlot* accumulatedWellFlowPlot();
RimTotalWellAllocationPlot* totalWellFlowPlot(); RimTotalWellAllocationPlot* totalWellFlowPlot();
RimTofAccumulatedPhaseFractionsPlot* tofAccumulatedPhaseFractionsPlot(); RimTofAccumulatedPhaseFractionsPlot* tofAccumulatedPhaseFractionsPlot();
caf::PdmObject* plotLegend(); caf::PdmObject* plotLegend();
@ -83,6 +89,10 @@ public:
protected: protected:
// Overridden PDM methods // Overridden PDM methods
caf::PdmFieldHandle* userDescriptionField() override
{
return &m_userName;
}
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue ) override; const QVariant& newValue ) override;
@ -92,9 +102,10 @@ protected:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override; bool* useOptionsOnly ) override;
QImage snapshotWindowContent() override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void onLoadDataAndUpdate() override; void onLoadDataAndUpdate() override;
void initAfterRead() override;
private: private:
void updateFromWell(); void updateFromWell();
@ -108,22 +119,24 @@ private:
const std::vector<double>& accFlow, const std::vector<double>& accFlow,
RimWellLogTrack* plotTrack ); RimWellLogTrack* plotTrack );
void updateWidgetTitleWindowTitle();
static QString wellStatusTextForTimeStep( const QString& wellName, static QString wellStatusTextForTimeStep( const QString& wellName,
const RimEclipseResultCase* eclipseResultCase, const RimEclipseResultCase* eclipseResultCase,
size_t timeStep ); size_t timeStep );
// RimViewWindow overrides
QWidget* createViewWidget( QWidget* mainWindowParent ) override; QWidget* createViewWidget( QWidget* mainWindowParent ) override;
void deleteViewWidget() override;
cvf::Color3f getTracerColor( const QString& tracerName ); cvf::Color3f getTracerColor( const QString& tracerName );
void updateFormationNamesData() const; void updateFormationNamesData() const;
std::set<RiaDefines::DepthUnitType> availableDepthUnits() const override;
std::set<RimWellLogPlot::DepthTypeEnum> availableDepthTypes() const override;
void onDepthTypeChanged() override;
RiuWellAllocationPlot* allocationPlotWidget() const;
private: private:
caf::PdmField<bool> m_showPlotTitle;
caf::PdmField<QString> m_userName;
caf::PdmField<bool> m_branchDetection; caf::PdmField<bool> m_branchDetection;
caf::PdmPtrField<RimEclipseResultCase*> m_case; caf::PdmPtrField<RimEclipseResultCase*> m_case;
@ -134,10 +147,10 @@ private:
caf::PdmField<double> m_smallContributionsThreshold; caf::PdmField<double> m_smallContributionsThreshold;
caf::PdmField<caf::AppEnum<FlowType>> m_flowType; caf::PdmField<caf::AppEnum<FlowType>> m_flowType;
QPointer<RiuWellAllocationPlot> m_wellAllocationPlotWidget;
caf::PdmChildField<RimWellLogPlot*> m_accumulatedWellFlowPlot;
caf::PdmChildField<RimTotalWellAllocationPlot*> m_totalWellAllocationPlot; caf::PdmChildField<RimTotalWellAllocationPlot*> m_totalWellAllocationPlot;
caf::PdmChildField<RimWellAllocationPlotLegend*> m_wellAllocationPlotLegend; caf::PdmChildField<RimWellAllocationPlotLegend*> m_wellAllocationPlotLegend;
caf::PdmChildField<RimTofAccumulatedPhaseFractionsPlot*> m_tofAccumulatedPhaseFractionsPlot; caf::PdmChildField<RimTofAccumulatedPhaseFractionsPlot*> m_tofAccumulatedPhaseFractionsPlot;
caf::PdmChildField<RimWellLogPlot*> m_accumulatedWellFlowPlot_OBSOLETE;
caf::PdmField<bool> m_showPlotTitle_OBSOLETE;
}; };

View File

@ -138,6 +138,8 @@ RimWellPltPlot::RimWellPltPlot()
this->setAsPlotMdiWindow(); this->setAsPlotMdiWindow();
m_doInitAfterLoad = false; m_doInitAfterLoad = false;
m_isOnLoad = true; m_isOnLoad = true;
setAvailableDepthTypes( {RimWellLogPlot::MEASURED_DEPTH} );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -247,14 +249,6 @@ void RimWellPltPlot::updateFormationsOnPlot() const
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RimWellLogPlot::DepthTypeEnum> RimWellPltPlot::availableDepthTypes() const
{
return {RimWellLogPlot::MEASURED_DEPTH};
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -114,7 +114,6 @@ private:
void setPlotXAxisTitles( RimWellLogTrack* plotTrack ); void setPlotXAxisTitles( RimWellLogTrack* plotTrack );
void updateFormationsOnPlot() const; void updateFormationsOnPlot() const;
std::set<RimWellLogPlot::DepthTypeEnum> availableDepthTypes() const override;
private: private:
caf::PdmField<bool> m_showPlotTitle_OBSOLETE; caf::PdmField<bool> m_showPlotTitle_OBSOLETE;

View File

@ -116,6 +116,9 @@ RimWellLogPlot::RimWellLogPlot()
m_nameConfig.uiCapability()->setUiTreeChildrenHidden( true ); m_nameConfig.uiCapability()->setUiTreeChildrenHidden( true );
m_nameConfig = new RimWellLogPlotNameConfig(); m_nameConfig = new RimWellLogPlotNameConfig();
m_availableDepthUnits = {RiaDefines::UNIT_METER, RiaDefines::UNIT_FEET};
m_availableDepthTypes = {MEASURED_DEPTH, TRUE_VERTICAL_DEPTH};
m_minAvailableDepth = HUGE_VAL; m_minAvailableDepth = HUGE_VAL;
m_maxAvailableDepth = -HUGE_VAL; m_maxAvailableDepth = -HUGE_VAL;
} }
@ -247,7 +250,7 @@ QList<caf::PdmOptionItemInfo> RimWellLogPlot::calculateValueOptions( const caf::
{ {
DepthTypeEnum enumVal = DepthAppEnum::fromIndex( i ); DepthTypeEnum enumVal = DepthAppEnum::fromIndex( i );
if ( availableDepthTypes().count( enumVal ) ) if ( m_availableDepthTypes.count( enumVal ) )
{ {
options.push_back( caf::PdmOptionItemInfo( DepthAppEnum::uiText( enumVal ), enumVal ) ); options.push_back( caf::PdmOptionItemInfo( DepthAppEnum::uiText( enumVal ), enumVal ) );
} }
@ -256,7 +259,7 @@ QList<caf::PdmOptionItemInfo> RimWellLogPlot::calculateValueOptions( const caf::
else if ( fieldNeedingOptions == &m_depthUnit ) else if ( fieldNeedingOptions == &m_depthUnit )
{ {
using UnitAppEnum = caf::AppEnum<RiaDefines::DepthUnitType>; using UnitAppEnum = caf::AppEnum<RiaDefines::DepthUnitType>;
for ( auto depthUnit : availableDepthUnits() ) for ( auto depthUnit : m_availableDepthUnits )
{ {
options.push_back( caf::PdmOptionItemInfo( UnitAppEnum::uiText( depthUnit ), depthUnit ) ); options.push_back( caf::PdmOptionItemInfo( UnitAppEnum::uiText( depthUnit ), depthUnit ) );
} }
@ -573,12 +576,12 @@ void RimWellLogPlot::uiOrderingForDepthAxis( caf::PdmUiOrdering& uiOrdering )
{ {
caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup( "Depth Axis" ); caf::PdmUiGroup* gridGroup = uiOrdering.addNewGroup( "Depth Axis" );
if ( availableDepthTypes().size() > 1u ) if ( m_availableDepthTypes.size() > 1u )
{ {
gridGroup->add( &m_depthType ); gridGroup->add( &m_depthType );
} }
if ( availableDepthUnits().size() > 1u ) if ( m_availableDepthUnits.size() > 1u )
{ {
gridGroup->add( &m_depthUnit ); gridGroup->add( &m_depthUnit );
} }
@ -738,6 +741,22 @@ RimWellLogCurveCommonDataSource* RimWellLogPlot::commonDataSource() const
return m_commonDataSource; return m_commonDataSource;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::setAvailableDepthUnits( const std::set<RiaDefines::DepthUnitType>& depthUnits )
{
m_availableDepthUnits = depthUnits;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::setAvailableDepthTypes( const std::set<DepthTypeEnum>& depthTypes )
{
m_availableDepthTypes = depthTypes;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1085,22 +1104,6 @@ void RimWellLogPlot::setDepthUnit( RiaDefines::DepthUnitType depthUnit )
updateTracks(); updateTracks();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RiaDefines::DepthUnitType> RimWellLogPlot::availableDepthUnits() const
{
return {RiaDefines::UNIT_METER, RiaDefines::UNIT_FEET};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RimWellLogPlot::DepthTypeEnum> RimWellLogPlot::availableDepthTypes() const
{
return {MEASURED_DEPTH, TRUE_VERTICAL_DEPTH};
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -132,6 +132,9 @@ public:
void handleKeyPressEvent( QKeyEvent* keyEvent ); void handleKeyPressEvent( QKeyEvent* keyEvent );
RimWellLogCurveCommonDataSource* commonDataSource() const; RimWellLogCurveCommonDataSource* commonDataSource() const;
void setAvailableDepthUnits( const std::set<RiaDefines::DepthUnitType>& depthUnits );
void setAvailableDepthTypes( const std::set<RimWellLogPlot::DepthTypeEnum>& depthTypes );
protected: protected:
void performAutoNameUpdate() override; void performAutoNameUpdate() override;
@ -158,8 +161,6 @@ private:
void recreateTrackPlots(); void recreateTrackPlots();
void detachAllCurves(); void detachAllCurves();
virtual std::set<RiaDefines::DepthUnitType> availableDepthUnits() const;
virtual std::set<RimWellLogPlot::DepthTypeEnum> availableDepthTypes() const;
void updatePlotTitle(); void updatePlotTitle();
virtual void onDepthTypeChanged(); virtual void onDepthTypeChanged();
@ -181,6 +182,9 @@ protected:
caf::PdmChildField<RimWellLogPlotNameConfig*> m_nameConfig; caf::PdmChildField<RimWellLogPlotNameConfig*> m_nameConfig;
std::set<RiaDefines::DepthUnitType> m_availableDepthUnits;
std::set<RimWellLogPlot::DepthTypeEnum> m_availableDepthTypes;
double m_minAvailableDepth; double m_minAvailableDepth;
double m_maxAvailableDepth; double m_maxAvailableDepth;

View File

@ -21,11 +21,11 @@
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RimContextCommandBuilder.h" #include "RimContextCommandBuilder.h"
#include "RimTofAccumulatedPhaseFractionsPlot.h"
#include "RimTotalWellAllocationPlot.h" #include "RimTotalWellAllocationPlot.h"
#include "RimWellAllocationPlot.h" #include "RimWellAllocationPlot.h"
#include "RimWellLogPlot.h" #include "RimWellLogPlot.h"
#include "RimWellLogTrack.h" #include "RimWellLogTrack.h"
#include "RimTofAccumulatedPhaseFractionsPlot.h"
#include "RiuContextMenuLauncher.h" #include "RiuContextMenuLauncher.h"
#include "RiuNightchartsWidget.h" #include "RiuNightchartsWidget.h"
@ -38,44 +38,108 @@
#include <QLabel> #include <QLabel>
#include <QMenu> #include <QMenu>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent) RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent)
: RiuWellLogPlot( plotDefinition, parent ) : QFrame(parent)
, m_plotDefinition(plotDefinition)
{ {
Q_ASSERT(m_plotDefinition); Q_ASSERT(m_plotDefinition);
auto leftColumnLayout = new QVBoxLayout(); QVBoxLayout* mainLayout = new QVBoxLayout();
this->setLayout(mainLayout);
this->layout()->setMargin(0);
this->layout()->setSpacing(2);
m_plotLayout->insertLayout( 0, leftColumnLayout ); m_titleLabel = new QLabel(this);
new RiuPlotObjectPicker(m_titleLabel, m_plotDefinition->accumulatedWellFlowPlot());
QFont font = m_titleLabel->font();
font.setPointSize(14);
font.setBold(true);
m_titleLabel->setFont(font);
// White background
QPalette pal = this->palette();
pal.setColor(QPalette::Background, Qt::white);
this->setAutoFillBackground(true);
this->setPalette(pal);
mainLayout->addWidget(m_titleLabel, 0, Qt::AlignCenter);
auto plotWidgetsLayout = new QHBoxLayout();
auto rightColumnLayout = new QVBoxLayout();
mainLayout->addLayout(plotWidgetsLayout);
plotWidgetsLayout->addLayout(rightColumnLayout);
m_legendWidget = new RiuNightchartsWidget(this); m_legendWidget = new RiuNightchartsWidget(this);
RimWellAllocationPlot* wellAllocationPlot = dynamic_cast<RimWellAllocationPlot*>( m_plotDefinition.p() ); new RiuPlotObjectPicker(m_legendWidget, m_plotDefinition->plotLegend());
new RiuPlotObjectPicker( m_legendWidget, wellAllocationPlot->plotLegend() );
caf::CmdFeatureMenuBuilder menuBuilder; caf::CmdFeatureMenuBuilder menuBuilder;
menuBuilder << "RicShowTotalAllocationDataFeature"; menuBuilder << "RicShowTotalAllocationDataFeature";
new RiuContextMenuLauncher(m_legendWidget, menuBuilder); new RiuContextMenuLauncher(m_legendWidget, menuBuilder);
leftColumnLayout->addWidget( m_legendWidget ); rightColumnLayout->addWidget(m_legendWidget);
m_legendWidget->showPie(false); m_legendWidget->showPie(false);
QWidget* totalFlowAllocationWidget = wellAllocationPlot->totalWellFlowPlot()->createViewWidget( nullptr ); QWidget* totalFlowAllocationWidget = m_plotDefinition->totalWellFlowPlot()->createViewWidget(this);
new RiuPlotObjectPicker( totalFlowAllocationWidget, wellAllocationPlot->totalWellFlowPlot() ); new RiuPlotObjectPicker(totalFlowAllocationWidget, m_plotDefinition->totalWellFlowPlot());
new RiuContextMenuLauncher(totalFlowAllocationWidget, menuBuilder); new RiuContextMenuLauncher(totalFlowAllocationWidget, menuBuilder);
leftColumnLayout->addWidget( totalFlowAllocationWidget, Qt::AlignTop ); rightColumnLayout->addWidget(totalFlowAllocationWidget, Qt::AlignTop);
leftColumnLayout->addWidget( wellAllocationPlot->tofAccumulatedPhaseFractionsPlot()->createViewWidget( nullptr ), rightColumnLayout->addWidget(m_plotDefinition->tofAccumulatedPhaseFractionsPlot()->createViewWidget(this), Qt::AlignTop);
Qt::AlignTop ); rightColumnLayout->addStretch();
leftColumnLayout->addStretch();
this->update(); QWidget* wellFlowWidget = m_plotDefinition->accumulatedWellFlowPlot()->createPlotWidget();
plotWidgetsLayout->addWidget(wellFlowWidget);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuWellAllocationPlot::~RiuWellAllocationPlot() {} RiuWellAllocationPlot::~RiuWellAllocationPlot()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellAllocationPlot* RiuWellAllocationPlot::ownerPlotDefinition()
{
return m_plotDefinition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewWindow* RiuWellAllocationPlot::ownerViewWindow() const
{
return m_plotDefinition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::showTitle(const QString& title)
{
m_titleLabel->show();
m_titleLabel->setText(title);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::hideTitle()
{
m_titleLabel->hide();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@ -88,6 +152,7 @@ void RiuWellAllocationPlot::showLegend( bool doShow )
m_legendWidget->hide(); m_legendWidget->hide();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -100,6 +165,7 @@ void RiuWellAllocationPlot::addLegendItem( const QString& name, const cvf::Color
m_legendWidget->update(); m_legendWidget->update();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -108,6 +174,7 @@ void RiuWellAllocationPlot::clearLegend()
m_legendWidget->clear(); m_legendWidget->clear();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -141,3 +208,11 @@ QSize RiuWellAllocationPlot::sizeHint() const
{ {
return QSize(0, 0); return QSize(0, 0);
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::setDefaults()
{
}

View File

@ -18,22 +18,21 @@
#pragma once #pragma once
#include "RiuWellLogPlot.h" #include "qwt_plot.h"
#include "cafPdmPointer.h" #include "cafPdmPointer.h"
#include "qwt_plot.h"
#include <QFrame>
#include <QPointer> #include <QPointer>
#include <QFrame>
#include "RiuInterfaceToViewWindow.h"
class RimWellAllocationPlot; class RimWellAllocationPlot;
class RiuNightchartsWidget; class RiuNightchartsWidget;
class QLabel; class QLabel;
namespace cvf namespace cvf {
{
class Color3f; class Color3f;
} }
@ -42,18 +41,23 @@ class Color3f;
// //
// //
//================================================================================================== //==================================================================================================
class RiuWellAllocationPlot : public RiuWellLogPlot class RiuWellAllocationPlot : public QFrame, public RiuInterfaceToViewWindow
{ {
Q_OBJECT; Q_OBJECT;
public: public:
RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent = nullptr); RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent = nullptr);
~RiuWellAllocationPlot() override; ~RiuWellAllocationPlot() override;
RimWellAllocationPlot* ownerPlotDefinition();
RimViewWindow* ownerViewWindow() const override;
void showTitle(const QString& title);
void hideTitle();
void showLegend(bool doShow); void showLegend(bool doShow);
void addLegendItem(const QString& name, const cvf::Color3f& color, float value); void addLegendItem(const QString& name, const cvf::Color3f& color, float value);
void clearLegend(); void clearLegend();
protected: protected:
QSize sizeHint() const override; QSize sizeHint() const override;
QSize minimumSizeHint() const override; QSize minimumSizeHint() const override;
@ -61,5 +65,10 @@ protected:
void contextMenuEvent(QContextMenuEvent *) override; void contextMenuEvent(QContextMenuEvent *) override;
private: private:
void setDefaults();
private:
caf::PdmPointer<RimWellAllocationPlot> m_plotDefinition;
QPointer<RiuNightchartsWidget> m_legendWidget; QPointer<RiuNightchartsWidget> m_legendWidget;
QPointer<QLabel> m_titleLabel;
}; };