def __init__(self, parent=None): super().__init__(parent, title='PCA', size=(800, 800)) self.panel = wx.Panel(self) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.AddSpacer(5) self.panel.SetSizer(self.sizer) top_sizer = wx.BoxSizer(wx.HORIZONTAL) self.sizer.Add(top_sizer, 0) ctl_sizer = wx.BoxSizer(wx.VERTICAL) top_sizer.Add(ctl_sizer, 0) ctl_sizer.Add(wx.StaticText(self.panel, -1, 'Variables:'), flag=wx.TOP | wx.LEFT | wx.RIGHT, border=20) self.data = Project.get().all_data data_choices = [n.data.data_name for n in self.data] self.chooser = wx.ListBox(self.panel, choices=data_choices, style=wx.LB_EXTENDED) ctl_sizer.Add(self.chooser, 0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM, border=20) ctl_sizer.Add(wx.StaticText(self.panel, -1, 'Plot type:'), flag=wx.TOP | wx.LEFT | wx.RIGHT, border=12) self.plot_type = wx.RadioBox(self.panel, choices=['scatterplot', 'heatmap']) ctl_sizer.Add(self.plot_type, flag=wx.LEFT | wx.RIGHT, border=10) ctl_sizer.Add(wx.StaticText(self.panel, -1, 'Axis type:'), flag=wx.TOP | wx.LEFT | wx.RIGHT, border=12) self.axis_type = wx.RadioBox(self.panel, choices=['fixed', 'adaptive']) ctl_sizer.Add(self.axis_type, flag=wx.LEFT | wx.RIGHT, border=10) self.Bind(wx.EVT_RADIOBOX, self.doPlot) self.fig = mpl.figure.Figure() self.canvas = wxagg.FigureCanvasWxAgg(self.panel, -1, self.fig) top_sizer.Add(self.canvas, 1, wx.EXPAND) self.Bind(wx.EVT_LISTBOX, self.doPlot) self.Bind(wx.EVT_CLOSE, self.onClose) get_main_window().Bind(EVT_TIMELINE_CHANGED, self.doPlot) self.CenterOnParent() self.panel.Layout() self.Show()
def run(self): event = RenderEvent( image=self.plugin.render(self.width, self.height)) handler = self.handler if self.handler is not None else get_main_window( ) self.sync_with_main(self.post_render) wx.PostEvent(handler, event)
def set_type(self, interactor, send_event=True): self.sphere_button.opaque = False self.freelook_button.opaque = False self.pan_button.opaque = False if interactor in (self.SPHERE, CameraInteractor.SPHERE): self.sphere_button.opaque = True self.camera_interactor = SphereInteractor(self.camera, False) elif interactor in (self.FREELOOK, CameraInteractor.FREELOOK): self.freelook_button.opaque = True self.camera_interactor = FreelookInteractor(self.camera, False) elif interactor in (self.PAN, CameraInteractor.PAN): self.pan_button.opaque = True self.camera_interactor = PanInteractor(self.camera, False) self.canvas.Refresh() if send_event: wx.PostEvent(get_main_window(), CameraChangedEvent())
def on_close(self, event): get_main_window().Unbind(EVT_TIMELINE_CHANGED) self.Destroy()
def __init__(self, parent=None): super().__init__(parent, title='Linear Regression', size=(800, 800)) self.zoom = zoom.Zoom() # Global variables self.reset_bounds = True # True if bounds have been reset by changing variables self.update_graph = True # True if graph needs to be updated self.update_table = True # True if data tables need to be updated self.user_bounds = False # True if the user bounds should be used self.user_update = False # True if the user bounds have been updated self.box_dirty = False # True if textboxes have been modified # Sizers self.panel = wx.Panel(self) self.sizer = wx.BoxSizer(wx.VERTICAL) # Main sizer self.panel.SetSizer(self.sizer) top_sizer = wx.BoxSizer( wx.HORIZONTAL) # Sizer to divide screen into left and right halves self.sizer.Add(top_sizer, 0) ctl_sizer = wx.BoxSizer( wx.VERTICAL) # Sizer for the controls on left size of the screen top_sizer.Add(ctl_sizer, 0) zoom_sizer = wx.BoxSizer(wx.HORIZONTAL) # Sizer for the zoom controls self.right_sizer = wx.BoxSizer( wx.VERTICAL) # Sizer for the right half of the window # Variables title ctl_sizer.Add(wx.StaticText(self.panel, -1, 'Variables:'), flag=wx.TOP | wx.LEFT | wx.RIGHT, border=20) # Get choices for independent and dependent variables self.data = Project.get().all_data data_choices = [n.data.data_name for n in self.data] # Independent variable ctl_sizer.Add(wx.StaticText(self.panel, -1, 'Independent variable(s):'), flag=wx.TOP | wx.LEFT | wx.RIGHT, border=12) self.iv_chooser = wx.ListBox(self.panel, choices=data_choices, style=wx.LB_EXTENDED) ctl_sizer.Add(self.iv_chooser, flag=wx.LEFT | wx.RIGHT, border=12) # Dependent variable ctl_sizer.Add(wx.StaticText(self.panel, -1, 'Dependent variable:'), flag=wx.TOP | wx.LEFT | wx.RIGHT, border=12) self.dv_chooser = wx.Choice(self.panel, choices=['-'] + data_choices) ctl_sizer.Add(self.dv_chooser, flag=wx.LEFT | wx.RIGHT, border=12) # Plot type ctl_sizer.Add(wx.StaticText(self.panel, -1, 'Plot type:'), flag=wx.TOP | wx.LEFT | wx.RIGHT, border=12) self.plot_type = wx.RadioBox(self.panel, choices=['Scatterplot', 'Heatmap']) ctl_sizer.Add(self.plot_type, flag=wx.LEFT | wx.RIGHT, border=10) # Axis type ctl_sizer.Add(wx.StaticText(self.panel, -1, 'Axis type:'), flag=wx.TOP | wx.LEFT | wx.RIGHT, border=12) self.axis_type = wx.RadioBox(self.panel, choices=['Fit All', 'Adaptive', 'Zoom']) ctl_sizer.Add(self.axis_type, flag=wx.LEFT | wx.RIGHT, border=10) self.Bind(wx.EVT_RADIOBOX, self.on_axis_change) # User Bounds x_full_sizer = wx.BoxSizer(wx.VERTICAL) x_full_sizer.Add(wx.StaticText(self.panel, -1, 'X-axis:'), flag=wx.TOP, border=15) self.bound_box_max_length = 6 x_sizer = wx.BoxSizer(wx.HORIZONTAL) self.box_x_min = wx.TextCtrl(self.panel, -1, size=(50, 20), value="", style=wx.TE_PROCESS_ENTER) self.box_x_min.SetMaxLength(self.bound_box_max_length) x_sizer.Add(self.box_x_min, flag=wx.LEFT, border=10) self.box_x_max = wx.TextCtrl(self.panel, -1, size=(50, 20), value="", style=wx.TE_PROCESS_ENTER) self.box_x_max.SetMaxLength(self.bound_box_max_length) x_sizer.Add(self.box_x_max, flag=wx.LEFT, border=5) x_full_sizer.Add(x_sizer, flag=wx.LEFT | wx.TOP, border=0) y_full_sizer = wx.BoxSizer(wx.VERTICAL) y_full_sizer.Add(wx.StaticText(self.panel, -1, 'Y-axis:'), flag=wx.TOP, border=15) y_sizer = wx.BoxSizer(wx.HORIZONTAL) self.box_y_min = wx.TextCtrl(self.panel, -1, size=(50, 20), value="", style=wx.TE_PROCESS_ENTER) self.box_y_min.SetMaxLength(self.bound_box_max_length) y_sizer.Add(self.box_y_min, flag=wx.LEFT, border=10) self.box_y_max = wx.TextCtrl(self.panel, -1, size=(50, 20), value="", style=wx.TE_PROCESS_ENTER) self.box_y_max.SetMaxLength(self.bound_box_max_length) y_sizer.Add(self.box_y_max, flag=wx.LEFT, border=5) y_full_sizer.Add(y_sizer) text_box_sizer = wx.BoxSizer(wx.HORIZONTAL) text_box_sizer.Add(x_full_sizer, flag=wx.LEFT, border=15) text_box_sizer.Add(y_full_sizer, flag=wx.LEFT, border=15) ctl_sizer.Add(text_box_sizer) self.Bind(wx.EVT_TEXT, self.on_text) self.Bind(wx.EVT_TEXT_ENTER, self.on_enter) self.default_box = wx.Button(self.panel, label="Default") ctl_sizer.Add(self.default_box, flag=wx.LEFT | wx.TOP, border=15) self.default_box.Bind(wx.EVT_BUTTON, self.on_default_box_button) # Blank spacer ctl_sizer.AddSpacer(130) # Zoom controls # Zoom button for dragging a box self.zoom_box = wx.Button(self.panel, label="Box Zoom") zoom_sizer.Add(self.zoom_box) self.zoom_box.Bind(wx.EVT_BUTTON, self.on_zoom_box_button) # Zoom slider self.zoom_slider = wx.Slider(self.panel, value=0, minValue=0, maxValue=49 * self.zoom.zoom_multiple, size=(600, -1), style=wx.SL_HORIZONTAL) zoom_sizer.Add(self.zoom_slider, flag=wx.LEFT, border=10) self.zoom_slider.Bind(wx.EVT_SCROLL, self.on_zoom_scroll) # Graph canvas self.fig = mpl.figure.Figure() self.canvas = wxagg.FigureCanvasWxAgg(self.panel, -1, self.fig) self.right_sizer.Add(self.canvas, 1, wx.EXPAND) self.right_sizer.Add(zoom_sizer, flag=wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, border=10) top_sizer.Add(self.right_sizer) # Events self.Bind(wx.EVT_LISTBOX, self.on_var_change) self.Bind(wx.EVT_CHOICE, self.on_var_change) self.Bind(wx.EVT_CLOSE, self.on_close) # Move along with timeline get_main_window().Bind(EVT_TIMELINE_CHANGED, self.on_timeline_change) # Mouse events on graph (Matplotlib events) self.fig.canvas.mpl_connect('button_press_event', self.on_mouse_press) self.fig.canvas.mpl_connect('button_release_event', self.on_mouse_release) self.fig.canvas.mpl_connect('motion_notify_event', self.on_mouse_move) # Open in the center of VISTAS main window self.CenterOnParent() self.panel.Layout() self.Show()
def option_updated(self): get_main_window().AddPendingEvent(PluginOptionEvent(plugin=self.plugin, option=self, change=PluginOptionEvent.OPTION_CHANGED))