Commit bde01752 authored by Félix Hartmann's avatar Félix Hartmann
Browse files

The floating menu which pops up when an organ is clicked is now

contextual. It depends on the model chosen and past actions.
parent 6a8b2b3a
......@@ -2424,8 +2424,12 @@ def show_growth_length():
fig_growth_length.show()
def show_beta():
"""Interactive estimation of the angle-response parameter beta."""
def show_beta_tilde():
r"""Interactive estimation of the dimensionless graviceptive sensitivity β̃.
The definition of β̃ ($\tilde{\beta}$) can be found in :
Bastien, Douady and Moulia (2014), https://doi.org/10.3389/fpls.2014.00136.
"""
# Force la fermeture du menu popup dans tk
interekt.floatmenuisopen = False
......@@ -2687,8 +2691,11 @@ def show_beta():
fig_beta.show()
def show_gamma():
"""Estimation interactive du paramètre de proprioception gamma.
def show_gamma_tilde():
r"""Interactive estimation of the dimensionless proprioceptive sensitivity γ̃.
The definition of γ̃ ($\tilde{\gamma}$) can be found in :
Bastien, Douady and Moulia (2014), https://doi.org/10.3389/fpls.2014.00136.
Ce code s'applique aux résultats issus du protocole expérimental suivant :
1. La plante est initialement à l'horizontal, clinostat éteint.
......@@ -2710,9 +2717,6 @@ def show_gamma():
Pour obtenir gamma_tilde, issu du modèle ACĖ (Bastien et al. 2014 Frontiers), il faut
le taux relatif d'élongation (Relative Elongation Rate, RER). Il est obtenu à partir
de la courbe de croissance.
Le code de cette fonction reprend en partie celui de la fonction 'show_time_series'
initialement écrit par Hugo Chauvet.
"""
# Force la fermeture du menu popup dans tk
interekt.floatmenuisopen = False
......@@ -3270,10 +3274,6 @@ def show_B(tige_id=None):
fig_B.show()
def show_curvature_around_mark(mark_number):
pass
def plot_moyenne():
"""
Trace l'ensemble des courbes angles/tailles vs temps pour toutes
......@@ -3804,7 +3804,7 @@ class Interekt:
plotmenu.add_command(label=_("Time series"), command=plot_moyenne)
menubar.add_cascade(label=_("Plots"), menu=plotmenu)
#Options menu
#options menu
options_menu = Tk.Menu(menubar)
#Pour chercher le temps dans les données EXIFS des images
......@@ -3845,47 +3845,32 @@ class Interekt:
menubar.add_cascade(label=_('Options'), menu=options_menu)
#Display the menu
self.master.config(menu=menubar)
self.master.columnconfigure(1, weight=1, minsize=600)
self.master.rowconfigure(1, weight=1)
#Floating menu (pour afficher des infos pour une tige)
self.floatmenu = Tk.Menu(self.master, tearoff=0)
#floatmenu.add_command(label="Inverser la base", command=_reverse_tige)
self.floatmenu.add_command(label=_("Time series"),
command=show_time_series)
self.floatmenu.add_command(label=strings["Spatiotemporal heatmaps"],
command=show_heatmaps)
self.floatmenu.add_command(label=_("Angles and curvatures"),
command=show_angle_and_curvature)
# Menu for choosing the model to use
model_menu = Tk.Menu(menubar)
self.model = Tk.StringVar()
self.model.set("No model")
self.floatmenu.add_command(label=_("Estimate growth rate"),
command=show_growth_rate)
model_menu.add_radiobutton(label=_('No model'), variable=self.model,
value="No model")
self.floatmenu.add_command(label=_("Estimate growth length"),
command=show_growth_length)
model_menu.add_radiobutton(label=_('Linear growth'), variable=self.model,
value="Linear growth")
self.floatmenu.add_command(label=_("Estimate beta"),
command=show_beta)
# model_menu.add_radiobutton(label='AC', variable=self.model,
# value="AC")
self.floatmenu.add_command(label=_("Estimate gamma"),
command=show_gamma)
model_menu.add_radiobutton(label='ACĖ', variable=self.model,
value="ACE")
self.floatmenu.add_command(label=_("Estimate B"),
command=show_B)
# model_menu.add_radiobutton(label='ACα', variable=self.model,
# value="ACalpha")
self.floatmenu.add_command(label=_("Settings"),
command=show_tige_options)
self.floatmenu.add_command(label=_("Suppress the base"),
command=remove_tige)
menubar.add_cascade(label=_('Model'), menu=model_menu)
self.floatmenuisopen = False
#Display the menu
self.master.config(menu=menubar)
self.master.columnconfigure(1, weight=1, minsize=600)
self.master.rowconfigure(1, weight=1)
#BOTTOM MENU BAR
buttonFrame = Frame(master=self.master)
......@@ -3927,6 +3912,30 @@ class Interekt:
self.prog_bar.grid(row=2, columnspan=2, sticky=Tk.E+Tk.W)
#Floating menu (pour afficher des infos pour une tige)
self.floatmenu = Tk.Menu(self.master, tearoff=0)
#floatmenu.add_command(label="Inverser la base", command=_reverse_tige)
self.floatmenu.add_command(label=_("Time series"),
command=show_time_series)
self.floatmenu.add_command(label=strings["Spatiotemporal heatmaps"],
command=show_heatmaps)
self.floatmenu.add_command(label=_("Angles and curvatures"),
command=show_angle_and_curvature)
self.floatmenu.add_separator()
self.floatmenu.add_command(label=_("Settings"),
command=show_tige_options)
self.floatmenu.add_command(label=_("Suppress the base"),
command=remove_tige)
self.floatmenuisopen = False
#button_export.pack(side=Tk.LEFT)
#figsize=(10,8)
self.fig = mpl.figure()
......@@ -3961,6 +3970,61 @@ class Interekt:
self.canvas.mpl_connect('pick_event', self.onPick)
self.canvas.mpl_connect("motion_notify_event", self.onmousemove)
def update_floatmenu(self, tige_hdf_id, line_type):
"""Set the available items in floatmenu depending on the context.
The method is called when a tige or a base has been picked, just before the
floating menu pops up. It populates the floating menu associated with a tige with
the actions which are possible given the model chosen and the values already
estimated.
Parameters:
- tige_id_hdf: tige identifier in the hdf file
- line_type: type of the clicked line ('tige' or 'base')
"""
self.floatmenu.delete(0, "end") # reset the floating menu
if line_type == "tige":
self.floatmenu.add_command(label=_("Time series"),
command=show_time_series)
self.floatmenu.add_command(label=strings["Spatiotemporal heatmaps"],
command=show_heatmaps)
self.floatmenu.add_command(label=_("Angles and curvatures"),
command=show_angle_and_curvature)
self.floatmenu.add_separator()
growth_data = h5store.get_postprocessing(hdf5file, 'growth_data', tige_hdf_id)
model = self.model.get()
if model == "Linear growth" or model == "ACE":
# Estimation of the growth rate and the growth length
self.floatmenu.add_command(label=_("Estimate growth rate"),
command=show_growth_rate)
if growth_data is not None and growth_data.get("dLdt") is not None:
# The growth rate has to be estimated before the growth length
self.floatmenu.add_command(label=_("Estimate growth length"),
command=show_growth_length)
self.floatmenu.add_separator()
if (model == "ACE" and growth_data is not None
and growth_data.get("dLdt") is not None):
# Estimation of beta tilde and gamma tilde
# The growth rate has to be estimated before beta tilde
self.floatmenu.add_command(label=_("Estimate β̃ (beta tilde)"),
command=show_beta_tilde)
if growth_data.get("Lgz") is not None:
# The growth length has to be estimated before gammatilde
self.floatmenu.add_command(label=_("Estimate γ̃ (gamma tilde)"),
command=show_gamma_tilde)
self.floatmenu.add_command(label=_("Estimate B"),
command=show_B)
self.floatmenu.add_separator()
# In all cases, add the base commands
self.floatmenu.add_command(label=_("Settings"),
command=show_tige_options)
self.floatmenu.add_command(label=_("Suppress the base"),
command=remove_tige)
def popup(self, tige_id):
global cur_tige
......@@ -4163,26 +4227,26 @@ class Interekt:
if line_type == "base" or line_type == "tige":
tige_id = int(label)
tige_id_hdf = get_hdf5_tigeid(hdf5file, tige_id)
tige_hdf_id = get_hdf5_tigeid(hdf5file, tige_id)
try:
print(u'Selection de la tige %s' % tiges_names[tige_id])
print(u'Enregistrée dans le fichier hdf sous tige%i ' % tige_id_hdf)
print(u'Enregistrée dans le fichier hdf sous tige%i ' % tige_hdf_id)
print(u'Position dans la liste du gui %i' % tige_id)
except:
print(u'Selection de la tige %i du gui'%(tige_id))
print(u'Enregistrée sous le nom tige%i dans le fichier hdf' % tige_id_hdf)
if event.mouseevent.button == 1:
if event.mouseevent.button == 1: # left click
if line_type == "tige":
show_time_series(tige_id=tige_id)
elif line_type == "mark":
mark_number = int(label.split("_")[-1])
show_curvature_around_mark(mark_number)
# no action for now
if event.mouseevent.button == 3:
if event.mouseevent.button == 3: # right click
if not self.floatmenuisopen and (line_type == "tige"
or line_type == "base"):
print('open float menu')
self.update_floatmenu(tige_hdf_id, line_type)
self.popup(tige_id)
......
Supports Markdown
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