Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 1363) +++ trunk/src/Makefile.dep (revision 1364) @@ -253,6 +253,15 @@ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h heap.h +hid_draw_helpers.o: hid_draw_helpers.c global.h ../config.h \ + ../config.manual.h ../config.auto.h const.h ../globalconst.h ../config.h \ + macro.h global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h \ + polyarea.h list_common.h list_line.h ../src_3rd/genlist/gentdlist_impl.h \ + ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ + list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ + vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ + ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ + list_element.h libpcb_fp.h polygon.h hid_extents.o: hid_extents.c ../config.h ../config.manual.h \ ../config.auto.h global.h const.h ../globalconst.h ../config.h macro.h \ global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ @@ -261,8 +270,7 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h data.h hid/gtk/../hidint.h \ - hid/common/draw_helpers.h + list_element.h libpcb_fp.h data.h hid/gtk/../hidint.h hid_draw_helpers.h hid_flags.o: hid_flags.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -275,6 +283,15 @@ mymem.h hid/gtk/../hidint.h ../src_3rd/genht/hash.h \ ../src_3rd/genht/htsp.h ../src_3rd/genht/ht.h \ ../src_3rd/genht/ht_inlines.h +hid_resource.o: hid_resource.c global.h ../config.h ../config.manual.h \ + ../config.auto.h const.h ../globalconst.h ../config.h macro.h \ + global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ + list_common.h list_line.h ../src_3rd/genlist/gentdlist_impl.h \ + ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ + list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ + vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ + ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ + list_element.h libpcb_fp.h resource.h hid_resource.h insert.o: insert.c ../config.h ../config.manual.h ../config.auto.h \ global.h const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h list_common.h \ @@ -741,24 +758,6 @@ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h hid.h -draw_helpers.o: hid/common/draw_helpers.c global.h ../config.h \ - ../config.manual.h ../config.auto.h const.h ../globalconst.h ../config.h \ - macro.h global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h \ - polyarea.h list_common.h list_line.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ - list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ - vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h polygon.h global.h -hid_resource.o: hid/common/hid_resource.c global.h ../config.h \ - ../config.manual.h ../config.auto.h const.h ../globalconst.h ../config.h \ - macro.h global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h \ - polyarea.h list_common.h list_line.h ../src_3rd/genlist/gentdlist_impl.h \ - ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ - list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ - vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ - ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h resource.h hid/common/hid_resource.h res_parse.o: res_parse.c ../config.h ../config.manual.h ../config.auto.h \ free_atexit.h global.h const.h ../globalconst.h ../config.h macro.h \ global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ @@ -841,11 +840,12 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h hid/common/hid_resource.h resource.h \ - data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + list_element.h libpcb_fp.h hid.h hid_resource.h resource.h data.h \ + global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h hid/gtk/ghid-cell-renderer-visibility.h + resource.h hid/gtk/gui-pinout-preview.h \ + hid/gtk/ghid-cell-renderer-visibility.h ghid-coord-entry.o: hid/gtk/ghid-coord-entry.c hid/gtk/gtkhid.h \ hid/gtk/gui.h global.h ../config.h ../config.manual.h ../config.auto.h \ const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ @@ -855,11 +855,11 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h hid/common/hid_resource.h resource.h \ - data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + list_element.h libpcb_fp.h hid.h hid_resource.h resource.h data.h \ + global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h pcb-printf.h + resource.h hid/gtk/gui-pinout-preview.h pcb-printf.h ghid-layer-selector.o: hid/gtk/ghid-layer-selector.c hid/gtk/gtkhid.h \ hid/gtk/gui.h global.h ../config.h ../config.manual.h ../config.auto.h \ const.h ../globalconst.h ../config.h macro.h global_typedefs.h \ @@ -869,11 +869,11 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h hid/common/hid_resource.h resource.h \ - data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + list_element.h libpcb_fp.h hid.h hid_resource.h resource.h data.h \ + global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h pcb-printf.h \ + resource.h hid/gtk/gui-pinout-preview.h pcb-printf.h \ hid/gtk/ghid-cell-renderer-visibility.h ghid-main-menu.o: hid/gtk/ghid-main-menu.c hid/gtk/gtkhid.h hid/gtk/gui.h \ global.h ../config.h ../config.manual.h ../config.auto.h const.h \ @@ -884,11 +884,11 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h hid/common/hid_resource.h resource.h \ - data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + list_element.h libpcb_fp.h hid.h hid_resource.h resource.h data.h \ + global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h pcb-printf.h + resource.h hid/gtk/gui-pinout-preview.h pcb-printf.h ghid-route-style-selector.o: hid/gtk/ghid-route-style-selector.c global.h \ ../config.h ../config.manual.h ../config.auto.h const.h ../globalconst.h \ ../config.h macro.h global_typedefs.h global_objs.h \ @@ -899,11 +899,11 @@ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h hid/gtk/gtkhid.h hid/gtk/gui.h hid.h \ - hid/common/hid_resource.h resource.h data.h global.h misc.h \ + hid_resource.h resource.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h hid/gtk/ghid-coord-entry.h \ hid/gtk/ghid-main-menu.h hid/gtk/ghid-layer-selector.h \ - hid/gtk/ghid-route-style-selector.h hid/gtk/gui-pinout-preview.h \ - pcb-printf.h + hid/gtk/ghid-route-style-selector.h resource.h \ + hid/gtk/gui-pinout-preview.h pcb-printf.h gtkhid-main.o: hid/gtk/gtkhid-main.c ../config.h ../config.manual.h \ ../config.auto.h action_helper.h global.h const.h ../globalconst.h \ ../config.h macro.h global_typedefs.h global_objs.h \ @@ -914,12 +914,12 @@ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h crosshair.h error.h hid/gtk/../hidint.h \ - hid/gtk/gui.h global.h hid.h hid/common/hid_resource.h resource.h data.h \ - misc.h ../src_3rd/genvector/gds_char.h mymem.h \ - hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ - hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h hid/common/hidnogui.h \ - hid/common/draw_helpers.h pcb-printf.h dolists.h + hid/gtk/gui.h global.h hid.h hid_resource.h resource.h data.h misc.h \ + ../src_3rd/genvector/gds_char.h mymem.h hid/gtk/ghid-coord-entry.h \ + hid/gtk/ghid-main-menu.h hid/gtk/ghid-layer-selector.h \ + hid/gtk/ghid-route-style-selector.h resource.h \ + hid/gtk/gui-pinout-preview.h hid/common/hidnogui.h hid_draw_helpers.h \ + pcb-printf.h dolists.h gui-command-window.o: hid/gtk/gui-command-window.c ../config.h \ ../config.manual.h ../config.auto.h hid/gtk/gui.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -929,11 +929,11 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h hid/common/hid_resource.h resource.h \ - data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + list_element.h libpcb_fp.h hid.h hid_resource.h resource.h data.h \ + global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h command.h crosshair.h + resource.h hid/gtk/gui-pinout-preview.h command.h crosshair.h gui-config.o: hid/gtk/gui-config.c ../config.h ../config.manual.h \ ../config.auto.h hid/gtk/gui.h global.h const.h ../globalconst.h \ ../config.h macro.h global_typedefs.h global_objs.h \ @@ -943,13 +943,13 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h hid/common/hid_resource.h resource.h \ - data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + list_element.h libpcb_fp.h hid.h hid_resource.h resource.h data.h \ + global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h hid/gtk/../hidint.h hid/gtk/gtkhid.h \ - action_helper.h change.h file.h error.h draw.h portability.h \ - pcb-printf.h set.h + resource.h hid/gtk/gui-pinout-preview.h hid/gtk/../hidint.h \ + hid/gtk/gtkhid.h action_helper.h change.h file.h error.h draw.h \ + portability.h pcb-printf.h set.h gui-dialog-print.o: hid/gtk/gui-dialog-print.c ../config.h \ ../config.manual.h ../config.auto.h hid/gtk/gui.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -959,11 +959,11 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h hid/common/hid_resource.h resource.h \ - data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + list_element.h libpcb_fp.h hid.h hid_resource.h resource.h data.h \ + global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h pcb-printf.h + resource.h hid/gtk/gui-pinout-preview.h pcb-printf.h gui-dialog.o: hid/gtk/gui-dialog.c ../config.h ../config.manual.h \ ../config.auto.h data.h global.h const.h ../globalconst.h ../config.h \ macro.h global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h \ @@ -972,12 +972,11 @@ list_arc.h list_text.h list_poly.h list_pad.h list_pin.h list_rat.h \ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid/gtk/gui.h global.h hid.h \ - hid/common/hid_resource.h resource.h misc.h \ - ../src_3rd/genvector/gds_char.h mymem.h hid/gtk/ghid-coord-entry.h \ - hid/gtk/ghid-main-menu.h hid/gtk/ghid-layer-selector.h \ - hid/gtk/ghid-route-style-selector.h hid/gtk/gui-pinout-preview.h \ - command.h + list_element.h libpcb_fp.h hid/gtk/gui.h global.h hid.h hid_resource.h \ + resource.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ + hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ + resource.h hid/gtk/gui-pinout-preview.h command.h gui-drc-window.o: hid/gtk/gui-drc-window.c ../config.h ../config.manual.h \ ../config.auto.h error.h search.h global.h const.h ../globalconst.h \ ../config.h macro.h global_typedefs.h global_objs.h \ @@ -989,10 +988,10 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h draw.h pcb-printf.h \ ../src_3rd/genvector/gds_char.h undo.h set.h hid/gtk/gui.h global.h \ - hid.h hid/common/hid_resource.h resource.h data.h misc.h mymem.h \ + hid.h hid_resource.h resource.h data.h misc.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h hid/gtk/gui-drc-window.h + resource.h hid/gtk/gui-pinout-preview.h hid/gtk/gui-drc-window.h gui-keyref-window.o: hid/gtk/gui-keyref-window.c ../config.h \ ../config.manual.h ../config.auto.h hid/gtk/gui.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1002,11 +1001,11 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h hid/common/hid_resource.h resource.h \ - data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + list_element.h libpcb_fp.h hid.h hid_resource.h resource.h data.h \ + global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h + resource.h hid/gtk/gui-pinout-preview.h gui-library-window.o: hid/gtk/gui-library-window.c ../config.h \ ../config.manual.h ../config.auto.h hid/gtk/gui.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1016,11 +1015,12 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h hid/common/hid_resource.h resource.h \ - data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + list_element.h libpcb_fp.h hid.h hid_resource.h resource.h data.h \ + global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h buffer.h set.h hid/gtk/gui-library-window.h + resource.h hid/gtk/gui-pinout-preview.h buffer.h set.h \ + hid/gtk/gui-library-window.h gui-log-window.o: hid/gtk/gui-log-window.c ../config.h ../config.manual.h \ ../config.auto.h hid/gtk/gui.h global.h const.h ../globalconst.h \ ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1030,11 +1030,11 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h hid/common/hid_resource.h resource.h \ - data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + list_element.h libpcb_fp.h hid.h hid_resource.h resource.h data.h \ + global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h pcb-printf.h + resource.h hid/gtk/gui-pinout-preview.h pcb-printf.h gui-misc.o: hid/gtk/gui-misc.c ../config.h ../config.manual.h \ ../config.auto.h global.h const.h ../globalconst.h ../config.h macro.h \ global_typedefs.h global_objs.h ../src_3rd/genlist/gendlist.h polyarea.h \ @@ -1045,10 +1045,10 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h crosshair.h global.h data.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h action_helper.h set.h \ - pcb-printf.h hid/gtk/gui.h hid.h hid/common/hid_resource.h resource.h \ + pcb-printf.h hid/gtk/gui.h hid.h hid_resource.h resource.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h + resource.h hid/gtk/gui-pinout-preview.h gui-netlist-window.o: hid/gtk/gui-netlist-window.c ../config.h \ ../config.manual.h ../config.auto.h global.h const.h ../globalconst.h \ ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1061,9 +1061,10 @@ list_element.h libpcb_fp.h create.h global.h data.h draw.h error.h \ find.h misc.h ../src_3rd/genvector/gds_char.h mymem.h mymem.h rats.h \ remove.h search.h select.h set.h undo.h hid/gtk/gui.h hid.h \ - hid/common/hid_resource.h resource.h hid/gtk/ghid-coord-entry.h \ + hid_resource.h resource.h hid/gtk/ghid-coord-entry.h \ hid/gtk/ghid-main-menu.h hid/gtk/ghid-layer-selector.h \ - hid/gtk/ghid-route-style-selector.h hid/gtk/gui-pinout-preview.h + hid/gtk/ghid-route-style-selector.h resource.h \ + hid/gtk/gui-pinout-preview.h gui-output-events.o: hid/gtk/gui-output-events.c ../config.h \ ../config.manual.h ../config.auto.h hid/gtk/gui.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1073,11 +1074,11 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h hid/common/hid_resource.h resource.h \ - data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + list_element.h libpcb_fp.h hid.h hid_resource.h resource.h data.h \ + global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h hid/gtk/gtkhid.h action_helper.h \ + resource.h hid/gtk/gui-pinout-preview.h hid/gtk/gtkhid.h action_helper.h \ crosshair.h draw.h error.h set.h find.h search.h rats.h gui-pinout-preview.o: hid/gtk/gui-pinout-preview.c ../config.h \ ../config.manual.h ../config.auto.h global.h const.h ../globalconst.h \ @@ -1088,11 +1089,12 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid/gtk/gui.h hid.h hid/common/hid_resource.h \ - resource.h data.h global.h misc.h ../src_3rd/genvector/gds_char.h \ - mymem.h hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ + list_element.h libpcb_fp.h hid/gtk/gui.h hid.h hid_resource.h resource.h \ + data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h copy.h draw.h mymem.h move.h rotate.h + resource.h hid/gtk/gui-pinout-preview.h copy.h draw.h mymem.h move.h \ + rotate.h gui-pinout-window.o: hid/gtk/gui-pinout-window.c ../config.h \ ../config.manual.h ../config.auto.h global.h const.h ../globalconst.h \ ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1102,11 +1104,12 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid/gtk/gui.h hid.h hid/common/hid_resource.h \ - resource.h data.h global.h misc.h ../src_3rd/genvector/gds_char.h \ - mymem.h hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ + list_element.h libpcb_fp.h hid/gtk/gui.h hid.h hid_resource.h resource.h \ + data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h copy.h draw.h mymem.h move.h rotate.h + resource.h hid/gtk/gui-pinout-preview.h copy.h draw.h mymem.h move.h \ + rotate.h gui-top-window.o: hid/gtk/gui-top-window.c ../config.h ../config.manual.h \ ../config.auto.h hid/gtk/ghid-layer-selector.h \ hid/gtk/ghid-route-style-selector.h global.h const.h ../globalconst.h \ @@ -1118,9 +1121,9 @@ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h hid/gtk/gtkhid.h hid/gtk/gui.h hid.h \ - hid/common/hid_resource.h resource.h data.h global.h misc.h \ + hid_resource.h resource.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h hid/gtk/ghid-coord-entry.h \ - hid/gtk/ghid-main-menu.h hid/gtk/gui-pinout-preview.h \ + hid/gtk/ghid-main-menu.h resource.h hid/gtk/gui-pinout-preview.h \ hid/gtk/../hidint.h action_helper.h buffer.h change.h command.h copy.h \ create.h crosshair.h draw.h error.h file.h find.h gpcb-menu.h insert.h \ line.h mymem.h move.h pcb-printf.h polygon.h rats.h remove.h report.h \ @@ -1136,11 +1139,11 @@ list_pad.h list_pin.h list_rat.h vtonpoint.h \ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ - list_element.h libpcb_fp.h hid.h hid/common/hid_resource.h resource.h \ - data.h global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ + list_element.h libpcb_fp.h hid.h hid_resource.h resource.h data.h \ + global.h misc.h ../src_3rd/genvector/gds_char.h mymem.h \ hid/gtk/ghid-coord-entry.h hid/gtk/ghid-main-menu.h \ hid/gtk/ghid-layer-selector.h hid/gtk/ghid-route-style-selector.h \ - hid/gtk/gui-pinout-preview.h + resource.h hid/gtk/gui-pinout-preview.h gtkhid-gdk.o: hid/gtk/gtkhid-gdk.c ../config.h ../config.manual.h \ ../config.auto.h crosshair.h global.h const.h ../globalconst.h \ ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1151,11 +1154,11 @@ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h clip.h hid/gtk/../hidint.h hid/gtk/gui.h \ - global.h hid.h hid/common/hid_resource.h resource.h data.h misc.h \ + global.h hid.h hid_resource.h resource.h data.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h hid/gtk/ghid-coord-entry.h \ hid/gtk/ghid-main-menu.h hid/gtk/ghid-layer-selector.h \ - hid/gtk/ghid-route-style-selector.h hid/gtk/gui-pinout-preview.h \ - hid/common/draw_helpers.h + hid/gtk/ghid-route-style-selector.h resource.h \ + hid/gtk/gui-pinout-preview.h hid_draw_helpers.h dialogs.o: hid/lesstif/dialogs.c ../config.h ../config.manual.h \ ../config.auto.h hid/lesstif/xincludes.h compat.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1192,8 +1195,8 @@ list_element.h libpcb_fp.h data.h global.h action_helper.h crosshair.h \ mymem.h misc.h ../src_3rd/genvector/gds_char.h mymem.h pcb-printf.h \ resource.h clip.h event.h error.h hid.h hid/lesstif/../hidint.h \ - hid/common/hidnogui.h hid/common/draw_helpers.h \ - hid/common/hid_resource.h hid/lesstif/lesstif.h dolists.h + hid/common/hidnogui.h hid_draw_helpers.h hid_resource.h resource.h \ + hid/lesstif/lesstif.h dolists.h menu.o: hid/lesstif/menu.c ../config.h ../config.manual.h \ ../config.auto.h hid/lesstif/xincludes.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1205,7 +1208,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h data.h global.h error.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h pcb-printf.h hid.h \ - hid/lesstif/../hidint.h hid/common/hid_resource.h resource.h \ + hid/lesstif/../hidint.h hid_resource.h resource.h resource.h \ hid/lesstif/lesstif.h mymem.h paths.h pcb-menu.h \ hid/lesstif/../../../src_3rd/genht/htsp.h \ hid/lesstif/../../../src_3rd/genht/ht.h \ @@ -1245,7 +1248,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h hid.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h hid/batch/../hidint.h \ - pcb-printf.h hid/common/draw_helpers.h hid/common/hidnogui.h actions.h \ + pcb-printf.h hid_draw_helpers.h hid/common/hidnogui.h actions.h \ hid/common/hidinit.h dolists.h ../src_plugins/autoplace/autoplace.o: \ ../src_plugins/autoplace/autoplace.c ../config.h ../config.manual.h \ @@ -1446,7 +1449,7 @@ list_element.h libpcb_fp.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h error.h draw.h pcb-printf.h \ plugins.h layer_helper.h hid.h hid/hidint.h hid/common/hidnogui.h \ - hid/common/draw_helpers.h ../src_plugins/export_ps/ps.h print.h \ + hid_draw_helpers.h ../src_plugins/export_ps/ps.h print.h \ hid/common/hidinit.h dolists.h ../src_plugins/export_ps/eps.o: ../src_plugins/export_ps/eps.c \ ../config.h ../config.manual.h ../config.auto.h global.h const.h \ @@ -1459,8 +1462,8 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h pcb-printf.h hid.h hid/hidint.h \ - hid/common/hidnogui.h hid/common/draw_helpers.h \ - ../src_plugins/export_ps/ps.h hid/common/hidinit.h + hid/common/hidnogui.h hid_draw_helpers.h ../src_plugins/export_ps/ps.h \ + hid/common/hidinit.h ../src_plugins/export_lpr/lpr.o: ../src_plugins/export_lpr/lpr.c \ ../config.h ../config.manual.h ../config.auto.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1485,7 +1488,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h error.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h rats.h layer_helper.h hid.h \ - hid/gtk/../hidint.h hid/common/hidnogui.h hid/common/draw_helpers.h \ + hid/gtk/../hidint.h hid/common/hidnogui.h hid_draw_helpers.h \ ../src_plugins/export_gcode/gcode.h ../src_plugins/export_gcode/bitmap.h \ ../src_plugins/export_gcode/potracelib.h \ ../src_plugins/export_gcode/curve.h \ @@ -1530,8 +1533,8 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h error.h data.h global.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h rats.h plugins.h layer_helper.h \ - hid.h hid/gtk/../hidint.h hid/common/hidnogui.h \ - hid/common/draw_helpers.h hid/common/hidinit.h dolists.h + hid.h hid/gtk/../hidint.h hid/common/hidnogui.h hid_draw_helpers.h \ + hid/common/hidinit.h dolists.h ../src_plugins/export_png/png.o: ../src_plugins/export_png/png.c \ ../config.h ../config.manual.h ../config.auto.h global.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1543,7 +1546,7 @@ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h libpcb_fp.h data.h global.h error.h misc.h \ ../src_3rd/genvector/gds_char.h mymem.h plugins.h hid.h \ - hid/gtk/../hidint.h hid/common/hidnogui.h hid/common/draw_helpers.h \ + hid/gtk/../hidint.h hid/common/hidnogui.h hid_draw_helpers.h \ ../src_plugins/export_png/png.h hid/common/hidinit.h dolists.h ../src_plugins/export_bom/bom.o: ../src_plugins/export_bom/bom.c \ ../config.h ../config.manual.h ../config.auto.h global.h const.h \ Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 1363) +++ trunk/src/Makefile.in (revision 1364) @@ -36,8 +36,10 @@ funchash.o gui_act.o heap.o + hid_draw_helpers.o hid_extents.o hid_flags.o + hid_resource.o insert.o intersect.o layer_helper.o @@ -89,8 +91,6 @@ vtonpoint.o hid/common/hidinit.o hid/common/hidnogui.o - hid/common/draw_helpers.o - hid/common/hid_resource.o res_parse.o res_lex.o portability.o Index: trunk/src/hid/batch/batch.c =================================================================== --- trunk/src/hid/batch/batch.c (revision 1363) +++ trunk/src/hid/batch/batch.c (revision 1364) @@ -16,7 +16,7 @@ #include "../hidint.h" #include "pcb-printf.h" -#include "hid/common/draw_helpers.h" +#include "hid_draw_helpers.h" #include "hid/common/hidnogui.h" #include "actions.h" #include "hid/common/hidinit.h" Index: trunk/src/hid/common/hid_resource.h =================================================================== --- trunk/src/hid/common/hid_resource.h (revision 1363) +++ trunk/src/hid/common/hid_resource.h (nonexistent) @@ -1,21 +0,0 @@ - -#ifndef PCB_HID_COMMON_HID_RESOURCE_H -#define PCB_HID_COMMON_HID_RESOURCE_H - -#include "resource.h" - -#define M_Shift 1 -#define M_Ctrl 2 -#define M_Mod(n) (1<<(n+1)) -#define M_Alt M_Mod(1) -#define M_Multi M_Mod(2) -#define M_Release (~((unsigned)-1>>1)) /* set the top bit */ - -void load_mouse_resource(const Resource * res); -void do_mouse_action(int button, int mods); - -/* Create a set of resources representing a single menu item */ -Resource *resource_create_menu(const char *name, const char *action, const char *mnemonic, const char *accel, const char *tip, - int flags); - -#endif Index: trunk/src/hid/common/draw_helpers.h =================================================================== --- trunk/src/hid/common/draw_helpers.h (revision 1363) +++ trunk/src/hid/common/draw_helpers.h (nonexistent) @@ -1,7 +0,0 @@ -void common_fill_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box); -void common_thindraw_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box); -void common_fill_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask); -void common_thindraw_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask); -void common_fill_pcb_pv(hidGC gc, PinType * pv, bool drawHole, bool mask); -void common_thindraw_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pv, bool drawHole, bool mask); -void common_draw_helpers_init(HID * hid); Index: trunk/src/hid/common/hid_resource.c =================================================================== --- trunk/src/hid/common/hid_resource.c (revision 1363) +++ trunk/src/hid/common/hid_resource.c (nonexistent) @@ -1,267 +0,0 @@ -#include -#include -#include - -#include "global.h" -#include "hid.h" -#include "resource.h" -#include "hid/common/hid_resource.h" - -/* #define DEBUG_HID_RESOURCE */ - -static int button_count; /* number of buttons we have actions for */ -static int *button_nums; /* list of button numbers */ -static int *mod_count; /* how many mods they have */ -static unsigned *mods; /* mods, in order, one button after another */ -static Resource **actions; /* actions, in order, one button after another */ - -static Resource *res_wrap(char *value) -{ - Resource *tmp; - tmp = resource_create(0); - resource_add_val(tmp, 0, value, 0); - return tmp; -} - -static unsigned parse_mods(char *value) -{ - unsigned m = 0; - long int mod_num; - char *s; - - for (s = value; *s; s++) - *s = tolower(*s); - - s = strstr(value, "mod"); - if (s) { - s += 3; /* skip "mod" to get to number */ - errno = 0; - mod_num = strtol(s, (char **) NULL, 0); - if (!errno) - m |= M_Mod(mod_num); - } - if (strstr(value, "shift")) - m |= M_Shift; - if (strstr(value, "ctrl")) - m |= M_Ctrl; - if (strstr(value, "alt")) - m |= M_Alt; - if (strstr(value, "up")) - m |= M_Release; - return m; -} - -static int button_name_to_num(const char *name) -{ - /* All mouse-related resources must be named. The name is the - mouse button number. */ - if (!name) - return -1; - else if (strcasecmp(name, "left") == 0) - return 1; - else if (strcasecmp(name, "middle") == 0) - return 2; - else if (strcasecmp(name, "right") == 0) - return 3; - else if (strcasecmp(name, "up") == 0) - return 4; - else if (strcasecmp(name, "down") == 0) - return 5; - else - return atoi(name); -} - -void load_mouse_resource(const Resource * res) -{ - int bi, mi, a; - int action_count; -#ifdef DEBUG_HID_RESOURCE - fprintf(stderr, "note mouse resource:\n"); - resource_dump(res); -#endif - - button_count = res->c; - button_nums = (int *) malloc(res->c * sizeof(int)); - mod_count = (int *) malloc(res->c * sizeof(int)); - action_count = 0; - for (bi = 0; bi < res->c; bi++) { - if (res->v[bi].value) - action_count++; - - if (res->v[bi].subres) - action_count += res->v[bi].subres->c; - - } - mods = (unsigned int *) malloc(action_count * sizeof(int)); - actions = (Resource **) malloc(action_count * sizeof(Resource *)); - - a = 0; - for (bi = 0; bi < res->c; bi++) { - int button_num = button_name_to_num(res->v[bi].name); - - if (button_num < 0) - continue; - - button_nums[bi] = button_num; - mod_count[bi] = 0; - - if (res->v[bi].value) { - mods[a] = 0; - actions[a++] = res_wrap(res->v[bi].value); - mod_count[bi] = 1; - } - - if (res->v[bi].subres) { - Resource *m = res->v[bi].subres; - mod_count[bi] += m->c; - - for (mi = 0; mi < m->c; mi++, a++) { - switch (resource_type(m->v[mi])) { - case 1: /* subres only */ - mods[a] = 0; - actions[a] = m->v[mi].subres; - break; - - case 10: /* value only */ - mods[a] = 0; - actions[a] = res_wrap(m->v[mi].value); - break; - - case 101: /* name = subres */ - mods[a] = parse_mods(m->v[mi].name); - actions[a] = m->v[mi].subres; - break; - - case 110: /* name = value */ - mods[a] = parse_mods(m->v[mi].name); - actions[a] = res_wrap(m->v[mi].value); - break; - } - } - } - } -} - -static Resource *find_best_action(int button, int start, unsigned mod_mask) -{ - int i, j; - int count = mod_count[button]; - unsigned search_mask = mod_mask & ~M_Release; - unsigned release_mask = mod_mask & M_Release; - - /* look for exact mod match */ - for (i = start; i < start + count; i++) - if (mods[i] == mod_mask) { - return actions[i]; - } - - for (j = search_mask - 1; j >= 0; j--) - if ((j & search_mask) == j) /* this would work */ - for (i = start; i < start + count; i++) /* search for it */ - if (mods[i] == (j | release_mask)) - return actions[i]; - - return NULL; -} - -void do_mouse_action(int button, int mod_mask) -{ - Resource *action = NULL; - int bi, i, a; - - /* find the right set of actions; */ - a = 0; - for (bi = 0; bi < button_count && !action; bi++) - if (button_nums[bi] == button) { - action = find_best_action(bi, a, mod_mask); - break; - } - else - a += mod_count[bi]; /* skip this buttons actions */ - - if (!action) - return; - - for (i = 0; i < action->c; i++) - if (action->v[i].value) - if (hid_parse_actions(action->v[i].value)) - return; -} - -Resource *resource_create_menu(const char *name, const char *action, const char *mnemonic, const char *accel, const char *tip, - int flags) -{ - Resource *resp, *res; - ResourceVal *rvp, *rv; - int next; - - /* child */ - res = calloc(sizeof(Resource), 1); - res->c = 1 + (action != NULL) + (mnemonic != NULL) + (accel != NULL) + (tip != NULL); - rv = malloc(sizeof(ResourceVal) * res->c); - res->v = rv; - res->flags = flags; - - rv[0].name = NULL; - rv[0].value = strdup(name); - rv[0].subres = NULL; - next = 1; - - if (action != NULL) { - rv[next].name = NULL; - rv[next].value = strdup(action); - rv[next].subres = NULL; - next++; - } - - if (mnemonic != NULL) { - rv[next].name = "m"; - rv[next].value = strdup(mnemonic); - rv[next].subres = NULL; - next++; - } - - if (accel != NULL) { - Resource *ares; - ResourceVal *arv; - - ares = calloc(sizeof(Resource), 1); - arv = malloc(sizeof(ResourceVal) * 2); - ares->c = 2; - ares->v = arv; - ares->flags = 0; - - arv[0].name = NULL; - arv[0].value = strdup(accel); - arv[0].subres = NULL; - - arv[1].name = NULL; - arv[1].value = strdup(accel); - arv[1].subres = NULL; - - rv[next].name = "a"; - rv[next].value = NULL; - rv[next].subres = ares; - - next++; - } - - if (tip != NULL) { - rv[next].name = "tip"; - rv[next].value = strdup(tip); - rv[next].subres = NULL; - next++; - } - - /* parent */ - resp = calloc(sizeof(Resource), 1); - rvp = malloc(sizeof(ResourceVal)); - - resp->v = rvp; - resp->c = 1; - rvp->name = NULL; - rvp->value = NULL; - rvp->subres = res; - - return resp; -} Index: trunk/src/hid/common/draw_helpers.c =================================================================== --- trunk/src/hid/common/draw_helpers.c (revision 1363) +++ trunk/src/hid/common/draw_helpers.c (nonexistent) @@ -1,436 +0,0 @@ -#include "global.h" -#include "hid.h" -#include "polygon.h" - -static void fill_contour(hidGC gc, PLINE * pl) -{ - Coord *x, *y, n, i = 0; - VNODE *v; - - n = pl->Count; - x = (Coord *) malloc(n * sizeof(*x)); - y = (Coord *) malloc(n * sizeof(*y)); - - for (v = &pl->head; i < n; v = v->next) { - x[i] = v->point[0]; - y[i++] = v->point[1]; - } - - gui->fill_polygon(gc, n, x, y); - - free(x); - free(y); -} - -static void thindraw_contour(hidGC gc, PLINE * pl) -{ - VNODE *v; - Coord last_x, last_y; - Coord this_x, this_y; - - gui->set_line_width(gc, 0); - gui->set_line_cap(gc, Round_Cap); - - /* If the contour is round, use an arc drawing routine. */ - if (pl->is_round) { - gui->draw_arc(gc, pl->cx, pl->cy, pl->radius, pl->radius, 0, 360); - return; - } - - /* Need at least two points in the contour */ - if (pl->head.next == NULL) - return; - - last_x = pl->head.point[0]; - last_y = pl->head.point[1]; - v = pl->head.next; - - do { - this_x = v->point[0]; - this_y = v->point[1]; - - gui->draw_line(gc, last_x, last_y, this_x, this_y); - /* gui->fill_circle (gc, this_x, this_y, 30); */ - - last_x = this_x; - last_y = this_y; - } - while ((v = v->next) != pl->head.next); -} - -static void fill_contour_cb(PLINE * pl, void *user_data) -{ - hidGC gc = (hidGC) user_data; - PLINE *local_pl = pl; - - fill_contour(gc, pl); - poly_FreeContours(&local_pl); -} - -static void fill_clipped_contour(hidGC gc, PLINE * pl, const BoxType * clip_box) -{ - PLINE *pl_copy; - POLYAREA *clip_poly; - POLYAREA *piece_poly; - POLYAREA *clipped_pieces; - POLYAREA *draw_piece; - int x; - - clip_poly = RectPoly(clip_box->X1, clip_box->X2, clip_box->Y1, clip_box->Y2); - poly_CopyContour(&pl_copy, pl); - piece_poly = poly_Create(); - poly_InclContour(piece_poly, pl_copy); - x = poly_Boolean_free(piece_poly, clip_poly, &clipped_pieces, PBO_ISECT); - if (x != err_ok || clipped_pieces == NULL) - return; - - draw_piece = clipped_pieces; - do { - /* NB: The polygon won't have any holes in it */ - fill_contour(gc, draw_piece->contours); - } - while ((draw_piece = draw_piece->f) != clipped_pieces); - poly_Free(&clipped_pieces); -} - -/* If at least 50% of the bounding box of the polygon is on the screen, - * lets compute the complete no-holes polygon. - */ -#define BOUNDS_INSIDE_CLIP_THRESHOLD 0.5 -static int should_compute_no_holes(PolygonType * poly, const BoxType * clip_box) -{ - Coord x1, x2, y1, y2; - double poly_bounding_area; - double clipped_poly_area; - - /* If there is no passed clip box, compute the whole thing */ - if (clip_box == NULL) - return 1; - - x1 = MAX(poly->BoundingBox.X1, clip_box->X1); - x2 = MIN(poly->BoundingBox.X2, clip_box->X2); - y1 = MAX(poly->BoundingBox.Y1, clip_box->Y1); - y2 = MIN(poly->BoundingBox.Y2, clip_box->Y2); - - /* Check if the polygon is outside the clip box */ - if ((x2 <= x1) || (y2 <= y1)) - return 0; - - poly_bounding_area = (double) (poly->BoundingBox.X2 - poly->BoundingBox.X1) * - (double) (poly->BoundingBox.Y2 - poly->BoundingBox.Y1); - - clipped_poly_area = (double) (x2 - x1) * (double) (y2 - y1); - - if (clipped_poly_area / poly_bounding_area >= BOUNDS_INSIDE_CLIP_THRESHOLD) - return 1; - - return 0; -} - -#undef BOUNDS_INSIDE_CLIP_THRESHOLD - -void common_fill_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box) -{ - if (!poly->NoHolesValid) { - /* If enough of the polygon is on-screen, compute the entire - * NoHoles version and cache it for later rendering, otherwise - * just compute what we need to render now. - */ - if (should_compute_no_holes(poly, clip_box)) - ComputeNoHoles(poly); - else - NoHolesPolygonDicer(poly, clip_box, fill_contour_cb, gc); - } - if (poly->NoHolesValid && poly->NoHoles) { - PLINE *pl; - - for (pl = poly->NoHoles; pl != NULL; pl = pl->next) { - if (clip_box == NULL) - fill_contour(gc, pl); - else - fill_clipped_contour(gc, pl, clip_box); - } - } - - /* Draw other parts of the polygon if fullpoly flag is set */ - /* NB: No "NoHoles" cache for these */ - if (TEST_FLAG(FULLPOLYFLAG, poly)) { - PolygonType p = *poly; - - for (p.Clipped = poly->Clipped->f; p.Clipped != poly->Clipped; p.Clipped = p.Clipped->f) - NoHolesPolygonDicer(&p, clip_box, fill_contour_cb, gc); - } -} - -static int thindraw_hole_cb(PLINE * pl, void *user_data) -{ - hidGC gc = (hidGC) user_data; - thindraw_contour(gc, pl); - return 0; -} - -void common_thindraw_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box) -{ - thindraw_contour(gc, poly->Clipped->contours); - PolygonHoles(poly, clip_box, thindraw_hole_cb, gc); -} - -void common_thindraw_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask) -{ - Coord w = clear ? (mask ? pad->Mask : pad->Thickness + pad->Clearance) - : pad->Thickness; - Coord x1, y1, x2, y2; - Coord t = w / 2; - x1 = pad->Point1.X; - y1 = pad->Point1.Y; - x2 = pad->Point2.X; - y2 = pad->Point2.Y; - if (x1 > x2 || y1 > y2) { - Coord temp_x = x1; - Coord temp_y = y1; - x1 = x2; - x2 = temp_x; - y1 = y2; - y2 = temp_y; - } - gui->set_line_cap(gc, Round_Cap); - gui->set_line_width(gc, 0); - if (TEST_FLAG(SQUAREFLAG, pad)) { - /* slanted square pad */ - double tx, ty, theta; - - if (x1 == x2 && y1 == y2) - theta = 0; - else - theta = atan2(y2 - y1, x2 - x1); - - /* T is a vector half a thickness long, in the direction of - one of the corners. */ - tx = t * cos(theta + M_PI / 4) * sqrt(2.0); - ty = t * sin(theta + M_PI / 4) * sqrt(2.0); - - gui->draw_line(gc, x1 - tx, y1 - ty, x2 + ty, y2 - tx); - gui->draw_line(gc, x2 + ty, y2 - tx, x2 + tx, y2 + ty); - gui->draw_line(gc, x2 + tx, y2 + ty, x1 - ty, y1 + tx); - gui->draw_line(gc, x1 - ty, y1 + tx, x1 - tx, y1 - ty); - } - else if (x1 == x2 && y1 == y2) { - gui->draw_arc(gc, x1, y1, t, t, 0, 360); - } - else { - /* Slanted round-end pads. */ - Coord dx, dy, ox, oy; - double h; - - dx = x2 - x1; - dy = y2 - y1; - h = t / sqrt(SQUARE(dx) + SQUARE(dy)); - ox = dy * h + 0.5 * SGN(dy); - oy = -(dx * h + 0.5 * SGN(dx)); - - gui->draw_line(gc, x1 + ox, y1 + oy, x2 + ox, y2 + oy); - - if (abs(ox) >= pixel_slop || abs(oy) >= pixel_slop) { - Angle angle = atan2(dx, dy) * 57.295779; - gui->draw_line(gc, x1 - ox, y1 - oy, x2 - ox, y2 - oy); - gui->draw_arc(gc, x1, y1, t, t, angle - 180, 180); - gui->draw_arc(gc, x2, y2, t, t, angle, 180); - } - } -} - -void common_fill_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask) -{ - Coord w = clear ? (mask ? pad->Mask : pad->Thickness + pad->Clearance) - : pad->Thickness; - - if (pad->Point1.X == pad->Point2.X && pad->Point1.Y == pad->Point2.Y) { - if (TEST_FLAG(SQUAREFLAG, pad)) { - Coord l, r, t, b; - l = pad->Point1.X - w / 2; - b = pad->Point1.Y - w / 2; - r = l + w; - t = b + w; - gui->fill_rect(gc, l, b, r, t); - } - else { - gui->fill_circle(gc, pad->Point1.X, pad->Point1.Y, w / 2); - } - } - else { - gui->set_line_cap(gc, TEST_FLAG(SQUAREFLAG, pad) ? Square_Cap : Round_Cap); - gui->set_line_width(gc, w); - - gui->draw_line(gc, pad->Point1.X, pad->Point1.Y, pad->Point2.X, pad->Point2.Y); - } -} - -/* --------------------------------------------------------------------------- - * draws one polygon - * x and y are already in display coordinates - * the points are numbered: - * - * 5 --- 6 - * / \ - * 4 7 - * | | - * 3 0 - * \ / - * 2 --- 1 - */ - -typedef struct { - double X, Y; -} FloatPolyType; - -static void draw_square_pin_poly(hidGC gc, Coord X, Coord Y, Coord Thickness, Coord thin_draw, int style) -{ - static FloatPolyType p[8] = { - {0.5, -TAN_22_5_DEGREE_2}, - {TAN_22_5_DEGREE_2, -0.5}, - {-TAN_22_5_DEGREE_2, -0.5}, - {-0.5, -TAN_22_5_DEGREE_2}, - {-0.5, TAN_22_5_DEGREE_2}, - {-TAN_22_5_DEGREE_2, 0.5}, - {TAN_22_5_DEGREE_2, 0.5}, - {0.5, TAN_22_5_DEGREE_2} - }; - static int special_size = 0; - static int scaled_x[8]; - static int scaled_y[8]; - Coord polygon_x[9]; - Coord polygon_y[9]; - double xm[8], ym[8]; - int i; - - square_pin_factors(style, xm, ym); - - if (Thickness != special_size) { - special_size = Thickness; - for (i = 0; i < 8; i++) { - scaled_x[i] = p[i].X * special_size; - scaled_y[i] = p[i].Y * special_size; - } - } - /* add line offset */ - for (i = 0; i < 8; i++) { - polygon_x[i] = X + scaled_x[i] * xm[i]; - polygon_y[i] = Y + scaled_y[i] * ym[i]; - } - - if (thin_draw) { - int i; - gui->set_line_cap(gc, Round_Cap); - gui->set_line_width(gc, 0); - polygon_x[8] = X + scaled_x[0] * xm[0]; - polygon_y[8] = Y + scaled_y[0] * ym[0]; - for (i = 0; i < 8; i++) - gui->draw_line(gc, polygon_x[i], polygon_y[i], polygon_x[i + 1], polygon_y[i + 1]); - } - else - gui->fill_polygon(gc, 8, polygon_x, polygon_y); -} - -static void draw_octagon_poly(hidGC gc, Coord X, Coord Y, Coord Thickness, Coord thin_draw) -{ - draw_square_pin_poly(gc, X, Y, Thickness, thin_draw, 17); -} - - -void common_fill_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pv, bool drawHole, bool mask) -{ - Coord w = mask ? pv->Mask : pv->Thickness; - Coord r = w / 2; - - if (TEST_FLAG(HOLEFLAG, pv)) { - if (mask) - gui->fill_circle(bg_gc, pv->X, pv->Y, r); - if (drawHole) { - gui->fill_circle(bg_gc, pv->X, pv->Y, r); - gui->set_line_cap(fg_gc, Round_Cap); - gui->set_line_width(fg_gc, 0); - gui->draw_arc(fg_gc, pv->X, pv->Y, r, r, 0, 360); - } - return; - } - - if (TEST_FLAG(SQUAREFLAG, pv)) { - /* use the original code for now */ - if ((GET_SQUARE(pv) == 0) || (GET_SQUARE(pv) == 1)) { - Coord l = pv->X - r; - Coord b = pv->Y - r; - Coord r = l + w; - Coord t = b + w; - gui->fill_rect(fg_gc, l, b, r, t); - } - else - draw_square_pin_poly(fg_gc, pv->X, pv->Y, w, false, GET_SQUARE(pv)); - } - else if (TEST_FLAG(OCTAGONFLAG, pv)) - draw_octagon_poly(fg_gc, pv->X, pv->Y, w, false); - else /* draw a round pin or via */ - gui->fill_circle(fg_gc, pv->X, pv->Y, r); - - /* and the drilling hole (which is always round) */ - if (drawHole) - gui->fill_circle(bg_gc, pv->X, pv->Y, pv->DrillingHole / 2); -} - -void common_thindraw_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pv, bool drawHole, bool mask) -{ - Coord w = mask ? pv->Mask : pv->Thickness; - Coord r = w / 2; - - if (TEST_FLAG(HOLEFLAG, pv)) { - if (mask) - gui->draw_arc(fg_gc, pv->X, pv->Y, r, r, 0, 360); - if (drawHole) { - r = pv->DrillingHole / 2; - gui->set_line_cap(bg_gc, Round_Cap); - gui->set_line_width(bg_gc, 0); - gui->draw_arc(bg_gc, pv->X, pv->Y, r, r, 0, 360); - } - return; - } - - if (TEST_FLAG(SQUAREFLAG, pv)) { - Coord l = pv->X - r; - Coord b = pv->Y - r; - Coord r = l + w; - Coord t = b + w; - - gui->set_line_cap(fg_gc, Round_Cap); - gui->set_line_width(fg_gc, 0); - gui->draw_line(fg_gc, r, t, r, b); - gui->draw_line(fg_gc, l, t, l, b); - gui->draw_line(fg_gc, r, t, l, t); - gui->draw_line(fg_gc, r, b, l, b); - - } - else if (TEST_FLAG(OCTAGONFLAG, pv)) { - draw_octagon_poly(fg_gc, pv->X, pv->Y, w, true); - } - else { /* draw a round pin or via */ - - gui->set_line_cap(fg_gc, Round_Cap); - gui->set_line_width(fg_gc, 0); - gui->draw_arc(fg_gc, pv->X, pv->Y, r, r, 0, 360); - } - - /* and the drilling hole (which is always round */ - if (drawHole) { - gui->set_line_cap(bg_gc, Round_Cap); - gui->set_line_width(bg_gc, 0); - gui->draw_arc(bg_gc, pv->X, pv->Y, pv->DrillingHole / 2, pv->DrillingHole / 2, 0, 360); - } -} - -void common_draw_helpers_init(HID * hid) -{ - hid->fill_pcb_polygon = common_fill_pcb_polygon; - hid->thindraw_pcb_polygon = common_thindraw_pcb_polygon; - hid->fill_pcb_pad = common_fill_pcb_pad; - hid->thindraw_pcb_pad = common_thindraw_pcb_pad; - hid->fill_pcb_pv = common_fill_pcb_pv; - hid->thindraw_pcb_pv = common_thindraw_pcb_pv; -} Index: trunk/src/hid/gtk/gtkhid-gdk.c =================================================================== --- trunk/src/hid/gtk/gtkhid-gdk.c (revision 1363) +++ trunk/src/hid/gtk/gtkhid-gdk.c (revision 1364) @@ -8,7 +8,7 @@ #include "clip.h" #include "../hidint.h" #include "gui.h" -#include "hid/common/draw_helpers.h" +#include "hid_draw_helpers.h" Index: trunk/src/hid/gtk/gtkhid-gl.c =================================================================== --- trunk/src/hid/gtk/gtkhid-gl.c (revision 1363) +++ trunk/src/hid/gtk/gtkhid-gl.c (revision 1364) @@ -25,7 +25,7 @@ #include #include "hid/common/hidgl.h" -#include "hid/common/draw_helpers.h" +#include "hid_draw_helpers.h" RCSID("$Id$"); Index: trunk/src/hid/gtk/gtkhid-main.c =================================================================== --- trunk/src/hid/gtk/gtkhid-main.c (revision 1363) +++ trunk/src/hid/gtk/gtkhid-main.c (revision 1364) @@ -18,7 +18,7 @@ #include "../hidint.h" #include "gui.h" #include "hid/common/hidnogui.h" -#include "hid/common/draw_helpers.h" +#include "hid_draw_helpers.h" #include "pcb-printf.h" Index: trunk/src/hid/gtk/gui-output-events.c =================================================================== --- trunk/src/hid/gtk/gui-output-events.c (revision 1363) +++ trunk/src/hid/gtk/gui-output-events.c (revision 1364) @@ -30,7 +30,7 @@ #include "gui.h" #include "gtkhid.h" -#include "hid/common/hid_resource.h" +#include "hid_resource.h" #include Index: trunk/src/hid/gtk/gui-top-window.c =================================================================== --- trunk/src/hid/gtk/gui-top-window.c (revision 1363) +++ trunk/src/hid/gtk/gui-top-window.c (revision 1364) @@ -69,7 +69,7 @@ #include "gui.h" #include "hid.h" #include "../hidint.h" -#include "hid/common/hid_resource.h" +#include "hid_resource.h" #include "action_helper.h" #include "buffer.h" #include "change.h" Index: trunk/src/hid/gtk/gui.h =================================================================== --- trunk/src/hid/gtk/gui.h (revision 1363) +++ trunk/src/hid/gtk/gui.h (revision 1364) @@ -29,7 +29,7 @@ #include "global.h" #include "hid.h" -#include "hid/common/hid_resource.h" +#include "hid_resource.h" #include "data.h" #include "misc.h" Index: trunk/src/hid/lesstif/main.c =================================================================== --- trunk/src/hid/lesstif/main.c (revision 1363) +++ trunk/src/hid/lesstif/main.c (revision 1364) @@ -30,8 +30,8 @@ #include "hid.h" #include "../hidint.h" #include "hid/common/hidnogui.h" -#include "hid/common/draw_helpers.h" -#include "hid/common/hid_resource.h" +#include "hid_draw_helpers.h" +#include "hid_resource.h" #include "lesstif.h" Index: trunk/src/hid/lesstif/menu.c =================================================================== --- trunk/src/hid/lesstif/menu.c (revision 1363) +++ trunk/src/hid/lesstif/menu.c (revision 1364) @@ -18,7 +18,7 @@ #include "hid.h" #include "../hidint.h" -#include "hid/common/hid_resource.h" +#include "hid_resource.h" #include "resource.h" #include "lesstif.h" #include "mymem.h" Index: trunk/src/hid_draw_helpers.c =================================================================== --- trunk/src/hid_draw_helpers.c (nonexistent) +++ trunk/src/hid_draw_helpers.c (revision 1364) @@ -0,0 +1,436 @@ +#include "global.h" +#include "hid.h" +#include "polygon.h" + +static void fill_contour(hidGC gc, PLINE * pl) +{ + Coord *x, *y, n, i = 0; + VNODE *v; + + n = pl->Count; + x = (Coord *) malloc(n * sizeof(*x)); + y = (Coord *) malloc(n * sizeof(*y)); + + for (v = &pl->head; i < n; v = v->next) { + x[i] = v->point[0]; + y[i++] = v->point[1]; + } + + gui->fill_polygon(gc, n, x, y); + + free(x); + free(y); +} + +static void thindraw_contour(hidGC gc, PLINE * pl) +{ + VNODE *v; + Coord last_x, last_y; + Coord this_x, this_y; + + gui->set_line_width(gc, 0); + gui->set_line_cap(gc, Round_Cap); + + /* If the contour is round, use an arc drawing routine. */ + if (pl->is_round) { + gui->draw_arc(gc, pl->cx, pl->cy, pl->radius, pl->radius, 0, 360); + return; + } + + /* Need at least two points in the contour */ + if (pl->head.next == NULL) + return; + + last_x = pl->head.point[0]; + last_y = pl->head.point[1]; + v = pl->head.next; + + do { + this_x = v->point[0]; + this_y = v->point[1]; + + gui->draw_line(gc, last_x, last_y, this_x, this_y); + /* gui->fill_circle (gc, this_x, this_y, 30); */ + + last_x = this_x; + last_y = this_y; + } + while ((v = v->next) != pl->head.next); +} + +static void fill_contour_cb(PLINE * pl, void *user_data) +{ + hidGC gc = (hidGC) user_data; + PLINE *local_pl = pl; + + fill_contour(gc, pl); + poly_FreeContours(&local_pl); +} + +static void fill_clipped_contour(hidGC gc, PLINE * pl, const BoxType * clip_box) +{ + PLINE *pl_copy; + POLYAREA *clip_poly; + POLYAREA *piece_poly; + POLYAREA *clipped_pieces; + POLYAREA *draw_piece; + int x; + + clip_poly = RectPoly(clip_box->X1, clip_box->X2, clip_box->Y1, clip_box->Y2); + poly_CopyContour(&pl_copy, pl); + piece_poly = poly_Create(); + poly_InclContour(piece_poly, pl_copy); + x = poly_Boolean_free(piece_poly, clip_poly, &clipped_pieces, PBO_ISECT); + if (x != err_ok || clipped_pieces == NULL) + return; + + draw_piece = clipped_pieces; + do { + /* NB: The polygon won't have any holes in it */ + fill_contour(gc, draw_piece->contours); + } + while ((draw_piece = draw_piece->f) != clipped_pieces); + poly_Free(&clipped_pieces); +} + +/* If at least 50% of the bounding box of the polygon is on the screen, + * lets compute the complete no-holes polygon. + */ +#define BOUNDS_INSIDE_CLIP_THRESHOLD 0.5 +static int should_compute_no_holes(PolygonType * poly, const BoxType * clip_box) +{ + Coord x1, x2, y1, y2; + double poly_bounding_area; + double clipped_poly_area; + + /* If there is no passed clip box, compute the whole thing */ + if (clip_box == NULL) + return 1; + + x1 = MAX(poly->BoundingBox.X1, clip_box->X1); + x2 = MIN(poly->BoundingBox.X2, clip_box->X2); + y1 = MAX(poly->BoundingBox.Y1, clip_box->Y1); + y2 = MIN(poly->BoundingBox.Y2, clip_box->Y2); + + /* Check if the polygon is outside the clip box */ + if ((x2 <= x1) || (y2 <= y1)) + return 0; + + poly_bounding_area = (double) (poly->BoundingBox.X2 - poly->BoundingBox.X1) * + (double) (poly->BoundingBox.Y2 - poly->BoundingBox.Y1); + + clipped_poly_area = (double) (x2 - x1) * (double) (y2 - y1); + + if (clipped_poly_area / poly_bounding_area >= BOUNDS_INSIDE_CLIP_THRESHOLD) + return 1; + + return 0; +} + +#undef BOUNDS_INSIDE_CLIP_THRESHOLD + +void common_fill_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box) +{ + if (!poly->NoHolesValid) { + /* If enough of the polygon is on-screen, compute the entire + * NoHoles version and cache it for later rendering, otherwise + * just compute what we need to render now. + */ + if (should_compute_no_holes(poly, clip_box)) + ComputeNoHoles(poly); + else + NoHolesPolygonDicer(poly, clip_box, fill_contour_cb, gc); + } + if (poly->NoHolesValid && poly->NoHoles) { + PLINE *pl; + + for (pl = poly->NoHoles; pl != NULL; pl = pl->next) { + if (clip_box == NULL) + fill_contour(gc, pl); + else + fill_clipped_contour(gc, pl, clip_box); + } + } + + /* Draw other parts of the polygon if fullpoly flag is set */ + /* NB: No "NoHoles" cache for these */ + if (TEST_FLAG(FULLPOLYFLAG, poly)) { + PolygonType p = *poly; + + for (p.Clipped = poly->Clipped->f; p.Clipped != poly->Clipped; p.Clipped = p.Clipped->f) + NoHolesPolygonDicer(&p, clip_box, fill_contour_cb, gc); + } +} + +static int thindraw_hole_cb(PLINE * pl, void *user_data) +{ + hidGC gc = (hidGC) user_data; + thindraw_contour(gc, pl); + return 0; +} + +void common_thindraw_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box) +{ + thindraw_contour(gc, poly->Clipped->contours); + PolygonHoles(poly, clip_box, thindraw_hole_cb, gc); +} + +void common_thindraw_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask) +{ + Coord w = clear ? (mask ? pad->Mask : pad->Thickness + pad->Clearance) + : pad->Thickness; + Coord x1, y1, x2, y2; + Coord t = w / 2; + x1 = pad->Point1.X; + y1 = pad->Point1.Y; + x2 = pad->Point2.X; + y2 = pad->Point2.Y; + if (x1 > x2 || y1 > y2) { + Coord temp_x = x1; + Coord temp_y = y1; + x1 = x2; + x2 = temp_x; + y1 = y2; + y2 = temp_y; + } + gui->set_line_cap(gc, Round_Cap); + gui->set_line_width(gc, 0); + if (TEST_FLAG(SQUAREFLAG, pad)) { + /* slanted square pad */ + double tx, ty, theta; + + if (x1 == x2 && y1 == y2) + theta = 0; + else + theta = atan2(y2 - y1, x2 - x1); + + /* T is a vector half a thickness long, in the direction of + one of the corners. */ + tx = t * cos(theta + M_PI / 4) * sqrt(2.0); + ty = t * sin(theta + M_PI / 4) * sqrt(2.0); + + gui->draw_line(gc, x1 - tx, y1 - ty, x2 + ty, y2 - tx); + gui->draw_line(gc, x2 + ty, y2 - tx, x2 + tx, y2 + ty); + gui->draw_line(gc, x2 + tx, y2 + ty, x1 - ty, y1 + tx); + gui->draw_line(gc, x1 - ty, y1 + tx, x1 - tx, y1 - ty); + } + else if (x1 == x2 && y1 == y2) { + gui->draw_arc(gc, x1, y1, t, t, 0, 360); + } + else { + /* Slanted round-end pads. */ + Coord dx, dy, ox, oy; + double h; + + dx = x2 - x1; + dy = y2 - y1; + h = t / sqrt(SQUARE(dx) + SQUARE(dy)); + ox = dy * h + 0.5 * SGN(dy); + oy = -(dx * h + 0.5 * SGN(dx)); + + gui->draw_line(gc, x1 + ox, y1 + oy, x2 + ox, y2 + oy); + + if (abs(ox) >= pixel_slop || abs(oy) >= pixel_slop) { + Angle angle = atan2(dx, dy) * 57.295779; + gui->draw_line(gc, x1 - ox, y1 - oy, x2 - ox, y2 - oy); + gui->draw_arc(gc, x1, y1, t, t, angle - 180, 180); + gui->draw_arc(gc, x2, y2, t, t, angle, 180); + } + } +} + +void common_fill_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask) +{ + Coord w = clear ? (mask ? pad->Mask : pad->Thickness + pad->Clearance) + : pad->Thickness; + + if (pad->Point1.X == pad->Point2.X && pad->Point1.Y == pad->Point2.Y) { + if (TEST_FLAG(SQUAREFLAG, pad)) { + Coord l, r, t, b; + l = pad->Point1.X - w / 2; + b = pad->Point1.Y - w / 2; + r = l + w; + t = b + w; + gui->fill_rect(gc, l, b, r, t); + } + else { + gui->fill_circle(gc, pad->Point1.X, pad->Point1.Y, w / 2); + } + } + else { + gui->set_line_cap(gc, TEST_FLAG(SQUAREFLAG, pad) ? Square_Cap : Round_Cap); + gui->set_line_width(gc, w); + + gui->draw_line(gc, pad->Point1.X, pad->Point1.Y, pad->Point2.X, pad->Point2.Y); + } +} + +/* --------------------------------------------------------------------------- + * draws one polygon + * x and y are already in display coordinates + * the points are numbered: + * + * 5 --- 6 + * / \ + * 4 7 + * | | + * 3 0 + * \ / + * 2 --- 1 + */ + +typedef struct { + double X, Y; +} FloatPolyType; + +static void draw_square_pin_poly(hidGC gc, Coord X, Coord Y, Coord Thickness, Coord thin_draw, int style) +{ + static FloatPolyType p[8] = { + {0.5, -TAN_22_5_DEGREE_2}, + {TAN_22_5_DEGREE_2, -0.5}, + {-TAN_22_5_DEGREE_2, -0.5}, + {-0.5, -TAN_22_5_DEGREE_2}, + {-0.5, TAN_22_5_DEGREE_2}, + {-TAN_22_5_DEGREE_2, 0.5}, + {TAN_22_5_DEGREE_2, 0.5}, + {0.5, TAN_22_5_DEGREE_2} + }; + static int special_size = 0; + static int scaled_x[8]; + static int scaled_y[8]; + Coord polygon_x[9]; + Coord polygon_y[9]; + double xm[8], ym[8]; + int i; + + square_pin_factors(style, xm, ym); + + if (Thickness != special_size) { + special_size = Thickness; + for (i = 0; i < 8; i++) { + scaled_x[i] = p[i].X * special_size; + scaled_y[i] = p[i].Y * special_size; + } + } + /* add line offset */ + for (i = 0; i < 8; i++) { + polygon_x[i] = X + scaled_x[i] * xm[i]; + polygon_y[i] = Y + scaled_y[i] * ym[i]; + } + + if (thin_draw) { + int i; + gui->set_line_cap(gc, Round_Cap); + gui->set_line_width(gc, 0); + polygon_x[8] = X + scaled_x[0] * xm[0]; + polygon_y[8] = Y + scaled_y[0] * ym[0]; + for (i = 0; i < 8; i++) + gui->draw_line(gc, polygon_x[i], polygon_y[i], polygon_x[i + 1], polygon_y[i + 1]); + } + else + gui->fill_polygon(gc, 8, polygon_x, polygon_y); +} + +static void draw_octagon_poly(hidGC gc, Coord X, Coord Y, Coord Thickness, Coord thin_draw) +{ + draw_square_pin_poly(gc, X, Y, Thickness, thin_draw, 17); +} + + +void common_fill_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pv, bool drawHole, bool mask) +{ + Coord w = mask ? pv->Mask : pv->Thickness; + Coord r = w / 2; + + if (TEST_FLAG(HOLEFLAG, pv)) { + if (mask) + gui->fill_circle(bg_gc, pv->X, pv->Y, r); + if (drawHole) { + gui->fill_circle(bg_gc, pv->X, pv->Y, r); + gui->set_line_cap(fg_gc, Round_Cap); + gui->set_line_width(fg_gc, 0); + gui->draw_arc(fg_gc, pv->X, pv->Y, r, r, 0, 360); + } + return; + } + + if (TEST_FLAG(SQUAREFLAG, pv)) { + /* use the original code for now */ + if ((GET_SQUARE(pv) == 0) || (GET_SQUARE(pv) == 1)) { + Coord l = pv->X - r; + Coord b = pv->Y - r; + Coord r = l + w; + Coord t = b + w; + gui->fill_rect(fg_gc, l, b, r, t); + } + else + draw_square_pin_poly(fg_gc, pv->X, pv->Y, w, false, GET_SQUARE(pv)); + } + else if (TEST_FLAG(OCTAGONFLAG, pv)) + draw_octagon_poly(fg_gc, pv->X, pv->Y, w, false); + else /* draw a round pin or via */ + gui->fill_circle(fg_gc, pv->X, pv->Y, r); + + /* and the drilling hole (which is always round) */ + if (drawHole) + gui->fill_circle(bg_gc, pv->X, pv->Y, pv->DrillingHole / 2); +} + +void common_thindraw_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pv, bool drawHole, bool mask) +{ + Coord w = mask ? pv->Mask : pv->Thickness; + Coord r = w / 2; + + if (TEST_FLAG(HOLEFLAG, pv)) { + if (mask) + gui->draw_arc(fg_gc, pv->X, pv->Y, r, r, 0, 360); + if (drawHole) { + r = pv->DrillingHole / 2; + gui->set_line_cap(bg_gc, Round_Cap); + gui->set_line_width(bg_gc, 0); + gui->draw_arc(bg_gc, pv->X, pv->Y, r, r, 0, 360); + } + return; + } + + if (TEST_FLAG(SQUAREFLAG, pv)) { + Coord l = pv->X - r; + Coord b = pv->Y - r; + Coord r = l + w; + Coord t = b + w; + + gui->set_line_cap(fg_gc, Round_Cap); + gui->set_line_width(fg_gc, 0); + gui->draw_line(fg_gc, r, t, r, b); + gui->draw_line(fg_gc, l, t, l, b); + gui->draw_line(fg_gc, r, t, l, t); + gui->draw_line(fg_gc, r, b, l, b); + + } + else if (TEST_FLAG(OCTAGONFLAG, pv)) { + draw_octagon_poly(fg_gc, pv->X, pv->Y, w, true); + } + else { /* draw a round pin or via */ + + gui->set_line_cap(fg_gc, Round_Cap); + gui->set_line_width(fg_gc, 0); + gui->draw_arc(fg_gc, pv->X, pv->Y, r, r, 0, 360); + } + + /* and the drilling hole (which is always round */ + if (drawHole) { + gui->set_line_cap(bg_gc, Round_Cap); + gui->set_line_width(bg_gc, 0); + gui->draw_arc(bg_gc, pv->X, pv->Y, pv->DrillingHole / 2, pv->DrillingHole / 2, 0, 360); + } +} + +void common_draw_helpers_init(HID * hid) +{ + hid->fill_pcb_polygon = common_fill_pcb_polygon; + hid->thindraw_pcb_polygon = common_thindraw_pcb_polygon; + hid->fill_pcb_pad = common_fill_pcb_pad; + hid->thindraw_pcb_pad = common_thindraw_pcb_pad; + hid->fill_pcb_pv = common_fill_pcb_pv; + hid->thindraw_pcb_pv = common_thindraw_pcb_pv; +} Index: trunk/src/hid_draw_helpers.h =================================================================== --- trunk/src/hid_draw_helpers.h (nonexistent) +++ trunk/src/hid_draw_helpers.h (revision 1364) @@ -0,0 +1,7 @@ +void common_fill_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box); +void common_thindraw_pcb_polygon(hidGC gc, PolygonType * poly, const BoxType * clip_box); +void common_fill_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask); +void common_thindraw_pcb_pad(hidGC gc, PadType * pad, bool clear, bool mask); +void common_fill_pcb_pv(hidGC gc, PinType * pv, bool drawHole, bool mask); +void common_thindraw_pcb_pv(hidGC fg_gc, hidGC bg_gc, PinType * pv, bool drawHole, bool mask); +void common_draw_helpers_init(HID * hid); Index: trunk/src/hid_extents.c =================================================================== --- trunk/src/hid_extents.c (revision 1363) +++ trunk/src/hid_extents.c (revision 1364) @@ -12,7 +12,7 @@ #include "hid.h" #include "../hidint.h" -#include "hid/common/draw_helpers.h" +#include "hid_draw_helpers.h" RCSID("$Id$"); Index: trunk/src/hid_resource.c =================================================================== --- trunk/src/hid_resource.c (nonexistent) +++ trunk/src/hid_resource.c (revision 1364) @@ -0,0 +1,267 @@ +#include +#include +#include + +#include "global.h" +#include "hid.h" +#include "resource.h" +#include "hid_resource.h" + +/* #define DEBUG_HID_RESOURCE */ + +static int button_count; /* number of buttons we have actions for */ +static int *button_nums; /* list of button numbers */ +static int *mod_count; /* how many mods they have */ +static unsigned *mods; /* mods, in order, one button after another */ +static Resource **actions; /* actions, in order, one button after another */ + +static Resource *res_wrap(char *value) +{ + Resource *tmp; + tmp = resource_create(0); + resource_add_val(tmp, 0, value, 0); + return tmp; +} + +static unsigned parse_mods(char *value) +{ + unsigned m = 0; + long int mod_num; + char *s; + + for (s = value; *s; s++) + *s = tolower(*s); + + s = strstr(value, "mod"); + if (s) { + s += 3; /* skip "mod" to get to number */ + errno = 0; + mod_num = strtol(s, (char **) NULL, 0); + if (!errno) + m |= M_Mod(mod_num); + } + if (strstr(value, "shift")) + m |= M_Shift; + if (strstr(value, "ctrl")) + m |= M_Ctrl; + if (strstr(value, "alt")) + m |= M_Alt; + if (strstr(value, "up")) + m |= M_Release; + return m; +} + +static int button_name_to_num(const char *name) +{ + /* All mouse-related resources must be named. The name is the + mouse button number. */ + if (!name) + return -1; + else if (strcasecmp(name, "left") == 0) + return 1; + else if (strcasecmp(name, "middle") == 0) + return 2; + else if (strcasecmp(name, "right") == 0) + return 3; + else if (strcasecmp(name, "up") == 0) + return 4; + else if (strcasecmp(name, "down") == 0) + return 5; + else + return atoi(name); +} + +void load_mouse_resource(const Resource * res) +{ + int bi, mi, a; + int action_count; +#ifdef DEBUG_HID_RESOURCE + fprintf(stderr, "note mouse resource:\n"); + resource_dump(res); +#endif + + button_count = res->c; + button_nums = (int *) malloc(res->c * sizeof(int)); + mod_count = (int *) malloc(res->c * sizeof(int)); + action_count = 0; + for (bi = 0; bi < res->c; bi++) { + if (res->v[bi].value) + action_count++; + + if (res->v[bi].subres) + action_count += res->v[bi].subres->c; + + } + mods = (unsigned int *) malloc(action_count * sizeof(int)); + actions = (Resource **) malloc(action_count * sizeof(Resource *)); + + a = 0; + for (bi = 0; bi < res->c; bi++) { + int button_num = button_name_to_num(res->v[bi].name); + + if (button_num < 0) + continue; + + button_nums[bi] = button_num; + mod_count[bi] = 0; + + if (res->v[bi].value) { + mods[a] = 0; + actions[a++] = res_wrap(res->v[bi].value); + mod_count[bi] = 1; + } + + if (res->v[bi].subres) { + Resource *m = res->v[bi].subres; + mod_count[bi] += m->c; + + for (mi = 0; mi < m->c; mi++, a++) { + switch (resource_type(m->v[mi])) { + case 1: /* subres only */ + mods[a] = 0; + actions[a] = m->v[mi].subres; + break; + + case 10: /* value only */ + mods[a] = 0; + actions[a] = res_wrap(m->v[mi].value); + break; + + case 101: /* name = subres */ + mods[a] = parse_mods(m->v[mi].name); + actions[a] = m->v[mi].subres; + break; + + case 110: /* name = value */ + mods[a] = parse_mods(m->v[mi].name); + actions[a] = res_wrap(m->v[mi].value); + break; + } + } + } + } +} + +static Resource *find_best_action(int button, int start, unsigned mod_mask) +{ + int i, j; + int count = mod_count[button]; + unsigned search_mask = mod_mask & ~M_Release; + unsigned release_mask = mod_mask & M_Release; + + /* look for exact mod match */ + for (i = start; i < start + count; i++) + if (mods[i] == mod_mask) { + return actions[i]; + } + + for (j = search_mask - 1; j >= 0; j--) + if ((j & search_mask) == j) /* this would work */ + for (i = start; i < start + count; i++) /* search for it */ + if (mods[i] == (j | release_mask)) + return actions[i]; + + return NULL; +} + +void do_mouse_action(int button, int mod_mask) +{ + Resource *action = NULL; + int bi, i, a; + + /* find the right set of actions; */ + a = 0; + for (bi = 0; bi < button_count && !action; bi++) + if (button_nums[bi] == button) { + action = find_best_action(bi, a, mod_mask); + break; + } + else + a += mod_count[bi]; /* skip this buttons actions */ + + if (!action) + return; + + for (i = 0; i < action->c; i++) + if (action->v[i].value) + if (hid_parse_actions(action->v[i].value)) + return; +} + +Resource *resource_create_menu(const char *name, const char *action, const char *mnemonic, const char *accel, const char *tip, + int flags) +{ + Resource *resp, *res; + ResourceVal *rvp, *rv; + int next; + + /* child */ + res = calloc(sizeof(Resource), 1); + res->c = 1 + (action != NULL) + (mnemonic != NULL) + (accel != NULL) + (tip != NULL); + rv = malloc(sizeof(ResourceVal) * res->c); + res->v = rv; + res->flags = flags; + + rv[0].name = NULL; + rv[0].value = strdup(name); + rv[0].subres = NULL; + next = 1; + + if (action != NULL) { + rv[next].name = NULL; + rv[next].value = strdup(action); + rv[next].subres = NULL; + next++; + } + + if (mnemonic != NULL) { + rv[next].name = "m"; + rv[next].value = strdup(mnemonic); + rv[next].subres = NULL; + next++; + } + + if (accel != NULL) { + Resource *ares; + ResourceVal *arv; + + ares = calloc(sizeof(Resource), 1); + arv = malloc(sizeof(ResourceVal) * 2); + ares->c = 2; + ares->v = arv; + ares->flags = 0; + + arv[0].name = NULL; + arv[0].value = strdup(accel); + arv[0].subres = NULL; + + arv[1].name = NULL; + arv[1].value = strdup(accel); + arv[1].subres = NULL; + + rv[next].name = "a"; + rv[next].value = NULL; + rv[next].subres = ares; + + next++; + } + + if (tip != NULL) { + rv[next].name = "tip"; + rv[next].value = strdup(tip); + rv[next].subres = NULL; + next++; + } + + /* parent */ + resp = calloc(sizeof(Resource), 1); + rvp = malloc(sizeof(ResourceVal)); + + resp->v = rvp; + resp->c = 1; + rvp->name = NULL; + rvp->value = NULL; + rvp->subres = res; + + return resp; +} Index: trunk/src/hid_resource.h =================================================================== --- trunk/src/hid_resource.h (nonexistent) +++ trunk/src/hid_resource.h (revision 1364) @@ -0,0 +1,21 @@ + +#ifndef PCB_HID_COMMON_HID_RESOURCE_H +#define PCB_HID_COMMON_HID_RESOURCE_H + +#include "resource.h" + +#define M_Shift 1 +#define M_Ctrl 2 +#define M_Mod(n) (1<<(n+1)) +#define M_Alt M_Mod(1) +#define M_Multi M_Mod(2) +#define M_Release (~((unsigned)-1>>1)) /* set the top bit */ + +void load_mouse_resource(const Resource * res); +void do_mouse_action(int button, int mods); + +/* Create a set of resources representing a single menu item */ +Resource *resource_create_menu(const char *name, const char *action, const char *mnemonic, const char *accel, const char *tip, + int flags); + +#endif Index: trunk/src_plugins/export_gcode/gcode.c =================================================================== --- trunk/src_plugins/export_gcode/gcode.c (revision 1363) +++ trunk/src_plugins/export_gcode/gcode.c (revision 1364) @@ -54,7 +54,7 @@ #include "../hidint.h" #include #include "hid/common/hidnogui.h" -#include "hid/common/draw_helpers.h" +#include "hid_draw_helpers.h" #include "gcode.h" #include "bitmap.h" #include "curve.h" Index: trunk/src_plugins/export_gerber/gerber.c =================================================================== --- trunk/src_plugins/export_gerber/gerber.c (revision 1363) +++ trunk/src_plugins/export_gerber/gerber.c (revision 1364) @@ -31,7 +31,7 @@ #include "hid.h" #include "../hidint.h" #include "hid/common/hidnogui.h" -#include "hid/common/draw_helpers.h" +#include "hid_draw_helpers.h" #include "hid/common/hidinit.h" Index: trunk/src_plugins/export_nelma/nelma.c =================================================================== --- trunk/src_plugins/export_nelma/nelma.c (revision 1363) +++ trunk/src_plugins/export_nelma/nelma.c (revision 1364) @@ -72,7 +72,7 @@ #include "hid.h" #include "../hidint.h" #include "hid/common/hidnogui.h" -#include "hid/common/draw_helpers.h" +#include "hid_draw_helpers.h" #include Index: trunk/src_plugins/export_png/png.c =================================================================== --- trunk/src_plugins/export_png/png.c (revision 1363) +++ trunk/src_plugins/export_png/png.c (revision 1364) @@ -42,7 +42,7 @@ #include "hid.h" #include "../hidint.h" #include "hid/common/hidnogui.h" -#include "hid/common/draw_helpers.h" +#include "hid_draw_helpers.h" #include "png.h" /* the gd library which makes this all so easy */ Index: trunk/src_plugins/export_ps/eps.c =================================================================== --- trunk/src_plugins/export_ps/eps.c (revision 1363) +++ trunk/src_plugins/export_ps/eps.c (revision 1364) @@ -16,7 +16,7 @@ #include "hid.h" #include "hid/hidint.h" #include "hid/common/hidnogui.h" -#include "hid/common/draw_helpers.h" +#include "hid_draw_helpers.h" #include "ps.h" #include "hid/common/hidinit.h" Index: trunk/src_plugins/export_ps/ps.c =================================================================== --- trunk/src_plugins/export_ps/ps.c (revision 1363) +++ trunk/src_plugins/export_ps/ps.c (revision 1364) @@ -21,7 +21,7 @@ #include "hid.h" #include "hid/hidint.h" #include "hid/common/hidnogui.h" -#include "hid/common/draw_helpers.h" +#include "hid_draw_helpers.h" #include "ps.h" #include "print.h" #include "hid/common/hidinit.h"