- 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

View File

@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
=================================================
31.01.2020
- 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.
30.01.2020
- remade GUI in Tool Cutout, Tool Align Objects, Tool Panelize

View File

@ -371,6 +371,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menuedit.addSeparator()
self.menueditorigin = self.menuedit.addAction(
QtGui.QIcon(self.app.resource_location + '/origin16.png'), _('Se&t Origin\tO'))
self.menuedit_move2origin = self.menuedit.addAction(
QtGui.QIcon(self.app.resource_location + '/origin2_16.png'), _('Move to Origin\tSHIFT+O'))
self.menueditjump = self.menuedit.addAction(
QtGui.QIcon(self.app.resource_location + '/jump_to16.png'), _('Jump to Location\tJ'))
self.menueditlocate = self.menuedit.addAction(
@ -841,6 +844,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
QtGui.QIcon(self.app.resource_location + '/distance_min32.png'), _("Distance Min Tool"))
self.origin_btn = self.toolbargeo.addAction(
QtGui.QIcon(self.app.resource_location + '/origin32.png'), _('Set Origin'))
self.move2origin_btn = self.toolbargeo.addAction(
QtGui.QIcon(self.app.resource_location + '/origin2_32.png'), _('Move to Origin'))
self.jmp_btn = self.toolbargeo.addAction(
QtGui.QIcon(self.app.resource_location + '/jump_to16.png'), _('Jump to Location'))
self.locate_btn = self.toolbargeo.addAction(

Binary file not shown.

Before

Width:  |  Height:  |  Size: 563 B

After

Width:  |  Height:  |  Size: 523 B

BIN
share/origin2_16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

BIN
share/origin2_32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 750 B

After

Width:  |  Height:  |  Size: 808 B