def _build_gui(): """ Build the widgets at the top of the window. :returns: 3DEqualizer UI request id. """ # Get the clipboard value and test if it's a valid .mmcamera file, # if so use it as the default. If not, use the current 3DE file # path as a directory to search. cwd_path = os.getcwd() proj_path = tde4.getProjectPath() file_path = None if mmcamera_format.SUPPORT_CLIPBOARD is True: file_path = tde4.getClipboardString() file_data = None if file_path: file_data = _parse_data(file_path) has_vaild_data = _file_data_has_valid_data(file_data) if has_vaild_data is not True: file_path = proj_path or cwd_path window_requester = tde4.createCustomRequester() file_pattern = '*' + EXT tde4.addFileWidget( window_requester, FILE_BROWSER_WIDGET, FILE_BROWSER_LABEL, file_pattern, file_path, ) tde4.setWidgetCallbackFunction( window_requester, FILE_BROWSER_WIDGET, '_build_widgets' ) tde4.addSeparatorWidget(window_requester, SEP_01_WIDGET) pgroup_id, cam_id, lens_id = _query_selection_state() has_vaild_data = _file_data_has_valid_data(file_data) if has_vaild_data is not True or not pgroup_id or not cam_id or not lens_id: _build_widgets(window_requester, FILE_BROWSER_WIDGET, 0) else: _build_widgets_with_data(window_requester, pgroup_id, cam_id, lens_id, file_data) return window_requester
def buildUI(): # calculate Output file # we will get the path of the first camera - changed # to path to file .3DE wo extension ''' firstCam = tde4.getIndexCamera(0) firstCamPath = tde4.getCameraPath(firstCam).replace('\\', '/') ''' if tde4.getProjectPath() == None: print "Can't get the Project Path" outputFile = "Can't get the Project Path" else: # the same as the file 3DE wo the extension (asume in the 4 last chars) outputFile = tde4.getProjectPath().replace('/', '\\')[:-4] # open requester... req = tde4.createCustomRequester() tde4.addFileWidget(req, "file_browser", "Browse...", "*", outputFile) # tde4.addTextFieldWidget(req, "filePath", "Optuput file", outputFile) labels = nukeVersions.keys() labels.sort() labels.reverse() print labels #tde4.addOptionMenuWidget(req, "nukeVersion", "Nuke Version", *labels) #tde4.addToggleWidget(req, "openNuke", "Open nuke after Export", 0) # To Export tde4.addSeparatorWidget(req, "sep2") # export all cameras tde4.addToggleWidget(req, "exportAllCameras", "Export all Cameras", 1) tde4.setWidgetCallbackFunction(req, "exportAllCameras", "callBackExportAll") tde4.addSeparatorWidget(req, "sepAllCameras") # cameras to select for cameraIndex in range(tde4.getNoCameras()): cameraTmp = tde4.getIndexCamera(cameraIndex) if not tools.validCamera(cameraTmp): buildUINotSupported(req, cameraIndex, cameraTmp) else: buildUICamera(req, cameraIndex, cameraTmp) return req
def buildUICamera(req, cameraIndex, cameraTmp): imageHeightOuttmp, imageWidthOuttmp = getOutSize(req, cameraIndex, cameraTmp) nametmp = "exportCamera" + str(cameraIndex) texttmp = "Export Camera " + str(tde4.getCameraName(cameraTmp)) tde4.addToggleWidget(req, nametmp, texttmp, 1) tde4.setWidgetCallbackFunction(req, nametmp, "callBackExportCamera") firstFrame = tde4.getCameraSequenceAttr(cameraTmp)[0] strRes = camWidgetFormat.format(imageWidth=str(imageWidthOuttmp), sep=resSpliter, imageHeight=str(imageHeightOuttmp), firstFrame=firstFrame) camResWidgetName = camWidgetPrefix + str(cameraIndex) log.debug('camResWidgetName (creation): ' + camResWidgetName) tde4.addTextFieldWidget(req, camResWidgetName, camResWidgetText, strRes) tde4.addSeparatorWidget(req, "sep" + str(cameraIndex))
def _build_widgets_with_data(req, pgroup_id, cam_id, lens_id, file_data): """ Build the bottom half of the window, using the data from the mmcamera file. :param req: The 3DEqualizer window requester id. :type req: str :param pgroup_id: The Point Group ID with the active camera in it. :type pgroup_id: str :param cam_id: The Camera ID to apply data to. :type cam_id: str :param lens_id: The Lens ID to apply data to. :type lens_id: str :param file_data: Valid file data from a .mmcamera file. :type file_data: dict """ assert isinstance(file_data, dict) assert 'data' in file_data data = file_data.get('data') assert data is not None image_data = data.get('image', dict()) plate_path = image_data.get('file_path') pixel_aspect = image_data.get('pixel_aspect_ratio') camera_name = str(data.get('name')) start_frame = str(data.get('start_frame')) end_frame = str(data.get('end_frame')) attrs_data = data.get('attr', dict()) attr_names = list(attrs_data.keys()) if not start_frame or not end_frame: msg = ('File contains invalid frame range: {file_start}-{file_end}') msg = msg.format( file_start=start_frame, file_end=end_frame, ) tde4.postQuestionRequester(TITLE, msg, 'Ok') return start_frame = int(start_frame) end_frame = int(end_frame) # Detect if the parsed file data does not have any frame # information in common with the selected camera. if not plate_path: has_common_frames = False cam_start, cam_end, _ = tde4.getCameraSequenceAttr(cam_id) if str(start_frame) and str(end_frame) and str(cam_start) and str( cam_end): cam_start = int(cam_start) cam_end = int(cam_end) cam_frames = set(range(cam_start, cam_end + 1)) file_frames = set(range(start_frame, end_frame + 1)) has_common_frames = not file_frames.isdisjoint(cam_frames) if has_common_frames is False: msg = ('The file path does not contain animated' ' data in the camera\'s frame range.\n' 'File Frame Range: {file_start}-{file_end}\n' 'Camera Frame Range: {cam_start}-{cam_end}\n') msg = msg.format(file_start=start_frame, file_end=end_frame, cam_start=cam_start, cam_end=cam_end) tde4.postQuestionRequester(TITLE, msg, 'Ok') return tde4.addSeparatorWidget(req, SEP_01_WIDGET) if plate_path: plate_path = os.path.normpath(plate_path) tde4.addToggleWidget(req, PLATE_LOAD_WIDGET, PLATE_LOAD_LABEL, True) tde4.addTextFieldWidget(req, PLATE_PATH_WIDGET, PLATE_PATH_LABEL, plate_path) plate_range = '{0}-{1}'.format(start_frame, end_frame) tde4.addTextFieldWidget(req, PLATE_RANGE_WIDGET, PLATE_RANGE_LABEL, plate_range) tde4.addSeparatorWidget(req, SEP_03_WIDGET) if camera_name: tde4.addToggleWidget(req, CAMERA_NAME_WIDGET, CAMERA_NAME_LABEL, True) tde4.addTextFieldWidget(req, START_FRAME_WIDGET, START_FRAME_LABEL, str(start_frame)) tde4.addTextFieldWidget(req, END_FRAME_WIDGET, END_FRAME_LABEL, str(end_frame)) has_fbk_w = ATTR_FBK_WIDTH in attr_names has_fbk_h = ATTR_FBK_HEIGHT in attr_names if has_fbk_w or has_fbk_h: tde4.addToggleWidget(req, ATTR_FBK_SIZE_WIDGET, ATTR_FBK_SIZE_LABEL, True) has_fbk_x = ATTR_FBK_OFFSET_X in attr_names has_fbk_y = ATTR_FBK_OFFSET_Y in attr_names if has_fbk_x or has_fbk_y: tde4.addToggleWidget(req, ATTR_FBK_OFFSET_WIDGET, ATTR_FBK_OFFSET_LABEL, True) if pixel_aspect: label = '{0} ({1})'.format(PIXEL_ASPECT_LABEL, str(pixel_aspect)) tde4.addToggleWidget(req, PIXEL_ASPECT_WIDGET, label, True) has_fl = ATTR_FOCAL_LENGTH in attr_names if has_fl: samples = attrs_data.get(ATTR_FOCAL_LENGTH) is_static = mmcamera_format.detect_samples_are_static(samples) static_mode = 'static' if is_static is not True: static_mode = 'animated' label = '{0} ({1})'.format(ATTR_FOCAL_LENGTH_LABEL, static_mode) tde4.addToggleWidget(req, ATTR_FOCAL_LENGTH_WIDGET, label, True) has_tx = ATTR_TRANSLATE_X in attr_names has_ty = ATTR_TRANSLATE_Y in attr_names has_tz = ATTR_TRANSLATE_Z in attr_names if has_tx or has_ty or has_tz: label = ATTR_TRANSLATE_LABEL + ' ' label += 'X' * has_tx label += 'Y' * has_ty label += 'Z' * has_tz tde4.addToggleWidget(req, ATTR_TRANSLATE_WIDGET, label, True) has_rx = ATTR_ROTATE_X in attr_names has_ry = ATTR_ROTATE_Y in attr_names has_rz = ATTR_ROTATE_Z in attr_names if has_rx or has_ry or has_rz: label = ATTR_ROTATE_LABEL + ' ' label += 'X' * has_rx label += 'Y' * has_ry label += 'Z' * has_rz tde4.addToggleWidget(req, ATTR_ROTATE_WIDGET, label, True) return