- optimized the Move Tool
- added support for key-based panning in 3D graphic engine. Moving the mouse wheel while pressing the CTRL key will pan up-down and while pressing SHIFT key will pan left-right
This commit is contained in:
@@ -97,12 +97,16 @@ class ToolMove(FlatCAMTool):
|
||||
sel_obj_list = self.app.collection.get_selected()
|
||||
if sel_obj_list:
|
||||
self.app.inform.emit(_("MOVE: Click on the Start point ..."))
|
||||
|
||||
# if we have an object selected then we can safely activate the mouse events
|
||||
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)
|
||||
|
||||
# draw the selection box
|
||||
self.draw_sel_bbox(obj_list=sel_obj_list)
|
||||
self.draw_sel_bbox()
|
||||
else:
|
||||
self.setVisible(False)
|
||||
# signal that there is no command active
|
||||
self.app.command_active = None
|
||||
self.toggle()
|
||||
self.app.inform.emit('[WARNING_NOTCL] %s' % _("MOVE action cancelled. No object(s) to move."))
|
||||
|
||||
def on_left_click(self, event):
|
||||
@@ -148,8 +152,9 @@ class ToolMove(FlatCAMTool):
|
||||
dx = pos[0] - self.point1[0]
|
||||
dy = pos[1] - self.point1[1]
|
||||
|
||||
# move only the objects selected and plotted
|
||||
obj_list = [obj for obj in self.app.collection.get_selected() if obj.options['plot']]
|
||||
# move only the objects selected and plotted and visible
|
||||
obj_list = [obj for obj in self.app.collection.get_selected()
|
||||
if obj.options['plot'] and obj.visible is True]
|
||||
|
||||
def job_move(app_obj):
|
||||
with self.app.proc_container.new(_("Moving...")) as proc:
|
||||
@@ -254,47 +259,40 @@ class ToolMove(FlatCAMTool):
|
||||
self.toggle()
|
||||
return
|
||||
|
||||
def draw_sel_bbox(self, obj_list):
|
||||
def draw_sel_bbox(self):
|
||||
xminlist = []
|
||||
yminlist = []
|
||||
xmaxlist = []
|
||||
ymaxlist = []
|
||||
|
||||
if not obj_list:
|
||||
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Object(s) not selected"))
|
||||
self.toggle()
|
||||
else:
|
||||
# if we have an object selected then we can safely activate the mouse events
|
||||
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)
|
||||
obj_list = self.app.collection.get_selected()
|
||||
|
||||
# first get a bounding box to fit all
|
||||
for obj in obj_list:
|
||||
# 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)
|
||||
# first get a bounding box to fit all
|
||||
for obj in obj_list:
|
||||
# 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)
|
||||
yminimal = min(yminlist)
|
||||
xmaximal = max(xmaxlist)
|
||||
ymaximal = max(ymaxlist)
|
||||
# get the minimum x,y and maximum x,y for all objects selected
|
||||
xminimal = min(xminlist)
|
||||
yminimal = min(yminlist)
|
||||
xmaximal = max(xmaxlist)
|
||||
ymaximal = max(ymaxlist)
|
||||
|
||||
p1 = (xminimal, yminimal)
|
||||
p2 = (xmaximal, yminimal)
|
||||
p3 = (xmaximal, ymaximal)
|
||||
p4 = (xminimal, ymaximal)
|
||||
p1 = (xminimal, yminimal)
|
||||
p2 = (xmaximal, yminimal)
|
||||
p3 = (xmaximal, ymaximal)
|
||||
p4 = (xminimal, ymaximal)
|
||||
|
||||
self.old_coords = [p1, p2, p3, p4]
|
||||
self.draw_shape(Polygon(self.old_coords))
|
||||
self.old_coords = [p1, p2, p3, p4]
|
||||
self.draw_shape(Polygon(self.old_coords))
|
||||
|
||||
if self.app.is_legacy is True:
|
||||
self.sel_shapes.redraw()
|
||||
if self.app.is_legacy is True:
|
||||
self.sel_shapes.redraw()
|
||||
|
||||
def update_sel_bbox(self, pos):
|
||||
self.delete_shape()
|
||||
|
||||
Reference in New Issue
Block a user