2017-10-12 00:30:37 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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 <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// 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 "cafPdmObject.h"
|
|
|
|
#include "cafPdmField.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
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
///
|
|
|
|
///
|
|
|
|
//==================================================================================================
|
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
|
|
|
|
2017-10-13 07:33:26 -05:00
|
|
|
void setDescription(const QString& description);
|
|
|
|
QString description() const;
|
2017-10-13 05:22:35 -05:00
|
|
|
|
2017-11-14 01:41:44 -06:00
|
|
|
bool isDirty() const;
|
|
|
|
|
2017-10-12 00:30:37 -05:00
|
|
|
caf::PdmChildArrayFieldHandle* variables();
|
|
|
|
|
|
|
|
const std::vector<double>& values() const;
|
2017-10-18 01:20:21 -05:00
|
|
|
const std::vector<time_t>& timeSteps() const;
|
2017-10-13 05:22:35 -05:00
|
|
|
|
2017-11-03 19:14:56 -05:00
|
|
|
void setExpression(const QString& expr);
|
|
|
|
QString expression() const;
|
2017-11-06 06:26:18 -06:00
|
|
|
QString unitName() const;
|
2017-11-03 02:36:51 -05:00
|
|
|
|
2017-10-13 05:22:35 -05:00
|
|
|
bool parseExpression();
|
|
|
|
bool calculate();
|
2017-10-20 03:20:53 -05:00
|
|
|
void updateDependentCurvesAndPlots();
|
2017-11-02 09:29:39 -05:00
|
|
|
|
2018-10-18 12:45:57 -05:00
|
|
|
caf::PdmFieldHandle* userDescriptionField() override;
|
2017-10-13 05:22:35 -05:00
|
|
|
|
|
|
|
static QString findLeftHandSide(const QString& expresion);
|
2017-11-02 09:29:39 -05:00
|
|
|
void attachToWidget();
|
2017-10-23 06:11:38 -05:00
|
|
|
|
2017-11-14 01:41:44 -06:00
|
|
|
|
2017-10-23 06:11:38 -05:00
|
|
|
private:
|
2018-10-18 12:45:57 -05:00
|
|
|
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue,
|
2017-11-14 01:41:44 -06:00
|
|
|
const QVariant& newValue) override;
|
|
|
|
|
2018-10-18 12:45:57 -05:00
|
|
|
void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName,
|
2017-11-29 01:20:43 -06:00
|
|
|
caf::PdmUiEditorAttribute* attribute) override;
|
2017-10-23 14:25:58 -05:00
|
|
|
RimSummaryCalculationVariable* findByName(const QString& name) const;
|
2017-10-24 02:57:32 -05:00
|
|
|
RimSummaryCalculationVariable* addVariable(const QString& name);
|
|
|
|
void deleteVariable(RimSummaryCalculationVariable* calcVariable);
|
2017-10-12 00:30:37 -05:00
|
|
|
|
2017-10-13 07:33:26 -05:00
|
|
|
QString buildCalculationName() const;
|
|
|
|
|
2017-10-12 00:30:37 -05:00
|
|
|
private:
|
2017-10-13 05:22:35 -05:00
|
|
|
caf::PdmField<QString> m_description;
|
2017-10-12 00:30:37 -05:00
|
|
|
caf::PdmField<QString> m_expression;
|
2017-11-06 06:26:18 -06:00
|
|
|
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
|
|
|
|
|
|
|
caf::PdmField<std::vector<double>> m_calculatedValues;
|
2017-10-18 01:20:21 -05:00
|
|
|
caf::PdmField<std::vector<time_t>> m_timesteps;
|
2017-11-02 09:29:39 -05:00
|
|
|
|
|
|
|
std::unique_ptr<RiuExpressionContextMenuManager> m_exprContextMenuMgr;
|
2017-11-14 01:41:44 -06:00
|
|
|
|
|
|
|
bool m_isDirty;
|
2017-10-12 00:30:37 -05:00
|
|
|
};
|