Fixes to CTM to support bitmap renderer; extra string rotation
authorandy_robinson
Sun, 28 Jan 2001 17:54:47 +0000
changeset 585 e0144950b3e2
parent 584 94214696e4b9
child 586 06bec1d89dca
Fixes to CTM to support bitmap renderer; extra string rotation and group tests.
reportlab/graphics/renderbase.py
reportlab/graphics/testshapes.py
--- a/reportlab/graphics/renderbase.py	Fri Jan 26 08:24:45 2001 +0000
+++ b/reportlab/graphics/renderbase.py	Sun Jan 28 17:54:47 2001 +0000
@@ -63,6 +63,9 @@
         self.__combined = []
         if defaults is None:
             defaults = STATE_DEFAULTS.copy()
+        #ensure  that if we have a transform, we have a CTM
+        if defaults.has_key('transform'):
+            defaults['ctm'] = defaults['transform']
         self.__combined.append(defaults)
 
     def push(self,delta):
@@ -74,7 +77,11 @@
         for (key, value) in delta.items():
             if key == 'transform':  #do cumulative matrix
                 newstate['transform'] = delta['transform']
-                newstate['ctm'] = mmult(self.__combined[-1]['transform'], delta['transform'])
+                #newstate['ctm'] = mmult(self.__combined[-1]['transform'], delta['transform'])
+                newstate['ctm'] = mmult(self.__combined[-1]['ctm'], delta['transform'])
+                print 'statetracker transform = (%0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f)' % tuple(newstate['transform'])
+                print 'statetracker ctm = (%0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f)' % tuple(newstate['ctm'])
+                
             else:  #just overwrite it
                 newstate[key] = value
 
@@ -182,8 +189,7 @@
         elif isinstance(node, String):
             self.drawString(node)
         elif isinstance(node, Group):
-            for childNode in node.contents:
-                self.drawNode(childNode)
+            self.drawGroup(node)
         elif isinstance(node, Wedge):
             #print "drawWedge"
             self.drawWedge(node)
@@ -194,7 +200,13 @@
     _restores = {'stroke':'_stroke','stroke_width': '_lineWidth','stroke_linecap':'_lineCap',
                 'stroke_linejoin':'_lineJoin','fill':'_fill','font_family':'_font',
                 'font_size':'_fontSize'}
-                
+
+    def drawGroup(self, group):
+        # just do the contents.  Some renderers might need to override this
+        # if they need a flipped transform
+        for childNode in group.contents:
+            self.drawNode(childNode)
+
     def drawWedge(self, wedge):
         # by default ask the wedge to make a polygon of itself and draw that!
         #print "drawWedge"
--- a/reportlab/graphics/testshapes.py	Fri Jan 26 08:24:45 2001 +0000
+++ b/reportlab/graphics/testshapes.py	Sun Jan 28 17:54:47 2001 +0000
@@ -316,6 +316,7 @@
 
     return D
 
+
 def getAllFunctionDrawingNames():
     "Get a list of drawing function names from somewhere."