#2031 Curve Calculator : Add display of curve address

This commit is contained in:
Magne Sjaastad 2017-10-24 09:44:50 +02:00
parent 9455ed1bac
commit 035e2ccaf9
5 changed files with 81 additions and 2 deletions

View File

@ -77,6 +77,32 @@ const std::vector<time_t>& RiaSummaryCurveDefinition::timeSteps(const RiaSummary
return reader->timeSteps(curveDefinition.summaryAddress());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaSummaryCurveDefinition::curveDefinitionText() const
{
return RiaSummaryCurveDefinition::curveDefinitionText(summaryCase(), summaryAddress());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaSummaryCurveDefinition::curveDefinitionText(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress)
{
QString txt;
if (summaryCase)
{
txt += summaryCase->caseName();
txt += ", ";
}
txt += QString::fromStdString(summaryAddress.uiText());
return txt;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -20,6 +20,8 @@
#include "RifEclipseSummaryAddress.h"
#include <QString>
#include <utility>
#include <vector>
@ -42,6 +44,11 @@ public:
static void resultValues(const RiaSummaryCurveDefinition& curveDefinition, std::vector<double>* values);
static const std::vector<time_t>& timeSteps(const RiaSummaryCurveDefinition& curveDefinition);
QString curveDefinitionText() const;
private:
static QString curveDefinitionText(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress);
private:
std::pair<RimSummaryCase*, RifEclipseSummaryAddress> m_curveDefinition;
};

View File

@ -91,6 +91,7 @@ void RimSummaryCalculationVariable::fieldChangedByUi(const caf::PdmFieldHandle*
dlg.summaryAddressSelection()->setSelectedCurveDefinitions(sumCasePairs);
dlg.summaryAddressSelection()->updateConnectedEditors();
dlg.updateLabel();
}
if (dlg.exec() == QDialog::Accepted)

View File

@ -18,10 +18,15 @@
#include "RiuSummaryCurveDefSelectionDialog.h"
#include "RiaSummaryCurveDefinition.h"
#include "RiuSummaryCurveDefSelection.h"
#include "RiuSummaryCurveDefSelectionEditor.h"
#include <QVBoxLayout>
#include <QBoxLayout>
#include <QDialogButtonBox>
#include <QLabel>
#include <QVBoxLayout>
//--------------------------------------------------------------------------------------------------
///
@ -39,11 +44,22 @@ RiuSummaryCurveDefSelectionDialog::RiuSummaryCurveDefSelectionDialog(QWidget* pa
setWindowTitle("Summary Address Selection");
resize(1200, 800);
m_label = new QLabel("", this);
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
mainLayout->addWidget(buttonBox);
QHBoxLayout* labelLayout = new QHBoxLayout(this);
labelLayout->addStretch(1);
labelLayout->addWidget(m_label);
labelLayout->addWidget(buttonBox);
mainLayout->addLayout(labelLayout);
m_addrSelWidget->summaryAddressSelection()->setFieldChangedHandler([this]() { this->updateLabel(); });
updateLabel();
}
//--------------------------------------------------------------------------------------------------
@ -61,3 +77,26 @@ RiuSummaryCurveDefSelection* RiuSummaryCurveDefSelectionDialog::summaryAddressSe
return m_addrSelWidget->summaryAddressSelection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuSummaryCurveDefSelectionDialog::updateLabel()
{
QString curveAddressText;
std::vector<RiaSummaryCurveDefinition> sumCasePairs = this->summaryAddressSelection()->selectedCurveDefinitions();
if (sumCasePairs.size() == 1)
{
curveAddressText = sumCasePairs.front().curveDefinitionText();
}
if (curveAddressText.isEmpty())
{
curveAddressText = "<None>";
}
QString txt = "Selected Address : ";
txt += curveAddressText;
m_label->setText(txt);
}

View File

@ -21,6 +21,8 @@
#include <QDialog>
#include <memory>
class QLabel;
class RiuSummaryCurveDefSelectionEditor;
class RiuSummaryCurveDefSelection;
@ -36,6 +38,10 @@ public:
RiuSummaryCurveDefSelection* summaryAddressSelection() const;
void updateLabel();
private:
std::unique_ptr<RiuSummaryCurveDefSelectionEditor> m_addrSelWidget;
QLabel* m_label;
};