Introduce RimGridPlotWindow and RiuQwtPlotWidget

This commit is contained in:
Gaute Lindkvist
2019-10-11 15:54:19 +02:00
parent 2857a13e7c
commit c578a43b53
89 changed files with 5249 additions and 3809 deletions

View File

@@ -46,8 +46,8 @@
#include "RimWellLogFile.h"
#include "RimWellPlotTools.h"
#include "RiuPlotMainWindow.h"
#include "RiuQwtPlotWidget.h"
#include "RiuWellAllocationPlot.h"
#include "RiuWellLogTrack.h"
CAF_PDM_SOURCE_INIT( RimWellAllocationPlot, "WellAllocationPlot" );
@@ -100,7 +100,7 @@ RimWellAllocationPlot::RimWellAllocationPlot()
m_accumulatedWellFlowPlot = new RimWellLogPlot;
m_accumulatedWellFlowPlot->setDepthUnit( RiaDefines::UNIT_NONE );
m_accumulatedWellFlowPlot->setDepthType( RimWellLogPlot::CONNECTION_NUMBER );
m_accumulatedWellFlowPlot->setTrackLegendsVisible( false );
m_accumulatedWellFlowPlot->setLegendsVisible( false );
m_accumulatedWellFlowPlot->uiCapability()->setUiIconFromResourceString( ":/WellFlowPlot16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_totalWellAllocationPlot, "TotalWellFlowPlot", "Total Well Flow", "", "", "" );
@@ -189,12 +189,12 @@ void RimWellAllocationPlot::updateFromWell()
for ( RimWellLogTrack* t : tracks )
{
accumulatedWellFlowPlot()->removeTrack( t );
accumulatedWellFlowPlot()->removePlot( t );
delete t;
}
}
CVF_ASSERT( accumulatedWellFlowPlot()->trackCount() == 0 );
CVF_ASSERT( accumulatedWellFlowPlot()->plotCount() == 0 );
QString description;
if ( m_flowType() == ACCUMULATED ) description = "Accumulated Flow";
@@ -270,7 +270,7 @@ void RimWellAllocationPlot::updateFromWell()
plotTrack->setFormationsForCaseWithSimWellOnly( true );
plotTrack->setFormationBranchIndex( (int)brIdx );
accumulatedWellFlowPlot()->addTrack( plotTrack );
accumulatedWellFlowPlot()->addPlot( plotTrack );
const std::vector<double>& depthValues = depthType == RimWellLogPlot::CONNECTION_NUMBER
? wfCalculator->connectionNumbersFromTop( brIdx )
@@ -865,9 +865,13 @@ cvf::Color3f RimWellAllocationPlot::getTracerColor( const QString& tracerName )
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::updateFormationNamesData() const
{
for ( size_t i = 0; i < m_accumulatedWellFlowPlot->trackCount(); ++i )
for ( size_t i = 0; i < m_accumulatedWellFlowPlot->plotCount(); ++i )
{
RimWellLogTrack* track = m_accumulatedWellFlowPlot->trackByIndex( i );
track->setAndUpdateSimWellFormationNamesData( m_case, m_wellName );
RimWellLogTrack* track = dynamic_cast<RimWellLogTrack*>( m_accumulatedWellFlowPlot->plotByIndex( i ) );
CAF_ASSERT( track );
if ( track )
{
track->setAndUpdateSimWellFormationNamesData( m_case, m_wellName );
}
}
}

View File

@@ -216,7 +216,7 @@ void RimWellFlowRateCurve::updateStackedPlotData()
RimWellLogTrack* wellLogTrack;
firstAncestorOrThisOfTypeAsserted( wellLogTrack );
bool isFirstTrack = ( wellLogTrack == wellLogPlot->trackByIndex( 0 ) );
bool isFirstTrack = ( wellLogTrack == wellLogPlot->plotByIndex( 0 ) );
RiaDefines::DepthUnitType displayUnit = RiaDefines::UNIT_NONE;
@@ -271,7 +271,7 @@ void RimWellFlowRateCurve::updateStackedPlotData()
stackedValues.insert( stackedValues.begin(), 0.0 );
polyLineStartStopIndices.front().second += 1;
if ( wellLogPlot->trackCount() > 1 && isFirstTrack )
if ( wellLogPlot->plotCount() > 1 && isFirstTrack )
{
// Add a dummy negative depth value to make the contribution
// from other branches connected to well head visible

View File

@@ -229,26 +229,31 @@ void RimWellPltPlot::setPlotXAxisTitles( RimWellLogTrack* plotTrack )
//--------------------------------------------------------------------------------------------------
void RimWellPltPlot::updateFormationsOnPlot() const
{
if ( trackCount() > 0 )
if ( plotCount() > 0 )
{
RimProject* proj = RiaApplication::instance()->project();
RimWellPath* wellPath = proj->wellPathByName( m_wellPathName );
RimCase* formationNamesCase = trackByIndex( 0 )->formationNamesCase();
if ( !formationNamesCase )
RimWellLogTrack* track = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( track );
if ( track )
{
/// Set default case. Todo : Use the first of the selected cases in the plot
std::vector<RimCase*> cases;
proj->allCases( cases );
RimCase* formationNamesCase = track->formationNamesCase();
if ( !cases.empty() )
if ( !formationNamesCase )
{
formationNamesCase = cases[0];
}
}
/// Set default case. Todo : Use the first of the selected cases in the plot
std::vector<RimCase*> cases;
proj->allCases( cases );
trackByIndex( 0 )->setAndUpdateWellPathFormationNamesData( formationNamesCase, wellPath );
if ( !cases.empty() )
{
formationNamesCase = cases[0];
}
}
track->setAndUpdateWellPathFormationNamesData( formationNamesCase, wellPath );
}
}
}
@@ -486,7 +491,11 @@ public:
//--------------------------------------------------------------------------------------------------
void RimWellPltPlot::syncCurvesFromUiSelection()
{
RimWellLogTrack* plotTrack = trackByIndex( 0 );
RimWellLogTrack* plotTrack = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( plotTrack );
if ( !plotTrack ) return;
const std::set<RiaRftPltCurveDefinition>& curveDefs = selectedCurveDefs();
setPlotXAxisTitles( plotTrack );
@@ -700,8 +709,8 @@ void RimWellPltPlot::syncCurvesFromUiSelection()
curveGroupId++;
}
plotTrack->setAutoScaleXEnabled( true );
RimWellLogPlot::onLoadDataAndUpdate();
plotTrack->calculateXZoomRange();
}
//--------------------------------------------------------------------------------------------------
@@ -886,11 +895,15 @@ void RimWellPltPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
if ( changedField == &m_wellPathName )
{
RimWellLogTrack* const plotTrack = trackByIndex( 0 );
plotTrack->deleteAllCurves();
m_selectedSources.v().clear();
m_selectedTimeSteps.v().clear();
updateFormationsOnPlot();
RimWellLogTrack* const plotTrack = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( plotTrack );
if ( plotTrack )
{
plotTrack->deleteAllCurves();
m_selectedSources.v().clear();
m_selectedTimeSteps.v().clear();
updateFormationsOnPlot();
}
}
else if ( changedField == &m_selectedSources )
{
@@ -924,20 +937,28 @@ void RimWellPltPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
updateFormationsOnPlot();
syncSourcesIoFieldFromGuiField();
syncCurvesFromUiSelection();
updateDepthZoom();
RimWellLogTrack* const plotTrack = trackByIndex( 0 );
plotTrack->calculateXZoomRangeAndUpdateQwt();
RimWellLogTrack* const plotTrack = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( plotTrack );
if ( plotTrack )
{
plotTrack->setAutoScaleXEnabled( true );
}
updateZoom();
}
if ( changedField == &m_useStandardConditionCurves || changedField == &m_useReservoirConditionCurves ||
changedField == &m_phases )
{
syncCurvesFromUiSelection();
updateDepthZoom();
RimWellLogTrack* const plotTrack = trackByIndex( 0 );
plotTrack->calculateXZoomRangeAndUpdateQwt();
RimWellLogTrack* const plotTrack = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( plotTrack );
if ( plotTrack )
{
plotTrack->setAutoScaleXEnabled( true );
}
updateZoom();
}
}
@@ -970,20 +991,23 @@ void RimWellPltPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
flowGroup->add( &m_phases );
if ( trackCount() > 0 )
if ( plotCount() > 0 )
{
RimWellLogTrack* track = trackByIndex( 0 );
RimWellLogTrack* const track = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( track );
if ( track )
{
track->uiOrderingForRftPltFormations( uiOrdering );
track->uiOrderingForRftPltFormations( uiOrdering );
caf::PdmUiGroup* legendAndAxisGroup = uiOrdering.addNewGroup( "Legend and Axis" );
legendAndAxisGroup->setCollapsedByDefault( true );
caf::PdmUiGroup* legendAndAxisGroup = uiOrdering.addNewGroup( "Legend and Axis" );
legendAndAxisGroup->setCollapsedByDefault( true );
createPlotSettingsUiGroup( *legendAndAxisGroup );
uiOrderingForPlotSettings( *legendAndAxisGroup );
track->uiOrderingForXAxisSettings( *legendAndAxisGroup );
track->uiOrderingForXAxisSettings( *legendAndAxisGroup );
uiOrderingForDepthAxis( *legendAndAxisGroup );
uiOrderingForDepthAxis( *legendAndAxisGroup );
}
}
uiOrdering.skipRemainingFields( true );
@@ -1098,9 +1122,14 @@ void RimWellPltPlot::onLoadDataAndUpdate()
if ( m_isOnLoad )
{
if ( trackCount() > 0 )
if ( plotCount() > 0 )
{
trackByIndex( 0 )->setAnnotationType( RiuPlotAnnotationTool::FORMATION_ANNOTATIONS );
RimWellLogTrack* const plotTrack = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( plotTrack );
if ( plotTrack )
{
plotTrack->setAnnotationType( RiuPlotAnnotationTool::FORMATION_ANNOTATIONS );
}
}
m_isOnLoad = false;
}

View File

@@ -53,7 +53,7 @@
#include "RimWellPlotTools.h"
#include "RimWellPltPlot.h"
#include "RiuWellLogTrack.h"
#include "RiuQwtPlotWidget.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafPdmUiTreeSelectionEditor.h"
@@ -118,7 +118,7 @@ RimWellRftPlot::RimWellRftPlot()
m_wellPathCollection = RiaApplication::instance()->project()->activeOilField()->wellPathCollection();
m_nameConfig->setCustomName( "RFT Plot" );
m_trackLegendsHorizontal = true;
m_plotLegendsHorizontal = true;
this->setAsPlotMdiWindow();
m_isOnLoad = true;
@@ -150,10 +150,10 @@ void RimWellRftPlot::applyCurveAppearance( RimWellLogCurve* newCurve )
currentColor = m_dataSourceColors[sourceAddress];
if ( m_showStatisticsCurves )
{
if ( trackByIndex( 0 ) && trackByIndex( 0 )->viewer() )
if ( plotByIndex( 0 ) && plotByIndex( 0 )->viewer() )
{
cvf::Color3f backgroundColor = RiaColorTools::fromQColorTo3f(
trackByIndex( 0 )->viewer()->canvasBackground().color() );
plotByIndex( 0 )->viewer()->canvasBackground().color() );
currentColor = RiaColorTools::blendCvfColors( backgroundColor, currentColor, 2, 1 );
}
}
@@ -185,35 +185,41 @@ void RimWellRftPlot::applyCurveAppearance( RimWellLogCurve* newCurve )
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::updateFormationsOnPlot() const
{
if ( trackCount() > 0 )
if ( plotCount() > 0 )
{
RimProject* proj = RiaApplication::instance()->project();
RimWellPath* wellPath = proj->wellPathByName( m_wellPathNameOrSimWellName );
RimCase* formationNamesCase = trackByIndex( 0 )->formationNamesCase();
if ( !formationNamesCase )
RimCase* formationNamesCase = nullptr;
RimWellLogTrack* track = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( track );
if ( track )
{
/// Set default case. Todo : Use the first of the selected cases in the plot
std::vector<RimCase*> cases;
proj->allCases( cases );
formationNamesCase = track->formationNamesCase();
if ( !cases.empty() )
if ( !formationNamesCase )
{
formationNamesCase = cases[0];
}
}
/// Set default case. Todo : Use the first of the selected cases in the plot
std::vector<RimCase*> cases;
proj->allCases( cases );
if ( wellPath )
{
trackByIndex( 0 )->setAndUpdateWellPathFormationNamesData( formationNamesCase, wellPath );
}
else
{
trackByIndex( 0 )->setAndUpdateSimWellFormationNamesAndBranchData( formationNamesCase,
associatedSimWellName(),
m_branchIndex,
m_branchDetection );
if ( !cases.empty() )
{
formationNamesCase = cases[0];
}
}
if ( wellPath )
{
track->setAndUpdateWellPathFormationNamesData( formationNamesCase, wellPath );
}
else
{
track->setAndUpdateSimWellFormationNamesAndBranchData( formationNamesCase,
associatedSimWellName(),
m_branchIndex,
m_branchDetection );
}
}
}
}
@@ -360,7 +366,10 @@ void RimWellRftPlot::updateEditorsFromCurves()
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::syncCurvesFromUiSelection()
{
RimWellLogTrack* plotTrack = trackByIndex( 0 );
RimWellLogTrack* plotTrack = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( plotTrack );
if ( !plotTrack ) return;
const std::set<RiaRftPltCurveDefinition>& allCurveDefs = selectedCurveDefs();
const std::set<RiaRftPltCurveDefinition>& curveDefsInPlot = curveDefsFromCurves();
@@ -379,7 +388,7 @@ void RimWellRftPlot::syncCurvesFromUiSelection()
allCurveDefs.end(),
std::inserter( deleteCurveDefs, deleteCurveDefs.end() ) );
for ( RimWellLogCurve* const curve : plotTrack->curvesVector() )
for ( RimWellLogCurve* const curve : plotTrack->curves() )
{
RiaRftPltCurveDefinition curveDef = RimWellPlotTools::curveDefFromCurve( curve );
if ( deleteCurveDefs.count( curveDef ) > 0 )
@@ -422,10 +431,14 @@ std::set<RiaRftPltCurveDefinition> RimWellRftPlot::curveDefsFromCurves() const
{
std::set<RiaRftPltCurveDefinition> curveDefs;
RimWellLogTrack* const plotTrack = trackByIndex( 0 );
for ( RimWellLogCurve* const curve : plotTrack->curvesVector() )
RimWellLogTrack* const plotTrack = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( plotTrack );
if ( plotTrack )
{
curveDefs.insert( RimWellPlotTools::curveDefFromCurve( curve ) );
for ( RimWellLogCurve* const curve : plotTrack->curves() )
{
curveDefs.insert( RimWellPlotTools::curveDefFromCurve( curve ) );
}
}
return curveDefs;
}
@@ -437,8 +450,11 @@ void RimWellRftPlot::updateCurvesInPlot( const std::set<RiaRftPltCurveDefinition
const std::set<RiaRftPltCurveDefinition>& curveDefsToAdd,
const std::set<RimWellLogCurve*>& curvesToDelete )
{
const QString simWellName = associatedSimWellName();
RimWellLogTrack* const plotTrack = trackByIndex( 0 );
const QString simWellName = associatedSimWellName();
RimWellLogTrack* const plotTrack = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( plotTrack );
if ( !plotTrack ) return;
// Delete curves
plotTrack->deleteAllCurves();
@@ -666,16 +682,20 @@ const char* RimWellRftPlot::plotNameFormatString()
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::deleteCurvesAssosicatedWithObservedData( const RimObservedFmuRftData* observedFmuRftData )
{
for ( auto track : tracks() )
for ( auto plot : plots() )
{
auto curves = track->curvesVector();
for ( auto curve : curves )
RimWellLogTrack* const track = dynamic_cast<RimWellLogTrack*>( plot );
if ( track )
{
RimWellLogRftCurve* rftCurve = dynamic_cast<RimWellLogRftCurve*>( curve );
if ( rftCurve && rftCurve->observedFmuRftData() == observedFmuRftData )
auto curves = track->curves();
for ( auto curve : curves )
{
track->takeOutCurve( rftCurve );
delete rftCurve;
RimWellLogRftCurve* rftCurve = dynamic_cast<RimWellLogRftCurve*>( curve );
if ( rftCurve && rftCurve->observedFmuRftData() == observedFmuRftData )
{
track->takeOutCurve( rftCurve );
delete rftCurve;
}
}
}
}
@@ -821,7 +841,7 @@ void RimWellRftPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
m_branchIndex = 0;
RimWellLogTrack* const plotTrack = trackByIndex( 0 );
RimWellLogTrack* const plotTrack = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
if ( plotTrack )
{
plotTrack->deleteAllCurves();
@@ -899,18 +919,21 @@ void RimWellRftPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
caf::PdmUiGroup* timeStepsGroup = uiOrdering.addNewGroupWithKeyword( "Time Steps", "TimeSteps" );
timeStepsGroup->add( &m_selectedTimeSteps );
if ( trackCount() > 0 )
if ( plotCount() > 0 )
{
RimWellLogTrack* track = trackByIndex( 0 );
RimWellLogTrack* const track = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( track );
if ( track )
{
track->uiOrderingForRftPltFormations( uiOrdering );
track->uiOrderingForRftPltFormations( uiOrdering );
caf::PdmUiGroup* legendAndAxisGroup = uiOrdering.addNewGroup( "Legend and Axis" );
legendAndAxisGroup->setCollapsedByDefault( true );
caf::PdmUiGroup* legendAndAxisGroup = uiOrdering.addNewGroup( "Legend and Axis" );
legendAndAxisGroup->setCollapsedByDefault( true );
uiOrderingForPlotSettings( *legendAndAxisGroup );
track->uiOrderingForXAxisSettings( *legendAndAxisGroup );
uiOrderingForDepthAxis( *legendAndAxisGroup );
createPlotSettingsUiGroup( *legendAndAxisGroup );
track->uiOrderingForXAxisSettings( *legendAndAxisGroup );
uiOrderingForDepthAxis( *legendAndAxisGroup );
}
}
uiOrdering.skipRemainingFields( true );
@@ -985,9 +1008,14 @@ void RimWellRftPlot::onLoadDataAndUpdate()
{
if ( m_isOnLoad )
{
if ( trackCount() > 0 )
if ( plotCount() > 0 )
{
trackByIndex( 0 )->setAnnotationType( RiuPlotAnnotationTool::FORMATION_ANNOTATIONS );
RimWellLogTrack* const plotTrack = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( plotTrack );
if ( plotTrack )
{
plotTrack->setAnnotationType( RiuPlotAnnotationTool::FORMATION_ANNOTATIONS );
}
}
m_isOnLoad = false;
@@ -1042,13 +1070,18 @@ void RimWellRftPlot::assignWellPathToExtractionCurves()
if ( wellPath )
{
for ( RimWellLogCurve* curve : trackByIndex( 0 )->curvesVector() )
RimWellLogTrack* const plotTrack = dynamic_cast<RimWellLogTrack*>( plotByIndex( 0 ) );
CAF_ASSERT( plotTrack );
if ( plotTrack )
{
auto extractionCurve = dynamic_cast<RimWellLogExtractionCurve*>( curve );
if ( extractionCurve )
for ( RimWellLogCurve* curve : plotTrack->curves() )
{
extractionCurve->setTrajectoryType( RimWellLogExtractionCurve::WELL_PATH );
extractionCurve->setWellPath( wellPath );
auto extractionCurve = dynamic_cast<RimWellLogExtractionCurve*>( curve );
if ( extractionCurve )
{
extractionCurve->setTrajectoryType( RimWellLogExtractionCurve::WELL_PATH );
extractionCurve->setWellPath( wellPath );
}
}
}
}
@@ -1138,14 +1171,6 @@ void RimWellRftPlot::defineCurveColorsAndSymbols( const std::set<RiaRftPltCurveD
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::onDepthTypeChanged()
{
loadDataAndUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -130,8 +130,6 @@ private:
void defineCurveColorsAndSymbols( const std::set<RiaRftPltCurveDefinition>& allCurveDefs );
void onDepthTypeChanged() override;
private:
caf::PdmField<QString> m_wellPathNameOrSimWellName;
caf::PdmField<int> m_branchIndex;