From 0b162bbd550480ab1f821b8ed3e2039bb754ee6d Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 31 Jan 2020 22:34:20 +0200 Subject: [PATCH] - 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. --- FlatCAMApp.py | 53 ++++++++++++++++++++++++++++++++++++++- README.md | 4 +++ flatcamGUI/FlatCAMGUI.py | 6 +++++ share/origin16.png | Bin 563 -> 523 bytes share/origin2_16.png | Bin 0 -> 516 bytes share/origin2_32.png | Bin 0 -> 763 bytes share/origin32.png | Bin 750 -> 808 bytes 7 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 share/origin2_16.png create mode 100644 share/origin2_32.png 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 e9fa79406da44f822d269ff5fb394d930e69e6f5..2c0374d81eff13a16666d3c0b0ea8613f1256f30 100644 GIT binary patch delta 330 zcmdnY(#Uk%e0^&Pnj1(?MmAHP`LMrGbVrA|NToPRY~-0xYeIYhb8rY#3r_VP$A&WoWK#U|?lnaO~g|ugMn~ Q#c;`QpQH0_G82;_0Ivau(f|Me delta 394 zcmeBX*~~Jbv;Hv`Kc~7??D^Ts3=E8no-U3d8s|eV9Mo=%f!bFzq{^VBq-`HFfwC;(L9@oidAKq=ZVBfX zyk5~Pp>1~OG)IlrjuPSNSL*vSXYcrMV{%YutGV;MyWhO)*UmTLpX(<3l!1XkwZt`| zBqgyV)hf9t6-Y4{85mmX8XD*tnuZuyS{YkfnObNYm{=JYM71u+M$wR)pOTqYiCcsA P4T^mT`@Tw0nS*ukeH=5SChz^rkFqry!mryOl1A=xW6NsSswZ*H7h`|Rvo^Y8A) zZf?Fx8GDk_{f^EKS??qq&b0f-m&eBzy)03hoRHS$@~*V#R>l2rs z3`zXD-gd(FV?0m3y$;p4IjtogG*eyw?6+gjoUDHY?bw!cpGj$Y#hUE$#l`RJADF2I zu90RdP`(kYX@0Ff!0JFw`|R3^BB@GB&j`FxECOure@Mzj$R0 ziiX_$l+3hB+#2rv6FdOaAPKS|I6tkVJh3R1p}f3YFEcN@I61K(RWH9NefB#WDWD<- MPgg&ebxsLQ0J@~H`Tzg` literal 0 HcmV?d00001 diff --git a/share/origin2_32.png b/share/origin2_32.png new file mode 100644 index 0000000000000000000000000000000000000000..b4c6c721ec72937a194949c4e7fe30cb7a7b35ec GIT binary patch literal 763 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10f+@+{-GzZ+Rj;xUkjGiz z5n0T@z;^_M8K-LVNdpDhOFVsD*`F}V3n}S#UirYrz`%IY)5S5wrB1dO zla*`NUR%QFRk^MII(ujOuYI52*?zzG`QGg}rE zWqXe4&)B?l;i@G|RwV{IYQ+^@suew*=lMD)WXgoH+g)8vDa*gq<>#C>ncv-Y_VW^1 z?_Z03-fUm;Xi{sy$4cc@YlR#ejptS7AG)sm`*+eIcJ70YO-$eCOb+dr`M7)yWBK8^ z>siw54{Ug7rng$=o9i>3@}eD`p+C!tPM^KOWNa3_a!OlCPNO3)^Z%gmn)em@d=mp~ zcPQW8@oK*6AF)vSi6MQJ1ja>+G8*m@8o~JZ~Fh( zzrRk~2ZS;f>^zP+QeKTvVc)%0_7s_nQE zkG$)>A$^7;d6UA#2H|6^lDtz_pZAD$beo>YEynYDievwklBIfXt*bK(Ra^G#QB}Oy zBKOeq=ZizdTTXa>wbGb)wShiPH{uU?NxQ*{6TwruD>{NSm_V*Lgw{XR{Y<*ht=j%&)aXmp6#}}YA62f z`$O-C{~BC3m)&@|x^hqP!ip)$tWjR6Wt*Mk=W(@n8(E~B6nMw&e*OG|$*gN74lh;u zlN#N#@alQdjEQpGk+*%l=f+=lY~SN@%rmim!58l>oXHld=@)rRg*p%Coj#p;%=@9w z&JMShye%_CJ_S`O`eYp|OHDkQh#UmS+O7Af3Y6kxpgv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