2017-10-12 00:30:37 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-10-12 00:30:37 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-10-12 00:30:37 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-10-12 00:30:37 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-11-02 09:29:39 -05:00
|
|
|
#include "RiuExpressionContextMenuManager.h"
|
2017-10-12 00:30:37 -05:00
|
|
|
#include "cafPdmChildArrayField.h"
|
2017-10-13 05:22:35 -05:00
|
|
|
#include "cafPdmField.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "cafPdmObject.h"
|
2017-11-02 09:29:39 -05:00
|
|
|
#include <QPointer>
|
|
|
|
#include <memory>
|
2017-10-12 00:30:37 -05:00
|
|
|
|
2017-10-23 07:42:38 -05:00
|
|
|
class RimSummaryCalculationVariable;
|
2017-11-02 09:29:39 -05:00
|
|
|
class QTextEdit;
|
2017-10-12 00:30:37 -05:00
|
|
|
|
|
|
|
//==================================================================================================
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
|
|
|
///
|
2017-10-12 00:30:37 -05:00
|
|
|
//==================================================================================================
|
2017-10-23 07:27:04 -05:00
|
|
|
class RimSummaryCalculation : public caf::PdmObject
|
2017-10-12 00:30:37 -05:00
|
|
|
{
|
|
|
|
CAF_PDM_HEADER_INIT;
|
|
|
|
|
|
|
|
public:
|
2017-10-23 07:27:04 -05:00
|
|
|
RimSummaryCalculation();
|
2017-10-12 00:30:37 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
void setDescription( const QString& description );
|
|
|
|
QString description() const;
|
2017-11-14 01:41:44 -06:00
|
|
|
|
2019-12-09 02:21:06 -06:00
|
|
|
void setId( int id );
|
|
|
|
int id() const;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
bool isDirty() const;
|
2017-10-12 00:30:37 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmChildArrayFieldHandle* variables();
|
2017-10-13 05:22:35 -05:00
|
|
|
|
2019-12-09 02:21:06 -06:00
|
|
|
std::vector<RimSummaryCalculationVariable*> allVariables() const;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
const std::vector<double>& values() const;
|
|
|
|
const std::vector<time_t>& timeSteps() const;
|
2017-11-03 02:36:51 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
void setExpression( const QString& expr );
|
|
|
|
QString expression() const;
|
|
|
|
QString unitName() const;
|
2017-11-02 09:29:39 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
bool parseExpression();
|
|
|
|
bool calculate();
|
|
|
|
void updateDependentCurvesAndPlots();
|
2017-10-13 05:22:35 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmFieldHandle* userDescriptionField() override;
|
2017-10-23 06:11:38 -05:00
|
|
|
|
2020-06-03 15:31:58 -05:00
|
|
|
static QString findLeftHandSide( const QString& expression );
|
2019-09-06 03:40:57 -05:00
|
|
|
void attachToWidget();
|
2017-11-14 01:41:44 -06:00
|
|
|
|
2017-10-23 06:11:38 -05:00
|
|
|
private:
|
2020-02-12 04:43:15 -06:00
|
|
|
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
2017-11-14 01:41:44 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
|
|
|
QString uiConfigName,
|
|
|
|
caf::PdmUiEditorAttribute* attribute ) override;
|
|
|
|
RimSummaryCalculationVariable* findByName( const QString& name ) const;
|
|
|
|
RimSummaryCalculationVariable* addVariable( const QString& name );
|
|
|
|
void deleteVariable( RimSummaryCalculationVariable* calcVariable );
|
2017-10-12 00:30:37 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QString buildCalculationName() const;
|
2017-10-13 07:33:26 -05:00
|
|
|
|
2017-10-12 00:30:37 -05:00
|
|
|
private:
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmField<QString> m_description;
|
|
|
|
caf::PdmField<QString> m_expression;
|
|
|
|
caf::PdmField<QString> m_unit;
|
2017-10-23 14:25:58 -05:00
|
|
|
|
|
|
|
caf::PdmChildArrayField<RimSummaryCalculationVariable*> m_variables;
|
2017-10-12 00:30:37 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmField<std::vector<double>> m_calculatedValues;
|
|
|
|
caf::PdmField<std::vector<time_t>> m_timesteps;
|
2019-12-09 02:21:06 -06:00
|
|
|
caf::PdmField<int> m_id;
|
2017-11-02 09:29:39 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
std::unique_ptr<RiuExpressionContextMenuManager> m_exprContextMenuMgr;
|
2017-11-14 01:41:44 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
bool m_isDirty;
|
2017-10-12 00:30:37 -05:00
|
|
|
};
|