pcb 4.1.1
An interactive printed circuit board layout editor.
|
Rats nest routines. More...
#include <math.h>
#include <stdio.h>
#include "global.h"
#include "create.h"
#include "data.h"
#include "draw.h"
#include "error.h"
#include "file.h"
#include "find.h"
#include "misc.h"
#include "mymem.h"
#include "polygon.h"
#include "rats.h"
#include "search.h"
#include "set.h"
#include "undo.h"
Go to the source code of this file.
Defines | |
#define | TRIEDFIRST 0x1 |
#define | BESTFOUND 0x2 |
Functions | |
static bool | FindPad (char *ElementName, char *PinNum, ConnectionType *conn, bool Same) |
Find a particular pad from an element name and pin number. | |
static bool | ParseConnection (char *InString, char *ElementName, char *PinNum) |
Parse a connection description from a string. | |
static bool | DrawShortestRats (NetListType *Netl, void(*funcp)(register ConnectionType *, register ConnectionType *, register RouteStyleType *)) |
Draw a rat net (tree) having the shortest lines. | |
static bool | GatherSubnets (NetListType *Netl, bool NoWarn, bool AndRats) |
Determine existing interconnections of the net and gather into sub-nets. | |
static bool | CheckShorts (LibraryMenuType *) |
static void | TransferNet (NetListType *Netl, NetType *SourceNet, NetType *DestNet) |
Copy all connections from one net into another and then remove the first net from its netlist. | |
bool | SeekPad (LibraryEntryType *entry, ConnectionType *conn, bool Same) |
Parse a netlist menu entry and locate the corresponding pad. | |
NetListType * | ProcNetlist (LibraryType *net_menu) |
Read the library-netlist build a true Netlist structure. | |
bool | AddAllRats (bool SelectedOnly, void(*funcp)(register ConnectionType *, register ConnectionType *, register RouteStyleType *)) |
AddAllRats puts the rats nest into the layout from the loaded netlist. | |
NetListListType | CollectSubnets (bool SelectedOnly) |
static int | rat_used (char *name) |
Check to see if a particular name is the name of an already existing rats line. | |
RatType * | AddNet (void) |
This function is moved from the original netlist.c as part of the gui code separation for the Gtk port. | |
char * | ConnectionName (int type, void *ptr1, void *ptr2) |
This function is moved from the original netlist.c as part of the gui code separation for the Gtk port. | |
Variables | |
static bool | badnet = false |
static Cardinal | top_group |
static Cardinal | bottom_group |
Rats nest routines.
PCB, interactive printed circuit board design
Copyright (C) 1994,1995,1996 Thomas Nau
Copyright (C) 1997, harry eaton
This module, rats.c, was written and is Copyright (C) 1997 by harry eaton.
This module is also subject to the GNU GPL as described below.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Definition in file rats.c.
bool AddAllRats | ( | bool | SelectedOnly, |
void(*)(register ConnectionType *, register ConnectionType *, register RouteStyleType *) | funcp | ||
) |
AddAllRats puts the rats nest into the layout from the loaded netlist.
If SelectedOnly is true, it will only draw rats to selected pins and pads.
Definition at line 741 of file rats.c.
References _, connection(), CONNECTION_LOOP, PCBType::Data, Draw(), DrawShortestRats(), END_LOOP, FreeConnectionLookupMemory(), FreeNetListMemory(), GatherSubnets(), GetConnectionMemory(), GetNetMemory(), IncrementUndoSerialNumber(), InitConnectionLookup(), Message(), NET_LOOP, PCBType::NetlistLib, NetListType::NetN, PCB, ProcNetlist(), DataType::RatN, SettingType::RatWarn, Settings, NetType::Style, and TEST_FLAG.
Referenced by ActionAddRats(), ActionImport(), AutoPlaceSelected(), AutoRoute(), and toporouter().
RatType* AddNet | ( | void | ) |
This function is moved from the original netlist.c as part of the gui code separation for the Gtk port.
Definition at line 915 of file rats.c.
References _, CrosshairType::AttachedLine, BOTTOM_SIDE, ConnectionName(), CreateNewRat(), Crosshair, PCBType::Data, LibraryMenuType::flag, GetLayerGroupNumberBySide(), GetLibraryEntryMemory(), GetLibraryMenuMemory(), LibraryEntryType::ListEntry, Message(), LibraryMenuType::Name, NAMEONPCB_NAME, NetlistChanged(), PCBType::NetlistLib, netnode_to_netname(), NoFlags, PCB, AttachedLineType::Point1, AttachedLineType::Point2, ptr1, ptr2, ptr3, rat_used(), SettingType::RatThickness, SearchObjectByLocation(), Settings, TEST_FLAG, TOP_SIDE, PointType::X, and PointType::Y.
Referenced by NotifyMode().
static bool CheckShorts | ( | LibraryMenuType * | theNet | ) | [static] |
Definition at line 366 of file rats.c.
References _, ALLPAD_LOOP, ALLPIN_LOOP, PCBType::Data, END_LOOP, ENDALL_LOOP, FreePointerListMemory(), GetPointerMemory(), Message(), LibraryMenuType::Name, NAMEONPCB_NAME, pin_st::Number, PCB, pin, POINTER_LOOP, ptr, SET_FLAG, pin_st::Spare, TEST_FLAG, and UNKNOWN.
Referenced by GatherSubnets().
NetListListType CollectSubnets | ( | bool | SelectedOnly | ) |
Definition at line 835 of file rats.c.
References _, connection(), CONNECTION_LOOP, END_LOOP, FreeConnectionLookupMemory(), GatherSubnets(), GetConnectionMemory(), GetNetListMemory(), GetNetMemory(), InitConnectionLookup(), Message(), NET_LOOP, PCBType::NetlistLib, PCB, ProcNetlist(), NetType::Style, and TEST_FLAG.
Referenced by CreateRouteData(), and import_clusters().
char* ConnectionName | ( | int | type, |
void * | ptr1, | ||
void * | ptr2 | ||
) |
This function is moved from the original netlist.c as part of the gui code separation for the Gtk port.
Definition at line 1025 of file rats.c.
References NAMEONPCB_NAME, and UNKNOWN.
Referenced by AddNet(), describe_location(), and LookupConnection().
static bool DrawShortestRats | ( | NetListType * | Netl, |
void(*)(register ConnectionType *, register ConnectionType *, register RouteStyleType *) | funcp | ||
) | [static] |
Draw a rat net (tree) having the shortest lines.
This also frees the subnet memory as they are consumed.
Netl
we are passed is NOT the main netlist - it's the connectivity for ONE net. It represents the CURRENT connectivity state for the net, with each Netl->Net[N] representing one copper-connected subset of the net.Everything inside the NetList Netl should be connected together.
Each Net in Netl
is a group of Connections which are already connected together somehow, either by real wires or by rats we've already drawn.
Each Connection is a vertex within that blob of connected items.
This loop finds the closest vertex pairs between each blob and draws rats that merge the blobs until there's just one big blob.
Just to clarify, with some examples:
Each Netl
is one full net from a netlist, like from gnetlist.
Each Netl->Net[N] is a subset of that net that's already physically connected on the pcb.
So a new design with no traces yet, would have a huge list of Net[N], each with one pin in it.
A fully routed design would have one Net[N] with all the pins (for that net) in it.
Definition at line 591 of file rats.c.
References AddObjectToCreateUndoList(), NetType::Connection, NetType::ConnectionN, CreateNewRat(), PCBType::Data, DrawRat(), FreeConnectionLookupMemory(), FreeNetMemory(), ConnectionType::group, InitConnectionLookup(), IsPointInPolygonIgnoreHoles(), line, m, n, NetListType::Net, NetListType::NetN, NoFlags, PCB, ConnectionType::ptr2, SettingType::RatThickness, SET_FLAG, Settings, SQUARE, NetType::Style, TransferNet(), ConnectionType::type, ConnectionType::X, and ConnectionType::Y.
Referenced by AddAllRats().
static bool FindPad | ( | char * | ElementName, |
char * | PinNum, | ||
ConnectionType * | conn, | ||
bool | Same | ||
) | [static] |
Find a particular pad from an element name and pin number.
Definition at line 128 of file rats.c.
References bottom_group, PCBType::Data, ConnectionType::group, NSTRCMP, pin_st::Number, pad_st::Number, ElementType::Pad, PCB, pin, ElementType::Pin, ConnectionType::ptr1, ConnectionType::ptr2, SearchElementByName(), TEST_FLAG, top_group, ConnectionType::type, pin_st::X, ConnectionType::X, pin_st::Y, and ConnectionType::Y.
Referenced by SeekPad().
static bool GatherSubnets | ( | NetListType * | Netl, |
bool | NoWarn, | ||
bool | AndRats | ||
) | [static] |
Determine existing interconnections of the net and gather into sub-nets.
Initially the netlist has each connection in its own individual net afterwards there can be many fewer nets with multiple connections each.
Definition at line 463 of file rats.c.
References ALLLINE_LOOP, ALLPOLYGON_LOOP, bottom_group, CheckShorts(), CLEAR_FLAG, ClearFlagOnAllObjects(), NetType::Connection, PCBType::Data, END_LOOP, ENDALL_LOOP, GetConnectionMemory(), GetLayerGroupNumberByPointer(), ConnectionType::group, layer, line, m, ConnectionType::menu, n, NetListType::Net, NetListType::NetN, PCB, ConnectionType::ptr1, ConnectionType::ptr2, RatFindHook(), TEST_FLAG, TransferNet(), ConnectionType::type, VIA_LOOP, ConnectionType::X, and ConnectionType::Y.
Referenced by AddAllRats(), and CollectSubnets().
static bool ParseConnection | ( | char * | InString, |
char * | ElementName, | ||
char * | PinNum | ||
) | [static] |
Parse a connection description from a string.
Puts the element name in the string and the pin number in the number.
Definition at line 99 of file rats.c.
Referenced by SeekPad().
NetListType* ProcNetlist | ( | LibraryType * | net_menu | ) |
Read the library-netlist build a true Netlist structure.
Definition at line 226 of file rats.c.
References _, ALLPAD_LOOP, ALLPIN_LOOP, BOTTOM_SIDE, CLEAR_FLAG, connection(), PCBType::Data, END_LOOP, ENDALL_LOOP, ENTRY_LOOP, FreeNetListMemory(), GetConnectionMemory(), GetLayerGroupNumberBySide(), GetNetMemory(), ConnectionType::menu, MENU_LOOP, LibraryType::MenuN, Message(), RouteStyleType::Name, NAMEONPCB_NAME, NSTRCMP, Number, PCB, pin, ConnectionType::ptr1, ConnectionType::ptr2, SeekPad(), SET_FLAG, pin_st::Spare, NetType::Style, style, STYLE_LOOP, TEST_FLAG, TOP_SIDE, and ConnectionType::type.
Referenced by AddAllRats(), AutoPlaceSelected(), CollectSubnets(), and smartdisperse().
static int rat_used | ( | char * | name | ) | [static] |
bool SeekPad | ( | LibraryEntryType * | entry, |
ConnectionType * | conn, | ||
bool | Same | ||
) |
Parse a netlist menu entry and locate the corresponding pad.
Definition at line 189 of file rats.c.
References _, FindPad(), LibraryEntryType::ListEntry, Message(), and ParseConnection().
Referenced by gsvit_create_netlist(), nbcb_select_common(), netlist_select_cb(), node_selection_changed_cb(), pin_name_to_xy(), ProcNetlist(), ReportNetLengthByName(), and toggle_pin_selected().
static void TransferNet | ( | NetListType * | Netl, |
NetType * | SourceNet, | ||
NetType * | DestNet | ||
) | [static] |
Copy all connections from one net into another and then remove the first net from its netlist.
Definition at line 345 of file rats.c.
References connection(), CONNECTION_LOOP, END_LOOP, FreeNetMemory(), GetConnectionMemory(), NetListType::Net, NetListType::NetN, and NetType::Style.
Referenced by DrawShortestRats(), and GatherSubnets().