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
25 #include <libgeda/libgeda.h>
27 #include "../include/globals.h"
28 #include "../include/x_states.h"
29 #include "../include/prototype.h"
31 #ifdef HAVE_LIBDMALLOC
35 /*! \todo Finish function documentation!!!
37 * \par Function Description
40 void o_pin_draw(TOPLEVEL
*w_current
, OBJECT
*o_current
)
43 int x1
, y1
, x2
, y2
; /* screen coords */
45 if (o_current
->line
== NULL
) {
49 /* reuse line's routine */
50 if ( (w_current
->DONT_REDRAW
== 1) ||
51 (!o_line_visible(w_current
, o_current
->line
, &x1
, &y1
, &x2
, &y2
)) ) {
56 printf("drawing pin\n\n");
59 if (w_current
->pin_style
== THICK
) {
60 size
= SCREENabs(w_current
, PIN_WIDTH
);
61 gdk_gc_set_line_attributes(w_current
->gc
, size
, GDK_LINE_SOLID
,
66 if (w_current
->override_color
!= -1 ) {
67 gdk_gc_set_foreground(w_current
->gc
,
68 x_get_color(w_current
->override_color
));
69 if (w_current
->DONT_REDRAW
== 0) {
70 gdk_draw_line(w_current
->window
, w_current
->gc
,
72 gdk_draw_line(w_current
->backingstore
, w_current
->gc
,
76 if (w_current
->DONT_REDRAW
== 0) {
77 gdk_gc_set_foreground(w_current
->gc
, x_get_color(o_current
->color
));
78 gdk_draw_line(w_current
->window
, w_current
->gc
,
80 gdk_draw_line(w_current
->backingstore
, w_current
->gc
,
85 /* draw the cue directly */
86 o_cue_draw_lowlevel(w_current
, o_current
, o_current
->whichend
);
88 /* yes zero is right for the width -> use hardware lines */
89 if (w_current
->pin_style
== THICK
) {
90 gdk_gc_set_line_attributes(w_current
->gc
, 0, GDK_LINE_SOLID
,
96 printf("drawing pin\n");
99 if (o_current
->draw_grips
&& w_current
->draw_grips
== TRUE
) {
100 /* pb20011109 - modified to use the new o_line_[draw|erase]_grips() */
101 /* reuse the line functions */
102 if (!o_current
->selected
) {
103 /* object is no more selected, erase the grips */
104 o_current
->draw_grips
= FALSE
;
105 o_line_erase_grips(w_current
, o_current
);
107 /* object is selected, draw the grips */
108 o_line_draw_grips(w_current
, o_current
);
113 /*! \todo Finish function documentation!!!
115 * \par Function Description
118 void o_pin_erase(TOPLEVEL
*w_current
, OBJECT
*o_current
)
120 w_current
->override_color
= w_current
->background_color
;
121 o_pin_draw(w_current
, o_current
);
122 w_current
->override_color
= -1;
125 /*! \todo Finish function documentation!!!
127 * \par Function Description
130 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 WORLDtoSCREEN( w_current
, o_current
->line
->x
[0], o_current
->line
->y
[0], &sx
[0], &sy
[0] );
157 WORLDtoSCREEN( w_current
, o_current
->line
->x
[1], o_current
->line
->y
[1], &sx
[1], &sy
[1] );
159 gdk_draw_line(w_current
->window
, w_current
->xor_gc
,
163 if (w_current
->pin_style
== THICK
) {
164 gdk_gc_set_line_attributes(w_current
->xor_gc
, 0,
171 /*! \todo Finish function documentation!!!
173 * \par Function Description
176 void o_pin_start(TOPLEVEL
*w_current
, int x
, int y
)
179 w_current
->last_x
= w_current
->start_x
= fix_x(w_current
, x
);
180 w_current
->last_y
= w_current
->start_y
= fix_y(w_current
, y
);
182 if (w_current
->pin_style
== THICK
) {
183 size
= SCREENabs(w_current
, PIN_WIDTH
);
184 gdk_gc_set_line_attributes(w_current
->xor_gc
, size
,
190 gdk_gc_set_foreground(w_current
->xor_gc
,
191 x_get_darkcolor(w_current
->select_color
) );
192 gdk_draw_line(w_current
->window
, w_current
->xor_gc
,
193 w_current
->start_x
, w_current
->start_y
,
194 w_current
->last_x
, w_current
->last_y
);
196 if (w_current
->pin_style
== THICK
) {
197 gdk_gc_set_line_attributes(w_current
->xor_gc
, 0,
204 /*! \todo Finish function documentation!!!
206 * \par Function Description
209 void o_pin_end(TOPLEVEL
*w_current
, int x
, int y
)
214 GList
*other_objects
= NULL
;
215 OBJECT
*o_current
, *o_current_pin
;
217 if (w_current
->inside_action
== 0) {
218 o_redraw(w_current
, w_current
->page_current
->object_head
, TRUE
);
222 if (w_current
->override_pin_color
== -1) {
223 color
= w_current
->pin_color
;
225 color
= w_current
->override_pin_color
;
228 /* removed 3/15 to see if we can get pins to be ortho only */
229 /* w_current->last_x = fix_x(w_current, x);
230 w_current->last_y = fix_y(w_current, y);*/
232 /* don't allow zero length pins */
233 if ( (w_current
->start_x
== w_current
->last_x
) &&
234 (w_current
->start_y
== w_current
->last_y
) ) {
235 w_current
->start_x
= (-1);
236 w_current
->start_y
= (-1);
237 w_current
->last_x
= (-1);
238 w_current
->last_y
= (-1);
242 SCREENtoWORLD(w_current
, w_current
->start_x
,w_current
->start_y
, &x1
, &y1
);
243 SCREENtoWORLD(w_current
, w_current
->last_x
, w_current
->last_y
, &x2
, &y2
);
244 x1
= snap_grid(w_current
, x1
);
245 y1
= snap_grid(w_current
, y1
);
246 x2
= snap_grid(w_current
, x2
);
247 y2
= snap_grid(w_current
, y2
);
249 w_current
->page_current
->object_tail
=
251 w_current
->page_current
->object_tail
,
256 o_current
= o_current_pin
= w_current
->page_current
->object_tail
;
258 if (scm_hook_empty_p(add_pin_hook
) == SCM_BOOL_F
&&
260 scm_run_hook(add_pin_hook
,
261 scm_cons(g_make_object_smob(w_current
, o_current
),
265 other_objects
= s_conn_return_others(other_objects
, o_current_pin
);
266 o_cue_undraw_list(w_current
, other_objects
);
267 o_cue_draw_list(w_current
, other_objects
);
268 g_list_free(other_objects
);
269 o_cue_draw_single(w_current
, o_current_pin
);
270 o_pin_draw(w_current
, o_current_pin
);
272 w_current
->start_x
= (-1);
273 w_current
->start_y
= (-1);
274 w_current
->last_x
= (-1);
275 w_current
->last_y
= (-1);
276 w_current
->page_current
->CHANGED
=1;
278 o_undo_savestate(w_current
, UNDO_ALL
);
281 /*! \todo Finish function documentation!!!
283 * \par Function Description
286 void o_pin_rubberpin(TOPLEVEL
*w_current
, int x
, int y
)
291 if (w_current
->inside_action
== 0) {
292 o_redraw(w_current
, w_current
->page_current
->object_head
, TRUE
);
296 size
= SCREENabs(w_current
, PIN_WIDTH
);
298 if (w_current
->pin_style
== THICK
) {
299 gdk_gc_set_line_attributes(w_current
->xor_gc
, size
,
305 gdk_gc_set_foreground(w_current
->xor_gc
,
306 x_get_darkcolor(w_current
->select_color
) );
307 gdk_draw_line(w_current
->window
, w_current
->xor_gc
,
308 w_current
->start_x
, w_current
->start_y
,
309 w_current
->last_x
, w_current
->last_y
);
311 w_current
->last_x
= fix_x(w_current
, x
);
312 w_current
->last_y
= fix_y(w_current
, y
);
314 diff_x
= abs(w_current
->last_x
- w_current
->start_x
);
315 diff_y
= abs(w_current
->last_y
- w_current
->start_y
);
317 if (diff_x
>= diff_y
) {
318 w_current
->last_y
= w_current
->start_y
;
320 w_current
->last_x
= w_current
->start_x
;
323 gdk_gc_set_foreground(w_current
->xor_gc
,
324 x_get_darkcolor(w_current
->select_color
) );
325 gdk_draw_line(w_current
->window
, w_current
->xor_gc
,
326 w_current
->start_x
, w_current
->start_y
,
327 w_current
->last_x
, w_current
->last_y
);
329 if (w_current
->pin_style
== THICK
) {
330 gdk_gc_set_line_attributes(w_current
->xor_gc
, 0,
337 /*! \todo Finish function documentation!!!
339 * \par Function Description
342 * used in o_stretch.c
344 void o_pin_eraserubber(TOPLEVEL
*w_current
)
348 if (w_current
->net_style
== THICK
) {
349 size
= SCREENabs(w_current
, PIN_WIDTH
);
354 gdk_gc_set_line_attributes(w_current
->xor_gc
, size
,
360 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
);
362 if (w_current
->net_style
== THICK
) {
363 gdk_gc_set_line_attributes(w_current
->xor_gc
, 0,