1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2010 Ales Hvezda
4 * Copyright (C) 1998-2020 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
27 /*! \todo Finish function documentation!!!
29 * \par Function Description
32 void o_pin_start(GschemToplevel
*w_current
, int w_x
, int w_y
)
34 i_action_start (w_current
);
36 w_current
->first_wx
= w_current
->second_wx
= w_x
;
37 w_current
->first_wy
= w_current
->second_wy
= w_y
;
40 /*! \todo Finish function documentation!!!
42 * \par Function Description
45 void o_pin_end(GschemToplevel
*w_current
, int x
, int y
)
49 g_assert( w_current
->inside_action
!= 0 );
51 GschemPageView
*page_view
= gschem_toplevel_get_current_page_view (w_current
);
52 g_return_if_fail (page_view
!= NULL
);
54 PAGE
*page
= gschem_page_view_get_page (page_view
);
55 g_return_if_fail (page
!= NULL
);
57 TOPLEVEL
*toplevel
= page
->toplevel
;
58 g_return_if_fail (toplevel
!= NULL
);
60 /* undraw rubber line */
61 /* o_pin_invalidate_rubber (w_current); */
62 w_current
->rubber_visible
= 0;
64 new_obj
= o_pin_new(toplevel
, PIN_COLOR
,
65 w_current
->first_wx
, w_current
->first_wy
,
66 w_current
->second_wx
, w_current
->second_wy
,
68 s_page_append (toplevel
, page
, new_obj
);
70 /* Call add-objects-hook */
71 g_run_hook_object (w_current
, "%add-objects-hook", new_obj
);
73 gschem_toplevel_page_content_changed (w_current
, page
);
74 o_undo_savestate (w_current
, page
, UNDO_ALL
, _("Add Pin"));
75 i_action_stop (w_current
);
78 /*! \todo Finish function documentation!!!
80 * \par Function Description
83 void o_pin_motion (GschemToplevel
*w_current
, int w_x
, int w_y
)
85 g_assert( w_current
->inside_action
!= 0 );
87 /* erase the rubberpin if it is visible */
88 if (w_current
->rubber_visible
)
89 o_pin_invalidate_rubber (w_current
);
91 w_current
->second_wx
= w_x
;
92 w_current
->second_wy
= w_y
;
94 /* decide whether to draw the pin vertical or horizontal */
95 if (abs(w_current
->second_wx
- w_current
->first_wx
)
96 >= abs(w_current
->second_wy
- w_current
->first_wy
)) {
97 w_current
->second_wy
= w_current
->first_wy
;
99 w_current
->second_wx
= w_current
->first_wx
;
102 o_pin_invalidate_rubber (w_current
);
103 w_current
->rubber_visible
= 1;
106 /*! \todo Finish function documentation!!!
108 * \par Function Description
110 void o_pin_invalidate_rubber (GschemToplevel
*w_current
)
112 g_return_if_fail (w_current
!= NULL
);
114 GschemPageView
*page_view
= gschem_toplevel_get_current_page_view (w_current
);
116 gschem_page_view_invalidate_world_rect (page_view
,
119 w_current
->second_wx
,
120 w_current
->second_wy
);
124 /*! \todo Finish function documentation!!!
126 * \par Function Description
129 void o_pin_draw_rubber (GschemToplevel
*w_current
, EdaRenderer
*renderer
)
131 double wwidth
= PIN_WIDTH_NET
;
132 cairo_t
*cr
= eda_renderer_get_cairo_context (renderer
);
133 GArray
*color_map
= eda_renderer_get_color_map (renderer
);
134 int flags
= eda_renderer_get_cairo_flags (renderer
);
136 eda_cairo_line (cr
, flags
, END_NONE
, wwidth
,
137 w_current
->first_wx
, w_current
->first_wy
,
138 w_current
->second_wx
, w_current
->second_wy
);
140 eda_cairo_set_source_color (cr
, SELECT_COLOR
, color_map
);
141 eda_cairo_stroke (cr
, flags
, TYPE_SOLID
, END_NONE
, wwidth
, -1, -1);