[reportlab-users] probable bug in renderbase.StateTracker treatment of transforms
Robin Becker
robin at reportlab.com
Mon Jun 4 12:08:41 EDT 2007
Boris Borcic wrote:
> Hello,
>
> In short, shouldn't renderbase.StateTracker.pop() read like :
>
> def pop(self) :
> del self._combined[-1]
> prevState = self._combined[-1]
> lastDelta = self._deltas.pop()
> reverseDelta = {}
> for key, curValue in lastDelta.items():
> if key == 'transform' :
> if curValue != (1 0 0 1 0 0) :
> reverseDelta[key] = inverse(curValue)
> elif curValue <> prevState[key] :
> reverseDelta[key] = prevState[key]
> return reverseDelta
>
> rather than the current :
>
> def pop(self):
> """steps back one, and returns a state dictionary with the
> deltas to reverse out of wherever you are. Depending
> on your back end, you may not need the return value,
> since you can get the complete state afterwards with getState()"""
>
> del self._combined[-1]
> newState = self._combined[-1]
> lastDelta = self._deltas[-1]
> del self._deltas[-1]
> #need to diff this against the last one in the state
> reverseDelta = {}
> #print 'pop()...'
> for key, curValue in lastDelta.items():
> prevValue = newState[key]
> ----------->if prevValue <> curValue:
> -----------> if key == 'transform':
> -----------> reverseDelta[key] = inverse(lastDelta['transform'])
> else: #just return to previous state
> reverseDelta[key] = prevValue
> return reverseDelta
>
> The 3 lines marked by arrows look inconsistent to me. If
> lastDelta['transform'] needs to be special-cased as it is there, this
> means that the condition of relevance for it, is not that
> prevValue<>curValue but rather that curValue isn't the identity transform.
>
> Or am I missing something ?
>
> TIA for comments,
>
> Boris Borcic
.......
I'm not sure if that's true. I'm fairly sure this whole scheme was a bit daft.
There's no real need for the delta stuff at all since the stack is supposed to
keep the actual values. I guess if anyone was using the relative values it might
be needed ie what do I need to do to get the transform that if applied here
results in the transform that was being used in another part of the stack.
However since the stack preserves the actual values it's fairly easy just to do
the appropriate arithmetic directly.
ie M0 = M1*M find M looks like M=inv(M1)*M0
--
Robin Becker
More information about the reportlab-users
mailing list