src/reportlab/graphics/renderbase.py
branchpy33
changeset 3723 99aa837b6703
parent 3721 0c93dd8ff567
child 4132 28379377462b
equal deleted inserted replaced
3722:29c11b905751 3723:99aa837b6703
    35     """Used to compute when we need to change the graphics state.
    35     """Used to compute when we need to change the graphics state.
    36     For example, if we have two adjacent red shapes we don't need
    36     For example, if we have two adjacent red shapes we don't need
    37     to set the pen color to red in between. Returns the effect
    37     to set the pen color to red in between. Returns the effect
    38     the given shape would have on the graphics state"""
    38     the given shape would have on the graphics state"""
    39     delta = {}
    39     delta = {}
    40     for (prop, value) in list(shape.getProperties().items()):
    40     for prop, value in shape.getProperties().items():
    41         if prop in STATE_DEFAULTS:
    41         if prop in STATE_DEFAULTS:
    42             delta[prop] = value
    42             delta[prop] = value
    43     return delta
    43     return delta
    44 
    44 
    45 
    45 
    70         """Take a new state dictionary of changes and push it onto
    70         """Take a new state dictionary of changes and push it onto
    71         the stack.  After doing this, the combined state is accessible
    71         the stack.  After doing this, the combined state is accessible
    72         through getState()"""
    72         through getState()"""
    73 
    73 
    74         newstate = self._combined[-1].copy()
    74         newstate = self._combined[-1].copy()
    75         for (key, value) in list(delta.items()):
    75         for key, value in delta.items():
    76             if key == 'transform':  #do cumulative matrix
    76             if key == 'transform':  #do cumulative matrix
    77                 newstate['transform'] = delta['transform']
    77                 newstate['transform'] = delta['transform']
    78                 newstate['ctm'] = mmult(self._combined[-1]['ctm'], delta['transform'])
    78                 newstate['ctm'] = mmult(self._combined[-1]['ctm'], delta['transform'])
    79                 #print 'statetracker transform = (%0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f)' % tuple(newstate['transform'])
    79                 #print 'statetracker transform = (%0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f)' % tuple(newstate['transform'])
    80                 #print 'statetracker ctm = (%0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f)' % tuple(newstate['ctm'])
    80                 #print 'statetracker ctm = (%0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f)' % tuple(newstate['ctm'])
    95         lastDelta = self._deltas[-1]
    95         lastDelta = self._deltas[-1]
    96         del  self._deltas[-1]
    96         del  self._deltas[-1]
    97         #need to diff this against the last one in the state
    97         #need to diff this against the last one in the state
    98         reverseDelta = {}
    98         reverseDelta = {}
    99         #print 'pop()...'
    99         #print 'pop()...'
   100         for key, curValue in list(lastDelta.items()):
   100         for key, curValue in lastDelta.items():
   101             #print '   key=%s, value=%s' % (key, curValue)
   101             #print '   key=%s, value=%s' % (key, curValue)
   102             prevValue = newState[key]
   102             prevValue = newState[key]
   103             if prevValue != curValue:
   103             if prevValue != curValue:
   104                 #print '    state popping "%s"="%s"' % (key, curValue)
   104                 #print '    state popping "%s"="%s"' % (key, curValue)
   105                 if key == 'transform':
   105                 if key == 'transform':
   228         and replace them with their calculated values.
   228         and replace them with their calculated values.
   229         Generally things may look at the drawing or their
   229         Generally things may look at the drawing or their
   230         parent.
   230         parent.
   231         
   231         
   232         """
   232         """
   233         for (key, value) in list(node.__dict__.items()):
   233         for key, value in node.__dict__.items():
   234             if isinstance(value, DerivedValue):
   234             if isinstance(value, DerivedValue):
   235                 #just replace with default for key?
   235                 #just replace with default for key?
   236                 #print '    fillDerivedValues(%s)' % key
   236                 #print '    fillDerivedValues(%s)' % key
   237                 newValue = value.getValue(self, key)
   237                 newValue = value.getValue(self, key)
   238                 #print '   got value of %s' % newValue
   238                 #print '   got value of %s' % newValue