moved cursor toggle to context menu
This commit is contained in:
+20
-49
@@ -275,14 +275,6 @@ class DamarisGUI:
|
|||||||
self.toolbar_run_button = self.xml_gui.get_object( "toolbar_run_button" )
|
self.toolbar_run_button = self.xml_gui.get_object( "toolbar_run_button" )
|
||||||
self.toolbar_pause_button = self.xml_gui.get_object( "toolbar_pause_button" )
|
self.toolbar_pause_button = self.xml_gui.get_object( "toolbar_pause_button" )
|
||||||
|
|
||||||
# print button
|
|
||||||
#self.toolbar_print_button = self.xml_gui.get_object( "toolbar_print_button" )
|
|
||||||
#if not hasattr( gtk, "PrintOperation" ):
|
|
||||||
# self.toolbar_print_button.set_sensitive( False )
|
|
||||||
# print("Printing is not supported by GTK+ version in use")
|
|
||||||
#else:
|
|
||||||
# self.toolbar_print_button.set_sensitive( True )
|
|
||||||
|
|
||||||
# prepare for edit state
|
# prepare for edit state
|
||||||
self.toolbar_run_button.set_sensitive( True )
|
self.toolbar_run_button.set_sensitive( True )
|
||||||
self.toolbar_stop_button.set_sensitive( False )
|
self.toolbar_stop_button.set_sensitive( False )
|
||||||
@@ -2330,16 +2322,6 @@ class MonitorWidgets:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Add cursor toggle button to toolbar
|
|
||||||
self.matplot_cursor = None
|
|
||||||
separator = gtk.SeparatorToolItem()
|
|
||||||
self.matplot_toolbar.insert(separator, self.matplot_toolbar.get_n_items())
|
|
||||||
cursor_btn = gtk.ToggleToolButton()
|
|
||||||
cursor_btn.set_label("Cursor")
|
|
||||||
cursor_btn.set_tooltip_text("Toggle crosshair cursor")
|
|
||||||
cursor_btn.connect("toggled", self.toggle_cursor)
|
|
||||||
self.matplot_toolbar.insert(cursor_btn, self.matplot_toolbar.get_n_items())
|
|
||||||
|
|
||||||
self.display_table.attach( self.matplot_toolbar, 0, 1, 1, 2, gtk.AttachOptions.FILL | gtk.AttachOptions.EXPAND, 0, 0, 0 )
|
self.display_table.attach( self.matplot_toolbar, 0, 1, 1, 2, gtk.AttachOptions.FILL | gtk.AttachOptions.EXPAND, 0, 0, 0 )
|
||||||
self.matplot_toolbar.show( )
|
self.matplot_toolbar.show( )
|
||||||
|
|
||||||
@@ -2643,6 +2625,7 @@ class MonitorWidgets:
|
|||||||
def display_source_changed_event( self, widget, data=None ):
|
def display_source_changed_event( self, widget, data=None ):
|
||||||
|
|
||||||
new_data_name = self.source_list_current( )
|
new_data_name = self.source_list_current( )
|
||||||
|
|
||||||
if (self.displayed_data[ 0 ] is None and new_data_name == "None"):
|
if (self.displayed_data[ 0 ] is None and new_data_name == "None"):
|
||||||
return
|
return
|
||||||
if (self.displayed_data[ 0 ] == new_data_name):
|
if (self.displayed_data[ 0 ] == new_data_name):
|
||||||
@@ -2765,10 +2748,14 @@ class MonitorWidgets:
|
|||||||
"""Toggle matplotlib crosshair cursor"""
|
"""Toggle matplotlib crosshair cursor"""
|
||||||
from matplotlib.widgets import Cursor
|
from matplotlib.widgets import Cursor
|
||||||
if widget.get_active():
|
if widget.get_active():
|
||||||
|
if hasattr(self, 'matplot_cursor') and self.matplot_cursor is not None:
|
||||||
|
self.matplot_cursor.disconnect_events()
|
||||||
self.matplot_cursor = Cursor(self.matplot_axes, useblit=False, color='red', linewidth=1)
|
self.matplot_cursor = Cursor(self.matplot_axes, useblit=False, color='red', linewidth=1)
|
||||||
else:
|
else:
|
||||||
|
if hasattr(self, 'matplot_cursor') and self.matplot_cursor is not None:
|
||||||
|
self.matplot_cursor.disconnect_events()
|
||||||
self.matplot_cursor = None
|
self.matplot_cursor = None
|
||||||
self.matplot_canvas.draw()
|
self.matplot_canvas.draw_idle()
|
||||||
|
|
||||||
def on_canvas_button_press(self, widget, event):
|
def on_canvas_button_press(self, widget, event):
|
||||||
"""Handle button press events on matplotlib canvas"""
|
"""Handle button press events on matplotlib canvas"""
|
||||||
@@ -2781,6 +2768,17 @@ class MonitorWidgets:
|
|||||||
"""Show context menu for matplotlib canvas"""
|
"""Show context menu for matplotlib canvas"""
|
||||||
menu = gtk.Menu()
|
menu = gtk.Menu()
|
||||||
|
|
||||||
|
# toggle cursor
|
||||||
|
toggle_cursor = gtk.CheckMenuItem(label="Crosshair")
|
||||||
|
# Set the current state based on whether cursor exists
|
||||||
|
if hasattr(self, 'matplot_cursor') and self.matplot_cursor is not None:
|
||||||
|
toggle_cursor.set_active(True)
|
||||||
|
else:
|
||||||
|
toggle_cursor.set_active(False)
|
||||||
|
toggle_cursor.connect("toggled", self.toggle_cursor)
|
||||||
|
menu.append(toggle_cursor)
|
||||||
|
|
||||||
|
|
||||||
# Copy as PNG
|
# Copy as PNG
|
||||||
item_copy_png = gtk.MenuItem(label="Copy as PNG")
|
item_copy_png = gtk.MenuItem(label="Copy as PNG")
|
||||||
item_copy_png.connect("activate", self.copy_canvas_as_png)
|
item_copy_png.connect("activate", self.copy_canvas_as_png)
|
||||||
@@ -2862,37 +2860,8 @@ class MonitorWidgets:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log("Error copying figure to clipboard: %s" % str(e))
|
log("Error copying figure to clipboard: %s" % str(e))
|
||||||
# Fall through to text data copy
|
|
||||||
|
|
||||||
# Fallback: copy data as text (original functionality)
|
|
||||||
# can be removed after thorough testing
|
|
||||||
data_to_save = self.displayed_data[ : ]
|
|
||||||
if self.displayed_data[ 1 ] is None:
|
|
||||||
# nothing to save
|
|
||||||
return
|
|
||||||
if not hasattr( data_to_save[ 1 ], "write_to_csv" ):
|
|
||||||
log( "do not know how to save %s of class/type %s" % (data_to_save[ 0 ], type( data_to_save[ 1 ] )) )
|
|
||||||
return
|
|
||||||
|
|
||||||
# tested with qtiplot, labplot, openoffice
|
|
||||||
# tab delimiters necessary
|
|
||||||
# comments are not welcome :-(
|
|
||||||
tmpdata = io.StringIO( )
|
|
||||||
data_to_save[ 1 ].write_to_csv( tmpdata, delimiter="\t" )
|
|
||||||
# cut away comments
|
|
||||||
tmpstring = ""
|
|
||||||
tmpdata.seek( 0 )
|
|
||||||
for line in tmpdata:
|
|
||||||
if line[ 0 ] == "#":
|
|
||||||
continue
|
|
||||||
tmpstring += line
|
|
||||||
del tmpdata
|
|
||||||
clipboard = gtk.Clipboard.get(gdk.SELECTION_CLIPBOARD)
|
|
||||||
clipboard.set_text( tmpstring, -1 )
|
|
||||||
del tmpstring
|
|
||||||
|
|
||||||
##################### functions to feed display
|
##################### functions to feed display
|
||||||
|
|
||||||
def clear_display( self ):
|
def clear_display( self ):
|
||||||
"""
|
"""
|
||||||
unconditionally throw away everything
|
unconditionally throw away everything
|
||||||
@@ -2918,7 +2887,9 @@ class MonitorWidgets:
|
|||||||
# clear line plot
|
# clear line plot
|
||||||
self.matplot_axes.lines.remove( self.measurementresultline[ 0 ] )
|
self.matplot_axes.lines.remove( self.measurementresultline[ 0 ] )
|
||||||
self.measurementresultline = None
|
self.measurementresultline = None
|
||||||
|
if hasattr(self, 'matplot_cursor') and self.matplot_cursor is not None:
|
||||||
|
self.matplot_cursor.disconnect_events()
|
||||||
|
self.matplot_cursor = None
|
||||||
if not hasattr( self, "measurementresultgraph" ):
|
if not hasattr( self, "measurementresultgraph" ):
|
||||||
self.measurementresultgraph = None
|
self.measurementresultgraph = None
|
||||||
elif self.measurementresultgraph is not None:
|
elif self.measurementresultgraph is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user