- in Geometry Editor, in Copy Tool - linear array utility geometry is working

This commit is contained in:
Marius Stanciu
2022-04-17 02:14:00 +03:00
committed by Marius Stanciu
parent 07995fd0c8
commit 0df270a48d
2 changed files with 28 additions and 35 deletions

View File

@@ -10,6 +10,8 @@ CHANGELOG for FlatCAM Evo beta
17.04.2022 17.04.2022
- in Geometry Editor, in Copy Tool - work in progress (adding utility geometry for the array mode) - in Geometry Editor, in Copy Tool - work in progress (adding utility geometry for the array mode)
- in Geometry Editor, in Copy Tool - linear array utility geometry is working
16.04.2022 16.04.2022

View File

@@ -2265,7 +2265,7 @@ class FCCopy(FCShapeTool):
return return
return DrawToolUtilityShape(geo_list) return DrawToolUtilityShape(geo_list)
else: else:
return self.array_util_geometry(data) return self.array_util_geometry((dx, dy))
else: else:
try: try:
ss_el = translate(self.selection_shape, xoff=dx, yoff=dy) ss_el = translate(self.selection_shape, xoff=dx, yoff=dy)
@@ -2274,23 +2274,11 @@ class FCCopy(FCShapeTool):
return DrawToolUtilityShape(ss_el) return DrawToolUtilityShape(ss_el)
def array_util_geometry(self, pos, static=None): def array_util_geometry(self, pos, static=None):
axis = self.draw_app.ui.axis_radio.get_value() axis = self.copy_tool.ui.axis_radio.get_value() # X, Y or A
direction = self.draw_app.ui.array_dir_radio.get_value() array_type = self.copy_tool.ui.array_type_radio.get_value() # 'linear', '2D', 'circular'
array_type = self.draw_app.ui.array_type_radio.get_value()
try:
array_size = int(self.copy_tool.ui.array_size_entry.get_value()) array_size = int(self.copy_tool.ui.array_size_entry.get_value())
try:
pitch = float(self.copy_tool.ui.pitch_entry.get_value()) pitch = float(self.copy_tool.ui.pitch_entry.get_value())
linear_angle = float(self.copy_tool.ui.linear_angle_spinner.get_value()) linear_angle = float(self.copy_tool.ui.linear_angle_spinner.get_value())
angle = float(self.copy_tool.ui.angle_entry.get_value())
except TypeError:
self.draw_app.app.inform.emit('[ERROR_NOTCL] %s' %
_("The value is not Float. Check for comma instead of dot separator."))
return
except Exception as e:
self.draw_app.app.inform.emit('[ERROR_NOTCL] %s. %s' %
(_("The value is mistyped. Check the value"), str(e)))
return
if array_type == 'linear': # 'Linear' if array_type == 'linear': # 'Linear'
if pos[0] is None and pos[1] is None: if pos[0] is None and pos[1] is None:
@@ -2301,7 +2289,7 @@ class FCCopy(FCShapeTool):
dy = pos[1] dy = pos[1]
geo_list = [] geo_list = []
self.points = [dx, dy] self.points = [(dx, dy)]
for item in range(array_size): for item in range(array_size):
if axis == 'X': if axis == 'X':
@@ -2315,20 +2303,18 @@ class FCCopy(FCShapeTool):
for g in self.draw_app.get_selected(): for g in self.draw_app.get_selected():
if static is None or static is False: if static is None or static is False:
geo_list.append(translate(g.geo, xoff=(dx - self.last_dx), yoff=(dy - self.last_dy))) geo_list.append(translate(g.geo, xoff=new_pos[0], yoff=new_pos[1]))
else: else:
geo_list.append(g.geo) geo_list.append(g.geo)
self.last_dx = dx
self.last_dy = dy
return DrawToolUtilityShape(geo_list) return DrawToolUtilityShape(geo_list)
elif array_type== 'circular': # 'Circular' elif array_type== 'circular': # 'Circular'
if pos[0] is None and pos[1] is None: if pos[0] is None and pos[1] is None:
cdx = self.draw_app.x cdx = self.draw_app.x
cdy = self.draw_app.y cdy = self.draw_app.y
else: else:
cdx = pos[0] cdx = pos[0] + self.origin[0]
cdy = pos[1] cdy = pos[1] + self.origin[1]
utility_list = [] utility_list = []
@@ -2347,12 +2333,15 @@ class FCCopy(FCShapeTool):
# draw the temp geometry # draw the temp geometry
initial_angle = math.asin((cdy - self.origin[1]) / radius) initial_angle = math.asin((cdy - self.origin[1]) / radius)
temp_circular_geo = self.circular_util_shape(radius, initial_angle) temp_circular_geo = self.circular_util_shape(radius, initial_angle)
# draw the line # draw the line
temp_points = [x for x in self.points] # temp_points = [x for x in self.points]
temp_points.append([cdx, cdy]) # temp_points.append((cdx, cdy))
temp_points = [
(self.origin[0], self.origin[1]),
(self.origin[0]+pos[0], self.origin[1]+pos[1])
]
temp_line = LineString(temp_points) temp_line = LineString(temp_points)
for geo_shape in temp_circular_geo: for geo_shape in temp_circular_geo:
@@ -2364,9 +2353,9 @@ class FCCopy(FCShapeTool):
log.error("DrillArray.utility_geometry -- circular -> %s" % str(e)) log.error("DrillArray.utility_geometry -- circular -> %s" % str(e))
def circular_util_shape(self, radius, angle): def circular_util_shape(self, radius, angle):
direction = self.draw_app.ui.drill_array_dir_radio.get_value() direction = self.copy_tool.ui.array_dir_radio.get_value() # CW or CCW
if angle is None: if angle is None:
angle = self.draw_app.ui.drill_angle_entry.get_value() angle = self.copy_tool.ui.angle_entry.get_value()
array_size = int(self.copy_tool.ui.array_size_entry.get_value()) array_size = int(self.copy_tool.ui.array_size_entry.get_value())
circular_geo = [] circular_geo = []
@@ -2376,7 +2365,8 @@ class FCCopy(FCShapeTool):
x = self.origin[0] + radius * math.cos(-angle_radians + angle) x = self.origin[0] + radius * math.cos(-angle_radians + angle)
y = self.origin[1] + radius * math.sin(-angle_radians + angle) y = self.origin[1] + radius * math.sin(-angle_radians + angle)
geo_sol = self.util_shape((x, y)) for shape in self.draw_app.get_selected():
geo_sol = translate(shape.geo, x, y)
# geo_sol = affinity.rotate(geo_sol, angle=(math.pi - angle_radians), use_radians=True) # geo_sol = affinity.rotate(geo_sol, angle=(math.pi - angle_radians), use_radians=True)
circular_geo.append(DrawToolShape(geo_sol)) circular_geo.append(DrawToolShape(geo_sol))
@@ -2386,7 +2376,8 @@ class FCCopy(FCShapeTool):
x = self.origin[0] + radius * math.cos(angle_radians + angle) x = self.origin[0] + radius * math.cos(angle_radians + angle)
y = self.origin[1] + radius * math.sin(angle_radians + angle) y = self.origin[1] + radius * math.sin(angle_radians + angle)
geo_sol = self.util_shape((x, y)) for shape in self.draw_app.get_selected():
geo_sol = translate(shape.geo, x, y)
# geo_sol = affinity.rotate(geo_sol, angle=(angle_radians - math.pi), use_radians=True) # geo_sol = affinity.rotate(geo_sol, angle=(angle_radians - math.pi), use_radians=True)
circular_geo.append(DrawToolShape(geo_sol)) circular_geo.append(DrawToolShape(geo_sol))