def __init__(self, logger): super(FitsViewer, self).__init__() self.logger = logger fig = Figure() w = FigureCanvas(fig) fi = ImageViewCanvas(logger=self.logger) fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_auto_orient(True) fi.enable_autozoom('on') #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_set_active(True) fi.set_figure(fig) self.fitsimage = fi fi.get_bindings().enable_all(True) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(w, stretch=1) self.readout = QtGui.QLabel("") vbox.addWidget(self.readout, stretch=0, alignment=QtCore.Qt.AlignCenter) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wopen = QtGui.QPushButton("Open File") wopen.clicked.connect(self.open_file) wquit = QtGui.QPushButton("Quit") wquit.clicked.connect(self.close) hbox.addStretch(1) for w in (wopen, wquit): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox) fi.configure(512, 512)
def __init__(self, logger): super(FitsViewer, self).__init__() self.logger = logger # create the ginga viewer and configure it fi = ImageViewCanvas(self.logger, render='widget') fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.set_callback('drag-drop', self.drop_file) fi.set_bg(0.2, 0.2, 0.2) fi.ui_setActive(True) fi.enable_draw(False) self.fitsimage = fi # enable some user interaction bd = fi.get_bindings() bd.enable_all(True) w = fi.get_widget() w.resize(512, 512) # add scrollbar interface around this viewer si = ScrolledView(fi) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(si, stretch=1) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wopen = QtGui.QPushButton("Open File") wopen.clicked.connect(self.open_file) wquit = QtGui.QPushButton("Quit") wquit.clicked.connect(self.quit) hbox.addStretch(1) for w in (wopen, wquit): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox)
def __init__(self, logger): super(FitsViewer, self).__init__() self.logger = logger fi = ImageViewZoom(self.logger, render='widget') fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.set_callback('drag-drop', self.drop_file) fi.set_bg(0.2, 0.2, 0.2) fi.ui_setActive(True) self.fitsimage = fi bd = fi.get_bindings() bd.enable_pan(True) bd.enable_zoom(True) bd.enable_cuts(True) bd.enable_flip(True) w = fi.get_widget() w.resize(512, 512) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(w, stretch=1) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wopen = QtGui.QPushButton("Open File") wopen.clicked.connect(self.open_file) wquit = QtGui.QPushButton("Quit") wquit.clicked.connect(self.quit) hbox.addStretch(1) for w in (wopen, wquit): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox)
def __init__(self, logger): super(FitsViewer, self).__init__() self.logger = logger fi = FitsImageZoom(self.logger, render='widget') fi.enable_autocuts('on') fi.enable_zoom('on') fi.enable_cuts(True) fi.enable_flip(True) fi.enable_rotate(True) fi.set_callback('drag-drop', self.drop_file) fi.set_bg(0.2, 0.2, 0.2) fi.ui_setActive(True) self.fitsimage = fi w = fi.get_widget() w.resize(512, 512) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(w, stretch=1) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wopen = QtGui.QPushButton("Open File") self.connect(wopen, QtCore.SIGNAL("clicked()"), self.open_file) wquit = QtGui.QPushButton("Quit") self.connect(wquit, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("close()")) hbox.addStretch(1) for w in (wopen, wquit): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox)
def __init__(self, logger, app, kapp, prefs): super(StartMenu, self).__init__() self.logger = logger self.preferences = prefs self.count = 0 self.viewers = {} self.app = app self.kapp = kapp self.app.aboutToQuit.connect(self.quit) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) console = QtGui.QPushButton('Qt Console') if self.kapp.ipkernel is None: console.setEnabled(False) console.clicked.connect(self.kapp.new_qt_console) newfits = QtGui.QPushButton('New Viewer') newfits.clicked.connect(self.new_viewer) wquit = QtGui.QPushButton("Quit") wquit.clicked.connect(self.quit) hbox.addStretch(1) for w in (console, newfits, wquit): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox) self.setWindowTitle("Ginga IPython Console") self.showNormal() self.raise_() self.activateWindow()
def __init__(self, logger): super(FitsViewer, self).__init__() self.logger = logger self.drawcolors = colors.get_colors() self.dc = get_canvas_types() fi = CanvasView(logger, render='widget') 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.enable_draw(False) fi.add_callback('drag-drop', self.drop_file_cb) fi.add_callback('cursor-changed', self.cursor_cb) fi.set_bg(0.2, 0.2, 0.2) fi.ui_set_active(True) self.fitsimage = fi bd = fi.get_bindings() bd.enable_all(True) # 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.set_surface(fi) self.canvas = canvas # add canvas to view #fi.add(canvas) private_canvas = fi.get_canvas() private_canvas.add(canvas) canvas.register_for_cursor_drawing(fi) canvas.add_callback('draw-event', self.draw_cb) canvas.set_draw_mode('draw') canvas.ui_set_active(True) self.drawtypes = canvas.get_drawtypes() self.drawtypes.sort() # add a color bar #fi.show_color_bar(True) fi.show_focus_indicator(True) # add little mode indicator that shows keyboard modal states fi.show_mode_indicator(True, corner='ur') w = fi.get_widget() w.resize(512, 512) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(w, stretch=1) self.readout = QtGui.QLabel("") vbox.addWidget(self.readout, stretch=0, alignment=QtCore.Qt.AlignCenter) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wdrawtype = QtGui.QComboBox() for name in self.drawtypes: wdrawtype.addItem(name) index = self.drawtypes.index('rectangle') wdrawtype.setCurrentIndex(index) wdrawtype.activated.connect(self.set_drawparams) self.wdrawtype = wdrawtype wdrawcolor = QtGui.QComboBox() for name in self.drawcolors: wdrawcolor.addItem(name) index = self.drawcolors.index('lightblue') wdrawcolor.setCurrentIndex(index) wdrawcolor.activated.connect(self.set_drawparams) self.wdrawcolor = wdrawcolor wfill = QtGui.QCheckBox("Fill") wfill.stateChanged.connect(self.set_drawparams) self.wfill = wfill walpha = QtGui.QDoubleSpinBox() walpha.setRange(0.0, 1.0) walpha.setSingleStep(0.1) walpha.setValue(1.0) walpha.valueChanged.connect(self.set_drawparams) self.walpha = walpha wclear = QtGui.QPushButton("Clear Canvas") wclear.clicked.connect(self.clear_canvas) wopen = QtGui.QPushButton("Open File") wopen.clicked.connect(self.open_file) wquit = QtGui.QPushButton("Quit") wquit.clicked.connect(self.quit) hbox.addStretch(1) for w in (wopen, wdrawtype, wdrawcolor, wfill, QtGui.QLabel('Alpha:'), walpha, wclear, wquit): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) mode = self.canvas.get_draw_mode() hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) btn1 = QtGui.QRadioButton("Draw") btn1.setChecked(mode == 'draw') btn1.toggled.connect(lambda val: self.set_mode_cb('draw', val)) btn1.setToolTip("Choose this to draw on the canvas") hbox.addWidget(btn1) btn2 = QtGui.QRadioButton("Edit") btn2.setChecked(mode == 'edit') btn2.toggled.connect(lambda val: self.set_mode_cb('edit', val)) btn2.setToolTip("Choose this to edit things on the canvas") hbox.addWidget(btn2) btn3 = QtGui.QRadioButton("Pick") btn3.setChecked(mode == 'pick') btn3.toggled.connect(lambda val: self.set_mode_cb('pick', val)) btn3.setToolTip("Choose this to pick things on the canvas") hbox.addWidget(btn3) hbox.addWidget(QtGui.QLabel(''), stretch=1) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox)
def __init__(self, logger): super(FitsViewer, self).__init__() self.logger = logger menubar = self.menuBar() # create a File pulldown menu, and add it to the menu bar filemenu = menubar.addMenu("File") item = QtGui.QAction("Open File", menubar) item.triggered.connect(self.open_file) filemenu.addAction(item) sep = QtGui.QAction(menubar) sep.setSeparator(True) filemenu.addAction(sep) item = QtGui.QAction("Quit", menubar) item.triggered.connect(self.close) filemenu.addAction(item) # Add matplotlib color maps to our built in ones cmap.add_matplotlib_cmaps() self.cmaps = cmap.get_names() self.imaps = imap.get_names() wd, ht = 500, 500 # Create a Ginga widget fi = ImageViewCanvas(logger, render='widget') fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.enable_draw(False) fi.set_callback('drag-drop', self.drop_file_cb) fi.set_callback('cursor-changed', self.cursor_cb) fi.set_bg(0.2, 0.2, 0.2) fi.ui_set_active(True) self.fitsimage = fi fi.show_color_bar(True) # enable various key and mouse controlled actions bd = fi.get_bindings() bd.enable_all(True) self.cp_tag = 'compass' # pack widget into layout gingaw = fi.get_widget() gingaw.resize(wd, ht) vbox1 = QtGui.QWidget() layout = QtGui.QVBoxLayout() layout.addWidget(gingaw, stretch=1) self.cm = cmap.get_cmap('gray') self.im = imap.get_imap('ramp') # color map selection widget wcmap = QtGui.QComboBox() for name in self.cmaps: wcmap.addItem(name) index = self.cmaps.index('gray') wcmap.setCurrentIndex(index) wcmap.activated.connect(self.set_cmap_cb) self.wcmap = wcmap # intensity map selection widget wimap = QtGui.QComboBox() for name in self.imaps: wimap.addItem(name) index = self.imaps.index('ramp') wimap.setCurrentIndex(index) wimap.activated.connect(self.set_cmap_cb) self.wimap = wimap #wopen = QtGui.QPushButton("Open File") #wopen.clicked.connect(self.open_file) # add buttons to layout hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) hbox.addStretch(1) for w in (wcmap, wimap): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) layout.addWidget(hw, stretch=0) vbox1.setLayout(layout) # Create a matplotlib Figure #self.fig = matplotlib.figure.Figure(figsize=(wd, ht)) self.fig = matplotlib.figure.Figure() self.canvas = FigureCanvas(self.fig) vbox2 = QtGui.QWidget() layout = QtGui.QVBoxLayout() layout.addWidget(self.canvas, stretch=1) # Add matplotlib buttons hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wgetimg = QtGui.QPushButton("Get Data") wgetimg.clicked.connect(self.get_image) wgetrgb = QtGui.QPushButton("Get RGB") wgetrgb.clicked.connect(self.get_rgb_image) #wquit = QtGui.QPushButton("Quit") #wquit.clicked.connect(self.close) hbox.addStretch(1) for w in (wgetimg, wgetrgb): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) layout.addWidget(hw, stretch=0) vbox2.setLayout(layout) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) w = QtGui.QWidget() layout = QtGui.QHBoxLayout() layout.addWidget(vbox1, stretch=1.0) layout.addWidget(vbox2, stretch=1.0) w.setLayout(layout) vbox.addWidget(w, stretch=1) self.readout = QtGui.QLabel("") vbox.addWidget(self.readout, stretch=0, alignment=QtCore.Qt.AlignCenter) vw = QtGui.QWidget() vw.setLayout(vbox) self.setCentralWidget(vw)
def __init__(self, logger): super(FitsViewer, self).__init__() self.logger = logger self.drawcolors = colors.get_colors() fig = Figure() w = FigureCanvas(fig) fi = ImageViewCanvas(logger) fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.enable_draw(False) 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 fi.set_figure(fig) bd = fi.get_bindings() bd.enable_all(True) # canvas that we will draw on DrawingCanvas = fi.getDrawClass('drawingcanvas') canvas = 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.add(canvas) canvas.ui_setActive(True) w.resize(512, 512) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(w, stretch=1) self.readout = QtGui.QLabel("") vbox.addWidget(self.readout, stretch=0, alignment=QtCore.Qt.AlignCenter) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wdrawtype = QtGui.QComboBox() self.drawtypes = fi.get_drawtypes() for name in self.drawtypes: wdrawtype.addItem(name) index = self.drawtypes.index('rectangle') wdrawtype.setCurrentIndex(index) wdrawtype.activated.connect(self.set_drawparams) self.wdrawtype = wdrawtype wdrawcolor = QtGui.QComboBox() for name in self.drawcolors: wdrawcolor.addItem(name) index = self.drawcolors.index('lightblue') wdrawcolor.setCurrentIndex(index) wdrawcolor.activated.connect(self.set_drawparams) self.wdrawcolor = wdrawcolor wfill = QtGui.QCheckBox("Fill") wfill.stateChanged.connect(self.set_drawparams) self.wfill = wfill walpha = QtGui.QDoubleSpinBox() walpha.setRange(0.0, 1.0) walpha.setSingleStep(0.1) walpha.setValue(1.0) walpha.valueChanged.connect(self.set_drawparams) self.walpha = walpha wclear = QtGui.QPushButton("Clear Canvas") wclear.clicked.connect(self.clear_canvas) wopen = QtGui.QPushButton("Open File") wopen.clicked.connect(self.open_file) wquit = QtGui.QPushButton("Quit") wquit.clicked.connect(self.close) hbox.addStretch(1) for w in (wopen, wdrawtype, wdrawcolor, wfill, QtGui.QLabel('Alpha:'), walpha, wclear, wquit): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox)
def __init__(self, logger): super(FitsViewer, self).__init__() self.logger = logger self.cachedFiles = None self.scanning = False #KTL stuff #Cache KTL keywords self.trickxpos = ktl.cache('ao', 'TRKRO1XP') self.trickypos = ktl.cache('ao', 'TRKRO1YP') self.trickxsize = ktl.cache('ao', 'TRKRO1XS') self.trickysize = ktl.cache('ao', 'TRKRO1YS') self.rawfile = '' self.threadpool = QtCore.QThreadPool() self.iqcalc = iqcalc.IQCalc(self.logger) # create the ginga viewer and configure it fi = CanvasView(self.logger, render='widget') fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') # fi.set_callback('drag-drop', self.drop_file) fi.set_bg(0.2, 0.2, 0.2) fi.ui_set_active(True) self.fitsimage = fi # enable some user interaction self.bd = fi.get_bindings() self.bd.enable_all(True) w = fi.get_widget() w.resize(512, 512) # add scrollbar interface around this viewer si = ScrolledView(fi) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(si, stretch=1) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) self.readout = QtGui.QLabel("") hbox.addStretch(1) hbox.addWidget(self.readout, stretch=0) self.box_readout = QtGui.QLabel("") hbox.addStretch(1) hbox.addWidget(self.box_readout, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) hbox2 = QtGui.QHBoxLayout() hbox2.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) self.wstartscan = QtGui.QPushButton("Start Scan") self.wstartscan.clicked.connect(self.start_scan) self.wstartscan.setEnabled(True) self.wstopscan = QtGui.QPushButton("Stop Scan") self.wstopscan.clicked.connect(self.stop_scan) self.wstopscan.setEnabled(False) self.wcut = QtGui.QComboBox() for name in fi.get_autocut_methods(): self.wcut.addItem(name) self.wcut.currentIndexChanged.connect(self.cut_change) self.wcolor = QtGui.QComboBox() for name in fi.get_color_algorithms(): self.wcolor.addItem(name) self.wcolor.currentIndexChanged.connect(self.color_change) wopen = QtGui.QPushButton("Open File") wopen.clicked.connect(self.open_file) self.wsky = QtGui.QPushButton("Load Sky") self.wsky.clicked.connect(self.load_sky) self.wsky.setEnabled(False) wquit = QtGui.QPushButton("Quit") wquit.clicked.connect(self.quit) fi.set_callback('cursor-changed', self.motion_cb) fi.add_callback('cursor-down', self.btndown) hbox2.addStretch(1) for w in (self.wstartscan, self.wstopscan, self.wcut, self.wcolor, wopen, self.wsky, wquit): hbox2.addWidget(w, stretch=0) hw2 = QtGui.QWidget() hw2.setLayout(hbox2) vbox.addWidget(hw2, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox) self.recdc, self.compdc = self.add_canvas() self.boxtag = "roi-box" self.picktag = "pick-box"
def __init__(self, logger): super(FitsViewer, self).__init__() self.logger = logger self.drawcolors = colors.get_colors() fig = Figure() w = FigureCanvas(fig) fi = ImageViewCanvas(logger) fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.enable_draw(True) fi.set_drawtype('ruler') fi.set_drawcolor('blue') 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 fi.set_figure(fig) fi.get_bindings().enable_all(True) w.resize(512, 512) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(w, stretch=1) self.readout = QtGui.QLabel("") vbox.addWidget(self.readout, stretch=0, alignment=QtCore.Qt.AlignCenter) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wdrawtype = QtGui.QComboBox() self.drawtypes = fi.get_drawtypes() for name in self.drawtypes: wdrawtype.addItem(name) index = self.drawtypes.index('ruler') wdrawtype.setCurrentIndex(index) wdrawtype.activated.connect(self.set_drawparams) self.wdrawtype = wdrawtype wdrawcolor = QtGui.QComboBox() for name in self.drawcolors: wdrawcolor.addItem(name) index = self.drawcolors.index('blue') wdrawcolor.setCurrentIndex(index) wdrawcolor.activated.connect(self.set_drawparams) self.wdrawcolor = wdrawcolor wclear = QtGui.QPushButton("Clear Canvas") wclear.clicked.connect(self.clear_canvas) wopen = QtGui.QPushButton("Open File") wopen.clicked.connect(self.open_file) wquit = QtGui.QPushButton("Quit") wquit.clicked.connect(self.close) hbox.addStretch(1) for w in (wopen, wdrawtype, wdrawcolor, wclear, wquit): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox)
def __init__(self, logger): super(FitsViewer, self).__init__() self.logger = logger self.drawcolors = colors.get_colors() self.dc = get_canvas_types() self.set_medfilt(0) self.set_c2c(0) # create the ginga viewer and configure it fi = CanvasView(self.logger, render='widget') fi.enable_autocuts('on') fi.set_autocut_params('zscale') fi.enable_autozoom('on') fi.set_callback('drag-drop', self.drop_file) fi.add_callback('cursor-changed', self.cursor_cb) fi.add_callback('cursor-down', self.click_cb) fi.set_bg(0.2, 0.2, 0.2) fi.ui_set_active(True) self.fitsimage = fi # enable some user interaction bd = fi.get_bindings() bd.enable_all(True) # canvas that we will draw on canvas = self.dc.DrawingCanvas() # canvas.enable_draw(True) # canvas.enable_edit(True) # canvas.set_drawtype('circle', color='lightblue') canvas.set_surface(fi) self.canvas = canvas # add canvas to view #fi.add(canvas) private_canvas = fi.get_canvas() private_canvas.add(canvas) # canvas.register_for_cursor_drawing(fi) # canvas.add_callback('draw-event', self.draw_cb) # canvas.set_draw_mode('draw') canvas.ui_set_active(True) self.drawtypes = canvas.get_drawtypes() self.drawtypes.sort() w = fi.get_widget() w.resize(1000, 1000) # --------------------------------------------------------------------- # add scrollbar interface around this viewer si = ScrolledView(fi) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(si, stretch=1) # --------------------------------------------------------------------- # add live cursor readout self.readout = QtGui.QLabel("") vbox.addWidget(self.readout, stretch=0, alignment=QtCore.Qt.AlignCenter) # --------------------------------------------------------------------- # add row of interface widgets hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wzoomfit = QtGui.QPushButton("Z0") wzoomfit.clicked.connect(self.zoom_fit) wzoomin = QtGui.QPushButton("Z+") wzoomin.clicked.connect(self.zoom_in) wzoomout = QtGui.QPushButton("Z-") wzoomout.clicked.connect(self.zoom_out) wc2c = QtGui.QCheckBox("Click to Center") wc2c.stateChanged.connect(self.set_c2c) self.wc2c = wc2c wsolve = QtGui.QPushButton("Solve") wsolve.clicked.connect(self.solve_astrometry) woverlay = QtGui.QPushButton("Overlay Catalog") woverlay.clicked.connect(self.overlay_catalog) wclear = QtGui.QPushButton("Clear Overlays") wclear.clicked.connect(self.clear_overlays) wmedfilt = QtGui.QCheckBox("Median Filter") wmedfilt.stateChanged.connect(self.set_medfilt) self.wmedfilt = wmedfilt wopen = QtGui.QPushButton("Open File") wopen.clicked.connect(self.open_file) wquit = QtGui.QPushButton("Quit") wquit.clicked.connect(self.quit) hbox.addStretch(1) hbox.addWidget(wzoomfit, stretch=0) hbox.addWidget(wzoomin, stretch=0) hbox.addWidget(wzoomout, stretch=0) hbox.addWidget(wc2c, stretch=0) # hbox.addWidget(wsolve, stretch=0) hbox.addWidget(woverlay, stretch=0) hbox.addWidget(wclear, stretch=0) hbox.addWidget(wmedfilt, stretch=0) # hbox.addWidget(wopen, stretch=0) hbox.addWidget(wquit, stretch=0) # --------------------------------------------------------------------- hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox)
def __init__(self, logger): super(FitsViewer, self).__init__() self.logger = logger self.drawcolors = colors.get_colors() self.dc = get_canvas_types() fi = CanvasView(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.enable_draw(False) fi.set_callback('drag-drop', self.drop_file_cb) fi.set_callback('none-move', self.cursor_cb) fi.ui_set_active(True) self.fitsimage = fi # quick hack to get 'u' to invoke hidden camera mode bm = fi.get_bindmap() bm.mode_map['u'] = bm.mode_map['mode_camera'] bd = fi.get_bindings() bd.enable_all(True) # canvas that we will draw on canvas = self.dc.DrawingCanvas() canvas.enable_draw(True) canvas.set_drawtype('rectangle', color='lightblue') canvas.set_surface(fi) self.canvas = canvas # add canvas to view #fi.add(canvas) private_canvas = fi.get_canvas() private_canvas.register_for_cursor_drawing(fi) private_canvas.add(canvas) canvas.ui_set_active(True) self.drawtypes = canvas.get_drawtypes() self.drawtypes.sort() # add a color bar #fi.show_color_bar(True) #fi.show_focus_indicator(True) # add little mode indicator that shows keyboard modal states #fi.show_mode_indicator(True, corner='ur') w = fi.get_widget() w.resize(512, 512) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(w, stretch=1) self.readout = QtGui.QLabel("") vbox.addWidget(self.readout, stretch=0, alignment=QtCore.Qt.AlignCenter) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wdrawtype = QtGui.QComboBox() for name in self.drawtypes: wdrawtype.addItem(name) index = self.drawtypes.index('rectangle') wdrawtype.setCurrentIndex(index) wdrawtype.activated.connect(self.set_drawparams) self.wdrawtype = wdrawtype wdrawcolor = QtGui.QComboBox() for name in self.drawcolors: wdrawcolor.addItem(name) index = self.drawcolors.index('lightblue') wdrawcolor.setCurrentIndex(index) wdrawcolor.activated.connect(self.set_drawparams) self.wdrawcolor = wdrawcolor wfill = QtGui.QCheckBox("Fill") wfill.stateChanged.connect(self.set_drawparams) self.wfill = wfill walpha = QtGui.QDoubleSpinBox() walpha.setRange(0.0, 1.0) walpha.setSingleStep(0.1) walpha.setValue(1.0) walpha.valueChanged.connect(self.set_drawparams) self.walpha = walpha wclear = QtGui.QPushButton("Clear Canvas") wclear.clicked.connect(self.clear_canvas) wopen = QtGui.QPushButton("Open File") wopen.clicked.connect(self.open_file) wquit = QtGui.QPushButton("Quit") wquit.clicked.connect(self.quit) hbox.addStretch(1) for w in (wopen, wdrawtype, wdrawcolor, wfill, QtGui.QLabel('Alpha:'), walpha, wclear, wquit): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox)
def __init__(self, logger): super(FitsViewer, self).__init__() self.logger = logger self.drawcolors = ['white', 'black', 'red', 'yellow', 'blue', 'green'] fi = FitsImageCanvas(logger, render='widget') fi.enable_autocuts('on') fi.enable_zoom('on') fi.enable_cuts(True) fi.enable_flip(True) fi.enable_rotate(True) fi.enable_draw(True) fi.set_drawtype('ruler') fi.set_drawcolor('blue') fi.set_callback('drag-drop', self.drop_file) fi.set_callback('motion', self.motion) fi.set_bg(0.2, 0.2, 0.2) fi.ui_setActive(True) self.fitsimage = fi w = fi.get_widget() w.resize(512, 512) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(w, stretch=1) self.readout = QtGui.QLabel("") vbox.addWidget(self.readout, stretch=0, alignment=QtCore.Qt.AlignCenter) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wdrawtype = QtGui.QComboBox() self.drawtypes = fi.get_drawtypes() for name in self.drawtypes: wdrawtype.addItem(name) index = self.drawtypes.index('ruler') wdrawtype.setCurrentIndex(index) self.connect(wdrawtype, QtCore.SIGNAL("activated(QString)"), self.set_drawparams) self.wdrawtype = wdrawtype wdrawcolor = QtGui.QComboBox() for name in self.drawcolors: wdrawcolor.addItem(name) index = self.drawcolors.index('blue') wdrawcolor.setCurrentIndex(index) self.connect(wdrawcolor, QtCore.SIGNAL("activated(QString)"), self.set_drawparams) self.wdrawcolor = wdrawcolor wclear = QtGui.QPushButton("Clear Canvas") self.connect(wclear, QtCore.SIGNAL("clicked()"), self.clear_canvas) wopen = QtGui.QPushButton("Open File") self.connect(wopen, QtCore.SIGNAL("clicked()"), self.open_file) wquit = QtGui.QPushButton("Quit") self.connect(wquit, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("close()")) hbox.addStretch(1) for w in (wopen, wdrawtype, wdrawcolor, wclear, wquit): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox)
def __init__(self, logger): super(FitsViewer, self).__init__() self.logger = logger self.drawcolors = colors.get_colors() self.dc = get_canvas_types() #fi = ImageViewCanvas(logger, render='widget') fi = CanvasView(logger, render='widget') 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.enable_draw(False) 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) # canvas that we will draw on canvas = self.dc.DrawingCanvas() canvas.enable_draw(True) canvas.set_drawtype('rectangle', color='lightblue') canvas.set_surface(fi) self.canvas = canvas # add canvas to view #fi.add(canvas) private_canvas = fi.get_canvas() private_canvas.add(canvas) canvas.ui_setActive(True) self.drawtypes = canvas.get_drawtypes() self.drawtypes.sort() # add a color bar private_canvas.add(self.dc.ColorBar(side='bottom', offset=10)) # add little mode indicator that shows modal states in # the corner private_canvas.add(self.dc.ModeIndicator(corner='ur')) # 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)) w = fi.get_widget() w.resize(512, 512) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(w, stretch=1) self.readout = QtGui.QLabel("") vbox.addWidget(self.readout, stretch=0, alignment=QtCore.Qt.AlignCenter) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wdrawtype = QtGui.QComboBox() for name in self.drawtypes: wdrawtype.addItem(name) index = self.drawtypes.index('rectangle') wdrawtype.setCurrentIndex(index) wdrawtype.activated.connect(self.set_drawparams) self.wdrawtype = wdrawtype wdrawcolor = QtGui.QComboBox() for name in self.drawcolors: wdrawcolor.addItem(name) index = self.drawcolors.index('lightblue') wdrawcolor.setCurrentIndex(index) wdrawcolor.activated.connect(self.set_drawparams) self.wdrawcolor = wdrawcolor wfill = QtGui.QCheckBox("Fill") wfill.stateChanged.connect(self.set_drawparams) self.wfill = wfill walpha = QtGui.QDoubleSpinBox() walpha.setRange(0.0, 1.0) walpha.setSingleStep(0.1) walpha.setValue(1.0) walpha.valueChanged.connect(self.set_drawparams) self.walpha = walpha wclear = QtGui.QPushButton("Clear Canvas") wclear.clicked.connect(self.clear_canvas) wopen = QtGui.QPushButton("Open File") wopen.clicked.connect(self.open_file) wquit = QtGui.QPushButton("Quit") wquit.clicked.connect(self.quit) hbox.addStretch(1) for w in (wopen, wdrawtype, wdrawcolor, wfill, QtGui.QLabel('Alpha:'), walpha, wclear, wquit): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox)
def new_viewer(self, name=None, settings=None): if not name: self.count += 1 name = 'v%d' % self.count if settings is None: settings = self.preferences.createCategory('ipg_viewer') settings.load(onError='silent') settings.addDefaults(autocut_method='zscale') # instantiate bindings loaded with users preferences bclass = IPyNbImageView.bindingsClass bindprefs = self.preferences.createCategory('bindings') bd = bclass(self.logger, settings=bindprefs) # create a ginga basic object for user interaction fi = IPyNbImageView(self.logger, settings=settings, render='widget', bindings=bd) fi.enable_draw(False) fi.set_callback('drag-drop', self.drop_file, name) fi.set_bg(0.2, 0.2, 0.2) fi.ui_setActive(True) # expose the fits viewer to the shared namespace self.kapp.namespace[name] = fi # enable various interactive operations bd = fi.get_bindings() bd.enable_all(True) # get the ginga Qt widget w = fi.get_widget() w.resize(512, 512) # pack it into a qt window with a couple other buttons vw = QtGui.QWidget() vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(w, stretch=1) # for simple WCS readout self.readout = Readout(-1, 16) readout = self.readout.get_widget() fi.set_callback('none-move', self.motion, self.readout) vbox.addWidget(readout, stretch=0, alignment=QtCore.Qt.AlignCenter) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wopen = QtGui.QPushButton("Open File") def _open_file(name): return lambda: self.open_file(name) wopen.clicked.connect(_open_file(name)) wquit = QtGui.QPushButton("Close") def _close(name): return lambda: self.close_viewer(name) wquit.clicked.connect(_close(name)) hbox.addStretch(1) for w in (wopen, wquit): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw.setLayout(vbox) vw.resize(524, 540) vw.setWindowTitle("Ginga: %s" % name) self.viewers[name] = vw vw.showNormal() vw.raise_() vw.activateWindow()
def __init__(self, qtmain, logger, ev_quit, options): super(GingaVision, self).__init__() self.qtmain = qtmain self.logger = logger self.ev_quit = ev_quit 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 fi = ImageViewZoom(self.logger, render='widget') 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) w = fi.get_widget() w.resize(512, 512) vbox = QtGui.QVBoxLayout() vbox.setContentsMargins(QtCore.QMargins(2, 2, 2, 2)) vbox.setSpacing(1) vbox.addWidget(w, stretch=1) hbox = QtGui.QHBoxLayout() hbox.setContentsMargins(QtCore.QMargins(4, 2, 4, 2)) wopen = QtGui.QPushButton("Open File") #wopen.clicked.connect(self.open_file) wquit = QtGui.QPushButton("Quit") wquit.clicked.connect(self.quit) hbox.addStretch(1) for w in (wopen, wquit): hbox.addWidget(w, stretch=0) hw = QtGui.QWidget() hw.setLayout(hbox) vbox.addWidget(hw, stretch=0) vw = QtGui.QWidget() self.setCentralWidget(vw) vw.setLayout(vbox) self.setWindowTitle("Video Example Viewer")