def export_study(study_name): # status bar status = squish.waitForObject(cvi42Objects.statusBar) # Searches for study, and exports squish.waitForObject(cvi42Objects.patientlistEditBox).setText(study_name) squish.openContextMenu( squish.waitForObjectItem(cvi42Objects.studyTreeitem, study_name), 50, 5, 0) squish.activateItem( squish.waitForObjectItem(cvi42Objects.contextMenu, "Export Study")) # export dialog flow squish.mouseClick( squish.waitForObjectItem(":splitter.sidebar_QSidebar", "My Computer"), 53, 13, 0, squish.Qt.LeftButton) squish.mouseClick( squish.waitForObjectItem(":stackedWidget.treeView_QTreeView", "DATA (D:)"), 33, 14, 0, squish.Qt.LeftButton) squish.doubleClick( squish.waitForObjectItem(":stackedWidget.treeView_QTreeView", "DATA (D:)"), 34, 11, 0, squish.Qt.LeftButton) squish.clickButton(squish.waitForObject(":dcmBrowser.Choose_QPushButton")) start = time.time() while True: if status.currentMessage() == "Export Images done": break else: pass end = time.time() test.log("Time to export study: %.2f" % (end - start))
def save_workspace(workspace_name): # Grabs the status bar object to check current message status = squish.waitForObject(cvi42Objects.statusBar) # Saves workspace as name given squish.activateItem( squish.waitForObjectItem(cvi42Objects.menuBar, "Workspace")) squish.activateItem( squish.waitForObjectItem(cvi42Objects.workspaceButton, "Save Workspace As")) squish.waitForObject( cvi42Objects.workspaceWindowEdit).setText(workspace_name) squish.clickButton( squish.waitForObject(cvi42Objects.workspaceWindowOkButton)) start = time.time() while True: if status.currentMessage() == "Save workspace done.": break else: pass end = time.time() test.log("Saving workspace: %.2f" % (end - start)) return
def accountAction(self, action): squish.sendEvent( "QMouseEvent", squish.waitForObject(self.ACCOUNT_BUTTON), squish.QEvent.MouseButtonPress, 0, 0, squish.Qt.LeftButton, 0, 0, ) squish.activateItem(squish.waitForObjectItem(self.ACCOUNT_MENU, action))
def reset_workspace(): menuBar = ":cmr42MainWindow.appMenuBar_QMenuBar" workspaceButton = ":cmr42MainWindow.workspaceMenu_QMenu" resetWorkspaceButtonOk = ":Reset Workspace.Reset_QPushButton" squish.activateItem(squish.waitForObjectItem(menuBar, "Workspace")) squish.activateItem( squish.waitForObjectItem(workspaceButton, "Reset Workspace")) squish.clickButton(squish.waitForObject(resetWorkspaceButtonOk)) # squish.snooze(2) return
def load_workspace(workspace_name): workspace = "{column='0' container=':pLoadWorkspaceDialog.workspacesWidget_QTreeWidget' text='%s' type='QModelIndex'}" % workspace_name menuBar = ":cmr42MainWindow.appMenuBar_QMenuBar" workspaceButton = ":cmr42MainWindow.workspaceMenu_QMenu" squish.activateItem(squish.waitForObjectItem(menuBar, "Workspace")) squish.activateItem( squish.waitForObjectItem(workspaceButton, "Load Workspace")) squish.doubleClick(squish.waitForObject(workspace)) # squish.snooze(2) return
def close_study(): squish.activateItem( squish.waitForObjectItem(cvi42Objects.menuBar, "Workspace")) squish.snooze(0.5) squish.activateItem( squish.waitForObjectItem(cvi42Objects.workspaceButton, "Close Study")) start = time.time() while True: if object.exists(cvi42Objects.patientlistEditBox) is True: break else: pass end = time.time() test.log("Time to close study: %.2f" % (end - start)) return
def click_ml(button): toolBarObject = ":cmr42MainWindow.ToolBar_QToolBar" contextWindow = ":cmr42MainWindow_QMenu" # # If button exists in toolbar, clicks otherwise, find button # children = find_children_by_text(squish.waitForObject(toolBarObject), button) contextButton = find_context_menu(button) squish.openContextMenu(squish.waitForObject(contextButton), 30, 20, 0) squish.activateItem(squish.waitForObjectItem(contextWindow, button)) # squish.snooze(1) squish.clickButton(squish.waitForObject(contextButton)) # Wait for progress bar time = studyFunctions.loading_time() test.log("Short3d %s: %.2f "% (button, time)) return
def anonymize_study(study, anon_name): # If user is not in patient list page condition if object.exists(cvi42Objects.returnPatientlistButton) is True: squish.clickButton( squish.waitForObject(cvi42Objects.returnPatientlistButton)) # Grabs the status bar object to check current message status = squish.waitForObject(cvi42Objects.statusBar) if "\\" in study: studyUpdated = study.replace("\\", "") else: studyUpdated = study # Searches for study, and anonymizes squish.waitForObject(cvi42Objects.patientlistEditBox).setText(studyUpdated) squish.openContextMenu( squish.waitForObjectItem(cvi42Objects.studyTreeitem, study), 50, 5, 0) squish.activateItem( squish.waitForObjectItem(cvi42Objects.contextMenu, "Anonymize Study")) squish.waitForObject(cvi42Objects.anonymizeEditBox).setText(anon_name) squish.clickButton(squish.waitForObject(cvi42Objects.anonymizeOkButton)) start = time.time() # squish.snooze(4) while True: if status.currentMessage() == "Import Study done": break else: pass end = time.time() test.log("Anonymizing %s time: %.2f" % (study, (end - start))) return anon_name
def delete_study(study_name): squish.waitForObject(cvi42Objects.patientlistEditBox).setText(study_name) squish.openContextMenu( squish.waitForObjectItem(cvi42Objects.studyTreeitem, study_name), 50, 13, 0) squish.activateItem( squish.waitForObjectItem(cvi42Objects.contextMenu, "Delete Study")) # squish.snooze(1) squish.clickButton(squish.waitForObject(cvi42Objects.DeleteStudyOkButton)) start = time.time() while True: if object.exists(cvi42Objects.UpdatingStudyListMessage): break else: pass end = time.time() # test.log("Time to delete study: %.2f" %(end-start)) squish.waitForObject(cvi42Objects.patientlistEditBox).setText("") return
def performAction(self, action): squish.openContextMenu( squish.waitForObjectItem(self.ACTION_MENU, "_1"), 0, 0, squish.Qt.NoModifier) squish.activateItem( squish.waitForObjectItem(names.settings_QMenu, action))
def click_module(module, ct=False): counter = 0 moduleListItem = "{container=':mWorkflowDockWidget.protocolSteps_Workflow::ProtocolStepListWidget' text='%s' type='QModelIndex'}" % module # If the study is MR, the icon of the selected module is available in the toolbar. Checks if module already selected if ct == False: if object.exists(cvi42Objects.toolbarModuleButton) is True: if squish.waitForObject( cvi42Objects.toolbarModuleButton).text == module: # test.log("Module Already Loaded") return while True: # If module not in the module list, search for it if object.exists(moduleListItem) is False: if counter == 0: # If module list scroll bar available, mouse scroll to try and find module if object.exists(cvi42Objects.moduleListScrollbar): # Mouse scrolls up all the way to see top of visible module list squish.sendEvent( "QWheelEvent", squish.waitForObject(cvi42Objects.moduleListScrollbar), 103, 527, 540, 0, 2) # If module is visible, click it, and exit loop if object.exists(moduleListItem) is True: squish.mouseClick(squish.waitForObject(moduleListItem)) time = loading_time() if time > 10: test.log("Time to load module: %.2f" % time) break # If scroll bar available, scroll down a little bit each iteration squish.sendEvent( "QWheelEvent", squish.waitForObject(cvi42Objects.moduleListScrollbar), 3, 307, -340, 0, 2) # If mouse scroll bar not available, pass each time else: pass counter += 1 # After four attempts, if module is not found, select it from the protocol list and click the module if counter == 4: squish.mouseClick( squish.waitForObject(cvi42Objects.addProtocolButton)) squish.activateItem( squish.waitForObjectItem(cvi42Objects.addProtocolWindow, module)) squish.mouseClick(squish.waitForObject(moduleListItem)) time = loading_time() if time > 10: test.log("Time to load module: %.2f" % time) return # If module exists from the beginning, select it and exit else: squish.mouseClick(squish.waitForObject(moduleListItem)) time = loading_time() if time > 10: test.log("Time to load module: %.2f" % time) return return