def gather_execute_options(): """ Query the current Solver UI ExecuteOptions state that is saved in the scene. :return: The ExecuteOptions ready to be passed to an execution function. :rtype: ExecuteOptions """ refresh_state = lib_state.get_refresh_viewport_state() disable_viewport_two_state = not refresh_state force_update_state = lib_state.get_force_dg_update_state() do_isolate_state = lib_state.get_isolate_object_while_solving_state() pre_solve_force_eval = lib_state.get_pre_solve_force_eval_state() # Display Types disp_node_types = dict() image_plane_state = lib_state.get_display_image_plane_while_solving_state() meshes_state = lib_state.get_display_meshes_while_solving_state() disp_node_types['imagePlane'] = image_plane_state disp_node_types['mesh'] = meshes_state options = mmapi.createExecuteOptions( refresh=refresh_state, disable_viewport_two=disable_viewport_two_state, force_update=force_update_state, do_isolate=do_isolate_state, pre_solve_force_eval=pre_solve_force_eval, display_node_types=disp_node_types, ) return options
def gather_execute_options(): """ Query the current Solver UI ExecuteOptions state that is saved in the scene. :return: The ExecuteOptions ready to be passed to an execution function. :rtype: ExecuteOptions """ refresh_state = lib_state.get_refresh_viewport_state() disable_viewport_two_state = not refresh_state force_update_state = lib_state.get_force_dg_update_state() do_isolate_state = lib_state.get_isolate_object_while_solving_state() pre_solve_force_eval = lib_state.get_pre_solve_force_eval_state() # Display Types disp_node_types = dict() image_plane_state = lib_state.get_display_image_plane_while_solving_state() meshes_state = lib_state.get_display_meshes_while_solving_state() disp_node_types['imagePlane'] = image_plane_state disp_node_types['mesh'] = meshes_state # Minimal UI from config file. config = userprefs_lib.get_config() key = userprefs_const.SOLVER_UI_MINIMAL_UI_WHILE_SOLVING_KEY minimal_ui = userprefs_lib.get_value(config, key) minimal_ui = minimal_ui == userprefs_const.SOLVER_UI_MINIMAL_UI_WHILE_SOLVING_TRUE_VALUE options = mmapi.createExecuteOptions( refresh=refresh_state, disable_viewport_two=disable_viewport_two_state, force_update=force_update_state, do_isolate=do_isolate_state, pre_solve_force_eval=pre_solve_force_eval, display_node_types=disp_node_types, use_minimal_ui=minimal_ui) return options
def addMenuBarContents(self, menubar): # File Menu file_menu = QtWidgets.QMenu('File', menubar) # New Collection label = 'New Collection' tooltip = 'Create a new Collection node.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.createNewCollectionNodeCB)) file_menu.addAction(action) # Rename Collection label = 'Rename Collection' tooltip = 'Rename a Collection node.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.renameCollectionNodeCB)) file_menu.addAction(action) file_menu.addSeparator() # Remove Collection label = 'Remove Collection' tooltip = 'Remove a Collection node.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.removeCollectionNodeCB)) file_menu.addAction(action) file_menu.addSeparator() # Close Window label = 'Close Window' tooltip = 'Close the mmSolver window.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.close)) file_menu.addAction(action) menubar.addMenu(file_menu) # Edit Menu edit_menu = QtWidgets.QMenu('Edit', menubar) edit_menu.setTearOffEnabled(True) if Qt.IsPySide2 or Qt.IsPyQt5: edit_menu.addSection('Undo / Redo') # Undo label = 'Undo (without UI update)' tooltip = ('Undo the Maya scene state, ' 'without updating the viewport or solver UI') action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.triggered.connect(self.undoTriggeredCB) edit_menu.addAction(action) # Redo label = 'Redo (without UI update)' tooltip = ('Redo the Maya scene state, ' 'without updating the viewport or solver UI') action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.triggered.connect(self.redoTriggeredCB) edit_menu.addAction(action) if Qt.IsPySide2 or Qt.IsPyQt5: edit_menu.addSection('Window Update') # Auto Update Solver Validation label = 'Auto-Update Solver Validation' tooltip = 'Auto-update details of the solver parameter/error numbers.' value = lib_state.get_auto_update_solver_validation_state() action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.solver_settings.autoUpdateSolverValidationChanged) edit_menu.addAction(action) if Qt.IsPySide2 or Qt.IsPyQt5: edit_menu.addSection('Solver Execution') # Pre-Solve Force Evaluation label = 'Pre-Solve Force Evaluation' tooltip = ('Before starting a solve, ' 'update the scene to force an evaluation.') pre_solve_force_eval = lib_state.get_pre_solve_force_eval_state() action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(pre_solve_force_eval) action.toggled.connect(type(self).preSolveForceEvalActionToggledCB) edit_menu.addAction(action) # Refresh Viewport During Solve label = 'Refresh Viewport' tooltip = 'Refresh the viewport while Solving.' refresh_value = lib_state.get_refresh_viewport_state() action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(refresh_value) action.toggled.connect(type(self).refreshActionToggledCB) edit_menu.addAction(action) # Force DG evaluation. label = 'Force DG Update' tooltip = 'Force Maya DG Evaluation while solving.' force_dg_update_value = lib_state.get_force_dg_update_state() action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(force_dg_update_value) action.toggled.connect(type(self).forceDgUpdateActionToggledCB) edit_menu.addAction(action) menubar.addMenu(edit_menu) # View Menu view_menu = QtWidgets.QMenu('View', menubar) view_menu.setTearOffEnabled(True) if Qt.IsPySide2 or Qt.IsPyQt5: view_menu.addSection('Input Object Display') # Display Object Weight label = 'Weight Column' tooltip = 'Display Object weight column' value = lib_state.get_display_object_weight_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.object_browser.displayWeightColumnChanged) view_menu.addAction(action) # Display Object Frame Deviation label = 'Frame Deviation' tooltip = 'Display per-frame deviation for each Marker/Camera.' value = lib_state.get_display_object_frame_deviation_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.object_browser.displayFrameDeviationColumnChanged) view_menu.addAction(action) # Display Object Average Deviation label = 'Average Deviation' tooltip = 'Display average deviation column' value = lib_state.get_display_object_average_deviation_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.object_browser.displayAverageDeviationColumnChanged) view_menu.addAction(action) # Display Object Maximum Deviation label = 'Maximum Deviation' tooltip = 'Display maximum deviation column' value = lib_state.get_display_object_maximum_deviation_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.object_browser.displayMaximumDeviationColumnChanged) view_menu.addAction(action) if Qt.IsPySide2 or Qt.IsPyQt5: view_menu.addSection('Output Attribute Display') # Display Attribute State label = 'Display Attribute State' tooltip = 'Display Attribute State column' value = lib_state.get_display_attribute_state_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.attribute_browser.displayStateColumnChanged) view_menu.addAction(action) # Display Attribute Min/Max label = 'Display Attribute Min/Max' tooltip = 'Display Attribute Minimum and Maximum columns' value = lib_state.get_display_attribute_min_max_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.attribute_browser.displayMinMaxColumnChanged) view_menu.addAction(action) if Qt.IsPySide2 or Qt.IsPyQt5: view_menu.addSection('During Solve') # Display the Image Planes while solving. # # TODO: Add other object types to show/hide while solving, # such as camera, nurbsCurves, nurbsSurfaces, and locators. label = 'Display Image Planes' tooltip = 'Display Image Planes while solving.' value = lib_state.get_display_image_plane_while_solving_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( type(self).displayImagePlaneWhileSolvingActionToggledCB) view_menu.addAction(action) # Display the Meshes while solving. label = 'Display Meshes' tooltip = 'Display Meshes while solving.' value = lib_state.get_display_meshes_while_solving_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( type(self).displayMeshesWhileSolvingActionToggledCB) view_menu.addAction(action) # Isolate Objects while solving label = 'Isolate Objects' tooltip = 'Isolate visibility of all Markers and Bundles while solving.' isolate_value = lib_state.get_isolate_object_while_solving_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(isolate_value) action.toggled.connect( type(self).isolateObjectWhileSolvingActionToggledCB) view_menu.addAction(action) menubar.addMenu(view_menu) # Log Menu # This menu depicts a radio button allowing the user to choose # how much information is returned to the console (the logging # level). log_menu = QtWidgets.QMenu('Log', menubar) # Errors label = 'Errors' tooltip = 'Send Errors to the log.' logErrorAction = QtWidgets.QAction(label, log_menu) logErrorAction.setStatusTip(tooltip) logErrorAction.setCheckable(True) logErrorAction.triggered.connect(partial(self.logErrorCB)) log_menu.addAction(logErrorAction) # Warnings label = 'Warnings' tooltip = 'Send Warnings to the log.' logWarningAction = QtWidgets.QAction(label, log_menu) logWarningAction.setStatusTip(tooltip) logWarningAction.setCheckable(True) logWarningAction.triggered.connect(partial(self.logWarningCB)) log_menu.addAction(logWarningAction) # Information label = 'Info' tooltip = 'Send Information to the log.' logInfoAction = QtWidgets.QAction(label, log_menu) logInfoAction.setStatusTip(tooltip) logInfoAction.setCheckable(True) logInfoAction.triggered.connect(partial(self.logInfoCB)) log_menu.addAction(logInfoAction) # Verbose label = 'Verbose' tooltip = 'Send Verboses to the log.' logVerboseAction = QtWidgets.QAction(label, log_menu) logVerboseAction.setStatusTip(tooltip) logVerboseAction.setCheckable(True) logVerboseAction.triggered.connect(partial(self.logVerboseCB)) log_menu.addAction(logVerboseAction) # Debug label = 'Debug' tooltip = 'Send Debug messages to the log.' logDebugAction = QtWidgets.QAction(label, log_menu) logDebugAction.setStatusTip(tooltip) logDebugAction.setCheckable(True) logDebugAction.triggered.connect(partial(self.logDebugCB)) log_menu.addAction(logDebugAction) # 'Radio' button for logging levels log_actionGroup = QtWidgets.QActionGroup(log_menu) log_actionGroup.addAction(logErrorAction) log_actionGroup.addAction(logWarningAction) log_actionGroup.addAction(logInfoAction) log_actionGroup.addAction(logVerboseAction) log_actionGroup.addAction(logDebugAction) log_level = lib_state.get_log_level() if log_level == const.LOG_LEVEL_ERROR: logErrorAction.setChecked(True) elif log_level == const.LOG_LEVEL_WARNING: logWarningAction.setChecked(True) elif log_level == const.LOG_LEVEL_INFO: logInfoAction.setChecked(True) elif log_level == const.LOG_LEVEL_VERBOSE: logVerboseAction.setChecked(True) elif log_level == const.LOG_LEVEL_DEBUG: logDebugAction.setChecked(True) else: LOG.warning('Invalid log level given: %r' % log_level) menubar.addMenu(log_menu) # Help Menu help_menu = QtWidgets.QMenu('Help', menubar) # Launch Help label = 'Help...' tooltip = 'Show help.' action = QtWidgets.QAction(label, help_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.launchHelpCB)) help_menu.addAction(action) # Launch System Info window. label = 'System Information...' tooltip = 'Display detailed information about software and hardware.' action = QtWidgets.QAction(label, help_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.launchSysInfoCB)) help_menu.addAction(action) # Launch About label = 'About mmSolver...' tooltip = 'About this software.' action = QtWidgets.QAction(label, help_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.launchAboutCB)) help_menu.addAction(action) menubar.addMenu(help_menu) return