LUA V2 dialog functions and visibility of segment numbers

Case number:845813-991632
Topic:Game: Tools
Opened by:Timo van der Laan
Status:Open
Type:Suggestion
Opened on:Wednesday, January 25, 2012 - 14:58
Last modified:Monday, December 15, 2014 - 11:41

First of all, I love the new dialog possibilities but in order to make it easier to use I have 2 suggestions.

1. Create a number input box where users can type a number.
Sliders do work ok, but are not userfriendly when you are asked to enter a segmentnumber in a big protein.
2. Create a view option to make the segmentnumbers directly visible on the segment.
Repeatingly using TAB is also not userfriendly.

This would make the scripts I want to design to semiautomate things that are now done by hand a lot easier to use. F.i. Create or make bigger a helix by Rebuild and repositioning it back in place, requires now a lot of freezing and pulling. This can be semi-automated including options at the end for optimizing.

(Wed, 01/25/2012 - 14:58  |  10 comments)


bertro's picture
User offline. Last seen 7 weeks 2 days ago. Offline
Joined: 05/02/2011
Groups: Beta Folders

For 1., you can use:

SegNum = 0
local ask = dialog.CreateDialog("Title")
ask.Instructions = dialog.AddLabel("Set these values:")
ask.SegmentNumber = dialog.AddSlider("for Segment:", 1, 1, SegCnt, 0) -- (default, min, max, 0=Int/1=Dec)
ask.SegNum = dialog.AddTextbox("Or seg #:", "")
ask.OK = dialog.AddButton("OK", 1)
ask.Cancel = dialog.AddButton("Exit recipe", 0)
if (dialog.Show(ask) > 0) then
if ask.SegNum.value == "" then
SegNum = ask.SegmentNumber.value
else
SegNum = ask.SegNum.value + 0 -- to force lua string to number conversion
end
else
SegNum = nil
print("Recipe cancelled")
end

Joined: 09/21/2011
Groups: Void Crushers

Thanks, I overlooked the textbox possibility. Will have to do some input checking, but I will use it instead of sliders for segmentnumbers.

brow42's picture
User offline. Last seen 3 days 21 hours ago. Offline
Joined: 09/19/2011
Groups: None

I use textboxes for segment numbers and segment ranges. If you don't need to impose some sort of structure on the user input, the following will convert all the numbers in a string into a table, and then you can interpret the table however you want.

userinput='1,5 10 15-20'
AnyInteger='-?%d+' -- - can be a minus sign
NoNegatives='%d+' -- - is not part of a number
nums = {}
for v in string.gfind(userinput,NoNegatives) do
    table.insert(nums, tonumber(v))
end
-- nums = {1,5,10,15,20}
Joined: 06/17/2010

Cool for setting numbers, not usable when want to get range.
Thanks for tip :)

Joined: 09/21/2011
Groups: Void Crushers

Just written and tested, very usable for ranges:
function askSegPairs(title,struc,subtitle)
local Pairs={}
local Err={}
local Input=""
if struc==nil then struc="Pairs" end
repeat
local ask = dialog.CreateDialog(title)
-- Build resultstring from pairs found
local listP=""
for i=1,#Pairs do
if i>1 then listP=listP.."," end
listP=listP..Pairs[i][1].." "..Pairs[i][2]
end
if subtitle~=nil then ask.sub= dialog.AddLabel(subtitle) end
-- Present max 4 errors found
if #Err > 0 then ask.error1=dialog.AddLabel(Err[1]) end
if #Err > 1 then ask.error1=dialog.AddLabel(Err[2]) end
if #Err > 2 then ask.error1=dialog.AddLabel(Err[3]) end
if #Err > 3 then ask.error1=dialog.AddLabel(Err[4]) end
Err={}
if listP=="" then
ask.sub1=dialog.AddLabel("Input "..struc.. " of segmentnumbers between 1 and "..segCnt)
ask.nums=dialog.AddTextbox(struc,Input)
ask.OK = dialog.AddButton("OK",1)
ask.Cancel = dialog.AddButton("Cancel",0)
else
ask.conf=dialog.AddLabel(struc.." found: "..listP)
ask.OK = dialog.AddButton("Confirm",1)
ask.Cancel = dialog.AddButton("Again",0)
end
if dialog.Show(ask) > 0 then
if listP=="" then --Asking mode
local NoNegatives='%d+' -- - is not part of a number
local nums = {}
for v in string.gfind(ask.nums.value,NoNegatives) do
table.insert(nums, tonumber(v))
end
Input=ask.nums.value
-- Now checking
if #nums%2 ~= 0 then
Err[#Err+1]="Not an even number of segments found"
else
for i=1,#nums do
if nums[i]==0 or nums[i]>segCnt then
Err[#Err+1]="Number "..nums[i].." is not a segment"
end
end
if #Err==0 then
for i=1,#nums/2 do
Pairs[i]={nums[2*i-1],nums[2*i]}
end
end
end
else
return Pairs
end
else if listP=="" then return nil else Pairs={} end
end
until false
end

bertro's picture
User offline. Last seen 7 weeks 2 days ago. Offline
Joined: 05/02/2011
Groups: Beta Folders

thanks for sharing

Joined: 01/03/2012
Groups: Void Crushers

A version with proper layout is in my just posted recipe.

Joined: 09/21/2011
Groups: Void Crushers
Status: Open » Closed

Not longer needed i think

Joined: 09/24/2012
Groups: Go Science
Status: Closed » Open

Bump for the second part of the question (and also because the discussion here is useful and related):

2. Create a view option to make the segmentnumbers directly visible on the segment.
Repeatingly using TAB is also not user friendly

The full potential of the dialog tools mentioned above will be met when we'll be able to easily identify the needed segment on screen. A small black number on each segment would be enough, without loosing visibility for folding. Several recipes write info on specific segments. It would then be quick to find the segment we want to read.

spmm's picture
User offline. Last seen 41 weeks 23 hours ago. Offline
Joined: 08/05/2010
Groups: Void Crushers

User experience in density puzzles is horrible - hit tab, scroll to see the density for each and every segment - worse than eterna

Sitemap

Developed by: UW Center for Game Science, UW Institute for Protein Design, Northeastern University, Vanderbilt University Meiler Lab, UC Davis
Supported by: DARPA, NSF, NIH, HHMI, Amazon, Microsoft, Adobe, RosettaCommons