CircuitLayout
view release on metacpan or search on metacpan
Examples/GDS2Tool/gds2tool view on Meta::CPAN
$G_mouseInfoText='mouse buttons: nothing | nothing | nothing';
$G_mouseMode = 'probe';
}
elsif ($G_keyLast eq 'Delete')
{
$G_canvas -> delete('type=drawingTmp');
$G_canvas -> delete('type=rulerTmp');
$G_canvas -> delete('type=ruler');
}
elsif ($G_keyLast eq 'Left') ## pan left
{
my $geom = $G_canvas -> geometry();
my ($xCtr,$yCtr) = split(/[xX]/,$geom);
$yCtr =~ s/[\+\-].*$//;
my $amount = $xCtr / 4;
$xCtr /= 2;
$yCtr /= 2;
pan($G_canvas, $xCtr - $amount, $yCtr);
}
elsif ($G_keyLast eq 'Right') ## pan Right
{
my $geom = $G_canvas -> geometry();
my ($xCtr,$yCtr) = split(/[xX]/,$geom);
$yCtr =~ s/[\+\-].*$//;
my $amount = $xCtr / 4;
$xCtr /= 2;
$yCtr /= 2;
pan($G_canvas, $xCtr + $amount, $yCtr);
}
elsif ($G_keyLast eq 'Up') ## pan Up
{
my $geom = $G_canvas -> geometry();
my ($xCtr,$yCtr) = split(/[xX]/,$geom);
$yCtr =~ s/[\+\-].*$//;
my $amount = $yCtr / 4;
$xCtr /= 2;
$yCtr /= 2;
pan($G_canvas, $xCtr, $yCtr - $amount);
}
elsif ($G_keyLast eq 'Down') ## pan Down
{
my $geom = $G_canvas -> geometry();
my ($xCtr,$yCtr) = split(/[xX]/,$geom);
$yCtr =~ s/[\+\-].*$//;
my $amount = $yCtr / 4;
$xCtr /= 2;
$yCtr /= 2;
pan($G_canvas, $xCtr, $yCtr + $amount);
}
elsif ($G_keyLast eq 'f') ## full view
{
zoom($G_canvas, 1, '', '');
}
elsif ($G_keyLast =~ m/r/i) ## ruler
{
$G_mouseInfoText='mouse buttons: ruler | nothing | nothing';
ruler($G_canvas, 1, '', '');
}
elsif ($G_keyLast eq 'z')
{
$G_canvas -> configure(-cursor => 'crosshair');
zoom($G_canvas, 0, $x - 20, $y - 30);
}
elsif ($G_keyLast eq 'plus')
{
zoom($G_canvas, 2, $x, $y);
}
elsif ($G_keyLast eq 'minus')
{
zoom($G_canvas, 0.5, $x, $y);
}
elsif ($G_keyLast eq 'p') ## pan
{
pan($G_canvas, $x, $y);
}
setCursor();
}
);
$G_keyBindingText = <<EOKBT;
<f> full view
<p> pan to cursor
<r> ruler
<z> zoom in with window
<-> zoom in on cursor
<+> zoom out on cursor
<Escape> clear, interrupt
<Delete> clear rulers
<Up-arrow> pan up
<Down-arrow> pan down
<Right-arrow> pan right
<Left-arrow> pan left
EOKBT
### y scroll bar
my $yScroll = $MW -> Scrollbar(
-activebackground => LightBlueColor,
-background => DarkBlueColor,
-command => [$G_canvas => 'yview'],
-width => SBwidth,
);
### x scroll bar
my $xScroll = $MW -> Scrollbar(
-activebackground => LightBlueColor,
-background => DarkBlueColor,
-command => [$G_canvas => 'xview'],
-orient => 'horizontal',
-width => SBwidth,
);
$G_canvas -> configure(
-xscrollcommand => ['set', $xScroll],
-yscrollcommand => ['set', $yScroll],
);
#### y scrollbar goes on the left side
$yScroll -> pack(
-fill => 'y',
-side => 'left',
);
#### x scrollbar goes on the bottom side
$xScroll -> pack(
-fill => 'x',
-side => 'bottom',
);
$G_canvas -> pack(
-expand => 'yes',
-fill => 'both',
);
$G_canvas -> Tk::bind('<Motion>', [\&reportXY, Ev('x'), Ev('y')]); ## reset
$G_progressBar = $G_canvas -> ProgressBar(
-anchor => 'n',
-blocks => 0,
-colors => [0 => BrightYellowColor],
-from => 0,
-gap => 0,
-highlightthickness => 1,
-resolution => 2,
-to => 99,
-troughcolor => GrayColor,
-variable => \$G_percentDone,
-width => 20,
Examples/GDS2Tool/gds2tool view on Meta::CPAN
0x00, 0x70, 0xe0, 0x83, 0x73, 0xc0, 0x71, 0x00, 0x3e, 0x70, 0xe0, 0x82,
0x73, 0xf8, 0x71, 0x00, 0x64, 0x70, 0xe0, 0x82, 0x73, 0xd0, 0x71, 0x00,
0x44, 0x7c, 0xdd, 0x82, 0x61, 0xd0, 0x71, 0x74, 0x64, 0x72, 0xc2, 0xc3,
0xe1, 0xf0, 0xf9, 0x18, 0x3c, 0x7e, 0x82, 0xe3, 0xc0, 0xf1, 0xf8, 0x1f,
0x04, 0xfe, 0x03, 0x3e, 0x00, 0x1f, 0xf8, 0x1f, 0x04, 0x22, 0x02, 0x02,
0x00, 0x10, 0x88, 0x08, 0x1e, 0x1c, 0x8f, 0x1f, 0x00, 0x78, 0x70, 0x3c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
'
}
################################################################################
sub pan
{
my ($canvas, $x, $y) = @_;
my ($xDataPt, $yDataPt) = $canvas -> worldxy($x,$y);
$canvas -> center($xDataPt, $yDataPt);
$G_statusText = "Panned to ".sprintf("%0.${pp}f %0.${pp}f",$xDataPt,$yDataPt);
}
################################################################################
sub round2Grid($$)
{
my $input = shift;
my $round2grid = shift;
my $scaleNum = 10000;
$input = int($input * $scaleNum);
$round2grid = int($round2grid * $scaleNum);
my $halfGrid = $round2grid/2;
my $modResult = $input % $round2grid;
my $result;
if ($modResult >= $halfGrid)
{
$result = $input + ($round2grid - $modResult);
}
else
{
$result = $input - $modResult;
}
$result /= $scaleNum;
$result;
}
################################################################################
sub ruler
{
my ($canvas, $type, $x, $y) = @_;
if ($x ne '')
{
$G_statusText='Enter another coordinate';
$canvas -> configure(-cursor => 'pencil');
my ($x1,$y1) = $canvas -> worldxy($x,$y); ## convert before call....
$G_startx = round2Grid($x1,$G_xSnapGrid);
$G_starty = round2Grid($y1,$G_ySnapGrid);
startPolygon($canvas,
-type => 'line',
-subtype => $type,
-x => $G_startx,
-y => $G_starty,
-tag => 'type=rulerTmp',
);
}
else
{
if(($G_mouseMode eq 'ruler') || ($G_keyLast eq 'r'))
{
$G_statusText='Enter ruler coordinate';
$canvas -> CanvasBind('<Button-1>' => [\&ruler, 1, Ev('x'), Ev('y')]);
$G_keyLast = '';
}
else
{
$canvas -> CanvasBind('<Button-1>' => '');
}
}
setCursor();
}
################################################################################
sub zoom
{
my ($canvas, $amount, $x, $y) = @_;
if ($amount > 0)
{
if ($amount == 1) ## full view
{
$canvas -> viewFit(-border => 0.02, ['layout=true']);
}
elsif ($amount > 1) ## bigger
{
pan($canvas, $x, $y);
$canvas -> zoom($amount);
$G_statusText='Enter coordinate to zoom on';
}
else ## smaller
{
pan($canvas, $x, $y);
$canvas -> zoom($amount);
$G_statusText='Enter coordinate to zoom on';
}
}
else ## zoom in with window
{
if ($x ne '')
{
$G_statusText='Enter 2nd coordinate';
$canvas -> configure(-cursor => 'crosshair');
my ($x1,$y1) = $canvas -> worldxy($x,$y); ## convert before call....
startPolygon($canvas,
-type => 'rectangle',
-x => $x1,
-y => $y1,
-tag => 'type=drawingTmp',
);
}
else
{
if(($G_mouseMode eq 'zoom in') || ($G_keyLast =~ m/z/i))
{
$G_statusText='Enter coordinate to zoom on';
$canvas -> CanvasBind('<Button-1>' => '');
$canvas -> CanvasBind('<Button-1>' => [\&zoom, 0, Ev('x'), Ev('y')]) if ($G_mouseMode eq 'zoom in');
$canvas -> viewFit('type=drawingTmp');
$canvas -> delete('type=drawingTmp');
setCursor();
$G_keyLast = '';
}
else
{
$canvas -> CanvasBind('<Button-1>' => '');
}
}
}
displayMyGrid($canvas);
}
################################################################################
sub getCanvasPoint
{
my ($canvas, $x, $y) = @_;
$x = $canvas -> worldx($x);
$y = $canvas -> worldy($y);
my @xy = ($x, $y);
@xy;
}
################################################################################
## from Perl/TK book by Nancy Walsh... use for edit in the future
sub bindCheck
{
my $canvas = shift;
my $itemType = shift;
# If there is a "Motion" binding, we need to allow the user
# to finish drawing the item before rebinding Button-1
my @bindings = $canvas -> Tk::bind('<Motion>');
return if ($#bindings >= 0);
}
################################################################################
sub startPolygon
{
my ($canvas, %args) = @_;
my $itemType = $args{'-type'};
if (! defined $itemType)
{
print ERROR,"missing -type arg to startPolygon\n";
Examples/GDS2Tool/gds2tool view on Meta::CPAN
$canvas -> itemconfigure($id,-tags=>\@tags,-fill=>$fill) if ("@tags" =~ m/type=path/ || "@tags" =~ m/type=text\b/);
}
@G_selected = @tmpIds;
}
}
################################################################################
sub unselectFromArray
{
my ($canvas,@ids) = @_;
foreach my $tmp (@ids)
{
my @tags = $canvas -> gettags($tmp);
my $fill = '';
my $layer = '';
my $layout = '';
my $outline = '';
my $stipple = '';
my $type = '';
foreach my $tag (@tags)
{
if ($tag =~ m/=/)
{
my ($id,$value) = split('=',$tag);
if ($value =~ m/^-?[\d\.]+$/)
{
eval("\$$tag");
}
else
{
eval("\$$id='$value'");
}
}
}
$fill = undef if ($fill eq '');
$outline = undef if ($outline eq '');
my $tags="@tags";
$tags =~ s/selected=true/selected=false/;
@tags=split(/\s/,$tags);
$canvas -> itemconfigure($tmp,-tags=>\@tags,-stipple=>$stipple,-fill=>$fill,-outline=>$outline) if ("@tags" =~ m/type=boundary/);
$canvas -> itemconfigure($tmp,-tags=>\@tags,-fill=>$fill) if ("@tags" =~ m/type=path/ || "@tags" =~ m/type=text\b/);
}
}
################################################################################
sub reportXY
{
my ($canvas, $x, $y) = @_;
my ($x1,$y1) = $canvas -> worldxy($x,$y); ## convert before call....
$G_xyStatusText = sprintf("xy:%0.${pp}f %0.${pp}f | #Selected:%d ",
round2Grid($x1,$G_xSnapGrid),
round2Grid($y1,$G_ySnapGrid),
($#G_selected+1));
}
################################################################################
sub setCursor
{
if ($G_mouseMode eq 'pan')
{
$G_canvas -> configure(-cursor => 'circle');
}
elsif ($G_mouseMode eq 'ruler')
{
$G_canvas -> configure(-cursor => 'pencil');
}
elsif ($G_mouseMode =~ m/zoom/)
{
$G_canvas -> configure(-cursor => 'iron_cross') if ($G_mouseMode eq 'zoomin');
$G_canvas -> configure(-cursor => 'fleur') if ($G_mouseMode eq 'zoomout');
}
else
{
$G_canvas -> configure(-cursor => 'arrow');
}
}
################################################################################
sub showGridWindow
{
if (! Exists($G_gridWindow))
{
$G_gridWindow = $MW -> Toplevel();
$G_gridWindow -> title('GDS2Tool set1 grid window');
$G_gridWindow -> iconname('grid');
my $gridFrame1 = $G_gridWindow -> Frame;
$gridFrame1 -> pack(-side => 'top');
#### major x grid
$gridFrame1 -> Label(
-text => ' Major X display grid: ',
-font => '-*-times-bold-r-normal--*-140-*-*-*-*-*-*',
#-background => WhiteColor,
-anchor => 'w',
) -> pack(-side => 'left', -padx => 0, -pady => 5, -fill => 'x');
$gridFrame1 -> Entry(
-font => '-*-courier-medium-r-normal--*-140-*-*-*-*-*-*',
-relief => 'sunken',
-state => 'normal',
-textvariable => \$G_xMajorGridNum,
-width => 11,
-background => WhiteColor,
-foreground => BlackColor,
) -> pack(-side => 'left', -padx => 0, -pady => 5, -fill => 'x');
my $gridFrame2 = $G_gridWindow -> Frame;
$gridFrame2 -> pack(-side => 'top');
#### major y grid
$gridFrame2 -> Label(
-text => ' Major Y display grid: ',
-font => '-*-times-bold-r-normal--*-140-*-*-*-*-*-*',
#-background => WhiteColor,
-anchor => 'w',
) -> pack(-side => 'left', -padx => 0, -pady => 5, -fill => 'x');
$gridFrame2 -> Entry(
-font => '-*-courier-medium-r-normal--*-140-*-*-*-*-*-*',
-relief => 'sunken',
-state => 'normal',
-textvariable => \$G_yMajorGridNum,
-width => 11,
-background => WhiteColor,
-foreground => BlackColor,
) -> pack(-side => 'left', -padx => 0, -pady => 5, -fill => 'x');
my $gridFrame3 = $G_gridWindow -> Frame;
$gridFrame3 -> pack(-side => 'top');
#### minor x grid
$gridFrame3 -> Label(
-text => ' Minor X display grid: ',
-font => '-*-times-bold-r-normal--*-140-*-*-*-*-*-*',
#-background => WhiteColor,
-anchor => 'w',
( run in 0.523 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )