- added a new functionality, a variation of Set Origin named Move to Origin. It will move a selection of objects to origin such as the bottom left corner of the bounding box that fit them all is in origin.

This commit is contained in:
Marius Stanciu
2020-01-31 22:34:20 +02:00
committed by Marius
parent ece94b7f60
commit 0b162bbd55
7 changed files with 62 additions and 1 deletions

View File

@@ -1974,6 +1974,8 @@ class App(QtCore.QObject):
self.ui.menueditconvert_any2gerber.triggered.connect(self.convert_any2gerber)
self.ui.menueditorigin.triggered.connect(self.on_set_origin)
self.ui.menuedit_move2origin.triggered.connect(self.on_move2origin)
self.ui.menueditjump.triggered.connect(self.on_jump_to)
self.ui.menueditlocate.triggered.connect(lambda: self.on_locate(obj=self.collection.get_active()))
@@ -3267,6 +3269,8 @@ class App(QtCore.QObject):
self.ui.distance_btn.triggered.connect(lambda: self.distance_tool.run(toggle=True))
self.ui.distance_min_btn.triggered.connect(lambda: self.distance_min_tool.run(toggle=True))
self.ui.origin_btn.triggered.connect(self.on_set_origin)
self.ui.move2origin_btn.triggered.connect(self.on_move2origin)
self.ui.jmp_btn.triggered.connect(self.on_jump_to)
self.ui.locate_btn.triggered.connect(lambda: self.on_locate(obj=self.collection.get_active()))
@@ -7275,7 +7279,7 @@ class App(QtCore.QObject):
event_pos = (event.xdata, event.ydata)
pos_canvas = self.plotcanvas.translate_coords(event_pos)
if self.grid_status() == True:
if self.grid_status():
pos = self.geo_editor.snap(pos_canvas[0], pos_canvas[1])
else:
pos = pos_canvas
@@ -7289,6 +7293,53 @@ class App(QtCore.QObject):
worker_task()
self.should_we_save = True
def on_move2origin(self, use_thread=True):
"""
:param event:
:param location:
:param noplot:
:param use_thread:
:return:
"""
def worker_task():
with self.proc_container.new(_("Moving to Origin...")):
obj_list = self.collection.get_selected()
xminlist = list()
yminlist = list()
# first get a bounding box to fit all
for obj in obj_list:
xmin, ymin, xmax, ymax = obj.bounds()
xminlist.append(xmin)
yminlist.append(ymin)
# get the minimum x,y for all objects selected
x = min(xminlist)
y = min(yminlist)
for obj in obj_list:
obj.offset((-x, -y))
self.object_changed.emit(obj)
# Update the object bounding box options
a, b, c, d = obj.bounds()
obj.options['xmin'] = a
obj.options['ymin'] = b
obj.options['xmax'] = c
obj.options['ymax'] = d
for obj in obj_list:
obj.plot()
self.inform.emit('[success] %s...' % _('Origin set'))
if use_thread is True:
self.worker_task.emit({'fcn': worker_task, 'params': []})
else:
worker_task()
self.should_we_save = True
def on_jump_to(self, custom_location=None, fit_center=True):
"""
Jump to a location by setting the mouse cursor location