try destroydialog igorznag_camera_info catch()
rollout igorznag_camera_info "Camera Info"
(
groupbox gb_render "Output Size" pos:[5,5] width:195 height:80
spinner sp_width "Width: " range:[1,32768,640] type:#integer scale:1 fieldWidth:45 pos:[10,20]
spinner sp_height "Height: " range:[1,32768,480] type:#integer scale:1 fieldWidth:45 pos:[10,40]
spinner sp_image_aspect "Image Aspect: " range:[0.001,32768,1.333] type:#float scale:0.1 fieldWidth:45 pos:[10,60]
checkbutton cb_ia_lock "Lock" pos:[150,57]
timer clock interval:33
button btn_set "Set" pos:[120,20] width:70 height:30
local igorznag_camera_temp_handle=undefined
fn precision_3 n= (return (floor (n*1000))/1000)
fn round_to val n =
(local mult = 10.0 ^ n;(floor ((val * mult) + 0.5)) / mult)
on btn_set pressed do
(
c=getActiveCamera()
if c!=undefined then
(
setUserProp c "igorznag_render_width" sp_width.value
setUserProp c "igorznag_render_height" sp_height.value
renderWidth= sp_width.value;renderHeight=sp_height.value
renderSceneDialog.update()
)
)--on btn_set apply pressed do
on clock tick do
(
c=getActiveCamera()
if c!=undefined then
(
if c.inode.handle!=igorznag_camera_temp_handle then
(
igorznag_camera_temp_handle=c.inode.handle
rw=getUserProp c "igorznag_render_width"
rh=getUserProp c "igorznag_render_height"
if rw!=undefined and rh!=undefined then
try
(
sp_width.value=rw;sp_height.value=rh;
renderWidth=rw;renderHeight=rh
renderSceneDialog.update()
sp_image_aspect.value=precision_3 (1.0*rw/rh)
) catch()
)
)--if c!=undefined then
)--on clock tick do
on sp_width entered do
(
if cb_ia_lock.checked==false then sp_image_aspect.value=precision_3(1.0*sp_width.value/sp_height.value)
else sp_height.value=round_to (sp_width.value/sp_image_aspect.value) 0
btn_set.pressed()
)
on sp_height entered do
(
if cb_ia_lock.checked==false then sp_image_aspect.value=precision_3(1.0*sp_width.value/sp_height.value)
else sp_width.value=round_to (sp_height.value*sp_image_aspect.value) 0
btn_set.pressed()
)
on sp_image_aspect entered do
(
sp_height.value=round_to (sp_width.value/sp_image_aspect.value) 0
btn_set.pressed()
)
on cb_ia_lock changed arg do
(
sp_image_aspect.enabled=not arg
)
); createdialog igorznag_camera_info 200 90 style:#(#style_minimizebox,#style_titlebar,#style_sysmenu)