Commit 0409c121 authored by Huff, Israel's avatar Huff, Israel
Browse files

partially added support for multiple ensemble data models

parent 474985d6
Pipeline #97688 failed with stages
in 40 seconds
......@@ -32,11 +32,11 @@ enum class FissionID
class APTEnsDataModel
{
private:
double mLatitude = 0.;
double mLongitude = 0.;
double mAltitude = 0.;
QString mSoilType = "";
QString mFissionID = "";
double mLatitude = 0.;
double mLongitude = 0.;
double mAltitude = 0.;
SoilType mSoilType = SoilType::siliceous;
FissionID mFissionID = FissionID::u235fi;
double mTotalYield = 0.;
bool mYieldDefEnsemble = false;
......@@ -95,8 +95,8 @@ class APTEnsDataModel
double latitude() { return mLatitude; }
double longitude() { return mLongitude; }
double altitude() { return mAltitude; }
QString soilType() { return mSoilType; }
QString fissionID() { return mFissionID; }
SoilType soilType() { return mSoilType; }
FissionID fissionID() { return mFissionID; }
double totalYield() { return mTotalYield; }
bool yieldDefEnsemble() { return mYieldDefEnsemble; }
......@@ -124,8 +124,8 @@ class APTEnsDataModel
void setLatitude(double a) { mLatitude = a; }
void setLongitude(double a) { mLongitude = a; }
void setAltitude(double a) { mAltitude = a; }
void setSoilType(QString a) { mSoilType = a; }
void setFissionID(QString a) { mFissionID = a; }
void setSoilType(SoilType a) { mSoilType = a; }
void setFissionID(FissionID a) { mFissionID = a; }
void setTotalYield(double a) { mTotalYield = a; }
void setYieldDefEnsemble(bool a) { mYieldDefEnsemble = a; }
......
......@@ -70,13 +70,21 @@ void LineEditFocusSelectAll::focusInEvent(QFocusEvent *event)
APTEnsWidget::APTEnsWidget(QWidget *parent)
: QWidget(parent)
{
mCurrentModel = "untitled";
mDataModels[mCurrentModel] = APTEnsDataModel();
APTEnsDataModel *model = &mDataModels[mCurrentModel];
// TODO: remove temporary code
mDataModel.metFileSets().append("asdf");
mDataModel.metFileSets().append("zxcv");
mDataModel.setupCfgs().append("sdfg");
mDataModel.setupCfgs().append("xcvb");
model->metFileSets().append("asdf");
model->metFileSets().append("zxcv");
model->setupCfgs().append("sdfg");
model->setupCfgs().append("xcvb");
mCurrentModelBox = new CenterTitleGroupBox("", this);
QGridLayout *cmLayout = new QGridLayout(this);
cmLayout->addWidget(mCurrentModelBox, 0, 0);
QGridLayout *layout = new QGridLayout(this);
QGridLayout *layout = new QGridLayout(mCurrentModelBox);
mEventDefBox = new CenterTitleGroupBox("Event Definition", this);
mYieldEnsBox = new CenterTitleGroupBox("Yield Ensemble", this);
mHeightOfBurstEnsBox =
......@@ -251,48 +259,48 @@ APTEnsWidget::APTEnsWidget(QWidget *parent)
// event definition connections
connect(mLatLineEdit, &QLineEdit::editingFinished, this, [=]() {
mDataModel.setLatitude(
model->setLatitude(
APTEnsDataModel::textFieldToDouble(mLatLineEdit->text()));
mLatLineEdit->setText(
APTEnsDataModel::doubleToTextField(mDataModel.latitude()));
APTEnsDataModel::doubleToTextField(model->latitude()));
});
connect(mLonLineEdit, &QLineEdit::editingFinished, this, [=]() {
mDataModel.setLongitude(
model->setLongitude(
APTEnsDataModel::textFieldToDouble(mLonLineEdit->text()));
mLonLineEdit->setText(
APTEnsDataModel::doubleToTextField(mDataModel.longitude()));
APTEnsDataModel::doubleToTextField(model->longitude()));
});
connect(mAltLineEdit, &QLineEdit::editingFinished, this, [=]() {
mDataModel.setAltitude(
model->setAltitude(
APTEnsDataModel::textFieldToDouble(mAltLineEdit->text()));
mAltLineEdit->setText(
APTEnsDataModel::doubleToTextField(mDataModel.altitude()));
APTEnsDataModel::doubleToTextField(model->altitude()));
});
// yield ensemble definition connections
connect(mTotalYieldLineEdit, &QLineEdit::editingFinished, this, [=]() {
mDataModel.setTotalYield(
model->setTotalYield(
APTEnsDataModel::textFieldToDouble(mTotalYieldLineEdit->text()));
mTotalYieldLineEdit->setText(
APTEnsDataModel::doubleToTextField(mDataModel.totalYield()));
APTEnsDataModel::doubleToTextField(model->totalYield()));
});
connect(mNumYieldsLineEdit, &QLineEdit::editingFinished, this, [=]() {
mDataModel.setNumYields(
model->setNumYields(
APTEnsDataModel::textFieldToUnsigned(mNumYieldsLineEdit->text()));
mNumYieldsLineEdit->setText(
APTEnsDataModel::doubleToTextField(mDataModel.numYields()));
APTEnsDataModel::doubleToTextField(model->numYields()));
});
connect(mMinYieldLineEdit, &QLineEdit::editingFinished, this, [=]() {
mDataModel.setMinYield(
model->setMinYield(
APTEnsDataModel::textFieldToDouble(mMinYieldLineEdit->text()));
mMinYieldLineEdit->setText(
APTEnsDataModel::doubleToTextField(mDataModel.minYield()));
APTEnsDataModel::doubleToTextField(model->minYield()));
});
connect(mMaxYieldLineEdit, &QLineEdit::editingFinished, this, [=]() {
mDataModel.setMaxYield(
model->setMaxYield(
APTEnsDataModel::textFieldToDouble(mMaxYieldLineEdit->text()));
mMaxYieldLineEdit->setText(
APTEnsDataModel::doubleToTextField(mDataModel.maxYield()));
APTEnsDataModel::doubleToTextField(model->maxYield()));
});
connect(mYieldDefineEnsCheckBox, &QCheckBox::stateChanged, this,
......@@ -300,28 +308,28 @@ APTEnsWidget::APTEnsWidget(QWidget *parent)
// height of burst ensemble connections
connect(mHOBLineEdit, &QLineEdit::editingFinished, this, [=]() {
mDataModel.setHeightOfBurst(
model->setHeightOfBurst(
APTEnsDataModel::textFieldToDouble(mHOBLineEdit->text()));
mHOBLineEdit->setText(
APTEnsDataModel::doubleToTextField(mDataModel.heightOfBurst()));
APTEnsDataModel::doubleToTextField(model->heightOfBurst()));
});
connect(mNumHOBsLineEdit, &QLineEdit::editingFinished, this, [=]() {
mDataModel.setNumHOBs(
model->setNumHOBs(
APTEnsDataModel::textFieldToUnsigned(mNumHOBsLineEdit->text()));
mNumHOBsLineEdit->setText(
APTEnsDataModel::doubleToTextField(mDataModel.numHOBs()));
APTEnsDataModel::doubleToTextField(model->numHOBs()));
});
connect(mMinHOBLineEdit, &QLineEdit::editingFinished, this, [=]() {
mDataModel.setMinHOB(
model->setMinHOB(
APTEnsDataModel::textFieldToDouble(mMinHOBLineEdit->text()));
mMinHOBLineEdit->setText(
APTEnsDataModel::doubleToTextField(mDataModel.minHOB()));
APTEnsDataModel::doubleToTextField(model->minHOB()));
});
connect(mMaxHOBLineEdit, &QLineEdit::editingFinished, this, [=]() {
mDataModel.setMaxHOB(
model->setMaxHOB(
APTEnsDataModel::textFieldToDouble(mMaxHOBLineEdit->text()));
mMaxHOBLineEdit->setText(
APTEnsDataModel::doubleToTextField(mDataModel.maxHOB()));
APTEnsDataModel::doubleToTextField(model->maxHOB()));
});
connect(mHOBDefineEnsCheckBox, &QCheckBox::stateChanged, this,
&APTEnsWidget::hobDefineEnsStateChange);
......@@ -340,67 +348,74 @@ APTEnsWidget::APTEnsWidget(QWidget *parent)
// turbulence ensemble connections
connect(mTurbEnsNumLineEdit, &QLineEdit::editingFinished, this, [=]() {
mDataModel.setTurbEnsNum(
model->setTurbEnsNum(
APTEnsDataModel::textFieldToUnsigned(mTurbEnsNumLineEdit->text()));
mTurbEnsNumLineEdit->setText(
APTEnsDataModel::doubleToTextField(mDataModel.turbEnsNum()));
APTEnsDataModel::doubleToTextField(model->turbEnsNum()));
});
// meteorology ensemble connections
connect(mMetEnsNumLineEdit, &QLineEdit::editingFinished, this, [=]() {
mDataModel.setMetEnsNum(
model->setMetEnsNum(
APTEnsDataModel::textFieldToUnsigned(mMetEnsNumLineEdit->text()));
mMetEnsNumLineEdit->setText(
APTEnsDataModel::doubleToTextField(mDataModel.metEnsNum()));
APTEnsDataModel::doubleToTextField(model->metEnsNum()));
});
readInputsFromDM();
readFromDataModel();
}
void APTEnsWidget::readInputsFromDM()
void APTEnsWidget::readFromDataModel()
{
mLatLineEdit->setText(QString::number(mDataModel.latitude()));
mLonLineEdit->setText(QString::number(mDataModel.longitude()));
mAltLineEdit->setText(QString::number(mDataModel.altitude()));
// TODO: fission id
// TODO: soil type
mTotalYieldLineEdit->setText(QString::number(mDataModel.totalYield()));
mNumYieldsLineEdit->setText(QString::number(mDataModel.numYields()));
mMinYieldLineEdit->setText(QString::number(mDataModel.minYield()));
mMaxYieldLineEdit->setText(QString::number(mDataModel.maxYield()));
Qt::CheckState state =
mDataModel.yieldDefEnsemble() ? Qt::Checked : Qt::Unchecked;
APTEnsDataModel &model = mDataModels[mCurrentModel];
mCurrentModelBox->setTitle(mCurrentModel);
mLatLineEdit->setText(QString::number(model.latitude()));
mLonLineEdit->setText(QString::number(model.longitude()));
mAltLineEdit->setText(QString::number(model.altitude()));
QString key = model.fissionIDStrings[model.fissionID()];
int index = mFissionIDComboBox->findText(key);
mFissionIDComboBox->setCurrentIndex(index);
key = model.soilTypeStrings[model.soilType()];
index = mSoilTypeComboBox->findText(key);
mSoilTypeComboBox->setCurrentIndex(index);
mTotalYieldLineEdit->setText(QString::number(model.totalYield()));
mNumYieldsLineEdit->setText(QString::number(model.numYields()));
mMinYieldLineEdit->setText(QString::number(model.minYield()));
mMaxYieldLineEdit->setText(QString::number(model.maxYield()));
Qt::CheckState state = model.yieldDefEnsemble() ? Qt::Checked : Qt::Unchecked;
mYieldDefineEnsCheckBox->setCheckState(state);
yieldDefineEnsStateChange(state);
mYieldSamplingComboBox->setCurrentIndex(Sampling::gaussian ==
mDataModel.yieldSampling());
model.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()));
state = mDataModel.hobDefEnsemble() ? Qt::Checked : Qt::Unchecked;
mHOBLineEdit->setText(QString::number(model.heightOfBurst()));
mNumHOBsLineEdit->setText(QString::number(model.numHOBs()));
mMinHOBLineEdit->setText(QString::number(model.minHOB()));
mMaxHOBLineEdit->setText(QString::number(model.maxHOB()));
state = model.hobDefEnsemble() ? Qt::Checked : Qt::Unchecked;
mHOBDefineEnsCheckBox->setCheckState(state);
hobDefineEnsStateChange(state);
mHOBSamplingComboBox->setCurrentIndex(Sampling::gaussian ==
mDataModel.hobSampling());
model.hobSampling());
mMetFileSetsListWidget->clear();
mMetFileSetsListWidget->addItems(mDataModel.metFileSets());
mMetFileSetsListWidget->addItems(model.metFileSets());
mSetupCfgsListWidget->clear();
mSetupCfgsListWidget->addItems(mDataModel.setupCfgs());
mSetupCfgsListWidget->addItems(model.setupCfgs());
mTurbEnsNumLineEdit->setText(QString::number(mDataModel.turbEnsNum()));
mMetEnsNumLineEdit->setText(QString::number(mDataModel.metEnsNum()));
mTurbEnsNumLineEdit->setText(QString::number(model.turbEnsNum()));
mMetEnsNumLineEdit->setText(QString::number(model.metEnsNum()));
}
void APTEnsWidget::yieldDefineEnsStateChange(int state)
{
bool checked = (Qt::Checked == state);
mDataModel.setYieldDefEnsemble(checked);
mDataModels[mCurrentModel].setYieldDefEnsemble(checked);
mTotalYieldLabel->setEnabled(checked);
mTotalYieldLineEdit->setEnabled(checked);
......@@ -418,7 +433,7 @@ void APTEnsWidget::hobDefineEnsStateChange(int state)
{
bool checked = (Qt::Checked == state);
mDataModel.setHOBDefEnsemble(checked);
mDataModels[mCurrentModel].setHOBDefEnsemble(checked);
mHOBLabel->setEnabled(checked);
mHOBLineEdit->setEnabled(checked);
......@@ -438,7 +453,7 @@ void APTEnsWidget::addMeteorologyFile()
this, tr("Add meteorology file"), ".", tr("meteorology file, *"));
if (!fileName.isEmpty())
{
mDataModel.metFileSets().append(fileName);
mDataModels[mCurrentModel].metFileSets().append(fileName);
mMetFileSetsListWidget->addItem(fileName);
}
}
......@@ -448,7 +463,7 @@ void APTEnsWidget::removeMeteorologyFile()
int row = mMetFileSetsListWidget->currentRow();
if (row < 0) return;
auto it = mMetFileSetsListWidget->takeItem(row);
mDataModel.metFileSets().removeAll(it->text());
mDataModels[mCurrentModel].metFileSets().removeAll(it->text());
delete it;
}
......@@ -458,7 +473,7 @@ void APTEnsWidget::importSetupCfgFile()
this, tr("Add SETUP.CFG file"), ".", tr("SETUP.CFG file, *"));
if (!fileName.isEmpty())
{
mDataModel.setupCfgs().append(fileName);
mDataModels[mCurrentModel].setupCfgs().append(fileName);
mSetupCfgsListWidget->addItem(fileName);
}
}
......@@ -468,6 +483,6 @@ void APTEnsWidget::removeSetupCfgtFile()
int row = mSetupCfgsListWidget->currentRow();
if (row < 0) return;
auto it = mSetupCfgsListWidget->takeItem(row);
mDataModel.setupCfgs().removeAll(it->text());
mDataModels[mCurrentModel].setupCfgs().removeAll(it->text());
delete it;
}
......@@ -46,7 +46,10 @@ class APTEnsWidget : public QWidget
Q_OBJECT
private:
APTEnsDataModel mDataModel;
QMap<QString, APTEnsDataModel> mDataModels;
QString mCurrentModel;
CenterTitleGroupBox *mCurrentModelBox;
CenterTitleGroupBox *mEventDefBox;
CenterTitleGroupBox *mYieldEnsBox;
......@@ -69,7 +72,6 @@ class APTEnsWidget : public QWidget
StyledLabel *mTotalYieldLabel;
LineEditFocusSelectAll *mTotalYieldLineEdit;
// TODO: enable/disable all other controls in group box
QCheckBox *mYieldDefineEnsCheckBox;
StyledLabel *mNumYieldsLabel;
LineEditFocusSelectAll *mNumYieldsLineEdit;
......@@ -82,7 +84,6 @@ class APTEnsWidget : public QWidget
StyledLabel *mHOBLabel;
LineEditFocusSelectAll *mHOBLineEdit;
// TODO: enable/disable all other controls in group box
QCheckBox *mHOBDefineEnsCheckBox;
StyledLabel *mNumHOBsLabel;
LineEditFocusSelectAll *mNumHOBsLineEdit;
......@@ -111,7 +112,7 @@ class APTEnsWidget : public QWidget
StyledLabel *mMetEnsNumLabel;
LineEditFocusSelectAll *mMetEnsNumLineEdit;
void readInputsFromDM();
void readFromDataModel();
public:
APTEnsWidget(QWidget *parent = nullptr);
......
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