def picker_a(self, a, evt): hit, extra = FigAxspan.picker_a(self, a, evt) if hit: self._figc_hit = self._artists.index(extra['child_artist']) self._drag_backup = a.get_xy() else: self._figc_hit = -1 return hit, extra
def picker_a(self, a, evt): hit, extra = FigAxspan.picker_a(self, a, evt) if hit: self._figc_hit = self._artists.index(extra['child_artist']) self._drag_backup = a.get_xy() else: self._figc_hit = -1 return hit, extra
def __new__(cls, *args,**kargs): draggable, kargs = ProcessKeywords(kargs, 'draggable', True) dragmode, kargs = ProcessKeywords(kargs, 'dragmodee', 'independent') # dragmode, kargs = ProcessKeywords(kargs, 'alpha', 1.0) # dragmode, kargs = ProcessKeywords(kargs, 'alpha_disabled', 0.5) enabled_point, kargs = ProcessKeywords(kargs, 'enabled_point', 'all') obj = FigAxspan.__new__(cls, *args,**kargs) if obj is not None: obj.setvar('draggable', draggable) obj.setvar('dragmode', dragmode) # obj.setvar('alpha', alpha) # obj.setvar('alpha_disabled', alpha_disabled) if not obj.hasvar('enabled_point'): obj.setvar('enabled_point', enabled_point) return obj
def canvas_menu(self): m = [('+Add...', None, None), ('X span', self.onAddXSpan, None), ('Y span', self.onAddYSpan, None), ('!', None, None),] if self._figc_hit != -1: if len(self.getp('x'))+len(self.getp('y')) > 1: m = m + [('Delete Span', self.onDelSpan, None),] if self.getp('enabled_point')[self._figc_hit]: m = m + [('Edit Data...', self.onEditSpan, None), #('Disalbe Span...', self.onEnableSpan, None), ] else: m = m + [ ('Edit Data...', self.onEditSpan, None), # ('Enable Span', self.onEnablePoint, None), ] return m + FigAxspan.canvas_menu(self)
def postprocess_data( self, ana, viewer, color_order=['red', 'blue', 'yellow'], ): def set_auto_color_to_color(kargs, name, col): if (not name in kargs) or (kargs[name] == 'auto'): kargs[name] = col return kargs from ifigure.mto.fig_plot import FigPlot, TimeTrace, StepPlot from ifigure.mto.fig_contour import FigContour from ifigure.mto.fig_image import FigImage from ifigure.mto.fig_surface import FigSurface from ifigure.mto.fig_axline import FigAxline from ifigure.mto.fig_axspan import FigAxspan from ifigure.mto.fig_text import FigText self._color_order = color_order dprint2('process_data', self) if ana.skipped: if ana.do_title: self.process_title(ana) return True if (self.isempty() and not self.get_figaxes().isempty() and not self._suppress): self.generate_artist() # app = self.get_app() # ax = self.get_container() # fig_ax = ax.figobj ishot = ana.ishot self._analysis_flag[ishot] = False col = color_order[ishot % len(color_order)] for x in range(ishot - self.num_child() + 1): plot_options = self.getvar('plot_options') if self._plot_type == 'plot': kargs = plot_options['plot'][1].copy() kargs = set_auto_color_to_color(kargs, 'color', col) kargs = set_auto_color_to_color(kargs, 'markerfacecolor', col) kargs = set_auto_color_to_color(kargs, 'markeredgecolor', col) obj = FigPlot([0], [0], *(plot_options['plot'][0]), **kargs) elif self._plot_type == 'timetrace': kargs = plot_options['timetrace'][1].copy() kargs = set_auto_color_to_color(kargs, 'color', col) kargs = set_auto_color_to_color(kargs, 'markerfacecolor', col) kargs = set_auto_color_to_color(kargs, 'markeredgecolor', col) obj = TimeTrace([0], [0], *(plot_options['timetrace'][0]), **kargs) elif self._plot_type == 'stepplot': kargs = plot_options['stepplot'][1].copy() kargs = set_auto_color_to_color(kargs, 'color', col) kargs = set_auto_color_to_color(kargs, 'markerfacecolor', col) kargs = set_auto_color_to_color(kargs, 'markeredgecolor', col) obj = StepPlot([0], [0], *(plot_options['stepplot'][0]), **kargs) elif self._plot_type == 'contour': obj = FigContour([0, 1], [0, 1], np.arange(4).reshape(2, 2), *(plot_options['contour'][0])) elif self._plot_type == 'image': obj = FigImage(np.zeros([2, 2])) elif self._plot_type == 'surface': obj = FigSurface(np.zeros([2, 2])) elif self._plot_type == 'axspan': obj = FigAxspan([0, 1]) elif self._plot_type == 'axline': obj = FigAxline(np.zeros([1])) elif self._plot_type == 'text': obj = FigText(0, 0, '') name = self._plot_type + str(self.num_child() + 1) self.add_child(name, obj) obj.set_container_idx(self._container_idx) obj.set_suppress(True) if self.get_script_local(): txt = self.make_script(ana.shot, short=True) debug_mode = viewer.debug_mode if txt is not None: try: vars = viewer.get_globals_for_figmds(ana.shot) # print vars for key in vars: ana.result[key] = vars[key] for key in viewer.startup_values: ana.result[key] = viewer.startup_values[key] ana.result['shot'] = ana.shot if self.getvar('posvars') is not None: a = {} b = {} exec self.getvar('posvars') in a, b for key in b: ana.result[key] = b[key] filepath = os.path.join(self.owndir(), script_file_name) from ifigure.widgets.debugger_core import get_breakpoint code = compile(txt, filepath, 'exec') if (len(get_breakpoint(filepath)) != 0 and debug_mode): app = wx.GetApp().TopWindow se = app.script_editor import threading if not se.CheckDebuggerStatus(): se.QueueSEDRequest(code, viewer.g, ana.result, filepath) # print threading.current_thread().name # wx.Yield() # time.sleep(3) else: se.RunSED(code, viewer.g, ana.result, filepath) else: exec code in viewer.g, ana.result except: dprint1('error occured when processing data by script') print( 'error occured when processing data by following script' ) print('#####') print(txt) print('#####') print(traceback.format_exc()) self.change_suppress(True, self.get_child(ishot)) return False if ana.do_title: self.process_title(ana) if self._plot_type == 'plot': self._update_plot(ana, ishot) #, color_order) elif self._plot_type == 'timetrace': self._update_plot(ana, ishot) #, color_order) elif self._plot_type == 'stepplot': self._update_plot(ana, ishot) #, color_order) elif self._plot_type == 'contour': self._update_contour(ana, ishot) elif self._plot_type == 'image': self._update_image(ana, ishot) elif self._plot_type == 'surface': self._update_surface(ana, ishot) elif self._plot_type == 'axspan': self._update_axspan(ana, ishot) elif self._plot_type == 'axline': self._update_axline(ana, ishot) elif self._plot_type == 'text': self._update_text(ana, ishot) obj = self.get_child(idx=ishot) if obj.is_suppress(): return False obj._data_extent = None try: if (self.get_figaxes() is not None): self.get_figaxes().adjust_axes_range() except: dprint1( "failed in adjusting axes at postprocess_data, continuing...") pass return True
def dragdone(self, a, evt): if self.getvar('dragmode') == 'independent': FigAxspan.dragdone(self, a, evt, idx=self._figc_hit) else: FigAxspan.dragdone(self, a, evt)
def __init__(self, *args, **kargs): FigAxspan.__init__(self, *args, **kargs) FigControl.__init__(self) self._figc_hit = -1 self._enable_a = None
def set_data(self, value, a): FigAxspan.set_data(self, value, a) self._data_extent = None self.set_update_artist_request() self.call_control_changed_callback()
def dragdone(self, a, evt): if self.getvar('dragmode') == 'independent': FigAxspan.dragdone(self, a, evt, idx = self._figc_hit) else: FigAxspan.dragdone(self, a, evt)
def __init__(self, *args, **kargs): FigAxspan.__init__(self, *args, **kargs) FigControl.__init__(self) self._figc_hit = -1 self._enable_a = None
def set_data(self, value, a): FigAxspan.set_data(self, value, a) self._data_extent = None self.set_update_artist_request() self.call_control_changed_callback()