[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: djboxsym - yet another symbol creator



Hello DJ

The attached patch fixes up the the following issues I found while
using your new perl script:

* Only use the visible part of the label when calculating it's length.
* Output top and bottom pins in the listed order not by number.
* Align top and bottom pins to 100 mils.

Robert

On Sun, Apr 09, 2006 at 12:24:18AM -0400, DJ Delorie wrote:
> 
> I wasn't looking forward to creating yet another box symbol, so
> instead I spent far more time writing a tool to do it for me.  Yeah,
> I'm that kind of hacker.  OTOH, the second symbol I used it for only
> took a minute or so to create.
> 
> Similar in functionality to tragesym, with some differences:
> 
> * You don't use gnumeric (or any other spreadsheet).
> * The symbols are in my "compromise" format.
> * No DRC support (use my sym2csv/csv2sym programs for that).
> * Supports packed bus pins.
> * It's in perl instead of python ;-)
> 
> http://www.gedasymbols.org/user/dj_delorie/tools/djboxsym.html
> 
> I also uploaded the CP2200/CP2201 symbols I made with it.
--- djboxsym.orig	2006-04-09 15:59:31.000000000 +0000
+++ djboxsym	2006-04-09 17:00:22.000000000 +0000
@@ -92,12 +92,17 @@
 	} else {
 	    $pinlabel{$pin} = $rest;
 	}
-	$rlen{$pin} = &textlen($rest);
+	$rlen{$pin} = &textlen($pinlabel{$pin});
 
 	if ($side =~ /left|right/) {
 	    $y = $piny{$pin} = $y{$side};
 	    $y{$side} += ($busmode ? 200 : 400);
 	}
+	if ($side =~ /top|bottom/) {
+	    $tw = alignpin((200 + $rlen{$pin}) / 2);
+	    $pinx{$pin} = $w{$side} + $tw;
+	    $w{$side} += $tw + $tw;
+	}
 
     }
 
@@ -111,7 +116,7 @@
 # width is used up by the left, middle, and right labels.
 for $lp ($minpin..$maxpin) {
     next unless $pinside{$lp} =~ /left|right|label/;
-    $yb = int($piny{$lp}/100)*100;
+    $yb = alignpin($piny{$lp});
     for ($y=$yb-100; $y<=$yb+100; $y+=100) {
 	if ($bw{$y}{$pinside{$lp}} < $rlen{$lp}) {
 	    $bw{$y}{$pinside{$lp}} = $rlen{$lp};
@@ -150,13 +155,6 @@
     }
 }
 
-# Compute the positions of the top/bottom labels.
-for $p (1..$maxpin) {
-    next unless $pinside{$p} =~ /top|bottom/;
-    $tw = 200 + &textlen($pinlabel{$p});
-    $pinx{$p} = $w{$pinside{$p}} + $tw/2;
-    $w{$pinside{$p}} += $tw;
-}
 $boxwidth = $w{top} if $boxwidth < $w{top};
 $boxwidth = $w{bottom} if $boxwidth < $w{bottom};
 
@@ -167,19 +165,19 @@
     $piny{$p} = $maxy - $piny{$p} + 300;
 }
 
-$boxwidth = int(($boxwidth + 99) / 100) * 100;
+$boxwidth = alignpin($boxwidth);
 $boxwidth += 200;
 
 # Adjust the position of the top/bottom pins so that, as a group,
 # they're centered.
 for $p ($minpin..$maxpin) {
     next unless $pinside{$p} =~ /top|bottom/;
-    $pinx{$p} += ($boxwidth - $w{$pinside{$p}})/2 + 300;
+    $pinx{$p} += alignpin(($boxwidth - $w{$pinside{$p}})/2) + 300;
 }
 
 # Labels are centered in the box.
 for $lp ($minpin..-1) {
-    $pinx{$lp} = $boxwidth/2 + 300;
+    $pinx{$lp} = alignpin($boxwidth/2) + 300;
 }
 
 # Version.
@@ -330,4 +328,9 @@
     return length($t) * 110;
 }
 
+sub alignpin {
+    my($v) = @_;
+    return int(($v + 99) / 100) * 100;
+}
+
 exit $errors;