diff --git a/CHANGELOG.md b/CHANGELOG.md index b2aee7fe..781b0abc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ FlatCAM Evo BETA (c) 2019 - by Marius Stanciu + Based on FlatCAM: 2D Computer-Aided PCB Manufacturing by (c) 2014-2016 Juan Pablo Caram ================================================= @@ -7,6 +8,10 @@ CHANGELOG for FlatCAM Evo beta ================================================= +5.03.2025 + +- upgrade to use the new notations in the Shapely's buffer method for the cap_style and join_style parameters (used to be integers, now they are strings or defines) + 02.02.2025 - modified the makefile file (contribution from @Paul Munsch on bitbucket) diff --git a/appCommon/Common.py b/appCommon/Common.py index 08c7b72a..3f80289e 100644 --- a/appCommon/Common.py +++ b/appCommon/Common.py @@ -731,7 +731,7 @@ class ExclusionAreas(QtCore.QObject): for area in self.exclusion_areas_storage: new_area = deepcopy(area) - new_area['shape'] = area['shape'].buffer(buffered_distance, join_style=2) + new_area['shape'] = area['shape'].buffer(buffered_distance, join_style="mitre") buffered_storage.append(new_area) # sort the Exclusion areas from the closest to the start_point to the farthest diff --git a/appEditors/appGeoEditor.py b/appEditors/appGeoEditor.py index 0bde596e..cbe2b746 100644 --- a/appEditors/appGeoEditor.py +++ b/appEditors/appGeoEditor.py @@ -5497,8 +5497,8 @@ class FCBuffer(FCShapeTool): _("Buffer distance value is missing or wrong format. Add it and retry.")) return # the cb index start from 0 but the join styles for the buffer start from 1 therefore the adjustment - # I populated the combobox such that the index coincide with the join styles value (whcih is really an INT) - join_style = self.buff_tool.ui.buffer_corner_cb.currentIndex() + 1 + # I populated the combobox such that the index coincide with the join styles value + join_style = {1: 'round', 2: 'mitre', 3: 'bevel'}.get(self.buff_tool.ui.buffer_corner_cb.currentIndex() + 1) ret_val = self.buff_tool.buffer(buffer_distance, join_style) self.deactivate() @@ -5523,8 +5523,8 @@ class FCBuffer(FCShapeTool): _("Buffer distance value is missing or wrong format. Add it and retry.")) return # the cb index start from 0 but the join styles for the buffer start from 1 therefore the adjustment - # I populated the combobox such that the index coincide with the join styles value (whcih is really an INT) - join_style = self.buff_tool.ui.buffer_corner_cb.currentIndex() + 1 + # I populated the combobox such that the index coincide with the join styles value + join_style = {1: 'round', 2: 'mitre', 3: 'bevel'}.get(self.buff_tool.ui.buffer_corner_cb.currentIndex() + 1) ret_val = self.buff_tool.buffer_int(buffer_distance, join_style) self.deactivate() @@ -5549,8 +5549,8 @@ class FCBuffer(FCShapeTool): _("Buffer distance value is missing or wrong format. Add it and retry.")) return # the cb index start from 0 but the join styles for the buffer start from 1 therefore the adjustment - # I populated the combobox such that the index coincide with the join styles value (whcih is really an INT) - join_style = self.buff_tool.ui.buffer_corner_cb.currentIndex() + 1 + # I populated the combobox such that the index coincide with the join styles value + join_style = {1: 'round', 2: 'mitre', 3: 'bevel'}.get(self.buff_tool.ui.buffer_corner_cb.currentIndex() + 1) ret_val = self.buff_tool.buffer_ext(buffer_distance, join_style) # self.app.ui.notebook.setTabText(2, _("Tools")) # self.draw_app.app.ui.splitter.setSizes([0, 1]) diff --git a/appEditors/appGerberEditor.py b/appEditors/appGerberEditor.py index c795155e..a3a792ec 100644 --- a/appEditors/appGerberEditor.py +++ b/appEditors/appGerberEditor.py @@ -1299,7 +1299,7 @@ class RegionEditorGrb(ShapeToolEditorGrb): if len(self.temp_points) > 1: try: geo_sol = LineString(self.temp_points) - geo_sol = geo_sol.buffer(self.buf_val, int(self.steps_per_circle), join_style=1) + geo_sol = geo_sol.buffer(self.buf_val, int(self.steps_per_circle), join_style="round") new_geo_el = { 'solid': geo_sol } @@ -1395,7 +1395,7 @@ class RegionEditorGrb(ShapeToolEditorGrb): # create the geometry geo_line = LinearRing(self.temp_points) - geo_sol = geo_line.buffer(self.buf_val, int(self.steps_per_circle), join_style=1) + geo_sol = geo_line.buffer(self.buf_val, int(self.steps_per_circle), join_style="round") new_geo_el = { 'solid': geo_sol, 'follow': geo_line @@ -1410,7 +1410,7 @@ class RegionEditorGrb(ShapeToolEditorGrb): if len(self.points) > 2: new_geo_el = { - 'solid': Polygon(self.points).buffer(self.buf_val, int(self.steps_per_circle), join_style=2), + 'solid': Polygon(self.points).buffer(self.buf_val, int(self.steps_per_circle), join_style="mitre"), 'follow': Polygon(self.points).exterior } @@ -4624,11 +4624,11 @@ class AppGerberEditor(QtCore.QObject): if isinstance(g_data['follow'], Point): new_geo_el['solid'] = deepcopy(g_data['solid'].buffer(adjust_size)) else: - new_geo_el['solid'] = deepcopy(g_data['solid'].buffer(adjust_size, join_style=2)) + new_geo_el['solid'] = deepcopy(g_data['solid'].buffer(adjust_size, join_style="mitre")) if 'follow' in g_data: new_geo_el['follow'] = deepcopy(g_data['follow']) if 'clear' in g_data: - new_geo_el['clear'] = deepcopy(g_data['clear'].buffer(adjust_size, join_style=2)) + new_geo_el['clear'] = deepcopy(g_data['clear'].buffer(adjust_size, join_style="mitre")) geometry.append(DrawToolShape(new_geo_el)) self.storage_dict[ap_code_old]['geometry'].clear() @@ -4678,7 +4678,7 @@ class AppGerberEditor(QtCore.QObject): geo = box(xmin=minx, ymin=miny, xmax=maxx, ymax=maxy) new_geo_el['clear'] = deepcopy(geo) else: - new_geo_el['clear'] = deepcopy(g_data['clear'].buffer(buff_val_lines, join_style=2)) + new_geo_el['clear'] = deepcopy(g_data['clear'].buffer(buff_val_lines, join_style="mitre")) geometry.append(DrawToolShape(new_geo_el)) self.storage_dict[ap_code_old]['geometry'].clear() @@ -7632,13 +7632,13 @@ class TransformEditorTool(AppTool): def on_buffer_by_distance(self): value = self.buffer_entry.get_value() - join = 1 if self.buffer_rounded_cb.get_value() else 2 + join = "round" if self.buffer_rounded_cb.get_value() else "mitre" self.app.worker_task.emit({'fcn': self.on_buffer_action, 'params': [value, join]}) def on_buffer_by_factor(self): value = 1 + (self.buffer_factor_entry.get_value() / 100.0) - join = 1 if self.buffer_rounded_cb.get_value() else 2 + join = "round" if self.buffer_rounded_cb.get_value() else "mitre" # tell the buffer method to use the factor factor = True diff --git a/appEditors/geo_plugins/GeoBufferPlugin.py b/appEditors/geo_plugins/GeoBufferPlugin.py index 6640787c..3f998b15 100644 --- a/appEditors/geo_plugins/GeoBufferPlugin.py +++ b/appEditors/geo_plugins/GeoBufferPlugin.py @@ -93,7 +93,7 @@ class BufferSelectionTool(AppToolEditor): return # the cb index start from 0 but the join styles for the buffer start from 1 therefore the adjustment # I populated the combobox such that the index coincide with the join styles value (which is really an INT) - join_style = self.ui.buffer_corner_cb.currentIndex() + 1 + join_style = {1: 'round', 2: 'mitre', 3: 'bevel'}.get(self.ui.buffer_corner_cb.currentIndex() + 1) self.buffer(buffer_distance, join_style) def on_buffer_int(self): @@ -110,7 +110,7 @@ class BufferSelectionTool(AppToolEditor): return # the cb index start from 0 but the join styles for the buffer start from 1 therefore the adjustment # I populated the combobox such that the index coincide with the join styles value (which is really an INT) - join_style = self.ui.buffer_corner_cb.currentIndex() + 1 + join_style = {1: 'round', 2: 'mitre', 3: 'bevel'}.get(self.ui.buffer_corner_cb.currentIndex() + 1) self.buffer_int(buffer_distance, join_style) def on_buffer_ext(self): @@ -127,7 +127,7 @@ class BufferSelectionTool(AppToolEditor): return # the cb index start from 0 but the join styles for the buffer start from 1 therefore the adjustment # I populated the combobox such that the index coincide with the join styles value (which is really an INT) - join_style = self.ui.buffer_corner_cb.currentIndex() + 1 + join_style = {1: 'round', 2: 'mitre', 3: 'bevel'}.get(self.ui.buffer_corner_cb.currentIndex() + 1) self.buffer_ext(buffer_distance, join_style) def buffer(self, buf_distance, join_style): @@ -158,13 +158,15 @@ class BufferSelectionTool(AppToolEditor): return 'fail' results = [] + usable_resolution = int(int(geo_editor.app.options["geometry_circle_steps"]) / 4) for t in selected: if not t.geo.is_empty and t.geo.is_valid: if t.geo.geom_type == 'Polygon': - results.append(t.geo.exterior.buffer( - buf_distance - 1e-10, - resolution=int(int(geo_editor.app.options["geometry_circle_steps"]) / 4), - join_style=join_style) + results.append( + t.geo.exterior.buffer( + buf_distance - 1e-10, + resolution=usable_resolution, + join_style=join_style) ) elif t.geo.geom_type == 'MultiLineString': for line in t.geo: @@ -172,25 +174,22 @@ class BufferSelectionTool(AppToolEditor): b_geo = Polygon(line) results.append(b_geo.buffer( buf_distance - 1e-10, - resolution=int(int(geo_editor.app.options["geometry_circle_steps"]) / 4), - join_style=join_style).exterior - ) + resolution=usable_resolution, + join_style=join_style).exterior) results.append(b_geo.buffer( -buf_distance + 1e-10, - resolution=int(int(geo_editor.app.options["geometry_circle_steps"]) / 4), - join_style=join_style).exterior - ) + resolution=usable_resolution, + join_style=join_style).exterior) elif t.geo.geom_type in ['LineString', 'LinearRing']: if t.geo.is_ring: b_geo = Polygon(t.geo) results.append(b_geo.buffer( buf_distance - 1e-10, - resolution=int(int(geo_editor.app.options["geometry_circle_steps"]) / 4), - join_style=join_style).exterior - ) + resolution=usable_resolution, + join_style=join_style).exterior) results.append(b_geo.buffer( -buf_distance + 1e-10, - resolution=int(int(geo_editor.app.options["geometry_circle_steps"]) / 4), + resolution=usable_resolution, join_style=join_style).exterior ) diff --git a/appEditors/grb_plugins/GrbBufferPlugin.py b/appEditors/grb_plugins/GrbBufferPlugin.py index 862d26d5..61c4d95c 100644 --- a/appEditors/grb_plugins/GrbBufferPlugin.py +++ b/appEditors/grb_plugins/GrbBufferPlugin.py @@ -93,7 +93,7 @@ class BufferEditorTool(AppToolEditor): return # the cb index start from 0 but the join styles for the buffer start from 1 therefore the adjustment # I populated the combobox such that the index coincide with the join styles value (which is really an INT) - join_style = self.ui.buffer_corner_cb.currentIndex() + 1 + join_style = {1: 'round', 2: 'mitre', 3: 'bevel'}[self.ui.buffer_corner_cb.currentIndex() + 1] self.buffer(buffer_distance, join_style) # def on_buffer_int(self): diff --git a/appObjects/GeometryObject.py b/appObjects/GeometryObject.py index a72a7ef0..d24521c5 100644 --- a/appObjects/GeometryObject.py +++ b/appObjects/GeometryObject.py @@ -44,7 +44,7 @@ class GeometryObject(FlatCAMObj, Geometry): format. """ optionChanged = QtCore.pyqtSignal(str) - builduiSig = QtCore.pyqtSignal() + build_ui_sig = QtCore.pyqtSignal() launch_job = QtCore.pyqtSignal() ui_type = GeometryObjectUI diff --git a/appObjects/GerberObject.py b/appObjects/GerberObject.py index 703b56bf..948f9b3e 100644 --- a/appObjects/GerberObject.py +++ b/appObjects/GerberObject.py @@ -1743,7 +1743,7 @@ class GerberObject(FlatCAMObj, Gerber): Gerber.skew(self, angle_x=angle_x, angle_y=angle_y, point=point) self.replotApertures.emit() - def buffer(self, distance, join=2, factor=None, only_exterior=False): + def buffer(self, distance, join="mitre", factor=None, only_exterior=False, muted=False): Gerber.buffer(self, distance=distance, join=join, factor=factor, only_exterior=only_exterior) self.replotApertures.emit() diff --git a/appParsers/ParseExcellon.py b/appParsers/ParseExcellon.py index c79b9a5d..910cf3ba 100644 --- a/appParsers/ParseExcellon.py +++ b/appParsers/ParseExcellon.py @@ -1580,7 +1580,7 @@ class Excellon(Geometry): self.create_geometry() self.app.proc_container.new_text = '' - def buffer(self, distance, join, factor, only_exterior=False): + def buffer(self, distance, join, factor, only_exterior=False, muted=False): """ :param distance: if 'factor' is True then distance is the factor diff --git a/appParsers/ParseGerber.py b/appParsers/ParseGerber.py index 0377e287..7d070628 100644 --- a/appParsers/ParseGerber.py +++ b/appParsers/ParseGerber.py @@ -2569,11 +2569,11 @@ class Gerber(Geometry): self.app.inform.emit('[success] %s' % _("Done.")) self.app.proc_container.new_text = '' - def buffer(self, distance, join=2, factor=None, only_exterior=False): + def buffer(self, distance, join="mitre", factor=None, only_exterior=False, muted=False): """ :param distance: If 'factor' is True then distance is the factor - :param join: The type of joining used by the Shapely buffer method. Can be: round, square and bevel + :param join: The type of joining used by the Shapely buffer method. Can be: round, mitre and bevel :param factor: True or False (None) :param only_exterior: Bool. If True, the LineStrings are buffered only on the outside :return: None @@ -2718,8 +2718,8 @@ class Gerber(Geometry): self.solid_geometry = MultiPolygon(new_solid_geo) self.solid_geometry = self.solid_geometry.buffer(0.000001) self.solid_geometry = self.solid_geometry.buffer(-0.000001) - - self.app.inform.emit('[success] %s' % _("Gerber Buffer done.")) + if muted is False: + self.app.inform.emit('[success] %s' % _("Gerber Buffer done.")) self.app.proc_container.new_text = '' diff --git a/appPlugins/ToolDrilling.py b/appPlugins/ToolDrilling.py index 84a124a5..bdd0993b 100644 --- a/appPlugins/ToolDrilling.py +++ b/appPlugins/ToolDrilling.py @@ -36,7 +36,7 @@ log = logging.getLogger('base') class ToolDrilling(AppTool, Excellon): - builduiSig = QtCore.pyqtSignal() + build_ui_sig = QtCore.pyqtSignal() def __init__(self, app): self.app = app @@ -198,7 +198,7 @@ class ToolDrilling(AppTool, Excellon): # ############################################################################# # ############################ SIGNALS ######################################## # ############################################################################# - self.builduiSig.connect(self.build_tool_ui) + self.build_ui_sig.connect(self.build_tool_ui) self.ui.level.toggled.connect(self.on_level_changed) @@ -228,7 +228,7 @@ class ToolDrilling(AppTool, Excellon): # ############################ SIGNALS ######################################## # ############################################################################# try: - self.builduiSig.disconnect() + self.build_ui_sig.disconnect() except (TypeError, AttributeError): pass @@ -1833,7 +1833,7 @@ class ToolDrilling(AppTool, Excellon): self.app.inform.emit('[success] %s' % _("Value edited in Exclusion Table.")) self.ui_connect() - self.builduiSig.emit() + self.build_ui_sig.emit() def on_exclusion_table_strategy(self): cw = self.sender() @@ -1848,7 +1848,7 @@ class ToolDrilling(AppTool, Excellon): self.app.inform.emit('[success] %s' % _("Value edited in Exclusion Table.")) self.ui_connect() - self.builduiSig.emit() + self.build_ui_sig.emit() @staticmethod def process_slot_as_drills(slot, overlap, add_last_pt=False): diff --git a/appPlugins/ToolFiducials.py b/appPlugins/ToolFiducials.py index f7ce5f7b..41be11db 100644 --- a/appPlugins/ToolFiducials.py +++ b/appPlugins/ToolFiducials.py @@ -323,7 +323,7 @@ class ToolFiducials(AppTool): if self.mode_method == 'auto': xmin, ymin, xmax, ymax = self.grb_object.bounds() bbox = box(xmin, ymin, xmax, ymax) - buf_bbox = bbox.buffer(self.margin_val, self.grb_steps_per_circle, join_style=2) + buf_bbox = bbox.buffer(self.margin_val, self.grb_steps_per_circle, join_style="mitre") x0, y0, x1, y1 = buf_bbox.bounds self.click_points.append( diff --git a/appPlugins/ToolFilm.py b/appPlugins/ToolFilm.py index 3ec668fc..070b69d4 100644 --- a/appPlugins/ToolFilm.py +++ b/appPlugins/ToolFilm.py @@ -776,7 +776,7 @@ class Film(AppTool): svg_footer = ' ' # decide if to round the bounding box for the negative - join_s = 1 if r_box else 2 + join_s = "round" if r_box else "mitre" if isinstance(box_geo, (LineString, LinearRing)): b_geo = Polygon(box_geo).buffer(margin, join_style=join_s) diff --git a/appPlugins/ToolInvertGerber.py b/appPlugins/ToolInvertGerber.py index 355617b7..99d230db 100644 --- a/appPlugins/ToolInvertGerber.py +++ b/appPlugins/ToolInvertGerber.py @@ -127,9 +127,9 @@ class ToolInvertGerber(AppTool): if round(margin, self.decimals) == 0.0: margin = 1E-10 - join_style = {'r': 1, 'b': 3, 's': 2}[self.ui.join_radio.get_value()] + join_style = {'r': "round", 'b': "bevel", 's': "mitre"}[self.ui.join_radio.get_value()] if join_style is None: - join_style = 'r' + join_style = 'round' grb_circle_steps = int(self.app.options["gerber_circle_steps"]) obj_name = self.ui.gerber_combo.currentText() diff --git a/appPlugins/ToolMarkers.py b/appPlugins/ToolMarkers.py index bf480c7a..6dec5492 100644 --- a/appPlugins/ToolMarkers.py +++ b/appPlugins/ToolMarkers.py @@ -655,7 +655,7 @@ class ToolMarkers(AppTool): geo_buff_list = [] if aperture_found: for geo in marker_geometry: - geo_buff = geo.buffer(line_thickness / 2.0, resolution=self.grb_steps_per_circle, join_style=2) + geo_buff = geo.buffer(line_thickness / 2.0, resolution=self.grb_steps_per_circle, join_style="mitre") geo_buff_list.append(geo_buff) dict_el = {'follow': geo, 'solid': geo_buff} @@ -674,7 +674,7 @@ class ToolMarkers(AppTool): } for geo in marker_geometry: - geo_buff = geo.buffer(line_thickness / 2.0, resolution=self.grb_steps_per_circle, join_style=3) + geo_buff = geo.buffer(line_thickness / 2.0, resolution=self.grb_steps_per_circle, join_style="bevel") geo_buff_list.append(geo_buff) dict_el = {'follow': geo, 'solid': geo_buff} diff --git a/appPlugins/ToolMilling.py b/appPlugins/ToolMilling.py index a6888a64..57be0b26 100644 --- a/appPlugins/ToolMilling.py +++ b/appPlugins/ToolMilling.py @@ -78,7 +78,7 @@ class HybridGeoExc: class ToolMilling(AppTool, Excellon): - builduiSig = QtCore.pyqtSignal() + build_ui_sig = QtCore.pyqtSignal() launch_job = QtCore.pyqtSignal() def __init__(self, app): @@ -239,7 +239,7 @@ class ToolMilling(AppTool, Excellon): # ############################################################################# # ############################ SIGNALS ######################################## # ############################################################################# - self.builduiSig.connect(self.build_ui) + self.build_ui_sig.connect(self.build_ui) self.ui.level.toggled.connect(self.on_level_changed) @@ -287,7 +287,7 @@ class ToolMilling(AppTool, Excellon): # ############################ SIGNALS ######################################## # ############################################################################# try: - self.builduiSig.disconnect() + self.build_ui_sig.disconnect() except (TypeError, AttributeError): pass @@ -2370,7 +2370,7 @@ class ToolMilling(AppTool, Excellon): self.app.inform.emit('[success] %s' % _("Tool was edited in Tool Table.")) self.ui_connect() - self.builduiSig.emit() + self.build_ui_sig.emit() self.target_obj.build_ui() def on_tool_copy(self, all_tools=None): @@ -2399,7 +2399,7 @@ class ToolMilling(AppTool, Excellon): except AttributeError: self.app.inform.emit('[WARNING_NOTCL] %s' % _("Failed. Select a tool to copy.")) self.ui_connect() - self.builduiSig.emit() + self.build_ui_sig.emit() return except Exception as e: self.app.log.error("on_tool_copy() --> " + str(e)) @@ -2408,7 +2408,7 @@ class ToolMilling(AppTool, Excellon): else: self.app.inform.emit('[WARNING_NOTCL] %s' % _("Failed. Select a tool to copy.")) self.ui_connect() - self.builduiSig.emit() + self.build_ui_sig.emit() return else: # we copy all tools in tools_table_mill_geo @@ -2429,7 +2429,7 @@ class ToolMilling(AppTool, Excellon): self.target_obj.ser_attrs.append('tools') self.ui_connect() - self.builduiSig.emit() + self.build_ui_sig.emit() self.app.inform.emit('[success] %s' % _("Tool was copied in Tool Table.")) def on_tool_delete(self, all_tools=None): @@ -2460,7 +2460,7 @@ class ToolMilling(AppTool, Excellon): except AttributeError: self.app.inform.emit('[WARNING_NOTCL] %s' % _("Failed. Select a tool to delete.")) self.ui_connect() - self.builduiSig.emit() + self.build_ui_sig.emit() return except Exception as e: self.app.log.error("on_tool_delete() --> " + str(e)) @@ -2469,7 +2469,7 @@ class ToolMilling(AppTool, Excellon): else: self.app.inform.emit('[WARNING_NOTCL] %s' % _("Failed. Select a tool to delete.")) self.ui_connect() - self.builduiSig.emit() + self.build_ui_sig.emit() return else: # we delete all tools in tools_table_mill_geo @@ -3928,7 +3928,7 @@ class ToolMilling(AppTool, Excellon): self.app.inform.emit('[success] %s' % _("Value edited in Exclusion Table.")) self.ui_connect() - self.builduiSig.emit() + self.build_ui_sig.emit() def on_exclusion_table_strategy(self): cw = self.sender() @@ -3943,7 +3943,7 @@ class ToolMilling(AppTool, Excellon): self.app.inform.emit('[success] %s' % _("Value edited in Exclusion Table.")) self.ui_connect() - self.builduiSig.emit() + self.build_ui_sig.emit() def reset_fields(self): self.ui.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) diff --git a/appPlugins/ToolQRCode.py b/appPlugins/ToolQRCode.py index 08c0c5ce..79898dc7 100644 --- a/appPlugins/ToolQRCode.py +++ b/appPlugins/ToolQRCode.py @@ -312,7 +312,7 @@ class QRCode(AppTool): if self.ui.bb_radio.get_value() == 'r': mask_geo = box(a, b, c, d).buffer(buff_val) else: - mask_geo = box(a, b, c, d).buffer(buff_val, join_style=2) + mask_geo = box(a, b, c, d).buffer(buff_val, join_style="mitre") # update the solid geometry with the cutout (if it is the case) new_solid_geometry = [] diff --git a/camlib.py b/camlib.py index be0bf645..6655b08f 100644 --- a/camlib.py +++ b/camlib.py @@ -271,7 +271,7 @@ class ApertureMacro: # pol, width, xs, ys, xe, ye, angle = ApertureMacro.default2zero(7, mods) line = LineString([(xs, ys), (xe, ye)]) - box = line.buffer(width / 2, cap_style=2) + box = line.buffer(width / 2, cap_style="flat") box_rotated = affinity.rotate(box, angle, origin=(0, 0)) return {"pol": int(pol), "geometry": box_rotated} @@ -439,8 +439,8 @@ class ApertureMacro: i += 1 # ## Crosshair - hor = LineString([(x - cross_len, y), (x + cross_len, y)]).buffer(cross_th / 2.0, cap_style=2) - ver = LineString([(x, y - cross_len), (x, y + cross_len)]).buffer(cross_th / 2.0, cap_style=2) + hor = LineString([(x - cross_len, y), (x + cross_len, y)]).buffer(cross_th / 2.0, cap_style="flat") + ver = LineString([(x, y - cross_len), (x, y + cross_len)]).buffer(cross_th / 2.0, cap_style="flat") result = unary_union([result, hor, ver]) return {"pol": 1, "geometry": result} @@ -466,8 +466,8 @@ class ApertureMacro: # angle = val[5] ring = Point((x, y)).buffer(dout / 2.0).difference(Point((x, y)).buffer(din / 2.0)) - hline = LineString([(x - dout / 2.0, y), (x + dout / 2.0, y)]).buffer(t / 2.0, cap_style=3) - vline = LineString([(x, y - dout / 2.0), (x, y + dout / 2.0)]).buffer(t / 2.0, cap_style=3) + hline = LineString([(x - dout / 2.0, y), (x + dout / 2.0, y)]).buffer(t / 2.0, cap_style="square") + vline = LineString([(x, y - dout / 2.0), (x, y + dout / 2.0)]).buffer(t / 2.0, cap_style="square") thermal = ring.difference(hline.union(vline)) return {"pol": 1, "geometry": thermal} @@ -1134,7 +1134,7 @@ class Geometry(object): old_disp_number = 0 pol_nr = 0 - # yet, it can be done by issuing an unary_union in the end, thus getting rid of the overlapping geo + # yet, it can be done by issuing a unary_union in the end, thus getting rid of the overlapping geo for pol in working_geo_shp: if self.app.abort_flag: # graceful abort requested by the user @@ -1142,7 +1142,7 @@ class Geometry(object): if offset == 0: temp_geo = pol else: - corner_type = 1 if corner is None else corner + corner_type = "round" if corner is None else corner temp_geo = pol.buffer(offset, int(self.geo_steps_per_circle), join_style=corner_type) geo_iso.append(temp_geo) @@ -2648,7 +2648,7 @@ class Geometry(object): """ :param distance: if 'factor' is True then distance is the scale factor for each geometric element - :param join: The kind of join used by the shapely buffer method: round, square or bevel + :param join: The kind of join used by the shapely buffer method: round, mitre or bevel :param factor: True or False (None) :param only_exterior: Bool. If True, the LineStrings are buffered only on the outside :param muted: Bool. If True no messages are created. @@ -3784,14 +3784,14 @@ class CNCjob(Geometry): if isinstance(it, LineString): if it.is_ring: it = Polygon(it) - temp_solid_geometry.append(it.buffer(tool_offset, join_style=2)) + temp_solid_geometry.append(it.buffer(tool_offset, join_style="mitre")) for it in flat_ints_geo: # if the geometry is a closed shape then create a Polygon out of it if isinstance(it, (LineString, LinearRing)): if it.is_ring: it = Polygon(it) - temp_solid_geometry.append(it.buffer(-tool_offset, join_style=2)) + temp_solid_geometry.append(it.buffer(-tool_offset, join_style="mitre")) temp_solid_geometry = self.flatten(temp_solid_geometry, reset=True, pathonly=True) else: @@ -4955,7 +4955,7 @@ class CNCjob(Geometry): c = it.coords if c[0] == c[-1]: it = Polygon(it) - temp_solid_geometry.append(it.buffer(offset, join_style=2)) + temp_solid_geometry.append(it.buffer(offset, join_style="mitre")) else: temp_solid_geometry = geometry @@ -5357,14 +5357,14 @@ class CNCjob(Geometry): if isinstance(it, LineString): if it.is_ring: it = Polygon(it) - temp_solid_geometry.append(it.buffer(offset_for_use, join_style=2)) + temp_solid_geometry.append(it.buffer(offset_for_use, join_style="mitre")) for it in flat_ints_geo: # if the geometry is a closed shape then create a Polygon out of it if isinstance(it, (LineString, LinearRing)): if it.is_ring: it = Polygon(it) - temp_solid_geometry.append(it.buffer(-offset_for_use, join_style=2)) + temp_solid_geometry.append(it.buffer(-offset_for_use, join_style="mitre")) temp_solid_geometry = self.flatten(temp_solid_geometry, reset=True, pathonly=True) else: diff --git a/tclCommands/TclCommandBuffer.py b/tclCommands/TclCommandBuffer.py index fcd1a388..afca4cd5 100644 --- a/tclCommands/TclCommandBuffer.py +++ b/tclCommands/TclCommandBuffer.py @@ -102,21 +102,21 @@ class TclCommandBuffer(TclCommand): join = 1 else: if args['join'] in ['square', 'Square', '2', 2]: - join = 2 + join = "square" elif args['join'] in ['bevel', 'Bevel', '3', 3]: - join = 3 + join = "bevel" else: - join = 1 + join = "round" 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 + x_min, y_min, x_max, y_max = obj_to_buff.bounds() + obj_to_buff.obj_options['xmin'] = x_min + obj_to_buff.obj_options['ymin'] = y_min + obj_to_buff.obj_options['xmax'] = x_max + obj_to_buff.obj_options['ymax'] = y_max except Exception as e: self.app.log.error("TclCommandBuffer -> The object has no bounds properties. %s" % str(e)) return "fail"