mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2051 Curve calc. Edit calculation command
This commit is contained in:
@@ -24,31 +24,6 @@
|
||||
CAF_PDM_SOURCE_INIT(RimCalculatedSummaryCase,"CalculatedSummaryCase");
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//==================================================================================================
|
||||
class RifCalculatedSummaryCurveReader : public RifSummaryReaderInterface
|
||||
{
|
||||
public:
|
||||
explicit RifCalculatedSummaryCurveReader(RimSummaryCalculationCollection* calculationCollection);
|
||||
|
||||
virtual const std::vector<time_t>& timeSteps(const RifEclipseSummaryAddress& resultAddress) const override;
|
||||
virtual bool values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values) const override;
|
||||
virtual std::string unitName(const RifEclipseSummaryAddress& resultAddress) const override;
|
||||
|
||||
void buildMetaData();
|
||||
|
||||
private:
|
||||
RimSummaryCalculation* findCalculationByName(const RifEclipseSummaryAddress& resultAddress) const;
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimSummaryCalculationCollection> m_calculationCollection;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -122,91 +97,3 @@ void RimCalculatedSummaryCase::buildMetaData()
|
||||
|
||||
m_calculatedCurveReader->buildMetaData();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifCalculatedSummaryCurveReader::RifCalculatedSummaryCurveReader(RimSummaryCalculationCollection* calculationCollection)
|
||||
: m_calculationCollection(calculationCollection)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<time_t>& RifCalculatedSummaryCurveReader::timeSteps(const RifEclipseSummaryAddress& resultAddress) const
|
||||
{
|
||||
RimSummaryCalculation* calc = findCalculationByName(resultAddress);
|
||||
if (calc)
|
||||
{
|
||||
return calc->timeSteps();
|
||||
}
|
||||
|
||||
static std::vector<time_t> dummy;
|
||||
|
||||
return dummy;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifCalculatedSummaryCurveReader::values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values) const
|
||||
{
|
||||
RimSummaryCalculation* calc = findCalculationByName(resultAddress);
|
||||
if (calc)
|
||||
{
|
||||
*values = calc->values();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::string RifCalculatedSummaryCurveReader::unitName(const RifEclipseSummaryAddress& resultAddress) const
|
||||
{
|
||||
RimSummaryCalculation* calculation = findCalculationByName(resultAddress);
|
||||
if (calculation != nullptr && !calculation->unitName().isEmpty())
|
||||
{
|
||||
return calculation->unitName().toStdString();
|
||||
}
|
||||
return "Calculated Curve Unit";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifCalculatedSummaryCurveReader::buildMetaData()
|
||||
{
|
||||
m_allResultAddresses.clear();
|
||||
|
||||
for (RimSummaryCalculation* calc : m_calculationCollection->calculations())
|
||||
{
|
||||
m_allResultAddresses.push_back(RifEclipseSummaryAddress::calculatedCurveAddress(calc->description().toStdString()));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCalculation* RifCalculatedSummaryCurveReader::findCalculationByName(const RifEclipseSummaryAddress& resultAddress) const
|
||||
{
|
||||
if (m_calculationCollection && resultAddress.category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED)
|
||||
{
|
||||
QString calculatedName = QString::fromStdString(resultAddress.quantityName());
|
||||
|
||||
for (RimSummaryCalculation* calc : m_calculationCollection->calculations())
|
||||
{
|
||||
if (calc->description() == calculatedName)
|
||||
{
|
||||
return calc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user