def updateFileInfoText(self): file_path = self.getFilePath() info_widget = self.fileInfo_plainTextEdit valid = fileutils.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 = fileutils.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 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_fileutils.is_valid_file_path(path) assert valid is True fmt = lib_fileutils.get_file_path_format(path) assert fmt is not None file_info = lib_fileutils.get_file_info(path) assert isinstance(file_info, interface.FileInfo) file_info_data = lib_fileutils.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) # Get the file path from the clipboard. try: clippy = QtGui.QClipboard() text = str(clippy.text()).strip() if fileutils.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 ) col_list = col_lib.get_collections() active_col = state_lib.get_active_collection() self.updateCollectionList( self.collection_comboBox, self.collection_model, active_col, col_list ) # If the user's preferences say to add the marker to the # collection, then turn on the feature. auto_add_marker = get_user_prefs_add_marker_to_collection() self.collection_checkBox.setChecked(auto_add_marker) self.updateCollectionEnabledState() 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) value = get_config_value( config, 'data/use_overscan', const.USE_OVERSCAN_DEFAULT_VALUE) self.overscan_checkBox.setChecked(value) self.updateOverscanValues() return