Skip to content

feat(gui): material database browser + UserTally editor#12

Closed
dhanavanthesh wants to merge 2 commits into
ir2-lab:mainfrom
dhanavanthesh:feat/gui-material-db-and-usertally
Closed

feat(gui): material database browser + UserTally editor#12
dhanavanthesh wants to merge 2 commits into
ir2-lab:mainfrom
dhanavanthesh:feat/gui-material-db-and-usertally

Conversation

@dhanavanthesh
Copy link
Copy Markdown
Contributor

Closes TODO.md lines 46, 102, 103.

  • Implement UserTally options/definition in GUI
  • Add a database of pre-defined materials with full definition
  • Pressing add material presents a selection/search function

Two config sections that required hand-written JSON now have full GUI editors.


Materials

A database search button is added first in the button row opens a dialog over 59 pre-defined materials loaded via ojson (no QJsonDocument).

  • Name filter: type "iron" gets Fe, FeO, Fe2O3, Fe3O4
  • Element filter: type "Fe" gets every material containing an Fe atom
  • Preview shows density + full composition table (Symbol, X, Ed, El, Es, Er, Rc) before accepting
  • Accept then material auto-selected, density and composition pre-filled. Zero typing.
  • Combo, density spinbox, color button disabled when list is empty
  • Duplicate IDs shown as "Fe" and "Fe (2)"
  • Tooltips corrected: "Add material from database" / "Add new material" / "Remove material" / "Rename material"
materials-screen-recording.mp4

UserTally

// TODO !! at simulationoptionsview.cpp:74 replaced with a full UserTallyView widget.

Tally management

  • Add, remove, rename, duplicate from toolbar
  • Duplicate produces collision-safe id: _copy, _copy2, ...
  • Event picker: IonStop, IonExit, Vacancy, Replacement, CascadeComplete, BoundaryCrossing
  • Disables during simulation run, reloads on revert

Bin variable table

  • 14 variables in a dropdown with name + description
  • [~] - linspace dialog per row: enter min, max, N, live edge preview
  • [×] - removes that variable
  • Non-monotonic edges turn the cell red

Live summary

  • "2D tally: x × E (100 × 50 = 5000 bins)"
  • Amber at 10.000 bins, red at 200.000
  • Memory shown as ~40.0 KB / ~2.30 MB
  • Warning text at 500.000 bins

Coordinate system

  • "Use lab frame" checkbox hides origin/z-axis/xz-vector fields when not needed

Templates

  • 6 presets: Depth Profile, Angular Distribution, Energy Spectrum, Implantation Map, Vacancy Depth Profile, Lateral Spread
  • Preview shows x : 0 to 100 (100 bins) per variable
  • If no tallies exist, one is created automatically before the dialog opens
  • Template JSON cached after first parse
user_tally-screen-recording.mp4

Also fixed a latent issue in OptionsModel - setData(idx, QVariant()) was silently reaching ojson::parse("") on every array edit from the GUI. Replaced with notifyDataChanged() across all 11 call sites in materialsdefview and regionsview. Empty string guard added in parse_json::set_impl_. Container nodes marked non-editable in flags().


New: materialdatabasedialog.h/.cpp, usertallyview.h/.cpp,
database-search.svg, materials_database.json, tally_templates.json

Modified: materialsdefview, simulationoptionsview, optionsmodel,
parse_json.cpp, opentrim.qrc, CMakeLists.txt, TODO.md

Closes TODO.md lines 46, 102, 103.

Materials: searchable database dialog (59 materials, name + element, filter, composition preview). Auto-selects after add. ojson throughout.

UserTally: replaces // TODO !! with full editor - add/remove/rename/duplicate tallies, 14 bin variables, linspace generator, 6 templates, live summary with traffic-light colors, coordinate system fields.

OptionsModel: notifyDataChanged() replaces setData(idx, QVariant()) across materialsdefview and regionsview - old pattern was silently hitting ojson::parse("") on every array edit. 11 call sites converted.
@gapost
Copy link
Copy Markdown
Member

gapost commented Mar 19, 2026

Thank you for your contribution and the effort you put into this PR!

Unfortunately, I'll be closing it for two reasons:

  1. Duplicate work – A solid implementation of the materials database dialog was already proposed in PR feat: Add MaterialDatabaseDialog for selecting predefined materials #8, which is currently in progress. Duplicating this effort creates unnecessary review overhead and goes against open source best practices around coordination.

  2. Scope – Bundling two large, independent features into a single PR makes it significantly harder to review, test, and merge cleanly.

Your work on the usertally editor is genuinely appreciated, and I don't want it to go to waste. Please submit it as a standalone PR and I'll be happy to review it properly.

Thanks for understanding, and I look forward to your next contribution!

@gapost gapost closed this Mar 19, 2026
@dhanavanthesh
Copy link
Copy Markdown
Contributor Author

Thank you for the feedback. Opened the UserTally editor as a standalone PR #14 . @gapost ready for review when you get a chance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants