Example #1
0
 def __init__(self, *args, **kwargs):
     ############################################################
     # Signals
     # Making QLayer inherit from QObject leads to
     # a bugged behavior of hasattr and getattr.
     # So, we don't add signals as first level class attributes.
     # Instead, we use instances of ad hoc signal containers.
     ############################################################
     self.visibilityChanged = baseSignal_bool()
     self.colorPicked = baseSignal_Int2()
     self.selectionChanged = baseSignal_No()
     self.maskSettingsChanged = baseSignal_No()
     ###########################################################
     # when a geometric transformation is applied to the whole image
     # each layer must be replaced with a transformed layer, recorded in tLayer
     # and tLayer.parentLayer keeps a reference to the original layer.
     ###########################################################
     self.tLayer = self
     self.parentLayer = self
     self.modified = False
     self.name = 'noname'
     self.visible = True
     self.isClipping = False
     self.role = kwargs.pop('role', '')
     self.tool = None
     # back link to parent image
     parentImage = kwargs.pop('parentImage', None)
     self.parentImage = weakProxy(parentImage)
     super().__init__(*args, **kwargs)  # don't move backwards
     # mask init, must be done after after calling super().__init__
     if type(self) not in [QPresentationLayer]:
         self.mask = QImage(self.width(), self.height(),
                            QImage.Format_ARGB32)
         # default : unmask all
         self.mask.fill(self.defaultColor_UnMasked)
     # layer opacity, range 0.0...1.0
     self.opacity = 1.0
     self.compositionMode = QPainter.CompositionMode_SourceOver
     # The next two attributes are used by adjustment layers only.
     self.execute = lambda l=None, pool=None: l.updatePixmap(
     ) if l is not None else None
     self.options = {}
     # actionName is used by methods graphics***.writeToStream()
     self.actionName = 'actionNull'
     # view is the dock widget containing
     # the graphics form associated with the layer
     self.view = None
     # undo/redo mask history
     self.historyListMask = historyList(size=5)
     # consecutive layers can be grouped.
     # A group is a list of QLayer objects
     self.group = []
     # layer offsets
     self.xOffset, self.yOffset = 0, 0
     self.Zoom_coeff = 1.0
     # clone dup layer shift and zoom  relative to current layer
     self.xAltOffset, self.yAltOffset = 0, 0
     self.AltZoom_coeff = 1.0
     self.updatePixmap()
Example #2
0
 def __init__(self, parent=None):
     super().__init__(parent=parent)
     self.closeSignal = baseSignal_No()