예제 #1
0
    def __init__(self, session, parent=None):

        super(ScatterWidget, self).__init__(session, parent)

        self.central_widget = MplWidget()
        self.setCentralWidget(self.central_widget)

        self.option_widget = QtWidgets.QWidget()
        self.ui = load_ui('options_widget.ui',
                          self.option_widget,
                          directory=os.path.dirname(__file__))

        self._tweak_geometry()

        self.client = ScatterClient(
            self._data,
            self.central_widget.canvas.fig,
            layer_artist_container=self._layer_artist_container)

        self._connect()
        self.unique_fields = set()
        tb = self.make_toolbar()
        cache_axes(self.client.axes, tb)
        self.statusBar().setSizeGripEnabled(False)
        self.setFocusPolicy(Qt.StrongFocus)
예제 #2
0
    def __init__(self, session, parent=None):

        super(MatplotlibDataViewer, self).__init__(session, parent)

        # Use MplWidget to set up a Matplotlib canvas inside the Qt window
        self.mpl_widget = MplWidget()
        self.setCentralWidget(self.mpl_widget)

        # TODO: shouldn't have to do this
        self.central_widget = self.mpl_widget

        self.figure, self._axes = init_mpl(self.mpl_widget.canvas.fig)

        # Set up the state which will contain everything needed to represent
        # the current state of the viewer
        self.state = self._state_cls()
        self.state.data_collection = session.data_collection

        # Set up the options widget, which will include options that control the
        # viewer state
        self.options = self._options_cls(viewer_state=self.state,
                                         session=session)

        add_callback(self.state, 'x_min', nonpartial(self.limits_to_mpl))
        add_callback(self.state, 'x_max', nonpartial(self.limits_to_mpl))
        add_callback(self.state, 'y_min', nonpartial(self.limits_to_mpl))
        add_callback(self.state, 'y_max', nonpartial(self.limits_to_mpl))

        self.axes.callbacks.connect('xlim_changed',
                                    nonpartial(self.limits_from_mpl))
        self.axes.callbacks.connect('ylim_changed',
                                    nonpartial(self.limits_from_mpl))

        self.state.add_callback('x_log', nonpartial(self.update_x_log))
        self.state.add_callback('y_log', nonpartial(self.update_y_log))

        self.axes.set_autoscale_on(False)

        # TODO: in future could move the following to a more basic data viewer class

        # When layer artists are removed from the layer artist container, we need
        # to make sure we remove matching layer states in the viewer state
        # layers attribute.
        self._layer_artist_container.on_changed(
            nonpartial(self._sync_state_layers))

        # And vice-versa when layer states are removed from the viewer state, we
        # need to keep the layer_artist_container in sync
        self.state.add_callback('layers',
                                nonpartial(self._sync_layer_artist_container))
예제 #3
0
    def __init__(self, session, parent=None):
        super(CustomWidgetBase, self).__init__(session, parent)
        self.central_widget = MplWidget()
        self.setCentralWidget(self.central_widget)

        self._build_coordinator()
        self.option_widget = self._build_ui()
        self.client = CustomClient(self._data,
                                   self.central_widget.canvas.fig,
                                   layer_artist_container=self._layer_artist_container,
                                   coordinator=self._coordinator)

        self.make_toolbar()
        self.statusBar().setSizeGripEnabled(False)
        self._update_artists = []
        self.settings_changed()
예제 #4
0
    def _build_main_widget(self):
        self.widget = SpectrumMainWindow()
        self.widget.window_closed.connect(self.reset)

        w = QtGui.QWidget()
        l = QtGui.QHBoxLayout()
        l.setSpacing(2)
        l.setContentsMargins(2, 2, 2, 2)
        w.setLayout(l)

        mpl = MplWidget()
        self.canvas = mpl.canvas
        l.addWidget(mpl)
        l.setStretchFactor(mpl, 5)

        self.widget.setCentralWidget(w)
예제 #5
0
    def __init__(self, session, parent=None):
        super(HistogramWidget, self).__init__(session, parent)

        self.central_widget = MplWidget()
        self.setCentralWidget(self.central_widget)
        self.option_widget = QtGui.QWidget()
        self.ui = load_ui('options_widget.ui', self.option_widget,
                          directory=os.path.dirname(__file__))
        self._tweak_geometry()
        self.client = HistogramClient(self._data,
                                      self.central_widget.canvas.fig,
                                      layer_artist_container=self._layer_artist_container)
        self._init_limits()
        self.make_toolbar()
        self._connect()
        # maps _hash(componentID) -> componentID
        self._component_hashes = {}
예제 #6
0
    def __init__(self, session, parent=None):
        super(DendroWidget, self).__init__(session, parent)

        self.central_widget = MplWidget()
        self.option_widget = QtWidgets.QWidget()
        self.setCentralWidget(self.central_widget)

        self.ui = load_ui('options_widget.ui',
                          self.option_widget,
                          directory=os.path.dirname(__file__))
        self.client = DendroClient(
            self._data,
            self.central_widget.canvas.fig,
            layer_artist_container=self._layer_artist_container)

        self._connect()

        self.statusBar().setSizeGripEnabled(False)
예제 #7
0
    def __init__(self, image=None, wcs=None, parent=None, **kwargs):
        """
        :param image: Image to display (2D numpy array)
        :param parent: Parent widget (optional)

        :param kwargs: Extra keywords to pass to imshow
        """
        super(StandaloneImageWidget, self).__init__(parent)
        self.central_widget = MplWidget()
        self.setCentralWidget(self.central_widget)
        self._setup_axes()

        self._im = None
        self._norm = DS9Normalize()

        self.make_toolbar()

        if image is not None:
            self.set_image(image=image, wcs=wcs, **kwargs)
예제 #8
0
    def __init__(self, session, parent=None):

        super(ScatterViewer, self).__init__(session, parent)

        # Use MplWidget to set up a Matplotlib canvas inside the Qt window
        self.mpl_widget = MplWidget()
        self._axes = self.mpl_widget.canvas.figure.add_subplot(1, 1, 1)
        self._axes.set_xlim(-10, 10)
        self._axes.set_ylim(-10, 10)
        self.setCentralWidget(self.mpl_widget)

        # Set up the state which will contain everything needed to represent
        # the current state of the viewer
        self.viewer_state = ScatterViewerState()

        # Set up the options widget, which will include options that control the
        # viewer state
        self.options = ScatterOptionsWidget(viewer_state=self.viewer_state,
                                            session=session)

        self.viewer_state.connect_all(self.update)
예제 #9
0
 def make_central_widget(self):
     return MplWidget()
예제 #10
0
 def __init__(self, session, parent=None):
     super(ExampleViewer, self).__init__(session, parent=parent)
     self.central_widget = MplWidget(parent)
     self._axes = self.central_widget.canvas.fig.add_subplot(111)
     self._axes.plot([1, 2, 3])[0]
     self.setCentralWidget(self.central_widget)
예제 #11
0
파일: test_toolbar.py 프로젝트: omad/glue
 def _make_plot_widget(self, parent):
     widget = MplWidget(parent)
     ax = widget.canvas.fig.add_subplot(111)
     p = ax.plot([1, 2, 3])[0]
     return widget, ax