import pyfbsdk as fb
import pyfbsdk_additions as fba
##Create A List Of All Cameras In The Scene
def GenerateCamList():
##Clean Out The Drop Down List And Generate A New List
delMe = DrpDwn_CamList.Items
for i in DrpDwn_CamList.Items[:]:
if i in delMe:
DrpDwn_CamList.Items.remove(i)
for cam in fb.FBSystem().Scene.Cameras:
DrpDwn_CamList.Items.append(cam.LongName)
##Filter Out Orthographic Cameras If Then "Filter Out Orthagraphic Cameras" Check Box Is Active
if btnFilterCamList.State == 1:
orthoCams = ("Producer Front", "Producer Back", "Producer Right", "Producer Left", "Producer Top", "Producer Bottom")
for i in DrpDwn_CamList.Items[:]:
if i in orthoCams:
DrpDwn_CamList.Items.remove(i)
##Filter Camera List By User Defined Name
if efilterCamByString.Text != "":
##Create A Data List
data = DrpDwn_CamList.Items
##Create An Empty Filter List
filterData = []
for i in data:
if efilterCamByString.Text.lower() in i.lower():
##Add Items To Filter List Based On The String Provided In The UI Field
filterData.extend([i])
##Generate The Filtered List
DrpDwn_CamList.Items.removeAll()
for i in filterData:
DrpDwn_CamList.Items.append(str(i))
##Filter Out Orthagraphic Cameras Check Box
def btnFilterCamList_CallBack(control, event):
GenerateCamList()
##Switch Viewer Camera To The Selected Drop Down Item
def CameraList_CallBack(control, event):
try:
cameraName = DrpDwn_CamList.Items[DrpDwn_CamList.ItemIndex]
for cam in fb.FBSystem().Scene.Cameras:
if cam.LongName == cameraName:
fb.FBApplication().SwitchViewerCamera(cam)
global camtool_CurrentCam
camtool_CurrentCam = cam
btnViewCameraInterest.State = camtool_CurrentCam.ViewCameraInterest
btnViewNearFarPlane.State = camtool_CurrentCam.ViewNearFarPlane = btnViewNearFarPlane.State
btnViewShowName.State = camtool_CurrentCam.ViewShowName
btnViewShowGrid.State = camtool_CurrentCam.ViewShowGrid
btnViewShowAxis.State = camtool_CurrentCam.ViewShowAxis
btnViewShowTimeCode.State = camtool_CurrentCam.ViewShowTimeCode
btnViewOpticalCenter.State = camtool_CurrentCam.ViewOpticalCenter
btnDisplaySafeArea.State = camtool_CurrentCam.PropertyList.Find("DisplaySafeArea").Data
btnViewCameraInterest.Enabled = True
btnViewNearFarPlane.Enabled = True
btnViewShowName.Enabled = True
btnViewShowGrid.Enabled = True
btnViewShowAxis.Enabled = True
btnViewShowTimeCode.Enabled = True
btnViewOpticalCenter.Enabled = True
btnDisplaySafeArea.Enabled = True
DrpDwn_SafeFrame.Enabled = btnDisplaySafeArea.State
return camtool_CurrentCam
except: pass
##Filter By Drop Down List By Name (As The User Types The List Will Be Updated)
def efilterCamByString_Callback(control, event):
GenerateCamList()
def UpDateCamDisplay():
try:
camtool_CurrentCam.ViewCameraInterest = btnViewCameraInterest.State
camtool_CurrentCam.ViewNearFarPlane = btnViewNearFarPlane.State
camtool_CurrentCam.ViewShowName = btnViewShowName.State
camtool_CurrentCam.ViewShowGrid = btnViewShowGrid.State
camtool_CurrentCam.ViewShowAxis = btnViewShowAxis.State
camtool_CurrentCam.ViewShowTimeCode = btnViewShowTimeCode.State
camtool_CurrentCam.ViewOpticalCenter = btnViewOpticalCenter.State
camtool_CurrentCam.PropertyList.Find("DisplaySafeArea").Data = btnDisplaySafeArea.State
##Enable Safe Frame Area Drop Down Menu
DrpDwn_SafeFrame.Enabled = btnDisplaySafeArea.State
if camtool_CurrentCam.SafeAreaMode == "kFBSafeAreaSquare": DrpDwn_SafeFrame.ItemIndex = 0
if camtool_CurrentCam.SafeAreaMode == "kFBSafeAreaRound": DrpDwn_SafeFrame.ItemIndex = 1
except: pass
##Camera Display Options
def CameraDislay_CallBack(control, event):
UpDateCamDisplay()
##Change Safe Frame Area Visual
def Change_SafeFrameArea():
if DrpDwn_SafeFrame.Items[DrpDwn_SafeFrame.ItemIndex] == "Square Safe Area":
try: camtool_CurrentCam.SafeAreaMode = fb.FBCameraSafeAreaMode.kFBSafeAreaSquare
except: pass
if DrpDwn_SafeFrame.Items[DrpDwn_SafeFrame.ItemIndex] == "Round Safe Area":
try: camtool_CurrentCam.SafeAreaMode = fb.FBCameraSafeAreaMode.kFBSafeAreaRound
except: pass
##Set Safe Frame Area Drop Down Menu
def DrpDwn_SafeFrame_CallBack(control, event):
Change_SafeFrameArea()
##Refresh Camera List Button
def RefreshCamList_CallBack(control, event):
GenerateCamList()
'''
UI Layout
'''
def PopulateTool(t):
##Camera Drop Down List------------------------------------------------------------------------------
CamList = fb.FBLabel()
x = fb.FBAddRegionParam(5,fb.FBAttachType.kFBAttachNone,"")
y = fb.FBAddRegionParam(5,fb.FBAttachType.kFBAttachNone,"")
w = fb.FBAddRegionParam(290,fb.FBAttachType.kFBAttachNone,"")
h = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("CamList","CamList", x, y, w, h)
t.SetControl("CamList", CamList)
CamList.Caption = "Camera List:"
CamList.ReadOnly = True
CamList.Style = fb.FBTextStyle.kFBTextStyleBold
CamList.Justify = fb.FBTextJustify.kFBTextJustifyCenter
global DrpDwn_CamList
DrpDwn_CamList = fb.FBList()
x = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachLeft,"CamList")
y = fb.FBAddRegionParam(5,fb.FBAttachType.kFBAttachBottom,"CamList")
w = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachRight,"CamList")
h = fb.FBAddRegionParam(120,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("DrpDwn_CamList","DrpDwn_CamList", x, y, w, h)
t.SetControl("DrpDwn_CamList", DrpDwn_CamList)
DrpDwn_CamList.ItemIndex = -1
DrpDwn_CamList.MultiSelect = False
DrpDwn_CamList.ExtendedSelect = False
DrpDwn_CamList.Style = fb.FBListStyle.kFBVerticalList
for cam in fb.FBSystem().Scene.Cameras:
DrpDwn_CamList.Items.append(cam.LongName)
DrpDwn_CamList.OnChange.Add(CameraList_CallBack)
##Filter Orthographic And Perspective Cameras
global btnFilterCamList
btnFilterCamList = fb.FBButton()
x = fb.FBAddRegionParam(10,fb.FBAttachType.kFBAttachRight,"DrpDwn_CamList")
y = fb.FBAddRegionParam(-20,fb.FBAttachType.kFBAttachTop,"DrpDwn_CamList")
w = fb.FBAddRegionParam(185,fb.FBAttachType.kFBAttachNone,"")
h = fb.FBAddRegionParam(35,fb.FBAttachType.kFBAttachNone,"DrpDwn_CamList")
t.AddRegion("btnFilterCamList","btnFilterCamList", x, y, w, h)
t.SetControl("btnFilterCamList", btnFilterCamList)
btnFilterCamList.Caption = "Filter Out Orthographic Cameras"
btnFilterCamList.Style = fb.FBButtonStyle.kFBCheckbox
btnFilterCamList.State = 0
btnFilterCamList.Justify = fb.FBTextJustify.kFBTextJustifyCenter
btnFilterCamList.Look = fb.FBButtonLook.kFBLookNormal
btnFilterCamList.OnClick.Add(btnFilterCamList_CallBack)
##Filter By String
FilterCamByName = fb.FBLabel()
x = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachLeft,"DrpDwn_CamList")
y = fb.FBAddRegionParam(10,fb.FBAttachType.kFBAttachBottom,"DrpDwn_CamList")
w = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachRight,"DrpDwn_CamList")
h = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("FilterCamByName","FilterCamByName", x, y, w, h)
t.SetControl("FilterCamByName", FilterCamByName)
FilterCamByName.Caption = "Filter Camer List By Name:"
FilterCamByName.ReadOnly = True
FilterCamByName.Style = fb.FBTextStyle.kFBTextStyleBold
FilterCamByName.Justify = fb.FBTextJustify.kFBTextJustifyCenter
global efilterCamByString
efilterCamByString = fb.FBEdit()
x = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachLeft,"FilterCamByName")
y = fb.FBAddRegionParam(5,fb.FBAttachType.kFBAttachBottom,"FilterCamByName")
w = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachRight,"FilterCamByName")
h = fb.FBAddRegionParam(25,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("efilterCamByString","efilterCamByString", x, y, w, h)
t.SetControl("efilterCamByString", efilterCamByString)
efilterCamByString.OnChange.Add(efilterCamByString_Callback)
CamDisplay = fb.FBLabel()
x = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachLeft,"btnFilterCamList")
y = fb.FBAddRegionParam(1,fb.FBAttachType.kFBAttachBottom,"btnFilterCamList")
w = fb.FBAddRegionParam(100,fb.FBAttachType.kFBAttachNone,"")
h = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("CamDisplay","CamDisplay", x, y, w, h)
t.SetControl("CamDisplay", CamDisplay)
CamDisplay.Caption = "Display:"
CamDisplay.ReadOnly = True
CamDisplay.Style = fb.FBTextStyle.kFBTextStyleBold
CamDisplay.Justify = fb.FBTextJustify.kFBTextJustifyLeft
##Display Check Boxes
global btnViewCameraInterest
btnViewCameraInterest = fb.FBButton()
x = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachLeft,"CamDisplay")
y = fb.FBAddRegionParam(2,fb.FBAttachType.kFBAttachBottom,"CamDisplay")
w = fb.FBAddRegionParam(110,fb.FBAttachType.kFBAttachNone,"")
h = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("btnViewCameraInterest","btnViewCameraInterest", x, y, w, h)
t.SetControl("btnViewCameraInterest", btnViewCameraInterest)
btnViewCameraInterest.Caption = "Camera Interest"
btnViewCameraInterest.Style = fb.FBButtonStyle.kFBCheckbox
btnViewCameraInterest.Enabled = False
btnViewCameraInterest.State = 0
btnViewCameraInterest.Justify = fb.FBTextJustify.kFBTextJustifyCenter
btnViewCameraInterest.Look = fb.FBButtonLook.kFBLookNormal
btnViewCameraInterest.OnClick.Add(CameraDislay_CallBack)
global btnViewNearFarPlane
btnViewNearFarPlane = fb.FBButton()
x = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachLeft,"btnViewCameraInterest")
y = fb.FBAddRegionParam(2,fb.FBAttachType.kFBAttachBottom,"btnViewCameraInterest")
w = fb.FBAddRegionParam(140,fb.FBAttachType.kFBAttachNone,"")
h = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("btnViewNearFarPlane","btnViewNearFarPlane", x, y, w, h)
t.SetControl("btnViewNearFarPlane", btnViewNearFarPlane)
btnViewNearFarPlane.Caption = "Camera Near/Far Plane"
btnViewNearFarPlane.Style = fb.FBButtonStyle.kFBCheckbox
btnViewNearFarPlane.Enabled = False
btnViewNearFarPlane.State = 0
btnViewNearFarPlane.Justify = fb.FBTextJustify.kFBTextJustifyCenter
btnViewNearFarPlane.Look = fb.FBButtonLook.kFBLookNormal
btnViewNearFarPlane.OnClick.Add(CameraDislay_CallBack)
global btnViewShowName
btnViewShowName = fb.FBButton()
x = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachLeft,"btnViewNearFarPlane")
y = fb.FBAddRegionParam(2,fb.FBAttachType.kFBAttachBottom,"btnViewNearFarPlane")
w = fb.FBAddRegionParam(95,fb.FBAttachType.kFBAttachNone,"")
h = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("btnViewShowName","btnViewShowName", x, y, w, h)
t.SetControl("btnViewShowName", btnViewShowName)
btnViewShowName.Caption = "Camera Label"
btnViewShowName.Style = fb.FBButtonStyle.kFBCheckbox
btnViewShowName.Enabled = False
btnViewShowName.State = 1
btnViewShowName.Justify = fb.FBTextJustify.kFBTextJustifyCenter
btnViewShowName.Look = fb.FBButtonLook.kFBLookNormal
btnViewShowName.OnClick.Add(CameraDislay_CallBack)
global btnViewShowGrid
btnViewShowGrid = fb.FBButton()
x = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachLeft,"btnViewShowName")
y = fb.FBAddRegionParam(2,fb.FBAttachType.kFBAttachBottom,"btnViewShowName")
w = fb.FBAddRegionParam(50,fb.FBAttachType.kFBAttachNone,"")
h = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("btnViewShowGrid","btnViewShowGrid", x, y, w, h)
t.SetControl("btnViewShowGrid", btnViewShowGrid)
btnViewShowGrid.Caption = "Grid"
btnViewShowGrid.Style = fb.FBButtonStyle.kFBCheckbox
btnViewShowGrid.Enabled = False
btnViewShowGrid.State = 1
btnViewShowGrid.Justify = fb.FBTextJustify.kFBTextJustifyCenter
btnViewShowGrid.Look = fb.FBButtonLook.kFBLookNormal
btnViewShowGrid.OnClick.Add(CameraDislay_CallBack)
global btnViewShowAxis
btnViewShowAxis = fb.FBButton()
x = fb.FBAddRegionParam(40,fb.FBAttachType.kFBAttachRight,"btnViewShowGrid")
y = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachTop,"btnViewShowGrid")
w = fb.FBAddRegionParam(50,fb.FBAttachType.kFBAttachNone,"")
h = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("btnViewShowAxis","btnViewShowAxis", x, y, w, h)
t.SetControl("btnViewShowAxis", btnViewShowAxis)
btnViewShowAxis.Caption = "Axis"
btnViewShowAxis.Style = fb.FBButtonStyle.kFBCheckbox
btnViewShowAxis.Enabled = False
btnViewShowAxis.State = 0
btnViewShowAxis.Justify = fb.FBTextJustify.kFBTextJustifyCenter
btnViewShowAxis.Look = fb.FBButtonLook.kFBLookNormal
btnViewShowAxis.OnClick.Add(CameraDislay_CallBack)
global btnViewShowTimeCode
btnViewShowTimeCode = fb.FBButton()
x = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachLeft,"btnViewShowGrid")
y = fb.FBAddRegionParam(2,fb.FBAttachType.kFBAttachBottom,"btnViewShowGrid")
w = fb.FBAddRegionParam(80,fb.FBAttachType.kFBAttachNone,"")
h = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("btnViewShowTimeCode","btnViewShowTimeCode", x, y, w, h)
t.SetControl("btnViewShowTimeCode", btnViewShowTimeCode)
btnViewShowTimeCode.Caption = "Time Code"
btnViewShowTimeCode.Style = fb.FBButtonStyle.kFBCheckbox
btnViewShowTimeCode.Enabled = False
btnViewShowTimeCode.State = 0
btnViewShowTimeCode.Justify = fb.FBTextJustify.kFBTextJustifyCenter
btnViewShowTimeCode.Look = fb.FBButtonLook.kFBLookNormal
btnViewShowTimeCode.OnClick.Add(CameraDislay_CallBack)
global btnViewOpticalCenter
btnViewOpticalCenter = fb.FBButton()
x = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachLeft,"btnViewShowAxis")
y = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachTop,"btnViewShowTimeCode")
w = fb.FBAddRegionParam(60,fb.FBAttachType.kFBAttachNone,"")
h = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("btnViewOpticalCenter","btnViewOpticalCenter", x, y, w, h)
t.SetControl("btnViewOpticalCenter", btnViewOpticalCenter)
btnViewOpticalCenter.Caption = "Center"
btnViewOpticalCenter.Style = fb.FBButtonStyle.kFBCheckbox
btnViewOpticalCenter.Enabled = False
btnViewOpticalCenter.State = 0
btnViewOpticalCenter.Justify = fb.FBTextJustify.kFBTextJustifyCenter
btnViewOpticalCenter.Look = fb.FBButtonLook.kFBLookNormal
btnViewOpticalCenter.OnClick.Add(CameraDislay_CallBack)
global btnDisplaySafeArea
btnDisplaySafeArea = fb.FBButton()
x = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachLeft,"btnViewShowTimeCode")
y = fb.FBAddRegionParam(2,fb.FBAttachType.kFBAttachBottom,"btnViewShowTimeCode")
w = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachNone,"")
h = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("btnDisplaySafeArea","btnDisplaySafeArea", x, y, w, h)
t.SetControl("btnDisplaySafeArea", btnDisplaySafeArea)
btnDisplaySafeArea.Caption = ""
btnDisplaySafeArea.Style = fb.FBButtonStyle.kFBCheckbox
btnDisplaySafeArea.Enabled = False
btnDisplaySafeArea.State = 0
btnDisplaySafeArea.Justify = fb.FBTextJustify.kFBTextJustifyCenter
btnDisplaySafeArea.Look = fb.FBButtonLook.kFBLookNormal
btnDisplaySafeArea.OnClick.Add(CameraDislay_CallBack)
global DrpDwn_SafeFrame
DrpDwn_SafeFrame = fb.FBList()
x = fb.FBAddRegionParam(2,fb.FBAttachType.kFBAttachRight,"btnDisplaySafeArea")
y = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachTop,"btnDisplaySafeArea")
w = fb.FBAddRegionParam(155,fb.FBAttachType.kFBAttachRight,"CamList")
h = fb.FBAddRegionParam(20,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("DrpDwn_SafeFrame","DrpDwn_SafeFrame", x, y, w, h)
t.SetControl("DrpDwn_SafeFrame", DrpDwn_SafeFrame)
DrpDwn_SafeFrame.ItemIndex = 0
DrpDwn_SafeFrame.MultiSelect = False
DrpDwn_SafeFrame.ExtendedSelect = False
DrpDwn_SafeFrame.Enabled = False
DrpDwn_SafeFrame.Style = fb.FBListStyle.kFBDropDownList
safeFrameList = ["Square Safe Area", "Round Safe Area"]
for i in safeFrameList:
DrpDwn_SafeFrame.Items.append(i)
DrpDwn_SafeFrame.OnChange.Add(DrpDwn_SafeFrame_CallBack)
btnRefreshCamList = fb.FBButton()
x = fb.FBAddRegionParam(0,fb.FBAttachType.kFBAttachLeft,"btnDisplaySafeArea")
y = fb.FBAddRegionParam(15,fb.FBAttachType.kFBAttachBottom,"btnDisplaySafeArea")
w = fb.FBAddRegionParam(40,fb.FBAttachType.kFBAttachRight,"DrpDwn_SafeFrame")
h = fb.FBAddRegionParam(40,fb.FBAttachType.kFBAttachNone,"")
t.AddRegion("btnRefreshCamList","btnRefreshCamList", x, y, w, h)
t.SetControl("btnRefreshCamList", btnRefreshCamList)
btnRefreshCamList.Caption = "Refresh Camera List"
btnRefreshCamList.Style = fb.FBButtonStyle.kFBPushButton
btnRefreshCamList.Justify = fb.FBTextJustify.kFBTextJustifyCenter
btnRefreshCamList.Look = fb.FBButtonLook.kFBLookNormal
btnRefreshCamList.OnClick.Add(RefreshCamList_CallBack)
def CreateTool():
global t
t = fba.FBCreateUniqueTool("Swtich To Camera Tool")
t.MinSizeX = t.MaxSizeX = 495
t.MinSizeY = t.MaxSizeY = 250
PopulateTool(t)
fb.ShowTool(t)
CreateTool()
上一篇
Docker
2024-05-10
下一篇
unreal导出MH关键帧
2024-05-10