Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
### GUI:

- [ ] Better help in configuration. A foldable dedicated text browser widget to show info?
- [ ] Implement UserTally options/definition in GUI
- [X] Implement UserTally options/definition in GUI
- [X] Getting Started
- [X] About

Expand Down
2 changes: 2 additions & 0 deletions source/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(GUI_HEADERS
simulationoptionsview.h
periodictablewidget.h
materialsdefview.h
usertallyview.h
optionsmodel.h
floatlineedit.h
mydatawidgetmapper.h
Expand All @@ -31,6 +32,7 @@ set(GUI_SOURCES
simulationoptionsview.cpp
periodictablewidget.cpp
materialsdefview.cpp
usertallyview.cpp
optionsmodel.cpp
floatlineedit.cpp
mydatawidgetmapper.cpp
Expand Down
77 changes: 77 additions & 0 deletions source/gui/assets/data/tally_templates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[
{
"id": "DepthProfile",
"description": "Ion implantation depth distribution along x-axis (100 bins, 0-100 nm)",
"event": "IonStop",
"bins": { "x": [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0,
10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0,
20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0,
30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0,
40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0,
50.0, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0,
60.0, 61.0, 62.0, 63.0, 64.0, 65.0, 66.0, 67.0, 68.0, 69.0,
70.0, 71.0, 72.0, 73.0, 74.0, 75.0, 76.0, 77.0, 78.0, 79.0,
80.0, 81.0, 82.0, 83.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0,
90.0, 91.0, 92.0, 93.0, 94.0, 95.0, 96.0, 97.0, 98.0, 99.0, 100.0] }
},
{
"id": "AngularDistribution",
"description": "Angular distribution of exiting ions (direction cosines nx, ny)",
"event": "IonExit",
"bins": {
"nx": [-1.0, -0.9, -0.8, -0.6, -0.4, -0.2, 0.0, 0.2, 0.4, 0.6, 0.8, 0.9, 1.0],
"ny": [-1.0, -0.8, -0.6, -0.4, -0.2, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
}
},
{
"id": "EnergySpectrum",
"description": "Energy spectrum of stopped ions (logarithmic bins, 1 eV - 1 MeV)",
"event": "IonStop",
"bins": { "E": [1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0, 500.0,
1000.0, 2000.0, 5000.0, 10000.0, 20000.0, 50000.0, 100000.0,
200000.0, 500000.0, 1000000.0] }
},
{
"id": "ImplantationMap",
"description": "2D implantation position map (x-depth vs y-lateral, 50x20 bins)",
"event": "IonStop",
"bins": {
"x": [0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0,
20.0, 22.0, 24.0, 26.0, 28.0, 30.0, 32.0, 34.0, 36.0, 38.0,
40.0, 42.0, 44.0, 46.0, 48.0, 50.0, 52.0, 54.0, 56.0, 58.0,
60.0, 62.0, 64.0, 66.0, 68.0, 70.0, 72.0, 74.0, 76.0, 78.0,
80.0, 82.0, 84.0, 86.0, 88.0, 90.0, 92.0, 94.0, 96.0, 98.0, 100.0],
"y": [-50.0, -45.0, -40.0, -35.0, -30.0, -25.0, -20.0, -15.0, -10.0, -5.0,
0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0]
}
},
{
"id": "VacancyDepthProfile",
"description": "Vacancy depth distribution along x-axis (100 bins, 0-100 nm)",
"event": "Vacancy",
"bins": { "x": [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0,
10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0,
20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0,
30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0,
40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0,
50.0, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0,
60.0, 61.0, 62.0, 63.0, 64.0, 65.0, 66.0, 67.0, 68.0, 69.0,
70.0, 71.0, 72.0, 73.0, 74.0, 75.0, 76.0, 77.0, 78.0, 79.0,
80.0, 81.0, 82.0, 83.0, 84.0, 85.0, 86.0, 87.0, 88.0, 89.0,
90.0, 91.0, 92.0, 93.0, 94.0, 95.0, 96.0, 97.0, 98.0, 99.0, 100.0] }
},
{
"id": "LateralSpread",
"description": "Cylindrical radius r vs depth x (lateral spread map, 20x50 bins)",
"event": "IonStop",
"bins": {
"r": [0.0, 2.5, 5.0, 7.5, 10.0, 12.5, 15.0, 17.5, 20.0, 22.5,
25.0, 27.5, 30.0, 32.5, 35.0, 37.5, 40.0, 42.5, 45.0, 47.5, 50.0],
"x": [0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0,
20.0, 22.0, 24.0, 26.0, 28.0, 30.0, 32.0, 34.0, 36.0, 38.0,
40.0, 42.0, 44.0, 46.0, 48.0, 50.0, 52.0, 54.0, 56.0, 58.0,
60.0, 62.0, 64.0, 66.0, 68.0, 70.0, 72.0, 74.0, 76.0, 78.0,
80.0, 82.0, 84.0, 86.0, 88.0, 90.0, 92.0, 94.0, 96.0, 98.0, 100.0]
}
}
]
1 change: 1 addition & 0 deletions source/gui/assets/ionicons/copy-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 8 additions & 24 deletions source/gui/materialsdefview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ void MaterialsDefView::addMaterial()
materials.push_back(newMaterial);
setWidgetData(); // widgets updated
cbMaterialID->setCurrentText(id);
// fake setData just to let model_ know that
// underlying data changed
model_->setData(materialsIndex_, QVariant());
model_->notifyDataChanged(materialsIndex_);

emit materialsChanged();
}
Expand All @@ -140,9 +138,7 @@ void MaterialsDefView::editMaterialName()
cbMaterialID->setItemText(i, id);
material::material_desc_t &m = model_->options()->Target.materials[i];
m.id = id.toStdString();
// fake setData just to let model_ know that
// underlying data changed
model_->setData(materialsIndex_, QVariant());
model_->notifyDataChanged(materialsIndex_);
}
setValueData(); // update material name
}
Expand All @@ -160,9 +156,7 @@ void MaterialsDefView::removeMaterial()
auto &materials = model_->options()->Target.materials;
materials.erase(materials.begin() + i);
setWidgetData(); // widgets updated
// fake setData just to let model_ know that
// underlying data changed
model_->setData(materialsIndex_, QVariant());
model_->notifyDataChanged(materialsIndex_);

emit materialsChanged();
}
Expand Down Expand Up @@ -245,9 +239,7 @@ void MaterialsDefView::setDensity(double v)
QString matid = cbMaterialID->currentText();
material::material_desc_t &mat = materials[i];
mat.density = v;
// fake setData just to let model_ know that
// underlying data changed
model_->setData(materialsIndex_, QVariant());
model_->notifyDataChanged(materialsIndex_);
}

void MaterialsDefView::selectColor()
Expand All @@ -269,9 +261,7 @@ void MaterialsDefView::selectColor()
if (clr.isValid()) {
mat.color = clr.name(QColor::HexArgb).toStdString();
setBtMatColor(clr);
// fake setData just to let model_ know that
// underlying data changed
model_->setData(materialsIndex_, QVariant());
model_->notifyDataChanged(materialsIndex_);

emit materialsChanged();
}
Expand Down Expand Up @@ -431,9 +421,7 @@ bool MaterialCompositionModel::setData(const QModelIndex &index, const QVariant
default:;
}

// fake setData just to let model_ know that
// underlying data changed
model_->setData(materialsIndex_, QVariant());
model_->notifyDataChanged(materialsIndex_);

return true;
}
Expand All @@ -451,9 +439,7 @@ bool MaterialCompositionModel::insertRows(int position, int rows, const QModelIn
mat->composition.push_back(atom::parameters());
endInsertRows();

// fake setData just to let model_ know that
// underlying data changed
model_->setData(materialsIndex_, QVariant());
model_->notifyDataChanged(materialsIndex_);

return true;
}
Expand All @@ -473,9 +459,7 @@ bool MaterialCompositionModel::removeRows(int position, int rows, const QModelIn
mat->composition.erase(mat->composition.begin() + position);
endRemoveRows();

// fake setData just to let model_ know that
// underlying data changed
model_->setData(materialsIndex_, QVariant());
model_->notifyDataChanged(materialsIndex_);

return true;
}
Expand Down
2 changes: 2 additions & 0 deletions source/gui/opentrim.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<file>assets/ionicons/list-outline.png</file>
<file>assets/ionicons/bar-chart-outline.png</file>
<file>assets/lucide/chart-line.svg</file>
<file>assets/data/tally_templates.json</file>
<file>md/quick_start.md</file>
<file>md/images/intro.png</file>
<file>md/images/intro22.png</file>
Expand All @@ -37,6 +38,7 @@
<file>assets/ionicons/open-outline.svg</file>
<file>assets/3d/cubeFlat.obj</file>
<file>assets/ionicons/create-outline.svg</file>
<file>assets/ionicons/copy-outline.svg</file>
<file>examples/270keV_He_on_C.json</file>
</qresource>
</RCC>
57 changes: 48 additions & 9 deletions source/gui/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,19 @@ QVariant OptionsItem::value() const
}
bool OptionsItem::setValue(const QVariant &v)
{
QString vnew = v.toString();
if (vnew.trimmed().isEmpty()) {
const QString k = key().trimmed();
const QString jp = QString::fromStdString(jpath_);
if (k == "materials" || k == "regions" || k == "UserTally"
|| jp.endsWith("/materials") || jp.endsWith("/regions") || jp.endsWith("/UserTally")) {
vnew = "[]";
}
}

QVariant v0 = value();
if (v0.toString() != v.toString()) {
set_(v.toString());
if (v0.toString() != vnew) {
set_(vnew);
return true;
}
return false;
Expand Down Expand Up @@ -112,6 +122,21 @@ bool OptionsItem::get_(QString &qs) const
bool OptionsItem::set_(const QString &qs)
{
std::string s = qs.toStdString();
if (qs.trimmed().isEmpty()) {
const QString jp = QString::fromStdString(jpath_);
if (jp.endsWith("/materials") || jp.endsWith("/regions") || jp.endsWith("/UserTally")) {
s = "[]";
}

QString current;
if (s.empty() && get_(current)) {
const QString trimmed = current.trimmed();
if (trimmed.startsWith('['))
s = "[]";
else if (trimmed.startsWith('{'))
s = "{}";
}
}
std::ostringstream os;
bool ret = options_->set(jpath_, s, &os);
if (!ret) {
Expand Down Expand Up @@ -450,17 +475,25 @@ QVariant OptionsModel::data(const QModelIndex &index, int role) const
}
bool OptionsModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
// int col = index.column();
if (Qt::EditRole == role) {
// if (col == 1) {
if (!index.isValid() || index.column() != 1 || !value.isValid())
return false;

OptionsItem *item = static_cast<OptionsItem *>(index.internalPointer());
// Base OptionsItem represents struct/array containers; these should never be edited directly.
if (typeid(*item) == typeid(OptionsItem))
return false;

if (item->setValue(value))
emit dataChanged(index, index, { Qt::EditRole });
return true;
//}
}
return false;
}
void OptionsModel::notifyDataChanged(const QModelIndex &index)
{
emit dataChanged(index, index, { Qt::EditRole });
}
QVariant OptionsModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role != Qt::DisplayRole)
Expand Down Expand Up @@ -552,10 +585,16 @@ int OptionsModel::columnCount(const QModelIndex &parent) const

Qt::ItemFlags OptionsModel::flags(const QModelIndex &index) const
{
if (index.column() == 1)
return Qt::ItemIsEditable | QAbstractItemModel::flags(index);
else
return QAbstractItemModel::flags(index);
Qt::ItemFlags baseFlags = QAbstractItemModel::flags(index);
if (!index.isValid() || index.column() != 1)
return baseFlags;

OptionsItem *item = static_cast<OptionsItem *>(index.internalPointer());
// Only typed option nodes are editable. Container nodes (struct/array) are read-only.
if (item && typeid(*item) != typeid(OptionsItem))
return baseFlags | Qt::ItemIsEditable;

return baseFlags;
}

OptionsItem *OptionsModel::getItem(const QModelIndex &index) const
Expand Down
1 change: 1 addition & 0 deletions source/gui/optionsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class OptionsModel : public QAbstractItemModel

Qt::ItemFlags flags(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
void notifyDataChanged(const QModelIndex &index);

OptionsItem *getItem(const QModelIndex &index) const;

Expand Down
16 changes: 4 additions & 12 deletions source/gui/regionsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ bool RegionsModel::setData(const QModelIndex &index, const QVariant &value, int
break;
}

// fake setData just to let model_ know that
// underlying data changed
model_->setData(regionsIndex_, QVariant());
model_->notifyDataChanged(regionsIndex_);

emit dataChanged(index, index);

Expand All @@ -161,9 +159,7 @@ bool RegionsModel::insertRows(int position, int rows, const QModelIndex &parent)
opt->Target.regions.push_back(reg);
endInsertRows();

// fake setData just to let model_ know that
// underlying data changed
model_->setData(regionsIndex_, QVariant());
model_->notifyDataChanged(regionsIndex_);

return true;
}
Expand All @@ -181,9 +177,7 @@ bool RegionsModel::removeRows(int position, int rows, const QModelIndex &parent)
regions.erase(it);
endRemoveRows();

// fake setData just to let model_ know that
// underlying data changed
model_->setData(regionsIndex_, QVariant());
model_->notifyDataChanged(regionsIndex_);

return true;
}
Expand Down Expand Up @@ -215,9 +209,7 @@ bool RegionsModel::moveRow(int from, int to)
regions.insert(regions.begin() + to, reg);
endInsertRows();

// fake setData just to let model_ know that
// underlying data changed
model_->setData(regionsIndex_, QVariant());
model_->notifyDataChanged(regionsIndex_);

return true;
}
Expand Down
8 changes: 7 additions & 1 deletion source/gui/simulationoptionsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "periodic_table.h"
#include "periodictablewidget.h"
#include "materialsdefview.h"
#include "usertallyview.h"
#include "regionsview.h"
#include "optionsmodel.h"
#include "mydatawidgetmapper.h"
Expand Down Expand Up @@ -72,7 +73,8 @@ SimulationOptionsView::SimulationOptionsView(MainUI *iui, QWidget *parent)
else if (category == "Target")
widget = createTargetTab(idx);
else if (category == "UserTally") {
// TODO !!
userTallyView_ = new UserTallyView(model);
widget = userTallyView_;
} else
widget = createTab(idx);

Expand Down Expand Up @@ -193,6 +195,8 @@ void SimulationOptionsView::revert()
mapper->model()->setOptions(opt);
mapper->revert();
materialsView->setWidgetData();
if (userTallyView_)
userTallyView_->setWidgetData();
regionsView->revert();
jsonView->setPlainText(QString::fromStdString(ionsui->driverObj()->json()));

Expand Down Expand Up @@ -443,6 +447,8 @@ void SimulationOptionsView::onDriverStatusChanged()
mapper->setEnabled(isreset);
btSelectIon->setEnabled(isreset);
materialsView->setEnabled(isreset);
if (userTallyView_)
userTallyView_->setEnabled(isreset);
regionsView->setEnabled(isreset);
if (isreset)
applyRules();
Expand Down
Loading