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

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



The branch, master has been updated
       via  ede84819b39e07be001791c243cceacb6d4a61ed (commit)
       via  945cfd557f973d46127038636805a18c96ad0572 (commit)
       via  a923d869c230bcc78799ed927cd390f9a15cbca9 (commit)
       via  ad57581a4a4674b8fec8f6a9f296bd71f751c1fc (commit)
       via  b0b6bf90b1cd78f9e8e850d26fb48ff9b1bb5088 (commit)
      from  0a654a3009972f24a121e0d34d2b299190f44f05 (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/action.c      |  308 +++++++++++++++++++++++++++++++++++++++-------------
 src/gpcb-menu.res |    8 ++
 src/misc.c        |   30 +++++-
 src/misc.h        |    4 +
 src/pcb-menu.res  |    8 ++
 5 files changed, 278 insertions(+), 80 deletions(-)


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

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

    Add import settings to menus
    
    At the bottom of the Settings menu, add a submenu for import settings
    for placing new elements.

:100644 100644 e92a59a... bd9acac... M	src/gpcb-menu.res
:100644 100644 1166439... dcba346... M	src/pcb-menu.res

commit 945cfd557f973d46127038636805a18c96ad0572
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Store units for import::disperse
    
    If the user specified the dispersement as "123mm" for example,
    store that string as-is for convenience.

:100644 100644 595e103... 32e294c... M	src/action.c

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

    Enhance GetValue
    
    Allow cm and in as units.  Allow the units to be part of the value
    string or separate.

:100644 100644 55b5e63... 5599d82... M	src/misc.c

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

    Add new-part-location to import
    
    Adds import::newX, import::newY, and import::disperse attributes.
    These determine where new parts are located when they're added to
    the layout, including some random variation to keep them from being
    all on exactly the same spot.  Parameters were added to Import()
    to set these:
    
    In @code{Import()} is called with @code{setnewpoint} then the location
    of new components can be specified.  This is where parts show up when
    they're added to the board.  The default is the center of the board.
    
    @table @code
    
    @item Import(setnewpoint)
    
    Prompts the user to click on the board somewhere, uses that point.  If
    called by a hotkey, uses the current location of the crosshair.
    
    @item Import(setnewpoint,mark)
    
    Uses the location of the mark.  If no mark is present, the point is
    not changed.
    
    @item Import(setnewpoint,center)
    
    Resets the point to the center of the board.
    
    @item Import(setnewpoint,X,Y,units)
    
    Sets the point to the specific coordinates given.  Example:
    @code{Import(setnewpoint,50,25,mm)}
    
    @end table
    
    Note that the X and Y locations are stored in attributes named
    @code{import::newX} and @code{import::newY} so you could change them
    manually if you wished.
    
    Calling @code{Import(setdisperse,D,units)} sets how much the newly
    placed elements are dispersed relative to the set point.  For example,
    @code{Import(setdisperse,10,mm)} will offset each part randomly up to
    10mm away from the point.  The default dispersion is 1/10th of the
    smallest board dimension.  Dispersion is saved in the
    @code{import::disperse} attribute.

:100644 100644 0a85391... 595e103... M	src/action.c

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

    Add AttributeRemove functions
    
    Add AttributeRemoveFromList() and the wrapper AttributeRemove()

:100644 100644 dfbb1d7... 55b5e63... M	src/misc.c
:100644 100644 d58e12e... bb88a21... M	src/misc.h

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

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

    Add import settings to menus
    
    At the bottom of the Settings menu, add a submenu for import settings
    for placing new elements.

diff --git a/src/gpcb-menu.res b/src/gpcb-menu.res
index e92a59a..bd9acac 100644
--- a/src/gpcb-menu.res
+++ b/src/gpcb-menu.res
@@ -217,6 +217,14 @@ MainMenu =
    {"Check polygons" checked=checkplanes Display(ToggleCheckPlanes)}
    -
    {"Vendor drill mapping" ToggleVendor() checked=VendorMapOn}
+   {"Import Settings"
+    {"New elements added at..." foreground=grey50 sensitive=false}
+    {" Center" Import(setnewpoint,center)}
+    {" Mark" Import(setnewpoint,mark)}
+    {" Crosshair" Import(setnewpoint)}
+    -
+    {"Set Dispersion" Import(setdisperse)}
+   }
   }
 
 #
diff --git a/src/pcb-menu.res b/src/pcb-menu.res
index 1166439..dcba346 100644
--- a/src/pcb-menu.res
+++ b/src/pcb-menu.res
@@ -212,6 +212,14 @@ MainMenu =
    {"Pinout shows number" checked=shownumber Display(ToggleName)}
    {"Pins/Via show Name/Number" Display(PinOrPadName) a={"D" "<Key>d"}}
    {"Enable vendor drill mapping" ToggleVendor() checked=VendorMapOn}
+   {"Import Settings"
+    {"New elements added at..." foreground=grey50 sensitive=false}
+    {" Center" Import(setnewpoint,center)}
+    {" Mark" Import(setnewpoint,mark)}
+    {" Crosshair" Import(setnewpoint)}
+    -
+    {"Set Dispersion" Import(setdisperse)}
+   }
   }
     
   {Select

commit 945cfd557f973d46127038636805a18c96ad0572
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Store units for import::disperse
    
    If the user specified the dispersement as "123mm" for example,
    store that string as-is for convenience.

diff --git a/src/action.c b/src/action.c
index 595e103..32e294c 100644
--- a/src/action.c
+++ b/src/action.c
@@ -7603,17 +7603,23 @@ ActionImport (int argc, char **argv, int x, int y)
     {
       const char *ds, *units;
       int d, r;
+      char buf[50];
 
       ds = ARG (1);
       units = ARG (2);
-      if (ds)
+      if (!ds)
+	{
+	  const char *as = AttributeGet (PCB, "import::disperse");
+	  ds = gui->prompt_for("Enter dispersion:", as ? as : "0");
+	}
+      if (units)
 	{
-	  char buf[50];
-	  d = GetValue (ds, units, &r);
-	  sprintf (buf, "%d", d);
+	  sprintf(buf, "%s%s", ds, units);
 	  AttributePut (PCB, "import::disperse", buf);
-	  return 0;
 	}
+      else
+	AttributePut (PCB, "import::disperse", ds);
+      return 0;
     }
 
   if (mode && strcasecmp (mode, "setnewpoint") == 0)

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

    Enhance GetValue
    
    Allow cm and in as units.  Allow the units to be part of the value
    string or separate.

diff --git a/src/misc.c b/src/misc.c
index 55b5e63..5599d82 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -110,7 +110,8 @@ static struct
 float
 GetValue (char *val, char *units, bool * absolute)
 {
-  float value;
+  double value;
+  int n = -1;
 
   /* if the first character is a sign we have to add the
    * value to the current one
@@ -118,7 +119,8 @@ GetValue (char *val, char *units, bool * absolute)
   if (*val == '=')
     {
       *absolute = true;
-      value = atof (val + 1);
+      sscanf (val+1, "%lf%n", &value, &n);
+      n++;
     }
   else
     {
@@ -126,14 +128,21 @@ GetValue (char *val, char *units, bool * absolute)
         *absolute = true;
       else
         *absolute = false;
-      value = atof (val);
+      sscanf (val, "%lf%n", &value, &n);
     }
+  if (!units && n > 0)
+    units = val + n;
+    
   if (units && *units)
     {
       if (strncasecmp (units, "mm", 2) == 0)
         value *= MM_TO_COOR;
+      else if (strncasecmp (units, "cm", 2) == 0)
+        value *= MM_TO_COOR * 10;
       else if (strncasecmp (units, "mil", 3) == 0)
         value *= 100;
+      else if (strncasecmp (units, "in", 3) == 0)
+        value *= 100000;
     }
   return value;
 }

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

    Add new-part-location to import
    
    Adds import::newX, import::newY, and import::disperse attributes.
    These determine where new parts are located when they're added to
    the layout, including some random variation to keep them from being
    all on exactly the same spot.  Parameters were added to Import()
    to set these:
    
    In @code{Import()} is called with @code{setnewpoint} then the location
    of new components can be specified.  This is where parts show up when
    they're added to the board.  The default is the center of the board.
    
    @table @code
    
    @item Import(setnewpoint)
    
    Prompts the user to click on the board somewhere, uses that point.  If
    called by a hotkey, uses the current location of the crosshair.
    
    @item Import(setnewpoint,mark)
    
    Uses the location of the mark.  If no mark is present, the point is
    not changed.
    
    @item Import(setnewpoint,center)
    
    Resets the point to the center of the board.
    
    @item Import(setnewpoint,X,Y,units)
    
    Sets the point to the specific coordinates given.  Example:
    @code{Import(setnewpoint,50,25,mm)}
    
    @end table
    
    Note that the X and Y locations are stored in attributes named
    @code{import::newX} and @code{import::newY} so you could change them
    manually if you wished.
    
    Calling @code{Import(setdisperse,D,units)} sets how much the newly
    placed elements are dispersed relative to the set point.  For example,
    @code{Import(setdisperse,10,mm)} will offset each part randomly up to
    10mm away from the point.  The default dispersion is 1/10th of the
    smallest board dimension.  Dispersion is saved in the
    @code{import::disperse} attribute.

diff --git a/src/action.c b/src/action.c
index 0a85391..595e103 100644
--- a/src/action.c
+++ b/src/action.c
@@ -7009,6 +7009,24 @@ them.
 %end-doc */
 
 static int
+parse_layout_attribute_units (char *name, int def)
+{
+  const char *as, *units = NULL;
+  int n = 0, v, r;
+
+  as = AttributeGet (PCB, name);
+  if (!as)
+    return def;
+
+  sscanf (as, "%d%n", &v, &n);
+  units = as + n;
+  if (! *units)
+    units = NULL;
+  v = GetValue (as, units, &r);
+  return v;
+}
+
+static int
 ActionElementList (int argc, char **argv, int x, int y)
 {
   ElementType *e = NULL;
@@ -7076,14 +7094,38 @@ ActionElementList (int argc, char **argv, int x, int y)
 
   if (!e)
     {
+      int nx, ny, d;
+      char *as;
+
 #ifdef DEBUG
       printf("  ... Footprint not on board, need to add it.\n");
 #endif
       /* Not on board, need to add it. */
       if (LoadFootprint(argc, args, x, y))
 	return 1;
+
+      nx = PCB->MaxWidth / 2;
+      ny = PCB->MaxHeight / 2;
+      d = MIN (PCB->MaxWidth, PCB->MaxHeight) / 10;
+
+      nx = parse_layout_attribute_units ("import::newX", nx);
+      ny = parse_layout_attribute_units ("import::newY", ny);
+      d = parse_layout_attribute_units ("import::disperse", d);
+
+      nx += random () % (d*2) - d;
+      ny += random () % (d*2) - d;
+
+      if (nx < 0)
+	nx = 0;
+      if (nx >= PCB->MaxWidth)
+	nx = PCB->MaxWidth - 1;
+      if (ny < 0)
+	ny = 0;
+      if (ny >= PCB->MaxHeight)
+	ny = PCB->MaxHeight - 1;
+
       /* Place components onto center of board. */
-      if (CopyPastebufferToLayout (PCB->MaxWidth/2, PCB->MaxHeight/2))
+      if (CopyPastebufferToLayout (nx, ny))
 	SetChangedFlag (true);
     }
 
@@ -7236,82 +7278,6 @@ ActionExecCommand (int argc, char **argv, int x, int y)
 }
 
 /* ---------------------------------------------------------------- */
-static const char import_syntax[] =
-  "Import()\n"
-  "Import([gnetlist|make[,source,source,...]])\n";
-
-static const char import_help[] = "Import schematics";
-
-/* %start-doc actions Import
-
-Imports element and netlist data from the schematics (or some other
-source).  The first parameter, which is optional, is the mode.  If not
-specified, the @code{import::mode} attribute in the PCB is used.
-@code{gnetlist} means gnetlist is used to obtain the information from
-the schematics.  @code{make} invokes @code{make}, assuming the user
-has a @code{Makefile} in the current directory.  The @code{Makefile}
-will be invoked with the following variables set:
-
-@table @code
-
-@item PCB
-The name of the .pcb file
-
-@item SRCLIST
-A space-separated list of source files
-
-@item OUT
-The name of the file in which to put the command script, which may
-contain any @pcb{} actions.  By default, this is a temporary file
-selected by @pcb{}, but if you specify an @code{import::outfile}
-attribute, that file name is used instead (and not automatically
-deleted afterwards).
-
-@end table
-
-The target specified to be built is the first of these that apply:
-
-@itemize @bullet
-
-@item
-The target specified by an @code{import::target} attribute.
-
-@item
-The output file specified by an @code{import::outfile} attribute.
-
-@item
-If nothing else is specified, the target is @code{pcb_import}.
-
-@end itemize
-
-If you specify an @code{import::makefile} attribute, then "-f <that
-file>" will be added to the command line.
-
-If you specify the mode, you may also specify the source files
-(schematics).  If you do not specify any, the list of schematics is
-obtained by reading the @code{import::src@var{N}} attributes (like
-@code{import::src0}, @code{import::src1}, etc).
-
-For compatibility with future extensions to the import file format,
-the generated file @emph{must not} start with the two characters
-@code{#%}.
-
-If a temporary file is needed the @code{TMPDIR} environment variable
-is used to select its location.
-
-Note that the programs @code{gnetlist} and @code{make} may be
-overridden by the user via the @code{make-program} and @code{gnetlist}
-@code{pcb} settings (i.e. in @code{~/.pcb/settings} or on the command
-line).
-
-If @pcb{} cannot determine which schematic(s) to import from, the GUI
-is called to let user choose (see @code{ImportGUI()}).
-
-Note that Import() doesn't delete anything - after an Import, elements
-which shouldn't be on the board are selected and may be removed once
-it's determined that the deletion is appropriate.
-
-%end-doc */
 
 static int
 pcb_spawnvp (char **argv)
@@ -7503,6 +7469,123 @@ tempfile_unlink (char * name)
 }
 
 /* ---------------------------------------------------------------- */
+static const char import_syntax[] =
+  "Import()\n"
+  "Import([gnetlist|make[,source,source,...]])\n"
+  "Import(setnewpoint[,(mark|center|X,Y)])\n"
+  "Import(setdisperse,D,units)\n";
+
+static const char import_help[] = "Import schematics";
+
+/* %start-doc actions Import
+
+Imports element and netlist data from the schematics (or some other
+source).  The first parameter, which is optional, is the mode.  If not
+specified, the @code{import::mode} attribute in the PCB is used.
+@code{gnetlist} means gnetlist is used to obtain the information from
+the schematics.  @code{make} invokes @code{make}, assuming the user
+has a @code{Makefile} in the current directory.  The @code{Makefile}
+will be invoked with the following variables set:
+
+@table @code
+
+@item PCB
+The name of the .pcb file
+
+@item SRCLIST
+A space-separated list of source files
+
+@item OUT
+The name of the file in which to put the command script, which may
+contain any @pcb{} actions.  By default, this is a temporary file
+selected by @pcb{}, but if you specify an @code{import::outfile}
+attribute, that file name is used instead (and not automatically
+deleted afterwards).
+
+@end table
+
+The target specified to be built is the first of these that apply:
+
+@itemize @bullet
+
+@item
+The target specified by an @code{import::target} attribute.
+
+@item
+The output file specified by an @code{import::outfile} attribute.
+
+@item
+If nothing else is specified, the target is @code{pcb_import}.
+
+@end itemize
+
+If you specify an @code{import::makefile} attribute, then "-f <that
+file>" will be added to the command line.
+
+If you specify the mode, you may also specify the source files
+(schematics).  If you do not specify any, the list of schematics is
+obtained by reading the @code{import::src@var{N}} attributes (like
+@code{import::src0}, @code{import::src1}, etc).
+
+For compatibility with future extensions to the import file format,
+the generated file @emph{must not} start with the two characters
+@code{#%}.
+
+If a temporary file is needed the @code{TMPDIR} environment variable
+is used to select its location.
+
+Note that the programs @code{gnetlist} and @code{make} may be
+overridden by the user via the @code{make-program} and @code{gnetlist}
+@code{pcb} settings (i.e. in @code{~/.pcb/settings} or on the command
+line).
+
+If @pcb{} cannot determine which schematic(s) to import from, the GUI
+is called to let user choose (see @code{ImportGUI()}).
+
+Note that Import() doesn't delete anything - after an Import, elements
+which shouldn't be on the board are selected and may be removed once
+it's determined that the deletion is appropriate.
+
+In @code{Import()} is called with @code{setnewpoint} then the location
+of new components can be specified.  This is where parts show up when
+they're added to the board.  The default is the center of the board.
+
+@table @code
+
+@item Import(setnewpoint)
+
+Prompts the user to click on the board somewhere, uses that point.  If
+called by a hotkey, uses the current location of the crosshair.
+
+@item Import(setnewpoint,mark)
+
+Uses the location of the mark.  If no mark is present, the point is
+not changed.
+
+@item Import(setnewpoint,center)
+
+Resets the point to the center of the board.
+
+@item Import(setnewpoint,X,Y,units)
+
+Sets the point to the specific coordinates given.  Example:
+@code{Import(setnewpoint,50,25,mm)}
+
+@end table
+
+Note that the X and Y locations are stored in attributes named
+@code{import::newX} and @code{import::newY} so you could change them
+manually if you wished.
+
+Calling @code{Import(setdisperse,D,units)} sets how much the newly
+placed elements are dispersed relative to the set point.  For example,
+@code{Import(setdisperse,10,mm)} will offset each part randomly up to
+10mm away from the point.  The default dispersion is 1/10th of the
+smallest board dimension.  Dispersion is saved in the
+@code{import::disperse} attribute.
+
+%end-doc */
+
 static int
 ActionImport (int argc, char **argv, int x, int y)
 {
@@ -7515,6 +7598,71 @@ ActionImport (int argc, char **argv, int x, int y)
 #endif
 
   mode = ARG (0);
+
+  if (mode && strcasecmp (mode, "setdisperse") == 0)
+    {
+      const char *ds, *units;
+      int d, r;
+
+      ds = ARG (1);
+      units = ARG (2);
+      if (ds)
+	{
+	  char buf[50];
+	  d = GetValue (ds, units, &r);
+	  sprintf (buf, "%d", d);
+	  AttributePut (PCB, "import::disperse", buf);
+	  return 0;
+	}
+    }
+
+  if (mode && strcasecmp (mode, "setnewpoint") == 0)
+    {
+      const char *xs, *ys, *units;
+      int x, y;
+      char buf[50];
+
+      xs = ARG (1);
+      ys = ARG (2);
+      units = ARG (3);
+
+      if (!xs)
+	{
+	  gui->get_coords (_("Click on a location"), &x, &y);
+	}
+      else if (strcasecmp (xs, "center") == 0)
+	{
+	  AttributeRemove (PCB, "import::newX");
+	  AttributeRemove (PCB, "import::newY");
+	  return;
+	}
+      else if (strcasecmp (xs, "mark") == 0)
+	{
+	  if (Marked.status)
+	    {
+	      x = Marked.X;
+	      y = Marked.Y;
+	    }
+	}
+      else if (ys)
+	{
+	  int r;
+	  x = GetValue (xs, units, &r);
+	  y = GetValue (ys, units, &r);
+	}
+      else
+	{
+	  Message ("Bad syntax for Import(setnewpoint)");
+	  return 1;
+	}
+
+      sprintf (buf, "%d", x);
+      AttributePut (PCB, "import::newX", buf);
+      sprintf (buf, "%d", y);
+      AttributePut (PCB, "import::newY", buf);
+      return 0;
+    }
+
   if (! mode)
     mode = AttributeGet (PCB, "import::mode");
   if (! mode)

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

    Add AttributeRemove functions
    
    Add AttributeRemoveFromList() and the wrapper AttributeRemove()

diff --git a/src/misc.c b/src/misc.c
index dfbb1d7..55b5e63 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1919,6 +1919,21 @@ AttributePutToList (AttributeListType *list, char *name, char *value, int replac
   return 0;
 }
 
+void
+AttributeRemoveFromList(AttributeListType *list, char *name)
+{
+  int i, j;
+  for (i=0; i<list->Number; i++)
+    if (strcmp (name, list->List[i].name) == 0)
+      {
+	free (list->List[i].name);
+	free (list->List[i].value);
+	for (j=i; j<list->Number-i; j++)
+	  list->List[j] = list->List[j+1];
+	list->Number --;
+      }
+}
+
 
 
 const char *
diff --git a/src/misc.h b/src/misc.h
index d58e12e..bb88a21 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -91,6 +91,10 @@ int AttributePutToList (AttributeListType *list, char *name, char *value, int re
 #define AttributeGet(OBJ,name) AttributeGetFromList (&(OBJ->Attributes), name)
 /* Simplistic version: Takes a pointer to an object, sets attributes in it.  */
 #define AttributePut(OBJ,name,value) AttributePutToList (&(OBJ->Attributes), name, value, 1)
+/* Remove an attribute by name.  */
+void AttributeRemoveFromList(AttributeListType *list, char *name);
+/* Simplistic version of Remove.  */
+#define AttributeRemove(OBJ, name) AttributeRemoveFromList (&(OBJ->Attributes), name)
 
 /* For passing modified flags to other functions. */
 FlagType MakeFlags (unsigned int);




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