def _create_pan_image(self, fitsimage): pi = Viewers.CanvasView(logger=self.logger) pi.enable_autozoom('on') pi.enable_autocuts('off') hand = pi.get_cursor('pan') pi.define_cursor('pick', hand) pi.set_bg(0.4, 0.4, 0.4) pi.set_desired_size(self._wd, self._ht) pi.set_callback('cursor-down', self.btndown) pi.set_callback('cursor-move', self.drag_cb) pi.set_callback('none-move', self.motion_cb) pi.set_callback('zoom-scroll', self.zoom_cb) pi.set_callback('configure', self.reconfigure) # for debugging pi.set_name('panimage') #pi.ui_setActive(True) my_canvas = pi.get_canvas() my_canvas.enable_draw(True) my_canvas.set_drawtype('rectangle', linestyle='dash', color='green') my_canvas.set_callback('draw-event', self.draw_cb) my_canvas.ui_setActive(True) if self.use_shared_canvas: canvas = fitsimage.get_canvas() pi.set_canvas(canvas) bd = pi.get_bindings() bd.enable_pan(False) bd.enable_zoom(False) return pi
def build_gui(self, container): zi = Viewers.CanvasView(logger=self.logger) zi.set_desired_size(self._wd, self._ht) zi.enable_autozoom('off') zi.enable_autocuts('off') zi.set_bg(0.95, 0.95, 0.95) zi.set_fg(0.25, 0.25, 0.75) self.viewer = zi p_canvas = zi.get_canvas() self.dc = p_canvas.get_draw_classes() self.canvas = self.dc.DrawingCanvas() p_canvas.add(self.canvas) self.initialize_plot() bd = zi.get_bindings() bd.enable_zoom(True) bd.enable_pan(True) iw = Viewers.GingaViewerWidget(zi) container.set_margins(2, 2, 2, 2) container.set_spacing(4) container.add_widget(iw, stretch=1)
def __init__(self, width, height): logger = log.get_logger(null=True) # We just use a ginga widget to implement the readout readout = Viewers.CanvasView(logger=logger) readout.name = 'readout' readout.set_desired_size(width, height) bg = colors.lookup_color('#202030') readout.set_bg(*bg) self.viewer = readout self.readout = Widgets.wrap(readout.get_widget()) self.readout.resize(width, height) canvas = readout.get_canvas() Text = canvas.get_draw_class('text') xoff, yoff = 4, 4 self.text_obj = Text(xoff, height - yoff, text='', color='lightgreen', fontsize=14, coord='window') canvas.add(self.text_obj, redraw=False) self.maxx = 0 self.maxy = 0 self.maxv = 0 self.fitsimage = None
def __init__(self, logger, rgbmap=None, link=False, settings=None): Callback.Callbacks.__init__(self) self.logger = logger self.link_rgbmap = link if not rgbmap: rgbmap = RGBMap.RGBMapper(logger) # Create settings and set defaults if settings is None: settings = Settings.SettingGroup(logger=self.logger) self.settings = settings self._start_x = 0 self._sarr = None cbar = Viewers.CanvasView(logger=self.logger) width, height = 1, self.settings.get('cbar_height', 36) cbar.set_desired_size(width, height) cbar.enable_autozoom('off') cbar.enable_autocuts('off') # In web backend, JPEG rendering makes for mushy text ## settings = cbar.get_settings() ## settings.set(html5_canvas_format='png') # to respond quickly to contrast adjustment #cbar.defer_lagtime = 0.005 cbar.set_bg(0.4, 0.4, 0.4) # for debugging cbar.set_name('colorbar') self.cbar_view = cbar # add callbacks for contrast adjustment, etc. cbar.add_callback('configure', self.resize_cb) cbar.add_callback('cursor-down', self.cursor_press_cb) cbar.add_callback('cursor-move', self.cursor_drag_cb) cbar.add_callback('cursor-up', self.cursor_release_cb) cbar.add_callback('draw-up', self.draw_release_cb) cbar.add_callback('none-move', self.none_move_cb) cbar.add_callback('zoom-scroll', self.scroll_cb) cbar.add_callback('zoom-pinch', self.pinch_cb) #cbar.configure(width, height) iw = Viewers.GingaViewerWidget(viewer=cbar) self.widget = iw iw.resize(width, height) fontsize = self.settings.get('fontsize', 12) canvas = self.cbar_view.get_canvas() self.cbar = utils.ColorBar(offset=0, height=height, rgbmap=rgbmap, fontsize=fontsize) canvas.add(self.cbar, tag='colorbar') self.set_rgbmap(rgbmap) # For callbacks for name in ('motion', 'scroll'): self.enable_callback(name)
def __init__(self, app, logger, timezone_info, color='lightgreen', font='Liberation Sans', show_seconds=False): """Constructor for a clock object using a ginga canvas. """ self.logger = logger if isinstance(timezone_info, Bunch): self.timezone_name = timezone_info.location self.tzinfo = tz.tzoffset(self.timezone_name, timezone_info.time_offset) else: # assume timezone_info is a str self.timezone_name = timezone_info #self.tzinfo = pytz.timezone(timezone) # NOTE: wierd construction is necessary to get a dateutil # timezone from the better names produced by pytz self.tzinfo = tz.gettz(str(pytz.timezone(timezone_info))) self.color = color self.font = font self.largesize = 72 self.smallsize = 24 self.show_seconds = show_seconds # now import our items from ginga.gw import Viewers fi = Viewers.CanvasView(logger=logger) fi.set_bg(0.2, 0.2, 0.2) self.viewer = fi fi.add_callback('configure', self.clock_resized_cb) # canvas that we will draw on self.canvas = fi.get_canvas() wd, ht = width, height if self.show_seconds: wd += 300 fi.set_desired_size(wd, ht) iw = Viewers.GingaViewerWidget(viewer=fi) self.widget = iw self.clock_resized_cb(self.viewer, wd, ht) dt = datetime.utcnow().replace(tzinfo=tz.UTC) self.update_clock(dt)
def build_gui(self, container): vbox = Widgets.VBox() vbox.set_border_width(4) vbox.set_spacing(2) # construct an interactive viewer to view and scroll # the RGB image, and to let the user pick the cmap self.c_view = Viewers.CanvasView(logger=self.logger) c_v = self.c_view c_v.set_desired_size(self._wd, self._ht) c_v.enable_autozoom('off') c_v.enable_autocuts('off') c_v.set_pan(0, 0) c_v.scale_to(1, 1) c_v.transform(False, True, False) c_v.cut_levels(0, 255) c_v.set_bg(0.4, 0.4, 0.4) # for debugging c_v.set_name('cmimage') canvas = c_v.get_canvas() canvas.register_for_cursor_drawing(c_v) c_v.add_callback('cursor-down', self.select_cb) c_v.add_callback('scroll', self.scroll_cb) bd = c_v.get_bindings() bd.enable_pan(True) # disable zooming so scrolling can be used to pan up/down bd.enable_zoom(False) bd.enable_cmap(False) iw = Viewers.GingaScrolledViewerWidget(c_v) iw.resize(self._wd, self._ht) vbox.add_widget(iw, stretch=1) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) btn = Widgets.Button("Close") btn.add_callback('activated', lambda w: self.close()) btns.add_widget(btn, stretch=0) btn = Widgets.Button("Help") btn.add_callback('activated', lambda w: self.help()) btns.add_widget(btn, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) vbox.add_widget(btns, stretch=0) container.add_widget(vbox, stretch=1)
def __init__(self, app, logger, timezone, color='lightgreen', font='Liberation Sans', show_seconds=False): """Constructor for a clock object using a ginga canvas. """ self.logger = logger if isinstance(timezone, Bunch): self.timezone = timezone.location self.tzinfo = tz.tzoffset(timezone.location, timezone.time_offset) else: self.timezone = timezone self.tzinfo = pytz.timezone(timezone) self.color = color self.font = font self.largesize = 72 self.smallsize = 24 self.show_seconds = show_seconds # now import our items from ginga.gw import Viewers fi = Viewers.CanvasView(logger=logger) fi.set_bg(0.2, 0.2, 0.2) self.viewer = fi fi.add_callback('configure', self.clock_resized_cb) # canvas that we will draw on self.canvas = fi.get_canvas() wd, ht = width, height if self.show_seconds: wd += 300 fi.set_desired_size(wd, ht) iw = Viewers.GingaViewerWidget(viewer=fi) self.widget = iw self.clock_resized_cb(self.viewer, wd, ht) dt = datetime.utcnow().replace(tzinfo=pytz.utc) self.update_clock(dt)
def __init__(self, logger): self.logger = logger self.drawcolors = colors.get_colors() self.dc = get_canvas_types() from ginga.gw import Widgets, Viewers 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', self.closed) vbox = Widgets.VBox() vbox.set_border_width(2) vbox.set_spacing(1) hbox = Widgets.HBox() hbox.set_border_width(2) hbox.set_spacing(4) v1 = Viewers.CanvasView(logger) v1.enable_autocuts('on') v1.set_autocut_params('zscale') v1.enable_autozoom('on') v1.set_zoom_algorithm('rate') v1.set_zoomrate(1.4) v1.show_pan_mark(True) v1.set_callback('drag-drop', self.drop_file) v1.set_callback('none-move', self.motion) v1.set_bg(0.2, 0.2, 0.2) v1.ui_setActive(True) v1.set_name('tweedledee') self.viewer1 = v1 self._mi1 = ModeIndicator(v1) bd = v1.get_bindings() bd.enable_all(True) # shared canvas between the two viewers canvas = self.dc.DrawingCanvas() canvas.enable_draw(True) canvas.enable_edit(True) canvas.set_drawtype('rectangle', color='lightblue') self.canvas = canvas # Tell viewer1 to use this canvas v1.set_canvas(canvas) self.drawtypes = canvas.get_drawtypes() self.drawtypes.sort() v1.set_desired_size(300, 300) iw = Viewers.GingaViewerWidget(viewer=v1) hbox.add_widget(iw, stretch=1) # Add a second viewer viewing the same canvas v2 = Viewers.CanvasView(logger) v2.enable_autocuts('on') v2.set_autocut_params('zscale') v2.enable_autozoom('on') v2.set_zoom_algorithm('rate') v2.set_zoomrate(1.4) v2.show_pan_mark(True) v2.set_callback('drag-drop', self.drop_file) v2.set_callback('none-move', self.motion) v2.set_bg(0.2, 0.2, 0.2) v2.ui_setActive(True) v1.set_name('tweedledum') self.viewer2 = v2 self._mi2 = ModeIndicator(v2) # Tell viewer2 to use this same canvas v2.set_canvas(canvas) bd = v2.get_bindings() bd.enable_all(True) v2.set_desired_size(300, 300) iw = Viewers.GingaViewerWidget(viewer=v2) hbox.add_widget(iw, stretch=1) vbox.add_widget(hbox, stretch=1) self.readout = Widgets.Label("") vbox.add_widget(self.readout, stretch=0) hbox = Widgets.HBox() hbox.set_border_width(2) wdrawtype = Widgets.ComboBox() for name in self.drawtypes: wdrawtype.append_text(name) index = self.drawtypes.index('rectangle') wdrawtype.set_index(index) wdrawtype.add_callback('activated', lambda w, idx: self.set_drawparams()) self.wdrawtype = wdrawtype wdrawcolor = Widgets.ComboBox() for name in self.drawcolors: wdrawcolor.append_text(name) index = self.drawcolors.index('lightblue') wdrawcolor.set_index(index) wdrawcolor.add_callback('activated', lambda w, idx: self.set_drawparams()) self.wdrawcolor = wdrawcolor wfill = Widgets.CheckBox("Fill") wfill.add_callback('activated', lambda w, tf: self.set_drawparams()) self.wfill = wfill walpha = Widgets.SpinBox(dtype=float) walpha.set_limits(0.0, 1.0, incr_value=0.1) walpha.set_value(1.0) walpha.set_decimals(2) walpha.add_callback('value-changed', lambda w, val: self.set_drawparams()) self.walpha = walpha wclear = Widgets.Button("Clear Canvas") wclear.add_callback('activated', lambda w: self.clear_canvas()) wopen = Widgets.Button("Open File") wopen.add_callback('activated', lambda w: self.open_file()) wquit = Widgets.Button("Quit") wquit.add_callback('activated', lambda w: self.quit()) hbox.add_widget(Widgets.Label(''), stretch=1) for w in (wopen, wdrawtype, wdrawcolor, wfill, Widgets.Label('Alpha:'), walpha, wclear, wquit): hbox.add_widget(w, stretch=0) vbox.add_widget(hbox, stretch=0) self.top.set_widget(vbox)
def build_gui(self, container): vbox = Widgets.VBox() vbox.set_border_width(4) vbox.set_spacing(2) vbox1 = Widgets.VBox() # Uncomment to debug; passing parent logger generates too # much noise in the main logger #zi = Viewers.CanvasView(logger=self.logger) zi = Viewers.CanvasView(logger=None) zi.set_desired_size(self._wd, self._ht) zi.enable_autozoom('once') zi.enable_autocuts('once') zi.enable_autocenter('override') zi.set_zoom_algorithm('step') zi.cut_levels(0, 255) zi.transform(False, True, False) #zi.set_scale_limits(0.001, 1000.0) zi.set_bg(0.4, 0.4, 0.4) zi.set_color_map('gray') zi.set_intensity_map('ramp') # for debugging zi.set_name('scrnimage') self.scrnimage = zi bd = zi.get_bindings() bd.enable_zoom(True) bd.enable_pan(True) bd.enable_cmap(False) zi.show_mode_indicator(True) iw = Viewers.ScrolledView(zi) iw.resize(self._wd, self._ht) vbox1.add_widget(iw, stretch=1) captions = (('Screen size', 'checkbutton', 'Width:', 'label', 'width', 'entry', 'Height:', 'label', 'height', 'entry'), ('Lock aspect', 'checkbutton', 'Aspect:', 'label', 'aspect', 'entry')) w, b = Widgets.build_info(captions, orientation='vertical') self.w = b if self._sg_wd is None: wd, ht = self.fitsimage.get_window_size() self.shot_generator.configure_surface(wd, ht) else: wd, ht = self._sg_wd, self._sg_ht b.screen_size.set_state(self._screen_size) b.screen_size.set_tooltip("From screen viewer actual size") b.screen_size.add_callback('activated', self._screen_size_cb) b.lock_aspect.set_state(self._lock_aspect) b.lock_aspect.set_tooltip("Lock aspect ratio of screen shot") b.lock_aspect.add_callback('activated', self._lock_aspect_cb) b.width.set_text(str(wd)) b.height.set_text(str(ht)) b.width.set_enabled(not self._screen_size) b.height.set_enabled(not self._screen_size) if self._sg_aspect is None: _as = self.calc_aspect_str(wd, ht) b.aspect.set_text(_as) else: b.aspect.set_text(str(self._sg_aspect)) b.aspect.set_enabled(self._lock_aspect) b.lock_aspect.set_enabled(not self._screen_size) b.width.add_callback('activated', lambda *args: self._set_width_cb()) b.height.add_callback('activated', lambda *args: self._set_height_cb()) b.aspect.add_callback('activated', lambda *args: self._set_aspect_cb()) vbox1.add_widget(w, stretch=0) captions = (('Type:', 'label', 'grtype', 'combobox', 'Snap', 'button'), ('Clear', 'button', 'Center', 'button', 'Fit', 'button', 'Full', 'button')) w, b = Widgets.build_info(captions, orientation='vertical') self.w.update(b) combobox = b.grtype for name in self.savetypes: combobox.append_text(name) index = self.savetypes.index(self.tosave_type) combobox.set_index(index) combobox.add_callback('activated', lambda w, idx: self.set_type(idx)) combobox.set_tooltip("Set the format of the snap image") b.snap.set_tooltip( "Click to grab a snapshot of this channel viewer image") b.snap.add_callback('activated', self._snap_cb) b.clear.set_tooltip("Clear the snap image") b.clear.add_callback('activated', self._clear_cb) b.center.set_tooltip("Center the snap image") b.center.add_callback('activated', self._center_cb) b.fit.set_tooltip("Fit snap image to window") b.fit.add_callback('activated', self._fit_cb) b.full.set_tooltip("View at 100% (1:1)") b.full.add_callback('activated', self._full_cb) vbox1.add_widget(w, stretch=0) fr = Widgets.Frame("Screenshot") fr.set_widget(vbox1) vpaned = Widgets.Splitter(orientation='vertical') self.w.splitter = vpaned vpaned.add_widget(fr) vpaned.add_widget(Widgets.Label('')) vpaned.set_sizes(self._split_sizes) vbox2 = Widgets.VBox() fr = Widgets.Frame("Save File") captions = ( ('Folder:', 'label', 'folder', 'entry'), ('Name:', 'label', 'name', 'entry'), ('Save', 'button'), ) w, b = Widgets.build_info(captions, orientation='vertical') self.w.update(b) b.folder.set_text(self.save_path) b.folder.set_tooltip("Set the folder path for the snap image") b.name.set_text(self.save_name) b.name.set_tooltip("Set the name for the snap image") b.save.set_tooltip("Click to save the last snap") b.save.add_callback('activated', self._save_cb) fr.set_widget(w) vbox2.add_widget(fr, stretch=0) # stretch spacer = Widgets.Label('') vbox2.add_widget(spacer, stretch=1) btns = Widgets.HBox() btns.set_spacing(3) btn = Widgets.Button("Close") btn.add_callback('activated', lambda w: self.close()) btns.add_widget(btn, stretch=0) btn = Widgets.Button("Help") btn.add_callback('activated', lambda w: self.help()) btns.add_widget(btn, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(btns, stretch=0) #vpaned.add_widget(vbox2) vbox.add_widget(vpaned, stretch=1) container.add_widget(vbox, stretch=1) container.add_widget(vbox2, stretch=0) self.gui_up = True
def build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) box, sw, orientation = Widgets.get_oriented_box(container) box.set_border_width(4) box.set_spacing(2) fr = Widgets.Frame("Pixel Values") # We just use a ginga widget to implement the pixtable pixview = Viewers.CanvasView(logger=self.logger) pixview.set_desired_size(self._wd, self._ht) bg = colors.lookup_color('#202030') pixview.set_bg(*bg) bd = pixview.get_bindings() bd.enable_zoom(True) bd.enable_pan(True) self.pixview = pixview self.pix_w = Viewers.GingaViewerWidget(pixview) fr.set_widget(self.pix_w) self.pix_w.resize(self._wd, self._ht) paned = Widgets.Splitter(orientation=orientation) paned.add_widget(fr) self._rebuild_table() btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) cbox1 = Widgets.ComboBox() index = 0 for i in self.sizes: j = 1 + i * 2 name = "%dx%d" % (j, j) cbox1.append_text(name) index += 1 index = self.sizes.index(self.pixtbl_radius) cbox1.set_index(index) cbox1.add_callback('activated', self.set_cutout_size_cb) cbox1.set_tooltip("Select size of pixel table") btns.add_widget(cbox1, stretch=0) # control for selecting a mark cbox2 = Widgets.ComboBox() for tag in self.marks: cbox2.append_text(tag) if self.mark_selected is None: cbox2.set_index(0) else: cbox2.show_text(self.mark_selected) cbox2.add_callback('activated', self.mark_select_cb) self.w.marks = cbox2 cbox2.set_tooltip("Select a mark") #cbox2.setMinimumContentsLength(8) btns.add_widget(cbox2, stretch=0) btn1 = Widgets.Button("Delete") btn1.add_callback('activated', lambda w: self.clear_mark_cb()) btn1.set_tooltip("Delete selected mark") btns.add_widget(btn1, stretch=0) btn2 = Widgets.Button("Delete All") btn2.add_callback('activated', lambda w: self.clear_all()) btn2.set_tooltip("Clear all marks") btns.add_widget(btn2, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) vbox2 = Widgets.VBox() vbox2.add_widget(btns, stretch=0) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) btn3 = Widgets.CheckBox("Pan to mark") btn3.set_state(self.pan2mark) btn3.add_callback('activated', self.pan2mark_cb) btn3.set_tooltip("Pan follows selected mark") btns.add_widget(btn3) btns.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(btns, stretch=0) captions = [ ('Font size:', 'label', 'Font size', 'combobox'), ] w, b = Widgets.build_info(captions) self.w.update(b) vbox2.add_widget(w, stretch=0) b.font_size.set_tooltip("Set font size for pixel display") for size in self.fontsizes: b.font_size.append_text(str(size)) b.font_size.show_text(str(self.fontsize)) b.font_size.add_callback('activated', self.set_font_size_cb) vbox2.add_widget(Widgets.Label(''), stretch=1) box.add_widget(vbox2, stretch=1) ## spacer = Widgets.Label('') ## box.add_widget(spacer, stretch=1) paned.add_widget(sw) # hack to set a reasonable starting position for the splitter _sz = max(self._wd, self._ht) paned.set_sizes([_sz, _sz]) top.add_widget(paned, stretch=1) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) btn = Widgets.Button("Close") btn.add_callback('activated', lambda w: self.close()) btns.add_widget(btn) btn = Widgets.Button("Help") btn.add_callback('activated', lambda w: self.help()) btns.add_widget(btn, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) top.add_widget(btns, stretch=0) container.add_widget(top, stretch=1)
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 build_gui(self, container): vtop = Widgets.VBox() vtop.set_border_width(4) box, sw, orientation = Widgets.get_oriented_box(container) # Uncomment to debug; passing parent logger generates too # much noise in the main logger #zi = Viewers.CanvasView(logger=self.logger) zi = Viewers.CanvasView(logger=None) zi.set_desired_size(self._wd, self._ht) zi.enable_autozoom('off') zi.enable_autocuts('off') zi.zoom_to(self.default_zoom) settings = zi.get_settings() settings.get_setting('zoomlevel').add_callback('set', self.zoomset, zi) zi.set_bg(0.4, 0.4, 0.4) zi.show_pan_mark(True) cmname = self.settings.get('zoom_cmap_name', None) if cmname is not None: zi.set_color_map(cmname) imname = self.settings.get('zoom_imap_name', None) if imname is not None: zi.set_intensity_map(imname) # for debugging zi.set_name('zoomimage') self.zoomimage = zi bd = zi.get_bindings() bd.enable_zoom(False) bd.enable_pan(False) bd.enable_cmap(False) iw = Viewers.GingaViewerWidget(zi) iw.resize(self._wd, self._ht) paned = Widgets.Splitter(orientation=orientation) paned.add_widget(iw) vbox2 = Widgets.VBox() captions = ( ("Zoom Radius:", 'label', 'Zoom Radius', 'hscale'), ("Zoom Amount:", 'label', 'Zoom Amount', 'hscale'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) vbox2.add_widget(w, stretch=0) self.w.zoom_radius.set_limits(1, 300, incr_value=1) self.w.zoom_radius.set_value(self.zoom_radius) self.w.zoom_radius.add_callback('value-changed', self.set_radius_cb) self.w.zoom_radius.set_tracking(True) self.w.zoom_amount.set_limits(-20, 30, incr_value=1) self.w.zoom_amount.set_value(self.zoom_amount) self.w.zoom_amount.add_callback('value-changed', self.set_amount_cb) self.w.zoom_amount.set_tracking(True) captions = ( ("Zoom:", 'label', 'Zoom', 'label'), ("Relative Zoom", 'checkbutton'), ("Refresh Interval", 'label', 'Refresh Interval', 'spinbutton'), ("Defaults", 'button'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.zoom.set_text(self.fv.scale2text(zi.get_scale())) b.relative_zoom.set_state(not self.t_abszoom) b.relative_zoom.add_callback("activated", self.set_absrel_cb) b.defaults.add_callback("activated", lambda w: self.set_defaults()) b.refresh_interval.set_limits(0, 200, incr_value=1) b.refresh_interval.set_value(int(self.refresh_interval * 1000)) b.refresh_interval.add_callback('value-changed', self.set_refresh_cb) row = Widgets.HBox() row.add_widget(w, stretch=0) row.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(row, stretch=0) # stretch spacer = Widgets.Label('') vbox2.add_widget(spacer, stretch=1) box.add_widget(vbox2, stretch=1) paned.add_widget(sw) # hack to set a reasonable starting position for the splitter _sz = max(self._wd, self._ht) paned.set_sizes([_sz, _sz]) vtop.add_widget(paned, stretch=5) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) btn = Widgets.Button("Close") btn.add_callback('activated', lambda w: self.close()) btns.add_widget(btn) btn = Widgets.Button("Help") btn.add_callback('activated', lambda w: self.help()) btns.add_widget(btn, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) vtop.add_widget(btns, stretch=0) container.add_widget(vtop, stretch=5) self.gui_up = True
def build_gui(self, container): assert iqcalc.have_scipy == True, \ Exception("Please install python-scipy to use this plugin") self.pickcenter = None vtop = Widgets.VBox() vtop.set_border_width(4) box, sw, orientation = Widgets.get_oriented_box(container, fill=True) box.set_border_width(4) box.set_spacing(2) self.msg_font = self.fv.get_font("sansFont", 12) tw = Widgets.TextArea(wrap=True, editable=False) tw.set_font(self.msg_font) self.tw = tw fr = Widgets.Expander("Instructions") fr.set_widget(tw) box.add_widget(fr, stretch=0) vpaned = Widgets.Splitter(orientation=orientation) nb = Widgets.TabWidget(tabpos='bottom') self.w.nb1 = nb vpaned.add_widget(nb) cm, im = self.fv.cm, self.fv.im di = Viewers.CanvasView(logger=self.logger) width, height = 300, 300 di.set_desired_size(width, height) di.enable_autozoom('off') di.enable_autocuts('off') di.zoom_to(3) settings = di.get_settings() settings.getSetting('zoomlevel').add_callback('set', self.zoomset, di) di.set_cmap(cm) di.set_imap(im) di.set_callback('none-move', self.detailxy) di.set_bg(0.4, 0.4, 0.4) # for debugging di.set_name('pickimage') self.pickimage = di bd = di.get_bindings() bd.enable_pan(True) bd.enable_zoom(True) bd.enable_cuts(True) di.configure(width, height) iw = Viewers.GingaViewerWidget(viewer=di) iw.resize(300, 300) nb.add_widget(iw, title="Image") if have_mpl: # Contour plot hbox = Widgets.HBox() self.contour_plot = plots.ContourPlot(logger=self.logger, width=400, height=300) self.contour_plot.add_axis(axisbg='black') pw = Plot.PlotWidget(self.contour_plot) pw.resize(400, 300) hbox.add_widget(pw, stretch=1) zoom = Widgets.Slider(orientation='vertical', track=True) zoom.set_limits(1, 100, incr_value=1) zoom.set_value(self.contour_plot.plot_zoomlevel) def zoom_contour_cb(w, val): self.contour_plot.plot_zoom(val / 10.0) zoom.add_callback('value-changed', zoom_contour_cb) hbox.add_widget(zoom, stretch=0) nb.add_widget(hbox, title="Contour") # FWHM gaussians plot self.fwhm_plot = plots.FWHMPlot(logger=self.logger, width=400, height=300) self.fwhm_plot.add_axis(axisbg='white') pw = Plot.PlotWidget(self.fwhm_plot) pw.resize(400, 300) nb.add_widget(pw, title="FWHM") # Radial profile plot self.radial_plot = plots.RadialPlot(logger=self.logger, width=400, height=300) self.radial_plot.add_axis(axisbg='white') pw = Plot.PlotWidget(self.radial_plot) pw.resize(400, 300) nb.add_widget(pw, title="Radial") fr = Widgets.Frame(self._textlabel) nb = Widgets.TabWidget(tabpos='bottom') self.w.nb2 = nb # Build report panel captions = ( ('Zoom:', 'label', 'Zoom', 'llabel'), ('Object_X', 'label', 'Object_X', 'llabel', 'Object_Y', 'label', 'Object_Y', 'llabel'), ('RA:', 'label', 'RA', 'llabel', 'DEC:', 'label', 'DEC', 'llabel'), ('Equinox:', 'label', 'Equinox', 'llabel', 'Background:', 'label', 'Background', 'llabel'), ('Sky Level:', 'label', 'Sky Level', 'llabel', 'Brightness:', 'label', 'Brightness', 'llabel'), ('FWHM X:', 'label', 'FWHM X', 'llabel', 'FWHM Y:', 'label', 'FWHM Y', 'llabel'), ('FWHM:', 'label', 'FWHM', 'llabel', 'Star Size:', 'label', 'Star Size', 'llabel'), ('Sample Area:', 'label', 'Sample Area', 'llabel', 'Default Region', 'button'), ('Pan to pick', 'button'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.zoom.set_text(self.fv.scale2text(di.get_scale())) self.wdetail = b b.default_region.add_callback('activated', lambda w: self.reset_region()) b.default_region.set_tooltip("Reset region size to default") b.pan_to_pick.add_callback('activated', lambda w: self.pan_to_pick_cb()) b.pan_to_pick.set_tooltip("Pan image to pick center") vbox1 = Widgets.VBox() vbox1.add_widget(w, stretch=0) # spacer vbox1.add_widget(Widgets.Label(''), stretch=0) # Pick field evaluation status hbox = Widgets.HBox() hbox.set_spacing(4) hbox.set_border_width(4) label = Widgets.Label() #label.set_alignment(0.05, 0.5) self.w.eval_status = label hbox.add_widget(self.w.eval_status, stretch=0) hbox.add_widget(Widgets.Label(''), stretch=1) vbox1.add_widget(hbox, stretch=0) # Pick field evaluation progress bar and stop button hbox = Widgets.HBox() hbox.set_spacing(4) hbox.set_border_width(4) btn = Widgets.Button("Stop") btn.add_callback('activated', lambda w: self.eval_intr()) btn.set_enabled(False) self.w.btn_intr_eval = btn hbox.add_widget(btn, stretch=0) self.w.eval_pgs = Widgets.ProgressBar() hbox.add_widget(self.w.eval_pgs, stretch=1) vbox1.add_widget(hbox, stretch=0) nb.add_widget(vbox1, title="Readout") # Build settings panel captions = ( ('Show Candidates', 'checkbutton'), ('Radius:', 'label', 'xlbl_radius', 'label', 'Radius', 'spinbutton'), ('Threshold:', 'label', 'xlbl_threshold', 'label', 'Threshold', 'entry'), ('Min FWHM:', 'label', 'xlbl_min_fwhm', 'label', 'Min FWHM', 'spinbutton'), ('Max FWHM:', 'label', 'xlbl_max_fwhm', 'label', 'Max FWHM', 'spinbutton'), ('Ellipticity:', 'label', 'xlbl_ellipticity', 'label', 'Ellipticity', 'entry'), ('Edge:', 'label', 'xlbl_edge', 'label', 'Edge', 'entry'), ('Max side:', 'label', 'xlbl_max_side', 'label', 'Max side', 'spinbutton'), ('Coordinate Base:', 'label', 'xlbl_coordinate_base', 'label', 'Coordinate Base', 'entry'), ('Redo Pick', 'button'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.radius.set_tooltip("Radius for peak detection") b.threshold.set_tooltip("Threshold for peak detection (blank=default)") b.min_fwhm.set_tooltip("Minimum FWHM for selection") b.max_fwhm.set_tooltip("Maximum FWHM for selection") b.ellipticity.set_tooltip("Minimum ellipticity for selection") b.edge.set_tooltip("Minimum edge distance for selection") b.show_candidates.set_tooltip("Show all peak candidates") b.max_side.set_tooltip("Maximum dimension to search for peaks") b.coordinate_base.set_tooltip("Base of pixel coordinate system") # radius control #b.radius.set_digits(2) #b.radius.set_numeric(True) b.radius.set_limits(5.0, 200.0, incr_value=1.0) def chg_radius(w, val): self.radius = float(val) self.w.xlbl_radius.set_text(str(self.radius)) return True b.xlbl_radius.set_text(str(self.radius)) b.radius.add_callback('value-changed', chg_radius) # threshold control def chg_threshold(w): threshold = None ths = w.get_text().strip() if len(ths) > 0: threshold = float(ths) self.threshold = threshold self.w.xlbl_threshold.set_text(str(self.threshold)) return True b.xlbl_threshold.set_text(str(self.threshold)) b.threshold.add_callback('activated', chg_threshold) # min fwhm #b.min_fwhm.set_digits(2) #b.min_fwhm.set_numeric(True) b.min_fwhm.set_limits(0.1, 200.0, incr_value=0.1) b.min_fwhm.set_value(self.min_fwhm) def chg_min(w, val): self.min_fwhm = float(val) self.w.xlbl_min_fwhm.set_text(str(self.min_fwhm)) return True b.xlbl_min_fwhm.set_text(str(self.min_fwhm)) b.min_fwhm.add_callback('value-changed', chg_min) # max fwhm #b.max_fwhm.set_digits(2) #b.max_fwhm.set_numeric(True) b.max_fwhm.set_limits(0.1, 200.0, incr_value=0.1) b.max_fwhm.set_value(self.max_fwhm) def chg_max(w, val): self.max_fwhm = float(val) self.w.xlbl_max_fwhm.set_text(str(self.max_fwhm)) return True b.xlbl_max_fwhm.set_text(str(self.max_fwhm)) b.max_fwhm.add_callback('value-changed', chg_max) # Ellipticity control def chg_ellipticity(w): minellipse = None val = w.get_text().strip() if len(val) > 0: minellipse = float(val) self.min_ellipse = minellipse self.w.xlbl_ellipticity.set_text(str(self.min_ellipse)) return True b.xlbl_ellipticity.set_text(str(self.min_ellipse)) b.ellipticity.add_callback('activated', chg_ellipticity) # Edge control def chg_edgew(w): edgew = None val = w.get_text().strip() if len(val) > 0: edgew = float(val) self.edgew = edgew self.w.xlbl_edge.set_text(str(self.edgew)) return True b.xlbl_edge.set_text(str(self.edgew)) b.edge.add_callback('activated', chg_edgew) #b.max_side.set_digits(0) #b.max_side.set_numeric(True) b.max_side.set_limits(5, 10000, incr_value=10) b.max_side.set_value(self.max_side) def chg_max_side(w, val): self.max_side = int(val) self.w.xlbl_max_side.set_text(str(self.max_side)) return True b.xlbl_max_side.set_text(str(self.max_side)) b.max_side.add_callback('value-changed', chg_max_side) b.redo_pick.add_callback('activated', lambda w: self.redo()) b.show_candidates.set_state(self.show_candidates) b.show_candidates.add_callback('activated', self.show_candidates_cb) self.w.xlbl_coordinate_base.set_text(str(self.pixel_coords_offset)) b.coordinate_base.set_text(str(self.pixel_coords_offset)) b.coordinate_base.add_callback('activated', self.coordinate_base_cb) vbox3 = Widgets.VBox() vbox3.add_widget(w, stretch=0) vbox3.add_widget(Widgets.Label(''), stretch=1) nb.add_widget(vbox3, title="Settings") # Build controls panel vbox3 = Widgets.VBox() captions = ( ('Sky cut', 'button', 'Delta sky:', 'label', 'xlbl_delta_sky', 'label', 'Delta sky', 'entry'), ('Bright cut', 'button', 'Delta bright:', 'label', 'xlbl_delta_bright', 'label', 'Delta bright', 'entry'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.sky_cut.set_tooltip("Set image low cut to Sky Level") b.delta_sky.set_tooltip("Delta to apply to low cut") b.bright_cut.set_tooltip("Set image high cut to Sky Level+Brightness") b.delta_bright.set_tooltip("Delta to apply to high cut") b.sky_cut.set_enabled(False) self.w.btn_sky_cut = b.sky_cut self.w.btn_sky_cut.add_callback('activated', lambda w: self.sky_cut()) self.w.sky_cut_delta = b.delta_sky b.xlbl_delta_sky.set_text(str(self.delta_sky)) b.delta_sky.set_text(str(self.delta_sky)) def chg_delta_sky(w): delta_sky = 0.0 val = w.get_text().strip() if len(val) > 0: delta_sky = float(val) self.delta_sky = delta_sky self.w.xlbl_delta_sky.set_text(str(self.delta_sky)) return True b.delta_sky.add_callback('activated', chg_delta_sky) b.bright_cut.set_enabled(False) self.w.btn_bright_cut = b.bright_cut self.w.btn_bright_cut.add_callback('activated', lambda w: self.bright_cut()) self.w.bright_cut_delta = b.delta_bright b.xlbl_delta_bright.set_text(str(self.delta_bright)) b.delta_bright.set_text(str(self.delta_bright)) def chg_delta_bright(w): delta_bright = 0.0 val = w.get_text().strip() if len(val) > 0: delta_bright = float(val) self.delta_bright = delta_bright self.w.xlbl_delta_bright.set_text(str(self.delta_bright)) return True b.delta_bright.add_callback('activated', chg_delta_bright) vbox3.add_widget(w, stretch=0) vbox3.add_widget(Widgets.Label(''), stretch=1) nb.add_widget(vbox3, title="Controls") vbox3 = Widgets.VBox() msg_font = self.fv.get_font("fixedFont", 10) tw = Widgets.TextArea(wrap=False, editable=True) tw.set_font(msg_font) self.w.report = tw sw1 = Widgets.ScrollArea() sw1.set_widget(tw) vbox3.add_widget(sw1, stretch=1) tw.append_text(self._make_report_header()) btns = Widgets.HBox() btns.set_spacing(4) btn = Widgets.Button("Add Pick") btn.add_callback('activated', lambda w: self.add_pick_cb()) btns.add_widget(btn) btn = Widgets.CheckBox("Record Picks automatically") btn.set_state(self.do_record) btn.add_callback('activated', self.record_cb) btns.add_widget(btn) btns.add_widget(Widgets.Label(''), stretch=1) vbox3.add_widget(btns, stretch=0) btns = Widgets.HBox() btns.set_spacing(4) btn = Widgets.CheckBox("Log Records") btn.set_state(self.do_report_log) btn.add_callback('activated', self.do_report_log_cb) btns.add_widget(btn) btns.add_widget(Widgets.Label("File:")) ent = Widgets.TextEntry() ent.set_text(self.report_log) ent.add_callback('activated', self.set_report_log_cb) btns.add_widget(ent, stretch=1) vbox3.add_widget(btns, stretch=0) nb.add_widget(vbox3, title="Report") ## sw2 = Widgets.ScrollArea() ## sw2.set_widget(nb) ## fr.set_widget(sw2) fr.set_widget(nb) vpaned.add_widget(fr) mode = self.canvas.get_draw_mode() hbox = Widgets.HBox() btn1 = Widgets.RadioButton("Move") btn1.set_state(mode == 'move') btn1.add_callback('activated', lambda w, val: self.set_mode_cb('move', val)) btn1.set_tooltip("Choose this to position pick") self.w.btn_move = btn1 hbox.add_widget(btn1) btn2 = Widgets.RadioButton("Draw", group=btn1) btn2.set_state(mode == 'draw') btn2.add_callback('activated', lambda w, val: self.set_mode_cb('draw', val)) btn2.set_tooltip("Choose this to draw a replacement pick") self.w.btn_draw = btn2 hbox.add_widget(btn2) btn3 = Widgets.RadioButton("Edit", group=btn1) btn3.set_state(mode == 'edit') btn3.add_callback('activated', lambda w, val: self.set_mode_cb('edit', val)) btn3.set_tooltip("Choose this to edit a pick") self.w.btn_edit = btn3 hbox.add_widget(btn3) hbox.add_widget(Widgets.Label(''), stretch=1) #box.add_widget(hbox, stretch=0) vpaned.add_widget(hbox) box.add_widget(vpaned, stretch=1) vtop.add_widget(sw, stretch=5) ## spacer = Widgets.Label('') ## vtop.add_widget(spacer, stretch=0) btns = Widgets.HBox() btns.set_spacing(4) btn = Widgets.Button("Close") btn.add_callback('activated', lambda w: self.close()) btns.add_widget(btn) btns.add_widget(Widgets.Label(''), stretch=1) vtop.add_widget(btns, stretch=0) container.add_widget(vtop, stretch=5)
def __init__(self, name, logger, gv, zv): self.logger = logger self.gv = gv self.zv = zv self.name = name self.app = gv.app ## self.drawcolors = colors.get_colors() self.dc = get_canvas_types() from ginga.gw import Widgets, Viewers self.top = self.app.make_window(name) self.top.add_callback('close', self.closed) vbox = Widgets.VBox() vbox.set_border_width(2) vbox.set_spacing(1) fi = Viewers.CanvasView(logger=logger) fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.set_zoom_algorithm('rate') fi.set_zoomrate(1.4) fi.show_pan_mark(True) fi.set_callback('drag-drop', self.drop_file) fi.set_callback('none-move', self.motion) fi.set_bg(0.2, 0.2, 0.2) fi.ui_setActive(True) self.gw = fi bd = fi.get_bindings() bd.enable_all(True) bd.get_settings().set(scroll_zoom_direct_scale=True) # add a color bar fi.private_canvas.add(self.dc.ColorBar(side='bottom', offset=10)) # add little mode indicator that shows modal states in # lower left hand corner fi.private_canvas.add(self.dc.ModeIndicator(corner='ur', fontsize=10)) # little hack necessary to get correct operation of the mode indicator # in all circumstances bm = fi.get_bindmap() bm.add_callback('mode-set', lambda *args: fi.redraw(whence=3)) # add a new "zview" mode bm.add_mode('z', 'zview', mode_type='locked', msg=None) # zview had this kind of zooming function bm.map_event('zview', (), 'right', 'zoom_in') bm.map_event('zview', (), 'left', 'zoom_out') # canvas that we will draw on canvas = self.dc.DrawingCanvas() ## canvas.enable_draw(True) ## canvas.enable_edit(True) canvas.set_drawtype('rectangle', color='lightblue') canvas.setSurface(fi) self.canvas = canvas # add canvas to view fi.get_canvas().add(canvas) canvas.ui_setActive(True) fi.set_desired_size(512, 512) iw = Viewers.GingaViewerWidget(viewer=fi) self.viewer_w = iw vbox.add_widget(iw, stretch=1) bm.map_event('zview', (), 'p', 'radial-plot') fi.set_callback('keydown-radial-plot', self.gv.plot_cmd_cb, self.zv.do_radial_plot, "Radial Profile", self.viewer_w) bm.map_event('zview', (), 'e', 'contour-plot') fi.set_callback('keydown-contour-plot', self.gv.plot_cmd_cb, self.zv.do_contour_plot, "Contours", self.viewer_w) bm.map_event('zview', (), 'g', 'gaussians-plot') fi.set_callback('keydown-gaussians-plot', self.gv.plot_cmd_cb, self.zv.do_gaussians_plot, "FWHM", self.viewer_w) self.readout = Widgets.Label("") self.readout.set_color(bg='black', fg='lightgreen') vbox.add_widget(self.readout, stretch=0) self.top.set_widget(vbox)
def build_gui(self, container): # Users sometimes don't open the plugin on the correct channel. # Force the correct channel to be used. chinfo = self.fv.get_channel_on_demand('CHARIS') self.fitsimage = chinfo.fitsimage top = Widgets.VBox() top.set_border_width(4) top.set_spacing(2) vbox1 = Widgets.VBox() # Uncomment to debug; passing parent logger generates too # much noise in the main logger #zi = Viewers.CanvasView(logger=self.logger) zi = Viewers.CanvasView(logger=None) zi.set_desired_size(self._wd, self._ht) zi.enable_autozoom('once') zi.enable_autocuts('once') #zi.enable_autocenter('once') zi.set_autocenter('once') zi.set_zoom_algorithm('step') zi.show_mode_indicator(True) zi.show_color_bar(True) settings = zi.get_settings() zi.set_bg(0.4, 0.4, 0.4) zi.set_color_map('gray') zi.set_color_map('gray') zi.set_intensity_map('ramp') # for debugging zi.set_name('charis_qimage') zi.add_callback('cursor-changed', self.motion_cb) self.q_image = zi bd = zi.get_bindings() bd.enable_all(True) iw = Viewers.GingaViewerWidget(zi) iw.resize(self._wd, self._ht) vbox1.add_widget(iw, stretch=1) fr = Widgets.Frame("Reduced") fr.set_widget(vbox1) top.add_widget(fr, stretch=1) fr = Widgets.Frame("Charis") captions = (('Subtract HDU 0', 'checkbutton'), ('Quick Reduce', 'button'), ) w, b = Widgets.build_info(captions, orientation='vertical') self.w = b chk_btn = b.subtract_hdu_0 chk_btn.set_state(self.sb_hdu1) chk_btn.add_callback('activated', self.toggle_sb_hdu1) b.quick_reduce.add_callback('activated', lambda w: self.quick_reduce()) b.quick_reduce.set_tooltip("Update from the current image in the channel") fr.set_widget(w) top.add_widget(fr, stretch=0) #spacer = Widgets.Label('') #top.add_widget(spacer, stretch=1) btns = Widgets.HBox() btns.set_spacing(3) btn = Widgets.Button("Close") btn.add_callback('activated', lambda w: self.close()) btns.add_widget(btn, stretch=0) ## btn = Widgets.Button("Help") ## btn.add_callback('activated', lambda w: self.help()) ## btns.add_widget(btn, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) top.add_widget(btns, stretch=0) container.add_widget(top, stretch=1)
def build_gui(self, container): vbox, sw, orientation = Widgets.get_oriented_box(container, fill=True, scrolled=False) vbox.set_border_width(4) vbox.set_spacing(2) # Uncomment to debug; passing parent logger generates too # much noise in the main logger #zi = Viewers.CanvasView(logger=self.logger) zi = Viewers.CanvasView(logger=None) zi.set_desired_size(self._wd, self._ht) zi.enable_autozoom('off') zi.enable_autocuts('off') #zi.set_scale_limits(0.001, 1000.0) zi.zoom_to(self.default_zoom) settings = zi.get_settings() settings.getSetting('zoomlevel').add_callback('set', self.zoomset, zi) zi.set_bg(0.4, 0.4, 0.4) zi.show_pan_mark(True) # for debugging zi.set_name('zoomimage') self.zoomimage = zi bd = zi.get_bindings() bd.enable_zoom(False) bd.enable_pan(False) bd.enable_cmap(False) iw = Viewers.GingaViewerWidget(zi) iw.resize(self._wd, self._ht) vpaned = Widgets.Splitter(orientation=orientation) vpaned.add_widget(iw) vbox2 = Widgets.VBox() captions = (("Zoom Radius:", 'label', 'Zoom Radius', 'hscale'), ("Zoom Amount:", 'label', 'Zoom Amount', 'hscale'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) vbox2.add_widget(w, stretch=0) self.w.zoom_radius.set_limits(1, 300, incr_value=1) self.w.zoom_radius.set_value(self.zoom_radius) self.w.zoom_radius.add_callback('value-changed', self.set_radius_cb) self.w.zoom_radius.set_tracking(True) self.w.zoom_amount.set_limits(-20, 30, incr_value=1) self.w.zoom_amount.set_value(self.zoom_amount) self.w.zoom_amount.add_callback('value-changed', self.set_amount_cb) self.w.zoom_amount.set_tracking(True) captions = (("Zoom:", 'label', 'Zoom', 'label'), ("Relative Zoom", 'checkbutton'), ("Refresh Interval", 'label', 'Refresh Interval', 'spinbutton'), ("Defaults", 'button'), ) w, b = Widgets.build_info(captions, orientation=orientation) self.w.update(b) b.zoom.set_text(self.fv.scale2text(zi.get_scale())) b.relative_zoom.set_state(not self.t_abszoom) b.relative_zoom.add_callback("activated", self.set_absrel_cb) b.defaults.add_callback("activated", lambda w: self.set_defaults()) b.refresh_interval.set_limits(0, 200, incr_value=1) b.refresh_interval.set_value(int(self.refresh_interval * 1000)) b.refresh_interval.add_callback('value-changed', self.set_refresh_cb) row = Widgets.HBox() row.add_widget(w, stretch=0) row.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(row, stretch=0) # stretch spacer = Widgets.Label('') vbox2.add_widget(spacer, stretch=1) vpaned.add_widget(vbox2) #vpaned.add_widget(Widgets.Label('')) vbox.add_widget(vpaned, stretch=1) #vbox.add_widget(Widgets.Label(''), stretch=1) container.add_widget(sw, stretch=1)
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")
def build_gui(self, container): vbox = Widgets.VBox() vbox.set_border_width(4) vbox.set_spacing(2) # construct an interaactive viewer to view and scroll # the thumbs pane self.c_view = Viewers.CanvasView(logger=self.logger) c_v = self.c_view c_v.set_desired_size(self._wd, self._ht) c_v.enable_autozoom('off') c_v.enable_autocuts('off') c_v.set_pan(0, 0) c_v.scale_to(1.0, 1.0) # Y-axis flipped c_v.transform(False, True, False) c_v.cut_levels(0, 255) c_v.set_bg(0.4, 0.4, 0.4) # for debugging c_v.set_name('cmimage') c_v.add_callback('configure', self.thumbpane_resized_cb) c_v.add_callback('drag-drop', self.drag_drop_cb) c_v.get_settings().get_setting('pan').add_callback('set', self.thumbs_pan_cb) canvas = c_v.get_canvas() canvas.register_for_cursor_drawing(c_v) canvas.set_draw_mode('pick') canvas.ui_set_active(True) self.canvas = canvas bd = c_v.get_bindings() bd.enable_pan(True) bd.enable_zoom(False) bd.enable_cmap(False) # remap some bindings for pan mode into no mode needed bm = c_v.get_bindmap() for name in ['home', 'end', 'page_up', 'page_down', 'left', 'right', 'up', 'down']: bm.map_event(None, [], 'kp_%s' % name, 'pan_%s' % name) # scroll wheel bm.map_event(None, [], 'sc_scroll', 'pan') iw = Viewers.GingaScrolledViewerWidget(c_v) iw.resize(self._wd, self._ht) vbox.add_widget(iw, stretch=1) captions = (('Auto scroll', 'checkbutton', 'Clear', 'button'),) w, b = Widgets.build_info(captions) self.w.update(b) b.auto_scroll.set_tooltip( "Scroll the thumbs window when new images arrive") b.clear.set_tooltip("Remove all current thumbnails") b.clear.add_callback('activated', lambda w: self.clear()) auto_scroll = self.settings.get('auto_scroll', False) b.auto_scroll.set_state(auto_scroll) vbox.add_widget(w, stretch=0) container.add_widget(vbox, stretch=1) self.gui_up = True
def build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) box, sw, orientation = Widgets.get_oriented_box(container) box.set_border_width(4) box.set_spacing(2) fr = Widgets.Frame("Pixel Values") # We just use a ginga widget to implement the pixtable pixview = Viewers.CanvasView(logger=self.logger) pixview.set_desired_size(self._wd, self._ht) bg = colors.lookup_color('#202030') pixview.set_bg(*bg) bd = pixview.get_bindings() bd.enable_zoom(True) bd.enable_pan(True) self.pixview = pixview self.pix_w = Viewers.GingaViewerWidget(pixview) fr.set_widget(self.pix_w) self.pix_w.resize(self._wd, self._ht) paned = Widgets.Splitter(orientation=orientation) self.w.splitter = paned paned.add_widget(fr) self._rebuild_table() btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) cbox1 = Widgets.ComboBox() index = 0 for i in self.sizes: j = 1 + i * 2 name = "%dx%d" % (j, j) cbox1.append_text(name) index += 1 index = self.sizes.index(self.pixtbl_radius) cbox1.set_index(index) cbox1.add_callback('activated', self.set_cutout_size_cb) cbox1.set_tooltip("Select size of pixel table") btns.add_widget(cbox1, stretch=0) # control for selecting a mark cbox2 = Widgets.ComboBox() for tag in self.marks: cbox2.append_text(tag) if self.mark_selected is None: cbox2.set_index(0) else: cbox2.show_text(self.mark_selected) cbox2.add_callback('activated', self.mark_select_cb) self.w.marks = cbox2 cbox2.set_tooltip("Select a mark") #cbox2.setMinimumContentsLength(8) btns.add_widget(cbox2, stretch=0) btn1 = Widgets.Button("Delete") btn1.add_callback('activated', lambda w: self.clear_mark_cb()) btn1.set_tooltip("Delete selected mark") btn1.set_enabled(len(self.marks) > 1) self.w.btn_delete = btn1 btns.add_widget(btn1, stretch=0) btn2 = Widgets.Button("Delete All") btn2.add_callback('activated', lambda w: self.clear_all()) btn2.set_tooltip("Clear all marks") btns.add_widget(btn2, stretch=0) btn2.set_enabled(len(self.marks) > 1) self.w.btn_delete_all = btn2 btns.add_widget(Widgets.Label(''), stretch=1) vbox2 = Widgets.VBox() vbox2.add_widget(btns, stretch=0) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) btn3 = Widgets.CheckBox("Pan to mark") btn3.set_state(self.pan2mark) btn3.add_callback('activated', self.pan2mark_cb) btn3.set_tooltip("Pan follows selected mark") btns.add_widget(btn3) btns.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(btns, stretch=0) captions = [ ('Font size:', 'label', 'Font size', 'combobox', 'Caption:', 'label', 'Caption', 'entry'), ] w, b = Widgets.build_info(captions) self.w.update(b) vbox2.add_widget(w, stretch=0) b.font_size.set_tooltip("Set font size for pixel display") for size in self.fontsizes: b.font_size.append_text(str(size)) b.font_size.show_text(str(self.fontsize)) b.font_size.add_callback('activated', self.set_font_size_cb) b.caption.set_tooltip("Text to append to the marker") vbox2.add_widget(Widgets.Label(''), stretch=1) box.add_widget(vbox2, stretch=1) ## spacer = Widgets.Label('') ## box.add_widget(spacer, stretch=1) paned.add_widget(sw) paned.set_sizes(self._split_sizes) top.add_widget(paned, stretch=1) mode = self.canvas.get_draw_mode() hbox = Widgets.HBox() btn1 = Widgets.RadioButton("Move") btn1.set_state(mode == 'move') btn1.add_callback('activated', lambda w, val: self.set_mode_cb('move', val)) btn1.set_tooltip("Choose this to add or move a mark") self.w.btn_move = btn1 hbox.add_widget(btn1) btn2 = Widgets.RadioButton("Draw", group=btn1) btn2.set_state(mode == 'draw') btn2.add_callback('activated', lambda w, val: self.set_mode_cb('draw', val)) btn2.set_tooltip("Choose this to draw a new or replacement mark") self.w.btn_draw = btn2 hbox.add_widget(btn2) btn3 = Widgets.RadioButton("Edit", group=btn1) btn3.set_state(mode == 'edit') btn3.add_callback('activated', lambda w, val: self.set_mode_cb('edit', val)) btn3.set_tooltip("Choose this to edit a mark") self.w.btn_edit = btn3 hbox.add_widget(btn3) hbox.add_widget(Widgets.Label(''), stretch=1) top.add_widget(hbox, stretch=0) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) btn = Widgets.Button("Close") btn.add_callback('activated', lambda w: self.close()) btns.add_widget(btn) btn = Widgets.Button("Help") btn.add_callback('activated', lambda w: self.help()) btns.add_widget(btn, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) top.add_widget(btns, stretch=0) container.add_widget(top, stretch=1) self.gui_up = True
def build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) vbox, sw, orientation = Widgets.get_oriented_box(container, fill=True) vbox.set_border_width(4) vbox.set_spacing(2) self.msg_font = self.fv.get_font("sansFont", 12) tw = Widgets.TextArea(wrap=True, editable=False) tw.set_font(self.msg_font) self.tw = tw fr = Widgets.Expander("Instructions") fr.set_widget(tw) vbox.add_widget(fr, stretch=0) fr = Widgets.Frame("Pixel Values") # We just use a ginga widget to implement the pixtable pixview = Viewers.CanvasView(logger=self.logger) width, height = 300, 300 pixview.set_desired_size(width, height) bg = colors.lookup_color('#202030') pixview.set_bg(*bg) bd = pixview.get_bindings() self.pixview = pixview self.pix_w = Viewers.ScrolledView(pixview) self.pix_w.resize(width, height) fr.set_widget(self.pix_w) vbox.add_widget(fr, stretch=1) self._rebuild_table() btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) cbox1 = Widgets.ComboBox() index = 0 for i in self.sizes: j = 1 + i * 2 name = "%dx%d" % (j, j) cbox1.append_text(name) index += 1 index = self.sizes.index(self.pixtbl_radius) cbox1.set_index(index) cbox1.add_callback('activated', self.set_cutout_size_cb) cbox1.set_tooltip("Select size of pixel table") btns.add_widget(cbox1, stretch=0) # control for selecting a mark cbox2 = Widgets.ComboBox() for tag in self.marks: cbox2.append_text(tag) if self.mark_selected is None: cbox2.set_index(0) else: cbox2.show_text(self.mark_selected) cbox2.add_callback('activated', self.mark_select_cb) self.w.marks = cbox2 cbox2.set_tooltip("Select a mark") #cbox2.setMinimumContentsLength(8) btns.add_widget(cbox2, stretch=0) btn1 = Widgets.Button("Delete") btn1.add_callback('activated', lambda w: self.clear_mark_cb()) btn1.set_tooltip("Delete selected mark") btns.add_widget(btn1, stretch=0) btn2 = Widgets.Button("Delete All") btn2.add_callback('activated', lambda w: self.clear_all()) btn2.set_tooltip("Clear all marks") btns.add_widget(btn2, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) vbox2 = Widgets.VBox() vbox2.add_widget(btns, stretch=0) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) btn3 = Widgets.CheckBox("Pan to mark") btn3.set_state(self.pan2mark) btn3.add_callback('activated', self.pan2mark_cb) btn3.set_tooltip("Pan follows selected mark") btns.add_widget(btn3) btns.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(btns, stretch=0) captions = [ ('Font size:', 'label', 'Font size', 'combobox'), ] w, b = Widgets.build_info(captions) self.w.update(b) vbox2.add_widget(w, stretch=0) b.font_size.set_tooltip("Set font size for pixel display") for size in (8, 9, 10, 11, 12, 14, 16): b.font_size.append_text(str(size)) b.font_size.show_text(str(self.fontsize)) b.font_size.add_callback('activated', self.set_font_size_cb) vbox2.add_widget(Widgets.Label(''), stretch=1) vbox.add_widget(vbox2, stretch=1) ## spacer = Widgets.Label('') ## vbox.add_widget(spacer, stretch=1) top.add_widget(sw, stretch=1) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) btn = Widgets.Button("Close") btn.add_callback('activated', lambda w: self.close()) btns.add_widget(btn) btns.add_widget(Widgets.Label(''), stretch=1) top.add_widget(btns, stretch=0) container.add_widget(top, stretch=1)
def build_gui(self, container): top = Widgets.VBox() top.set_border_width(4) vbox, sw, orientation = Widgets.get_oriented_box(container) vbox.set_border_width(4) vbox.set_spacing(2) fr = Widgets.Frame("Compositing") captions = ( ("Compose Type:", 'label', "Compose Type", 'combobox'), ("New Image", 'button', "Insert from Channel", 'button'), ) w, b = Widgets.build_info(captions) self.w.update(b) fr.set_widget(w) vbox.add_widget(fr, stretch=0) combobox = b.compose_type index = 0 for name in ('Alpha', 'RGB'): combobox.append_text(name) index += 1 combobox.set_index(1) b.new_image.add_callback('activated', lambda w: self.new_cb()) b.new_image.set_tooltip("Start a new composite image") b.insert_from_channel.add_callback('activated', lambda w: self.insert_cb()) b.insert_from_channel.set_tooltip("Insert channel image as layer") zi = Viewers.CanvasView(logger=None) zi.set_desired_size(self._wd, self._ht) zi.enable_autozoom('on') zi.enable_autocuts('off') zi.cut_levels(0, 255) zi.set_bg(0.4, 0.4, 0.4) zi.set_name('compose_image') self.preview_image = zi bd = zi.get_bindings() bd.enable_zoom(True) bd.enable_pan(True) bd.enable_flip(True) bd.enable_cuts(True) bd.enable_cmap(True) iw = Viewers.GingaViewerWidget(zi) iw.resize(self._wd, self._ht) zi.get_canvas().add(self.canvas) self.canvas.set_surface(zi) self.canvas.ui_set_active(True) fr = Widgets.Frame("Preview") fr.set_widget(iw) vpaned = Widgets.Splitter(orientation=orientation) vpaned.add_widget(fr) # spacer vpaned.add_widget(Widgets.Label('')) fr = Widgets.Frame("Layers") self.w.scales = fr #vpaned.add_widget(fr) vbox.add_widget(vpaned, stretch=1) vbox.add_widget(fr, stretch=0) captions = ( ("Save Image As", 'button', "Save Path", 'entry'), ("Save to Channel", 'button'), ) w, b = Widgets.build_info(captions) self.w.update(b) b.save_to_channel.add_callback('activated', lambda w: self.save_to_channel_cb()) b.save_to_channel.set_tooltip("Save composite image to channel") b.save_image_as.add_callback('activated', lambda w: self.save_as_cb()) self.entry2 = b.save_path self.entry2.add_callback('activated', lambda *args: self.save_as_cb()) vbox.add_widget(w, stretch=0) top.add_widget(vbox, stretch=1) btns = Widgets.HBox() btns.set_border_width(4) btns.set_spacing(4) btn = Widgets.Button("Close") btn.add_callback('activated', lambda w: self.close()) btns.add_widget(btn) btn = Widgets.Button("Help") btn.add_callback('activated', lambda w: self.help()) btns.add_widget(btn, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) top.add_widget(btns, stretch=0) container.add_widget(top, stretch=1) self.gui_up = True
def __init__(self, logger): self.logger = logger self.drawcolors = colors.get_colors() self.dc = get_canvas_types() from ginga.gw import Widgets, Viewers, GwHelp 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', self.closed) vbox = Widgets.VBox() vbox.set_border_width(2) vbox.set_spacing(1) fi = Viewers.CanvasView(logger=logger) fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.set_zoom_algorithm('rate') fi.set_zoomrate(1.4) fi.show_pan_mark(True) fi.set_callback('drag-drop', self.drop_file) fi.set_callback('none-move', self.motion) fi.set_bg(0.2, 0.2, 0.2) fi.ui_setActive(True) self.fitsimage = fi bd = fi.get_bindings() bd.enable_all(True) # add a color bar fi.private_canvas.add(self.dc.ColorBar(side='bottom', offset=10)) # add little mode indicator that shows modal states in # lower left hand corner fi.private_canvas.add(self.dc.ModeIndicator(corner='ur', fontsize=14)) # little hack necessary to get correct operation of the mode indicator # in all circumstances bm = fi.get_bindmap() bm.add_callback('mode-set', lambda *args: fi.redraw(whence=3)) # canvas that we will draw on canvas = self.dc.DrawingCanvas() canvas.enable_draw(True) canvas.enable_edit(True) canvas.set_drawtype('rectangle', color='lightblue') canvas.setSurface(fi) self.canvas = canvas # add canvas to view fi.get_canvas().add(canvas) canvas.ui_setActive(True) canvas.register_for_cursor_drawing(fi) self.drawtypes = canvas.get_drawtypes() self.drawtypes.sort() fi.set_desired_size(512, 512) iw = Viewers.GingaViewerWidget(viewer=fi) vbox.add_widget(iw, stretch=1) self.readout = Widgets.Label("") vbox.add_widget(self.readout, stretch=0) hbox = Widgets.HBox() hbox.set_border_width(2) wdrawtype = Widgets.ComboBox() for name in self.drawtypes: wdrawtype.append_text(name) index = self.drawtypes.index('rectangle') wdrawtype.set_index(index) wdrawtype.add_callback('activated', lambda w, idx: self.set_drawparams()) self.wdrawtype = wdrawtype wdrawcolor = Widgets.ComboBox() for name in self.drawcolors: wdrawcolor.append_text(name) index = self.drawcolors.index('lightblue') wdrawcolor.set_index(index) wdrawcolor.add_callback('activated', lambda w, idx: self.set_drawparams()) self.wdrawcolor = wdrawcolor wfill = Widgets.CheckBox("Fill") wfill.add_callback('activated', lambda w, tf: self.set_drawparams()) self.wfill = wfill walpha = Widgets.SpinBox(dtype=float) walpha.set_limits(0.0, 1.0, incr_value=0.1) walpha.set_value(1.0) walpha.set_decimals(2) walpha.add_callback('value-changed', lambda w, val: self.set_drawparams()) self.walpha = walpha wclear = Widgets.Button("Clear Canvas") wclear.add_callback('activated', lambda w: self.clear_canvas()) wopen = Widgets.Button("Open File") wopen.add_callback('activated', lambda w: self.open_file()) wquit = Widgets.Button("Quit") wquit.add_callback('activated', lambda w: self.quit()) hbox.add_widget(Widgets.Label(''), stretch=1) for w in (wopen, wdrawtype, wdrawcolor, wfill, Widgets.Label('Alpha:'), walpha, wclear, wquit): hbox.add_widget(w, stretch=0) vbox.add_widget(hbox, stretch=0) mode = self.canvas.get_draw_mode() hbox = Widgets.HBox() btn1 = Widgets.RadioButton("Draw") btn1.set_state(mode == 'draw') btn1.add_callback('activated', lambda w, val: self.set_mode_cb('draw', val)) btn1.set_tooltip("Choose this to draw on the canvas") hbox.add_widget(btn1) btn2 = Widgets.RadioButton("Edit", group=btn1) btn2.set_state(mode == 'edit') btn2.add_callback('activated', lambda w, val: self.set_mode_cb('edit', val)) btn2.set_tooltip("Choose this to edit things on the canvas") hbox.add_widget(btn2) btn3 = Widgets.CheckBox("I'm using a trackpad") btn3.add_callback('activated', lambda w, tf: self.use_trackpad_cb(tf)) hbox.add_widget(btn3) hbox.add_widget(Widgets.Label(''), stretch=1) vbox.add_widget(hbox, stretch=0) self.top.set_widget(vbox) self.fs = None if hasattr(GwHelp, 'FileSelection'): self.fs = GwHelp.FileSelection(self.top.get_widget())
def build_gui(self, container): vbox = Widgets.VBox() vbox.set_border_width(4) vbox.set_spacing(2) vbox1 = Widgets.VBox() # Uncomment to debug; passing parent logger generates too # much noise in the main logger #zi = Viewers.CanvasView(logger=self.logger) zi = Viewers.CanvasView(logger=None) zi.set_desired_size(self._wd, self._ht) zi.enable_autozoom('once') zi.enable_autocuts('once') zi.enable_autocenter('once') zi.set_zoom_algorithm('step') zi.cut_levels(0, 255) zi.transform(False, True, False) #zi.set_scale_limits(0.001, 1000.0) settings = zi.get_settings() zi.set_bg(0.4, 0.4, 0.4) zi.set_color_map('gray') zi.set_intensity_map('ramp') # for debugging zi.set_name('scrnimage') self.scrnimage = zi bd = zi.get_bindings() bd.enable_zoom(True) bd.enable_pan(True) bd.enable_cmap(False) iw = Viewers.GingaViewerWidget(zi) iw.resize(self._wd, self._ht) vbox1.add_widget(iw, stretch=1) captions = ( ('Type:', 'label', 'grtype', 'combobox', 'Snap', 'button'), ('Clear', 'button', 'Center', 'button', 'Fit', 'button'), ) w, b = Widgets.build_info(captions, orientation='vertical') self.w = b combobox = b.grtype for name in self.savetypes: combobox.append_text(name) index = self.savetypes.index(self.tosave_type) combobox.set_index(index) combobox.add_callback('activated', lambda w, idx: self.set_type(idx)) combobox.set_tooltip("Set the format of the snap image") b.snap.set_tooltip( "Click to grab a snapshot of this channel viewer image") b.snap.add_callback('activated', self.snap_cb) b.clear.set_tooltip("Clear the snap image") b.clear.add_callback('activated', self.clear_cb) b.center.set_tooltip("Center the snap image") b.center.add_callback('activated', self.center_cb) b.fit.set_tooltip("Fit snap image to window") b.fit.add_callback('activated', self.fit_cb) vbox1.add_widget(w, stretch=0) fr = Widgets.Frame("Screenshot") fr.set_widget(vbox1) vpaned = Widgets.Splitter(orientation='vertical') vpaned.add_widget(fr) vpaned.add_widget(Widgets.Label('')) vbox2 = Widgets.VBox() fr = Widgets.Frame("Save File") captions = ( ('Folder:', 'label', 'folder', 'entry'), ('Name:', 'label', 'name', 'entry'), ('Save', 'button'), ) w, b = Widgets.build_info(captions, orientation='vertical') self.w.update(b) b.folder.set_text(self.save_path) b.folder.set_tooltip("Set the folder path for the snap image") b.name.set_text(self.save_name) b.name.set_tooltip("Set the name for the snap image") b.save.set_tooltip("Click to save the last snap") b.save.add_callback('activated', self.save_cb) fr.set_widget(w) vbox2.add_widget(fr, stretch=0) # stretch spacer = Widgets.Label('') vbox2.add_widget(spacer, stretch=1) btns = Widgets.HBox() btns.set_spacing(3) btn = Widgets.Button("Close") btn.add_callback('activated', lambda w: self.close()) btns.add_widget(btn, stretch=0) btn = Widgets.Button("Help") btn.add_callback('activated', lambda w: self.help()) btns.add_widget(btn, stretch=0) btns.add_widget(Widgets.Label(''), stretch=1) vbox2.add_widget(btns, stretch=0) #vpaned.add_widget(vbox2) vbox.add_widget(vpaned, stretch=1) container.add_widget(vbox, stretch=1) container.add_widget(vbox2, stretch=0)