def __init__(self, wxparent=None, window=1, _larch=None, size=(725, 425), **kws): XRFDisplayFrame.__init__(self, parent=wxparent, size=size, _larch=_larch, exit_callback=self.onExit, **kws) self.Show() self.Raise() self.panel.cursor_callback = self.onCursor self.window = int(window) self._larch = _larch self._xylims = {} self.symname = '%s.xrf%i' % (MODNAME, self.window) symtable = ensuremod(self._larch, MODNAME) if symtable is not None: symtable.set_symbol(self.symname, self) if window not in XRF_DISPLAYS: XRF_DISPLAYS[window] = self
def __init__(self, wxparent=None, window=1, _larch=None, size=None, **kws): StackedPlotFrame.__init__(self, parent=None, exit_callback=self.onExit, **kws) self.Show() self.Raise() self.panel.cursor_callback = self.onCursor self.panel.cursor_mode = 'zoom' self.window = int(window) self._larch = _larch self._xylims = {} self.cursor_hist = [] self.symname = '%s.plot%i' % (MODNAME, self.window) symtable = ensuremod(self._larch, MODNAME) self.panel.canvas.figure.set_facecolor('#FDFDFB') self.panel_bot.canvas.figure.set_facecolor('#FDFDFB') if symtable is not None: symtable.set_symbol(self.symname, self) if not hasattr(symtable, '%s.cursor_maxhistory' % MODNAME): symtable.set_symbol('%s.cursor_maxhistory' % MODNAME, MAX_CURSHIST) if window not in PLOT_DISPLAYS: PLOT_DISPLAYS[window] = self
def onCursor(self, x=None, y=None, ix=None, iy=None, val=None, **kw): symtable = ensuremod(self._larch, MODNAME) if symtable is None: return set = symtable.set_symbol if x is not None: set('%s_x' % self.symname, x) if y is not None: set('%s_y' % self.symname, y) if ix is not None: set('%s_ix' % self.symname, ix) if iy is not None: set('%s_iy' % self.symname, iy) if val is not None: set('%s_val' % self.symname, val)
def onCursor(self,x=None, y=None, ix=None, iy=None, val=None, **kw): symtable = ensuremod(self._larch, MODNAME) if symtable is None: return set = symtable.set_symbol if x is not None: set('%s_x' % self.symname, x) if y is not None: set('%s_y' % self.symname, y) if ix is not None: set('%s_ix' % self.symname, ix) if iy is not None: set('%s_iy' % self.symname, iy) if val is not None: set('%s_val' % self.symname, val)
def onCursor(self, x=None, y=None, **kw): symtable = ensuremod(self._larch, MODNAME) if symtable is None: return hmax = getattr(symtable, '%s.cursor_maxhistory' % MODNAME, MAX_CURSHIST) symtable.set_symbol('%s_x' % self.symname, x) symtable.set_symbol('%s_y' % self.symname, y) self.cursor_hist.insert(0, (x, y)) if len(self.cursor_hist) > hmax: self.cursor_hist = self.cursor_hist[:hmax] symtable.set_symbol('%s_cursor_hist' % self.symname, self.cursor_hist)
def onCursor(self, x=None, y=None, **kw): symtable = ensuremod(self._larch, MODNAME) if symtable is None: return hmax = getattr(symtable, '%s.cursor_maxhistory' % MODNAME, MAX_CURSHIST) symtable.set_symbol('%s_x' % self.symname, x) symtable.set_symbol('%s_y' % self.symname, y) self.cursor_hist.insert(0, (x, y)) if len(self.cursor_hist) > hmax: self.cursor_hist = self.cursor_hist[:hmax] symtable.set_symbol('%s_cursor_hist' % self.symname, self.cursor_hist)
def __init__(self, wxparent=None, window=1, _larch=None, size=None, **kws): ImageFrame.__init__(self, parent=None, size=size, exit_callback=self.onExit, **kws) self.Show() self.Raise() self.cursor_pos = [] self.panel.cursor_callback = self.onCursor self.panel.contour_callback = self.onContour self.window = int(window) self.symname = '%s.img%i' % (MODNAME, self.window) self._larch = _larch symtable = ensuremod(self._larch, MODNAME) if symtable is not None: symtable.set_symbol(self.symname, self) if self.window not in IMG_DISPLAYS: IMG_DISPLAYS[self.window] = self
def __init__(self, wxparent=None, window=1, _larch=None, size=None, **kws): ImageFrame.__init__(self, parent=None, size=size, exit_callback=self.onExit, **kws) self.Show() self.Raise() self.cursor_pos = [] self.panel.cursor_callback = self.onCursor self.panel.contour_callback = self.onContour self.window = int(window) self.symname = '%s.img%i' % (MODNAME, self.window) self._larch = _larch symtable = ensuremod(self._larch, MODNAME) if symtable is not None: symtable.set_symbol(self.symname, self) if self.window not in IMG_DISPLAYS: IMG_DISPLAYS[self.window] = self
def __init__(self, wxparent=None, window=1, _larch=None, size=None, **kws): XRFDisplayFrame.__init__(self, parent=None, size=size, output_title='XRF', _larch=_larch, exit_callback=self.onExit, **kws) self.Show() self.Raise() self.panel.cursor_callback = self.onCursor self.window = int(window) self._larch = _larch self._xylims = {} self.symname = '%s.xrf%i' % (MODNAME, self.window) symtable = ensuremod(self._larch, MODNAME) if symtable is not None: symtable.set_symbol(self.symname, self) if window not in XRF_DISPLAYS: XRF_DISPLAYS[window] = self
def _getcursor(win=1, timeout=30, _larch=None, wxparent=None, size=None, **kws): """get_cursor(win=1, timeout=30) waits (up to timeout) for cursor click in selected plot window, and returns x, y position of cursor. On timeout, returns the last known cursor position, or (None, None) Note that _plotter.plotWIN_x and _plotter.plotWIN_y will be updated, with each cursor click, and so can be used to read the last cursor position without blocking. For a more consistent programmatic approach, this routine can be called with timeout <= 0 to read the most recently clicked cursor position. """ plotter = _getDisplay(wxparent=wxparent, win=win, size=size, _larch=_larch) if plotter is None: return symtable = ensuremod(_larch, MODNAME) sentinal = '%s.plot%i_cursorflag' % (MODNAME, win) xsym = '%s.plot%i_x' % (MODNAME, win) ysym = '%s.plot%i_y' % (MODNAME, win) xval = symtable.get_symbol(xsym, create=True) yval = symtable.get_symbol(ysym, create=True) symtable.set_symbol(sentinal, False) def onChange(symbolname=None, **kws): symtable.set_symbol(kws['sentinal'], True) symtable.add_callback(xsym, onChange, kws={'sentinal': sentinal}) t0 = time.time() while time.time() - t0 < timeout: wx_update(_larch=_larch) if symtable.get_symbol(sentinal): break symtable.del_symbol(sentinal) symtable.clear_callbacks(xsym) return (symtable.get_symbol(xsym), symtable.get_symbol(ysym))
def __init__(self, wxparent=None, window=1, _larch=None, size=None, **kws): PlotFrame.__init__(self, parent=None, size=size, output_title='plot2d', exit_callback=self.onExit, **kws) self.Show() self.Raise() self.panel.cursor_callback = self.onCursor self.panel.cursor_mode = 'zoom' self.window = int(window) self._larch = _larch self._xylims = {} self.symname = '%s.plot%i' % (MODNAME, self.window) symtable = ensuremod(self._larch, MODNAME) if symtable is not None: symtable.set_symbol(self.symname, self) if window not in PLOT_DISPLAYS: PLOT_DISPLAYS[window] = self
def __init__(self, wxparent=None, window=1, _larch=None, size=None, **kws): PlotFrame.__init__(self, parent=None, size=size, output_title='plot2d', exit_callback=self.onExit, **kws) self.Show() self.Raise() self.panel.cursor_callback = self.onCursor self.panel.cursor_mode = 'zoom' self.window = int(window) self._larch = _larch self._xylims = {} self.cursor_hist = [] self.symname = '%s.plot%i' % (MODNAME, self.window) symtable = ensuremod(self._larch, MODNAME) if symtable is not None: symtable.set_symbol(self.symname, self) if not hasattr(symtable, '%s.cursor_maxhistory' % MODNAME): symtable.set_symbol('%s.cursor_maxhistory' % MODNAME, MAX_CURSHIST) if window not in PLOT_DISPLAYS: PLOT_DISPLAYS[window] = self
def _getcursor(win=1, timeout=30, _larch=None, wxparent=None, size=None, **kws): """get_cursor(win=1, timeout=30) waits (up to timeout) for cursor click in selected plot window, and returns x, y position of cursor. On timeout, returns the last known cursor position, or (None, None) Note that _plotter.plotWIN_x and _plotter.plotWIN_y will be updated, with each cursor click, and so can be used to read the last cursor position without blocking. For a more consistent programmatic approach, this routine can be called with timeout <= 0 to read the most recently clicked cursor position. """ plotter = _getDisplay(wxparent=wxparent, win=win, size=size, _larch=_larch) symtable = ensuremod(_larch, MODNAME) sentinal = '%s.plot%i_cursorflag' % (MODNAME, win) xsym = '%s.plot%i_x' % (MODNAME, win) ysym = '%s.plot%i_y' % (MODNAME, win) xval = symtable.get_symbol(xsym, create=True) yval = symtable.get_symbol(ysym, create=True) symtable.set_symbol(sentinal, False) def onChange(symbolname=None, **kws): symtable.set_symbol(kws['sentinal'], True) symtable.add_callback(xsym, onChange, kws={'sentinal': sentinal}) t0 = time.time() while time.time() - t0 < timeout: wx_update(_larch=_larch) if symtable.get_symbol(sentinal): break symtable.del_symbol(sentinal) symtable.clear_callbacks(xsym) return (symtable.get_symbol(xsym), symtable.get_symbol(ysym))
def onContour(self, levels=None, **kws): symtable = ensuremod(self._larch, MODNAME) if symtable is not None and levels is not None: symtable.set_symbol('%s_contour_levels' % self.symname, levels)
def onContour(self, levels=None, **kws): symtable = ensuremod(self._larch, MODNAME) if symtable is not None and levels is not None: symtable.set_symbol('%s_contour_levels' % self.symname, levels)
def onCursor(self, x=None, y=None, **kw): symtable = ensuremod(self._larch, MODNAME) if symtable is None: return symtable.set_symbol('%s_x' % self.symname, x) symtable.set_symbol('%s_y' % self.symname, y)
def onCursor(self, x=None, y=None, **kw): symtable = ensuremod(self._larch, MODNAME) if symtable is None: return symtable.set_symbol('%s_xrf_x' % self.symname, x) symtable.set_symbol('%s_xrf_y' % self.symname, y)