gnetlist: Add basic concatenated net support for verilog.
[geda-gaf/whiteaudio.git] / libgeda / src / s_cue.c
blobb50c6795e856ebe5efd0be77b0ed24fa933d7b52
1 /* gEDA - GPL Electronic Design Automation
2 * libgeda - gEDA's library
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <config.h>
22 #include <stdio.h>
23 #include <ctype.h>
24 #ifdef HAVE_STDLIB_H
25 #include <stdlib.h>
26 #endif
28 #include "libgeda_priv.h"
30 #ifdef HAVE_LIBDMALLOC
31 #include <dmalloc.h>
32 #endif
34 /*! \todo Finish function documentation!!!
35 * \brief
36 * \par Function Description
39 void s_cue_postscript_fillbox(TOPLEVEL * toplevel, FILE * fp, int x,
40 int y)
42 int offset;
43 int offset2;
45 /* hard coded values */
46 offset = CUE_BOX_SIZE;
47 offset2 = offset*2;
49 f_print_set_color(toplevel, fp, NET_ENDPOINT_COLOR);
51 fprintf(fp, "%d %d %d %d fbox\n",
52 offset2, offset2, x-offset, y-offset);
55 /*! \todo Finish function documentation!!!
56 * \brief
57 * \par Function Description
60 void s_cue_postscript_junction (TOPLEVEL * toplevel, FILE * fp,
61 int x, int y, int bus_involved)
63 int offset2;
65 if (bus_involved) {
66 offset2 = JUNCTION_CUE_SIZE_BUS;
67 } else {
68 offset2 = JUNCTION_CUE_SIZE_NET;
71 f_print_set_color(toplevel, fp, JUNCTION_COLOR);
73 fprintf(fp, "newpath\n");
74 fprintf(fp, "%d %d\n", x, y);
75 fprintf(fp, "%d\n", offset2 / 2);
76 fprintf(fp, "0 360 arc\n");
77 fprintf(fp, "fill\n");
81 /*! \todo Finish function documentation!!!
82 * \brief
83 * \par Function Description
86 void s_cue_output_all (TOPLEVEL * toplevel, const GList *obj_list, FILE * fp,
87 int type)
89 OBJECT *o_current;
90 const GList *iter;
92 iter = obj_list;
93 while (iter != NULL) {
94 o_current = (OBJECT *)iter->data;
95 switch (o_current->type) {
96 case (OBJ_NET):
97 case (OBJ_BUS):
98 case (OBJ_PIN):
99 s_cue_output_single(toplevel, o_current, fp, type);
100 break;
102 case (OBJ_COMPLEX):
103 case (OBJ_PLACEHOLDER):
104 s_cue_output_all(toplevel, o_current->complex->prim_objs, fp,
105 type);
106 break;
109 iter = g_list_next (iter);
113 /*! \todo Finish function documentation!!!
114 * \brief
115 * \par Function Description
118 void s_cue_output_lowlevel(TOPLEVEL * toplevel, OBJECT * object, int whichone,
119 FILE * fp, int output_type)
121 int x, y;
122 GList *cl_current;
123 CONN *conn;
124 int type, count = 0;
125 int done = FALSE;
126 int bus_involved = FALSE;
128 x = object->line->x[whichone];
129 y = object->line->y[whichone];
131 type = CONN_ENDPOINT;
133 if (object->type == OBJ_BUS ||
134 (object->type == OBJ_PIN && object->pin_type == PIN_TYPE_BUS))
135 bus_involved = TRUE;
137 cl_current = object->conn_list;
138 while (cl_current != NULL && !done) {
139 conn = (CONN *) cl_current->data;
141 if (conn->x == x && conn->y == y) {
143 if (conn->other_object &&
144 (conn->other_object->type == OBJ_BUS ||
145 (conn->other_object->type == OBJ_PIN &&
146 conn->other_object->pin_type == PIN_TYPE_BUS)))
147 bus_involved=TRUE;
149 switch (conn->type) {
151 case (CONN_ENDPOINT):
152 count++;
153 break;
155 case (CONN_MIDPOINT):
156 type = CONN_MIDPOINT;
157 done = TRUE;
158 count = 0;
159 break;
163 cl_current = g_list_next(cl_current);
166 #if DEBUG
167 printf("type: %d count: %d\n", type, count);
168 #endif
170 switch (type) {
172 case (CONN_ENDPOINT):
173 if (object->type == OBJ_NET) { /* only nets have these cues */
174 if (count < 1) { /* Didn't find anything connected there */
175 if (output_type == POSTSCRIPT) {
176 s_cue_postscript_fillbox(toplevel, fp, x, y);
180 } else if (count >= 2) {
181 if (output_type == POSTSCRIPT)
182 s_cue_postscript_junction (toplevel, fp, x, y, bus_involved);
185 break;
187 case (CONN_MIDPOINT):
188 if (output_type == POSTSCRIPT)
189 s_cue_postscript_junction (toplevel, fp, x, y, bus_involved);
190 break;
195 /*! \todo Finish function documentation!!!
196 * \brief
197 * \par Function Description
200 void s_cue_output_lowlevel_midpoints(TOPLEVEL * toplevel, OBJECT * object,
201 FILE * fp, int output_type)
203 int x, y;
204 GList *cl_current;
205 CONN *conn;
206 int bus_involved = FALSE;
208 if (object->type == OBJ_BUS)
209 bus_involved = TRUE;
211 cl_current = object->conn_list;
212 while (cl_current != NULL) {
213 conn = (CONN *) cl_current->data;
215 switch (conn->type) {
216 case (CONN_MIDPOINT):
218 x = conn->x;
219 y = conn->y;
221 if (conn->other_object && conn->other_object->type == OBJ_BUS)
222 bus_involved = TRUE;
224 if (output_type == POSTSCRIPT) {
225 s_cue_postscript_junction (toplevel, fp, x, y, bus_involved);
227 break;
231 cl_current = g_list_next(cl_current);
235 /*! \todo Finish function documentation!!!
236 * \brief
237 * \par Function Description
240 void s_cue_output_single(TOPLEVEL * toplevel, OBJECT * object, FILE * fp,
241 int type)
243 if (!object) {
244 return;
247 if (object->type != OBJ_NET && object->type != OBJ_PIN &&
248 object->type != OBJ_BUS) {
249 return;
252 s_cue_output_lowlevel(toplevel, object, 0, fp, type);
253 s_cue_output_lowlevel(toplevel, object, 1, fp, type);
254 s_cue_output_lowlevel_midpoints(toplevel, object, fp, type);