def updateFileInfoText(self): file_path = self.getFilePath() info_widget = self.fileInfo_plainTextEdit valid = lib.is_valid_file_path(file_path) if valid is False: text = 'File path is not valid:\n' text += repr(file_path) info_widget.setPlainText(text) return text = 'Frame Range: {start_frame}-{end_frame}\n' text += 'Number of Points: {num_points}\n' text += 'Point Names: {point_names}\n' text += '\n' text += 'Format: {fmt_name}\n' text += 'Distorted Data: {lens_dist}\n' text += 'Undistorted Data: {lens_undist}\n' text += 'Bundle Positions: {positions}\n' text += 'With Camera FOV: {has_camera_fov}\n' info = lib.get_file_info_strings(file_path) # Change point names into single string. point_names = info.get('point_names', '') point_names = point_names.strip() point_names = '\n- ' + point_names.replace(' ', '\n- ') info['point_names'] = point_names text = text.format(**info) info_widget.setPlainText(text) return
def __init__(self, parent=None, *args, **kwargs): super(LoadMarkerLayout, self).__init__(*args, **kwargs) self.setupUi(self) self.loadMode_model = QtCore.QStringListModel() self.loadMode_comboBox.setModel(self.loadMode_model) self.camera_model = uimodels.StringDataListModel() self.camera_comboBox.setModel(self.camera_model) self.markerGroup_model = uimodels.StringDataListModel() self.markerGroup_comboBox.setModel(self.markerGroup_model) self.distortionMode_model = QtCore.QStringListModel() self.distortionMode_comboBox.setModel(self.distortionMode_model) # Set default values self._file_info = None w, h = lib.get_default_image_resolution() self.imageResWidth_label.setEnabled(False) self.imageResWidth_spinBox.setValue(w) self.imageResWidth_spinBox.setEnabled(False) self.imageResWidth_spinBox.setMaximum(99999) self.imageResHeight_spinBox.setValue(h) self.imageResHeight_spinBox.setEnabled(False) self.imageResHeight_spinBox.setMaximum(99999) self.fileInfo_plainTextEdit.setReadOnly(True) value = const.LOAD_BUNDLE_POS_DEFAULT_VALUE self.loadBndPositions_checkBox.setChecked(value) # Get the file path from the clipboard. try: clippy = QtGui.QClipboard() text = str(clippy.text()).strip() if lib.is_valid_file_path(text): self.setFilePath(text) except Exception as e: msg = 'Could not get file path from clipboard.' LOG.warning(msg) LOG.info(str(e)) # Set up callback connections self.loadMode_comboBox.currentIndexChanged[str].connect(lambda x: self.updateLoadMode()) self.camera_comboBox.currentIndexChanged[str].connect(lambda x: self.markerGroupUpdateClicked()) self.cameraUpdate_pushButton.clicked.connect(self.cameraUpdateClicked) self.markerGroupUpdate_pushButton.clicked.connect(self.markerGroupUpdateClicked) self.filepath_pushButton.clicked.connect(self.filePathBrowseClicked) self.filepath_lineEdit.editingFinished.connect(self.updateFilePathWidget) self.populateUi()
def __init__(self, parent=None, *args, **kwargs): super(LoadMarkerLayout, self).__init__(*args, **kwargs) self.setupUi(self) # 'File Info' should be read-only. self.fileInfo_plainTextEdit.setReadOnly(True) # Camera combo box. self.camera_model = uimodels.StringDataListModel() self.camera_comboBox.setModel(self.camera_model) # Camera update. self.cameraUpdate_pushButton.clicked.connect(self.cameraUpdateClicked) # Set default image resolution values w, h = lib.get_default_image_resolution() self.imageResWidth_spinBox.setValue(w) self.imageResWidth_spinBox.setEnabled(False) self.imageResWidth_spinBox.setMaximum(99999) self.imageResHeight_spinBox.setValue(h) self.imageResHeight_spinBox.setEnabled(False) self.imageResHeight_spinBox.setMaximum(99999) # File path browse. self.filepath_pushButton.clicked.connect(self.filePathBrowseClicked) # Get the file path from the clipboard. try: clippy = QtGui.QClipboard() text = str(clippy.text()).strip() if lib.is_valid_file_path(text): self.setFilePath(text) except Exception as e: msg = 'Could not get file path from clipboard.' LOG.warning(msg) LOG.info(str(e)) # Update the 'Image Resolution' enable state when the file # patch changes. self.filepath_lineEdit.editingFinished.connect( self.updateImageResEnabledState) # Update the 'File Info' when the file patch changes self.filepath_lineEdit.editingFinished.connect(self.updateFileInfoText) # Populate the UI with data self.populateUi()
def updateFileInfoText(self): file_path = self.getFilePath() info_widget = self.fileInfo_plainTextEdit valid = lib.is_valid_file_path(file_path) if valid is False: text = 'File path is not valid:\n' text += repr(file_path) info_widget.setPlainText(text) return text = 'Format: {fmt_name}\n' text += 'Frame Range: {start_frame}-{end_frame}\n' text += 'Number of Points: {num_points}\n' text += 'Point Names: {point_names}\n' info = lib.get_file_info(file_path) text = text.format(**info) info_widget.setPlainText(text) return
def test_file_path(self): values = ( ('match_mover', 'loadmarker.rz2'), ('uvtrack', 'test_v1.uv'), ('uvtrack', 'test_v3.uv'), ('uvtrack', 'test_v4.uv'), ) for dir_name, file_name in values: path = self.get_data_path(dir_name, file_name) valid = lib_utils.is_valid_file_path(path) assert valid is True fmt = lib_utils.get_file_path_format(path) assert fmt is not None file_info = lib_utils.get_file_info(path) assert isinstance(file_info, interface.FileInfo) file_info_data = lib_utils.get_file_info_strings(path) assert isinstance(file_info_data, dict) assert len(file_info_data) == 11 keys = file_info_data.keys() assert 'fmt' in keys assert 'fmt_name' in keys assert 'num_points' in keys assert 'point_names' in keys assert 'start_frame' in keys assert 'end_frame' in keys assert 'frame_range' in keys assert 'lens_dist' in keys assert 'lens_undist' in keys assert 'positions' in keys assert 'has_camera_fov' in keys start_dir = lib_utils.get_start_directory(path) assert os.path.isdir(start_dir) is True return
def populateUi(self): config = get_config() self._file_info = None w, h = lib.get_default_image_resolution() self.imageRes_label.setEnabled(False) self.imageResWidth_label.setEnabled(False) self.imageResWidth_spinBox.setValue(w) self.imageResWidth_spinBox.setEnabled(False) self.imageResHeight_label.setEnabled(False) self.imageResHeight_spinBox.setValue(h) self.imageResHeight_spinBox.setEnabled(False) self.fileInfo_plainTextEdit.setReadOnly(True) value = get_config_value( config, 'data/load_bundle_position', const.LOAD_BUNDLE_POS_DEFAULT_VALUE) self.loadBndPositions_checkBox.setChecked(value) value = get_config_value( config, 'data/use_overscan', const.USE_OVERSCAN_DEFAULT_VALUE) self.overscan_checkBox.setChecked(value) # Get the file path from the clipboard. try: clippy = QtGui.QClipboard() text = str(clippy.text()).strip() if lib.is_valid_file_path(text): self.setFilePath(text) except Exception as e: msg = 'Could not get file path from clipboard.' LOG.warning(msg) LOG.info(str(e)) all_camera_nodes = lib.get_cameras() selected_cameras = lib.get_selected_cameras() active_camera = lib.get_active_viewport_camera() self.updateCameraList( self.camera_comboBox, self.camera_model, all_camera_nodes, selected_cameras, active_camera ) active_camera = self.getCameraData() mkr_grp_nodes = lib.get_marker_groups(active_camera) active_mkr_grp = None self.updateMarkerGroupList( self.markerGroup_comboBox, self.markerGroup_model, active_mkr_grp, mkr_grp_nodes ) value = get_config_value( config, "data/load_mode", const.LOAD_MODE_DEFAULT_VALUE ) self.populateLoadModeModel(self.loadMode_model) 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 ) self.populateDistortionModeModel(self.distortionMode_model) index = self.distortionMode_model.stringList().index(value) self.distortionMode_comboBox.setCurrentIndex(index) return