diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 697978a7..14a05111 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -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 diff --git a/README.md b/README.md index 92b79cb6..c537aaf9 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/flatcamGUI/FlatCAMGUI.py b/flatcamGUI/FlatCAMGUI.py index e7a4bc68..b67b4c0e 100644 --- a/flatcamGUI/FlatCAMGUI.py +++ b/flatcamGUI/FlatCAMGUI.py @@ -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( diff --git a/share/origin16.png b/share/origin16.png index e9fa7940..2c0374d8 100644 Binary files a/share/origin16.png and b/share/origin16.png differ diff --git a/share/origin2_16.png b/share/origin2_16.png new file mode 100644 index 00000000..0940f28b Binary files /dev/null and b/share/origin2_16.png differ diff --git a/share/origin2_32.png b/share/origin2_32.png new file mode 100644 index 00000000..b4c6c721 Binary files /dev/null and b/share/origin2_32.png differ diff --git a/share/origin32.png b/share/origin32.png index 20228f57..f208af48 100644 Binary files a/share/origin32.png and b/share/origin32.png differ