Skip to content

Commit d816920

Browse files
camerasolver - move look up maps into constant.py file
1 parent 0622e06 commit d816920

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

python/mmSolver/tools/camerasolver/constant.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@
114114
LOG_LEVEL_INFO,
115115
LOG_LEVEL_DEBUG,
116116
]
117+
ADJUSTMENT_SOLVER_TO_INDEX = {
118+
v: i for i, v in enumerate(ADJUSTMENT_SOLVER_TYPE_INDEX_LIST)
119+
}
120+
LOG_LEVEL_TO_INDEX = {v: i for i, v in enumerate(LOG_LEVEL_INDEX_LIST)}
117121

118122
# Default values used when a scene option has not yet been set.
119123
DEFAULT_LOG_LEVEL = LOG_LEVEL_PROGRESS

python/mmSolver/tools/camerasolver/ui/camerasolver_layout.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,6 @@
5151

5252
LOG = mmSolver.logger.get_logger()
5353

54-
# Lookup tables derived from the ordered index lists in constant.py.
55-
#
56-
# TODO: Hard-code these variables and move them to the constant.py
57-
# file.
58-
_ADJUSTMENT_SOLVER_CONST_TO_INDEX = {
59-
v: i for i, v in enumerate(const.ADJUSTMENT_SOLVER_TYPE_INDEX_LIST)
60-
}
61-
_LOG_LEVEL_CONST_TO_INDEX = {v: i for i, v in enumerate(const.LOG_LEVEL_INDEX_LIST)}
62-
6354

6455
def find_group_box_spacer(outer_layout, widget_before, widget_after):
6556
"""Return the QSpacerItem sitting between two widgets in a layout, or None.
@@ -279,7 +270,7 @@ def populateUi(self):
279270
const.SCENE_OPTION_ADJUSTMENT_SOLVER_TYPE,
280271
default=const.DEFAULT_ADJUSTMENT_SOLVER_TYPE,
281272
)
282-
adjustment_solver_index = _ADJUSTMENT_SOLVER_CONST_TO_INDEX.get(
273+
adjustment_solver_index = const.ADJUSTMENT_SOLVER_TO_INDEX.get(
283274
adjustment_solver_type, 0
284275
)
285276
self.adjustmentSolver_comboBox.setCurrentIndex(adjustment_solver_index)
@@ -290,7 +281,7 @@ def populateUi(self):
290281
const.SCENE_OPTION_LOG_LEVEL,
291282
default=const.DEFAULT_LOG_LEVEL,
292283
)
293-
log_level_index = _LOG_LEVEL_CONST_TO_INDEX.get(log_level, 2)
284+
log_level_index = const.LOG_LEVEL_TO_INDEX.get(log_level, 2)
294285
self.logLevel_comboBox.setCurrentIndex(log_level_index)
295286

296287
# Focal length range.

0 commit comments

Comments
 (0)