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=
"overview">Overview
</h1>
17 As stated in
<a href=
"libgeda3.html" class=
"wikilink1" title=
"libgeda3.html">libgeda3
</a>, libgeda has some design problems that needs to be addressed. The structure described in this page is very different from the current libgeda structure and design, while hopefully can be flexible enough to be the basement of future developments.
22 <h1 id=
"descriptionoftheneedsinanelectricalcadsystem">Description of the needs in an Electrical CAD system
</h1>
26 Schematics and PCB (or IC) designs are, by nature, a graphical representation of objects, with interconnections between them.
30 The basic primitives used in the graphical artwork are:
33 <li class=
"level1"><div class=
"li"> Lines
</div>
35 <li class=
"level1"><div class=
"li"> Arcs
</div>
37 <li class=
"level1"><div class=
"li"> Rectangles
</div>
39 <li class=
"level1"><div class=
"li"> Circles
</div>
41 <li class=
"level1"><div class=
"li"> Text
</div>
43 <li class=
"level1"><div class=
"li"> Images (not very often)
</div>
48 These basic shapes can have attributes modifying how they are drawn in the screen: dashed or dotted lines, filled or unfilled shapes,... , and can be grouped into a composed object (this object is drawn as a combination of one or more basic primitives). The graphical representation of a composed object is a symbol.
52 An electrical or electronic CAD must be able to draw components (composed objects) and interconnections between them. The interconnections is the key difference from other CAD packages, and are the basis of further engineering work, such as simulations or layouts. They are drawn as lines, but they are not only lines and therefore should be handled differently. The interconnection primitives are:
55 <li class=
"level1"><div class=
"li"> Pin or ports: points of a composed object which can be used for interconnection, or connection points between pages.
</div>
57 <li class=
"level1"><div class=
"li"> Nets: define the interconnections between pin or ports. It is usually drawn as a line.
</div>
59 <li class=
"level1"><div class=
"li"> Junction: define the connection between crossing nets. It is usually drawn as a dot at the intersection of two crossing nets.
</div>
61 <li class=
"level1"><div class=
"li"> Buses: group of nets. Trying to make things simple, they are drawn as a line, usually thicker than nets.
</div>
63 <li class=
"level1"><div class=
"li"> Bus ripper: connects a net to a bus. It is needed because there should be a way to specify which net of the bus should be connected.
</div>
68 An electric circuit can be drawn in a page, but, as designs grow in complexity, it is usually divided into several interconnected pages, or is drawn as a hierarchy.
69 One common way is to draw a circuit defining some ports (where it is going to connect to other circuits), make a symbol for it, and include the symbol in other pages as it was a common composed object. So a design is composed of one or several pages, which can also include other page
's symbols, and so on. Therefore, a design can be drawn as a hiearchy tree.
73 Finally, but not less important, every object described can have properties attached, describing the nature of the component, its attributes, or other representations (simulation models, graphical representation for PCB design,...).
78 <h1 id=
"objectbaseddesign">Object based design
</h1>
82 Despite its title, this is not a section talking about Object Oriented Programming. :-)
86 It is a known fact that all schematics are graphical representations of components, interconnections and properties, organized as a plain or hierarchical tree.
90 One of the current issues with libgeda is that the schematic program itself, and hence the developers, should take care of all the drawing stuff associated with schematics. Plus, there are drawing transforms, like moving, rotating, mirroring, etc... This is very time consuming for the developer, and the results are not always the best.
94 This was fine at the moment when it was born, but technology is continuously evolving.
95 Today there are more advanced widgets that take care of all the object drawing, and lets the applications concentrate on what they should do. This kind of widgets are called
"canvas
".
99 Let
's take a look at one of them: goocanvas. There are no screenshots, no official webpage, but don
't be scared and look further. Download it and take a look at the documentation into the
"doc
" directory. You can also compile a demo, but you will need GTK
2.10 (for goocanvas version greater than
0.4), or GTK2.8 (goocanvas
0.4). I can tell you that the demo of the last version (
0.8 at this moment) is quite impressive. If you have time, try it!. It is worth!.
103 Basically what it provides is:
106 <li class=
"level1"><div class=
"li"> Already defined primitives: ellipse, image, path, polyline, rectangle, text, and even support for other GTK widges.
</div>
108 <li class=
"level1"><div class=
"li"> Takes care of all the drawing stuff.
</div>
110 <li class=
"level1"><div class=
"li"> Model/view implementation: several views of the same page is easily supported.
</div>
112 <li class=
"level1"><div class=
"li"> Full hierarchy/nesting capability: there are no nesting limits.
</div>
114 <li class=
"level1"><div class=
"li"> Uses cairo, already in GTK. This can be a drawback for some people, but if you have problems with cairo, it
's likely you are going to have problems with the current gschem when GTK complete the transition into cairo.
</div>
116 <li class=
"level1"><div class=
"li"> Built-in drawing transforms (rotating, scaling, moving,...).
</div>
118 <li class=
"level1"><div class=
"li"> Full international text support without creating a new font. This is something true with some programs using a custom font: if you want it to support your language, you have to create the font for your special characters. (This is the case of the current gschem).
</div>
120 <li class=
"level1"><div class=
"li"> Built-in object visibility and clipping handling.
</div>
122 <li class=
"level1"><div class=
"li"> Built-in object events: it can detect clicks on objects, for example.
</div>
124 <li class=
"level1"><div class=
"li"> Written in C using GObject.
</div>
129 The advantage is clear: all the basic drawing primitives and operations are already done.
133 So the proposal is to base all the geda objects on the objects supplied by the canvas (note that every canvas you find is going to provide its own object classes, so this is a canvas based generic design.
138 <h1 id=
"gedaobjects">geda objects
</h1>
142 The geda object definition could be something as simple as:
144 <pre class=
"code C"><span class=
"kw4">struct
</span> GedaObject
<span class=
"br0">{</span>
145 <span class=
"kw4">int
</span> GedaType
<span class=
"sy0">;
</span>
146 GList
<span class=
"sy0">*
</span>views
<span class=
"sy0">;
</span> <span class=
"coMULTI">/* List of pointers to GooCanvasItems
147 This could solve the problem about heterogeneus parts:
148 We can store as many graphical representations of they object as we want */
</span>
149 <span class=
"coMULTI">/* Still not sure about this, though */
</span>
150 GooCanvasItem
<span class=
"sy0">*
</span>current_view
<span class=
"sy0">;
</span>
151 <span class=
"br0">}</span><span class=
"sy0">;
</span>
153 <span class=
"kw4">struct
</span> GedaObjectGroup
<span class=
"br0">{</span>
154 <span class=
"kw4">int
</span> GedaType
<span class=
"sy0">;
</span>
155 GooCanvasItem group
<span class=
"sy0">;
</span> <span class=
"coMULTI">/* There is also an item for groups of objects */
</span>
156 <span class=
"br0">}</span><span class=
"sy0">;
</span></pre>
159 There is no need to store graphic attributes in GedaObject. If the position is needed, since the canvas item can be queried.
160 Some special definition for properties is needed (they shouldn
't be handled as just text):
162 <pre class=
"code C"><span class=
"kw4">struct
</span> GedaObjectProperty
<span class=
"br0">{</span>
163 GedaType
<span class=
"sy0">;
</span>
164 GooCanvasItem
<span class=
"sy0">*
</span>name
<span class=
"sy0">;
</span>
165 GooCanvasItem
<span class=
"sy0">*
</span>value
<span class=
"sy0">;
</span>
166 <span class=
"br0">}</span><span class=
"sy0">;
</span></pre>
169 and another one for connectivity items:
171 <pre class=
"code C"><span class=
"kw4">struct
</span> GedaObjectPort
<span class=
"br0">{</span>
172 <span class=
"kw4">int
</span> GedaType
<span class=
"sy0">;
</span>
173 GooCanvasItem
<span class=
"sy0">*
</span>graphic
<span class=
"sy0">;
</span>
174 GedaObject
<span class=
"sy0">*
</span>connected_object
<span class=
"sy0">;
</span>
175 <span class=
"br0">}</span><span class=
"sy0">;
</span>
177 <span class=
"kw4">struct
</span> GedaObjectDotConnection
<span class=
"br0">{</span>
178 <span class=
"kw4">int
</span> GedaType
<span class=
"sy0">;
</span>
179 GooCanvasItem
<span class=
"sy0">*
</span>graphic
<span class=
"sy0">;
</span>
180 GList
<span class=
"sy0">*
</span>connected_objects
<span class=
"sy0">;
</span>
181 <span class=
"br0">}</span><span class=
"sy0">;
</span>
183 <span class=
"kw4">struct
</span> GedaObjectNet
<span class=
"br0">{</span> <span class=
"coMULTI">/* or bus, or bus ripper */
</span>
184 <span class=
"kw4">int
</span> GedaType
<span class=
"sy0">;
</span>
185 GooCanvasItem
<span class=
"sy0">*
</span>graphic
<span class=
"sy0">;
</span>
186 GList
<span class=
"sy0">*
</span>connected_objects
<span class=
"sy0">;
</span>
187 <span class=
"br0">}</span><span class=
"sy0">;
</span></pre>
190 Everything else can be done attaching properties to the defined objects. For example, a page is just as any other GedaObject, where the view item points to a GedaObjectGroup.
191 Notice that having multiple views for a page could be just like a page having multiple pages (at the same hierarchy level).
195 No object naming is required, although it is already supported by default: you can add a GedaProperty to any other object (it will become part of the object).
199 Example: a
7400 symbol, with a footprint attribute
"DIP-
16", and reference designator
"U1
" would look as:
201 <pre class=
"code">GedaObject
204 | | |- GedaObjectGroup /* the graphic representation */
205 | | |- GedaObjectProperty /* name =
"refdes
", value=
"U1
" */
206 | | |- GedaObjectProperty /* name =
"footprint
", value=
"DIP-
16" */
211 <h1 id=
"integrationwithcurrentcode">Integration with current code
</h1>
215 There is no easy and direct way to get this structure into the current codebase. However, the current codebase can be adapted progressively to use this structure.
219 All canvas specific code can be hidden by a common interface or a runtime plugin, so a possible change of the used canvas could be easy.
224 <h1 id=
"comments">Comments?
</h1>
228 Leave your comment here!
236 Hi. I think a canvas could be the right way to go with gschem, however we should design libgeda structures to represent the underlying circuit, design, and CAD / graphics concepts involved. I
'd hope we can avoid linking any canvas or UI specific structures into libgeda. In a sense, part of what libgeda
's does is define canvas independent data-structures and manipulation functions for for the graphic objects on a schematic page.
240 We can write a wrapper between libgeda and the canvas for actual rendering. It looks (superficially) that this is possible with goocanvas. The two basic cases are
"compound
" gEDA objects which map to groups of other objects (like complex objects, the current font implementation etc.), and gEDA objects which map to primitives like lines and arcs.
244 I think some of the important design decisions to make now involve defining the API for object / design database manipulation, and what signals and hooks we might expose to other code. I
'd start by considering starting with basic
"translate, rotate, mirror, ....
" operations like libgeda has now, and then explore signals notifying that an object has changed.