示例#1
0
        if changed:
            self.colors_changed.emit()

        self.artist.update()
        self.artist.redraw()

    def update_current(self, *args):
        if self.artist is None:
            return

        for c in ['red', 'green', 'blue']:
            if self.current[c].isChecked():
                self.artist.contrast_layer = c
                self.current_changed.emit(c)
                break
        else:
            raise RuntimeError("Could not determine which layer is current")

    def update_visible(self, *args):
        if self.artist is None:
            return

        self.artist.layer_visible['red'] = self.vis['red'].isChecked()
        self.artist.layer_visible['green'] = self.vis['green'].isChecked()
        self.artist.layer_visible['blue'] = self.vis['blue'].isChecked()
        self.artist.update()
        self.artist.redraw()


CUSTOM_QWIDGETS.append(RGBEdit)
示例#2
0
from __future__ import absolute_import, division, print_function

from glue.external.qt.QtCore import Qt
from glue.external.qt import QtGui, QtCore
from glue.icons.qt import POINT_ICONS, symbol_icon
from glue.utils.qt import mpl_to_qt4_color, qt4_to_mpl_color, CUSTOM_QWIDGETS


class ColorWidget(QtGui.QLabel):
    mousePressed = QtCore.Signal()

    def mousePressEvent(self, event):
        self.mousePressed.emit()
        event.accept()

CUSTOM_QWIDGETS.append(ColorWidget)


class StyleDialog(QtGui.QDialog):

    """Dialog which edits the style of a layer (Data or Subset)

    Use via StyleDialog.edit_style(layer)
    """

    def __init__(self, layer, parent=None, edit_label=True):
        super(StyleDialog, self).__init__(parent)
        self.setWindowTitle("Style Editor")
        self.layer = layer
        self._edit_label = edit_label
        self._symbols = list(POINT_ICONS.keys())
示例#3
0
文件: style_dialog.py 项目: omad/glue
from qtpy.QtCore import Qt
from qtpy import QtCore, QtWidgets
from glue.icons.qt import POINT_ICONS, symbol_icon
from glue.utils.qt import mpl_to_qt4_color, qt4_to_mpl_color, CUSTOM_QWIDGETS


class ColorWidget(QtWidgets.QLabel):
    mousePressed = QtCore.Signal()

    def mousePressEvent(self, event):
        self.mousePressed.emit()
        event.accept()


CUSTOM_QWIDGETS.append(ColorWidget)


class StyleDialog(QtWidgets.QDialog):
    """Dialog which edits the style of a layer (Data or Subset)

    Use via StyleDialog.edit_style(layer)
    """
    def __init__(self, layer, parent=None, edit_label=True):
        super(StyleDialog, self).__init__(parent)
        self.setWindowTitle("Style Editor")
        self.layer = layer
        self._edit_label = edit_label
        self._symbols = list(POINT_ICONS.keys())

        self._setup_widgets()
示例#4
0
        index = self._ui.data_selector.currentIndex()
        if index < 0:
            return
        return self._data[index]

    @data.setter
    def data(self, value):
        for i, d in enumerate(self._data):
            if d is value:
                self._ui.data_selector.setCurrentIndex(i)
                return
        else:
            raise ValueError("Data is not part of the DataCollection")


CUSTOM_QWIDGETS.append(ComponentSelector)


def main():  # pragma: no cover
    import glue
    import numpy as np
    from glue.external.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()
示例#5
0
        index = self._ui.data_selector.currentIndex()
        if index < 0:
            return
        return self._data[index]

    @data.setter
    def data(self, value):
        for i, d in enumerate(self._data):
            if d is value:
                self._ui.data_selector.setCurrentIndex(i)
                return
        else:
            raise ValueError("Data is not part of the DataCollection")


CUSTOM_QWIDGETS.append(ComponentSelector)


def main():  # pragma: no cover
    import glue
    import numpy as np
    from glue.external.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()
示例#6
0
文件: rgb_edit.py 项目: bmorris3/glue
        if changed:
            self.colors_changed.emit()

        self.artist.update()
        self.artist.redraw()

    def update_current(self, *args):
        if self.artist is None:
            return

        for c in ['red', 'green', 'blue']:
            if self.current[c].isChecked():
                self.artist.contrast_layer = c
                self.current_changed.emit(c)
                break
        else:
            raise RuntimeError("Could not determine which layer is current")

    def update_visible(self, *args):
        if self.artist is None:
            return

        self.artist.layer_visible['red'] = self.vis['red'].isChecked()
        self.artist.layer_visible['green'] = self.vis['green'].isChecked()
        self.artist.layer_visible['blue'] = self.vis['blue'].isChecked()
        self.artist.update()
        self.artist.redraw()

CUSTOM_QWIDGETS.append(RGBEdit)
示例#7
0
    def _add_argument_widget(self, argument):
        """ Create and add a single argument widget to the input canvas
        :param arguement: The argument name (string)
        """
        widget = ArgumentWidget(argument)
        widget.editor.textChanged.connect(nonpartial(self._update_add_enabled))
        self._ui.input_canvas.layout().addWidget(widget)
        self._argument_widgets.append(widget)

    def _clear_input_canvas(self):
        """ Remove all widgets from the input canvas """
        layout = self._ui.input_canvas.layout()
        for a in self._argument_widgets:
            layout.removeWidget(a)
            a.close()

        if not PYSIDE:
            # PySide crashing here
            layout.removeItem(self.spacer)

        self._argument_widgets = []

    def _populate_function_combo(self):
        """ Add name of functions to function combo box """
        self._ui.function.clear()
        for f in self._functions:
            self._ui.function.addItem(f)


CUSTOM_QWIDGETS.append(LinkEquation)
示例#8
0
from __future__ import absolute_import, division, print_function

from glue.external.qt import QtGui
from glue.utils.qt import PyMimeData, GlueItemWidget, CUSTOM_QWIDGETS

# some standard glue mime types
LAYER_MIME_TYPE = 'glue/layer'
LAYERS_MIME_TYPE = 'glue/layers'
INSTANCE_MIME_TYPE = PyMimeData.MIME_TYPE


class GlueMimeListWidget(GlueItemWidget, QtGui.QListWidget):
    SUPPORTED_MIME_TYPE = LAYERS_MIME_TYPE


CUSTOM_QWIDGETS.append(GlueMimeListWidget)
示例#9
0
    def _add_argument_widget(self, argument):
        """ Create and add a single argument widget to the input canvas
        :param arguement: The argument name (string)
        """
        widget = ArgumentWidget(argument)
        widget.editor.textChanged.connect(self._update_add_enabled)
        self._ui.input_canvas.layout().addWidget(widget)
        self._argument_widgets.append(widget)

    def _clear_input_canvas(self):
        """ Remove all widgets from the input canvas """
        layout = self._ui.input_canvas.layout()
        for a in self._argument_widgets:
            layout.removeWidget(a)
            a.close()

        if not is_pyside():
            # PySide crashing here
            layout.removeItem(self.spacer)

        self._argument_widgets = []

    def _populate_function_combo(self):
        """ Add name of functions to function combo box """
        self._ui.function.clear()
        for f in self._functions:
            self._ui.function.addItem(f)

CUSTOM_QWIDGETS.append(LinkEquation)
示例#10
0
文件: mime.py 项目: bmorris3/glue
from __future__ import absolute_import, division, print_function

from glue.external.qt import QtGui
from glue.utils.qt import PyMimeData, GlueItemWidget, CUSTOM_QWIDGETS

# some standard glue mime types
LAYER_MIME_TYPE = 'glue/layer'
LAYERS_MIME_TYPE = 'glue/layers'
INSTANCE_MIME_TYPE = PyMimeData.MIME_TYPE

class GlueMimeListWidget(GlueItemWidget, QtGui.QListWidget):
    SUPPORTED_MIME_TYPE = LAYERS_MIME_TYPE


CUSTOM_QWIDGETS.append(GlueMimeListWidget)