Esempio n. 1
0
    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()
Esempio n. 2
0
    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()
Esempio n. 3
0
    def __init__(self, data_collection=None, session=None):

        QMainWindow.__init__(self)
        Application.__init__(self,
                             data_collection=data_collection,
                             session=session)

        self.app = get_qapp()

        self.ui = loadUi('slicer5.ui', None)
        self.setCentralWidget(self.ui)
        self.resize(1200, 800)

        box1 = QStackedWidget()
        box2 = QStackedWidget()

        class PVSlicerTool(GluePVSlicerTool):

            def _extract_pv_slice(self, mode):
                super(PVSlicerTool, self)._extract_pv_slice(mode)
                box2.setCurrentIndex(1)

        class ImageWidget(GlueImageWidget):

            def _setup_tools(self):
                self._tools = [PVSlicerTool(self)]

        self.box1 = box1
        self.box2 = box2

        self.image = ImageWidget(session=self._session)

        self.slice = PVSliceWidget(image_widget=self.image)

        for tool in self.image._tools:
            if isinstance(tool, PVSlicerTool):
                tool._slice_widget = self.slice

        self.dummy1 = QWidget()
        self.dummy2 = QWidget()

        self.box1.addWidget(self.dummy1)
        self.box1.addWidget(self.image)

        self.box2.addWidget(self.dummy2)
        self.box2.addWidget(self.slice)

        self.ui.data_layout.addWidget(self.box1, stretch=1)
        self.ui.data_layout.addWidget(self.box2, stretch=1)

        self.ui.load_button.clicked.connect(self._load_data)
        self.ui.save_button.clicked.connect(self._save_data)
Esempio n. 4
0
    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)
        pth = os.path.abspath(os.path.dirname(__file__))
        pth = os.path.join(pth, 'icons', 'app_icon.png')
        self.app.setWindowIcon(QtGui.QIcon(pth))

        # 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.setWindowIcon(self.app.windowIcon())
        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._ui.layerWidget
        a = PlotAction(lwidget, self)
        lwidget.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()
Esempio n. 5
0
    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()
Esempio n. 6
0
def test_linking_after_collapse(spectral_cube_wcs):

    app = Application()
    dc = app.data_collection
    dc.append(
        Data(x=np.ones((3, 4, 5)), label='test', coords=spectral_cube_wcs))

    coll = Collapse(app=app)

    coll.selected_data_item = 'test'

    coll.selected_axis = 0
    coll.vue_collapse()

    assert len(dc) == 2
    assert dc[1].label == 'Collapsed test'
    assert len(dc.external_links) == 2

    assert dc.external_links[0].cids1[0] is dc[0].pixel_component_ids[1]
    assert dc.external_links[0].cids2[0] is dc[1].pixel_component_ids[0]
    assert dc.external_links[1].cids1[0] is dc[0].pixel_component_ids[2]
    assert dc.external_links[1].cids2[0] is dc[1].pixel_component_ids[1]

    coll.selected_axis = 1
    coll.vue_collapse()

    assert len(dc) == 2
    assert dc[1].label == 'Collapsed test'
    assert len(dc.external_links) == 2

    assert dc.external_links[0].cids1[0] is dc[0].pixel_component_ids[0]
    assert dc.external_links[0].cids2[0] is dc[1].pixel_component_ids[0]
    assert dc.external_links[1].cids1[0] is dc[0].pixel_component_ids[2]
    assert dc.external_links[1].cids2[0] is dc[1].pixel_component_ids[1]

    coll.selected_axis = 2
    coll.vue_collapse()

    assert len(dc) == 2
    assert dc[1].label == 'Collapsed test'
    assert len(dc.external_links) == 2

    assert dc.external_links[0].cids1[0] is dc[0].pixel_component_ids[0]
    assert dc.external_links[0].cids2[0] is dc[1].pixel_component_ids[0]
    assert dc.external_links[1].cids1[0] is dc[0].pixel_component_ids[1]
    assert dc.external_links[1].cids2[0] is dc[1].pixel_component_ids[1]
Esempio n. 7
0
def test_linking_after_gaussian_smooth(spectral_cube_wcs):

    app = Application()
    dc = app.data_collection
    dc.append(Data(x=np.ones((3, 4, 5)), label='test', coords=spectral_cube_wcs))

    gs = GaussianSmooth(app=app)

    gs._on_data_selected({'new': 'test'})
    gs.stddev = '3.2'
    gs.vue_gaussian_smooth()

    assert len(dc) == 2
    assert dc[1].label == 'Smoothed test'
    assert len(dc.external_links) == 1

    assert dc.external_links[0].cids1[0] is dc[0].pixel_component_ids[0]
    assert dc.external_links[0].cids2[0] is dc[1].pixel_component_ids[0]
Esempio n. 8
0
    def restore_session(path, show=True):
        """
        Reload a previously-saved session

        Parameters
        ----------
        path : str
            Path to the file to load
        show : bool, optional
            If True (the default), immediately show the widget

        Returns
        -------
        app : :class:`glue.app.qt.application.GlueApplication`
            The loaded application
        """
        ga = Application.restore_session(path)
        if show:
            ga.start(block=False)
        return ga
Esempio n. 9
0
    def restore_session(path, show=True):
        """
        Reload a previously-saved session

        Parameters
        ----------
        path : str
            Path to the file to load
        show : bool, optional
            If True (the default), immediately show the widget

        Returns
        -------
        app : :class:`glue.app.qt.application.GlueApplication`
            The loaded application
        """
        ga = Application.restore_session(path)
        if show:
            ga.show()
        return ga
Esempio n. 10
0
def simple_profile(app, data=None):
    viewer = Application.new_data_viewer(app, SimpleBqplotProfileViewer)
    if data is not None:
        viewer.add_data(data)
    return viewer
Esempio n. 11
0
def simple_imshow(app, data=None):
    viewer = Application.new_data_viewer(app, SimpleBqplotImageViewer)
    if data is not None:
        viewer.add_data(data)
    return viewer