1 \input texinfo @c -*-texinfo-*-
2 @setfilename geda-scheme.info
4 @settitle gEDA Scheme Reference Manual @value{VERSION}
7 This manual is for gEDA/gaf, version @value{VERSION}.
9 Copyright @copyright{} 2011 Peter TB Brett
11 The text of and illustrations in this document are licensed under a
12 Creative Commons Attribution–Share Alike 3.0 Unported license
13 ("CC-BY-SA"). An explanation of CC-BY-SA is available at
14 http://creativecommons.org/licenses/by-sa/3.0/. The original authors
15 of this document designate the gEDA Project as the "Attribution Party"
16 for purposes of CC-BY-SA. In accordance with CC-BY-SA, if you
17 distribute this document or an adaptation of it, you must provide the
18 URL for the original version.
22 @title gEDA Scheme Reference Manual
23 @author Peter TB Brett
26 @vskip 0pt plus 1filll
35 @top gEDA Scheme Reference Manual
42 * Schematic Document Model::
43 * Core API Reference::
44 * gschem API Reference::
51 @unnumbered Introduction
55 @dfn{gEDA}, or @emph{GPL Electronic Design Automation}, is a suite of
56 free software tools for designing electronics. The gEDA project has
57 produced and continues working on a full GPL'd suite and toolkit of
58 Electronic Design Automation (EDA) tools. These tools are used for
59 electrical circuit design, schematic capture, simulation, prototyping,
60 and production. Currently, the gEDA project offers a mature suite of
61 free software applications for electronics design, including schematic
62 capture, attribute management, bill of materials (BOM) generation,
63 netlisting into over 20 netlist formats, analog and digital
64 simulation, and printed circuit board (PCB) layout.
66 The gEDA project was started because of the lack of free EDA tools for
67 POSIX systems with the primary purpose of advancing the state of free
68 hardware or open source hardware. The suite is mainly being developed
69 on the GNU/Linux platform with some development effort going into
70 making sure the tools run on other platforms as well.
72 @section About the gEDA Scheme API
74 The @dfn{gEDA Scheme API}, documented in this manual, is a set of
75 Scheme functions which can be used to enhance gEDA applications by
76 adding new functionality or modify existing behaviour.
78 gEDA has always used a Scheme interpreter for interpreting
79 configuration files, managing keybindings in gschem, and implementing
80 netlist exporter backends in gnetlist. However, for a long time the
81 utility of embedding a Scheme interpreter was diminished by the lack
82 of a low-level API for inspecting and modifying schematic documents.
83 The Scheme types and functions documented here were added to gEDA to
86 gEDA uses the @emph{Guile} Scheme implementation (otherwise known as
87 the @emph{GNU Ubiquitous Intelligent Language for Extensions}) as its
88 embedded Scheme. For more information about Guile, please visit
89 @uref{http://www.gnu.org/s/guile/}.
91 @section Getting Additional Help
92 @cindex Reporting bugs
94 If you think you have found a bug, please file a bug report in
95 Launchpad: @uref{http://bugs.launchpad.net/geda}. Please add the tag
96 @samp{scheme-api}. It will help us to fix your bug quickly if you can
97 describe in detail how to reproduce the bug.
99 If you have a question about using gEDA, or about extending gEDA using
100 Scheme, you may wish to send a message to one of the gEDA mailing
101 lists. You may also find additional information in the gEDA
104 Both the mailing lists and wiki can be accessed from the main gEDA
105 website: @uref{http://gpleda.org/}.
107 @section We Need Feedback!
109 If you find a typographical error in this manual, or if you have
110 thought of a way to make this manual better, we would love to hear
111 from you! Please submit a report in Launchpad:
112 @uref{http://bugs.launchpad.net/geda}, with the tag @samp{scheme-api}.
114 @node Schematic Document Model
115 @chapter The Schematic Document Model
117 When using gEDA to design an electronic circuit, users use the
118 schematic editor, gschem, to choose and place @emph{schematic symbols}
119 on a @emph{schematic page}, and connect the @emph{pins} of the symbols
120 together by drawing @emph{nets}. The user may add various
121 @emph{attributes} to symbols, nets or pins to modify how the circuit
122 diagrams should be interpreted. The resulting schematics are then
123 processed with the gnetlist tool to generate a @emph{netlist}.
125 This chapter describes the different data types used by the Scheme API
126 to represent gEDA documents (both schematics and symbols), and how
127 they relate to each other.
132 * Component objects::
134 * Coordinate system::
143 Schematics and symbols are presented as different types of document to
144 the user, with different file extensions, icons and mime-types.
145 However, when they are loaded into a gEDA application such as gschem
146 for editing, they are internally represented in exactly the same way,
147 by the @code{page} type. The @code{page} is the top-level gEDA document
150 Internally, the main difference between a @code{page} for a schematic
151 and a @code{page} for a symbol is the types of schematic element they
152 are permitted to contain (@pxref{Objects}). For example, a symbol is
153 not permitted to contain nets, buses, or instances of other symbols,
154 and a schematic is not permitted to contain pins.
156 @strong{Note}: Although the restrictions on what types of primitive
157 element schematics and symbols may contain are not enforced by the
158 API, designs which violate these restrictions may cause the netlister
159 not to work as expected.
161 Each @code{page} is associated with a filename, although the filename is
162 not required by the API either to be valid or to be associated with a
163 accessible file in the filesystem.
165 Pages are not garbage-collected; once you create a @code{page}, you are
166 responsible for making sure that it is disposed of when it is no
172 @cindex Schematic elements
174 Each @code{page} contains some number of @dfn{schematic elements},
175 represented by the @code{object} type. There are several sub-types of
176 @code{object}, including:
180 graphical lines, circles, arcs, rectangles and paths;
195 and symbol instances, known as 'components'.
198 Each @code{object} can be part of at most a single @code{page} -- they
199 cannot be shared between pages. @code{object}s are automatically
202 Most of different @code{object} sub-types are quite straightforward to
203 understand. The main exceptions are components, and the text
204 @code{object}-based attribute mechanism, which are described in the
207 @node Component objects
208 @section Component objects
210 @cindex Component library
211 @cindex Embedded component
213 When a symbol is instantiated in a schematic (e.g. by the user
214 selecting it from the gschem component library and placing it on the
215 page), a compound @code{object} known as a @dfn{component} is created.
217 Like a @code{page}, a component contains some number of @code{object}
218 elements. When a component is created from a symbol, the contents of
219 the symbol's @code{page} are copied into the component.
221 In order to allow the component to appear in the correct place on the
222 schematic page, at the correct orientation, etc., a transformation is
223 applied to every @code{object} in the component.
225 Normally, when the schematic @code{page} is closed, the parameters of
226 the transformation are stored in the schematic file along with the
227 basename of the original symbol, but the @code{object} contents of the
228 component are discarded. When the schematic is subsequently
229 re-opened, the original symbol is retrieved from the component
230 library, and used to recreate the component.
232 However, a component may optionally be @emph{embedded}. In this case,
233 its contents @emph{are} stored in the schematic file.
235 @strong{Note}: A component cannot contain another component -- only
236 other types of @code{object}.
241 @cindex Attribute format
243 A gEDA user is able to annotate schematic elements with additional
244 data, such as footprints for components or net names for nets. This
245 is carried out using @dfn{attributes}.
247 An attribute is text @code{object} which contains a text string in the
248 form @samp{@var{name}=@var{value}}. Currently, the restrictions on
249 attribute format that are enforced by the API are:
253 Attribute @var{name}s:
257 must contain at least one character;
259 must not contain a @samp{=} character (Unicode @code{U+003D});
261 must not end with a space (@samp{ }, Unicode @code{U+0020}).
265 Attribute @var{value}s:
269 must contain at least one character;
271 must not begin with a space (@samp{ }, Unicode @code{U+0020}).
275 @strong{Note}: Due to assumptions made by some gEDA tools, it is
276 @emph{strongly recommended} that you use attribute @var{NAME}s which
277 contain only lower-case Latin characters, decimal digits, full stops
278 @samp{.} (@code{U+002E}), and hyphens @samp{-} (@code{U+002D}).
280 There are two types of attribute:
282 @cindex Attached attribute
283 @emph{Attached attributes} are attribute text @code{object}s that are
284 linked to another @code{object}. To attach an attribute to another
285 schematic element, both @code{object}s must be part of the same
286 component or part of the same @code{object}. For example, a
287 @samp{netname=@var{NAME}} attribute attached to a net @code{object}
288 can be used to give that net a specific name in netlist output, such
289 as @samp{VCC} or @samp{GND}.
291 @cindex Floating attribute
292 @emph{Floating attributes} are attribute text @code{object}s that are
293 not linked to another @code{object}. These attributes affect the
294 schematic or symbol that they're part of as a whole. For example, a
295 floating @samp{documentation=@var{url}} attribute in a symbol tells
296 gschem's @strong{Help → Component Documentation} command how to find
297 the component's data sheet.
299 @node Coordinate system
300 @section Coordinate system
302 gEDA documents use a @dfn{coordinate system} (internally referred to
303 as `world' coordinates) with coordinates increasing upwards and to the
304 right (i.e. a conventional right-handed Cartesian coordinate
307 Although all coordinates may be positive or negative, gschem only
308 displays objects with positive coordinates (i.e. in the upper right
309 quadrant of the coordinate system). It is therefore recommended to
310 use only positive coordinates.
312 In the Scheme API, the coordinate of a point is expressed in the format:
318 and a set of @dfn{bounds} (i.e. a rectangular area in the document
319 plane) is expressed in the format:
322 ((left . top) . (right . bottom))
325 where @code{left} is the smaller x coordinate, @code{right} is the
326 larger x coordinate, and @code{bottom} and @code{top} are respectively
327 the smaller and larger y coordinates.
329 @node Core API Reference
330 @chapter Core API Reference
332 The Scheme modules and functions described in this chapter are
333 primitive operations for working with schematics and symbols, and are
334 available to be used in all gEDA applications.
337 * Core page functions::
338 * Core object functions::
339 * Core attribute functions::
342 @node Core page functions
343 @section Core page functions
345 To use the functions described in this section, you will need to load
346 the @code{(geda page)} module.
351 Returns @samp{#t} if and only if @var{obj} is a @code{page}.
355 Returns a list of all open @code{page}s.
358 @subsection Page creation, disposal and filenames
360 Every @code{page} is associated with a @emph{filename}. The filename
361 does not necessarily have to be a file which exists and/or is
362 accessible in the filesystem.
364 @defun make-page filename
365 Creates and returns a new, empty @code{page}, with the given
366 string @var{filename}.
369 @defun close-page! page
370 Destroys @var{page}. The returned value is undefined.
372 @strong{Warning}: This function closes and destroys @var{page}
373 immediately, regardless of whether the page has been modified since
374 loading or saving, and without asking the user.
377 @defun page-filename page
378 Returns the filename associated with @var{page} as a string.
381 @defun set-page-filename! page filename
382 Sets the filename of @var{page} to @var{filename}. Returns
386 @subsection Page contents
388 A schematic or symbol @code{page} is composed of a set of
389 @code{object}s which determine both its graphical appearance and its
392 @defun page-contents page
393 Returns a list of the @code{object}s which make up @var{page}. The
394 list can be freely modified without changing the contents of
398 @defun page-append! page objects...
399 Appends zero or more @var{objects} to the contents of @var{page} in
400 the order given. Returns @var{page}.
402 If any of the @var{objects} is already part of a @code{page} other
403 than @var{page}, or is part of a component @code{object}, raises an
404 @code{object-state} error. Any of the @var{objects} that are already
405 in the @var{page} are ignored.
408 @defun page-remove! page objects...
409 Removes zero or more @var{objects} from the contents of @var{page}.
412 Any @var{objects} that are not part of a @code{page} or component
413 @code{object} are ignored.
415 An @samp{object-state} error will be thrown if any of the
416 @var{objects} satisfies any of the following conditions:
420 part of a @code{page} other than @var{page};
422 part of component @code{object};
424 has attached attributes (@pxref{Attributes});
426 is attached as an attribute.
430 @defun object-page object
431 Returns the @code{page} which contains @var{object} (either directly
432 or indirectly), or @samp{#f} if @var{object} is not part of a
435 @strong{Note}: If the @var{object} argument to @code{object-page} is
436 part of a component @code{object} which is itself part of a
437 @code{page}, that @code{page} will be returned.
440 @subsection Page dirty flags
442 A @code{page} has a @emph{dirty flag} that is used to indicate to
443 applications that the @code{page} has been modified since it was last
446 @defun page-dirty? page
447 Returns @samp{#t} if the @var{page}'s page has been marked as dirty;
448 otherwise, returns @samp{#f}.
451 @defun set-page-dirty! page [state]
452 Sets the dirty flag for @var{page}. If @var{state} is @samp{#f},
453 clears the dirty flag; otherwise, or if @var{state} is omitted, marks
454 the page as dirty. Returns @var{page}.
457 @node Core object functions
458 @section Core object functions
460 To use the functions described in this section, you will need to load
461 the @code{(geda object)} module.
464 * General object functions::
477 @node General object functions
478 @subsection General object functions
481 Returns @samp{#t} if and only if @var{obj} is an @code{object}.
484 @defun copy-object object
485 Returns a deep copy of @var{object}. The new @code{object} returned
486 has no attached attributes, and is not part of a @code{page} or part
487 of a component @code{object}.
490 @defun object-component object
491 Returns the component @code{object} that contains @var{object}, or
492 @samp{#f} if @var{object} is not part of a component.
495 @defun object-connections object
496 Returns a list of other @code{object}s that are @emph{directly}
497 connected to @var{object}. If @code{object} is not included in a
498 @code{page}, raises an @samp{object-state} error. The connections
499 reported are independent of inclusion in components.
501 For example, consider a page containing a net and a component, and the
502 component contains a single pin. If the connectable end of the pin
503 intersects the net, then @code{(object-connections <net>)} will return
504 a list containing the pin @code{object}, and @emph{not} the component.
511 * Object fill and stroke::
514 @node Object sub-types
515 @subsubsection Object sub-types
517 Schematic element @code{object}s come in several subtypes.
519 @defun object-type object
520 Returns the sub-type of @var{object} as a symbol. The subtype will be
521 one of the following symbols:
533 @samp{complex} (indicates a component @code{object})
549 @defun object-type? object type
550 Returns @samp{#t} if and only if @var{object} is an @code{object} and
551 that its subtype is @var{type}, which should be a symbol.
555 @subsubsection Object bounds
557 The bounds of an object is the smallest bounding rectangle of the
558 object, expressed in document coordinates (@pxref{Coordinate system}).
560 @defun object-bounds objects...
561 Returns the world coordinate bounding box containing all of the
562 @var{objects} passed as arguments, or @samp{#f} if none of the
563 @var{objects} have bounds (for example, this can occur if no
564 @var{objects} are specified, or if they are all empty component
567 @strong{Note}: @code{object-bounds} always returns the actual bounds
568 of the @var{objects}, not the visible bounds. This means that the bounds of
569 invisible text is always included.
572 @defun fold-bounds bounds...
573 Calculates the union of several sets of @var{bounds} (as returned by
574 @code{object-bounds}). If any of the @var{bounds} are @samp{#f}, they
575 are skipped; if all of the @var{bounds} are @samp{#f}, @samp{#f} is
580 @subsubsection Object color
582 Object colors in gEDA documents are specified as indices into a color
583 map. This allows users to specify the color map that suits them when
584 viewing schematics and symbols.
586 @defun object-color object
587 Returns the integer color map index of the the color used to draw
591 @defun set-object-color! object color
592 Sets the integer color map index for @var{object} to @var{color}.
593 Returns @var{object}.
596 @node Object fill and stroke
597 @subsubsection Object fill and stroke
599 Graphical object subtypes -- lines, boxes, circles, arcs and paths --
600 are drawn with a stroke pattern that can be configured in detail.
602 @defun object-stroke object
603 Returns the stroke settings of the @var{object}, which must be a line,
604 box, circle, arc or path @code{object}. The return value is a list of
609 stroke width, as an integer number of world units
611 cap style, one of the symbols @code{none}, @code{square} or
614 dash style, one of the symbols @code{solid}, @code{dotted},
615 @code{dashed}, @code{center} or @code{phantom}.
617 up to two dash parameters, depending on the dash style:
620 for solid lines, no parameters;
622 for dotted lines, dot spacing;
624 for other styles, dot/dash spacing and dash length.
629 @defun set-object-stroke! object width cap dash [dash-space [dash-length]]
630 Set the stroke settings of the @var{object}, which must be a line,
631 box, circle, arc or path @code{object}. The arguments are the same as
632 the contents of the list returned by @code{object-stroke}. Returns
636 @defun object-stroke-width object
637 Returns the integer stroke width of @var{object}, which must be a
638 line, box, circle, arc or path @code{object}.
641 @defun object-stroke-cap object
642 Returns the stroke cap style of @var{object}, which must be a line,
643 box, circle, arc or path @code{object}. The returned value is one of
644 the symbols @code{none}, @code{square} or @code{round}.
647 @defun object-stroke-dash object
648 Returns the dash style of @var{object}, which must be a line, box,
649 circle, arc or path @code{object}. The return value is a list of
650 between one and three parameters:
654 dash style, one of the symbols @code{solid}, @code{dotted},
655 @code{dashed}, @code{center} or @code{phantom}.
657 for styles other than @code{solid}, dot/dash spacing;
659 for @code{dashed}, @code{center} and @code{phantom}, dash length.
663 Some types of @code{object} -- boxes, circles and paths -- can have
664 their interiors filled with a variety of patterns.
666 @defun object-fill object
667 Returns the fill settings of @var{object}, which must be a box, circle
668 or path @code{object}. The return value is a list of one to six
673 fill style, one of the symbols @code{hollow}, @code{solid},
674 @code{mesh} or @code{hatch};
676 up to five fill parameters, depending on fill style:
679 none for @code{hollow} or @code{solid} fills;
681 line width, line angle (in degrees) and line spacing for @code{hatch} fills;
683 line width, first angle and spacing, and second angle and spacing for
689 @defun set-object-fill! object fill-type . fill-args
690 Sets the fill settings of @var{object}, which must be a box, circle or
691 path @code{object}. The arguments are the same as the contents of the
692 list returned by @code{object-fill}. Returns @var{object}.
697 Line @code{object}s are straight graphical line segments with no
698 electrical meaning. A line's geometrical parameters are a start point
699 and end point, and it supports different colors and stroke styles.
701 Many of the functions for manipulating lines are also used to
702 manipulate line-like objects such as nets, buses or pins.
705 Returns @samp{#t} if and only if @var{object} is a line @code{object}.
708 @defun make-line start end [color]
709 Creates and returns a new line @code{object}. @var{start} is the
710 position of the start of the new line in the form @code{(x . y)} and
711 @var{end} is the position of end of the line. If @var{color} is
712 specified, it should be the integer color map index of the color with
713 which to draw the line. If @var{color} is not specified, the default
717 @defun set-line! line start end [color]
718 Sets the parameters of @var{line} (which may be a line, net, bus or
719 pin @code{object}). The arguments are the same as to
720 @code{make-line}. Returns @var{line}.
723 @defun line-info line
724 Returns the parameters of @var{line} (which may be a line, net, bus or
725 pin @code{object}). The return value is a list in the form:
728 ((start-x . start-y) (end-x . end-y) color)
731 @strong{Note}: For pin @code{object}s, first coordinate is the
732 connectable point on the pin.
735 @defun line-start line
736 Returns the position @samp{(x . y)} of the start of @var{line} (which
737 may be a line, net, bus or pin @code{object}). For pin
738 @code{objects}, this is the position of the connectable point on the
743 Returns the position @samp{(x . y)} of the end of @var{line} (which
744 may be a line, net, bus or pin @code{object}).
748 @subsection Nets and buses
750 Net and bus @code{object}s are straight line segments which represent
751 electrical connectivity. Nets represent single wires, and buses
752 multi-wire connections of arbitrary composition.
754 All of the functions that work on line @code{object}s also work with
755 nets and buses (@pxref{Lines}). Note that @code{line?} will return
756 @code{#f} if called with a net or bus argument.
759 Returns @samp{#t} if and only if @var{object} is a net.
762 @defun make-net start end [color]
763 Creates and returns a new net @code{object}. @var{start} is the
764 position of the start of the new net in the form @code{(x . y)} and
765 @var{end} is the position of end of the net. If @var{color} is
766 specified, it should be the integer color map index of the color with
767 which to draw the net. If @var{color} is not specified, the default
772 Returns @samp{#t} if and only if @var{object} is a bus.
775 @defun make-bus start end [color]
776 Creates and returns a new bus @code{object}. Arguments are as for
783 Pin @code{objects} are straight line segments which represent
784 connectable points in symbols or subcircuits, such as the pins of a
785 semiconductor package. Only one end of a pin can be connected to
786 nets, buses or other pins; the rest of a pin is purely graphical.
788 Pins come in two varieties: @dfn{net pins} and @dfn{bus pins}, which
789 are used for connections to nets and buses respectively (@pxref{Nets
792 All of the functions that work on line @code{object}s also work with
793 pins (@pxref{Lines}). Note that @code{line?} will return @code{#f} if
794 called with a pin argument.
797 Returns @samp{#t} if and only if @var{object} is a pin @code{object}.
800 @defun net-pin? object
801 Returns @samp{#t} if and only if @var{object} is a net pin.
804 @defun make-net-pin start end [color]
805 Creates and returns a new net pin @code{object}. @var{start} is the
806 position of the start of the new pin (the connectable end) in the form
807 @code{(x . y)} and @var{end} is the position of end of the pin. If
808 @var{color} is specified, it should be the integer color map index of
809 the color with which to draw the pin. If @var{color} is not
810 specified, the default pin color is used.
813 @defun bus-pin? object
814 Returns @samp{#t} if and only if @var{object} is a bus pin.
817 @defun make-bus-pin start end [color]
818 Creates and returns a new bus pin @code{object}. Arguments are as for
825 Boxes are rectangles specified by the coordinates of their top left
826 and bottom right corners. They are purely graphical, and have no
827 electrical meaning. They can be drawn in different colors, and with
828 various stroke and fill settings.
831 @xref{Object fill and stroke}.
834 Returns @samp{#t} if and only of @var{object} is a box @code{object}.
837 @defun make-box top-left bottom-right [color]
838 Creates and returns a new box @code{object}. @var{top-left} is the
839 position of the top left of the new box in the form @code{(x . y)},
840 and @var{bottom-right} is the position of the bottom right of the box.
841 If @var{color} is specified, it should be the integer color map index
842 of the color with which to draw the box. If @var{color} is not
843 specified, the default box color is used.
846 @defun set-box! box top-left bottom-right [color]
847 Sets the parameters of @var{box}. The arguments are the same as to
848 @code{make-box}. Returns @var{box}.
852 Returns the parameters of @var{box}. The return value is a list in the form:
855 ((top-left-x . top-left-y) (bottom-right-x . bottom-right-y) color)
859 @defun box-top-left box
860 Returns the position of the top left corner of @var{box} in the form
864 @defun box-bottom-right box
865 Returns the position of the bottom right corner of @var{box} in the
872 Circle @code{objects} are specified by center position and radius, and
873 are purely graphical with no electrical meaning. They can be drawn in
874 different colors, and with various stroke and fill settings.
877 @xref{Object fill and stroke}.
879 @defun circle? object
880 Returns @samp{#t} if and only of @var{object} is a circle @code{object}.
883 @defun make-circle center radius [color]
884 Creates and returns a new circle @code{object}. @var{center} is the
885 position of the center of the new circle in the form @code{(x . y)},
886 and @var{radius} is the integer radius of the circle. If @var{color}
887 is specified, it should be the integer color map index of the color
888 with which to draw the circle. If @var{color} is not specified, the
889 default circle color is used.
892 @defun set-circle! circle center radius [color]
893 Sets the parameters of @var{circle}. The arguments are the same as to
894 @code{make-circle}. Returns @var{circle}.
897 @defun circle-info circle
898 Returns the parameters of @var{circle} as a list of the form:
901 ((center-x . center-y) radius color)
905 @defun circle-center circle
906 Returns the position of the center of @var{circle} as in the form
910 @defun circle-radius circle
911 Returns the radius of @var{circle} as an integer.
916 Arc @code{objects} are specified by center position, radius, and start
917 and end angles. They are purely graphical with no electrical
918 meaning. They can be drawn in different colors, and with various
922 Returns @samp{#t} if and only if @var{object} is an arc @code{object}.
925 @defun make-arc center radius start-angle end-angle [color]
926 Creates and returns a new arc @code{object}. @var{center} is the
927 position of the center of the new arc in the form @code{(x . y)}, and
928 @var{radius} is the integer radius of the arc. @var{start-angle} and
929 @var{end-angle} are the angles at which to start and end the arc, in
930 degrees. If @var{color} is specified, it should be the integer color
931 map index of the color with which to draw the arc. If @var{color}
932 is not specified, the default arc color is used.
935 @defun set-arc! arc center radius start-angle end-angle [color]
936 Sets the parameters of @var{arc}. The arguments are the same as to
937 @code{make-arc}. Returns @var{arc}.
941 Returns the parameters of @var{arc} as a list of the form:
944 ((center-x . center-y) radius start-angle end-angle color)
948 @defun arc-center arc
949 Returns the position of the center of @var{arc} in the form
953 @defun arc-radius arc
954 Returns the radius of @var{arc} as an integer.
957 @defun arc-start-angle arc
958 Returns the start angle of @var{arc} as an integer number of degrees.
961 @defun arc-end-angle arc
962 Returns the end angle of @var{arc} as an integer number of degrees.
969 Returns @samp{#t} if and only if @var{object} is a path @code{object}.
975 @defun picture? object
976 Returns @samp{#t} if and only if @var{object} is a picture @code{object}.
982 Text fulfils two roles, as straightforward labels and notes on
983 schematics and symbols, and as attached or floating attributes
984 (@pxref{Attributes}). A text @code{object} can be aligned in
985 different ways relative to its anchor position, and can be displayed
986 in different font sizes.
988 Any text can be set to be visible or invisible on printed output (and
989 gschem provides ways to preview invisible text). When a text
990 @code{object} is an attribute (i.e. its string is in a
991 @samp{@var{name}=@var{value}} format) then the visibility settings are
992 more fine-grained: the text can be set to display just the attribute
993 name, just the attribute value, or both.
998 Returns @samp{#t} if and only if @var{object} is a text @code{object}.
1001 @defun make-text anchor align angle string size visible show [color]
1002 Creates and returns a new text @code{object}. @var{anchor} is the
1003 position of the anchor of the new text in the form @code{(x . y)}, and
1004 @var{align} is a symbol determining how the text should be aligned
1005 relative to the anchor. @var{align} must be one of the following
1018 @samp{middle-center}
1029 For example, if @var{align} is @samp{upper-center}, the anchor will be
1030 located at the top center of the rendered text block.
1032 @var{angle} should be an integer multiple of 90 degrees, determining
1033 the angle which the text should be displayed at. @var{string} is the
1034 string contents for the @code{text} object, and must not contain any
1035 null characters (@samp{#\0} in Scheme, Unicode
1036 @samp{U+0000}. @var{size} is the font size to use. If @var{visible}
1037 is @samp{#f}, the text will be invisible; otherwise, it will be
1040 When the @var{string} is in an attribute format (@pxref{Attributes}),
1041 the @var{show} argument determines which parts of the @var{string}
1042 will be displayed. It must be one of the following symbols:
1053 If @var{color} is specified, it should be the integer color map index
1054 of the color with which to draw the text. If @var{color} is not
1055 specified, the default arc color is used.
1058 @defun set-text! text anchor align angle string size visible show [color]
1059 Sets the parameters of @var{text}. The arguments are the same as to
1060 @code{make-text}. Returns @var{text}.
1063 @defun text-info text
1064 Returns the parameters of @var{text} as a list in the form:
1067 ((anchor-x . anchor-y) align angle string size visible show color)
1070 See @code{make-text} for a description of all of these parameters.
1073 @defun text-center text
1074 Returns the position of the anchor of @var{text} in the form
1078 @defun text-align text
1079 Returns the alignment of @var{text} as one of the following symbols:
1091 @samp{middle-center}
1103 @defun text-angle text
1104 Returns the angle that @var{text} is displayed at as an integer
1105 multiple of 90 degrees.
1108 @defun text-string text
1109 Returns the string content of @var{text}.
1112 @defun set-text-string! text str
1113 Set the string content of @var{text} to @var{str}. @var{str} must not
1114 contain any null characters (@samp{#\0} in Scheme, Unicode
1118 @defun text-size text
1119 Return the font size of @var{text} as an integer.
1122 @defun text-visible? text
1123 Returns @samp{#t} if and only if @var{text} is set to be visible.
1126 @defun set-text-visibility! text visible?
1127 If @var{visible?} is @samp{#f}, sets @var{text} to be invisible;
1128 otherwise, sets it to be visible.
1131 @defun text-attribute-mode text
1132 Returns a symbol indicating which parts of @var{text} will be
1133 displayed when @var{text} is a valid attribute. The returned value
1134 will be one of the following symbols:
1147 @subsection Components
1149 Component @code{object}s represent instances of symbols. They contain
1150 other @code{object}s copied from the original symbol when it is
1151 instantiated into a schematic.
1153 A component's @var{basename} is a string used to identify which symbol
1154 it originated from. When instantiating a symbol on initial placement
1155 in a schematic, or when recreating a component while loading a
1156 schematic, the @var{basename} is used to find the underlying symbol
1157 file in the component library.
1159 @xref{Component objects}.
1161 @strong{Note}: In the gEDA C source code, these are normally called
1162 ``complex'' objects. However, as Guile Scheme supports complex
1163 numbers, and the procedures related to working with complex numbers
1164 use the word @samp{complex} to describe them, this API uses
1165 @samp{component} to avoid ambiguity.
1167 The @var{position}, @var{angle} and @var{mirror} flag of a component
1168 indicates the transformation that was applied to the contents of the
1169 original symbol. The transformation is applied in the following order:
1173 If @var{mirror} is true, the symbol is reflected in the line x = 0.
1175 The symbol is rotated anti-clockwise by @var{angle} degrees about the
1176 point (0,0) (@var{angle} may only be an integer multiple of 90
1179 Finally, the symbol is translated by @var{position}.
1182 The component's contents (as returned by @code{component-contents})
1183 have the transformation already applied to them. Updating the
1184 translation information using e.g. @code{set-component!} will not
1185 alter them -- that must be done separately (e.g. by reloading the
1188 @defun component? object
1189 Returns @samp{#t} if and only if @var{object} is a component @code{object}.
1192 @defun make-component basename position angle mirror locked
1193 Creates and returns a new, empty component @code{object} with the
1194 given @var{basename}. @var{position}, @var{angle} and @var{mirror}
1195 specify the symbol transformation. If @var{locked} is true, the
1196 component will be protected against accidental selection by the user
1197 (this is used in gschem e.g. for titleblocks).
1199 No attempt is made to load a symbol matching @var{basename} from
1200 component libraries, and the returned component is flagged as
1204 @defun make-component/library basename position angle mirror locked
1205 Searches the component libraries for a symbol matching @var{basename},
1206 and if found, instantiates the symbol and returns the resulting
1207 component (which is not flagged as embedded). Arguments are as for
1208 @code{make-component}.
1210 If no match for @var{basename} is found, @samp{#f} is returned.
1213 @defun set-component! component position angle mirror locked
1214 Sets the parameters of @var{component}. Arguments are the same as to
1215 @code{make-component}. Returns @var{component}.
1217 @strong{Note}: Remember that modifying the transformation parameters
1218 of a component does not update the component's contents.
1221 @defun component-info component
1222 Returns the parameters of @var{component} as a list of the form:
1225 (basename (x . y) angle mirror locked)
1229 @defun component-basename component
1230 Returns the basename of @var{component}.
1233 @defun component-position component
1234 Returns the position to which the original symbol was translated when
1235 creating @var{component}.
1238 @defun component-angle component
1239 Returns the angle by which the original symbol was rotated when
1240 creating @var{component}, as an integer number of degrees.
1243 @defun component-mirror? component
1244 Returns true if the original symbol was mirrored when creating
1248 @defun component-locked? component
1249 Returns true if @var{component} is non-selectable.
1252 @defun component-contents component
1253 Returns the contents of @var{components} as a list of objects.
1256 @defun component-append! component objects...
1257 Appends @var{objects} (which must not be component @code{object}s) to
1258 the contents of @var{component}. Any @var{objects} which are already
1259 included in @var{component} are ignored. If any @var{objects} are
1260 already part of a @code{page} or of another component @code{object},
1261 an @samp{object-state} error is raised. Returns @var{component}.
1264 @defun component-remove! component objects...
1265 Removes @var{objects} from the contents of @var{component}. Any
1266 @var{objects} which are not part of a component or of a page are
1267 ignored. Returns @var{component}.
1269 An @samp{object-state} error will be raised if any @var{objects}
1270 satisfy any of the following conditions:
1274 are part of a @code{page};
1276 are part of a component @code{object} other than @var{component};
1278 have attached attributes
1280 are attached as an attribute.
1284 @node Core attribute functions
1285 @section Core attribute functions
1287 To use the functions described in this section, you will need to load
1288 the @code{(geda attrib)} module.
1290 Attributes are text @code{object}s with a particular format of string.
1291 They can be floating, or they can be attached to another
1294 @defun attribute? object
1295 Returns true if and only if @var{object} is an attribute (i.e. a text
1296 @code{object} and in attribute format).
1299 @subsection Attribute names and values
1301 @defun parse-attrib text
1302 Splits the string from @var{text} (a text @code{object}) into name and
1303 value, if it is in attribute format. If it is not in attribute
1304 format, raises an @samp{attribute-format} error. The return value is
1305 in the form @samp{(@var{name} . @var{value})}.
1308 @defun attrib-name attrib
1309 Returns the name part of @var{attrib}, as a string.
1312 @defun attrib-value attrib
1313 Returns the value part of @var{attrib}, as a string.
1316 @defun set-attrib-value! attrib value
1317 Sets the value part of @var{attrib} to @var{value}.
1320 @subsection Attribute attachment
1322 @defun attrib-attachment attrib
1323 If @var{attrib} is attached to another @code{object}, returns that
1324 object. Otherwise, returns @samp{#f}.
1327 @defun object-attribs object
1328 Returns a list of all attributes attached to @var{object}.
1331 @defun attach-attribs! object [attribs...]
1332 Attach @var{attribs} to @var{object}. All the @var{attribs} must be
1333 text @code{object}s. The following conditions must be satisfied, or
1334 an @samp{object-state} error will be raised:
1338 Neither @var{object} nor any of the @var{attribs} may be already
1339 attached as an attribute;
1341 Both @var{object} and all @var{attribs} must be part of the same
1342 @code{page} and/or component @code{object};
1345 Any @var{attribs} that are already attached to @var{object} are
1346 ignored. Returns @var{object}.
1348 @strong{Note}: For historical reasons, @code{attach-attribs!} does not
1349 require that all @var{attribs} satisfy @code{attribute?}.
1350 Nevertheless, avoid attaching non-attribute text objects as attributes.
1353 @defun detach-attribs! object [attribs...]
1354 Detach @var{attribs} from @var{object}. Any @var{attribs} that are
1355 not attached as attributes are ignored. If any @var{attribs} are
1356 attached to @code{object}s other than @var{object}, an
1357 @samp{object-state} error is raised.
1360 @subsection Inherited and promoted attributes
1362 @dfn{Inherited attributes} are unattached attributes inside a
1363 component @code{object}.
1365 @defun inherited-attribs object
1366 Returns the inherited attributes of @var{object}, if @var{object} is a
1367 component. If @var{object} is not a component, returns the empty
1371 @defun attrib-inherited? attrib
1372 Returns @samp{#t} if @var{attrib} is an inherited attribute.
1375 @dfn{promotable attributes} are inherited attributes that are both
1376 visible and have names that are in the list of promotable attributes
1377 set with the @code{always-promote-attributes} rc file parameter.
1379 @defun promotable-attribs component
1380 Returns a list of promotable attributes of @var{component}.
1383 @defun promote-attribs! component
1384 Promote all promotable attributes from @var{component} into the
1385 @code{page} that contains @var{component}. If @var{component} is not
1386 in a page, an @samp{object-state} error is raised.
1388 All promotable attributes are copied, and made invisible. The copies
1389 are added to the @code{page}, and attached as attributes of @var{component}.
1391 The promoted attributes are returned. If @var{component} is not in
1392 fact a component @code{object}, does nothing and returns the empty list.
1395 @node gschem API Reference
1396 @chapter gschem API Reference
1398 The Scheme modules and functions described in this chapter are
1399 available in the gschem schematic editor application. They are more
1400 focused on enabling and responding to user editing operations.
1403 * Windows and views::
1406 * Miscellanous gschem functions::
1409 @node Windows and views
1410 @section Windows and views
1412 To use the functions described in this section, you will need to load
1413 the @code{(gschem window)} module.
1416 Returns the @code{page} currently being displayed for editing.
1419 @defun set-active-page! page
1420 Sets the current @code{page} to @var{page}.
1423 @defun pointer-position
1424 Returns the current mouse pointer position in world coordinates in the
1425 form @samp{(x . y)}. If the pointer is outside the display area,
1435 @node Miscellanous gschem functions
1436 @section Miscellaneous gschem functions
1439 @unnumbered Concept Index
1443 @node Function Index
1444 @unnumbered Function Index