1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2007 Ales Hvezda
4 * Copyright (C) 1998-2007 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., 59 Temple Place, Suite 330, Boston, MA 02111 USA
27 #ifdef HAVE_LIBDMALLOC
31 /*! \todo Finish function documentation!!!
33 * \par Function Description
36 void o_pin_draw(GSCHEM_TOPLEVEL
*w_current
, OBJECT
*o_current
)
38 TOPLEVEL
*toplevel
= w_current
->toplevel
;
39 PAGE
*page
= toplevel
->page_current
;
41 int x1
, y1
, x2
, y2
; /* screen coords */
43 if (o_current
->line
== NULL
) {
47 /* reuse line's routine */
48 if ( (toplevel
->DONT_REDRAW
== 1) ||
49 (!o_line_visible(toplevel
, o_current
, &x1
, &y1
, &x2
, &y2
)) ) {
54 printf("drawing pin\n\n");
57 if (toplevel
->pin_style
== THICK
) {
58 size
= SCREENabs(page
, PIN_WIDTH
);
59 gdk_gc_set_line_attributes(w_current
->gc
, size
, GDK_LINE_SOLID
,
64 if (toplevel
->override_color
!= -1 ) {
65 gdk_gc_set_foreground(w_current
->gc
,
66 x_get_color(toplevel
->override_color
));
67 if (toplevel
->DONT_REDRAW
== 0) {
68 gdk_draw_line(w_current
->backingstore
, w_current
->gc
,
72 if (toplevel
->DONT_REDRAW
== 0) {
73 gdk_gc_set_foreground(w_current
->gc
, x_get_color(o_current
->color
));
74 gdk_draw_line(w_current
->backingstore
, w_current
->gc
,
79 /* draw the cue directly */
80 o_cue_draw_lowlevel(w_current
, o_current
, o_current
->whichend
);
82 /* yes zero is right for the width -> use hardware lines */
83 if (toplevel
->pin_style
== THICK
) {
84 gdk_gc_set_line_attributes(w_current
->gc
, 0, GDK_LINE_SOLID
,
90 printf("drawing pin\n");
95 /*! \todo Finish function documentation!!!
97 * \par Function Description
100 void o_pin_draw_xor(GSCHEM_TOPLEVEL
*w_current
, int dx
, int dy
, OBJECT
*o_current
)
102 TOPLEVEL
*toplevel
= w_current
->toplevel
;
103 PAGE
*page
= toplevel
->page_current
;
106 int w_x1
, w_y1
, w_x2
, w_y2
;
109 if (o_current
->line
== NULL
) {
113 if (o_current
->saved_color
!= -1) {
114 color
= o_current
->saved_color
;
116 color
= o_current
->color
;
119 gdk_gc_set_foreground(w_current
->xor_gc
, x_get_darkcolor(color
));
121 if (toplevel
->pin_style
== THICK
) {
122 size
= SCREENabs(page
, PIN_WIDTH
);
123 gdk_gc_set_line_attributes(w_current
->xor_gc
, size
,
129 s_basic_get_grip(o_current
, GRIP_1
, &w_x1
, &w_y1
);
130 s_basic_get_grip(o_current
, GRIP_2
, &w_x2
, &w_y2
);
132 WORLDtoSCREEN(page
, w_x1
+ dx
, w_y1
+ dy
, &sx
[0], &sy
[0]);
133 WORLDtoSCREEN(page
, w_x2
+ dx
, w_y2
+ dy
, &sx
[1], &sy
[1]);
135 gdk_draw_line(w_current
->backingstore
, w_current
->xor_gc
,
136 sx
[0], sy
[0], sx
[1], sy
[1]);
138 if (toplevel
->pin_style
== THICK
) {
139 gdk_gc_set_line_attributes(w_current
->xor_gc
, 0,
146 /*! \todo Finish function documentation!!!
148 * \par Function Description
151 void o_pin_start(GSCHEM_TOPLEVEL
*w_current
, int w_x
, int w_y
)
153 w_current
->first_wx
= w_current
->second_wx
= w_x
;
154 w_current
->first_wy
= w_current
->second_wy
= w_y
;
157 /*! \todo Finish function documentation!!!
159 * \par Function Description
162 void o_pin_end(GSCHEM_TOPLEVEL
*w_current
, int x
, int y
)
164 TOPLEVEL
*toplevel
= w_current
->toplevel
;
167 GList
*other_objects
= NULL
;
168 OBJECT
*o_current
, *o_current_pin
;
170 g_assert( w_current
->inside_action
!= 0 );
172 if (toplevel
->override_pin_color
== -1) {
173 color
= w_current
->pin_color
;
175 color
= toplevel
->override_pin_color
;
178 /* undraw rubber line */
179 o_pin_rubberpin_xor(w_current
);
180 w_current
->rubber_visible
= 0;
182 /* don't allow zero length pins */
183 if ((w_current
->first_wx
== w_current
->second_wx
) &&
184 (w_current
->first_wy
== w_current
->second_wy
)) {
188 new_obj
= o_pin_new(toplevel
, OBJ_PIN
, color
,
189 w_current
->first_wx
, w_current
->first_wy
,
190 w_current
->second_wx
, w_current
->second_wy
,
192 s_page_append(toplevel
->page_current
, new_obj
);
194 o_current
= o_current_pin
= toplevel
->page_current
->object_tail
;
196 if (scm_hook_empty_p(add_pin_hook
) == SCM_BOOL_F
&&
198 scm_run_hook(add_pin_hook
,
199 scm_cons(g_make_object_smob(toplevel
, o_current
),
203 /* look for connected objects */
204 other_objects
= s_conn_return_others(other_objects
, o_current_pin
);
205 o_cue_undraw_list(w_current
, other_objects
);
206 o_cue_draw_list(w_current
, other_objects
);
207 g_list_free(other_objects
);
208 o_cue_draw_single(w_current
, o_current_pin
);
209 o_pin_draw(w_current
, o_current_pin
);
211 toplevel
->page_current
->CHANGED
=1;
212 o_undo_savestate(w_current
, UNDO_ALL
);
215 /*! \todo Finish function documentation!!!
217 * \par Function Description
220 void o_pin_rubberpin(GSCHEM_TOPLEVEL
*w_current
, int w_x
, int w_y
)
222 g_assert( w_current
->inside_action
!= 0 );
224 /* erase the rubberpin if it is visible */
225 if (w_current
->rubber_visible
)
226 o_pin_rubberpin_xor(w_current
);
228 w_current
->second_wx
= w_x
;
229 w_current
->second_wy
= w_y
;
231 /* decide whether to draw the pin vertical or horizontal */
232 if (abs(w_current
->second_wx
- w_current
->first_wx
)
233 >= abs(w_current
->second_wy
- w_current
->first_wy
)) {
234 w_current
->second_wy
= w_current
->first_wy
;
236 w_current
->second_wx
= w_current
->first_wx
;
239 o_pin_rubberpin_xor(w_current
);
240 w_current
->rubber_visible
= 1;
243 /*! \todo Finish function documentation!!!
245 * \par Function Description
248 * used in o_stretch.c
250 void o_pin_eraserubber(GSCHEM_TOPLEVEL
*w_current
)
252 o_pin_rubberpin_xor(w_current
);
256 /*! \todo Finish function documentation!!!
258 * \par Function Description
261 void o_pin_rubberpin_xor(GSCHEM_TOPLEVEL
*w_current
)
263 TOPLEVEL
*toplevel
= w_current
->toplevel
;
264 PAGE
*page
= toplevel
->page_current
;
268 WORLDtoSCREEN(page
, w_current
->first_wx
, w_current
->first_wy
, &x1
, &y1
);
269 WORLDtoSCREEN(page
, w_current
->second_wx
, w_current
->second_wy
, &x2
, &y2
);
271 if (toplevel
->net_style
== THICK
) {
272 size
= SCREENabs(page
, PIN_WIDTH
);
277 gdk_gc_set_line_attributes(w_current
->xor_gc
, size
,
283 gdk_gc_set_foreground(w_current
->xor_gc
,
284 x_get_darkcolor(w_current
->select_color
));
285 gdk_draw_line(w_current
->backingstore
, w_current
->xor_gc
, x1
, y1
, x2
, y2
);
286 o_invalidate_rect(w_current
,
287 min(x1
, x2
) - size
/2, min(y1
, y2
) - size
/2,
288 max(x1
, x2
) + size
/2, max(y1
, y2
) + size
/2);
290 if (toplevel
->net_style
== THICK
) {
291 gdk_gc_set_line_attributes(w_current
->xor_gc
, 0,