def __init__(self, parent=None, *args, **kwargs): super(SolverWidget, self).__init__(*args, **kwargs) self.setupUi(self) # Solver Settings Basic Widget self.basic_widget = solver_basic_widget.SolverBasicWidget(self) self.basic_layout.addWidget(self.basic_widget) # Solver Settings Standard Widget self.standard_widget = solver_standard_widget.SolverStandardWidget( self) self.standard_layout.addWidget(self.standard_widget) # Solver Settings Legacy Widget self.legacy_widget = solver_legacy_widget.SolverLegacyWidget(self) self.legacy_layout.addWidget(self.legacy_widget) self._tab_name_to_index_map = { 'basic': 0, 'standard': 1, 'legacy': 2, } self._tab_index_to_widget_map = { 0: self.basic_widget, 1: self.standard_widget, 2: self.legacy_widget, } self.all_tab_widgets = [ self.basic_widget, self.standard_widget, self.legacy_widget ] self.validate_pushButton.setEnabled(False) self.tabWidget.currentChanged.connect(self._tabChanged) self.basic_widget.dataChanged.connect(self._dataChanged) self.standard_widget.dataChanged.connect(self._dataChanged) self.legacy_widget.dataChanged.connect(self._dataChanged) self.standard_widget.sendWarning.connect(self._sendWarningToUser) self.standard_widget.sendWarning.connect(self._sendWarningToUser) self.basic_widget.frameRange_widget.rangeTypeChanged.connect( self.updateInfo) self.basic_widget.frameRange_widget.framesChanged.connect( self.updateInfo) self.basic_widget.frameRange_widget.incrementByFrameChanged.connect( self.updateInfo) self.standard_widget.frameRange_widget.rangeTypeChanged.connect( self.updateInfo) self.validate_pushButton.clicked.connect(self.runUpdateInfo) # First time we open this UI, we should update the solver info text. value = lib_state.get_auto_update_solver_validation_state() if value is False: self.validate_pushButton.clicked.emit() return
def updateInfo(self): is_running = mmapi.is_solver_running() if is_running is True: return value = lib_state.get_auto_update_solver_validation_state() self.validate_pushButton.setEnabled(not value) if value is not True: return self.runUpdateInfo() return
def redoTriggeredCB(self): LOG.debug('redoTriggeredCB') validation = lib_state.get_auto_update_solver_validation_state() with undo_utils.no_undo_context(): lib_state.set_auto_update_solver_validation_state(False) block = self.blockSignals(True) try: undoredoscene_tool.main_redo() finally: with undo_utils.no_undo_context(): lib_state.set_auto_update_solver_validation_state(validation) self.blockSignals(block) return
def updateValidationWidgets(self): LOG.debug('updateValidationWidgets') # Show the validate button? visible = _getShowValidateButton() self.info_groupBox.setVisible(visible) # Only run a solver validation if the user wants updates. validate_on_open = _getValidateOnOpen() if validate_on_open: value = lib_state.get_auto_update_solver_validation_state() if value is False: self.validate_pushButton.clicked.emit() return
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
def __init__(self, parent=None, *args, **kwargs): s = time.time() super(SolverWidget, self).__init__(parent, *args, **kwargs) self.setupUi(self) # Solver Settings Basic Widget self.basic_widget = solver_basic_widget.SolverBasicWidget(self) self.basic_layout.addWidget(self.basic_widget) # Solver Settings Standard Widget self.standard_widget = solver_standard_widget.SolverStandardWidget( self) self.standard_layout.addWidget(self.standard_widget) # Solver Settings Legacy Widget self.legacy_widget = solver_legacy_widget.SolverLegacyWidget(self) self.legacy_layout.addWidget(self.legacy_widget) self._tab_name_to_index_map = { 'basic': 0, 'standard': 1, 'legacy': 2, } self._tab_index_to_widget_map = { 0: self.basic_widget, 1: self.standard_widget, 2: self.legacy_widget, } self.all_tab_widgets = [ self.basic_widget, self.standard_widget, self.legacy_widget ] self.validate_pushButton.setEnabled(False) # Show the validate button? visible = _getShowValidateButton() self.info_groupBox.setVisible(visible) self.tabWidget.currentChanged.connect(self._tabChanged) self.basic_widget.dataChanged.connect(self._dataChanged) self.standard_widget.dataChanged.connect(self._dataChanged) self.legacy_widget.dataChanged.connect(self._dataChanged) self.standard_widget.sendWarning.connect(self._sendWarningToUser) self.standard_widget.sendWarning.connect(self._sendWarningToUser) self.basic_widget.frameRange_widget.rangeTypeChanged.connect( self.updateInfo) self.basic_widget.frameRange_widget.framesChanged.connect( self.updateInfo) self.basic_widget.frameRange_widget.incrementByFrameChanged.connect( self.updateInfo) self.standard_widget.frameRange_widget.rangeTypeChanged.connect( self.updateInfo) self.validate_pushButton.clicked.connect(self.runUpdateInfo) # Only run a solver validation if the user wants updates. validate_on_open = _getValidateOnOpen() if validate_on_open: value = lib_state.get_auto_update_solver_validation_state() if value is False: self.validate_pushButton.clicked.emit() e = time.time() LOG.debug('SolverWidget init: %r seconds', e - s) return