|
|
@@ -2456,8 +2456,10 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
row_to_be_selected = int(key) - 1
|
|
|
self.last_tool_selected = int(key)
|
|
|
break
|
|
|
-
|
|
|
- self.tools_table_exc.selectRow(row_to_be_selected)
|
|
|
+ try:
|
|
|
+ self.tools_table_exc.selectRow(row_to_be_selected)
|
|
|
+ except TypeError as e:
|
|
|
+ log.debug("FlatCAMExcEditor.on_tool_add() --> %s" % str(e))
|
|
|
|
|
|
def on_tool_delete(self, dia=None):
|
|
|
self.is_modified = True
|
|
|
@@ -2928,6 +2930,11 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
|
|
|
self.select_tool("drill_select")
|
|
|
|
|
|
+ # reset the tool table
|
|
|
+ self.tools_table_exc.clear()
|
|
|
+ self.tools_table_exc.setHorizontalHeaderLabels(['#', _('Diameter'), 'D', 'S'])
|
|
|
+ self.last_tool_selected = None
|
|
|
+
|
|
|
self.set_ui()
|
|
|
|
|
|
# now that we hava data, create the GUI interface and add it to the Tool Tab
|
|
|
@@ -3078,6 +3085,7 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
# element[1] of the tuple is a list of coordinates (a tuple themselves)
|
|
|
ordered_edited_points = sorted(zip(edited_points.keys(), edited_points.values()))
|
|
|
|
|
|
+
|
|
|
current_tool = 0
|
|
|
for tool_dia in ordered_edited_points:
|
|
|
current_tool += 1
|
|
|
@@ -3146,26 +3154,13 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
self.edited_obj_name += "_1"
|
|
|
else:
|
|
|
self.edited_obj_name += "_edit"
|
|
|
-
|
|
|
- self.app.worker_task.emit({'fcn': self.new_edited_excellon,
|
|
|
- 'params': [self.edited_obj_name]})
|
|
|
-
|
|
|
self.new_tool_offset = self.exc_obj.tool_offset
|
|
|
|
|
|
- # reset the tool table
|
|
|
- self.tools_table_exc.clear()
|
|
|
- self.tools_table_exc.setHorizontalHeaderLabels(['#', _('Diameter'), 'D', 'S'])
|
|
|
- self.last_tool_selected = None
|
|
|
-
|
|
|
- # delete the edited Excellon object which will be replaced by a new one having the edited content of the first
|
|
|
- # self.app.collection.set_active(self.exc_obj.options['name'])
|
|
|
- # self.app.collection.delete_active()
|
|
|
-
|
|
|
- # restore GUI to the Selected TAB
|
|
|
- # Remove anything else in the GUI
|
|
|
- self.app.ui.tool_scroll_area.takeWidget()
|
|
|
- # Switch notebook to Selected page
|
|
|
- self.app.ui.notebook.setCurrentWidget(self.app.ui.selected_tab)
|
|
|
+ self.app.worker_task.emit({'fcn': self.new_edited_excellon,
|
|
|
+ 'params': [self.edited_obj_name,
|
|
|
+ self.new_drills,
|
|
|
+ self.new_slots,
|
|
|
+ self.new_tools]})
|
|
|
|
|
|
def update_options(self, obj):
|
|
|
try:
|
|
|
@@ -3182,7 +3177,7 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
obj.options = {}
|
|
|
return True
|
|
|
|
|
|
- def new_edited_excellon(self, outname):
|
|
|
+ def new_edited_excellon(self, outname, n_drills, n_slots, n_tools):
|
|
|
"""
|
|
|
Creates a new Excellon object for the edited Excellon. Thread-safe.
|
|
|
|
|
|
@@ -3195,12 +3190,17 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
self.app.log.debug("Update the Excellon object with edited content. Source is %s" %
|
|
|
self.exc_obj.options['name'])
|
|
|
|
|
|
+ new_drills = n_drills
|
|
|
+ new_slots = n_slots
|
|
|
+ new_tools = n_tools
|
|
|
+
|
|
|
# How the object should be initialized
|
|
|
def obj_init(excellon_obj, app_obj):
|
|
|
+
|
|
|
# self.progress.emit(20)
|
|
|
- excellon_obj.drills = self.new_drills
|
|
|
- excellon_obj.tools = self.new_tools
|
|
|
- excellon_obj.slots = self.new_slots
|
|
|
+ excellon_obj.drills = deepcopy(new_drills)
|
|
|
+ excellon_obj.tools = deepcopy(new_tools)
|
|
|
+ excellon_obj.slots = deepcopy(new_slots)
|
|
|
excellon_obj.tool_offset = self.new_tool_offset
|
|
|
excellon_obj.options['name'] = outname
|
|
|
|
|
|
@@ -3217,15 +3217,17 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
app_obj.inform.emit(msg)
|
|
|
raise
|
|
|
# raise
|
|
|
- excellon_obj.source_file = self.app.export_excellon(obj_name=outname, filename=None,
|
|
|
- local_use=excellon_obj, use_thread=False)
|
|
|
|
|
|
with self.app.proc_container.new(_("Creating Excellon.")):
|
|
|
|
|
|
try:
|
|
|
- self.app.new_object("excellon", outname, obj_init)
|
|
|
+ edited_obj = self.app.new_object("excellon", outname, obj_init)
|
|
|
+ edited_obj.source_file = self.app.export_excellon(obj_name=edited_obj.options['name'],
|
|
|
+ local_use=edited_obj,
|
|
|
+ filename=None,
|
|
|
+ use_thread=False)
|
|
|
except Exception as e:
|
|
|
- log.error("Error on object creation: %s" % str(e))
|
|
|
+ log.error("Error on Edited object creation: %s" % str(e))
|
|
|
self.app.progress.emit(100)
|
|
|
return
|
|
|
|
|
|
@@ -3307,20 +3309,28 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
:param event: Event object dispatched by VisPy
|
|
|
:return: None
|
|
|
"""
|
|
|
+ if self.app.is_legacy is False:
|
|
|
+ event_pos = event.pos
|
|
|
+ event_is_dragging = event.is_dragging
|
|
|
+ right_button = 2
|
|
|
+ else:
|
|
|
+ event_pos = (event.xdata, event.ydata)
|
|
|
+ event_is_dragging = self.app.plotcanvas.is_dragging
|
|
|
+ right_button = 3
|
|
|
|
|
|
- self.pos = self.canvas.translate_coords(event.pos)
|
|
|
+ self.pos = self.canvas.translate_coords(event_pos)
|
|
|
|
|
|
if self.app.grid_status() == True:
|
|
|
self.pos = self.app.geo_editor.snap(self.pos[0], self.pos[1])
|
|
|
else:
|
|
|
self.pos = (self.pos[0], self.pos[1])
|
|
|
|
|
|
- if event.button is 1:
|
|
|
+ if event.button == 1:
|
|
|
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
|
|
"%.4f " % (0, 0))
|
|
|
|
|
|
# Selection with left mouse button
|
|
|
- if self.active_tool is not None and event.button is 1:
|
|
|
+ if self.active_tool is not None and event.button == 1:
|
|
|
# Dispatch event to active_tool
|
|
|
# msg = self.active_tool.click(self.app.geo_editor.snap(event.xdata, event.ydata))
|
|
|
self.active_tool.click(self.app.geo_editor.snap(self.pos[0], self.pos[1]))
|
|
|
@@ -3338,6 +3348,7 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
modifier_to_use = Qt.ControlModifier
|
|
|
else:
|
|
|
modifier_to_use = Qt.ShiftModifier
|
|
|
+
|
|
|
# if modifier key is pressed then we add to the selected list the current shape but if it's already
|
|
|
# in the selected list, we removed it. Therefore first click selects, second deselects.
|
|
|
if key_modifier == modifier_to_use:
|
|
|
@@ -3442,7 +3453,17 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
:param event: Event object dispatched by VisPy SceneCavas
|
|
|
:return: None
|
|
|
"""
|
|
|
- pos_canvas = self.canvas.translate_coords(event.pos)
|
|
|
+
|
|
|
+ if self.app.is_legacy is False:
|
|
|
+ event_pos = event.pos
|
|
|
+ event_is_dragging = event.is_dragging
|
|
|
+ right_button = 2
|
|
|
+ else:
|
|
|
+ event_pos = (event.xdata, event.ydata)
|
|
|
+ event_is_dragging = self.app.plotcanvas.is_dragging
|
|
|
+ right_button = 3
|
|
|
+
|
|
|
+ pos_canvas = self.canvas.translate_coords(event_pos)
|
|
|
|
|
|
if self.app.grid_status() == True:
|
|
|
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
|
|
|
@@ -3452,7 +3473,7 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
# if the released mouse button was RMB then test if it was a panning motion or not, if not it was a context
|
|
|
# canvas menu
|
|
|
try:
|
|
|
- if event.button == 2: # right click
|
|
|
+ if event.button == right_button: # right click
|
|
|
if self.app.ui.popMenu.mouse_is_panning is False:
|
|
|
try:
|
|
|
QtGui.QGuiApplication.restoreOverrideCursor()
|
|
|
@@ -3600,7 +3621,16 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
:return: None
|
|
|
"""
|
|
|
|
|
|
- pos = self.canvas.translate_coords(event.pos)
|
|
|
+ if self.app.is_legacy is False:
|
|
|
+ event_pos = event.pos
|
|
|
+ event_is_dragging = event.is_dragging
|
|
|
+ right_button = 2
|
|
|
+ else:
|
|
|
+ event_pos = (event.xdata, event.ydata)
|
|
|
+ event_is_dragging = self.app.plotcanvas.is_dragging
|
|
|
+ right_button = 3
|
|
|
+
|
|
|
+ pos = self.canvas.translate_coords(event_pos)
|
|
|
event.xdata, event.ydata = pos[0], pos[1]
|
|
|
|
|
|
self.x = event.xdata
|
|
|
@@ -3609,7 +3639,7 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
self.app.ui.popMenu.mouse_is_panning = False
|
|
|
|
|
|
# if the RMB is clicked and mouse is moving over plot then 'panning_action' is True
|
|
|
- if event.button == 2 and event.is_dragging == 1:
|
|
|
+ if event.button == right_button and event_is_dragging == 1:
|
|
|
self.app.ui.popMenu.mouse_is_panning = True
|
|
|
return
|
|
|
|
|
|
@@ -3625,8 +3655,9 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
# ## Snap coordinates
|
|
|
if self.app.grid_status() == True:
|
|
|
x, y = self.app.geo_editor.snap(x, y)
|
|
|
- # Update cursor
|
|
|
- self.app.app_cursor.set_data(np.asarray([(x, y)]), symbol='++', edge_color='black', size=20)
|
|
|
+ if self.app.is_legacy is False:
|
|
|
+ # Update cursor
|
|
|
+ self.app.app_cursor.set_data(np.asarray([(x, y)]), symbol='++', edge_color='black', size=20)
|
|
|
|
|
|
self.snap_x = x
|
|
|
self.snap_y = y
|
|
|
@@ -3653,7 +3684,7 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
self.draw_utility_geometry(geo=geo)
|
|
|
|
|
|
# ## Selection area on canvas section # ##
|
|
|
- if event.is_dragging == 1 and event.button == 1:
|
|
|
+ if event_is_dragging == 1 and event.button == 1:
|
|
|
# I make an exception for FCDrillAdd and FCDrillArray because clicking and dragging while making regions
|
|
|
# can create strange issues. Also for FCSlot and FCSlotArray
|
|
|
if isinstance(self.active_tool, FCDrillAdd) or isinstance(self.active_tool, FCDrillArray) or \
|
|
|
@@ -3673,8 +3704,9 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
else:
|
|
|
self.app.selection_type = None
|
|
|
|
|
|
- # Update cursor
|
|
|
- self.app.app_cursor.set_data(np.asarray([(x, y)]), symbol='++', edge_color='black', size=20)
|
|
|
+ if self.app.is_legacy is False:
|
|
|
+ # Update cursor
|
|
|
+ self.app.app_cursor.set_data(np.asarray([(x, y)]), symbol='++', edge_color='black', size=20)
|
|
|
|
|
|
def on_canvas_key_release(self, event):
|
|
|
self.key = None
|
|
|
@@ -3735,10 +3767,10 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
continue
|
|
|
|
|
|
if shape_plus in self.selected:
|
|
|
- self.plot_shape(geometry=shape_plus.geo, color=self.app.defaults['global_sel_draw_color'],
|
|
|
+ self.plot_shape(geometry=shape_plus.geo, color=self.app.defaults['global_sel_draw_color'] + 'FF',
|
|
|
linewidth=2)
|
|
|
continue
|
|
|
- self.plot_shape(geometry=shape_plus.geo, color=self.app.defaults['global_draw_color'])
|
|
|
+ self.plot_shape(geometry=shape_plus.geo, color=self.app.defaults['global_draw_color'] + 'FF')
|
|
|
|
|
|
# for shape in self.storage.get_objects():
|
|
|
# if shape.geo is None: # TODO: This shouldn't have happened
|
|
|
@@ -3756,7 +3788,7 @@ class FlatCAMExcEditor(QtCore.QObject):
|
|
|
|
|
|
self.shapes.redraw()
|
|
|
|
|
|
- def plot_shape(self, geometry=None, color='black', linewidth=1):
|
|
|
+ def plot_shape(self, geometry=None, color='0x000000FF', linewidth=1):
|
|
|
"""
|
|
|
Plots a geometric object or list of objects without rendering. Plotted objects
|
|
|
are returned as a list. This allows for efficient/animated rendering.
|