diff --git a/CHANGELOG.md b/CHANGELOG.md index ead22038..a600bea2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ CHANGELOG for FlatCAM Evo beta ================================================= +15.06.2023 + +- a bit of optimization in camblib.clear_polygon() method +- added the update of bounds for the TclCommands: Mirror, Scale, Offset, Skew, Buffer + 12.06.2023 - Geometry Editor: fixed the selected shapes width issue; now the selected shapes are thicker diff --git a/camlib.py b/camlib.py index 676b5e55..3d54da0c 100644 --- a/camlib.py +++ b/camlib.py @@ -1488,37 +1488,56 @@ class Geometry(object): QtWidgets.QApplication.processEvents() cl_pol = cl_pol.buffer(-tooldia * (1 - overlap), int(steps_per_circle)) - if isinstance(cl_pol, MultiPolygon): - cl_pol = flatten_shapely_geometry(cl_pol) + cl_pol_list = flatten_shapely_geometry(cl_pol) - added_flag = False - for tiny_pol in cl_pol: - if tiny_pol.area > 0: - added_flag = True - geoms.insert(tiny_pol.exterior) - if prog_plot: - self.plot_temp_shapes(tiny_pol.exterior) - - for i in tiny_pol.interiors: - geoms.insert(i) - if prog_plot: - self.plot_temp_shapes(i) - if added_flag is False: - break - - cl_pol = MultiPolygon(cl_pol) - else: - if cl_pol.area > 0: - geoms.insert(cl_pol.exterior) + added_flag = False + for tiny_pol in cl_pol_list: + if tiny_pol.area > 0: + added_flag = True + geoms.insert(tiny_pol.exterior) if prog_plot: - self.plot_temp_shapes(cl_pol.exterior) + self.plot_temp_shapes(tiny_pol.exterior) - for i in cl_pol.interiors: + for i in tiny_pol.interiors: geoms.insert(i) if prog_plot: self.plot_temp_shapes(i) - else: - break + if added_flag is False: + break + + cl_pol = MultiPolygon(cl_pol_list) + + # if isinstance(cl_pol, MultiPolygon): + # cl_pol = flatten_shapely_geometry(cl_pol) + # + # added_flag = False + # for tiny_pol in cl_pol: + # if tiny_pol.area > 0: + # added_flag = True + # geoms.insert(tiny_pol.exterior) + # if prog_plot: + # self.plot_temp_shapes(tiny_pol.exterior) + # + # for i in tiny_pol.interiors: + # geoms.insert(i) + # if prog_plot: + # self.plot_temp_shapes(i) + # if added_flag is False: + # break + # + # cl_pol = MultiPolygon(cl_pol) + # else: + # if cl_pol.area > 0: + # geoms.insert(cl_pol.exterior) + # if prog_plot: + # self.plot_temp_shapes(cl_pol.exterior) + # + # for i in cl_pol.interiors: + # geoms.insert(i) + # if prog_plot: + # self.plot_temp_shapes(i) + # else: + # break if not geoms.objects: self.app.log.debug("camlib.Geometry.clear_polygon() --> Current Area is zero") diff --git a/tclCommands/TclCommandBuffer.py b/tclCommands/TclCommandBuffer.py index 353fa9b4..fcd1a388 100644 --- a/tclCommands/TclCommandBuffer.py +++ b/tclCommands/TclCommandBuffer.py @@ -110,3 +110,13 @@ class TclCommandBuffer(TclCommand): factor = bool(eval(str(args['factor']).capitalize())) if 'factor' in args else None obj_to_buff.buffer(distance, join, factor, only_exterior=True) + + try: + xmin, ymin, xmax, ymax = obj_to_buff.bounds() + obj_to_buff.obj_options['xmin'] = xmin + obj_to_buff.obj_options['ymin'] = ymin + obj_to_buff.obj_options['xmax'] = xmax + obj_to_buff.obj_options['ymax'] = ymax + except Exception as e: + self.app.log.error("TclCommandBuffer -> The object has no bounds properties. %s" % str(e)) + return "fail" diff --git a/tclCommands/TclCommandMirror.py b/tclCommands/TclCommandMirror.py index 4ef909bb..96d6008d 100644 --- a/tclCommands/TclCommandMirror.py +++ b/tclCommands/TclCommandMirror.py @@ -162,3 +162,13 @@ class TclCommandMirror(TclCommandSignaled): except Exception as e: self.app.log.error("Operation failed: %s" % str(e)) return "fail" + + try: + xmin, ymin, xmax, ymax = obj.bounds() + obj.obj_options['xmin'] = xmin + obj.obj_options['ymin'] = ymin + obj.obj_options['xmax'] = xmax + obj.obj_options['ymax'] = ymax + except Exception as e: + self.app.log.error("TclCommandMirror -> The object has no bounds properties. %s" % str(e)) + return "fail" diff --git a/tclCommands/TclCommandOffset.py b/tclCommands/TclCommandOffset.py index 8a97480c..67984845 100644 --- a/tclCommands/TclCommandOffset.py +++ b/tclCommands/TclCommandOffset.py @@ -72,3 +72,13 @@ class TclCommandOffset(TclCommand): return "fail" obj.offset((x, y)) + + try: + xmin, ymin, xmax, ymax = obj.bounds() + obj.obj_options['xmin'] = xmin + obj.obj_options['ymin'] = ymin + obj.obj_options['xmax'] = xmax + obj.obj_options['ymax'] = ymax + except Exception as e: + self.app.log.error("TclCommandOffset -> The object has no bounds properties. %s" % str(e)) + return "fail" diff --git a/tclCommands/TclCommandScale.py b/tclCommands/TclCommandScale.py index 053a0a1d..52b6ba00 100644 --- a/tclCommands/TclCommandScale.py +++ b/tclCommands/TclCommandScale.py @@ -155,3 +155,13 @@ class TclCommandScale(TclCommand): f_x = float(args['x']) f_y = float(args['y']) obj_to_scale.scale(f_x, f_y, point=point) + + try: + xmin, ymin, xmax, ymax = obj_to_scale.bounds() + obj_to_scale.obj_options['xmin'] = xmin + obj_to_scale.obj_options['ymin'] = ymin + obj_to_scale.obj_options['xmax'] = xmax + obj_to_scale.obj_options['ymax'] = ymax + except Exception as e: + self.app.log.error("TclCommandScale -> The object has no bounds properties. %s" % str(e)) + return "fail" diff --git a/tclCommands/TclCommandSkew.py b/tclCommands/TclCommandSkew.py index 1eae6844..936dbbae 100644 --- a/tclCommands/TclCommandSkew.py +++ b/tclCommands/TclCommandSkew.py @@ -202,3 +202,13 @@ class TclCommandSkew(TclCommand): angle_y = math.degrees(math.atan(dist_y/width)) obj_to_skew.skew(angle_x, angle_y, point=ref_point) + + try: + xmin, ymin, xmax, ymax = obj_to_skew.bounds() + obj_to_skew.obj_options['xmin'] = xmin + obj_to_skew.obj_options['ymin'] = ymin + obj_to_skew.obj_options['xmax'] = xmax + obj_to_skew.obj_options['ymax'] = ymax + except Exception as e: + self.app.log.error("TclCommandSkew -> The object has no bounds properties. %s" % str(e)) + return "fail"