示例#1
0
def demo(name):
    """
    Demo instructions (from original, demo changed since them)

    The list on the right of the plot shows the components of the model.
    Click on one to set it as the "active model", which can be tweaked by
    mouse interaction.

    Left click/dragging will adjust the amplitude and mean of the active model
    Right click/dragging will adjust the width

    You can add and delete models, as well as fit them
    (using the current values as a seed)

    Next steps:
    -----------

    Explore whether other mouse/keyboard gestures are better for tweaking parameters.
    Make the UI binding configurable
    Display and edit information about bounds, tied, fixed, etc
    Show and use errors
    """
    x, y = demo_data[name]

    #    _models = [models.Const1D(0), models.Gaussian1D(3, 1, .3), models.Gaussian1D(3, 2, .3)]
    #     _models = [models.Const1D(0)]
    _models = None

    mv = ModelBrowser(x, y, y * 0, _models)

    mv.show()

    from glue.qt import get_qapp
    get_qapp().exec_()
示例#2
0
def demo(name):
    """
    Demo instructions (from original, demo changed since them)

    The list on the right of the plot shows the components of the model.
    Click on one to set it as the "active model", which can be tweaked by
    mouse interaction.

    Left click/dragging will adjust the amplitude and mean of the active model
    Right click/dragging will adjust the width

    You can add and delete models, as well as fit them
    (using the current values as a seed)

    Next steps:
    -----------

    Explore whether other mouse/keyboard gestures are better for tweaking parameters.
    Make the UI binding configurable
    Display and edit information about bounds, tied, fixed, etc
    Show and use errors
    """
    x, y = demo_data[name]

#    _models = [models.Const1D(0), models.Gaussian1D(3, 1, .3), models.Gaussian1D(3, 2, .3)]
#     _models = [models.Const1D(0)]
    _models = None

    mv = ModelBrowser(x, y, y * 0, _models)

    mv.show()

    from glue.qt import get_qapp
    get_qapp().exec_()
示例#3
0
 def new_client(self, dc=None, canvas=None):
     from glue.qt import get_qapp
     get_qapp()
     dc = dc or self.collect
     l = log.get_logger(name='ginga', log_stderr=True)
     canvas = ImageViewCanvas(l, render='widget')
     return GingaClient(dc, canvas)
示例#4
0
文件: mouse_mode.py 项目: antonl/glue
    def __init__(self, axes, **kwargs):
        super(RoiMode, self).__init__(axes, **kwargs)

        self._start_event = None
        self._drag = False
        app = get_qapp()
        self._drag_dist = app.startDragDistance()
示例#5
0
文件: decorators.py 项目: antonl/glue
 def result(*args, **kwargs):
     from glue.qt import get_qapp
     app = get_qapp()
     app.setOverrideCursor(shape)
     try:
         return func(*args, **kwargs)
     finally:
         app.restoreOverrideCursor()
示例#6
0
def test_main():

    app = get_qapp()

    w = QMessageBox(QMessageBox.Critical, "Error", "An error occurred")
    w.setDetailedText("Spam")
    w.select_all()
    w.copy_detailed()

    assert app.clipboard().text() == "Spam"

    app.quit()
示例#7
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)
示例#8
0
def main():

    from glue.core import Data, DataCollection
    from glue.qt import get_qapp
    import numpy as np

    app = get_qapp()

    d = Data(label="data", _RAJ2000=np.random.random((100)) + 0,
             _DEJ2000=np.random.random((100)) + 85)
    dc = DataCollection([d])

    wwt = WWTDataViewer(dc)
    wwt.show()
    app.exec_()
示例#9
0
def main():

    from glue.core import Data, DataCollection
    from glue.qt import get_qapp
    import numpy as np

    app = get_qapp()

    d = Data(label="data",
             _RAJ2000=np.random.random((100)) + 0,
             _DEJ2000=np.random.random((100)) + 85)
    dc = DataCollection([d])

    wwt = WWTDataViewer(dc)
    wwt.show()
    app.exec_()
示例#10
0
def main():
    from glue.core import Data, DataCollection
    from glue.qt import get_qapp
    import numpy as np

    app = get_qapp()

    sz = 10**5
    x = np.random.normal(0, 1, sz)
    y = np.random.random(sz)
    d = Data(x=x, y=y)
    dc = DataCollection([d])

    tw = TableWidget(dc)
    tw.set_data(d)

    tw.show()

    app.exec_()
示例#11
0
def main():
    from glue.core import Data, DataCollection
    from glue.qt import get_qapp
    import numpy as np

    app = get_qapp()

    sz = 10 ** 5
    x = np.random.normal(0, 1, sz)
    y = np.random.random(sz)
    d = Data(x=x, y=y)
    dc = DataCollection([d])

    tw = TableWidget(dc)
    tw.set_data(d)

    tw.show()

    app.exec_()
示例#12
0
def main():
    from glue.core import Data, DataCollection
    from glue.qt import get_qapp
    app = get_qapp()

    d = Data(label='d1', x=[1, 2, 3], y=[2, 3, 4])
    d2 = Data(label='d2', z=[1, 2, 3], w=[2, 3, 4])

    dc = DataCollection([d, d2])
    SubsetFacet.facet(dc)

    print 'd1 subsets'
    for s in d.subsets:
        print s.label, s.subset_state, s.style.color

    print 'd2 subsets'
    for s in d2.subsets:
        print s.label, s.subset_state, s.style.color

    del app
示例#13
0
def main():
    from glue.core import Data, DataCollection
    from glue.qt import get_qapp
    app = get_qapp()

    d = Data(label='d1', x=[1, 2, 3], y=[2, 3, 4])
    d2 = Data(label='d2', z=[1, 2, 3], w=[2, 3, 4])

    dc = DataCollection([d, d2])
    SubsetFacet.facet(dc)

    print 'd1 subsets'
    for s in d.subsets:
        print s.label, s.subset_state, s.style.color

    print 'd2 subsets'
    for s in d2.subsets:
        print s.label, s.subset_state, s.style.color

    del app
示例#14
0
    def __init__(self, data_collection=None, session=None):
        QtGui.QMainWindow.__init__(self)
        Application.__init__(self, data_collection=data_collection,
                             session=session)

        self.app = get_qapp()
        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()
示例#15
0
    def __init__(self, session, parent=None):
        """
        :type session: :class:`~glue.core.Session`
        """
        QtGui.QMainWindow.__init__(self, parent)
        ViewerBase.__init__(self, session)
        self.setWindowIcon(get_qapp().windowIcon())
        self._view = LayerArtistView()
        self._view.setModel(self._layer_artist_container.model)
        self._tb_vis = {}  # store whether toolbars are enabled
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setAcceptDrops(True)
        self.setAnimated(False)
        self._toolbars = []
        self._warn_close = True
        self.setContentsMargins(2, 2, 2, 2)
        self._mdi_wrapper = None  # GlueMdiSubWindow that self is embedded in
        self.statusBar().setStyleSheet("QStatusBar{font-size:10px}")

        # close window when last plot layer deleted
        self._layer_artist_container.on_empty(lambda: self.close(warn=False))
        self._layer_artist_container.on_changed(self.update_window_title)
示例#16
0
def main():  # pragma: no cover
    import glue
    import numpy as np
    from glue.qt import get_qapp

    d = glue.core.Data(label="hi")
    d2 = glue.core.Data(label="there")

    c1 = glue.core.Component(np.array([1, 2, 3]))
    c2 = glue.core.Component(np.array([1, 2, 3]))
    c3 = glue.core.Component(np.array([1, 2, 3]))

    dc = glue.core.DataCollection()
    dc.append(d)
    dc.append(d2)
    d.add_component(c1, "a")
    d.add_component(c2, "b")
    d2.add_component(c3, "c")

    app = get_qapp()
    w = ComponentSelector()
    w.setup(dc)
    w.show()
    app.exec_()
示例#17
0

if __name__ == "__main__":
    from glue.qt import get_qapp

    class Foo(object):
        layer_visible = {}
        layer = None

        def update(self):
            print('update', self.layer_visible)

        def redraw(self):
            print('draw')

    app = get_qapp()
    f = Foo()

    rgb = RGBEdit()
    rgb.show()
    app.exec_()

    print(f.layer_visible)
    print(f.contrast_layer)


class Worker(QThread):
    result = Signal(object)
    error = Signal(object)

    def __init__(self, func, *args, **kwargs):
示例#18
0
文件: qtutil.py 项目: borkin/glue

if __name__ == "__main__":
    from glue.qt import get_qapp

    class Foo(object):
        layer_visible = {}
        layer = None

        def update(self):
            print('update', self.layer_visible)

        def redraw(self):
            print('draw')

    app = get_qapp()
    f = Foo()

    rgb = RGBEdit()
    rgb.show()
    app.exec_()

    print(f.layer_visible)
    print(f.contrast_layer)


class Worker(QThread):
    result = Signal(object)
    error = Signal(object)

    def __init__(self, func, *args, **kwargs):