def init_control_pannel(self): self.control_window = ControlPannel(self) self.parent_window.show_specific(self.control_window) self.widgetlist.append(self.control_window)
class RCTboxer: ''' The is the main command and control center for the RCT particle picker. This object acts as a mediator for MainWin objects and follows the mediator pattern ''' def __init__(self, application, boxsize): self.boxsize = boxsize self.parent_window = application self.strategy = None self.widgetlist = [] self.windowlist = [] self.init_particles_window() self.init_main_window() self.init_tilted_window() #self.init_control_pannel() # Set the box colors EMBox.set_box_color("untilted",[0,0,1]) EMBox.set_box_color("tilted",[0,1,0]) ######################## Client functions ############################################ # initialize the picked particles window def init_particles_window(self): self.particles_window = ParticlesWindow(self) self.parent_window.show_specific(self.particles_window.window) E2loadappwin("e2rctboxer","particles",self.particles_window.window.qt_parent) self.widgetlist.append(self.particles_window.window) # initialize tilited and untilted windows, if desired for tilted windows can be easily added def init_main_window(self): self.untilt_win = MainWin(self, "untilted") self.untilt_win.show_mainwin() self.widgetlist.append(self.untilt_win.window) self.windowlist.append(self.untilt_win) self.particles_window.addlist("untilted") E2loadappwin("e2rctboxer","untilted",self.untilt_win.window.qt_parent) def load_untilt_image(self, filename): self.untilt_win.load_image(filename) def init_tilted_window(self): self.tilt_win = MainWin(self, "tilted") self.tilt_win.show_mainwin() self.widgetlist.append(self.tilt_win.window) self.windowlist.append(self.tilt_win) self.particles_window.addlist("tilted") E2loadappwin("e2rctboxer","tilted",self.tilt_win.window.qt_parent) def load_tilt_image(self, filename): self.tilt_win.load_image(filename) # Initialize the GUI def init_control_pannel(self): self.control_window = ControlPannel(self) self.parent_window.show_specific(self.control_window) self.widgetlist.append(self.control_window) def init_control_pannel_tools(self): self.control_window.configure_tools() ############################ Functions to support Mediator pattern #################################### def set_strategy(self, strategy): self.strategy = strategy(self) # handle pick events comming from the MainWin objects, and then send commands to the MainWin objects in responce (Mediator pattern) def handle_pick_event(self, caller, x=0, y=0): if not self.strategy.pickevent(caller, x, y): return False return True def handle_unpick_event(self, caller, box_num): if not self.strategy.unpickevent(caller, box_num): return False return True def handle_move_event(self): if not self.strategy.moveevent(): return False return True def handle_image_save(self, image): if self.strategy != None: self.strategy.imagesaveevent(image) def update_particles(self, particles, idx): self.particles_window.update_particles(particles, idx) def configure_strategy(self, caller): if self.strategy != None: self.strategy.configure_strategy(caller) def handle_strategy_signal(self, signal): self.strategy.handle_strategy_signal(signal)