def __init__(self, logger, ev_quit, options): super(GingaVision, self).__init__() self.logger = logger self.ev_quit = ev_quit from ginga.gw import Widgets, Viewers, GwHelp, GwMain self.card = 'default' # playback rate; changed when we know the actual rate self.fps = 30 self.playback_rate = 1.0 / self.fps # Use an AstroImage, not RGBImage for now because we get a # different default (faster) scaling algorithm self.pimage = AstroImage.AstroImage() self.pdata = None self.app = Widgets.Application(logger=logger) self.app.add_callback('shutdown', self.quit) self.top = self.app.make_window("Ginga example2") self.top.add_callback('close', lambda *args: self.quit()) thread_pool = Task.ThreadPool(2, logger, ev_quit=ev_quit) thread_pool.startall() self.main = GwMain.GwMain(logger=logger, ev_quit=ev_quit, app=self.app, thread_pool=thread_pool) vbox = Widgets.VBox() vbox.set_border_width(2) vbox.set_spacing(1) fi = Viewers.CanvasView(logger=logger) fi.enable_autocuts('off') fi.set_autocut_params('histogram') fi.enable_autozoom('off') fi.cut_levels(0, 255) fi.defer_redraw = False fi.set_bg(0.2, 0.2, 0.2) # flip y fi.transform(False, False, False) fi.ui_setActive(True) self.fitsimage = fi # Some optomizations to smooth playback at decent FPS fi.set_redraw_lag(self.playback_rate) #fi.set_redraw_lag(0.0) fi._invertY = False # PassThruRGBMapper doesn't color map data--data is already colored rgbmap = RGBMap.PassThruRGBMapper(self.logger) fi.set_rgbmap(rgbmap) # Clip cuts assumes data does not need to be scaled in cut levels-- # only clipped fi.set_autocuts(AutoCuts.Clip(logger=self.logger)) bd = fi.get_bindings() bd.enable_pan(True) bd.enable_zoom(True) bd.enable_cuts(True) bd.enable_flip(True) bd.enable_cmap(True) fi.set_desired_size(512, 512) iw = Viewers.GingaViewerWidget(viewer=fi) vbox.add_widget(iw, stretch=1) hbox = Widgets.HBox() hbox.set_margins(4, 2, 4, 2) wopen = Widgets.Button("Open File") #wopen.clicked.connect(self.open_file) wquit = Widgets.Button("Quit") wquit.add_callback('activated', lambda *args: self.quit()) for w in (wopen, wquit): hbox.add_widget(w, stretch=0) hbox.add_widget(Widgets.Label(''), stretch=1) vbox.add_widget(hbox, stretch=0) self.top.set_widget(vbox) self.top.set_title("Video Example Viewer")
def __init__(self, logger, ev_quit, options): super(GingaVision, self).__init__() self.logger = logger self.ev_quit = ev_quit from ginga.gw import Widgets, Viewers, GwMain self.card = 'default' # playback rate; changed when we know the actual rate self.fps = options.fps self.playback_rate = 1.0 / 30.0 self.pimage = RGBImage.RGBImage() self.pdata = None self.app = Widgets.Application(logger=logger) self.app.add_callback('shutdown', self.quit) self.top = self.app.make_window("Ginga example2") self.top.add_callback('close', lambda *args: self.quit()) thread_pool = Task.ThreadPool(2, logger, ev_quit=ev_quit) thread_pool.startall() self.main = GwMain.GwMain(logger=logger, ev_quit=ev_quit, app=self.app, thread_pool=thread_pool) vbox = Widgets.VBox() vbox.set_border_width(2) vbox.set_spacing(1) fi = Viewers.CanvasView(logger=logger) fi.set_autocut_params('histogram') fi.enable_autozoom('off') fi.enable_autocenter('once') fi.enable_autocuts('off') fi.cut_levels(0, 255) fi.scale_to(1, 1) fi.set_bg(0.2, 0.2, 0.2) fi.ui_set_active(True) self.viewer = fi if options.optimize: # Some optimizations to smooth playback at decent FPS # PassThruRGBMapper is the most efficient mapper rgbmap = RGBMap.PassThruRGBMapper(self.logger) fi.set_rgbmap(rgbmap) # Clip cuts assumes data does not need to be scaled in cut levels-- # only clipped fi.set_autocuts(AutoCuts.Clip(logger=self.logger)) bd = fi.get_bindings() bd.enable_all(True) fi.set_desired_size(512, 512) iw = Viewers.GingaViewerWidget(viewer=fi) vbox.add_widget(iw, stretch=1) hbox = Widgets.HBox() hbox.set_margins(4, 2, 4, 2) wopen = Widgets.Button("Open File") #wopen.clicked.connect(self.open_file) wquit = Widgets.Button("Quit") wquit.add_callback('activated', lambda *args: self.quit()) for w in (wopen, wquit): hbox.add_widget(w, stretch=0) hbox.add_widget(Widgets.Label(''), stretch=1) vbox.add_widget(hbox, stretch=0) self.top.set_widget(vbox) self.top.set_title("Video Example Viewer")