Root/
| 1 | fped - Footprint editor |
| 2 | ======================= |
| 3 | |
| 4 | fped is an editor that allows the interactive creation of footprints of |
| 5 | electronic components. Footprint definitions are stored in a text format |
| 6 | that resembles a programming language. |
| 7 | |
| 8 | The language is constrained such that anything that can be expressed in |
| 9 | the textual definition also has a straightforward equivalent operation |
| 10 | that can be performed through the GUI. |
| 11 | |
| 12 | This README describes only the footprint definition language. A |
| 13 | description of the GUI can be found here: |
| 14 | |
| 15 | http://downloads.qi-hardware.com/people/werner/fped/gui.html |
| 16 | |
| 17 | This work is distributed under the terms of the GNU GENERAL PUBLIC |
| 18 | LICENSE, Version 2: |
| 19 | |
| 20 | This program is free software; you can redistribute it and/or modify |
| 21 | it under the terms of the GNU General Public License as published by |
| 22 | the Free Software Foundation; either version 2 of the License, or |
| 23 | (at your option) any later version. |
| 24 | |
| 25 | For your convenience, a copy of the complete license has been included |
| 26 | in the file COPYING.GPLv2. |
| 27 | |
| 28 | |
| 29 | Building |
| 30 | -------- |
| 31 | |
| 32 | Prerequisites: |
| 33 | |
| 34 | - bash |
| 35 | - flex |
| 36 | - bison |
| 37 | - fig2dev (transfig) |
| 38 | - ImageMagick |
| 39 | - Netpbm |
| 40 | - Gtk+ 2.x development package (libgtk2.0-dev or similar) |
| 41 | - Liberation Fonts (ttf-liberation or similar) |
| 42 | |
| 43 | Check out the repository: |
| 44 | |
| 45 | git clone git://projects.qi-hardware.com/fped.git |
| 46 | cd fped |
| 47 | |
| 48 | Get updates: |
| 49 | |
| 50 | git pull |
| 51 | |
| 52 | Compile: |
| 53 | |
| 54 | make |
| 55 | |
| 56 | Run an example: |
| 57 | |
| 58 | ./fped examples/qfn.fpd |
| 59 | |
| 60 | |
| 61 | Motivation |
| 62 | ---------- |
| 63 | |
| 64 | KiCad already includes a footprint ("module") editor, so why do we need |
| 65 | a new one ? The issue with footprint generation for KiCad is that the |
| 66 | built-in module editor is basically a drawing program that only captures |
| 67 | the result of the module author's interpretation of a footprint drawing, |
| 68 | but does not include the steps that led to this construction. |
| 69 | |
| 70 | Furthermore, accurate measuring of dimensions in the drawing can only be |
| 71 | done manually in the module editor, which makes review difficult and |
| 72 | time-consuming. |
| 73 | |
| 74 | In fped, the construction process is made explicit and each step can be |
| 75 | expressed in terms of the parameters that appear in the vendor's |
| 76 | drawing. Dimensions can be explicitly measured and the results can be |
| 77 | included in the graphical output generated by fped. |
| 78 | |
| 79 | Directly using parameters and construction steps from the reference |
| 80 | drawing reduces the risk of mistakes. Visualizing the construction |
| 81 | process and verificative measurements helps efficient and accurate |
| 82 | review. |
| 83 | |
| 84 | Leveraging the work already done, and growing the intellectual commons |
| 85 | of available footprints has motivated the addition of an export to gEDA |
| 86 | pcb format option. Single or multiple footprints are exported in a |
| 87 | gEDA PCB layout (.pcb) file. A select all command can be used, followed |
| 88 | by a "disperse elements" command, to allow viewing of multiple elements |
| 89 | in the gEDA layout editor. An element can then be selected, cut to |
| 90 | buffer, and exported to a footprint (.fp) file with the usual menu |
| 91 | commands. |
| 92 | |
| 93 | gEDA PCB format footprints are exported in centimil units. Pads with |
| 94 | offset centre holes are not faithfully reproduced; the pad is exported |
| 95 | with minimum dimensions and centred on the hole. Trapezoidal and |
| 96 | roundrect pads are not supported in gEDA. |
| 97 | |
| 98 | |
| 99 | Footprint definition file format |
| 100 | -------------------------------- |
| 101 | |
| 102 | Footprint definitions are stored in text files. The program "fped" reads |
| 103 | and (soon) writes such files, visualizes their content, and provides a |
| 104 | graphical editor for them. |
| 105 | |
| 106 | The syntax is unique and draws from elements of a variety of languages |
| 107 | commonly found on unix systems. One specialty is that there are no |
| 108 | reserved words - the language keywords appear only at the beginning of |
| 109 | a line and can thus be recognized as such without restricting their use |
| 110 | for identifiers. This reduces the risk of creating incompatibilities |
| 111 | with existing designs when introduction future language features. |
| 112 | |
| 113 | fped uses the C preprocessor for comments, conditional compilation, |
| 114 | and - to a limited extent - also macros. Long lines can be split by |
| 115 | ending them with a backslash. If multiple items need to be placed in a |
| 116 | single line, e.g., in a macro, they can be separated with semicolons. |
| 117 | |
| 118 | The file has the following structure: |
| 119 | |
| 120 | frame definitions |
| 121 | ... |
| 122 | package name |
| 123 | setup |
| 124 | objects |
| 125 | ... |
| 126 | |
| 127 | |
| 128 | Geometry model |
| 129 | -------------- |
| 130 | |
| 131 | The geometry model consists of frames, vectors, and objects. The shape of |
| 132 | objects is defined by a number of points. These points are produced by |
| 133 | concatenating vectors. |
| 134 | |
| 135 | E.g., to draw a line from (1mm, 1mm) to (2mm, 2mm), one would make a |
| 136 | vector from the origin to (1mm, 1mm) and one either from the origin or |
| 137 | from the previous vector to (2mm, 2mm), and then make a line connecting |
| 138 | the two points. |
| 139 | |
| 140 | |
| 141 | Setup |
| 142 | - - - |
| 143 | |
| 144 | The setup section defines settings that affect the entire footprint. |
| 145 | It is optional and can contain a "unit" directive and an "allow" |
| 146 | directive. |
| 147 | |
| 148 | |
| 149 | Units |
| 150 | - - - |
| 151 | |
| 152 | fped can calculate in mm and mil. Units are specified by following a |
| 153 | number with "mm", "um", or "mil", separated by zero or more spaces or |
| 154 | tabs. |
| 155 | |
| 156 | Examples: |
| 157 | |
| 158 | 1mm |
| 159 | 2 mil |
| 160 | |
| 161 | Units can be mixed in calculations, e.g., |
| 162 | |
| 163 | set a = 1mm+20mil |
| 164 | set b = 10*1mm |
| 165 | |
| 166 | All values used as dimensions must be either mm or mil. |
| 167 | |
| 168 | The default unit can be set with one of the following directives: |
| 169 | |
| 170 | unit mm |
| 171 | unit mil |
| 172 | unit auto |
| 173 | |
| 174 | If the "unit" directive is omitted, fped defaults to millimeters. |
| 175 | |
| 176 | When saving a footprint definition, the default unit is set to the |
| 177 | unit set in the GUI. |
| 178 | |
| 179 | |
| 180 | Allow |
| 181 | - - - |
| 182 | |
| 183 | fped normally disallows overlapping pads. This restriction can be |
| 184 | relaxed with the "allow" directive. |
| 185 | |
| 186 | allow touch |
| 187 | |
| 188 | Allows pads touching but not having more than their border in common. |
| 189 | |
| 190 | allow overlap |
| 191 | |
| 192 | Do not check for overlaps at all. |
| 193 | |
| 194 | If the "allow" directive is omitted, fped defaults to allowing |
| 195 | neither overlap nor touch. |
| 196 | |
| 197 | There is also the following experimental directive that can be used |
| 198 | alone or without one of the overlap-checking directives: |
| 199 | |
| 200 | allow holes |
| 201 | |
| 202 | Allow multiple holes per pad. |
| 203 | |
| 204 | |
| 205 | Vectors |
| 206 | - - - - |
| 207 | |
| 208 | Vectors can be anonymous or they can be named for future reference: |
| 209 | |
| 210 | vec <base> ( <x-expr>, <y-expr> ) |
| 211 | <identifier>: vec <base> ( <x-expr>, <y-expr> ) |
| 212 | |
| 213 | The base can be one of the following items: |
| 214 | |
| 215 | - @ is the origin of the frame containing the vector |
| 216 | - . is the end of the previous vector in this frame |
| 217 | - <identifier> is the name of a previous vector in the same frame |
| 218 | |
| 219 | The following example would draw the line described in the previous |
| 220 | section: |
| 221 | |
| 222 | a: vec @(1mm, 1mm) |
| 223 | b: vec .(1mm, 1mm) |
| 224 | line a b |
| 225 | |
| 226 | |
| 227 | Silk screen objects |
| 228 | - - - - - - - - - - |
| 229 | |
| 230 | The output of fped is a footprint definition that contains pads and silk |
| 231 | screen drawings (we may add more layers in the future). These items are |
| 232 | called "objects". Their geometry is defined through points obtained with |
| 233 | vectors. |
| 234 | |
| 235 | A line connects two points: |
| 236 | |
| 237 | line <point-a> <point-b> [<width>] |
| 238 | |
| 239 | The points can be specified with @, ., and an identifier, just like |
| 240 | a vector base. The option width specifies the thickness of the silk |
| 241 | screen line. If omitted, a hard-coded default of 15 mil is used. |
| 242 | |
| 243 | A rectangle has sides parallel to the x and y axis and is defined |
| 244 | by two diagonally opposite corners: |
| 245 | |
| 246 | rect <point-a> <point-b> [<width>] |
| 247 | |
| 248 | A circle is defined by its center and a point on the circle: |
| 249 | |
| 250 | circ <center> <point> [<width>] |
| 251 | |
| 252 | This example draws a unit circle: |
| 253 | |
| 254 | vec @(1mm, 0mm) |
| 255 | circ @ . |
| 256 | |
| 257 | An arc is like a circle, but the part of the circle drawn is determined |
| 258 | by two points. The first point determines the radius and the starting |
| 259 | angle. The second point only determines the end angle but its distance |
| 260 | from the center is ignored. |
| 261 | |
| 262 | arc <center> <radius> <end> [<width>] |
| 263 | |
| 264 | The arc is drawn in a counter-clockwise direction. The following example |
| 265 | draws an arc of the unit circle in the x > 0, y > 0 quadrant: |
| 266 | |
| 267 | from: vec @(1mm, 0mm) |
| 268 | to: vec @(0mm, 1mm) |
| 269 | arc @ from to |
| 270 | |
| 271 | |
| 272 | Pads |
| 273 | - - |
| 274 | |
| 275 | Pads are similar to rectangles, but they also have a name. |
| 276 | |
| 277 | pad "<name>" <point-a> <point-b> [<type>] |
| 278 | |
| 279 | Variables can be expanded in a pad's name by prefixing their name with |
| 280 | a dollar sign. The ${name} syntax is also available. |
| 281 | |
| 282 | Example: |
| 283 | |
| 284 | vec @(1mm, 1mm) |
| 285 | pad "1" @ . |
| 286 | |
| 287 | Pads normally affect the surface copper layer, the solder mask layer, |
| 288 | and the solder paste layer. This can be modified with the optional |
| 289 | type argument: |
| 290 | |
| 291 | Type Layers |
| 292 | --------- ------------------------------------- |
| 293 | (default) copper, solder mask, and solder paste |
| 294 | bare copper and solder mask |
| 295 | trace copper without solder mask opening |
| 296 | paste solder paste |
| 297 | mask solder mask |
| 298 | |
| 299 | Typical uses: |
| 300 | - "bare": connectors printed directly on the PCB |
| 301 | - "trace": connections or antennas |
| 302 | - "paste": sparse solder paste, e.g., for QFN center pads |
| 303 | - "mask": non-standard mask openings, e.g., for solder mask defined |
| 304 | pads |
| 305 | |
| 306 | |
| 307 | Rounded pads |
| 308 | - - - - - - |
| 309 | |
| 310 | Rounded pads are like rectangular pads except that they end with a |
| 311 | semi-circle at each of the smaller sides of the enclosing rectangle. |
| 312 | If enclosed in a square, rounded pads form a circle. |
| 313 | |
| 314 | rpad "<name>" <point-a> <point-b> [<type>] |
| 315 | |
| 316 | |
| 317 | Holes |
| 318 | - - - |
| 319 | |
| 320 | Holes can be used for through-hole pins or for mechanical support. |
| 321 | In the former case, the hole must be placed inside a pad. Only one |
| 322 | hole per pad is allowed. Mechanical holes must be outside any pads. |
| 323 | |
| 324 | Through-hole pads are always present on both sides of the board, i.e., |
| 325 | when fped generates a KiCad module, the surface layers of a pad |
| 326 | containing a hole are propagated to the opposite side of the board. |
| 327 | |
| 328 | Holes have the same shape as a rounded pad and their geometry is |
| 329 | defined in the same way: |
| 330 | |
| 331 | hole <point-a> <point-b> |
| 332 | |
| 333 | |
| 334 | Measurements |
| 335 | - - - - - - |
| 336 | |
| 337 | *** This is obsolete - see the section on new-style mesurements at the end. *** |
| 338 | |
| 339 | Measurements show the distance between two points: |
| 340 | |
| 341 | meas <point-a> <point-b> <offset> |
| 342 | |
| 343 | The offset is the distance from the imaginary line connecting points A |
| 344 | and B the measurement line is draw: |
| 345 | |
| 346 | - if the offset is 0mm, the line will connect A and B |
| 347 | - if the offset is positive, the line would be on the left-hand side when |
| 348 | traveling from A to B |
| 349 | - if the offset is negative , the line would be on the right-hand side when |
| 350 | traveling from A to B |
| 351 | |
| 352 | Example: |
| 353 | |
| 354 | a: vec @(-1mm, 1mm) |
| 355 | b: vec @(1mm, 1mm) |
| 356 | meas a b 0.2 mm |
| 357 | |
| 358 | |
| 359 | Package name |
| 360 | - - - - - - |
| 361 | |
| 362 | The package name is a non-empty string of printable ASCII characters, |
| 363 | including spaces. If the "package" directive is omitted, fped defaults |
| 364 | to using the name "_". |
| 365 | |
| 366 | package "<name>" |
| 367 | |
| 368 | Examples: |
| 369 | |
| 370 | package "48-SSOP" |
| 371 | package "0603" |
| 372 | |
| 373 | Like in pad names, variables are expanded in package names. This allows |
| 374 | the generation of multiple packages from a single definition. |
| 375 | |
| 376 | |
| 377 | Frames |
| 378 | - - - |
| 379 | |
| 380 | Frames are used to group things and to reuse them multiple times. Frames |
| 381 | must be defined before they can be used: |
| 382 | |
| 383 | frame <name> { |
| 384 | ... items ... |
| 385 | } |
| 386 | |
| 387 | Once defined, a frame is placed at a given location with |
| 388 | |
| 389 | frame <name> <point> |
| 390 | |
| 391 | The frame definitions must precede all other items in a footprint |
| 392 | description. Frames cannot be defined inside other frames, but frames |
| 393 | can invoke each other recursively. |
| 394 | |
| 395 | For example, this puts two unity squares, one centered at (0 mm, 0 mm), |
| 396 | the other at (2 mm, 0 mm): |
| 397 | |
| 398 | frame unit_square { |
| 399 | a: vec @(-0.5mm, -0.5mm) |
| 400 | b: vec .(1mm, 1mm) |
| 401 | rect a b |
| 402 | } |
| 403 | |
| 404 | frame unit_square @ |
| 405 | vec @(2mm, 0mm) |
| 406 | frame unit_square . |
| 407 | |
| 408 | |
| 409 | Names and variables |
| 410 | ------------------- |
| 411 | |
| 412 | fped uses several name spaces: |
| 413 | |
| 414 | - frame names occupy one global name space |
| 415 | |
| 416 | - vector names occupy name spaces delimited by the frame they're |
| 417 | contained in. A vector name is only visible inside the frame in which |
| 418 | it is defined. |
| 419 | |
| 420 | - variable names occupy name spaces delimited by the frame they're |
| 421 | contained in. A variable lookup starts in the frame in which the |
| 422 | corresponding expression appears and propagates to outer frames |
| 423 | until the variable is found. |
| 424 | |
| 425 | - pads occupy one global name space (this is currently not enforced) |
| 426 | |
| 427 | Note that names cannot be redefined. E.g., this does not work: |
| 428 | |
| 429 | set a = 1 |
| 430 | set a = a+1 |
| 431 | |
| 432 | The names spaces of frames, vectors, variables, and pads are separate |
| 433 | from each other. |
| 434 | |
| 435 | |
| 436 | Simple variables |
| 437 | - - - - - - - - |
| 438 | |
| 439 | A variable with a single value is defined with the following |
| 440 | assignment syntax: |
| 441 | |
| 442 | set <identifier> = <expression> |
| 443 | |
| 444 | Example: |
| 445 | |
| 446 | set a = b+2 |
| 447 | |
| 448 | |
| 449 | Loops |
| 450 | - - - |
| 451 | |
| 452 | A loop is a variable with a range of values: |
| 453 | |
| 454 | loop <identifier> = <from>, <to> |
| 455 | |
| 456 | The variable assumes all the values i for <from> <= i <= <to>, in |
| 457 | increments of one. E.g., |
| 458 | |
| 459 | loop n = 1, 3 |
| 460 | |
| 461 | and |
| 462 | |
| 463 | loop n = 1, 3.5 |
| 464 | |
| 465 | both assign the values 1, 2, and 3 to the variable "n". The |
| 466 | following loop would not execute at all: |
| 467 | |
| 468 | loop n = 1, 0 |
| 469 | |
| 470 | This can be used to implement conditional execution. For example, |
| 471 | the items in the following frame would be instantiated if the |
| 472 | variable "enable" is set to 1 but not it is set to 0: |
| 473 | |
| 474 | frame ... { |
| 475 | loop dummy = 1, enable |
| 476 | ... |
| 477 | } |
| 478 | |
| 479 | When a loop is executed, the objects contained in the body of the |
| 480 | enclosing frame are generated for each value of the variable. If |
| 481 | a frame contains multiple loops, all possible combinations of the |
| 482 | values are generated. |
| 483 | |
| 484 | The following example draws three concentric circles around the |
| 485 | origin, with radii 1, 2, and 3: |
| 486 | |
| 487 | loop x = 1, 3 |
| 488 | vec @(x*1mm, 0mm) |
| 489 | circ @ . |
| 490 | |
| 491 | |
| 492 | Tables |
| 493 | - - - |
| 494 | |
| 495 | Tables combine values for multiple variables. Like loops, they are |
| 496 | used to iteratively generate objects. A table begins with a row of |
| 497 | variable names, followed by one or more rows with values. Rows are |
| 498 | enclosed in curly braces and their elements are separated by commas. |
| 499 | |
| 500 | table |
| 501 | { <identifier>, ... } |
| 502 | { <expression>, ... } |
| 503 | ... |
| 504 | |
| 505 | Like loops, tables are iterated to generate objects. The following |
| 506 | example is equivalent to the one in the previous section: |
| 507 | |
| 508 | table |
| 509 | { x } |
| 510 | { 1mm } |
| 511 | { 2mm } |
| 512 | { 3mm } |
| 513 | vec @(x, 0mm) |
| 514 | circ @ . |
| 515 | |
| 516 | Note that we can set the unit of the values directly in this case. |
| 517 | |
| 518 | Iteration is performed over rows. All variables of the table are set |
| 519 | to the value in the respective row at the same time. For example, in |
| 520 | |
| 521 | table |
| 522 | { x, y } |
| 523 | { 1, 2 } |
| 524 | { 3, 4 } |
| 525 | |
| 526 | (x, y) assume the values (1, 2) and (3, 4). |
| 527 | |
| 528 | Tables can also be used to provide information that depends on |
| 529 | other variables. The value of such a variable acts as a key, and a |
| 530 | row is only selected if all the keys in that row match the |
| 531 | respective variables. To mark a variable as being used as key, its |
| 532 | name it prefixed with a question mark. |
| 533 | |
| 534 | Example: |
| 535 | |
| 536 | loop n = 1, 2, 3 |
| 537 | table |
| 538 | { ?n, name } |
| 539 | { 1, "one" } |
| 540 | { 2, "two" } |
| 541 | { 3, "three" } |
| 542 | |
| 543 | |
| 544 | Expressions |
| 545 | ----------- |
| 546 | |
| 547 | Expressions can contain numeric constants (in non-exponential notation), |
| 548 | variable names, the arithmetic operations +, -, *, /, unary -, and the |
| 549 | functions sin(), cos(), sqrt(), and floor(). |
| 550 | |
| 551 | Parentheses can be used to change precedence. |
| 552 | |
| 553 | The argument of sin and cos is a dimensionless number that specifies the |
| 554 | angle in degrees. E.g., sin(90) yields 1. |
| 555 | |
| 556 | The argument of sqrt() can be dimensionless or have a dimension with an |
| 557 | exponent that's a multiple of two. E.g., sqrt(2) and sqrt(2mm*3mm) are |
| 558 | valid expressions, sqrt(2mm) isn't. |
| 559 | |
| 560 | The function floor() returns the next integer that is below or equal to |
| 561 | the argument. If the argument has a dimension, that dimension is |
| 562 | preserved. E.g., floor(-1.2) returns -2, floor(4.7mm) returns 4mm. |
| 563 | |
| 564 | |
| 565 | GUI |
| 566 | --- |
| 567 | |
| 568 | Part of the GUI is described in |
| 569 | http://downloads.qi-hardware.com/people/werner/fped/gui.html |
| 570 | |
| 571 | |
| 572 | Keyboard shortcuts |
| 573 | - - - - - - - - - |
| 574 | |
| 575 | Space reset user coordinates |
| 576 | +, = zoom in (like mouse wheel forward) |
| 577 | - zoom out (like mouse wheel backward) |
| 578 | . cursor position to screen center (like middle click) |
| 579 | * zoom and center to extents |
| 580 | # zoom and center to currently active frame instance |
| 581 | U undelete the previously deleted object |
| 582 | / Switch between variables, code, and packages display. |
| 583 | |
| 584 | |
| 585 | Canvas |
| 586 | - - - |
| 587 | |
| 588 | To create a new object, click on the corresponding tool icon, move the |
| 589 | mouse to the base point of the new object, then drag to the object's |
| 590 | second point. |
| 591 | |
| 592 | Frame references are created as follows: |
| 593 | |
| 594 | - select the frame you want to add |
| 595 | - click on the frame icon. A black dot should appear on the icon. |
| 596 | - select the frame on which you want to add the new reference. |
| 597 | The black dot should change to a green dot. If the current frame |
| 598 | is a child of the selected frame, the dot remains black. |
| 599 | - click on the desired base location |
| 600 | |
| 601 | To change a point of an object, select the object, then drag the point |
| 602 | to its new location. To edit the object's parameters, select it and |
| 603 | make the changes in the input area at the bottom. |
| 604 | |
| 605 | To delete an object, select the delete tool and click on the object. |
| 606 | Deleted objects can be undeleted by pressing "u". If any other changes |
| 607 | have been made since deletion, fped may misbehave. If deleting a vector, |
| 608 | all items that reference it are deleted as well. |
| 609 | |
| 610 | |
| 611 | Experimental: new-style measurements |
| 612 | ------------------------------------ |
| 613 | |
| 614 | New-style measurements can measure the distance between various pairs |
| 615 | of points, not only between points in the same instance and the same |
| 616 | frame. They operate on the set of points produced during instantiation. |
| 617 | |
| 618 | New-style measurements are placed in the root frame after all other |
| 619 | items. |
| 620 | |
| 621 | Known issues: |
| 622 | - they currently can't be edited through the GUI |
| 623 | - tie-breaking heuristics don't always do what one expects |
| 624 | |
| 625 | Syntax: |
| 626 | |
| 627 | <type> [<label>] <from> <op> <to> [<offset>] |
| 628 | |
| 629 | Types: |
| 630 | - meas: measure diagonally |
| 631 | - measx: measure along the X axis |
| 632 | - measy: measure along the y axis |
| 633 | |
| 634 | Note that the type also affects the selection of the points. E.g., |
| 635 | measx will select maximum x values. |
| 636 | |
| 637 | Operators: |
| 638 | - A -> B: smallest value of A and smallest B greater than A |
| 639 | - A <- B: like A -> B, but normal (for offset and text) is inverted |
| 640 | - A >> B: smallest value of A and greatest value of B |
| 641 | - A << B: like A -> B, but normal (for offset and text) is inverted |
| 642 | |
| 643 | Operands are qualified vector names. Vectors in the root frame are |
| 644 | referenced by their name. Vectors in other frames are prefixed with |
| 645 | the name of the frame followed by a dot. |
| 646 | |
| 647 | Example: |
| 648 | |
| 649 | measx pad.sw -> pad.se 1mm |
| 650 | |
| 651 | The optional label is printed directly before the distance. Example: |
| 652 | |
| 653 | a: vec @(0mm, 0mm) |
| 654 | b: vec @(1mm, 0mm) |
| 655 | measx "width = " a >> b 0mm |
| 656 | |
| 657 | would print "width = 1mm" |
| 658 | |
| 659 | |
| 660 | Additional qualifiers |
| 661 | - - - - - - - - - - - |
| 662 | |
| 663 | When using frames as reusable building blocks, similar to functions or |
| 664 | macros in many programming languages, one may need finer control over |
| 665 | the points that are selected for measurements. |
| 666 | |
| 667 | For example, let us consider a frame "square" that draws a square |
| 668 | centered at the frame's origin and with a side length given by the |
| 669 | variable "size". This variable be set in the frame referencing |
| 670 | "square". |
| 671 | |
| 672 | frame square { |
| 673 | a: vec @(-size/2, -size/2) |
| 674 | b: vec @(size/2, size/2) |
| 675 | rect a b |
| 676 | } |
| 677 | |
| 678 | frame small { |
| 679 | set size = 2mm |
| 680 | frame square @ |
| 681 | } |
| 682 | |
| 683 | frame big { |
| 684 | set size = 5mm |
| 685 | frame square @ |
| 686 | } |
| 687 | |
| 688 | frame small @ |
| 689 | vec @(5mm, 0mm) |
| 690 | frame big . |
| 691 | |
| 692 | If we want to measure the size of each square, we could use |
| 693 | |
| 694 | measx square.a -> square.b |
| 695 | |
| 696 | Unfortunately, this only measures the small square. To reach the |
| 697 | big frame, we need to tell fped to use only those points in "square" |
| 698 | that have been placed when "square" was invoked from the big frame. |
| 699 | |
| 700 | This is accomplished by prefixing the points in question with the |
| 701 | name(s) of the frames that need to be visited. The frame names are |
| 702 | separated by slashes (/). |
| 703 | |
| 704 | measx big/square.a -> square.b |
| 705 | |
| 706 | For clarity, it's better to qualify both points, e.g., |
| 707 | |
| 708 | measx big/square.a -> big/square.b |
| 709 | |
| 710 | If multiple frame names are given, they must be in the order in |
| 711 | which they are invoked. |
| 712 | |
| 713 | |
| 714 | Experimental: debugging directives |
| 715 | ---------------------------------- |
| 716 | |
| 717 | For debugging and regression tests, fped supports the following commands, |
| 718 | most of which mimick the effect of GUI operations: |
| 719 | |
| 720 | %del <qualified-identifier> |
| 721 | %move <identifier> [<number>] <identifier> |
| 722 | %frame <identifier> <qualified-base> |
| 723 | %print <expression> |
| 724 | %iprint <expression> |
| 725 | %meas <identifier> |
| 726 | %dump |
| 727 | %exit |
| 728 | %tsort { -<id> | +<id> | <id-before> <id-after> [<number>] ... } |
| 729 | |
| 730 | %del removes the specified item. This can be a vector, an object, or |
| 731 | a frame. If the vector or object is in a different frame than the |
| 732 | current, its name is qualified with the frame name, e.g., "foo.obj". |
| 733 | |
| 734 | For this purpose, also objects can be labeled. Object labels behave like |
| 735 | vector labels and share the same name space. They are not normally |
| 736 | accessible in the GUI. (You can see them in the code view.) |
| 737 | |
| 738 | %move take as its first argument the name of the vector or object to |
| 739 | manipulate. %move sets an anchor point to the vector named as its last |
| 740 | argument. The anchor point is identified by index as follows: |
| 741 | |
| 742 | anchor index vec/frame line/rect/pad arc measurement |
| 743 | -------------- --------- ------------- ------------ ----------- |
| 744 | 0 (or omitted) base first point center low point |
| 745 | 1 - second point end of arc high point |
| 746 | 2 - - start of arc - |
| 747 | |
| 748 | %frame creates a frame reference. Unlike "frame", the destination frame |
| 749 | can be different from the current frame. E.g., "%frame foo bar.a" would |
| 750 | add a reference to frame "foo" in frame "bar", rooted at vector "a". The |
| 751 | parent frame's origin can be references as "@". |
| 752 | |
| 753 | %dump writes the footprint definition in the fped language to standard |
| 754 | output. %exit immediately exits fped, without invoking the GUI. |
| 755 | |
| 756 | %print and %iprint evaluate the expression and print the result to |
| 757 | standard output. The difference between them is that %print runs only |
| 758 | once and without explicit instantiation, while %iprint is treated as |
| 759 | a regular object and is executed as many times as instantiation |
| 760 | demands. |
| 761 | |
| 762 | For example, after loop x = 1, 3 we would obtain just 1 with %print |
| 763 | while %iprint would display, 1, 2, and 3. |
| 764 | |
| 765 | %meas performs an instantiation and prints the value of the labeled |
| 766 | measurement. |
| 767 | |
| 768 | %tsort is used to test-drive the topological sort algorithm. The items |
| 769 | in the curly braces are declarations of nodes with (-<id>) or without |
| 770 | (+<id>) decay or edges in the partial order. The optional number is |
| 771 | the edge's priority. See tsort.c for details, test/tsort for examples. |
| 772 |
Branches:
master
