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

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



The branch, master has been updated
       via  b1626728f9d65f16208cde500fd76046169869df (commit)
       via  565c250349a949d9cd42ec99e11be653321c6342 (commit)
      from  8f3fcd5ba0c4f26aae49fca59fa128141388b265 (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/file.c |   10 ++++--
 src/misc.c |  108 +++++++++++++++++++++++++++++++++++++++++-------------------
 2 files changed, 81 insertions(+), 37 deletions(-)


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

commit b1626728f9d65f16208cde500fd76046169869df
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Calculate text bounding boxes based on that actual drawn glyphs.
    
    Previously, a text's bounding box was calculated based on overall
    font metrics, not the actual glyphs.  This meant that text clearing
    a polygon would have far more space around it than called for.

:100644 100644 2e471d0... e1e14c8... M	src/misc.c

commit 565c250349a949d9cd42ec99e11be653321c6342
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Make new PCB active during parsing
    
    Set the global PCB pointer to the "new" pcb while it's being loaded.
    Some of the creation functions use the DRC values in PCB to compute,
    for example, bounding boxes.  Before, it used whatever was hanging
    around in the previous PCB (or the default values).

:100644 100644 4e4d55d... 9e38217... M	src/file.c

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

commit b1626728f9d65f16208cde500fd76046169869df
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Calculate text bounding boxes based on that actual drawn glyphs.
    
    Previously, a text's bounding box was calculated based on overall
    font metrics, not the actual glyphs.  This meant that text clearing
    a polygon would have far more space around it than called for.

diff --git a/src/misc.c b/src/misc.c
index 2e471d0..e1e14c8 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -427,58 +427,98 @@ SetTextBoundingBox (FontTypePtr FontPtr, TextTypePtr Text)
 {
   SymbolTypePtr symbol = FontPtr->Symbol;
   unsigned char *s = (unsigned char *) Text->TextString;
-  LocationType width = 0, height = 0;
-  BDimension maxThick = 0;
+  BDimension minThick = 0;
   int i;
+  int space = 0;
+
+  LocationType minx=0, miny=0, maxx=0, maxy=0;
+  LocationType tx;
+  int first_time = 1;
+
+  if (PCB->minSlk < PCB->minWid)
+    minThick = PCB->minWid;
+  else
+    minThick = PCB->minSlk;
+
+  minThick /= Text->Scale / 50.0;
+
+  tx = 0;
 
   /* calculate size of the bounding box */
   for (; s && *s; s++)
-    if (*s <= MAX_FONTPOSITION && symbol[*s].Valid)
-      {
-        LineTypePtr line = symbol[*s].Line;
-        for (i = 0; i < symbol[*s].LineN; line++, i++)
-          if (line->Thickness > maxThick)
-            maxThick = line->Thickness;
-        width += symbol[*s].Width + symbol[*s].Delta;
-        height = MAX (height, (LocationType) symbol[*s].Height);
-      }
-    else
-      {
-        width +=
-          ((FontPtr->DefaultSymbol.X2 - FontPtr->DefaultSymbol.X1) * 6 / 5);
-        height = (FontPtr->DefaultSymbol.Y2 - FontPtr->DefaultSymbol.Y1);
-      }
+    {
+      if (*s <= MAX_FONTPOSITION && symbol[*s].Valid)
+	{
+	  LineTypePtr line = symbol[*s].Line;
+	  for (i = 0; i < symbol[*s].LineN; line++, i++)
+	    {
+	      int t = line->Thickness / 4;
+	      if (t < minThick)
+		t = minThick;
+
+	      if (first_time)
+		{
+		  minx = maxx = line->Point1.X;
+		  miny = maxy = line->Point1.Y;
+		  first_time = 0;
+		}
+
+	      minx = MIN (minx, line->Point1.X - t + tx);
+	      miny = MIN (miny, line->Point1.Y - t);
+	      minx = MIN (minx, line->Point2.X - t + tx);
+	      miny = MIN (miny, line->Point2.Y - t);
+	      maxx = MAX (maxx, line->Point1.X + t + tx);
+	      maxy = MAX (maxy, line->Point1.Y + t);
+	      maxx = MAX (maxx, line->Point2.X + t + tx);
+	      maxy = MAX (maxy, line->Point2.Y + t);
+	    }
+	  space = symbol[*s].Delta;
+	}
+      else
+	{
+	  BoxType *ds = &FontPtr->DefaultSymbol;
+	  int w = ds->X2 - ds->X1;
+
+	  minx = MIN (minx, ds->X1 + tx);
+	  miny = MIN (miny, ds->Y1);
+	  minx = MIN (minx, ds->X2 + tx);
+	  miny = MIN (miny, ds->Y2);
+	  maxx = MAX (maxx, ds->X1 + tx);
+	  maxy = MAX (maxy, ds->Y1);
+	  maxx = MAX (maxx, ds->X2 + tx);
+	  maxy = MAX (maxy, ds->Y2);
+
+	  space = w / 5;
+	}
+      tx += symbol[*s].Width + space;
+    }
 
   /* scale values */
-  width *= Text->Scale / 100.;
-  height *= Text->Scale / 100.;
-  maxThick *= Text->Scale / 200.;
-  if (maxThick < 400)
-    maxThick = 400;
+  minx *= Text->Scale / 100.;
+  miny *= Text->Scale / 100.;
+  maxx *= Text->Scale / 100.;
+  maxy *= Text->Scale / 100.;
 
   /* set upper-left and lower-right corner;
    * swap coordinates if necessary (origin is already in 'swapped')
    * and rotate box
    */
-  Text->BoundingBox.X1 = Text->X;
-  Text->BoundingBox.Y1 = Text->Y;
+
   if (TEST_FLAG (ONSOLDERFLAG, Text))
     {
-      Text->BoundingBox.X1 -= maxThick;
-      Text->BoundingBox.Y1 -= SWAP_SIGN_Y (maxThick);
-      Text->BoundingBox.X2 =
-        Text->BoundingBox.X1 + SWAP_SIGN_X (width + maxThick);
-      Text->BoundingBox.Y2 =
-        Text->BoundingBox.Y1 + SWAP_SIGN_Y (height + 2 * maxThick);
+      Text->BoundingBox.X1 = Text->X + minx;
+      Text->BoundingBox.Y1 = Text->Y - miny;
+      Text->BoundingBox.X2 = Text->X + maxx;
+      Text->BoundingBox.Y2 = Text->Y - maxy;
       RotateBoxLowLevel (&Text->BoundingBox, Text->X, Text->Y,
                          (4 - Text->Direction) & 0x03);
     }
   else
     {
-      Text->BoundingBox.X1 -= maxThick;
-      Text->BoundingBox.Y1 -= maxThick;
-      Text->BoundingBox.X2 = Text->BoundingBox.X1 + width + maxThick;
-      Text->BoundingBox.Y2 = Text->BoundingBox.Y1 + height + 2 * maxThick;
+      Text->BoundingBox.X1 = Text->X + minx;
+      Text->BoundingBox.Y1 = Text->Y + miny;
+      Text->BoundingBox.X2 = Text->X + maxx;
+      Text->BoundingBox.Y2 = Text->Y + maxy;
       RotateBoxLowLevel (&Text->BoundingBox,
                          Text->X, Text->Y, Text->Direction);
     }

commit 565c250349a949d9cd42ec99e11be653321c6342
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Make new PCB active during parsing
    
    Set the global PCB pointer to the "new" pcb while it's being loaded.
    Some of the creation functions use the DRC values in PCB to compute,
    for example, bounding boxes.  Before, it used whatever was hanging
    around in the previous PCB (or the default values).

diff --git a/src/file.c b/src/file.c
index 4e4d55d..9e38217 100644
--- a/src/file.c
+++ b/src/file.c
@@ -351,6 +351,7 @@ int
 LoadPCB (char *Filename)
 {
   PCBTypePtr newPCB = CreateNewPCB (false);
+  PCBTypePtr oldPCB;
   bool units_mm;
 #ifdef DEBUG
   double elapsed;
@@ -359,11 +360,13 @@ LoadPCB (char *Filename)
   start = clock ();
 #endif
 
+  oldPCB = PCB;
+  PCB = newPCB;
+
   /* new data isn't added to the undo list */
-  if (!ParsePCB (newPCB, Filename))
+  if (!ParsePCB (PCB, Filename))
     {
-      RemovePCB (PCB);
-      PCB = newPCB;
+      RemovePCB (oldPCB);
 
       CreateNewPCBPost (PCB, 0);
       ResetStackAndVisibility ();
@@ -412,6 +415,7 @@ LoadPCB (char *Filename)
 
       return (0);
     }
+  PCB = oldPCB;
   hid_action ("PCBChanged");
 
   /* release unused memory */




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