예제 #1
0
파일: mymem.c 프로젝트: majenkotech/pcb
/*!
 * \brief Free the memory that's allocated by the library.
 */
void
FreeLibraryMemory (LibraryType *lib) {
    MENU_LOOP (lib);
    {
        ENTRY_LOOP (menu);
        {
            free (entry->AllocatedMemory);
            free (entry->ListEntry);
        }
        END_LOOP;
        free (menu->Entry);
        free (menu->Name);
    }
    END_LOOP;
    free (lib->Menu);
    /* clear struct */
    memset (lib, 0, sizeof (LibraryType));
}
예제 #2
0
파일: mymem.c 프로젝트: bert/pcb-update
/* ---------------------------------------------------------------------------
 * releases the memory that's allocated by the library
 */
void
FreeLibraryMemory (LibraryTypePtr lib)
{
  MENU_LOOP (lib);
  {
    ENTRY_LOOP (menu);
    {
      SaveFree ((void *) entry->AllocatedMemory);
      SaveFree ((void *) entry->ListEntry);
    }
    END_LOOP;
    SaveFree ((void *) menu->Entry);
    SaveFree ((void *) menu->Name);
  }
  END_LOOP;
  SaveFree ((void *) lib->Menu);

  /* clear struct */
  memset (lib, 0, sizeof (LibraryType));
}
예제 #3
0
/* Given a net in the netlist (a LibraryMenuType) put all the Entry[]
   |  names (the nodes) into a newly created node tree model.
*/
static GtkTreeModel *
node_model_create (LibraryMenuType * menu)
{
  GtkListStore *store;
  GtkTreeIter iter;

  store = gtk_list_store_new (N_NODE_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER);

  if (menu == NULL)
    return GTK_TREE_MODEL (store);

  ENTRY_LOOP (menu);
  {
    if (!entry->ListEntry)
      continue;
    gtk_list_store_append (store, &iter);
    gtk_list_store_set (store, &iter,
			NODE_NAME_COLUMN, entry->ListEntry,
			NODE_LIBRARY_COLUMN, entry, -1);
  }
  END_LOOP;

  return GTK_TREE_MODEL (store);
}
예제 #4
0
static char *
describe_location (Coord X, Coord Y)
{
  void *ptr1, *ptr2, *ptr3;
  int type;
  int Range = 0;
  char *elename = "";
  char *pinname;
  char *netname = NULL;
  char *description;

  /* check if there are any pins or pads at that position */

  type = SearchObjectByLocation (PIN_TYPE | PAD_TYPE,
                                 &ptr1, &ptr2, &ptr3, X, Y, Range);
  if (type == NO_TYPE)
    return NULL;

  /* don't mess with silk objects! */
  if (type & SILK_TYPE &&
      GetLayerNumber (PCB->Data, (LayerType *) ptr1) >= max_copper_layer)
    return NULL;

  if (type == PIN_TYPE || type == PAD_TYPE)
    elename = (char *)UNKNOWN (NAMEONPCB_NAME ((ElementType *) ptr1));

  pinname = ConnectionName (type, ptr1, ptr2);

  if (pinname == NULL)
    return NULL;

  /* Find netlist entry */
  MENU_LOOP (&PCB->NetlistLib);
  {
    if (!menu->Name)
    continue;

    ENTRY_LOOP (menu);
    {
      if (!entry->ListEntry)
        continue;

      if (strcmp (entry->ListEntry, pinname) == 0) {
        netname = g_strdup (menu->Name);
        /* For some reason, the netname has spaces in front of it, strip them */
        g_strstrip (netname);
        break;
      }
    }
    END_LOOP;

    if (netname != NULL)
      break;
  }
  END_LOOP;

  description = g_strdup_printf ("Element name: %s\n"
                                 "Pinname : %s\n"
                                 "Netname : %s",
                                 elename,
                                 (pinname != NULL) ? pinname : "--",
                                 (netname != NULL) ? netname : "--");

  g_free (netname);

  return description;
}
예제 #5
0
파일: rats.c 프로젝트: rlutz/pcb
/*!
 * \brief Read the library-netlist build a true Netlist structure.
 */
NetListType *
ProcNetlist (LibraryType *net_menu)
{
  ConnectionType *connection;
  ConnectionType LastPoint;
  NetType *net;
  static NetListType *Wantlist = NULL;

  if (!net_menu->MenuN)
    return (NULL);
  FreeNetListMemory (Wantlist);
  free (Wantlist);
  badnet = false;

  /* find layer groups of the component side and solder side */
  bottom_group = GetLayerGroupNumberBySide (BOTTOM_SIDE);
  top_group = GetLayerGroupNumberBySide (TOP_SIDE);

  Wantlist = (NetListType *)calloc (1, sizeof (NetListType));
  if (Wantlist)
    {
      ALLPIN_LOOP (PCB->Data);
      {
	pin->Spare = NULL;
	CLEAR_FLAG (DRCFLAG, pin);
      }
      ENDALL_LOOP;
      ALLPAD_LOOP (PCB->Data);
      {
	pad->Spare = NULL;
	CLEAR_FLAG (DRCFLAG, pad);
      }
      ENDALL_LOOP;
      MENU_LOOP (net_menu);
      {
	if (menu->Name[0] == '*' || menu->flag == 0)
	  {
	    badnet = true;
	    continue;
	  }
	net = GetNetMemory (Wantlist);
	if (menu->Style)
	  {
	    STYLE_LOOP (PCB);
	    {
	      if (style->Name && !NSTRCMP (style->Name, menu->Style))
		{
		  net->Style = style;
		  break;
		}
	    }
	    END_LOOP;
	  }
	else			/* default to NULL if none found */
	  net->Style = NULL;
	ENTRY_LOOP (menu);
	{
	  if (SeekPad (entry, &LastPoint, false))
	    {
	      if (TEST_FLAG (DRCFLAG, (PinType *) LastPoint.ptr2))
		Message (_
			 ("Error! Element %s pin %s appears multiple times in the netlist file.\n"),
			 NAMEONPCB_NAME ((ElementType *) LastPoint.ptr1),
			 (LastPoint.type ==
			  PIN_TYPE) ? ((PinType *) LastPoint.ptr2)->
			 Number : ((PadType *) LastPoint.ptr2)->Number);
	      else
		{
		  connection = GetConnectionMemory (net);
		  *connection = LastPoint;
		  /* indicate expect net */
		  connection->menu = menu;
		  /* mark as visited */
		  SET_FLAG (DRCFLAG, (PinType *) LastPoint.ptr2);
		  if (LastPoint.type == PIN_TYPE)
		    ((PinType *) LastPoint.ptr2)->Spare = (void *) menu;
		  else
		    ((PadType *) LastPoint.ptr2)->Spare = (void *) menu;
		}
	    }
	  else
	    badnet = true;
	  /* check for more pins with the same number */
	  for (; SeekPad (entry, &LastPoint, true);)
	    {
	      connection = GetConnectionMemory (net);
	      *connection = LastPoint;
	      /* indicate expect net */
	      connection->menu = menu;
	      /* mark as visited */
	      SET_FLAG (DRCFLAG, (PinType *) LastPoint.ptr2);
	      if (LastPoint.type == PIN_TYPE)
		((PinType *) LastPoint.ptr2)->Spare = (void *) menu;
	      else
		((PadType *) LastPoint.ptr2)->Spare = (void *) menu;
	    }
	}
	END_LOOP;
      }
      END_LOOP;
    }
  /* clear all visit marks */
  ALLPIN_LOOP (PCB->Data);
  {
    CLEAR_FLAG (DRCFLAG, pin);
  }
  ENDALL_LOOP;
  ALLPAD_LOOP (PCB->Data);
  {
    CLEAR_FLAG (DRCFLAG, pad);
  }
  ENDALL_LOOP;
  return (Wantlist);
}
예제 #6
0
/* \brief Create the tree model for the "Library" view.
 * \par Function Description
 * Creates a tree where the branches are the available library
 * sources and the leaves are the footprints.
 */
static GtkTreeModel *
create_lib_tree_model (GhidLibraryWindow * library_window)
{
  GtkTreeStore *tree;
  GtkTreeIter iter, p_iter, e_iter, c_iter;
  gchar *name;
  gboolean exists;

  tree = gtk_tree_store_new (N_MENU_COLUMNS,
			     G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER);

  MENU_LOOP (&Library);
  {
    /* Watch for directory changes of library parts and create new
       |  parent iter at each change.
     */
    if (!menu->directory)	/* Shouldn't happen */
      menu->directory = g_strdup ("???");

    exists = FALSE;
    if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (tree), &e_iter))
      do
	{
	  gtk_tree_model_get (GTK_TREE_MODEL (tree), &e_iter,
			      MENU_NAME_COLUMN, &name, -1);
	  if (!strcmp (name, menu->directory))
	    {
	      exists = TRUE;
	      break;
	    }
	}
      while (gtk_tree_model_iter_next (GTK_TREE_MODEL (tree), &e_iter));

    if (exists)
      p_iter = e_iter;
    else
      {
	gtk_tree_store_append (tree, &p_iter, NULL);
	gtk_tree_store_set (tree, &p_iter,
			    MENU_NAME_COLUMN, menu->directory,
			    MENU_LIBRARY_COLUMN, NULL,
			    MENU_ENTRY_COLUMN, NULL, -1);
      }
    gtk_tree_store_append (tree, &iter, &p_iter);
    gtk_tree_store_set (tree, &iter,
			MENU_NAME_COLUMN, menu->Name,
			MENU_LIBRARY_COLUMN, menu,
			MENU_ENTRY_COLUMN, NULL, -1);
    ENTRY_LOOP (menu);
    {
      gtk_tree_store_append (tree, &c_iter, &iter);
      gtk_tree_store_set (tree, &c_iter,
			  MENU_NAME_COLUMN, entry->ListEntry,
			  MENU_LIBRARY_COLUMN, menu,
			  MENU_ENTRY_COLUMN, entry, -1);
    }
    END_LOOP;

  }
  END_LOOP;

  return (GtkTreeModel *) tree;
}