<s> """<STR_LIT>""" <EOL> import operator <EOL> from koko . lib . shapes2d import color <EOL> from koko . fab . tree import MathTree <EOL> class FabVars ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self ) : <EOL> self . _shapes = [ ] <EOL> self . _shape = None <EOL> self . render_mode = None <EOL> self . mm_per_unit = <NUM_LIT> <EOL> self . border = <NUM_LIT> <EOL> @ property <EOL> def shapes ( self ) : return self . _shapes <EOL> @ shapes . setter <EOL> def shapes ( self , value ) : <EOL> if type ( value ) not in ( list , tuple ) : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> value = map ( MathTree . wrap , value ) <EOL> self . _shapes = list ( value ) <EOL> self . _shape = reduce ( operator . add , <EOL> [ color ( s , None ) for s in self . shapes ] <EOL> ) <EOL> @ property <EOL> def shape ( self ) : return self . _shape <EOL> @ shape . setter <EOL> def shape ( self , value ) : self . shapes = [ MathTree . wrap ( value ) ] <EOL> @ property <EOL> def function ( self ) : return self . shape <EOL> @ function . setter <EOL> def function ( self , value ) : self . shape = value <EOL> @ property <EOL> def render_mode ( self ) : <EOL> return self . _render_mode <EOL> @ render_mode . setter <EOL> def render_mode ( self , value ) : <EOL> if value not in [ '<STR_LIT>' , '<STR_LIT>' , None ] : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> self . _render_mode = value <EOL> @ property <EOL> def mm_per_unit ( self ) : <EOL> return self . _mm_per_unit <EOL> @ mm_per_unit . setter <EOL> def mm_per_unit ( self , value ) : <EOL> try : <EOL> self . _mm_per_unit = float ( value ) <EOL> except TypeError : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> @ property <EOL> def xmin ( self ) : <EOL> try : <EOL> dx = ( max ( s . xmax for s in self . shapes ) - <EOL> min ( s . xmin for s in self . shapes ) ) <EOL> return min ( s . xmin for s in self . shapes ) - dx * self . border / <NUM_LIT> <EOL> except ( TypeError , ValueError , AttributeError ) : return None <EOL> @ property <EOL> def xmax ( self ) : <EOL> try : <EOL> dx = ( max ( s . xmax for s in self . shapes ) - <EOL> min ( s . xmin for s in self . shapes ) ) <EOL> return max ( s . xmax for s in self . shapes ) + dx * self . border / <NUM_LIT> <EOL> except ( TypeError , ValueError , AttributeError ) : return None <EOL> @ property <EOL> def dx ( self ) : <EOL> try : return self . xmax - self . xmin <EOL> except TypeError : return None <EOL> @ property <EOL> def ymin ( self ) : <EOL> try : <EOL> dy = ( max ( s . ymax for s in self . shapes ) - <EOL> min ( s . ymin for s in self . shapes ) ) <EOL> return min ( s . ymin for s in self . shapes ) - dy * self . border / <NUM_LIT> <EOL> except ( TypeError , ValueError , AttributeError ) : return None <EOL> @ property <EOL> def ymax ( self ) : <EOL> try : <EOL> dy = ( max ( s . ymax for s in self . shapes ) - <EOL> min ( s . ymin for s in self . shapes ) ) <EOL> return max ( s . ymax for s in self . shapes ) + dy * self . border / <NUM_LIT> <EOL> except ( TypeError , ValueError , AttributeError ) : return None <EOL> @ property <EOL> def dy ( self ) : <EOL> try : return self . ymax - self . ymin <EOL> except TypeError : return None <EOL> @ property <EOL> def zmin ( self ) : <EOL> try : <EOL> dz = ( max ( s . zmax for s in self . shapes ) - <EOL> min ( s . zmin for s in self . shapes ) ) <EOL> return min ( s . zmin for s in self . shapes ) - dz * self . border / <NUM_LIT> <EOL> except ( TypeError , ValueError , AttributeError ) : return None <EOL> @ property <EOL> def zmax ( self ) : <EOL> try : <EOL> dz = ( max ( s . zmax for s in self . shapes ) - <EOL> min ( s . zmin for s in self . shapes ) ) <EOL> return max ( s . zmax for s in self . shapes ) + dz * self . border / <NUM_LIT> <EOL> except ( TypeError , ValueError , AttributeError ) : return None <EOL> @ property <EOL> def dz ( self ) : <EOL> try : return self . zmax - self . zmin <EOL> except TypeError : return None <EOL> @ property <EOL> def bounded ( self ) : <EOL> return all ( getattr ( self , b ) is not None for b in <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) </s>
