Help with coding panel - suggestions are welcome!

Dear Forum,

I would be very thankful if any of you with more experience in making GUIs would give me a hand in making a panel to display results.
The layout of the panel I am implementing is shown in attachment to this post.

Essentially, the purpose of the panel is to display results of data corresponding to signal intensity vs time. From the time series, it is possible to access different parameters, such as peak height, peak width, peak area, etc. The purpose of the panel is to allow the user to check several of these parameters at the same time, and display them either as a Time Series plot, a Histogram, or as a bar chart for the display of averages.

Currently, I am attempting to implement this as as a panel with 6 areas in which the data can be visualized. Each group of elements is coded with terminations in indexes 0 through 5 (e.g. ControlBox_A0, ControlBox_A1, ControlBox_A2,..., ControlBox_A5). Initially I thought of taking advantage of the indexes combined with a switch-case-Endswhich approach, but it seems that cases have to be declared as literal strings, not string variables and $ cannot be used either.

My impression is that I have to approach such panel with a lengthy series of If-Else-EndIf statements, for each of the plot areas. So I am thinking of the writing a very monotonous, lengthy and highly repetitive sections of code for each of the plot areas. I am just wondering if anyone as a bit more interesting idea on to code for this panel without much repetition, in a bit more elegant way.

Please drop me a line if you have any thoughts on this, either towards implementing this particular panel structure, or maybe with an entirely new layout.

Best,
R.
Hi,

It's hard for me to tell exactly what you want to do without seeing sample code. However, my thought is that the operations for what you want to accomplish (such as manipulating a graph) will accept string variables to specify the window/subwindow areas of your panel. So you might consider removing the area specific part of the control name to get the area to work on. Then process the control as a generic type and finally recombine the generic control action with the area specific part in a command that permits a variable subwindow name.

Hope this makes sense.
Extract the last digit of the name and use it in the switch.

num = str2num(ctrlname[strlen(ctrlname)-1])
switch(num)
...
endswitch


--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
If you make each area into a subwindow, the controls can use the same name:

Window Panel0() : Panel
    PauseUpdate; Silent 1       // building window...
    NewPanel /W=(151,77,635,375)
    DefineGuide UGH0={FB,0.550802,FT},UGV0={FL,116}
    NewPanel/W=(127,97,521,294)/FG=(UGV0,FT,FR,UGH0)/HOST=#
    Button button0,pos={10.00,10.00},size={50.00,20.00}
    RenameWindow #,P0
    SetActiveSubwindow ##
    NewPanel/W=(185,97,391,293)/FG=(UGV0,UGH0,FR,FB)/HOST=#
    Button button0,pos={10.00,10.00},size={50.00,20.00}
    RenameWindow #,P1
    SetActiveSubwindow ##
EndMacro


Then you can write one routine to update the area designated by the subwindow name.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
JimProuty wrote:
If you make each area into a subwindow, the controls can use the same name:

Window Panel0() : Panel
    PauseUpdate; Silent 1       // building window...
    NewPanel /W=(151,77,635,375)
    DefineGuide UGH0={FB,0.550802,FT},UGV0={FL,116}
    NewPanel/W=(127,97,521,294)/FG=(UGV0,FT,FR,UGH0)/HOST=#
    Button button0,pos={10.00,10.00},size={50.00,20.00}
    RenameWindow #,P0
    SetActiveSubwindow ##
    NewPanel/W=(185,97,391,293)/FG=(UGV0,UGH0,FR,FB)/HOST=#
    Button button0,pos={10.00,10.00},size={50.00,20.00}
    RenameWindow #,P1
    SetActiveSubwindow ##
EndMacro


Then you can write one routine to update the area designated by the subwindow name.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.


You can also pop this into a function to save repeating the commands to make the controls in each subwindow panel.
For example:
Function MakePanel()
    NewPanel /W=(151,77,635,375) /N=MyPanel
    DefineGuide UGH0={FB,0.550802,FT},UGV0={FL,116}
    Variable i
    for(i = 0; i < 2; i += 1)
        switch(i)
            case 0:
                NewPanel/W=(127,97,521,294)/FG=(UGV0,FT,FR,UGH0)/HOST=MyPanel
                break
            case 1:
                NewPanel/W=(185,97,391,293)/FG=(UGV0,UGH0,FR,FB)/HOST=MyPanel
                break
        endswitch
        Button button0,pos={10.00,10.00},size={50.00,20.00}
        // add more controls here...
       
        RenameWindow #,$("P" + num2istr(i))
    endfor
    SetActiveSubwindow ##
End


Hope this helps,
Kurt



Dear all,

This is quite an interesting assortment of suggestions.
Some of the things you guys suggested are fairly new to me, so I'm very glad for your input.
Many thanks to all of you - I will study these!

Cheers,

R.