Пример #1
0
class BrushFormation(InstrumentFormation):
    ''' Specialize to Qt <QBrush> '''
    def __init__(self, parentSelector, role=""):

        InstrumentFormation.__init__(self,
                                     name="Brush",
                                     parentSelector=parentSelector,
                                     role=role)
        self.instrument = QBrush()
        self.styleProperties = [
            BaseStyleProperty("Color",
                              self.instrument.setColor,
                              self.selector,
                              resettableValueFactory=ResettableColorValue,
                              layoutFactory=ColorStylePropertyLayout,
                              default=self.instrument.color()),
            BaseStyleProperty(
                "Style",  # Was Pattern
                self.instrument.setStyle,
                self.selector,
                default=self.instrument.style(),
                # ResettableIntValue defaults and works
                layoutFactory=ComboBoxStylePropertyLayout,
                domainModel=config.BrushModel),
        ]
        '''
    sic, BrushPattern is called Style in Qt
    
    Need Pattern, since defaults to NoBrush and that means color is moot.
    If we just have Color, once it is set, no way to go back to unfilled.
    
    TODO: user friendly:  if user chooses color, ensure pattern is not NoBrush
    '''

        # TODO gradients and texture not working?

    def applyTo(self, morph):
        #print "setBrush on morph", self.instrument.color()

        # Morph knows it's scale and applies it to self instrument
        morph.scaleInstrument(self.instrument)  # No baseValue, defaults to 1
        # Tell Morph to use self.instrument to draw itself
        morph.setBrush(self.instrument)

    """
Пример #2
0
class BrushFormation(InstrumentFormation):
  ''' Specialize to Qt <QBrush> '''
  
  def __init__(self, parentSelector, role=""):
    
    InstrumentFormation.__init__(self, name="Brush", parentSelector=parentSelector, role=role)
    self.instrument = QBrush()
    self.styleProperties=[BaseStyleProperty("Color", self.instrument.setColor, self.selector,
                                            resettableValueFactory=ResettableColorValue,
                                            layoutFactory=ColorStylePropertyLayout,
                                            default=self.instrument.color()),
                          BaseStyleProperty("Style", # Was Pattern
                                            self.instrument.setStyle, self.selector,
                                            default=self.instrument.style(),
                                            # ResettableIntValue defaults and works
                                            layoutFactory=ComboBoxStylePropertyLayout,
                                            domainModel = config.BrushModel),]
    
    '''
    sic, BrushPattern is called Style in Qt
    
    Need Pattern, since defaults to NoBrush and that means color is moot.
    If we just have Color, once it is set, no way to go back to unfilled.
    
    TODO: user friendly:  if user chooses color, ensure pattern is not NoBrush
    '''
    
    # TODO gradients and texture not working?
  
  
  def applyTo(self, morph):
    #print "setBrush on morph", self.instrument.color()
    
    # Morph knows it's scale and applies it to self instrument
    morph.scaleInstrument(self.instrument)  # No baseValue, defaults to 1
    # Tell Morph to use self.instrument to draw itself
    morph.setBrush(self.instrument) 
  
  
  """