pcb 4.1.1
An interactive printed circuit board layout editor.

rats.c File Reference

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"
Include dependency graph for rats.c:

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.
NetListTypeProcNetlist (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.
RatTypeAddNet (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

Detailed Description

Rats nest routines.


Copyright.


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.


Define Documentation

#define BESTFOUND   0x2

Definition at line 71 of file rats.c.

#define TRIEDFIRST   0x1

Definition at line 70 of file rats.c.


Function Documentation

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().

Here is the call graph for this function:

static bool CheckShorts ( LibraryMenuType theNet) [static]
NetListListType CollectSubnets ( bool  SelectedOnly)
Todo:
This is copied in large part from AddAllRats above; for maintainability, AddAllRats probably wants to be tweaked to use this version of the code so that we don't have duplication.

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().

Here is the call graph for this function:

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.

Note:
The 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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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.

Returns:
If a valid connection is found, it returns the number of characters processed from the string, otherwise it returns 0.

Definition at line 99 of file rats.c.

References _, and Message().

Referenced by SeekPad().

Here is the call graph for this function:

static int rat_used ( char *  name) [static]

Check to see if a particular name is the name of an already existing rats line.

Definition at line 895 of file rats.c.

References END_LOOP, MENU_LOOP, PCBType::NetlistLib, and PCB.

Referenced by AddNet().

bool SeekPad ( LibraryEntryType entry,
ConnectionType conn,
bool  Same 
)

Parse a netlist menu entry and locate the corresponding pad.

Returns:
true if found, and fills in Connection information.

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:


Variable Documentation

bool badnet = false [static]

Definition at line 86 of file rats.c.

Definition at line 87 of file rats.c.

Cardinal top_group [static]

Definition at line 87 of file rats.c.

Referenced by FindPad().