mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4795 Summary Plot Templates : Make sure summary address is valid
If the summary address specified in the template does not exist, uses the first valid address of the specified quantity.
This commit is contained in:
parent
cf482edd3e
commit
d2df004cf3
@ -25,6 +25,8 @@
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include "PlotTemplates/RimPlotTemplateFileItem.h"
|
||||
#include "RimDialogData.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
@ -100,12 +102,29 @@ void RicCreatePlotFromSelectionFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
if ( conversionOk && index < sumCases.size() )
|
||||
{
|
||||
curve->setSummaryCaseY( sumCases[index] );
|
||||
auto summaryCaseY = sumCases[index];
|
||||
curve->setSummaryCaseY( summaryCaseY );
|
||||
|
||||
auto currentAddressY = curve->summaryAddressY();
|
||||
if ( summaryCaseY->summaryReader() &&
|
||||
!summaryCaseY->summaryReader()->hasAddress( currentAddressY ) )
|
||||
{
|
||||
auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses();
|
||||
|
||||
auto candidate = RicCreatePlotFromSelectionFeature::firstAddressByQuantity( currentAddressY,
|
||||
allAddresses );
|
||||
if ( candidate.category() != RifEclipseSummaryAddress::SUMMARY_INVALID )
|
||||
{
|
||||
curve->setSummaryAddressY( candidate );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Create additional curves in selected case count is larger than template count
|
||||
|
||||
plotColl->updateConnectedEditors();
|
||||
|
||||
newSummaryPlot->loadDataAndUpdate();
|
||||
@ -131,3 +150,21 @@ std::vector<RimSummaryCase*> RicCreatePlotFromSelectionFeature::selectedSummaryC
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifEclipseSummaryAddress
|
||||
RicCreatePlotFromSelectionFeature::firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress,
|
||||
const std::set<RifEclipseSummaryAddress>& allAddresses )
|
||||
{
|
||||
for ( const auto& a : allAddresses )
|
||||
{
|
||||
if ( sourceAddress.quantityName() == a.quantityName() )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
return RifEclipseSummaryAddress();
|
||||
}
|
||||
|
@ -18,8 +18,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
class RimSummaryCase;
|
||||
|
||||
//==================================================================================================
|
||||
@ -35,5 +39,7 @@ protected:
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
std::vector<RimSummaryCase*> selectedSummaryCases() const;
|
||||
std::vector<RimSummaryCase*> selectedSummaryCases() const;
|
||||
static RifEclipseSummaryAddress firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress,
|
||||
const std::set<RifEclipseSummaryAddress>& allAddresses );
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user