- fixed Excellon object move and all the other transformations
This commit is contained in:
parent
85ff3805ae
commit
90ff773546
|
@ -12,6 +12,7 @@ CAD program, and create G-Code for Isolation routing.
|
||||||
4.03.2019
|
4.03.2019
|
||||||
|
|
||||||
- finished work on object hovering
|
- finished work on object hovering
|
||||||
|
- fixed Excellon object move and all the other transformations
|
||||||
|
|
||||||
3.03.2019
|
3.03.2019
|
||||||
|
|
||||||
|
|
85
camlib.py
85
camlib.py
|
@ -3721,7 +3721,6 @@ class Excellon(Geometry):
|
||||||
headerless = True
|
headerless = True
|
||||||
try:
|
try:
|
||||||
self.convert_units({"INCH": "IN", "METRIC": "MM"}[self.excellon_units])
|
self.convert_units({"INCH": "IN", "METRIC": "MM"}[self.excellon_units])
|
||||||
print("Units converted .............................. %s" % self.excellon_units)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.warning("Units could not be converted: %s" % str(e))
|
log.warning("Units could not be converted: %s" % str(e))
|
||||||
|
|
||||||
|
@ -4427,10 +4426,24 @@ class Excellon(Geometry):
|
||||||
else:
|
else:
|
||||||
px, py = point
|
px, py = point
|
||||||
|
|
||||||
|
def scale_geom(obj):
|
||||||
|
if type(obj) is list:
|
||||||
|
new_obj = []
|
||||||
|
for g in obj:
|
||||||
|
new_obj.append(scale_geom(g))
|
||||||
|
return new_obj
|
||||||
|
else:
|
||||||
|
return affinity.scale(obj, xfactor,
|
||||||
|
yfactor, origin=(px, py))
|
||||||
|
|
||||||
# Drills
|
# Drills
|
||||||
for drill in self.drills:
|
for drill in self.drills:
|
||||||
drill['point'] = affinity.scale(drill['point'], xfactor, yfactor, origin=(px, py))
|
drill['point'] = affinity.scale(drill['point'], xfactor, yfactor, origin=(px, py))
|
||||||
|
|
||||||
|
# scale solid_geometry
|
||||||
|
for tool in self.tools:
|
||||||
|
self.tools[tool]['solid_geometry'] = scale_geom(self.tools[tool]['solid_geometry'])
|
||||||
|
|
||||||
# Slots
|
# Slots
|
||||||
for slot in self.slots:
|
for slot in self.slots:
|
||||||
slot['stop'] = affinity.scale(slot['stop'], xfactor, yfactor, origin=(px, py))
|
slot['stop'] = affinity.scale(slot['stop'], xfactor, yfactor, origin=(px, py))
|
||||||
|
@ -4449,14 +4462,22 @@ class Excellon(Geometry):
|
||||||
|
|
||||||
dx, dy = vect
|
dx, dy = vect
|
||||||
|
|
||||||
|
def offset_geom(obj):
|
||||||
|
if type(obj) is list:
|
||||||
|
new_obj = []
|
||||||
|
for g in obj:
|
||||||
|
new_obj.append(offset_geom(g))
|
||||||
|
return new_obj
|
||||||
|
else:
|
||||||
|
return affinity.translate(obj, xoff=dx, yoff=dy)
|
||||||
|
|
||||||
# Drills
|
# Drills
|
||||||
for drill in self.drills:
|
for drill in self.drills:
|
||||||
drill['point'] = affinity.translate(drill['point'], xoff=dx, yoff=dy)
|
drill['point'] = affinity.translate(drill['point'], xoff=dx, yoff=dy)
|
||||||
|
|
||||||
# offset solid_geometry
|
# offset solid_geometry
|
||||||
for tool in self.tools:
|
for tool in self.tools:
|
||||||
for geo in self.tools[tool]['solid_geometry']:
|
self.tools[tool]['solid_geometry'] = offset_geom(self.tools[tool]['solid_geometry'])
|
||||||
geo = affinity.translate(geo, xoff=dx, yoff=dy)
|
|
||||||
|
|
||||||
# Slots
|
# Slots
|
||||||
for slot in self.slots:
|
for slot in self.slots:
|
||||||
|
@ -4478,11 +4499,24 @@ class Excellon(Geometry):
|
||||||
px, py = point
|
px, py = point
|
||||||
xscale, yscale = {"X": (1.0, -1.0), "Y": (-1.0, 1.0)}[axis]
|
xscale, yscale = {"X": (1.0, -1.0), "Y": (-1.0, 1.0)}[axis]
|
||||||
|
|
||||||
|
def mirror_geom(obj):
|
||||||
|
if type(obj) is list:
|
||||||
|
new_obj = []
|
||||||
|
for g in obj:
|
||||||
|
new_obj.append(mirror_geom(g))
|
||||||
|
return new_obj
|
||||||
|
else:
|
||||||
|
return affinity.scale(obj, xscale, yscale, origin=(px, py))
|
||||||
|
|
||||||
# Modify data
|
# Modify data
|
||||||
# Drills
|
# Drills
|
||||||
for drill in self.drills:
|
for drill in self.drills:
|
||||||
drill['point'] = affinity.scale(drill['point'], xscale, yscale, origin=(px, py))
|
drill['point'] = affinity.scale(drill['point'], xscale, yscale, origin=(px, py))
|
||||||
|
|
||||||
|
# mirror solid_geometry
|
||||||
|
for tool in self.tools:
|
||||||
|
self.tools[tool]['solid_geometry'] = mirror_geom(self.tools[tool]['solid_geometry'])
|
||||||
|
|
||||||
# Slots
|
# Slots
|
||||||
for slot in self.slots:
|
for slot in self.slots:
|
||||||
slot['stop'] = affinity.scale(slot['stop'], xscale, yscale, origin=(px, py))
|
slot['stop'] = affinity.scale(slot['stop'], xscale, yscale, origin=(px, py))
|
||||||
|
@ -4512,16 +4546,30 @@ class Excellon(Geometry):
|
||||||
if angle_y is None:
|
if angle_y is None:
|
||||||
angle_y = 0.0
|
angle_y = 0.0
|
||||||
|
|
||||||
|
def skew_geom(obj):
|
||||||
|
if type(obj) is list:
|
||||||
|
new_obj = []
|
||||||
|
for g in obj:
|
||||||
|
new_obj.append(skew_geom(g))
|
||||||
|
return new_obj
|
||||||
|
else:
|
||||||
|
return affinity.skew(obj, angle_x, angle_y, origin=(px, py))
|
||||||
|
|
||||||
if point is None:
|
if point is None:
|
||||||
|
px, py = 0, 0
|
||||||
|
|
||||||
# Drills
|
# Drills
|
||||||
for drill in self.drills:
|
for drill in self.drills:
|
||||||
drill['point'] = affinity.skew(drill['point'], angle_x, angle_y,
|
drill['point'] = affinity.skew(drill['point'], angle_x, angle_y,
|
||||||
origin=(0, 0))
|
origin=(px, py))
|
||||||
|
# skew solid_geometry
|
||||||
|
for tool in self.tools:
|
||||||
|
self.tools[tool]['solid_geometry'] = skew_geom(self.tools[tool]['solid_geometry'])
|
||||||
|
|
||||||
# Slots
|
# Slots
|
||||||
for slot in self.slots:
|
for slot in self.slots:
|
||||||
slot['stop'] = affinity.skew(slot['stop'], angle_x, angle_y, origin=(0, 0))
|
slot['stop'] = affinity.skew(slot['stop'], angle_x, angle_y, origin=(px, py))
|
||||||
slot['start'] = affinity.skew(slot['start'], angle_x, angle_y, origin=(0, 0))
|
slot['start'] = affinity.skew(slot['start'], angle_x, angle_y, origin=(px, py))
|
||||||
else:
|
else:
|
||||||
px, py = point
|
px, py = point
|
||||||
# Drills
|
# Drills
|
||||||
|
@ -4529,6 +4577,10 @@ class Excellon(Geometry):
|
||||||
drill['point'] = affinity.skew(drill['point'], angle_x, angle_y,
|
drill['point'] = affinity.skew(drill['point'], angle_x, angle_y,
|
||||||
origin=(px, py))
|
origin=(px, py))
|
||||||
|
|
||||||
|
# skew solid_geometry
|
||||||
|
for tool in self.tools:
|
||||||
|
self.tools[tool]['solid_geometry'] = skew_geom( self.tools[tool]['solid_geometry'])
|
||||||
|
|
||||||
# Slots
|
# Slots
|
||||||
for slot in self.slots:
|
for slot in self.slots:
|
||||||
slot['stop'] = affinity.skew(slot['stop'], angle_x, angle_y, origin=(px, py))
|
slot['stop'] = affinity.skew(slot['stop'], angle_x, angle_y, origin=(px, py))
|
||||||
|
@ -4543,11 +4595,28 @@ class Excellon(Geometry):
|
||||||
:param point: tuple of coordinates (x, y)
|
:param point: tuple of coordinates (x, y)
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def rotate_geom(obj, origin=None):
|
||||||
|
if type(obj) is list:
|
||||||
|
new_obj = []
|
||||||
|
for g in obj:
|
||||||
|
new_obj.append(rotate_geom(g))
|
||||||
|
return new_obj
|
||||||
|
else:
|
||||||
|
if origin:
|
||||||
|
return affinity.rotate(obj, angle, origin=origin)
|
||||||
|
else:
|
||||||
|
return affinity.rotate(obj, angle, origin=(px, py))
|
||||||
|
|
||||||
if point is None:
|
if point is None:
|
||||||
# Drills
|
# Drills
|
||||||
for drill in self.drills:
|
for drill in self.drills:
|
||||||
drill['point'] = affinity.rotate(drill['point'], angle, origin='center')
|
drill['point'] = affinity.rotate(drill['point'], angle, origin='center')
|
||||||
|
|
||||||
|
# rotate solid_geometry
|
||||||
|
for tool in self.tools:
|
||||||
|
self.tools[tool]['solid_geometry'] = rotate_geom(self.tools[tool]['solid_geometry'], origin='center')
|
||||||
|
|
||||||
# Slots
|
# Slots
|
||||||
for slot in self.slots:
|
for slot in self.slots:
|
||||||
slot['stop'] = affinity.rotate(slot['stop'], angle, origin='center')
|
slot['stop'] = affinity.rotate(slot['stop'], angle, origin='center')
|
||||||
|
@ -4558,6 +4627,10 @@ class Excellon(Geometry):
|
||||||
for drill in self.drills:
|
for drill in self.drills:
|
||||||
drill['point'] = affinity.rotate(drill['point'], angle, origin=(px, py))
|
drill['point'] = affinity.rotate(drill['point'], angle, origin=(px, py))
|
||||||
|
|
||||||
|
# rotate solid_geometry
|
||||||
|
for tool in self.tools:
|
||||||
|
self.tools[tool]['solid_geometry'] = rotate_geom(self.tools[tool]['solid_geometry'])
|
||||||
|
|
||||||
# Slots
|
# Slots
|
||||||
for slot in self.slots:
|
for slot in self.slots:
|
||||||
slot['stop'] = affinity.rotate(slot['stop'], angle, origin=(px, py))
|
slot['stop'] = affinity.rotate(slot['stop'], angle, origin=(px, py))
|
||||||
|
|
|
@ -125,7 +125,11 @@ class ToolMove(FlatCAMTool):
|
||||||
# offset
|
# offset
|
||||||
sel_obj.offset((dx, dy))
|
sel_obj.offset((dx, dy))
|
||||||
sel_obj.plot()
|
sel_obj.plot()
|
||||||
sel_obj.replotApertures.emit()
|
|
||||||
|
try:
|
||||||
|
sel_obj.replotApertures.emit()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
# Update the object bounding box options
|
# Update the object bounding box options
|
||||||
a,b,c,d = sel_obj.bounds()
|
a,b,c,d = sel_obj.bounds()
|
||||||
|
|
Loading…
Reference in New Issue