self.sync_state() def sync_state(self): """Called to synchronize state (e.g. when parameters have changed). """ oradius = self.radius + self.width if oradius < self.radius: raise ValueError('Outer boundary < inner boundary') d = dict(x=self.x, y=self.y, radius=self.radius, color=self.color, linewidth=self.linewidth, linestyle=self.linestyle, alpha=self.alpha) # update inner object self.objects[0].__dict__.update(d) # update outer object d['radius'] = oradius self.objects[1].__dict__.update(d) def move_to(self, xdst, ydst): super(Annulus, self).move_to(xdst, ydst) self.set_data_points([(xdst, ydst)]) register_canvas_types(dict(ruler=Ruler, compass=Compass, crosshair=Crosshair, annulus=Annulus)) #END
else: autocuts = viewer.autocuts # Apply cut levels loval, hival = viewer.t_['cuts'] newdata = autocuts.cut_levels(data, loval, hival, vmin=vmin, vmax=vmax) return newdata def _reset_cache(self, cache): cache.setvals(cutout=None, prergb=None, rgbarr=None, drawn=False, cvs_pos=(0, 0)) return cache def set_image(self, image): self.image = image self.reset_optimize() self.make_callback('image-set', image) def scale_by(self, scale_x, scale_y): self.scale_x *= scale_x self.scale_y *= scale_y self.reset_optimize() # register our types register_canvas_types(dict(image=Image, normimage=NormImage)) #END
## Param(name='coord', type=str, default='data', ## valid=['data', 'wcs'], ## description="Set type of coordinates"), ] def __init__(self, *objects, **kwdargs): CompoundObject.__init__(self, *objects, **kwdargs) CanvasMixin.__init__(self) self.kind = "canvas" self.editable = False class DrawingCanvas(Mixins.UIMixin, DrawingMixin, Canvas): """Drawing canvas.""" def __init__(self, **kwdargs): Canvas.__init__(self, **kwdargs) DrawingMixin.__init__(self) Mixins.UIMixin.__init__(self) self.kind = "drawingcanvas" self.editable = False catalog = dict(compoundobject=CompoundObject, canvas=Canvas, drawingcanvas=DrawingCanvas) register_canvas_types(catalog) # END
if (not self.has_focus) or (not self.enabled): return cr = viewer.renderer.setup_cr(self) tr = viewer.tform['window_to_native'] wd, ht = viewer.get_window_size() lw = self.linewidth off = lw // 2 # draw a rectangle around the perimeter cr.set_line(color=self.color, linewidth=lw, alpha=self.alpha, style=self.linestyle) cpoints = ((off, off), (wd - off, off), (wd - off, ht - off), (off, ht - off)) cr.draw_polygon(tr.to_(cpoints)) def focus_cb(self, viewer, onoff): has_focus = self.has_focus self.has_focus = onoff if has_focus != self.has_focus: viewer.redraw(whence=3) # register our types register_canvas_types(dict(colorbar=ColorBar, drawablecolorbar=DrawableColorBar, modeindicator=ModeIndicator, focusindicator=FocusIndicator))
cur_rot = viewer.get_rotation() if cur_rot != self._cur_rot and self.show_label: # rotation has changed # TODO: for a rotation or swap axes change, it would be # sufficient to simply calculate the new rotation angles # and update all the text objects in self.objects update = True if len(self.objects) == 0: # initial time update = True if update: # only expensive recalculation of grid if needed self.ra_angle = None self.dec_angle = None self.objects = self._calc_axes(viewer, image, cur_rot, cur_swap) super(WCSAxes, self).draw(viewer) register_canvas_types( dict(ruler=Ruler, compass=Compass, crosshair=Crosshair, annulus=Annulus, wcsaxes=WCSAxes)) # END
txt_wd, txt_ht = cr.text_extents(text) # draw bg box_wd, box_ht = 2 * self.xpad + txt_wd, 2 * self.ypad + txt_ht if self.corner == 'lr': x_base, y_base = win_wd - self.offset - box_wd, win_ht - self.offset - box_ht elif self.corner == 'll': x_base, y_base = self.offset, win_ht - self.offset - box_ht if self.corner == 'ur': x_base, y_base = win_wd - self.offset - box_wd, self.offset if self.corner == 'ul': x_base, y_base = self.offset, self.offset cr.set_line('black', linewidth=0) cr.set_fill('black', alpha=self.fillalpha) cx1, cy1, cx2, cy2 = x_base, y_base, x_base + box_wd, y_base + box_ht cr.draw_polygon(((cx1, cy1), (cx2, cy1), (cx2, cy2), (cx1, cy2))) # draw fg cr.set_line(color=self.color, linewidth=1, alpha=self.alpha) cx, cy = x_base + self.xpad, y_base + txt_ht + self.ypad cr.draw_text(cx, cy, text) # register our types register_canvas_types(dict(colorbar=ColorBar, drawablecolorbar=DrawableColorBar, modeindicator=ModeIndicator))
return [ ## Param(name='coord', type=str, default='data', ## valid=['data', 'wcs'], ## description="Set type of coordinates"), ] def __init__(self, *objects): CompoundObject.__init__(self, *objects) CanvasMixin.__init__(self) self.kind = 'canvas' self.editable = False class DrawingCanvas(Mixins.UIMixin, DrawingMixin, Canvas): def __init__(self): Canvas.__init__(self) DrawingMixin.__init__(self) Mixins.UIMixin.__init__(self) self.kind = 'drawingcanvas' self.editable = False catalog = dict(compoundobject=CompoundObject, canvas=Canvas, drawingcanvas=DrawingCanvas) register_canvas_types(catalog) #END
self.sync_state() def sync_state(self): """Called to synchronize state (e.g. when parameters have changed). """ oradius = self.radius + self.width if oradius < self.radius: raise ValueError('Outer boundary < inner boundary') d = dict(x=self.x, y=self.y, radius=self.radius, color=self.color, linewidth=self.linewidth, linestyle=self.linestyle, alpha=self.alpha) # update inner object self.objects[0].__dict__.update(d) # update outer object d['radius'] = oradius self.objects[1].__dict__.update(d) def move_to(self, xdst, ydst): super(Annulus, self).move_to(xdst, ydst) self.x = xdst self.y = ydst register_canvas_types(dict(ruler=Ruler, compass=Compass, annulus=Annulus)) #END