diff --git a/python/mmSolver/tools/loadmarker/constant.py b/python/mmSolver/tools/loadmarker/constant.py index 89425692..c98ee4e7 100644 --- a/python/mmSolver/tools/loadmarker/constant.py +++ b/python/mmSolver/tools/loadmarker/constant.py @@ -19,6 +19,9 @@ Contains constant values for the Load Marker tool. """ +import mmSolver.tools.userpreferences.constant as userprefs_const + + CONFIG_FILE_NAME = "tools_loadmarker.json" WINDOW_TITLE = 'Load Markers - mmSolver' @@ -52,12 +55,9 @@ NEW_MARKER_GROUP_VALUE = '' NEW_COLLECTION_VALUE = '' -DISTORTION_MODE_VALUE = 'Distorted' -UNDISTORTION_MODE_VALUE = 'Undistorted' +DISTORTION_MODE_VALUE = userprefs_const.LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_DISTORT_LABEL +UNDISTORTION_MODE_VALUE = userprefs_const.LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_UNDISTORT_LABEL # Default values LOAD_MODE_DEFAULT_VALUE = LOAD_MODE_NEW_VALUE -DISTORTION_MODE_DEFAULT_VALUE = UNDISTORTION_MODE_VALUE -LOAD_BUNDLE_POS_DEFAULT_VALUE = True -USE_OVERSCAN_DEFAULT_VALUE = True diff --git a/python/mmSolver/tools/loadmarker/ui/loadmarker_layout.py b/python/mmSolver/tools/loadmarker/ui/loadmarker_layout.py index a2de2d0a..6230a328 100644 --- a/python/mmSolver/tools/loadmarker/ui/loadmarker_layout.py +++ b/python/mmSolver/tools/loadmarker/ui/loadmarker_layout.py @@ -77,6 +77,32 @@ def get_user_prefs_add_marker_to_collection(): return value != userprefs_const.REG_EVNT_ADD_NEW_MKR_TO_NONE_VALUE +def get_user_prefs_distortion_mode_default(): + config = userprefs_lib.get_config() + key = userprefs_const.LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_KEY + value = userprefs_lib.get_value(config, key) + result = None + if value == userprefs_const.LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_UNDISTORT_VALUE: + result = userprefs_const.LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_UNDISTORT_LABEL + elif value == userprefs_const.LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_DISTORT_VALUE: + result = userprefs_const.LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_DISTORT_LABEL + return result + + +def get_user_prefs_use_overscan_default(): + config = userprefs_lib.get_config() + key = userprefs_const.LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_KEY + value = userprefs_lib.get_value(config, key) + return value == userprefs_const.LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_TRUE_VALUE + + +def get_user_prefs_load_bundle_positions_default(): + config = userprefs_lib.get_config() + key = userprefs_const.LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_KEY + value = userprefs_lib.get_value(config, key) + return value == userprefs_const.LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_TRUE_VALUE + + class LoadMarkerLayout(QtWidgets.QWidget, ui_loadmarker_layout.Ui_Form): def __init__(self, parent=None, *args, **kwargs): super(LoadMarkerLayout, self).__init__(*args, **kwargs) @@ -143,9 +169,8 @@ def populateUi(self): self.fileInfo_plainTextEdit.setReadOnly(True) - value = get_config_value( - config, 'data/load_bundle_position', const.LOAD_BUNDLE_POS_DEFAULT_VALUE - ) + default_value = get_user_prefs_load_bundle_positions_default() + value = get_config_value(config, 'data/load_bundle_position', default_value) self.loadBndPositions_checkBox.setChecked(value) # Get the file path from the clipboard. @@ -197,16 +222,19 @@ def populateUi(self): index = self.loadMode_model.stringList().index(value) self.loadMode_comboBox.setCurrentIndex(index) - value = get_config_value( - config, "data/distortion_mode", const.DISTORTION_MODE_DEFAULT_VALUE - ) + default_value = get_user_prefs_distortion_mode_default() + value = get_config_value(config, "data/distortion_mode", default_value) self.populateDistortionModeModel(self.distortionMode_model) index = self.distortionMode_model.stringList().index(value) self.distortionMode_comboBox.setCurrentIndex(index) - value = get_config_value( - config, 'data/use_overscan', const.USE_OVERSCAN_DEFAULT_VALUE - ) + default_value = get_user_prefs_use_overscan_default() + value = get_config_value(config, 'data/use_overscan', default_value) + self.overscan_checkBox.setChecked(value) + self.updateOverscanValues() + + default_value = get_user_prefs_load_bundle_positions_default() + value = get_config_value(config, 'data/load_bundle_positions', default_value) self.overscan_checkBox.setChecked(value) self.updateOverscanValues() return diff --git a/python/mmSolver/tools/userpreferences/constant.py b/python/mmSolver/tools/userpreferences/constant.py index c2a9a6fa..20c3bd2f 100644 --- a/python/mmSolver/tools/userpreferences/constant.py +++ b/python/mmSolver/tools/userpreferences/constant.py @@ -64,6 +64,57 @@ ] +# "Load Marker UI - Distortion Mode Default" preference. +LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_KEY = 'load_marker_ui/distortion_mode_default' +LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_TYPE = TYPE_ENUMERATION_INT +LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_UNDISTORT_VALUE = 1 +LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_UNDISTORT_LABEL = 'Undistorted' +LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_DISTORT_VALUE = 0 +LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_DISTORT_LABEL = 'Distorted' +LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_VALUES = [ + LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_UNDISTORT_VALUE, + LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_DISTORT_VALUE, +] +LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_LABELS = [ + LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_UNDISTORT_LABEL, + LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_DISTORT_LABEL, +] + + +# "Load Marker UI - Use Overscan Default" preference. +LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_KEY = 'load_marker_ui/use_overscan_default' +LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_TYPE = TYPE_ENUMERATION_INT +LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_TRUE_VALUE = 1 +LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_TRUE_LABEL = 'Yes' +LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_FALSE_VALUE = 0 +LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_FALSE_LABEL = 'No' +LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_VALUES = [ + LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_TRUE_VALUE, + LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_FALSE_VALUE, +] +LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_LABELS = [ + LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_TRUE_LABEL, + LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_FALSE_LABEL, +] + + +# "Load Marker UI - Load Bundle Positions Default" preference. +LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_KEY = 'load_marker_ui/load_bundle_positions_default' +LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_TYPE = TYPE_ENUMERATION_INT +LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_TRUE_VALUE = 1 +LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_TRUE_LABEL = 'Yes' +LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_FALSE_VALUE = 0 +LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_FALSE_LABEL = 'No' +LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_VALUES = [ + LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_TRUE_VALUE, + LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_FALSE_VALUE, +] +LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_LABELS = [ + LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_TRUE_LABEL, + LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_FALSE_LABEL, +] + + # "Solver UI - Validate on open" preference. # # This option is deprecated and is not used. @@ -159,6 +210,9 @@ VALUES_MAP = { REG_EVNT_ADD_NEW_MKR_TO_KEY: REG_EVNT_ADD_NEW_MKR_TO_VALUES, REG_EVNT_ADD_NEW_LINE_TO_KEY: REG_EVNT_ADD_NEW_LINE_TO_VALUES, + LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_KEY: LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_VALUES, + LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_KEY: LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_VALUES, + LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_KEY: LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_VALUES, SOLVER_UI_MINIMAL_UI_WHILE_SOLVING_KEY: SOLVER_UI_MINIMAL_UI_WHILE_SOLVING_VALUES, CREATE_CONTROLLER_SHAPE_KEY: CREATE_CONTROLLER_SHAPE_VALUES, } @@ -168,6 +222,9 @@ LABELS_MAP = { REG_EVNT_ADD_NEW_MKR_TO_KEY: REG_EVNT_ADD_NEW_MKR_TO_LABELS, REG_EVNT_ADD_NEW_LINE_TO_KEY: REG_EVNT_ADD_NEW_LINE_TO_LABELS, + LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_KEY: LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_LABELS, + LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_KEY: LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_LABELS, + LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_KEY: LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_LABELS, SOLVER_UI_MINIMAL_UI_WHILE_SOLVING_KEY: SOLVER_UI_MINIMAL_UI_WHILE_SOLVING_LABELS, CREATE_CONTROLLER_SHAPE_KEY: CREATE_CONTROLLER_SHAPE_LABELS, } @@ -177,6 +234,9 @@ DEFAULT_VALUE_MAP = { REG_EVNT_ADD_NEW_MKR_TO_KEY: REG_EVNT_ADD_NEW_MKR_TO_ACTIVE_COL_VALUE, REG_EVNT_ADD_NEW_LINE_TO_KEY: REG_EVNT_ADD_NEW_LINE_TO_ACTIVE_COL_VALUE, + LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_KEY: LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_UNDISTORT_VALUE, + LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_KEY: LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_TRUE_VALUE, + LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_KEY: LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_TRUE_VALUE, SOLVER_UI_MINIMAL_UI_WHILE_SOLVING_KEY: SOLVER_UI_MINIMAL_UI_WHILE_SOLVING_TRUE_VALUE, CREATE_CONTROLLER_SHAPE_KEY: CREATE_CONTROLLER_SHAPE_LOCATOR_VALUE, } @@ -186,6 +246,9 @@ VALUE_TYPE_MAP = { REG_EVNT_ADD_NEW_MKR_TO_KEY: REG_EVNT_ADD_NEW_MKR_TO_TYPE, REG_EVNT_ADD_NEW_LINE_TO_KEY: REG_EVNT_ADD_NEW_LINE_TO_TYPE, + LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_KEY: LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_TYPE, + LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_KEY: LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_TYPE, + LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_KEY: LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_TYPE, SOLVER_UI_MINIMAL_UI_WHILE_SOLVING_KEY: SOLVER_UI_MINIMAL_UI_WHILE_SOLVING_TYPE, CREATE_CONTROLLER_SHAPE_KEY: CREATE_CONTROLLER_SHAPE_TYPE, } diff --git a/python/mmSolver/tools/userprefswindow/ui/pref_layout.py b/python/mmSolver/tools/userprefswindow/ui/pref_layout.py index 4297b1b5..4d7ae0a2 100644 --- a/python/mmSolver/tools/userprefswindow/ui/pref_layout.py +++ b/python/mmSolver/tools/userprefswindow/ui/pref_layout.py @@ -59,6 +59,9 @@ def populateUI(self, config): self.updateAddNewMarkersToWidget(config) self.updateAddNewLinesToWidget(config) self.updateSolverUIMinimalUIWhileSolvingWidget(config) + self.updateLoadMarkerUIDistortionModeDefaultWidget(config) + self.updateLoadMarkerUIUseOverscanDefaultWidget(config) + self.updateLoadMarkerUILoadBundlePositionsDefaultWidget(config) # Deprecated options, kept for backwards compatibility, but # they are hidden by default anyway. @@ -101,6 +104,57 @@ def getAddNewLinesToConfigValue(self): value = userprefs_lib.get_value_from_label(key, label) return value + def updateLoadMarkerUIDistortionModeDefaultWidget(self, config): + key = pref_const.LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_KEY + value = userprefs_lib.get_value(config, key) + label = userprefs_lib.get_label_from_value(key, value) + assert isinstance(label, pycompat.TEXT_TYPE) + labels = userprefs_lib.get_labels(key) + self.distortionModeDefaultComboBox.clear() + self.distortionModeDefaultComboBox.addItems(labels) + self.distortionModeDefaultComboBox.setCurrentText(label) + return + + def getLoadMarkerUIDistortionModeDefaultConfigValue(self): + key = pref_const.LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_KEY + label = self.distortionModeDefaultComboBox.currentText() + value = userprefs_lib.get_value_from_label(key, label) + return value + + def updateLoadMarkerUIUseOverscanDefaultWidget(self, config): + key = pref_const.LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_KEY + value = userprefs_lib.get_value(config, key) + label = userprefs_lib.get_label_from_value(key, value) + assert isinstance(label, pycompat.TEXT_TYPE) + labels = userprefs_lib.get_labels(key) + self.useOverscanDefaultComboBox.clear() + self.useOverscanDefaultComboBox.addItems(labels) + self.useOverscanDefaultComboBox.setCurrentText(label) + return + + def getLoadMarkerUIUseOverscanDefaultConfigValue(self): + key = pref_const.LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_KEY + label = self.useOverscanDefaultComboBox.currentText() + value = userprefs_lib.get_value_from_label(key, label) + return value + + def updateLoadMarkerUILoadBundlePositionsDefaultWidget(self, config): + key = pref_const.LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_KEY + value = userprefs_lib.get_value(config, key) + label = userprefs_lib.get_label_from_value(key, value) + assert isinstance(label, pycompat.TEXT_TYPE) + labels = userprefs_lib.get_labels(key) + self.loadBundlePositionsDefaultComboBox.clear() + self.loadBundlePositionsDefaultComboBox.addItems(labels) + self.loadBundlePositionsDefaultComboBox.setCurrentText(label) + return + + def getLoadMarkerUILoadBundlePositionsDefaultConfigValue(self): + key = pref_const.LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_KEY + label = self.loadBundlePositionsDefaultComboBox.currentText() + value = userprefs_lib.get_value_from_label(key, label) + return value + def updateSolverUIValidateOnOpenWidget(self, config): # This feature is deprecated and is no longer allowed. return diff --git a/python/mmSolver/tools/userprefswindow/ui/pref_layout.ui b/python/mmSolver/tools/userprefswindow/ui/pref_layout.ui index 10aaaf0d..ead973d2 100644 --- a/python/mmSolver/tools/userprefswindow/ui/pref_layout.ui +++ b/python/mmSolver/tools/userprefswindow/ui/pref_layout.ui @@ -6,8 +6,8 @@ 0 0 - 501 - 428 + 1144 + 826 @@ -70,6 +70,49 @@ + + + + Load Marker UI Preferences + + + + + + + + Use Embedded Overscan Default: + + + + + + + + + + Load Bundle Positions Default: + + + + + + + + + + Distortion Mode Default: + + + + + + + + + + + diff --git a/python/mmSolver/tools/userprefswindow/ui/pref_window.py b/python/mmSolver/tools/userprefswindow/ui/pref_window.py index dad029d0..f80fcdbe 100644 --- a/python/mmSolver/tools/userprefswindow/ui/pref_window.py +++ b/python/mmSolver/tools/userprefswindow/ui/pref_window.py @@ -110,6 +110,18 @@ def save_prefs(self): pref_const.REG_EVNT_ADD_NEW_LINE_TO_KEY, self.subForm.getAddNewLinesToConfigValue, ), + ( + pref_const.LOAD_MARKER_UI_DISTORTION_MODE_DEFAULT_KEY, + self.subForm.getLoadMarkerUIDistortionModeDefaultConfigValue, + ), + ( + pref_const.LOAD_MARKER_UI_USE_OVERSCAN_DEFAULT_KEY, + self.subForm.getLoadMarkerUIUseOverscanDefaultConfigValue, + ), + ( + pref_const.LOAD_MARKER_UI_LOAD_BUNDLE_POSITIONS_DEFAULT_KEY, + self.subForm.getLoadMarkerUILoadBundlePositionsDefaultConfigValue, + ), ( pref_const.SOLVER_UI_MINIMAL_UI_WHILE_SOLVING_KEY, self.subForm.getSolverUIMinimalUIWhileSolvingConfigValue,