Index: trunk/src/conf_core.h =================================================================== --- trunk/src/conf_core.h (revision 713) +++ trunk/src/conf_core.h (revision 714) @@ -11,6 +11,7 @@ RND_CFT_COLOR attached; } color; RND_CFT_STRING default_font; /* OBSOLETE: used to be path to a ttf font; camv-rnd uses an embedded internal vector font now */ + RND_CFT_BOOLEAN bbox_debug; /* enable rendering bounding box of objects, for debugging */ } appearance; const struct rc { /* rc */ RND_CFT_BOOLEAN error_on_bad_cli_files; Index: trunk/src/conf_core_fields.h =================================================================== --- trunk/src/conf_core_fields.h (revision 713) +++ trunk/src/conf_core_fields.h (revision 714) @@ -1,4 +1,5 @@ conf_reg(appearance.default_font, scalar, RND_CFN_STRING, "appearance", "default_font", "OBSOLETE: used to be path to a ttf font; camv-rnd uses an embedded internal vector font now", 0) +conf_reg(appearance.bbox_debug, scalar, RND_CFN_BOOLEAN, "appearance", "bbox_debug", "enable rendering bounding box of objects, for debugging", 0) conf_reg(appearance.color.layer, array, RND_CFN_COLOR, "appearance/color", "layer", "default layer colors; when a new layer is created, a color from this list is assigned initially", 0) conf_reg(appearance.color.attached, scalar, RND_CFN_COLOR, "appearance/color", "attached", "", 0) conf_reg(rc.error_on_bad_cli_files, scalar, RND_CFN_BOOLEAN, "rc", "error_on_bad_cli_files", "", 0) Index: trunk/src/draw.c =================================================================== --- trunk/src/draw.c (revision 713) +++ trunk/src/draw.c (revision 714) @@ -2,7 +2,7 @@ * COPYRIGHT * * camv-rnd - electronics-related CAM viewer - * Copyright (C) 2019 Tibor 'Igor2' Palinkas + * Copyright (C) 2019,2023 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 @@ -25,7 +25,9 @@ */ #include +#include #include "obj_any.h" +#include "conf_core.h" /* based on https://math.stackexchange.com/questions/13150/extracting-rotation-scale-values-from-2d-transformation-matrix/13165#13165 */ static double mx_extract_rot(rnd_xform_mx_t mx) @@ -94,6 +96,25 @@ for(o = camv_rtree_first(&it, &ly->objs, view); o != NULL; o = camv_rtree_next(&it)) { camv_any_obj_t *obj = o; obj->proto.calls->draw(obj, gc, mx); + if (conf_core.appearance.bbox_debug) { + rnd_coord_t x1, y1, x2, y2; + + if (mx != NULL) { + x1 = rnd_xform_x((*mx), obj->proto.bbox.x1, obj->proto.bbox.y1); y1 = rnd_xform_y((*mx), obj->proto.bbox.x1, obj->proto.bbox.y1); + x2 = rnd_xform_x((*mx), obj->proto.bbox.x2, obj->proto.bbox.y2); y2 = rnd_xform_y((*mx), obj->proto.bbox.x2, obj->proto.bbox.y2); + } + else { + x1 = obj->proto.bbox.x1; y1 = obj->proto.bbox.y1; + x2 = obj->proto.bbox.x2; y2 = obj->proto.bbox.y2; + } + + rnd_hid_set_line_cap(gc, rnd_cap_round); + rnd_hid_set_line_width(gc, -1); + rnd_render->draw_line(gc, x1, y1, x2, y1); + rnd_render->draw_line(gc, x2, y1, x2, y2); + rnd_render->draw_line(gc, x2, y2, x1, y2); + rnd_render->draw_line(gc, x1, y2, x1, y1); + } } }