Example #1
0
File: create.c Project: thequux/pcb
/* This post-processing step adds the top and bottom silk layers to a
 * pre-existing PCB.
 */
int
CreateNewPCBPost (PCBTypePtr pcb, int use_defaults)
{
  /* copy default settings */
  pcb_colors_from_settings (pcb);

  if (use_defaults)
    {
      if (ParseGroupString (Settings.Groups, &pcb->LayerGroups, DEF_LAYER))
	return 1;

      pcb->Data->Layer[component_silk_layer].Name = strdup ("silk");
      pcb->Data->Layer[solder_silk_layer].Name = strdup ("silk");
    }
  return 0;
}
Example #2
0
/*!
 * \brief This post-processing step adds the top and bottom silk layers
 * to a pre-existing PCB.
 *
 * Called after PCB->Data->LayerN is set.
 *
 * \return Returns zero if no errors, else nonzero.
 */
int
CreateNewPCBPost (PCBType *pcb, int use_defaults)
{
  /* copy default settings */
  pcb_colors_from_settings (pcb);

  if (use_defaults)
    {
      if (ParseGroupString (Settings.Groups, &pcb->LayerGroups, &pcb->Data->LayerN))
	return 1;
    }

  pcb->Data->Layer[top_silk_layer].Name = strdup ("top silk");
  pcb->Data->Layer[top_silk_layer].Type = LT_SILK;
  pcb->Data->Layer[bottom_silk_layer].Name = strdup ("bottom silk");
  pcb->Data->Layer[bottom_silk_layer].Type = LT_SILK;

  return 0;
}
Example #3
0
File: file.c Project: thequux/pcb
void
PostLoadElementPCB ()
{
  PCBTypePtr pcb_save = PCB;
  ElementTypePtr e;

  if (!yyPCB)
    return;

  CreateNewPCBPost (yyPCB, 0);
  ParseGroupString("1,c:2,s", &yyPCB->LayerGroups, yyData->LayerN);
  e = yyPCB->Data->Element; /* we know there's only one */
  PCB = yyPCB;
  MoveElementLowLevel (yyPCB->Data,
		       e, -e->BoundingBox.X1, -e->BoundingBox.Y1);
  PCB = pcb_save;
  yyPCB->MaxWidth = e->BoundingBox.X2;
  yyPCB->MaxHeight = e->BoundingBox.Y2;
}
Example #4
0
File: main.c Project: bert/pcb-rnd
int
main (int argc, char *argv[])
{
  int i;

  /* init application:
   * - make program name available for error handlers
   * - evaluate special options
   * - initialize toplevel shell and resources
   * - create an empty PCB with default symbols
   * - initialize all other widgets
   * - update screen and get size of drawing area
   * - evaluate command-line arguments
   * - register 'call on exit()' function
   */

#include "core_lists.h"
  setbuf (stdout, 0);
  InitPaths (argv[0]);

  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  textdomain(GETTEXT_PACKAGE);
  bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
  setlocale(LC_ALL,"");

  srand ( time(NULL) ); /* Set seed for rand() */

  initialize_units();
  polygon_init ();
  hid_init ();

  hid_load_settings ();

  program_name = argv[0];
  program_basename = strrchr (program_name, PCB_DIR_SEPARATOR_C);
  if (program_basename)
    {
      program_directory = strdup (program_name);
      *strrchr (program_directory, PCB_DIR_SEPARATOR_C) = 0;
      program_basename++;
    }
  else
    {
      program_directory = ".";
      program_basename = program_name;
    }
  Progname = program_basename;

  /* Print usage or version if requested.  Then exit.  */  
  if (argc > 1 &&
      (strcmp (argv[1], "-h") == 0 ||
       strcmp (argv[1], "-?") == 0 ||
       strcmp (argv[1], "--help") == 0))
    usage ();
  if (argc > 1 && strcmp (argv[1], "-V") == 0)
    print_version ();
  /* Export pcb from command line if requested.  */
  if (argc > 1 && strcmp (argv[1], "-p") == 0)
    {
      exporter = gui = hid_find_printer ();
      argc--;
      argv++;
    }
  else if (argc > 2 && strcmp (argv[1], "-x") == 0)
    {
      exporter = gui = hid_find_exporter (argv[2]);
      argc -= 2;
      argv += 2;
    }
    /* Otherwise start GUI. */
  else
    gui = hid_find_gui ();

  /* Exit with error if GUI failed to start. */
  if (!gui)
    exit (1);

  /* Set up layers. */
  for (i = 0; i < MAX_LAYER; i++)
    {
      char buf[20];
      sprintf (buf, "signal%d", i + 1);
      Settings.DefaultLayerName[i] = strdup (buf);
      Settings.LayerColor[i] = "#c49350";
      Settings.LayerSelectedColor[i] = "#00ffff";
    }

  gui->parse_arguments (&argc, &argv);

  if (show_help || (argc > 1 && argv[1][0] == '-'))
    usage ();
  if (show_version)
    print_version ();
  if (show_defaults)
    print_defaults ();
  if (show_copyright)
    copyright ();

  settings_post_process ();


  if (show_actions)
    {
      print_actions ();
      exit (0);
    }

  if (do_dump_actions)
    {
      extern void dump_actions (void);
      dump_actions ();
      exit (0);
    }

  /* Create a new PCB object in memory */
  PCB = CreateNewPCB (true);
  PCB->Data->LayerN = DEF_LAYER;
  ParseGroupString (Settings.Groups, &PCB->LayerGroups, DEF_LAYER);
  /* Add silk layers to newly created PCB */
  CreateNewPCBPost (PCB, 1);
  if (argc > 1)
    command_line_pcb = argv[1];

  ResetStackAndVisibility ();

  if (gui->gui)
    InitCrosshair ();
  InitHandler ();
  InitBuffers ();
  SetMode (ARROW_MODE);

  if (command_line_pcb)
    {
      /* keep filename even if initial load command failed;
       * file might not exist
       */
      if (LoadPCB (command_line_pcb))
	PCB->Filename = strdup (command_line_pcb);
    }

  if (Settings.InitialLayerStack
      && Settings.InitialLayerStack[0])
    {
      LayerStringToLayerStack (Settings.InitialLayerStack);
    }

  /* This must be called before any other atexit functions
   * are registered, as it configures an atexit function to
   * clean up and free various items of allocated memory,
   * and must be the last last atexit function to run.
   */
  leaky_init ();

  /* Register a function to be called when the program terminates.
   * This makes sure that data is saved even if LEX/YACC routines
   * abort the program.
   * If the OS doesn't have at least one of them,
   * the critical sections will be handled by parse_l.l
   */
  atexit (EmergencySave);

  /* read the library file and display it if it's not empty
   */
  if (!ReadLibraryContents () && Library.MenuN)
    hid_action ("LibraryChanged");

#ifdef HAVE_LIBSTROKE
  stroke_init ();
#endif

  if (Settings.ScriptFilename)
    {
      Message (_("Executing startup script file %s\n"),
	       Settings.ScriptFilename);
      hid_actionl ("ExecuteFile", Settings.ScriptFilename, NULL);
    }
  if (Settings.ActionString)
    {
      Message (_("Executing startup action %s\n"), Settings.ActionString);
      hid_parse_actions (Settings.ActionString);
    }

  if (gui->printer || gui->exporter)
    {
      gui->do_export (0);
      exit (0);
    }

#if HAVE_DBUS
  pcb_dbus_setup();
#endif

  EnableAutosave ();

#ifdef DEBUG
  printf ("Settings.LibraryCommandDir = \"%s\"\n",
          Settings.LibraryCommandDir);
  printf ("Settings.FontPath          = \"%s\"\n", 
          Settings.FontPath);
  printf ("Settings.ElementPath       = \"%s\"\n", 
          Settings.ElementPath);
  printf ("Settings.LibraryPath       = \"%s\"\n", 
          Settings.LibraryPath);
  printf ("Settings.LibraryTree       = \"%s\"\n", 
          Settings.LibraryTree);
  printf ("Settings.MakeProgram = \"%s\"\n",
          UNKNOWN (Settings.MakeProgram));
  printf ("Settings.GnetlistProgram = \"%s\"\n",
          UNKNOWN (Settings.GnetlistProgram));
#endif

  gui->do_export (0);
#if HAVE_DBUS
  pcb_dbus_finish();
#endif

  return (0);
}