From bd5dd2f68ec3d0be80efa830e4c972b69cf3b150 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Thu, 10 Oct 2019 19:33:30 +0300 Subject: [PATCH] - fixed Tool Move to work only for objects that are selected but also plotted, therefore disabled objects will not be moved even if selected --- README.md | 1 + flatcamTools/ToolMove.py | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4a8e0491..71f4e6c4 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ CAD program, and create G-Code for Isolation routing. - made FCDoubleSpinner to use either comma or dot as a decimal separator - fixed the FCDoubleSpinner to only allow the amount of decimals already set with set_precision() - fixed ToolPanelize to use FCDoubleSpinner in some places +- fixed Tool Move to work only for objects that are selected but also plotted, therefore disabled objects will not be moved even if selected 8.10.2019 diff --git a/flatcamTools/ToolMove.py b/flatcamTools/ToolMove.py index a9c36a2b..72d14e4d 100644 --- a/flatcamTools/ToolMove.py +++ b/flatcamTools/ToolMove.py @@ -50,6 +50,10 @@ class ToolMove(FlatCAMTool): from flatcamGUI.PlotCanvasLegacy import ShapeCollectionLegacy self.sel_shapes = ShapeCollectionLegacy(obj=self, app=self.app, name="move") + self.mm = None + self.mp = None + self.kr = None + self.replot_signal[list].connect(self.replot) def install(self, icon=None, separator=None, **kwargs): @@ -90,10 +94,11 @@ class ToolMove(FlatCAMTool): # signal that there is a command active and it is 'Move' self.app.command_active = "Move" - if self.app.collection.get_selected(): + sel_obj_list = self.app.collection.get_selected() + if sel_obj_list: self.app.inform.emit(_("MOVE: Click on the Start point ...")) # draw the selection box - self.draw_sel_bbox() + self.draw_sel_bbox(obj_list=sel_obj_list) else: self.setVisible(False) # signal that there is no command active @@ -143,7 +148,8 @@ class ToolMove(FlatCAMTool): dx = pos[0] - self.point1[0] dy = pos[1] - self.point1[1] - obj_list = self.app.collection.get_selected() + # move only the objects selected and plotted + obj_list = [obj for obj in self.app.collection.get_selected() if obj.options['plot']] def job_move(app_obj): with self.app.proc_container.new(_("Moving...")) as proc: @@ -248,13 +254,12 @@ class ToolMove(FlatCAMTool): self.toggle() return - def draw_sel_bbox(self): + def draw_sel_bbox(self, obj_list): xminlist = [] yminlist = [] xmaxlist = [] ymaxlist = [] - obj_list = self.app.collection.get_selected() if not obj_list: self.app.inform.emit('[WARNING_NOTCL] %s' % _("Object(s) not selected")) self.toggle() @@ -263,13 +268,16 @@ class ToolMove(FlatCAMTool): self.mm = self.app.plotcanvas.graph_event_connect('mouse_move', self.on_move) self.mp = self.app.plotcanvas.graph_event_connect('mouse_press', self.on_left_click) self.kr = self.app.plotcanvas.graph_event_connect('key_release', self.on_key_press) + # 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) - xmaxlist.append(xmax) - ymaxlist.append(ymax) + # don't move disabled objects, move only plotted objects + if obj.options['plot']: + xmin, ymin, xmax, ymax = obj.bounds() + xminlist.append(xmin) + yminlist.append(ymin) + xmaxlist.append(xmax) + ymaxlist.append(ymax) # get the minimum x,y and maximum x,y for all objects selected xminimal = min(xminlist)