Beispiel #1
0
def get_length_units():
    # Create a dict we can use for scalebar unit conversions
    unit_symbols = {}
    for name in LengthI.SYMBOLS.keys():
        if name in ("PIXEL", "REFERENCEFRAME"):
            continue
        klass = getattr(UnitsLength, name)
        unit = LengthI(1, klass)
        to_microns = LengthI(unit, UnitsLength.MICROMETER)
        unit_symbols[name] = {
            'symbol': unit.getSymbol(),
            'microns': to_microns.getValue()
        }
    return unit_symbols
Beispiel #2
0
class ShapeSettingsData(object):

    ##
    # Initialises the default values of the ShapeSettings.
    # Stroke has default colour of darkGrey
    # StrokeWidth defaults to 1
    #

    def __init__(self):
        warnings.warn("This module is deprecated as of OMERO 5.3.0",
                      DeprecationWarning)
        self.WHITE = 16777215
        self.BLACK = 0
        self.GREY = 11184810
        self.strokeColour = rint(self.GREY)
        self.strokeWidth = LengthI()
        self.strokeWidth.setValue(1)
        self.strokeWidth.setUnit(UnitsLength.POINT)
        self.strokeDashArray = rstring('')
        self.fillColour = rint(self.GREY)
        self.fillRule = rstring('')

    ##
    # Applies the settings in the ShapeSettingsData to the ROITypeI
    # @param shape the omero.model.ROITypeI that these settings will
    #              be applied to
    #
    def setROIShapeSettings(self, shape):
        warnings.warn("This module is deprecated as of OMERO 5.3.0",
                      DeprecationWarning)
        shape.setStrokeColor(self.strokeColour)
        shape.setStrokeWidth(self.strokeWidth)
        shape.setStrokeDashArray(self.strokeDashArray)
        shape.setFillColor(self.fillColour)
        shape.setFillRule(self.fillRule)

    ##
    # Set the Stroke settings of the ShapeSettings.
    # @param colour The colour of the stroke.
    # @param width The stroke width.
    #
    def setStrokeSettings(self, colour, width=1):
        warnings.warn("This module is deprecated as of OMERO 5.3.0",
                      DeprecationWarning)
        self.strokeColour = rint(colour)
        self.strokeWidth = LengthI()
        self.strokeWidth.setValue(width)
        self.strokeWidth.setUnit(UnitsLength.POINT)

    ###
    # Set the Fill Settings for the ShapeSettings.
    # @param colour The fill colour of the shape.
    def setFillSettings(self, colour):
        warnings.warn("This module is deprecated as of OMERO 5.3.0",
                      DeprecationWarning)
        self.fillColour = rstring(colour)

    ##
    # Get the stroke settings as the tuple (strokeColour, strokeWidth).
    # @return See above.
    #
    def getStrokeSettings(self):
        warnings.warn("This module is deprecated as of OMERO 5.3.0",
                      DeprecationWarning)
        return (self.strokeColour.getValue(), self.strokeWidth.getValue())

    ##
    # Get the fill setting as a tuple of (fillColour)
    # @return See above.
    #
    def getFillSettings(self):
        warnings.warn("This module is deprecated as of OMERO 5.3.0",
                      DeprecationWarning)
        return (self.fillColour.getValue())

    ##
    # Get the tuple ((stokeColor, strokeWidth), (fillColour)).
    # @return see above.
    #
    def getSettings(self):
        warnings.warn("This module is deprecated as of OMERO 5.3.0",
                      DeprecationWarning)
        return (self.getStrokeSettings(), self.getFillSettings())

    ##
    # Set the current shapeSettings from the ROI roi.
    # @param roi see above.
    #
    def getShapeSettingsFromROI(self, roi):
        warnings.warn("This module is deprecated as of OMERO 5.3.0",
                      DeprecationWarning)
        self.strokeColour = roi.getStrokeColor()
        self.strokeWidth = roi.getStrokeWidth()
        self.strokeDashArray = roi.getStrokeDashArray()
        self.fillColour = roi.getFillColor()
        self.fillRule = roi.getFillRule()
class ShapeSettingsData:

    ##
    # Initialises the default values of the ShapeSettings.
    # Stroke has default colour of darkGrey
    # StrokeWidth defaults to 1
    #

    def __init__(self):
        self.WHITE = 16777215
        self.BLACK = 0
        self.GREY = 11184810
        self.strokeColour = rint(self.GREY)
        self.strokeWidth = LengthI()
        self.strokeWidth.setValue(1)
        self.strokeWidth.setUnit(UnitsLength.POINT)
        self.strokeDashArray = rstring('')
        self.strokeDashOffset = rint(0)
        self.strokeLineCap = rstring('')
        self.strokeLineJoin = rstring('')
        self.strokeMiterLimit = rint(0)
        self.fillColour = rint(self.GREY)
        self.fillRule = rstring('')

    ##
    # Applies the settings in the ShapeSettingsData to the ROITypeI
    # @param shape the omero.model.ROITypeI that these settings will
    #              be applied to
    #
    def setROIShapeSettings(self, shape):
        shape.setStrokeColor(self.strokeColour)
        shape.setStrokeWidth(self.strokeWidth)
        shape.setStrokeDashArray(self.strokeDashArray)
        shape.setStrokeDashOffset(self.strokeDashOffset)
        shape.setStrokeLineCap(self.strokeLineCap)
        shape.setStrokeLineJoin(self.strokeLineJoin)
        shape.setStrokeMiterLimit(self.strokeMiterLimit)
        shape.setFillColor(self.fillColour)
        shape.setFillRule(self.fillRule)

    ##
    # Set the Stroke settings of the ShapeSettings.
    # @param colour The colour of the stroke.
    # @param width The stroke width.
    #
    def setStrokeSettings(self, colour, width=1):
        self.strokeColour = rint(colour)
        self.strokeWidth = LengthI()
        self.strokeWidth.setValue(width)
        self.strokeWidth.setUnit(UnitsLength.POINT)

    ###
    # Set the Fill Settings for the ShapeSettings.
    # @param colour The fill colour of the shape.
    def setFillSettings(self, colour):
        self.fillColour = rstring(colour)

    ##
    # Get the stroke settings as the tuple (strokeColour, strokeWidth).
    # @return See above.
    #
    def getStrokeSettings(self):
        return (self.strokeColour.getValue(), self.strokeWidth.getValue())

    ##
    # Get the fill setting as a tuple of (fillColour)
    # @return See above.
    #
    def getFillSettings(self):
        return (self.fillColour.getValue())

    ##
    # Get the tuple ((stokeColor, strokeWidth), (fillColour)).
    # @return see above.
    #
    def getSettings(self):
        return (self.getStrokeSettings(), self.getFillSettings())

    ##
    # Set the current shapeSettings from the ROI roi.
    # @param roi see above.
    #
    def getShapeSettingsFromROI(self, roi):
        self.strokeColour = roi.getStrokeColor()
        self.strokeWidth = roi.getStrokeWidth()
        self.strokeDashArray = roi.getStrokeDashArray()
        self.strokeDashOffset = roi.getStrokeDashOffset()
        self.strokeLineCap = roi.getStrokeLineCap()
        self.strokeLineJoin = roi.getStrokeLineJoin()
        self.strokeMiterLimit = roi.getStrokeMiterLimit()
        self.fillColour = roi.getFillColor()
        self.fillRule = roi.getFillRule()