Example #1
0
def symbol_icon(symbol, color=None):
    bm = QtGui.QBitmap(icon_path(POINT_ICONS.get(symbol, 'glue_circle')))

    if color is not None:
        return QtGui.QIcon(tint_pixmap(bm, color))

    return QtGui.QIcon(bm)
Example #2
0
def layer_artist_icon(artist):
    """Create a QtGui.QIcon for a LayerArtist instance"""

    # TODO: need a test for this

    from glue.viewers.image.layer_artist import ImageLayerArtist

    if not artist.enabled:
        bm = QtGui.QBitmap(icon_path('glue_delete'))
    elif isinstance(artist, ImageLayerArtist):
        bm = QtGui.QBitmap(icon_path('glue_image'))
    else:
        bm = QtGui.QBitmap(icon_path(POINT_ICONS.get(artist.layer.style.marker,
                                                     'glue_circle_point')))
    color = mpl_to_qt4_color(artist.layer.style.color)

    pm = tint_pixmap(bm, color)
    return QtGui.QIcon(pm)
Example #3
0
def layer_artist_icon(artist):
    """Create a QtGui.QIcon for a LayerArtist instance"""

    # TODO: need a test for this

    from glue.viewers.scatter.layer_artist import ScatterLayerArtist

    color = artist.get_layer_color()

    if isinstance(color, Colormap):
        pm = cmap2pixmap(color)
    else:
        if isinstance(artist, ScatterLayerArtist):
            bm = QtGui.QBitmap(icon_path(POINT_ICONS.get(artist.layer.style.marker,
                                                         'glue_circle_point')))
        else:
            bm = QtGui.QBitmap(icon_path('glue_box_point'))
        color = mpl_to_qt_color(color)
        pm = tint_pixmap(bm, color)

    return QtGui.QIcon(pm)
Example #4
0
def crosshair_cursor():
    if os.name == 'nt':
        # On windows, cursors support "inversion" mode, where they invert the
        # underlying color. This is achived with two bitmap.
        # Final cursor has mask all 0
        # When main bitmap is 0, this means transparent, when 1, inversion.
        bm = QtGui.QBitmap(16, 16)
        ma = QtGui.QBitmap(16, 16)
        bm.clear()
        ma.clear()
        # Paint a crosshair on the main bitmap with color1.
        pbm = QtGui.QPainter(bm)
        pbm.setPen(QtCore.Qt.color1)
        pbm.drawLine(8, 0, 8, 15)
        pbm.drawLine(0, 8, 15, 8)
        pbm.setPen(QtCore.Qt.color0)
        pbm.drawPoint(8, 8)
        pbm.end()
        return QtGui.QCursor(bm, ma, 8, 8)
    else:
        fn = os.path.dirname(__file__) + '/images/picker.svg'
        return load_cursor(fn, 8, 8)
Example #5
0
def layer_icon(layer):
    """Create a QtGui.QIcon for a Data or Subset instance

    :type layer: :class:`~glue.core.data.Data`,
                 :class:`~glue.core.subset.Subset`,
                 or object with a .style attribute

    :rtype: QtGui.QIcon
    """
    icon = POINT_ICONS.get(layer.style.marker, 'circle_point')
    bm = QtGui.QBitmap(icon_path(icon))
    color = mpl_to_qt4_color(layer.style.color)
    pm = tint_pixmap(bm, color)
    return QtGui.QIcon(pm)