#1967 Curve Calculator : Add calculation objects and containers

This commit is contained in:
Magne Sjaastad 2017-10-12 07:30:37 +02:00
parent 4046665044
commit 4b8186652f
10 changed files with 436 additions and 0 deletions

View File

@ -92,6 +92,9 @@ ${CEE_CURRENT_LIST_DIR}RimGeometrySelectionItem.h
${CEE_CURRENT_LIST_DIR}RimEclipseGeometrySelectionItem.h
${CEE_CURRENT_LIST_DIR}RimDialogData.h
${CEE_CURRENT_LIST_DIR}RimTimeStepFilter.h
${CEE_CURRENT_LIST_DIR}RimCalculation.h
${CEE_CURRENT_LIST_DIR}RimCalculationCollection.h
${CEE_CURRENT_LIST_DIR}RimCalculationVariable.h
)
if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES)
@ -189,6 +192,9 @@ ${CEE_CURRENT_LIST_DIR}RimGeometrySelectionItem.cpp
${CEE_CURRENT_LIST_DIR}RimEclipseGeometrySelectionItem.cpp
${CEE_CURRENT_LIST_DIR}RimDialogData.cpp
${CEE_CURRENT_LIST_DIR}RimTimeStepFilter.cpp
${CEE_CURRENT_LIST_DIR}RimCalculation.cpp
${CEE_CURRENT_LIST_DIR}RimCalculationCollection.cpp
${CEE_CURRENT_LIST_DIR}RimCalculationVariable.cpp
)
if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES)

View File

@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimCalculation.h"
#include "RimCalculationVariable.h"
CAF_PDM_SOURCE_INIT(RimCalculation, "RimCalculation");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCalculation::RimCalculation()
{
CAF_PDM_InitObject("RimCalculation", ":/octave.png", "Calculation", "");
CAF_PDM_InitFieldNoDefault(&m_expression, "Expression", "Expression", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_variables, "Variables", "Variables", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_calculatedValues, "CalculatedValues", "Calculated Values", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmChildArrayFieldHandle* RimCalculation::variables()
{
return &m_variables;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCalculationVariable* RimCalculation::addVariable()
{
RimCalculationVariable* v = new RimCalculationVariable;
m_variables.push_back(v);
return v;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCalculation::deleteVariable(RimCalculationVariable* calcVariable)
{
m_variables.removeChildObject(calcVariable);
delete calcVariable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RimCalculation::values() const
{
return m_calculatedValues();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCalculation::setCalculatedValues(const std::vector<double>& values)
{
m_calculatedValues = values;
}

View File

@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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
#include "RimNamedObject.h"
#include "cafPdmChildArrayField.h"
class RimCalculationVariable;
//==================================================================================================
///
///
//==================================================================================================
class RimCalculation : public RimNamedObject
{
CAF_PDM_HEADER_INIT;
public:
RimCalculation();
caf::PdmChildArrayFieldHandle* variables();
RimCalculationVariable* addVariable();
void deleteVariable(RimCalculationVariable* calcVariable);
const std::vector<double>& values() const;
void setCalculatedValues(const std::vector<double>& values);
private:
caf::PdmField<QString> m_expression;
caf::PdmChildArrayField<RimCalculationVariable*> m_variables;
caf::PdmField<std::vector<double>> m_calculatedValues;
};

View File

@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimCalculationCollection.h"
#include "RimCalculation.h"
#include "cafPdmUiGroup.h"
#include "cafPdmUiTreeSelectionEditor.h"
CAF_PDM_SOURCE_INIT(RimCalculationCollection, "RimCalculationCollection");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCalculationCollection::RimCalculationCollection()
{
CAF_PDM_InitObject("Calculation Collection", ":/chain.png", "", "");
CAF_PDM_InitFieldNoDefault(&m_calcuations, "Calculations", "Calculations", "", "", "");
m_calcuations.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCalculation* RimCalculationCollection::addCalculation()
{
RimCalculation* calculation = new RimCalculation;
calculation->setName(QString("Calculation %1").arg(m_calcuations.size()));
m_calcuations.push_back(calculation);
return calculation;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCalculationCollection::deleteCalculation(RimCalculation* calculation)
{
m_calcuations.removeChildObject(calculation);
delete calculation;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimCalculation*> RimCalculationCollection::calculations() const
{
std::vector<RimCalculation*> calcs;
for (auto c : m_calcuations)
{
calcs.push_back(c);
}
return calcs;
}

View File

@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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
#include "cafPdmObject.h"
#include "cafPdmChildArrayField.h"
class RimCalculation;
//==================================================================================================
///
///
//==================================================================================================
class RimCalculationCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimCalculationCollection();
RimCalculation* addCalculation();
void deleteCalculation(RimCalculation* calculation);
std::vector<RimCalculation*> calculations() const;
private:
caf::PdmChildArrayField<RimCalculation*> m_calcuations;
};

View File

@ -0,0 +1,115 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimCalculationVariable.h"
#include "RiaSummaryCurveDefinition.h"
#include "RimSummaryCase.h"
#include "RimSummaryCurve.h"
#include "RiuSummaryCurveDefSelection.h"
#include "RiuSummaryCurveDefSelectionDialog.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTableView.h"
CAF_PDM_SOURCE_INIT(RimCalculationVariable, "RimCalculationVariable");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCalculationVariable::RimCalculationVariable()
{
CAF_PDM_InitObject("RimCalculationVariable", ":/octave.png", "RimCalculationVariable", "");
CAF_PDM_InitFieldNoDefault(&m_name, "VariableName", "Variable Name", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_button, "PushButton", "Edit ", "", "", "");
m_button.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName());
m_button.xmlCapability()->disableIO();
CAF_PDM_InitFieldNoDefault(&m_summaryAddressUi, "SummaryAddressUi", "Summary Address", "", "", "");
m_summaryAddressUi.registerGetMethod(this, &RimCalculationVariable::summaryAddressDisplayString);
m_summaryAddressUi.xmlCapability()->disableIO();
CAF_PDM_InitFieldNoDefault(&m_case, "SummaryCase", "Summary Case", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_summaryAddress, "SummaryAddress", "Summary Address", "", "", "");
m_summaryAddress = new RimSummaryAddress;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCalculationVariable::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &m_button)
{
RiuSummaryCurveDefSelectionDialog dlg(nullptr);
{
std::vector<RiaSummaryCurveDefinition> sumCasePairs;
sumCasePairs.push_back(RiaSummaryCurveDefinition(m_case(), m_summaryAddress->address()));
dlg.summaryAddressSelection()->setSelectedCurveDefinitions(sumCasePairs);
dlg.summaryAddressSelection()->updateConnectedEditors();
}
if (dlg.exec() == QDialog::Accepted)
{
std::vector<RiaSummaryCurveDefinition> sumCasePairs = dlg.summaryAddressSelection()->selectedCurveDefinitions();
if (sumCasePairs.size() == 1)
{
m_case = sumCasePairs[0].summaryCase();
m_summaryAddress->setAddress(sumCasePairs[0].summaryAddress());
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimCalculationVariable::summaryAddressDisplayString() const
{
return "test";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCalculationVariable::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_name);
uiOrdering.add(&m_summaryAddressUi);
uiOrdering.add(&m_button);
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCalculationVariable::defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
caf::PdmUiTableViewEditorAttribute* attr = dynamic_cast<caf::PdmUiTableViewEditorAttribute*>(attribute);
if (attr)
{
attr->registerPushButtonTextForFieldKeyword(m_button.keyword(), "Edit");
}
}

View File

@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafPdmPtrField.h"
#include "cafPdmProxyValueField.h"
#include "RifEclipseSummaryAddressQMetaType.h"
#include "cafPdmChildField.h"
class RimSummaryCase;
class RimSummaryAddress;
//==================================================================================================
///
///
//==================================================================================================
class RimCalculationVariable : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimCalculationVariable();
private:
QString summaryAddressDisplayString() const;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual void defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
private:
caf::PdmField<QString> m_name;
caf::PdmProxyValueField<QString> m_summaryAddressUi;
caf::PdmField<bool> m_button;
caf::PdmPtrField<RimSummaryCase*> m_case;
caf::PdmChildField<RimSummaryAddress*> m_summaryAddress;
};

View File

@ -307,6 +307,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
commandIds << "RicPasteAsciiDataToSummaryPlotFeature";
commandIds << "Separator";
commandIds << "RicEditSummaryPlotFeature";
commandIds << "RicShowSummaryCurveCalculatorFeature";
commandIds << "RicNewSummaryPlotFeature";
commandIds << "RicNewSummaryCurveFeature";
commandIds << "RicAsciiExportSummaryPlotFeature";

View File

@ -30,6 +30,7 @@
#include "RigWellPath.h"
#include "RimCalcScript.h"
#include "RimCalculationCollection.h"
#include "RimCase.h"
#include "RimCaseCollection.h"
#include "RimCommandObject.h"
@ -112,6 +113,9 @@ RimProject::RimProject(void)
viewLinkerCollection.uiCapability()->setUiHidden(true);
viewLinkerCollection = new RimViewLinkerCollection;
CAF_PDM_InitFieldNoDefault(&calculationCollection, "CalculationCollection", "Calculation Collection", "", "", "");
calculationCollection = new RimCalculationCollection;
CAF_PDM_InitFieldNoDefault(&commandObjects, "CommandObjects", "CommandObjects", "", "", "");
//wellPathImport.uiCapability()->setUiHidden(true);

View File

@ -49,6 +49,7 @@ class RimView;
class RimViewLinker;
class RimViewLinkerCollection;
class RimWellPathImport;
class RimCalculationCollection;
class RimWellPath;
namespace caf
@ -77,6 +78,7 @@ public:
caf::PdmChildField<RimWellPathImport*> wellPathImport;
caf::PdmChildField<RimMainPlotCollection*> mainPlotCollection;
caf::PdmChildField<RimViewLinkerCollection*> viewLinkerCollection;
caf::PdmChildField<RimCalculationCollection*> calculationCollection;
caf::PdmChildArrayField<RimCommandObject*> commandObjects;
caf::PdmChildArrayField<RimMultiSnapshotDefinition*> multiSnapshotDefinitions;