///////////////////////////////////////////////////////////////////////////////// // // 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 // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include "RimSummaryCalculationVariable.h" #include "RimUserDefinedCalculation.h" #include //================================================================================================== /// /// //================================================================================================== class RimSummaryCalculationAddress { public: RimSummaryCalculationAddress( RifEclipseSummaryAddress summaryAddress ) : m_summaryAddress( summaryAddress ) { } RifEclipseSummaryAddress address() const { return m_summaryAddress; } private: RifEclipseSummaryAddress m_summaryAddress; }; struct SummaryCalculationVariable { QString name; RimSummaryCase* summaryCase; RifEclipseSummaryAddress summaryAddress; }; class RimSummaryCalculation : public RimUserDefinedCalculation { CAF_PDM_HEADER_INIT; public: RimSummaryCalculation(); std::vector allAddressesForSummaryCase( RimSummaryCase* summaryCase ) const; std::vector values( RimSummaryCase* summaryCase, const RimSummaryCalculationAddress& addr ); std::vector timeSteps( RimSummaryCase* summaryCase, const RimSummaryCalculationAddress& addr ); bool calculate() override; void updateDependentObjects() override; void removeDependentObjects() override; QString buildCalculationName() const override; protected: RimSummaryCalculationVariable* createVariable() override; static std::optional, std::vector>> calculateResult( const QString& expression, const std::vector& variables, RimSummaryCase* summaryCase ); std::optional, std::vector>> calculateWithSubstitutions( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& addr ); static void substituteVariables( std::vector& vars, const RifEclipseSummaryAddress& address ); std::vector allAddressesForCategory( RifEclipseSummaryAddress::SummaryVarCategory category, const std::set& allResultAddresses ) const; RimSummaryCalculationAddress singleAddressesForCategory( const RifEclipseSummaryAddress& address ) const; std::optional> getVariables() const; bool checkVariables() const; bool detectCyclicCalculation( int id, std::set& ids ) const; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; private: caf::PdmField m_distributeToOtherItems; };