Posted: 02 Mar 2015, 15:05

Spoiler:
Code: Select all
sub drawcutline
{
my $a = shift;
my $b = shift;
my $c = shift;
my $d = shift;
my $orientation = shift;
my $shifty = shift;
my $xs = $a;
my $ys = $b;
my $xe = $c;
my $ye = $d;
if($orientation =~ /[VY]/)
{
$xs+=$shifty;
$xe+=$shifty;
return "DS $ys $xs $ye $xe 60 27\n";
}
$ys+=$shifty;
$ye+=$shifty;
return "DS $xs $ys $xe $ye 60 27\n";
}
sub drawstabs
{
my $str=shift;
# -3.5,PMX
my $BASEW=7500;
my $cutoutx=2750;
my $cutouty=2750;
if($alps_f)
{
$cutoutx=3055;
$cutouty=2525;
}
my @mystab=split(/\,/,$str);
my @mylines=();
if(@mystab>1)
{
# left, regular is the connonical case.
# $sx=-1 for right side
# $sy=-1 for upside-down montage (X-flag)
my $sx=1;
my $sy=1;
my $shifty=0;
my $orientation="H";
if($mystab[0] > 0 ) { $sx=-1; }
if($mystab[1] =~ /X/) { $sy=-1; $orientation="X"; }
if($mystab[1] =~ /Y/) { $sy=-1; $orientation="Y"; $shifty=-$BASEW/2; }
if($mystab[1] =~ /V/) { $orientation="V"; $shifty=-$BASEW/2; }
my $wirecut=925*$sy;
if(abs($mystab[0])<1) { $wirecut=2400*$sy; }
print "STAB:: --------------------- $str --------------------------------\n";
my $center=float2int($mystab[0]*$BASEW);
my $xs=0;
my $ys=0;
my $xe=0;
my $ye=0;
my $temp=0;
# top and bottom cut of switch:
if($mystab[0]<0)
{
$xs=-$cutoutx*$sx;
$xe= $cutoutx*$sx;
$ys=-$cutouty*$sy;
$ye=$ys;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
$ys=$cutouty*$sy;
$ye=$ys;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
}
# start is top left corner, then clockwise
$xs=$center-1310*$sx;
$ys=-2720*$sy;
$xe=$center+1310*$sx;
$ye=-2720*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
$xs=$xe;
$ys=$ye;
$ye=-$wirecut;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# line to switch-cutout (top)
$xe=-$cutoutx*$sx;
$ys=$ye;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# switch coutout:
if((abs($mystab[0])<1) || $alps_f)
{
$xs=$xe;
$ys=$ye;
$ye=-$cutouty*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
$ys=$cutouty*$sy;
$ye=$wirecut;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
}
else
{
# up
$xs=$xe;
$ys=$ye;
$ye=-$MYCUTD/2*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# left
$xs=$xe;
$xe=-$MYCUTX*$sx+$xs;
$ys=$ye;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# up
$xs=$xe;
$ys=$ye;
$ye+=-$MYCUTY*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# right
$xs=$xe;
$xe=$MYCUTX*$sx+$xs;
$ys=$ye;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# up
$xs=$xe;
$ys=$ye;
$ye=-$cutouty*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# ---- lower part:
$ye=-$wirecut;
$ys=$ye;
# up
$xs=-$cutoutx*$sx;
$xe=$xs;
$ys=$wirecut;
$ye=$MYCUTD/2*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# left
$xs=$xe;
$xe=-$MYCUTX*$sx+$xs;
$ys=$ye;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# up
$xs=$xe;
$ys=$ye;
$ye+=$MYCUTY*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# right
$xs=$xe;
$xe=$MYCUTX*$sx+$xs;
$ys=$ye;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# up
$xs=$xe;
$ys=$ye;
$ye=$cutouty*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
}
# line to switch-cutout (bottom)
$xs=$center+1310*$sx;
$xe=-$cutoutx*$sx;
$ys=$wirecut;
$ye=$wirecut;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# down
$xe=$xs;
$ye=2600*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# left
$xe=$xs-715*$sx;
$ys=$ye;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# down
$xs=$xe;
$ye=$ys+475*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# at the bottom:left
$xs=$center+595*$sx;
$xe=$center-595*$sx;
$ys=$ye;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# up
$xs=$xe;
$ye=$ys-475*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# left
$xe=$xs-715*$sx;
$ys=$ye;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# up (lower section of left up-line)
$xs=$xe;
$ye=$ys-2400*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# left
$xe=$xs-345*$sx;
$ys=$ye;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# up (middle section of left up-line)
$xs=$xe;
$ye=$ys-1105*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# right
$xe=$xs+345*$sx;
$ys=$ye;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
# up (to close the line)
$xs=$xe;
$ye=-2720*$sy;
push(@mylines,drawcutline($xs,$ys,$xe,$ye,$orientation,$shifty));
}
return @mylines;
}
