static int LesstifNetlistShow (int argc, char **argv, Coord x, Coord y) { if (build_netlist_dialog ()) return 0; if (argc == 1) { LibraryMenuTypePtr net; net = netnode_to_netname(argv[0]); if (net) { XmString item; int vis = 0; /* Select net first, 'True' causes pick_net() to be invoked */ item = XmStringCreatePCB (net->Name); XmListSelectItem (netlist_list, item, True); XmListSetItem (netlist_list, item); XmStringFree (item); /* Now the netnode_list has the right contents */ item = XmStringCreatePCB (argv[0]); XmListSelectItem (netnode_list, item, False); /* * Only force the item to the top if there are enough to scroll. * A bug (?) in lesstif will cause the window to get ever wider * if an XmList that doesn't require a scrollbar is forced to * have one (when the top item is not the first item). */ n = 0; stdarg (XmNvisibleItemCount, &vis); XtGetValues (netnode_list, args, n); if (n_netnode_strings > vis) { XmListSetItem (netnode_list, item); } XmStringFree (item); } else { /* Try the argument as a netname */ net = netname_to_netname(argv[0]); if (net) { XmString item; item = XmStringCreatePCB (net->Name); XmListSetItem (netlist_list, item); XmListSelectItem (netlist_list, item, True); XmStringFree (item); } } } return 0; }
/*! * \brief This function is moved from the original netlist.c as * part of the gui code separation for the Gtk port. */ RatType * AddNet (void) { static int ratDrawn = 0; char name1[256], *name2; Cardinal group1, group2; char ratname[20]; int found; void *ptr1, *ptr2, *ptr3; LibraryMenuType *menu; LibraryEntryType *entry; if (Crosshair.AttachedLine.Point1.X == Crosshair.AttachedLine.Point2.X && Crosshair.AttachedLine.Point1.Y == Crosshair.AttachedLine.Point2.Y) return (NULL); found = SearchObjectByLocation (PAD_TYPE | PIN_TYPE, &ptr1, &ptr2, &ptr3, Crosshair.AttachedLine.Point1.X, Crosshair.AttachedLine.Point1.Y, 5); if (found == NO_TYPE) { Message (_("No pad/pin under rat line\n")); return (NULL); } if (NAMEONPCB_NAME ((ElementType *) ptr1) == NULL || *NAMEONPCB_NAME ((ElementType *) ptr1) == 0) { Message (_("You must name the starting element first\n")); return (NULL); } /* will work for pins to since the FLAG is common */ group1 = GetLayerGroupNumberBySide ( TEST_FLAG (ONSOLDERFLAG, (PadType *) ptr2) ? BOTTOM_SIDE : TOP_SIDE); strcpy (name1, ConnectionName (found, ptr1, ptr2)); found = SearchObjectByLocation (PAD_TYPE | PIN_TYPE, &ptr1, &ptr2, &ptr3, Crosshair.AttachedLine.Point2.X, Crosshair.AttachedLine.Point2.Y, 5); if (found == NO_TYPE) { Message (_("No pad/pin under rat line\n")); return (NULL); } if (NAMEONPCB_NAME ((ElementType *) ptr1) == NULL || *NAMEONPCB_NAME ((ElementType *) ptr1) == 0) { Message (_("You must name the ending element first\n")); return (NULL); } group2 = GetLayerGroupNumberBySide ( TEST_FLAG (ONSOLDERFLAG, (PadType *) ptr2) ? BOTTOM_SIDE : TOP_SIDE); name2 = ConnectionName (found, ptr1, ptr2); menu = netnode_to_netname (name1); if (menu) { if (netnode_to_netname (name2)) { Message (_ ("Both connections already in netlist - cannot merge nets\n")); return (NULL); } entry = GetLibraryEntryMemory (menu); entry->ListEntry = strdup (name2); netnode_to_netname (name2); goto ratIt; } /* ok, the first name did not belong to a net */ menu = netnode_to_netname (name2); if (menu) { entry = GetLibraryEntryMemory (menu); entry->ListEntry = strdup (name1); netnode_to_netname (name1); goto ratIt; } /* * neither belong to a net, so create a new one. * * before creating a new rats here, we need to search * for a unique name. */ sprintf (ratname, " ratDrawn%i", ++ratDrawn); while (rat_used (ratname)) { sprintf (ratname, " ratDrawn%i", ++ratDrawn); } menu = GetLibraryMenuMemory (&PCB->NetlistLib); menu->Name = strdup (ratname); entry = GetLibraryEntryMemory (menu); entry->ListEntry = strdup (name1); entry = GetLibraryEntryMemory (menu); entry->ListEntry = strdup (name2); menu->flag = 1; ratIt: NetlistChanged (0); return (CreateNewRat (PCB->Data, Crosshair.AttachedLine.Point1.X, Crosshair.AttachedLine.Point1.Y, Crosshair.AttachedLine.Point2.X, Crosshair.AttachedLine.Point2.Y, group1, group2, Settings.RatThickness, NoFlags ())); }
/*! * \brief The main IPC-D-356 function. * * Gets the filename for the netlist from the dialog. */ int IPCD356_Netlist (void) { FILE *fp; char nodename[256]; char net[256]; LibraryMenuType *netname; IPCD356_AliasList * aliaslist; if (IPCD356_SanityCheck()) /* Check for invalid names + numbers. */ { Message ("Aborting.\n"); return(1); } sprintf (net, "%s.ipc", PCB->Name); if (IPCD356_filename == NULL) return 1; fp = fopen (IPCD356_filename, "w+"); if (fp == NULL) { Message ("error opening %s\n", IPCD356_filename); return 1; } /* free (IPCD356_filename); */ IPCD356_WriteHeader (fp); aliaslist = CreateAliasList (); if (aliaslist == NULL) { Message ("Error Aloccating memory for IPC-D-356 AliasList\n"); return 1; } if (IPCD356_WriteAliases (fp, aliaslist)) { Message ("Error Writing IPC-D-356 AliasList\n"); return 1; } ELEMENT_LOOP (PCB->Data); PIN_LOOP (element); if (!TEST_FLAG (VISITFLAG, pin)) { ClearFlagOnLinesAndPolygons (true, FOUNDFLAG); ClearFlagOnPinsViasAndPads (true, FOUNDFLAG); LookupConnectionByPin (PIN_TYPE, pin); sprintf (nodename, "%s-%s", element->Name[1].TextString, pin->Number); netname = netnode_to_netname (nodename); /* Message("Netname: %s\n", netname->Name +2); */ if (netname) { strcpy (net, &netname->Name[2]); CheckNetLength (net, aliaslist); } else { strcpy (net, "N/C"); } IPCD356_WriteNet (fp, net); } END_LOOP; /* Pin. */ PAD_LOOP (element); if (!TEST_FLAG (VISITFLAG, pad)) { ClearFlagOnLinesAndPolygons (true, FOUNDFLAG); ClearFlagOnPinsViasAndPads (true, FOUNDFLAG); LookupConnectionByPin (PAD_TYPE, pad); sprintf (nodename, "%s-%s", element->Name[1].TextString, pad->Number); netname = netnode_to_netname (nodename); /* Message("Netname: %s\n", netname->Name +2); */ if (netname) { strcpy (net, &netname->Name[2]); CheckNetLength (net, aliaslist); } else { strcpy (net, "N/C"); } IPCD356_WriteNet (fp, net); } END_LOOP; /* Pad. */ END_LOOP; /* Element. */ VIA_LOOP (PCB->Data); if (!TEST_FLAG (VISITFLAG, via)) { ClearFlagOnLinesAndPolygons (true, FOUNDFLAG); ClearFlagOnPinsViasAndPads (true, FOUNDFLAG); LookupConnectionByPin (PIN_TYPE, via); strcpy (net, "N/C"); IPCD356_WriteNet (fp, net); } END_LOOP; /* Via. */ IPCD356_End (fp); fclose (fp); free (aliaslist); ResetVisitPinsViasAndPads (); ClearFlagOnLinesAndPolygons (true, FOUNDFLAG); ClearFlagOnPinsViasAndPads (true, FOUNDFLAG); return 0; }