Minor code adjustments

This commit is contained in:
Magne Sjaastad 2019-12-19 11:55:34 +01:00
parent 4ccbd274b8
commit 4d3113255e
6 changed files with 48 additions and 46 deletions

View File

@ -398,7 +398,7 @@ void RimWellDistributionPlot::populatePlotWidgetWithCurveData( const RigTofWellD
plotWidget->setAxisAutoScale( QwtPlot::xBottom, true ); plotWidget->setAxisAutoScale( QwtPlot::xBottom, true );
plotWidget->setAxisAutoScale( QwtPlot::yLeft, true ); plotWidget->setAxisAutoScale( QwtPlot::yLeft, true );
const std::vector<double>& tofValuesDays = calculator.sortedUniqueTOFValues(); const std::vector<double>& tofValuesDays = calculator.sortedUniqueTofValues();
if ( tofValuesDays.size() == 0 ) if ( tofValuesDays.size() == 0 )
{ {
// cvf::Trace::show("No TOF values!"); // cvf::Trace::show("No TOF values!");
@ -422,7 +422,7 @@ void RimWellDistributionPlot::populatePlotWidgetWithCurveData( const RigTofWellD
for ( size_t i = 0; i < numWells; i++ ) for ( size_t i = 0; i < numWells; i++ )
{ {
QString wellName = calculator.contributingWellName( i ); const QString& wellName = calculator.contributingWellName( i );
const std::vector<double>& volArr = calculator.accumulatedVolumeForContributingWell( i ); const std::vector<double>& volArr = calculator.accumulatedVolumeForContributingWell( i );
cvf::Color3f cvfClr = flowDiagSolution.tracerColor( wellName ); cvf::Color3f cvfClr = flowDiagSolution.tracerColor( wellName );

View File

@ -47,35 +47,35 @@ public:
void setPlotOptions( bool groupSmallContributions, double smallContributionsRelativeThreshold ); void setPlotOptions( bool groupSmallContributions, double smallContributionsRelativeThreshold );
// RimPlot implementations // RimPlot implementations
virtual RiuQwtPlotWidget* viewer() override; RiuQwtPlotWidget* viewer() override;
virtual void setAutoScaleXEnabled( bool enabled ) override; void setAutoScaleXEnabled( bool enabled ) override;
virtual void setAutoScaleYEnabled( bool enabled ) override; void setAutoScaleYEnabled( bool enabled ) override;
virtual void updateAxes() override; void updateAxes() override;
virtual void updateLegend() override; void updateLegend() override;
virtual void updateZoomInQwt() override; void updateZoomInQwt() override;
virtual void updateZoomFromQwt() override; void updateZoomFromQwt() override;
virtual QString asciiDataForPlotExport() const override; QString asciiDataForPlotExport() const override;
virtual void reattachAllCurves() override; void reattachAllCurves() override;
virtual void detachAllCurves() override; void detachAllCurves() override;
virtual caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override; caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override;
virtual void onAxisSelected( int axis, bool toggle ) override; void onAxisSelected( int axis, bool toggle ) override;
// RimPlotWindow implementations // RimPlotWindow implementations
virtual QString description() const override; QString description() const override;
// RimViewWindow implementations // RimViewWindow implementations
virtual QWidget* viewWidget() override; QWidget* viewWidget() override;
virtual QImage snapshotWindowContent() override; QImage snapshotWindowContent() override;
virtual void zoomAll() override; void zoomAll() override;
private: private:
// RimPlot implementations // RimPlot implementations
virtual void doRemoveFromCollection() override; void doRemoveFromCollection() override;
// RimViewWindow implementations // RimViewWindow implementations
virtual QWidget* createViewWidget( QWidget* mainWindowParent ) override; QWidget* createViewWidget( QWidget* mainWindowParent ) override;
virtual void deleteViewWidget() override; void deleteViewWidget() override;
virtual void onLoadDataAndUpdate() override; void onLoadDataAndUpdate() override;
private: private:
void fixupDependentFieldsAfterCaseChange(); void fixupDependentFieldsAfterCaseChange();
@ -83,12 +83,13 @@ private:
const RimFlowDiagSolution& flowDiagSolution, const RimFlowDiagSolution& flowDiagSolution,
RiuQwtPlotWidget* plotWidget ); RiuQwtPlotWidget* plotWidget );
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
virtual 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;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override; QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
private: private:
caf::PdmPtrField<RimEclipseResultCase*> m_case; caf::PdmPtrField<RimEclipseResultCase*> m_case;

View File

@ -49,18 +49,18 @@ public:
private: private:
// RimPlotWindow overrides // RimPlotWindow overrides
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override; bool* useOptionsOnly ) override;
virtual 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;
virtual void onLoadDataAndUpdate() override; void onLoadDataAndUpdate() override;
private: private:
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fixupDependentFieldsAfterCaseChange(); void fixupDependentFieldsAfterCaseChange();
void applyPlotParametersToContainedPlots(); void applyPlotParametersToContainedPlots();
private: private:
caf::PdmPtrField<RimEclipseResultCase*> m_case; caf::PdmPtrField<RimEclipseResultCase*> m_case;

View File

@ -132,7 +132,7 @@ void RigTofAccumulatedPhaseFractionsCalculator::sortTofAndCalculateAccPhaseFract
double fractionPorvPhaseSumSoil = 0.0; double fractionPorvPhaseSumSoil = 0.0;
double fractionPorvPhaseSumSgas = 0.0; double fractionPorvPhaseSumSgas = 0.0;
for ( auto element : tofAndIndexMap ) for ( const auto& element : tofAndIndexMap )
{ {
double tofValue = element.first; double tofValue = element.first;
for ( int index : element.second ) for ( int index : element.second )
@ -160,4 +160,4 @@ void RigTofAccumulatedPhaseFractionsCalculator::sortTofAndCalculateAccPhaseFract
accumulatedPhaseFractionSoil.push_back( fractionPorvPhaseSumSoil / fractionPorvSum ); accumulatedPhaseFractionSoil.push_back( fractionPorvPhaseSumSoil / fractionPorvSum );
accumulatedPhaseFractionSgas.push_back( fractionPorvPhaseSumSgas / fractionPorvSum ); accumulatedPhaseFractionSgas.push_back( fractionPorvPhaseSumSgas / fractionPorvSum );
} }
} }

View File

@ -91,7 +91,8 @@ RigTofWellDistributionCalculator::RigTofWellDistributionCalculator( RimEclipseRe
const RigFlowDiagResultAddress resultAddrFraction( "Fraction", const RigFlowDiagResultAddress resultAddrFraction( "Fraction",
RigFlowDiagResultAddress::PhaseSelection::PHASE_ALL, RigFlowDiagResultAddress::PhaseSelection::PHASE_ALL,
targetWellname.toStdString() ); targetWellname.toStdString() );
const std::vector<double>* tofData = flowDiagResults->resultValues( resultAddrTof, timeStepIndex );
const std::vector<double>* tofData = flowDiagResults->resultValues( resultAddrTof, timeStepIndex );
const std::vector<double>* targetWellFractionData = flowDiagResults->resultValues( resultAddrFraction, timeStepIndex ); const std::vector<double>* targetWellFractionData = flowDiagResults->resultValues( resultAddrFraction, timeStepIndex );
if ( !tofData || !targetWellFractionData ) if ( !tofData || !targetWellFractionData )
{ {
@ -103,8 +104,8 @@ RigTofWellDistributionCalculator::RigTofWellDistributionCalculator( RimEclipseRe
const std::vector<QString> candidateContributingWellNames = findCandidateContributingWellNames( *flowDiagSolution, const std::vector<QString> candidateContributingWellNames = findCandidateContributingWellNames( *flowDiagSolution,
targetWellname, targetWellname,
timeStepIndex ); timeStepIndex );
const size_t numContribWells = candidateContributingWellNames.size();
const size_t numContribWells = candidateContributingWellNames.size();
for ( size_t iContribWell = 0; iContribWell < numContribWells; iContribWell++ ) for ( size_t iContribWell = 0; iContribWell < numContribWells; iContribWell++ )
{ {
const QString contribWellName = candidateContributingWellNames[iContribWell]; const QString contribWellName = candidateContributingWellNames[iContribWell];
@ -124,7 +125,7 @@ RigTofWellDistributionCalculator::RigTofWellDistributionCalculator( RimEclipseRe
ContribWellEntry contribWellEntry; ContribWellEntry contribWellEntry;
contribWellEntry.name = contribWellName; contribWellEntry.name = contribWellName;
for ( auto mapElement : tofToCellIndicesMap ) for ( const auto& mapElement : tofToCellIndicesMap )
{ {
const double tofValue = mapElement.first; const double tofValue = mapElement.first;
const std::vector<size_t>& cellIndicesArr = mapElement.second; const std::vector<size_t>& cellIndicesArr = mapElement.second;
@ -152,7 +153,7 @@ RigTofWellDistributionCalculator::RigTofWellDistributionCalculator( RimEclipseRe
} }
} }
for ( auto mapElement : tofToCellIndicesMap ) for ( const auto& mapElement : tofToCellIndicesMap )
{ {
const double tofValue = mapElement.first; const double tofValue = mapElement.first;
m_tofInIncreasingOrder.push_back( tofValue ); m_tofInIncreasingOrder.push_back( tofValue );
@ -262,7 +263,7 @@ std::vector<QString>
: RimFlowDiagSolution::INJECTOR; : RimFlowDiagSolution::INJECTOR;
const std::vector<QString> allWellNames = flowDiagSolution.tracerNames(); const std::vector<QString> allWellNames = flowDiagSolution.tracerNames();
for ( QString name : allWellNames ) for ( const QString& name : allWellNames )
{ {
const RimFlowDiagSolution::TracerStatusType status = flowDiagSolution.tracerStatusInTimeStep( name, const RimFlowDiagSolution::TracerStatusType status = flowDiagSolution.tracerStatusInTimeStep( name,
timeStepIndex ); timeStepIndex );
@ -285,7 +286,7 @@ std::vector<QString>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const std::vector<double>& RigTofWellDistributionCalculator::sortedUniqueTOFValues() const const std::vector<double>& RigTofWellDistributionCalculator::sortedUniqueTofValues() const
{ {
return m_tofInIncreasingOrder; return m_tofInIncreasingOrder;
} }

View File

@ -45,7 +45,7 @@ public:
void groupSmallContributions( double smallContribThreshold ); void groupSmallContributions( double smallContribThreshold );
const std::vector<double>& sortedUniqueTOFValues() const; const std::vector<double>& sortedUniqueTofValues() const;
size_t contributingWellCount() const; size_t contributingWellCount() const;
const QString& contributingWellName( size_t contribWellIndex ) const; const QString& contributingWellName( size_t contribWellIndex ) const;