<?php
################################################################
# @(#) $Id: cradle_defs.inc,v 1.2 2001/06/28 01:05:23 andr Exp $
#
# A.Gaponenko, May 2001
#


$cradle_width  = 150;
$cradle_length = 560;

# leave some space for "upstream" and "downstream" labels

$cradle_z_margin = 40;

##================
# relative thicknesses in z direction

$mod_dz_weight = array(
    'UV'    => 2,
    'PC'    => 3,
    'TGT'   => 4,
    'Dense' => 5,

    # cital spacers in between modules

    'c2'    => 1,
    'c4'    => 2,

    # no gap
    'c0'    => 0
);

##================
# upstream to downstream
$mod_order = array(
    array('module' => 'PC',    'gap' => 'c2'), 
    array('module' => 'Dense', 'gap' => 'c2'), 

    array('module' => 'UV',    'gap' => 'c4'), 
    array('module' => 'UV',    'gap' => 'c2'), 
    array('module' => 'UV',    'gap' => 'c4'), 
    array('module' => 'UV',    'gap' => 'c2'), 
    array('module' => 'UV',    'gap' => 'c4'), 
    array('module' => 'UV',    'gap' => 'c2'), 
    array('module' => 'UV',    'gap' => 'c2'), 

    array('module' => 'TGT',   'gap' => 'c2'),

    array('module' => 'UV',    'gap' => 'c2'), 
    array('module' => 'UV',    'gap' => 'c2'), 
    array('module' => 'UV',    'gap' => 'c4'), 
    array('module' => 'UV',    'gap' => 'c2'), 
    array('module' => 'UV',    'gap' => 'c4'), 
    array('module' => 'UV',    'gap' => 'c2'), 
    array('module' => 'UV',    'gap' => 'c4'), 

    array('module' => 'Dense', 'gap' => 'c2'), 
    array('module' => 'PC',    'gap' => 'c0')
);

##================================================================
## Calculate conversion factor to absolute module and gap sizes

# first find sum of all z weights
$sumw = 0;
reset($mod_order);
while(list($key, $data) = each($mod_order)) {
    $sumw += $mod_dz_weight[$data['module']] 
	     + $mod_dz_weight[$data['gap']];
}

# echo "Weight sum = $sumw<br>\n";

$zUnit = ($cradle_length - 2* $cradle_z_margin)/$sumw;

##================================================================
# Calculate coordinates of the boxes

$xcurr = $cradle_z_margin;

reset($mod_order);
while(list($key, $data) = each($mod_order)) {
    $type = $data['module'];
    $gap  = $zUnit* $mod_dz_weight[$data['gap']];

    $x1 = $xcurr;
    $x2 = $x1 + $zUnit* $mod_dz_weight[$type];

    $y1 = 0.1 * $cradle_width;
    $y2 = 0.9 * $cradle_width;

#    echo "$x1,$y1,$x2,$y2<br>\n";
    ##================================================================
    ## (like HTML 4.0.1)
    ## "shape": one of rect|circle|poly 
    ## "coords": shape-dependent interpretation

    $modules[] = array(
	   'shape'  => 'rect',
	   'coords' => array($x1,$y1,$x2,$y2),
	   'label'  => $type
    );
    $xcurr = $x2 + $gap;
}

##================================================================
?>