Commit c9ad6728 authored by Huff, Israel's avatar Huff, Israel
Browse files

- "Define Ensemble" checkboxes now enable/disable grouped controls

- now using enum classes and static maps (enum item -> string) for combobox options
parent 12b5db8e
Pipeline #97650 failed with stages
in 39 seconds
......@@ -12,6 +12,7 @@ TRIBITS_ADD_EXECUTABLE(rsmportalexample
NOEXEPREFIX
SOURCES
rsmportalexample.cc
aptensdatamodel.cc
aptenswidget.cc
${PORTAL_MOC_FILES} ${PORTAL_HEADERS}
)
#include "aptensdatamodel.hh"
using namespace AptEns;
const QMap<Sampling, QString> APTEnsDataModel::sampleStrings = {
{Sampling::uniform, "uniform"}, {Sampling::gaussian, "gaussian"}};
const QMap<SoilType, QString> APTEnsDataModel::soilTypeStrings = {
{SoilType::siliceous, "siliceous"}, {SoilType::calcareous, "calcareous"}};
const QMap<FissionID, QString> APTEnsDataModel::fissionIDStrings = {
{FissionID::u235fi, "u235fi"}, {FissionID::u238fi, "u238fi"},
{FissionID::pu239fi, "pu239fi"}, {FissionID::u235he, "u235he"},
{FissionID::u238he, "u238he"}, {FissionID::pu239he, "pu239he"}};
#ifndef RSM_RSMWIDGETSEXAMPLE_APTENSDATAMODEL_HH_
#define RSM_RSMWIDGETSEXAMPLE_APTENSDATAMODEL_HH_
#include <QMap>
#include <QString>
#include <QStringList>
namespace AptEns
{
enum class Sampling
{
uniform,
gaussian
};
enum class SoilType
{
siliceous,
calcareous
};
enum class FissionID
{
u235fi,
u238fi,
pu239fi,
u235he,
u238he,
pu239he
};
class APTEnsDataModel
{
private:
......@@ -15,19 +38,19 @@ class APTEnsDataModel
QString mSoilType = "";
QString mFissionID = "";
double mTotalYield = 0.;
bool mYieldDefEnsemble = false;
unsigned mNumYields = 0;
double mMinYield = 0.;
double mMaxYield = 0.;
QString mYieldSampling = "";
double mTotalYield = 0.;
bool mYieldDefEnsemble = false;
unsigned mNumYields = 0;
double mMinYield = 0.;
double mMaxYield = 0.;
Sampling mYieldSampling = Sampling::uniform;
double mHeightOfBurst = 0.;
bool mHOBDefEnsemble = false;
unsigned mNumHOBs = 0;
double mMinHOB = 0.;
double mMaxHOB = 0.;
QString mHOBSampling = "";
Sampling mHOBSampling = Sampling::uniform;
QStringList mMetFileSets;
......@@ -38,6 +61,11 @@ class APTEnsDataModel
unsigned mMetEnsNum = 0;
public:
// map strings to enum items
static const QMap<Sampling, QString> sampleStrings;
static const QMap<SoilType, QString> soilTypeStrings;
static const QMap<FissionID, QString> fissionIDStrings;
// getters
double latitude() { return mLatitude; }
double longitude() { return mLongitude; }
......@@ -50,14 +78,14 @@ class APTEnsDataModel
unsigned numYields() { return mNumYields; }
double minYield() { return mMinYield; }
double maxYield() { return mMaxYield; }
QString yieldSampling() { return mYieldSampling; }
Sampling yieldSampling() { return mYieldSampling; }
double heightOfBurst() { return mHeightOfBurst; }
bool hobDefEnsemble() { return mHOBDefEnsemble; }
unsigned numHOBs() { return mNumHOBs; }
double minHOB() { return mMinHOB; }
double maxHOB() { return mMaxHOB; }
QString hobSampling() { return mHOBSampling; }
Sampling hobSampling() { return mHOBSampling; }
QStringList &metFileSets() { return mMetFileSets; }
......@@ -79,14 +107,14 @@ class APTEnsDataModel
void setNumYields(unsigned a) { mNumYields = a; }
void setMinYield(double a) { mMinYield = a; }
void setMaxYield(double a) { mMaxYield = a; }
void setYieldSampling(QString a) { mYieldSampling = a; }
void setYieldSampling(Sampling a) { mYieldSampling = a; }
void setHeightOfBurst(double a) { mHeightOfBurst = a; }
void setHOBDefEnsemble(bool a) { mHOBDefEnsemble = a; }
void setNumHOBs(unsigned a) { mNumHOBs = a; }
void setMinHOB(double a) { mMinHOB = a; }
void setMaxHOB(double a) { mMaxHOB = a; }
void setHOBSampling(QString a) { mHOBSampling = a; }
void setHOBSampling(Sampling a) { mHOBSampling = a; }
void setTurbEnsNum(unsigned a) { mTurbEnsNum = a; }
......
......@@ -102,16 +102,16 @@ APTEnsWidget::APTEnsWidget(QWidget *parent)
mFissionIDComboBox = new QComboBox(mEventDefBox);
mSoilTypeComboBox->setEditable(true);
mSoilTypeComboBox->setInsertPolicy(QComboBox::NoInsert);
mSoilTypeComboBox->addItem("siliceous");
mSoilTypeComboBox->addItem("calcareous");
for (auto item : APTEnsDataModel::soilTypeStrings)
{
mSoilTypeComboBox->addItem(item);
}
mFissionIDComboBox->setEditable(true);
mFissionIDComboBox->setInsertPolicy(QComboBox::NoInsert);
mFissionIDComboBox->addItem("u235fi");
mFissionIDComboBox->addItem("u238fi");
mFissionIDComboBox->addItem("pu239fi");
mFissionIDComboBox->addItem("u235he");
mFissionIDComboBox->addItem("u238he");
mFissionIDComboBox->addItem("pu239he");
for (auto item : APTEnsDataModel::fissionIDStrings)
{
mFissionIDComboBox->addItem(item);
}
row = 0;
edLayout->addWidget(mLatLabel, row, 0);
edLayout->addWidget(mLatLineEdit, row, 1);
......@@ -137,8 +137,10 @@ APTEnsWidget::APTEnsWidget(QWidget *parent)
mMaxYieldLineEdit = new LineEditFocusSelectAll(mYieldEnsBox);
mYieldSamplingLabel = new StyledLabel("Sampling", mYieldEnsBox);
mYieldSamplingComboBox = new QComboBox(mYieldEnsBox);
mYieldSamplingComboBox->addItem("uniform");
mYieldSamplingComboBox->addItem("gaussian");
for (auto item : APTEnsDataModel::sampleStrings)
{
mYieldSamplingComboBox->addItem(item);
}
row = 0;
yeLayout->addWidget(mTotalYieldLabel, row, 0);
yeLayout->addWidget(mTotalYieldLineEdit, row, 1);
......@@ -166,8 +168,10 @@ APTEnsWidget::APTEnsWidget(QWidget *parent)
mMaxHOBLineEdit = new LineEditFocusSelectAll(mHeightOfBurstEnsBox);
mHOBSamplingLabel = new StyledLabel("Sampling", mHeightOfBurstEnsBox);
mHOBSamplingComboBox = new QComboBox(mHeightOfBurstEnsBox);
mHOBSamplingComboBox->addItem("uniform");
mHOBSamplingComboBox->addItem("gaussian");
for (auto item : APTEnsDataModel::sampleStrings)
{
mHOBSamplingComboBox->addItem(item);
}
row = 0;
hobLayout->addWidget(mHOBLabel, row, 0);
hobLayout->addWidget(mHOBLineEdit, row, 1);
......@@ -237,6 +241,11 @@ APTEnsWidget::APTEnsWidget(QWidget *parent)
meLayout->addWidget(mMetEnsNumLineEdit, 0, 1);
meLayout->addWidget(meSpacer, 0, 2);
connect(mYieldDefineEnsCheckBox, &QCheckBox::stateChanged, this,
&APTEnsWidget::yieldDefineEnsStateChange);
connect(mHOBDefineEnsCheckBox, &QCheckBox::stateChanged, this,
&APTEnsWidget::hobDefineEnsStateChange);
readInputsFromDM();
}
......@@ -252,13 +261,22 @@ void APTEnsWidget::readInputsFromDM()
mNumYieldsLineEdit->setText(QString::number(mDataModel.numYields()));
mMinYieldLineEdit->setText(QString::number(mDataModel.minYield()));
mMaxYieldLineEdit->setText(QString::number(mDataModel.maxYield()));
// TODO: sampling
Qt::CheckState state =
mDataModel.yieldDefEnsemble() ? Qt::Checked : Qt::Unchecked;
mYieldDefineEnsCheckBox->setCheckState(state);
yieldDefineEnsStateChange(state);
mYieldSamplingComboBox->setCurrentIndex(Sampling::gaussian ==
mDataModel.yieldSampling());
mHOBLineEdit->setText(QString::number(mDataModel.heightOfBurst()));
mNumHOBsLineEdit->setText(QString::number(mDataModel.numHOBs()));
mMinHOBLineEdit->setText(QString::number(mDataModel.minHOB()));
mMaxHOBLineEdit->setText(QString::number(mDataModel.maxHOB()));
// TODO: sampling
state = mDataModel.hobDefEnsemble() ? Qt::Checked : Qt::Unchecked;
mHOBDefineEnsCheckBox->setCheckState(state);
hobDefineEnsStateChange(state);
mHOBSamplingComboBox->setCurrentIndex(Sampling::gaussian ==
mDataModel.hobSampling());
mDataModel.metFileSets().append("asdf");
mDataModel.metFileSets().append("zxcv");
......@@ -271,3 +289,39 @@ void APTEnsWidget::readInputsFromDM()
mTurbEnsNumLineEdit->setText(QString::number(mDataModel.turbEnsNum()));
mMetEnsNumLineEdit->setText(QString::number(mDataModel.metEnsNum()));
}
void APTEnsWidget::yieldDefineEnsStateChange(int state)
{
bool checked = (Qt::Checked == state);
mDataModel.setYieldDefEnsemble(checked);
mTotalYieldLabel->setEnabled(checked);
mTotalYieldLineEdit->setEnabled(checked);
mNumYieldsLabel->setEnabled(checked);
mNumYieldsLineEdit->setEnabled(checked);
mMinYieldLabel->setEnabled(checked);
mMinYieldLineEdit->setEnabled(checked);
mMaxYieldLabel->setEnabled(checked);
mMaxYieldLineEdit->setEnabled(checked);
mYieldSamplingLabel->setEnabled(checked);
mYieldSamplingComboBox->setEnabled(checked);
}
void APTEnsWidget::hobDefineEnsStateChange(int state)
{
bool checked = (Qt::Checked == state);
mDataModel.setHOBDefEnsemble(checked);
mHOBLabel->setEnabled(checked);
mHOBLineEdit->setEnabled(checked);
mNumHOBsLabel->setEnabled(checked);
mNumHOBsLineEdit->setEnabled(checked);
mMinHOBLabel->setEnabled(checked);
mMinHOBLineEdit->setEnabled(checked);
mMaxHOBLabel->setEnabled(checked);
mMaxHOBLineEdit->setEnabled(checked);
mHOBSamplingLabel->setEnabled(checked);
mHOBSamplingComboBox->setEnabled(checked);
}
......@@ -57,14 +57,14 @@ class APTEnsWidget : public QWidget
CenterTitleGroupBox *mMetEnsBox;
StyledLabel *mLatLabel;
StyledLabel *mLonLabel;
StyledLabel *mAltLabel;
StyledLabel *mSoilTypeLabel;
StyledLabel *mFissionIDLabel;
LineEditFocusSelectAll *mLatLineEdit;
StyledLabel *mLonLabel;
LineEditFocusSelectAll *mLonLineEdit;
StyledLabel *mAltLabel;
LineEditFocusSelectAll *mAltLineEdit;
StyledLabel *mSoilTypeLabel;
QComboBox *mSoilTypeComboBox;
StyledLabel *mFissionIDLabel;
QComboBox *mFissionIDComboBox;
StyledLabel *mTotalYieldLabel;
......@@ -117,9 +117,8 @@ class APTEnsWidget : public QWidget
APTEnsWidget(QWidget *parent = nullptr);
public slots:
// void execOutputReady();
// void execFailed(QString message);
// void execFinished();
void yieldDefineEnsStateChange(int state);
void hobDefineEnsStateChange(int state);
};
} // namespace AptEns
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment