Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot / sum spectrum is not updating when a recoil element is removed #230

Open
jkpnen opened this issue Nov 25, 2021 · 2 comments · Fixed by #232
Open

Plot / sum spectrum is not updating when a recoil element is removed #230

jkpnen opened this issue Nov 25, 2021 · 2 comments · Fixed by #232

Comments

@jkpnen
Copy link
Contributor

jkpnen commented Nov 25, 2021

When a recoil element (such as Cl) is removed from the GUI it should be removed from the plot too.

remove_selected_element
sum_spectrum_not_updating

@jkpnen jkpnen mentioned this issue Nov 25, 2021
3 tasks
@jkpnen
Copy link
Contributor Author

jkpnen commented Nov 25, 2021

@tpitkanen , any ideas how to tackle this?

I think here should be some kind of listener:

def remove_element_simulation(self, element_simulation: ElementSimulation):
"""Remove element simulation.
Args:
element_simulation: An ElementSimulation object to be removed.
"""
element_simulation.get_main_recoil().delete_widgets()
self.element_simulations.remove(element_simulation)
# Delete all files that relate to element_simulation
element_simulation.delete_all_files()

Is it somehow possible to use this:

def update_spectra(self, rec_elem: RecoilElement,
elem_sim: ElementSimulation):
"""Update a spectra that belongs to given recoil element.
Args:
rec_elem: RecoilElement object
elem_sim: ElementSimulation object that is used to calculate the
spectrum
"""
# TODO change plot range if necessary
if rec_elem is None or elem_sim is None:
return
espe_file = Path(elem_sim.directory, f"{rec_elem.get_full_name()}.simu")
if espe_file in self.plots:
espe, _ = elem_sim.calculate_espe(rec_elem, ch=self.channel_width)
data = get_axis_values(espe)
self.plots[espe_file].set_data(data)
self._update_sum_spectra(espe_file, espe)
self.canvas.draw()
self.canvas.flush_events()

@tpitkanen
Copy link
Member

The "Remove selected element" button calls this method: RecoilAtomDistributionWidget.remove_current_element. Try looking into that. Looks like the method should remove the element from plots, but doesn't for some reason.

I think you should first ask @mlaitin if Potku has previously done this or not. If it has, this current behavior is caused by a bug and needs to be fixed. If it hasn't, then this is new functionality that needs to be implemented.

Also, as always, check if this change has any possible side effects.

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 a pull request may close this issue.

2 participants