- replaced the testing if instance of FlatCAMObj with testing the obj.kind attribute

- removed the import of the whole FlatCAMApp file only for the usage of GracefulException
- remove the import of FlatCAMApp and used alternate ways
- optimized the imports in some files
- moved the Bookmarksmanager and ToolDB classes into their own files
- solved some bugs that were not so visible in the Editors and HPGL parser
This commit is contained in:
Marius Stanciu
2020-04-27 10:03:22 +03:00
committed by Marius
parent 61020e3624
commit 3ec666edbb
28 changed files with 3452 additions and 3389 deletions

View File

@@ -7,10 +7,9 @@
from PyQt5 import QtWidgets, QtCore
import FlatCAMApp
from FlatCAMCommon import GracefulException as grace
from FlatCAMTool import FlatCAMTool
from flatcamGUI.GUIElements import FCDoubleSpinner, RadioSet, FCEntry, FCComboBox
from FlatCAMObj import FlatCAMGerber, FlatCAMGeometry, FlatCAMExcellon
import shapely.geometry.base as base
from shapely.ops import cascaded_union, unary_union
@@ -994,7 +993,7 @@ class ToolCopperThieving(FlatCAMTool):
for pol in app_obj.grb_object.solid_geometry:
if app_obj.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
clearance_geometry.append(
pol.buffer(c_val, int(int(app_obj.geo_steps_per_circle) / 4))
@@ -1073,7 +1072,7 @@ class ToolCopperThieving(FlatCAMTool):
for poly in working_obj:
if app_obj.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_buff_list.append(poly.buffer(distance=margin, join_style=base.JOIN_STYLE.mitre))
except TypeError:
geo_buff_list.append(working_obj.buffer(distance=margin, join_style=base.JOIN_STYLE.mitre))
@@ -1082,7 +1081,7 @@ class ToolCopperThieving(FlatCAMTool):
else: # ref_selected == 'box'
geo_n = working_obj.solid_geometry
if isinstance(working_obj, FlatCAMGeometry):
if working_obj.kind == 'geometry':
try:
__ = iter(geo_n)
except Exception as e:
@@ -1093,11 +1092,11 @@ class ToolCopperThieving(FlatCAMTool):
for poly in geo_n:
if app_obj.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_buff_list.append(poly.buffer(distance=margin, join_style=base.JOIN_STYLE.mitre))
bounding_box = cascaded_union(geo_buff_list)
elif isinstance(working_obj, FlatCAMGerber):
elif working_obj.kind == 'gerber':
geo_n = cascaded_union(geo_n).convex_hull
bounding_box = cascaded_union(thieving_obj.solid_geometry).convex_hull.intersection(geo_n)
bounding_box = bounding_box.buffer(distance=margin, join_style=base.JOIN_STYLE.mitre)
@@ -1192,7 +1191,7 @@ class ToolCopperThieving(FlatCAMTool):
for pol in app_obj.grb_object.solid_geometry:
if app_obj.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
outline_geometry.append(
pol.buffer(c_val+half_thick_line, int(int(app_obj.geo_steps_per_circle) / 4))

View File

@@ -8,7 +8,6 @@
from PyQt5 import QtWidgets, QtGui, QtCore
from FlatCAMTool import FlatCAMTool
from flatcamGUI.GUIElements import FCDoubleSpinner, FCCheckBox, RadioSet, FCComboBox, OptionalInputSection, FCButton
from FlatCAMObj import FlatCAMGerber
from shapely.geometry import box, MultiPolygon, Polygon, LineString, LinearRing
from shapely.ops import cascaded_union, unary_union
@@ -270,7 +269,7 @@ class CutOut(FlatCAMTool):
form_layout_2.addRow(gaps_label, self.gaps)
# Buttons
self.ff_cutout_object_btn = QtWidgets.QPushButton(_("Generate Freeform Geometry"))
self.ff_cutout_object_btn = FCButton(_("Generate Freeform Geometry"))
self.ff_cutout_object_btn.setToolTip(
_("Cutout the selected object.\n"
"The cutout shape can be of any shape.\n"
@@ -284,7 +283,7 @@ class CutOut(FlatCAMTool):
""")
grid0.addWidget(self.ff_cutout_object_btn, 20, 0, 1, 2)
self.rect_cutout_object_btn = QtWidgets.QPushButton(_("Generate Rectangular Geometry"))
self.rect_cutout_object_btn = FCButton(_("Generate Rectangular Geometry"))
self.rect_cutout_object_btn.setToolTip(
_("Cutout the selected object.\n"
"The resulting cutout shape is\n"
@@ -335,7 +334,7 @@ class CutOut(FlatCAMTool):
# form_layout_3.addRow(e_lab_0)
self.man_geo_creation_btn = QtWidgets.QPushButton(_("Generate Manual Geometry"))
self.man_geo_creation_btn = FCButton(_("Generate Manual Geometry"))
self.man_geo_creation_btn.setToolTip(
_("If the object to be cutout is a Gerber\n"
"first create a Geometry that surrounds it,\n"
@@ -350,7 +349,7 @@ class CutOut(FlatCAMTool):
""")
grid0.addWidget(self.man_geo_creation_btn, 24, 0, 1, 2)
self.man_gaps_creation_btn = QtWidgets.QPushButton(_("Manual Add Bridge Gaps"))
self.man_gaps_creation_btn = FCButton(_("Manual Add Bridge Gaps"))
self.man_gaps_creation_btn.setToolTip(
_("Use the left mouse button (LMB) click\n"
"to create a bridge gap to separate the PCB from\n"
@@ -369,7 +368,7 @@ class CutOut(FlatCAMTool):
self.layout.addStretch()
# ## Reset Tool
self.reset_button = QtWidgets.QPushButton(_("Reset Tool"))
self.reset_button = FCButton(_("Reset Tool"))
self.reset_button.setToolTip(
_("Will reset the tool parameters.")
)
@@ -525,7 +524,7 @@ class CutOut(FlatCAMTool):
def geo_init(geo_obj, app_obj):
solid_geo = []
if isinstance(cutout_obj, FlatCAMGerber):
if cutout_obj.kind == 'gerber':
if isinstance(cutout_obj.solid_geometry, list):
cutout_obj.solid_geometry = MultiPolygon(cutout_obj.solid_geometry)
@@ -542,12 +541,12 @@ class CutOut(FlatCAMTool):
def cutout_handler(geom):
# Get min and max data for each object as we just cut rectangles across X or Y
xmin, ymin, xmax, ymax = recursive_bounds(geom)
xxmin, yymin, xxmax, yymax = recursive_bounds(geom)
px = 0.5 * (xmin + xmax) + margin
py = 0.5 * (ymin + ymax) + margin
lenx = (xmax - xmin) + (margin * 2)
leny = (ymax - ymin) + (margin * 2)
px = 0.5 * (xxmin + xxmax) + margin
py = 0.5 * (yymin + yymax) + margin
lenx = (xxmax - xxmin) + (margin * 2)
leny = (yymax - yymin) + (margin * 2)
proc_geometry = []
if gaps == 'None':
@@ -555,41 +554,41 @@ class CutOut(FlatCAMTool):
else:
if gaps == '8' or gaps == '2LR':
geom = self.subtract_poly_from_geo(geom,
xmin - gapsize, # botleft_x
xxmin - gapsize, # botleft_x
py - gapsize + leny / 4, # botleft_y
xmax + gapsize, # topright_x
xxmax + gapsize, # topright_x
py + gapsize + leny / 4) # topright_y
geom = self.subtract_poly_from_geo(geom,
xmin - gapsize,
xxmin - gapsize,
py - gapsize - leny / 4,
xmax + gapsize,
xxmax + gapsize,
py + gapsize - leny / 4)
if gaps == '8' or gaps == '2TB':
geom = self.subtract_poly_from_geo(geom,
px - gapsize + lenx / 4,
ymin - gapsize,
yymin - gapsize,
px + gapsize + lenx / 4,
ymax + gapsize)
yymax + gapsize)
geom = self.subtract_poly_from_geo(geom,
px - gapsize - lenx / 4,
ymin - gapsize,
yymin - gapsize,
px + gapsize - lenx / 4,
ymax + gapsize)
yymax + gapsize)
if gaps == '4' or gaps == 'LR':
geom = self.subtract_poly_from_geo(geom,
xmin - gapsize,
xxmin - gapsize,
py - gapsize,
xmax + gapsize,
xxmax + gapsize,
py + gapsize)
if gaps == '4' or gaps == 'TB':
geom = self.subtract_poly_from_geo(geom,
px - gapsize,
ymin - gapsize,
yymin - gapsize,
px + gapsize,
ymax + gapsize)
yymax + gapsize)
try:
for g in geom:
@@ -603,7 +602,7 @@ class CutOut(FlatCAMTool):
object_geo = unary_union(object_geo)
# for geo in object_geo:
if isinstance(cutout_obj, FlatCAMGerber):
if cutout_obj.kind == 'gerber':
if isinstance(object_geo, MultiPolygon):
x0, y0, x1, y1 = object_geo.bounds
object_geo = box(x0, y0, x1, y1)
@@ -623,7 +622,7 @@ class CutOut(FlatCAMTool):
object_geo = [object_geo]
for geom_struct in object_geo:
if isinstance(cutout_obj, FlatCAMGerber):
if cutout_obj.kind == 'gerber':
if margin >= 0:
geom_struct = (geom_struct.buffer(margin + abs(dia / 2))).exterior
else:
@@ -775,7 +774,7 @@ class CutOut(FlatCAMTool):
# if Gerber create a buffer at a distance
# if Geometry then cut through the geometry
if isinstance(cutout_obj, FlatCAMGerber):
if cutout_obj.kind == 'gerber':
if margin >= 0:
geo = geo.buffer(margin + abs(dia / 2))
else:
@@ -909,7 +908,7 @@ class CutOut(FlatCAMTool):
"Select one and try again."))
return
if not isinstance(cutout_obj, FlatCAMGerber):
if cutout_obj.kind != 'gerber':
self.app.inform.emit('[ERROR_NOTCL] %s' %
_("The selected object has to be of Gerber type.\n"
"Select a Gerber file and try again."))
@@ -988,11 +987,11 @@ class CutOut(FlatCAMTool):
if self.app.is_legacy is False:
event_pos = event.pos
event_is_dragging = event.is_dragging
# event_is_dragging = event.is_dragging
right_button = 2
else:
event_pos = (event.xdata, event.ydata)
event_is_dragging = self.app.plotcanvas.is_dragging
# event_is_dragging = self.app.plotcanvas.is_dragging
right_button = 3
try:
@@ -1038,11 +1037,11 @@ class CutOut(FlatCAMTool):
if self.app.is_legacy is False:
event_pos = event.pos
event_is_dragging = event.is_dragging
right_button = 2
# right_button = 2
else:
event_pos = (event.xdata, event.ydata)
event_is_dragging = self.app.plotcanvas.is_dragging
right_button = 3
# right_button = 3
try:
x = float(event_pos[0])
@@ -1159,13 +1158,17 @@ class CutOut(FlatCAMTool):
if '+' in key_string:
mod, __, key_text = key_string.rpartition('+')
if mod.lower() == 'ctrl':
modifiers = QtCore.Qt.ControlModifier
# modifiers = QtCore.Qt.ControlModifier
pass
elif mod.lower() == 'alt':
modifiers = QtCore.Qt.AltModifier
# modifiers = QtCore.Qt.AltModifier
pass
elif mod.lower() == 'shift':
modifiers = QtCore.Qt.ShiftModifier
# modifiers = QtCore.Qt.ShiftModifier
pass
else:
modifiers = QtCore.Qt.NoModifier
# modifiers = QtCore.Qt.NoModifier
pass
key = QtGui.QKeySequence(key_text)
# events from Vispy are of type KeyEvent
else:
@@ -1203,7 +1206,8 @@ class CutOut(FlatCAMTool):
geo = self.cutting_geo(pos=(l_x, l_y))
self.draw_utility_geometry(geo=geo)
def subtract_poly_from_geo(self, solid_geo, x0, y0, x1, y1):
@staticmethod
def subtract_poly_from_geo(solid_geo, x0, y0, x1, y1):
"""
Subtract polygon made from points from the given object.
This only operates on the paths in the original geometry,
@@ -1270,8 +1274,9 @@ def flatten(geometry):
def recursive_bounds(geometry):
"""
Returns coordinates of rectangular bounds
of geometry: (xmin, ymin, xmax, ymax).
:param geometry: a iterable object that holds geometry
:return: Returns coordinates of rectangular bounds of geometry: (xmin, ymin, xmax, ymax).
"""
# now it can get bounds for nested lists of objects

View File

@@ -3,7 +3,6 @@ from PyQt5 import QtWidgets, QtCore
from FlatCAMTool import FlatCAMTool
from flatcamGUI.GUIElements import RadioSet, FCDoubleSpinner, EvalEntry, FCEntry, FCButton, FCComboBox
from FlatCAMObj import FlatCAMGerber, FlatCAMExcellon, FlatCAMGeometry
from numpy import Inf
@@ -658,7 +657,7 @@ class DblSidedTool(FlatCAMTool):
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
return
if not isinstance(fcobj, FlatCAMGerber):
if fcobj.kind != 'gerber':
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Only Gerber, Excellon and Geometry objects can be mirrored."))
return
@@ -701,7 +700,7 @@ class DblSidedTool(FlatCAMTool):
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Excellon object loaded ..."))
return
if not isinstance(fcobj, FlatCAMExcellon):
if fcobj.kind != 'excellon':
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Only Gerber, Excellon and Geometry objects can be mirrored."))
return
@@ -745,7 +744,7 @@ class DblSidedTool(FlatCAMTool):
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Geometry object loaded ..."))
return
if not isinstance(fcobj, FlatCAMGeometry):
if fcobj.kind != 'geometry':
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Only Gerber, Excellon and Geometry objects can be mirrored."))
return

View File

@@ -8,7 +8,6 @@
from PyQt5 import QtWidgets, QtCore
from FlatCAMTool import FlatCAMTool
from flatcamGUI.VisPyVisuals import *
from FlatCAMObj import FlatCAMGerber
from copy import copy
import logging
@@ -128,7 +127,7 @@ class ToolMove(FlatCAMTool):
pos_canvas = self.app.plotcanvas.translate_coords(event_pos)
# if GRID is active we need to get the snapped positions
if self.app.grid_status() == True:
if self.app.grid_status():
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
else:
pos = pos_canvas
@@ -148,7 +147,7 @@ class ToolMove(FlatCAMTool):
self.delete_shape()
# if GRID is active we need to get the snapped positions
if self.app.grid_status() == True:
if self.app.grid_status():
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
else:
pos = pos_canvas
@@ -171,7 +170,7 @@ class ToolMove(FlatCAMTool):
# remove any mark aperture shape that may be displayed
for sel_obj in obj_list:
# if the Gerber mark shapes are enabled they need to be disabled before move
if isinstance(sel_obj, FlatCAMGerber):
if sel_obj.kind == 'gerber':
sel_obj.ui.aperture_table_visibility_cb.setChecked(False)
try:
@@ -198,8 +197,8 @@ class ToolMove(FlatCAMTool):
elif sel_obj.kind == 'excellon':
sel_obj.source_file = self.app.export_excellon(
obj_name=out_name, filename=None, local_use=sel_obj, use_thread=False)
except Exception as e:
log.debug('[ERROR_NOTCL] %s --> %s' % ('ToolMove.on_left_click()', str(e)))
except Exception as err:
log.debug('[ERROR_NOTCL] %s --> %s' % ('ToolMove.on_left_click()', str(err)))
return "fail"
# time to plot the moved objects
@@ -249,7 +248,7 @@ class ToolMove(FlatCAMTool):
pos_canvas = self.app.plotcanvas.translate_coords((x, y))
# if GRID is active we need to get the snapped positions
if self.app.grid_status() == True:
if self.app.grid_status():
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
else:
pos = pos_canvas

View File

@@ -12,7 +12,7 @@ from flatcamGUI.GUIElements import FCCheckBox, FCDoubleSpinner, RadioSet, FCTabl
FCComboBox, OptionalInputSection
from flatcamParsers.ParseGerber import Gerber
import FlatCAMApp
from FlatCAMCommon import GracefulException as grace
from copy import deepcopy
@@ -1987,7 +1987,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
for poly in env_obj:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_buff_list.append(poly.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre))
bounding_box = cascaded_union(geo_buff_list)
elif ncc_select == _("Reference Object"):
@@ -1996,7 +1996,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
for poly in env_obj:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_buff_list.append(poly.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre))
bounding_box = cascaded_union(geo_buff_list)
@@ -2090,7 +2090,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
if isinstance(geo_elem, Polygon):
for ring in self.poly2rings(geo_elem):
@@ -2312,7 +2312,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
log.debug("Starting geometry processing for tool: %s" % str(tool))
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
# provide the app with a way to process the GUI events when in a blocking loop
QtWidgets.QApplication.processEvents()
@@ -2377,7 +2377,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
# clean the polygon
p = p.buffer(0)
@@ -2595,7 +2595,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
log.debug("Starting geometry processing for tool: %s" % str(tool))
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
# provide the app with a way to process the GUI events when in a blocking loop
QtWidgets.QApplication.processEvents()
@@ -2644,7 +2644,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
try:
area = area.difference(poly)
except Exception:
@@ -2674,7 +2674,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
for p in area.geoms:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
# clean the polygon
p = p.buffer(0)
@@ -2753,7 +2753,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
# check if there is a geometry at all in the cleared geometry
if cleared_geo:
@@ -2771,7 +2771,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
for p in cleared_area:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
poly = p.buffer(buffer_value)
cleared_by_last_tool.append(poly)
@@ -2836,7 +2836,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
app_obj.new_object("geometry", name, gen_clear_area_rest)
else:
app_obj.new_object("geometry", name, gen_clear_area)
except FlatCAMApp.GracefulException:
except grace:
if run_threaded:
proc.done()
return
@@ -2999,7 +2999,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
for poly in geo_n:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_buff_list.append(poly.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre))
bounding_box = cascaded_union(geo_buff_list)
@@ -3017,7 +3017,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
for poly in geo_n:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_buff_list.append(poly.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre))
bounding_box = cascaded_union(geo_buff_list)
@@ -3141,7 +3141,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
if isinstance(geo_elem, Polygon):
for ring in self.poly2rings(geo_elem):
@@ -3242,7 +3242,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
log.debug("Starting geometry processing for tool: %s" % str(tool))
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
# provide the app with a way to process the GUI events when in a blocking loop
QtWidgets.QApplication.processEvents()
@@ -3283,7 +3283,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
# clean the polygon
p = p.buffer(0)
@@ -3520,7 +3520,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
if isinstance(geo_elem, Polygon):
for ring in self.poly2rings(geo_elem):
@@ -3614,7 +3614,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
if type(empty) is Polygon:
empty = MultiPolygon([empty])
@@ -3628,7 +3628,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
while sorted_tools:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
tool = sorted_tools.pop(0)
log.debug("Starting geometry processing for tool: %s" % str(tool))
@@ -3648,7 +3648,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
try:
area = area.difference(poly_r)
except Exception:
@@ -3678,7 +3678,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
for p in area.geoms:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
# clean the polygon
p = p.buffer(0)
@@ -3754,7 +3754,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
# check if there is a geometry at all in the cleared geometry
if cleared_geo:
@@ -3772,7 +3772,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
for p in cleared_area:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
r_poly = p.buffer(buffer_value)
cleared_by_last_tool.append(r_poly)
@@ -3833,7 +3833,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
app_obj.new_object("geometry", name, gen_clear_area_rest, plot=plot)
else:
app_obj.new_object("geometry", name, gen_clear_area, plot=plot)
except FlatCAMApp.GracefulException:
except grace:
if run_threaded:
proc.done()
return
@@ -3887,7 +3887,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
boundary = boundary.difference(el)
pol_nr += 1
disp_number = int(np.interp(pol_nr, [0, geo_len], [0, 100]))

View File

@@ -9,8 +9,7 @@ from PyQt5 import QtWidgets, QtCore, QtGui
from FlatCAMTool import FlatCAMTool
from flatcamGUI.GUIElements import OptionalHideInputSection, FCTextArea, FCEntry, FCSpinner, FCCheckBox, FCComboBox
from FlatCAMObj import FlatCAMGerber
import FlatCAMApp
from FlatCAMCommon import GracefulException as grace
from shapely.geometry import MultiPolygon
from shapely.ops import nearest_points
@@ -343,7 +342,7 @@ class ToolOptimal(FlatCAMTool):
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
return
if not isinstance(fcobj, FlatCAMGerber):
if fcobj.kind != 'gerber':
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Only Gerber objects can be evaluated."))
return
@@ -365,7 +364,7 @@ class ToolOptimal(FlatCAMTool):
for geo_el in fcobj.apertures[ap]['geometry']:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
if 'solid' in geo_el and geo_el['solid'] is not None and geo_el['solid'].is_valid:
total_geo.append(geo_el['solid'])
@@ -395,7 +394,7 @@ class ToolOptimal(FlatCAMTool):
for s_geo in total_geo[idx:]:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
# minimize the number of distances by not taking into considerations those that are too small
dist = geo.distance(s_geo)
@@ -459,7 +458,7 @@ class ToolOptimal(FlatCAMTool):
log.debug("ToolOptimal.on_locate_position() --> first try %s" % str(e))
self.app.inform.emit("[ERROR_NOTCL] The selected text is no valid location in the format "
"((x0, y0), (x1, y1)).")
return 'fail'
return
try:
loc_1 = loc[0]
@@ -471,7 +470,7 @@ class ToolOptimal(FlatCAMTool):
self.app.on_jump_to(custom_location=loc)
except Exception as e:
log.debug("ToolOptimal.on_locate_position() --> sec try %s" % str(e))
return 'fail'
return
def on_update_text(self, data):
txt = ''
@@ -567,12 +566,12 @@ class ToolOptimal(FlatCAMTool):
if self.selected_locations_text != '':
loc = eval(self.selected_locations_text)
else:
return 'fail'
return
except Exception as e:
log.debug("ToolOptimal.on_locate_sec_position() --> first try %s" % str(e))
self.app.inform.emit("[ERROR_NOTCL] The selected text is no valid location in the format "
"((x0, y0), (x1, y1)).")
return 'fail'
return
try:
loc_1 = loc[0]
@@ -584,7 +583,7 @@ class ToolOptimal(FlatCAMTool):
self.app.on_jump_to(custom_location=loc)
except Exception as e:
log.debug("ToolOptimal.on_locate_sec_position() --> sec try %s" % str(e))
return 'fail'
return
def reset_fields(self):
self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))

View File

@@ -8,7 +8,7 @@
from PyQt5 import QtWidgets, QtCore
from FlatCAMTool import FlatCAMTool
import FlatCAMApp
from FlatCAMCommon import GracefulException as grace
from shapely.geometry import Point, Polygon, LineString, MultiPolygon
from shapely.ops import unary_union
@@ -190,7 +190,7 @@ class ToolPDF(FlatCAMTool):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
with self.app.proc_container.new(_("Parsing PDF file ...")):
with open(filename, "rb") as f:
@@ -200,7 +200,7 @@ class ToolPDF(FlatCAMTool):
for s in re.findall(self.stream_re, pdf):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
stream_nr += 1
log.debug(" PDF STREAM: %d\n" % stream_nr)
@@ -291,7 +291,7 @@ class ToolPDF(FlatCAMTool):
def layer_rendering_as_gerber(self, filename, ap_dict, layer_nr):
outname = filename.split('/')[-1].split('\\')[-1] + "_%s" % str(layer_nr)
def obj_init(grb_obj, app_obj):
def obj_init(grb_obj):
grb_obj.apertures = ap_dict
@@ -404,7 +404,7 @@ class ToolPDF(FlatCAMTool):
for object_name in self.pdf_parsed:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
filename = deepcopy(self.pdf_parsed[object_name]['filename'])
pdf_content = deepcopy(self.pdf_parsed[object_name]['pdf'])
@@ -412,7 +412,7 @@ class ToolPDF(FlatCAMTool):
for k in pdf_content:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
ap_dict = pdf_content[k]
if ap_dict:
@@ -493,7 +493,7 @@ class ToolPDF(FlatCAMTool):
for pline in lines:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
line_nr += 1
log.debug("line %d: %s" % (line_nr, pline))
@@ -868,7 +868,6 @@ class ToolPDF(FlatCAMTool):
new_el['solid'] = pdf_geo
new_el['follow'] = pdf_geo.exterior
apertures_dict[copy(found_aperture)]['geometry'].append(deepcopy(new_el))
found_aperture = None
else:
if str(aperture) in apertures_dict.keys():
aperture += 1
@@ -1231,7 +1230,6 @@ class ToolPDF(FlatCAMTool):
new_el['solid'] = pdf_geo
new_el['follow'] = pdf_geo.exterior
apertures_dict[copy(found_aperture)]['geometry'].append(deepcopy(new_el))
found_aperture = None
else:
if str(aperture) in apertures_dict.keys():
aperture += 1
@@ -1355,7 +1353,7 @@ class ToolPDF(FlatCAMTool):
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
return object_dict

View File

@@ -14,7 +14,7 @@ from copy import deepcopy
from flatcamParsers.ParseGerber import Gerber
from camlib import Geometry, FlatCAMRTreeStorage
from flatcamGUI.GUIElements import FCTable, FCDoubleSpinner, FCCheckBox, FCInputDialog, RadioSet, FCButton, FCComboBox
import FlatCAMApp
from FlatCAMCommon import GracefulException as grace
from shapely.geometry import base, Polygon, MultiPolygon, LinearRing, Point
from shapely.ops import cascaded_union, unary_union, linemerge
@@ -1836,7 +1836,7 @@ class ToolPaint(FlatCAMTool, Gerber):
contour=cont,
connect=conn,
prog_plot=prog_plot)
except FlatCAMApp.GracefulException:
except grace:
return "fail"
except Exception as ee:
log.debug("ToolPaint.paint_polygon_worker() Standard --> %s" % str(ee))
@@ -1850,7 +1850,7 @@ class ToolPaint(FlatCAMTool, Gerber):
contour=cont,
connect=conn,
prog_plot=prog_plot)
except FlatCAMApp.GracefulException:
except grace:
return "fail"
except Exception as ee:
log.debug("ToolPaint.paint_polygon_worker() Seed --> %s" % str(ee))
@@ -1864,7 +1864,7 @@ class ToolPaint(FlatCAMTool, Gerber):
contour=cont,
connect=conn,
prog_plot=prog_plot)
except FlatCAMApp.GracefulException:
except grace:
return "fail"
except Exception as ee:
log.debug("ToolPaint.paint_polygon_worker() Lines --> %s" % str(ee))
@@ -2015,7 +2015,7 @@ class ToolPaint(FlatCAMTool, Gerber):
# contour=cont,
# connect=conn,
# prog_plot=prog_plot)
except FlatCAMApp.GracefulException:
except grace:
return "fail"
except Exception as ee:
log.debug("ToolPaint.paint_polygon_worker() Laser Lines --> %s" % str(ee))
@@ -2052,7 +2052,7 @@ class ToolPaint(FlatCAMTool, Gerber):
contour=cont,
connect=conn,
prog_plot=prog_plot)
except FlatCAMApp.GracefulException:
except grace:
return "fail"
except Exception as ee:
log.debug("ToolPaint.paint_polygon_worker() Combo --> %s" % str(ee))
@@ -2199,7 +2199,7 @@ class ToolPaint(FlatCAMTool, Gerber):
QtWidgets.QApplication.processEvents()
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_res = self.paint_polygon_worker(pp, tooldiameter=tool_dia, over=over, conn=conn,
cont=cont, paint_method=paint_method, obj=obj,
prog_plot=prog_plot)
@@ -2217,7 +2217,7 @@ class ToolPaint(FlatCAMTool, Gerber):
QtWidgets.QApplication.processEvents()
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_res = self.paint_polygon_worker(poly_buf, tooldiameter=tool_dia, over=over, conn=conn,
cont=cont, paint_method=paint_method, obj=obj,
@@ -2230,7 +2230,7 @@ class ToolPaint(FlatCAMTool, Gerber):
for x in cp:
total_geometry += list(x.get_objects())
final_solid_geometry += total_geometry
except FlatCAMApp.GracefulException:
except grace:
return "fail"
except Exception as e:
log.debug("Could not Paint the polygons. %s" % str(e))
@@ -2305,7 +2305,7 @@ class ToolPaint(FlatCAMTool, Gerber):
def job_thread(app_obj):
try:
ret = app_obj.new_object("geometry", name, job_init, plot=plot)
except FlatCAMApp.GracefulException:
except grace:
proc.done()
return
except Exception as er:
@@ -2376,7 +2376,7 @@ class ToolPaint(FlatCAMTool, Gerber):
"""
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
if geometry is None:
return
@@ -2517,7 +2517,7 @@ class ToolPaint(FlatCAMTool, Gerber):
QtWidgets.QApplication.processEvents()
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_res = self.paint_polygon_worker(pp, tooldiameter=tool_dia, over=over, conn=conn,
cont=cont, paint_method=paint_method, obj=obj,
@@ -2542,7 +2542,7 @@ class ToolPaint(FlatCAMTool, Gerber):
QtWidgets.QApplication.processEvents()
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_res = self.paint_polygon_worker(poly_buf, tooldiameter=tool_dia, over=over, conn=conn,
cont=cont, paint_method=paint_method, obj=obj,
@@ -2705,7 +2705,7 @@ class ToolPaint(FlatCAMTool, Gerber):
QtWidgets.QApplication.processEvents()
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_res = self.paint_polygon_worker(pp, tooldiameter=tool_dia, over=over, conn=conn,
cont=cont, paint_method=paint_method, obj=obj,
prog_plot=prog_plot)
@@ -2723,7 +2723,7 @@ class ToolPaint(FlatCAMTool, Gerber):
QtWidgets.QApplication.processEvents()
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_res = self.paint_polygon_worker(poly_buf, tooldiameter=tool_dia, over=over, conn=conn,
cont=cont, paint_method=paint_method, obj=obj,
@@ -2735,7 +2735,7 @@ class ToolPaint(FlatCAMTool, Gerber):
for x in cp:
cleared_geo += list(x.get_objects())
final_solid_geometry += cleared_geo
except FlatCAMApp.GracefulException:
except grace:
return "fail"
except Exception as e:
log.debug("Could not Paint the polygons. %s" % str(e))
@@ -2815,7 +2815,7 @@ class ToolPaint(FlatCAMTool, Gerber):
ret = app_obj.new_object("geometry", name, gen_paintarea_rest_machining, plot=plot)
else:
ret = app_obj.new_object("geometry", name, gen_paintarea, plot=plot)
except FlatCAMApp.GracefulException:
except grace:
proc.done()
return
except Exception as err:
@@ -2873,7 +2873,7 @@ class ToolPaint(FlatCAMTool, Gerber):
"""
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
if geometry is None:
return
@@ -3015,7 +3015,7 @@ class ToolPaint(FlatCAMTool, Gerber):
QtWidgets.QApplication.processEvents()
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_res = self.paint_polygon_worker(pp, tooldiameter=tool_dia, over=over, conn=conn,
cont=cont, paint_method=paint_method, obj=obj,
@@ -3040,7 +3040,7 @@ class ToolPaint(FlatCAMTool, Gerber):
QtWidgets.QApplication.processEvents()
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_res = self.paint_polygon_worker(poly_buf, tooldiameter=tool_dia, over=over, conn=conn,
cont=cont, paint_method=paint_method, obj=obj,
@@ -3193,7 +3193,7 @@ class ToolPaint(FlatCAMTool, Gerber):
QtWidgets.QApplication.processEvents()
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_res = self.paint_polygon_worker(pp, tooldiameter=tool_dia, over=over, conn=conn,
cont=cont, paint_method=paint_method, obj=obj,
@@ -3218,7 +3218,7 @@ class ToolPaint(FlatCAMTool, Gerber):
QtWidgets.QApplication.processEvents()
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
geo_res = self.paint_polygon_worker(poly_buf, tooldiameter=tool_dia, over=over, conn=conn,
cont=cont, paint_method=paint_method, obj=obj,
@@ -3312,7 +3312,7 @@ class ToolPaint(FlatCAMTool, Gerber):
ret = app_obj.new_object("geometry", name, gen_paintarea_rest_machining, plot=plot)
else:
ret = app_obj.new_object("geometry", name, gen_paintarea, plot=plot)
except FlatCAMApp.GracefulException:
except grace:
proc.done()
return
except Exception as err:

View File

@@ -9,10 +9,8 @@ from PyQt5 import QtWidgets, QtGui, QtCore
from FlatCAMTool import FlatCAMTool
from flatcamGUI.GUIElements import FCSpinner, FCDoubleSpinner, RadioSet, FCCheckBox, OptionalInputSection, FCComboBox
from FlatCAMObj import FlatCAMGeometry, FlatCAMGerber, FlatCAMExcellon
import FlatCAMApp
from FlatCAMCommon import GracefulException as grace
from copy import deepcopy
# from ObjectCollection import *
import numpy as np
import shapely.affinity as affinity
@@ -480,13 +478,13 @@ class Panelize(FlatCAMTool):
rows -= 1
panel_lengthy = ((ymax - ymin) * rows) + (spacing_rows * (rows - 1))
if isinstance(panel_obj, FlatCAMExcellon) or isinstance(panel_obj, FlatCAMGeometry):
if panel_obj.kind == 'excellon' or panel_obj.kind == 'geometry':
# make a copy of the panelized Excellon or Geometry tools
copied_tools = {}
for tt, tt_val in list(panel_obj.tools.items()):
copied_tools[tt] = deepcopy(tt_val)
if isinstance(panel_obj, FlatCAMGerber):
if panel_obj.kind == 'gerber':
# make a copy of the panelized Gerber apertures
copied_apertures = {}
for tt, tt_val in list(panel_obj.apertures.items()):
@@ -525,7 +523,7 @@ class Panelize(FlatCAMTool):
for tool_dict in panel_obj.drills:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
point_offseted = affinity.translate(tool_dict['point'], currentx, currenty)
obj_fin.drills.append(
@@ -550,7 +548,7 @@ class Panelize(FlatCAMTool):
for tool_dict in panel_obj.slots:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
start_offseted = affinity.translate(tool_dict['start'], currentx, currenty)
stop_offseted = affinity.translate(tool_dict['stop'], currentx, currenty)
@@ -600,20 +598,20 @@ class Panelize(FlatCAMTool):
obj_fin.solid_geometry = []
# create the initial structure on which to create the panel
if isinstance(panel_obj, FlatCAMGeometry):
if panel_obj.kind == 'geometry':
obj_fin.multigeo = panel_obj.multigeo
obj_fin.tools = copied_tools
if panel_obj.multigeo is True:
for tool in panel_obj.tools:
obj_fin.tools[tool]['solid_geometry'][:] = []
elif isinstance(panel_obj, FlatCAMGerber):
elif panel_obj.kind == 'gerber':
obj_fin.apertures = copied_apertures
for ap in obj_fin.apertures:
obj_fin.apertures[ap]['geometry'] = []
# find the number of polygons in the source solid_geometry
geo_len = 0
if isinstance(panel_obj, FlatCAMGeometry):
if panel_obj.kind == 'geometry':
if panel_obj.multigeo is True:
for tool in panel_obj.tools:
try:
@@ -625,7 +623,7 @@ class Panelize(FlatCAMTool):
geo_len = len(panel_obj.solid_geometry)
except TypeError:
geo_len = 1
elif isinstance(panel_obj, FlatCAMGerber):
elif panel_obj.kind == 'gerber':
for ap in panel_obj.apertures:
if 'geometry' in panel_obj.apertures[ap]:
try:
@@ -641,12 +639,12 @@ class Panelize(FlatCAMTool):
element += 1
old_disp_number = 0
if isinstance(panel_obj, FlatCAMGeometry):
if panel_obj.kind == 'geometry':
if panel_obj.multigeo is True:
for tool in panel_obj.tools:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
# geo = translate_recursion(panel_obj.tools[tool]['solid_geometry'])
# if isinstance(geo, list):
@@ -678,7 +676,7 @@ class Panelize(FlatCAMTool):
# obj_fin.solid_geometry.append(geo)
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
try:
# calculate the number of polygons
@@ -690,7 +688,7 @@ class Panelize(FlatCAMTool):
for geo_el in panel_obj.solid_geometry:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
trans_geo = translate_recursion(geo_el)
obj_fin.solid_geometry.append(trans_geo)
@@ -715,13 +713,13 @@ class Panelize(FlatCAMTool):
# obj_fin.solid_geometry.append(geo)
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
try:
for geo_el in panel_obj.solid_geometry:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
trans_geo = translate_recursion(geo_el)
obj_fin.solid_geometry.append(trans_geo)
@@ -732,7 +730,7 @@ class Panelize(FlatCAMTool):
for apid in panel_obj.apertures:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
if 'geometry' in panel_obj.apertures[apid]:
try:
# calculate the number of polygons
@@ -743,7 +741,7 @@ class Panelize(FlatCAMTool):
for el in panel_obj.apertures[apid]['geometry']:
if self.app.abort_flag:
# graceful abort requested by the user
raise FlatCAMApp.GracefulException
raise grace
new_el = {}
if 'solid' in el:
@@ -786,7 +784,7 @@ class Panelize(FlatCAMTool):
self.app.proc_container.update_view_text('')
self.app.inform.emit('%s: %d' % (_("Generating panel... Spawning copies"), (int(rows * columns))))
if isinstance(panel_obj, FlatCAMExcellon):
if panel_obj.kind == 'excellon':
self.app.new_object("excellon", self.outname, job_init_excellon, plot=True, autoselected=True)
else:
self.app.new_object(panel_type, self.outname, job_init_geometry, plot=True, autoselected=True)

View File

@@ -11,7 +11,6 @@ from flatcamGUI.GUIElements import FCComboBox, FCEntry, FCTable, \
FCInputDialog, FCDoubleSpinner, FCSpinner, FCFileSaveDialog
from FlatCAMApp import log
from camlib import distance
from FlatCAMObj import FlatCAMCNCjob
from flatcamEditors.FlatCAMTextEditor import TextEditor
from PyQt5 import QtGui, QtCore, QtWidgets
@@ -506,7 +505,8 @@ class SolderPaste(FlatCAMTool):
self.flat_geometry = []
# action to be added in the combobox context menu
self.combo_context_del_action = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/trash16.png'), _("Delete Object"))
self.combo_context_del_action = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/trash16.png'),
_("Delete Object"))
# ## Signals
self.combo_context_del_action.triggered.connect(self.on_delete_object)
@@ -966,6 +966,7 @@ class SolderPaste(FlatCAMTool):
self.build_ui()
return
else:
old_tool_dia = ''
# identify the old tool_dia and restore the text in tool table
for k, v in self.tooltable_tools.items():
if k == tooluid:
@@ -1332,8 +1333,8 @@ class SolderPaste(FlatCAMTool):
# Object initialization function for app.new_object()
# RUNNING ON SEPARATE THREAD!
def job_init(job_obj, app_obj):
assert isinstance(job_obj, FlatCAMCNCjob), \
def job_init(job_obj):
assert job_obj.kind == 'cncjob', \
"Initializer expected a FlatCAMCNCjob, got %s" % type(job_obj)
# this turn on the FlatCAMCNCJob plot for multiple tools

View File

@@ -8,7 +8,6 @@
from PyQt5 import QtWidgets
from FlatCAMTool import FlatCAMTool
from flatcamGUI.GUIElements import FCDoubleSpinner, FCCheckBox, FCButton, OptionalInputSection, EvalEntry2
from FlatCAMObj import FlatCAMCNCjob
import gettext
import FlatCAMTranslation as fcTranslate
@@ -681,7 +680,7 @@ class ToolTransform(FlatCAMTool):
try:
# first get a bounding box to fit all
for obj in obj_list:
if isinstance(obj, FlatCAMCNCjob):
if obj.kind == 'cncjob':
pass
else:
xmin, ymin, xmax, ymax = obj.bounds()
@@ -699,7 +698,7 @@ class ToolTransform(FlatCAMTool):
px = 0.5 * (xminimal + xmaximal)
py = 0.5 * (yminimal + ymaximal)
for sel_obj in obj_list:
if isinstance(sel_obj, FlatCAMCNCjob):
if sel_obj.kind == 'cncjob':
self.app.inform.emit(_("CNCJob objects can't be rotated."))
else:
sel_obj.rotate(-num, point=(px, py))
@@ -735,7 +734,7 @@ class ToolTransform(FlatCAMTool):
else:
# first get a bounding box to fit all
for obj in obj_list:
if isinstance(obj, FlatCAMCNCjob):
if obj.kind == 'cncjob':
pass
else:
xmin, ymin, xmax, ymax = obj.bounds()
@@ -755,7 +754,7 @@ class ToolTransform(FlatCAMTool):
# execute mirroring
for sel_obj in obj_list:
if isinstance(sel_obj, FlatCAMCNCjob):
if sel_obj.kind == 'cncjob':
self.app.inform.emit(_("CNCJob objects can't be mirrored/flipped."))
else:
if axis == 'X':
@@ -803,7 +802,7 @@ class ToolTransform(FlatCAMTool):
try:
# first get a bounding box to fit all
for obj in obj_list:
if isinstance(obj, FlatCAMCNCjob):
if obj.kind == 'cncjob':
pass
else:
xmin, ymin, xmax, ymax = obj.bounds()
@@ -815,7 +814,7 @@ class ToolTransform(FlatCAMTool):
yminimal = min(yminlist)
for sel_obj in obj_list:
if isinstance(sel_obj, FlatCAMCNCjob):
if sel_obj.kind == 'cncjob':
self.app.inform.emit(_("CNCJob objects can't be skewed."))
else:
if axis == 'X':
@@ -842,15 +841,14 @@ class ToolTransform(FlatCAMTool):
ymaxlist = []
if not obj_list:
self.app.inform.emit('[WARNING_NOTCL] %s' %
_("No object selected. Please Select an object to scale!"))
self.app.inform.emit('[WARNING_NOTCL] %s' % _("No object selected. Please Select an object to scale!"))
return
else:
with self.app.proc_container.new(_("Applying Scale")):
try:
# first get a bounding box to fit all
for obj in obj_list:
if isinstance(obj, FlatCAMCNCjob):
if obj.kind == 'cncjob':
pass
else:
xmin, ymin, xmax, ymax = obj.bounds()
@@ -873,7 +871,7 @@ class ToolTransform(FlatCAMTool):
py = 0
for sel_obj in obj_list:
if isinstance(sel_obj, FlatCAMCNCjob):
if sel_obj.kind == 'cncjob':
self.app.inform.emit(_("CNCJob objects can't be scaled."))
else:
sel_obj.scale(xfactor, yfactor, point=(px, py))
@@ -883,8 +881,7 @@ class ToolTransform(FlatCAMTool):
self.app.object_changed.emit(sel_obj)
sel_obj.plot()
self.app.inform.emit('[success] %s %s %s...' %
(_('Scale on the'), str(axis), _('axis done')))
self.app.inform.emit('[success] %s %s %s...' % (_('Scale on the'), str(axis), _('axis done')))
except Exception as e:
self.app.inform.emit('[ERROR_NOTCL] %s %s, %s.' %
(_("Due of"), str(e), _("action was not executed.")))
@@ -894,14 +891,13 @@ class ToolTransform(FlatCAMTool):
obj_list = self.app.collection.get_selected()
if not obj_list:
self.app.inform.emit('[WARNING_NOTCL] %s' %
_("No object selected. Please Select an object to offset!"))
self.app.inform.emit('[WARNING_NOTCL] %s' % _("No object selected. Please Select an object to offset!"))
return
else:
with self.app.proc_container.new(_("Applying Offset")):
try:
for sel_obj in obj_list:
if isinstance(sel_obj, FlatCAMCNCjob):
if sel_obj.kind == 'cncjob':
self.app.inform.emit(_("CNCJob objects can't be offset."))
else:
if axis == 'X':
@@ -915,8 +911,7 @@ class ToolTransform(FlatCAMTool):
self.app.object_changed.emit(sel_obj)
sel_obj.plot()
self.app.inform.emit('[success] %s %s %s...' %
(_('Offset on the'), str(axis), _('axis done')))
self.app.inform.emit('[success] %s %s %s...' % (_('Offset on the'), str(axis), _('axis done')))
except Exception as e:
self.app.inform.emit('[ERROR_NOTCL] %s %s, %s.' %
(_("Due of"), str(e), _("action was not executed.")))
@@ -932,7 +927,7 @@ class ToolTransform(FlatCAMTool):
with self.app.proc_container.new(_("Applying Buffer")):
try:
for sel_obj in obj_list:
if isinstance(sel_obj, FlatCAMCNCjob):
if sel_obj.kind == 'cncjob':
self.app.inform.emit(_("CNCJob objects can't be buffered."))
elif sel_obj.kind.lower() == 'gerber':
sel_obj.buffer(value, join, factor)