< Previous | Contents | Manuals Home | Boris FX
Using Pick Modes
The following is a simple test program showing the Dialog pick modes being used in a detached dialog. (It must be detached, ie non-modal, so that the camera view isn’t locked up, in order to be able to pick the point/rectangle!)
//SIZZLET Pick and draw test
// Includes a per-frame redrawn thingie
hsz = 0.01
vsz = 0.02
pntcnt = 0
rectcnt = 0
dlg = NewDialog("picktst")
dlg.Button("setPickPoint", "Pick a point", "Start") dlg.Button("setPickRect", "Pick a rectangle", "Start") dlg.Button("setPickGfx", "Pick a graphic", "Start") dlg.Button("setDeleteGfx", "Delete picked graphic", "Start") dlg.Button("setPickCancel", "Stop picking", "Stop") dlg.Button("DeleteRects", "Delete All Rectangles", "Go!") dlg.Button("checkup", "Checkup", "Now")
dlg.Detach()
// This one is immediate! function DeleteRects()
dlg.RemoveGroup("Rect*")
end
function setPickPoint()
if (dlg.IsChecked("setPickPoint")) dlg.SetChecked("setPickPoint", 0) dlg.PickCancel()
else
dlg.SetChecked("setPickPoint", 1) dlg.PickPoint("gotPickPoint", "canceledPickPoint")
end
end
function setPickRect()
if (dlg.IsChecked("setPickRect")) dlg.SetChecked("setPickRect", 0) dlg.PickCancel()
else
dlg.SetChecked("setPickRect", 1) dlg.PickRectangle("gotPickRect", "canceledPickRect")
end
end
function setPickGfx()
if (dlg.IsChecked("setPickGfx")) dlg.SetChecked("setPickGfx", 0) dlg.PickCancel()
else
dlg.SetChecked("setPickGfx", 1) dlg.PickGraphic("gotPickGfx", "canceledPickGfx")
end
end
function setDeleteGfx()
if (dlg.IsChecked("setDeleteGfx")) dlg.SetChecked("setDeleteGfx", 0) dlg.PickCancel()
else
dlg.SetChecked("setDeleteGfx", 1) dlg.PickGraphic("gotDeleteGfx", "canceledDeleteGfx")
end
end
function setPickCancel()
// Turn these off ourself because we initiate the cancel dlg.SetChecked("setPickPoint", 0)
dlg.SetChecked("setPickRect", 0)
dlg.SetChecked("setPickGfx", 0)
dlg.SetChecked("setDeleteGfx", 0) dlg.PickCancel()
end
function checkup() // Cancel should never be checked!
Message(printf("Point: %s, Rect: %s, Gfx: %s, Cancel: %s", (dlg.IsChecked("setPickPoint") ? "checked" : "unchecked"), (dlg.IsChecked("setPickRect") ? "checked" : "unchecked"), (dlg.IsChecked("setPickGfx") ? "checked" : "unchecked"), (dlg.IsChecked("setPickCancel") ? "checked" : "unchecked")))
end
function gotPickPoint(shot, pt) dlg.SetChecked("setPickPoint", 0) nm = ("Point" ++pntcnt) dlg.AddGroup(nm, 0x0000ff)
dlg.AddGroupLine(nm, Point(pt.u-hsz, pt.v), Point(pt.u+hsz, pt.v)) dlg.AddGroupLine(nm, Point(pt.u, pt.v-vsz), Point(pt.u, pt.v+vsz)) Scene.Redraw() // so it is visible before the message shows! Message(printf("PickPoint shot %s at %g, %g", shot.nm, pt.u,
pt.v)) end
function gotPickRect(shot, pt1, pt2)
// NO: set for multiple operations... dlg.SetChecked("setPickRect", 0)
nm = ("Rect" ++pntcnt) dlg.AddGroup(nm, 0x00ff00)
dlg.AddGroupLine(nm, Point(pt1.u, pt1.v), Point(pt2.u, pt1.v)) dlg.AddGroupLine(nm, Point(pt2.u, pt1.v), Point(pt2.u, pt2.v)) dlg.AddGroupLine(nm, Point(pt2.u, pt2.v), Point(pt1.u, pt2.v)) dlg.AddGroupLine(nm, Point(pt1.u, pt2.v), Point(pt1.u, pt1.v)) Scene.Redraw() // so it is visible before the message shows! Message(printf("PickRect shot %s from %g, %g to %g, %g",
shot.nm, pt1.u, pt1.v, pt2.u, pt2.v))
return 1
end
function gotPickGfx(shot, grpnm) dlg.SetChecked("setPickGfx", 0)
Message(printf("PickGraphic shot %s group %s", shot.nm, grpnm))
end
function gotDeleteGfx(shot, grpnm) dlg.SetChecked("setDeleteGfx", 0) dlg.RemoveGroup(grpnm)
Scene.Redraw() // so it is visible before the message shows! Message(printf("DeleteGraphic shot %s group %s", shot.nm, grpnm))
end
function canceledPickPoint() dlg.SetChecked("setPickPoint", 0) Message("Canceled picking a point")
end
function canceledPickRect() dlg.SetChecked("setPickRect", 0) Message("Canceled picking a rectangle")
end
function canceledPickGfx() dlg.SetChecked("setPickGfx", 0) Message("Canceled picking a graphic")
end
function canceledDeleteGfx() dlg.SetChecked("setDeleteGfx", 0) Message("Canceled deleting a picked graphic")
end
function ReloadPanel() local nm
nm = "tbar"
if (!dlg.DoesGroupExist(nm)) // AddGroup would replace an dlg.AddGroup(nm, 0xff0000) // existing one, so test
logic
else // here is just for testing! dlg.ClearGroup(nm)
end
shot = Scene.activeObject.shot hpos = 2*frame / shot.length - 1
dlg.AddGroupLine(nm, Point(hpos, -0.1), Point(hpos, 0.1))
©2025 Boris FX, Inc. — UNOFFICIAL — Converted from original PDF.