JYU-IBA / potku

Potku is analysis and simulation software for ToF-ERD measurements
https://www.jyu.fi/science/en/physics/research/infrastructures/accelerator-laboratory/pelletron/potku/
GNU General Public License v2.0
7 stars 7 forks source link

Fix saving bugs and RecoilElement renaming #299

Closed samivout closed 1 year ago

samivout commented 1 year ago

This PR fixes the various saving bugs that have popped up in Potku.

Firstly an unnecessary and breaking call of default_simulation.to_file in request_settings.py caused .mccfg files of simulations to be overwritten with the default .mcsimu file's content. This left the name field of the default element simulation as 'Default', while Potku expects the name to have an element prefix, e.g. 'Ti-Default'. Removing the mentioned function call fixes this and allows saving request settings to work as intended.

Secondly there were no StopIteration exception handling to set profile_file to None for finding .profile files in simulation.add_simulation_json method, even though there later was a conditional for NoneType.

Thirdly this fixes creation of element simulations with a simulation type that is different from the request-wide default. I added some functionality to pass the information to the initialization of ElementSimulation objects to create the object with the attribute use_default_settings as false when the simulation type is mismatched with the request default value.

Also fixes issue with the '' symbol added to scatter type element simulations in MCERD being updated only on relaunching Potku. I added an update_recoil_text method to widgets/matplotlib/simulation/element.py to handle this. There is still one issue with this however: the symbol updates only when clicking an element simulations own settings button. When the default element simulation type is changed in request settings, the state is reflected in the UI only after opening and closing the element simulation-specific settings dialog. This issue is beyond the scope of this PR as it requires some bigger changes in the movement of information between the back end and front end.

Additionally I noticed a bug that caused Potku to crash when changing a recoil element's name. This was caused by ´element_simulation.pymodule'supdate_recoil_element` method. The method has a lot of code to manage the old recoil element element simulation files, but as they're not used anymore they caused only problems. This issue was fixed by commenting out the portion regarding those files.