src/reportlab/graphics/renderbase.py
author robin
Fri, 19 Feb 2021 10:50:39 +0000
changeset 4642 ba6b914af331
parent 4528 e09377955af8
permissions -rw-r--r--
rearange transformation math and text2Path functionality
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4642
ba6b914af331 rearange transformation math and text2Path functionality
robin
parents: 4528
diff changeset
     1
#Copyright ReportLab Europe Ltd. 2000-2021
817
8c3a399effda License text changes
rgbecker
parents: 604
diff changeset
     2
#see license.txt for license details
4528
e09377955af8 try to eliminate changed bitbucket.org references
robin
parents: 4493
diff changeset
     3
#history https://hg.reportlab.com/hg-public/reportlab/log/tip/src/reportlab/graphics/renderbase.py
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
     4
4252
fe660f227cac changes for release 3.3.0
robin
parents: 4132
diff changeset
     5
__version__='3.3.0'
3032
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 2964
diff changeset
     6
__doc__='''Superclass for renderers to factor out common functionality and default implementations.'''
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
     7
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
     8
from reportlab.graphics.shapes import *
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
     9
from reportlab.lib.validators import DerivedValue
2360
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
    10
from reportlab import rl_config
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
    11
4642
ba6b914af331 rearange transformation math and text2Path functionality
robin
parents: 4528
diff changeset
    12
from . transform import mmult, inverse
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
    13
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
    14
def getStateDelta(shape):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    15
    """Used to compute when we need to change the graphics state.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    16
    For example, if we have two adjacent red shapes we don't need
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    17
    to set the pen color to red in between. Returns the effect
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    18
    the given shape would have on the graphics state"""
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    19
    delta = {}
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
    20
    for prop, value in shape.getProperties().items():
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3233
diff changeset
    21
        if prop in STATE_DEFAULTS:
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    22
            delta[prop] = value
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    23
    return delta
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
    24
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
    25
class StateTracker:
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    26
    """Keeps a stack of transforms and state
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    27
    properties.  It can contain any properties you
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    28
    want, but the keys 'transform' and 'ctm' have
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    29
    special meanings.  The getCTM()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    30
    method returns the current transformation
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    31
    matrix at any point, without needing to
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    32
    invert matrixes when you pop."""
4274
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
    33
    def __init__(self, defaults=None, defaultObj=None):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    34
        # one stack to keep track of what changes...
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
    35
        self._deltas = []
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
    36
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    37
        # and another to keep track of cumulative effects.  Last one in
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    38
        # list is the current graphics state.  We put one in to simplify
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    39
        # loops below.
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
    40
        self._combined = []
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    41
        if defaults is None:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    42
            defaults = STATE_DEFAULTS.copy()
4274
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
    43
        if defaultObj:
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
    44
            for k in STATE_DEFAULTS.keys():
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
    45
                a = 'initial'+k[:1].upper()+k[1:]
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
    46
                if hasattr(defaultObj,a):
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
    47
                    defaults[k] = getattr(defaultObj,a)
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    48
        #ensure  that if we have a transform, we have a CTM
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3233
diff changeset
    49
        if 'transform' in defaults:
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    50
            defaults['ctm'] = defaults['transform']
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
    51
        self._combined.append(defaults)
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
    52
4274
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
    53
    def _applyDefaultObj(self,d):
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
    54
        return d
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
    55
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    56
    def push(self,delta):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    57
        """Take a new state dictionary of changes and push it onto
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    58
        the stack.  After doing this, the combined state is accessible
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    59
        through getState()"""
1665
c2ce87221cf7 Changes to allow flaky _drawTimeResize
rgbecker
parents: 1609
diff changeset
    60
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
    61
        newstate = self._combined[-1].copy()
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
    62
        for key, value in delta.items():
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    63
            if key == 'transform':  #do cumulative matrix
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    64
                newstate['transform'] = delta['transform']
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
    65
                newstate['ctm'] = mmult(self._combined[-1]['ctm'], delta['transform'])
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    66
                #print 'statetracker transform = (%0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f)' % tuple(newstate['transform'])
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    67
                #print 'statetracker ctm = (%0.2f, %0.2f, %0.2f, %0.2f, %0.2f, %0.2f)' % tuple(newstate['ctm'])
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
    68
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    69
            else:  #just overwrite it
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    70
                newstate[key] = value
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
    71
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
    72
        self._combined.append(newstate)
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
    73
        self._deltas.append(delta)
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
    74
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    75
    def pop(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    76
        """steps back one, and returns a state dictionary with the
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    77
        deltas to reverse out of wherever you are.  Depending
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    78
        on your back end, you may not need the return value,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    79
        since you can get the complete state afterwards with getState()"""
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
    80
        del self._combined[-1]
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
    81
        newState = self._combined[-1]
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
    82
        lastDelta = self._deltas[-1]
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
    83
        del  self._deltas[-1]
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    84
        #need to diff this against the last one in the state
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    85
        reverseDelta = {}
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    86
        #print 'pop()...'
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
    87
        for key, curValue in lastDelta.items():
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    88
            #print '   key=%s, value=%s' % (key, curValue)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    89
            prevValue = newState[key]
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3233
diff changeset
    90
            if prevValue != curValue:
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    91
                #print '    state popping "%s"="%s"' % (key, curValue)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    92
                if key == 'transform':
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    93
                    reverseDelta[key] = inverse(lastDelta['transform'])
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    94
                else:  #just return to previous state
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    95
                    reverseDelta[key] = prevValue
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    96
        return reverseDelta
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
    97
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    98
    def getState(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
    99
        "returns the complete graphics state at this point"
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   100
        return self._combined[-1]
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   101
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   102
    def getCTM(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   103
        "returns the current transformation matrix at this point"""
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   104
        return self._combined[-1]['ctm']
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   105
2401
cd68d7a84d05 CanvasAdapter related changes
rgbecker
parents: 2360
diff changeset
   106
    def __getitem__(self,key):
cd68d7a84d05 CanvasAdapter related changes
rgbecker
parents: 2360
diff changeset
   107
        "returns the complete graphics state value of key at this point"
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   108
        return self._combined[-1][key]
2401
cd68d7a84d05 CanvasAdapter related changes
rgbecker
parents: 2360
diff changeset
   109
cd68d7a84d05 CanvasAdapter related changes
rgbecker
parents: 2360
diff changeset
   110
    def __setitem__(self,key,value):
cd68d7a84d05 CanvasAdapter related changes
rgbecker
parents: 2360
diff changeset
   111
        "sets the complete graphics state value of key to value"
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   112
        self._combined[-1][key] = value
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   113
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   114
def testStateTracker():
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   115
    print('Testing state tracker')
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   116
    defaults = {'fillColor':None, 'strokeColor':None,'fontName':None, 'transform':[1,0,0,1,0,0]}
3368
afa025c34493 reportlab: new base font mechanism more fully applied
rgbecker
parents: 3326
diff changeset
   117
    from reportlab.graphics.shapes import _baseGFontName
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   118
    deltas = [
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   119
        {'fillColor':'red'},
3368
afa025c34493 reportlab: new base font mechanism more fully applied
rgbecker
parents: 3326
diff changeset
   120
        {'fillColor':'green', 'strokeColor':'blue','fontName':_baseGFontName},
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   121
        {'transform':[0.5,0,0,0.5,0,0]},
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   122
        {'transform':[0.5,0,0,0.5,2,3]},
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   123
        {'strokeColor':'red'}
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   124
        ]
1665
c2ce87221cf7 Changes to allow flaky _drawTimeResize
rgbecker
parents: 1609
diff changeset
   125
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   126
    st = StateTracker(defaults)
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   127
    print('initial:', st.getState())
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   128
    print()
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   129
    for delta in deltas:
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   130
        print('pushing:', delta)
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   131
        st.push(delta)
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   132
        print('state:  ',st.getState(),'\n')
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   133
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   134
    for delta in deltas:
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   135
        print('popping:',st.pop())
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   136
        print('state:  ',st.getState(),'\n')
1665
c2ce87221cf7 Changes to allow flaky _drawTimeResize
rgbecker
parents: 1609
diff changeset
   137
c2ce87221cf7 Changes to allow flaky _drawTimeResize
rgbecker
parents: 1609
diff changeset
   138
def _expandUserNode(node,canvas):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   139
    if isinstance(node, UserNode):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   140
        try:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   141
            if hasattr(node,'_canvas'):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   142
                ocanvas = 1
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   143
            else:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   144
                node._canvas = canvas
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   145
                ocanvas = None
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   146
            onode = node
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   147
            node = node.provideNode()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   148
        finally:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   149
            if not ocanvas: del onode._canvas
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   150
    return node
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   151
2544
a6b9aa99b3c3 graphics: added Drawing.renderScale hack for renderer terminal drawing scales
rgbecker
parents: 2401
diff changeset
   152
def renderScaledDrawing(d):
a6b9aa99b3c3 graphics: added Drawing.renderScale hack for renderer terminal drawing scales
rgbecker
parents: 2401
diff changeset
   153
    renderScale = d.renderScale
a6b9aa99b3c3 graphics: added Drawing.renderScale hack for renderer terminal drawing scales
rgbecker
parents: 2401
diff changeset
   154
    if renderScale!=1.0:
2827
ec03c767079c renderbase.py: attempt to fix problems with copy in renderScaledDrawing
rgbecker
parents: 2570
diff changeset
   155
        o = d
ec03c767079c renderbase.py: attempt to fix problems with copy in renderScaledDrawing
rgbecker
parents: 2570
diff changeset
   156
        d = d.__class__(o.width*renderScale,o.height*renderScale)
ec03c767079c renderbase.py: attempt to fix problems with copy in renderScaledDrawing
rgbecker
parents: 2570
diff changeset
   157
        d.__dict__ = o.__dict__.copy()
2544
a6b9aa99b3c3 graphics: added Drawing.renderScale hack for renderer terminal drawing scales
rgbecker
parents: 2401
diff changeset
   158
        d.scale(renderScale,renderScale)
a6b9aa99b3c3 graphics: added Drawing.renderScale hack for renderer terminal drawing scales
rgbecker
parents: 2401
diff changeset
   159
        d.renderScale = 1.0
a6b9aa99b3c3 graphics: added Drawing.renderScale hack for renderer terminal drawing scales
rgbecker
parents: 2401
diff changeset
   160
    return d
a6b9aa99b3c3 graphics: added Drawing.renderScale hack for renderer terminal drawing scales
rgbecker
parents: 2401
diff changeset
   161
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   162
class Renderer:
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   163
    """Virtual superclass for graphics renderers."""
1665
c2ce87221cf7 Changes to allow flaky _drawTimeResize
rgbecker
parents: 1609
diff changeset
   164
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   165
    def undefined(self, operation):
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   166
        raise ValueError("%s operation not defined at superclass class=%s" %(operation, self.__class__))
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   167
2360
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   168
    def draw(self, drawing, canvas, x=0, y=0, showBoundary=rl_config._unset_):
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   169
        """This is the top level function, which draws the drawing at the given
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   170
        location. The recursive part is handled by drawNode."""
4274
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
   171
        self._tracker = StateTracker(defaultObj=drawing)
2360
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   172
        #stash references for ease of  communication
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   173
        if showBoundary is rl_config._unset_: showBoundary=rl_config.showBoundary
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   174
        self._canvas = canvas
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   175
        canvas.__dict__['_drawing'] = self._drawing = drawing
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   176
        drawing._parent = None
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   177
        try:
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   178
            #bounding box
4493
ed067f3c4678 improve showBoundary usage
robin <robin@reportlab.com>
parents: 4470
diff changeset
   179
            if showBoundary:
ed067f3c4678 improve showBoundary usage
robin <robin@reportlab.com>
parents: 4470
diff changeset
   180
                if hasattr(canvas,'drawBoundary'):
ed067f3c4678 improve showBoundary usage
robin <robin@reportlab.com>
parents: 4470
diff changeset
   181
                    canvas.drawBoundary(showBoundary,x,y,drawing.width,drawing.height)
ed067f3c4678 improve showBoundary usage
robin <robin@reportlab.com>
parents: 4470
diff changeset
   182
                else:
ed067f3c4678 improve showBoundary usage
robin <robin@reportlab.com>
parents: 4470
diff changeset
   183
                    canvas.rect(x, y, drawing.width, drawing.height)
2360
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   184
            canvas.saveState()
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   185
            self.initState(x,y)  #this is the push()
2360
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   186
            self.drawNode(drawing)
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   187
            self.pop()
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   188
            canvas.restoreState()
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   189
        finally:
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   190
            #remove any circular references
4274
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
   191
            del self._canvas, self._drawing, canvas._drawing, drawing._parent, self._tracker
2360
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   192
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   193
    def initState(self,x,y):
4274
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
   194
        deltas = self._tracker._combined[-1]
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
   195
        deltas['transform'] = tuple(list(deltas['transform'])[:4])+(x,y)
2360
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   196
        self._tracker.push(deltas)
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   197
        self.applyStateChanges(deltas, {})
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   198
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   199
    def pop(self):
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   200
        self._tracker.pop()
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   201
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   202
    def drawNode(self, node):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   203
        """This is the recursive method called for each node
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   204
        in the tree"""
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   205
        # Undefined here, but with closer analysis probably can be handled in superclass
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   206
        self.undefined("drawNode")
1665
c2ce87221cf7 Changes to allow flaky _drawTimeResize
rgbecker
parents: 1609
diff changeset
   207
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   208
    def getStateValue(self, key):
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   209
        """Return current state parameter for given key"""
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   210
        currentState = self._tracker._combined[-1]
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   211
        return currentState[key]
4274
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
   212
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   213
    def fillDerivedValues(self, node):
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   214
        """Examine a node for any values which are Derived,
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   215
        and replace them with their calculated values.
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   216
        Generally things may look at the drawing or their
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   217
        parent.
4274
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
   218
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   219
        """
3723
99aa837b6703 second stage of port to Python 3.3; working hello world
rptlab
parents: 3721
diff changeset
   220
        for key, value in node.__dict__.items():
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   221
            if isinstance(value, DerivedValue):
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   222
                #just replace with default for key?
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   223
                #print '    fillDerivedValues(%s)' % key
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   224
                newValue = value.getValue(self, key)
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   225
                #print '   got value of %s' % newValue
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   226
                node.__dict__[key] = newValue
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   227
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   228
    def drawNodeDispatcher(self, node):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   229
        """dispatch on the node's (super) class: shared code"""
2570
7b93b3b42e51 reportlab/graphics cosmetics and adding drawImage to renderPS
rgbecker
parents: 2547
diff changeset
   230
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   231
        canvas = getattr(self,'_canvas',None)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   232
        # replace UserNode with its contents
2570
7b93b3b42e51 reportlab/graphics cosmetics and adding drawImage to renderPS
rgbecker
parents: 2547
diff changeset
   233
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   234
        try:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   235
            node = _expandUserNode(node,canvas)
3233
9408fec15198 renderbase.py: allow user nodes to return None
rgbecker
parents: 3032
diff changeset
   236
            if not node: return
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   237
            if hasattr(node,'_canvas'):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   238
                ocanvas = 1
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   239
            else:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   240
                node._canvas = canvas
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   241
                ocanvas = None
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   242
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   243
            self.fillDerivedValues(node)
3385
e45ca0b2053c graphics: start on run time callback support
rgbecker
parents: 3368
diff changeset
   244
            dtcb = getattr(node,'_drawTimeCallback',None)
e45ca0b2053c graphics: start on run time callback support
rgbecker
parents: 3368
diff changeset
   245
            if dtcb:
e45ca0b2053c graphics: start on run time callback support
rgbecker
parents: 3368
diff changeset
   246
                dtcb(node,canvas=canvas,renderer=self)
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   247
            #draw the object, or recurse
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   248
            if isinstance(node, Line):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   249
                self.drawLine(node)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   250
            elif isinstance(node, Image):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   251
                self.drawImage(node)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   252
            elif isinstance(node, Rect):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   253
                self.drawRect(node)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   254
            elif isinstance(node, Circle):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   255
                self.drawCircle(node)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   256
            elif isinstance(node, Ellipse):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   257
                self.drawEllipse(node)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   258
            elif isinstance(node, PolyLine):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   259
                self.drawPolyLine(node)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   260
            elif isinstance(node, Polygon):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   261
                self.drawPolygon(node)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   262
            elif isinstance(node, Path):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   263
                self.drawPath(node)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   264
            elif isinstance(node, String):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   265
                self.drawString(node)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   266
            elif isinstance(node, Group):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   267
                self.drawGroup(node)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   268
            elif isinstance(node, Wedge):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   269
                self.drawWedge(node)
4470
364affa6e2b9 add support for DirectDraw nodes to allow canvas adaptation
robin <robin@reportlab.com>
parents: 4370
diff changeset
   270
            elif isinstance(node, DirectDraw):
364affa6e2b9 add support for DirectDraw nodes to allow canvas adaptation
robin <robin@reportlab.com>
parents: 4370
diff changeset
   271
                node.drawDirectly(self)
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   272
            else:
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   273
                print('DrawingError','Unexpected element %s in drawing!' % str(node))
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   274
        finally:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   275
            if not ocanvas: del node._canvas
1665
c2ce87221cf7 Changes to allow flaky _drawTimeResize
rgbecker
parents: 1609
diff changeset
   276
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   277
    _restores = {'stroke':'_stroke','stroke_width': '_lineWidth','stroke_linecap':'_lineCap',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   278
                'stroke_linejoin':'_lineJoin','fill':'_fill','font_family':'_font',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   279
                'font_size':'_fontSize'}
585
e0144950b3e2 Fixes to CTM to support bitmap renderer; extra string rotation
andy_robinson
parents: 580
diff changeset
   280
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   281
    def drawGroup(self, group):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   282
        # just do the contents.  Some renderers might need to override this
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   283
        # if they need a flipped transform
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   284
        canvas = getattr(self,'_canvas',None)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   285
        for node in group.getContents():
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   286
            node = _expandUserNode(node,canvas)
3233
9408fec15198 renderbase.py: allow user nodes to return None
rgbecker
parents: 3032
diff changeset
   287
            if not node: continue
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   288
4274
ec03159b74bb changes to Render class; allow drawings to specify initialFontName/Size version-->3.3.9
robin
parents: 4252
diff changeset
   289
            #here is where we do derived values - this seems to get everything. Touch wood.
2547
9d13685212f2 datacharts synchronised
andy
parents: 2544
diff changeset
   290
            self.fillDerivedValues(node)
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   291
            try:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   292
                if hasattr(node,'_canvas'):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   293
                    ocanvas = 1
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   294
                else:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   295
                    node._canvas = canvas
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   296
                    ocanvas = None
2360
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   297
                node._parent = group
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   298
                self.drawNode(node)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   299
            finally:
2360
0fbaee224de1 rl_config add _unset_, graphics.renderxxx refactoring
rgbecker
parents: 2332
diff changeset
   300
                del node._parent
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   301
                if not ocanvas: del node._canvas
585
e0144950b3e2 Fixes to CTM to support bitmap renderer; extra string rotation
andy_robinson
parents: 580
diff changeset
   302
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   303
    def drawWedge(self, wedge):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   304
        # by default ask the wedge to make a polygon of itself and draw that!
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   305
        #print "drawWedge"
4132
28379377462b fix doughnut chart special case and how it is drawn; bump to 3.1.31
robin
parents: 3723
diff changeset
   306
        P = wedge.asPolygon()
28379377462b fix doughnut chart special case and how it is drawn; bump to 3.1.31
robin
parents: 3723
diff changeset
   307
        if isinstance(P,Path):
28379377462b fix doughnut chart special case and how it is drawn; bump to 3.1.31
robin
parents: 3723
diff changeset
   308
            self.drawPath(P)
28379377462b fix doughnut chart special case and how it is drawn; bump to 3.1.31
robin
parents: 3723
diff changeset
   309
        else:
28379377462b fix doughnut chart special case and how it is drawn; bump to 3.1.31
robin
parents: 3723
diff changeset
   310
            self.drawPolygon(P)
1665
c2ce87221cf7 Changes to allow flaky _drawTimeResize
rgbecker
parents: 1609
diff changeset
   311
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   312
    def drawPath(self, path):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   313
        polygons = path.asPolygons()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   314
        for polygon in polygons:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   315
                self.drawPolygon(polygon)
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   316
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   317
    def drawRect(self, rect):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   318
        # could be implemented in terms of polygon
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   319
        self.undefined("drawRect")
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   320
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   321
    def drawLine(self, line):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   322
        self.undefined("drawLine")
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   323
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   324
    def drawCircle(self, circle):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   325
        self.undefined("drawCircle")
1665
c2ce87221cf7 Changes to allow flaky _drawTimeResize
rgbecker
parents: 1609
diff changeset
   326
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   327
    def drawPolyLine(self, p):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   328
        self.undefined("drawPolyLine")
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   329
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   330
    def drawEllipse(self, ellipse):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   331
        self.undefined("drawEllipse")
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   332
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   333
    def drawPolygon(self, p):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   334
        self.undefined("drawPolygon")
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   335
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   336
    def drawString(self, stringObj):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   337
        self.undefined("drawString")
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   338
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   339
    def applyStateChanges(self, delta, newState):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   340
        """This takes a set of states, and outputs the operators
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   341
        needed to set those properties"""
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1665
diff changeset
   342
        self.undefined("applyStateChanges")
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   343
4303
1dbe6269e831 improved support for images in renderPM/renderSVG bug report from Claude Paroz; version --> 3.3.26
robin
parents: 4274
diff changeset
   344
    def drawImage(self,*args,**kwds):
1dbe6269e831 improved support for images in renderPM/renderSVG bug report from Claude Paroz; version --> 3.3.26
robin
parents: 4274
diff changeset
   345
        raise NotImplementedError('drawImage')
1dbe6269e831 improved support for images in renderPM/renderSVG bug report from Claude Paroz; version --> 3.3.26
robin
parents: 4274
diff changeset
   346
568
9cadc5ef53db Added graphics module
andy_robinson
parents:
diff changeset
   347
if __name__=='__main__':
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   348
    print("this file has no script interpretation")
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
   349
    print(__doc__)