- in Geometry Editor, COpy Tool, finished the copy-as-array feature except the 2D array type which was not implemented yet
This commit is contained in:
@@ -11,7 +11,7 @@ CHANGELOG for FlatCAM Evo beta
|
|||||||
|
|
||||||
- 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
|
- in Geometry Editor, in Copy Tool - linear array utility geometry is working
|
||||||
|
- in Geometry Editor, COpy Tool, finished the copy-as-array feature except the 2D array type which was not implemented yet
|
||||||
|
|
||||||
16.04.2022
|
16.04.2022
|
||||||
|
|
||||||
|
|||||||
@@ -2133,6 +2133,9 @@ class FCCopy(FCShapeTool):
|
|||||||
self.sel_limit = self.draw_app.app.options["geometry_editor_sel_limit"]
|
self.sel_limit = self.draw_app.app.options["geometry_editor_sel_limit"]
|
||||||
self.selection_shape = self.selection_bbox()
|
self.selection_shape = self.selection_bbox()
|
||||||
|
|
||||||
|
# store here the utility geometry, so we can use it on the last step
|
||||||
|
self.util_geo = None
|
||||||
|
|
||||||
if len(self.draw_app.get_selected()) == 0:
|
if len(self.draw_app.get_selected()) == 0:
|
||||||
self.has_selection = False
|
self.has_selection = False
|
||||||
self.draw_app.app.inform.emit('[WARNING_NOTCL] %s %s' %
|
self.draw_app.app.inform.emit('[WARNING_NOTCL] %s %s' %
|
||||||
@@ -2205,10 +2208,12 @@ class FCCopy(FCShapeTool):
|
|||||||
|
|
||||||
def make(self):
|
def make(self):
|
||||||
# Create new geometry
|
# Create new geometry
|
||||||
dx = self.destination[0] - self.origin[0]
|
# when doing circular array we remove the last geometry item in the list because it is the temp_line
|
||||||
dy = self.destination[1] - self.origin[1]
|
if self.copy_tool.ui.mode_radio.get_value() == 'a' and \
|
||||||
self.geometry = [DrawToolShape(translate(geom.geo, xoff=dx, yoff=dy))
|
self.copy_tool.ui.array_type_radio.get_value() == 'circular':
|
||||||
for geom in self.draw_app.get_selected()]
|
del self.util_geo.geo[-1]
|
||||||
|
self.geometry = [DrawToolShape(deepcopy(shp)) for shp in self.util_geo.geo]
|
||||||
|
|
||||||
self.complete = True
|
self.complete = True
|
||||||
self.origin = None
|
self.origin = None
|
||||||
self.draw_cursor_data(delete=True)
|
self.draw_cursor_data(delete=True)
|
||||||
@@ -2263,15 +2268,17 @@ class FCCopy(FCShapeTool):
|
|||||||
self.draw_app.select_tool('select')
|
self.draw_app.select_tool('select')
|
||||||
self.draw_app.selected = []
|
self.draw_app.selected = []
|
||||||
return
|
return
|
||||||
return DrawToolUtilityShape(geo_list)
|
self.util_geo = DrawToolUtilityShape(geo_list)
|
||||||
else:
|
else:
|
||||||
return self.array_util_geometry((dx, dy))
|
self.util_geo = 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)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
ss_el = None
|
ss_el = None
|
||||||
return DrawToolUtilityShape(ss_el)
|
self.util_geo = DrawToolUtilityShape(ss_el)
|
||||||
|
|
||||||
|
return self.util_geo
|
||||||
|
|
||||||
def array_util_geometry(self, pos, static=None):
|
def array_util_geometry(self, pos, static=None):
|
||||||
axis = self.copy_tool.ui.axis_radio.get_value() # X, Y or A
|
axis = self.copy_tool.ui.axis_radio.get_value() # X, Y or A
|
||||||
@@ -2308,6 +2315,8 @@ class FCCopy(FCShapeTool):
|
|||||||
geo_list.append(g.geo)
|
geo_list.append(g.geo)
|
||||||
|
|
||||||
return DrawToolUtilityShape(geo_list)
|
return DrawToolUtilityShape(geo_list)
|
||||||
|
elif array_type == '2D':
|
||||||
|
pass
|
||||||
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
|
||||||
@@ -2335,9 +2344,6 @@ class FCCopy(FCShapeTool):
|
|||||||
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
|
|
||||||
# temp_points = [x for x in self.points]
|
|
||||||
# temp_points.append((cdx, cdy))
|
|
||||||
temp_points = [
|
temp_points = [
|
||||||
(self.origin[0], self.origin[1]),
|
(self.origin[0], self.origin[1]),
|
||||||
(self.origin[0]+pos[0], self.origin[1]+pos[1])
|
(self.origin[0]+pos[0], self.origin[1]+pos[1])
|
||||||
@@ -2352,34 +2358,25 @@ class FCCopy(FCShapeTool):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
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, ini_angle):
|
||||||
direction = self.copy_tool.ui.array_dir_radio.get_value() # CW or CCW
|
direction = self.copy_tool.ui.array_dir_radio.get_value() # CW or CCW
|
||||||
if angle is None:
|
|
||||||
angle = self.copy_tool.ui.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 = []
|
||||||
if direction == 'CW':
|
|
||||||
for i in range(array_size):
|
for i in range(array_size):
|
||||||
angle_radians = math.radians(angle * i)
|
angle_radians = math.radians(angle * i)
|
||||||
x = self.origin[0] + radius * math.cos(-angle_radians + angle)
|
if direction == 'CW':
|
||||||
y = self.origin[1] + radius * math.sin(-angle_radians + angle)
|
x = radius * math.cos(-angle_radians + ini_angle)
|
||||||
|
y = radius * math.sin(-angle_radians + ini_angle)
|
||||||
|
else:
|
||||||
|
x = radius * math.cos(angle_radians + ini_angle)
|
||||||
|
y = radius * math.sin(angle_radians + ini_angle)
|
||||||
|
|
||||||
for shape in self.draw_app.get_selected():
|
for shape in self.draw_app.get_selected():
|
||||||
geo_sol = translate(shape.geo, x, y)
|
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))
|
|
||||||
else:
|
|
||||||
for i in range(array_size):
|
|
||||||
angle_radians = math.radians(angle * i)
|
|
||||||
x = self.origin[0] + radius * math.cos(angle_radians + angle)
|
|
||||||
y = self.origin[1] + radius * math.sin(angle_radians + angle)
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
circular_geo.append(DrawToolShape(geo_sol))
|
circular_geo.append(DrawToolShape(geo_sol))
|
||||||
|
|
||||||
return circular_geo
|
return circular_geo
|
||||||
@@ -4706,6 +4703,7 @@ class AppGeoEditor(QtCore.QObject):
|
|||||||
return 'fail'
|
return 'fail'
|
||||||
|
|
||||||
# Add shape
|
# Add shape
|
||||||
|
|
||||||
self.add_shape(geom_list)
|
self.add_shape(geom_list)
|
||||||
|
|
||||||
# Remove any utility shapes
|
# Remove any utility shapes
|
||||||
|
|||||||
Reference in New Issue
Block a user