Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 17199) +++ trunk/scconfig/Rev.h (revision 17200) @@ -1 +1 @@ -static const int myrev = 16898; +static const int myrev = 17200; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 17199) +++ trunk/scconfig/Rev.tab (revision 17200) @@ -1,3 +1,4 @@ +17200 configure moved clip.h out from core 16898 configure new stroke plugin 16616 configure fixes for large boards and 64 bit coords 16591 configure export_xy: tempalte config Index: trunk/src/clip.c =================================================================== --- trunk/src/clip.c (revision 17199) +++ trunk/src/clip.c (nonexistent) @@ -1,114 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * (this file is based on PCB, interactive printed circuit board design) - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 2004 harry eaton - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: email to pcb-rnd (at) igor2.repo.hu - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - */ - -#include "config.h" -#include "clip.h" - -#warning TODO: move this to lib_hid_common - -/* Clip the line to the clipBox - * return pcb_true if something to be drawn - * pcb_false if the whole thing is clipped - */ -pcb_bool pcb_line_clip(double minx, double miny, double maxx, double maxy, double *x1, double *y1, double *x2, double *y2, double margin) -{ - double d, r; - - minx -= margin; - miny -= margin; - maxx += margin; - maxy += margin; - - /* clip first point on left side */ - if (*x1 < minx) { - if (*x2 < minx) - return pcb_false; - d = *x2 - *x1; - r = (minx - *x1) / d; - *x1 = minx; - *y1 += r * (*y2 - *y1); - } - /* clip second point on left side */ - if (*x2 < minx) { - d = *x1 - *x2; - r = (minx - *x2) / d; - *x2 = minx; - *y2 += r * (*y1 - *y2); - } - /* clip first point on right side */ - if (*x1 > maxx) { - if (*x2 > maxx) - return pcb_false; - d = *x2 - *x1; - r = (maxx - *x1) / d; - *x1 = maxx; - *y1 += r * (*y2 - *y1); - } - /* clip second point on right side */ - if (*x2 > maxx) { - d = *x1 - *x2; - r = (maxx - *x2) / d; - *x2 = maxx; - *y2 += r * (*y1 - *y2); - } - - /* clip first point on top */ - if (*y1 < miny) { - if (*y2 < miny) - return pcb_false; - d = *y2 - *y1; - r = (miny - *y1) / d; - *y1 = miny; - *x1 += r * (*x2 - *x1); - } - /* clip second point on top */ - if (*y2 < miny) { - d = *y1 - *y2; - r = (miny - *y2) / d; - *y2 = miny; - *x2 += r * (*x1 - *x2); - } - /* clip first point on bottom */ - if (*y1 > maxy) { - if (*y2 > maxy) - return pcb_false; - d = *y2 - *y1; - r = (maxy - *y1) / d; - *y1 = maxy; - *x1 += r * (*x2 - *x1); - } - /* clip second point on top */ - if (*y2 > maxy) { - d = *y1 - *y2; - r = (maxy - *y2) / d; - *y2 = maxy; - *x2 += r * (*x1 - *x2); - } - return pcb_true; -} Index: trunk/src/clip.h =================================================================== --- trunk/src/clip.h (revision 17199) +++ trunk/src/clip.h (nonexistent) @@ -1,40 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * (this file is based on PCB, interactive printed circuit board design) - * Copyright (C) 1994,1995,1996 Thomas Nau - * Copyright (C) 2004 harry eaton - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: email to pcb-rnd (at) igor2.repo.hu - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - * - */ - -#ifndef PCB_CLIP_H -#define PCB_CLIP_H - -#include "global_typedefs.h" - -/* Clip X,Y to the given bounding box, plus a margin. Returns pcb_true if - there is something left to be drawn. */ -pcb_bool pcb_line_clip(double minx, double miny, double maxx, double maxy, - double *x1, double *y1, double *x2, double *y2, double margin); - -#endif Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 17199) +++ trunk/src/Makefile.dep (revision 17200) @@ -1151,7 +1151,7 @@ data_parent.h obj_arc.h ../src_3rd/genlist/gendlist.h obj_line_list.h \ obj_line.h obj_poly_list.h obj_poly.h polyarea.h obj_text_list.h \ obj_text.h font.h ../src_3rd/genht/htip.h box.h math_helper.h move.h \ - misc_util.h layer_grp.h route.h clip.h data.h crosshair.h buffer.h \ + misc_util.h layer_grp.h route.h data.h crosshair.h buffer.h \ obj_rat_list.h obj_rat.h obj_subc_list.h obj_subc.h \ ../src_3rd/libminuid/libminuid.h rtree.h \ ../src_3rd/genrtree/genrtree_api.h rtree2_compat.h ht_subc.h \ @@ -1180,7 +1180,8 @@ ../src_plugins/lib_gtk_hid/coord_conv.h compat_misc.h \ ../src_plugins/lib_gtk_hid/preview_helper.h \ ../src_plugins/lib_gtk_config/hid_gtk_conf.h \ - ../src_plugins/lib_gtk_config/lib_gtk_config.h + ../src_plugins/lib_gtk_config/lib_gtk_config.h \ + ../src_plugins/lib_hid_common/clip.h global_typedefs.h ../src_plugins/hid_gtk2_gdk/gtkhid-main.o: \ ../src_plugins/hid_gtk2_gdk/gtkhid-main.c ../config.h action_helper.h \ global_typedefs.h pcb_bool.h unit.h error.h pcb-printf.h \ @@ -1240,15 +1241,16 @@ ../src_3rd/genlist/gentdlist_undef.h obj_line_list.h obj_line.h \ obj_poly_list.h obj_poly.h polyarea.h obj_text_list.h obj_text.h font.h \ ../src_3rd/genht/htip.h box.h math_helper.h move.h misc_util.h \ - ../src_3rd/genvector/gds_char.h layer_grp.h route.h clip.h data.h \ - crosshair.h buffer.h obj_rat_list.h obj_rat.h obj_subc_list.h obj_subc.h \ + ../src_3rd/genvector/gds_char.h layer_grp.h route.h data.h crosshair.h \ + buffer.h obj_rat_list.h obj_rat.h obj_subc_list.h obj_subc.h \ ../src_3rd/libminuid/libminuid.h rtree.h \ ../src_3rd/genrtree/genrtree_api.h rtree2_compat.h ht_subc.h \ ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ ../src_3rd/genvector/vtp0.h vtpadstack.h obj_pstk_shape.h polygon.h \ vtpadstack_t.h layer.h hid_draw_helpers.h hid_attrib.h hid_helper.h \ - hid_color.h ../src_plugins/lib_gtk_config/hid_gtk_conf.h conf.h \ - pcb-printf.h ../src_3rd/liblihata/lihata.h list_conf.h conf.h \ + hid_color.h ../src_plugins/lib_hid_common/clip.h global_typedefs.h \ + ../src_plugins/lib_gtk_config/hid_gtk_conf.h conf.h pcb-printf.h \ + ../src_3rd/liblihata/lihata.h list_conf.h conf.h \ ../src_plugins/lib_gtk_config/lib_gtk_config.h hid.h event.h conf_hid.h \ ../src_plugins/lib_gtk_common/glue.h \ ../src_plugins/lib_gtk_common/compat.h ../src_plugins/lib_gtk_hid/gui.h \ @@ -1336,7 +1338,7 @@ data_parent.h obj_arc.h ../src_3rd/genlist/gendlist.h obj_line_list.h \ obj_line.h obj_poly_list.h obj_poly.h polyarea.h obj_text_list.h \ obj_text.h font.h ../src_3rd/genht/htip.h box.h math_helper.h move.h \ - misc_util.h layer_grp.h route.h clip.h data.h crosshair.h buffer.h \ + misc_util.h layer_grp.h route.h data.h crosshair.h buffer.h \ obj_rat_list.h obj_rat.h obj_subc_list.h obj_subc.h \ ../src_3rd/libminuid/libminuid.h rtree.h \ ../src_3rd/genrtree/genrtree_api.h rtree2_compat.h ht_subc.h \ @@ -1365,7 +1367,8 @@ ../src_plugins/lib_gtk_hid/coord_conv.h compat_misc.h \ ../src_plugins/lib_gtk_hid/preview_helper.h \ ../src_plugins/lib_gtk_config/hid_gtk_conf.h \ - ../src_plugins/lib_gtk_config/lib_gtk_config.h + ../src_plugins/lib_gtk_config/lib_gtk_config.h \ + ../src_plugins/lib_hid_common/clip.h global_typedefs.h ../src_plugins/hid_gtk3_cairo/gtkhid-main.o: \ ../src_plugins/hid_gtk3_cairo/gtkhid-main.c ../config.h action_helper.h \ global_typedefs.h pcb_bool.h unit.h error.h pcb-printf.h \ @@ -1530,8 +1533,8 @@ ../src_3rd/genrtree/genrtree_api.h rtree2_compat.h ht_subc.h \ ../src_3rd/genht/ht.h ../src_3rd/genht/hash.h obj_pstk_list.h obj_pstk.h \ vtpadstack.h obj_pstk_shape.h polygon.h vtpadstack_t.h action_helper.h \ - crosshair.h conf_hid.h layer.h pcb-printf.h clip.h event.h error.h \ - plugins.h ../src_3rd/puplug/puplug.h ../src_3rd/puplug/libs.h \ + crosshair.h conf_hid.h layer.h pcb-printf.h event.h error.h plugins.h \ + ../src_3rd/puplug/puplug.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/os_dep.h ../src_3rd/puplug/config.h \ ../src_3rd/puplug/libs.h ../src_3rd/puplug/error.h macro.h safe_fs.h \ hid.h hid_nogui.h hid_draw_helpers.h hid_cfg.h \ @@ -1540,7 +1543,8 @@ library.h rats_patch.h board.h hid_attrib.h hid_helper.h hid_init.h \ hid_color.h hid_extents.h hid_flags.h hid_actions.h \ ../src_plugins/hid_lesstif/stdarg.h grid.h misc_util.h compat_misc.h \ - layer_vis.h tool.h ../src_plugins/hid_lesstif/dlg_preview.c stub_draw.h \ + layer_vis.h tool.h ../src_plugins/lib_hid_common/clip.h \ + global_typedefs.h ../src_plugins/hid_lesstif/dlg_preview.c stub_draw.h \ dolists.h ../src_plugins/hid_lesstif/menu.o: ../src_plugins/hid_lesstif/menu.c \ ../src_plugins/hid_lesstif/xincludes.h ../config.h conf_core.h conf.h \ @@ -5340,7 +5344,6 @@ rats.h netlist.h route_style.h undo.h ../src_3rd/libuundo/uundo.h \ undo_old.h event.h compat_misc.h compat_nls.h obj_rat_draw.h data_it.h \ macro.h grid.h -clip.o: clip.c ../config.h clip.h global_typedefs.h pcb_bool.h unit.h compat_fs.o: compat_fs.c ../config.h compat_inc.h compat_fs.h \ compat_misc.h compat_nls.h globalconst.h safe_fs.h conf.h \ global_typedefs.h pcb_bool.h unit.h pcb-printf.h \ Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 17199) +++ trunk/src/Makefile.in (revision 17200) @@ -38,7 +38,6 @@ conf_core.o conf_hid.o conf_internal.o - clip.o compat_fs.o compat_lrealpath.o compat_misc.o Index: trunk/src_plugins/hid_gtk2_gdk/gtkhid-gdk.c =================================================================== --- trunk/src_plugins/hid_gtk2_gdk/gtkhid-gdk.c (revision 17199) +++ trunk/src_plugins/hid_gtk2_gdk/gtkhid-gdk.c (revision 17200) @@ -4,7 +4,6 @@ #include #include "crosshair.h" -#include "clip.h" #include "data.h" #include "layer.h" #include "grid.h" @@ -20,6 +19,8 @@ #include "../src_plugins/lib_gtk_config/hid_gtk_conf.h" #include "../src_plugins/lib_gtk_config/lib_gtk_config.h" +#include "../src_plugins/lib_hid_common/clip.h" + extern pcb_hid_t gtk2_gdk_hid; static void ghid_gdk_screen_update(void); Index: trunk/src_plugins/hid_gtk2_gl/gtkhid-gl.c =================================================================== --- trunk/src_plugins/hid_gtk2_gl/gtkhid-gl.c (revision 17199) +++ trunk/src_plugins/hid_gtk2_gl/gtkhid-gl.c (revision 17200) @@ -3,7 +3,6 @@ #include #include "crosshair.h" -#include "clip.h" #include "data.h" #include "layer.h" #include "hid_draw_helpers.h" @@ -11,6 +10,7 @@ #include "hid_helper.h" #include "hid_color.h" +#include "../src_plugins/lib_hid_common/clip.h" #include "../src_plugins/lib_gtk_config/hid_gtk_conf.h" #include "../src_plugins/lib_gtk_config/lib_gtk_config.h" Index: trunk/src_plugins/hid_gtk3_cairo/gtkhid-cairo.c =================================================================== --- trunk/src_plugins/hid_gtk3_cairo/gtkhid-cairo.c (revision 17199) +++ trunk/src_plugins/hid_gtk3_cairo/gtkhid-cairo.c (revision 17200) @@ -32,7 +32,6 @@ #include #include "crosshair.h" -#include "clip.h" #include "data.h" #include "layer.h" #include "grid.h" @@ -48,6 +47,8 @@ #include "../src_plugins/lib_gtk_config/hid_gtk_conf.h" #include "../src_plugins/lib_gtk_config/lib_gtk_config.h" +#include "../src_plugins/lib_hid_common/clip.h" + extern pcb_hid_t gtk3_cairo_hid; static void ghid_cairo_screen_update(void); Index: trunk/src_plugins/hid_lesstif/main.c =================================================================== --- trunk/src_plugins/hid_lesstif/main.c (revision 17199) +++ trunk/src_plugins/hid_lesstif/main.c (revision 17200) @@ -23,7 +23,6 @@ #include "conf_hid.h" #include "layer.h" #include "pcb-printf.h" -#include "clip.h" #include "event.h" #include "error.h" #include "plugins.h" @@ -51,6 +50,8 @@ #include "layer_vis.h" #include "tool.h" +#include "../src_plugins/lib_hid_common/clip.h" + #include const char *lesstif_cookie = "lesstif HID"; Index: trunk/src_plugins/lib_hid_common/clip.h =================================================================== --- trunk/src_plugins/lib_hid_common/clip.h (nonexistent) +++ trunk/src_plugins/lib_hid_common/clip.h (revision 17200) @@ -0,0 +1,115 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * (this file is based on PCB, interactive printed circuit board design) + * Copyright (C) 1994,1995,1996 Thomas Nau + * Copyright (C) 2004 harry eaton + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: email to pcb-rnd (at) igor2.repo.hu + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + * + */ + +#ifndef PCB_CLIP_H +#define PCB_CLIP_H + + +#include "global_typedefs.h" + +/* Clip X,Y to the given bounding box, plus a margin. Returns pcb_true if + there is something left to be drawn. */ +PCB_INLINE pcb_bool pcb_line_clip(double minx, double miny, double maxx, double maxy, double *x1, double *y1, double *x2, double *y2, double margin) +{ + double d, r; + + minx -= margin; + miny -= margin; + maxx += margin; + maxy += margin; + + /* clip first point on left side */ + if (*x1 < minx) { + if (*x2 < minx) + return pcb_false; + d = *x2 - *x1; + r = (minx - *x1) / d; + *x1 = minx; + *y1 += r * (*y2 - *y1); + } + /* clip second point on left side */ + if (*x2 < minx) { + d = *x1 - *x2; + r = (minx - *x2) / d; + *x2 = minx; + *y2 += r * (*y1 - *y2); + } + /* clip first point on right side */ + if (*x1 > maxx) { + if (*x2 > maxx) + return pcb_false; + d = *x2 - *x1; + r = (maxx - *x1) / d; + *x1 = maxx; + *y1 += r * (*y2 - *y1); + } + /* clip second point on right side */ + if (*x2 > maxx) { + d = *x1 - *x2; + r = (maxx - *x2) / d; + *x2 = maxx; + *y2 += r * (*y1 - *y2); + } + + /* clip first point on top */ + if (*y1 < miny) { + if (*y2 < miny) + return pcb_false; + d = *y2 - *y1; + r = (miny - *y1) / d; + *y1 = miny; + *x1 += r * (*x2 - *x1); + } + /* clip second point on top */ + if (*y2 < miny) { + d = *y1 - *y2; + r = (miny - *y2) / d; + *y2 = miny; + *x2 += r * (*x1 - *x2); + } + /* clip first point on bottom */ + if (*y1 > maxy) { + if (*y2 > maxy) + return pcb_false; + d = *y2 - *y1; + r = (maxy - *y1) / d; + *y1 = maxy; + *x1 += r * (*x2 - *x1); + } + /* clip second point on top */ + if (*y2 > maxy) { + d = *y1 - *y2; + r = (maxy - *y2) / d; + *y2 = maxy; + *x2 += r * (*x1 - *x2); + } + return pcb_true; +} + +#endif