1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./style.css" />
6 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./design.css" />
7 <link rel=
"stylesheet" media=
"print" type=
"text/css" href=
"./print.css" />
9 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
13 <h1 id=
"pcbdevelopmentintroduction">PCB Development Introduction
</h1>
17 I started this document to get an insight in the structure/architecture of the PCB program. The main objective is to get up to speed so we are able to start contributing to the PCB program.
21 This document is work in progress.
26 <h2 id=
"getinformation">Get Information
</h2>
30 These links help to get an understanding of PCB:
32 <div class=
"table sectionedit1"><table class=
"inline">
35 <th class=
"col0 leftalign">Link
</th><th class=
"col1 leftalign">Remark
</th>
39 <td class=
"col0">http://pcb.geda-project.org/manual.html
</td><td class=
"col1 leftalign">As always read the manual first.
</td>
42 <td class=
"col0 leftalign">http://pcb.geda-project.org/faq.html
</td><td class=
"col1"> </td>
45 <td class=
"col0 leftalign">http://www.delorie.com/pcb/docs/gs/gs.html#Terminology
</td><td class=
"col1 leftalign">Knowing the terminology helps in understanding the code
</td>
48 <td class=
"col0 leftalign">http://wiki.geda-project.org/geda:pcb-quick_reference
</td><td class=
"col1"> </td>
51 <td class=
"col0 leftalign">http://wiki.geda-project.org/geda:pcb_footprints
</td><td class=
"col1"> </td>
54 <td class=
"col0 leftalign">http://wiki.geda-project.org/geda:pcb_tips
</td><td class=
"col1"> </td>
57 <td class=
"col0">http://wiki.geda-project.org/geda:documentation
</td><td class=
"col1"> </td>
60 <!-- EDIT1 TABLE [349-848] -->
63 <h2 id=
"rootdirectorystructure">root Directory structure
</h2>
67 This is the ~/pcb directory
69 <div class=
"table sectionedit2"><table class=
"inline">
71 <td class=
"col0"> </td><td class=
"col1 rightalign"> data
</td><td class=
"col2">PCB layout and gerber icons and mime registration data
</td>
74 <td class=
"col0"> </td><td class=
"col1 rightalign"> doc
</td><td class=
"col2">All files used to generate the documentation
</td>
77 <td class=
"col0"> </td><td class=
"col1 rightalign"> example
</td><td class=
"col2">Speaks for it self, examples how to use PCB
</td>
80 <td class=
"col0"> </td><td class=
"col1 rightalign"> gts
</td><td class=
"col2">This directory/library is only used by the toporouter (toporouter.h includes gts.h)
</td>
83 <td class=
"col0">*
</td><td class=
"col1 rightalign"> intl
</td><td class=
"col2">Internationalization - it handles conversions to non-English languages. It is for i18n, l10n and related stuff. See the
<em><strong>ABOUT-NLS
</strong></em> text file in the root directory for more information.
</td>
86 <td class=
"col0"> </td><td class=
"col1 rightalign"> lib
</td><td class=
"col2">The M4 library stores the footprints as M4 macros
</td>
89 <td class=
"col0"> </td><td class=
"col1 rightalign"> m4
</td><td class=
"col2">Some additional m4 scripts used by configure
</td>
92 <td class=
"col0"> </td><td class=
"col1 rightalign"> newlib
</td><td class=
"col2">File to make newlib library components
</td>
95 <td class=
"col0"> </td><td class=
"col1 rightalign"> po
</td><td class=
"col2">Translation files
</td>
98 <td class=
"col0"> </td><td class=
"col1 rightalign"> README_FILES
</td><td class=
"col2 leftalign">Information in this directory is obsolete and/or very old. Just ignore it.
</td>
101 <td class=
"col0"> </td><td class=
"col1 rightalign"> src
</td><td class=
"col2">The source code
</td>
104 <td class=
"col0"> </td><td class=
"col1 rightalign"> tests
</td><td class=
"col2">File to test the build during make
</td>
107 <td class=
"col0"> </td><td class=
"col1 rightalign"> tools
</td><td class=
"col2">Build tools
</td>
110 <td class=
"col0"> </td><td class=
"col1 rightalign"> tutorial
</td><td class=
"col2"> </td>
113 <td class=
"col0"> </td><td class=
"col1 rightalign"> utils
</td><td class=
"col2">Build tools
</td>
116 <td class=
"col0"> </td><td class=
"col1 rightalign"> w32
</td><td class=
"col2">File needed to build for Windows
</td>
119 <td class=
"col0" colspan=
"3"> </td>
122 <td class=
"col0">*
</td><td class=
"col1" colspan=
"2">This directory is no part of the git repository it is added by the
<code>./autogen.sh
</code> script
</td>
125 <!-- EDIT2 TABLE [917-1964] -->
128 <h2 id=
"srcdirectorystructure">src Directory structure
</h2>
132 This is the ~/pcb/src directory
134 <div class=
"table sectionedit3"><table class=
"inline">
136 <td class=
"col0">src/hid
</td><td class=
"col1"> </td><td class=
"col2">Human Interface Device layer. The basic idea is that every action outside the core is treated as a separate human interface device.
</td>
139 <td class=
"col0"> </td><td class=
"col1 leftalign">src/hid/batch
</td><td class=
"col2">Batch mode
</td>
142 <td class=
"col0"> </td><td class=
"col1 leftalign">src/hid/bom
</td><td class=
"col2">Export a bill of materials
</td>
145 <td class=
"col0"> </td><td class=
"col1 leftalign">src/hid/common
</td><td class=
"col2"> </td>
148 <td class=
"col0"> </td><td class=
"col1 leftalign">src/hid/gcode
</td><td class=
"col2">Export to G-Code
</td>
151 <td class=
"col0"> </td><td class=
"col1 leftalign">src/hid/gerber
</td><td class=
"col2">Export RS-
274X (Gerber)
</td>
154 <td class=
"col0"> </td><td class=
"col1 leftalign">src/hid/gtk
</td><td class=
"col2">Graphical User Interface based on GTK2
</td>
157 <td class=
"col0"> </td><td class=
"col1 leftalign">src/hid/lesstif
</td><td class=
"col2">Graphical User Interface based on lessif
</td>
160 <td class=
"col0"> </td><td class=
"col1 leftalign">src/hid/lpr
</td><td class=
"col2">Printer driver
</td>
163 <td class=
"col0"> </td><td class=
"col1 leftalign">src/hid/nelma
</td><td class=
"col2">Numerical analysis package export
</td>
166 <td class=
"col0"> </td><td class=
"col1 leftalign">src/hid/png
</td><td class=
"col2">export GIF/JPEG/PNG
</td>
169 <td class=
"col0"> </td><td class=
"col1 leftalign">src/hid/ps
</td><td class=
"col2">export postscript /encapsulated postscript
</td>
172 <td class=
"col0"> </td><td class=
"col1 leftalign">src/hid/hidint.h
</td><td class=
"col2">HID internal interfaces. These may ONLY be called from the HID modules, not from the common PCB code.
</td>
175 <td class=
"col0" colspan=
"3">src/icons
</td>
178 <!-- EDIT3 TABLE [2037-2819] -->
181 <h2 id=
"srcdirectoryfilelist">src Directory file list
</h2>
185 These are the files in the ~/pcb/src directory
187 <div class=
"table sectionedit4"><table class=
"inline">
190 <th class=
"col0"> _*_
</th><th class=
"col1 leftalign">File
</th><th class=
"col2 leftalign">Short description
</th><th class=
"col3">Comment / Explanation
</th>
194 <td class=
"col0">H
</td><td class=
"col1">action.*
</td><td class=
"col2 leftalign">action routines for output window
</td><td class=
"col3">This is one of the top files. A lot of the functionality will start here. This is a good place to start your digging work when learning the PCB code.
<br/>
195 This file also contains a lot of documentation generating code.
<br/>
196 This means two things:
<br/>
197 - Look at the PCB manual for a description of all actions (manual is in doc directory after make)
<br/>
198 - Take this as an example how to add documentation to the code.
</td>
201 <td class=
"col0">H
</td><td class=
"col1">autoplace.*
</td><td class=
"col2 leftalign">functions used to autoplace elements.
</td><td class=
"col3"> </td>
204 <td class=
"col0">H
</td><td class=
"col1">autoroute.*
</td><td class=
"col2 leftalign">functions used to autoroute nets.
</td><td class=
"col3"> </td>
207 <td class=
"col0">C
</td><td class=
"col1">box.h
</td><td class=
"col2 leftalign">random box-related utilities.
</td><td class=
"col3"> </td>
210 <td class=
"col0">C
</td><td class=
"col1">buffer.*
</td><td class=
"col2 leftalign">functions used by paste- and move/copy buffer
</td><td class=
"col3"> </td>
213 <td class=
"col0">D
</td><td class=
"col1">change.*
</td><td class=
"col2 leftalign">functions used to change object properties
</td><td class=
"col3"> </td>
216 <td class=
"col0"> </td><td class=
"col1">check_icon.data
</td><td class=
"col2"> </td><td class=
"col3"> </td>
219 <td class=
"col0"> </td><td class=
"col1">clip.*
</td><td class=
"col2 leftalign">Clip the line to the clipBox
</td><td class=
"col3"> </td>
222 <td class=
"col0">C
</td><td class=
"col1">command.*
</td><td class=
"col2 leftalign">executes commands from user
</td><td class=
"col3">That is, some commands, only the short-hand vi compatible commands like l, le, m, q, w, s and rn.
<br/>
223 See pcb manual for the explanation.
<br/>
224 See action.c for the other commands.
</td>
227 <td class=
"col0">C
</td><td class=
"col1">compat.*
</td><td class=
"col2"> </td><td class=
"col3">This file is for compatibility across operating systems; we can define functions there that might be missing elsewhere (like linux-specific things) or broken elsewhere. Mostly it
's for unix-vs-windows.
</td>
230 <td class=
"col0"> </td><td class=
"col1">const.h
</td><td class=
"col2 leftalign">global source constants
</td><td class=
"col3"> </td>
233 <td class=
"col0">D
</td><td class=
"col1">copy.*
</td><td class=
"col2 leftalign">functions used to copy pins, elements ...
</td><td class=
"col3"> </td>
236 <td class=
"col0">D
</td><td class=
"col1">create.*
</td><td class=
"col2 leftalign">functions used to create vias, pins ...
</td><td class=
"col3"> </td>
239 <td class=
"col0">H
</td><td class=
"col1">crosshair.*
</td><td class=
"col2 leftalign">crosshair stuff
</td><td class=
"col3">is for the board
's crosshair; this handles (for example) grid snapping. This is *not* the same as the GUI
's mouse cursor. For the GKT GUI the crosshair will follow the mouse if its over the board-space/canvas.
</td>
242 <td class=
"col0">C
</td><td class=
"col1">data.*
</td><td class=
"col2 leftalign">just defines common identifiers
</td><td class=
"col3"> </td>
245 <td class=
"col0">C
</td><td class=
"col1">dbus.*
</td><td class=
"col2 leftalign">Interprocess communication (IPC)
</td><td class=
"col3">D-Bus is a system for interprocess communication (IPC). D-Bus code originally derived from example-service.c in the dbus-glib bindings.
<br/>
246 The dbus was added to provide some communications between gschem and pcb, and to provide some remote-control options for pcb. Not sure if anything uses it at the moment.
<br/>
247 If you
're not interested in connecting to other programs just ignore the files.
</td>
250 <td class=
"col0">C
</td><td class=
"col1">dbus-pcbmain.*
</td><td class=
"col2 leftalign">PCB HID main loop integration.
</td><td class=
"col3"> </td>
253 <td class=
"col0">C
</td><td class=
"col1">default_font
</td><td class=
"col2"> </td><td class=
"col3">From the PCB documentation: A number of user defined Symbols are called a font. There is only one per layout. All symbols are made of lines. See the file
'default_font
' as an example.
<br/>
254 Fontmode.c is linked with this file.
</td>
257 <td class=
"col0">D
</td><td class=
"col1">djopt.*
</td><td class=
"col2">optimize functions
</td><td class=
"col3">is for the
"Connects-
>Optimize Routed Tracks
" functions.
</td>
260 <td class=
"col0">C
</td><td class=
"col1">dolists.h
</td><td class=
"col2"> </td><td class=
"col3">REGISTER_*(a) macro in dolists.h will be expanded by the preprocessor to the actual calling of these functions.
</td>
263 <td class=
"col0">H
</td><td class=
"col1">draw.*
</td><td class=
"col2 leftalign">drawing routines
</td><td class=
"col3"> </td>
266 <td class=
"col0">H
</td><td class=
"col1">drill.*
</td><td class=
"col2 leftalign">functions to generate drill information
</td><td class=
"col3">is for generating drill report information.
</td>
269 <td class=
"col0" rowspan=
"3">H
</td><td class=
"col1">edif.*
</td><td class=
"col2 leftalign">EDIF stands for Electronic Design Interchange Format.
</td><td class=
"col3" rowspan=
"3">These files are associated with only one action
"LoadFrom(Netlist)
". This will call the function ImportNetlist() in file.c. If the first line of the netlist file contains
"edif
" it will use these files to parse the EDIF
2.0.0 formatted file. A little googling learns that the EDIF
2.0.0 file format was approved in March
1988. File format EDIF
4.0.0 was released in August
1996. The PCB documentation doesn
't say anything about EDIF.
<br/>
270 The files are here to be backwards compatible, so we are able to read files generated many year ago. It doesn
't hurt so just ignore it.
</td>
273 <td class=
"col0">edif_parse.h
</td><td class=
"col1 leftalign">This file defines the interface to the outside world.
</td>
276 <td class=
"col0">edif.y
</td><td class=
"col1 leftalign">file says: A Bison parser, used in with edif.c. EDIF stands for Electronic Design Interchange Format.
</td>
279 <td class=
"col0">C
</td><td class=
"col1">error.*
</td><td class=
"col2 leftalign">error and debug functions
</td><td class=
"col3"> </td>
282 <td class=
"col0">C
</td><td class=
"col1">file.*
</td><td class=
"col2 leftalign">file save, load, merge ... routines
</td><td class=
"col3"> </td>
285 <td class=
"col0">D
</td><td class=
"col1">find.*
</td><td class=
"col2 leftalign">routines to find connections between pins, vias, lines...
</td><td class=
"col3"> </td>
288 <td class=
"col0">C
</td><td class=
"col1">flags.*
</td><td class=
"col2 leftalign">routines to initialize and use flags
</td><td class=
"col3">flags.c functions are used by some of the HIDs to mark menu entries as
"checked
" vs
"unchecked
" when they refer to flags. That
's why they
're registered, too, there
's a list with ASCII names that hids can refer to.
</td>
291 <td class=
"col0">H
</td><td class=
"col1">fontmode.c
</td><td class=
"col2 leftalign">routines to edit the font in PCB
</td><td class=
"col3">There are two actions:
<br/>
292 FontEdit() and FontSave()
<br/>
293 Font editing draws one of each character on the screen as a PCB. You edit the PCB. Then it reads the traces from the PCB and turns it back into a font. You can then cut/paste the font section out of that pcb to default_font.
<br/>
294 default_font is linked with this file.
</td>
297 <td class=
"col0">C
</td><td class=
"col1">free_atexit.*
</td><td class=
"col2 leftalign">some routines to free memory
</td><td class=
"col3"> </td>
300 <td class=
"col0"> </td><td class=
"col1">gather-actions
</td><td class=
"col2 leftalign">shell script used during build.
</td><td class=
"col3">Probably a leftover from an old build script, I can
't find where it is called. Think the script isn
't used.
<br/>
304 <td class=
"col0"> </td><td class=
"col1">gettext.h
</td><td class=
"col2"> </td><td class=
"col3">Used if --enable-nls option is configured. Takes care of internationalization.
</td>
307 <td class=
"col0">C
</td><td class=
"col1">global.h
</td><td class=
"col2"> </td><td class=
"col3">The big include just about everything include file
</td>
310 <td class=
"col0">H
</td><td class=
"col1">gpcb-menu.res
</td><td class=
"col2"> </td><td class=
"col3"> </td>
313 <td class=
"col0">C
</td><td class=
"col1">heap.*
</td><td class=
"col2"> </td><td class=
"col3">The heap functions seem to be associated mainly with the two autorouters. Additionally the file polygon1.c makes use of a heap in one of its functions
</td>
316 <td class=
"col0">H
</td><td class=
"col1">hid_draw.h
</td><td class=
"col2 leftalign">Low level drawing API.
</td><td class=
"col3"> </td>
319 <td class=
"col0">H
</td><td class=
"col1">hid.h
</td><td class=
"col2 leftalign">Human Interface Device layer.
</td><td class=
"col3">This is one of the top files.
<br/>
320 This is a good place to start looking if you want to know what
's-what.
</td>
323 <td class=
"col0"> </td><td class=
"col1">icon.data
</td><td class=
"col2"> </td><td class=
"col3"> </td>
326 <td class=
"col0">D
</td><td class=
"col1">insert.*
</td><td class=
"col2 leftalign">functions used to insert points into objects
</td><td class=
"col3"> </td>
329 <td class=
"col0">D
</td><td class=
"col1">intersect.*
</td><td class=
"col2 leftalign">rectangle intersection/union routines.
</td><td class=
"col3"> </td>
332 <td class=
"col0">D
</td><td class=
"col1">line.*
</td><td class=
"col2">line routines
</td><td class=
"col3"> </td>
335 <td class=
"col0"> </td><td class=
"col1">lrealpath.*
</td><td class=
"col2 leftalign">Libiberty realpath. Like realpath, but more consistent behaviour
</td><td class=
"col3"> </td>
338 <td class=
"col0">C
</td><td class=
"col1">macro.h
</td><td class=
"col2 leftalign">some commonly used macros not related to a special C-file the file is included by global.h after const.h
</td><td class=
"col3"> </td>
341 <td class=
"col0">C
</td><td class=
"col1">main.c
</td><td class=
"col2"> </td><td class=
"col3">It all starts here
</td>
344 <td class=
"col0"> </td><td class=
"col1">main-test.c
</td><td class=
"col2"> </td><td class=
"col3"> </td>
347 <td class=
"col0">D
</td><td class=
"col1">mirror.*
</td><td class=
"col2 leftalign">functions used to change the mirror flag of an object
</td><td class=
"col3"> </td>
350 <td class=
"col0">C
</td><td class=
"col1">misc.*
</td><td class=
"col2"> </td><td class=
"col3"> </td>
353 <td class=
"col0"> </td><td class=
"col1">mode_icon.data
</td><td class=
"col2"> </td><td class=
"col3">Icons used in the GUI
</td>
356 <td class=
"col0">D
</td><td class=
"col1">move.*
</td><td class=
"col2 leftalign">functions used to move pins, elements ...
</td><td class=
"col3"> </td>
359 <td class=
"col0">C
</td><td class=
"col1">mtspace.*
</td><td class=
"col2 leftalign">implementation for
"empty space
" routines (needed for via-space tracking in the auto-router.
</td><td class=
"col3"> </td>
362 <td class=
"col0">C
</td><td class=
"col1">mymem.*
</td><td class=
"col2 leftalign">memory management functions
</td><td class=
"col3"> </td>
365 <td class=
"col0">H
</td><td class=
"col1">netlist.c
</td><td class=
"col2"> </td><td class=
"col3"> </td>
368 <td class=
"col0" rowspan=
"2">C
</td><td class=
"col1">parse_l.*
</td><td class=
"col2 leftalign">lexical definitions to parse ASCII input of PCB and Element description
</td><td class=
"col3" rowspan=
"2">Parse an element file or layout file. This is either a footprint file or our PCB layout file
</td>
371 <td class=
"col0">parse_y.*
</td><td class=
"col1 leftalign">grammar to parse ASCII input of PCB description
</td>
374 <td class=
"col0">H
</td><td class=
"col1">pcb-menu.res
</td><td class=
"col2"> </td><td class=
"col3"> </td>
377 <td class=
"col0">C
</td><td class=
"col1">pcb-printf.*
</td><td class=
"col2 leftalign">Implementation of printf wrapper to output pcb coords and angles.
</td><td class=
"col3"> </td>
380 <td class=
"col0"> </td><td class=
"col1">pcbtest.sh.in
</td><td class=
"col2 leftalign">Used during the build to test the program
</td><td class=
"col3"> </td>
383 <td class=
"col0" rowspan=
"3">D
</td><td class=
"col1">polyarea.h
</td><td class=
"col2 leftalign">file says: poly_Boolean: a polygon clip library.
</td><td class=
"col3">Used in polygon.c, polygon1.c and thermal.c
</td>
386 <td class=
"col0">polygon1.c
</td><td class=
"col1 leftalign">polygon clipping functions
</td><td class=
"col2"> </td>
389 <td class=
"col0">polygon.*
</td><td class=
"col1 leftalign">special polygon editing routines
</td><td class=
"col2"> </td>
392 <td class=
"col0">H
</td><td class=
"col1">print.*
</td><td class=
"col2 leftalign">printing routines
</td><td class=
"col3">Looks like it is used to
"print
" the fabrication layer. print.c generates a layer to be used as a fabrication drawing. Whether the HID uses that or not (and what it does with it) is a Separate question. At least, both ps and gerber need that layer. Since the layer is created in
"pcb unit space
" it
's in the core. HID things tend to happen in
"hid unit space
" instead.
</td>
395 <td class=
"col0">H
</td><td class=
"col1">puller.c
</td><td class=
"col2 leftalign">PCB HID Project - Puller
</td><td class=
"col3">See http://www.delorie.com/pcb/puller for more information.
</td>
398 <td class=
"col0">H
</td><td class=
"col1">rats.*
</td><td class=
"col2 leftalign">rats nest routines
</td><td class=
"col3"> </td>
401 <td class=
"col0">D
</td><td class=
"col1">remove.*
</td><td class=
"col2 leftalign">functions used to remove vias, pins ...
</td><td class=
"col3"> </td>
404 <td class=
"col0">H
</td><td class=
"col1">report.*
</td><td class=
"col2 leftalign">Tell the user what he/she must know
</td><td class=
"col3">See PCB manual for the options.
</td>
407 <td class=
"col0" rowspan=
"2">H
</td><td class=
"col1">res_lex.*
</td><td class=
"col2"> </td><td class=
"col3" rowspan=
"2">These files are used to parse the pcb-menu.res and gpcb-menu.res files. This defines the menu structure of PCB. res_* is a generic resource parser. Both gtk and lesstif hids use them.
</td>
410 <td class=
"col0">res_parse.*
</td><td class=
"col1 leftalign">A parser, to read the resource (menu items etc) form PCB
</td>
413 <td class=
"col0">H
</td><td class=
"col1">resource.h
</td><td class=
"col2"> </td><td class=
"col3"> </td>
416 <td class=
"col0">D
</td><td class=
"col1">rotate.*
</td><td class=
"col2 leftalign">functions used to rotate pins, elements ...
</td><td class=
"col3"> </td>
419 <td class=
"col0">C
</td><td class=
"col1">rtree.*
</td><td class=
"col2 leftalign">r-tree functions
</td><td class=
"col3">a way to quickly find
2-D objects in a
2-D space
</td>
422 <td class=
"col0"> </td><td class=
"col1">rubberband.*
</td><td class=
"col2 leftalign">functions used by
'rubberband moves
' </td><td class=
"col3"> </td>
425 <td class=
"col0">C
</td><td class=
"col1">search.*
</td><td class=
"col2 leftalign">search routines some of the functions use dummy parameters
</td><td class=
"col3"> </td>
428 <td class=
"col0">C
</td><td class=
"col1">select.*
</td><td class=
"col2 leftalign">select routines
</td><td class=
"col3"> </td>
431 <td class=
"col0">C
</td><td class=
"col1">set.*
</td><td class=
"col2 leftalign">routines to update widgets and global settings (except output window and dialogs)
</td><td class=
"col3"> </td>
434 <td class=
"col0">C
</td><td class=
"col1">strflags.*
</td><td class=
"col2 leftalign">Some flags routines
</td><td class=
"col3"> </td>
437 <td class=
"col0">C
</td><td class=
"col1">thermal.*
</td><td class=
"col2 leftalign">negative thermal finger polygons
</td><td class=
"col3"> </td>
440 <td class=
"col0"> </td><td class=
"col1">toporouter.*
</td><td class=
"col2 leftalign">This file implements a topological autorouter.
</td><td class=
"col3">Please take a look inside the file for some literature references on the toporouter.
</td>
443 <td class=
"col0">C
</td><td class=
"col1">undo.*
</td><td class=
"col2 leftalign">functions used to undo operations
</td><td class=
"col3"> </td>
446 <td class=
"col0">C
</td><td class=
"col1">vector.*
</td><td class=
"col2 leftalign">operations on vectors.
</td><td class=
"col3"> </td>
449 <td class=
"col0">H
</td><td class=
"col1">vendor.*
</td><td class=
"col2 leftalign">routines to generate vendor specific output
</td><td class=
"col3">vendor.c is used to load vendor-specific DRC rules and apply them.
</td>
452 <!-- EDIT4 TABLE [2906-11399] -->
454 D = These files have there focus on the Data Functionality. They manipulate the
<a href=
"geda-pcb_developer_introduction.html#pcbtype" class=
"wikilink1" title=
"geda-pcb_developer_introduction.html">PCBType
</a> or
<a href=
"geda-pcb_developer_introduction.html#datatype" class=
"wikilink1" title=
"geda-pcb_developer_introduction.html">DataType
</a> structure.
458 C = These files have there focus on the Core Functionality. They support the overall working of the program.
462 H = These files have there focus on the HID Functionality. They support the HID actions and requests.
467 <h2 id=
"buildsystem">Build system
</h2>
471 You must have a working build system before you even can think about hacking the source code. Make sure you can build a git clone.
<br/>
473 Try building the sources from git before you try anything else.
<br/>
475 The wiki page http://wiki.geda-project.org/geda:developer shows the git command to get the geda-gaf repository. We are talking about pcb here.
<br/>
476 For pcb we need to do:
478 <pre class=
"code">git clone git://git.geda-project.org/pcb.git
</pre>
481 For the other repositories take a look at http://git.geda-project.org/
485 Next get your build system working. http://wiki.geda-project.org/geda:gaf_building_git_version
489 While working on the pcb sources remember that PCB uses The AutoTools as there build system.
<br/>
490 This isn
't as daunting as it sounds, for the newbie developer.
<br/>
491 The PCB development team has made it easy for us.
497 <pre class=
"code">./autogen.sh
</pre>
500 and the scary part is over ;-)
506 <pre class=
"code">./configure
510 The autogen.sh script is usually only needed once, after a git clone or if a file is added to be build into PCB. See
<a href=
"geda-pcb_developer_introduction.html#example" class=
"wikilink1" title=
"geda-pcb_developer_introduction.html">Example
</a> on when to use the autogen.sh script.
514 For more information on the AutoTools take a look at: https://www.gnu.org/software/automake/manual/html_node/Autotools-Introduction.html
518 If you want to know more about git take a look at: https://git-scm.com/docs/gittutorial
523 <h2 id=
"dependencies">Dependencies
</h2>
527 PCB is a open source program and it uses open source libraries and tools to do what it does.
528 Doing a
<code>repoquery --requires pcb
</code> on my Fedora
20 system show the following dependencies:
530 <div class=
"table sectionedit5"><table class=
"inline">
532 <td class=
"col0 rightalign"> perl
</td><td class=
"col1 rightalign"> libdl.so
.2()
</td><td class=
"col2 rightalign"> libm.so
.6(GLIBC_2.2
.5)
</td>
535 <td class=
"col0 rightalign"> wish
</td><td class=
"col1 rightalign"> libdl.so
.2(GLIBC_2.2
.5)
</td><td class=
"col2 rightalign"> libpango-
1.0.so
.0()
</td>
538 <td class=
"col0 rightalign"> libGL.so
.1()
</td><td class=
"col1 rightalign"> libfontconfig.so
.1()
</td><td class=
"col2 rightalign"> libpangocairo-
1.0.so
.0()
</td>
541 <td class=
"col0 rightalign"> libGLU.so
.1()
</td><td class=
"col1 rightalign"> libfreetype.so
.6()
</td><td class=
"col2 rightalign"> libpangoft2-
1.0.so
.0()
</td>
544 <td class=
"col0 rightalign"> libICE.so
.6()
</td><td class=
"col1 rightalign"> libgd.so
.3()
</td><td class=
"col2 rightalign"> libpangox-
1.0.so
.0()
</td>
547 <td class=
"col0 rightalign"> libSM.so
.6()
</td><td class=
"col1 rightalign"> libgdk-x11-
2.0.so
.0()
</td><td class=
"col2 rightalign"> libpng16.so
.16()
</td>
550 <td class=
"col0 rightalign"> libX11.so
.6()
</td><td class=
"col1 rightalign"> libgdk_pixbuf-
2.0.so
.0()
</td><td class=
"col2 rightalign"> libpthread.so
.0()
</td>
553 <td class=
"col0 rightalign"> libXinerama.so
.1()
</td><td class=
"col1 rightalign"> libgdkglext-x11-
1.0.so
.0()
</td><td class=
"col2 rightalign"> libpthread.so
.0(GLIBC_2.2
.5)
</td>
556 <td class=
"col0 rightalign"> libXmu.so
.6()
</td><td class=
"col1 rightalign"> libgio-
2.0.so
.0()
</td><td class=
"col2 rightalign"> libtiff.so
.5()
</td>
559 <td class=
"col0 rightalign"> libXpm.so
.4()
</td><td class=
"col1 rightalign"> libglib-
2.0.so
.0()
</td><td class=
"col2 rightalign"> libvpx.so
.1()
</td>
562 <td class=
"col0 rightalign"> libXrender.so
.1()
</td><td class=
"col1 rightalign"> libgmodule-
2.0.so
.0()
</td><td class=
"col2 rightalign"> libz.so
.1()
</td>
565 <td class=
"col0 rightalign"> libXt.so
.6()
</td><td class=
"col1 rightalign"> libgobject-
2.0.so
.0()
</td><td class=
"col2 rightalign"> m4
</td>
568 <td class=
"col0 rightalign"> libatk-
1.0.so
.0()
</td><td class=
"col1 rightalign"> libgtk-x11-
2.0.so
.0()
</td><td class=
"col2 rightalign"> perl(File::Basename)
</td>
571 <td class=
"col0 rightalign"> libc.so
.6(GLIBC_2.14)
</td><td class=
"col1 rightalign"> libgtkglext-x11-
1.0.so
.0()
</td><td class=
"col2 rightalign"> perl(File::Copy)
</td>
574 <td class=
"col0 rightalign"> libcairo.so
.2()
</td><td class=
"col1 rightalign"> libjpeg.so
.62()
</td><td class=
"col2 rightalign"> rtld(GNU_HASH)
</td>
577 <td class=
"col0 rightalign"> libdbus-
1.so
.3()
</td><td class=
"col1 rightalign"> libm.so
.6()
</td><td class=
"col2"> </td>
580 <!-- EDIT5 TABLE [13410-14361] -->
583 <h2 id=
"traceanaction">Trace an action
</h2>
587 Here is a short introduction where to start if you want to trace an action down into the source code:
588 Lets draw a line in the (GTK) GUI.
592 If we start pcb the default mode is the select mode, in order to draw a trace we need to switch to the LINE mode. We do that by pressing
<kbd>F2
</kbd>. Next we use the mouse to select a starting point and do a left click of the mouse button. Now we can start drawing a trace.
596 So what happens in the source code? PCB uses a flexible way of implementing menu structures and it uses a flexible way to implement actions the program should do. All this flexibility made it a bit difficult for me to see where to start.
601 <h3 id=
"f2key">F2 key
</h3>
605 First let
's trace the LINE mode selecting by pressing
<kbd>F2
</kbd>.
609 In the file
<em><strong>gpcb-menu.res
</strong></em> we look for our
<kbd>F2
</kbd> key and we find
611 <pre class=
"code">{
"Line
" checked=linemode,
1 Mode(Line) a={
"F2
" "<Key
>F2
"}}
</pre>
614 In the file
<em><strong>action.c
</strong></em> we find
616 <pre class=
"code">HID_Action action_action_list[] {
"Mode
",
0, ActionMode, mode_help, mode_syntax}
</pre>
619 The action_action_list defines that the
<strong>Mode
</strong> event is translated into the
<em class=
"u">ActionMode
</em> function. So the function called when we press
<kbd>F2
</kbd> is
<code>ActionMode(Line)
</code>.
623 ActionMode is a generic function and therefore it will need to find what to do.
625 <pre class=
"code c">ActionMode
<span class=
"br0">(</span><span class=
"kw4">int
</span> argc
<span class=
"sy0">,
</span> <span class=
"kw4">char
</span> <span class=
"sy0">**
</span>argv
<span class=
"sy0">,
</span> Coord x
<span class=
"sy0">,
</span> Coord y
<span class=
"br0">)</span></pre>
628 It will do that by calling
<code>GetFunctionID (AGV[
0])
</code> in this example AGV[
0] = Line. The function ID will tell it to do the function
<code>SetMode (LINE_MODE);
</code>
632 That function will set the variable
<strong>Settings.Mode
</strong> to LINE_MODE
636 <a href=
"media/devel_intro/set_mode.png" class=
"media" target=
"_blank" title=
"devel_intro:set_mode.png">devel_intro:set_mode.png
</a>
641 <h3 id=
"mouseclick">Mouse click
</h3>
645 Next we trace down what will happen if we left click the mouse button to start drawing a track.
<br/>
646 Please note this is a very simplified call graph.
650 <a href=
"media/devel_intro/draw_line.png" class=
"media" target=
"_blank" title=
"devel_intro:draw_line.png">devel_intro:draw_line.png
</a>
654 In the file
<em><strong>gpcb-menu.res
</strong></em> Left mouse click Mouse = Left =
> points to Mode(Notify)
662 <strong>Mode
</strong> translates in the action_action_list into _ActionMode_
666 [*
2] Left mouse click translates into calling function ActionMode(Notify)
670 [*
3] The program will go back and forth between NotifyMode and NotifyLine until [*
4].
<br/>
672 In the function NotifyLine all the dynamic processing is done, meaning that here the limitations and restrictions are check realtime. e.g. if the Auto force DRC check flag is checked, this function checks if we try to draw over existing copper.
676 [*
4]if two points are selected we can create a line
680 [*
5] We need to free memory-space and add our new Line into the linked list. This is done through the GLIB Library.
681 Next our newly created LINE object is filled with the relevant data.
682 Basically we are done, the line is added to the data structure. However there is one more thing to do.
686 [*
6] Our new line is stored into the main PCBType data structure (actually in the DataType sub structure). Now there is one more administrative task to do, the newly created line must be add to the rtree data structure. Every item that is added to the data structure is also added to the rtree data structure. The R-TREE data structure makes it easy to search for free or occupied areas on a layer.
690 This is in a very simplified description on what happens and the path the software takes to draw a line.
695 <h2 id=
"crosshair">Crosshair
</h2>
699 From: http://www.delorie.com/pcb/docs/gs/gs.html#Terminology
707 This is the actual location on the board which is used when you perform an action. If grid snap is active, the crosshair reflects the grid point closest to the cursor, else the crosshair reflects the cursor itself.
711 So the crosshair is the X Y position on the PCB canvas. When grid is enabled the crosshair is automatically snapped to the grid.
<br/>
712 Let
's see how that works:
716 Open the file
<em><strong>crosshair.c
</strong></em> with your favourite text editor and look for the function
<code>FitCrosshairIntoGrid.
</code> In my version its around line
920.
720 Add the debug code into the function:
722 <pre class=
"code c"><span class=
"coMULTI">/* ---------------------------------------------------------------------------
723 * recalculates the passed coordinates to fit the current grid setting
725 <span class=
"kw4">void
</span>
726 FitCrosshairIntoGrid
<span class=
"br0">(</span>Coord X
<span class=
"sy0">,
</span> Coord Y
<span class=
"br0">)</span>
727 <span class=
"br0">{</span>
728 Coord nearest_grid_x
<span class=
"sy0">,
</span> nearest_grid_y
<span class=
"sy0">;
</span>
729 <span class=
"kw4">void
</span> <span class=
"sy0">*
</span>ptr1
<span class=
"sy0">,
</span> <span class=
"sy0">*
</span>ptr2
<span class=
"sy0">,
</span> <span class=
"sy0">*
</span>ptr3
<span class=
"sy0">;
</span>
730 <span class=
"kw4">struct
</span> snap_data snap_data
<span class=
"sy0">;
</span>
731 <span class=
"kw4">int
</span> ans
<span class=
"sy0">;
</span>
733 <span class=
"coMULTI">/* Add the next two lines */
</span>
734 <span class=
"coMULTI">/* RZE: Debug code please remove if I forget */
</span>
735 pcb_printf
<span class=
"br0">(</span><span class=
"st0">"X=%d, Y=%d
<span class=
"es1">\n
</span>"</span><span class=
"sy0">,
</span> Crosshair.
<span class=
"me1">X
</span><span class=
"sy0">,
</span> Crosshair.
<span class=
"me1">Y
</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
737 Crosshair.
<span class=
"me1">X
</span> <span class=
"sy0">=
</span> CLAMP
<span class=
"br0">(</span>X
<span class=
"sy0">,
</span> Crosshair.
<span class=
"me1">MinX
</span><span class=
"sy0">,
</span> Crosshair.
<span class=
"me1">MaxX
</span><span class=
"br0">)</span><span class=
"sy0">;
</span><span class=
"st0">''
</span>
738 Crosshair.
<span class=
"me1">Y
</span> <span class=
"sy0">=
</span> CLAMP
<span class=
"br0">(</span>Y
<span class=
"sy0">,
</span> Crosshair.
<span class=
"me1">MinY
</span><span class=
"sy0">,
</span> Crosshair.
<span class=
"me1">MaxY
</span><span class=
"br0">)</span><span class=
"sy0">;
</span><span class=
"st0">''
</span></pre>
742 From the command-line terminal do:
744 <pre class=
"code">cd
<to_pcb_source_directory
>
750 In your terminal you will see the X and Y coordinates of the crosshair.
<br/>
751 Please note that they are rounded numbers.
<br/>
752 Turn off grid snapping and watch the numbers.
756 Congratulations, you just hacked into the PCB source code ;-)
761 <h2 id=
"example">Example
</h2>
765 As an exercise let
's do something easy, like adding an action to PCB.
769 Before you start coding take a look at:
<a href=
"geda-pcb_developer_introduction.html#buildsystem" class=
"wikilink1" title=
"geda-pcb_developer_introduction.html">Build system
</a>
770 It is essential that you have a working build system.
774 When working on the source code of PCB then please make use of lots and lots of comments (preferably doxygen style). In trying to understand the code I was very grateful for every piece of comment the developer had written.
778 First make a file called
<em><strong>example.c
</strong></em> and add:
780 <pre class=
"code c"><span class=
"coMULTI">/*!
781 * =====================================================================================
784 * Example action implementation for PCB.
785 * Copyright (C)
2015 Robert Zeegers
787 * This program is free software; you can redistribute it and/or
788 * modify it under the terms of the GNU General Public License
789 * as published by the Free Software Foundation; either version
2
790 * of the License, or (at your option) any later version.
792 * This program is distributed in the hope that it will be useful,
793 * but WITHOUT ANY WARRANTY; without even the implied warranty of
794 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
795 * GNU General Public License for more details.
797 * You should have received a copy of the GNU General Public License
798 * along with this program; if not, write to the Free Software
799 * Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA
02110-
1301, USA.
802 * \Brief: Example on how to implement a action in the PCB program.
804 * Example action implementation for PCB, interactive printed circuit board design
805 * \copyright (C)
2015 Robert Zeegers
811 * \Bug: not that I know of
813 * =====================================================================================
816 <span class=
"coMULTI">/* First thing todo is include global.h */
</span>
817 <span class=
"coMULTI">/* This will automatically also include const.h and macro.h */
</span>
818 <span class=
"co2">#include
"global.h
"</span>
820 <span class=
"coMULTI">/* Second we include hid.h because we want to register our action to the HID */
</span>
821 <span class=
"co2">#include
"hid.h
"</span>
823 <span class=
"coMULTI">/* We are going to add an action and therefore we want it to show-up in the PCB manual, */
</span>
824 <span class=
"coMULTI">/* so we add some documentation comments */
</span>
825 <span class=
"coMULTI">/* For the documentation style see the
"extract-docs
" perl script in the doc directory */
</span>
827 <span class=
"coMULTI">/* %start-doc actions DoSilly
828 This function doesn't do anything useful.
836 <span class=
"coMULTI">/* All action entry functions must have the same syntax as defined in */
</span>
837 <span class=
"coMULTI">/* typedef struct HID_Action (hid.h) */
</span>
838 <span class=
"kw4">static
</span> <span class=
"kw4">int
</span>
839 ExampleDo
<span class=
"br0">(</span><span class=
"kw4">int
</span> argc
<span class=
"sy0">,
</span> <span class=
"kw4">char
</span> <span class=
"sy0">**
</span>argv
<span class=
"sy0">,
</span> <span class=
"kw4">int
</span> x
<span class=
"sy0">,
</span> <span class=
"kw4">int
</span> y
<span class=
"br0">)</span>
840 <span class=
"br0">{</span>
841 <span class=
"coMULTI">/* It should do something, so let's do something silly */
</span>
842 <span class=
"coMULTI">/* Let's write a Dutch songtext to the Message Log window */
</span>
843 <span class=
"coMULTI">/* The struct HID is defined in hid.h */
</span>
844 <span class=
"coMULTI">/* and the variable gui is made available there by
"extern HID *gui;
" */
</span>
845 <span class=
"coMULTI">/* First we check if we have a gui. */
</span>
846 <span class=
"kw1">if
</span><span class=
"br0">(</span> <span class=
"nu0">1</span> <span class=
"sy0">==
</span> gui
<span class=
"sy0">-
></span>gui
<span class=
"br0">)</span>
847 <span class=
"br0">{</span>
848 <span class=
"coMULTI">/* if we have one let's write the songtext */
</span>
849 gui
<span class=
"sy0">-
></span><a href=
"http://www.opengroup.org/onlinepubs/009695399/functions/log.html"><span class=
"kw3">log
</span></a> <span class=
"br0">(</span>_
<span class=
"br0">(</span><span class=
"st0">"Iedereen is van de wereld en de wereld is van iedereen!
<span class=
"es1">\n
</span>"</span><span class=
"br0">)</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
850 <span class=
"br0">}</span>
851 <span class=
"br0">}</span>
853 <span class=
"coMULTI">/* Now we have to make an action list. */
</span>
854 <span class=
"coMULTI">/* Here we make the connection between our command
"DoSilly()
" and */
</span>
855 <span class=
"coMULTI">/* the actual function which should be executed ExampleDo().*/
</span>
856 <span class=
"kw4">static
</span> HID_Action exampledo_action_list
<span class=
"br0">[</span><span class=
"br0">]</span> <span class=
"sy0">=
</span> <span class=
"br0">{</span>
857 <span class=
"br0">{</span><span class=
"st0">"DoSilly
"</span><span class=
"sy0">,
</span> <span class=
"st0">"Example action
"</span><span class=
"sy0">,
</span> ExampleDo
<span class=
"sy0">,
</span> <span class=
"st0">"Always provide some help
"</span><span class=
"sy0">,
</span> <span class=
"st0">"DoSilly()
"</span><span class=
"br0">}</span>
858 <span class=
"br0">}</span><span class=
"sy0">;
</span>
860 <span class=
"coMULTI">/* Next a macro to register the action in the HID */
</span>
861 <span class=
"coMULTI">/* Note the missing ; at the end, that's correct ;-) */
</span>
862 REGISTER_ACTIONS
<span class=
"br0">(</span>exampledo_action_list
<span class=
"br0">)</span></pre>
865 For an explanation on the
<code>REGISTER_ACTION
</code> macro see paragraph
<a href=
"geda-pcb_developer_introduction.html#register" class=
"wikilink1" title=
"geda-pcb_developer_introduction.html">REGISTER
</a>.
869 Next we need to add our file to the build system.
<br/>
871 We do that in the file
<em><strong>MakeFile.am
</strong></em>.
<br/>
872 Open
<em><strong>MakeFile.am
</strong></em> and look for the variable
<em class=
"u">PCB_SRCS
</em> and add the file
<em><strong>example.c
</strong></em> there like the others.
876 Clean your build directory by doing:
878 <pre class=
"code">make distclean
</pre>
883 <pre class=
"code">./autogen.sh
</pre>
886 Now our file is in
<em><strong>MakeFile.in
</strong></em>
892 <pre class=
"code">./configure
898 <pre class=
"code">src/pcb
</pre>
901 In the PCB program type
":DoSilly()
" and watch the message log window.
905 And do check out the pcb manual in doc/pcb.pdf search for
"DoSilly
"
910 <h2 id=
"register">REGISTER
</h2>
914 <strong>REGISTER_ACTIONS - REGISTER_FLAGS - REGISTER_ATTRIBUTES
</strong>
918 Every action file must register its actions in the HID.
919 The action file will have an
921 <pre class=
"code c"><span class=
"co2">#include
"hid.h
"</span></pre>
924 which define the REGISTER_* macros.
925 Then somewhere in the file you add:
927 <pre class=
"code">REGISTER_ACTIONS(exampledo_action_list)
</pre>
930 This will be expanded by the preprocessor into:
932 <pre class=
"code c"><span class=
"kw4">void
</span> register_exampledo_action_list
<span class=
"br0">(</span><span class=
"br0">)</span>
933 <span class=
"br0">{</span> hid_register_actions
<span class=
"br0">(</span>exampledo_action_list
<span class=
"sy0">,
</span><span class=
"nu0">1</span><span class=
"br0">)</span><span class=
"sy0">;
</span> <span class=
"br0">}</span></pre>
936 During the build process the files
<em><strong>core_lists.h
</strong></em> and
<em><strong>gtk_lists.h
</strong></em> are created. These files contain nothing more than a collection of REGISTER_* instructions it found in its source files.
<br/>
937 So
<em><strong>core_lists.h
</strong></em> and
<em><strong>gtk_lists.h
</strong></em> will contain:
939 <pre class=
"code">REGISTER_ACTION(exampledo_action_list)
</pre>
942 In the file
<em><strong>main.c
</strong></em> around the
<em class=
"u">main
</em> functions we find the instruction:
944 <pre class=
"code c"><span class=
"co2">#include
"dolists.h
"</span></pre>
947 And soon after that we find
949 <pre class=
"code c"><span class=
"co2">#include
"core_lists.h
"</span></pre>
952 Because
<em><strong>dolists.h
</strong></em> redefines the REGISTER_* macros, the macros in
<em><strong>core_lists.h
</strong></em>
954 <pre class=
"code">REGISTER_ACTIONS(exampledo_action_list)
</pre>
957 will be expanded by the preprocessor into:
959 <pre class=
"code c">external
<span class=
"kw4">void
</span> register_exampledo_action_list
<span class=
"br0">(</span><span class=
"br0">)</span><span class=
"sy0">;
</span>
960 register_exampledo_action_list
<span class=
"br0">(</span><span class=
"br0">)</span><span class=
"sy0">;
</span></pre>
963 And therefore it will call all functions to register the actions at the beginning of the main function.
968 <h3 id=
"options">Options
</h3>
970 <div class=
"table sectionedit6"><table class=
"inline">
972 <td class=
"col0">REGISTER_ACTIONS
</td><td class=
"col1">These actions can be called though the user command window (start with
":
" in the PCB program.
</td>
975 <td class=
"col0">REGISTER_FLAGS
</td><td class=
"col1">These flags initiate a functions when set or unset.
<br/>
976 E.g. in file
<em><strong>flags.c
</strong></em> we find
<pre class=
"code c">HID_Flag flags_flag_list
<span class=
"br0">[</span><span class=
"br0">]</span> <span class=
"sy0">=
</span> <span class=
"br0">{</span>
977 <span class=
"br0">{</span><span class=
"st0">"style
"</span><span class=
"sy0">,
</span> FlagCurrentStyle
<span class=
"sy0">,
</span> NULL
<span class=
"br0">}</span><span class=
"sy0">,
</span>
978 <span class=
"br0">{</span><span class=
"st0">"grid
"</span><span class=
"sy0">,
</span> FlagGrid
<span class=
"sy0">,
</span> NULL
<span class=
"br0">}</span><span class=
"sy0">,
</span></pre>
981 The
"grid
" flags is associated with the menu flag:
<strong>View-
>enable visible grid
</strong> and makes the connection to the
<code>FlagGrid()
</code> function.
<br/>
982 If you select
<strong>View-
>enable visible grid
</strong> the function
<code>FlagGrid
</code> will be called.
987 <td class=
"col0">REGISTER_ATTRIBUTES
</td><td class=
"col1">In
<em><strong>main.c
</strong></em> there is a call to this macro:
<code>REGISTER_ATTRIBUTES (main_attribute_list)
</code><br/>
988 The main_attribute_list defines the command-line options.
<br/>
989 Most of the HID also use this macro, to add their command line options as well.
</td>
992 <!-- EDIT6 TABLE [25173-26028] -->
995 <h2 id=
"pcbtype">PCBType
</h2>
999 PCBType is the main data structure
1003 PCBType contain all the general information used in the program and it contains a pointer to the DataType
1007 <a href=
"media/devel_intro/structpcbtype_graph.png" class=
"media" target=
"_blank" title=
"devel_intro:structpcbtype_graph.png">devel_intro:structpcbtype_graph.png
</a>
1012 <h2 id=
"datatype">DataType
</h2>
1013 <div class=
"level2">
1016 The DataType contains the actual data that defines our printed circuit board.
1020 DataType is what
's stored in the Buffers when you do cut/paste.
1022 <div class=
"table sectionedit7"><table class=
"inline">
1025 <th class=
"col0">Data Fields
</th><th class=
"col1" colspan=
"2"> </th>
1029 <td class=
"col0">Cardinal
</td><td class=
"col1">ViaN
</td><td class=
"col2"> </td>
1032 <td class=
"col0">Cardinal
</td><td class=
"col1">ElementN
</td><td class=
"col2"> </td>
1035 <td class=
"col0">Cardinal
</td><td class=
"col1">RatN
</td><td class=
"col2"> </td>
1038 <td class=
"col0">int
</td><td class=
"col1">LayerN
</td><td class=
"col2"> </td>
1041 <td class=
"col0">GList *
</td><td class=
"col1">Via
</td><td class=
"col2">Layer independent via
's
</td>
1044 <td class=
"col0">GList *
</td><td class=
"col1">Element
</td><td class=
"col2">Layer independent elements
</td>
1047 <td class=
"col0">GList *
</td><td class=
"col1">Rat
</td><td class=
"col2">Layer independent rat-lines
</td>
1050 <td class=
"col0">rtree_t *
</td><td class=
"col1">via_tree
</td><td class=
"col2"> </td>
1053 <td class=
"col0">rtree_t *
</td><td class=
"col1">element_tree
</td><td class=
"col2"> </td>
1056 <td class=
"col0">rtree_t *
</td><td class=
"col1">pin_tree
</td><td class=
"col2"> </td>
1059 <td class=
"col0">rtree_t *
</td><td class=
"col1">pad_tree
</td><td class=
"col2"> </td>
1062 <td class=
"col0">rtree_t *
</td><td class=
"col1">name_tree [
3]
</td><td class=
"col2"> </td>
1065 <td class=
"col0">rtree_t *
</td><td class=
"col1">rat_tree
</td><td class=
"col2"> </td>
1068 <td class=
"col0">struct PCBType *
</td><td class=
"col1">pcb
</td><td class=
"col2">A pointer back to the main data structure
</td>
1071 <td class=
"col0">LayerType
</td><td class=
"col1">Layer [MAX_LAYER+
2]
</td><td class=
"col2">All layer dependent items
</td>
1074 <td class=
"col0">int
</td><td class=
"col1">polyClip
</td><td class=
"col2"> </td>
1077 <!-- EDIT7 TABLE [26402-26904] -->
1079 The actual data is stored in the
<a href=
"geda-pcb_developer_introduction.html#glist" class=
"wikilink1" title=
"geda-pcb_developer_introduction.html">GList
</a> data elements. The rest is there for administrative purposes, to keep track of it all.
1080 Here I like to specially mention the rtree_t* data members. Although they have an administrative character the
<a href=
"geda-pcb_developer_introduction.html#r-tree" class=
"wikilink1" title=
"geda-pcb_developer_introduction.html">R-TREE
</a> data structure is heavily used in the PCB program.
1085 <h2 id=
"glist">GList
</h2>
1086 <div class=
"level2">
1087 <pre class=
"code c"><span class=
"kw4">struct
</span> GList
<span class=
"br0">{</span>
1088 gpointer data
<span class=
"sy0">;
</span>
1089 GList
<span class=
"sy0">*
</span>next
<span class=
"sy0">;
</span>
1090 GList
<span class=
"sy0">*
</span>prev
<span class=
"sy0">;
</span>
1091 <span class=
"br0">}</span><span class=
"sy0">;
</span> </pre>
1094 The GList struct is used for each element in a doubly-linked list.
1100 <div class=
"table sectionedit8"><table class=
"inline">
1102 <td class=
"col0">gpointer data
</td><td class=
"col1">holds the element
's data , which can be a pointer to any kind of data.
</td>
1105 <td class=
"col0">GList *next
</td><td class=
"col1">contains the link to the next element in the list
</td>
1108 <td class=
"col0">GList *prev;
</td><td class=
"col1">contains the link to the previous element in the list
</td>
1111 <!-- EDIT8 TABLE [27458-27677] -->
1115 <pre class=
"code c"><span class=
"kw4">typedef
</span> <span class=
"kw4">void
</span><span class=
"sy0">*
</span> gpointer
<span class=
"sy0">;
</span></pre>
1118 An untyped pointer.
<code>gpointer
</code> looks better and is easier to use than
<code>void*
</code>.
1123 <h2 id=
"r-tree">R-TREE
</h2>
1124 <div class=
"level2">
1128 The key idea of the r-tree data structure is to group nearby objects and represent them with their minimum bounding rectangle in the next higher level of the tree; the
"R
" in R-tree is for rectangle. Since all objects lie within this bounding rectangle, a query that does not intersect the bounding rectangle also cannot intersect any of the contained objects. At the leaf level, each rectangle describes a single object; at higher levels the aggregation of an increasing number of objects. This can also be seen as an increasingly coarse approximation of the data set.
1132 A general r-tree will look like this:
1136 <a href=
"media/devel_intro/rtree.png" class=
"media" target=
"_blank" title=
"devel_intro:rtree.png">devel_intro:rtree.png
</a>
1140 The bottom row of records are called leafs.
1144 The rtree data structure PCB uses is:
1148 <a href=
"media/devel_intro/structrtree.png" class=
"media" target=
"_blank" title=
"devel_intro:structrtree.png">devel_intro:structrtree.png
</a>
1152 The r-tree data structure hold a copy of the where
's what data. Meaning that it holds a list of every item on our canvas arranged in successively smaller boxes.
1153 <a href=
"media/devel_intro/rtreepicture.png" class=
"media" target=
"_blank" title=
"devel_intro:rtreepicture.png">devel_intro:rtreepicture.png
</a>
1158 <h2 id=
"morein-depthexplanations">More in-depth explanations:
</h2>
1159 <div class=
"level2">
1161 <li class=
"level1"><div class=
"li"> DRC
</div>
1163 <li class=
"level1"><div class=
"li"> ?
</div>