Index: trunk/src/board.c =================================================================== --- trunk/src/board.c (revision 25183) +++ trunk/src/board.c (revision 25184) @@ -285,29 +285,6 @@ free(Ptr); } -/* sets cursor grid with respect to grid offset values */ -void pcb_board_set_grid(pcb_coord_t Grid, pcb_bool align, pcb_coord_t ox, pcb_coord_t oy) -{ - if (Grid >= 1 && Grid <= PCB_MAX_GRID) { - if (align) { - PCB->hidlib.grid_ox = ox % Grid; - PCB->hidlib.grid_oy = oy % Grid; - } - PCB->hidlib.grid = Grid; - conf_set_design("editor/grid", "%$mS", Grid); - if (pcbhl_conf.editor.draw_grid) - pcb_redraw(); - } -} - -void pcb_board_set_unit(pcb_board_t *pcb, const pcb_unit_t *new_unit) -{ - if (new_unit != NULL && new_unit->allow != PCB_UNIT_NO_PRINT) { - conf_set(CFR_DESIGN, "editor/grid_unit", -1, new_unit->suffix, POL_OVERWRITE); - pcb_attrib_put(pcb, "PCB::grid::unit", new_unit->suffix); - } -} - /* sets a new line thickness */ void pcb_board_set_line_width(pcb_coord_t Size) { Index: trunk/src/board.h =================================================================== --- trunk/src/board.h (revision 25183) +++ trunk/src/board.h (revision 25184) @@ -146,11 +146,6 @@ /* free the board and remove its undo list */ void pcb_board_remove(pcb_board_t *Ptr); -/* sets cursor grid with respect to grid offset values or default unit*/ -void pcb_board_set_grid(pcb_coord_t Grid, pcb_bool align, pcb_coord_t ox, pcb_coord_t oy); -void pcb_board_set_unit(pcb_board_t *pcb, const pcb_unit_t *new_unit); - - /* sets a new line thickness */ void pcb_board_set_line_width(pcb_coord_t Size); Index: trunk/src/change_act.c =================================================================== --- trunk/src/change_act.c (revision 25183) +++ trunk/src/change_act.c (revision 25184) @@ -55,6 +55,7 @@ #include "macro.h" #include "grid.h" #include "route_style.h" +#include "hidlib_conf.h" static void ChangeFlag(const char *, const char *, int, const char *); static fgw_error_t pcb_act_ChangeSize(fgw_arg_t *ores, int oargc, fgw_arg_t *oargv); @@ -507,7 +508,7 @@ if ((type = pcb_search_screen(x, y, type, &ptr1, &ptr2, &ptr3)) != PCB_OBJ_VOID) { pcb_undo_save_serial(); if (pcb_chg_obj_name_query(ptr2)) { - pcb_redraw(); + pcb_hid_redraw(); pcb_board_set_changed_flag(pcb_true); pcb_actionl("DeleteRats", "AllRats", NULL); } @@ -769,9 +770,9 @@ } pcb_grid_inval(); if (val[0] == '*') - pcb_board_set_grid(pcb_round(PCB->hidlib.grid * d), pcb_false, 0, 0); + pcb_hidlib_set_grid(&PCB->hidlib, pcb_round(PCB->hidlib.grid * d), pcb_false, 0, 0); else - pcb_board_set_grid(pcb_round(PCB->hidlib.grid / d), pcb_false, 0, 0); + pcb_hidlib_set_grid(&PCB->hidlib, pcb_round(PCB->hidlib.grid / d), pcb_false, 0, 0); } value = pcb_get_value(val, units, &absolute, NULL); @@ -780,16 +781,16 @@ case F_Grid: pcb_grid_inval(); if (absolute) - pcb_board_set_grid(value, pcb_false, 0, 0); + pcb_hidlib_set_grid(&PCB->hidlib, value, pcb_false, 0, 0); else { /* On the way down, short against the minimum * PCB drawing unit */ if ((value + PCB->hidlib.grid) < 1) - pcb_board_set_grid(1, pcb_false, 0, 0); + pcb_hidlib_set_grid(&PCB->hidlib, 1, pcb_false, 0, 0); else if (PCB->hidlib.grid == 1) - pcb_board_set_grid(value, pcb_false, 0, 0); + pcb_hidlib_set_grid(&PCB->hidlib, value, pcb_false, 0, 0); else - pcb_board_set_grid(value + PCB->hidlib.grid, pcb_false, 0, 0); + pcb_hidlib_set_grid(&PCB->hidlib, value + PCB->hidlib.grid, pcb_false, 0, 0); } break; Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 25183) +++ trunk/src/crosshair.c (revision 25184) @@ -721,7 +721,7 @@ } if (redraw) { - pcb_redraw(); + pcb_hid_redraw(); } } Index: trunk/src/draw.c =================================================================== --- trunk/src/draw.c (revision 25183) +++ trunk/src/draw.c (revision 25184) @@ -167,14 +167,6 @@ pcb_draw_invalidated.X2 = pcb_draw_invalidated.Y2 = -COORD_MAX; } -/* ---------------------------------------------------------------------- - * redraws all the data by the event handlers - */ -void pcb_redraw(void) -{ - pcb_gui->invalidate_all(); -} - static void draw_everything_holes(pcb_draw_info_t *info, pcb_layergrp_id_t gid) { int plated, unplated; Index: trunk/src/draw.h =================================================================== --- trunk/src/draw.h (revision 25183) +++ trunk/src/draw.h (revision 25184) @@ -124,7 +124,6 @@ void pcb_draw(void); -void pcb_redraw(void); void pcb_draw_obj(pcb_any_obj_t *obj); void pcb_draw_layer(pcb_draw_info_t *info, const pcb_layer_t *ly); void pcb_draw_layer_noxform(pcb_board_t *pcb, const pcb_layer_t *ly, const pcb_box_t *screen); Index: trunk/src/file_act.c =================================================================== --- trunk/src/file_act.c (revision 25183) +++ trunk/src/file_act.c (revision 25184) @@ -161,7 +161,7 @@ pcb_layervis_reset_stack(); pcb_crosshair_set_range(0, 0, PCB->hidlib.size_x, PCB->hidlib.size_y); pcb_center_display(PCB->hidlib.size_x / 2, PCB->hidlib.size_y / 2); - pcb_redraw(); + pcb_hid_redraw(); pcb_board_changed(0); pcb_notify_crosshair_change(pcb_true); PCB_ACT_IRES(0); Index: trunk/src/globalconst.h =================================================================== --- trunk/src/globalconst.h (revision 25183) +++ trunk/src/globalconst.h (revision 25184) @@ -47,7 +47,6 @@ #define PCB_MAX_PINORVIASIZE ((pcb_coord_t)PCB_LARGE_VALUE) #define PCB_MIN_PINORVIACOPPER PCB_MIL_TO_COORD(4) /* min difference outer-inner diameter */ #define PCB_MIN_GRID 1 -#define PCB_MAX_GRID PCB_MIL_TO_COORD(1000) #define PCB_MAX_FONTPOSITION 255 /* upper limit of characters in my font */ #define PCB_MAX_COORD ((pcb_coord_t)PCB_LARGE_VALUE) /* coordinate limits */ Index: trunk/src/grid.c =================================================================== --- trunk/src/grid.c (revision 25183) +++ trunk/src/grid.c (revision 25184) @@ -166,11 +166,11 @@ return tmp.array; /* do not uninit tmp */ } -void pcb_grid_set(pcb_board_t *pcb, const pcb_grid_t *src) +void pcb_grid_set(pcb_hidlib_t *hidlib, const pcb_grid_t *src) { - pcb_board_set_grid(src->size, pcb_true, src->ox, src->oy); + pcb_hidlib_set_grid(hidlib, src->size, pcb_true, src->ox, src->oy); if (src->unit != NULL) - pcb_board_set_unit(pcb, src->unit); + pcb_hidlib_set_unit(hidlib, src->unit); } void pcb_grid_free(pcb_grid_t *dst) @@ -179,7 +179,7 @@ dst->name = NULL; } -pcb_bool_t pcb_grid_list_jump(int dst) +pcb_bool_t pcb_grid_list_jump(pcb_hidlib_t *hidlib, int dst) { const conf_listitem_t *li; pcb_grid_t g; @@ -201,18 +201,18 @@ if (!pcb_grid_parse(&g, li->payload)) return pcb_false; - pcb_grid_set(PCB, &g); + pcb_grid_set(hidlib, &g); pcb_grid_free(&g); return pcb_true; } -pcb_bool_t pcb_grid_list_step(int stp) +pcb_bool_t pcb_grid_list_step(pcb_hidlib_t *hidlib, int stp) { int dst = pcbhl_conf.editor.grids_idx; if (dst < 0) dst = -dst-1; - return pcb_grid_list_jump(dst + stp); + return pcb_grid_list_jump(hidlib, dst + stp); } void pcb_grid_inval(void) Index: trunk/src/grid.h =================================================================== --- trunk/src/grid.h (revision 25183) +++ trunk/src/grid.h (revision 25184) @@ -61,13 +61,13 @@ char *pcb_grid_print(const pcb_grid_t *src); /* Apply grid settings from src to the pcb */ -void pcb_grid_set(pcb_board_t *pcb, const pcb_grid_t *src); +void pcb_grid_set(pcb_hidlib_t *hidlib, const pcb_grid_t *src); /* Jump to grid index dst (clamped); absolute set */ -pcb_bool_t pcb_grid_list_jump(int dst); +pcb_bool_t pcb_grid_list_jump(pcb_hidlib_t *hidlib, int dst); /* Step stp steps (can be 0) on the grids list and set the resulting grid; relative set */ -pcb_bool_t pcb_grid_list_step(int stp); +pcb_bool_t pcb_grid_list_step(pcb_hidlib_t *hidlib, int stp); /* invalidate the grid index; call this when changing the grid settings */ void pcb_grid_inval(void); Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 25183) +++ trunk/src/gui_act.c (revision 25184) @@ -137,7 +137,7 @@ /* redraw layout */ case F_ClearAndRedraw: case F_Redraw: - pcb_redraw(); + pcb_hid_redraw(); break; /* toggle line-adjust flag */ @@ -207,12 +207,12 @@ case F_ToggleThindraw: conf_toggle_editor(thin_draw); - pcb_redraw(); + pcb_hid_redraw(); break; case F_ToggleThindrawPoly: conf_toggle_editor(thin_draw_poly); - pcb_redraw(); + pcb_hid_redraw(); break; case F_ToggleLockNames: @@ -227,7 +227,7 @@ case F_ToggleHideNames: conf_toggle_editor(hide_names); - pcb_redraw(); + pcb_hid_redraw(); break; case F_ToggleStroke: @@ -264,7 +264,7 @@ case F_ToggleCheckPlanes: conf_toggle_editor(check_planes); - pcb_redraw(); + pcb_hid_redraw(); break; case F_ToggleOrthoMove: @@ -273,7 +273,7 @@ case F_ToggleName: conf_toggle_editor(show_number); - pcb_redraw(); + pcb_hid_redraw(); break; case F_ToggleClearLine: @@ -292,7 +292,7 @@ PCB->hidlib.grid = 1; if (pcb_crosshair_move_absolute(pcb_crosshair.X, pcb_crosshair.Y)) pcb_notify_crosshair_change(pcb_true); /* first notify was in MoveCrosshairAbs */ - pcb_board_set_grid(oldGrid, pcb_true, pcb_crosshair.X, pcb_crosshair.Y); + pcb_hidlib_set_grid(&PCB->hidlib, oldGrid, pcb_true, pcb_crosshair.X, pcb_crosshair.Y); pcb_grid_inval(); } break; @@ -300,7 +300,7 @@ /* toggle displaying of the grid */ case F_Grid: conf_toggle_heditor(draw_grid); - pcb_redraw(); + pcb_hid_redraw(); break; /* display the pinout of a subcircuit */ @@ -364,7 +364,7 @@ PCB->hidlib.grid_ox = pcb_get_value(argv[2].val.str, NULL, NULL, NULL); PCB->hidlib.grid_oy = pcb_get_value(argv[3].val.str, NULL, NULL, NULL); if (pcbhl_conf.editor.draw_grid) - pcb_redraw(); + pcb_hid_redraw(); } break; @@ -892,7 +892,7 @@ } if (layer != CURRENT) { pcb_layervis_change_group_vis(pcb_layer_id(PCB->Data, layer), pcb_true, pcb_true); - pcb_redraw(); + pcb_hid_redraw(); } PCB_ACT_IRES(0); return 0; @@ -1635,7 +1635,7 @@ PCB_ACT_IRES(0); new_unit = get_unit_struct(name); - pcb_board_set_unit(PCB, new_unit); + pcb_hidlib_set_unit(&PCB->hidlib, new_unit); return 0; } @@ -1656,19 +1656,19 @@ PCB_ACT_CONVARG(2, FGW_STR, grid, a = argv[2].val.str); if (!pcb_grid_parse(&dst, a)) PCB_ACT_FAIL(grid); - pcb_grid_set(PCB, &dst); + pcb_grid_set(&PCB->hidlib, &dst); pcb_grid_free(&dst); } else if ((strcmp(op, "up") == 0) || (strcmp(op, "+") == 0)) - pcb_grid_list_step(+1); + pcb_grid_list_step(&PCB->hidlib, +1); else if ((strcmp(op, "down") == 0) || (strcmp(op, "-") == 0)) - pcb_grid_list_step(-1); + pcb_grid_list_step(&PCB->hidlib, -1); else if (strcmp(op, "idx") == 0) { PCB_ACT_CONVARG(2, FGW_STR, grid, a = argv[2].val.str); - pcb_grid_list_jump(atoi(a)); + pcb_grid_list_jump(&PCB->hidlib, atoi(a)); } else if (op[0] == '#') { - pcb_grid_list_jump(atoi(op+1)); + pcb_grid_list_jump(&PCB->hidlib, atoi(op+1)); } else PCB_ACT_FAIL(grid); Index: trunk/src/hid.h =================================================================== --- trunk/src/hid.h (revision 25183) +++ trunk/src/hid.h (revision 25184) @@ -632,4 +632,6 @@ int pcb_hid_dock_enter(pcb_hid_dad_subdialog_t *sub, pcb_hid_dock_t where, const char *id); void pcb_hid_dock_leave(pcb_hid_dad_subdialog_t *sub); +#define pcb_hid_redraw() pcb_gui->invalidate_all() + #endif Index: trunk/src/hidlib.c =================================================================== --- trunk/src/hidlib.c (revision 25183) +++ trunk/src/hidlib.c (revision 25184) @@ -44,4 +44,3 @@ return pcb_hidlib_get_name(); return NULL; } - Index: trunk/src/hidlib_conf.c =================================================================== --- trunk/src/hidlib_conf.c (revision 25183) +++ trunk/src/hidlib_conf.c (revision 25184) @@ -29,9 +29,13 @@ #include "conf.h" #include "error.h" #include "color.h" +#include "hidlib.h" +#include "hid.h" #include "hidlib_conf.h" +#define PCB_MAX_GRID PCB_MIL_TO_COORD(1000) + pcbhl_conf_t pcbhl_conf; int pcb_hidlib_conf_init() @@ -44,3 +48,24 @@ return cnt; } + +/* sets cursor grid with respect to grid offset values */ +void pcb_hidlib_set_grid(pcb_hidlib_t *hidlib, pcb_coord_t Grid, pcb_bool align, pcb_coord_t ox, pcb_coord_t oy) +{ + if (Grid >= 1 && Grid <= PCB_MAX_GRID) { + if (align) { + hidlib->grid_ox = ox % Grid; + hidlib->grid_oy = oy % Grid; + } + hidlib->grid = Grid; + conf_set_design("editor/grid", "%$mS", Grid); + if (pcbhl_conf.editor.draw_grid) + pcb_hid_redraw(); + } +} + +void pcb_hidlib_set_unit(pcb_hidlib_t *hidlib, const pcb_unit_t *new_unit) +{ + if (new_unit != NULL && new_unit->allow != PCB_UNIT_NO_PRINT) + conf_set(CFR_DESIGN, "editor/grid_unit", -1, new_unit->suffix, POL_OVERWRITE); +} Index: trunk/src/hidlib_conf.h =================================================================== --- trunk/src/hidlib_conf.h (revision 25183) +++ trunk/src/hidlib_conf.h (revision 25184) @@ -94,4 +94,9 @@ int pcb_hidlib_conf_init(); +/* sets cursor grid with respect to grid spacing, offset and unit values */ +void pcb_hidlib_set_grid(pcb_hidlib_t *hidlib, pcb_coord_t Grid, pcb_bool align, pcb_coord_t ox, pcb_coord_t oy); +void pcb_hidlib_set_unit(pcb_hidlib_t *hidlib, const pcb_unit_t *new_unit); + + #endif Index: trunk/src/object_act.c =================================================================== --- trunk/src/object_act.c (revision 25183) +++ trunk/src/object_act.c (revision 25184) @@ -241,7 +241,7 @@ /* done with our action so increment the undo # */ pcb_undo_inc_serial(); - pcb_redraw(); + pcb_hid_redraw(); pcb_board_set_changed_flag(pcb_true); return 0; Index: trunk/src_plugins/asm/asm.c =================================================================== --- trunk/src_plugins/asm/asm.c (revision 25183) +++ trunk/src_plugins/asm/asm.c (revision 25184) @@ -306,7 +306,7 @@ ly->meta.real.color = asm_ctx.layer_colors.array[n]; vtclr_uninit(&asm_ctx.layer_colors); } - pcb_redraw(); + pcb_hid_redraw(); } /*** UI callbacks ***/ @@ -377,7 +377,7 @@ pcb_gui->attr_dlg_widget_state(hid_ctx, asm_ctx.wdoneg, isgrp | ispart); pcb_gui->attr_dlg_widget_state(hid_ctx, asm_ctx.wskipp, ispart); pcb_gui->attr_dlg_widget_state(hid_ctx, asm_ctx.wdonep, ispart); - pcb_redraw(); /* for displaying the new selection */ + pcb_hid_redraw(); /* for displaying the new selection */ } static void skip(void *hid_ctx, int pick_grp, pcb_hid_row_t *row) Index: trunk/src_plugins/autocrop/autocrop.c =================================================================== --- trunk/src_plugins/autocrop/autocrop.c (revision 25183) +++ trunk/src_plugins/autocrop/autocrop.c (revision 25184) @@ -65,7 +65,7 @@ pcb_draw_inhibit_dec(); pcb_undo_inc_serial(); - pcb_redraw(); + pcb_hid_redraw(); pcb_board_set_changed_flag(1); PCB_ACT_IRES(0); Index: trunk/src_plugins/autoplace/autoplace.c =================================================================== --- trunk/src_plugins/autoplace/autoplace.c (revision 25183) +++ trunk/src_plugins/autoplace/autoplace.c (revision 25184) @@ -799,7 +799,7 @@ if (changed) { pcb_rats_destroy(pcb_false); pcb_net_add_all_rats(PCB, PCB_RATACC_PRECISE); - pcb_redraw(); + pcb_hid_redraw(); } vtp0_uninit(&Selected); return changed; Index: trunk/src_plugins/autoroute/autoroute.c =================================================================== --- trunk/src_plugins/autoroute/autoroute.c (revision 25183) +++ trunk/src_plugins/autoroute/autoroute.c (revision 25184) @@ -4774,7 +4774,7 @@ pcb_undo_inc_serial(); - pcb_redraw(); + pcb_hid_redraw(); } #if defined (ROUTE_DEBUG) aabort = 0; Index: trunk/src_plugins/distalign/distalign.c =================================================================== --- trunk/src_plugins/distalign/distalign.c (revision 25183) +++ trunk/src_plugins/distalign/distalign.c (revision 25184) @@ -341,7 +341,7 @@ PCB_END_LOOP; if (changed) { pcb_undo_inc_serial(); - pcb_redraw(); + pcb_hid_redraw(); pcb_board_set_changed_flag(1); } free_subcs_by_pos(); @@ -510,7 +510,7 @@ } if (changed) { pcb_undo_inc_serial(); - pcb_redraw(); + pcb_hid_redraw(); pcb_board_set_changed_flag(1); } free_subcs_by_pos(); Index: trunk/src_plugins/distaligntext/distaligntext.c =================================================================== --- trunk/src_plugins/distaligntext/distaligntext.c (revision 25183) +++ trunk/src_plugins/distaligntext/distaligntext.c (revision 25184) @@ -397,7 +397,7 @@ if (changed) { pcb_undo_restore_serial(); pcb_undo_inc_serial(); - pcb_redraw(); + pcb_hid_redraw(); pcb_board_set_changed_flag(pcb_true); } free_texts_by_pos(); @@ -576,7 +576,7 @@ if (changed) { pcb_undo_restore_serial(); pcb_undo_inc_serial(); - pcb_redraw(); + pcb_hid_redraw(); pcb_board_set_changed_flag(pcb_true); } free_texts_by_pos(); Index: trunk/src_plugins/export_oldconn/oldconn.c =================================================================== --- trunk/src_plugins/export_oldconn/oldconn.c (revision 25183) +++ trunk/src_plugins/export_oldconn/oldconn.c (revision 25184) @@ -232,7 +232,7 @@ if (conf_core.editor.beep_when_finished) pcb_gui->beep(); - pcb_redraw(); + pcb_hid_redraw(); } static FILE *pcb_check_and_open_file(const char *Filename) Index: trunk/src_plugins/lib_hid_common/grid_menu.c =================================================================== --- trunk/src_plugins/lib_hid_common/grid_menu.c (revision 25183) +++ trunk/src_plugins/lib_hid_common/grid_menu.c (revision 25184) @@ -108,7 +108,7 @@ /* to get the right menu checked */ if ((grids_idx.nat != NULL) && (grids_idx.nat->val.integer[0] >= 0)) - pcb_grid_list_step(0); + pcb_grid_list_step(&PCB->hidlib, 0); grid_lock--; } Index: trunk/src_plugins/query/query_act.c =================================================================== --- trunk/src_plugins/query/query_act.c (revision 25183) +++ trunk/src_plugins/query/query_act.c (revision 25184) @@ -164,7 +164,7 @@ printf("Failed to run the query\n"); if (sel.cnt > 0) { pcb_board_set_changed_flag(pcb_true); - pcb_redraw(); + pcb_hid_redraw(); } PCB_ACT_IRES(0); return 0; @@ -176,7 +176,7 @@ printf("Failed to run the query\n"); if (sel.cnt > 0) { pcb_board_set_changed_flag(pcb_true); - pcb_redraw(); + pcb_hid_redraw(); } PCB_ACT_IRES(0); return 0; Index: trunk/src_plugins/smartdisperse/smartdisperse.c =================================================================== --- trunk/src_plugins/smartdisperse/smartdisperse.c (revision 25183) +++ trunk/src_plugins/smartdisperse/smartdisperse.c (revision 25184) @@ -217,7 +217,7 @@ htpi_uninit(&visited); pcb_undo_inc_serial(); - pcb_redraw(); + pcb_hid_redraw(); pcb_board_set_changed_flag(1); PCB_ACT_IRES(0); Index: trunk/src_plugins/vendordrill/vendor.c =================================================================== --- trunk/src_plugins/vendordrill/vendor.c (revision 25183) +++ trunk/src_plugins/vendordrill/vendor.c (revision 25184) @@ -372,7 +372,7 @@ */ if (changed) { pcb_board_set_changed_flag(pcb_true); - pcb_redraw(); + pcb_hid_redraw(); pcb_undo_inc_serial(); } }