Skip to content

Commit d7c14ff

Browse files
committed
qtdragon -fix recording of main tab splitter position
It didn't record the splitter setting on mode changes. Also added cycling of the split in auto mode by hitting the main tab button
1 parent a60dd88 commit d7c14ff

1 file changed

Lines changed: 69 additions & 32 deletions

File tree

share/qtvcp/screens/qtdragon/qtdragon_handler.py

Lines changed: 69 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def __init__(self, halcomp, widgets, paths):
8686
self.reload_tool = 0
8787
self.last_loaded_program = ""
8888
self.first_turnon = True
89+
self._maintab_cycle = 1
8990
self.lineedit_list = ["work_height", "touch_height", "sensor_height", "laser_x", "laser_y",
9091
"sensor_x", "sensor_y", "camera_x", "camera_y",
9192
"search_vel", "probe_vel", "max_probe", "eoffset_count"]
@@ -612,6 +613,8 @@ def main_tab_changed(self, btn):
612613
elif index == self.w.stackedWidget_mainTab.currentIndex():
613614
self.w.stackedWidget_dro.setCurrentIndex(0)
614615

616+
if index == TAB_MAIN and STATUS.is_auto_mode():
617+
self._maintab_cycle +=1
615618
if index is None: return
616619

617620
# adjust the stack widgets depending on modes
@@ -1099,13 +1102,15 @@ def add_status(self, message, alertLevel = DEFAULT):
10991102
def enable_auto(self, state):
11001103
for widget in self.auto_list:
11011104
self.w[widget].setEnabled(state)
1105+
# need to let adjust stack function know the mode changed
1106+
# not auto
11021107
if state is True:
1103-
if self.w.stackedWidget_mainTab.currentIndex() != TAB_SETUP:
1104-
self.adjust_stacked_widgets(self.w.stackedWidget_mainTab.currentIndex())
1108+
self.adjust_stacked_widgets(self.w.stackedWidget_mainTab.currentIndex(),mode_change = True)
1109+
# auto mode
11051110
else:
1106-
if self.w.stackedWidget_mainTab.currentIndex() != TAB_PROBE:
1107-
self.w.btn_main.setChecked(True)
1108-
self.adjust_stacked_widgets(TAB_MAIN)
1111+
self.w.btn_main.setChecked(True)
1112+
self.adjust_stacked_widgets(TAB_MAIN,mode_change = True)
1113+
11091114

11101115
def enable_onoff(self, state):
11111116
if state:
@@ -1217,41 +1222,44 @@ def set_style_critical(self):
12171222
self.w.lineEdit_statusbar.setStyleSheet("background-color: rgb(255, 144, 0);color: rgb(0,0,0)") #orange
12181223
self.endcolor()
12191224

1220-
def adjust_stacked_widgets(self,requestedIndex):
1225+
def adjust_stacked_widgets(self,requestedIndex,mode_change=False):
12211226
IGNORE = -1
12221227
SHOW_DRO = 0
1223-
premode = ['','','Auto','MDI'][STATUS.get_previous_mode()]
12241228
mode = ['','','Auto','MDI'][STATUS.get_current_mode()]
1229+
if mode_change:
1230+
premode = ['','','Auto','MDI'][STATUS.get_previous_mode()]
1231+
else:
1232+
premode=mode
12251233
currentIndex = self.w.stackedWidget_mainTab.currentIndex()
12261234
indexList = ['main','file','offsets','tool','status','probe','cam',
12271235
'gcode','setup','settings','util','user']
12281236

12291237
if mode == 'Auto':
1230-
seq = {TAB_MAIN: (TAB_MAIN,PAGE_GCODE,False,SHOW_DRO),
1231-
TAB_FILE: (TAB_MAIN,PAGE_GCODE,False,SHOW_DRO),
1232-
TAB_OFFSETS: (TAB_MAIN,PAGE_GCODE,False,SHOW_DRO),
1233-
TAB_TOOL: (TAB_MAIN,PAGE_GCODE,False,SHOW_DRO),
1234-
TAB_STATUS: (requestedIndex,PAGE_GCODE,False,SHOW_DRO),
1235-
TAB_PROBE: (TAB_MAIN,PAGE_GCODE,False,SHOW_DRO),
1236-
TAB_CAMERA: (requestedIndex,PAGE_UNCHANGED,False,SHOW_DRO),
1237-
TAB_GCODES: (requestedIndex,PAGE_UNCHANGED,False,SHOW_DRO),
1238-
TAB_SETUP: (requestedIndex,PAGE_UNCHANGED,False,SHOW_DRO),
1239-
TAB_SETTINGS: (requestedIndex,PAGE_GCODE,False,SHOW_DRO),
1240-
TAB_UTILITIES: (TAB_MAIN,PAGE_GCODE,False,SHOW_DRO),
1241-
TAB_USER: (requestedIndex,PAGE_UNCHANGED,IGNORE,IGNORE) }
1238+
seq = {TAB_MAIN: (TAB_MAIN,PAGE_GCODE,False,SHOW_DRO,False),
1239+
TAB_FILE: (TAB_MAIN,PAGE_GCODE,False,SHOW_DRO,False),
1240+
TAB_OFFSETS: (TAB_MAIN,PAGE_GCODE,False,SHOW_DRO,False),
1241+
TAB_TOOL: (TAB_MAIN,PAGE_GCODE,False,SHOW_DRO,False),
1242+
TAB_STATUS: (requestedIndex,PAGE_GCODE,False,SHOW_DRO,False),
1243+
TAB_PROBE: (TAB_MAIN,PAGE_GCODE,False,SHOW_DRO,False),
1244+
TAB_CAMERA: (requestedIndex,PAGE_UNCHANGED,False,SHOW_DRO,False),
1245+
TAB_GCODES: (requestedIndex,PAGE_UNCHANGED,False,SHOW_DRO,False),
1246+
TAB_SETUP: (requestedIndex,PAGE_UNCHANGED,False,SHOW_DRO,False),
1247+
TAB_SETTINGS: (requestedIndex,PAGE_GCODE,False,SHOW_DRO,False),
1248+
TAB_UTILITIES: (TAB_MAIN,PAGE_GCODE,False,SHOW_DRO,False),
1249+
TAB_USER: (requestedIndex,PAGE_UNCHANGED,IGNORE,IGNORE,False) }
12421250
else:
1243-
seq = {TAB_MAIN: (requestedIndex,PAGE_GCODE,True,SHOW_DRO),
1244-
TAB_FILE: (requestedIndex,PAGE_FILE,True,IGNORE),
1245-
TAB_OFFSETS: (requestedIndex,PAGE_OFFSET,True,IGNORE),
1246-
TAB_TOOL: (requestedIndex,PAGE_TOOL,True,IGNORE),
1247-
TAB_STATUS: (requestedIndex,PAGE_UNCHANGED,True,SHOW_DRO),
1248-
TAB_PROBE: (requestedIndex,PAGE_GCODE,True,SHOW_DRO),
1249-
TAB_CAMERA: (requestedIndex,PAGE_UNCHANGED,True,IGNORE),
1250-
TAB_GCODES: (requestedIndex,PAGE_UNCHANGED,False,SHOW_DRO),
1251-
TAB_SETUP: (requestedIndex,PAGE_UNCHANGED,False,IGNORE),
1252-
TAB_SETTINGS: (requestedIndex,PAGE_UNCHANGED,False,SHOW_DRO),
1253-
TAB_UTILITIES: (requestedIndex,PAGE_UNCHANGED,True,SHOW_DRO),
1254-
TAB_USER: (requestedIndex,PAGE_UNCHANGED,IGNORE,IGNORE) }
1251+
seq = {TAB_MAIN: (requestedIndex,PAGE_GCODE,True,SHOW_DRO,True),
1252+
TAB_FILE: (requestedIndex,PAGE_FILE,True,IGNORE,True),
1253+
TAB_OFFSETS: (requestedIndex,PAGE_OFFSET,True,IGNORE,True),
1254+
TAB_TOOL: (requestedIndex,PAGE_TOOL,True,IGNORE,True),
1255+
TAB_STATUS: (requestedIndex,PAGE_UNCHANGED,True,SHOW_DRO,True),
1256+
TAB_PROBE: (requestedIndex,PAGE_GCODE,True,SHOW_DRO,True),
1257+
TAB_CAMERA: (requestedIndex,PAGE_UNCHANGED,True,IGNORE,True),
1258+
TAB_GCODES: (requestedIndex,PAGE_UNCHANGED,False,SHOW_DRO,True),
1259+
TAB_SETUP: (requestedIndex,PAGE_UNCHANGED,False,IGNORE,True),
1260+
TAB_SETTINGS: (requestedIndex,PAGE_UNCHANGED,False,SHOW_DRO,True),
1261+
TAB_UTILITIES: (requestedIndex,PAGE_UNCHANGED,True,SHOW_DRO,True),
1262+
TAB_USER: (requestedIndex,PAGE_UNCHANGED,IGNORE,IGNORE,True) }
12551263

12561264
rtn = seq.get(requestedIndex)
12571265

@@ -1261,8 +1269,9 @@ def adjust_stacked_widgets(self,requestedIndex):
12611269
stacked_index = 0
12621270
show_JogControls = True
12631271
show_dro = 0
1272+
show_macro = True
12641273
else:
1265-
main_index,stacked_index,show_JogControls,show_dro = rtn
1274+
main_index,stacked_index,show_JogControls,show_dro,show_macro = rtn
12661275

12671276
# user tab button covers multiple tabs so adjust name
12681277
# for extra user tabs
@@ -1289,6 +1298,12 @@ def adjust_stacked_widgets(self,requestedIndex):
12891298
if show_dro > IGNORE:
12901299
self.w.stackedWidget_dro.setCurrentIndex(0)
12911300

1301+
# macros can only be run in manual or mdi mode
1302+
if show_macro:
1303+
self.w.frame_macro_buttons.show()
1304+
else:
1305+
self.w.frame_macro_buttons.hide()
1306+
12921307
# show ngcgui info tab if utilities tab is selected
12931308
# but only if the utilities tab has ngcgui selected
12941309
if main_index == TAB_UTILITIES:
@@ -1334,6 +1349,28 @@ def adjust_stacked_widgets(self,requestedIndex):
13341349
tabId = 'user{}'.format(cur - len(indexList))
13351350
else:
13361351
tabId = indexList[cur]
1352+
1353+
# if in auto mode and the main tab button is pressed
1354+
# cycle between full gcode, split and pull graphics
1355+
if main_index == TAB_MAIN and mode =='Auto':
1356+
if self._maintab_cycle >3: self._maintab_cycle = 1
1357+
if self._maintab_cycle == 2:
1358+
self.w.frame_top_left.hide()
1359+
self.w.frm_backplot.show()
1360+
return
1361+
elif self._maintab_cycle == 3:
1362+
self.w.frame_top_left.show()
1363+
self.w.frm_backplot.hide()
1364+
return
1365+
else:
1366+
self.w.frame_top_left.show()
1367+
self.w.frm_backplot.show()
1368+
else:
1369+
self.w.frame_top_left.show()
1370+
self.w.frm_backplot.show()
1371+
1372+
# adjust window splitter size as per saved adjustments
1373+
13371374
name = 'splitterSettings-{}{}'.format(tabId,mode)
13381375
#print ('NOW:',name)
13391376
# restore new qsplitter setting

0 commit comments

Comments
 (0)