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 step(context, views): if not context.userData: context.userData = {} calling_name = context.userData['calling'] # use a natural numbering, so +1 since entry 0 is entry 1 squish.snooze(0.25) # switch and wait a little app.switch_to_app('phone') squish.snooze(0.25) caller_name_obj = squish.waitForObject(names.phoneCallerLabel) caller_name = None if caller_name_obj is not None: caller_name = str(caller_name_obj.text) # end call before comparing end_call_button = squish.waitForObject(names.phoneCallerEndButton) squish.tapObject(end_call_button) app.compare(calling_name, caller_name, "calling the right name") # switch to main before new command app.switch_to_main_app() squish.snooze(0.2)
def addServer(self, context): clientDetails = getClientDetails(context) squish.mouseClick(squish.waitForObject(self.SERVER_ADDRESS_BOX)) squish.type( squish.waitForObject(self.SERVER_ADDRESS_BOX), clientDetails['server'] ) squish.clickButton(squish.waitForObject(self.NEXT_BUTTON))
def enterPassword(self, password): try: squish.waitForObject(self.PASSWORD_BOX, 10000) squish.type(squish.waitForObject(self.PASSWORD_BOX), password) squish.clickButton(squish.waitForObject(self.OK_BUTTON)) except LookupError: pass
def createPublicLinkWithRole(self, role): radioObjectName = self.getRadioObjectForPermssion(role) squish.clickButton(squish.waitForObject(radioObjectName)) squish.clickButton(squish.waitForObject(self.CREATE_SHARE_BUTTON)) squish.waitFor(lambda: (squish.findObject( names.linkShares_0_0_QModelIndex).displayText == "Public link"))
def segment_forward(): segmentContour = ":mContourOptions.ToolButton-segAction_QToolButton" forwardContour = ":mContourOptions.ToolButton-segForwardAction_QToolButton" squish.mousePress(squish.waitForObject(segmentContour)) # squish.snooze(1) squish.mouseRelease(squish.waitForObject(segmentContour)) squish.clickButton(squish.waitForObject(forwardContour)) return
def aortic_measurement_capture(): firstIndexMeasurements = "{container=':mMprCaptureFrame_MprCaptureListWidget' type='QModelIndex'}" tagLVOT = ":mGroupFrame.LVOT_QModelIndex" # Drag and drop LVOT tag on first measurement capture image squish.mousePress(squish.waitForObject(tagLVOT)) # squish.snooze(1) squish.mouseMove(squish.waitForObject(firstIndexMeasurements), 5, 5) squish.mouseRelease(squish.waitForObject(firstIndexMeasurements)) return
def checkFileExist(self, filename): squish.waitForObject(names.settings_OCC_SettingsDialog) squish.waitForObjectExists({ "column": 1, "container": names.oCC_IssuesWidget_tableView_QTableView, "text": RegularExpression(buildConflictedRegex(filename)), "type": "QModelIndex", })
def measurement_capture(): measurementCaptureButton = ":mViewerMeasurementFrame.mCameraButton_QPushButton" SelectAllButton = ":mCentralStack.mSelectAllButton_QPushButton" PushtoReportOk = ":mCentralStack.mOkButton_QPushButton" # Open measurement capture window and send to report squish.clickButton(squish.waitForObject(measurementCaptureButton)) squish.clickButton(squish.waitForObject(SelectAllButton)) squish.clickButton(squish.waitForObject(PushtoReportOk)) # Check report42 time check_report42() return
def select_comparison(): comparisonFlowButton = ":mFlowSeriesPanelButtons.ToolButton-mFlow2PanelAction_QToolButton" squish.mouseClick(squish.waitForObject(comparisonFlowButton)) return
def select_pulmonary(): pulmonaryFlowButton = ":mFlowSeriesPanelButtons.ToolButton-mFlow1PanelAction_QToolButton" squish.mouseClick(squish.waitForObject(pulmonaryFlowButton)) return
def removePermissions(self, permissions): removePermissionsList = permissions.split(",") ( isEditPermissionAvailable, isSharePermissionAvailable, ) = self.getAvailablePermission() if 'share' in removePermissionsList and isSharePermissionAvailable: squish.clickButton( squish.waitForObject( names.scrollArea_permissionShare_QCheckBox)) if 'edit' in removePermissionsList and isEditPermissionAvailable: squish.clickButton( squish.waitForObject( names.scrollArea_permissionsEdit_QCheckBox))
def select_systemic(): systemicFlowButton = ":mFlowSeriesPanelButtons.ToolButton-mFlow0PanelAction_QToolButton" squish.mouseClick(squish.waitForObject(systemicFlowButton)) return
def openPublicLinkDialog(self): squish.mouseClick( squish.waitForObject(self.PUBLIC_LINKS_TAB), 0, 0, squish.Qt.NoModifier, squish.Qt.LeftButton, )
def selectSyncFolder(self, context): clientDetails = getClientDetails(context) try: squish.clickButton(squish.waitForObject(self.ERROR_OK_BUTTON)) except LookupError: pass squish.clickButton(squish.waitForObject(self.SELECT_LOCAL_FOLDER)) squish.mouseClick(squish.waitForObject(self.DIRECTORY_NAME_BOX)) squish.type( squish.waitForObject(self.DIRECTORY_NAME_BOX), clientDetails['localfolder'] ) squish.clickButton(squish.waitForObject(self.CHOOSE_BUTTON)) test.compare( str(squish.waitForObjectExists(self.SELECT_LOCAL_FOLDER).text), self.sanitizeFolderPath(clientDetails['localfolder']), )
def aortic_annulus(): annulusTab = ":cmr42MainWindow.mPageButtons[ePage::Annulus]_QToolButton" perimeterPoints = ":cmr42MainWindow.ToolButton-contourAction-perimeterPoints_QToolButton" aorticWindow = ":mMprFrame.mAxialMprFrame_TriPlaneMprFrame" # Click on annulus tab squish.clickButton(squish.waitForObject(annulusTab)) # Click on the perimeter contour button squish.clickButton(squish.waitForObject(perimeterPoints)) # Hardcoded mouse clicks for drawing annulus measurement squish.mouseClick(squish.waitForObject(aorticWindow), 172, 153, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(aorticWindow), 101, 208, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(aorticWindow), 172, 277, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(aorticWindow), 239, 227, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.doubleClick(squish.waitForObject(aorticWindow), 175, 152, 0, squish.Qt.LeftButton) return
def mitral_measurement_capture(): firstIndexMeasurements = "{container=':mMprCaptureFrame_MprCaptureListWidget' type='QModelIndex'}" bottomFrame = ":mMprFrame.mCoronalMprFrame_TriPlaneMprFrame" lineContourEmbedFrame = ":contourHandle.ToolButton-contourAction-lineRoiContour_QToolButton" tagMVTOLAA = ":mGroupFrame.MV to LAA_QModelIndex" x, y = squish.waitForObject(bottomFrame).height, squish.waitForObject( bottomFrame).width squish.mouseMove(squish.waitForObject(bottomFrame), 10, x - 20) squish.clickButton(squish.waitForObject(lineContourEmbedFrame)) squish.mousePress(bottomFrame, randint(0 + 50, x - 70), randint(0 + 50, y - 70), squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseRelease(bottomFrame, randint(0 + 50, x - 70), randint(0 + 50, y - 70), squish.Qt.LeftButton) # squish.snooze(0.5) # Drag and drop LVOT tag on first measurement capture image squish.mousePress(squish.waitForObject(tagMVTOLAA)) # squish.snooze(1) squish.mouseMove(squish.waitForObject(firstIndexMeasurements), 5, 5) squish.mouseRelease(squish.waitForObject(firstIndexMeasurements)) return
def mitral_define_annulus(): mitralWindow = ":mMprFrame.mAxialMprFrame_TriPlaneMprFrame" annulusTab = ":cmr42MainWindow.mPageButtons[ePage::Annulus]_QToolButton" annulusStartButton = ":groupBox.mStartAssistedButton_QPushButton" topFrame = ":mMprFrame.mSagittalMprFrame_TriPlaneMprFrame" bottomFrame = ":mMprFrame.mCoronalMprFrame_TriPlaneMprFrame" # Click on start annulus squish.mouseClick(squish.waitForObject(mitralWindow), 180, 460, 0, squish.Qt.LeftButton) # Switch to annulus tab and start annulus squish.clickButton(squish.waitForObject(annulusTab)) squish.clickButton(squish.waitForObject(annulusStartButton)) # Hardcoded annulus drawing squish.mouseClick(squish.waitForObject(topFrame), 146, 162, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(topFrame), 148, 253, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(bottomFrame), 158, 181, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(bottomFrame), 154, 252, 0, squish.Qt.LeftButton) return
def addCollaborator(self, receiver, permissions, isGroup=False): self.selectCollaborator(receiver, isGroup) permissionsList = permissions.split(",") editChecked, shareChecked = self.getAvailablePermission() if ('edit' in permissionsList and editChecked == False) or ('edit' not in permissionsList and editChecked == True): squish.clickButton( squish.waitForObject(self.EDIT_PERMISSIONS_CHECKBOX)) if ('share' in permissionsList and shareChecked == False) or ('share' not in permissionsList and shareChecked == True): squish.clickButton( squish.waitForObject(self.SHARE_PERMISSIONS_CHECKBOX)) squish.clickButton( squish.waitForObject(self.SHARING_DIALOG_CLOSE_BUTTON))
def sortBy(self, headerText): squish.mouseClick( squish.waitForObject( { "container": names.deselect_remote_folders_you_do_not_wish_to_synchronize_QHeaderView, "text": headerText, "type": "HeaderViewItem", "visible": True, } ) )
def selectFoldersToSync(self, context): self.openSyncDialog() # first deselect all squish.mouseClick( squish.waitForObject(self.SYNC_DIALOG_ROOT_FOLDER), 11, 11, squish.Qt.NoModifier, squish.Qt.LeftButton, ) for row in context.table[1:]: squish.mouseClick( squish.waitForObjectItem(self.SYNC_DIALOG_FOLDER_TREE, "/." + row[0]), 11, 11, squish.Qt.NoModifier, squish.Qt.LeftButton, ) squish.clickButton(squish.waitForObject(self.SYNC_DIALOG_OK_BUTTON))
def aortic_tricuspid(): tricuspidButton = ":mWorkflowGroupbox.mTricuspidPushButton_QPushButton" aorticWindow = ":mMprFrame.mAxialMprFrame_TriPlaneMprFrame" # Click on the tricuspid option squish.clickButton(squish.waitForObject(tricuspidButton)) # Hardcoded mouse clicks of tricuspid locations squish.mouseClick(squish.waitForObject(aorticWindow), 169, 195, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(aorticWindow), 197, 249, 0, squish.Qt.LeftButton) # squish.snooze(0.5) squish.mouseClick(squish.waitForObject(aorticWindow), 134, 243, 0, squish.Qt.LeftButton) # squish.snooze(1.5) return
def add_to_report(): addToReportButton = ":cmr42MainWindow.Add Report_QToolButton" # Click on the add to report button squish.clickButton(squish.waitForObject(addToReportButton)) # Check report42 time check_report42() 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 ml_button(): mlButton = ":mContourDetectionTools.mlButton_SwitchingToolButton" squish.clickButton(squish.waitForObject(mlButton)) # Wait for progress bar time = studyFunctions.loading_time() test.log("biplanarLAX ML %.2f" % time) return
def load_series(window_given, series_num): series = ":scrollArea.frame-%s_SeriesThumbPreview" % (series_num - 1) window, x, y = find_window(window_given) # if series needed is bigger than 8, check if scrolling is needed to reach the series if object.exists(cvi42Objects.series_scrollbar): squish.scrollTo(squish.waitForObject(cvi42Objects.series_scrollbar), -505) if series_num > 8: squish.scrollTo( squish.waitForObject(cvi42Objects.series_scrollbar), 855) # Load series into window requested squish.mouseMove(squish.waitForObject(series), 5, 5) squish.mousePress(squish.waitForObject(series)) # squish.snooze(1) squish.mouseRelease(squish.waitForObject(window)) squish.snooze(0.2) if object.exists(":Load Volume.Yes_QPushButton"): squish.clickButton( squish.waitForObject(":Load Volume.Yes_QPushButton")) # Wait for progress bar time = loading_time() if time > 10: test.log("Time to load series: %.2f" % time) return
def createPublicLink(self, context, resource, password='', permissions=''): radioObjectName = '' if permissions: radioObjectName = self.getRadioObjectForPermssion(permissions) test.compare( str(squish.waitForObjectExists(self.ITEM_TO_SHARE).text), resource.replace(context.userData['clientSyncPathUser1'], ''), ) if radioObjectName: test.compare(str(squish.waitForObjectExists(radioObjectName).text), permissions) squish.clickButton(squish.waitForObject(radioObjectName)) if password: squish.clickButton(squish.waitForObject(self.PASSWORD_CHECKBOX)) squish.mouseClick( squish.waitForObject(self.PASSWORD_CHECKBOX), 0, 0, squish.Qt.NoModifier, squish.Qt.LeftButton, ) squish.type( squish.waitForObject(self.PASSWORD_CHECKBOX), password, ) squish.clickButton(squish.waitForObject(self.CREATE_SHARE_BUTTON)) squish.waitFor(lambda: (squish.waitForObject( names.linkShares_0_0_QModelIndex).displayText == "Public link"))
def curvedMeasContour(window_name, num=3): curvedMeasurementContour = ":mContourTools.ToolButton-contourAction-openSplinePerimeterPoints_QToolButton" # Grabs Qt equivalent of given window name window, x, y = studyFunctions.find_window(window_name) # Finds and clicks on the Contour measurement button squish.clickButton(squish.waitForObject(curvedMeasurementContour)) counter = 0 while counter < num - 1: # Mouse click inside the frame of the selected window squish.mouseClick(squish.waitForObject(window), randint(0 + 50, x - 70), randint(0 + 50, y - 70), 0, squish.Qt.LeftButton) counter += 1 squish.doubleClick(squish.waitForObject(window), randint(0 + 50, x - 70), randint(0 + 50, y - 70), 0, squish.Qt.LeftButton) return
def freehandContour(window_name): freehandContour = ":mContourTools.ToolButton-contourAction-freeDrawRoiContour_QToolButton" # Grabs Qt equivalent of given window name window, x, y = studyFunctions.find_window(window_name) # Finds and clicks on the Contour measurement button squish.clickButton(squish.waitForObject(freehandContour)) # Starts drawing freehand contour by pressing the left mouse button squish.mousePress(squish.waitForObject(window), randint(0 + 50, x - 70), randint(0 + 50, y - 70), squish.Qt.LeftButton) for i in range(3): squish.mouseMove(squish.waitForObject(window), randint(0 + 50, x - 70), randint(0 + 50, y - 70)) squish.mouseRelease(squish.waitForObject(window), randint(0 + 50, x - 70), randint(0 + 50, y - 70), squish.Qt.LeftButton) return