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