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

Re: gEDA-user: Information on PCB



On 10/27/09, Ineiev <ineiev@xxxxxxxxx> wrote:
> Try the attached patch; it introduces SwapSides_nogui action for such
Awfully sorry, forgot to commit a typo fix;
and there is no need in `compatible' with GTK and Lesstif hids
arguments parsing.

BTW, it seems to me that it does not really changes the groups
visibility: I press Tab with `component' layer from the component
group active and see the same `component' above all; the pads
are shown from the right side, though. am I doing
something wrong? I stack the patches on top of current master.
From 303def6c5467f63383b58b5fe0353dd97415e647 Mon Sep 17 00:00:00 2001
From: Ineiev <ineiev@xxxxxxxxxxxxxxxx>
Date: Tue, 27 Oct 2009 03:05:47 +0000
Subject: [PATCH] Add SwapSides_nogui action

The action is similar to SwapSides, but it
depends on no real GUI, so can have effect when
running an exporter from command line or
with batch GUI.
---
 src/action.c |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/src/action.c b/src/action.c
index 6b979d3..9ac52e8 100644
--- a/src/action.c
+++ b/src/action.c
@@ -6793,6 +6793,66 @@ ActionPSCalib (int argc, char **argv, int x, int y)
   return 0;
 }
 
+/* ---------------------------------------------------------------------- */
+static const char swapsides_syntax[] =
+"SwapSides_nogui()";
+
+static const char swapsides_help[] =
+"Swaps the side of the board you're looking at.";
+
+/* %start-doc actions SwapSides_nogui
+
+This action shows the opposite side of the board: version
+for scripts when there is no GUI.
+
+Normally, this action changes which pads and silk layer are drawn as
+true silk, and which are drawn as the "invisible" layer.  It also
+determines which solder mask you see.
+
+As a special case, if the layer group for the side you're looking at
+is visible and currently active, and the layer group for the opposite
+is not visible (i.e. disabled), then this action will also swap which
+layer group is visible and active, effectively swapping the ``working
+side'' of the board.
+
+%end-doc */
+
+static int
+SwapSides_nogui (int argc, char **argv, int x, int y)
+{
+  int comp_group = GetLayerGroupNumberByNumber (max_layer + COMPONENT_LAYER);
+  int solder_group = GetLayerGroupNumberByNumber (max_layer + SOLDER_LAYER);
+  int active_group = GetLayerGroupNumberByNumber (LayerStack[0]);
+  int comp_showing =
+    PCB->Data->Layer[PCB->LayerGroups.Entries[comp_group][0]].On;
+  int solder_showing =
+    PCB->Data->Layer[PCB->LayerGroups.Entries[solder_group][0]].On;
+
+  Settings.ShowSolderSide = !Settings.ShowSolderSide;
+  if (Settings.ShowSolderSide)
+    {
+      if (active_group == comp_group && comp_showing && !solder_showing)
+	{
+	  ChangeGroupVisibility (PCB->LayerGroups.Entries[comp_group][0], 0,
+				 0);
+	  ChangeGroupVisibility (PCB->LayerGroups.Entries[solder_group][0], 1,
+				 1);
+	}
+    }
+  else
+    {
+      if (active_group == solder_group && solder_showing && !comp_showing)
+	{
+	  ChangeGroupVisibility (PCB->LayerGroups.Entries[solder_group][0], 0,
+				 0);
+	  ChangeGroupVisibility (PCB->LayerGroups.Entries[comp_group][0], 1,
+				 1);
+	}
+    }
+
+  return 0;
+}
+
 /* --------------------------------------------------------------------------- */
 
 HID_Action action_action_list[] = {
@@ -6931,6 +6991,9 @@ HID_Action action_action_list[] = {
   {"SetValue", 0, ActionSetValue,
    setvalue_help, setvalue_syntax}
   ,
+  {"SwapSides_nogui", 0, SwapSides_nogui,
+   swapsides_help, swapsides_syntax}
+  ,
   {"ToggleHideName", 0, ActionToggleHideName,
    togglehidename_help, togglehidename_syntax}
   ,
-- 
1.6.4.1


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