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;
}

View File

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

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

View File

@ -116,6 +116,9 @@ RimWellLogPlot::RimWellLogPlot()
m_nameConfig.uiCapability()->setUiTreeChildrenHidden( true );
m_nameConfig = new RimWellLogPlotNameConfig();
m_availableDepthUnits = {RiaDefines::UNIT_METER, RiaDefines::UNIT_FEET};
m_availableDepthTypes = {MEASURED_DEPTH, TRUE_VERTICAL_DEPTH};
m_minAvailableDepth = HUGE_VAL;
m_maxAvailableDepth = -HUGE_VAL;
}
@ -247,7 +250,7 @@ QList<caf::PdmOptionItemInfo> RimWellLogPlot::calculateValueOptions( const caf::
{
DepthTypeEnum enumVal = DepthAppEnum::fromIndex( i );
if ( availableDepthTypes().count( enumVal ) )
if ( m_availableDepthTypes.count( 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 )
{
using UnitAppEnum = caf::AppEnum<RiaDefines::DepthUnitType>;
for ( auto depthUnit : availableDepthUnits() )
for ( auto depthUnit : m_availableDepthUnits )
{
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" );
if ( availableDepthTypes().size() > 1u )
if ( m_availableDepthTypes.size() > 1u )
{
gridGroup->add( &m_depthType );
}
if ( availableDepthUnits().size() > 1u )
if ( m_availableDepthUnits.size() > 1u )
{
gridGroup->add( &m_depthUnit );
}
@ -738,6 +741,22 @@ RimWellLogCurveCommonDataSource* RimWellLogPlot::commonDataSource() const
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();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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 );
RimWellLogCurveCommonDataSource* commonDataSource() const;
void setAvailableDepthUnits( const std::set<RiaDefines::DepthUnitType>& depthUnits );
void setAvailableDepthTypes( const std::set<RimWellLogPlot::DepthTypeEnum>& depthTypes );
protected:
void performAutoNameUpdate() override;
@ -158,10 +161,8 @@ private:
void recreateTrackPlots();
void detachAllCurves();
virtual std::set<RiaDefines::DepthUnitType> availableDepthUnits() const;
virtual std::set<RimWellLogPlot::DepthTypeEnum> availableDepthTypes() const;
void updatePlotTitle();
virtual void onDepthTypeChanged();
void updatePlotTitle();
virtual void onDepthTypeChanged();
protected:
caf::PdmField<QString> m_userName_OBSOLETE;
@ -181,6 +182,9 @@ protected:
caf::PdmChildField<RimWellLogPlotNameConfig*> m_nameConfig;
std::set<RiaDefines::DepthUnitType> m_availableDepthUnits;
std::set<RimWellLogPlot::DepthTypeEnum> m_availableDepthTypes;
double m_minAvailableDepth;
double m_maxAvailableDepth;

View File

@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@ -21,11 +21,11 @@
#include "RiaApplication.h"
#include "RimContextCommandBuilder.h"
#include "RimTofAccumulatedPhaseFractionsPlot.h"
#include "RimTotalWellAllocationPlot.h"
#include "RimWellAllocationPlot.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RimTofAccumulatedPhaseFractionsPlot.h"
#include "RiuContextMenuLauncher.h"
#include "RiuNightchartsWidget.h"
@ -38,106 +38,181 @@
#include <QLabel>
#include <QMenu>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuWellAllocationPlot::RiuWellAllocationPlot( RimWellAllocationPlot* plotDefinition, QWidget* parent )
: RiuWellLogPlot( plotDefinition, parent )
RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* 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());
m_legendWidget = new RiuNightchartsWidget( this );
RimWellAllocationPlot* wellAllocationPlot = dynamic_cast<RimWellAllocationPlot*>( m_plotDefinition.p() );
new RiuPlotObjectPicker( m_legendWidget, wellAllocationPlot->plotLegend() );
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);
new RiuPlotObjectPicker(m_legendWidget, m_plotDefinition->plotLegend());
caf::CmdFeatureMenuBuilder menuBuilder;
menuBuilder << "RicShowTotalAllocationDataFeature";
new RiuContextMenuLauncher( m_legendWidget, menuBuilder );
new RiuContextMenuLauncher(m_legendWidget, menuBuilder);
leftColumnLayout->addWidget( m_legendWidget );
m_legendWidget->showPie( false );
rightColumnLayout->addWidget(m_legendWidget);
m_legendWidget->showPie(false);
QWidget* totalFlowAllocationWidget = wellAllocationPlot->totalWellFlowPlot()->createViewWidget( nullptr );
new RiuPlotObjectPicker( totalFlowAllocationWidget, wellAllocationPlot->totalWellFlowPlot() );
new RiuContextMenuLauncher( totalFlowAllocationWidget, menuBuilder );
QWidget* totalFlowAllocationWidget = m_plotDefinition->totalWellFlowPlot()->createViewWidget(this);
new RiuPlotObjectPicker(totalFlowAllocationWidget, m_plotDefinition->totalWellFlowPlot());
new RiuContextMenuLauncher(totalFlowAllocationWidget, menuBuilder);
leftColumnLayout->addWidget( totalFlowAllocationWidget, Qt::AlignTop );
leftColumnLayout->addWidget( wellAllocationPlot->tofAccumulatedPhaseFractionsPlot()->createViewWidget( nullptr ),
Qt::AlignTop );
leftColumnLayout->addStretch();
this->update();
rightColumnLayout->addWidget(totalFlowAllocationWidget, Qt::AlignTop);
rightColumnLayout->addWidget(m_plotDefinition->tofAccumulatedPhaseFractionsPlot()->createViewWidget(this), Qt::AlignTop);
rightColumnLayout->addStretch();
QWidget* wellFlowWidget = m_plotDefinition->accumulatedWellFlowPlot()->createPlotWidget();
plotWidgetsLayout->addWidget(wellFlowWidget);
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RiuWellAllocationPlot::~RiuWellAllocationPlot() {}
RiuWellAllocationPlot::~RiuWellAllocationPlot()
{
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::showLegend( bool doShow )
RimWellAllocationPlot* RiuWellAllocationPlot::ownerPlotDefinition()
{
if ( doShow )
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();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::showLegend(bool doShow)
{
if (doShow)
m_legendWidget->show();
else
m_legendWidget->hide();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::addLegendItem( const QString& name, const cvf::Color3f& color, float value )
{
QColor sliceColor( color.rByte(), color.gByte(), color.bByte() );
m_legendWidget->addItem( name, sliceColor, value );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::addLegendItem(const QString& name, const cvf::Color3f& color, float value)
{
QColor sliceColor(color.rByte(), color.gByte(), color.bByte());
m_legendWidget->addItem(name, sliceColor, value);
m_legendWidget->updateGeometry();
m_legendWidget->update();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::clearLegend()
{
m_legendWidget->clear();
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QSize RiuWellAllocationPlot::minimumSizeHint() const
{
return QSize( 0, 100 );
return QSize(0, 100);
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::contextMenuEvent( QContextMenuEvent* event )
void RiuWellAllocationPlot::contextMenuEvent(QContextMenuEvent* event)
{
QMenu menu;
QMenu menu;
caf::CmdFeatureMenuBuilder menuBuilder;
menuBuilder << "RicShowContributingWellsFromPlotFeature";
menuBuilder.appendToMenu( &menu );
menuBuilder.appendToMenu(&menu);
if ( menu.actions().size() > 0 )
if (menu.actions().size() > 0)
{
menu.exec( event->globalPos() );
menu.exec(event->globalPos());
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
QSize RiuWellAllocationPlot::sizeHint() const
{
return QSize( 0, 0 );
return QSize(0, 0);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuWellAllocationPlot::setDefaults()
{
}

View File

@ -1,40 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RiuWellLogPlot.h"
#include "qwt_plot.h"
#include "cafPdmPointer.h"
#include "qwt_plot.h"
#include <QFrame>
#include <QPointer>
#include <QFrame>
#include "RiuInterfaceToViewWindow.h"
class RimWellAllocationPlot;
class RiuNightchartsWidget;
class QLabel;
namespace cvf
{
class Color3f;
namespace cvf {
class Color3f;
}
//==================================================================================================
@ -42,24 +41,34 @@ class Color3f;
//
//
//==================================================================================================
class RiuWellAllocationPlot : public RiuWellLogPlot
class RiuWellAllocationPlot : public QFrame, public RiuInterfaceToViewWindow
{
Q_OBJECT;
public:
RiuWellAllocationPlot( RimWellAllocationPlot* plotDefinition, QWidget* parent = nullptr );
RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent = nullptr);
~RiuWellAllocationPlot() override;
void showLegend( bool doShow );
void addLegendItem( const QString& name, const cvf::Color3f& color, float value );
void clearLegend();
RimWellAllocationPlot* ownerPlotDefinition();
RimViewWindow* ownerViewWindow() const override;
void showTitle(const QString& title);
void hideTitle();
void showLegend(bool doShow);
void addLegendItem(const QString& name, const cvf::Color3f& color, float value);
void clearLegend();
protected:
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
void contextMenuEvent( QContextMenuEvent* ) override;
void contextMenuEvent(QContextMenuEvent *) override;
private:
void setDefaults();
private:
caf::PdmPointer<RimWellAllocationPlot> m_plotDefinition;
QPointer<RiuNightchartsWidget> m_legendWidget;
QPointer<QLabel> m_titleLabel;
};