mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1977 Curve Calculator : Main dialog with expression editor
This commit is contained in:
@@ -25,7 +25,6 @@ ${CEE_CURRENT_LIST_DIR}RicEditSummaryPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreator.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorSplitterUi.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorDialog.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefinitionKeywords.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorFactoryImpl.h
|
||||
)
|
||||
|
||||
@@ -50,6 +49,10 @@ ${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorSplitterUi.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorDialog.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorFactoryImpl.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicShowSummaryCurveCalculatorFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorDialog.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorWidget.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculator.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
@@ -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 "RicShowSummaryCurveCalculatorFeature.h"
|
||||
|
||||
#include "RicSummaryCurveCalculatorDialog.h"
|
||||
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicShowSummaryCurveCalculatorFeature, "RicShowSummaryCurveCalculatorFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicShowSummaryCurveCalculatorFeature::isCommandEnabled()
|
||||
{
|
||||
if (selectedSummaryPlot()) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicShowSummaryCurveCalculatorFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RicSummaryCurveCalculatorDialog dlg(nullptr);
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicShowSummaryCurveCalculatorFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Curve Calculator");
|
||||
actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png"));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot* RicShowSummaryCurveCalculatorFeature::selectedSummaryPlot() const
|
||||
{
|
||||
RimSummaryPlot* sumPlot = nullptr;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
|
||||
if (selObj)
|
||||
{
|
||||
selObj->firstAncestorOrThisOfType(sumPlot);
|
||||
}
|
||||
|
||||
return sumPlot;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafCmdFeature.h"
|
||||
|
||||
class RimSummaryPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicShowSummaryCurveCalculatorFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered( bool isChecked ) override;
|
||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||
|
||||
private:
|
||||
RimSummaryPlot* selectedSummaryPlot() const;
|
||||
};
|
||||
@@ -0,0 +1,226 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicSummaryCurveCalculator.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimCalculation.h"
|
||||
#include "RimCalculationCollection.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicSummaryCurveCalculator, "RicSummaryCurveCalculator");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicSummaryCurveCalculator::RicSummaryCurveCalculator()
|
||||
{
|
||||
CAF_PDM_InitObject("RicSummaryCurveCalculator", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_currentCalculation, "CurrentCalculation", "Current Calculation", "", "", "");
|
||||
m_currentCalculation.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
|
||||
//m_currentCalculation.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
|
||||
m_currentCalculation.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_newCalculation, "NewCalculation", "New Calculation", "", "", "");
|
||||
RicSummaryCurveCalculator::assignPushButtonEditor(&m_newCalculation);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_deleteCalculation, "DeleteCalculation", "Delete Calculation", "", "", "");
|
||||
RicSummaryCurveCalculator::assignPushButtonEditor(&m_deleteCalculation);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_newVariable, "NewVariable", "New Variable", "", "", "");
|
||||
RicSummaryCurveCalculator::assignPushButtonEditor(&m_newVariable);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_deleteVariable, "DeleteVariable", "Delete Variable", "", "", "");
|
||||
RicSummaryCurveCalculator::assignPushButtonEditor(&m_deleteVariable);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryCurveCalculator::calculatedSummariesGroupName()
|
||||
{
|
||||
return "CalculatedSummariesGroupName";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryCurveCalculator::calulationGroupName()
|
||||
{
|
||||
return "CalulationGroupName";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCalculation* RicSummaryCurveCalculator::currentCalculation() const
|
||||
{
|
||||
return m_currentCalculation();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveCalculator::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &m_newCalculation)
|
||||
{
|
||||
m_newCalculation = false;
|
||||
|
||||
RimCalculation* rimCalc = calculationCollection()->addCalculation();
|
||||
m_currentCalculation = rimCalc;
|
||||
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
else if (changedField == &m_deleteCalculation)
|
||||
{
|
||||
m_deleteCalculation = false;
|
||||
|
||||
if (m_currentCalculation())
|
||||
{
|
||||
calculationCollection()->deleteCalculation(m_currentCalculation());
|
||||
m_currentCalculation = nullptr;
|
||||
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
else if (changedField == &m_newVariable)
|
||||
{
|
||||
m_newVariable = false;
|
||||
|
||||
if (m_currentCalculation())
|
||||
{
|
||||
m_currentCalculation()->addVariable();
|
||||
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
else if (changedField == &m_deleteVariable)
|
||||
{
|
||||
m_deleteVariable = false;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveCalculator::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
{
|
||||
caf::PdmUiGroup* group = uiOrdering.addNewGroupWithKeyword("Calculated Summaries", RicSummaryCurveCalculator::calculatedSummariesGroupName());
|
||||
group->add(&m_currentCalculation);
|
||||
group->add(&m_newCalculation);
|
||||
group->add(&m_deleteCalculation);
|
||||
}
|
||||
|
||||
{
|
||||
caf::PdmUiGroup* group = uiOrdering.addNewGroupWithKeyword("Calculation Settings", RicSummaryCurveCalculator::calulationGroupName());
|
||||
if (m_currentCalculation())
|
||||
{
|
||||
m_currentCalculation->uiOrdering(uiConfigName, *group);
|
||||
}
|
||||
|
||||
group->add(&m_newVariable);
|
||||
group->add(&m_deleteVariable);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RicSummaryCurveCalculator::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
if (fieldNeedingOptions == &m_currentCalculation)
|
||||
{
|
||||
for (auto c : calculationCollection()->calculations())
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(c->name(), c));
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCalculationCollection* RicSummaryCurveCalculator::calculationCollection()
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
if (proj)
|
||||
{
|
||||
return proj->calculationCollection();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveCalculator::assignPushButtonEditor(caf::PdmFieldHandle* fieldHandle)
|
||||
{
|
||||
CVF_ASSERT(fieldHandle);
|
||||
CVF_ASSERT(fieldHandle->uiCapability());
|
||||
|
||||
fieldHandle->uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName());
|
||||
fieldHandle->uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveCalculator::assignPushButtonEditorText(caf::PdmUiEditorAttribute* attribute, const QString& text)
|
||||
{
|
||||
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*> (attribute);
|
||||
if (attrib)
|
||||
{
|
||||
attrib->m_buttonText = text;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveCalculator::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
||||
{
|
||||
if (&m_newCalculation == field)
|
||||
{
|
||||
RicSummaryCurveCalculator::assignPushButtonEditorText(attribute, "New Calculation");
|
||||
}
|
||||
else if (&m_deleteCalculation == field)
|
||||
{
|
||||
RicSummaryCurveCalculator::assignPushButtonEditorText(attribute, "Delete Calculation");
|
||||
}
|
||||
else if (&m_newVariable == field)
|
||||
{
|
||||
RicSummaryCurveCalculator::assignPushButtonEditorText(attribute, "New Variable");
|
||||
}
|
||||
else if (&m_deleteVariable == field)
|
||||
{
|
||||
RicSummaryCurveCalculator::assignPushButtonEditorText(attribute, "Delete Variable");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
class RimCalculationCollection;
|
||||
class RimCalculation;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSummaryCurveCalculator : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicSummaryCurveCalculator();
|
||||
|
||||
static QString calculatedSummariesGroupName();
|
||||
static QString calulationGroupName();
|
||||
|
||||
RimCalculation* currentCalculation() const;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
|
||||
|
||||
private:
|
||||
static RimCalculationCollection* calculationCollection();
|
||||
|
||||
// TODO : Move to a common caf helper class
|
||||
static void assignPushButtonEditor(caf::PdmFieldHandle* fieldHandle);
|
||||
static void assignPushButtonEditorText(caf::PdmUiEditorAttribute* attribute, const QString& text);
|
||||
|
||||
private:
|
||||
caf::PdmPtrField<RimCalculation*> m_currentCalculation;
|
||||
|
||||
caf::PdmField<bool> m_newCalculation;
|
||||
caf::PdmField<bool> m_deleteCalculation;
|
||||
|
||||
caf::PdmField<bool> m_newVariable;
|
||||
caf::PdmField<bool> m_deleteVariable;
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicSummaryCurveCalculatorDialog.h"
|
||||
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include "RicSummaryCurveCalculatorWidget.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicSummaryCurveCalculatorDialog::RicSummaryCurveCalculatorDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
setWindowTitle("Summary Curve Calculator");
|
||||
resize(1200, 800);
|
||||
|
||||
setUp();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicSummaryCurveCalculatorDialog::~RicSummaryCurveCalculatorDialog()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveCalculatorDialog::setUp()
|
||||
{
|
||||
QVBoxLayout* dummy = new QVBoxLayout(this);
|
||||
dummy->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
RicSummaryCurveCalculatorWidget* w = new RicSummaryCurveCalculatorWidget(this);
|
||||
dummy->addWidget(w->getOrCreateWidget(this));
|
||||
|
||||
w->updateUi();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <QDialog>
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSummaryCurveCalculatorDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
RicSummaryCurveCalculatorDialog(QWidget* parent);
|
||||
~RicSummaryCurveCalculatorDialog();
|
||||
|
||||
private:
|
||||
void setUp();
|
||||
|
||||
};
|
||||
@@ -0,0 +1,159 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicSummaryCurveCalculatorWidget.h"
|
||||
|
||||
#include "RicSummaryCurveCalculator.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RimCalculationCollection.h"
|
||||
#include "RimCalculation.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "cafPdmUiTableView.h"
|
||||
|
||||
#include "QMinimizePanel.h"
|
||||
|
||||
#include <QAbstractItemView>
|
||||
#include <QBoxLayout>
|
||||
#include <QFrame>
|
||||
#include <QHeaderView>
|
||||
#include <QSplitter>
|
||||
#include <QTableView>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicSummaryCurveCalculatorWidget::RicSummaryCurveCalculatorWidget(QWidget* parent)
|
||||
{
|
||||
m_calculator = std::unique_ptr<RicSummaryCurveCalculator>(new RicSummaryCurveCalculator);
|
||||
|
||||
this->setPdmObject(m_calculator.get());
|
||||
|
||||
m_pdmTableView = new caf::PdmUiTableView(parent);
|
||||
m_pdmTableView->tableView()->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_pdmTableView->enableHeaderText(false);
|
||||
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
|
||||
QHeaderView* verticalHeader = m_pdmTableView->tableView()->verticalHeader();
|
||||
verticalHeader->setResizeMode(QHeaderView::Interactive);
|
||||
|
||||
m_pdmTableView->tableView()->resizeColumnsToContents();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicSummaryCurveCalculatorWidget::~RicSummaryCurveCalculatorWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryCurveCalculatorWidget::recursivelyConfigureAndUpdateTopLevelUiItems(const std::vector<caf::PdmUiItem *>& topLevelUiItems, const QString& uiConfigName)
|
||||
{
|
||||
if (!m_firstRowLeftLayout || !m_firstRowRightLayout) return;
|
||||
|
||||
for (size_t i = 0; i < topLevelUiItems.size(); ++i)
|
||||
{
|
||||
if (topLevelUiItems[i]->isUiHidden(uiConfigName)) continue;
|
||||
|
||||
if (topLevelUiItems[i]->isUiGroup())
|
||||
{
|
||||
caf::PdmUiGroup* group = static_cast<caf::PdmUiGroup*>(topLevelUiItems[i]);
|
||||
auto groupBox = updateGroupBoxWithContent(group, uiConfigName);
|
||||
|
||||
if (group->keyword() == RicSummaryCurveCalculator::calculatedSummariesGroupName())
|
||||
{
|
||||
m_firstRowLeftLayout->addWidget(groupBox);
|
||||
}
|
||||
else if (group->keyword() == RicSummaryCurveCalculator::calulationGroupName())
|
||||
{
|
||||
m_firstRowRightLayout->addWidget(groupBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_calculator->currentCalculation())
|
||||
{
|
||||
m_pdmTableView->setListField(m_calculator->currentCalculation()->variables());
|
||||
}
|
||||
else
|
||||
m_pdmTableView->setListField(nullptr);
|
||||
|
||||
m_firstRowRightLayout->addWidget(m_pdmTableView);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RicSummaryCurveCalculatorWidget::createWidget(QWidget* parent)
|
||||
{
|
||||
QWidget* widget = new QWidget(parent);
|
||||
|
||||
QVBoxLayout* mainLayout = new QVBoxLayout();
|
||||
mainLayout->setContentsMargins(5, 5, 5, 5);
|
||||
widget->setLayout(mainLayout);
|
||||
|
||||
QFrame* firstRowFrame = new QFrame(widget);
|
||||
QHBoxLayout* firstRowLayout = new QHBoxLayout;
|
||||
firstRowLayout->setContentsMargins(0, 0, 0, 0);
|
||||
firstRowFrame->setLayout(firstRowLayout);
|
||||
|
||||
QFrame* firstRowLeftFrame = new QFrame(widget);
|
||||
m_firstRowLeftLayout = new QHBoxLayout;
|
||||
m_firstRowLeftLayout->setContentsMargins(0, 0, 0, 0);
|
||||
firstRowLeftFrame->setLayout(m_firstRowLeftLayout);
|
||||
|
||||
QFrame* firstRowRightFrame = new QFrame(widget);
|
||||
m_firstRowRightLayout = new QVBoxLayout;
|
||||
m_firstRowRightLayout->setContentsMargins(0, 0, 0, 0);
|
||||
firstRowRightFrame->setLayout(m_firstRowRightLayout);
|
||||
|
||||
QSplitter* rowSplitter = new QSplitter(Qt::Horizontal);
|
||||
rowSplitter->setContentsMargins(0, 0, 0, 0);
|
||||
rowSplitter->setHandleWidth(6);
|
||||
rowSplitter->setStyleSheet("QSplitter::handle { image: url(:/SplitterV.png); }");
|
||||
rowSplitter->insertWidget(0, firstRowLeftFrame);
|
||||
rowSplitter->insertWidget(1, firstRowRightFrame);
|
||||
rowSplitter->setSizes(QList<int>() << 1 << 1);
|
||||
firstRowLayout->addWidget(rowSplitter);
|
||||
|
||||
mainLayout->addWidget(rowSplitter);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QMinimizePanel* RicSummaryCurveCalculatorWidget::updateGroupBoxWithContent(caf::PdmUiGroup* group,
|
||||
const QString& uiConfigName)
|
||||
{
|
||||
QMinimizePanel* groupBox = findOrCreateGroupBox(this->widget(), group, uiConfigName);
|
||||
|
||||
const std::vector<caf::PdmUiItem*>& groupChildren = group->uiItems();
|
||||
recursivelyConfigureAndUpdateUiItemsInGridLayoutColumn(groupChildren, groupBox->contentFrame(), uiConfigName);
|
||||
return groupBox;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafPdmUiWidgetBasedObjectEditor.h"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
class RicSummaryCurveCalculator;
|
||||
|
||||
class QMinimizePanel;
|
||||
class QSplitter;
|
||||
class QString;
|
||||
class QVBoxLayout;
|
||||
class QHBoxLayout;
|
||||
class QBoxLayout;
|
||||
|
||||
namespace caf {
|
||||
class PdmUiItem;
|
||||
class PdmUiTableView;
|
||||
}
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSummaryCurveCalculatorWidget : public caf::PdmUiWidgetBasedObjectEditor
|
||||
{
|
||||
public:
|
||||
RicSummaryCurveCalculatorWidget(QWidget* parent);
|
||||
~RicSummaryCurveCalculatorWidget();
|
||||
|
||||
private:
|
||||
virtual void recursivelyConfigureAndUpdateTopLevelUiItems(const std::vector<caf::PdmUiItem *>& topLevelUiItems,
|
||||
const QString& uiConfigName) override;
|
||||
|
||||
virtual QWidget* createWidget(QWidget* parent) override;
|
||||
|
||||
QMinimizePanel* updateGroupBoxWithContent(caf::PdmUiGroup* group, const QString& uiConfigName);
|
||||
|
||||
private:
|
||||
QPointer<QHBoxLayout> m_firstRowLeftLayout;
|
||||
QPointer<QVBoxLayout> m_firstRowRightLayout;
|
||||
|
||||
caf::PdmUiTableView* m_pdmTableView;
|
||||
|
||||
std::unique_ptr<RicSummaryCurveCalculator> m_calculator;
|
||||
};
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
#include "RiuMainPlotWindow.h"
|
||||
#include "RiuSummaryCurveDefinitionKeywords.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
#include "RicSummaryCurveCreatorSplitterUi.h"
|
||||
|
||||
#include "RicSummaryCurveCreator.h"
|
||||
#include "RimSummaryCurveCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "RiuSummaryCurveDefinitionKeywords.h"
|
||||
|
||||
#include "cafPdmUiFieldEditorHandle.h"
|
||||
@@ -32,8 +35,6 @@
|
||||
#include <QSplitter>
|
||||
#include <QFrame>
|
||||
#include <QTreeView>
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryCurveCollection.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user