Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 31569) +++ trunk/src/crosshair.c (revision 31570) @@ -462,6 +462,22 @@ break; } + case PCB_OBJ_GFX_POINT: + { + pcb_gfx_t *gfx; + rnd_point_t *point; + int point_idx; + + gfx = (pcb_gfx_t *)pcb_crosshair.AttachedObject.Ptr2; + point = (rnd_point_t *)pcb_crosshair.AttachedObject.Ptr3; + point_idx = point - gfx->corner; + if ((point_idx < 0) || (point_idx > 3)) + break; + + TODO("gfx: crosshair"); + } + break; + case PCB_OBJ_SUBC: pcb_xordraw_subc((pcb_subc_t *) pcb_crosshair.AttachedObject.Ptr2, dx, dy, 0); break; @@ -961,7 +977,7 @@ ans = pcb_search_grid_slop(X, Y, PCB_OBJ_GFX | PCB_OBJ_SUBC_PART, &ptr1, &ptr2, &ptr3); if (ans == PCB_OBJ_GFX) { - TODO("gfx"); + TODO("gfx: crosshair"); } /* Snap to offgrid points on lines. */ Index: trunk/src/move.h =================================================================== --- trunk/src/move.h (revision 31569) +++ trunk/src/move.h (revision 31570) @@ -33,7 +33,7 @@ /*** move ***/ #define PCB_MOVE_TYPES \ - (PCB_OBJ_PSTK | PCB_OBJ_LINE | PCB_OBJ_TEXT | PCB_OBJ_GFX | PCB_OBJ_SUBC | \ + (PCB_OBJ_PSTK | PCB_OBJ_LINE | PCB_OBJ_TEXT | PCB_OBJ_GFX | PCB_OBJ_GFX_POINT | PCB_OBJ_SUBC | \ PCB_OBJ_POLY | PCB_OBJ_POLY_POINT | PCB_OBJ_LINE_POINT | PCB_OBJ_ARC | PCB_OBJ_ARC_POINT) #define PCB_MOVETOLAYER_TYPES \ (PCB_OBJ_LINE | PCB_OBJ_TEXT | PCB_OBJ_POLY | PCB_OBJ_RAT | PCB_OBJ_ARC | PCB_OBJ_GFX) Index: trunk/src/obj_common.c =================================================================== --- trunk/src/obj_common.c (revision 31569) +++ trunk/src/obj_common.c (revision 31570) @@ -65,6 +65,8 @@ case PCB_OBJ_SUBC_PART: return "subc_part"; case PCB_OBJ_LOCKED: return "locked"; case PCB_OBJ_FLOATER: return "floater"; + case PCB_OBJ_GFX_POINT: return "gfx_point"; + } return ""; } @@ -88,6 +90,7 @@ return 0; case PCB_OBJ_POLY_POINT: case PCB_OBJ_LINE_POINT: + case PCB_OBJ_GFX_POINT: *res = *(rnd_rnd_box_t *)Ptr3; return 0; case PCB_OBJ_ARC_POINT: Index: trunk/src/obj_common.h =================================================================== --- trunk/src/obj_common.h (revision 31569) +++ trunk/src/obj_common.h (revision 31570) @@ -63,7 +63,8 @@ PCB_OBJ_POLY_POINT = 0x0400000, PCB_OBJ_SUBC_PART = 0x0800000, PCB_OBJ_LOCKED = 0x1000000, - PCB_OBJ_FLOATER = 0x2000000 + PCB_OBJ_FLOATER = 0x2000000, + PCB_OBJ_GFX_POINT = 0x4000000 } pcb_vobjtype_t; Index: trunk/src/operation.c =================================================================== --- trunk/src/operation.c (revision 31569) +++ trunk/src/operation.c (revision 31570) @@ -93,6 +93,10 @@ res = F->Point(ctx, (pcb_layer_t *)Ptr1, (pcb_poly_t *)Ptr2, (rnd_point_t *)Ptr3); break; + case PCB_OBJ_GFX_POINT: + TODO("gfx: operation"); + break; + case PCB_OBJ_SUBC: if (F->subc) res = F->subc(ctx, (pcb_subc_t *)Ptr2); Index: trunk/src/search.c =================================================================== --- trunk/src/search.c (revision 31569) +++ trunk/src/search.c (revision 31570) @@ -530,7 +530,71 @@ return rnd_false; } +/* --------------------------------------------------------------------------- + * searches a gfx-point on all layers that are switched on + * in layerstack order + */ +typedef struct { + double least; + rnd_bool found; + unsigned long Type; + /* result */ + pcb_gfx_t **gfx; + rnd_point_t **Point; +} gfxptcb_t; + +static rnd_r_dir_t gfxpoint_callback(const rnd_rnd_box_t *box, void *cl) +{ + pcb_gfx_t *gfx = (pcb_gfx_t *)box; + gfxptcb_t *ctx = (ptcb_t *)cl; + double d; + pcb_data_t *dt; + int n; + + dt = gfx->parent.layer->parent.data; /* gfx -> layer -> data */ + if ((dt != NULL) && (dt->parent_type == PCB_PARENT_SUBC)) { + /* do not find subc part poly points if not explicitly requested */ + if (!(ctx->Type & PCB_OBJ_SUBC_PART)) + return RND_R_DIR_NOT_FOUND; + + /* don't find subc poly points even as subc part unless we are editing a subc */ + if (!PCB->loose_subc) + return RND_R_DIR_NOT_FOUND; + } + + for(n = 0; n < 4; n++) { + d = rnd_distance2(gfx->corner[n].X, gfx->corner[n].Y, PosX, PosY); + if (d < ctx->least) { + ctx->least = d; + *ctx->gfx = gfx; + *ctx->Point = &gfx->corner[n]; + ctx->found = rnd_true; + } + } + + return RND_R_DIR_NOT_FOUND; +} + +static rnd_bool SearchGfxPointByLocation(unsigned long Type, unsigned long objst, unsigned long req_flag, pcb_layer_t **Layer, pcb_gfx_t **gfx, rnd_point_t **Point) +{ + gfxptcb_t ctx; + + *Layer = SearchLayer; + ctx.Type = Type; + ctx.gfx = gfx; + ctx.Point = Point; + ctx.found = rnd_false;; + ctx.least = SearchRadius + RND_MAX_POLYGON_POINT_DISTANCE; + ctx.least = ctx.least * ctx.least; + rnd_r_search(SearchLayer->gfx_tree, &SearchBox, NULL, gfxpoint_callback, &ctx, NULL); + + if (ctx.found) + return rnd_true; + return rnd_false; +} + + static rnd_r_dir_t subc_callback(const rnd_rnd_box_t *box, void *cl) { pcb_subc_t *subc = (pcb_subc_t *) box; @@ -1210,6 +1274,11 @@ { if (SearchLayer->meta.real.vis) { if ((HigherAvail & (PCB_OBJ_PSTK)) == 0 && + Type & PCB_OBJ_GFX_POINT && + SearchGfxPointByLocation(Type, objst, req_flag, (pcb_layer_t **) Result1, (pcb_gfx_t **) Result2, (rnd_point_t **) Result3)) + return PCB_OBJ_GFX_POINT; + + if ((HigherAvail & (PCB_OBJ_PSTK)) == 0 && Type & PCB_OBJ_POLY_POINT && SearchPointByLocation(Type, objst, req_flag, (pcb_layer_t **) Result1, (pcb_poly_t **) Result2, (rnd_point_t **) Result3)) return PCB_OBJ_POLY_POINT; @@ -1546,7 +1615,7 @@ PCB_ENDALL_LOOP; } - if (type == PCB_OBJ_GFX) { + if ((type == PCB_OBJ_GFX) || (type == PCB_OBJ_GFX_POINT)) { PCB_GFX_ALL_LOOP(Base); { if (gfx->ID == ID) { @@ -1554,6 +1623,9 @@ *Result2 = *Result3 = (void *)gfx; return PCB_OBJ_GFX; } + if (type == PCB_OBJ_GFX_POINT) { + TODO("gfx: id on point?"); + } } PCB_ENDALL_LOOP; } Index: trunk/src/tool_logic.c =================================================================== --- trunk/src/tool_logic.c (revision 31569) +++ trunk/src/tool_logic.c (revision 31570) @@ -120,6 +120,7 @@ case PCB_OBJ_LINE_POINT: case PCB_OBJ_POLY_POINT: + case PCB_OBJ_GFX_POINT: *x = ((rnd_point_t *) ptr3)->X; *y = ((rnd_point_t *) ptr3)->Y; break;