- fixed the Drillcncjob Tcl command by adding an custom self.options key "Tools_in_use" and build it's value, in case it does not exist, to make the toolchange command work

- middle mouse click on closable tabs will close them
This commit is contained in:
Marius Stanciu 2020-01-02 01:50:49 +02:00 committed by Marius
parent b5d69f493d
commit 84c8588f89
5 changed files with 68 additions and 19 deletions

View File

@ -339,13 +339,23 @@ class App(QtCore.QObject):
os.makedirs(self.preprocessorpaths) os.makedirs(self.preprocessorpaths)
App.log.debug('Created preprocessors folder: ' + self.preprocessorpaths) App.log.debug('Created preprocessors folder: ' + self.preprocessorpaths)
# create tools_db.FlatDB file if there is none # create geo_tools_db.FlatDB file if there is none
try: try:
f = open(self.data_path + '/tools_db.FlatDB') f = open(self.data_path + '/geo_tools_db.FlatDB')
f.close() f.close()
except IOError: except IOError:
App.log.debug('Creating empty tool_db.FlatDB') App.log.debug('Creating empty geo_tool_db.FlatDB')
f = open(self.data_path + '/tools_db.FlatDB', 'w') f = open(self.data_path + '/geo_tools_db.FlatDB', 'w')
json.dump({}, f)
f.close()
# create fctool_tools_db.FlatDB file if there is none
try:
f = open(self.data_path + '/fctool_tools_db.FlatDB')
f.close()
except IOError:
App.log.debug('Creating empty fctool_tool_db.FlatDB')
f = open(self.data_path + '/fctool_tools_db.FlatDB', 'w')
json.dump({}, f) json.dump({}, f)
f.close() f.close()
@ -956,13 +966,15 @@ class App(QtCore.QObject):
'Repetier, Roland_MDX_20, Users, Toolchange_Custom, Toolchange_Probe_MACH3, ' 'Repetier, Roland_MDX_20, Users, Toolchange_Custom, Toolchange_Probe_MACH3, '
'Toolchange_manual, Users, all, angle_x, angle_y, axis, auto, axisoffset, ' 'Toolchange_manual, Users, all, angle_x, angle_y, axis, auto, axisoffset, '
'box, center_x, center_y, columns, combine, connect, contour, default, ' 'box, center_x, center_y, columns, combine, connect, contour, default, '
'depthperpass, dia, diatol, dist, drilled_dias, drillz, dwell, dwelltime, ' 'depthperpass, dia, diatol, dist, drilled_dias, drillz, dwelltime, '
'extracut_length, '
'feedrate_z, grbl_11, grbl_laser, gridoffsety, gridx, gridy, has_offset, ' 'feedrate_z, grbl_11, grbl_laser, gridoffsety, gridx, gridy, has_offset, '
'holes, hpgl, iso_type, line_xyz, margin, marlin, method, milled_dias, ' 'holes, hpgl, iso_type, line_xyz, margin, marlin, method, milled_dias, '
'minoffset, multidepth, name, offset, opt_type, order, outname, overlap, ' 'minoffset, name, offset, opt_type, order, outname, overlap, '
'passes, postamble, pp, ppname_e, ppname_g, preamble, radius, ref, rest, ' 'passes, postamble, pp, ppname_e, ppname_g, preamble, radius, ref, rest, '
'rows, shellvar_, scale_factor, spacing_columns, spacing_rows, spindlespeed, ' 'rows, shellvar_, scale_factor, spacing_columns, spacing_rows, spindlespeed, '
'toolchange_xy, tooldia, use_threads, value, x, x0, x1, y, y0, y1, z_cut, ' 'toolchange_xy, toolchangez, '
'tooldia, use_threads, value, x, x0, x1, y, y0, y1, z_cut, '
'z_move', 'z_move',
"script_autocompleter": True, "script_autocompleter": True,
"script_text": "", "script_text": "",
@ -2188,14 +2200,16 @@ class App(QtCore.QObject):
'Toolchange_manual', 'Users', 'all', 'angle_x', 'angle_y', 'auto', 'axis', 'Toolchange_manual', 'Users', 'all', 'angle_x', 'angle_y', 'auto', 'axis',
'axisoffset', 'axisoffset',
'box', 'center_x', 'center_y', 'columns', 'combine', 'connect', 'contour', 'default', 'box', 'center_x', 'center_y', 'columns', 'combine', 'connect', 'contour', 'default',
'depthperpass', 'dia', 'diatol', 'dist', 'drilled_dias', 'drillz', 'dwell', 'depthperpass', 'dia', 'diatol', 'dist', 'drilled_dias', 'drillz',
'dwelltime', 'feedrate_z', 'grbl_11', 'grbl_laser', 'gridoffsety', 'gridx', 'gridy', 'dwelltime', 'extracut_length',
'feedrate_z', 'grbl_11', 'grbl_laser', 'gridoffsety', 'gridx', 'gridy',
'has_offset', 'holes', 'hpgl', 'iso_type', 'line_xyz', 'margin', 'marlin', 'method', 'has_offset', 'holes', 'hpgl', 'iso_type', 'line_xyz', 'margin', 'marlin', 'method',
'milled_dias', 'minoffset', 'multidepth', 'name', 'offset', 'opt_type', 'order', 'milled_dias', 'minoffset', 'name', 'offset', 'opt_type', 'order',
'outname', 'overlap', 'passes', 'postamble', 'pp', 'ppname_e', 'ppname_g', 'outname', 'overlap', 'passes', 'postamble', 'pp', 'ppname_e', 'ppname_g',
'preamble', 'radius', 'ref', 'rest', 'rows', 'shellvar_', 'scale_factor', 'preamble', 'radius', 'ref', 'rest', 'rows', 'shellvar_', 'scale_factor',
'spacing_columns', 'spacing_columns',
'spacing_rows', 'spindlespeed', 'toolchange_xy', 'tooldia', 'use_threads', 'value', 'spacing_rows', 'spindlespeed', 'toolchange_xy', 'toolchangez',
'tooldia', 'use_threads', 'value',
'x', 'x0', 'x1', 'y', 'y0', 'y1', 'z_cut', 'z_move' 'x', 'x0', 'x1', 'y', 'y0', 'y1', 'z_cut', 'z_move'
] ]

View File

@ -737,7 +737,7 @@ class ToolsDB(QtWidgets.QWidget):
"A position on Z plane to move immediately after job stop.")) "A position on Z plane to move immediately after job stop."))
def setup_db_ui(self): def setup_db_ui(self):
filename = self.app.data_path + '/tools_db.FlatDB' filename = self.app.data_path + '/geo_tools_db.FlatDB'
# load the database tools from the file # load the database tools from the file
try: try:
@ -1174,7 +1174,7 @@ class ToolsDB(QtWidgets.QWidget):
def on_save_tools_db(self, silent=False): def on_save_tools_db(self, silent=False):
self.app.log.debug("ToolsDB.on_save_button() --> Saving Tools Database to file.") self.app.log.debug("ToolsDB.on_save_button() --> Saving Tools Database to file.")
filename = self.app.data_path + "/tools_db.FlatDB" filename = self.app.data_path + "/geo_tools_db.FlatDB"
# Preferences save, update the color of the Tools DB Tab text # Preferences save, update the color of the Tools DB Tab text
for idx in range(self.app.ui.plot_tab_area.count()): for idx in range(self.app.ui.plot_tab_area.count()):

View File

@ -18,6 +18,8 @@ CAD program, and create G-Code for Isolation routing.
- modified the Drillcncjob and Cncjob Tcl commands to be allowed to work without the 'dwell' and 'toolchange' arguments. If 'dwelltime' argument is present it will be assumed that the 'dwell' is True and the same for 'toolchangez' parameter, if present then 'toolchange' will be assumed to be True, else False - modified the Drillcncjob and Cncjob Tcl commands to be allowed to work without the 'dwell' and 'toolchange' arguments. If 'dwelltime' argument is present it will be assumed that the 'dwell' is True and the same for 'toolchangez' parameter, if present then 'toolchange' will be assumed to be True, else False
- modified the extracut and multidepth parameters in Cncjob Tcl command like for dwell and toolchange - modified the extracut and multidepth parameters in Cncjob Tcl command like for dwell and toolchange
- added ability for Tcl commands to have optional arguments with None value (meaning missing value). This case should be treated for each Tcl command in execute() method - added ability for Tcl commands to have optional arguments with None value (meaning missing value). This case should be treated for each Tcl command in execute() method
- fixed the Drillcncjob Tcl command by adding an custom self.options key "Tools_in_use" and build it's value, in case it does not exist, to make the toolchange command work
- middle mouse click on closable tabs will close them
30.12.2019 30.12.2019

View File

@ -2415,11 +2415,8 @@ class CNCjob(Geometry):
must_visit.remove(nearest) must_visit.remove(nearest)
return path return path
def generate_from_excellon_by_tool( def generate_from_excellon_by_tool(self, exobj, tools="all", drillz = 3.0, toolchange=False, toolchangez=0.1,
self, exobj, tools="all", drillz = 3.0, toolchangexy='', endz=2.0, startz=None, excellon_optimization_type='B'):
toolchange=False, toolchangez=0.1, toolchangexy='',
endz=2.0, startz=None,
excellon_optimization_type='B'):
""" """
Creates gcode for this object from an Excellon object Creates gcode for this object from an Excellon object
for the specified tools. for the specified tools.
@ -2515,6 +2512,16 @@ class CNCjob(Geometry):
tools = [i for i, j in sorted_tools for k in selected_tools if i == k] tools = [i for i, j in sorted_tools for k in selected_tools if i == k]
log.debug("Tools selected and sorted are: %s" % str(tools)) log.debug("Tools selected and sorted are: %s" % str(tools))
# build a self.options['Tools_in_use'] list from scratch if we don't have one like in the case of
# running this method from a Tcl Command
build_tools_in_use_list = False
if 'Tools_in_use' not in self.options:
self.options['Tools_in_use'] = list()
# if the list is empty (either we just added the key or it was already there but empty) signal to build it
if not self.options['Tools_in_use']:
build_tools_in_use_list = True
# fill the data into the self.exc_cnc_tools dictionary # fill the data into the self.exc_cnc_tools dictionary
for it in sorted_tools: for it in sorted_tools:
for to_ol in tools: for to_ol in tools:
@ -2552,6 +2559,15 @@ class CNCjob(Geometry):
self.exc_cnc_tools[it[1]]['data'] = default_data self.exc_cnc_tools[it[1]]['data'] = default_data
self.exc_cnc_tools[it[1]]['solid_geometry'] = deepcopy(sol_geo) self.exc_cnc_tools[it[1]]['solid_geometry'] = deepcopy(sol_geo)
# build a self.options['Tools_in_use'] list from scratch if we don't have one like in the case of
# running this method from a Tcl Command
if build_tools_in_use_list is True:
self.options['Tools_in_use'].append(
[it[0], it[1], drill_no, slot_no]
)
print(self.options['Tools_in_use'])
self.app.inform.emit(_("Creating a list of points to drill...")) self.app.inform.emit(_("Creating a list of points to drill..."))
# Points (Group by tool) # Points (Group by tool)
points = dict() points = dict()

View File

@ -1263,6 +1263,8 @@ class FCDetachableTab(QtWidgets.QTabWidget):
self.tabBar = self.FCTabBar(self) self.tabBar = self.FCTabBar(self)
self.tabBar.onMoveTabSignal.connect(self.moveTab) self.tabBar.onMoveTabSignal.connect(self.moveTab)
self.tabBar.onCloseTabSignal.connect(self.on_closetab_middle_button)
self.tabBar.detachedTabDropSignal.connect(self.detachedTabDrop) self.tabBar.detachedTabDropSignal.connect(self.detachedTabDrop)
self.set_detachable(val=True) self.set_detachable(val=True)
@ -1351,6 +1353,17 @@ class FCDetachableTab(QtWidgets.QTabWidget):
self.removeTab(currentIndex) self.removeTab(currentIndex)
def on_closetab_middle_button(self, current_index):
"""
:param current_index:
:return:
"""
# if tab is protected don't delete it
if self.tabBar.tabButton(current_index, QtWidgets.QTabBar.RightSide) is not None:
self.removeTab(current_index)
def protectTab(self, currentIndex): def protectTab(self, currentIndex):
# self.FCTabBar().setTabButton(currentIndex, QtWidgets.QTabBar.RightSide, None) # self.FCTabBar().setTabButton(currentIndex, QtWidgets.QTabBar.RightSide, None)
self.tabBar.setTabButton(currentIndex, QtWidgets.QTabBar.RightSide, None) self.tabBar.setTabButton(currentIndex, QtWidgets.QTabBar.RightSide, None)
@ -1664,7 +1677,7 @@ class FCDetachableTab(QtWidgets.QTabWidget):
onDetachTabSignal = QtCore.pyqtSignal(int, QtCore.QPoint) onDetachTabSignal = QtCore.pyqtSignal(int, QtCore.QPoint)
onMoveTabSignal = QtCore.pyqtSignal(int, int) onMoveTabSignal = QtCore.pyqtSignal(int, int)
detachedTabDropSignal = QtCore.pyqtSignal(str, int, QtCore.QPoint) detachedTabDropSignal = QtCore.pyqtSignal(str, int, QtCore.QPoint)
onCloseTabSignal = QtCore.pyqtSignal(int)
right_click = QtCore.pyqtSignal(int) right_click = QtCore.pyqtSignal(int)
def __init__(self, parent=None): def __init__(self, parent=None):
@ -1724,6 +1737,10 @@ class FCDetachableTab(QtWidgets.QTabWidget):
""" """
if event.button() == QtCore.Qt.RightButton and self.prev_index == self.tabAt(event.pos()): if event.button() == QtCore.Qt.RightButton and self.prev_index == self.tabAt(event.pos()):
self.right_click.emit(self.prev_index) self.right_click.emit(self.prev_index)
if event.button() == QtCore.Qt.MiddleButton:
self.onCloseTabSignal.emit(int(self.tabAt(event.pos())))
self.prev_index = -1 self.prev_index = -1
QtWidgets.QTabBar.mouseReleaseEvent(self, event) QtWidgets.QTabBar.mouseReleaseEvent(self, event)