Merge branch 'main' of gitea.pkm.physik.tu-darmstadt.de:IPKM/python3-damaris
merge
This commit is contained in:
@@ -128,12 +128,10 @@ class Drawable:
|
|||||||
|
|
||||||
def set_legend(self, channel, value):
|
def set_legend(self, channel, value):
|
||||||
"Sets the legend of the plot"
|
"Sets the legend of the plot"
|
||||||
if key in self.legend:
|
if channel in self.legend:
|
||||||
print("Drawable Warning: Legend key \"%s\" will be overwritten with \"%s\"" % (str(channel), str(value)))
|
print("Drawable Warning: Legend key \"%s\" will be overwritten with \"%s\"" % (str(channel), str(value)))
|
||||||
|
|
||||||
self.legend[channel] = str(value)
|
self.legend[channel] = str(value)
|
||||||
|
|
||||||
|
|
||||||
def get_xmin(self):
|
def get_xmin(self):
|
||||||
"Returns minimun of x"
|
"Returns minimun of x"
|
||||||
return self.x.min()
|
return self.x.min()
|
||||||
@@ -142,17 +140,14 @@ class Drawable:
|
|||||||
"Sets minimum of x"
|
"Sets minimum of x"
|
||||||
self.xmin = xmin
|
self.xmin = xmin
|
||||||
|
|
||||||
|
|
||||||
def get_xmax(self):
|
def get_xmax(self):
|
||||||
"Returns maximum of x"
|
"Returns maximum of x"
|
||||||
return self.x.max()
|
return self.x.max()
|
||||||
|
|
||||||
|
|
||||||
def set_xmax(self, xmax):
|
def set_xmax(self, xmax):
|
||||||
"Sets maximum of x"
|
"Sets maximum of x"
|
||||||
self.xmax = xmax
|
self.xmax = xmax
|
||||||
|
|
||||||
|
|
||||||
def get_ymin(self):
|
def get_ymin(self):
|
||||||
"Returns minimum of y"
|
"Returns minimum of y"
|
||||||
if type(self.y)==type([]):
|
if type(self.y)==type([]):
|
||||||
@@ -160,12 +155,10 @@ class Drawable:
|
|||||||
else:
|
else:
|
||||||
return self.y.min()
|
return self.y.min()
|
||||||
|
|
||||||
|
|
||||||
def set_ymin(self, ymin):
|
def set_ymin(self, ymin):
|
||||||
"Sets minimum of y"
|
"Sets minimum of y"
|
||||||
self.ymin = ymin
|
self.ymin = ymin
|
||||||
|
|
||||||
|
|
||||||
def get_ymax(self):
|
def get_ymax(self):
|
||||||
"Returns maximimum of y"
|
"Returns maximimum of y"
|
||||||
if type(self.y)==type([]):
|
if type(self.y)==type([]):
|
||||||
@@ -173,7 +166,6 @@ class Drawable:
|
|||||||
else:
|
else:
|
||||||
return self.y.max()
|
return self.y.max()
|
||||||
|
|
||||||
|
|
||||||
def set_ymax(self, ymax):
|
def set_ymax(self, ymax):
|
||||||
"Sets maximum of y"
|
"Sets maximum of y"
|
||||||
self.ymax = ymax
|
self.ymax = ymax
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class MeasurementResult(Drawable.Drawable, collections.UserDict):
|
|||||||
Drawable.Drawable.__init__(self)
|
Drawable.Drawable.__init__(self)
|
||||||
collections.UserDict.__init__(self)
|
collections.UserDict.__init__(self)
|
||||||
self.quantity_name=quantity_name
|
self.quantity_name=quantity_name
|
||||||
self.lock=threading.RLock()
|
self.lock = threading.RLock()
|
||||||
|
|
||||||
# get the selected item, if it does not exist, create an empty one
|
# get the selected item, if it does not exist, create an empty one
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
@@ -226,7 +226,6 @@ class MeasurementResult(Drawable.Drawable, collections.UserDict):
|
|||||||
|
|
||||||
|
|
||||||
def write_to_hdf(self, hdffile, where, name, title, complib=None, complevel=None):
|
def write_to_hdf(self, hdffile, where, name, title, complib=None, complevel=None):
|
||||||
|
|
||||||
h5_table_format= {
|
h5_table_format= {
|
||||||
"x" : tables.Float32Col(),
|
"x" : tables.Float32Col(),
|
||||||
"y" : tables.Float32Col(),
|
"y" : tables.Float32Col(),
|
||||||
|
|||||||
+27
-52
@@ -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 )
|
||||||
@@ -426,9 +418,8 @@ class DamarisGUI:
|
|||||||
lo = 0
|
lo = 0
|
||||||
print("Experiment Script: %s at line %d, col %d:" % (e.__class__.__name__, ln, lo))
|
print("Experiment Script: %s at line %d, col %d:" % (e.__class__.__name__, ln, lo))
|
||||||
if e.text != "":
|
if e.text != "":
|
||||||
print("\"%s\"" % e.text)
|
print(e.text.rstrip())
|
||||||
# print " "*(e.offset+1)+"^" # nice idea, but needs monospaced fonts
|
print(" "*(e.offset-1)+"^")
|
||||||
pass
|
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
res_code = None
|
res_code = None
|
||||||
@@ -1088,6 +1079,8 @@ class LogWindow:
|
|||||||
self.damaris_gui = damaris_gui
|
self.damaris_gui = damaris_gui
|
||||||
self.textview = self.xml_gui.get_object( "messages_textview" )
|
self.textview = self.xml_gui.get_object( "messages_textview" )
|
||||||
self.textview.connect( "key-press-event", self.textview_keypress)
|
self.textview.connect( "key-press-event", self.textview_keypress)
|
||||||
|
font_desc = pango.FontDescription("Monospace 10")
|
||||||
|
self.textview.modify_font(font_desc)
|
||||||
self.textbuffer = self.textview.get_buffer( )
|
self.textbuffer = self.textview.get_buffer( )
|
||||||
self.logstream = log
|
self.logstream = log
|
||||||
self.logstream.gui_log = self
|
self.logstream.gui_log = self
|
||||||
@@ -1959,9 +1952,12 @@ class ConfigTab:
|
|||||||
self.config_del_jobs_after_execution_checkbutton = self.xml_gui.get_object(
|
self.config_del_jobs_after_execution_checkbutton = self.xml_gui.get_object(
|
||||||
"del_jobs_after_execution_checkbutton" )
|
"del_jobs_after_execution_checkbutton" )
|
||||||
self.config_data_pool_name_entry = self.xml_gui.get_object( "data_pool_name_entry" )
|
self.config_data_pool_name_entry = self.xml_gui.get_object( "data_pool_name_entry" )
|
||||||
|
self.config_data_pool_name_entry.set_tooltip_text("Use %(date)s for ISO date or %(datetime)s for ISO date+time")
|
||||||
self.config_data_pool_write_interval_entry = self.xml_gui.get_object( "data_pool_write_interval_entry" )
|
self.config_data_pool_write_interval_entry = self.xml_gui.get_object( "data_pool_write_interval_entry" )
|
||||||
self.config_data_pool_complib = self.xml_gui.get_object( "CompLibs" )
|
self.config_data_pool_complib = self.xml_gui.get_object( "CompLibs" )
|
||||||
|
self.config_data_pool_complib.set_tooltip_text("Use zlib for best compatibility with other tools")
|
||||||
self.config_data_pool_comprate = self.xml_gui.get_object( "CompRatio" )
|
self.config_data_pool_comprate = self.xml_gui.get_object( "CompRatio" )
|
||||||
|
self.config_data_pool_comprate.set_tooltip_text("Use 1 for best compression, 9 for best speed; 3 is very usable")
|
||||||
self.config_info_textview = self.xml_gui.get_object( "info_textview" )
|
self.config_info_textview = self.xml_gui.get_object( "info_textview" )
|
||||||
self.config_script_font_button = self.xml_gui.get_object( "script_fontbutton" )
|
self.config_script_font_button = self.xml_gui.get_object( "script_fontbutton" )
|
||||||
|
|
||||||
@@ -2330,16 +2326,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 +2629,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 +2752,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 +2772,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 +2864,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 +2891,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