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

gEDA-user: PCB patches (was: [PATCH 1/7] PCB localization)



On Tue, May 25, 2010 at 1:58 PM, Bert Timmerman
<bert.timmerman@xxxxxxxxx> wrote:
>> By email also has its advantages:
>>
>> 1. Email means the patches get seen and reviewed 2. Git sends
>> the email for you - so no extra work for the sender 3. I can
>> save the patches without having to poke sourceforge 4. I can
>> save the patches without having to poke sourceforge
>>
>
> 5. *all* the impatient geda-users can apply the patches to their local
> repository themselves, and have a test drive, without having to poke
> sourceforge.
>
> 6. *all* impatient geda-devs can apply the patches to their local repository
> themselves, and have a test drive, without having to poke sourceforge ;-)
>

Last time this was brought up there was a big discussion about how
pretty much everyone is not happy with the sourceforge trackers.  A
few of us asked to be allowed to help out to get a new tracker up and
going so the devs didn't have to spend their time worrying about, but
I got a definite impression any work on that front would also not be
used by the developers (that blaming it on sourceforge was just a
euphemism for "we don't have enough time to deal with contributions,"
which is unfortunate but understandable.)

So being stuck with sourceforge I thought maybe I could help out and
make it a little nicer, got my sourceforge account access to the PCB
trackers, cleaned up a few bugs, and tackled a few that I felt like I
could handle.  Put the patches in the patch tracker, commented on the
bug that a patch was available, etc.  The result? One of four patches
applied; better than nothing I guess.

There was a suggestion that a group of non-devs go through and filter
bugs and patches and suggest patches for the devs to review.  Until
there is evidence that there is a process or method of handling
patches within the devs themselves, it seems such a team wouldn't be
of much use.

So since the only way to contribute to PCB seems to be to continually
spam the list with patches, here's three patches to fix bugs in the
bug tracker.  Comments welcome.  If any of the devs have any
suggestions for how I can better contribute to PCB, I'd be glad to
hear it.  I don't want to sound like I'm continually complaining, I
just want to know how to help out.

Jared
From 2344dab7f2544e33a7374d763a24db7e6a42cb86 Mon Sep 17 00:00:00 2001
From: Jared Casper <jaredcasper@xxxxxxxxx>
Date: Fri, 9 Apr 2010 15:32:34 -0700
Subject: [PATCH] Fix pr2717258, Lock mode with F12.

Binds F12 to lock mode in the default gcpb-menu.res and pcb-menu.res
files, bringing them inline with existing documentation.
---
 src/gpcb-menu.res |    2 +-
 src/pcb-menu.res  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gpcb-menu.res b/src/gpcb-menu.res
index 1511e09..29e575f 100644
--- a/src/gpcb-menu.res
+++ b/src/gpcb-menu.res
@@ -518,7 +518,7 @@ PopupMenus =
        {"Insert Point" checked=insertpointmode,1 Mode(InsertPoint) a={"Insert" "<Key>Insert"}}
        {"Move" checked=movemode,1 Mode(Move)}
        {"Copy" checked=copymode,1 Mode(Copy)}
-       {"Lock" checked=lockmode,1 Mode(Lock)}
+       {"Lock" checked=lockmode,1 Mode(Lock) a={"F12" "<Key>F12"}}
        {"Cancel" Mode(Escape) a={"Esc" "<Key>Escape"}}
       }
     }
diff --git a/src/pcb-menu.res b/src/pcb-menu.res
index c18eb86..69ed6f5 100644
--- a/src/pcb-menu.res
+++ b/src/pcb-menu.res
@@ -182,7 +182,7 @@ MainMenu =
    {"Insert Point" checked=insertpointmode,1 Mode(InsertPoint) a={"Insert" "<Key>Insert"}}
    {"Move" checked=movemode,1 Mode(Move)}
    {"Copy" checked=copymode,1 Mode(Copy)}
-   {"Lock" checked=lockmode,1 Mode(Lock)}
+   {"Lock" checked=lockmode,1 Mode(Lock) a={"F12" "<Key>F12"}}
    {"Cancel" Mode(Cancel) a={"Esc" "<Key>Escape"}}
    -
    {"Command" Command() a={":" "<Key>:"}}
-- 
1.7.1

From f4deaa4efc523c89ff12dc8aa17288e3d10db1ef Mon Sep 17 00:00:00 2001
From: Jared Casper <jaredcasper@xxxxxxxxx>
Date: Fri, 16 Apr 2010 21:30:14 -0700
Subject: [PATCH] Fix pr2924962 and other issues with layer selection in the gtk hid.

In general there was a lack of consistency in the behavior when
changing the visibility of layers using the buttons and menu.  This
fixes both the hang in the bug report, and many other small issues.

The code attempted to make it so that the active layer was always
visible, but failed in a few places, such as when the silk or rats
layers were activated while hidden or hidden while active, or when the
last layer group was active and hidden, it remained active. There was
also issues when the active layer was hidden using the menus.  This
patch fixes all of that.

This patch allows the active layer to become the silk or rats layer if
no copper layer is visible.

It was necessary to add an additional flag to ChangeGroupVisibility()
to indicate if the hid should be notified via the LayersChanged
action.  This was causing problem when the menu was used to hide the
active layer, an extra LayersChanged call was scheduling a
ghid_menu_cb which reverted the change to the layer visibility.  In
generally this was causing also just causing a lot of extra calls to
update the gui when the gui itself was calling ChangeGroupVisibility
and was going to be updating itself later on anyway.  For the most
part I set the new flag to be true (to keep the old behavior) except
when it was causing problems and definitely correct to set it to
false.
---
 src/action.c                 |    2 +-
 src/find.c                   |    2 +-
 src/hid/gtk/gtkhid-main.c    |    8 ++--
 src/hid/gtk/gui-drc-window.c |    3 +-
 src/hid/gtk/gui-top-window.c |  115 +++++++++++++++++++++++++++++++++---------
 src/hid/lesstif/main.c       |    8 ++--
 src/hid/lesstif/menu.c       |    2 +-
 src/misc.c                   |   17 ++++---
 src/misc.h                   |    2 +-
 src/move.c                   |    2 +-
 10 files changed, 116 insertions(+), 45 deletions(-)

diff --git a/src/action.c b/src/action.c
index 6bbee09..d1e2d29 100644
--- a/src/action.c
+++ b/src/action.c
@@ -6542,7 +6542,7 @@ ActionSetSame (int argc, char **argv, int x, int y)
     }
   if (layer != CURRENT)
     {
-      ChangeGroupVisibility (GetLayerNumber (PCB->Data, layer), True, True);
+      ChangeGroupVisibility (GetLayerNumber (PCB->Data, layer), True, True, True);
       ClearAndRedrawOutput ();
     }
   return 0;
diff --git a/src/find.c b/src/find.c
index 6fb62b6..9683b4b 100644
--- a/src/find.c
+++ b/src/find.c
@@ -4522,7 +4522,7 @@ GotoError (void)
     case POLYGON_TYPE:
       ChangeGroupVisibility (GetLayerNumber
                              (PCB->Data, (LayerTypePtr) thing_ptr1), True,
-                             True);
+                             True, True);
     }
   CenterDisplay (X, Y, False);
 }
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 90d1485..f9584ac 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -1556,9 +1556,9 @@ SwapSides (int argc, char **argv, int x, int y)
       if (active_group == comp_group && comp_showing && !solder_showing)
 	{
 	  ChangeGroupVisibility (PCB->LayerGroups.Entries[comp_group][0], 0,
-				 0);
+				 0, 1);
 	  ChangeGroupVisibility (PCB->LayerGroups.Entries[solder_group][0], 1,
-				 1);
+				 1, 1);
 	}
     }
   else
@@ -1566,9 +1566,9 @@ SwapSides (int argc, char **argv, int x, int y)
       if (active_group == solder_group && solder_showing && !comp_showing)
 	{
 	  ChangeGroupVisibility (PCB->LayerGroups.Entries[solder_group][0], 0,
-				 0);
+				 0, 1);
 	  ChangeGroupVisibility (PCB->LayerGroups.Entries[comp_group][0], 1,
-				 1);
+				 1, 1);
 	}
     }
 
diff --git a/src/hid/gtk/gui-drc-window.c b/src/hid/gtk/gui-drc-window.c
index fa2ec86..460d241 100644
--- a/src/hid/gtk/gui-drc-window.c
+++ b/src/hid/gtk/gui-drc-window.c
@@ -236,7 +236,8 @@ selection_changed_cb (GtkTreeSelection *selection, gpointer user_data)
 	case LINE_TYPE:
 	case ARC_TYPE:
 	case POLYGON_TYPE:
-	  ChangeGroupVisibility (GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1), True, True);
+	  ChangeGroupVisibility (GetLayerNumber (PCB->Data, (LayerTypePtr) ptr1),
+                                 True, True, True);
 	}
       DrawObject (object_type, ptr1, ptr2, 0);
     }
diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index e61c9f3..d3fe447 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -1346,11 +1346,23 @@ layer_select_button_cb (GtkWidget * widget, LayerButtonSet * lb)
 
   in_cb = TRUE;
 
-  PCB->SilkActive = (lb->index == LAYER_BUTTON_SILK);
-  PCB->RatDraw = (lb->index == LAYER_BUTTON_RATS);
+  switch (lb->index)
+    {
+    case LAYER_BUTTON_SILK:
+      PCB->SilkActive = True;
+      PCB->ElementOn = True;
+      PCB->Data->SILKLAYER.On = PCB->ElementOn;
+      PCB->Data->BACKSILKLAYER.On = PCB->ElementOn;
+      break;
+
+    case LAYER_BUTTON_RATS:
+      PCB->RatDraw = True;
+      PCB->RatOn = True;
+      break;
+    }
 
   if (lb->index < max_layer)
-    ChangeGroupVisibility (lb->index, True, True);
+    ChangeGroupVisibility (lb->index, True, True, False);
 
   layer_select_button_index = lb->index;
 
@@ -1364,11 +1376,52 @@ layer_select_button_cb (GtkWidget * widget, LayerButtonSet * lb)
   in_cb = FALSE;
 }
 
+/* ----------------------------------------------------------------------
+ * Puts the next available layer active.  First trys to make a copper
+ * layer active, failing that will go to the silk layer, then the rat layer
+ * returns true if successful, false if there is no layer available to activate
+ */
+static gboolean
+activate_next_available_layer (gint layer)
+{
+  gint i, group, orig_layer;
+  group = GetGroupOfLayer (layer);
+
+  /* if we were on one of the special layers, try to move to a copper layer */
+  orig_layer = layer;
+  if (layer >= max_layer)
+    layer = max_layer - 1;
+
+  for (i = (layer + 1) % (max_layer); i != layer; i = (i + 1) % (max_layer))
+    if (PCB->Data->Layer[i].On == True && GetGroupOfLayer (i) != group)
+      break;
+  if (i != layer)
+    {
+      ChangeGroupVisibility ((int) i, True, True, False);
+    }
+  else
+    {
+      /* no copper layers to switch to, try silk and rats */
+      if (PCB->ElementOn && (orig_layer != LAYER_BUTTON_SILK))
+        {
+          PCB->SilkActive = True;
+        }
+      else if (PCB->RatOn && (orig_layer != LAYER_BUTTON_RATS))
+        {
+          PCB->RatDraw = True;
+        }
+      /* via layer, etc. can't be active, so they don't work */
+      else
+        return False;
+    }
+  return True;
+}
+
 static void
 layer_enable_button_cb (GtkWidget * widget, gpointer data)
 {
   LayerButtonSet *lb;
-  gint i, group, layer = GPOINTER_TO_INT (data);
+  gint group, layer = GPOINTER_TO_INT (data);
   gboolean active, redraw = FALSE;
 
   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
@@ -1380,6 +1433,16 @@ layer_enable_button_cb (GtkWidget * widget, gpointer data)
   switch (layer)
     {
     case LAYER_BUTTON_SILK:
+      if (PCB->SilkActive)
+        {
+          if (!activate_next_available_layer (layer))
+            {
+              Message (_("Can't turn off last visible editable layer.\n"));
+              gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+              return;
+            }
+          PCB->SilkActive = False;
+        }
       PCB->ElementOn = active;
       PCB->Data->SILKLAYER.On = PCB->ElementOn;
       PCB->Data->BACKSILKLAYER.On = PCB->ElementOn;
@@ -1387,6 +1450,16 @@ layer_enable_button_cb (GtkWidget * widget, gpointer data)
       break;
 
     case LAYER_BUTTON_RATS:
+      if (PCB->RatDraw)
+        {
+          if (!activate_next_available_layer (layer))
+            {
+              Message (_("Can't turn off last visible editable layer.\n"));
+              gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+              return;
+            }
+          PCB->RatDraw = False;
+        }
       PCB->RatOn = active;
       redraw = 1;
       break;
@@ -1416,31 +1489,23 @@ layer_enable_button_cb (GtkWidget * widget, gpointer data)
       break;
 
     default:
-      /* check if active layer is in the group;
+      /* check if active layer (which must be visible) is in the group;
          |  if YES, make a different one active if possible.  Logic from
          |  Xt PCB code.
        */
       if ((group = GetGroupOfLayer (layer)) ==
-	  GetGroupOfLayer (MIN (max_layer, INDEXOFCURRENT)))
-	{
-	  for (i = (layer + 1) % (max_layer + 1); i != layer;
-	       i = (i + 1) % (max_layer + 1))
-	    if (PCB->Data->Layer[i].On == True &&
-		GetGroupOfLayer (i) != group)
-	      break;
-	  if (i != layer)
-	    {
-	      ChangeGroupVisibility ((int) i, True, True);
-	    }
-	  else
-	    {
-	      /* everything else off, we can't turn this off too */
-	      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
-	      return;
-	    }
-	}
+          GetGroupOfLayer (MIN (max_layer, INDEXOFCURRENT)))
+        {
+          if (!activate_next_available_layer (layer))
+            {
+              Message (_("Can't turn off last visible editable layer.\n"));
+              gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+              return;
+            }
+        }
+
       /* switch layer group on/off */
-      ChangeGroupVisibility (layer, active, False);
+      ChangeGroupVisibility (layer, active, False, False);
       redraw = TRUE;
       break;
     }
@@ -2814,7 +2879,9 @@ ToggleView (int argc, char **argv, int x, int y)
 
     }
 
+#ifdef DEBUG_MENUS
   printf ("ToggleView():  l = %d\n", l);
+#endif
 
   /* Now that we've figured out which toggle button ought to control
    * this layer, simply hit the button and let the pre-existing code deal
diff --git a/src/hid/lesstif/main.c b/src/hid/lesstif/main.c
index 1613547..d5d7846 100644
--- a/src/hid/lesstif/main.c
+++ b/src/hid/lesstif/main.c
@@ -603,9 +603,9 @@ SwapSides (int argc, char **argv, int x, int y)
 	    {
 	      if (comp_showing && !solder_showing)
 		ChangeGroupVisibility (PCB->LayerGroups.Entries[comp_group][0], 0,
-				       0);
+				       0, 1);
 	      ChangeGroupVisibility (PCB->LayerGroups.Entries[solder_group][0], 1,
-				     1);
+				     1, 1);
 	    }
 	}
       else
@@ -614,9 +614,9 @@ SwapSides (int argc, char **argv, int x, int y)
 	    {
 	      if (solder_showing && !comp_showing)
 		ChangeGroupVisibility (PCB->LayerGroups.Entries[solder_group][0], 0,
-				       0);
+				       0, 1);
 	      ChangeGroupVisibility (PCB->LayerGroups.Entries[comp_group][0], 1,
-				     1);
+				     1, 1);
 	    }
 	}
     }
diff --git a/src/hid/lesstif/menu.c b/src/hid/lesstif/menu.c
index f88664d..ca0dba3 100644
--- a/src/hid/lesstif/menu.c
+++ b/src/hid/lesstif/menu.c
@@ -391,7 +391,7 @@ layerpick_button_callback (Widget w, int layer,
   PCB->RatDraw = (layer == LB_RATS);
   PCB->SilkActive = (layer == LB_SILK);
   if (layer < max_layer)
-    ChangeGroupVisibility (layer, 1, 1);
+    ChangeGroupVisibility (layer, 1, 1, 1);
   for (l = 0; l < num_layer_buttons; l++)
     {
       LayerButtons *lb = layer_button_list + l;
diff --git a/src/misc.c b/src/misc.c
index 20048db..a3f73c2 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1023,7 +1023,8 @@ PushOnTopOfLayerStack (int NewTop)
  * returns the number of changed layers
  */
 int
-ChangeGroupVisibility (int Layer, Boolean On, Boolean ChangeStackOrder)
+ChangeGroupVisibility (int Layer, Boolean On,
+                       Boolean ChangeStackOrder, Boolean UpdateHid)
 {
   int group, i, changed = 1;    /* at least the current layer changes */
 
@@ -1032,8 +1033,9 @@ ChangeGroupVisibility (int Layer, Boolean On, Boolean ChangeStackOrder)
    */
 
   if (Settings.verbose)
-    printf ("ChangeGroupVisibility(Layer=%d, On=%d, ChangeStackOrder=%d)\n",
-            Layer, On, ChangeStackOrder);
+    printf ("ChangeGroupVisibility(Layer=%d, On=%d, "
+            "ChangeStackOrder=%d, UpdateHid=%d)\n",
+            Layer, On, ChangeStackOrder, UpdateHid);
 
   /* decrement 'i' to keep stack in order of layergroup */
   if ((group = GetGroupOfLayer (Layer)) < max_layer)
@@ -1059,7 +1061,8 @@ ChangeGroupVisibility (int Layer, Boolean On, Boolean ChangeStackOrder)
     PushOnTopOfLayerStack (Layer);
 
   /* update control panel and exit */
-  hid_action ("LayersChanged");
+  if (UpdateHid)
+    hid_action ("LayersChanged");
   return (changed);
 }
 
@@ -1135,7 +1138,7 @@ LayerStringToLayerStack (char *s)
       else if (isdigit ((int) args[i][0]))
 	{
 	  lno = atoi (args[i]);
-	  ChangeGroupVisibility (lno, True, True);
+	  ChangeGroupVisibility (lno, True, True, True);
 	}
       else
 	{
@@ -1143,7 +1146,7 @@ LayerStringToLayerStack (char *s)
 	  for (lno = 0; lno < max_layer; lno++)
 	    if (strcasecmp (args[i], PCB->Data->Layer[lno].Name) == 0)
 	      {
-		ChangeGroupVisibility (lno, True, True);
+		ChangeGroupVisibility (lno, True, True, True);
 		found = 1;
 		break;
 	      }
@@ -1357,7 +1360,7 @@ ResetStackAndVisibility (void)
 
   /* Bring the component group to the front and make it active.  */
   comp_group = GetLayerGroupNumberByNumber (max_layer + COMPONENT_LAYER);
-  ChangeGroupVisibility (PCB->LayerGroups.Entries[comp_group][0], 1, 1);
+  ChangeGroupVisibility (PCB->LayerGroups.Entries[comp_group][0], 1, 1, 1);
 }
 
 /* ---------------------------------------------------------------------------
diff --git a/src/misc.h b/src/misc.h
index 3634f9b..aa1fcbd 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -59,7 +59,7 @@ int GetLayerNumber (DataTypePtr, LayerTypePtr);
 int GetLayerGroupNumberByPointer (LayerTypePtr);
 int GetLayerGroupNumberByNumber (Cardinal);
 int GetGroupOfLayer (int);
-int ChangeGroupVisibility (int, Boolean, Boolean);
+int ChangeGroupVisibility (int, Boolean, Boolean, Boolean);
 void LayerStringToLayerStack (char *);
 
 
diff --git a/src/move.c b/src/move.c
index 6f0c82f..147a079 100644
--- a/src/move.c
+++ b/src/move.c
@@ -1155,7 +1155,7 @@ MoveLayerAction (int argc, char **argv, int x, int y)
     new_top = new_index;
 
   if (new_top != -1)
-    ChangeGroupVisibility (new_index, 1, 1);
+    ChangeGroupVisibility (new_index, 1, 1, 1);
 
   return 0;
 }
-- 
1.7.1

From 57b0ffde0fc5813d0da9b0f70c4064c0f8782b95 Mon Sep 17 00:00:00 2001
From: Jared Casper <jaredcasper@xxxxxxxxx>
Date: Thu, 8 Apr 2010 22:42:39 -0700
Subject: [PATCH] Fix pr2976245, refdes labels in new layout can't be moved.

The .pcb file that gsch2pcb creates does not have a font in it.  When
loading files, the bounding box for all the text is calculated as the
file is read.  In the case that there is no font, this is before the
default font is installed, so the bounding box is way too small.

This is remedied by looping through all the text and resetting the
bouding box after the default font is installed (if there was no font
in the file).
---
 src/file.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/file.c b/src/file.c
index 639c971..9299232 100644
--- a/src/file.c
+++ b/src/file.c
@@ -92,6 +92,7 @@
 #include "polygon.h"
 #include "rats.h"
 #include "remove.h"
+#include "rtree.h"
 #include "set.h"
 #include "strflags.h"
 
@@ -384,6 +385,26 @@ LoadPCB (char *Filename)
 		   ("File '%s' has no font information, using default font\n"),
 		   Filename);
 	  CreateDefaultFont ();
+          /* Bounding box on text was calcuated with empty font,
+           * so it needs to be recalculated */
+          ELEMENT_LOOP (PCB->Data);
+          {
+            ELEMENTTEXT_LOOP (element);
+            {
+              SetTextBoundingBox (&PCB->Font, text);
+            }
+            END_LOOP;
+          }
+          END_LOOP;
+          ALLTEXT_LOOP (PCB->Data);
+          {
+            r_delete_entry (layer->text_tree, (BoxTypePtr) text);
+            RestoreToPolygon (PCB->Data, TEXT_TYPE, layer, text);
+            SetTextBoundingBox (&PCB->Font, text);
+            ClearFromPolygon (PCB->Data, TEXT_TYPE, layer, text);
+            r_insert_entry (layer->text_tree, (BoxTypePtr) text, 0);
+          }
+          ENDALL_LOOP;
 	}
 
       /* clear 'changed flag' */
-- 
1.7.1


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