- corrected some issues and made Move Tool to show correctly when it is moving and when it is offsetting the objects position

This commit is contained in:
Marius Stanciu 2019-09-07 18:41:48 +03:00 committed by Marius
parent 4cbb5846e3
commit 97024ed643
6 changed files with 77 additions and 34 deletions

View File

@ -1398,6 +1398,8 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
cw_row = cw_index.row()
except AttributeError:
cw_row = 0
except TypeError:
return
self.marked_rows[:] = []
@ -5195,9 +5197,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
except AttributeError:
self.solid_geometry = []
return
self.app.inform.emit(_(
"[success] Geometry Scale done."
))
self.app.proc_container.new_text = ''
self.app.inform.emit('[success] %s' % _("Geometry Scale done."))
def offset(self, vect):
"""
@ -5266,7 +5268,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.el_count = 0
self.solid_geometry = translate_recursion(self.solid_geometry)
self.app.inform.emit(_("[success] Geometry Offset done."))
self.app.proc_container.new_text = ''
self.app.inform.emit('[success] %s' % _("Geometry Offset done."))
def convert_units(self, units):
log.debug("FlatCAMObj.FlatCAMGeometry.convert_units()")

View File

@ -162,9 +162,9 @@ class FCVisibleProcessContainer(QtCore.QObject, FCProcessContainer):
def update_view(self):
if len(self.procs) == 0:
self.new_text = ''
self.view.set_idle()
self.idle_flag.emit()
self.new_text = ''
elif len(self.procs) == 1:
self.view.set_busy(self.text_to_display_in_activity + self.new_text)
@ -175,4 +175,4 @@ class FCVisibleProcessContainer(QtCore.QObject, FCProcessContainer):
# this has to be called after the method 'new' inherited by this class is called with a string text as param
self.new_text = new_text
if len(self.procs) == 1:
self.view.set_busy(self.text_to_display_in_activity + self.new_text)
self.view.set_busy(self.text_to_display_in_activity + self.new_text, no_movie=True)

View File

@ -18,6 +18,7 @@ CAD program, and create G-Code for Isolation routing.
- added new feature in the Gerber object isolation allowing for the isolation to avoid an area defined by another object (Gerber or Geometry)
- all transformation functions show now the progress (rotate, mirror, scale, offset, skew)
- made threaded the Offset and Scale operations found in the Selected tab of the object
- corrected some issues and made Move Tool to show correctly when it is moving and when it is offsetting the objects position
6.09.2019

View File

@ -1453,6 +1453,8 @@ class Geometry(object):
except AttributeError:
self.app.inform.emit(_("[ERROR_NOTCL] Failed to mirror. No object selected"))
self.app.proc_container.new_text = ''
def rotate(self, angle, point):
"""
Rotate an object by an angle (in degrees) around the provided coordinates.
@ -1521,6 +1523,8 @@ class Geometry(object):
except AttributeError:
self.app.inform.emit(_("[ERROR_NOTCL] Failed to rotate. No object selected"))
self.app.proc_container.new_text = ''
def skew(self, angle_x, angle_y, point):
"""
Shear/Skew the geometries of an object by angles along x and y dimensions.
@ -1588,6 +1592,8 @@ class Geometry(object):
except AttributeError:
self.app.inform.emit(_("[ERROR_NOTCL] Failed to skew. No object selected"))
self.app.proc_container.new_text = ''
# if type(self.solid_geometry) == list:
# self.solid_geometry = [affinity.skew(g, angle_x, angle_y, origin=(px, py))
# for g in self.solid_geometry]
@ -3469,7 +3475,8 @@ class Gerber (Geometry):
try:
xfactor = float(xfactor)
except:
self.app.inform.emit(_("[ERROR_NOTCL] Scale factor has to be a number: integer or float."))
self.app.inform.emit('[ERROR_NOTCL] %s' %
_("Scale factor has to be a number: integer or float."))
return
if yfactor is None:
@ -3478,7 +3485,8 @@ class Gerber (Geometry):
try:
yfactor = float(yfactor)
except:
self.app.inform.emit(_("[ERROR_NOTCL] Scale factor has to be a number: integer or float."))
self.app.inform.emit('[ERROR_NOTCL] %s' %
_("Scale factor has to be a number: integer or float."))
return
if point is None:
@ -3535,7 +3543,8 @@ class Gerber (Geometry):
log.debug('camlib.Gerber.scale() Exception --> %s' % str(e))
return 'fail'
self.app.inform.emit(_("[success] Gerber Scale done."))
self.app.inform.emit('[success] %s' % _("Gerber Scale done."))
self.app.proc_container.new_text = ''
# ## solid_geometry ???
# It's a cascaded union of objects.
@ -3569,8 +3578,9 @@ class Gerber (Geometry):
try:
dx, dy = vect
except TypeError:
self.app.inform.emit(_("[ERROR_NOTCL] An (x,y) pair of values are needed. "
"Probable you entered only one value in the Offset field."))
self.app.inform.emit('[ERROR_NOTCL] %s' %
_("An (x,y) pair of values are needed. "
"Probable you entered only one value in the Offset field."))
return
# variables to display the percentage of work done
@ -3622,7 +3632,8 @@ class Gerber (Geometry):
log.debug('camlib.Gerber.offset() Exception --> %s' % str(e))
return 'fail'
self.app.inform.emit(_("[success] Gerber Offset done."))
self.app.inform.emit('[success] %s' % _("Gerber Offset done."))
self.app.proc_container.new_text = ''
def mirror(self, axis, point):
"""
@ -3697,7 +3708,8 @@ class Gerber (Geometry):
log.debug('camlib.Gerber.mirror() Exception --> %s' % str(e))
return 'fail'
self.app.inform.emit(_("[success] Gerber Mirror done."))
self.app.inform.emit('[success] %s' % _("Gerber Mirror done."))
self.app.proc_container.new_text = ''
def skew(self, angle_x, angle_y, point):
"""
@ -3764,7 +3776,8 @@ class Gerber (Geometry):
log.debug('camlib.Gerber.skew() Exception --> %s' % str(e))
return 'fail'
self.app.inform.emit(_("[success] Gerber Skew done."))
self.app.inform.emit('[success] %s' % _("Gerber Skew done."))
self.app.proc_container.new_text = ''
def rotate(self, angle, point):
"""
@ -3823,7 +3836,8 @@ class Gerber (Geometry):
except Exception as e:
log.debug('camlib.Gerber.rotate() Exception --> %s' % str(e))
return 'fail'
self.app.inform.emit(_("[success] Gerber Rotate done."))
self.app.inform.emit('[success] %s' % _("Gerber Rotate done."))
self.app.proc_container.new_text = ''
class Excellon(Geometry):
@ -4948,6 +4962,7 @@ class Excellon(Geometry):
slot['start'] = affinity.scale(slot['start'], xfactor, yfactor, origin=(px, py))
self.create_geometry()
self.app.proc_container.new_text = ''
def offset(self, vect):
"""
@ -5004,6 +5019,7 @@ class Excellon(Geometry):
# Recreate geometry
self.create_geometry()
self.app.proc_container.new_text = ''
def mirror(self, axis, point):
"""
@ -5064,6 +5080,7 @@ class Excellon(Geometry):
# Recreate geometry
self.create_geometry()
self.app.proc_container.new_text = ''
def skew(self, angle_x=None, angle_y=None, point=None):
"""
@ -5155,6 +5172,7 @@ class Excellon(Geometry):
slot['start'] = affinity.skew(slot['start'], angle_x, angle_y, origin=(px, py))
self.create_geometry()
self.app.proc_container.new_text = ''
def rotate(self, angle, point=None):
"""
@ -5234,6 +5252,7 @@ class Excellon(Geometry):
slot['start'] = affinity.rotate(slot['start'], angle, origin=(px, py))
self.create_geometry()
self.app.proc_container.new_text = ''
class AttrDict(dict):
@ -7911,6 +7930,7 @@ class CNCjob(Geometry):
v['solid_geometry'] = cascaded_union([geo['geom'] for geo in v['gcode_parsed']])
self.create_geometry()
self.app.proc_container.new_text = ''
def offset(self, vect):
"""
@ -8021,6 +8041,8 @@ class CNCjob(Geometry):
# for the bounding box
v['solid_geometry'] = cascaded_union([geo['geom'] for geo in v['gcode_parsed']])
self.app.proc_container.new_text = ''
def mirror(self, axis, point):
"""
Mirror the geometrys of an object by an given axis around the coordinates of the 'point'
@ -8056,6 +8078,7 @@ class CNCjob(Geometry):
self.old_disp_number = disp_number
self.create_geometry()
self.app.proc_container.new_text = ''
def skew(self, angle_x, angle_y, point):
"""
@ -8099,6 +8122,7 @@ class CNCjob(Geometry):
self.old_disp_number = disp_number
self.create_geometry()
self.app.proc_container.new_text = ''
def rotate(self, angle, point):
"""
@ -8134,6 +8158,7 @@ class CNCjob(Geometry):
self.old_disp_number = disp_number
self.create_geometry()
self.app.proc_container.new_text = ''
def get_bounds(geometry_list):

View File

@ -7655,8 +7655,9 @@ class FlatCAMActivityView(QtWidgets.QWidget):
self.movie.stop()
self.text.setText(_("Idle."))
def set_busy(self, msg):
self.movie.start()
def set_busy(self, msg, no_movie=None):
if no_movie is not True:
self.movie.start()
self.text.setText(msg)

View File

@ -24,6 +24,7 @@ if '_' not in builtins.__dict__:
class ToolMove(FlatCAMTool):
toolName = _("Move")
replot_signal = pyqtSignal(list)
def __init__(self, app):
FlatCAMTool.__init__(self, app)
@ -45,6 +46,8 @@ class ToolMove(FlatCAMTool):
# VisPy visuals
self.sel_shapes = ShapeCollection(parent=self.app.plotcanvas.view.scene, layers=1)
self.replot_signal[list].connect(self.replot)
def install(self, icon=None, separator=None, **kwargs):
FlatCAMTool.install(self, icon, separator, shortcut='M', **kwargs)
@ -125,21 +128,20 @@ class ToolMove(FlatCAMTool):
dx = pos[0] - self.point1[0]
dy = pos[1] - self.point1[1]
proc = self.app.proc_container.new(_("Moving ..."))
obj_list = self.app.collection.get_selected()
def job_move(app_obj):
obj_list = self.app.collection.get_selected()
with self.app.proc_container.new(_("Moving...")) as proc:
try:
if not obj_list:
self.app.inform.emit('[WARNING_NOTCL] %s' % _("No object(s) selected."))
return "fail"
try:
if not obj_list:
self.app.inform.emit('[WARNING_NOTCL] %s' % _("No object(s) selected."))
return "fail"
else:
for sel_obj in obj_list:
# offset solid_geometry
sel_obj.offset((dx, dy))
sel_obj.plot()
# sel_obj.plot()
try:
sel_obj.replotApertures.emit()
@ -152,18 +154,19 @@ class ToolMove(FlatCAMTool):
sel_obj.options['ymin'] = b
sel_obj.options['xmax'] = c
sel_obj.options['ymax'] = d
# self.app.collection.set_active(sel_obj.options['name'])
except Exception as e:
proc.done()
self.app.inform.emit('[ERROR_NOTCL] %s --> %s' % (_('ToolMove.on_left_click()'), str(e)))
return "fail"
# time to plot the moved objects
self.replot_signal.emit(obj_list)
except Exception as e:
proc.done()
self.app.inform.emit('[ERROR_NOTCL] %s --> %s' % (_('ToolMove.on_left_click()'), str(e)))
return "fail"
proc.done()
# delete the selection bounding box
self.delete_shape()
self.app.inform.emit('[success] %s %s' % (str(sel_obj.kind).capitalize(),
_('object was moved ...')
)
)
self.app.inform.emit('[success] %s %s' %
(str(sel_obj.kind).capitalize(), 'object was moved ...'))
self.app.worker_task.emit({'fcn': job_move, 'params': [self]})
@ -178,6 +181,15 @@ class ToolMove(FlatCAMTool):
self.clicked_move = 1
def replot(self, obj_list):
def worker_task():
with self.app.proc_container.new(_("Plotting...")):
for sel_obj in obj_list:
sel_obj.plot()
self.app.worker_task.emit({'fcn': worker_task, 'params': []})
def on_move(self, event):
pos_canvas = self.app.plotcanvas.translate_coords(event.pos)