def __onPresetComboBoxCurrentIndexChanged(self, widget): presets = PresetManager().getPresets() try: preset = presets.getByIndex(self._view.presetComboBox.currentIndex()) self._model.preset.name = preset.getName() self.refreshView() except ValueError: Logger().exception("MainController.__onPresetComboBoxCurrentIndexChanged()", debug=True) pass
def __populatePresetComboBox(self): """ Populate the preset combo box. """ self._view.presetComboBox.clear() presets = PresetManager().getPresets() i = 0 while True: try: preset = presets.getByIndex(i) name = preset.getName() self._view.presetComboBox.addItem(name) i += 1 except ValueError: #Logger().exception("MainController.__populatePresetComboBox()", debug=True) break
class PresetScan(AbstractScan): """ PresetScan model. """ def __init__(self, *args, **kwargs): """ Init the Preset object. """ super(PresetScan, self).__init__(*args, **kwargs) self.__presets = PresetManager().getPresets() # Properties def _getTotalNbPicts(self): """ Compute the total number of pictures. """ preset = self.__presets.getByName(self.name) return preset.getNbPicts() def __getName(self): """ """ return ConfigManager().get('Core/PRESET_NAME') def __setName(self, name): """ """ ConfigManager().set('Core/PRESET_NAME', name) name = property(__getName, __setName) # Interface def generatePositions(self): self._positions = [] self._index = 1 preset = self.__presets.getByName(self.name) Logger().debug("PresetScan.generatePositions(): preset=%s" % preset) self._positions = preset.getPositions() def getCurrentPosition(self): yaw, pitch = self._positions[self._index - 1] return self._index, (yaw, pitch) def getAllPositions(self): positions = [] for index, position in enumerate(self._positions): yaw, pitch = position positions.append((index + 1, (yaw, pitch))) return positions
def refreshView(self): if self._model.mode == 'mosaic': self._view.tabWidget.setCurrentIndex(0) self._refreshMosaicPage() else: self._view.tabWidget.setCurrentIndex(1) flag = self._model.cameraOrientation != 'custom' and self._model.camera.lens.type_ != 'fisheye' self._view.tabWidget.setTabEnabled(0, flag) presets = PresetManager().getPresets() try: index = presets.nameToIndex(self._model.preset.name) except ValueError: Logger().warning("Previously selected '%s' preset not found" % self._model.preset.name) index = 0 self._model.preset.name = presets.getByIndex(index).getName() self._view.presetComboBox.setCurrentIndex(index) self._view.presetInfoPlainTextEdit.clear() preset = presets.getByIndex(index) tooltip = preset.getTooltip() self._view.presetInfoPlainTextEdit.setPlainText(tooltip) self._view.yawHeadPosLabel.setText("%.1f" % self.__yawPos) self._view.pitchHeadPosLabel.setText("%.1f" % self.__pitchPos)
class PresetManagerTest(unittest.TestCase): """ Test the PresetManager class. """ __presets = PresetManager().getPresets() def setUp(self): """ Build context (before each xxxTest() method call) """ def tearDown(self): """ Cleanup contaxt ((before each xxxTest() method call) """ def testAll(self): for preset in PresetManagerTest.__presets.getAll(): print preset for yaw, pitch in preset.iterPositions(): print "yaw=%5.1f, pitch=%5.1f" % (yaw, pitch)
def __init__(self, *args, **kwargs): """ Init the Preset object. """ super(PresetScan, self).__init__(*args, **kwargs) self.__presets = PresetManager().getPresets()