Changeset 631

Show
Ignore:
Timestamp:
07/15/03 21:10:02 (5 years ago)
Author:
sholloway
Message:

*** empty log message ***

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/Renderers/Abstract.py

    r630 r631  
    3535 
    3636    def Display(self, ri): 
    37         return ri.DisplayOn(self) 
     37        raise NotImplementedError 
    3838 
    3939    #~ Meta Information ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/Renderers/Logging.py

    r630 r631  
    4343    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    4444 
    45     def __init__(self): 
     45    def Display(self, ri): 
    4646        self.resolver = [] 
     47        ri.DisplayOn(self) 
     48        del self.resolver 
    4749 
    4850    #~ Meta Information ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/Renderers/Null.py

    r630 r631  
    3232 
    3333class NullRenderer(Abstract.AbstractRenderer): 
    34     def __init__(self): 
     34    def Display(self, ri): 
    3535        self.resolver = [] 
     36        ri.DisplayOn(self) 
     37        del self.resolver 
    3638 
    3739    #~ Meta Information ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/Renderers/Rapier.py

    r630 r631  
    2424#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2525 
    26 import logging 
     26import warnings 
     27from OpenGL import GL 
     28 
     29from RBRapier.Renderer.View import Transformations 
     30from RBRapier.Renderer.Geometry import VertexArrays 
     31from RBRapier.Renderer.Geometry import ArrayTraversal 
     32from RBRapier.Renderer import SequenceMgr 
     33 
    2734import Abstract 
     35import RapierObjects 
    2836 
    2937#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    3139#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    3240 
     41class RapierPathFactory(Abstract.AbstractPathFactory): 
     42    __slots__ = 'pos', 'pathlist' 
     43 
     44    def BeginPath(self, pathstr):  
     45        self.pathlist = [] 
     46        self.pos = 0., 0. 
     47 
     48    def AddPathElement(self, name, *args): 
     49        name, relative = self.command_table[name] 
     50        getattr(self, name.lower())(relative, *args) 
     51 
     52    def EndPath(self, pathstr):  
     53        pass 
     54 
     55    def move(self, relative, x, y):  
     56        if relative: 
     57            dx, dy = self.pos 
     58            x += dx 
     59            y += dy 
     60        self.pathlist.append([(x,y)]) 
     61        self.pos = x,y 
     62 
     63    def closepath(self, relative):  
     64        lastpath = self.pathlist[-1] 
     65        self.pos = lastpath[0] 
     66        lastpath.append(self.pos) 
     67 
     68    def line(self, relative, x, y):  
     69        if relative: 
     70            dx, dy = self.pos 
     71            x += dx 
     72            y += dy 
     73        self.pathlist[-1].append((x,y)) 
     74        self.pos = x,y 
     75 
     76    def hline(self, relative, x):  
     77        dx, y = self.pos 
     78        if relative: 
     79            x += dx 
     80        self.pathlist[-1].append((x,y)) 
     81        self.pos = x,y 
     82 
     83    def vline(self, relative, y):  
     84        x, dy = self.pos 
     85        if relative: 
     86            y += dy 
     87        self.pathlist[-1].append((x,y)) 
     88        self.pos = x,y 
     89 
     90    def cubicbezier(self, relative, x1, y1, x2, y2, x, y):  
     91        if relative: 
     92            dx, dy = self.x, self.y 
     93            x1 += dx 
     94            y1 += dy 
     95            x2 += dx 
     96            y2 += dy 
     97            x += dx 
     98            y += dy 
     99        warnings.warn( "TODO: path.cubicbezier") 
     100        self.pathlist[-1].append((x,y)) 
     101        self.pos = x,y 
     102 
     103    def smoothcurve(self, relative, x2, y2, x, y):  
     104        if relative: 
     105            dx, dy = self.pos 
     106            x2 += dx 
     107            y2 += dy 
     108            x += dx 
     109            y += dy 
     110        warnings.warn( "TODO: path.smoothcurve") 
     111        self.pathlist[-1].append((x,y)) 
     112        self.pos = x,y 
     113 
     114    def quadraticbezier(self, relative, x1, y1, x, y):  
     115        if relative: 
     116            dx, dy = self.pos 
     117            x1 += dx 
     118            y1 += dy 
     119            x += dx 
     120            y += dy 
     121        warnings.warn( "TODO: path.quadraticbezier") 
     122        self.pathlist[-1].append((x,y)) 
     123        self.pos = x,y 
     124 
     125    def smoothquadraticbezier(self, relative, x, y):  
     126        if relative: 
     127            dx, dy = self.pos 
     128            x += dx 
     129            y += dy 
     130        warnings.warn( "TODO: path.smoothquadraticbezier") 
     131        self.pathlist[-1].append((x,y)) 
     132        self.pos = x,y 
     133 
     134    def ellipticarc(self, relative, rx, ry, xrotation, largeArcFlag, sweepFlag, x, y):  
     135        if relative: 
     136            dx, dy = self.pos 
     137            x += dx 
     138            y += dy 
     139        warnings.warn( "TODO: path.ellipticarc") 
     140        self.pathlist[-1].append((x,y)) 
     141        self.pos = x,y 
     142 
     143#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     144 
     145class RapierTransformFactory(object): 
     146    def __init__(self, xform): 
     147        pass 
     148 
     149    def BeginTransform(self, transformstr):  
     150        pass 
     151    def AddTransformElement(self, name, *args):  
     152        pass 
     153    def EndTransform(self, transformstr):  
     154        pass 
     155 
     156    def translate(self, x=0.0, y=0.0):  
     157        warnings.warn( "TODO: transform.translate") 
     158    def scale(self, x=1., y=None):  
     159        warnings.warn( "TODO: transform.scale") 
     160    def rotate(self, angle=0.0, x=0, y=0):  
     161        warnings.warn( "TODO: transform.rotate") 
     162    def skewx(self, angle=0.0):  
     163        warnings.warn( "TODO: transform.skewx") 
     164    def skewy(self, angle=0.0):  
     165        warnings.warn( "TODO: transform.skewy") 
     166    def matrix(self, xx=1.0, xy=0.0, xh=0.0, yx=0.0, yy=1.0, yh=0.0, hx=0.0, hy=0.0, hh=1.0):  
     167        warnings.warn( "TODO: transform.matrix") 
     168 
     169#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     170 
    33171class RapierRenderer(Abstract.AbstractRenderer): 
    34     def __init__(self): 
     172    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     173    #~ Constants / Variables / Etc.  
     174    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     175 
     176    PathFactory = RapierPathFactory 
     177    TransformFactory = RapierTransformFactory 
     178    SequenceFactory = SequenceMgr.Sequence 
     179 
     180    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     181    #~ Public Methods  
     182    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     183 
     184    def Display(self, ri): 
     185        rootsequence = self.SequenceFactory() 
     186        self.sequence = rootsequence 
     187        self.style = {} 
     188 
     189        # SVG coordinate system is upside down from OpenGL's  
     190        xform = Transformations.ScaleMgd(GL.GL_PROJECTION, True, (1, -1, 1)) 
     191        self.sequence.AddElement(xform.Select) 
     192        self.sequence.AddPostElement(xform.Deselect) 
     193 
     194        xform = Transformations.IdentityMgd(GL.GL_MODELVIEW, True) 
     195        self.sequence.AddElement(xform.Select) 
     196        self.sequence.AddPostElement(xform.Deselect) 
     197 
    35198        self.context = [] 
    36199        self.resolver = [] 
    37200 
     201        try: 
     202            ri.DisplayOn(self) 
     203        finally: 
     204            del self.resolver 
     205            del self.context 
     206            del self.sequence 
     207        return rootsequence 
     208 
    38209    #~ Meta Information ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    39210 
     
    47218 
    48219    def DisplaySVG(self, ri_svg):  
    49         self.PushContext(ri_svg
     220        self.PushContext(ri_svg, True
    50221        self.resolver.append(ri_svg.idmapping) 
    51222        try: 
     
    63234 
    64235    def DisplaySymbol(self, ri_symbol):  
    65         self.PushContext(ri_symbol
     236        self.PushContext(ri_symbol, True
    66237        try: 
    67238            ri_symbol.DisplayChildrenOn(self) 
     
    81252 
    82253    def DisplayLine(self, ri_line):  
    83         print "TODO: DisplayLine" 
     254        self.PushContext(ri_line) 
     255        try: 
     256            self.sequence.AddElement(RapierObjects.Line((ri_line.x1, ri_line.y1), (ri_line.x2, ri_line.y2))) 
     257        finally: 
     258            self.PopContext(ri_line) 
    84259 
    85260    def DisplayRect(self, ri_rect):  
    86         print "TODO: DisplayRect" 
     261        self.PushContext(ri_rect) 
     262        try: 
     263            self.sequence.AddElement(RapierObjects.Rect(ri_rect.width, ri_rect.height)) 
     264        finally: 
     265            self.PopContext(ri_rect) 
    87266 
    88267    def DisplayCircle(self, ri_circle):  
    89         print "TODO: DisplayCircle" 
     268        self.PushContext(ri_circle) 
     269        try: 
     270            warnings.warn( "TODO: DisplayCircle") 
     271        finally: 
     272            self.PopContext(ri_circle) 
    90273 
    91274    def DisplayEllipse(self, ri_ellipse):  
    92         print "TODO: DisplayEllipse" 
     275        self.PushContext(ri_ellipse) 
     276        try: 
     277            warnings.warn( "TODO: DisplayEllipse") 
     278        finally: 
     279            self.PopContext(ri_ellipse) 
    93280 
    94281    def DisplayPolygon(self, ri_polygon):  
    95         print "TODO: DisplayPolygon" 
     282        self.PushContext(ri_polygon) 
     283        try: 
     284            self.sequence.AddElement(RapierObjects.Polygon(ri_polygon.points)) 
     285        finally: 
     286            self.PopContext(ri_polygon) 
    96287 
    97288    def DisplayPolyline(self, ri_polyline):  
    98         print "TODO: DisplayPolyline" 
     289        self.PushContext(ri_polyline) 
     290        try: 
     291            self.sequence.AddElement(RapierObjects.Polyline(ri_polyline.points)) 
     292        finally: 
     293            self.PopContext(ri_polyline) 
    99294 
    100295    def DisplayPath(self, ri_path):  
    101         print "TODO: DisplayPath" 
     296        self.PushContext(ri_path) 
     297        try: 
     298            pathlist = ri_path.path.RestoreTo(self.PathFactory()).pathlist 
     299            self.sequence.AddElement(RapierObjects.Path(pathlist)) 
     300        finally: 
     301            self.PopContext(ri_path) 
    102302 
    103303    def DisplayText(self, ri_text):  
    104         print "TODO: DisplayText" 
     304        self.PushContext(ri_text) 
     305        try: 
     306            warnings.warn( "TODO: DisplayText") 
     307        finally: 
     308            self.PopContext(ri_text) 
    105309 
    106310    #~ Order management ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    110314        return self.resolver[-1].get(tag, None) 
    111315 
    112     def PushContext(self, ri): 
    113         print "TODO: PushContext" 
     316    def PushContext(self, ri, extendTransform=False): 
     317        self.context.append([self.sequence, self.style]) 
     318 
     319        if extendTransform: 
     320            self._DoExtendedTransform(ri) 
     321        else: 
     322            self._DoTransform(ri) 
     323        self._DoStyle(ri) 
    114324 
    115325    def PopContext(self, ri): 
    116         print "TODO: PopContext" 
    117  
    118 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    119  
    120 class RapierPathFactory(object): 
    121     def BeginPath(self, pathstr):  
    122         pass 
    123     def AddPathElement(self, name, relative, *args): 
    124         getattr(self, name.lower())(relative, *args) 
    125     def EndPath(self, pathstr):  
    126         pass 
    127  
    128     def move(self, relative, x, y):  
    129         pass 
    130     def closepath(self, relative):  
    131         pass 
    132     def line(self, relative, x, y):  
    133         pass 
    134     def hline(self, relative, x):  
    135         pass 
    136     def vline(self, relative, y):  
    137         pass 
    138     def cubicbezier(self, relative, x1, y1, x2, y2, x, y):  
    139         pass 
    140     def smoothcurve(self, relative, x2, y2, x, y):  
    141         pass 
    142     def quadraticbezier(self, relative, x1, y1, x, y):  
    143         pass 
    144     def smoothquadraticbezier(self, relative, x, y):  
    145         pass 
    146     def ellipticarc(self, relative, rx, ry, xrotation, largeArcFlag, sweepFlag, x, y):  
    147         pass 
    148  
    149 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    150  
    151 class RapierTransform(object): 
    152     def BeginTransform(self, transformstr):  
    153         pass 
    154     def AddTransformElement(self, name, *args):  
    155         pass 
    156     def EndTransform(self, transformstr):  
    157         pass 
    158  
    159     def translate(self, x=0.0, y=0.0):  
    160         pass 
    161     def scale(self, x=1., y=None):  
    162         pass 
    163     def rotate(self, angle=0.0, x=0, y=0):  
    164         pass 
    165     def skewx(self, angle=0.0):  
    166         pass 
    167     def skewy(self, angle=0.0):  
    168         pass 
    169     def matrix(self, xx=1.0, xy=0.0, xh=0.0, yx=0.0, yy=1.0, yh=0.0, hx=0.0, hy=0.0, hh=1.0):  
    170         pass 
    171  
     326        self.sequence, self.style = self.context.pop() 
     327 
     328    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     329 
     330    def PushSequence(self): 
     331        newsequence = self.SequenceFactory() 
     332        self.sequence.AddElement(newsequence.Execute) 
     333        self.sequence = newsequence  
     334        return self.sequence 
     335 
     336    def _DoStyle(self, ri): 
     337        try: newstyle = ri.style 
     338        except AttributeError: pass 
     339 
     340        if newstyle: 
     341            self.style = self.style.copy() 
     342            self.style.update(newstyle) 
     343 
     344        if self.style: 
     345            color = self.style.get('fill') or self.style.get('stroke') 
     346            if color: 
     347                self.sequence.AddElement(RapierObjects.Color(color)) 
     348 
     349    def _DoTransform(self, ri): 
     350        x, y, transform = ri.x, ri.y, ri.transform 
     351        if not (x or y or transform): 
     352            return False 
     353 
     354        if transform: 
     355            xform = Transformations.CompositeMgd(None, True) 
     356            if x or y: 
     357                xform.Add(Transformations.Translate((x or 0., y or 0.))) 
     358            transform.RestoreTo(self.TransformFactory(xform)) 
     359        elif x or y: 
     360            xform = Transformations.TranslateMgd(None, True, (x or 0., y or 0.)) 
     361 
     362        sequence = self.PushSequence() 
     363        sequence.AddElement(xform.Select) 
     364        sequence.AddPostElement(xform.Deselect) 
     365 
     366        return True 
     367 
     368    def _DoExtendedTransform(self, ri): 
     369        l, b, w, h = ri.viewBox 
     370        xform = Transformations.OrthographicMgd(None, True, l, l+w, b, b+h) 
     371 
     372        sequence = self.PushSequence() 
     373        sequence.AddElement(xform.Select) 
     374        sequence.AddPostElement(xform.Deselect) 
     375         
     376        return True 
     377          
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/RenderItems/Common.py

    r630 r631  
    4040    #~ Public Methods  
    4141    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     42 
     43    def __init__(self): 
     44        RenderItemBase.count += 1 
     45    count = 0 
     46    def __del__(self): 
     47        RenderItemBase.count -= 1 
     48        if not RenderItemBase.count: 
     49            print "Zero point for svg render items" 
    4250 
    4351    def __repr__(self): 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/RenderItems/Groups.py

    r630 r631  
    2424#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2525 
    26 from Common import TransformableRenderItem 
     26from Styled import StyledRenderItem 
    2727 
    2828#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    3030#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    3131 
    32 class GroupRenderItem(TransformableRenderItem): 
     32class GroupRenderItem(StyledRenderItem): 
    3333    def __init__(self): 
    34         TransformableRenderItem.__init__(self) 
     34        StyledRenderItem.__init__(self) 
    3535        self.children = [] 
    3636 
     
    4949        GroupRenderItem.InterpretSettings(self, settings) 
    5050 
    51         try: width = settings['width '] 
     51        try: width = settings['width'] 
    5252        except LookupError: pass 
    5353        else: self.width = width   
     
    9393    def GetViewBox(self): 
    9494        try: 
    95             return self.viewbox 
     95            return self._viewBox 
    9696        except AttributeError: 
    9797            self._viewbox = [self.x, self.y, self.width, self.height] 
    9898            return self._viewbox 
    9999    def SetViewBox(self, value): 
    100         self._viewbox = self._asViewBox(value) 
    101     viewbox = property(GetViewBox, SetViewBox) 
     100        self._viewBox = self._asViewBox(value) 
     101    viewBox = property(GetViewBox, SetViewBox) 
    102102 
    103103    def GetPreserveAspectRatio(self): 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/RenderItems/PathBuilder.py

    r629 r631  
    6161 
    6262#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    63 #~ Definitions  
    64 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    65  
    66 def _pathcommand(name, relative, nextcommand, argtypes): 
    67     return {'name':name, 'relative':relative, 'nextcommand':nextcommand, 'argtypes':argtypes} 
    68  
    69 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    7063#~ Path Factories 
    7164#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    7366class AbstractPathFactory(object): 
    7467    __slots__ = () 
     68 
     69    command_table = { 
     70        'M': ('move', False), 
     71        'm': ('move', True), 
     72 
     73        'Z': ('closepath', False), 
     74        'z': ('closepath', True), 
     75 
     76        'L': ('line', False), 
     77        'l': ('line', True), 
     78 
     79        'H': ('hline', False), 
     80        'h': ('hline', True), 
     81 
     82        'V': ('vline', False), 
     83        'v': ('vline', True), 
     84 
     85        'C': ('cubicbezier', False), 
     86        'c': ('cubicbezier', True), 
     87 
     88        'S': ('smoothcurve', False), 
     89        's': ('smoothcurve', True), 
     90 
     91        'Q': ('quadraticbezier', False), 
     92        'q': ('quadraticbezier', True), 
     93 
     94        'T': ('smoothquadraticbezier', False), 
     95        't': ('smoothquadraticbezier', True), 
     96 
     97        'A': ('ellipticarc', False), 
     98        'a': ('ellipticarc', True), 
     99        } 
    75100 
    76101    def BeginPath(self, pathstr):  
     
    122147            pathfactory.AddPathElement(*args) 
    123148        pathfactory.EndPath(self.pathstr) 
     149        return pathfactory 
    124150 
    125151#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    141167    _flag = (_re_flag, int) 
    142168 
    143     pathCommandTable = { 
    144         'M': _pathcommand('move', False, 'L', (_coord, _coord)), 
    145         'm': _pathcommand('move', True, 'l', (_coord, _coord)), 
    146  
    147         'Z': _pathcommand('closepath', False, 'M', ()), 
    148         'z': _pathcommand('closepath', True, 'm', ()), 
    149  
    150         'L': _pathcommand('line', False, None, (_coord, _coord)), 
    151         'l': _pathcommand('line', True, None, (_coord, _coord)), 
    152  
    153         'H': _pathcommand('hline', False, None, (_coord, )), 
    154         'h': _pathcommand('hline', True, None, (_coord, )), 
    155  
    156         'V': _pathcommand('vline', False, None, (_coord, )), 
    157         'v': _pathcommand('vline', True, None, (_coord, )), 
    158  
    159         'C': _pathcommand('cubicbezier', False, None, (_coord, _coord, _coord, _coord, _coord, _coord)), 
    160         'c': _pathcommand('cubicbezier', True, None, (_coord, _coord, _coord, _coord, _coord, _coord)), 
    161  
    162         'S': _pathcommand('smoothcurve', False, None, (_coord, _coord, _coord, _coord)), 
    163         's': _pathcommand('smoothcurve', True, None, (_coord, _coord, _coord, _coord)), 
    164  
    165         'Q': _pathcommand('quadraticbezier', False, None, (_coord, _coord, _coord, _coord)), 
    166         'q': _pathcommand('quadraticbezier', True, None, (_coord, _coord, _coord, _coord)), 
    167  
    168         'T': _pathcommand('smoothquadraticbezier', False, None, (_coord, _coord)), 
    169         't': _pathcommand('smoothquadraticbezier', True, None, (_coord, _coord)), 
    170  
    171         'A': _pathcommand('ellipticarc', False, None, (_coord, _coord, _rotation, _flag, _flag, _coord, _coord)), 
    172         'a': _pathcommand('ellipticarc', True, None, (_coord, _coord, _rotation, _flag, _flag, _coord, _coord)), 
     169    path_transitions = { 'M': 'L', 'm': 'l', 'Z': 'M', 'z': 'm', } 
     170    path_args = { 
     171        'M': (_coord, _coord), 
     172        'm': (_coord, _coord), 
     173 
     174        'Z': (), 
     175        'z': (), 
     176 
     177        'L': (_coord, _coord), 
     178        'l': (_coord, _coord), 
     179 
     180        'H': (_coord, ), 
     181        'h': (_coord, ), 
     182 
     183        'V': (_coord, ), 
     184        'v': (_coord, ), 
     185 
     186        'C': (_coord, _coord, _coord, _coord, _coord, _coord), 
     187        'c': (_coord, _coord, _coord, _coord, _coord, _coord), 
     188 
     189        'S': (_coord, _coord, _coord, _coord), 
     190        's': (_coord, _coord, _coord, _coord), 
     191 
     192        'Q': (_coord, _coord, _coord, _coord), 
     193        'q': (_coord, _coord, _coord, _coord), 
     194 
     195        'T': (_coord, _coord), 
     196        't': (_coord, _coord), 
     197 
     198        'A': (_coord, _coord, _rotation, _flag, _flag, _coord, _coord), 
     199        'a': (_coord, _coord, _rotation, _flag, _flag, _coord, _coord), 
    173200        } 
    174201 
     
    185212 
    186213        matchidx = 0 
    187         # MoveTo is the default command 
    188         command = self.pathCommandTable['M'] 
     214        # MoveTo absolute is the default command 
     215        commandidx = 'M' 
    189216        while matchidx < len(pathstr): 
    190217            # Find out what command we're dealing with 
    191218            commandmatch = self._re_command.match(pathstr, matchidx) 
    192219            if commandmatch is not None: 
    193                 commandidx = commandmatch.groups()[0] 
     220                commandidx = commandmatch.groups()[0] or commandidx  
    194221                matchidx = commandmatch.end() 
    195  
    196                 if commandidx: 
    197                     # Lookup our new command 
    198                     command = self.pathCommandTable[commandidx] 
    199222 
    200223            # parse out the arguments for the path element 
    201224            arguments = [] 
    202             for argre, argvalue in command['argtypes']: 
     225            for argre, argvalue in self.path_args[commandidx]: # CommandArguments 
    203226                argmatch = argre.match(pathstr, matchidx) 
    204227                if argmatch is None: 
     
    209232 
    210233            # go get the path factory method for our command 
    211             pathfactory.AddPathElement(command['name'], command['relative'], *arguments) 
     234            pathfactory.AddPathElement(commandidx, *arguments) 
    212235 
    213236            # see if we have a command transfer 
    214             commandidx = command['nextcommand'] 
    215             if commandidx is not None: 
    216                 # Lookup our new command 
    217                 command = self.pathCommandTable[commandidx] 
     237            commandidx = self.path_transitions.get(commandidx, commandidx) 
    218238 
    219239        pathfactory.EndPath(pathstr) 
     
    231251            self.results = ["begin()"] 
    232252        def AddPathElement(self, name, *args): 
    233             self.results.append('%s%r' % (name, args)) 
     253            name, relative = self.command_table[name] 
     254            self.results.append('%s%r' % (name, (relative,) + args)) 
    234255        def EndPath(self, pathstr):  
    235256            self.results.append("end()") 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/RenderItems/Styled.py

    r628 r631  
    2424#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    2525 
     26import warnings 
    2627from RBFoundation.XMLUtilityFunctions import ColorStringToRGB 
    2728from Common import TransformableRenderItem 
     
    7677        """ 
    7778        if isinstance(color, (type(None), int, long, tuple)): 
    78             return color 
     79            result = color 
    7980        elif color == 'currentColor': 
    80             return 'currentColor' 
     81            result = 'currentColor' 
     82        elif color.startswith('url'): 
     83            warnings.warn('TODO: implement color url') 
     84            result = None 
    8185        elif not color: 
    82             return None 
     86            result = None 
    8387        else: 
    84             return ColorStringToRGB(color) 
     88            result = ColorStringToRGB(color) 
     89        return result  
    8590 
    8691    def _asOpacity(self, opacity): 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/RenderItems/TransformBuilder.py

    r629 r631  
    9191            transformfactory.AddTransformElement(*args) 
    9292        transformfactory.EndTransform(self.transformstr) 
     93        return transformfactory 
    9394 
    9495#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/SVGSkinObject.py

    r630 r631  
    5353            self.context = None 
    5454 
     55        SVGSkinObject.count += 1 
     56    count = 0 
     57    def __del__(self): 
     58        SVGSkinObject.count -= 1 
     59        if not SVGSkinObject.count: 
     60            print "Zero point for svg skin elements" 
     61 
    5562    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    5663 
     
    7077        self.children = [] 
    7178        self.object = self.RenderItemFactory() 
     79 
     80        try:  
     81            idname = self.settings['id'] 
     82            idmapping = self.context.idmapping 
     83        except (KeyError, AttributeError): pass 
     84        else: idmapping[idname] = self.object 
     85 
    7286        if self.object is not None: 
    7387            self.object.InterpretSettings(self.settings) 
     
    8195    def _xmlInitFinalized(self): 
    8296        if self.object is not None: 
    83             try: 
    84                 idname = self.settings['id'] 
    85             except KeyError:  
    86                 pass 
    87             else: 
    88                 self.context.idmapping[idname] = self.object 
    89  
    9097            children = filter(None, [getattr(child, 'object', None) for child in self.children]) 
    9198            self.object.AddChildRenderItems(children) 
  • trunk/RBRapier/RBRapier/Formats/Attic/SVG.old/SVGSkin/use.py

    r630 r631  
    2626import warnings 
    2727from SVGSkinObject import SVGSkinObject 
    28 from RenderItems.Common import TransformableRenderItem 
     28from RenderItems.Styled import StyledRenderItem 
    2929 
    3030#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    3232#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    3333 
    34 class UseRenderItem(TransformableRenderItem): 
     34class UseRenderItem(StyledRenderItem): 
    3535    def DisplayOn(self, renderer): 
    3636        renderer.DisplayUse(self) 
    3737 
    3838    def InterpretSettings(self, settings): 
    39         TransformableRenderItem.InterpretSettings(self, settings) 
     39        StyledRenderItem.InterpretSettings(self, settings) 
    4040 
    4141        xlink = settings[('http://www.w3.org/1999/xlink', 'href')] 
  • trunk/RBRapier/demo/Attic/SVG.old/display.py

    r626 r631  
    3939from RBRapier.Formats import SVG 
    4040import RBRapier.Formats.SVG.SVGSkinner 
    41 import RBRapier.Formats.SVG.Renderers.Null 
     41import RBRapier.Formats.SVG.Renderers.Rapier 
    4242 
    4343#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    4747skinxml = """<?xml version='1.0'?>  
    4848<skin:skin xmlns:skin='http://namespaces.runeblade.com/skin' xmlns:py='http://namespaces.runeblade.com/xmlPython' xmlns='http://namespaces.runeblade.com/wxPythonSkin'> 
    49     <frame title='Simple Cube Demo' show='1' pos='0,0' size='800,600'> 
     49    <frame title='SVG Displayer' show='1' pos='0,0' size='800,600'> 
    5050        <layout fit='0'> 
    5151            <panel> 
     
    5757    </frame> 
    5858 
     59    <!-- 
    5960    <frame title='Demo PyCrust' show='1' pos='850,0' size='400,800'> 
    6061        <layout fit='0'> 
     
    6263        </layout>  
    6364    </frame> 
     65    --> 
    6466</skin:skin> 
    6567""" 
     
    7476 
    7577    def OnSkinFinalize(self): 
    76         self.svgrenderer = SVG.Renderers.Null.NullRenderer() 
    77  
    78         self.svgskins = [SVG.SVGSkinner.SkinFile(svgfile).object for svgfile in sys.argv[1:]] 
     78        self.svgitems = [SVG.SVGSkinner.SkinFile(svgfile).object for svgfile in sys.argv[1:]] 
    7979 
    8080        self.viewsetup = GLViewSetup(self.glcanvas) 
     
    8787        self.root = SequenceMgr.RootSequence() 
    8888 
    89         self.clearcolor = Buffers.ClearColor((0.5,0.5,0.7,1.0)) 
     89        self.clearcolor = Buffers.ClearColor((1.0,1.0,1.0,0.0)) 
    9090        self.root.AddElement(self.clearcolor, -2) 
    9191 
     
    9393        self.root.AddElement(self.viewport, -2) 
    9494 
    95         self.root.AddElement(self.DisplaySVGSkins) 
     95        svgrenderer = SVG.Renderers.Rapier.RapierRenderer() 
     96        while self.svgitems: 
     97            svg = self.svgitems.pop() 
     98            self.root.AddElement(svgrenderer.Display(svg)) 
    9699 
    97100    def Render(self, subject, canvas): 
     
    99102        self.root.Execute(None) 
    100103 
    101     def DisplaySVGSkins(self, glcontext): 
    102         for svgskin in self.svgskins: 
    103             self.svgrenderer.Display(svgskin) 
     104        maxfps = 40 
     105        realfps = self.root.Statistics['persecond'] 
     106        targetfps = self.viewsetup.GetTargetFPS() 
     107        if realfps < 2*targetfps: 
     108            newtarget = min(maxfps, realfps*0.45) 
     109            self.viewsetup.SetTargetFPS(newtarget) 
     110            print "Lowering fps to:", newtarget, "old target:", targetfps, "real:", realfps 
    104111 
    105112#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBRapier/demo/Attic/SVG.old/logdisplay.py

    r626 r631  
    4141 
    4242    for svgfile in sys.argv[1:]: 
    43         print "Started \"%s\" on %s" % (svgfile, time.asctime()) 
    44         print 
     43        print "Started \"" + svgfile + "\" on", time.asctime() 
    4544 
    4645        start = time.clock() 
    4746        skin = SkinFile(svgfile) 
    48         parseend = time.clock() 
     47        parsed = time.clock() 
    4948        skin.DisplayOn(renderer) 
    50         displayend = time.clock() 
     49        displayed = time.clock() 
    5150 
    52         print 
    53         print "Completed on %s (parse %1.1fs, display %1.1fs, total %1.1fs)" % (time.asctime(), parseend-start, displayend-parseend, displayend-start) 
     51        print "Completed on", time.asctime() 
     52        print "Timing info: %1.1f display, %1.1f parse, %1.1f total" % ( displayed-parsed, parsed-start, displayed-start) 
     53 
  • trunk/RBRapier/demo/Attic/SVG.old/nulldisplay.py

    r626 r631  
    3939 
    4040    for svgfile in sys.argv[1:]: 
    41         print "Started \"%s\" on %s" % (svgfile, time.asctime()) 
    42         print 
     41        print "Started \"" + svgfile + "\" on", time.asctime() 
    4342 
    4443        times = [time.clock()] 
     
    5049 
    5150        times = [b-a for a, b in zip(times[:-1], times[1:])] 
    52         print 
    53         print "Completed on %s times: %r" % (time.asctime(), times) 
     51        print "Completed on", time.asctime() 
     52        print "Timing info:", ', '.join(['%1.5fs' % t for t in times]) 
     53