00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 from SCons.Script import Builder, Action, Delete
00044 from os import environ
00045 from repro.functions.reproexports import reproexports
00046 from string import join
00047
00048 PNGCMD = 'pstoimg'
00049
00050
00051
00052
00053
00054 def png_emitter( target, source, env ):
00055
00056 env.Default( source )
00057 env.Alias( 'png', target)
00058 return target, source
00059
00060
00061
00062
00063
00064 def eps_emitter( target, source, env ):
00065 reproexports( env )
00066
00067 env.Default( source )
00068 env.Alias( 'eps', target)
00069 return target, source
00070
00071 def always_succeed(s):
00072
00073 return 0
00074
00075
00076
00077
00078
00079 def pdf_vpl_emitter( target, source, env ):
00080 reproexports( env )
00081
00082 return target, source
00083
00084
00085
00086
00087
00088
00089 def generate(env):
00090
00091
00092 REPROEXPORTS= ['RSFROOT','PSTEXPENOPTS','PSBORDER','GS_OPTIONS']
00093
00094 vpl2eps_act = Action('vplot2eps ${SOURCE} ${TARGET}',
00095 exitstatfunc=always_succeed,
00096 varlist=REPROEXPORTS,
00097 )
00098
00099 env['PSIMAGEOPTS'] = ""
00100 su2eps_act = Action('supsimage <${SOURCE} $PSIMAGEOPTS >${TARGET}',
00101 exitstatfunc=always_succeed,
00102 )
00103
00104 eps_builder = Builder(action={".vpl":vpl2eps_act,
00105 ".su":su2eps_act},
00106 suffix=".eps",
00107 single_source=True,
00108 emitter=eps_emitter
00109 )
00110 env['BUILDERS']['EPS'] = eps_builder
00111
00112
00113 env['aaliastext'] = True
00114 env['antialias'] = True
00115 env['color'] = 24
00116 env['density'] = 100
00117 env['interlaced'] = True
00118 env['itype'] = 'png'
00119
00120 env['PNGCMD'] = PNGCMD
00121 env['_aaliastext'] = "${aaliastext and '-aaliastext' or ' '}"
00122 env['_antialias'] = "${antialias and '-antialias' or ' '}"
00123 env['_interlaced'] = "${interlaced and '-interlaced' or ' '}"
00124 env['PNGOPTS'] = "$_aaliastext $_antialias -color $color -density $density $_interlaced -type $itype"
00125
00126 png_act = Action( "$PNGCMD $SOURCE -out $TARGET $PNGOPTS",
00127 varlist=['PSTEXPENOPTS'],
00128 )
00129
00130 png_builder = Builder(action={".pdf":png_act,
00131 ".eps":png_act
00132 },
00133 source_suffix=['.pdf','.eps'],
00134 suffix=".png",
00135 single_source=True,
00136 emitter=png_emitter,
00137 src_builder=eps_builder
00138 )
00139 env['BUILDERS']['PNG'] = png_builder
00140
00141
00142 PS2PDFACTION = Action('epstopdf ${TARGET.base}.eps >${TARGET}', chdir=1 )
00143
00144 env.PDF.method.add_action( '.vpl', [ vpl2eps_act , PS2PDFACTION, Delete('${TARGET.base}.eps')] )
00145
00146 env.Append( REPROEXPORTS=REPROEXPORTS )
00147
00148 env['PSTEXPENOPTS'] = environ.get('PSTEXPENOPTS')
00149 env['PSBORDER'] = environ.get('PSBORDER')
00150 env.PDF.method.builder.add_emitter( '.vpl', pdf_vpl_emitter )
00151
00152 gs_options = join(['-dAutoFilterColorImages=false',
00153 '-dColorImageFilter=/LZWEncode',
00154 '-dAutoFilterGrayImages=false',
00155 '-dGrayImageFilter=/LZWEncode'])
00156 env['GS_OPTIONS'] = environ.get( 'GS_OPTIONS',gs_options )
00157 env.PDF.method.add_action( '.ps', Action('epstopdf ${SOURCE} >${TARGET}') )
00158 env.PDF.method.add_action( '.eps', Action('epstopdf ${SOURCE} >${TARGET}') )
00159
00160
00161
00162
00163
00164 def exists( env ):
00165 return 1
00166
00167