1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2000 Ales V. Hvezda
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
24 #include <libgeda/libgeda.h>
26 #include "../include/globals.h"
27 #include "../include/x_states.h"
28 #include "../include/prototype.h"
30 #ifdef HAVE_LIBDMALLOC
34 /*! \todo Finish function documentation!!!
36 * \par Function Description
39 void o_pin_draw(TOPLEVEL
*w_current
, OBJECT
*o_current
)
42 int x1
, y1
, x2
, y2
; /* screen coords */
44 if (o_current
->line
== NULL
) {
48 o_pin_recalc(w_current
, o_current
);
50 /* reuse line's routine */
51 if ( (w_current
->DONT_REDRAW
== 1) ||
52 (!o_line_visible(w_current
, o_current
->line
, &x1
, &y1
, &x2
, &y2
)) ) {
57 printf("drawing pin\n\n");
60 if (w_current
->pin_style
== THICK
) {
61 size
= SCREENabs(w_current
, PIN_WIDTH
);
62 gdk_gc_set_line_attributes(w_current
->gc
, size
, GDK_LINE_SOLID
,
67 if (w_current
->override_color
!= -1 ) {
68 gdk_gc_set_foreground(w_current
->gc
,
69 x_get_color(w_current
->override_color
));
70 if (w_current
->DONT_REDRAW
== 0) {
71 gdk_draw_line(w_current
->window
, w_current
->gc
,
73 gdk_draw_line(w_current
->backingstore
, w_current
->gc
,
77 if (w_current
->DONT_REDRAW
== 0) {
78 gdk_gc_set_foreground(w_current
->gc
, x_get_color(o_current
->color
));
79 gdk_draw_line(w_current
->window
, w_current
->gc
,
81 gdk_draw_line(w_current
->backingstore
, w_current
->gc
,
86 /* draw the cue directly */
87 o_cue_draw_lowlevel(w_current
, o_current
, o_current
->whichend
);
89 /* yes zero is right for the width -> use hardware lines */
90 if (w_current
->pin_style
== THICK
) {
91 gdk_gc_set_line_attributes(w_current
->gc
, 0, GDK_LINE_SOLID
,
97 printf("drawing pin\n");
100 if (o_current
->draw_grips
&& w_current
->draw_grips
== TRUE
) {
101 /* pb20011109 - modified to use the new o_line_[draw|erase]_grips() */
102 /* reuse the line functions */
103 if (!o_current
->selected
) {
104 /* object is no more selected, erase the grips */
105 o_current
->draw_grips
= FALSE
;
106 o_line_erase_grips(w_current
, o_current
);
108 /* object is selected, draw the grips */
109 o_line_draw_grips(w_current
, o_current
);
114 /*! \todo Finish function documentation!!!
116 * \par Function Description
119 void o_pin_erase(TOPLEVEL
*w_current
, OBJECT
*o_current
)
121 w_current
->override_color
= w_current
->background_color
;
122 o_pin_draw(w_current
, o_current
);
123 w_current
->override_color
= -1;
126 /*! \todo Finish function documentation!!!
128 * \par Function Description
131 void o_pin_draw_xor(TOPLEVEL
*w_current
, int dx
, int dy
, OBJECT
*o_current
)
136 if (o_current
->line
== NULL
) {
140 if (o_current
->saved_color
!= -1) {
141 color
= o_current
->saved_color
;
143 color
= o_current
->color
;
146 gdk_gc_set_foreground(w_current
->xor_gc
, x_get_darkcolor(color
));
148 if (w_current
->pin_style
== THICK
) {
149 size
= SCREENabs(w_current
, PIN_WIDTH
);
150 gdk_gc_set_line_attributes(w_current
->xor_gc
, size
,
156 gdk_draw_line(w_current
->window
, w_current
->xor_gc
,
157 o_current
->line
->screen_x
[0]+dx
,
158 o_current
->line
->screen_y
[0]+dy
,
159 o_current
->line
->screen_x
[1]+dx
,
160 o_current
->line
->screen_y
[1]+dy
);
162 if (w_current
->pin_style
== THICK
) {
163 gdk_gc_set_line_attributes(w_current
->xor_gc
, 0,
170 /*! \todo Finish function documentation!!!
172 * \par Function Description
175 void o_pin_start(TOPLEVEL
*w_current
, int x
, int y
)
178 w_current
->last_x
= w_current
->start_x
= fix_x(w_current
, x
);
179 w_current
->last_y
= w_current
->start_y
= fix_y(w_current
, y
);
181 if (w_current
->pin_style
== THICK
) {
182 size
= SCREENabs(w_current
, PIN_WIDTH
);
183 gdk_gc_set_line_attributes(w_current
->xor_gc
, size
,
189 gdk_gc_set_foreground(w_current
->xor_gc
,
190 x_get_darkcolor(w_current
->select_color
) );
191 gdk_draw_line(w_current
->window
, w_current
->xor_gc
,
192 w_current
->start_x
, w_current
->start_y
,
193 w_current
->last_x
, w_current
->last_y
);
195 if (w_current
->pin_style
== THICK
) {
196 gdk_gc_set_line_attributes(w_current
->xor_gc
, 0,
203 /*! \todo Finish function documentation!!!
205 * \par Function Description
208 void o_pin_end(TOPLEVEL
*w_current
, int x
, int y
)
213 GList
*other_objects
= NULL
;
214 OBJECT
*o_current
, *o_current_pin
;
216 if (w_current
->inside_action
== 0) {
217 o_redraw(w_current
, w_current
->page_current
->object_head
, TRUE
);
221 if (w_current
->override_pin_color
== -1) {
222 color
= w_current
->pin_color
;
224 color
= w_current
->override_pin_color
;
227 /* removed 3/15 to see if we can get pins to be ortho only */
228 /* w_current->last_x = fix_x(w_current, x);
229 w_current->last_y = fix_y(w_current, y);*/
231 /* don't allow zero length pins */
232 if ( (w_current
->start_x
== w_current
->last_x
) &&
233 (w_current
->start_y
== w_current
->last_y
) ) {
234 w_current
->start_x
= (-1);
235 w_current
->start_y
= (-1);
236 w_current
->last_x
= (-1);
237 w_current
->last_y
= (-1);
241 SCREENtoWORLD(w_current
, w_current
->start_x
,w_current
->start_y
, &x1
, &y1
);
242 SCREENtoWORLD(w_current
, w_current
->last_x
, w_current
->last_y
, &x2
, &y2
);
243 x1
= snap_grid(w_current
, x1
);
244 y1
= snap_grid(w_current
, y1
);
245 x2
= snap_grid(w_current
, x2
);
246 y2
= snap_grid(w_current
, y2
);
248 w_current
->page_current
->object_tail
=
250 w_current
->page_current
->object_tail
,
255 o_current
= o_current_pin
= w_current
->page_current
->object_tail
;
257 if (scm_hook_empty_p(add_pin_hook
) == SCM_BOOL_F
&&
259 scm_run_hook(add_pin_hook
,
260 scm_cons(g_make_object_smob(w_current
, o_current
),
264 other_objects
= s_conn_return_others(other_objects
, o_current_pin
);
265 o_cue_undraw_list(w_current
, other_objects
);
266 o_cue_draw_list(w_current
, other_objects
);
267 g_list_free(other_objects
);
268 o_cue_draw_single(w_current
, o_current_pin
);
269 o_pin_draw(w_current
, o_current_pin
);
271 w_current
->start_x
= (-1);
272 w_current
->start_y
= (-1);
273 w_current
->last_x
= (-1);
274 w_current
->last_y
= (-1);
275 w_current
->page_current
->CHANGED
=1;
277 o_undo_savestate(w_current
, UNDO_ALL
);
280 /*! \todo Finish function documentation!!!
282 * \par Function Description
285 void o_pin_rubberpin(TOPLEVEL
*w_current
, int x
, int y
)
290 if (w_current
->inside_action
== 0) {
291 o_redraw(w_current
, w_current
->page_current
->object_head
, TRUE
);
295 size
= SCREENabs(w_current
, PIN_WIDTH
);
297 if (w_current
->pin_style
== THICK
) {
298 gdk_gc_set_line_attributes(w_current
->xor_gc
, size
,
304 gdk_gc_set_foreground(w_current
->xor_gc
,
305 x_get_darkcolor(w_current
->select_color
) );
306 gdk_draw_line(w_current
->window
, w_current
->xor_gc
,
307 w_current
->start_x
, w_current
->start_y
,
308 w_current
->last_x
, w_current
->last_y
);
310 w_current
->last_x
= fix_x(w_current
, x
);
311 w_current
->last_y
= fix_y(w_current
, y
);
313 diff_x
= abs(w_current
->last_x
- w_current
->start_x
);
314 diff_y
= abs(w_current
->last_y
- w_current
->start_y
);
316 if (diff_x
>= diff_y
) {
317 w_current
->last_y
= w_current
->start_y
;
319 w_current
->last_x
= w_current
->start_x
;
322 gdk_gc_set_foreground(w_current
->xor_gc
,
323 x_get_darkcolor(w_current
->select_color
) );
324 gdk_draw_line(w_current
->window
, w_current
->xor_gc
,
325 w_current
->start_x
, w_current
->start_y
,
326 w_current
->last_x
, w_current
->last_y
);
328 if (w_current
->pin_style
== THICK
) {
329 gdk_gc_set_line_attributes(w_current
->xor_gc
, 0,
336 /*! \todo Finish function documentation!!!
338 * \par Function Description
341 * used in o_stretch.c
343 void o_pin_eraserubber(TOPLEVEL
*w_current
)
347 if (w_current
->net_style
== THICK
) {
348 size
= SCREENabs(w_current
, PIN_WIDTH
);
353 gdk_gc_set_line_attributes(w_current
->xor_gc
, size
,
360 gdk_gc_set_foreground(w_current
->xor_gc
,
361 x_get_color(w_current
->background_color
) );
364 gdk_draw_line(w_current
->window
, w_current
->xor_gc
, w_current
->start_x
, w_current
->start_y
, w_current
->last_x
, w_current
->last_y
);
366 if (w_current
->net_style
== THICK
) {
367 gdk_gc_set_line_attributes(w_current
->xor_gc
, 0,