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 "RimWellAllocationPlotLegend.h"
#include "RimWellFlowRateCurve.h"
#include "RimWellLogFile.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RimWellPlotTools.h"
#include "RimWellLogFile.h"
#include "RimWellPlotTools.h"
#include "RiuPlotMainWindow.h"
#include "RiuWellAllocationPlot.h"
#include "RiuWellLogPlot.h"
#include "RiuWellLogTrack.h"
CAF_PDM_SOURCE_INIT( RimWellAllocationPlot, "WellAllocationPlot" );
@@ -71,12 +70,13 @@ void AppEnum<RimWellAllocationPlot::FlowType>::setUp()
///
//--------------------------------------------------------------------------------------------------
RimWellAllocationPlot::RimWellAllocationPlot()
: RimWellLogPlot()
{
CAF_PDM_InitObject( "Well Allocation Plot", ":/WellAllocPlot16x16.png", "", "" );
CAF_PDM_InitField( &m_showPlotTitle_OBSOLETE, "ShowPlotTitle", true, "Show Plot Title", "", "", "" );
m_showPlotTitle_OBSOLETE.xmlCapability()->setIOWritable( false );
CAF_PDM_InitField( &m_userName, "PlotDescription", QString( "Flow Diagnostics Plot" ), "Name", "", "", "" );
m_userName.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitField( &m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "" );
CAF_PDM_InitField( &m_branchDetection,
"BranchDetection",
@@ -95,19 +95,13 @@ RimWellAllocationPlot::RimWellAllocationPlot()
CAF_PDM_InitFieldNoDefault( &m_flowType, "FlowType", "Flow Type", "", "", "" );
CAF_PDM_InitField( &m_groupSmallContributions, "GroupSmallContributions", true, "Group Small Contributions", "", "", "" );
CAF_PDM_InitField( &m_smallContributionsThreshold, "SmallContributionsThreshold", 0.005, "Threshold", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_accumulatedWellFlowPlot_OBSOLETE,
"AccumulatedWellFlowPlot",
"Accumulated Well Flow",
"",
"",
"" );
m_accumulatedWellFlowPlot_OBSOLETE.uiCapability()->setUiHidden( true );
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_accumulatedWellFlowPlot, "AccumulatedWellFlowPlot", "Accumulated Well Flow", "", "", "" );
m_accumulatedWellFlowPlot.uiCapability()->setUiHidden( true );
m_accumulatedWellFlowPlot = new RimWellLogPlot;
m_accumulatedWellFlowPlot->setDepthUnit( RiaDefines::UNIT_NONE );
m_accumulatedWellFlowPlot->setDepthType( RimWellLogPlot::CONNECTION_NUMBER );
m_accumulatedWellFlowPlot->setTrackLegendsVisible( false );
m_accumulatedWellFlowPlot->uiCapability()->setUiIconFromResourceString( ":/WellFlowPlot16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_totalWellAllocationPlot, "TotalWellFlowPlot", "Total Well Flow", "", "", "" );
m_totalWellAllocationPlot.uiCapability()->setUiHidden( true );
@@ -126,9 +120,11 @@ RimWellAllocationPlot::RimWellAllocationPlot()
m_tofAccumulatedPhaseFractionsPlot.uiCapability()->setUiHidden( true );
m_tofAccumulatedPhaseFractionsPlot = new RimTofAccumulatedPhaseFractionsPlot;
m_nameConfig->setCustomName( "Well Allocation Plot" );
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();
delete m_accumulatedWellFlowPlot();
delete m_totalWellAllocationPlot();
delete m_tofAccumulatedPhaseFractionsPlot();
@@ -168,6 +165,18 @@ void RimWellAllocationPlot::setFromSimulationWell( RimSimWellInView* simWell )
onLoadDataAndUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::deleteViewWidget()
{
if ( m_wellAllocationPlotWidget )
{
m_wellAllocationPlotWidget->deleteLater();
m_wellAllocationPlotWidget = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -176,22 +185,22 @@ void RimWellAllocationPlot::updateFromWell()
// Delete existing tracks
{
std::vector<RimWellLogTrack*> tracks;
descendantsIncludingThisOfType( tracks );
accumulatedWellFlowPlot()->descendantsIncludingThisOfType( tracks );
for ( RimWellLogTrack* t : tracks )
{
removeTrack( t );
accumulatedWellFlowPlot()->removeTrack( t );
delete t;
}
}
CVF_ASSERT( trackCount() == 0 );
CVF_ASSERT( accumulatedWellFlowPlot()->trackCount() == 0 );
QString description;
if ( m_flowType() == ACCUMULATED ) description = "Accumulated Flow";
if ( m_flowType() == INFLOW ) description = "Inflow Rates";
setDescription( description + " (" + m_wellName + ")" );
accumulatedWellFlowPlot()->setDescription( description + " (" + m_wellName + ")" );
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;
@@ -261,7 +270,7 @@ void RimWellAllocationPlot::updateFromWell()
plotTrack->setFormationsForCaseWithSimWellOnly( true );
plotTrack->setFormationBranchIndex( (int)brIdx );
addTrack( plotTrack );
accumulatedWellFlowPlot()->addTrack( plotTrack );
const std::vector<double>& depthValues = depthType == RimWellLogPlot::CONNECTION_NUMBER
? wfCalculator->connectionNumbersFromTop( brIdx )
@@ -310,10 +319,7 @@ void RimWellAllocationPlot::updateFromWell()
/// Pie chart
m_totalWellAllocationPlot->clearSlices();
if ( allocationPlotWidget() )
{
allocationPlotWidget()->clearLegend();
}
if ( m_wellAllocationPlotWidget ) m_wellAllocationPlotWidget->clearLegend();
if ( wfCalculator )
{
@@ -330,19 +336,21 @@ void RimWellAllocationPlot::updateFromWell()
double tracerPercent = 100 * tracerVal.second;
m_totalWellAllocationPlot->addSlice( tracerVal.first, color, tracerPercent );
if ( allocationPlotWidget() )
allocationPlotWidget()->addLegendItem( tracerVal.first, color, tracerPercent );
if ( m_wellAllocationPlotWidget )
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();
updateConnectedEditors();
accumulatedWellFlowPlot()->updateConnectedEditors();
m_tofAccumulatedPhaseFractionsPlot->reloadFromWell();
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 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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>
RimWellAllocationPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options = RimWellLogPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly );
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_wellName )
{
@@ -650,7 +702,7 @@ void RimWellAllocationPlot::removeFromMdiAreaAndDeleteViewWidget()
//--------------------------------------------------------------------------------------------------
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 );
if ( changedField == &m_case )
if ( changedField == &m_userName || changedField == &m_showPlotTitle )
{
updateWidgetTitleWindowTitle();
}
else if ( changedField == &m_case )
{
if ( m_flowDiagSolution && m_case )
{
@@ -717,11 +773,30 @@ std::set<QString> RimWellAllocationPlot::findSortedWellNames()
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 )
{
uiOrdering.add( &m_userName );
uiOrdering.add( &m_showPlotTitle );
caf::PdmUiGroup& dataGroup = *uiOrdering.addNewGroup( "Plot Data" );
dataGroup.add( &m_case );
dataGroup.add( &m_timeStep );
@@ -734,12 +809,24 @@ void RimWellAllocationPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOr
optionGroup.add( &m_groupSmallContributions );
optionGroup.add( &m_smallContributionsThreshold );
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();
updateFromWell();
RimWellLogPlot::onLoadDataAndUpdate();
m_accumulatedWellFlowPlot->loadDataAndUpdate();
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 )
{
m_viewer = new RiuWellAllocationPlot( this, mainWindowParent );
return m_viewer;
m_wellAllocationPlotWidget = new RiuWellAllocationPlot( this, mainWindowParent );
return m_wellAllocationPlotWidget;
}
//--------------------------------------------------------------------------------------------------
@@ -798,42 +865,9 @@ cvf::Color3f RimWellAllocationPlot::getTracerColor( const QString& tracerName )
//--------------------------------------------------------------------------------------------------
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 );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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;
}