Selection order with GetBrowserSelection
gustavoeddino
I was wondering if there is a way to accomplish the following:
I am trying to make an automatic plotting routine that plots arbitrarily selected waves from the Data Browser treating the first selection (that is the first wave I select while holding down the CTRL key) as the x-axis and the others as y-data. So far my code doesn't seem to correctly capture the order in which the waves are selected. Instead, it seems to follow the order in which the waves appear in the data browser. Thus, the x-wave is always the one that appears first on the data browser and not necessarily the one I selected first. I hope this is clear. My code is quoted below:
Function plotallselectedwaves()
//usage: open data browser and select waves to plot holding CTRL key. First selection is x-axis.
//known bug: order of selection (with ctrl) not reproduced in plot.
//variable op
SVAR cpth=root:currpth
string lby="", ns=""
string nm="",gph,leg="",d0
//string savedDataFolder = GetDataFolder(1)
Display
ModifyGraph width=288,height=216
Variable index=0
do
nm=GetBrowserSelection(index)
if (strlen(nm) == 0)
break
endif
if (index==0)
d0=nm
endif
if (index>0)
Appendtograph $nm vs $d0
gph=StringFromList(1,nm,":")
markerline(gph,index-1)
leg+="\\s("+gph+")"+nm+"\r"
print leg
endif
index+=1
while(1)
//cd $savedDataFolder
Label bottom StringFromList(1,d0,":")
Label left lby
ModifyGraph tick=2,mirror=1,minor=1,standoff=0
SetAxis/A/N=1 left;DelayUpdate
SetAxis/A/N=1 bottom
Legend/C/N=text0/J/F=0/S=3/B=1 leg
//TextBox/C/N=text2/F=0/S=3/A=MT/E savedDataFolder
// ModifyGraph width=288,height={Aspect,0.6}
// ModifyGraph mode=4,mrkThick=1,lsize=1.5,marker=2,msize=4
ModifyGraph tickUnit=1
if (op==2)
ModifyGraph log(left)=1
endif
ModifyGraph fSize=14,standoff(left)=1
//nm="VSTW_"+num2str(op)+".jpg"
//print nm, cpth
//NewPath/O nm2, cpth
//SavePICT/O/E=-6/RES=300/P=nm2 as nm
//KillPath nm2
End
//usage: open data browser and select waves to plot holding CTRL key. First selection is x-axis.
//known bug: order of selection (with ctrl) not reproduced in plot.
//variable op
SVAR cpth=root:currpth
string lby="", ns=""
string nm="",gph,leg="",d0
//string savedDataFolder = GetDataFolder(1)
Display
ModifyGraph width=288,height=216
Variable index=0
do
nm=GetBrowserSelection(index)
if (strlen(nm) == 0)
break
endif
if (index==0)
d0=nm
endif
if (index>0)
Appendtograph $nm vs $d0
gph=StringFromList(1,nm,":")
markerline(gph,index-1)
leg+="\\s("+gph+")"+nm+"\r"
print leg
endif
index+=1
while(1)
//cd $savedDataFolder
Label bottom StringFromList(1,d0,":")
Label left lby
ModifyGraph tick=2,mirror=1,minor=1,standoff=0
SetAxis/A/N=1 left;DelayUpdate
SetAxis/A/N=1 bottom
Legend/C/N=text0/J/F=0/S=3/B=1 leg
//TextBox/C/N=text2/F=0/S=3/A=MT/E savedDataFolder
// ModifyGraph width=288,height={Aspect,0.6}
// ModifyGraph mode=4,mrkThick=1,lsize=1.5,marker=2,msize=4
ModifyGraph tickUnit=1
if (op==2)
ModifyGraph log(left)=1
endif
ModifyGraph fSize=14,standoff(left)=1
//nm="VSTW_"+num2str(op)+".jpg"
//print nm, cpth
//NewPath/O nm2, cpth
//SavePICT/O/E=-6/RES=300/P=nm2 as nm
//KillPath nm2
End
There are several scenarios one could employ to get around this.
a) Just use the built-in IGOR code to create this graph, Windows-> New Graph. This creates the graph in the method that you want. If you need the graph to have specific attributes (size, colour, etc), then you can save graph preferences (Graph-> Capture Graph Preferences), or save the window recreation macro (Ctrl/Cmd+Y). The first option has the advantage of making all graphs look the same when they are created. The second would create code that could be called after the graph was created, to make the appearance correct.
b) To write your own code to do this (to replicate Windows->New Graph) you will need some way to select individual and multiple waves. Again, there are a few ways to do this. One way you could try would be to use the WaveSelectorWidget and PopupWaveSelector widgets. These can be found by the following includes:
#include <PopupWaveSelector>
There is an example experiment that shows you how to use them.
You could also create a gui which has two list boxes. THey both have a list of all the waves in the current datafolder. The first list box only allows you to select a single wave, the second allows you to make multiple selections. You then have a button that would make the graph when pressed.
May 8, 2011 at 07:33 pm - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
May 9, 2011 at 11:09 am - Permalink
Andy - I realize that what I wrote before made it seem like I was trying to reinvent the wheel by re-creating the "New graph" menu. However, I intended to go beyond just creating new graphs and to add some data processing as well, all to be done according to the order of the files selected. Thanks for the input.
May 10, 2011 at 03:53 pm - Permalink
Have you perhaps looked at the LinkDisplay and LinkVS packages? Perhaps they can do what you need with only minor modifications. The former is a command line UI, and the latter uses a control panel.
http://www.igorexchange.com/project/LinkDisplay
http://www.igorexchange.com/project/LinkVS
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
May 10, 2011 at 05:00 pm - Permalink
May 24, 2011 at 05:50 pm - Permalink
Hope it is useful. Feature requests and bug reports are always welcomed.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
May 25, 2011 at 02:43 pm - Permalink