ENLIGHTEN
Cross-platform desktop GUI for Wasatch Photonics spectrometers
Loading...
Searching...
No Matches
enlighten.scope.Graph.Graph Class Reference

Encapsulate the large graph in the center of ENLIGHTEN's Scope Capture screen. More...

Public Member Functions

 __init__ (self, ctl, name, legend=None, lock_marker=False, plot=None)
 This can be constructed in two ways.
 
 add_curve (self, name, y=[], x=None, pen=None, spec=None, measurement=None, rehide=True, in_legend=True)
 This was originally used used by ThumbnailWidget, when clicking the "show trace" thumbnail button.
 
 add_item (self, item)
 called by Cursor to add its InfiniteLine to the graph
 
 add_roi_region (self, region)
 Horizontal ROI.
 
 copy_to_clipboard_callback (self)
 
 enable_axis_selection (self, flag)
 
 enable_wavenumbers (self, flag)
 
 get_x_axis_unit (self)
 
 in_pixels (self)
 
 in_wavelengths (self)
 
 in_wavenumbers (self)
 
 invert_x_axis (self)
 
 populate_scope_capture (self)
 
 populate_scope_setup (self)
 
 register_observer (self, event, callback)
 
 remove_curve (self, name=None, measurement_id=None)
 If nobody else persists the curve, this will delete the curve object itself from memory, as well removing it from the graph.
 
 remove_from_legend (self, name=None, measurement_id=None)
 
 remove_roi_region (self, region)
 
 rescale_curves (self)
 Iterates through all the curves currently shown on the graph and updates them to the correct x-axis.
 
 reset_axes (self)
 
 set_data (self, curve, y=None, x=None, label=None)
 
 set_x_axis (self, enum)
 when the Mode changes, update axis as appropriate
 
 set_x_axis_label (self, text, locked=False)
 extra
provides margin from the frame bottom...probably would be better with CSS
 
 set_y_axis (self, enum)
 Only sets the "intention" to use the specified axis label; in reference- based modes, don't actually switch to the target axis until processing requirements are met (i.e., a reference has been taken).
 
 toggle_lock_axes (self)
 
 toggle_zoom (self)
 
 update_axis_callback (self)
 
 update_combo_tooltip (self)
 
 update_curve_marker (self, curve)
 
 update_marker (self)
 
 update_visibility (self)
 

Public Attributes

 button_copy = cfu.pushButton_copy_to_clipboard
 
 button_invert = cfu.pushButton_invert_x_axis
 
 button_lock_axes = cfu.pushButton_lock_axes
 
 button_zoom = cfu.pushButton_zoom_graph
 
 cb_marker = cfu.checkBox_graph_marker
 
 combo_axis = cfu.displayAxis_comboBox_axis
 
 copy_to_clipboard_callback
 
 ctl = ctl
 
str current_x_axis = self.combo_axis.currentIndex()
 
 current_y_axis = common.Axes.COUNTS
 
list hide_when_zoomed = [ cfu.frame_new_save_col_holder, cfu.controlWidget ]
 
 intended_y_axis = common.Axes.COUNTS
 
 invert_x_axis
 
bool inverted = False
 
 layout = cfu.layout_scope_capture_graphs
 
 legend = legend
 
 live_curve = self.live_plot.plot([], pen=self.ctl.gui.make_pen(widget="live"))
 
 live_plot = pyqtgraph.PlotWidget(name="Live Scope")
 
 lock_marker = lock_marker
 
 name = name
 
dict observers = {}
 
 plot = plot
 
bool show_marker = False
 
 stacked_widget = cfu.stackedWidget_scope_setup_live_spectrum
 
 toggle_lock_axes
 
 toggle_zoom
 
 update_axis_callback
 
 update_marker
 
bool x_axis_locked = False
 
bool y_axis_locked = False
 
bool zoomed = False
 

Detailed Description

Encapsulate the large graph in the center of ENLIGHTEN's Scope Capture screen.

This was intended to be a singleton, as the ENLIGHTEN GUI was basically written around one large central graph, but there can now be a second instance of this object used to control the "plugin graph" used by Plugin.PluginController.

We probably want to look into refactoring something (maybe split this class in half?), as some of these attributes / methods could be applied to "any graph", while others were intended to be specific to the main Scope Capture graph.

We are not making full use of pyqtgraph's power, in part because it turns out that surprisingly little of pyqtgraph is documented online. To get a better sense of its power, you should install and run the examples as described:

See also
http://www.pyqtgraph.org/documentation/introduction.html#examples

In particular, we should:

  • consider using CurvePlotItem's sigClicked event, which would let the user change Multispec selected spectrometer (or select a ThumbnailWidget, if that was useful) by clicking a curve on-screen

Constructor & Destructor Documentation

◆ __init__()

enlighten.scope.Graph.Graph.__init__ ( self,
ctl,
name,
legend = None,
lock_marker = False,
plot = None )

This can be constructed in two ways.

By default, the Graph populates its own chart and legend (the one used by most of ENLIGHTEN). However, it also allows an external caller (like PluginController) to pass-in an already-constructed chart and legend. Perhaps we need a GraphFactory?

Member Function Documentation

◆ add_curve()

enlighten.scope.Graph.Graph.add_curve ( self,
name,
y = [],
x = None,
pen = None,
spec = None,
measurement = None,
rehide = True,
in_legend = True )

This was originally used used by ThumbnailWidget, when clicking the "show trace" thumbnail button.

It's now also being used by BaselineCorrectionFeature, RamanShiftCorrection, etc.

Todo
we should probably create a Curve class to encapsulate data associated with a particular on-screen trace, rather than hanging attributes off a library class

◆ add_item()

enlighten.scope.Graph.Graph.add_item ( self,
item )

called by Cursor to add its InfiniteLine to the graph

◆ add_roi_region()

enlighten.scope.Graph.Graph.add_roi_region ( self,
region )

Horizontal ROI.

◆ copy_to_clipboard_callback()

enlighten.scope.Graph.Graph.copy_to_clipboard_callback ( self)

◆ enable_axis_selection()

enlighten.scope.Graph.Graph.enable_axis_selection ( self,
flag )

◆ enable_wavenumbers()

enlighten.scope.Graph.Graph.enable_wavenumbers ( self,
flag )

◆ get_x_axis_unit()

enlighten.scope.Graph.Graph.get_x_axis_unit ( self)
Todo
merge with common suffixes

◆ in_pixels()

enlighten.scope.Graph.Graph.in_pixels ( self)

◆ in_wavelengths()

enlighten.scope.Graph.Graph.in_wavelengths ( self)

◆ in_wavenumbers()

enlighten.scope.Graph.Graph.in_wavenumbers ( self)

◆ invert_x_axis()

enlighten.scope.Graph.Graph.invert_x_axis ( self)

◆ populate_scope_capture()

enlighten.scope.Graph.Graph.populate_scope_capture ( self)

◆ populate_scope_setup()

enlighten.scope.Graph.Graph.populate_scope_setup ( self)

◆ register_observer()

enlighten.scope.Graph.Graph.register_observer ( self,
event,
callback )

◆ remove_curve()

enlighten.scope.Graph.Graph.remove_curve ( self,
name = None,
measurement_id = None )

If nobody else persists the curve, this will delete the curve object itself from memory, as well removing it from the graph.

Note
apparently we don't need to call deleteLater() with pyqtgraph objects
See also
https://github.com/pyqtgraph/pyqtgraph/issues/524#issuecomment-319860256

◆ remove_from_legend()

enlighten.scope.Graph.Graph.remove_from_legend ( self,
name = None,
measurement_id = None )

◆ remove_roi_region()

enlighten.scope.Graph.Graph.remove_roi_region ( self,
region )

◆ rescale_curves()

enlighten.scope.Graph.Graph.rescale_curves ( self)

Iterates through all the curves currently shown on the graph and updates them to the correct x-axis.

◆ reset_axes()

enlighten.scope.Graph.Graph.reset_axes ( self)

◆ set_data()

enlighten.scope.Graph.Graph.set_data ( self,
curve,
y = None,
x = None,
label = None )

◆ set_x_axis()

enlighten.scope.Graph.Graph.set_x_axis ( self,
enum )

when the Mode changes, update axis as appropriate

◆ set_x_axis_label()

enlighten.scope.Graph.Graph.set_x_axis_label ( self,
text,
locked = False )

extra
provides margin from the frame bottom...probably would be better with CSS

◆ set_y_axis()

enlighten.scope.Graph.Graph.set_y_axis ( self,
enum )

Only sets the "intention" to use the specified axis label; in reference- based modes, don't actually switch to the target axis until processing requirements are met (i.e., a reference has been taken).

◆ toggle_lock_axes()

enlighten.scope.Graph.Graph.toggle_lock_axes ( self)

◆ toggle_zoom()

enlighten.scope.Graph.Graph.toggle_zoom ( self)

◆ update_axis_callback()

enlighten.scope.Graph.Graph.update_axis_callback ( self)

◆ update_combo_tooltip()

enlighten.scope.Graph.Graph.update_combo_tooltip ( self)

◆ update_curve_marker()

enlighten.scope.Graph.Graph.update_curve_marker ( self,
curve )

◆ update_marker()

enlighten.scope.Graph.Graph.update_marker ( self)

◆ update_visibility()

enlighten.scope.Graph.Graph.update_visibility ( self)

Member Data Documentation

◆ button_copy

enlighten.scope.Graph.Graph.button_copy = cfu.pushButton_copy_to_clipboard

◆ button_invert

enlighten.scope.Graph.Graph.button_invert = cfu.pushButton_invert_x_axis

◆ button_lock_axes

enlighten.scope.Graph.Graph.button_lock_axes = cfu.pushButton_lock_axes

◆ button_zoom

enlighten.scope.Graph.Graph.button_zoom = cfu.pushButton_zoom_graph

◆ cb_marker

enlighten.scope.Graph.Graph.cb_marker = cfu.checkBox_graph_marker

◆ combo_axis

enlighten.scope.Graph.Graph.combo_axis = cfu.displayAxis_comboBox_axis

◆ copy_to_clipboard_callback

enlighten.scope.Graph.Graph.copy_to_clipboard_callback

◆ ctl

enlighten.scope.Graph.Graph.ctl = ctl

◆ current_x_axis

enlighten.scope.Graph.Graph.current_x_axis = self.combo_axis.currentIndex()

◆ current_y_axis

enlighten.scope.Graph.Graph.current_y_axis = common.Axes.COUNTS

◆ hide_when_zoomed

list enlighten.scope.Graph.Graph.hide_when_zoomed = [ cfu.frame_new_save_col_holder, cfu.controlWidget ]

◆ intended_y_axis

enlighten.scope.Graph.Graph.intended_y_axis = common.Axes.COUNTS

◆ invert_x_axis

enlighten.scope.Graph.Graph.invert_x_axis

◆ inverted

enlighten.scope.Graph.Graph.inverted = False

◆ layout

enlighten.scope.Graph.Graph.layout = cfu.layout_scope_capture_graphs

◆ legend

enlighten.scope.Graph.Graph.legend = legend

◆ live_curve

enlighten.scope.Graph.Graph.live_curve = self.live_plot.plot([], pen=self.ctl.gui.make_pen(widget="live"))

◆ live_plot

enlighten.scope.Graph.Graph.live_plot = pyqtgraph.PlotWidget(name="Live Scope")

◆ lock_marker

enlighten.scope.Graph.Graph.lock_marker = lock_marker

◆ name

enlighten.scope.Graph.Graph.name = name

◆ observers

dict enlighten.scope.Graph.Graph.observers = {}

◆ plot

enlighten.scope.Graph.Graph.plot = plot

◆ show_marker

bool enlighten.scope.Graph.Graph.show_marker = False

◆ stacked_widget

enlighten.scope.Graph.Graph.stacked_widget = cfu.stackedWidget_scope_setup_live_spectrum

◆ toggle_lock_axes

enlighten.scope.Graph.Graph.toggle_lock_axes

◆ toggle_zoom

enlighten.scope.Graph.Graph.toggle_zoom

◆ update_axis_callback

enlighten.scope.Graph.Graph.update_axis_callback

◆ update_marker

enlighten.scope.Graph.Graph.update_marker

◆ x_axis_locked

bool enlighten.scope.Graph.Graph.x_axis_locked = False

◆ y_axis_locked

enlighten.scope.Graph.Graph.y_axis_locked = False

◆ zoomed

enlighten.scope.Graph.Graph.zoomed = False

The documentation for this class was generated from the following file: