Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 29317) +++ trunk/src/crosshair.c (revision 29318) @@ -240,7 +240,7 @@ } /* --------------------------------------------------------------------------- - * draws the attached object while in PCB_MODE_MOVE or PCB_MODE_COPY + * draws the attached object while in tool mode move or copy */ void pcb_xordraw_movecopy(void) { @@ -758,7 +758,7 @@ double sq_dist; /* avoid snapping to an object if it is in the same subc */ - if ((snapo != NULL) && (pcbhl_conf.editor.mode == PCB_MODE_MOVE) && (pcb_crosshair.AttachedObject.Type == PCB_OBJ_SUBC)) { + if ((snapo != NULL) && (pcbhl_conf.editor.mode == pcb_crosshair.tool_move) && (pcb_crosshair.AttachedObject.Type == PCB_OBJ_SUBC)) { pcb_any_obj_t *parent = (pcb_any_obj_t *)pcb_obj_parent_subc(snapo); int n; pcb_cardinal_t parent_id = snapo->ID; @@ -785,8 +785,8 @@ * the same layer), and when moving a line end-point * (but don't snap to the same line) */ - if ((pcbhl_conf.editor.mode == PCB_MODE_LINE && PCB_CURRLAYER(pcb) == layer) || - (pcbhl_conf.editor.mode == PCB_MODE_MOVE + if ((pcbhl_conf.editor.mode == pcb_crosshair.tool_line && PCB_CURRLAYER(pcb) == layer) || + (pcbhl_conf.editor.mode == pcb_crosshair.tool_move && pcb_crosshair.AttachedObject.Type == PCB_OBJ_LINE_POINT && pcb_crosshair.AttachedObject.Ptr1 == layer && pcb_crosshair.AttachedObject.Ptr2 != line)) @@ -923,7 +923,7 @@ ans = pcb_search_grid_slop(pcb_crosshair.X, pcb_crosshair.Y, PCB_OBJ_PSTK | PCB_OBJ_SUBC_PART, &ptr1, &ptr2, &ptr3); /* Avoid snapping padstack to any other padstack */ - if (pcbhl_conf.editor.mode == PCB_MODE_MOVE && pcb_crosshair.AttachedObject.Type == PCB_OBJ_PSTK && (ans & PCB_OBJ_PSTK)) + if (pcbhl_conf.editor.mode == pcb_crosshair.tool_move && pcb_crosshair.AttachedObject.Type == PCB_OBJ_PSTK && (ans & PCB_OBJ_PSTK)) ans = PCB_OBJ_VOID; if (ans != PCB_OBJ_VOID) { @@ -985,7 +985,7 @@ if (conf_core.editor.highlight_on_point) onpoint_work(&pcb_crosshair, pcb_crosshair.X, pcb_crosshair.Y); - if (pcbhl_conf.editor.mode == PCB_MODE_ARROW) { + if (pcbhl_conf.editor.mode == pcb_crosshair.tool_arrow) { ans = pcb_search_grid_slop(pcb_crosshair.X, pcb_crosshair.Y, PCB_OBJ_LINE_POINT, &ptr1, &ptr2, &ptr3); if (ans == PCB_OBJ_VOID) { if ((pcb_gui != NULL) && (pcb_gui->point_cursor != NULL)) @@ -997,7 +997,7 @@ } } - if (pcbhl_conf.editor.mode == PCB_MODE_LINE && pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST && conf_core.editor.auto_drc) + if (pcbhl_conf.editor.mode == pcb_crosshair.tool_line && pcb_crosshair.AttachedLine.State != PCB_CH_STATE_FIRST && conf_core.editor.auto_drc) pcb_line_enforce_drc(PCB); pcb_gui->set_crosshair(pcb_gui, pcb_crosshair.X, pcb_crosshair.Y, HID_SC_DO_NOTHING); @@ -1076,6 +1076,8 @@ /* Initialise Line Route */ pcb_route_init(&pcb_crosshair.Route); + pcb_crosshair.tool_arrow = pcb_crosshair.tool_move = pcb_crosshair.tool_line = -1; + pcb_crosshair.tool_arc = pcb_crosshair.tool_poly = pcb_crosshair.tool_poly_hole = -1; } void pcb_crosshair_uninit(void) Index: trunk/src/crosshair.h =================================================================== --- trunk/src/crosshair.h (revision 29317) +++ trunk/src/crosshair.h (revision 29318) @@ -43,8 +43,8 @@ } pcb_attached_box_t; typedef struct { /* currently attached object */ - pcb_coord_t X, Y; /* saved position when PCB_MODE_MOVE */ - pcb_coord_t tx, ty; /* target position when PCB_MODE_MOVE */ + pcb_coord_t X, Y; /* saved position when tool is move */ + pcb_coord_t tx, ty; /* target position when tool is move */ pcb_box_t BoundingBox; long int Type; /* object type */ long int State; @@ -79,6 +79,9 @@ long int *drags; int drags_len, drags_current; pcb_coord_t dragx, dragy; /* the point where drag started */ + + /* cached tool IDs */ + int tool_arrow, tool_line, tool_move, tool_arc, tool_poly, tool_poly_hole; } pcb_crosshair_t; Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 29317) +++ trunk/src/gui_act.c (revision 29318) @@ -246,7 +246,7 @@ case F_ToggleAutoDRC: pcb_notify_crosshair_change(pcb_false); conf_toggle_editor(auto_drc); - if (conf_core.editor.auto_drc && pcbhl_conf.editor.mode == PCB_MODE_LINE) { + if (conf_core.editor.auto_drc && pcbhl_conf.editor.mode == pcb_crosshair.tool_line) { if (pcb_data_clear_flag(PCB->Data, PCB_FLAG_FOUND, 1, 1) > 0) { pcb_undo_inc_serial(); pcb_draw(); @@ -803,7 +803,7 @@ pcb_notify_crosshair_change(pcb_false); set_same_(((pcb_line_t *) ptr2)->Thickness, -1, -1, ((pcb_line_t *) ptr2)->Clearance / 2, NULL); layer = (pcb_layer_t *) ptr1; - if (pcbhl_conf.editor.mode != PCB_MODE_LINE) + if (pcbhl_conf.editor.mode != pcb_crosshair.tool_line) pcb_tool_select_by_name(PCB_ACT_HIDLIB, "line"); pcb_notify_crosshair_change(pcb_true); pcb_event(PCB_ACT_HIDLIB, PCB_EVENT_ROUTE_STYLES_CHANGED, NULL); @@ -813,7 +813,7 @@ pcb_notify_crosshair_change(pcb_false); set_same_(((pcb_arc_t *) ptr2)->Thickness, -1, -1, ((pcb_arc_t *) ptr2)->Clearance / 2, NULL); layer = (pcb_layer_t *) ptr1; - if (pcbhl_conf.editor.mode != PCB_MODE_ARC) + if (pcbhl_conf.editor.mode != pcb_crosshair.tool_arc) pcb_tool_select_by_name(PCB_ACT_HIDLIB, "arc"); pcb_notify_crosshair_change(pcb_true); pcb_event(PCB_ACT_HIDLIB, PCB_EVENT_ROUTE_STYLES_CHANGED, NULL); Index: trunk/src/polygon.c =================================================================== --- trunk/src/polygon.c (revision 29317) +++ trunk/src/polygon.c (revision 29318) @@ -1090,7 +1090,7 @@ case 0: break; - /* reset number of points and 'PCB_MODE_LINE' state */ + /* reset number of points line tool state */ case 1: pcb_crosshair.AttachedPolygon.PointN = 0; pcb_crosshair.AttachedLine.State = PCB_CH_STATE_FIRST; Index: trunk/src/polygon_act.c =================================================================== --- trunk/src/polygon_act.c (revision 29317) +++ trunk/src/polygon_act.c (revision 29318) @@ -98,7 +98,7 @@ PCB_ACT_CONVARG(1, FGW_KEYWORD, Polygon, op = fgw_keyword(&argv[1])); - if ((argc > 1) && ((pcbhl_conf.editor.mode == PCB_MODE_POLYGON) || (pcbhl_conf.editor.mode == PCB_MODE_POLYGON_HOLE))) { + if ((argc > 1) && ((pcbhl_conf.editor.mode == pcb_crosshair.tool_poly) || (pcbhl_conf.editor.mode == pcb_crosshair.tool_poly_hole))) { pcb_notify_crosshair_change(pcb_false); switch(op) { /* close open polygon if possible */ Index: trunk/src_plugins/tool_std/tool_std.c =================================================================== --- trunk/src_plugins/tool_std/tool_std.c (revision 29317) +++ trunk/src_plugins/tool_std/tool_std.c (revision 29318) @@ -32,6 +32,7 @@ #include #include "tool.h" +#include "crosshair.h" #include "tool_arc.h" #include "tool_arrow.h" @@ -63,16 +64,16 @@ { 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_crosshair.tool_arc = pcb_tool_reg(&pcb_tool_arc, pcb_tool_std_cookie); + pcb_crosshair.tool_arrow = 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_crosshair.tool_line = 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_crosshair.tool_move = pcb_tool_reg(&pcb_tool_move, pcb_tool_std_cookie); + pcb_crosshair.tool_poly = pcb_tool_reg(&pcb_tool_poly, pcb_tool_std_cookie); + pcb_crosshair.tool_poly_hole = 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);