Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 29303) +++ trunk/scconfig/plugins.h (revision 29304) @@ -61,6 +61,7 @@ plugin_def("smartdisperse", "netlist based dispenser", sbuildin, 1, 0) plugin_def("stroke", "mouse gestures", sbuildin, 1, 0) plugin_def("teardrops", "draw teardrops on pins", sbuildin, 1, 0) +plugin_def("tool_std", "standard tools", sbuildin, 1, 0) plugin_def("vendordrill", "vendor drill mapping", sbuildin, 1, 0) plugin_header("\nFootprint backends:\n") Index: trunk/src/tool_text.c =================================================================== --- trunk/src/tool_text.c (revision 29303) +++ trunk/src/tool_text.c (nonexistent) @@ -1,140 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" -#include "conf_core.h" - -#include "board.h" -#include "data.h" -#include "draw.h" -#include -#include "tool.h" -#include "undo.h" - -#include "obj_text_draw.h" - - -void pcb_tool_text_notify_mode(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - char *string; - - if ((string = pcb_hid_prompt_for(hl, "Enter text:", "", "text")) != NULL) { - if (strlen(string) > 0) { - pcb_text_t *text; - int flag = PCB_FLAG_CLEARLINE; - - if (pcb_layer_flags(pcb, PCB_CURRLID(pcb)) & PCB_LYT_BOTTOM) - flag |= PCB_FLAG_ONSOLDER; - if ((text = pcb_text_new(pcb_loose_subc_layer(pcb, PCB_CURRLAYER(pcb), pcb_true), pcb_font(pcb, conf_core.design.text_font_id, 1), pcb_tool_note.X, - pcb_tool_note.Y, 0, conf_core.design.text_scale, conf_core.design.text_thickness, string, pcb_flag_make(flag))) != NULL) { - pcb_undo_add_obj_to_create(PCB_OBJ_TEXT, PCB_CURRLAYER(pcb), text, text); - pcb_undo_inc_serial(); - pcb_text_invalidate_draw(PCB_CURRLAYER(pcb), text); - pcb_subc_as_board_update(PCB); - pcb_draw(); - } - } - free(string); - } -} - -void pcb_tool_text_draw_attached(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - pcb_text_t text; - int flag = PCB_FLAG_CLEARLINE; - - if (pcb_layer_flags(pcb, PCB_CURRLID(pcb)) & PCB_LYT_BOTTOM) - flag |= PCB_FLAG_ONSOLDER; - - text.X = pcb_crosshair.X; - text.Y = pcb_crosshair.Y; - text.rot = 0; - text.Flags = pcb_flag_make(flag); - text.Scale = conf_core.design.text_scale; - text.thickness = conf_core.design.text_thickness; - text.TextString = "A"; - text.fid = conf_core.design.text_font_id; - text.ID = 0; - text.BoundingBox.X1 = text.BoundingBox.Y1 = text.BoundingBox.X2 = text.BoundingBox.Y2 = 0; - pcb_text_draw_xor(&text,0,0); - -} - -/* XPM */ -static const char *text_icon[] = { -/* columns rows colors chars-per-pixel */ -"21 21 3 1", -" c #000000", -". c #6EA5D7", -"o c None", -/* pixels */ -"ooooooooooooooooooooo", -"ooooooooooooooooooooo", -"ooooooooooooooooooooo", -"oo.ooo.ooo.ooo.ooo.oo", -"o.o.o.o.o.o.o.o.o.o.o", -"oo.ooo.ooo.ooo.ooo.oo", -"ooooooooooooooooooooo", -"ooooooooooooooooooooo", -"ooooooooooooooooooooo", -"ooooooooooooooooooooo", -"ooooooooooooooooooooo", -"ooooooooooooooooooooo", -" o o ooo o ", -"oo ooo ooo ooo ooo oo", -"oo ooo oooo o oooo oo", -"oo ooo ooooo ooooo oo", -"oo ooo ooo o oooo oo", -"oo ooo ooo ooo ooo oo", -"oo ooo ooo ooo ooo oo", -"oo ooo o ooo ooo oo", -"ooooooooooooooooooooo" -}; - -pcb_tool_t pcb_tool_text = { - "text", NULL, NULL, 100, text_icon, PCB_TOOL_CURSOR_NAMED("xterm"), 0, - NULL, - NULL, - pcb_tool_text_notify_mode, - NULL, - NULL, - pcb_tool_text_draw_attached, - NULL, - NULL, - - pcb_false -}; - Index: trunk/src/tool_text.h =================================================================== --- trunk/src/tool_text.h (revision 29303) +++ trunk/src/tool_text.h (nonexistent) @@ -1,3 +0,0 @@ -extern pcb_tool_t pcb_tool_text; - -void pcb_tool_text_notify_mode(pcb_hidlib_t *hl); Index: trunk/src/tool_via.c =================================================================== --- trunk/src/tool_via.c (revision 29303) +++ trunk/src/tool_via.c (nonexistent) @@ -1,150 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" - -#include "conf_core.h" -#include - -#include "board.h" -#include "change.h" -#include -#include "data.h" -#include "draw.h" -#include "tool.h" -#include "tool_thermal.h" -#include "undo.h" - -#include "obj_pstk_draw.h" - -TODO("padstack: remove this when via is removed and the padstack is created from style directly") -#include "src_plugins/lib_compat_help/pstk_compat.h" - -void pcb_tool_via_notify_mode(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - - if (!pcb->pstk_on) { - pcb_message(PCB_MSG_WARNING, "You must turn via visibility on before\nyou can place vias\n"); - return; - } - - if (conf_core.design.via_drilling_hole >= conf_core.design.via_thickness) { - pcb_message(PCB_MSG_ERROR, "Can't place via: invalid via geometry (hole too large for via size)\n"); - return; - } - -TODO("pstk #21: do not work in comp mode, use a pstk proto - scconfig also has TODO #21, fix it there too") - { - pcb_pstk_t *ps = pcb_pstk_new_compat_via(pcb->Data, -1, pcb_tool_note.X, pcb_tool_note.Y, - conf_core.design.via_drilling_hole, conf_core.design.via_thickness, conf_core.design.clearance, - 0, PCB_PSTK_COMPAT_ROUND, pcb_true); - if (ps == NULL) - return; - - pcb_obj_add_attribs((pcb_any_obj_t *)ps, pcb->pen_attr, NULL); - pcb_undo_add_obj_to_create(PCB_OBJ_PSTK, ps, ps, ps); - - if (pcb_gui->shift_is_pressed(pcb_gui)) - pcb_tool_thermal_on_pstk(ps, PCB_CURRLID(pcb)); - - pcb_undo_inc_serial(); - pcb_pstk_invalidate_draw(ps); - pcb_draw(); - } -} - -static void xor_draw_fake_via(pcb_coord_t x, pcb_coord_t y, pcb_coord_t dia, pcb_coord_t clearance) -{ - pcb_coord_t r = (dia/2)+clearance; - pcb_render->draw_arc(pcb_crosshair.GC, x, y, r, r, 0, 360); -} - - -void pcb_tool_via_draw_attached(pcb_hidlib_t *hl) -{ -TODO("pstk: replace this when route style has a prototype") - xor_draw_fake_via(pcb_crosshair.X, pcb_crosshair.Y, conf_core.design.via_thickness, 0); - if (conf_core.editor.show_drc) { - /* XXX: Naughty cheat - use the mask to draw DRC clearance! */ - pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.drc); - xor_draw_fake_via(pcb_crosshair.X, pcb_crosshair.Y, conf_core.design.via_thickness, conf_core.design.clearance); - pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.attached); - } -} - -/* XPM */ -static const char *via_icon[] = { -/* columns rows colors chars-per-pixel */ -"21 21 3 1", -" c #000000", -". c #7A8584", -"o c None", -/* pixels */ -"ooooooooooooooooooooo", -"ooooooooo...ooooooooo", -"oooooooo.....oooooooo", -"ooooooo..ooo..ooooooo", -"oooooo..ooooo..oooooo", -"oooooo..ooooo..oooooo", -"oooooo..ooooo..oooooo", -"ooooooo..ooo..ooooooo", -"oooooooo.....oooooooo", -"ooooooooo...ooooooooo", -"ooooooooooooooooooooo", -"ooooooooooooooooooooo", -"ooooooooooooooooooooo", -"ooo ooo o ooo ooooo", -"ooo ooo oo ooo o oooo", -"ooo ooo oo oo ooo ooo", -"oooo o ooo oo ooo ooo", -"oooo o ooo oo ooo", -"oooo o ooo oo ooo ooo", -"ooooo ooo o ooo ooo", -"ooooooooooooooooooooo" -}; - -pcb_tool_t pcb_tool_via = { - "via", NULL, NULL, 100, via_icon, PCB_TOOL_CURSOR_NAMED(NULL), 0, - NULL, - NULL, - pcb_tool_via_notify_mode, - NULL, - NULL, - pcb_tool_via_draw_attached, - NULL, - NULL, - - pcb_false -}; Index: trunk/src/tool_via.h =================================================================== --- trunk/src/tool_via.h (revision 29303) +++ trunk/src/tool_via.h (nonexistent) @@ -1,4 +0,0 @@ -extern pcb_tool_t pcb_tool_via; - -void pcb_tool_via_notify_mode(pcb_hidlib_t *hl); -void pcb_tool_via_draw_attached(pcb_hidlib_t *hl); Index: trunk/src/tool_move.c =================================================================== --- trunk/src/tool_move.c (revision 29303) +++ trunk/src/tool_move.c (nonexistent) @@ -1,142 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" - -#include "board.h" -#include "move.h" -#include "crosshair.h" -#include "search.h" -#include "tool.h" -#include "extobj.h" - - -void pcb_tool_move_uninit(void) -{ - pcb_notify_crosshair_change(pcb_false); - pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; - pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; - pcb_notify_crosshair_change(pcb_true); - pcb_crosshair.extobj_edit = NULL; -} - -void pcb_tool_move_notify_mode(pcb_hidlib_t *hl) -{ - pcb_coord_t dx, dy; - - switch (pcb_crosshair.AttachedObject.State) { - /* first notify, lookup object */ - case PCB_CH_STATE_FIRST: - { - int types = PCB_MOVE_TYPES; - - pcb_crosshair.AttachedObject.Type = - pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, types, - &pcb_crosshair.AttachedObject.Ptr1, &pcb_crosshair.AttachedObject.Ptr2, &pcb_crosshair.AttachedObject.Ptr3); - if (pcb_crosshair.AttachedObject.Type != PCB_OBJ_VOID) { - pcb_any_obj_t *obj = (pcb_any_obj_t *)pcb_crosshair.AttachedObject.Ptr2; - if (PCB_FLAG_TEST(PCB_FLAG_LOCK, obj)) { - pcb_message(PCB_MSG_WARNING, "Sorry, %s object is locked\n", pcb_obj_type_name(obj->type)); - pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; - pcb_crosshair.extobj_edit = NULL; - } - else - pcb_tool_attach_for_copy(hl, pcb_tool_note.X, pcb_tool_note.Y, pcb_true); - } - break; - } - - /* second notify, move object */ - case PCB_CH_STATE_SECOND: - dx = pcb_crosshair.AttachedObject.tx - pcb_crosshair.AttachedObject.X; - dy = pcb_crosshair.AttachedObject.ty - pcb_crosshair.AttachedObject.Y; - if ((dx != 0) || (dy != 0)) { - pcb_any_obj_t *newo = pcb_move_obj_and_rubberband(pcb_crosshair.AttachedObject.Type, pcb_crosshair.AttachedObject.Ptr1, pcb_crosshair.AttachedObject.Ptr2, pcb_crosshair.AttachedObject.Ptr3, dx, dy); - pcb_extobj_float_geo(newo); - if (!pcb_marked.user_placed) - pcb_crosshair_set_local_ref(0, 0, pcb_false); - pcb_subc_as_board_update(PCB); - pcb_board_set_changed_flag(pcb_true); - } - else if (pcb_crosshair.extobj_edit != NULL) - pcb_extobj_float_geo(pcb_crosshair.extobj_edit); - - /* reset identifiers */ - pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; - pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; - pcb_crosshair.extobj_edit = NULL; - break; - } -} - -void pcb_tool_move_release_mode(pcb_hidlib_t *hl) -{ - if (pcb_tool_note.Hit) { - pcb_tool_move_notify_mode(hl); - pcb_tool_note.Hit = 0; - } -} - -void pcb_tool_move_adjust_attached_objects(pcb_hidlib_t *hl) -{ - pcb_crosshair.AttachedObject.tx = pcb_crosshair.X; - pcb_crosshair.AttachedObject.ty = pcb_crosshair.Y; -} - -void pcb_tool_move_draw_attached(pcb_hidlib_t *hl) -{ - pcb_xordraw_movecopy(); -} - -pcb_bool pcb_tool_move_undo_act(pcb_hidlib_t *hl) -{ - /* don't allow undo in the middle of an operation */ - if (pcb_crosshair.AttachedObject.State != PCB_CH_STATE_FIRST) - return pcb_false; - return pcb_true; -} - -pcb_tool_t pcb_tool_move = { - "move", NULL, NULL, 100, NULL, PCB_TOOL_CURSOR_NAMED("crosshair"), 0, - NULL, - pcb_tool_move_uninit, - pcb_tool_move_notify_mode, - pcb_tool_move_release_mode, - pcb_tool_move_adjust_attached_objects, - pcb_tool_move_draw_attached, - pcb_tool_move_undo_act, - NULL, - - pcb_true -}; Index: trunk/src/tool_move.h =================================================================== --- trunk/src/tool_move.h (revision 29303) +++ trunk/src/tool_move.h (nonexistent) @@ -1,7 +0,0 @@ -extern pcb_tool_t pcb_tool_move; - -void pcb_tool_move_uninit(void); -void pcb_tool_move_notify_mode(pcb_hidlib_t *hl); -void pcb_tool_move_release_mode(pcb_hidlib_t *hl); -void pcb_tool_move_draw_attached(pcb_hidlib_t *hl); -pcb_bool pcb_tool_move_undo_act(pcb_hidlib_t *hl); Index: trunk/src/tool_lock.c =================================================================== --- trunk/src/tool_lock.c (revision 29303) +++ trunk/src/tool_lock.c (nonexistent) @@ -1,133 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" - -#include "board.h" -#include "change.h" -#include "data.h" -#include "draw.h" -#include -#include "search.h" -#include "tool.h" -#include "tool_lock.h" - -#define PCB_OBJ_CLASS_LOCK (PCB_OBJ_PSTK | PCB_OBJ_LINE | PCB_OBJ_ARC | PCB_OBJ_POLY | PCB_OBJ_SUBC | PCB_OBJ_TEXT | PCB_OBJ_LOCKED) - -void pcb_tool_lock_notify_mode(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - void *ptr1, *ptr2, *ptr3; - int type; - - type = pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, PCB_OBJ_CLASS_LOCK, &ptr1, &ptr2, &ptr3); - - if (type == PCB_OBJ_SUBC) { - pcb_subc_t *subc = (pcb_subc_t *)ptr2; - pcb_flag_change(pcb, PCB_CHGFLG_TOGGLE, PCB_FLAG_LOCK, PCB_OBJ_SUBC, ptr1, ptr2, ptr3); - - DrawSubc(subc); - pcb_draw(); - pcb_actionva(hl, "Report", "Subc", "log", NULL); - } - else if (type != PCB_OBJ_VOID) { - pcb_text_t *thing = (pcb_text_t *) ptr3; - PCB_FLAG_TOGGLE(PCB_FLAG_LOCK, thing); - if (PCB_FLAG_TEST(PCB_FLAG_LOCK, thing) - && PCB_FLAG_TEST(PCB_FLAG_SELECTED, thing)) { - /* this is not un-doable since LOCK isn't */ - PCB_FLAG_CLEAR(PCB_FLAG_SELECTED, thing); - pcb_draw_obj((pcb_any_obj_t *)ptr2); - pcb_draw(); - } - pcb_actionva(hl, "Report", "Object", "log", NULL); - } -} - -/* XPM */ -static const char *lock_icon[] = { -/* columns rows colors chars-per-pixel */ -"21 21 2 1", -" c black", -"X c None", -/* pixels */ -"XXXXXXXX XXXXXXXX", -"XXXXXXX XXX XXXXXXX", -"XXXXXXX XXXXX XXXXXXX", -"XXXXXX XXXXX XXXXXX", -"XXXXXX XXXXXXX XXXXXX", -"XXXXXX XXXXXXX XXXXXX", -"XXXX XXXX", -"XXXX XXXXXXXXXXX XXXX", -"XXXX XXXX", -"XXXX XXXXXXXXXXX XXXX", -"XXXX XXXX", -"XXXX XXXXXXXXXXX XXXX", -"XXXX XXXX", -"XXXXXXXXXXXXXXXXXXXXX", -"XX XXXX XXX X XX XX", -"XX XXX XX X XXX XX XX", -"XX XXX XX X XXX X XXX", -"XX XXX XX X XXX XXXX", -"XX XXX XX X XXX X XXX", -"XX XXX XX X XXX XX XX", -"XX XX XXX X XX XX" -}; - -#define lockIcon_width 16 -#define lockIcon_height 16 -static unsigned char lockIcon_bits[] = { - 0x00, 0x00, 0xe0, 0x07, 0x30, 0x0c, 0x10, 0x08, 0x18, 0x18, 0x08, 0x10, - 0x08, 0x00, 0xfc, 0x3f, 0x04, 0x20, 0xfc, 0x3f, 0x04, 0x20, 0xfc, 0x3f, - 0x04, 0x20, 0xfc, 0x3f, 0x04, 0x20, 0xfc, 0x3f}; -#define lockMask_width 16 -#define lockMask_height 16 -static unsigned char lockMask_bits[] = { - 0xf0, 0x0f, 0xf0, 0x0f, 0xf8, 0x1f, 0x38, 0x1c, 0x1c, 0x3c, 0x1c, 0x38, - 0x1c, 0x30, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, - 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f}; - -pcb_tool_t pcb_tool_lock = { - "lock", NULL, NULL, 100, lock_icon, PCB_TOOL_CURSOR_XBM(lockIcon_bits, lockMask_bits), 0, - NULL, - NULL, - pcb_tool_lock_notify_mode, - NULL, - NULL, - NULL, - NULL, - NULL, - - pcb_true -}; Index: trunk/src/tool_lock.h =================================================================== --- trunk/src/tool_lock.h (revision 29303) +++ trunk/src/tool_lock.h (nonexistent) @@ -1,3 +0,0 @@ -extern pcb_tool_t pcb_tool_lock; - -void pcb_tool_lock_notify_mode(pcb_hidlib_t *hl); Index: trunk/src/tool_buffer.c =================================================================== --- trunk/src/tool_buffer.c (revision 29303) +++ trunk/src/tool_buffer.c (nonexistent) @@ -1,144 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" -#include "conf_core.h" - -#include "board.h" -#include "buffer.h" -#include -#include "data.h" -#include -#include -#include "search.h" -#include "tool.h" -#include "undo.h" - -void pcb_tool_buffer_init(void) -{ -} - -void pcb_tool_buffer_uninit(void) -{ -} - -static void pcb_tool_buffer_notify_mode_(pcb_hidlib_t *hl, pcb_bool keep_ids) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - - if (pcb_gui->shift_is_pressed(pcb_gui)) { - pcb_actionva(hl, "ReplaceFootprint", "object", "@buffer", "dumb", NULL); - return; - } - - if (pcb_buffer_copy_to_layout(pcb, pcb_crosshair.AttachedObject.tx, pcb_crosshair.AttachedObject.ty, keep_ids)) { - pcb_board_set_changed_flag(pcb_true); - pcb_gui->invalidate_all(pcb_gui); - } -} - -void pcb_tool_buffer_notify_mode(pcb_hidlib_t *hl) -{ - pcb_tool_buffer_notify_mode_(hl, pcb_false); -} - -void pcb_tool_buffer_release_mode(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - - if (pcb_tool_note.Moving) { - pcb_undo_restore_serial(); - pcb_tool_buffer_notify_mode_(hl, pcb_true); - pcb_buffer_clear(pcb, PCB_PASTEBUFFER); - pcb_buffer_set_number(pcb_tool_note.Buffer); - pcb_tool_note.Moving = pcb_false; - pcb_tool_note.Hit = 0; - } -} - -void pcb_tool_buffer_adjust_attached_objects(pcb_hidlib_t *hl) -{ - pcb_crosshair.AttachedObject.tx = pcb_crosshair.X; - pcb_crosshair.AttachedObject.ty = pcb_crosshair.Y; -} - -void pcb_tool_buffer_draw_attached(pcb_hidlib_t *hl) -{ - pcb_xordraw_buffer(PCB_PASTEBUFFER); -} - -/* XPM */ -static const char *buf_icon[] = { -/* columns rows colors chars-per-pixel */ -"21 21 3 1", -" c #000000", -". c #7A8584", -"o c None", -/* pixels */ -"oooooooo oo ooooooo", -"oooooo.. o o ..ooooo", -"oooooooo oooo ooooooo", -"oooooo.. oooo ..ooooo", -"oooooooo oooo ooooooo", -"oooooo.. oooo ..ooooo", -"oooooooo oooo ooooooo", -"oooooo.. oooo ..ooooo", -"oooooooo oooo ooooooo", -"oooooo.. oooo ..ooooo", -"oooooooo ooooooo", -"ooooooooooooooooooooo", -"oo oo ooo o o", -"ooo ooo o ooo o ooooo", -"ooo ooo o ooo o ooooo", -"ooo ooo o ooo o oo", -"ooo oo ooo o ooooo", -"ooo ooo o ooo o ooooo", -"ooo ooo o ooo o ooooo", -"oo ooo oo ooooo", -"ooooooooooooooooooooo" -}; - -pcb_tool_t pcb_tool_buffer = { - "buffer", NULL, NULL, 100, buf_icon, PCB_TOOL_CURSOR_NAMED("hand"), 0, - pcb_tool_buffer_init, - pcb_tool_buffer_uninit, - pcb_tool_buffer_notify_mode, - pcb_tool_buffer_release_mode, - pcb_tool_buffer_adjust_attached_objects, - pcb_tool_buffer_draw_attached, - NULL, - NULL, - - pcb_true -}; Index: trunk/src/tool_buffer.h =================================================================== --- trunk/src/tool_buffer.h (revision 29303) +++ trunk/src/tool_buffer.h (nonexistent) @@ -1,7 +0,0 @@ -extern pcb_tool_t pcb_tool_buffer; - -void pcb_tool_buffer_init(void); -void pcb_tool_buffer_uninit(void); -void pcb_tool_buffer_notify_mode(pcb_hidlib_t *hl); -void pcb_tool_buffer_release_mode(pcb_hidlib_t *hl); -void pcb_tool_buffer_draw_attached(pcb_hidlib_t *hl); Index: trunk/src/tool_copy.c =================================================================== --- trunk/src/tool_copy.c (revision 29303) +++ trunk/src/tool_copy.c (nonexistent) @@ -1,133 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" - -#include "board.h" -#include "move.h" -#include "crosshair.h" -#include "search.h" -#include "tool.h" - -void pcb_tool_copy_uninit(void) -{ - pcb_notify_crosshair_change(pcb_false); - pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; - pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; - pcb_notify_crosshair_change(pcb_true); - pcb_crosshair.extobj_edit = NULL; -} - -void pcb_tool_copy_notify_mode(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - - switch (pcb_crosshair.AttachedObject.State) { - /* first notify, lookup object */ - case PCB_CH_STATE_FIRST: - { - int types = PCB_COPY_TYPES; - - pcb_crosshair.AttachedObject.Type = - pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, types, - &pcb_crosshair.AttachedObject.Ptr1, &pcb_crosshair.AttachedObject.Ptr2, &pcb_crosshair.AttachedObject.Ptr3); - if (pcb_crosshair.AttachedObject.Type != PCB_OBJ_VOID) { - pcb_tool_attach_for_copy(hl, pcb_tool_note.X, pcb_tool_note.Y, pcb_false); - } - break; - } - - /* second notify, move or copy object */ - case PCB_CH_STATE_SECOND: - - if ((pcb->is_footprint) && (pcb_crosshair.AttachedObject.Type == PCB_OBJ_SUBC)) { - pcb_message(PCB_MSG_WARNING, "Can not copy subcircuit in the footprint edit mode\n"); - } - else { - pcb_copy_obj(pcb_crosshair.AttachedObject.Type, - pcb_crosshair.AttachedObject.Ptr1, - pcb_crosshair.AttachedObject.Ptr2, - pcb_crosshair.AttachedObject.Ptr3, pcb_crosshair.AttachedObject.tx - pcb_crosshair.AttachedObject.X, pcb_crosshair.AttachedObject.ty - pcb_crosshair.AttachedObject.Y); - pcb_subc_as_board_update(PCB); - pcb_board_set_changed_flag(pcb_true); - } - - /* reset identifiers */ - pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; - pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; - pcb_crosshair.extobj_edit = NULL; - break; - } -} - -void pcb_tool_copy_release_mode(pcb_hidlib_t *hl) -{ - if (pcb_tool_note.Hit) { - pcb_tool_copy_notify_mode(hl); - pcb_tool_note.Hit = 0; - } -} - -void pcb_tool_copy_adjust_attached_objects(pcb_hidlib_t *hl) -{ - pcb_crosshair.AttachedObject.tx = pcb_crosshair.X; - pcb_crosshair.AttachedObject.ty = pcb_crosshair.Y; -} - -void pcb_tool_copy_draw_attached(pcb_hidlib_t *hl) -{ - pcb_xordraw_movecopy(); -} - -pcb_bool pcb_tool_copy_undo_act(pcb_hidlib_t *hl) -{ - /* don't allow undo in the middle of an operation */ - if (pcb_crosshair.AttachedObject.State != PCB_CH_STATE_FIRST) - return pcb_false; - return pcb_true; -} - -pcb_tool_t pcb_tool_copy = { - "copy", NULL, NULL, 100, NULL, PCB_TOOL_CURSOR_NAMED("crosshair"), 0, - NULL, - pcb_tool_copy_uninit, - pcb_tool_copy_notify_mode, - pcb_tool_copy_release_mode, - pcb_tool_copy_adjust_attached_objects, - pcb_tool_copy_draw_attached, - pcb_tool_copy_undo_act, - NULL, - - pcb_true -}; Index: trunk/src/tool_poly.c =================================================================== --- trunk/src/tool_poly.c (revision 29303) +++ trunk/src/tool_poly.c (nonexistent) @@ -1,195 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" -#include "conf_core.h" - -#include "crosshair.h" -#include -#include "polygon.h" -#include "tool.h" - - -void pcb_tool_poly_uninit(void) -{ - pcb_notify_crosshair_change(pcb_false); - pcb_crosshair.AttachedPolygon.PointN = 0; - pcb_crosshair.AttachedLine.State = PCB_CH_STATE_FIRST; - pcb_notify_crosshair_change(pcb_true); -} - -TODO("remove this when pcb_tool_poly_notify_mode() loses PCB") -#include "board.h" - -void pcb_tool_poly_notify_mode(pcb_hidlib_t *hl) -{ - pcb_point_t *points = pcb_crosshair.AttachedPolygon.Points; - pcb_cardinal_t n = pcb_crosshair.AttachedPolygon.PointN; - - /* do update of position */ - if (pcb_crosshair.AttachedLine.State == PCB_CH_STATE_FIRST) { - pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X = pcb_crosshair.X; - pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y = pcb_crosshair.Y; - pcb_crosshair.AttachedLine.State = PCB_CH_STATE_THIRD; - pcb_crosshair.AttachedPolygon_pts = 0; - } - - /* check if this is the last point of a polygon */ - if (n >= 3 && points[0].X == pcb_crosshair.AttachedLine.Point2.X && points[0].Y == pcb_crosshair.AttachedLine.Point2.Y) { - pcb_actionva(hl, "Polygon", "Close", NULL); - return; - } - - /* Someone clicking twice on the same point ('doubleclick'): close polygon */ - if (n >= 3 && points[n - 1].X == pcb_crosshair.AttachedLine.Point2.X && points[n - 1].Y == pcb_crosshair.AttachedLine.Point2.Y) { - pcb_actionva(hl, "Polygon", "Close", NULL); - return; - } - - /* create new point if it's the first one or if it's - * different to the last one - */ - if (!n || points[n - 1].X != pcb_crosshair.AttachedLine.Point2.X || points[n - 1].Y != pcb_crosshair.AttachedLine.Point2.Y) { - pcb_poly_point_new(&pcb_crosshair.AttachedPolygon, pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y); - pcb_crosshair.AttachedPolygon_pts = pcb_crosshair.AttachedPolygon.PointN; - - /* copy the coordinates */ - pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X; - pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y; - } - - if (conf_core.editor.orthogonal_moves) { - /* set the mark to the new starting point so ortho works */ - pcb_grabbed.X = pcb_tool_note.X; - pcb_grabbed.Y = pcb_tool_note.Y; - pcb_grabbed.status = pcb_true; - } -} - -void pcb_tool_poly_adjust_attached_objects(pcb_hidlib_t *hl) -{ - pcb_attached_line_t *line = &pcb_crosshair.AttachedLine; - - if (pcb_gui->control_is_pressed(pcb_gui)) { - line->draw = pcb_false; - return; - } - else - line->draw = pcb_true; - if (conf_core.editor.all_direction_lines) { - line->Point2.X = pcb_crosshair.X; - line->Point2.Y = pcb_crosshair.Y; - return; - } - - pcb_line_45(line); -} - -void pcb_tool_poly_draw_attached(pcb_hidlib_t *hl) -{ - /* draw only if starting point is set */ - if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST) - pcb_render->draw_line(pcb_crosshair.GC, - pcb_crosshair.AttachedLine.Point1.X, - pcb_crosshair.AttachedLine.Point1.Y, pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y); - - /* draw attached polygon only if in PCB_MODE_POLYGON or PCB_MODE_POLYGON_HOLE */ - if (pcb_crosshair.AttachedPolygon.PointN > 1) { - pcb_xordraw_poly(&pcb_crosshair.AttachedPolygon, 0, 0, 1); - } -} - -pcb_bool pcb_tool_poly_undo_act(pcb_hidlib_t *hl) -{ - if (pcb_crosshair.AttachedPolygon.PointN) { - pcb_polygon_go_to_prev_point(); - return pcb_false; - } - return pcb_true; -} - -pcb_bool pcb_tool_poly_redo_act(pcb_hidlib_t *hl) -{ - if (pcb_crosshair.AttachedPolygon.PointN) { - pcb_polygon_go_to_next_point(); - return pcb_false; - } - else - return pcb_true; -} - -/* XPM */ -static const char *poly_icon[] = { -/* columns rows colors chars-per-pixel */ -"21 21 3 1", -" c black", -". c #6EA5D7", -"o c None", -/* pixels */ -"ooooooooooo.ooooooooo", -"oooooooooo..ooooooooo", -"ooooooooo...ooooooooo", -"oooooooo....ooooooooo", -"ooooooo.....ooooooooo", -"oooooo.......oooooooo", -"ooooo.........ooooooo", -"oooo...........oooooo", -"oooo............ooooo", -"oooo.............oooo", -"oooo..............ooo", -"ooooooooooooooooooooo", -"o ooo oo oo ooo ", -"o ooo o ooo o oo ooo ", -"o ooo o ooo o ooo o o", -"o oo ooo o oooo oo", -"o ooooo ooo o oooo oo", -"o ooooo ooo o oooo oo", -"o ooooo ooo o oooo oo", -"o oooooo oo o oo", -"ooooooooooooooooooooo" -}; - -pcb_tool_t pcb_tool_poly = { - "poly", NULL, NULL, 100, poly_icon, PCB_TOOL_CURSOR_NAMED("up_arrow"), 0, - NULL, - pcb_tool_poly_uninit, - pcb_tool_poly_notify_mode, - NULL, - pcb_tool_poly_adjust_attached_objects, - pcb_tool_poly_draw_attached, - pcb_tool_poly_undo_act, - pcb_tool_poly_redo_act, - - pcb_false -}; Index: trunk/src/tool_copy.h =================================================================== --- trunk/src/tool_copy.h (revision 29303) +++ trunk/src/tool_copy.h (nonexistent) @@ -1,7 +0,0 @@ -extern pcb_tool_t pcb_tool_copy; - -void pcb_tool_copy_uninit(void); -void pcb_tool_copy_notify_mode(pcb_hidlib_t *hl); -void pcb_tool_copy_release_mode(pcb_hidlib_t *hl); -void pcb_tool_copy_draw_attached(pcb_hidlib_t *hl); -pcb_bool pcb_tool_copy_undo_act(pcb_hidlib_t *hl); Index: trunk/src/tool_poly.h =================================================================== --- trunk/src/tool_poly.h (revision 29303) +++ trunk/src/tool_poly.h (nonexistent) @@ -1,8 +0,0 @@ -extern pcb_tool_t pcb_tool_poly; - -void pcb_tool_poly_uninit(void); -void pcb_tool_poly_notify_mode(pcb_hidlib_t *hl); -void pcb_tool_poly_adjust_attached_objects(pcb_hidlib_t *hl); -void pcb_tool_poly_draw_attached(pcb_hidlib_t *hl); -pcb_bool pcb_tool_poly_undo_act(pcb_hidlib_t *hl); -pcb_bool pcb_tool_poly_redo_act(pcb_hidlib_t *hl); Index: trunk/src/tool_thermal.c =================================================================== --- trunk/src/tool_thermal.c (revision 29303) +++ trunk/src/tool_thermal.c (nonexistent) @@ -1,148 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" - -#include "board.h" -#include "change.h" -#include "data.h" -#include -#include "obj_pstk.h" -#include "search.h" -#include "thermal.h" -#include "tool.h" - -void pcb_tool_thermal_on_pstk(pcb_pstk_t *ps, unsigned long lid) -{ - unsigned char *th, newth = 0; - unsigned char cycle[] = { - PCB_THERMAL_ON | PCB_THERMAL_ROUND | PCB_THERMAL_DIAGONAL, /* default start shape */ - PCB_THERMAL_ON | PCB_THERMAL_ROUND, - PCB_THERMAL_ON | PCB_THERMAL_SHARP | PCB_THERMAL_DIAGONAL, - PCB_THERMAL_ON | PCB_THERMAL_SHARP, - PCB_THERMAL_ON | PCB_THERMAL_SOLID, - PCB_THERMAL_ON | PCB_THERMAL_NOSHAPE - }; - int cycles = sizeof(cycle) / sizeof(cycle[0]); - - th = pcb_pstk_get_thermal(ps, lid, 1); - if (pcb_gui->shift_is_pressed(pcb_gui)) { - int n, curr = -1; - /* cycle through the variants to find the current one */ - for(n = 0; n < cycles; n++) { - if (*th == cycle[n]) { - curr = n; - break; - } - } - - /* bump current pattern to the next or set it up */ - if (curr >= 0) { - curr++; - if (curr >= cycles) - curr = 0; - } - else - curr = 0; - - newth = cycle[curr]; - } - else { - if ((th != NULL) && (*th != 0)) - newth = *th ^ PCB_THERMAL_ON; /* existing thermal, toggle */ - else - newth = cycle[0]; /* new thermal, use default */ - } - - pcb_chg_obj_thermal(PCB_OBJ_PSTK, ps, ps, ps, newth, lid); -} - - -void pcb_tool_thermal_notify_mode(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - void *ptr1, *ptr2, *ptr3; - int type; - - if (((type = pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, PCB_OBJ_CLASS_PIN, &ptr1, &ptr2, &ptr3)) != PCB_OBJ_VOID) - && !PCB_FLAG_TEST(PCB_FLAG_HOLE, (pcb_any_obj_t *) ptr3)) { - if (type == PCB_OBJ_PSTK) - pcb_tool_thermal_on_pstk((pcb_pstk_t *)ptr2, PCB_CURRLID(pcb)); - } -} - -/* XPM */ -static const char *thrm_icon[] = { -/* columns rows colors chars-per-pixel */ -"21 21 3 1", -" c #000000", -". c #6EA5D7", -"o c None", -/* pixels */ -"ooooooooooooooooooooo", -"oooo ooooooooo oooooo", -"ooooo ooooooo ooooooo", -"oooooo o...o oooooooo", -"ooooooo ooo ooooooooo", -"oooooo.ooooo.oooooooo", -"oooooo.ooooo.oooooooo", -"oooooo.ooooo.oooooooo", -"ooooooo ooo ooooooooo", -"oooooo o...o oooooooo", -"ooooo ooooooo ooooooo", -"oooo ooooooooo oooooo", -"ooooooooooooooooooooo", -" o oo o oo ooo ", -"oo ooo oo o oo o o ", -"oo ooo oo o oo o o o ", -"oo ooo oo o oo o o ", -"oo ooo o o oo ooo ", -"oo ooo oo o oo o ooo ", -"oo ooo oo o oo o ooo ", -"oo ooo oo o oo o ooo " -}; - -pcb_tool_t pcb_tool_thermal = { - "thermal", NULL, NULL, 100, thrm_icon, PCB_TOOL_CURSOR_NAMED("iron_cross"), 0, - NULL, - NULL, - pcb_tool_thermal_notify_mode, - NULL, - NULL, - NULL, - NULL, - NULL, - - pcb_false -}; Index: trunk/src/tool_thermal.h =================================================================== --- trunk/src/tool_thermal.h (revision 29303) +++ trunk/src/tool_thermal.h (nonexistent) @@ -1,6 +0,0 @@ -extern pcb_tool_t pcb_tool_thermal; - -void pcb_tool_thermal_notify_mode(pcb_hidlib_t *hl); - -/* direct call: cycle through thermal modes on a padstack - provided for tool_via.h */ -void pcb_tool_thermal_on_pstk(pcb_pstk_t *ps, unsigned long lid); Index: trunk/src/tool_polyhole.c =================================================================== --- trunk/src/tool_polyhole.c (revision 29303) +++ trunk/src/tool_polyhole.c (nonexistent) @@ -1,224 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" -#include "conf_core.h" - -#include "crosshair.h" -#include -#include "polygon.h" -#include "search.h" -#include "tool.h" - - -void pcb_tool_polyhole_uninit(void) -{ - pcb_notify_crosshair_change(pcb_false); - pcb_crosshair.AttachedPolygon.PointN = 0; - pcb_crosshair.AttachedLine.State = PCB_CH_STATE_FIRST; - pcb_notify_crosshair_change(pcb_true); -} - -TODO("remove this when pcb_tool_polyhole_notify_mode() loses PCB") -#include "board.h" - -void pcb_tool_polyhole_notify_mode(pcb_hidlib_t *hl) -{ - switch (pcb_crosshair.AttachedObject.State) { - /* first notify, lookup object */ - case PCB_CH_STATE_FIRST: - pcb_crosshair.AttachedPolygon_pts = 0; - pcb_crosshair.AttachedObject.Type = - pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, PCB_OBJ_POLY, - &pcb_crosshair.AttachedObject.Ptr1, &pcb_crosshair.AttachedObject.Ptr2, &pcb_crosshair.AttachedObject.Ptr3); - - if (pcb_crosshair.AttachedObject.Type == PCB_OBJ_VOID) { - pcb_message(PCB_MSG_WARNING, "The first point of a polygon hole must be on a polygon.\n"); - break; /* don't start doing anything if clicket out of polys */ - } - - if (PCB_FLAG_TEST(PCB_FLAG_LOCK, (pcb_poly_t *)pcb_crosshair.AttachedObject.Ptr2)) { - pcb_message(PCB_MSG_WARNING, "Sorry, poly object is locked\n"); - pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; - pcb_crosshair.extobj_edit = NULL; - break; - } - else - pcb_crosshair.AttachedObject.State = PCB_CH_STATE_SECOND; - /* fall thru: first click is also the first point of the poly hole */ - - /* second notify, insert new point into object */ - case PCB_CH_STATE_SECOND: - { - pcb_point_t *points = pcb_crosshair.AttachedPolygon.Points; - pcb_cardinal_t n = pcb_crosshair.AttachedPolygon.PointN; - - /* do update of position */ - if (pcb_crosshair.AttachedLine.State == PCB_CH_STATE_FIRST) { - pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X = pcb_crosshair.X; - pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y = pcb_crosshair.Y; - pcb_crosshair.AttachedLine.State = PCB_CH_STATE_THIRD; - } - - if (conf_core.editor.orthogonal_moves) { - /* set the mark to the new starting point so ortho works */ - pcb_grabbed.X = pcb_tool_note.X; - pcb_grabbed.Y = pcb_tool_note.Y; - pcb_grabbed.status = pcb_true; - } - - /* check if this is the last point of a polygon */ - if (n >= 3 && points[0].X == pcb_crosshair.AttachedLine.Point2.X && points[0].Y == pcb_crosshair.AttachedLine.Point2.Y) { - pcb_actionva(hl, "Polygon", "CloseHole", NULL); - break; - } - - /* Someone clicking twice on the same point ('doubleclick'): close polygon hole */ - if (n >= 3 && points[n - 1].X == pcb_crosshair.AttachedLine.Point2.X && points[n - 1].Y == pcb_crosshair.AttachedLine.Point2.Y) { - pcb_actionva(hl, "Polygon", "CloseHole", NULL); - break; - } - - /* create new point if it's the first one or if it's - * different to the last one - */ - if (!n || points[n - 1].X != pcb_crosshair.AttachedLine.Point2.X || points[n - 1].Y != pcb_crosshair.AttachedLine.Point2.Y) { - pcb_poly_point_new(&pcb_crosshair.AttachedPolygon, - pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y); - pcb_crosshair.AttachedPolygon_pts = pcb_crosshair.AttachedPolygon.PointN; - - /* copy the coordinates */ - pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X; - pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y; - } - break; - } - } -} - -void pcb_tool_polyhole_adjust_attached_objects(pcb_hidlib_t *hl) -{ - pcb_attached_line_t *line = &pcb_crosshair.AttachedLine; - - if (pcb_gui->control_is_pressed(pcb_gui)) { - line->draw = pcb_false; - return; - } - else - line->draw = pcb_true; - if (conf_core.editor.all_direction_lines) { - line->Point2.X = pcb_crosshair.X; - line->Point2.Y = pcb_crosshair.Y; - return; - } - - pcb_line_45(line); -} - -void pcb_tool_polyhole_draw_attached(pcb_hidlib_t *hl) -{ - /* draw only if starting point is set */ - if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST) - pcb_render->draw_line(pcb_crosshair.GC, - pcb_crosshair.AttachedLine.Point1.X, - pcb_crosshair.AttachedLine.Point1.Y, pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y); - - /* draw attached polygon only if in PCB_MODE_POLYGON or PCB_MODE_POLYGON_HOLE */ - if (pcb_crosshair.AttachedPolygon.PointN > 1) { - pcb_xordraw_poly(&pcb_crosshair.AttachedPolygon, 0, 0, 1); - } -} - -pcb_bool pcb_tool_polyhole_undo_act(pcb_hidlib_t *hl) -{ - if (pcb_crosshair.AttachedPolygon.PointN) { - pcb_polygon_go_to_prev_point(); - return pcb_false; - } - return pcb_true; -} - -pcb_bool pcb_tool_polyhole_redo_act(pcb_hidlib_t *hl) -{ - if (pcb_crosshair.AttachedPolygon.PointN) { - pcb_polygon_go_to_next_point(); - return pcb_false; - } - else - return pcb_true; -} - -/* XPM */ -static const char * polyhole_icon[] = { -"21 21 3 1", -" c None", -". c #6EA5D7", -"+ c #000000", -" .. ", -" ... ", -" ..... ", -" ....... ", -" ......... ", -" ....+++++... ", -" ....+ +.... ", -" ...+ +..... ", -" ...++++++...... ", -" ................ ", -" ................. ", -" ", -" + + ++ + +++ ", -" + + + + + + ", -" + + + + + + ", -" ++++ + + + +++ ", -" + + + + + + ", -" + + + + + + ", -" + + + + + + ", -" + + ++ +++ +++ ", -" " -}; - - -pcb_tool_t pcb_tool_polyhole = { - "polyhole", NULL, NULL, 100, polyhole_icon, PCB_TOOL_CURSOR_NAMED("up_arrow"), 0, - NULL, - pcb_tool_polyhole_uninit, - pcb_tool_polyhole_notify_mode, - NULL, - pcb_tool_polyhole_adjust_attached_objects, - pcb_tool_polyhole_draw_attached, - pcb_tool_polyhole_undo_act, - pcb_tool_polyhole_redo_act, - - pcb_false -}; Index: trunk/src/tool_arrow.c =================================================================== --- trunk/src/tool_arrow.c (revision 29303) +++ trunk/src/tool_arrow.c (nonexistent) @@ -1,280 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" -#include "conf_core.h" - -#include "board.h" -#include "buffer.h" -#include "crosshair.h" -#include "data.h" -#include -#include "remove.h" -#include "move.h" -#include "search.h" -#include "select.h" -#include "tool.h" -#include "undo.h" -#include "extobj.h" - - -void pcb_tool_arrow_uninit(void) -{ - pcb_notify_crosshair_change(pcb_false); - pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; - pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; - pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; - pcb_notify_crosshair_change(pcb_true); -} - -/* Called some time after the click if there was a release but no second click - a.k.a. finalize single click (some things are already done in pcb_notify_mode - at the initial click event) */ -static void click_timer_cb(pcb_hidval_t hv) -{ - pcb_hidlib_t *hl = hv.ptr; - pcb_board_t *pcb = hv.ptr; - - if (pcb_tool_note.Click) { - pcb_notify_crosshair_change(pcb_false); - pcb_tool_note.Click = pcb_false; - if (pcb_tool_note.Moving && !pcb_gui->shift_is_pressed(pcb_gui)) { - pcb_grabbed.status = pcb_true; - pcb_tool_note.Buffer = conf_core.editor.buffer_number; - pcb_buffer_set_number(PCB_MAX_BUFFER - 1); - pcb_buffer_clear(pcb, PCB_PASTEBUFFER); - pcb_buffer_add_selected(pcb, PCB_PASTEBUFFER, pcb_tool_note.X, pcb_tool_note.Y, pcb_true, pcb_true); - pcb_undo_save_serial(); - pcb_remove_selected(pcb_false); - pcb_tool_save(hl); - pcb_tool_is_saved = pcb_true; - pcb_tool_select_by_id(hl, PCB_MODE_PASTE_BUFFER); - } - else if (pcb_tool_note.Hit && !pcb_gui->shift_is_pressed(pcb_gui)) { - pcb_box_t box; - - pcb_grabbed.status = pcb_true; - pcb_tool_save(hl); - pcb_tool_is_saved = pcb_true; - pcb_tool_select_by_id(hl, pcb_gui->control_is_pressed(pcb_gui)? PCB_MODE_COPY : PCB_MODE_MOVE); - pcb_crosshair.AttachedObject.Ptr1 = pcb_tool_note.ptr1; - pcb_crosshair.AttachedObject.Ptr2 = pcb_tool_note.ptr2; - pcb_crosshair.AttachedObject.Ptr3 = pcb_tool_note.ptr3; - pcb_crosshair.AttachedObject.Type = pcb_tool_note.Hit; - - if (pcb_crosshair.drags != NULL) { - free(pcb_crosshair.drags); - pcb_crosshair.drags = NULL; - } - pcb_crosshair.dragx = pcb_tool_note.X; - pcb_crosshair.dragy = pcb_tool_note.Y; - box.X1 = pcb_tool_note.X + PCB_SLOP * pcb_pixel_slop; - box.X2 = pcb_tool_note.X - PCB_SLOP * pcb_pixel_slop; - box.Y1 = pcb_tool_note.Y + PCB_SLOP * pcb_pixel_slop; - box.Y2 = pcb_tool_note.Y - PCB_SLOP * pcb_pixel_slop; - pcb_crosshair.drags = pcb_list_block(pcb, &box, &pcb_crosshair.drags_len); - pcb_crosshair.drags_current = 0; - pcb_tool_attach_for_copy(hl, pcb_tool_note.X, pcb_tool_note.Y, pcb_true); - } - else { - pcb_box_t box; - - pcb_tool_note.Hit = 0; - pcb_tool_note.Moving = pcb_false; - pcb_undo_save_serial(); - box.X1 = -PCB_MAX_COORD; - box.Y1 = -PCB_MAX_COORD; - box.X2 = PCB_MAX_COORD; - box.Y2 = PCB_MAX_COORD; - /* unselect first if shift key not down */ - if (!pcb_gui->shift_is_pressed(pcb_gui) && pcb_select_block(pcb, &box, pcb_false, pcb_false, pcb_false)) - pcb_board_set_changed_flag(pcb_true); - pcb_tool_notify_block(); - pcb_crosshair.AttachedBox.Point1.X = pcb_tool_note.X; - pcb_crosshair.AttachedBox.Point1.Y = pcb_tool_note.Y; - } - pcb_notify_crosshair_change(pcb_true); - } - - if (pcb_crosshair.extobj_edit != NULL) { - pcb_extobj_float_geo(pcb_crosshair.extobj_edit); - pcb_gui->invalidate_all(pcb_gui); - } -} - -void pcb_tool_arrow_notify_mode(pcb_hidlib_t *hl) -{ - void *ptr1, *ptr2, *ptr3; - int otype, type; - int test; - pcb_hidval_t hv; - - pcb_tool_note.Click = pcb_true; - /* do something after click time */ - hv.ptr = hl; - pcb_gui->add_timer(pcb_gui, click_timer_cb, conf_core.editor.click_time, hv); - - /* see if we clicked on something already selected - * (pcb_tool_note.Moving) or clicked on a MOVE_TYPE - * (pcb_tool_note.Hit) - */ - for (test = (PCB_SELECT_TYPES | PCB_MOVE_TYPES | PCB_OBJ_FLOATER | PCB_LOOSE_SUBC(PCB)) & ~PCB_OBJ_RAT; test; test &= ~otype) { - /* grab object/point (e.g. line endpoint) for edit */ - otype = type = pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, test, &ptr1, &ptr2, &ptr3); - if (otype == PCB_OBJ_ARC_POINT) { /* ignore arc endpoints if arc radius is 0 (so arc center is grabbed) */ - pcb_arc_t *arc = (pcb_arc_t *)ptr2; - if ((arc->Width == 0) && (arc->Height == 0)) - continue; - } - if (!pcb_tool_note.Hit && (type & PCB_MOVE_TYPES) && !PCB_FLAG_TEST(PCB_FLAG_LOCK, (pcb_any_obj_t *) ptr2)) { - pcb_tool_note.Hit = type; - pcb_tool_note.ptr1 = ptr1; - pcb_tool_note.ptr2 = ptr2; - pcb_tool_note.ptr3 = ptr3; - pcb_crosshair.AttachedObject.tx = pcb_tool_note.X; - pcb_crosshair.AttachedObject.ty = pcb_tool_note.Y; - } - if (!pcb_tool_note.Moving && (type & (PCB_SELECT_TYPES | PCB_LOOSE_SUBC(PCB))) && PCB_FLAG_TEST(PCB_FLAG_SELECTED, (pcb_any_obj_t *) ptr2)) { - pcb_tool_note.Moving = pcb_true; - /* remember where the user clicked to start this op */ - pcb_crosshair.AttachedObject.tx = pcb_crosshair.AttachedObject.X = pcb_tool_note.X; - pcb_crosshair.AttachedObject.ty = pcb_crosshair.AttachedObject.Y = pcb_tool_note.Y; - } - if ((pcb_tool_note.Hit && pcb_tool_note.Moving) || type == PCB_OBJ_VOID) - return; - } -} - -void pcb_tool_arrow_release_mode(pcb_hidlib_t *hl) -{ - pcb_box_t box; - pcb_board_t *pcb = (pcb_board_t *)hl; - - if (pcb_tool_note.Click) { - pcb_box_t box; - - box.X1 = -PCB_MAX_COORD; - box.Y1 = -PCB_MAX_COORD; - box.X2 = PCB_MAX_COORD; - box.Y2 = PCB_MAX_COORD; - - pcb_tool_note.Click = pcb_false; /* inhibit timer action */ - pcb_undo_save_serial(); - /* unselect first if shift key not down */ - if (!pcb_gui->shift_is_pressed(pcb_gui)) { - if (pcb_select_block(pcb, &box, pcb_false, pcb_false, pcb_false)) - pcb_board_set_changed_flag(pcb_true); - if (pcb_tool_note.Moving) { - pcb_tool_note.Moving = 0; - pcb_tool_note.Hit = 0; - return; - } - } - /* Restore the SN so that if we select something the deselect/select combo - gets the same SN. */ - pcb_undo_restore_serial(); - if (pcb_select_object(PCB)) - pcb_board_set_changed_flag(pcb_true); - else - pcb_undo_inc_serial(); /* We didn't select anything new, so, the deselection should get its own SN. */ - pcb_tool_note.Hit = 0; - pcb_tool_note.Moving = 0; - } - else if (pcb_crosshair.AttachedBox.State == PCB_CH_STATE_SECOND) { - box.X1 = pcb_crosshair.AttachedBox.Point1.X; - box.Y1 = pcb_crosshair.AttachedBox.Point1.Y; - box.X2 = pcb_crosshair.AttachedBox.Point2.X; - box.Y2 = pcb_crosshair.AttachedBox.Point2.Y; - - pcb_undo_restore_serial(); - if (pcb_select_block(pcb, &box, pcb_true, pcb_true, pcb_false)) - pcb_board_set_changed_flag(pcb_true); - else if (pcb_bumped) - pcb_undo_inc_serial(); - pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; - } -} - -void pcb_tool_arrow_adjust_attached_objects(pcb_hidlib_t *hl) -{ - if (pcb_crosshair.AttachedBox.State) { - pcb_crosshair.AttachedBox.Point2.X = pcb_crosshair.X; - pcb_crosshair.AttachedBox.Point2.Y = pcb_crosshair.Y; - } -} - -/* XPM */ -static const char *arrow_icon[] = { -/* columns rows colors chars-per-pixel */ -"21 21 3 1", -" c #000000", -". c #6EA5D7", -"o c None", -/* pixels */ -"oo .. ooooooooooooooo", -"oo .... ooooooooooooo", -"ooo ...... oooooooooo", -"ooo ........ oooooooo", -"ooo ....... ooooooooo", -"oooo ..... oooooooooo", -"oooo ...... ooooooooo", -"ooooo .. ... oooooooo", -"ooooo . o ... ooooooo", -"oooooooooo ... oooooo", -"ooooooooooo .. oooooo", -"oooooooooooo ooooooo", -"ooooooooooooooooooooo", -"ooo ooo ooo ooo", -"oo o oo ooo oo ooo oo", -"oo o oo ooo oo ooo oo", -"o ooo o ooo ooo", -"o ooo o ooo oo ooo oo", -"o o ooo oo ooo oo", -"o ooo o ooo oo ooo oo", -"o ooo o ooo oo ooo oo" -}; - -pcb_tool_t pcb_tool_arrow = { - "arrow", NULL, NULL, 10, arrow_icon, PCB_TOOL_CURSOR_NAMED("left_ptr"), 0, - NULL, - pcb_tool_arrow_uninit, - pcb_tool_arrow_notify_mode, - pcb_tool_arrow_release_mode, - pcb_tool_arrow_adjust_attached_objects, - NULL, - NULL, - NULL, - - pcb_true -}; Index: trunk/src/tool_polyhole.h =================================================================== --- trunk/src/tool_polyhole.h (revision 29303) +++ trunk/src/tool_polyhole.h (nonexistent) @@ -1,8 +0,0 @@ -extern pcb_tool_t pcb_tool_polyhole; - -void pcb_tool_polyhole_uninit(void); -void pcb_tool_polyhole_notify_mode(pcb_hidlib_t *hl); -void pcb_tool_polyhole_adjust_attached_objects(pcb_hidlib_t *hl); -void pcb_tool_polyhole_draw_attached(pcb_hidlib_t *hl); -pcb_bool pcb_tool_polyhole_undo_act(pcb_hidlib_t *hl); -pcb_bool pcb_tool_polyhole_redo_act(pcb_hidlib_t *hl); Index: trunk/src/tool_arc.c =================================================================== --- trunk/src/tool_arc.c (revision 29303) +++ trunk/src/tool_arc.c (nonexistent) @@ -1,239 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" - -#include "conf_core.h" -#include - -#include "board.h" -#include "crosshair.h" -#include "data.h" -#include "draw.h" -#include "draw_wireframe.h" -#include "search.h" -#include "tool.h" -#include "undo.h" - -#include "obj_arc_draw.h" - - -void pcb_tool_arc_init(void) -{ - pcb_notify_crosshair_change(pcb_false); - if (pcb_tool_prev_id == PCB_MODE_LINE && pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST) { - pcb_crosshair.AttachedLine.State = PCB_CH_STATE_FIRST; - pcb_crosshair.AttachedBox.State = PCB_CH_STATE_SECOND; - pcb_crosshair.AttachedBox.Point1.X = pcb_crosshair.AttachedBox.Point2.X = pcb_crosshair.AttachedLine.Point1.X; - pcb_crosshair.AttachedBox.Point1.Y = pcb_crosshair.AttachedBox.Point2.Y = pcb_crosshair.AttachedLine.Point1.Y; - pcb_tool_adjust_attached_objects(NULL); - } - pcb_notify_crosshair_change(pcb_true); -} - -void pcb_tool_arc_uninit(void) -{ - pcb_notify_crosshair_change(pcb_false); - pcb_added_lines = 0; - if (pcb_tool_next_id != PCB_MODE_LINE) { - pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; - if (!pcb_marked.user_placed) - pcb_crosshair_set_local_ref(0, 0, pcb_false); - } - pcb_notify_crosshair_change(pcb_true); -} - -void pcb_tool_arc_notify_mode(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - - switch (pcb_crosshair.AttachedBox.State) { - case PCB_CH_STATE_FIRST: - pcb_crosshair.AttachedBox.Point1.X = pcb_crosshair.AttachedBox.Point2.X = pcb_tool_note.X; - pcb_crosshair.AttachedBox.Point1.Y = pcb_crosshair.AttachedBox.Point2.Y = pcb_tool_note.Y; - pcb_crosshair.AttachedBox.State = PCB_CH_STATE_SECOND; - break; - - case PCB_CH_STATE_SECOND: - case PCB_CH_STATE_THIRD: - { - pcb_arc_t *arc; - pcb_coord_t wx, wy; - pcb_angle_t sa, dir; - - wx = pcb_tool_note.X - pcb_crosshair.AttachedBox.Point1.X; - wy = pcb_tool_note.Y - pcb_crosshair.AttachedBox.Point1.Y; - if (PCB_XOR(pcb_crosshair.AttachedBox.otherway, coord_abs(wy) > coord_abs(wx))) { - pcb_crosshair.AttachedBox.Point2.X = pcb_crosshair.AttachedBox.Point1.X + coord_abs(wy) * PCB_SGNZ(wx); - sa = (wx >= 0) ? 0 : 180; - dir = (PCB_SGNZ(wx) == PCB_SGNZ(wy)) ? 90 : -90; - } - else { - pcb_crosshair.AttachedBox.Point2.Y = pcb_crosshair.AttachedBox.Point1.Y + coord_abs(wx) * PCB_SGNZ(wy); - sa = (wy >= 0) ? -90 : 90; - dir = (PCB_SGNZ(wx) == PCB_SGNZ(wy)) ? -90 : 90; - wy = wx; - } - if (coord_abs(wy) > 0 && (arc = pcb_arc_new(pcb_loose_subc_layer(pcb, PCB_CURRLAYER(pcb), pcb_true), - pcb_crosshair.AttachedBox.Point2.X, - pcb_crosshair.AttachedBox.Point2.Y, - coord_abs(wy), - coord_abs(wy), - sa, - dir, - conf_core.design.line_thickness, - 2 * conf_core.design.clearance, - pcb_flag_make(conf_core.editor.clear_line ? PCB_FLAG_CLEARLINE : 0), pcb_true))) { - pcb_obj_add_attribs((pcb_any_obj_t *)arc, pcb->pen_attr, NULL); - pcb_arc_get_end(arc, 1, &pcb_crosshair.AttachedBox.Point2.X, &pcb_crosshair.AttachedBox.Point2.Y); - pcb_crosshair.AttachedBox.Point1.X = pcb_crosshair.AttachedBox.Point2.X; - pcb_crosshair.AttachedBox.Point1.Y = pcb_crosshair.AttachedBox.Point2.Y; - pcb_undo_add_obj_to_create(PCB_OBJ_ARC, PCB_CURRLAYER(pcb), arc, arc); - pcb_undo_inc_serial(); - pcb_added_lines++; - pcb_arc_invalidate_draw(PCB_CURRLAYER(pcb), arc); - pcb_subc_as_board_update(pcb); - pcb_draw(); - pcb_crosshair.AttachedBox.State = PCB_CH_STATE_THIRD; - } - break; - } - } -} - -void pcb_tool_arc_adjust_attached_objects(pcb_hidlib_t *hl) -{ - pcb_crosshair.AttachedBox.otherway = pcb_gui->shift_is_pressed(pcb_gui); -} - -void pcb_tool_arc_draw_attached(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - - if (pcb_crosshair.AttachedBox.State != PCB_CH_STATE_FIRST) { - pcb_xordraw_attached_arc(conf_core.design.line_thickness); - if (conf_core.editor.show_drc) { - pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.drc); - pcb_xordraw_attached_arc(conf_core.design.line_thickness + 2 * (conf_core.design.bloat + 1)); - pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.attached); - } - } - else { - /* Draw a circle (0 length line) to show where the arc will start when placed */ - if(PCB_CURRLAYER(pcb)) - pcb_render->set_color(pcb_crosshair.GC, &PCB_CURRLAYER(pcb)->meta.real.color); - - pcb_draw_wireframe_line(pcb_crosshair.GC, - pcb_crosshair.X, pcb_crosshair.Y, - pcb_crosshair.X, pcb_crosshair.Y, - conf_core.design.line_thickness, 0); - - if(conf_core.editor.show_drc) { - pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.drc); - pcb_draw_wireframe_line(pcb_crosshair.GC, - pcb_crosshair.X, pcb_crosshair.Y, - pcb_crosshair.X, pcb_crosshair.Y, - conf_core.design.line_thickness + (2 * conf_core.design.bloat), 0); - pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.attached); - } - } - -} - -pcb_bool pcb_tool_arc_undo_act(pcb_hidlib_t *hl) -{ - if (pcb_crosshair.AttachedBox.State == PCB_CH_STATE_SECOND) { - pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; - pcb_notify_crosshair_change(pcb_true); - return pcb_false; - } - if (pcb_crosshair.AttachedBox.State == PCB_CH_STATE_THIRD) { - void *ptr1, *ptr2, *ptr3; - /* guaranteed to succeed */ - pcb_search_obj_by_location(PCB_OBJ_ARC, &ptr1, &ptr2, &ptr3, - pcb_crosshair.AttachedBox.Point1.X, pcb_crosshair.AttachedBox.Point1.Y, 0); - pcb_arc_get_end((pcb_arc_t *) ptr2, 0, &pcb_crosshair.AttachedBox.Point2.X, &pcb_crosshair.AttachedBox.Point2.Y); - pcb_crosshair.AttachedBox.Point1.X = pcb_crosshair.AttachedBox.Point2.X; - pcb_crosshair.AttachedBox.Point1.Y = pcb_crosshair.AttachedBox.Point2.Y; - pcb_tool_adjust_attached_objects(hl); - if (--pcb_added_lines == 0) - pcb_crosshair.AttachedBox.State = PCB_CH_STATE_SECOND; - } - return pcb_true; -} - -/* XPM */ -static const char *arc_icon[] = { -/* columns rows colors chars-per-pixel */ -"21 21 3 1", -" c #000000", -". c #6EA5D7", -"o c None", -/* pixels */ -"ooooo.ooooooooooooooo", -"ooooo.ooooooooooooooo", -"ooooo.ooooooooooooooo", -"ooooo.ooooooooooooooo", -"oooooo.oooooooooooooo", -"oooooo.oooooooooooooo", -"ooooooo.ooooooooooooo", -"ooooooo..oooooooooooo", -"oooooooo..ooooooooooo", -"oooooooooo..ooooooooo", -"oooooooooooo....ooooo", -"ooooooooooooooooooooo", -"ooo oooo oooo oo", -"oo o ooo ooo oo ooo o", -"oo o ooo ooo oo ooo o", -"o ooo oo ooo ooooo", -"o oo ooooo ooooo", -"o ooo oo o oooo ooooo", -"o ooo oo oo ooo ooo o", -"o ooo oo ooo ooo oo", -"ooooooooooooooooooooo" -}; - -pcb_tool_t pcb_tool_arc = { - "arc", NULL, NULL, 100, arc_icon, PCB_TOOL_CURSOR_NAMED("question_arrow"), 0, - pcb_tool_arc_init, - pcb_tool_arc_uninit, - pcb_tool_arc_notify_mode, - NULL, - pcb_tool_arc_adjust_attached_objects, - pcb_tool_arc_draw_attached, - pcb_tool_arc_undo_act, - NULL, - - pcb_false -}; Index: trunk/src/tool_arc.h =================================================================== --- trunk/src/tool_arc.h (revision 29303) +++ trunk/src/tool_arc.h (nonexistent) @@ -1,8 +0,0 @@ -extern pcb_tool_t pcb_tool_arc; - -void pcb_tool_arc_init(void); -void pcb_tool_arc_uninit(void); -void pcb_tool_arc_notify_mode(pcb_hidlib_t *hl); -void pcb_tool_arc_adjust_attached_objects(pcb_hidlib_t *hl); -void pcb_tool_arc_draw_attached(pcb_hidlib_t *hl); -pcb_bool pcb_tool_arc_undo_act(pcb_hidlib_t *hl); Index: trunk/src/tool_rectangle.h =================================================================== --- trunk/src/tool_rectangle.h (revision 29303) +++ trunk/src/tool_rectangle.h (nonexistent) @@ -1,6 +0,0 @@ -extern pcb_tool_t pcb_tool_rectangle; - -void pcb_tool_rectangle_uninit(void); -void pcb_tool_rectangle_notify_mode(pcb_hidlib_t *hl); -void pcb_tool_rectangle_adjust_attached_objects(pcb_hidlib_t *hl); -pcb_bool pcb_tool_rectangle_undo_act(pcb_hidlib_t *hl); Index: trunk/src/tool_rotate.c =================================================================== --- trunk/src/tool_rotate.c (revision 29303) +++ trunk/src/tool_rotate.c (nonexistent) @@ -1,109 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" -#include "conf_core.h" - -#include -#include "board.h" -#include "rotate.h" -#include "tool.h" - - -void pcb_tool_rotate_notify_mode(pcb_hidlib_t *hl) -{ - pcb_screen_obj_rotate90((pcb_board_t *)hl, pcb_tool_note.X, pcb_tool_note.Y, - pcb_gui->shift_is_pressed(pcb_gui) ? (conf_core.editor.show_solder_side ? 1 : 3) : (conf_core.editor.show_solder_side ? 3 : 1)); - pcb_subc_as_board_update(PCB); -} - -/* XPM */ -static const char *rot_icon[] = { -/* columns rows colors chars-per-pixel */ -"21 21 4 1", -" c black", -". c #6EA5D7", -"X c gray100", -"o c None", -/* pixels */ -"ooooooooooo.ooooooooo", -"oooooooooo..ooooooooo", -"ooooooooo....oooooooo", -"oooooooooo..o.ooooooo", -"ooooooooooo.oo.oooooo", -"oooooooooooooo.oooooo", -"oooooooooooooo.oooooo", -"oooooooooooooo.oooooo", -"oooooooooooooo.oooooo", -"ooooooooooooo.ooooooo", -"oooooooooooo.oooooooo", -"oooooooooo..ooooooooo", -"ooooooooooooooooooooo", -"ooo ooo oo o", -"ooo ooo o ooo ooo ooo", -"ooo ooo o ooo ooo ooo", -"ooo oo ooo ooo ooo", -"ooo ooo ooo ooo ooo", -"ooo o oo ooo ooo ooo", -"ooo oo o ooo ooo ooo", -"ooo ooo oo oooo ooo" -}; - -#define rotateIcon_width 16 -#define rotateIcon_height 16 -static unsigned char rotateIcon_bits[] = { - 0xf0, 0x03, 0xf8, 0x87, 0x0c, 0xcc, 0x06, 0xf8, 0x03, 0xb0, 0x01, 0x98, - 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x19, 0x80, 0x0d, 0xc0, - 0x1f, 0x60, 0x3b, 0x30, 0xe1, 0x3f, 0xc0, 0x0f}; - -#define rotateMask_width 16 -#define rotateMask_height 16 -static unsigned char rotateMask_bits[] = { - 0xf0, 0x03, 0xf8, 0x87, 0x0c, 0xcc, 0x06, 0xf8, 0x03, 0xf0, 0x01, 0xf8, - 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x1f, 0x80, 0x0f, 0xc0, - 0x1f, 0x60, 0x3b, 0x30, 0xe1, 0x3f, 0xc0, 0x0f}; - -pcb_tool_t pcb_tool_rotate = { - "rotate", NULL, NULL, 100, rot_icon, PCB_TOOL_CURSOR_XBM(rotateIcon_bits, rotateMask_bits), 0, - NULL, - NULL, - pcb_tool_rotate_notify_mode, - NULL, - NULL, - NULL, - NULL, - NULL, - - pcb_true -}; Index: trunk/src/tool_rotate.h =================================================================== --- trunk/src/tool_rotate.h (revision 29303) +++ trunk/src/tool_rotate.h (nonexistent) @@ -1,3 +0,0 @@ -extern pcb_tool_t pcb_tool_rotate; - -void pcb_tool_rotate_notify_mode(pcb_hidlib_t *hl); Index: trunk/src/tool_insert.c =================================================================== --- trunk/src/tool_insert.c (revision 29303) +++ trunk/src/tool_insert.c (nonexistent) @@ -1,180 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" - -#include "board.h" -#include "crosshair.h" -#include "insert.h" -#include "polygon.h" -#include "search.h" -#include "tool.h" - - -static struct { - pcb_poly_t *poly; - pcb_line_t line; -} fake; - -static pcb_point_t InsertedPoint; -static pcb_cardinal_t polyIndex = 0; - - -void pcb_tool_insert_uninit(void) -{ - pcb_notify_crosshair_change(pcb_false); - pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; - pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; - pcb_crosshair.extobj_edit = NULL; - pcb_notify_crosshair_change(pcb_true); -} - -void pcb_tool_insert_notify_mode(pcb_hidlib_t *hl) -{ - switch (pcb_crosshair.AttachedObject.State) { - /* first notify, lookup object */ - case PCB_CH_STATE_FIRST: - pcb_crosshair.AttachedObject.Type = - pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, PCB_INSERT_TYPES, - &pcb_crosshair.AttachedObject.Ptr1, &pcb_crosshair.AttachedObject.Ptr2, &pcb_crosshair.AttachedObject.Ptr3); - - if (pcb_crosshair.AttachedObject.Type != PCB_OBJ_VOID) { - pcb_any_obj_t *obj = (pcb_any_obj_t *)pcb_crosshair.AttachedObject.Ptr2; - if (PCB_FLAG_TEST(PCB_FLAG_LOCK, obj)) { - pcb_message(PCB_MSG_WARNING, "Sorry, %s object is locked\n", pcb_obj_type_name(obj->type)); - pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; - pcb_crosshair.extobj_edit = NULL; - break; - } - else { - /* get starting point of nearest segment */ - if (pcb_crosshair.AttachedObject.Type == PCB_OBJ_POLY) { - fake.poly = (pcb_poly_t *) pcb_crosshair.AttachedObject.Ptr2; - polyIndex = pcb_poly_get_lowest_distance_point(fake.poly, pcb_tool_note.X, pcb_tool_note.Y); - fake.line.Point1 = fake.poly->Points[polyIndex]; - fake.line.Point2 = fake.poly->Points[pcb_poly_contour_prev_point(fake.poly, polyIndex)]; - pcb_crosshair.AttachedObject.Ptr2 = &fake.line; - - } - pcb_crosshair.AttachedObject.State = PCB_CH_STATE_SECOND; - InsertedPoint = *pcb_adjust_insert_point(); - } - } - break; - - /* second notify, insert new point into object */ - case PCB_CH_STATE_SECOND: - if (pcb_crosshair.AttachedObject.Type == PCB_OBJ_POLY) - pcb_insert_point_in_object(PCB_OBJ_POLY, - pcb_crosshair.AttachedObject.Ptr1, fake.poly, - &polyIndex, InsertedPoint.X, InsertedPoint.Y, pcb_false, pcb_false); - else - pcb_insert_point_in_object(pcb_crosshair.AttachedObject.Type, - pcb_crosshair.AttachedObject.Ptr1, - pcb_crosshair.AttachedObject.Ptr2, &polyIndex, InsertedPoint.X, InsertedPoint.Y, pcb_false, pcb_false); - pcb_board_set_changed_flag(pcb_true); - - /* reset identifiers */ - pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; - pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; - pcb_crosshair.extobj_edit = NULL; - break; - } -} - -void pcb_tool_insert_adjust_attached_objects(pcb_hidlib_t *hl) -{ - pcb_point_t *pnt; - pnt = pcb_adjust_insert_point(); - if (pnt) - InsertedPoint = *pnt; -} - -void pcb_tool_insert_draw_attached(pcb_hidlib_t *hl) -{ - pcb_xordraw_insert_pt_obj(); -} - -pcb_bool pcb_tool_insert_undo_act(pcb_hidlib_t *hl) -{ - /* don't allow undo in the middle of an operation */ - if (pcb_crosshair.AttachedObject.State != PCB_CH_STATE_FIRST) - return pcb_false; - return pcb_true; -} - -/* XPM */ -static const char *ins_icon[] = { -/* columns rows colors chars-per-pixel */ -"21 21 3 1", -" c #000000", -". c #6EA5D7", -"o c None", -/* pixels */ -"oooooo...oooooooooooo", -"ooooo.ooo.ooooooooooo", -"ooooo.o.o.ooooooooooo", -"oooooo....ooooooooooo", -"ooooooooooooooooooooo", -"oooo ooooo oooooooo", -"ooooooooooooooooooooo", -"oo...ooooooooooo...oo", -"o.oo..ooooooooo.ooo.o", -"o.o o...........o o.o", -"o.ooo.ooooooooo.ooo.o", -"oo...ooooooooooo...oo", -"ooooooooooooooooooooo", -"ooo o ooo oo ooo", -"oooo oo ooo o ooooooo", -"oooo oo oo o ooooooo", -"oooo oo o o oo oooo", -"oooo oo oo ooooo ooo", -"oooo oo ooo ooooo ooo", -"oooo oo ooo ooooo ooo", -"ooo o ooo o oooo" -}; - -pcb_tool_t pcb_tool_insert = { - "insert", NULL, NULL, 100, ins_icon, PCB_TOOL_CURSOR_NAMED("dotbox"), 0, - NULL, - pcb_tool_insert_uninit, - pcb_tool_insert_notify_mode, - NULL, - pcb_tool_insert_adjust_attached_objects, - pcb_tool_insert_draw_attached, - pcb_tool_insert_undo_act, - NULL, - - pcb_true -}; Index: trunk/src/tool_insert.h =================================================================== --- trunk/src/tool_insert.h (revision 29303) +++ trunk/src/tool_insert.h (nonexistent) @@ -1,7 +0,0 @@ -extern pcb_tool_t pcb_tool_insert; - -void pcb_tool_insert_uninit(void); -void pcb_tool_insert_notify_mode(pcb_hidlib_t *hl); -void pcb_tool_insert_adjust_attached_objects(pcb_hidlib_t *hl); -void pcb_tool_insert_draw_attached(pcb_hidlib_t *hl); -pcb_bool pcb_tool_insert_undo_act(pcb_hidlib_t *hl); Index: trunk/src/tool_arrow.h =================================================================== --- trunk/src/tool_arrow.h (revision 29303) +++ trunk/src/tool_arrow.h (nonexistent) @@ -1,6 +0,0 @@ -extern pcb_tool_t pcb_tool_arrow; - -void pcb_tool_arrow_uninit(void); -void pcb_tool_arrow_notify_mode(pcb_hidlib_t *hl); -void pcb_tool_arrow_release_mode(pcb_hidlib_t *hl); -void pcb_tool_arrow_adjust_attached_objects(pcb_hidlib_t *hl); Index: trunk/src/tool_remove.c =================================================================== --- trunk/src/tool_remove.c (revision 29303) +++ trunk/src/tool_remove.c (nonexistent) @@ -1,129 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" - -#include "board.h" -#include -#include -#include "undo.h" -#include "remove.h" -#include "search.h" -#include "obj_rat.h" -#include "tool.h" - - -void pcb_tool_remove_notify_mode(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - void *ptr1, *ptr2, *ptr3; - pcb_any_obj_t *obj; - int type; - - if ((type = pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, PCB_REMOVE_TYPES | PCB_LOOSE_SUBC(PCB) | PCB_OBJ_FLOATER, &ptr1, &ptr2, &ptr3)) != PCB_OBJ_VOID) { - obj = (pcb_any_obj_t *)ptr2; - if (PCB_FLAG_TEST(PCB_FLAG_LOCK, obj)) { - pcb_message(PCB_MSG_WARNING, "Sorry, %s object is locked\n", pcb_obj_type_name(obj->type)); - return; - } - - if (type == PCB_OBJ_SUBC) { - if(pcb->is_footprint) { - pcb_message(PCB_MSG_WARNING, "Can not remove the subcircuit being edited in the footprint edit mode\n"); - return; - } - } - - obj = ptr2; - pcb_rat_update_obj_removed(pcb, obj); - - /* preserve original parent over the board layer pcb_search_screen operated on - - this is essential for undo: it needs to put back the object to the original - layer (e.g. inside a subc) instead of on the board layer */ - if (obj->parent_type == PCB_PARENT_LAYER) - ptr1 = obj->parent.layer; - else if (obj->parent_type == PCB_PARENT_DATA) - ptr1 = obj->parent.data; - - pcb_remove_object(type, ptr1, ptr2, ptr3); - pcb_undo_inc_serial(); - pcb_subc_as_board_update(PCB); - pcb_board_set_changed_flag(pcb_true); - } -} - -/* XPM */ -static const char *del_icon[] = { -/* columns rows colors chars-per-pixel */ -"21 21 3 1", -" c black", -". c gray100", -"X c None", -/* pixels */ -"XXX XXXXXXXXXXXX XXXX", -"XXXX XXX XXX XXXXX", -"XXXXX X X XXXXXX", -"XXXXXX XX XX XXXXXXX", -"XXXXX XX XX XXXXXX", -"XXXXX XXXXXX", -"XXXXXX XXXXXXX", -"XXXXXXX XX XXXXXXXX", -"XXXXXXX XX XXXXXXXXX", -"XXXXXX X XX XXXXXXXX", -"XXXX XX X XXXXXX", -"XX XXXXX XXXX XXXX", -"XXXXXXXXXXXXXXXXXXXXX", -"XX XX X XXXXX", -"XXX XXX X XXXXX XXXXX", -"XXX XXX X XXXXX XXXXX", -"XXX XXX X XXXXX XXXXX", -"XXX XXX X XX XXXXX", -"XXX XXX X XXXXX XXXXX", -"XXX XXX X XXXXX XXXXX", -"XX XX X X" -}; - -pcb_tool_t pcb_tool_remove = { - "remove", NULL, NULL, 100, del_icon, PCB_TOOL_CURSOR_NAMED("pirate"), 0, - NULL, - NULL, - pcb_tool_remove_notify_mode, - NULL, - NULL, - NULL, - NULL, - NULL, - - pcb_true -}; Index: trunk/src/tool_remove.h =================================================================== --- trunk/src/tool_remove.h (revision 29303) +++ trunk/src/tool_remove.h (nonexistent) @@ -1,3 +0,0 @@ -extern pcb_tool_t pcb_tool_remove; - -void pcb_tool_remove_notify_mode(pcb_hidlib_t *hl); Index: trunk/src/tool_rectangle.c =================================================================== --- trunk/src/tool_rectangle.c (revision 29303) +++ trunk/src/tool_rectangle.c (nonexistent) @@ -1,161 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" -#include "conf_core.h" - -#include "board.h" -#include "crosshair.h" -#include "data.h" -#include "draw.h" -#include "tool.h" -#include "undo.h" - -#include "obj_poly_draw.h" - - -void pcb_tool_rectangle_uninit(void) -{ - pcb_notify_crosshair_change(pcb_false); - pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; - pcb_notify_crosshair_change(pcb_true); -} - -void pcb_tool_rectangle_notify_mode(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - - /* do update of position */ - pcb_tool_notify_block(); - - /* create rectangle if both corners are determined - * and width, height are != 0 - */ - if (pcb_crosshair.AttachedBox.State == PCB_CH_STATE_THIRD && - pcb_crosshair.AttachedBox.Point1.X != pcb_crosshair.AttachedBox.Point2.X && - pcb_crosshair.AttachedBox.Point1.Y != pcb_crosshair.AttachedBox.Point2.Y) { - pcb_poly_t *polygon; - pcb_layer_t *layer = pcb_loose_subc_layer(pcb, PCB_CURRLAYER(pcb), pcb_true); - - int flags = PCB_FLAG_CLEARPOLY; - if (conf_core.editor.full_poly) - flags |= PCB_FLAG_FULLPOLY; - if (conf_core.editor.clear_polypoly) - flags |= PCB_FLAG_CLEARPOLYPOLY; - if ((polygon = pcb_poly_new_from_rectangle(layer, - pcb_crosshair.AttachedBox.Point1.X, - pcb_crosshair.AttachedBox.Point1.Y, - pcb_crosshair.AttachedBox.Point2.X, - pcb_crosshair.AttachedBox.Point2.Y, - 2 * conf_core.design.clearance, - pcb_flag_make(flags))) != NULL) { - pcb_obj_add_attribs((pcb_any_obj_t *)polygon, pcb->pen_attr, NULL); - pcb_undo_add_obj_to_create(PCB_OBJ_POLY, layer, polygon, polygon); - pcb_undo_inc_serial(); - pcb_poly_invalidate_draw(layer, polygon); - pcb_draw(); - } - - /* reset state to 'first corner' */ - pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; - pcb_subc_as_board_update(PCB); - } -} - -void pcb_tool_rectangle_adjust_attached_objects(pcb_hidlib_t *hl) -{ - switch (pcb_crosshair.AttachedBox.State) { - case PCB_CH_STATE_SECOND: /* one corner is selected */ - { - /* update coordinates */ - pcb_crosshair.AttachedBox.Point2.X = pcb_crosshair.X; - pcb_crosshair.AttachedBox.Point2.Y = pcb_crosshair.Y; - break; - } - } -} - -pcb_bool pcb_tool_rectangle_anydo_act(pcb_hidlib_t *hl) -{ - /* don't allow undo in the middle of an operation */ - if (pcb_crosshair.AttachedBox.State != PCB_CH_STATE_FIRST) - return pcb_false; - return pcb_true; -} - -/* XPM */ -static const char *rect_icon[] = { -/* columns rows colors chars-per-pixel */ -"21 21 3 1", -" c black", -". c #6EA5D7", -"o c None", -/* pixels */ -"ooooooooooooooooooooo", -"oo..................o", -"oo..................o", -"oo..................o", -"oo..................o", -"oo..................o", -"oo..................o", -"oo..................o", -"oo..................o", -"oo..................o", -"ooooooooooooooooooooo", -"ooooooooooooooooooooo", -"o oo oo oo ", -"o oo o oooo oo ooo oo", -"o oo o oooo oooooo oo", -"o oo oooo oooooo oo", -"o o oo oo oooooo oo", -"o oo o oooo oooooo oo", -"o oo o oooo oo ooo oo", -"o oo o oo oooo oo", -"ooooooooooooooooooooo" -}; - - -pcb_tool_t pcb_tool_rectangle = { - "rectangle", NULL, NULL, 100, rect_icon, PCB_TOOL_CURSOR_NAMED("ul_angle"), 0, - NULL, - pcb_tool_rectangle_uninit, - pcb_tool_rectangle_notify_mode, - NULL, - pcb_tool_rectangle_adjust_attached_objects, - NULL, - pcb_tool_rectangle_anydo_act, - pcb_tool_rectangle_anydo_act, - - pcb_false -}; Index: trunk/src/tool_line.c =================================================================== --- trunk/src/tool_line.c (revision 29303) +++ trunk/src/tool_line.c (nonexistent) @@ -1,522 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton - * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas - * - * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - * - * Old contact info: - * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include "config.h" - -#include "conf_core.h" -#include - -#include "board.h" -#include "crosshair.h" -#include "data.h" -#include "draw.h" -#include "draw_wireframe.h" -#include "find.h" -#include "obj_line.h" -#include "obj_subc.h" -#include "search.h" -#include "tool.h" -#include "undo.h" -#include "netlist.h" - -#include "obj_line_draw.h" -#include "obj_pstk_draw.h" -#include "obj_rat_draw.h" -#include "route_draw.h" - -TODO("pstk: remove this when via is removed and the padstack is created from style directly") -#include "src_plugins/lib_compat_help/pstk_compat.h" - -static pcb_layer_t *last_layer; - - -void pcb_tool_line_init(void) -{ - pcb_notify_crosshair_change(pcb_false); - if (pcb_tool_prev_id == PCB_MODE_ARC && pcb_crosshair.AttachedBox.State != PCB_CH_STATE_FIRST) { - pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; - pcb_crosshair.AttachedLine.State = PCB_CH_STATE_SECOND; - pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X = pcb_crosshair.AttachedBox.Point1.X; - pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y = pcb_crosshair.AttachedBox.Point1.Y; - pcb_tool_adjust_attached_objects(NULL); - } - else { - if (conf_core.editor.auto_drc) { - if (pcb_data_clear_flag(PCB->Data, PCB_FLAG_FOUND, 1, 1) > 0) { - pcb_undo_inc_serial(); - pcb_draw(); - } - } - } - pcb_notify_crosshair_change(pcb_true); -} - -void pcb_tool_line_uninit(void) -{ - pcb_notify_crosshair_change(pcb_false); - pcb_added_lines = 0; - pcb_route_reset(&pcb_crosshair.Route); - if (pcb_tool_next_id != PCB_MODE_ARC) { - pcb_crosshair.AttachedLine.State = PCB_CH_STATE_FIRST; - if (!pcb_marked.user_placed) - pcb_crosshair_set_local_ref(0, 0, pcb_false); - } - pcb_notify_crosshair_change(pcb_true); -} - -/* creates points of a line (when clicked) */ -static void notify_line(pcb_hidlib_t *hl) -{ - int type = PCB_OBJ_VOID; - void *ptr1, *ptr2, *ptr3; - pcb_board_t *pcb = (pcb_board_t *)hl; - - if ((!pcb_marked.status || conf_core.editor.local_ref) && !pcb_marked.user_placed) - pcb_crosshair_set_local_ref(pcb_crosshair.X, pcb_crosshair.Y, pcb_true); - switch (pcb_crosshair.AttachedLine.State) { - case PCB_CH_STATE_FIRST: /* first point */ -TODO("subc: this should work on heavy terminals too!") - if (pcb->RatDraw && pcb_search_screen(pcb_crosshair.X, pcb_crosshair.Y, PCB_OBJ_PSTK | PCB_OBJ_SUBC_PART, &ptr1, &ptr1, &ptr1) == PCB_OBJ_VOID) { - pcb_gui->beep(pcb_gui); - break; - } - if (conf_core.editor.auto_drc) { - pcb_find_t fctx; - type = pcb_search_screen(pcb_crosshair.X, pcb_crosshair.Y, PCB_OBJ_PSTK | PCB_OBJ_SUBC_PART, &ptr1, &ptr2, &ptr3); - memset(&fctx, 0, sizeof(fctx)); - fctx.flag_set = PCB_FLAG_FOUND; - fctx.flag_chg_undoable = 1; - pcb_find_from_xy(&fctx, pcb->Data, pcb_crosshair.X, pcb_crosshair.Y); - pcb_find_free(&fctx); - } - if (type == PCB_OBJ_PSTK) { - pcb_pstk_t *pstk = (pcb_pstk_t *)ptr2; - pcb_crosshair.AttachedLine.Point1.X = pstk->x; - pcb_crosshair.AttachedLine.Point1.Y = pstk->y; - } - else { - pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X = pcb_crosshair.X; - pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y = pcb_crosshair.Y; - } - pcb_crosshair.AttachedLine.State = PCB_CH_STATE_SECOND; - break; - - case PCB_CH_STATE_SECOND: - /* fall through to third state too */ - last_layer = PCB_CURRLAYER(pcb); - default: /* all following points */ - pcb_crosshair.AttachedLine.State = PCB_CH_STATE_THIRD; - break; - } -} - -void pcb_tool_line_notify_mode(pcb_hidlib_t *hl) -{ - void *ptr1, *ptr2, *ptr3; - pcb_board_t *pcb = (pcb_board_t *)hl; - - /* do update of position */ - notify_line(hl); - if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_THIRD) - return; - /* Remove anchor if clicking on start point; - * this means we can't paint 0 length lines - * which could be used for square SMD pads. - * Instead use a very small delta, or change - * the file after saving. - */ - if (pcb_crosshair.X == pcb_crosshair.AttachedLine.Point1.X && pcb_crosshair.Y == pcb_crosshair.AttachedLine.Point1.Y) { - pcb_tool_select_by_id(hl, PCB_MODE_LINE); - return; - } - - if (pcb->RatDraw) { - pcb_rat_t *line = pcb_net_create_by_rat_coords(pcb, pcb_crosshair.AttachedLine.Point1.X, pcb_crosshair.AttachedLine.Point1.Y, pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y, 1); - - if (line != NULL) { - pcb_added_lines++; - pcb_undo_add_obj_to_create(PCB_OBJ_RAT, line, line, line); - pcb_undo_inc_serial(); - pcb_rat_invalidate_draw(line); - pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X; - pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y; - pcb_draw(); - } - return; - } - else if(pcb_crosshair.Route.size > 0) - { - pcb_pstk_t *ps = NULL; - - /* place a via if vias are visible, the layer is - in a new group since the last line and there - isn't a pin already here */ -TODO("pstk #21: do not work in comp mode, use a pstk proto - scconfig also has TODO #21, fix it there too") - if (conf_core.editor.auto_via && pcb->pstk_on - && pcb_layer_get_group_(PCB_CURRLAYER(pcb)) != pcb_layer_get_group_(last_layer) - && pcb_search_obj_by_location(PCB_OBJ_CLASS_PIN, &ptr1, &ptr2, &ptr3, - pcb_crosshair.AttachedLine.Point1.X, - pcb_crosshair.AttachedLine.Point1.Y, - conf_core.design.via_thickness / 2) == - PCB_OBJ_VOID - && (pcb_layer_flags_(PCB_CURRLAYER(pcb)) & PCB_LYT_COPPER) - && (pcb_layer_flags_(last_layer) & PCB_LYT_COPPER) - && (!pcb->is_footprint) - && ((ps = pcb_pstk_new_compat_via(pcb->Data, -1, - pcb_crosshair.AttachedLine.Point1.X, - pcb_crosshair.AttachedLine.Point1.Y, - conf_core.design.via_drilling_hole, conf_core.design.via_thickness, conf_core.design.clearance, - 0, PCB_PSTK_COMPAT_ROUND, pcb_true)) != NULL)) { - pcb_obj_add_attribs((pcb_any_obj_t *)ps, pcb->pen_attr, NULL); - pcb_undo_add_obj_to_create(PCB_OBJ_PSTK, ps, ps, ps); - } - - /* Add the route to the design */ - pcb_route_apply(&pcb_crosshair.Route); - - /* move to new start point */ - pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.Route.end_point.X; - pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.Route.end_point.Y; - pcb_crosshair.AttachedLine.Point2.X = pcb_crosshair.Route.end_point.X; - pcb_crosshair.AttachedLine.Point2.Y = pcb_crosshair.Route.end_point.Y; - - /* automatic swap of line refraction after each click - should work only if refraction is in effect (no ortho, no alldir) */ - if (conf_core.editor.swap_start_direction && (conf_core.editor.line_refraction != 0) && !conf_core.editor.all_direction_lines) - pcb_conf_setf(CFR_DESIGN,"editor/line_refraction", -1, "%d",conf_core.editor.line_refraction ^ 3); - - if (conf_core.editor.orthogonal_moves) { - /* set the mark to the new starting point so ortho works as expected and we can draw a perpendicular line from here */ - pcb_grabbed.X = pcb_crosshair.Route.end_point.X; - pcb_grabbed.Y = pcb_crosshair.Route.end_point.Y; - pcb_grabbed.status = pcb_true; - } - - if (ps) - pcb_pstk_invalidate_draw(ps); - - pcb_draw(); - pcb_undo_inc_serial(); - last_layer = PCB_CURRLAYER(pcb); - } - else - /* create line if both ends are determined && length != 0 */ - { - pcb_line_t *line; - int maybe_found_flag; - - if (conf_core.editor.line_refraction - && pcb_crosshair.AttachedLine.Point1.X == - pcb_crosshair.AttachedLine.Point2.X - && pcb_crosshair.AttachedLine.Point1.Y == - pcb_crosshair.AttachedLine.Point2.Y - && (pcb_crosshair.AttachedLine.Point2.X != pcb_tool_note.X || pcb_crosshair.AttachedLine.Point2.Y != pcb_tool_note.Y)) { - /* We will only need to paint the second line segment. - Since we only check for vias on the first segment, - swap them so the non-empty segment is the first segment. */ - pcb_crosshair.AttachedLine.Point2.X = pcb_tool_note.X; - pcb_crosshair.AttachedLine.Point2.Y = pcb_tool_note.Y; - } - - if (conf_core.editor.auto_drc - && (pcb_layer_flags_(PCB_CURRLAYER(pcb)) & PCB_LYT_COPPER)) - maybe_found_flag = PCB_FLAG_FOUND; - else - maybe_found_flag = 0; - - if ((pcb_crosshair.AttachedLine.Point1.X != - pcb_crosshair.AttachedLine.Point2.X || pcb_crosshair.AttachedLine.Point1.Y != pcb_crosshair.AttachedLine.Point2.Y) - && (line = - pcb_line_new_merge(pcb_loose_subc_layer(pcb, PCB_CURRLAYER(pcb), pcb_true), - pcb_crosshair.AttachedLine.Point1.X, - pcb_crosshair.AttachedLine.Point1.Y, - pcb_crosshair.AttachedLine.Point2.X, - pcb_crosshair.AttachedLine.Point2.Y, - conf_core.design.line_thickness, - 2 * conf_core.design.clearance, - pcb_flag_make(maybe_found_flag | - (conf_core.editor.clear_line ? PCB_FLAG_CLEARLINE : 0)))) != NULL) { - pcb_pstk_t *ps = NULL; - - pcb_added_lines++; - pcb_obj_add_attribs(line, pcb->pen_attr, NULL); - pcb_undo_add_obj_to_create(PCB_OBJ_LINE, PCB_CURRLAYER(pcb), line, line); - pcb_line_invalidate_draw(PCB_CURRLAYER(pcb), line); - /* place a via if vias are visible, the layer is - in a new group since the last line and there - isn't a pin already here */ -TODO("pstk #21: do not work in comp mode, use a pstk proto - scconfig also has TODO #21, fix it there too") - if (pcb->pstk_on - && pcb_layer_get_group_(PCB_CURRLAYER(pcb)) != pcb_layer_get_group_(last_layer) - && (pcb_layer_flags_(PCB_CURRLAYER(pcb)) & PCB_LYT_COPPER) - && (pcb_layer_flags_(last_layer) & PCB_LYT_COPPER) - && (!pcb->is_footprint) - && pcb_search_obj_by_location(PCB_OBJ_CLASS_PIN, &ptr1, &ptr2, &ptr3, - pcb_crosshair.AttachedLine.Point1.X, - pcb_crosshair.AttachedLine.Point1.Y, - conf_core.design.via_thickness / 2) == PCB_OBJ_VOID - && ((ps = pcb_pstk_new_compat_via(pcb->Data, -1, - pcb_crosshair.AttachedLine.Point1.X, - pcb_crosshair.AttachedLine.Point1.Y, - conf_core.design.via_drilling_hole, conf_core.design.via_thickness, conf_core.design.clearance, - 0, PCB_PSTK_COMPAT_ROUND, pcb_true)) != NULL)) { - pcb_obj_add_attribs(ps, pcb->pen_attr, NULL); - pcb_undo_add_obj_to_create(PCB_OBJ_PSTK, ps, ps, ps); - pcb_pstk_invalidate_draw(ps); - } - /* copy the coordinates */ - pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X; - pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y; - pcb_undo_inc_serial(); - last_layer = PCB_CURRLAYER(pcb); - pcb_subc_as_board_update(PCB); - } - if (conf_core.editor.line_refraction && (pcb_tool_note.X != pcb_crosshair.AttachedLine.Point2.X || pcb_tool_note.Y != pcb_crosshair.AttachedLine.Point2.Y) - && (line = - pcb_line_new_merge(pcb_loose_subc_layer(pcb, PCB_CURRLAYER(pcb), pcb_true), - pcb_crosshair.AttachedLine.Point2.X, - pcb_crosshair.AttachedLine.Point2.Y, - pcb_tool_note.X, pcb_tool_note.Y, - conf_core.design.line_thickness, - 2 * conf_core.design.clearance, - pcb_flag_make((conf_core.editor.auto_drc ? PCB_FLAG_FOUND : 0) | - (conf_core.editor.clear_line ? PCB_FLAG_CLEARLINE : 0)))) != NULL) { - pcb_added_lines++; - pcb_obj_add_attribs((pcb_any_obj_t *)line, pcb->pen_attr, NULL); - pcb_undo_add_obj_to_create(PCB_OBJ_LINE, PCB_CURRLAYER(pcb), line, line); - pcb_undo_inc_serial(); - pcb_line_invalidate_draw(PCB_CURRLAYER(pcb), line); - /* move to new start point */ - pcb_crosshair.AttachedLine.Point1.X = pcb_tool_note.X; - pcb_crosshair.AttachedLine.Point1.Y = pcb_tool_note.Y; - pcb_crosshair.AttachedLine.Point2.X = pcb_tool_note.X; - pcb_crosshair.AttachedLine.Point2.Y = pcb_tool_note.Y; - - - if (conf_core.editor.swap_start_direction) { - pcb_conf_setf(CFR_DESIGN,"editor/line_refraction", -1, "%d",conf_core.editor.line_refraction ^ 3); - } - pcb_subc_as_board_update(PCB); - } - if (conf_core.editor.orthogonal_moves) { - /* set the mark to the new starting point so ortho works as expected and we can draw a perpendicular line from here */ - pcb_marked.X = pcb_tool_note.X; - pcb_marked.Y = pcb_tool_note.Y; - } - pcb_draw(); - } -} - -void pcb_tool_line_adjust_attached_objects(pcb_hidlib_t *hl) -{ - /* don't draw outline when ctrl key is pressed */ - if (pcb_gui->control_is_pressed(pcb_gui)) { - pcb_crosshair.AttachedLine.draw = pcb_false; - } - else { - pcb_crosshair.AttachedLine.draw = pcb_true; - pcb_line_adjust_attached(); - } -} - -void pcb_tool_line_draw_attached(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - - if (pcb->RatDraw) { - /* draw only if starting point exists and the line has length */ - if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST && pcb_crosshair.AttachedLine.draw) - pcb_draw_wireframe_line(pcb_crosshair.GC, - pcb_crosshair.AttachedLine.Point1.X, pcb_crosshair.AttachedLine.Point1.Y, - pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y, - 10, 0); - } - else if (pcb_crosshair.Route.size > 0) { - pcb_route_draw(&pcb_crosshair.Route,pcb_crosshair.GC); - if (conf_core.editor.show_drc) - pcb_route_draw_drc(&pcb_crosshair.Route,pcb_crosshair.GC); - pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.attached); - } - else { - /* Draw a circle (0 length line) to show where the line will be placed */ - if (PCB_CURRLAYER(pcb)) - pcb_render->set_color(pcb_crosshair.GC, &PCB_CURRLAYER(pcb)->meta.real.color); - - pcb_draw_wireframe_line(pcb_crosshair.GC, - pcb_crosshair.X, pcb_crosshair.Y, - pcb_crosshair.X, pcb_crosshair.Y, - conf_core.design.line_thickness,0 ); - - if (conf_core.editor.show_drc) { - pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.drc); - pcb_draw_wireframe_line(pcb_crosshair.GC, - pcb_crosshair.X, pcb_crosshair.Y, - pcb_crosshair.X, pcb_crosshair.Y, - conf_core.design.line_thickness + (2 * conf_core.design.bloat), 0); - pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.attached); - } - } -} - -pcb_bool pcb_tool_line_undo_act(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - - if (pcb_crosshair.AttachedLine.State == PCB_CH_STATE_SECOND) { - if (conf_core.editor.auto_drc) - pcb_undo(pcb_true); /* undo the connection find */ - pcb_crosshair.AttachedLine.State = PCB_CH_STATE_FIRST; - pcb_route_reset(&pcb_crosshair.Route); - if (!pcb_marked.user_placed) - pcb_crosshair_set_local_ref(0, 0, pcb_false); - return pcb_false; - } - if (pcb_crosshair.AttachedLine.State == PCB_CH_STATE_THIRD) { - int type; - void *ptr1, *ptr3, *ptrtmp; - pcb_line_t *ptr2; - ptrtmp = &pcb_crosshair.AttachedLine; /* a workaround for the line undo bug */ - /* this search is guaranteed to succeed */ - pcb_search_obj_by_location(PCB_OBJ_LINE | PCB_OBJ_RAT, &ptr1, - &ptrtmp, &ptr3, pcb_crosshair.AttachedLine.Point1.X, pcb_crosshair.AttachedLine.Point1.Y, 0); - ptr2 = (pcb_line_t *) ptrtmp; - - /* save both ends of line */ - pcb_crosshair.AttachedLine.Point2.X = ptr2->Point1.X; - pcb_crosshair.AttachedLine.Point2.Y = ptr2->Point1.Y; - if ((type = pcb_undo(pcb_true)) == 0) - pcb_board_set_changed_flag(pcb_true); - /* check that the undo was of the right type */ - if ((type & PCB_UNDO_CREATE) == 0) { - /* wrong undo type, restore anchor points */ - pcb_crosshair.AttachedLine.Point2.X = pcb_crosshair.AttachedLine.Point1.X; - pcb_crosshair.AttachedLine.Point2.Y = pcb_crosshair.AttachedLine.Point1.Y; - return pcb_false; - } - /* move to new anchor */ - pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X; - pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y; - /* check if an intermediate point was removed */ - if (type & PCB_UNDO_REMOVE) { - /* this search should find the restored line */ - pcb_search_obj_by_location(PCB_OBJ_LINE | PCB_OBJ_RAT, &ptr1, &ptrtmp, &ptr3, pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y, 0); - ptr2 = (pcb_line_t *) ptrtmp; - if (conf_core.editor.auto_drc) { - /* undo loses PCB_FLAG_FOUND */ - PCB_FLAG_SET(PCB_FLAG_FOUND, ptr2); - pcb_line_invalidate_draw(PCB_CURRLAYER(pcb), ptr2); - } - pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X = ptr2->Point2.X; - pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y = ptr2->Point2.Y; - } - pcb_crosshair_grid_fit(pcb_crosshair.X, pcb_crosshair.Y); - pcb_tool_adjust_attached_objects(hl); - if (--pcb_added_lines == 0) { - pcb_crosshair.AttachedLine.State = PCB_CH_STATE_SECOND; - last_layer = PCB_CURRLAYER(pcb); - } - else { - /* this search is guaranteed to succeed too */ - pcb_search_obj_by_location(PCB_OBJ_LINE | PCB_OBJ_RAT, &ptr1, &ptrtmp, &ptr3, pcb_crosshair.AttachedLine.Point1.X, pcb_crosshair.AttachedLine.Point1.Y, 0); - ptr2 = (pcb_line_t *) ptrtmp; - last_layer = (pcb_layer_t *) ptr1; - } - return pcb_false; - } - return pcb_true; -} - -pcb_bool pcb_tool_line_redo_act(pcb_hidlib_t *hl) -{ - pcb_board_t *pcb = (pcb_board_t *)hl; - - if (pcb_crosshair.AttachedLine.State == PCB_CH_STATE_SECOND) - return pcb_false; - if (pcb_redo(pcb_true)) { - pcb_board_set_changed_flag(pcb_true); - if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST) { - pcb_line_t *line = linelist_last(&PCB_CURRLAYER(pcb)->Line); - pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X = line->Point2.X; - pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y = line->Point2.Y; - pcb_added_lines++; - } - } - return pcb_false; -} - -/* XPM */ -static const char *line_icon[] = { -/* columns rows colors chars-per-pixel */ -"21 21 4 1", -" c #000000", -". c #7A8584", -"X c #6EA5D7", -"O c None", -/* pixels */ -"OOOOOOOOOOOOOOOOOOOOO", -"OO...OOOOOOOOOOOOOOOO", -"O.OOO.OOOOOOOOOOOOOOO", -"O.OXXXOOOOOOOOOOOOOOO", -"O.OOO.XXXOOOOOOOOOOOO", -"OO...OOOOXXXOOOO...OO", -"OOOOOOOOOOOOXXX.OOO.O", -"OOOOOOOOOOOOOOOXXXO.O", -"OOOOOOOOOOOOOOO.OOO.O", -"OOOOOOOOOOOOOOOO...OO", -"OOOOOOOOOOOOOOOOOOOOO", -"OOOOOOOOOOOOOOOOOOOOO", -" OOOO O OOOO O O", -" OOOOO OO OOO O OOOO", -" OOOOO OO O OO O OOOO", -" OOOOO OO O OO O OOOO", -" OOOOO OO OO O O OO", -" OOOOO OO OO O O OOOO", -" OOOOO OO OOO O OOOO", -" O O OOOO O O", -"OOOOOOOOOOOOOOOOOOOOO" -}; - - -pcb_tool_t pcb_tool_line = { - "line", NULL, NULL, 100, line_icon, PCB_TOOL_CURSOR_NAMED("pencil"), 0, - pcb_tool_line_init, - pcb_tool_line_uninit, - pcb_tool_line_notify_mode, - NULL, - pcb_tool_line_adjust_attached_objects, - pcb_tool_line_draw_attached, - pcb_tool_line_undo_act, - pcb_tool_line_redo_act, - - pcb_true -}; Index: trunk/src/tool_line.h =================================================================== --- trunk/src/tool_line.h (revision 29303) +++ trunk/src/tool_line.h (nonexistent) @@ -1,9 +0,0 @@ -extern pcb_tool_t pcb_tool_line; - -void pcb_tool_line_init(void); -void pcb_tool_line_uninit(void); -void pcb_tool_line_notify_mode(pcb_hidlib_t *hl); -void pcb_tool_line_adjust_attached_objects(pcb_hidlib_t *hl); -void pcb_tool_line_draw_attached(pcb_hidlib_t *hl); -pcb_bool pcb_tool_line_undo_act(pcb_hidlib_t *hl); -pcb_bool pcb_tool_line_redo_act(pcb_hidlib_t *hl); Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 29303) +++ trunk/src/Makefile.dep (revision 29304) @@ -9392,396 +9392,7 @@ vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h draw.h \ librnd/core/event.h find.h librnd/core/grid.h undo.h \ ../src_3rd/libuundo/uundo.h undo_old.h librnd/core/actions.h \ - librnd/core/conf_hid.h tool_arc.h tool_arrow.h tool_buffer.h tool_copy.h \ - tool_insert.h tool_line.h tool_lock.h tool_move.h tool_poly.h \ - tool_polyhole.h tool_rectangle.h tool_remove.h tool_rotate.h tool_text.h \ - tool_thermal.h tool_via.h -tool_arc.o: tool_arc.c ../config.h librnd/config.h conf_core.h \ - librnd/core/conf.h librnd/core/global_typedefs.h librnd/core/pcb_bool.h \ - librnd/core/pcb-printf.h ../src_3rd/genvector/gds_char.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h librnd/core/unit.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - ../src_3rd/genvector/vtp0.h librnd/core/list_conf.h \ - ../src_3rd/genlist/gentdlist_undef.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h librnd/core/globalconst.h \ - librnd/core/color.h librnd/core/hidlib_conf.h board.h vtroutestyle.h \ - librnd/core/attrib.h layer.h obj_common.h flag.h data_parent.h \ - obj_arc_list.h obj_arc.h ../src_3rd/genlist/gendlist.h obj_line_list.h \ - obj_line.h obj_poly_list.h obj_poly.h librnd/poly/polyarea.h \ - obj_text_list.h obj_text.h font.h ../src_3rd/genht/htip.h \ - librnd/core/box.h librnd/core/math_helper.h librnd/core/misc_util.h \ - layer_grp.h rats_patch.h librnd/core/hidlib.h crosshair.h vtonpoint.h \ - librnd/core/hid.h librnd/core/error.h route.h data.h buffer.h \ - ../src_3rd/libfungw/fungw.h ../src_3rd/genht/htpp.h obj_rat_list.h \ - obj_rat.h idpath.h obj_subc_list.h obj_subc.h \ - ../src_3rd/libminuid/libminuid.h librnd/poly/rtree2_compat.h \ - librnd/poly/rtree.h ../src_3rd/genrtree/genrtree_api.h ht_subc.h \ - ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ - vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h draw.h \ - draw_wireframe.h search.h tool.h undo.h ../src_3rd/libuundo/uundo.h \ - undo_old.h obj_arc_draw.h -tool_arrow.o: tool_arrow.c ../config.h librnd/config.h conf_core.h \ - librnd/core/conf.h librnd/core/global_typedefs.h librnd/core/pcb_bool.h \ - librnd/core/pcb-printf.h ../src_3rd/genvector/gds_char.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h librnd/core/unit.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - ../src_3rd/genvector/vtp0.h librnd/core/list_conf.h \ - ../src_3rd/genlist/gentdlist_undef.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h librnd/core/globalconst.h \ - librnd/core/color.h board.h vtroutestyle.h librnd/core/attrib.h layer.h \ - obj_common.h flag.h data_parent.h obj_arc_list.h obj_arc.h \ - ../src_3rd/genlist/gendlist.h obj_line_list.h obj_line.h obj_poly_list.h \ - obj_poly.h librnd/poly/polyarea.h obj_text_list.h obj_text.h font.h \ - ../src_3rd/genht/htip.h librnd/core/box.h librnd/core/math_helper.h \ - librnd/core/misc_util.h layer_grp.h rats_patch.h librnd/core/hidlib.h \ - buffer.h ../src_3rd/libfungw/fungw.h ../src_3rd/genht/htpp.h crosshair.h \ - vtonpoint.h librnd/core/hid.h librnd/core/error.h route.h data.h \ - obj_rat_list.h obj_rat.h idpath.h obj_subc_list.h obj_subc.h \ - ../src_3rd/libminuid/libminuid.h librnd/poly/rtree2_compat.h \ - librnd/poly/rtree.h ../src_3rd/genrtree/genrtree_api.h ht_subc.h \ - ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ - vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h \ - librnd/core/actions.h remove.h move.h search.h select.h operation.h \ - tool.h undo.h ../src_3rd/libuundo/uundo.h undo_old.h extobj.h \ - obj_subc_parent.h draw.h -tool_buffer.o: tool_buffer.c ../config.h librnd/config.h conf_core.h \ - librnd/core/conf.h librnd/core/global_typedefs.h librnd/core/pcb_bool.h \ - librnd/core/pcb-printf.h ../src_3rd/genvector/gds_char.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h librnd/core/unit.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - ../src_3rd/genvector/vtp0.h librnd/core/list_conf.h \ - ../src_3rd/genlist/gentdlist_undef.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h librnd/core/globalconst.h \ - librnd/core/color.h board.h vtroutestyle.h librnd/core/attrib.h layer.h \ - obj_common.h flag.h data_parent.h obj_arc_list.h obj_arc.h \ - ../src_3rd/genlist/gendlist.h obj_line_list.h obj_line.h obj_poly_list.h \ - obj_poly.h librnd/poly/polyarea.h obj_text_list.h obj_text.h font.h \ - ../src_3rd/genht/htip.h librnd/core/box.h librnd/core/math_helper.h \ - librnd/core/misc_util.h layer_grp.h rats_patch.h librnd/core/hidlib.h \ - buffer.h ../src_3rd/libfungw/fungw.h ../src_3rd/genht/htpp.h \ - librnd/core/compat_misc.h data.h crosshair.h vtonpoint.h \ - librnd/core/hid.h librnd/core/error.h route.h obj_rat_list.h obj_rat.h \ - idpath.h obj_subc_list.h obj_subc.h ../src_3rd/libminuid/libminuid.h \ - librnd/poly/rtree2_compat.h librnd/poly/rtree.h \ - ../src_3rd/genrtree/genrtree_api.h ht_subc.h ../src_3rd/genht/ht.h \ - ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h vtpadstack.h \ - obj_pstk_shape.h polygon.h vtpadstack_t.h librnd/core/actions.h search.h \ - tool.h undo.h ../src_3rd/libuundo/uundo.h undo_old.h -tool_copy.o: tool_copy.c ../config.h librnd/config.h board.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - librnd/core/global_typedefs.h librnd/core/pcb_bool.h vtroutestyle.h \ - librnd/core/unit.h librnd/core/attrib.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h layer.h librnd/core/globalconst.h \ - librnd/core/color.h obj_common.h flag.h data_parent.h obj_arc_list.h \ - obj_arc.h ../src_3rd/genlist/gendlist.h \ - ../src_3rd/genlist/gentdlist_impl.h ../src_3rd/genlist/gendlist.h \ - ../src_3rd/genlist/gentdlist_undef.h obj_line_list.h obj_line.h \ - obj_poly_list.h obj_poly.h librnd/poly/polyarea.h obj_text_list.h \ - obj_text.h font.h ../src_3rd/genht/htip.h librnd/core/box.h \ - librnd/core/math_helper.h librnd/core/misc_util.h \ - ../src_3rd/genvector/gds_char.h layer_grp.h rats_patch.h \ - librnd/core/hidlib.h move.h crosshair.h vtonpoint.h librnd/core/hid.h \ - ../src_3rd/liblihata/dom.h ../src_3rd/liblihata/lihata.h \ - ../src_3rd/liblihata/parser.h librnd/core/error.h route.h search.h \ - tool.h ../src_3rd/genvector/vtp0.h -tool_insert.o: tool_insert.c ../config.h librnd/config.h board.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - librnd/core/global_typedefs.h librnd/core/pcb_bool.h vtroutestyle.h \ - librnd/core/unit.h librnd/core/attrib.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h layer.h librnd/core/globalconst.h \ - librnd/core/color.h obj_common.h flag.h data_parent.h obj_arc_list.h \ - obj_arc.h ../src_3rd/genlist/gendlist.h \ - ../src_3rd/genlist/gentdlist_impl.h ../src_3rd/genlist/gendlist.h \ - ../src_3rd/genlist/gentdlist_undef.h obj_line_list.h obj_line.h \ - obj_poly_list.h obj_poly.h librnd/poly/polyarea.h obj_text_list.h \ - obj_text.h font.h ../src_3rd/genht/htip.h librnd/core/box.h \ - librnd/core/math_helper.h librnd/core/misc_util.h \ - ../src_3rd/genvector/gds_char.h layer_grp.h rats_patch.h \ - librnd/core/hidlib.h crosshair.h vtonpoint.h librnd/core/hid.h \ - ../src_3rd/liblihata/dom.h ../src_3rd/liblihata/lihata.h \ - ../src_3rd/liblihata/parser.h librnd/core/error.h route.h insert.h \ - polygon.h librnd/poly/rtree.h ../src_3rd/genrtree/genrtree_api.h \ - librnd/poly/rtree2_compat.h search.h tool.h ../src_3rd/genvector/vtp0.h -tool_line.o: tool_line.c ../config.h librnd/config.h conf_core.h \ - librnd/core/conf.h librnd/core/global_typedefs.h librnd/core/pcb_bool.h \ - librnd/core/pcb-printf.h ../src_3rd/genvector/gds_char.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h librnd/core/unit.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - ../src_3rd/genvector/vtp0.h librnd/core/list_conf.h \ - ../src_3rd/genlist/gentdlist_undef.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h librnd/core/globalconst.h \ - librnd/core/color.h librnd/core/hidlib_conf.h board.h vtroutestyle.h \ - librnd/core/attrib.h layer.h obj_common.h flag.h data_parent.h \ - obj_arc_list.h obj_arc.h ../src_3rd/genlist/gendlist.h obj_line_list.h \ - obj_line.h obj_poly_list.h obj_poly.h librnd/poly/polyarea.h \ - obj_text_list.h obj_text.h font.h ../src_3rd/genht/htip.h \ - librnd/core/box.h librnd/core/math_helper.h librnd/core/misc_util.h \ - layer_grp.h rats_patch.h librnd/core/hidlib.h crosshair.h vtonpoint.h \ - librnd/core/hid.h librnd/core/error.h route.h data.h buffer.h \ - ../src_3rd/libfungw/fungw.h ../src_3rd/genht/htpp.h obj_rat_list.h \ - obj_rat.h idpath.h obj_subc_list.h obj_subc.h \ - ../src_3rd/libminuid/libminuid.h librnd/poly/rtree2_compat.h \ - librnd/poly/rtree.h ../src_3rd/genrtree/genrtree_api.h ht_subc.h \ - ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ - vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h draw.h \ - draw_wireframe.h find.h search.h tool.h undo.h \ - ../src_3rd/libuundo/uundo.h undo_old.h netlist.h obj_line_draw.h \ - obj_pstk_draw.h obj_rat_draw.h route_draw.h \ - ../src_plugins/lib_compat_help/pstk_compat.h obj_pstk.h -tool_lock.o: tool_lock.c ../config.h librnd/config.h board.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - librnd/core/global_typedefs.h librnd/core/pcb_bool.h vtroutestyle.h \ - librnd/core/unit.h librnd/core/attrib.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h layer.h librnd/core/globalconst.h \ - librnd/core/color.h obj_common.h flag.h data_parent.h obj_arc_list.h \ - obj_arc.h ../src_3rd/genlist/gendlist.h \ - ../src_3rd/genlist/gentdlist_impl.h ../src_3rd/genlist/gendlist.h \ - ../src_3rd/genlist/gentdlist_undef.h obj_line_list.h obj_line.h \ - obj_poly_list.h obj_poly.h librnd/poly/polyarea.h obj_text_list.h \ - obj_text.h font.h ../src_3rd/genht/htip.h librnd/core/box.h \ - librnd/core/math_helper.h librnd/core/misc_util.h \ - ../src_3rd/genvector/gds_char.h layer_grp.h rats_patch.h \ - librnd/core/hidlib.h change.h data.h crosshair.h vtonpoint.h \ - librnd/core/hid.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - librnd/core/error.h route.h buffer.h ../src_3rd/libfungw/fungw.h \ - ../src_3rd/genht/htpp.h obj_rat_list.h obj_rat.h idpath.h \ - obj_subc_list.h obj_subc.h ../src_3rd/libminuid/libminuid.h \ - librnd/poly/rtree2_compat.h librnd/poly/rtree.h \ - ../src_3rd/genrtree/genrtree_api.h ht_subc.h ../src_3rd/genht/ht.h \ - ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ - ../src_3rd/genvector/vtp0.h vtpadstack.h obj_pstk_shape.h polygon.h \ - vtpadstack_t.h draw.h librnd/core/actions.h search.h tool.h tool_lock.h -tool_move.o: tool_move.c ../config.h librnd/config.h board.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - librnd/core/global_typedefs.h librnd/core/pcb_bool.h vtroutestyle.h \ - librnd/core/unit.h librnd/core/attrib.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h layer.h librnd/core/globalconst.h \ - librnd/core/color.h obj_common.h flag.h data_parent.h obj_arc_list.h \ - obj_arc.h ../src_3rd/genlist/gendlist.h \ - ../src_3rd/genlist/gentdlist_impl.h ../src_3rd/genlist/gendlist.h \ - ../src_3rd/genlist/gentdlist_undef.h obj_line_list.h obj_line.h \ - obj_poly_list.h obj_poly.h librnd/poly/polyarea.h obj_text_list.h \ - obj_text.h font.h ../src_3rd/genht/htip.h librnd/core/box.h \ - librnd/core/math_helper.h librnd/core/misc_util.h \ - ../src_3rd/genvector/gds_char.h layer_grp.h rats_patch.h \ - librnd/core/hidlib.h move.h crosshair.h vtonpoint.h librnd/core/hid.h \ - ../src_3rd/liblihata/dom.h ../src_3rd/liblihata/lihata.h \ - ../src_3rd/liblihata/parser.h librnd/core/error.h route.h search.h \ - tool.h ../src_3rd/genvector/vtp0.h extobj.h data.h buffer.h \ - ../src_3rd/libfungw/fungw.h ../src_3rd/genht/htpp.h obj_rat_list.h \ - obj_rat.h idpath.h obj_subc_list.h obj_subc.h \ - ../src_3rd/libminuid/libminuid.h librnd/poly/rtree2_compat.h \ - librnd/poly/rtree.h ../src_3rd/genrtree/genrtree_api.h ht_subc.h \ - ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ - vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h obj_subc_parent.h \ - draw.h -tool_poly.o: tool_poly.c ../config.h librnd/config.h conf_core.h \ - librnd/core/conf.h librnd/core/global_typedefs.h librnd/core/pcb_bool.h \ - librnd/core/pcb-printf.h ../src_3rd/genvector/gds_char.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h librnd/core/unit.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - ../src_3rd/genvector/vtp0.h librnd/core/list_conf.h \ - ../src_3rd/genlist/gentdlist_undef.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h librnd/core/globalconst.h \ - librnd/core/color.h crosshair.h vtonpoint.h librnd/core/hid.h \ - librnd/core/error.h librnd/core/attrib.h librnd/core/box.h \ - librnd/core/math_helper.h librnd/core/misc_util.h obj_line.h \ - ../src_3rd/genlist/gendlist.h obj_common.h flag.h data_parent.h \ - obj_poly.h librnd/poly/polyarea.h route.h librnd/core/actions.h \ - ../src_3rd/libfungw/fungw.h ../src_3rd/genht/htpp.h polygon.h \ - librnd/poly/rtree.h ../src_3rd/genrtree/genrtree_api.h \ - librnd/poly/rtree2_compat.h tool.h board.h vtroutestyle.h layer.h \ - obj_arc_list.h obj_arc.h obj_line_list.h obj_poly_list.h obj_text_list.h \ - obj_text.h font.h ../src_3rd/genht/htip.h layer_grp.h rats_patch.h \ - librnd/core/hidlib.h -tool_polyhole.o: tool_polyhole.c ../config.h librnd/config.h conf_core.h \ - librnd/core/conf.h librnd/core/global_typedefs.h librnd/core/pcb_bool.h \ - librnd/core/pcb-printf.h ../src_3rd/genvector/gds_char.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h librnd/core/unit.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - ../src_3rd/genvector/vtp0.h librnd/core/list_conf.h \ - ../src_3rd/genlist/gentdlist_undef.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h librnd/core/globalconst.h \ - librnd/core/color.h crosshair.h vtonpoint.h librnd/core/hid.h \ - librnd/core/error.h librnd/core/attrib.h librnd/core/box.h \ - librnd/core/math_helper.h librnd/core/misc_util.h obj_line.h \ - ../src_3rd/genlist/gendlist.h obj_common.h flag.h data_parent.h \ - obj_poly.h librnd/poly/polyarea.h route.h librnd/core/actions.h \ - ../src_3rd/libfungw/fungw.h ../src_3rd/genht/htpp.h polygon.h \ - librnd/poly/rtree.h ../src_3rd/genrtree/genrtree_api.h \ - librnd/poly/rtree2_compat.h search.h layer.h obj_arc_list.h obj_arc.h \ - obj_line_list.h obj_poly_list.h obj_text_list.h obj_text.h font.h \ - ../src_3rd/genht/htip.h tool.h board.h vtroutestyle.h layer_grp.h \ - rats_patch.h librnd/core/hidlib.h -tool_rectangle.o: tool_rectangle.c ../config.h librnd/config.h \ - conf_core.h librnd/core/conf.h librnd/core/global_typedefs.h \ - librnd/core/pcb_bool.h librnd/core/pcb-printf.h \ - ../src_3rd/genvector/gds_char.h ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h librnd/core/unit.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - ../src_3rd/genvector/vtp0.h librnd/core/list_conf.h \ - ../src_3rd/genlist/gentdlist_undef.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h librnd/core/globalconst.h \ - librnd/core/color.h board.h vtroutestyle.h librnd/core/attrib.h layer.h \ - obj_common.h flag.h data_parent.h obj_arc_list.h obj_arc.h \ - ../src_3rd/genlist/gendlist.h obj_line_list.h obj_line.h obj_poly_list.h \ - obj_poly.h librnd/poly/polyarea.h obj_text_list.h obj_text.h font.h \ - ../src_3rd/genht/htip.h librnd/core/box.h librnd/core/math_helper.h \ - librnd/core/misc_util.h layer_grp.h rats_patch.h librnd/core/hidlib.h \ - crosshair.h vtonpoint.h librnd/core/hid.h librnd/core/error.h route.h \ - data.h buffer.h ../src_3rd/libfungw/fungw.h ../src_3rd/genht/htpp.h \ - obj_rat_list.h obj_rat.h idpath.h obj_subc_list.h obj_subc.h \ - ../src_3rd/libminuid/libminuid.h librnd/poly/rtree2_compat.h \ - librnd/poly/rtree.h ../src_3rd/genrtree/genrtree_api.h ht_subc.h \ - ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ - vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h draw.h tool.h \ - undo.h ../src_3rd/libuundo/uundo.h undo_old.h obj_poly_draw.h -tool_remove.o: tool_remove.c ../config.h librnd/config.h board.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - librnd/core/global_typedefs.h librnd/core/pcb_bool.h vtroutestyle.h \ - librnd/core/unit.h librnd/core/attrib.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h layer.h librnd/core/globalconst.h \ - librnd/core/color.h obj_common.h flag.h data_parent.h obj_arc_list.h \ - obj_arc.h ../src_3rd/genlist/gendlist.h \ - ../src_3rd/genlist/gentdlist_impl.h ../src_3rd/genlist/gendlist.h \ - ../src_3rd/genlist/gentdlist_undef.h obj_line_list.h obj_line.h \ - obj_poly_list.h obj_poly.h librnd/poly/polyarea.h obj_text_list.h \ - obj_text.h font.h ../src_3rd/genht/htip.h librnd/core/box.h \ - librnd/core/math_helper.h librnd/core/misc_util.h \ - ../src_3rd/genvector/gds_char.h layer_grp.h rats_patch.h \ - librnd/core/hidlib.h librnd/core/event.h librnd/core/actions.h \ - librnd/core/hid.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - librnd/core/error.h ../src_3rd/libfungw/fungw.h ../src_3rd/genht/htpp.h \ - undo.h ../src_3rd/libuundo/uundo.h undo_old.h remove.h search.h \ - obj_rat.h idpath.h tool.h ../src_3rd/genvector/vtp0.h -tool_rotate.o: tool_rotate.c ../config.h librnd/config.h conf_core.h \ - librnd/core/conf.h librnd/core/global_typedefs.h librnd/core/pcb_bool.h \ - librnd/core/pcb-printf.h ../src_3rd/genvector/gds_char.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h librnd/core/unit.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - ../src_3rd/genvector/vtp0.h librnd/core/list_conf.h \ - ../src_3rd/genlist/gentdlist_undef.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h librnd/core/globalconst.h \ - librnd/core/color.h librnd/core/actions.h librnd/core/hid.h \ - librnd/core/error.h librnd/core/attrib.h librnd/core/box.h \ - librnd/core/math_helper.h librnd/core/misc_util.h \ - ../src_3rd/libfungw/fungw.h ../src_3rd/genht/htpp.h board.h \ - vtroutestyle.h layer.h obj_common.h flag.h data_parent.h obj_arc_list.h \ - obj_arc.h ../src_3rd/genlist/gendlist.h obj_line_list.h obj_line.h \ - obj_poly_list.h obj_poly.h librnd/poly/polyarea.h obj_text_list.h \ - obj_text.h font.h ../src_3rd/genht/htip.h layer_grp.h rats_patch.h \ - librnd/core/hidlib.h rotate.h librnd/core/rotate.h \ - librnd/core/compat_misc.h tool.h -tool_text.o: tool_text.c ../config.h librnd/config.h conf_core.h \ - librnd/core/conf.h librnd/core/global_typedefs.h librnd/core/pcb_bool.h \ - librnd/core/pcb-printf.h ../src_3rd/genvector/gds_char.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h librnd/core/unit.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - ../src_3rd/genvector/vtp0.h librnd/core/list_conf.h \ - ../src_3rd/genlist/gentdlist_undef.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h librnd/core/globalconst.h \ - librnd/core/color.h board.h vtroutestyle.h librnd/core/attrib.h layer.h \ - obj_common.h flag.h data_parent.h obj_arc_list.h obj_arc.h \ - ../src_3rd/genlist/gendlist.h obj_line_list.h obj_line.h obj_poly_list.h \ - obj_poly.h librnd/poly/polyarea.h obj_text_list.h obj_text.h font.h \ - ../src_3rd/genht/htip.h librnd/core/box.h librnd/core/math_helper.h \ - librnd/core/misc_util.h layer_grp.h rats_patch.h librnd/core/hidlib.h \ - data.h crosshair.h vtonpoint.h librnd/core/hid.h librnd/core/error.h \ - route.h buffer.h ../src_3rd/libfungw/fungw.h ../src_3rd/genht/htpp.h \ - obj_rat_list.h obj_rat.h idpath.h obj_subc_list.h obj_subc.h \ - ../src_3rd/libminuid/libminuid.h librnd/poly/rtree2_compat.h \ - librnd/poly/rtree.h ../src_3rd/genrtree/genrtree_api.h ht_subc.h \ - ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ - vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h draw.h \ - librnd/core/actions.h tool.h undo.h ../src_3rd/libuundo/uundo.h \ - undo_old.h obj_text_draw.h -tool_thermal.o: tool_thermal.c ../config.h librnd/config.h board.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - librnd/core/global_typedefs.h librnd/core/pcb_bool.h vtroutestyle.h \ - librnd/core/unit.h librnd/core/attrib.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h layer.h librnd/core/globalconst.h \ - librnd/core/color.h obj_common.h flag.h data_parent.h obj_arc_list.h \ - obj_arc.h ../src_3rd/genlist/gendlist.h \ - ../src_3rd/genlist/gentdlist_impl.h ../src_3rd/genlist/gendlist.h \ - ../src_3rd/genlist/gentdlist_undef.h obj_line_list.h obj_line.h \ - obj_poly_list.h obj_poly.h librnd/poly/polyarea.h obj_text_list.h \ - obj_text.h font.h ../src_3rd/genht/htip.h librnd/core/box.h \ - librnd/core/math_helper.h librnd/core/misc_util.h \ - ../src_3rd/genvector/gds_char.h layer_grp.h rats_patch.h \ - librnd/core/hidlib.h change.h data.h crosshair.h vtonpoint.h \ - librnd/core/hid.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - librnd/core/error.h route.h buffer.h ../src_3rd/libfungw/fungw.h \ - ../src_3rd/genht/htpp.h obj_rat_list.h obj_rat.h idpath.h \ - obj_subc_list.h obj_subc.h ../src_3rd/libminuid/libminuid.h \ - librnd/poly/rtree2_compat.h librnd/poly/rtree.h \ - ../src_3rd/genrtree/genrtree_api.h ht_subc.h ../src_3rd/genht/ht.h \ - ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ - ../src_3rd/genvector/vtp0.h vtpadstack.h obj_pstk_shape.h polygon.h \ - vtpadstack_t.h librnd/core/actions.h search.h thermal.h \ - librnd/poly/polygon1_gen.h tool.h -tool_via.o: tool_via.c ../config.h librnd/config.h conf_core.h \ - librnd/core/conf.h librnd/core/global_typedefs.h librnd/core/pcb_bool.h \ - librnd/core/pcb-printf.h ../src_3rd/genvector/gds_char.h \ - ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h librnd/core/unit.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/dom.h \ - ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ - ../src_3rd/genvector/vtp0.h librnd/core/list_conf.h \ - ../src_3rd/genlist/gentdlist_undef.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h librnd/core/globalconst.h \ - librnd/core/color.h librnd/core/hidlib_conf.h board.h vtroutestyle.h \ - librnd/core/attrib.h layer.h obj_common.h flag.h data_parent.h \ - obj_arc_list.h obj_arc.h ../src_3rd/genlist/gendlist.h obj_line_list.h \ - obj_line.h obj_poly_list.h obj_poly.h librnd/poly/polyarea.h \ - obj_text_list.h obj_text.h font.h ../src_3rd/genht/htip.h \ - librnd/core/box.h librnd/core/math_helper.h librnd/core/misc_util.h \ - layer_grp.h rats_patch.h librnd/core/hidlib.h change.h \ - librnd/core/hid_inlines.h librnd/core/hid.h librnd/core/error.h data.h \ - crosshair.h vtonpoint.h route.h buffer.h ../src_3rd/libfungw/fungw.h \ - ../src_3rd/genht/htpp.h obj_rat_list.h obj_rat.h idpath.h \ - obj_subc_list.h obj_subc.h ../src_3rd/libminuid/libminuid.h \ - librnd/poly/rtree2_compat.h librnd/poly/rtree.h \ - ../src_3rd/genrtree/genrtree_api.h ht_subc.h ../src_3rd/genht/ht.h \ - ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h vtpadstack.h \ - obj_pstk_shape.h polygon.h vtpadstack_t.h draw.h tool.h tool_thermal.h \ - undo.h ../src_3rd/libuundo/uundo.h undo_old.h obj_pstk_draw.h \ - ../src_plugins/lib_compat_help/pstk_compat.h obj_pstk.h + librnd/core/conf_hid.h undo.o: undo.c ../config.h librnd/config.h \ ../src_3rd/libuundo/uundo_debug.h ../src_3rd/libuundo/uundo.h board.h \ ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 29303) +++ trunk/src/Makefile.in (revision 29304) @@ -236,22 +236,6 @@ stub_stroke.o thermal.o tool.o - tool_arc.o - tool_arrow.o - tool_buffer.o - tool_copy.o - tool_insert.o - tool_line.o - tool_lock.o - tool_move.o - tool_poly.o - tool_polyhole.o - tool_rectangle.o - tool_remove.o - tool_rotate.o - tool_text.o - tool_thermal.o - tool_via.o undo.o undo_act.o undo_old.o Index: trunk/src/tool.c =================================================================== --- trunk/src/tool.c (revision 29303) +++ trunk/src/tool.c (revision 29304) @@ -69,7 +69,6 @@ conf_native_t *n_mode = pcb_conf_get_field("editor/mode"); vtp0_init(&pcb_tools); - default_tool_reg(); /* temporary */ tool_conf_id = pcb_conf_hid_reg(pcb_tool_cookie, NULL); @@ -82,7 +81,6 @@ void pcb_tool_uninit() { - default_tool_unreg(); /* temporary */ while(vtp0_len(&pcb_tools) != 0) { const pcb_tool_t *tool = pcb_tool_get(0); pcb_message(PCB_MSG_WARNING, "Unregistered tool: %s of %s; check your plugins, fix them to unregister their tools!\n", tool->name, tool->cookie); @@ -372,52 +370,6 @@ pcb_notify_crosshair_change(pcb_true); } -TODO("tool: move this out to a tool plugin") - -#include "tool_arc.h" -#include "tool_arrow.h" -#include "tool_buffer.h" -#include "tool_copy.h" -#include "tool_insert.h" -#include "tool_line.h" -#include "tool_lock.h" -#include "tool_move.h" -#include "tool_poly.h" -#include "tool_polyhole.h" -#include "tool_rectangle.h" -#include "tool_remove.h" -#include "tool_rotate.h" -#include "tool_text.h" -#include "tool_thermal.h" -#include "tool_via.h" - - -static void default_tool_reg(void) -{ - pcb_tool_reg(&pcb_tool_arc, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_arrow, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_buffer, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_copy, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_insert, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_line, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_lock, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_move, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_poly, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_polyhole, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_rectangle, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_remove, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_rotate, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_text, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_thermal, pcb_tool_cookie); - pcb_tool_reg(&pcb_tool_via, pcb_tool_cookie); -} - -static void default_tool_unreg(void) -{ - pcb_tool_unreg_by_cookie(pcb_tool_cookie); -} - - /*** old helpers ***/ void pcb_release_mode(pcb_hidlib_t *hidlib) { Index: trunk/src_plugins/plugins_ALL.tmpasm =================================================================== --- trunk/src_plugins/plugins_ALL.tmpasm (revision 29303) +++ trunk/src_plugins/plugins_ALL.tmpasm (revision 29304) @@ -109,4 +109,5 @@ include {../src_plugins/smartdisperse/Plug.tmpasm} include {../src_plugins/stroke/Plug.tmpasm} include {../src_plugins/teardrops/Plug.tmpasm} +include {../src_plugins/tool_std/Plug.tmpasm} include {../src_plugins/vendordrill/Plug.tmpasm} Index: trunk/src_plugins/tool_std/Makefile =================================================================== --- trunk/src_plugins/tool_std/Makefile (nonexistent) +++ trunk/src_plugins/tool_std/Makefile (revision 29304) @@ -0,0 +1,6 @@ +all: + cd ../../src && $(MAKE) mod_tool_std + + +clean: + rm *.o *.so 2>/dev/null ; true Index: trunk/src_plugins/tool_std/Plug.tmpasm =================================================================== --- trunk/src_plugins/tool_std/Plug.tmpasm (nonexistent) +++ trunk/src_plugins/tool_std/Plug.tmpasm (revision 29304) @@ -0,0 +1,26 @@ +put /local/pcb/mod {tool_std} +put /local/pcb/mod/OBJS [@ + $(PLUGDIR)/tool_std/tool_std.o + $(PLUGDIR)/tool_std/tool_arc.o + $(PLUGDIR)/tool_std/tool_arrow.o + $(PLUGDIR)/tool_std/tool_buffer.o + $(PLUGDIR)/tool_std/tool_copy.o + $(PLUGDIR)/tool_std/tool_insert.o + $(PLUGDIR)/tool_std/tool_line.o + $(PLUGDIR)/tool_std/tool_lock.o + $(PLUGDIR)/tool_std/tool_move.o + $(PLUGDIR)/tool_std/tool_poly.o + $(PLUGDIR)/tool_std/tool_polyhole.o + $(PLUGDIR)/tool_std/tool_rectangle.o + $(PLUGDIR)/tool_std/tool_remove.o + $(PLUGDIR)/tool_std/tool_rotate.o + $(PLUGDIR)/tool_std/tool_text.o + $(PLUGDIR)/tool_std/tool_thermal.o + $(PLUGDIR)/tool_std/tool_via.o +@] + +switch /local/pcb/tool_std/controls + case {buildin} include /local/pcb/tmpasm/buildin; end; + case {plugin} include /local/pcb/tmpasm/plugin; end; + case {disable} include /local/pcb/tmpasm/disable; end; +end Index: trunk/src_plugins/tool_std/tool_arc.c =================================================================== --- trunk/src_plugins/tool_std/tool_arc.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_arc.c (revision 29304) @@ -0,0 +1,239 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" + +#include "conf_core.h" +#include + +#include "board.h" +#include "crosshair.h" +#include "data.h" +#include "draw.h" +#include "draw_wireframe.h" +#include "search.h" +#include "tool.h" +#include "undo.h" + +#include "obj_arc_draw.h" + + +void pcb_tool_arc_init(void) +{ + pcb_notify_crosshair_change(pcb_false); + if (pcb_tool_prev_id == PCB_MODE_LINE && pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST) { + pcb_crosshair.AttachedLine.State = PCB_CH_STATE_FIRST; + pcb_crosshair.AttachedBox.State = PCB_CH_STATE_SECOND; + pcb_crosshair.AttachedBox.Point1.X = pcb_crosshair.AttachedBox.Point2.X = pcb_crosshair.AttachedLine.Point1.X; + pcb_crosshair.AttachedBox.Point1.Y = pcb_crosshair.AttachedBox.Point2.Y = pcb_crosshair.AttachedLine.Point1.Y; + pcb_tool_adjust_attached_objects(NULL); + } + pcb_notify_crosshair_change(pcb_true); +} + +void pcb_tool_arc_uninit(void) +{ + pcb_notify_crosshair_change(pcb_false); + pcb_added_lines = 0; + if (pcb_tool_next_id != PCB_MODE_LINE) { + pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; + if (!pcb_marked.user_placed) + pcb_crosshair_set_local_ref(0, 0, pcb_false); + } + pcb_notify_crosshair_change(pcb_true); +} + +void pcb_tool_arc_notify_mode(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + + switch (pcb_crosshair.AttachedBox.State) { + case PCB_CH_STATE_FIRST: + pcb_crosshair.AttachedBox.Point1.X = pcb_crosshair.AttachedBox.Point2.X = pcb_tool_note.X; + pcb_crosshair.AttachedBox.Point1.Y = pcb_crosshair.AttachedBox.Point2.Y = pcb_tool_note.Y; + pcb_crosshair.AttachedBox.State = PCB_CH_STATE_SECOND; + break; + + case PCB_CH_STATE_SECOND: + case PCB_CH_STATE_THIRD: + { + pcb_arc_t *arc; + pcb_coord_t wx, wy; + pcb_angle_t sa, dir; + + wx = pcb_tool_note.X - pcb_crosshair.AttachedBox.Point1.X; + wy = pcb_tool_note.Y - pcb_crosshair.AttachedBox.Point1.Y; + if (PCB_XOR(pcb_crosshair.AttachedBox.otherway, coord_abs(wy) > coord_abs(wx))) { + pcb_crosshair.AttachedBox.Point2.X = pcb_crosshair.AttachedBox.Point1.X + coord_abs(wy) * PCB_SGNZ(wx); + sa = (wx >= 0) ? 0 : 180; + dir = (PCB_SGNZ(wx) == PCB_SGNZ(wy)) ? 90 : -90; + } + else { + pcb_crosshair.AttachedBox.Point2.Y = pcb_crosshair.AttachedBox.Point1.Y + coord_abs(wx) * PCB_SGNZ(wy); + sa = (wy >= 0) ? -90 : 90; + dir = (PCB_SGNZ(wx) == PCB_SGNZ(wy)) ? -90 : 90; + wy = wx; + } + if (coord_abs(wy) > 0 && (arc = pcb_arc_new(pcb_loose_subc_layer(pcb, PCB_CURRLAYER(pcb), pcb_true), + pcb_crosshair.AttachedBox.Point2.X, + pcb_crosshair.AttachedBox.Point2.Y, + coord_abs(wy), + coord_abs(wy), + sa, + dir, + conf_core.design.line_thickness, + 2 * conf_core.design.clearance, + pcb_flag_make(conf_core.editor.clear_line ? PCB_FLAG_CLEARLINE : 0), pcb_true))) { + pcb_obj_add_attribs((pcb_any_obj_t *)arc, pcb->pen_attr, NULL); + pcb_arc_get_end(arc, 1, &pcb_crosshair.AttachedBox.Point2.X, &pcb_crosshair.AttachedBox.Point2.Y); + pcb_crosshair.AttachedBox.Point1.X = pcb_crosshair.AttachedBox.Point2.X; + pcb_crosshair.AttachedBox.Point1.Y = pcb_crosshair.AttachedBox.Point2.Y; + pcb_undo_add_obj_to_create(PCB_OBJ_ARC, PCB_CURRLAYER(pcb), arc, arc); + pcb_undo_inc_serial(); + pcb_added_lines++; + pcb_arc_invalidate_draw(PCB_CURRLAYER(pcb), arc); + pcb_subc_as_board_update(pcb); + pcb_draw(); + pcb_crosshair.AttachedBox.State = PCB_CH_STATE_THIRD; + } + break; + } + } +} + +void pcb_tool_arc_adjust_attached_objects(pcb_hidlib_t *hl) +{ + pcb_crosshair.AttachedBox.otherway = pcb_gui->shift_is_pressed(pcb_gui); +} + +void pcb_tool_arc_draw_attached(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + + if (pcb_crosshair.AttachedBox.State != PCB_CH_STATE_FIRST) { + pcb_xordraw_attached_arc(conf_core.design.line_thickness); + if (conf_core.editor.show_drc) { + pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.drc); + pcb_xordraw_attached_arc(conf_core.design.line_thickness + 2 * (conf_core.design.bloat + 1)); + pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.attached); + } + } + else { + /* Draw a circle (0 length line) to show where the arc will start when placed */ + if(PCB_CURRLAYER(pcb)) + pcb_render->set_color(pcb_crosshair.GC, &PCB_CURRLAYER(pcb)->meta.real.color); + + pcb_draw_wireframe_line(pcb_crosshair.GC, + pcb_crosshair.X, pcb_crosshair.Y, + pcb_crosshair.X, pcb_crosshair.Y, + conf_core.design.line_thickness, 0); + + if(conf_core.editor.show_drc) { + pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.drc); + pcb_draw_wireframe_line(pcb_crosshair.GC, + pcb_crosshair.X, pcb_crosshair.Y, + pcb_crosshair.X, pcb_crosshair.Y, + conf_core.design.line_thickness + (2 * conf_core.design.bloat), 0); + pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.attached); + } + } + +} + +pcb_bool pcb_tool_arc_undo_act(pcb_hidlib_t *hl) +{ + if (pcb_crosshair.AttachedBox.State == PCB_CH_STATE_SECOND) { + pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; + pcb_notify_crosshair_change(pcb_true); + return pcb_false; + } + if (pcb_crosshair.AttachedBox.State == PCB_CH_STATE_THIRD) { + void *ptr1, *ptr2, *ptr3; + /* guaranteed to succeed */ + pcb_search_obj_by_location(PCB_OBJ_ARC, &ptr1, &ptr2, &ptr3, + pcb_crosshair.AttachedBox.Point1.X, pcb_crosshair.AttachedBox.Point1.Y, 0); + pcb_arc_get_end((pcb_arc_t *) ptr2, 0, &pcb_crosshair.AttachedBox.Point2.X, &pcb_crosshair.AttachedBox.Point2.Y); + pcb_crosshair.AttachedBox.Point1.X = pcb_crosshair.AttachedBox.Point2.X; + pcb_crosshair.AttachedBox.Point1.Y = pcb_crosshair.AttachedBox.Point2.Y; + pcb_tool_adjust_attached_objects(hl); + if (--pcb_added_lines == 0) + pcb_crosshair.AttachedBox.State = PCB_CH_STATE_SECOND; + } + return pcb_true; +} + +/* XPM */ +static const char *arc_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 3 1", +" c #000000", +". c #6EA5D7", +"o c None", +/* pixels */ +"ooooo.ooooooooooooooo", +"ooooo.ooooooooooooooo", +"ooooo.ooooooooooooooo", +"ooooo.ooooooooooooooo", +"oooooo.oooooooooooooo", +"oooooo.oooooooooooooo", +"ooooooo.ooooooooooooo", +"ooooooo..oooooooooooo", +"oooooooo..ooooooooooo", +"oooooooooo..ooooooooo", +"oooooooooooo....ooooo", +"ooooooooooooooooooooo", +"ooo oooo oooo oo", +"oo o ooo ooo oo ooo o", +"oo o ooo ooo oo ooo o", +"o ooo oo ooo ooooo", +"o oo ooooo ooooo", +"o ooo oo o oooo ooooo", +"o ooo oo oo ooo ooo o", +"o ooo oo ooo ooo oo", +"ooooooooooooooooooooo" +}; + +pcb_tool_t pcb_tool_arc = { + "arc", NULL, NULL, 100, arc_icon, PCB_TOOL_CURSOR_NAMED("question_arrow"), 0, + pcb_tool_arc_init, + pcb_tool_arc_uninit, + pcb_tool_arc_notify_mode, + NULL, + pcb_tool_arc_adjust_attached_objects, + pcb_tool_arc_draw_attached, + pcb_tool_arc_undo_act, + NULL, + + pcb_false +}; Index: trunk/src_plugins/tool_std/tool_arc.h =================================================================== --- trunk/src_plugins/tool_std/tool_arc.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_arc.h (revision 29304) @@ -0,0 +1,8 @@ +extern pcb_tool_t pcb_tool_arc; + +void pcb_tool_arc_init(void); +void pcb_tool_arc_uninit(void); +void pcb_tool_arc_notify_mode(pcb_hidlib_t *hl); +void pcb_tool_arc_adjust_attached_objects(pcb_hidlib_t *hl); +void pcb_tool_arc_draw_attached(pcb_hidlib_t *hl); +pcb_bool pcb_tool_arc_undo_act(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_arrow.c =================================================================== --- trunk/src_plugins/tool_std/tool_arrow.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_arrow.c (revision 29304) @@ -0,0 +1,280 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" +#include "conf_core.h" + +#include "board.h" +#include "buffer.h" +#include "crosshair.h" +#include "data.h" +#include +#include "remove.h" +#include "move.h" +#include "search.h" +#include "select.h" +#include "tool.h" +#include "undo.h" +#include "extobj.h" + + +void pcb_tool_arrow_uninit(void) +{ + pcb_notify_crosshair_change(pcb_false); + pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; + pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; + pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; + pcb_notify_crosshair_change(pcb_true); +} + +/* Called some time after the click if there was a release but no second click + a.k.a. finalize single click (some things are already done in pcb_notify_mode + at the initial click event) */ +static void click_timer_cb(pcb_hidval_t hv) +{ + pcb_hidlib_t *hl = hv.ptr; + pcb_board_t *pcb = hv.ptr; + + if (pcb_tool_note.Click) { + pcb_notify_crosshair_change(pcb_false); + pcb_tool_note.Click = pcb_false; + if (pcb_tool_note.Moving && !pcb_gui->shift_is_pressed(pcb_gui)) { + pcb_grabbed.status = pcb_true; + pcb_tool_note.Buffer = conf_core.editor.buffer_number; + pcb_buffer_set_number(PCB_MAX_BUFFER - 1); + pcb_buffer_clear(pcb, PCB_PASTEBUFFER); + pcb_buffer_add_selected(pcb, PCB_PASTEBUFFER, pcb_tool_note.X, pcb_tool_note.Y, pcb_true, pcb_true); + pcb_undo_save_serial(); + pcb_remove_selected(pcb_false); + pcb_tool_save(hl); + pcb_tool_is_saved = pcb_true; + pcb_tool_select_by_id(hl, PCB_MODE_PASTE_BUFFER); + } + else if (pcb_tool_note.Hit && !pcb_gui->shift_is_pressed(pcb_gui)) { + pcb_box_t box; + + pcb_grabbed.status = pcb_true; + pcb_tool_save(hl); + pcb_tool_is_saved = pcb_true; + pcb_tool_select_by_id(hl, pcb_gui->control_is_pressed(pcb_gui)? PCB_MODE_COPY : PCB_MODE_MOVE); + pcb_crosshair.AttachedObject.Ptr1 = pcb_tool_note.ptr1; + pcb_crosshair.AttachedObject.Ptr2 = pcb_tool_note.ptr2; + pcb_crosshair.AttachedObject.Ptr3 = pcb_tool_note.ptr3; + pcb_crosshair.AttachedObject.Type = pcb_tool_note.Hit; + + if (pcb_crosshair.drags != NULL) { + free(pcb_crosshair.drags); + pcb_crosshair.drags = NULL; + } + pcb_crosshair.dragx = pcb_tool_note.X; + pcb_crosshair.dragy = pcb_tool_note.Y; + box.X1 = pcb_tool_note.X + PCB_SLOP * pcb_pixel_slop; + box.X2 = pcb_tool_note.X - PCB_SLOP * pcb_pixel_slop; + box.Y1 = pcb_tool_note.Y + PCB_SLOP * pcb_pixel_slop; + box.Y2 = pcb_tool_note.Y - PCB_SLOP * pcb_pixel_slop; + pcb_crosshair.drags = pcb_list_block(pcb, &box, &pcb_crosshair.drags_len); + pcb_crosshair.drags_current = 0; + pcb_tool_attach_for_copy(hl, pcb_tool_note.X, pcb_tool_note.Y, pcb_true); + } + else { + pcb_box_t box; + + pcb_tool_note.Hit = 0; + pcb_tool_note.Moving = pcb_false; + pcb_undo_save_serial(); + box.X1 = -PCB_MAX_COORD; + box.Y1 = -PCB_MAX_COORD; + box.X2 = PCB_MAX_COORD; + box.Y2 = PCB_MAX_COORD; + /* unselect first if shift key not down */ + if (!pcb_gui->shift_is_pressed(pcb_gui) && pcb_select_block(pcb, &box, pcb_false, pcb_false, pcb_false)) + pcb_board_set_changed_flag(pcb_true); + pcb_tool_notify_block(); + pcb_crosshair.AttachedBox.Point1.X = pcb_tool_note.X; + pcb_crosshair.AttachedBox.Point1.Y = pcb_tool_note.Y; + } + pcb_notify_crosshair_change(pcb_true); + } + + if (pcb_crosshair.extobj_edit != NULL) { + pcb_extobj_float_geo(pcb_crosshair.extobj_edit); + pcb_gui->invalidate_all(pcb_gui); + } +} + +void pcb_tool_arrow_notify_mode(pcb_hidlib_t *hl) +{ + void *ptr1, *ptr2, *ptr3; + int otype, type; + int test; + pcb_hidval_t hv; + + pcb_tool_note.Click = pcb_true; + /* do something after click time */ + hv.ptr = hl; + pcb_gui->add_timer(pcb_gui, click_timer_cb, conf_core.editor.click_time, hv); + + /* see if we clicked on something already selected + * (pcb_tool_note.Moving) or clicked on a MOVE_TYPE + * (pcb_tool_note.Hit) + */ + for (test = (PCB_SELECT_TYPES | PCB_MOVE_TYPES | PCB_OBJ_FLOATER | PCB_LOOSE_SUBC(PCB)) & ~PCB_OBJ_RAT; test; test &= ~otype) { + /* grab object/point (e.g. line endpoint) for edit */ + otype = type = pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, test, &ptr1, &ptr2, &ptr3); + if (otype == PCB_OBJ_ARC_POINT) { /* ignore arc endpoints if arc radius is 0 (so arc center is grabbed) */ + pcb_arc_t *arc = (pcb_arc_t *)ptr2; + if ((arc->Width == 0) && (arc->Height == 0)) + continue; + } + if (!pcb_tool_note.Hit && (type & PCB_MOVE_TYPES) && !PCB_FLAG_TEST(PCB_FLAG_LOCK, (pcb_any_obj_t *) ptr2)) { + pcb_tool_note.Hit = type; + pcb_tool_note.ptr1 = ptr1; + pcb_tool_note.ptr2 = ptr2; + pcb_tool_note.ptr3 = ptr3; + pcb_crosshair.AttachedObject.tx = pcb_tool_note.X; + pcb_crosshair.AttachedObject.ty = pcb_tool_note.Y; + } + if (!pcb_tool_note.Moving && (type & (PCB_SELECT_TYPES | PCB_LOOSE_SUBC(PCB))) && PCB_FLAG_TEST(PCB_FLAG_SELECTED, (pcb_any_obj_t *) ptr2)) { + pcb_tool_note.Moving = pcb_true; + /* remember where the user clicked to start this op */ + pcb_crosshair.AttachedObject.tx = pcb_crosshair.AttachedObject.X = pcb_tool_note.X; + pcb_crosshair.AttachedObject.ty = pcb_crosshair.AttachedObject.Y = pcb_tool_note.Y; + } + if ((pcb_tool_note.Hit && pcb_tool_note.Moving) || type == PCB_OBJ_VOID) + return; + } +} + +void pcb_tool_arrow_release_mode(pcb_hidlib_t *hl) +{ + pcb_box_t box; + pcb_board_t *pcb = (pcb_board_t *)hl; + + if (pcb_tool_note.Click) { + pcb_box_t box; + + box.X1 = -PCB_MAX_COORD; + box.Y1 = -PCB_MAX_COORD; + box.X2 = PCB_MAX_COORD; + box.Y2 = PCB_MAX_COORD; + + pcb_tool_note.Click = pcb_false; /* inhibit timer action */ + pcb_undo_save_serial(); + /* unselect first if shift key not down */ + if (!pcb_gui->shift_is_pressed(pcb_gui)) { + if (pcb_select_block(pcb, &box, pcb_false, pcb_false, pcb_false)) + pcb_board_set_changed_flag(pcb_true); + if (pcb_tool_note.Moving) { + pcb_tool_note.Moving = 0; + pcb_tool_note.Hit = 0; + return; + } + } + /* Restore the SN so that if we select something the deselect/select combo + gets the same SN. */ + pcb_undo_restore_serial(); + if (pcb_select_object(PCB)) + pcb_board_set_changed_flag(pcb_true); + else + pcb_undo_inc_serial(); /* We didn't select anything new, so, the deselection should get its own SN. */ + pcb_tool_note.Hit = 0; + pcb_tool_note.Moving = 0; + } + else if (pcb_crosshair.AttachedBox.State == PCB_CH_STATE_SECOND) { + box.X1 = pcb_crosshair.AttachedBox.Point1.X; + box.Y1 = pcb_crosshair.AttachedBox.Point1.Y; + box.X2 = pcb_crosshair.AttachedBox.Point2.X; + box.Y2 = pcb_crosshair.AttachedBox.Point2.Y; + + pcb_undo_restore_serial(); + if (pcb_select_block(pcb, &box, pcb_true, pcb_true, pcb_false)) + pcb_board_set_changed_flag(pcb_true); + else if (pcb_bumped) + pcb_undo_inc_serial(); + pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; + } +} + +void pcb_tool_arrow_adjust_attached_objects(pcb_hidlib_t *hl) +{ + if (pcb_crosshair.AttachedBox.State) { + pcb_crosshair.AttachedBox.Point2.X = pcb_crosshair.X; + pcb_crosshair.AttachedBox.Point2.Y = pcb_crosshair.Y; + } +} + +/* XPM */ +static const char *arrow_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 3 1", +" c #000000", +". c #6EA5D7", +"o c None", +/* pixels */ +"oo .. ooooooooooooooo", +"oo .... ooooooooooooo", +"ooo ...... oooooooooo", +"ooo ........ oooooooo", +"ooo ....... ooooooooo", +"oooo ..... oooooooooo", +"oooo ...... ooooooooo", +"ooooo .. ... oooooooo", +"ooooo . o ... ooooooo", +"oooooooooo ... oooooo", +"ooooooooooo .. oooooo", +"oooooooooooo ooooooo", +"ooooooooooooooooooooo", +"ooo ooo ooo ooo", +"oo o oo ooo oo ooo oo", +"oo o oo ooo oo ooo oo", +"o ooo o ooo ooo", +"o ooo o ooo oo ooo oo", +"o o ooo oo ooo oo", +"o ooo o ooo oo ooo oo", +"o ooo o ooo oo ooo oo" +}; + +pcb_tool_t pcb_tool_arrow = { + "arrow", NULL, NULL, 10, arrow_icon, PCB_TOOL_CURSOR_NAMED("left_ptr"), 0, + NULL, + pcb_tool_arrow_uninit, + pcb_tool_arrow_notify_mode, + pcb_tool_arrow_release_mode, + pcb_tool_arrow_adjust_attached_objects, + NULL, + NULL, + NULL, + + pcb_true +}; Index: trunk/src_plugins/tool_std/tool_arrow.h =================================================================== --- trunk/src_plugins/tool_std/tool_arrow.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_arrow.h (revision 29304) @@ -0,0 +1,6 @@ +extern pcb_tool_t pcb_tool_arrow; + +void pcb_tool_arrow_uninit(void); +void pcb_tool_arrow_notify_mode(pcb_hidlib_t *hl); +void pcb_tool_arrow_release_mode(pcb_hidlib_t *hl); +void pcb_tool_arrow_adjust_attached_objects(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_buffer.c =================================================================== --- trunk/src_plugins/tool_std/tool_buffer.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_buffer.c (revision 29304) @@ -0,0 +1,144 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" +#include "conf_core.h" + +#include "board.h" +#include "buffer.h" +#include +#include "data.h" +#include +#include +#include "search.h" +#include "tool.h" +#include "undo.h" + +void pcb_tool_buffer_init(void) +{ +} + +void pcb_tool_buffer_uninit(void) +{ +} + +static void pcb_tool_buffer_notify_mode_(pcb_hidlib_t *hl, pcb_bool keep_ids) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + + if (pcb_gui->shift_is_pressed(pcb_gui)) { + pcb_actionva(hl, "ReplaceFootprint", "object", "@buffer", "dumb", NULL); + return; + } + + if (pcb_buffer_copy_to_layout(pcb, pcb_crosshair.AttachedObject.tx, pcb_crosshair.AttachedObject.ty, keep_ids)) { + pcb_board_set_changed_flag(pcb_true); + pcb_gui->invalidate_all(pcb_gui); + } +} + +void pcb_tool_buffer_notify_mode(pcb_hidlib_t *hl) +{ + pcb_tool_buffer_notify_mode_(hl, pcb_false); +} + +void pcb_tool_buffer_release_mode(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + + if (pcb_tool_note.Moving) { + pcb_undo_restore_serial(); + pcb_tool_buffer_notify_mode_(hl, pcb_true); + pcb_buffer_clear(pcb, PCB_PASTEBUFFER); + pcb_buffer_set_number(pcb_tool_note.Buffer); + pcb_tool_note.Moving = pcb_false; + pcb_tool_note.Hit = 0; + } +} + +void pcb_tool_buffer_adjust_attached_objects(pcb_hidlib_t *hl) +{ + pcb_crosshair.AttachedObject.tx = pcb_crosshair.X; + pcb_crosshair.AttachedObject.ty = pcb_crosshair.Y; +} + +void pcb_tool_buffer_draw_attached(pcb_hidlib_t *hl) +{ + pcb_xordraw_buffer(PCB_PASTEBUFFER); +} + +/* XPM */ +static const char *buf_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 3 1", +" c #000000", +". c #7A8584", +"o c None", +/* pixels */ +"oooooooo oo ooooooo", +"oooooo.. o o ..ooooo", +"oooooooo oooo ooooooo", +"oooooo.. oooo ..ooooo", +"oooooooo oooo ooooooo", +"oooooo.. oooo ..ooooo", +"oooooooo oooo ooooooo", +"oooooo.. oooo ..ooooo", +"oooooooo oooo ooooooo", +"oooooo.. oooo ..ooooo", +"oooooooo ooooooo", +"ooooooooooooooooooooo", +"oo oo ooo o o", +"ooo ooo o ooo o ooooo", +"ooo ooo o ooo o ooooo", +"ooo ooo o ooo o oo", +"ooo oo ooo o ooooo", +"ooo ooo o ooo o ooooo", +"ooo ooo o ooo o ooooo", +"oo ooo oo ooooo", +"ooooooooooooooooooooo" +}; + +pcb_tool_t pcb_tool_buffer = { + "buffer", NULL, NULL, 100, buf_icon, PCB_TOOL_CURSOR_NAMED("hand"), 0, + pcb_tool_buffer_init, + pcb_tool_buffer_uninit, + pcb_tool_buffer_notify_mode, + pcb_tool_buffer_release_mode, + pcb_tool_buffer_adjust_attached_objects, + pcb_tool_buffer_draw_attached, + NULL, + NULL, + + pcb_true +}; Index: trunk/src_plugins/tool_std/tool_buffer.h =================================================================== --- trunk/src_plugins/tool_std/tool_buffer.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_buffer.h (revision 29304) @@ -0,0 +1,7 @@ +extern pcb_tool_t pcb_tool_buffer; + +void pcb_tool_buffer_init(void); +void pcb_tool_buffer_uninit(void); +void pcb_tool_buffer_notify_mode(pcb_hidlib_t *hl); +void pcb_tool_buffer_release_mode(pcb_hidlib_t *hl); +void pcb_tool_buffer_draw_attached(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_copy.c =================================================================== --- trunk/src_plugins/tool_std/tool_copy.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_copy.c (revision 29304) @@ -0,0 +1,133 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" + +#include "board.h" +#include "move.h" +#include "crosshair.h" +#include "search.h" +#include "tool.h" + +void pcb_tool_copy_uninit(void) +{ + pcb_notify_crosshair_change(pcb_false); + pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; + pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; + pcb_notify_crosshair_change(pcb_true); + pcb_crosshair.extobj_edit = NULL; +} + +void pcb_tool_copy_notify_mode(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + + switch (pcb_crosshair.AttachedObject.State) { + /* first notify, lookup object */ + case PCB_CH_STATE_FIRST: + { + int types = PCB_COPY_TYPES; + + pcb_crosshair.AttachedObject.Type = + pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, types, + &pcb_crosshair.AttachedObject.Ptr1, &pcb_crosshair.AttachedObject.Ptr2, &pcb_crosshair.AttachedObject.Ptr3); + if (pcb_crosshair.AttachedObject.Type != PCB_OBJ_VOID) { + pcb_tool_attach_for_copy(hl, pcb_tool_note.X, pcb_tool_note.Y, pcb_false); + } + break; + } + + /* second notify, move or copy object */ + case PCB_CH_STATE_SECOND: + + if ((pcb->is_footprint) && (pcb_crosshair.AttachedObject.Type == PCB_OBJ_SUBC)) { + pcb_message(PCB_MSG_WARNING, "Can not copy subcircuit in the footprint edit mode\n"); + } + else { + pcb_copy_obj(pcb_crosshair.AttachedObject.Type, + pcb_crosshair.AttachedObject.Ptr1, + pcb_crosshair.AttachedObject.Ptr2, + pcb_crosshair.AttachedObject.Ptr3, pcb_crosshair.AttachedObject.tx - pcb_crosshair.AttachedObject.X, pcb_crosshair.AttachedObject.ty - pcb_crosshair.AttachedObject.Y); + pcb_subc_as_board_update(PCB); + pcb_board_set_changed_flag(pcb_true); + } + + /* reset identifiers */ + pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; + pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; + pcb_crosshair.extobj_edit = NULL; + break; + } +} + +void pcb_tool_copy_release_mode(pcb_hidlib_t *hl) +{ + if (pcb_tool_note.Hit) { + pcb_tool_copy_notify_mode(hl); + pcb_tool_note.Hit = 0; + } +} + +void pcb_tool_copy_adjust_attached_objects(pcb_hidlib_t *hl) +{ + pcb_crosshair.AttachedObject.tx = pcb_crosshair.X; + pcb_crosshair.AttachedObject.ty = pcb_crosshair.Y; +} + +void pcb_tool_copy_draw_attached(pcb_hidlib_t *hl) +{ + pcb_xordraw_movecopy(); +} + +pcb_bool pcb_tool_copy_undo_act(pcb_hidlib_t *hl) +{ + /* don't allow undo in the middle of an operation */ + if (pcb_crosshair.AttachedObject.State != PCB_CH_STATE_FIRST) + return pcb_false; + return pcb_true; +} + +pcb_tool_t pcb_tool_copy = { + "copy", NULL, NULL, 100, NULL, PCB_TOOL_CURSOR_NAMED("crosshair"), 0, + NULL, + pcb_tool_copy_uninit, + pcb_tool_copy_notify_mode, + pcb_tool_copy_release_mode, + pcb_tool_copy_adjust_attached_objects, + pcb_tool_copy_draw_attached, + pcb_tool_copy_undo_act, + NULL, + + pcb_true +}; Index: trunk/src_plugins/tool_std/tool_copy.h =================================================================== --- trunk/src_plugins/tool_std/tool_copy.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_copy.h (revision 29304) @@ -0,0 +1,7 @@ +extern pcb_tool_t pcb_tool_copy; + +void pcb_tool_copy_uninit(void); +void pcb_tool_copy_notify_mode(pcb_hidlib_t *hl); +void pcb_tool_copy_release_mode(pcb_hidlib_t *hl); +void pcb_tool_copy_draw_attached(pcb_hidlib_t *hl); +pcb_bool pcb_tool_copy_undo_act(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_insert.c =================================================================== --- trunk/src_plugins/tool_std/tool_insert.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_insert.c (revision 29304) @@ -0,0 +1,180 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" + +#include "board.h" +#include "crosshair.h" +#include "insert.h" +#include "polygon.h" +#include "search.h" +#include "tool.h" + + +static struct { + pcb_poly_t *poly; + pcb_line_t line; +} fake; + +static pcb_point_t InsertedPoint; +static pcb_cardinal_t polyIndex = 0; + + +void pcb_tool_insert_uninit(void) +{ + pcb_notify_crosshair_change(pcb_false); + pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; + pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; + pcb_crosshair.extobj_edit = NULL; + pcb_notify_crosshair_change(pcb_true); +} + +void pcb_tool_insert_notify_mode(pcb_hidlib_t *hl) +{ + switch (pcb_crosshair.AttachedObject.State) { + /* first notify, lookup object */ + case PCB_CH_STATE_FIRST: + pcb_crosshair.AttachedObject.Type = + pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, PCB_INSERT_TYPES, + &pcb_crosshair.AttachedObject.Ptr1, &pcb_crosshair.AttachedObject.Ptr2, &pcb_crosshair.AttachedObject.Ptr3); + + if (pcb_crosshair.AttachedObject.Type != PCB_OBJ_VOID) { + pcb_any_obj_t *obj = (pcb_any_obj_t *)pcb_crosshair.AttachedObject.Ptr2; + if (PCB_FLAG_TEST(PCB_FLAG_LOCK, obj)) { + pcb_message(PCB_MSG_WARNING, "Sorry, %s object is locked\n", pcb_obj_type_name(obj->type)); + pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; + pcb_crosshair.extobj_edit = NULL; + break; + } + else { + /* get starting point of nearest segment */ + if (pcb_crosshair.AttachedObject.Type == PCB_OBJ_POLY) { + fake.poly = (pcb_poly_t *) pcb_crosshair.AttachedObject.Ptr2; + polyIndex = pcb_poly_get_lowest_distance_point(fake.poly, pcb_tool_note.X, pcb_tool_note.Y); + fake.line.Point1 = fake.poly->Points[polyIndex]; + fake.line.Point2 = fake.poly->Points[pcb_poly_contour_prev_point(fake.poly, polyIndex)]; + pcb_crosshair.AttachedObject.Ptr2 = &fake.line; + + } + pcb_crosshair.AttachedObject.State = PCB_CH_STATE_SECOND; + InsertedPoint = *pcb_adjust_insert_point(); + } + } + break; + + /* second notify, insert new point into object */ + case PCB_CH_STATE_SECOND: + if (pcb_crosshair.AttachedObject.Type == PCB_OBJ_POLY) + pcb_insert_point_in_object(PCB_OBJ_POLY, + pcb_crosshair.AttachedObject.Ptr1, fake.poly, + &polyIndex, InsertedPoint.X, InsertedPoint.Y, pcb_false, pcb_false); + else + pcb_insert_point_in_object(pcb_crosshair.AttachedObject.Type, + pcb_crosshair.AttachedObject.Ptr1, + pcb_crosshair.AttachedObject.Ptr2, &polyIndex, InsertedPoint.X, InsertedPoint.Y, pcb_false, pcb_false); + pcb_board_set_changed_flag(pcb_true); + + /* reset identifiers */ + pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; + pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; + pcb_crosshair.extobj_edit = NULL; + break; + } +} + +void pcb_tool_insert_adjust_attached_objects(pcb_hidlib_t *hl) +{ + pcb_point_t *pnt; + pnt = pcb_adjust_insert_point(); + if (pnt) + InsertedPoint = *pnt; +} + +void pcb_tool_insert_draw_attached(pcb_hidlib_t *hl) +{ + pcb_xordraw_insert_pt_obj(); +} + +pcb_bool pcb_tool_insert_undo_act(pcb_hidlib_t *hl) +{ + /* don't allow undo in the middle of an operation */ + if (pcb_crosshair.AttachedObject.State != PCB_CH_STATE_FIRST) + return pcb_false; + return pcb_true; +} + +/* XPM */ +static const char *ins_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 3 1", +" c #000000", +". c #6EA5D7", +"o c None", +/* pixels */ +"oooooo...oooooooooooo", +"ooooo.ooo.ooooooooooo", +"ooooo.o.o.ooooooooooo", +"oooooo....ooooooooooo", +"ooooooooooooooooooooo", +"oooo ooooo oooooooo", +"ooooooooooooooooooooo", +"oo...ooooooooooo...oo", +"o.oo..ooooooooo.ooo.o", +"o.o o...........o o.o", +"o.ooo.ooooooooo.ooo.o", +"oo...ooooooooooo...oo", +"ooooooooooooooooooooo", +"ooo o ooo oo ooo", +"oooo oo ooo o ooooooo", +"oooo oo oo o ooooooo", +"oooo oo o o oo oooo", +"oooo oo oo ooooo ooo", +"oooo oo ooo ooooo ooo", +"oooo oo ooo ooooo ooo", +"ooo o ooo o oooo" +}; + +pcb_tool_t pcb_tool_insert = { + "insert", NULL, NULL, 100, ins_icon, PCB_TOOL_CURSOR_NAMED("dotbox"), 0, + NULL, + pcb_tool_insert_uninit, + pcb_tool_insert_notify_mode, + NULL, + pcb_tool_insert_adjust_attached_objects, + pcb_tool_insert_draw_attached, + pcb_tool_insert_undo_act, + NULL, + + pcb_true +}; Index: trunk/src_plugins/tool_std/tool_insert.h =================================================================== --- trunk/src_plugins/tool_std/tool_insert.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_insert.h (revision 29304) @@ -0,0 +1,7 @@ +extern pcb_tool_t pcb_tool_insert; + +void pcb_tool_insert_uninit(void); +void pcb_tool_insert_notify_mode(pcb_hidlib_t *hl); +void pcb_tool_insert_adjust_attached_objects(pcb_hidlib_t *hl); +void pcb_tool_insert_draw_attached(pcb_hidlib_t *hl); +pcb_bool pcb_tool_insert_undo_act(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_line.c =================================================================== --- trunk/src_plugins/tool_std/tool_line.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_line.c (revision 29304) @@ -0,0 +1,522 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" + +#include "conf_core.h" +#include + +#include "board.h" +#include "crosshair.h" +#include "data.h" +#include "draw.h" +#include "draw_wireframe.h" +#include "find.h" +#include "obj_line.h" +#include "obj_subc.h" +#include "search.h" +#include "tool.h" +#include "undo.h" +#include "netlist.h" + +#include "obj_line_draw.h" +#include "obj_pstk_draw.h" +#include "obj_rat_draw.h" +#include "route_draw.h" + +TODO("pstk: remove this when via is removed and the padstack is created from style directly") +#include "src_plugins/lib_compat_help/pstk_compat.h" + +static pcb_layer_t *last_layer; + + +void pcb_tool_line_init(void) +{ + pcb_notify_crosshair_change(pcb_false); + if (pcb_tool_prev_id == PCB_MODE_ARC && pcb_crosshair.AttachedBox.State != PCB_CH_STATE_FIRST) { + pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; + pcb_crosshair.AttachedLine.State = PCB_CH_STATE_SECOND; + pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X = pcb_crosshair.AttachedBox.Point1.X; + pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y = pcb_crosshair.AttachedBox.Point1.Y; + pcb_tool_adjust_attached_objects(NULL); + } + else { + if (conf_core.editor.auto_drc) { + if (pcb_data_clear_flag(PCB->Data, PCB_FLAG_FOUND, 1, 1) > 0) { + pcb_undo_inc_serial(); + pcb_draw(); + } + } + } + pcb_notify_crosshair_change(pcb_true); +} + +void pcb_tool_line_uninit(void) +{ + pcb_notify_crosshair_change(pcb_false); + pcb_added_lines = 0; + pcb_route_reset(&pcb_crosshair.Route); + if (pcb_tool_next_id != PCB_MODE_ARC) { + pcb_crosshair.AttachedLine.State = PCB_CH_STATE_FIRST; + if (!pcb_marked.user_placed) + pcb_crosshair_set_local_ref(0, 0, pcb_false); + } + pcb_notify_crosshair_change(pcb_true); +} + +/* creates points of a line (when clicked) */ +static void notify_line(pcb_hidlib_t *hl) +{ + int type = PCB_OBJ_VOID; + void *ptr1, *ptr2, *ptr3; + pcb_board_t *pcb = (pcb_board_t *)hl; + + if ((!pcb_marked.status || conf_core.editor.local_ref) && !pcb_marked.user_placed) + pcb_crosshair_set_local_ref(pcb_crosshair.X, pcb_crosshair.Y, pcb_true); + switch (pcb_crosshair.AttachedLine.State) { + case PCB_CH_STATE_FIRST: /* first point */ +TODO("subc: this should work on heavy terminals too!") + if (pcb->RatDraw && pcb_search_screen(pcb_crosshair.X, pcb_crosshair.Y, PCB_OBJ_PSTK | PCB_OBJ_SUBC_PART, &ptr1, &ptr1, &ptr1) == PCB_OBJ_VOID) { + pcb_gui->beep(pcb_gui); + break; + } + if (conf_core.editor.auto_drc) { + pcb_find_t fctx; + type = pcb_search_screen(pcb_crosshair.X, pcb_crosshair.Y, PCB_OBJ_PSTK | PCB_OBJ_SUBC_PART, &ptr1, &ptr2, &ptr3); + memset(&fctx, 0, sizeof(fctx)); + fctx.flag_set = PCB_FLAG_FOUND; + fctx.flag_chg_undoable = 1; + pcb_find_from_xy(&fctx, pcb->Data, pcb_crosshair.X, pcb_crosshair.Y); + pcb_find_free(&fctx); + } + if (type == PCB_OBJ_PSTK) { + pcb_pstk_t *pstk = (pcb_pstk_t *)ptr2; + pcb_crosshair.AttachedLine.Point1.X = pstk->x; + pcb_crosshair.AttachedLine.Point1.Y = pstk->y; + } + else { + pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X = pcb_crosshair.X; + pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y = pcb_crosshair.Y; + } + pcb_crosshair.AttachedLine.State = PCB_CH_STATE_SECOND; + break; + + case PCB_CH_STATE_SECOND: + /* fall through to third state too */ + last_layer = PCB_CURRLAYER(pcb); + default: /* all following points */ + pcb_crosshair.AttachedLine.State = PCB_CH_STATE_THIRD; + break; + } +} + +void pcb_tool_line_notify_mode(pcb_hidlib_t *hl) +{ + void *ptr1, *ptr2, *ptr3; + pcb_board_t *pcb = (pcb_board_t *)hl; + + /* do update of position */ + notify_line(hl); + if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_THIRD) + return; + /* Remove anchor if clicking on start point; + * this means we can't paint 0 length lines + * which could be used for square SMD pads. + * Instead use a very small delta, or change + * the file after saving. + */ + if (pcb_crosshair.X == pcb_crosshair.AttachedLine.Point1.X && pcb_crosshair.Y == pcb_crosshair.AttachedLine.Point1.Y) { + pcb_tool_select_by_id(hl, PCB_MODE_LINE); + return; + } + + if (pcb->RatDraw) { + pcb_rat_t *line = pcb_net_create_by_rat_coords(pcb, pcb_crosshair.AttachedLine.Point1.X, pcb_crosshair.AttachedLine.Point1.Y, pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y, 1); + + if (line != NULL) { + pcb_added_lines++; + pcb_undo_add_obj_to_create(PCB_OBJ_RAT, line, line, line); + pcb_undo_inc_serial(); + pcb_rat_invalidate_draw(line); + pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X; + pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y; + pcb_draw(); + } + return; + } + else if(pcb_crosshair.Route.size > 0) + { + pcb_pstk_t *ps = NULL; + + /* place a via if vias are visible, the layer is + in a new group since the last line and there + isn't a pin already here */ +TODO("pstk #21: do not work in comp mode, use a pstk proto - scconfig also has TODO #21, fix it there too") + if (conf_core.editor.auto_via && pcb->pstk_on + && pcb_layer_get_group_(PCB_CURRLAYER(pcb)) != pcb_layer_get_group_(last_layer) + && pcb_search_obj_by_location(PCB_OBJ_CLASS_PIN, &ptr1, &ptr2, &ptr3, + pcb_crosshair.AttachedLine.Point1.X, + pcb_crosshair.AttachedLine.Point1.Y, + conf_core.design.via_thickness / 2) == + PCB_OBJ_VOID + && (pcb_layer_flags_(PCB_CURRLAYER(pcb)) & PCB_LYT_COPPER) + && (pcb_layer_flags_(last_layer) & PCB_LYT_COPPER) + && (!pcb->is_footprint) + && ((ps = pcb_pstk_new_compat_via(pcb->Data, -1, + pcb_crosshair.AttachedLine.Point1.X, + pcb_crosshair.AttachedLine.Point1.Y, + conf_core.design.via_drilling_hole, conf_core.design.via_thickness, conf_core.design.clearance, + 0, PCB_PSTK_COMPAT_ROUND, pcb_true)) != NULL)) { + pcb_obj_add_attribs((pcb_any_obj_t *)ps, pcb->pen_attr, NULL); + pcb_undo_add_obj_to_create(PCB_OBJ_PSTK, ps, ps, ps); + } + + /* Add the route to the design */ + pcb_route_apply(&pcb_crosshair.Route); + + /* move to new start point */ + pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.Route.end_point.X; + pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.Route.end_point.Y; + pcb_crosshair.AttachedLine.Point2.X = pcb_crosshair.Route.end_point.X; + pcb_crosshair.AttachedLine.Point2.Y = pcb_crosshair.Route.end_point.Y; + + /* automatic swap of line refraction after each click - should work only if refraction is in effect (no ortho, no alldir) */ + if (conf_core.editor.swap_start_direction && (conf_core.editor.line_refraction != 0) && !conf_core.editor.all_direction_lines) + pcb_conf_setf(CFR_DESIGN,"editor/line_refraction", -1, "%d",conf_core.editor.line_refraction ^ 3); + + if (conf_core.editor.orthogonal_moves) { + /* set the mark to the new starting point so ortho works as expected and we can draw a perpendicular line from here */ + pcb_grabbed.X = pcb_crosshair.Route.end_point.X; + pcb_grabbed.Y = pcb_crosshair.Route.end_point.Y; + pcb_grabbed.status = pcb_true; + } + + if (ps) + pcb_pstk_invalidate_draw(ps); + + pcb_draw(); + pcb_undo_inc_serial(); + last_layer = PCB_CURRLAYER(pcb); + } + else + /* create line if both ends are determined && length != 0 */ + { + pcb_line_t *line; + int maybe_found_flag; + + if (conf_core.editor.line_refraction + && pcb_crosshair.AttachedLine.Point1.X == + pcb_crosshair.AttachedLine.Point2.X + && pcb_crosshair.AttachedLine.Point1.Y == + pcb_crosshair.AttachedLine.Point2.Y + && (pcb_crosshair.AttachedLine.Point2.X != pcb_tool_note.X || pcb_crosshair.AttachedLine.Point2.Y != pcb_tool_note.Y)) { + /* We will only need to paint the second line segment. + Since we only check for vias on the first segment, + swap them so the non-empty segment is the first segment. */ + pcb_crosshair.AttachedLine.Point2.X = pcb_tool_note.X; + pcb_crosshair.AttachedLine.Point2.Y = pcb_tool_note.Y; + } + + if (conf_core.editor.auto_drc + && (pcb_layer_flags_(PCB_CURRLAYER(pcb)) & PCB_LYT_COPPER)) + maybe_found_flag = PCB_FLAG_FOUND; + else + maybe_found_flag = 0; + + if ((pcb_crosshair.AttachedLine.Point1.X != + pcb_crosshair.AttachedLine.Point2.X || pcb_crosshair.AttachedLine.Point1.Y != pcb_crosshair.AttachedLine.Point2.Y) + && (line = + pcb_line_new_merge(pcb_loose_subc_layer(pcb, PCB_CURRLAYER(pcb), pcb_true), + pcb_crosshair.AttachedLine.Point1.X, + pcb_crosshair.AttachedLine.Point1.Y, + pcb_crosshair.AttachedLine.Point2.X, + pcb_crosshair.AttachedLine.Point2.Y, + conf_core.design.line_thickness, + 2 * conf_core.design.clearance, + pcb_flag_make(maybe_found_flag | + (conf_core.editor.clear_line ? PCB_FLAG_CLEARLINE : 0)))) != NULL) { + pcb_pstk_t *ps = NULL; + + pcb_added_lines++; + pcb_obj_add_attribs(line, pcb->pen_attr, NULL); + pcb_undo_add_obj_to_create(PCB_OBJ_LINE, PCB_CURRLAYER(pcb), line, line); + pcb_line_invalidate_draw(PCB_CURRLAYER(pcb), line); + /* place a via if vias are visible, the layer is + in a new group since the last line and there + isn't a pin already here */ +TODO("pstk #21: do not work in comp mode, use a pstk proto - scconfig also has TODO #21, fix it there too") + if (pcb->pstk_on + && pcb_layer_get_group_(PCB_CURRLAYER(pcb)) != pcb_layer_get_group_(last_layer) + && (pcb_layer_flags_(PCB_CURRLAYER(pcb)) & PCB_LYT_COPPER) + && (pcb_layer_flags_(last_layer) & PCB_LYT_COPPER) + && (!pcb->is_footprint) + && pcb_search_obj_by_location(PCB_OBJ_CLASS_PIN, &ptr1, &ptr2, &ptr3, + pcb_crosshair.AttachedLine.Point1.X, + pcb_crosshair.AttachedLine.Point1.Y, + conf_core.design.via_thickness / 2) == PCB_OBJ_VOID + && ((ps = pcb_pstk_new_compat_via(pcb->Data, -1, + pcb_crosshair.AttachedLine.Point1.X, + pcb_crosshair.AttachedLine.Point1.Y, + conf_core.design.via_drilling_hole, conf_core.design.via_thickness, conf_core.design.clearance, + 0, PCB_PSTK_COMPAT_ROUND, pcb_true)) != NULL)) { + pcb_obj_add_attribs(ps, pcb->pen_attr, NULL); + pcb_undo_add_obj_to_create(PCB_OBJ_PSTK, ps, ps, ps); + pcb_pstk_invalidate_draw(ps); + } + /* copy the coordinates */ + pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X; + pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y; + pcb_undo_inc_serial(); + last_layer = PCB_CURRLAYER(pcb); + pcb_subc_as_board_update(PCB); + } + if (conf_core.editor.line_refraction && (pcb_tool_note.X != pcb_crosshair.AttachedLine.Point2.X || pcb_tool_note.Y != pcb_crosshair.AttachedLine.Point2.Y) + && (line = + pcb_line_new_merge(pcb_loose_subc_layer(pcb, PCB_CURRLAYER(pcb), pcb_true), + pcb_crosshair.AttachedLine.Point2.X, + pcb_crosshair.AttachedLine.Point2.Y, + pcb_tool_note.X, pcb_tool_note.Y, + conf_core.design.line_thickness, + 2 * conf_core.design.clearance, + pcb_flag_make((conf_core.editor.auto_drc ? PCB_FLAG_FOUND : 0) | + (conf_core.editor.clear_line ? PCB_FLAG_CLEARLINE : 0)))) != NULL) { + pcb_added_lines++; + pcb_obj_add_attribs((pcb_any_obj_t *)line, pcb->pen_attr, NULL); + pcb_undo_add_obj_to_create(PCB_OBJ_LINE, PCB_CURRLAYER(pcb), line, line); + pcb_undo_inc_serial(); + pcb_line_invalidate_draw(PCB_CURRLAYER(pcb), line); + /* move to new start point */ + pcb_crosshair.AttachedLine.Point1.X = pcb_tool_note.X; + pcb_crosshair.AttachedLine.Point1.Y = pcb_tool_note.Y; + pcb_crosshair.AttachedLine.Point2.X = pcb_tool_note.X; + pcb_crosshair.AttachedLine.Point2.Y = pcb_tool_note.Y; + + + if (conf_core.editor.swap_start_direction) { + pcb_conf_setf(CFR_DESIGN,"editor/line_refraction", -1, "%d",conf_core.editor.line_refraction ^ 3); + } + pcb_subc_as_board_update(PCB); + } + if (conf_core.editor.orthogonal_moves) { + /* set the mark to the new starting point so ortho works as expected and we can draw a perpendicular line from here */ + pcb_marked.X = pcb_tool_note.X; + pcb_marked.Y = pcb_tool_note.Y; + } + pcb_draw(); + } +} + +void pcb_tool_line_adjust_attached_objects(pcb_hidlib_t *hl) +{ + /* don't draw outline when ctrl key is pressed */ + if (pcb_gui->control_is_pressed(pcb_gui)) { + pcb_crosshair.AttachedLine.draw = pcb_false; + } + else { + pcb_crosshair.AttachedLine.draw = pcb_true; + pcb_line_adjust_attached(); + } +} + +void pcb_tool_line_draw_attached(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + + if (pcb->RatDraw) { + /* draw only if starting point exists and the line has length */ + if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST && pcb_crosshair.AttachedLine.draw) + pcb_draw_wireframe_line(pcb_crosshair.GC, + pcb_crosshair.AttachedLine.Point1.X, pcb_crosshair.AttachedLine.Point1.Y, + pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y, + 10, 0); + } + else if (pcb_crosshair.Route.size > 0) { + pcb_route_draw(&pcb_crosshair.Route,pcb_crosshair.GC); + if (conf_core.editor.show_drc) + pcb_route_draw_drc(&pcb_crosshair.Route,pcb_crosshair.GC); + pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.attached); + } + else { + /* Draw a circle (0 length line) to show where the line will be placed */ + if (PCB_CURRLAYER(pcb)) + pcb_render->set_color(pcb_crosshair.GC, &PCB_CURRLAYER(pcb)->meta.real.color); + + pcb_draw_wireframe_line(pcb_crosshair.GC, + pcb_crosshair.X, pcb_crosshair.Y, + pcb_crosshair.X, pcb_crosshair.Y, + conf_core.design.line_thickness,0 ); + + if (conf_core.editor.show_drc) { + pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.drc); + pcb_draw_wireframe_line(pcb_crosshair.GC, + pcb_crosshair.X, pcb_crosshair.Y, + pcb_crosshair.X, pcb_crosshair.Y, + conf_core.design.line_thickness + (2 * conf_core.design.bloat), 0); + pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.attached); + } + } +} + +pcb_bool pcb_tool_line_undo_act(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + + if (pcb_crosshair.AttachedLine.State == PCB_CH_STATE_SECOND) { + if (conf_core.editor.auto_drc) + pcb_undo(pcb_true); /* undo the connection find */ + pcb_crosshair.AttachedLine.State = PCB_CH_STATE_FIRST; + pcb_route_reset(&pcb_crosshair.Route); + if (!pcb_marked.user_placed) + pcb_crosshair_set_local_ref(0, 0, pcb_false); + return pcb_false; + } + if (pcb_crosshair.AttachedLine.State == PCB_CH_STATE_THIRD) { + int type; + void *ptr1, *ptr3, *ptrtmp; + pcb_line_t *ptr2; + ptrtmp = &pcb_crosshair.AttachedLine; /* a workaround for the line undo bug */ + /* this search is guaranteed to succeed */ + pcb_search_obj_by_location(PCB_OBJ_LINE | PCB_OBJ_RAT, &ptr1, + &ptrtmp, &ptr3, pcb_crosshair.AttachedLine.Point1.X, pcb_crosshair.AttachedLine.Point1.Y, 0); + ptr2 = (pcb_line_t *) ptrtmp; + + /* save both ends of line */ + pcb_crosshair.AttachedLine.Point2.X = ptr2->Point1.X; + pcb_crosshair.AttachedLine.Point2.Y = ptr2->Point1.Y; + if ((type = pcb_undo(pcb_true)) == 0) + pcb_board_set_changed_flag(pcb_true); + /* check that the undo was of the right type */ + if ((type & PCB_UNDO_CREATE) == 0) { + /* wrong undo type, restore anchor points */ + pcb_crosshair.AttachedLine.Point2.X = pcb_crosshair.AttachedLine.Point1.X; + pcb_crosshair.AttachedLine.Point2.Y = pcb_crosshair.AttachedLine.Point1.Y; + return pcb_false; + } + /* move to new anchor */ + pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X; + pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y; + /* check if an intermediate point was removed */ + if (type & PCB_UNDO_REMOVE) { + /* this search should find the restored line */ + pcb_search_obj_by_location(PCB_OBJ_LINE | PCB_OBJ_RAT, &ptr1, &ptrtmp, &ptr3, pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y, 0); + ptr2 = (pcb_line_t *) ptrtmp; + if (conf_core.editor.auto_drc) { + /* undo loses PCB_FLAG_FOUND */ + PCB_FLAG_SET(PCB_FLAG_FOUND, ptr2); + pcb_line_invalidate_draw(PCB_CURRLAYER(pcb), ptr2); + } + pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X = ptr2->Point2.X; + pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y = ptr2->Point2.Y; + } + pcb_crosshair_grid_fit(pcb_crosshair.X, pcb_crosshair.Y); + pcb_tool_adjust_attached_objects(hl); + if (--pcb_added_lines == 0) { + pcb_crosshair.AttachedLine.State = PCB_CH_STATE_SECOND; + last_layer = PCB_CURRLAYER(pcb); + } + else { + /* this search is guaranteed to succeed too */ + pcb_search_obj_by_location(PCB_OBJ_LINE | PCB_OBJ_RAT, &ptr1, &ptrtmp, &ptr3, pcb_crosshair.AttachedLine.Point1.X, pcb_crosshair.AttachedLine.Point1.Y, 0); + ptr2 = (pcb_line_t *) ptrtmp; + last_layer = (pcb_layer_t *) ptr1; + } + return pcb_false; + } + return pcb_true; +} + +pcb_bool pcb_tool_line_redo_act(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + + if (pcb_crosshair.AttachedLine.State == PCB_CH_STATE_SECOND) + return pcb_false; + if (pcb_redo(pcb_true)) { + pcb_board_set_changed_flag(pcb_true); + if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST) { + pcb_line_t *line = linelist_last(&PCB_CURRLAYER(pcb)->Line); + pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X = line->Point2.X; + pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y = line->Point2.Y; + pcb_added_lines++; + } + } + return pcb_false; +} + +/* XPM */ +static const char *line_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 4 1", +" c #000000", +". c #7A8584", +"X c #6EA5D7", +"O c None", +/* pixels */ +"OOOOOOOOOOOOOOOOOOOOO", +"OO...OOOOOOOOOOOOOOOO", +"O.OOO.OOOOOOOOOOOOOOO", +"O.OXXXOOOOOOOOOOOOOOO", +"O.OOO.XXXOOOOOOOOOOOO", +"OO...OOOOXXXOOOO...OO", +"OOOOOOOOOOOOXXX.OOO.O", +"OOOOOOOOOOOOOOOXXXO.O", +"OOOOOOOOOOOOOOO.OOO.O", +"OOOOOOOOOOOOOOOO...OO", +"OOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOO", +" OOOO O OOOO O O", +" OOOOO OO OOO O OOOO", +" OOOOO OO O OO O OOOO", +" OOOOO OO O OO O OOOO", +" OOOOO OO OO O O OO", +" OOOOO OO OO O O OOOO", +" OOOOO OO OOO O OOOO", +" O O OOOO O O", +"OOOOOOOOOOOOOOOOOOOOO" +}; + + +pcb_tool_t pcb_tool_line = { + "line", NULL, NULL, 100, line_icon, PCB_TOOL_CURSOR_NAMED("pencil"), 0, + pcb_tool_line_init, + pcb_tool_line_uninit, + pcb_tool_line_notify_mode, + NULL, + pcb_tool_line_adjust_attached_objects, + pcb_tool_line_draw_attached, + pcb_tool_line_undo_act, + pcb_tool_line_redo_act, + + pcb_true +}; Index: trunk/src_plugins/tool_std/tool_line.h =================================================================== --- trunk/src_plugins/tool_std/tool_line.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_line.h (revision 29304) @@ -0,0 +1,9 @@ +extern pcb_tool_t pcb_tool_line; + +void pcb_tool_line_init(void); +void pcb_tool_line_uninit(void); +void pcb_tool_line_notify_mode(pcb_hidlib_t *hl); +void pcb_tool_line_adjust_attached_objects(pcb_hidlib_t *hl); +void pcb_tool_line_draw_attached(pcb_hidlib_t *hl); +pcb_bool pcb_tool_line_undo_act(pcb_hidlib_t *hl); +pcb_bool pcb_tool_line_redo_act(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_lock.c =================================================================== --- trunk/src_plugins/tool_std/tool_lock.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_lock.c (revision 29304) @@ -0,0 +1,133 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" + +#include "board.h" +#include "change.h" +#include "data.h" +#include "draw.h" +#include +#include "search.h" +#include "tool.h" +#include "tool_lock.h" + +#define PCB_OBJ_CLASS_LOCK (PCB_OBJ_PSTK | PCB_OBJ_LINE | PCB_OBJ_ARC | PCB_OBJ_POLY | PCB_OBJ_SUBC | PCB_OBJ_TEXT | PCB_OBJ_LOCKED) + +void pcb_tool_lock_notify_mode(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + void *ptr1, *ptr2, *ptr3; + int type; + + type = pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, PCB_OBJ_CLASS_LOCK, &ptr1, &ptr2, &ptr3); + + if (type == PCB_OBJ_SUBC) { + pcb_subc_t *subc = (pcb_subc_t *)ptr2; + pcb_flag_change(pcb, PCB_CHGFLG_TOGGLE, PCB_FLAG_LOCK, PCB_OBJ_SUBC, ptr1, ptr2, ptr3); + + DrawSubc(subc); + pcb_draw(); + pcb_actionva(hl, "Report", "Subc", "log", NULL); + } + else if (type != PCB_OBJ_VOID) { + pcb_text_t *thing = (pcb_text_t *) ptr3; + PCB_FLAG_TOGGLE(PCB_FLAG_LOCK, thing); + if (PCB_FLAG_TEST(PCB_FLAG_LOCK, thing) + && PCB_FLAG_TEST(PCB_FLAG_SELECTED, thing)) { + /* this is not un-doable since LOCK isn't */ + PCB_FLAG_CLEAR(PCB_FLAG_SELECTED, thing); + pcb_draw_obj((pcb_any_obj_t *)ptr2); + pcb_draw(); + } + pcb_actionva(hl, "Report", "Object", "log", NULL); + } +} + +/* XPM */ +static const char *lock_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 2 1", +" c black", +"X c None", +/* pixels */ +"XXXXXXXX XXXXXXXX", +"XXXXXXX XXX XXXXXXX", +"XXXXXXX XXXXX XXXXXXX", +"XXXXXX XXXXX XXXXXX", +"XXXXXX XXXXXXX XXXXXX", +"XXXXXX XXXXXXX XXXXXX", +"XXXX XXXX", +"XXXX XXXXXXXXXXX XXXX", +"XXXX XXXX", +"XXXX XXXXXXXXXXX XXXX", +"XXXX XXXX", +"XXXX XXXXXXXXXXX XXXX", +"XXXX XXXX", +"XXXXXXXXXXXXXXXXXXXXX", +"XX XXXX XXX X XX XX", +"XX XXX XX X XXX XX XX", +"XX XXX XX X XXX X XXX", +"XX XXX XX X XXX XXXX", +"XX XXX XX X XXX X XXX", +"XX XXX XX X XXX XX XX", +"XX XX XXX X XX XX" +}; + +#define lockIcon_width 16 +#define lockIcon_height 16 +static unsigned char lockIcon_bits[] = { + 0x00, 0x00, 0xe0, 0x07, 0x30, 0x0c, 0x10, 0x08, 0x18, 0x18, 0x08, 0x10, + 0x08, 0x00, 0xfc, 0x3f, 0x04, 0x20, 0xfc, 0x3f, 0x04, 0x20, 0xfc, 0x3f, + 0x04, 0x20, 0xfc, 0x3f, 0x04, 0x20, 0xfc, 0x3f}; +#define lockMask_width 16 +#define lockMask_height 16 +static unsigned char lockMask_bits[] = { + 0xf0, 0x0f, 0xf0, 0x0f, 0xf8, 0x1f, 0x38, 0x1c, 0x1c, 0x3c, 0x1c, 0x38, + 0x1c, 0x30, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, + 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f}; + +pcb_tool_t pcb_tool_lock = { + "lock", NULL, NULL, 100, lock_icon, PCB_TOOL_CURSOR_XBM(lockIcon_bits, lockMask_bits), 0, + NULL, + NULL, + pcb_tool_lock_notify_mode, + NULL, + NULL, + NULL, + NULL, + NULL, + + pcb_true +}; Index: trunk/src_plugins/tool_std/tool_lock.h =================================================================== --- trunk/src_plugins/tool_std/tool_lock.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_lock.h (revision 29304) @@ -0,0 +1,3 @@ +extern pcb_tool_t pcb_tool_lock; + +void pcb_tool_lock_notify_mode(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_move.c =================================================================== --- trunk/src_plugins/tool_std/tool_move.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_move.c (revision 29304) @@ -0,0 +1,142 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" + +#include "board.h" +#include "move.h" +#include "crosshair.h" +#include "search.h" +#include "tool.h" +#include "extobj.h" + + +void pcb_tool_move_uninit(void) +{ + pcb_notify_crosshair_change(pcb_false); + pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; + pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; + pcb_notify_crosshair_change(pcb_true); + pcb_crosshair.extobj_edit = NULL; +} + +void pcb_tool_move_notify_mode(pcb_hidlib_t *hl) +{ + pcb_coord_t dx, dy; + + switch (pcb_crosshair.AttachedObject.State) { + /* first notify, lookup object */ + case PCB_CH_STATE_FIRST: + { + int types = PCB_MOVE_TYPES; + + pcb_crosshair.AttachedObject.Type = + pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, types, + &pcb_crosshair.AttachedObject.Ptr1, &pcb_crosshair.AttachedObject.Ptr2, &pcb_crosshair.AttachedObject.Ptr3); + if (pcb_crosshair.AttachedObject.Type != PCB_OBJ_VOID) { + pcb_any_obj_t *obj = (pcb_any_obj_t *)pcb_crosshair.AttachedObject.Ptr2; + if (PCB_FLAG_TEST(PCB_FLAG_LOCK, obj)) { + pcb_message(PCB_MSG_WARNING, "Sorry, %s object is locked\n", pcb_obj_type_name(obj->type)); + pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; + pcb_crosshair.extobj_edit = NULL; + } + else + pcb_tool_attach_for_copy(hl, pcb_tool_note.X, pcb_tool_note.Y, pcb_true); + } + break; + } + + /* second notify, move object */ + case PCB_CH_STATE_SECOND: + dx = pcb_crosshair.AttachedObject.tx - pcb_crosshair.AttachedObject.X; + dy = pcb_crosshair.AttachedObject.ty - pcb_crosshair.AttachedObject.Y; + if ((dx != 0) || (dy != 0)) { + pcb_any_obj_t *newo = pcb_move_obj_and_rubberband(pcb_crosshair.AttachedObject.Type, pcb_crosshair.AttachedObject.Ptr1, pcb_crosshair.AttachedObject.Ptr2, pcb_crosshair.AttachedObject.Ptr3, dx, dy); + pcb_extobj_float_geo(newo); + if (!pcb_marked.user_placed) + pcb_crosshair_set_local_ref(0, 0, pcb_false); + pcb_subc_as_board_update(PCB); + pcb_board_set_changed_flag(pcb_true); + } + else if (pcb_crosshair.extobj_edit != NULL) + pcb_extobj_float_geo(pcb_crosshair.extobj_edit); + + /* reset identifiers */ + pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; + pcb_crosshair.AttachedObject.State = PCB_CH_STATE_FIRST; + pcb_crosshair.extobj_edit = NULL; + break; + } +} + +void pcb_tool_move_release_mode(pcb_hidlib_t *hl) +{ + if (pcb_tool_note.Hit) { + pcb_tool_move_notify_mode(hl); + pcb_tool_note.Hit = 0; + } +} + +void pcb_tool_move_adjust_attached_objects(pcb_hidlib_t *hl) +{ + pcb_crosshair.AttachedObject.tx = pcb_crosshair.X; + pcb_crosshair.AttachedObject.ty = pcb_crosshair.Y; +} + +void pcb_tool_move_draw_attached(pcb_hidlib_t *hl) +{ + pcb_xordraw_movecopy(); +} + +pcb_bool pcb_tool_move_undo_act(pcb_hidlib_t *hl) +{ + /* don't allow undo in the middle of an operation */ + if (pcb_crosshair.AttachedObject.State != PCB_CH_STATE_FIRST) + return pcb_false; + return pcb_true; +} + +pcb_tool_t pcb_tool_move = { + "move", NULL, NULL, 100, NULL, PCB_TOOL_CURSOR_NAMED("crosshair"), 0, + NULL, + pcb_tool_move_uninit, + pcb_tool_move_notify_mode, + pcb_tool_move_release_mode, + pcb_tool_move_adjust_attached_objects, + pcb_tool_move_draw_attached, + pcb_tool_move_undo_act, + NULL, + + pcb_true +}; Index: trunk/src_plugins/tool_std/tool_move.h =================================================================== --- trunk/src_plugins/tool_std/tool_move.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_move.h (revision 29304) @@ -0,0 +1,7 @@ +extern pcb_tool_t pcb_tool_move; + +void pcb_tool_move_uninit(void); +void pcb_tool_move_notify_mode(pcb_hidlib_t *hl); +void pcb_tool_move_release_mode(pcb_hidlib_t *hl); +void pcb_tool_move_draw_attached(pcb_hidlib_t *hl); +pcb_bool pcb_tool_move_undo_act(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_poly.c =================================================================== --- trunk/src_plugins/tool_std/tool_poly.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_poly.c (revision 29304) @@ -0,0 +1,195 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" +#include "conf_core.h" + +#include "crosshair.h" +#include +#include "polygon.h" +#include "tool.h" + + +void pcb_tool_poly_uninit(void) +{ + pcb_notify_crosshair_change(pcb_false); + pcb_crosshair.AttachedPolygon.PointN = 0; + pcb_crosshair.AttachedLine.State = PCB_CH_STATE_FIRST; + pcb_notify_crosshair_change(pcb_true); +} + +TODO("remove this when pcb_tool_poly_notify_mode() loses PCB") +#include "board.h" + +void pcb_tool_poly_notify_mode(pcb_hidlib_t *hl) +{ + pcb_point_t *points = pcb_crosshair.AttachedPolygon.Points; + pcb_cardinal_t n = pcb_crosshair.AttachedPolygon.PointN; + + /* do update of position */ + if (pcb_crosshair.AttachedLine.State == PCB_CH_STATE_FIRST) { + pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X = pcb_crosshair.X; + pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y = pcb_crosshair.Y; + pcb_crosshair.AttachedLine.State = PCB_CH_STATE_THIRD; + pcb_crosshair.AttachedPolygon_pts = 0; + } + + /* check if this is the last point of a polygon */ + if (n >= 3 && points[0].X == pcb_crosshair.AttachedLine.Point2.X && points[0].Y == pcb_crosshair.AttachedLine.Point2.Y) { + pcb_actionva(hl, "Polygon", "Close", NULL); + return; + } + + /* Someone clicking twice on the same point ('doubleclick'): close polygon */ + if (n >= 3 && points[n - 1].X == pcb_crosshair.AttachedLine.Point2.X && points[n - 1].Y == pcb_crosshair.AttachedLine.Point2.Y) { + pcb_actionva(hl, "Polygon", "Close", NULL); + return; + } + + /* create new point if it's the first one or if it's + * different to the last one + */ + if (!n || points[n - 1].X != pcb_crosshair.AttachedLine.Point2.X || points[n - 1].Y != pcb_crosshair.AttachedLine.Point2.Y) { + pcb_poly_point_new(&pcb_crosshair.AttachedPolygon, pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y); + pcb_crosshair.AttachedPolygon_pts = pcb_crosshair.AttachedPolygon.PointN; + + /* copy the coordinates */ + pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X; + pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y; + } + + if (conf_core.editor.orthogonal_moves) { + /* set the mark to the new starting point so ortho works */ + pcb_grabbed.X = pcb_tool_note.X; + pcb_grabbed.Y = pcb_tool_note.Y; + pcb_grabbed.status = pcb_true; + } +} + +void pcb_tool_poly_adjust_attached_objects(pcb_hidlib_t *hl) +{ + pcb_attached_line_t *line = &pcb_crosshair.AttachedLine; + + if (pcb_gui->control_is_pressed(pcb_gui)) { + line->draw = pcb_false; + return; + } + else + line->draw = pcb_true; + if (conf_core.editor.all_direction_lines) { + line->Point2.X = pcb_crosshair.X; + line->Point2.Y = pcb_crosshair.Y; + return; + } + + pcb_line_45(line); +} + +void pcb_tool_poly_draw_attached(pcb_hidlib_t *hl) +{ + /* draw only if starting point is set */ + if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST) + pcb_render->draw_line(pcb_crosshair.GC, + pcb_crosshair.AttachedLine.Point1.X, + pcb_crosshair.AttachedLine.Point1.Y, pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y); + + /* draw attached polygon only if in PCB_MODE_POLYGON or PCB_MODE_POLYGON_HOLE */ + if (pcb_crosshair.AttachedPolygon.PointN > 1) { + pcb_xordraw_poly(&pcb_crosshair.AttachedPolygon, 0, 0, 1); + } +} + +pcb_bool pcb_tool_poly_undo_act(pcb_hidlib_t *hl) +{ + if (pcb_crosshair.AttachedPolygon.PointN) { + pcb_polygon_go_to_prev_point(); + return pcb_false; + } + return pcb_true; +} + +pcb_bool pcb_tool_poly_redo_act(pcb_hidlib_t *hl) +{ + if (pcb_crosshair.AttachedPolygon.PointN) { + pcb_polygon_go_to_next_point(); + return pcb_false; + } + else + return pcb_true; +} + +/* XPM */ +static const char *poly_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 3 1", +" c black", +". c #6EA5D7", +"o c None", +/* pixels */ +"ooooooooooo.ooooooooo", +"oooooooooo..ooooooooo", +"ooooooooo...ooooooooo", +"oooooooo....ooooooooo", +"ooooooo.....ooooooooo", +"oooooo.......oooooooo", +"ooooo.........ooooooo", +"oooo...........oooooo", +"oooo............ooooo", +"oooo.............oooo", +"oooo..............ooo", +"ooooooooooooooooooooo", +"o ooo oo oo ooo ", +"o ooo o ooo o oo ooo ", +"o ooo o ooo o ooo o o", +"o oo ooo o oooo oo", +"o ooooo ooo o oooo oo", +"o ooooo ooo o oooo oo", +"o ooooo ooo o oooo oo", +"o oooooo oo o oo", +"ooooooooooooooooooooo" +}; + +pcb_tool_t pcb_tool_poly = { + "poly", NULL, NULL, 100, poly_icon, PCB_TOOL_CURSOR_NAMED("up_arrow"), 0, + NULL, + pcb_tool_poly_uninit, + pcb_tool_poly_notify_mode, + NULL, + pcb_tool_poly_adjust_attached_objects, + pcb_tool_poly_draw_attached, + pcb_tool_poly_undo_act, + pcb_tool_poly_redo_act, + + pcb_false +}; Index: trunk/src_plugins/tool_std/tool_poly.h =================================================================== --- trunk/src_plugins/tool_std/tool_poly.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_poly.h (revision 29304) @@ -0,0 +1,8 @@ +extern pcb_tool_t pcb_tool_poly; + +void pcb_tool_poly_uninit(void); +void pcb_tool_poly_notify_mode(pcb_hidlib_t *hl); +void pcb_tool_poly_adjust_attached_objects(pcb_hidlib_t *hl); +void pcb_tool_poly_draw_attached(pcb_hidlib_t *hl); +pcb_bool pcb_tool_poly_undo_act(pcb_hidlib_t *hl); +pcb_bool pcb_tool_poly_redo_act(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_polyhole.c =================================================================== --- trunk/src_plugins/tool_std/tool_polyhole.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_polyhole.c (revision 29304) @@ -0,0 +1,224 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" +#include "conf_core.h" + +#include "crosshair.h" +#include +#include "polygon.h" +#include "search.h" +#include "tool.h" + + +void pcb_tool_polyhole_uninit(void) +{ + pcb_notify_crosshair_change(pcb_false); + pcb_crosshair.AttachedPolygon.PointN = 0; + pcb_crosshair.AttachedLine.State = PCB_CH_STATE_FIRST; + pcb_notify_crosshair_change(pcb_true); +} + +TODO("remove this when pcb_tool_polyhole_notify_mode() loses PCB") +#include "board.h" + +void pcb_tool_polyhole_notify_mode(pcb_hidlib_t *hl) +{ + switch (pcb_crosshair.AttachedObject.State) { + /* first notify, lookup object */ + case PCB_CH_STATE_FIRST: + pcb_crosshair.AttachedPolygon_pts = 0; + pcb_crosshair.AttachedObject.Type = + pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, PCB_OBJ_POLY, + &pcb_crosshair.AttachedObject.Ptr1, &pcb_crosshair.AttachedObject.Ptr2, &pcb_crosshair.AttachedObject.Ptr3); + + if (pcb_crosshair.AttachedObject.Type == PCB_OBJ_VOID) { + pcb_message(PCB_MSG_WARNING, "The first point of a polygon hole must be on a polygon.\n"); + break; /* don't start doing anything if clicket out of polys */ + } + + if (PCB_FLAG_TEST(PCB_FLAG_LOCK, (pcb_poly_t *)pcb_crosshair.AttachedObject.Ptr2)) { + pcb_message(PCB_MSG_WARNING, "Sorry, poly object is locked\n"); + pcb_crosshair.AttachedObject.Type = PCB_OBJ_VOID; + pcb_crosshair.extobj_edit = NULL; + break; + } + else + pcb_crosshair.AttachedObject.State = PCB_CH_STATE_SECOND; + /* fall thru: first click is also the first point of the poly hole */ + + /* second notify, insert new point into object */ + case PCB_CH_STATE_SECOND: + { + pcb_point_t *points = pcb_crosshair.AttachedPolygon.Points; + pcb_cardinal_t n = pcb_crosshair.AttachedPolygon.PointN; + + /* do update of position */ + if (pcb_crosshair.AttachedLine.State == PCB_CH_STATE_FIRST) { + pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X = pcb_crosshair.X; + pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y = pcb_crosshair.Y; + pcb_crosshair.AttachedLine.State = PCB_CH_STATE_THIRD; + } + + if (conf_core.editor.orthogonal_moves) { + /* set the mark to the new starting point so ortho works */ + pcb_grabbed.X = pcb_tool_note.X; + pcb_grabbed.Y = pcb_tool_note.Y; + pcb_grabbed.status = pcb_true; + } + + /* check if this is the last point of a polygon */ + if (n >= 3 && points[0].X == pcb_crosshair.AttachedLine.Point2.X && points[0].Y == pcb_crosshair.AttachedLine.Point2.Y) { + pcb_actionva(hl, "Polygon", "CloseHole", NULL); + break; + } + + /* Someone clicking twice on the same point ('doubleclick'): close polygon hole */ + if (n >= 3 && points[n - 1].X == pcb_crosshair.AttachedLine.Point2.X && points[n - 1].Y == pcb_crosshair.AttachedLine.Point2.Y) { + pcb_actionva(hl, "Polygon", "CloseHole", NULL); + break; + } + + /* create new point if it's the first one or if it's + * different to the last one + */ + if (!n || points[n - 1].X != pcb_crosshair.AttachedLine.Point2.X || points[n - 1].Y != pcb_crosshair.AttachedLine.Point2.Y) { + pcb_poly_point_new(&pcb_crosshair.AttachedPolygon, + pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y); + pcb_crosshair.AttachedPolygon_pts = pcb_crosshair.AttachedPolygon.PointN; + + /* copy the coordinates */ + pcb_crosshair.AttachedLine.Point1.X = pcb_crosshair.AttachedLine.Point2.X; + pcb_crosshair.AttachedLine.Point1.Y = pcb_crosshair.AttachedLine.Point2.Y; + } + break; + } + } +} + +void pcb_tool_polyhole_adjust_attached_objects(pcb_hidlib_t *hl) +{ + pcb_attached_line_t *line = &pcb_crosshair.AttachedLine; + + if (pcb_gui->control_is_pressed(pcb_gui)) { + line->draw = pcb_false; + return; + } + else + line->draw = pcb_true; + if (conf_core.editor.all_direction_lines) { + line->Point2.X = pcb_crosshair.X; + line->Point2.Y = pcb_crosshair.Y; + return; + } + + pcb_line_45(line); +} + +void pcb_tool_polyhole_draw_attached(pcb_hidlib_t *hl) +{ + /* draw only if starting point is set */ + if (pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST) + pcb_render->draw_line(pcb_crosshair.GC, + pcb_crosshair.AttachedLine.Point1.X, + pcb_crosshair.AttachedLine.Point1.Y, pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y); + + /* draw attached polygon only if in PCB_MODE_POLYGON or PCB_MODE_POLYGON_HOLE */ + if (pcb_crosshair.AttachedPolygon.PointN > 1) { + pcb_xordraw_poly(&pcb_crosshair.AttachedPolygon, 0, 0, 1); + } +} + +pcb_bool pcb_tool_polyhole_undo_act(pcb_hidlib_t *hl) +{ + if (pcb_crosshair.AttachedPolygon.PointN) { + pcb_polygon_go_to_prev_point(); + return pcb_false; + } + return pcb_true; +} + +pcb_bool pcb_tool_polyhole_redo_act(pcb_hidlib_t *hl) +{ + if (pcb_crosshair.AttachedPolygon.PointN) { + pcb_polygon_go_to_next_point(); + return pcb_false; + } + else + return pcb_true; +} + +/* XPM */ +static const char * polyhole_icon[] = { +"21 21 3 1", +" c None", +". c #6EA5D7", +"+ c #000000", +" .. ", +" ... ", +" ..... ", +" ....... ", +" ......... ", +" ....+++++... ", +" ....+ +.... ", +" ...+ +..... ", +" ...++++++...... ", +" ................ ", +" ................. ", +" ", +" + + ++ + +++ ", +" + + + + + + ", +" + + + + + + ", +" ++++ + + + +++ ", +" + + + + + + ", +" + + + + + + ", +" + + + + + + ", +" + + ++ +++ +++ ", +" " +}; + + +pcb_tool_t pcb_tool_polyhole = { + "polyhole", NULL, NULL, 100, polyhole_icon, PCB_TOOL_CURSOR_NAMED("up_arrow"), 0, + NULL, + pcb_tool_polyhole_uninit, + pcb_tool_polyhole_notify_mode, + NULL, + pcb_tool_polyhole_adjust_attached_objects, + pcb_tool_polyhole_draw_attached, + pcb_tool_polyhole_undo_act, + pcb_tool_polyhole_redo_act, + + pcb_false +}; Index: trunk/src_plugins/tool_std/tool_polyhole.h =================================================================== --- trunk/src_plugins/tool_std/tool_polyhole.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_polyhole.h (revision 29304) @@ -0,0 +1,8 @@ +extern pcb_tool_t pcb_tool_polyhole; + +void pcb_tool_polyhole_uninit(void); +void pcb_tool_polyhole_notify_mode(pcb_hidlib_t *hl); +void pcb_tool_polyhole_adjust_attached_objects(pcb_hidlib_t *hl); +void pcb_tool_polyhole_draw_attached(pcb_hidlib_t *hl); +pcb_bool pcb_tool_polyhole_undo_act(pcb_hidlib_t *hl); +pcb_bool pcb_tool_polyhole_redo_act(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_rectangle.c =================================================================== --- trunk/src_plugins/tool_std/tool_rectangle.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_rectangle.c (revision 29304) @@ -0,0 +1,161 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" +#include "conf_core.h" + +#include "board.h" +#include "crosshair.h" +#include "data.h" +#include "draw.h" +#include "tool.h" +#include "undo.h" + +#include "obj_poly_draw.h" + + +void pcb_tool_rectangle_uninit(void) +{ + pcb_notify_crosshair_change(pcb_false); + pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; + pcb_notify_crosshair_change(pcb_true); +} + +void pcb_tool_rectangle_notify_mode(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + + /* do update of position */ + pcb_tool_notify_block(); + + /* create rectangle if both corners are determined + * and width, height are != 0 + */ + if (pcb_crosshair.AttachedBox.State == PCB_CH_STATE_THIRD && + pcb_crosshair.AttachedBox.Point1.X != pcb_crosshair.AttachedBox.Point2.X && + pcb_crosshair.AttachedBox.Point1.Y != pcb_crosshair.AttachedBox.Point2.Y) { + pcb_poly_t *polygon; + pcb_layer_t *layer = pcb_loose_subc_layer(pcb, PCB_CURRLAYER(pcb), pcb_true); + + int flags = PCB_FLAG_CLEARPOLY; + if (conf_core.editor.full_poly) + flags |= PCB_FLAG_FULLPOLY; + if (conf_core.editor.clear_polypoly) + flags |= PCB_FLAG_CLEARPOLYPOLY; + if ((polygon = pcb_poly_new_from_rectangle(layer, + pcb_crosshair.AttachedBox.Point1.X, + pcb_crosshair.AttachedBox.Point1.Y, + pcb_crosshair.AttachedBox.Point2.X, + pcb_crosshair.AttachedBox.Point2.Y, + 2 * conf_core.design.clearance, + pcb_flag_make(flags))) != NULL) { + pcb_obj_add_attribs((pcb_any_obj_t *)polygon, pcb->pen_attr, NULL); + pcb_undo_add_obj_to_create(PCB_OBJ_POLY, layer, polygon, polygon); + pcb_undo_inc_serial(); + pcb_poly_invalidate_draw(layer, polygon); + pcb_draw(); + } + + /* reset state to 'first corner' */ + pcb_crosshair.AttachedBox.State = PCB_CH_STATE_FIRST; + pcb_subc_as_board_update(PCB); + } +} + +void pcb_tool_rectangle_adjust_attached_objects(pcb_hidlib_t *hl) +{ + switch (pcb_crosshair.AttachedBox.State) { + case PCB_CH_STATE_SECOND: /* one corner is selected */ + { + /* update coordinates */ + pcb_crosshair.AttachedBox.Point2.X = pcb_crosshair.X; + pcb_crosshair.AttachedBox.Point2.Y = pcb_crosshair.Y; + break; + } + } +} + +pcb_bool pcb_tool_rectangle_anydo_act(pcb_hidlib_t *hl) +{ + /* don't allow undo in the middle of an operation */ + if (pcb_crosshair.AttachedBox.State != PCB_CH_STATE_FIRST) + return pcb_false; + return pcb_true; +} + +/* XPM */ +static const char *rect_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 3 1", +" c black", +". c #6EA5D7", +"o c None", +/* pixels */ +"ooooooooooooooooooooo", +"oo..................o", +"oo..................o", +"oo..................o", +"oo..................o", +"oo..................o", +"oo..................o", +"oo..................o", +"oo..................o", +"oo..................o", +"ooooooooooooooooooooo", +"ooooooooooooooooooooo", +"o oo oo oo ", +"o oo o oooo oo ooo oo", +"o oo o oooo oooooo oo", +"o oo oooo oooooo oo", +"o o oo oo oooooo oo", +"o oo o oooo oooooo oo", +"o oo o oooo oo ooo oo", +"o oo o oo oooo oo", +"ooooooooooooooooooooo" +}; + + +pcb_tool_t pcb_tool_rectangle = { + "rectangle", NULL, NULL, 100, rect_icon, PCB_TOOL_CURSOR_NAMED("ul_angle"), 0, + NULL, + pcb_tool_rectangle_uninit, + pcb_tool_rectangle_notify_mode, + NULL, + pcb_tool_rectangle_adjust_attached_objects, + NULL, + pcb_tool_rectangle_anydo_act, + pcb_tool_rectangle_anydo_act, + + pcb_false +}; Index: trunk/src_plugins/tool_std/tool_rectangle.h =================================================================== --- trunk/src_plugins/tool_std/tool_rectangle.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_rectangle.h (revision 29304) @@ -0,0 +1,6 @@ +extern pcb_tool_t pcb_tool_rectangle; + +void pcb_tool_rectangle_uninit(void); +void pcb_tool_rectangle_notify_mode(pcb_hidlib_t *hl); +void pcb_tool_rectangle_adjust_attached_objects(pcb_hidlib_t *hl); +pcb_bool pcb_tool_rectangle_undo_act(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_remove.c =================================================================== --- trunk/src_plugins/tool_std/tool_remove.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_remove.c (revision 29304) @@ -0,0 +1,129 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" + +#include "board.h" +#include +#include +#include "undo.h" +#include "remove.h" +#include "search.h" +#include "obj_rat.h" +#include "tool.h" + + +void pcb_tool_remove_notify_mode(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + void *ptr1, *ptr2, *ptr3; + pcb_any_obj_t *obj; + int type; + + if ((type = pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, PCB_REMOVE_TYPES | PCB_LOOSE_SUBC(PCB) | PCB_OBJ_FLOATER, &ptr1, &ptr2, &ptr3)) != PCB_OBJ_VOID) { + obj = (pcb_any_obj_t *)ptr2; + if (PCB_FLAG_TEST(PCB_FLAG_LOCK, obj)) { + pcb_message(PCB_MSG_WARNING, "Sorry, %s object is locked\n", pcb_obj_type_name(obj->type)); + return; + } + + if (type == PCB_OBJ_SUBC) { + if(pcb->is_footprint) { + pcb_message(PCB_MSG_WARNING, "Can not remove the subcircuit being edited in the footprint edit mode\n"); + return; + } + } + + obj = ptr2; + pcb_rat_update_obj_removed(pcb, obj); + + /* preserve original parent over the board layer pcb_search_screen operated on - + this is essential for undo: it needs to put back the object to the original + layer (e.g. inside a subc) instead of on the board layer */ + if (obj->parent_type == PCB_PARENT_LAYER) + ptr1 = obj->parent.layer; + else if (obj->parent_type == PCB_PARENT_DATA) + ptr1 = obj->parent.data; + + pcb_remove_object(type, ptr1, ptr2, ptr3); + pcb_undo_inc_serial(); + pcb_subc_as_board_update(PCB); + pcb_board_set_changed_flag(pcb_true); + } +} + +/* XPM */ +static const char *del_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 3 1", +" c black", +". c gray100", +"X c None", +/* pixels */ +"XXX XXXXXXXXXXXX XXXX", +"XXXX XXX XXX XXXXX", +"XXXXX X X XXXXXX", +"XXXXXX XX XX XXXXXXX", +"XXXXX XX XX XXXXXX", +"XXXXX XXXXXX", +"XXXXXX XXXXXXX", +"XXXXXXX XX XXXXXXXX", +"XXXXXXX XX XXXXXXXXX", +"XXXXXX X XX XXXXXXXX", +"XXXX XX X XXXXXX", +"XX XXXXX XXXX XXXX", +"XXXXXXXXXXXXXXXXXXXXX", +"XX XX X XXXXX", +"XXX XXX X XXXXX XXXXX", +"XXX XXX X XXXXX XXXXX", +"XXX XXX X XXXXX XXXXX", +"XXX XXX X XX XXXXX", +"XXX XXX X XXXXX XXXXX", +"XXX XXX X XXXXX XXXXX", +"XX XX X X" +}; + +pcb_tool_t pcb_tool_remove = { + "remove", NULL, NULL, 100, del_icon, PCB_TOOL_CURSOR_NAMED("pirate"), 0, + NULL, + NULL, + pcb_tool_remove_notify_mode, + NULL, + NULL, + NULL, + NULL, + NULL, + + pcb_true +}; Index: trunk/src_plugins/tool_std/tool_remove.h =================================================================== --- trunk/src_plugins/tool_std/tool_remove.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_remove.h (revision 29304) @@ -0,0 +1,3 @@ +extern pcb_tool_t pcb_tool_remove; + +void pcb_tool_remove_notify_mode(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_rotate.c =================================================================== --- trunk/src_plugins/tool_std/tool_rotate.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_rotate.c (revision 29304) @@ -0,0 +1,109 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" +#include "conf_core.h" + +#include +#include "board.h" +#include "rotate.h" +#include "tool.h" + + +void pcb_tool_rotate_notify_mode(pcb_hidlib_t *hl) +{ + pcb_screen_obj_rotate90((pcb_board_t *)hl, pcb_tool_note.X, pcb_tool_note.Y, + pcb_gui->shift_is_pressed(pcb_gui) ? (conf_core.editor.show_solder_side ? 1 : 3) : (conf_core.editor.show_solder_side ? 3 : 1)); + pcb_subc_as_board_update(PCB); +} + +/* XPM */ +static const char *rot_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 4 1", +" c black", +". c #6EA5D7", +"X c gray100", +"o c None", +/* pixels */ +"ooooooooooo.ooooooooo", +"oooooooooo..ooooooooo", +"ooooooooo....oooooooo", +"oooooooooo..o.ooooooo", +"ooooooooooo.oo.oooooo", +"oooooooooooooo.oooooo", +"oooooooooooooo.oooooo", +"oooooooooooooo.oooooo", +"oooooooooooooo.oooooo", +"ooooooooooooo.ooooooo", +"oooooooooooo.oooooooo", +"oooooooooo..ooooooooo", +"ooooooooooooooooooooo", +"ooo ooo oo o", +"ooo ooo o ooo ooo ooo", +"ooo ooo o ooo ooo ooo", +"ooo oo ooo ooo ooo", +"ooo ooo ooo ooo ooo", +"ooo o oo ooo ooo ooo", +"ooo oo o ooo ooo ooo", +"ooo ooo oo oooo ooo" +}; + +#define rotateIcon_width 16 +#define rotateIcon_height 16 +static unsigned char rotateIcon_bits[] = { + 0xf0, 0x03, 0xf8, 0x87, 0x0c, 0xcc, 0x06, 0xf8, 0x03, 0xb0, 0x01, 0x98, + 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x19, 0x80, 0x0d, 0xc0, + 0x1f, 0x60, 0x3b, 0x30, 0xe1, 0x3f, 0xc0, 0x0f}; + +#define rotateMask_width 16 +#define rotateMask_height 16 +static unsigned char rotateMask_bits[] = { + 0xf0, 0x03, 0xf8, 0x87, 0x0c, 0xcc, 0x06, 0xf8, 0x03, 0xf0, 0x01, 0xf8, + 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x1f, 0x80, 0x0f, 0xc0, + 0x1f, 0x60, 0x3b, 0x30, 0xe1, 0x3f, 0xc0, 0x0f}; + +pcb_tool_t pcb_tool_rotate = { + "rotate", NULL, NULL, 100, rot_icon, PCB_TOOL_CURSOR_XBM(rotateIcon_bits, rotateMask_bits), 0, + NULL, + NULL, + pcb_tool_rotate_notify_mode, + NULL, + NULL, + NULL, + NULL, + NULL, + + pcb_true +}; Index: trunk/src_plugins/tool_std/tool_rotate.h =================================================================== --- trunk/src_plugins/tool_std/tool_rotate.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_rotate.h (revision 29304) @@ -0,0 +1,3 @@ +extern pcb_tool_t pcb_tool_rotate; + +void pcb_tool_rotate_notify_mode(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_std.c =================================================================== --- trunk/src_plugins/tool_std/tool_std.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_std.c (revision 29304) @@ -0,0 +1,84 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2020 Tibor 'Igor2' Palinkas + * + * This module, dialogs, was written and is Copyright (C) 2017 by Tibor Palinkas + * this module is also subject to the GNU GPL as described below + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +#include "config.h" +#include "conf_core.h" + +#include +#include "tool.h" + +#include "tool_arc.h" +#include "tool_arrow.h" +#include "tool_buffer.h" +#include "tool_copy.h" +#include "tool_insert.h" +#include "tool_line.h" +#include "tool_lock.h" +#include "tool_move.h" +#include "tool_poly.h" +#include "tool_polyhole.h" +#include "tool_rectangle.h" +#include "tool_remove.h" +#include "tool_rotate.h" +#include "tool_text.h" +#include "tool_thermal.h" +#include "tool_via.h" + +static const char pcb_tool_std_cookie[] = "tool_std"; + +int pplg_check_ver_tool_std(int ver_needed) { return 0; } + +void pplg_uninit_tool_std(void) +{ + pcb_tool_unreg_by_cookie(pcb_tool_std_cookie); +} + +int pplg_init_tool_std(void) +{ + PCB_API_CHK_VER; + + pcb_tool_reg(&pcb_tool_arc, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_arrow, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_buffer, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_copy, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_insert, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_line, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_lock, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_move, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_poly, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_polyhole, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_rectangle, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_remove, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_rotate, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_text, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_thermal, pcb_tool_std_cookie); + pcb_tool_reg(&pcb_tool_via, pcb_tool_std_cookie); + + return 0; +} Index: trunk/src_plugins/tool_std/tool_std.pup =================================================================== --- trunk/src_plugins/tool_std/tool_std.pup (nonexistent) +++ trunk/src_plugins/tool_std/tool_std.pup (revision 29304) @@ -0,0 +1,7 @@ +$class feature +$short standard tools +$long The basic set of PCB drawing tools +$state works +$package (core) +default buildin +autoload 1 Index: trunk/src_plugins/tool_std/tool_text.c =================================================================== --- trunk/src_plugins/tool_std/tool_text.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_text.c (revision 29304) @@ -0,0 +1,140 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" +#include "conf_core.h" + +#include "board.h" +#include "data.h" +#include "draw.h" +#include +#include "tool.h" +#include "undo.h" + +#include "obj_text_draw.h" + + +void pcb_tool_text_notify_mode(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + char *string; + + if ((string = pcb_hid_prompt_for(hl, "Enter text:", "", "text")) != NULL) { + if (strlen(string) > 0) { + pcb_text_t *text; + int flag = PCB_FLAG_CLEARLINE; + + if (pcb_layer_flags(pcb, PCB_CURRLID(pcb)) & PCB_LYT_BOTTOM) + flag |= PCB_FLAG_ONSOLDER; + if ((text = pcb_text_new(pcb_loose_subc_layer(pcb, PCB_CURRLAYER(pcb), pcb_true), pcb_font(pcb, conf_core.design.text_font_id, 1), pcb_tool_note.X, + pcb_tool_note.Y, 0, conf_core.design.text_scale, conf_core.design.text_thickness, string, pcb_flag_make(flag))) != NULL) { + pcb_undo_add_obj_to_create(PCB_OBJ_TEXT, PCB_CURRLAYER(pcb), text, text); + pcb_undo_inc_serial(); + pcb_text_invalidate_draw(PCB_CURRLAYER(pcb), text); + pcb_subc_as_board_update(PCB); + pcb_draw(); + } + } + free(string); + } +} + +void pcb_tool_text_draw_attached(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + pcb_text_t text; + int flag = PCB_FLAG_CLEARLINE; + + if (pcb_layer_flags(pcb, PCB_CURRLID(pcb)) & PCB_LYT_BOTTOM) + flag |= PCB_FLAG_ONSOLDER; + + text.X = pcb_crosshair.X; + text.Y = pcb_crosshair.Y; + text.rot = 0; + text.Flags = pcb_flag_make(flag); + text.Scale = conf_core.design.text_scale; + text.thickness = conf_core.design.text_thickness; + text.TextString = "A"; + text.fid = conf_core.design.text_font_id; + text.ID = 0; + text.BoundingBox.X1 = text.BoundingBox.Y1 = text.BoundingBox.X2 = text.BoundingBox.Y2 = 0; + pcb_text_draw_xor(&text,0,0); + +} + +/* XPM */ +static const char *text_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 3 1", +" c #000000", +". c #6EA5D7", +"o c None", +/* pixels */ +"ooooooooooooooooooooo", +"ooooooooooooooooooooo", +"ooooooooooooooooooooo", +"oo.ooo.ooo.ooo.ooo.oo", +"o.o.o.o.o.o.o.o.o.o.o", +"oo.ooo.ooo.ooo.ooo.oo", +"ooooooooooooooooooooo", +"ooooooooooooooooooooo", +"ooooooooooooooooooooo", +"ooooooooooooooooooooo", +"ooooooooooooooooooooo", +"ooooooooooooooooooooo", +" o o ooo o ", +"oo ooo ooo ooo ooo oo", +"oo ooo oooo o oooo oo", +"oo ooo ooooo ooooo oo", +"oo ooo ooo o oooo oo", +"oo ooo ooo ooo ooo oo", +"oo ooo ooo ooo ooo oo", +"oo ooo o ooo ooo oo", +"ooooooooooooooooooooo" +}; + +pcb_tool_t pcb_tool_text = { + "text", NULL, NULL, 100, text_icon, PCB_TOOL_CURSOR_NAMED("xterm"), 0, + NULL, + NULL, + pcb_tool_text_notify_mode, + NULL, + NULL, + pcb_tool_text_draw_attached, + NULL, + NULL, + + pcb_false +}; + Index: trunk/src_plugins/tool_std/tool_text.h =================================================================== --- trunk/src_plugins/tool_std/tool_text.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_text.h (revision 29304) @@ -0,0 +1,3 @@ +extern pcb_tool_t pcb_tool_text; + +void pcb_tool_text_notify_mode(pcb_hidlib_t *hl); Index: trunk/src_plugins/tool_std/tool_thermal.c =================================================================== --- trunk/src_plugins/tool_std/tool_thermal.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_thermal.c (revision 29304) @@ -0,0 +1,148 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" + +#include "board.h" +#include "change.h" +#include "data.h" +#include +#include "obj_pstk.h" +#include "search.h" +#include "thermal.h" +#include "tool.h" + +void pcb_tool_thermal_on_pstk(pcb_pstk_t *ps, unsigned long lid) +{ + unsigned char *th, newth = 0; + unsigned char cycle[] = { + PCB_THERMAL_ON | PCB_THERMAL_ROUND | PCB_THERMAL_DIAGONAL, /* default start shape */ + PCB_THERMAL_ON | PCB_THERMAL_ROUND, + PCB_THERMAL_ON | PCB_THERMAL_SHARP | PCB_THERMAL_DIAGONAL, + PCB_THERMAL_ON | PCB_THERMAL_SHARP, + PCB_THERMAL_ON | PCB_THERMAL_SOLID, + PCB_THERMAL_ON | PCB_THERMAL_NOSHAPE + }; + int cycles = sizeof(cycle) / sizeof(cycle[0]); + + th = pcb_pstk_get_thermal(ps, lid, 1); + if (pcb_gui->shift_is_pressed(pcb_gui)) { + int n, curr = -1; + /* cycle through the variants to find the current one */ + for(n = 0; n < cycles; n++) { + if (*th == cycle[n]) { + curr = n; + break; + } + } + + /* bump current pattern to the next or set it up */ + if (curr >= 0) { + curr++; + if (curr >= cycles) + curr = 0; + } + else + curr = 0; + + newth = cycle[curr]; + } + else { + if ((th != NULL) && (*th != 0)) + newth = *th ^ PCB_THERMAL_ON; /* existing thermal, toggle */ + else + newth = cycle[0]; /* new thermal, use default */ + } + + pcb_chg_obj_thermal(PCB_OBJ_PSTK, ps, ps, ps, newth, lid); +} + + +void pcb_tool_thermal_notify_mode(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + void *ptr1, *ptr2, *ptr3; + int type; + + if (((type = pcb_search_screen(pcb_tool_note.X, pcb_tool_note.Y, PCB_OBJ_CLASS_PIN, &ptr1, &ptr2, &ptr3)) != PCB_OBJ_VOID) + && !PCB_FLAG_TEST(PCB_FLAG_HOLE, (pcb_any_obj_t *) ptr3)) { + if (type == PCB_OBJ_PSTK) + pcb_tool_thermal_on_pstk((pcb_pstk_t *)ptr2, PCB_CURRLID(pcb)); + } +} + +/* XPM */ +static const char *thrm_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 3 1", +" c #000000", +". c #6EA5D7", +"o c None", +/* pixels */ +"ooooooooooooooooooooo", +"oooo ooooooooo oooooo", +"ooooo ooooooo ooooooo", +"oooooo o...o oooooooo", +"ooooooo ooo ooooooooo", +"oooooo.ooooo.oooooooo", +"oooooo.ooooo.oooooooo", +"oooooo.ooooo.oooooooo", +"ooooooo ooo ooooooooo", +"oooooo o...o oooooooo", +"ooooo ooooooo ooooooo", +"oooo ooooooooo oooooo", +"ooooooooooooooooooooo", +" o oo o oo ooo ", +"oo ooo oo o oo o o ", +"oo ooo oo o oo o o o ", +"oo ooo oo o oo o o ", +"oo ooo o o oo ooo ", +"oo ooo oo o oo o ooo ", +"oo ooo oo o oo o ooo ", +"oo ooo oo o oo o ooo " +}; + +pcb_tool_t pcb_tool_thermal = { + "thermal", NULL, NULL, 100, thrm_icon, PCB_TOOL_CURSOR_NAMED("iron_cross"), 0, + NULL, + NULL, + pcb_tool_thermal_notify_mode, + NULL, + NULL, + NULL, + NULL, + NULL, + + pcb_false +}; Index: trunk/src_plugins/tool_std/tool_thermal.h =================================================================== --- trunk/src_plugins/tool_std/tool_thermal.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_thermal.h (revision 29304) @@ -0,0 +1,6 @@ +extern pcb_tool_t pcb_tool_thermal; + +void pcb_tool_thermal_notify_mode(pcb_hidlib_t *hl); + +/* direct call: cycle through thermal modes on a padstack - provided for tool_via.h */ +void pcb_tool_thermal_on_pstk(pcb_pstk_t *ps, unsigned long lid); Index: trunk/src_plugins/tool_std/tool_via.c =================================================================== --- trunk/src_plugins/tool_std/tool_via.c (nonexistent) +++ trunk/src_plugins/tool_std/tool_via.c (revision 29304) @@ -0,0 +1,150 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 1997, 1998, 1999, 2000, 2001 Harry Eaton + * Copyright (C) 2017,2019 Tibor 'Igor2' Palinkas + * + * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + * + * Old contact info: + * Harry Eaton, 6697 Buttonhole Ct, Columbia, MD 21044, USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include "config.h" + +#include "conf_core.h" +#include + +#include "board.h" +#include "change.h" +#include +#include "data.h" +#include "draw.h" +#include "tool.h" +#include "tool_thermal.h" +#include "undo.h" + +#include "obj_pstk_draw.h" + +TODO("padstack: remove this when via is removed and the padstack is created from style directly") +#include "src_plugins/lib_compat_help/pstk_compat.h" + +void pcb_tool_via_notify_mode(pcb_hidlib_t *hl) +{ + pcb_board_t *pcb = (pcb_board_t *)hl; + + if (!pcb->pstk_on) { + pcb_message(PCB_MSG_WARNING, "You must turn via visibility on before\nyou can place vias\n"); + return; + } + + if (conf_core.design.via_drilling_hole >= conf_core.design.via_thickness) { + pcb_message(PCB_MSG_ERROR, "Can't place via: invalid via geometry (hole too large for via size)\n"); + return; + } + +TODO("pstk #21: do not work in comp mode, use a pstk proto - scconfig also has TODO #21, fix it there too") + { + pcb_pstk_t *ps = pcb_pstk_new_compat_via(pcb->Data, -1, pcb_tool_note.X, pcb_tool_note.Y, + conf_core.design.via_drilling_hole, conf_core.design.via_thickness, conf_core.design.clearance, + 0, PCB_PSTK_COMPAT_ROUND, pcb_true); + if (ps == NULL) + return; + + pcb_obj_add_attribs((pcb_any_obj_t *)ps, pcb->pen_attr, NULL); + pcb_undo_add_obj_to_create(PCB_OBJ_PSTK, ps, ps, ps); + + if (pcb_gui->shift_is_pressed(pcb_gui)) + pcb_tool_thermal_on_pstk(ps, PCB_CURRLID(pcb)); + + pcb_undo_inc_serial(); + pcb_pstk_invalidate_draw(ps); + pcb_draw(); + } +} + +static void xor_draw_fake_via(pcb_coord_t x, pcb_coord_t y, pcb_coord_t dia, pcb_coord_t clearance) +{ + pcb_coord_t r = (dia/2)+clearance; + pcb_render->draw_arc(pcb_crosshair.GC, x, y, r, r, 0, 360); +} + + +void pcb_tool_via_draw_attached(pcb_hidlib_t *hl) +{ +TODO("pstk: replace this when route style has a prototype") + xor_draw_fake_via(pcb_crosshair.X, pcb_crosshair.Y, conf_core.design.via_thickness, 0); + if (conf_core.editor.show_drc) { + /* XXX: Naughty cheat - use the mask to draw DRC clearance! */ + pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.drc); + xor_draw_fake_via(pcb_crosshair.X, pcb_crosshair.Y, conf_core.design.via_thickness, conf_core.design.clearance); + pcb_render->set_color(pcb_crosshair.GC, &conf_core.appearance.color.attached); + } +} + +/* XPM */ +static const char *via_icon[] = { +/* columns rows colors chars-per-pixel */ +"21 21 3 1", +" c #000000", +". c #7A8584", +"o c None", +/* pixels */ +"ooooooooooooooooooooo", +"ooooooooo...ooooooooo", +"oooooooo.....oooooooo", +"ooooooo..ooo..ooooooo", +"oooooo..ooooo..oooooo", +"oooooo..ooooo..oooooo", +"oooooo..ooooo..oooooo", +"ooooooo..ooo..ooooooo", +"oooooooo.....oooooooo", +"ooooooooo...ooooooooo", +"ooooooooooooooooooooo", +"ooooooooooooooooooooo", +"ooooooooooooooooooooo", +"ooo ooo o ooo ooooo", +"ooo ooo oo ooo o oooo", +"ooo ooo oo oo ooo ooo", +"oooo o ooo oo ooo ooo", +"oooo o ooo oo ooo", +"oooo o ooo oo ooo ooo", +"ooooo ooo o ooo ooo", +"ooooooooooooooooooooo" +}; + +pcb_tool_t pcb_tool_via = { + "via", NULL, NULL, 100, via_icon, PCB_TOOL_CURSOR_NAMED(NULL), 0, + NULL, + NULL, + pcb_tool_via_notify_mode, + NULL, + NULL, + pcb_tool_via_draw_attached, + NULL, + NULL, + + pcb_false +}; Index: trunk/src_plugins/tool_std/tool_via.h =================================================================== --- trunk/src_plugins/tool_std/tool_via.h (nonexistent) +++ trunk/src_plugins/tool_std/tool_via.h (revision 29304) @@ -0,0 +1,4 @@ +extern pcb_tool_t pcb_tool_via; + +void pcb_tool_via_notify_mode(pcb_hidlib_t *hl); +void pcb_tool_via_draw_attached(pcb_hidlib_t *hl);