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

gEDA-cvs: pcb.git: branch: master updated (73f900441103cedc62e6f83e6052c83431fab46b)



The branch, master has been updated
       via  73f900441103cedc62e6f83e6052c83431fab46b (commit)
      from  b7ca83f0183ae97b165de2322815cb77c2a2bb45 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/report.c |  148 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 133 insertions(+), 15 deletions(-)


=================
 Commit Messages
=================

commit 73f900441103cedc62e6f83e6052c83431fab46b
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Add "report all net lengths" option
    
    Usage: Report (AllNetLengths[,(mm|in|mil|pcb)])

:100644 100644 0c610d1... 98b4f23... M	src/report.c

=========
 Changes
=========

commit 73f900441103cedc62e6f83e6052c83431fab46b
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Add "report all net lengths" option
    
    Usage: Report (AllNetLengths[,(mm|in|mil|pcb)])

diff --git a/src/report.c b/src/report.c
index 0c610d1..98b4f23 100644
--- a/src/report.c
+++ b/src/report.c
@@ -541,19 +541,13 @@ ReportFoundPins (int argc, char **argv, int x, int y)
   return 0;
 }
 
-static int
-ReportNetLength (int argc, char **argv, int x, int y)
+static double
+XYtoNetLength (int x, int y, int *found)
 {
-  double length = 0;
-  char *netname = 0;
-  int found = 0;
+  double length;
 
-  SaveUndoSerialNumber ();
-  ResetFoundPinsViasAndPads (True);
-  RestoreUndoSerialNumber ();
-  ResetFoundLinesAndPolygons (True);
-  RestoreUndoSerialNumber ();
-  gui->get_coords ("Click on a connection", &x, &y);
+  length = 0;
+  *found = 0;
   LookupConnection (x, y, True, PCB->Grid, FOUNDFLAG);
 
   ALLLINE_LOOP (PCB->Data);
@@ -566,7 +560,7 @@ ReportNetLength (int argc, char **argv, int x, int y)
 	dy = line->Point1.Y - line->Point2.Y;
 	l = sqrt ((double)dx*dx + (double)dy*dy);
 	length += l;
-	found = 1;
+	*found = 1;
       }
   }
   ENDALL_LOOP;
@@ -579,11 +573,128 @@ ReportNetLength (int argc, char **argv, int x, int y)
 	/* FIXME: we assume width==height here */
 	l = M_PI * 2*arc->Width * abs(arc->Delta)/360.0;
 	length += l;
-	found = 1;
+	*found = 1;
       }
   }
   ENDALL_LOOP;
 
+  return length;
+}
+
+static int
+ReportAllNetLengths (int argc, char **argv, int x, int y)
+{
+  enum { Upcb, Umm, Umil, Uin } units;
+  int ni, nei;
+  int found;
+  double length;
+
+  units = Settings.grid_units_mm ? Umm : Umil;
+
+  if (argc >= 1)
+    {
+      printf("Units: %s\n", argv[0]);
+      if (strcasecmp (argv[0], "mm") == 0)
+	units = Umm;
+      else if (strcasecmp (argv[0], "mil") == 0)
+	units = Umil;
+      else if (strcasecmp (argv[0], "in") == 0)
+	units = Uin;
+      else
+	units = Upcb;
+    }
+
+  for (ni = 0; ni < PCB->NetlistLib.MenuN; ni++)
+    {
+      char *netname = PCB->NetlistLib.Menu[ni].Name + 2;
+      char *ename = PCB->NetlistLib.Menu[ni].Entry[0].ListEntry;
+      char *pname;
+
+      ename = strdup (ename);
+      pname = strchr (ename, '-');
+      if (! pname)
+	{
+	  free (ename);
+	  continue;
+	}
+      *pname++ = 0;
+
+      ELEMENT_LOOP (PCB->Data);
+      {
+	char *es = element->Name[NAMEONPCB_INDEX].TextString;
+	if (es && strcmp (es, ename) == 0)
+	  {
+	    PIN_LOOP (element);
+	    {
+	      if (strcmp (pin->Number, pname) == 0)
+		{
+		  x = pin->X;
+		  y = pin->Y;
+		  goto got_one;
+		}
+	    }
+	    END_LOOP;
+	    PAD_LOOP (element);
+	    {
+	      if (strcmp (pad->Number, pname) == 0)
+		{
+		  x = (pad->Point1.X + pad->Point2.X) / 2;
+		  y = (pad->Point1.Y + pad->Point2.Y) / 2;
+		  goto got_one;
+		}
+	    }
+	    END_LOOP;
+	  }
+      }
+      END_LOOP;
+
+      continue;
+
+    got_one:
+      SaveUndoSerialNumber ();
+      ResetFoundPinsViasAndPads (True);
+      RestoreUndoSerialNumber ();
+      ResetFoundLinesAndPolygons (True);
+      RestoreUndoSerialNumber ();
+      length = XYtoNetLength (x, y, &found);
+
+      switch (units)
+	{
+	case Upcb:
+	  gui->log("Net %s length %d\n", netname, (int)length);
+	  break;
+	case Umm:
+	  length *= COOR_TO_MM;
+	  gui->log("Net %s length %.2f mm\n", netname, length);
+	  break;
+	case Umil:
+	  length /= 100;
+	  gui->log("Net %s length %d mil\n", netname, (int)length);
+	  break;
+	case Uin:
+	  length /= 100000.0;
+	  gui->log("Net %s length %.3f in\n", netname, length);
+	  break;
+	}
+    }
+}
+
+static int
+ReportNetLength (int argc, char **argv, int x, int y)
+{
+  double length = 0;
+  char *netname = 0;
+  int found = 0;
+
+  SaveUndoSerialNumber ();
+  ResetFoundPinsViasAndPads (True);
+  RestoreUndoSerialNumber ();
+  ResetFoundLinesAndPolygons (True);
+  RestoreUndoSerialNumber ();
+  gui->get_coords ("Click on a connection", &x, &y);
+
+  XYtoNetLength (x, y, &found);
+
   if (!found)
     {
       gui->log ("No net under cursor.\n");
@@ -659,7 +770,7 @@ ReportNetLength (int argc, char **argv, int x, int y)
  * syntax: 
  */
 
-static const char report_syntax[] = "Report(Object|DrillReport|FoundPins|NetLength)";
+static const char report_syntax[] = "Report(Object|DrillReport|FoundPins|NetLength|AllNetLengths)";
 
 static const char report_help[] = "Produce various report.";
 
@@ -683,6 +794,11 @@ be produced.
 The name and length of the net under the crosshair will be reported to
 the message log.
 
+@item AllNetLengths
+The name and length of the net under the crosshair will be reported to
+the message log.  An optional parameter specifies mm, mil, pcb, or in
+units
+
 @end table
 
 %end-doc */
@@ -690,7 +806,7 @@ the message log.
 static int
 Report (int argc, char **argv, int x, int y)
 {
-  if (argc != 1)
+  if (argc < 1)
     AUSAGE (report);
   else if (strcasecmp (argv[0], "Object") == 0)
     {
@@ -703,6 +819,8 @@ Report (int argc, char **argv, int x, int y)
     return ReportFoundPins (argc - 1, argv + 1, x, y);
   else if (strcasecmp (argv[0], "NetLength") == 0)
     return ReportNetLength (argc - 1, argv + 1, x, y);
+  else if (strcasecmp (argv[0], "AllNetLengths") == 0)
+    return ReportAllNetLengths (argc - 1, argv + 1, x, y);
   else
     AFAIL (report);
   return 1;




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs