def __init__(self, vispy_widget=None, parent=None): super(VispyDataViewerToolbar, self).__init__(parent=parent) # Keep a reference to the Vispy Widget and the Vispy Data Viewer self._vispy_widget = vispy_widget self._vispy_data_viewer = parent self._data_collection = parent._data # Set visual preferences self.setIconSize(QtCore.QSize(25, 25)) # Initialize drawing visual self.line_pos = [] self.line = scene.visuals.Line(color='white', method='gl', parent=self._vispy_widget.canvas.scene) # Selection defaults self._scatter = None self.mode = None self.selection_origin = (0, 0) self.selected = [] # Set up selection actions a = QtGui.QAction(get_icon('glue_lasso'), 'Lasso Selection', parent) a.triggered.connect(nonpartial(self.toggle_lasso)) a.setCheckable(True) parent.addAction(a) self.addAction(a) self.lasso_action = a a = QtGui.QAction(get_icon('glue_square'), 'Rectangle Selection', parent) a.triggered.connect(nonpartial(self.toggle_rectangle)) a.setCheckable(True) parent.addAction(a) self.addAction(a) self.rectangle_action = a a = QtGui.QAction(get_icon('glue_circle'), 'Ellipse Selection', parent) a.triggered.connect(nonpartial(self.toggle_ellipse)) a.setCheckable(True) parent.addAction(a) self.addAction(a) self.ellipse_action = a # TODO: change path to icon once it's in a released version of glue a = QtGui.QAction(QtGui.QIcon(POINT_ICON), 'Point Selection', parent) a.triggered.connect(nonpartial(self.toggle_point)) a.setCheckable(True) parent.addAction(a) self.addAction(a) self.point_action = a # Connect callback functions to VisPy Canvas self._vispy_widget.canvas.events.mouse_press.connect(self.on_mouse_press) self._vispy_widget.canvas.events.mouse_release.connect(self.on_mouse_release) self._vispy_widget.canvas.events.mouse_move.connect(self.on_mouse_move)
def _mouse_modes(self): modes = [] modes.append(("Rectangle", get_icon("glue_square"), lambda tf: self._set_roi_mode("rectangle", tf))) modes.append(("Circle", get_icon("glue_circle"), lambda tf: self._set_roi_mode("circle", tf))) modes.append(("Polygon", get_icon("glue_lasso"), lambda tf: self._set_roi_mode("polygon", tf))) for tool in self._tools: modes += tool._get_modes(self.canvas) add_callback(self.client, "display_data", tool._display_data_hook) return modes
def _mouse_modes(self): modes = [] modes.append(("Rectangle", get_icon('glue_square'), lambda tf: self._set_roi_mode('rectangle', tf))) modes.append(("Circle", get_icon('glue_circle'), lambda tf: self._set_roi_mode('circle', tf))) modes.append(("Polygon", get_icon('glue_lasso'), lambda tf: self._set_roi_mode('polygon', tf))) for tool in self._tools: modes += tool._get_modes(self.viewer) add_callback(self.client, 'display_data', tool._display_data_hook) return modes
def __init__(self, viewer, toolbar=None): super(BackTool, self).__init__(viewer=viewer) self.tool_id = 'mpl:back' self.icon = get_icon('glue_back') self.action_text = 'Back' self.tool_tip = 'Back to previous view' self.toolbar = toolbar
def _create_terminal(self): if self._terminal is not None: # already set up return if hasattr(self, '_terminal_exception'): # already failed to set up return self._terminal_button = QtWidgets.QToolButton(self._ui) self._terminal_button.setToolTip("Toggle IPython Prompt") i = get_icon('IPythonConsole') self._terminal_button.setIcon(i) self._terminal_button.setIconSize(QtCore.QSize(25, 25)) self._layer_widget.ui.button_row.addWidget(self._terminal_button) try: widget = glue_terminal(data_collection=self._data, dc=self._data, hub=self._hub, session=self.session, application=self, **vars(env)) except IPythonTerminalError as exc: self._terminal = None self._terminal_button.setEnabled(False) self._terminal_button.setToolTip(str(exc)) self._terminal_exception = str(exc) return self._terminal_button.clicked.connect(self._toggle_terminal) self._terminal = self.add_widget(widget) self._hide_terminal()
def _create_terminal(self): if self._terminal is not None: # already set up return if hasattr(self, '_terminal_exception'): # already failed to set up return self._terminal_button = QtWidgets.QToolButton(self._ui) self._terminal_button.setToolTip("Toggle IPython Prompt") i = get_icon('IPythonConsole') self._terminal_button.setIcon(i) self._terminal_button.setIconSize(QtCore.QSize(25, 25)) self._layer_widget.ui.button_row.addWidget(self._terminal_button) try: from glue.app.qt.terminal import glue_terminal widget = glue_terminal(data_collection=self._data, dc=self._data, hub=self._hub, session=self.session, application=self, **vars(env)) self._terminal_button.clicked.connect(self._toggle_terminal) except Exception as e: # pylint: disable=W0703 import traceback self._terminal_exception = traceback.format_exc() self._setup_terminal_error_dialog(e) return self._terminal = self.add_widget(widget, label='IPython') self._hide_terminal()
def __init__(self, viewer, toolbar=None): super(ForwardTool, self).__init__(viewer=viewer) self.tool_id = 'mpl:forward' self.icon = get_icon('glue_forward') self.action_text = 'Forward' self.tool_tip = 'Forward to next view' self.toolbar = toolbar
def __init__(self, axes, release_callback=None): super(MouseModeTest, self).__init__(axes, release_callback=release_callback) self.icon = get_icon('glue_square') self.mode_id = 'TEST' self.action_text = 'test text' self.tool_tip = 'just testing' self.last_mode = None
def _create_terminal(self): if self._terminal is not None: # already set up return if hasattr(self, '_terminal_exception'): # already failed to set up return self._terminal_button = QtGui.QToolButton(self._ui) self._terminal_button.setToolTip("Toggle IPython Prompt") i = get_icon('IPythonConsole') self._terminal_button.setIcon(i) self._terminal_button.setIconSize(QtCore.QSize(25, 25)) self._layer_widget.ui.button_row.addWidget(self._terminal_button) try: from glue.app.qt.terminal import glue_terminal widget = glue_terminal(data_collection=self._data, dc=self._data, hub=self._hub, session=self.session, application=self, **vars(env)) self._terminal_button.clicked.connect(self._toggle_terminal) except Exception as e: # pylint: disable=W0703 import traceback self._terminal_exception = traceback.format_exc() self._setup_terminal_error_dialog(e) return self._terminal = self.add_widget(widget, label='IPython') self._hide_terminal()
def make_toolbar(self): tb = QtGui.QToolBar(parent=self) tb.setIconSize(QtCore.QSize(25, 25)) tb.layout().setSpacing(1) tb.setFocusPolicy(Qt.StrongFocus) agroup = QtGui.QActionGroup(tb) agroup.setExclusive(True) for (mode_text, mode_icon, mode_cb) in self._mouse_modes(): # TODO: add icons similar to the Matplotlib toolbar action = tb.addAction(mode_icon, mode_text) action.setCheckable(True) action.toggled.connect(mode_cb) agroup.addAction(action) action = tb.addAction(get_icon("glue_move"), "Pan") self.mode_actns["pan"] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb("pan", tf)) agroup.addAction(action) icon = QtGui.QIcon(os.path.join(ginga_icon_dir, "hand_48.png")) action = tb.addAction(icon, "Free Pan") self.mode_actns["freepan"] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb("freepan", tf)) agroup.addAction(action) icon = QtGui.QIcon(os.path.join(ginga_icon_dir, "rotate_48.png")) action = tb.addAction(icon, "Rotate") self.mode_actns["rotate"] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb("rotate", tf)) agroup.addAction(action) action = tb.addAction(get_icon("glue_contrast"), "Contrast") self.mode_actns["contrast"] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb("contrast", tf)) agroup.addAction(action) icon = QtGui.QIcon(os.path.join(ginga_icon_dir, "cuts_48.png")) action = tb.addAction(icon, "Cuts") self.mode_actns["cuts"] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb("cuts", tf)) agroup.addAction(action) cmap_w = _colormap_mode(self, self.client.set_cmap) tb.addWidget(cmap_w) return tb
def make_toolbar(self): tb = QtWidgets.QToolBar(parent=self) tb.setIconSize(QtCore.QSize(25, 25)) tb.layout().setSpacing(1) tb.setFocusPolicy(Qt.StrongFocus) agroup = QtWidgets.QActionGroup(tb) agroup.setExclusive(True) for (mode_text, mode_icon, mode_cb) in self._mouse_modes(): # TODO: add icons similar to the Matplotlib toolbar action = tb.addAction(mode_icon, mode_text) action.setCheckable(True) action.toggled.connect(mode_cb) agroup.addAction(action) action = tb.addAction(get_icon('glue_move'), "Pan") self.mode_actns['pan'] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb('pan', tf)) agroup.addAction(action) icon = QtGui.QIcon(os.path.join(ginga_icon_dir, 'hand_48.png')) action = tb.addAction(icon, "Free Pan") self.mode_actns['freepan'] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb('freepan', tf)) agroup.addAction(action) icon = QtGui.QIcon(os.path.join(ginga_icon_dir, 'rotate_48.png')) action = tb.addAction(icon, "Rotate") self.mode_actns['rotate'] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb('rotate', tf)) agroup.addAction(action) action = tb.addAction(get_icon('glue_contrast'), "Contrast") self.mode_actns['contrast'] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb('contrast', tf)) agroup.addAction(action) icon = QtGui.QIcon(os.path.join(ginga_icon_dir, 'cuts_48.png')) action = tb.addAction(icon, "Cuts") self.mode_actns['cuts'] = action action.setCheckable(True) action.toggled.connect(lambda tf: self.mode_cb('cuts', tf)) agroup.addAction(action) cmap_w = _colormap_mode(self, self.client.set_cmap) tb.addWidget(cmap_w) return tb
def __init__(self, axes, **kwargs): super(VRangeMode, self).__init__(axes, **kwargs) self.icon = get_icon('glue_yrange_select') self.mode_id = 'Y range' self.action_text = 'Y range' self.tool_tip = 'Select a range of y values' self._roi_tool = qt_roi.QtYRangeROI(self._axes) self.shortcut = 'V'
def __init__(self, viewer, toolbar=None): super(ZoomTool, self).__init__(viewer=viewer) self.tool_id = 'mpl:zoom' self.icon = get_icon('glue_zoom_to_rect') self.action_text = 'Zoom' self.tool_tip = 'Zoom to rectangle' self.shortcut = 'Z' self.toolbar = toolbar
def __init__(self, axes, **kwargs): super(PickMode, self).__init__(axes, **kwargs) self.icon = get_icon('glue_yrange_select') self.mode_id = 'Pick' self.action_text = 'Pick' self.tool_tip = 'Select a single item' self._roi_tool = roi.MplPickROI(self._axes) self.shortcut = 'K'
def __init__(self, viewer, toolbar=None): super(PanTool, self).__init__(viewer=viewer) self.tool_id = 'mpl:pan' self.icon = get_icon('glue_move') self.action_text = 'Pan' self.tool_tip = 'Pan axes with left mouse, zoom with right' self.shortcut = 'M' self.toolbar = toolbar
def __init__(self, viewer, toolbar=None): super(SaveTool, self).__init__(viewer=viewer) self.tool_id = 'mpl:save' self.icon = get_icon('glue_filesave') self.action_text = 'Save' self.tool_tip = 'Save the figure' self.shortcut = 'Ctrl+Shift+S' self.toolbar = toolbar
def __init__(self, axes, **kwargs): super(LassoMode, self).__init__(axes, **kwargs) self.icon = get_icon('glue_lasso') self.mode_id = 'Lasso' self.action_text = 'Polygonal ROI' self.tool_tip = 'Lasso a region of interest' self._roi_tool = qt_roi.QtPolygonalROI(self._axes) self.shortcut = 'L'
def __init__(self, axes, **kwargs): super(CircleMode, self).__init__(axes, **kwargs) self.icon = get_icon('glue_circle') self.mode_id = 'Circle' self.action_text = 'Circular ROI' self.tool_tip = 'Define a circular region of interest' self._roi_tool = qt_roi.QtCircularROI(self._axes) self.shortcut = 'C'
def __init__(self, axes, **kwargs): super(RectangleMode, self).__init__(axes, **kwargs) self.icon = get_icon('glue_square') self.mode_id = 'Rectangle' self.action_text = 'Rectangular ROI' self.tool_tip = 'Define a rectangular region of interest' self._roi_tool = qt_roi.QtRectangularROI(self._axes) self.shortcut = 'R'
def __init__(self, axes, **kwargs): super(SpectrumExtractorMode, self).__init__(axes, **kwargs) self.icon = get_icon('glue_spectrum') self.mode_id = 'Spectrum' self.action_text = 'Spectrum' self.tool_tip = 'Extract a spectrum from the selection' self._roi_tool = qt_roi.QtRectangularROI(self._axes) # default self.shortcut = 'S'
def action(name, parent, tip='', icon=None, shortcut=None): """ Factory for making a new action """ a = QtGui.QAction(name, parent) a.setToolTip(tip) if icon: a.setIcon(get_icon(icon)) if shortcut: a.setShortcut(shortcut) return a
def __init__(self, viewer, toolbar=None): super(HomeTool, self).__init__(viewer=viewer) self.tool_id = 'mpl:home' self.icon = get_icon('glue_home') self.action_text = 'Home' self.tool_tip = 'Reset original zoom' self.shortcut = 'H' self.checkable = False self.toolbar = toolbar
def action(name, parent, tip='', icon=None, shortcut=None): """ Factory for making a new action """ a = QtWidgets.QAction(name, parent) a.setToolTip(tip) if icon: a.setIcon(get_icon(icon)) if shortcut: a.setShortcut(shortcut) return a
def __init__(self, data_collection=None, session=None): # At this point we need to check if a Qt application already exists - # this happens for example if using the %gui qt/qt5 mode in Jupyter. We # should keep a reference to the original icon so that we can restore it # later self._original_app = QtWidgets.QApplication.instance() if self._original_app is not None: self._original_icon = self._original_app.windowIcon() self._export_helper = ExportHelper(self) self._import_helper = ImportHelper(self) # Now we can get the application instance, which involves setting it # up if it doesn't already exist. self.app = get_qapp() QtWidgets.QMainWindow.__init__(self) Application.__init__(self, data_collection=data_collection, session=session) # Pull in any keybindings from an external file self.keybindings = keyboard_shortcut icon = get_icon('app_icon') self.app.setWindowIcon(icon) # Even though we loaded the plugins in start_glue, we re-load them here # in case glue was started directly by initializing this class. load_plugins(require_qt_plugins=True) self.setWindowTitle("Glue") self.setWindowIcon(icon) self.setAttribute(Qt.WA_DeleteOnClose) self._actions = {} self._terminal = None self._setup_ui() self.tab_widget.setMovable(True) self.tab_widget.setTabsClosable(True) # The following is a counter that never goes down, even if tabs are # deleted (this is by design, to avoid having two tabs called the # same if a tab is removed then a new one added again) self._total_tab_count = 0 lwidget = self._layer_widget a = PlotAction(lwidget, self) lwidget.ui.layerTree.addAction(a) self._tweak_geometry() self._create_actions() self._create_menu() self._connect() self.new_tab() self._update_viewer_in_focus()
def __init__(self, axes, **kwargs): super(PolyMode, self).__init__(axes, **kwargs) self.icon = get_icon('glue_lasso') self.mode_id = 'Polygon' self.action_text = 'Polygonal ROI' self.tool_tip = ('Lasso a region of interest\n' ' ENTER accepts the path\n' ' ESCAPE clears the path') self._roi_tool = qt_roi.QtPolygonalROI(self._axes) self.shortcut = 'G'
def __init__(self, data_collection=None, session=None): # At this point we need to check if a Qt application already exists - # this happens for example if using the %gui qt/qt5 mode in Jupyter. We # should keep a reference to the original icon so that we can restore it # later self._original_app = QtWidgets.QApplication.instance() if self._original_app is not None: self._original_icon = self._original_app.windowIcon() self._export_helper = ExportHelper(self) self._import_helper = ImportHelper(self) # Now we can get the application instance, which involves setting it # up if it doesn't already exist. self.app = get_qapp() QtWidgets.QMainWindow.__init__(self) Application.__init__(self, data_collection=data_collection, session=session) # Pull in any keybindings from an external file self.keybindings = keyboard_shortcut icon = get_icon('app_icon') self.app.setWindowIcon(icon) # Even though we loaded the plugins in start_glue, we re-load them here # in case glue was started directly by initializing this class. load_plugins() self.setWindowTitle("Glue") self.setWindowIcon(icon) self.setAttribute(Qt.WA_DeleteOnClose) self._actions = {} self._terminal = None self._setup_ui() self.tab_widget.setMovable(True) self.tab_widget.setTabsClosable(True) # The following is a counter that never goes down, even if tabs are # deleted (this is by design, to avoid having two tabs called the # same if a tab is removed then a new one added again) self._total_tab_count = 0 lwidget = self._layer_widget a = PlotAction(lwidget, self) lwidget.ui.layerTree.addAction(a) self._tweak_geometry() self._create_actions() self._create_menu() self._connect() self.new_tab() self._update_viewer_in_focus()
def __init__(self, axes, **kwargs): super(SpectrumExtractorMode, self).__init__(axes, **kwargs) self.icon = get_icon('glue_spectrum') self.mode_id = 'Spectrum' self.action_text = 'Spectrum' self.tool_tip = 'Extract a spectrum from the selection' self._roi_tool = qt_roi.QtRectangularROI(self._axes) self._roi_tool.plot_opts.update(edgecolor='#c51b7d', facecolor=None, edgewidth=3, alpha=1.0) self.shortcut = 'S'
def __init__(self, parent=None): super(LayerTreeWidget, self).__init__(parent) self.ui = load_ui('layer_tree_widget.ui', None, directory=os.path.dirname(__file__)) self.setCentralWidget(self.ui) self.ui.layerAddButton.setIcon(get_icon('glue_open')) self.ui.layerRemoveButton.setIcon(get_icon('glue_delete')) self._signals = LayerCommunicator() self._is_checkable = True self._layer_check_changed = self._signals.layer_check_changed self._layer_dict = {} self._actions = {} self._create_actions() self._connect() self._data_collection = None self._hub = None self.ui.layerTree.setDragEnabled(True)
def _init_toolbar(self): self.basedir = os.path.join(matplotlib.rcParams['datapath'], 'images') parent = QtGui.QToolBar.parent(self) a = QtGui.QAction(get_icon('glue_home'), 'Home', parent) a.triggered.connect(nonpartial(self.home)) a.setToolTip('Reset original zoom') a.setShortcut('H') a.setShortcutContext(Qt.WidgetShortcut) parent.addAction(a) self.buttons['HOME'] = a self.addAction(a) a = QtGui.QAction(get_icon('glue_filesave'), 'Save', parent) a.triggered.connect(nonpartial(self.save_figure)) a.setToolTip('Save the figure') a.setShortcut('Ctrl+Shift+S') parent.addAction(a) self.buttons['SAVE'] = a self.addAction(a) a = QtGui.QAction(get_icon('glue_back'), 'Back', parent) a.triggered.connect(nonpartial(self.back)) parent.addAction(a) self.addAction(a) self.buttons['BACK'] = a a.setToolTip('Back to previous view') a = QtGui.QAction(get_icon('glue_forward'), 'Forward', parent) a.triggered.connect(nonpartial(self.forward)) a.setToolTip('Forward to next view') parent.addAction(a) self.buttons['FORWARD'] = a self.addAction(a) a = QtGui.QAction(get_icon('glue_move'), 'Pan', parent) a.triggered.connect(nonpartial(self.pan)) a.setToolTip('Pan axes with left mouse, zoom with right') a.setCheckable(True) a.setShortcut('M') a.setShortcutContext(Qt.WidgetShortcut) parent.addAction(a) self.addAction(a) self.buttons['PAN'] = a a = QtGui.QAction(get_icon('glue_zoom_to_rect'), 'Zoom', parent) a.triggered.connect(nonpartial(self.zoom)) a.setToolTip('Zoom to rectangle') a.setShortcut('Z') a.setShortcutContext(Qt.WidgetShortcut) a.setCheckable(True) parent.addAction(a) self.addAction(a) self.buttons['ZOOM'] = a
def menu(self): m = QtWidgets.QMenu() a = QtWidgets.QAction("Or", m) a.setIcon(get_icon('glue_or')) a.triggered.connect(nonpartial(self._paste, OrMode)) m.addAction(a) a = QtWidgets.QAction("And", m) a.setIcon(get_icon('glue_and')) a.triggered.connect(nonpartial(self._paste, AndMode)) m.addAction(a) a = QtWidgets.QAction("XOR", m) a.setIcon(get_icon('glue_xor')) a.triggered.connect(nonpartial(self._paste, XorMode)) m.addAction(a) a = QtWidgets.QAction("Not", m) a.setIcon(get_icon('glue_andnot')) a.triggered.connect(nonpartial(self._paste, AndNotMode)) m.addAction(a) return m
def menu(self): m = QtGui.QMenu() a = QtGui.QAction("Or", m) a.setIcon(get_icon('glue_or')) a.triggered.connect(nonpartial(self._paste, OrMode)) m.addAction(a) a = QtGui.QAction("And", m) a.setIcon(get_icon('glue_and')) a.triggered.connect(nonpartial(self._paste, AndMode)) m.addAction(a) a = QtGui.QAction("XOR", m) a.setIcon(get_icon('glue_xor')) a.triggered.connect(nonpartial(self._paste, XorMode)) m.addAction(a) a = QtGui.QAction("Not", m) a.setIcon(get_icon('glue_andnot')) a.triggered.connect(nonpartial(self._paste, AndNotMode)) m.addAction(a) return m
def __init__(self, axes, **kwargs): super(PathMode, self).__init__(axes, **kwargs) self.icon = get_icon('glue_slice') self.mode_id = 'Slice' self.action_text = 'Slice Extraction' self.tool_tip = ('Extract a slice from an arbitrary path\n' ' ENTER accepts the path\n' ' ESCAPE clears the path') self._roi_tool = qt_roi.QtPathROI(self._axes) self.shortcut = 'P' self._roi_tool.plot_opts.update(edgecolor='#de2d26', facecolor=None, edgewidth=3, alpha=0.4)
def __init__(self, layer_tree_widget): self._parent = layer_tree_widget.layerTree super(LayerAction, self).__init__(self._title.title(), self._parent) self._layer_tree = layer_tree_widget if self._icon: self.setIcon(get_icon(self._icon)) if self._tooltip: self.setToolTip(self._tooltip) self.setEnabled(self._enabled_on_init) if self._shortcut_context is not None: self.setShortcutContext(self._shortcut_context) if self._shortcut: self.setShortcut(self._shortcut) self._parent.addAction(self) self._connect()
def __init__(self, layer_tree_widget): self._parent = layer_tree_widget.ui.layerTree super(LayerAction, self).__init__(self._title.title(), self._parent) self._layer_tree = layer_tree_widget if self._icon: self.setIcon(get_icon(self._icon)) if self._tooltip: self.setToolTip(self._tooltip) self.setEnabled(self._enabled_on_init) if self._shortcut_context is not None: self.setShortcutContext(self._shortcut_context) if self._shortcut: self.setShortcut(self._shortcut) self._parent.addAction(self) self._connect()
def _init_toolbar(self): self.basedir = os.path.join(matplotlib.rcParams['datapath'], 'images') parent = QtWidgets.QToolBar.parent(self) a = QtWidgets.QAction(get_icon('glue_home'), 'Home', parent) a.triggered.connect(nonpartial(self.home)) a.setToolTip('Reset original zoom') a.setShortcut('H') a.setShortcutContext(Qt.WidgetShortcut) parent.addAction(a) self.buttons['HOME'] = a self.addAction(a) a = QtWidgets.QAction(get_icon('glue_filesave'), 'Save', parent) a.triggered.connect(nonpartial(self.save_figure)) a.setToolTip('Save the figure') a.setShortcut('Ctrl+Shift+S') parent.addAction(a) self.buttons['SAVE'] = a self.addAction(a) a = QtWidgets.QAction(get_icon('glue_back'), 'Back', parent) a.triggered.connect(nonpartial(self.back)) parent.addAction(a) self.addAction(a) self.buttons['BACK'] = a a.setToolTip('Back to previous view') a = QtWidgets.QAction(get_icon('glue_forward'), 'Forward', parent) a.triggered.connect(nonpartial(self.forward)) a.setToolTip('Forward to next view') parent.addAction(a) self.buttons['FORWARD'] = a self.addAction(a) a = QtWidgets.QAction(get_icon('glue_move'), 'Pan', parent) a.triggered.connect(nonpartial(self.pan)) a.setToolTip('Pan axes with left mouse, zoom with right') a.setCheckable(True) a.setShortcut('M') a.setShortcutContext(Qt.WidgetShortcut) parent.addAction(a) self.addAction(a) self.buttons['PAN'] = a a = QtWidgets.QAction(get_icon('glue_zoom_to_rect'), 'Zoom', parent) a.triggered.connect(nonpartial(self.zoom)) a.setToolTip('Zoom to rectangle') a.setShortcut('Z') a.setShortcutContext(Qt.WidgetShortcut) a.setCheckable(True) parent.addAction(a) self.addAction(a) self.buttons['ZOOM'] = a
def __init__(self, *args, **kwargs): super(ContrastMode, self).__init__(*args, **kwargs) self.icon = get_icon('glue_contrast') self.mode_id = 'Contrast' self.action_text = 'Contrast' self.tool_tip = 'Adjust the bias/contrast' self.shortcut = 'B' self.bias = 0.5 self.contrast = 1.0 self._last = None self._result = None self._percent_lo = 1. self._percent_hi = 99. self.stretch = 'linear' self._vmin = None self._vmax = None
def __init__(self, data_collection=None, session=None): self.app = get_qapp() QtGui.QMainWindow.__init__(self) Application.__init__(self, data_collection=data_collection, session=session) self.app.setQuitOnLastWindowClosed(True) icon = get_icon('app_icon') self.app.setWindowIcon(icon) # Even though we loaded the plugins in start_glue, we re-load them here # in case glue was started directly by initializing this class. load_plugins() self.setWindowTitle("Glue") self.setWindowIcon(icon) self.setAttribute(Qt.WA_DeleteOnClose) self._actions = {} self._terminal = None self._setup_ui() self.tab_widget.setMovable(True) self.tab_widget.setTabsClosable(True) # The following is a counter that never goes down, even if tabs are # deleted (this is by design, to avoid having two tabs called the # same if a tab is removed then a new one added again) self._total_tab_count = 0 lwidget = self._layer_widget a = PlotAction(lwidget, self) lwidget.ui.layerTree.addAction(a) lwidget.bind_selection_to_edit_subset() self._tweak_geometry() self._create_actions() self._create_menu() self._connect() self.new_tab() self._update_plot_dashboard(None) self._load_settings()
def __init__(self, data_collection=None, session=None): self.app = get_qapp() QtGui.QMainWindow.__init__(self) Application.__init__(self, data_collection=data_collection, session=session) self.app.setQuitOnLastWindowClosed(True) icon = get_icon('app_icon') self.app.setWindowIcon(icon) # Even though we loaded the plugins in start_glue, we re-load them here # in case glue was started directly by initializing this class. load_plugins() self.setWindowTitle("Glue") self.setWindowIcon(icon) self.setAttribute(Qt.WA_DeleteOnClose) self._actions = {} self._terminal = None self._setup_ui() self.tab_widget.setMovable(True) self.tab_widget.setTabsClosable(True) # The following is a counter that never goes down, even if tabs are # deleted (this is by design, to avoid having two tabs called the # same if a tab is removed then a new one added again) self._total_tab_count = 0 lwidget = self._layer_widget a = PlotAction(lwidget, self) lwidget.ui.layerTree.addAction(a) lwidget.bind_selection_to_edit_subset() self._tweak_geometry() self._create_actions() self._create_menu() self._connect() self.new_tab() self._update_plot_dashboard(None)
def _colormap_mode(parent, on_trigger): from glue import config # actions for each colormap acts = [] for label, cmap in config.colormaps: a = ColormapAction(label, cmap, parent) a.triggered.connect(nonpartial(on_trigger, cmap)) acts.append(a) # Toolbar button tb = QtGui.QToolButton() tb.setWhatsThis("Set color scale") tb.setToolTip("Set color scale") icon = get_icon('glue_rainbow') tb.setIcon(icon) tb.setPopupMode(QtGui.QToolButton.InstantPopup) tb.addActions(acts) return tb
def _colormap_mode(parent, on_trigger): # actions for each colormap acts = [] # for label, cmap in config.colormaps: for label in ginga_cmap.get_names(): cmap = ginga_cmap.get_cmap(label) a = ColormapAction(label, cmap, parent) a.triggered.connect(nonpartial(on_trigger, cmap)) acts.append(a) # Toolbar button tb = QtWidgets.QToolButton() tb.setWhatsThis("Set color scale") tb.setToolTip("Set color scale") icon = get_icon('glue_rainbow') tb.setIcon(icon) tb.setPopupMode(QtWidgets.QToolButton.InstantPopup) tb.addActions(acts) return tb