Index: doc-rnd/hacking/data1.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: doc-rnd/hacking/data1.png
===================================================================
--- doc-rnd/hacking/data1.png (nonexistent)
+++ doc-rnd/hacking/data1.png (revision 2674)
Property changes on: doc-rnd/hacking/data1.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: doc-rnd/hacking/import.html
===================================================================
--- doc-rnd/hacking/import.html (nonexistent)
+++ doc-rnd/hacking/import.html (revision 2674)
@@ -0,0 +1,64 @@
+
+
+ pcb-rnd hacking - how importers work
+
+ Introduction
+This document describes the common aspects of import code, be it an
+import_ plugin or the load part of an io_plugin, importing a footprint,
+loading a board or a netlist.
+
+ Data structures
+
+The board is stored in PCBType *. Some import code, like the one
+that loads a design (an io plugin's ->parse_pcb function), gets the
+target in an argument. (Other, non-import code usually operate on
+the global variable that represents the current board:
+PCBType *PCB.).
+
+In either case, PCBType's most important field is PCBDataType *data,
+which holds lists and vectors to store all objects on the board. When
+the target is a buffer (e.g. io plugin's ->parse_element function), it's
+a DataType *buf which also have a PCBDataType *data containing
+the same data a board could.
+
+A PCBDataType struct in turn has three sets of important fields:
+
+ - lists for layer-independent objects (e.g. rat lines, vias, elements)
+
- number of layers in use (LayerN) and an array of layers (see later)
+
- rtree structures - these are used for looking up objects for locations
+
+Each layer is a LayerType structure. A layer has the following fields:
+
+ - lists for lines, texts, arcs, polygons
+
- some generic layer attributes (colors, flags, key-value pairs)
+
- an rtree struct for each object type.
+
+
+Any code that needs to create objects should use the functions in create.[ch].
+The functions that operate layer-independently usually get a destination as
+PCBDataType, so they can operate both on boards and buffers. A typical
+example is PinTypePtr CreateNewVia(DataTypePtr Data, ...) that returns
+NULL or the pointer to the new via that is already added to the corresponding list
+of Data and in the rtree.
+
+Layer object creation is done referencing the layer as LayerType *. A
+typical example is LineTypePtr CreateDrawnLineOnLayer(LayerTypePtr Layer, ...)
+which returns NULL on error or a pointer to the new line object created (inserted
+in the layer's line list, added to the rtree).
+
+Code should avoid manipulating the lists and rtree structures directly.
+
+
+
+Figure 1. simplified map of object related data structures
+
+diamond: variable; rectangle: struct; round: struct field
+ |
+
+
+ Extra steps around creating a new board
+TODO: postproc, post*, other setup
+
+
+
+
Index: doc-rnd/hacking/src/Makefile
===================================================================
--- doc-rnd/hacking/src/Makefile (nonexistent)
+++ doc-rnd/hacking/src/Makefile (revision 2674)
@@ -0,0 +1,2 @@
+../data1.png: data1.dot
+ dot -Tpng $^ > $@
Index: doc-rnd/hacking/src/data1.dot
===================================================================
--- doc-rnd/hacking/src/data1.dot (nonexistent)
+++ doc-rnd/hacking/src/data1.dot (revision 2674)
@@ -0,0 +1,47 @@
+digraph pcb_data {
+ PCBType_misc [label="misc fields:\nID\nName\nFileName\ncolors\ndrc settings\ncursor coords\ngrid\nlayergroups\nroute styles\n..."]
+ PCBType_flags [label="flags:\nChanged\nViaOn (vias drawn?)\n..."]
+ PCBType -> PCBType_misc
+ PCBType -> PCBType_flags
+ PCBType -> DataType
+ PCBType [shape=box]
+
+ PCB [label="extern PCBType PCB\nglobal variable\nholding the current\nboard" shape=diamond]
+ PCB -> PCBType
+
+ Buffers [label="extern BufferType Buffers[]\nglobal variable holding\nall paste buffers" shape=diamond]
+ Buffers -> BufferType
+
+ BufferType_misc [label="misc fields:\nbounding box\noffset"]
+ BufferType -> BufferType_misc
+ BufferType -> DataType
+ BufferType [shape=box]
+
+ DataType_lists [label="layer-independent lists:\nrats\nvias\nelements"]
+ DataType_rtrees [label="layer-independent rtrees"]
+ DataType_LayerN [label="LayerN: number of\nlayers in use"]
+ DataType_layers [label="an array of layers"]
+
+ DataType -> DataType_misc
+ DataType -> DataType_LayerN
+ DataType -> DataType_layers
+ DataType -> DataType_lists
+ DataType -> DataType_rtrees
+ DataType [shape=box]
+
+ DataType_layers -> LayerType
+
+
+ LayerType_lines [label="list and rtree of lines"]
+ LayerType_arcs [label="list and rtree of arcs"]
+ LayerType_texts [label="list and rtree of text objects"]
+ LayerType_polygons [label="list and rtree of polygons"]
+ LayerType_misc [label="misc fields:\nflags\ncolors"]
+
+ LayerType -> LayerType_misc
+ LayerType -> LayerType_lines
+ LayerType -> LayerType_arcs
+ LayerType -> LayerType_texts
+ LayerType -> LayerType_polygons
+ LayerType [shape=box]
+}