Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 12340) +++ trunk/src/Makefile.dep (revision 12341) @@ -5283,7 +5283,7 @@ rtree.h ht_subc.h vtpadstack.h draw.h select.h operation.h undo.h \ ../src_3rd/libuundo/uundo.h undo_old.h obj_all_op.h obj_arc_op.h \ obj_elem_op.h obj_line_op.h obj_pad_op.h obj_pinvia_op.h obj_poly_op.h \ - obj_text_op.h obj_rat_op.h obj_subc_op.h + obj_text_op.h obj_rat_op.h obj_subc_op.h obj_padstack_op.h crosshair.o: crosshair.c ../config.h conf_core.h conf.h global_typedefs.h \ pcb_bool.h unit.h pcb-printf.h ../src_3rd/genvector/gds_char.h \ ../src_3rd/genvector/genvector_impl.h \ @@ -5418,8 +5418,8 @@ find.h polygon.h search.h rats.h netlist.h library.h route_style.h \ vtroutestyle.h undo.h ../src_3rd/libuundo/uundo.h undo_old.h plug_io.h \ hid_actions.h compat_misc.h event.h layer_vis.h obj_all.h find_geo.c \ - obj_arc_ui.h find_lookup.c compat_nls.h board.h rats_patch.h \ - obj_subc_parent.h find_intconn.c find_drc.c obj_arc_draw.h \ + obj_arc_ui.h obj_padstack_inlines.h board.h rats_patch.h find_lookup.c \ + compat_nls.h obj_subc_parent.h find_intconn.c find_drc.c obj_arc_draw.h \ obj_pad_draw.h obj_rat_draw.h obj_line_draw.h obj_elem_draw.h \ obj_poly_draw.h obj_pinvia_draw.h obj_padstack_draw.h find_misc.c \ change.h find_clear.c find_debug.c find_print.c @@ -5910,7 +5910,7 @@ ../src_3rd/libuundo/uundo.h undo_old.h event.h hid_actions.h \ compat_misc.h obj_all_op.h obj_arc_op.h obj_elem_op.h obj_line_op.h \ obj_pad_op.h obj_pinvia_op.h obj_poly_op.h obj_text_op.h obj_rat_op.h \ - obj_subc_op.h + obj_subc_op.h obj_padstack_op.h netlist.o: netlist.c ../config.h board.h const.h macro.h \ global_typedefs.h pcb_bool.h unit.h vtroutestyle.h attrib.h \ ../src_3rd/genvector/genvector_impl.h \ @@ -6154,7 +6154,9 @@ crosshair.h vtonpoint.h hid.h error.h drc.h route.h buffer.h \ obj_subc_list.h obj_subc.h ../src_3rd/libminuid/libminuid.h rtree.h \ ht_subc.h vtpadstack.h data_list.h draw.h obj_padstack_draw.h \ - obj_padstack_inlines.h search.h rats.h netlist.h route_style.h + obj_padstack_inlines.h operation.h search.h rats.h netlist.h \ + route_style.h undo.h ../src_3rd/libuundo/uundo.h undo_old.h \ + obj_padstack_op.c obj_padstack_act.o: obj_padstack_act.c ../config.h obj_padstack.h \ obj_common.h ../src_3rd/genht/hash.h ../src_3rd/genlist/gendlist.h \ flag.h globalconst.h attrib.h global_typedefs.h pcb_bool.h unit.h \ @@ -6556,7 +6558,7 @@ ../src_3rd/genvector/gds_char.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h polyarea.h obj_common.h \ ../src_3rd/genht/hash.h ../src_3rd/genlist/gendlist.h flag.h \ - globalconst.h attrib.h data_parent.h macro.h + globalconst.h attrib.h data_parent.h macro.h box.h move.h misc_util.h polygon_act.o: polygon_act.c ../config.h conf_core.h conf.h \ global_typedefs.h pcb_bool.h unit.h pcb-printf.h \ ../src_3rd/genvector/gds_char.h ../src_3rd/genvector/genvector_impl.h \ @@ -6813,8 +6815,8 @@ ../src_3rd/libuundo/uundo.h undo_old.h find.h compat_misc.h compat_nls.h \ obj_elem_draw.h obj_pad_draw.h obj_arc_draw.h obj_pinvia_draw.h \ obj_line_draw.h obj_poly_draw.h obj_text_draw.h obj_rat_draw.h \ - ../src_3rd/genregex/regex_sei.h ../src_3rd/genregex/regex_templ.h \ - ../src_3rd/genregex/regex.h + obj_padstack_draw.h ../src_3rd/genregex/regex_sei.h \ + ../src_3rd/genregex/regex_templ.h ../src_3rd/genregex/regex.h select_act.o: select_act.c ../config.h conf_core.h conf.h \ global_typedefs.h pcb_bool.h unit.h pcb-printf.h \ ../src_3rd/genvector/gds_char.h ../src_3rd/genvector/genvector_impl.h \ Index: trunk/src/copy.c =================================================================== --- trunk/src/copy.c (revision 12340) +++ trunk/src/copy.c (revision 12341) @@ -38,6 +38,7 @@ #include "select.h" #include "undo.h" #include "obj_all_op.h" +#include "obj_padstack_op.h" /* --------------------------------------------------------------------------- * some local identifiers @@ -57,7 +58,7 @@ NULL, NULL, pcb_subcop_copy, - NULL /* padstack */ + pcb_padstackop_copy }; /* --------------------------------------------------------------------------- Index: trunk/src/copy.h =================================================================== --- trunk/src/copy.h (revision 12340) +++ trunk/src/copy.h (revision 12341) @@ -35,7 +35,7 @@ * some defines */ #define PCB_COPY_TYPES \ - (PCB_TYPE_VIA | PCB_TYPE_LINE | PCB_TYPE_TEXT | PCB_TYPE_ELEMENT | \ + (PCB_TYPE_VIA | PCB_TYPE_PADSTACK | PCB_TYPE_LINE | PCB_TYPE_TEXT | PCB_TYPE_ELEMENT | \ PCB_TYPE_SUBC | PCB_TYPE_ELEMENT_NAME | PCB_TYPE_POLYGON | PCB_TYPE_ARC) void *pcb_copy_obj(int, void *, void *, void *, pcb_coord_t, pcb_coord_t); Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 12340) +++ trunk/src/crosshair.c (revision 12341) @@ -49,6 +49,7 @@ #include "obj_line_draw.h" #include "obj_arc_draw.h" #include "obj_text_draw.h" +#include "obj_padstack_draw.h" #include "obj_arc_ui.h" #include "obj_all_op.h" @@ -88,6 +89,16 @@ } } +static void thindraw_moved_ps(pcb_padstack_t *ps, pcb_coord_t x, pcb_coord_t y) +{ + /* Make a copy of the pin structure, moved to the correct position */ + pcb_padstack_t moved_ps = *ps; + moved_ps.x += x; + moved_ps.y += y; + + pcb_padstack_thindraw(pcb_crosshair.GC, &moved_ps); +} + /* --------------------------------------------------------------------------- * creates a tmp polygon with coordinates converted to screen system */ @@ -329,6 +340,13 @@ break; } + case PCB_TYPE_PADSTACK: + { + pcb_padstack_t *ps = (pcb_padstack_t *) pcb_crosshair.AttachedObject.Ptr1; + thindraw_moved_ps(ps, dx, dy); + break; + } + case PCB_TYPE_LINE: { /* We move a local copy of the line -the real line hasn't moved, Index: trunk/src/move.c =================================================================== --- trunk/src/move.c (revision 12340) +++ trunk/src/move.c (revision 12341) @@ -44,6 +44,7 @@ #include "hid_actions.h" #include "compat_misc.h" #include "obj_all_op.h" +#include "obj_padstack_op.h" /* --------------------------------------------------------------------------- * some local identifiers @@ -63,7 +64,7 @@ NULL, NULL, pcb_subcop_move, - NULL /* padstack */ + pcb_padstackop_move }; pcb_opfunc_t MoveFunctions_noclip = { @@ -81,7 +82,7 @@ NULL, NULL, NULL, /* subc */ - NULL /* padstack */ + pcb_padstackop_move_noclip }; pcb_opfunc_t ClipFunctions = { @@ -99,7 +100,7 @@ NULL, NULL, NULL, /* subc */ - NULL /* padstack */ + pcb_padstackop_clip }; static pcb_opfunc_t MoveToLayerFunctions = { Index: trunk/src/move.h =================================================================== --- trunk/src/move.h (revision 12340) +++ trunk/src/move.h (revision 12341) @@ -41,7 +41,7 @@ } #define PCB_MOVE_TYPES \ - (PCB_TYPE_VIA | PCB_TYPE_LINE | PCB_TYPE_TEXT | PCB_TYPE_ELEMENT | PCB_TYPE_SUBC | PCB_TYPE_ELEMENT_NAME | \ + (PCB_TYPE_VIA | PCB_TYPE_PADSTACK | PCB_TYPE_LINE | PCB_TYPE_TEXT | PCB_TYPE_ELEMENT | PCB_TYPE_SUBC | PCB_TYPE_ELEMENT_NAME | \ PCB_TYPE_POLYGON | PCB_TYPE_POLYGON_POINT | PCB_TYPE_LINE_POINT | PCB_TYPE_ARC | PCB_TYPE_ARC_POINT) #define PCB_MOVETOLAYER_TYPES \ (PCB_TYPE_LINE | PCB_TYPE_TEXT | PCB_TYPE_POLYGON | PCB_TYPE_RATLINE | PCB_TYPE_ARC) Index: trunk/src/obj_common.c =================================================================== --- trunk/src/obj_common.c (revision 12340) +++ trunk/src/obj_common.c (revision 12341) @@ -76,6 +76,7 @@ case PCB_TYPE_POLYGON: case PCB_TYPE_PAD: case PCB_TYPE_PIN: + case PCB_TYPE_PADSTACK: case PCB_TYPE_ELEMENT_NAME: *res = *(pcb_box_t *)Ptr2; return 0; Index: trunk/src/obj_padstack.c =================================================================== --- trunk/src/obj_padstack.c (revision 12340) +++ trunk/src/obj_padstack.c (revision 12341) @@ -34,7 +34,9 @@ #include "obj_padstack_draw.h" #include "obj_padstack_list.h" #include "obj_padstack_inlines.h" +#include "operation.h" #include "search.h" +#include "undo.h" #include "vtpadstack.h" #define PS_CROSS_SIZE PCB_MM_TO_COORD(1) @@ -131,6 +133,27 @@ pcb_close_box(&ps->BoundingBox); } +/*** utils ***/ + +static pcb_padstack_t *pcb_padstack_copy_meta(pcb_padstack_t *dst, pcb_padstack_t *src) +{ + if (dst == NULL) + return NULL; + pcb_attribute_copy_all(&dst->Attributes, &src->Attributes); + return dst; +} + + +void pcb_padstack_move(pcb_padstack_t *ps, pcb_coord_t dx, pcb_coord_t dy) +{ + ps->x += dx; + ps->y += dy; + ps->BoundingBox.X1 += dx; + ps->BoundingBox.Y1 += dy; + ps->BoundingBox.X2 += dx; + ps->BoundingBox.Y2 += dy; +} + /*** draw ***/ static void set_ps_color(pcb_padstack_t *ps, int is_current) @@ -253,6 +276,35 @@ } + +void pcb_padstack_thindraw(pcb_hid_gc_t gc, pcb_padstack_t *ps) +{ + pcb_padstack_shape_t *shape; + pcb_board_t *pcb; + pcb_layergrp_id_t gid = CURRENT->meta.real.grp; + + pcb = pcb_data_get_top(ps->parent.data); + + shape = pcb_padstack_shape(ps, pcb_layergrp_flags(pcb, gid), 0); + if (shape != NULL) { + pcb_gui->set_draw_xor(gc, 0); + switch(shape->shape) { + case PCB_PSSH_POLY: + pcb_gui->fill_polygon_offs(gc, shape->data.poly.len, shape->data.poly.x, shape->data.poly.y, ps->x, ps->y); + break; + case PCB_PSSH_LINE: + pcb_gui->set_line_cap(gc, shape->data.line.square ? Square_Cap : Round_Cap); + pcb_gui->set_line_width(gc, shape->data.line.thickness); + pcb_gui->draw_line(gc, ps->x + shape->data.line.x1, ps->y + shape->data.line.y1, ps->x + shape->data.line.x2, ps->y + shape->data.line.y2); + pcb_gui->set_line_width(gc, 0); + break; + case PCB_PSSH_CIRC: + pcb_gui->fill_circle(gc, ps->x + shape->data.circ.x, ps->y + shape->data.circ.y, shape->data.circ.dia/2); + break; + } + } +} + #warning padstack TODO: implement these void pcb_padstack_invalidate_erase(pcb_padstack_t *ps) { @@ -289,3 +341,5 @@ #warning padstack TODO return 0; } + +#include "obj_padstack_op.c" Index: trunk/src/obj_padstack_draw.h =================================================================== --- trunk/src/obj_padstack_draw.h (revision 12340) +++ trunk/src/obj_padstack_draw.h (revision 12341) @@ -45,4 +45,7 @@ void pcb_padstack_invalidate_erase(pcb_padstack_t *ps); void pcb_padstack_invalidate_draw(pcb_padstack_t *ps); +void pcb_padstack_thindraw(pcb_hid_gc_t gc, pcb_padstack_t *ps); + + #endif Index: trunk/src/obj_padstack_op.c =================================================================== --- trunk/src/obj_padstack_op.c (nonexistent) +++ trunk/src/obj_padstack_op.c (revision 12341) @@ -0,0 +1,81 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2017 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +void *pcb_padstackop_move_to_buffer(pcb_opctx_t *ctx, pcb_layer_t * layer, pcb_line_t * line) +{ + +} + +void *pcb_padstackop_copy(pcb_opctx_t *ctx, pcb_padstack_t *ps) +{ + pcb_padstack_t *nps; + pcb_data_t *data = ps->parent.data; + assert(ps->parent_type = PCB_PARENT_DATA); + nps = pcb_padstack_new(data, ps->proto, ps->x + ctx->copy.DeltaX, ps->y + ctx->copy.DeltaY, pcb_flag_mask(ps->Flags, PCB_FLAG_FOUND)); + if (nps == NULL) + return NULL; + + pcb_padstack_copy_meta(nps, ps); + pcb_padstack_invalidate_draw(nps); + pcb_undo_add_obj_to_create(PCB_TYPE_PADSTACK, data, nps, nps); + return nps; +} + +void *pcb_padstackop_move_noclip(pcb_opctx_t *ctx, pcb_padstack_t *ps) +{ + pcb_line_invalidate_erase(ps); + pcb_padstack_move(ps, ctx->move.dx, ctx->move.dy); + pcb_line_invalidate_draw(ps); + pcb_draw(); + return ps; +} + +void *pcb_padstackop_move(pcb_opctx_t *ctx, pcb_padstack_t *ps) +{ + pcb_data_t *data = ps->parent.data; + assert(ps->parent_type = PCB_PARENT_DATA); + + pcb_r_delete_entry(data->padstack_tree, (pcb_box_t *)ps); + pcb_poly_restore_to_poly(data, PCB_TYPE_PADSTACK, ps, ps); + pcb_padstackop_move_noclip(ctx, ps); + pcb_r_insert_entry(data->padstack_tree, (pcb_box_t *)ps, 0); + pcb_poly_clear_from_poly(data, PCB_TYPE_PADSTACK, ps, ps); + return ps; +} + +void *pcb_padstackop_clip(pcb_opctx_t *ctx, pcb_padstack_t *ps) +{ + pcb_data_t *data = ps->parent.data; + assert(ps->parent_type = PCB_PARENT_DATA); + + if (ctx->clip.restore) { + pcb_r_delete_entry(data->padstack_tree, (pcb_box_t *)ps); + pcb_poly_restore_to_poly(data, PCB_TYPE_PADSTACK, ps, ps); + } + if (ctx->clip.clear) { + pcb_r_insert_entry(data->padstack_tree, (pcb_box_t *)ps, 0); + pcb_poly_clear_from_poly(data, PCB_TYPE_PADSTACK, ps, ps); + } + + return ps; +} + Index: trunk/src/obj_padstack_op.h =================================================================== --- trunk/src/obj_padstack_op.h (nonexistent) +++ trunk/src/obj_padstack_op.h (revision 12341) @@ -0,0 +1,46 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2017 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +/*** Standard operations on padstacks ***/ + +#include "operation.h" + +/* TODO +void *pcb_padstackop_change_size(pcb_opctx_t *ctx, pcb_padstack_t *ps); +void *pcb_padstackop_change_clear_size(pcb_opctx_t *ctx, pcb_padstack_t *ps); +void *pcb_padstackop_change_name(pcb_opctx_t *ctx, pcb_padstack_t *ps); +void *pcb_padstackop_change_num(pcb_opctx_t *ctx, pcb_padstack_t *ps); +void *pcb_padstackop_change_square(pcb_opctx_t *ctx, pcb_padstack_t *ps); +void *pcb_padstackop_set_square(pcb_opctx_t *ctx, pcb_padstack_t *ps); +void *pcb_padstackop_clear_square(pcb_opctx_t *ctx, pcb_padstack_t *ps); +void *pcb_padstackop_change_mask_size(pcb_opctx_t *ctx, pcb_padstack_t *ps); +void *pcb_padstackop_change_flag(pcb_opctx_t *ctx, pcb_element_t *elem, pcb_padstack_t *ps); +*/ + +void *pcb_padstackop_move_to_buffer(pcb_opctx_t *ctx, pcb_layer_t * layer, pcb_line_t * line); +void *pcb_padstackop_copy(pcb_opctx_t *ctx, pcb_padstack_t *ps); +void *pcb_padstackop_move(pcb_opctx_t *ctx, pcb_padstack_t *ps); +void *pcb_padstackop_move_noclip(pcb_opctx_t *ctx, pcb_padstack_t *ps); +void *pcb_padstackop_clip(pcb_opctx_t *ctx, pcb_padstack_t *ps); + + +