File: o_basic.nw

package info (click to toggle)
libgeda 20050313-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 5,636 kB
  • ctags: 1,505
  • sloc: ansic: 19,449; sh: 8,627; makefile: 197; perl: 59
file content (294 lines) | stat: -rw-r--r-- 6,486 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
@c -*- mode: Noweb; noweb-doc-mode: texinfo-mode; noweb-code-mode: c-mode -*-

@node File o_basic.c,,,Top
@chapter File @file{o_basic.c}

@section File header

<<o_basic.c : *>>=
<<o_basic.c : copyright and license>>

/* DO NOT read or edit this file ! Use ../noweb/o_basic.nw instead */

<<o_basic.c : include directives>>
<<o_basic.c : inside_region()>>
<<o_basic.c : o_redraw_single()>>
<<o_basic.c : o_recalc()>>
<<o_basic.c : o_set_line_options()>>
<<o_basic.c : o_set_fill_options()>>
<<o_basic.c : o_object_recalc()>>

@


<<o_basic.c : copyright and license>>=
/* gEDA - GPL Electronic Design Automation
 * libgeda - gEDA's library
 * Copyright (C) 1998-2000 Ales V. Hvezda
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
 */

@ 


<<o_basic.c : include directives>>=
#include <config.h>

#include <stdio.h>

/* instrumentation code */
#if 0
#include <sys/time.h>
#include <unistd.h>
#endif

#include <gtk/gtk.h>
#include <libguile.h>

#include "defines.h"
#include "struct.h"
#include "globals.h"
#include "o_types.h"
#include "colors.h"

#include "../include/prototype.h"

#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
#endif

/* Lots of Gross code... needs lots of cleanup */
/* mainly readability issues */


@


@section Function @code{inside_region()}

@defun inside_region left top right bottom x y
@end defun

<<o_basic.c : inside_region()>>=
int 
inside_region(int left, int top, int right, int bottom, int x, int y)
{
  return ((x >= left && x <= right && y >= top && y <= bottom) ? 1 : 0);
}

@ %def inside_region


@section Function @code{o_redraw_single()}

@defun o_redraw_single w_current o_current
@end defun

<<o_basic.c : o_redraw_single()>>=
void
o_redraw_single(TOPLEVEL *w_current, OBJECT *o_current)
{
  if (o_current == NULL)
  return;
	
  if (w_current->DONT_REDRAW) /* highly experimental */
  return;

  if (o_current->draw_func != NULL && o_current->type != OBJ_HEAD) {
    w_current->inside_redraw = 1;
    (*o_current->draw_func)(w_current, o_current);
    w_current->inside_redraw = 0;
  }
}

@ %def o_redraw_single


@section Function @code{o_recalc()}

@defun o_recalc w_current object_list
@end defun

<<o_basic.c : o_recalc()>>=
void
o_recalc(TOPLEVEL *w_current, OBJECT *object_list)
{
  OBJECT *o_current;

  if (object_list == NULL)
  return;
	
  o_current = object_list;
  while (o_current != NULL) {
    switch(o_current->type) {

      case(OBJ_LINE):
        o_line_recalc(w_current, o_current);
        break;

      case(OBJ_NET):
        o_net_recalc(w_current, o_current);
        break;

      case(OBJ_BUS):
        o_bus_recalc(w_current, o_current);
        break;

      case(OBJ_BOX):
        o_box_recalc(w_current, o_current);
        break;

      case(OBJ_PICTURE):
        o_picture_recalc(w_current, o_current);
        break;

      case(OBJ_CIRCLE):
        o_circle_recalc(w_current, o_current);
        break;

      case(OBJ_COMPLEX):
      case(OBJ_PLACEHOLDER):
        o_complex_recalc(w_current, o_current);
        break;

      case(OBJ_PIN):
        o_pin_recalc(w_current, o_current);
        break;

      case(OBJ_ARC):
        o_arc_recalc(w_current, o_current);
        break;
    }

    o_current = o_current->next;
  }
}

@ %def o_recalc


@section Function @code{o_set_line_options()}

@defun o_set_line_options w_current o_current end type width length space
@end defun

<<o_basic.c : o_set_line_options()>>=
void
o_set_line_options(TOPLEVEL *w_current, OBJECT *o_current,
				   OBJECT_END end, OBJECT_TYPE type,
				   int width, int length, int space) 
{
  if(o_current == NULL) {
    return;
  }

  /* do some error checking / correcting */
  switch(type) {
    case(TYPE_DOTTED):
    if (space < 1) {
      space = 100;
      s_log_message ("Invalid space specified, setting to 100\n");
    }
    break;
    case(TYPE_DASHED):
    case(TYPE_CENTER):
    case(TYPE_PHANTOM):
    if (length < 1) {
      length = 100;
      s_log_message ("Invalid length specified, setting to 100\n");
    }
    if (space < 1) {
      space = 100;
      s_log_message ("Invalid space specified, setting to 100\n");
    }
    break;
  }
  
  o_current->line_width = width;
  o_current->line_end   = end;
  o_current->line_type  = type;

  o_current->line_length = length;
  o_current->line_space  = space;
}

@ %def o_set_line_options


@section Function @code{o_set_fill_options()}

@defun o_set_fill_options w_current o_current type width pitch1 angle1 pitch2 angle2
@end defun

<<o_basic.c : o_set_fill_options()>>=
void
o_set_fill_options(TOPLEVEL *w_current, OBJECT *o_current,
				   OBJECT_FILLING type, int width,
				   int pitch1, int angle1,
				   int pitch2, int angle2) 
{
  if(o_current == NULL) {
    return;
  }

  o_current->fill_type = type;
  o_current->fill_width = width;

  o_current->fill_pitch1 = pitch1;
  o_current->fill_angle1 = angle1;

  o_current->fill_pitch2 = pitch2;
  o_current->fill_angle2 = angle2;
	
}

@ %def o_set_fill_options


@section Function @code{o_object_recalc()}

@defun o_object_recalc w_current o_current
@end defun

<<o_basic.c : o_object_recalc()>>=
void
o_object_recalc(TOPLEVEL *w_current, OBJECT *o_current) 
{
  int width, length, space, pitch;
	
  if(o_current == NULL) {
    return;
  }

  width = SCREENabs(w_current, o_current->line_width);
  o_current->screen_line_width = width;

  length = SCREENabs(w_current, o_current->line_length);
  o_current->screen_line_length = length;

  space = SCREENabs(w_current, o_current->line_space);
  o_current->screen_line_space = space;

  width = SCREENabs(w_current, o_current->fill_width);
  o_current->screen_fill_width = width;
  pitch = SCREENabs(w_current, o_current->fill_pitch1);
  o_current->screen_fill_pitch1 = pitch;
  pitch = SCREENabs(w_current, o_current->fill_pitch2);
  o_current->screen_fill_pitch2 = pitch;

}

@ %def o_object_recalc