controlpanel
saeed
Im trying to using controlpanel such as button and popupmenu. My datas uploaded from LabVIEW wich another program. I define different button for different requirement but unfortunately when I press those buttons, they work only one time, my goal is after press one button, only this part works continuously.
My questions:
1.Is there any way that my program work in better way? I mean when I press one button, the code works in that part until I press another button?
2. About poupmenu, how can I travel between different option? For example in my attachment, in one of my popupmenu there are tree option(Bin, ROI, Main), do I need define different function for them?
3. In part of binning and ROI, they upload in different graph. can somebody please tell me how can I see this guys in same graph as wave0, so I want to press button of RoI and it appears in my previous graph and if I press binning it also appears in same graph. Now I have those in different graph and I like to substitute them.
Thanks
Pressing a button will cause the function linked to it to execute. If you wish it to "disable" other features you must add that code in yourself. This can be done using a controls 'disable' property. If this isn't what you meant could you elaborate?
The popupmenu change will pass it's current value to the function linked to it (the proc). Based on this value, you can then decide which code to run. One function, with either a case structure of nested if-elseif-endif statements.
The key aspect of this question is "How will the code identify the graph it's supposed to add the ROI or binned data to?" Basic commands like AppendtoGraph will add to the topmost graph, whichever that may be unless they are provided with the windowname getting the window name of the proper graph will be important. One easy way to do this is to have your panel actually create the graph initially with a known windowname that you can use throughout the code. There are other methods of getting a window's name but I find it simpler to create a known one.
May 13, 2014 at 12:16 pm - Permalink
You right but for example I have this code:
Button button0_tab0,pos={60,310},size={161,35},proc=ROIProc,title=" ROI"
Function ROIProc(ROIName) : PopupMenuControl
String ROIName
wave Atomparameters0
print (1,2,3,4,5)
I want it print me until I press button again. Unfortunately it print one time not more, is it possible that it works more time with only one press?
May you please write one example about the popupmenu change, I didn't get your reply for question 2.
May 13, 2014 at 02:48 pm - Permalink
DisplayHelpTopic "Background Task Example #2"
You should read all about background tasks:
DisplayHelpTopic "Background Tasks"
Here's a quick example of a popupMenu control. Execute Panel0() to display the panel:
PauseUpdate; Silent 1 // building window...
NewPanel /W=(150,50,450,250)
PopupMenu popup0,pos={107,72},size={67,20},proc=PopMenuProc
PopupMenu popup0,mode=2,popvalue="Yellow",value= #"\"Red;Yellow;Blue;\""
EndMacro
// The action procedure for the popupMenu control:
Function PopMenuProc(pa) : PopupMenuControl
STRUCT WMPopupAction &pa
switch( pa.eventCode )
case 2: // mouse up
Variable popNum = pa.popNum
String popStr = pa.popStr
print "You selected item #"+num2str(popNum)
print "That item has the text \""+popStr+"\""
StrSwitch(popStr)
case "Red":
print "Do something with Red"
break;
case "Yellow":
print "Do something with Yellow"
break;
case "Blue":
print "Do something with Blue"
break;
endswitch
break
endswitch
return 0
End
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
May 13, 2014 at 04:36 pm - Permalink
popupmenu popup0_tab0,mode=3,popvalue="Main",value="Bin;Region;Main"
Function PopMenuProc(pa) : PopupMenuControl
STRUCT WMPopupAction &pa
switch( pa.eventCode )
case 2: // mouse up
Variable popNum = pa.popNum
String popStr = pa.popStr
print "You selected item #"+num2str(popNum)
print "That item has the text \""+popStr+"\""
StrSwitch(popStr)
case "Main":
GBLoadWave/O/N=wave/T={16,80}/W=1 "D:DATA:temporalIgor.txt"
Redimension/N=(640,480) wave0 //resize Image
Duplicate wave0 //Duplicate the original image
Display /N=MyGraph //new plot window will have name "MyGraph"
AppendImage wave0
break;
case "Bin":
imageinterpolate/pxsz={2,2} pixelate wave0
Display /N=new
AppendImage M_PixelatedImage
SetAxis/A/R left
ModifyImage M_PixelatedImage ctab= {*,*,Rainbow,0}
break;
case "Region":
Duplicate/O/R=[10,50][200,300] wave0,roi
Display /N=ROI
AppendImage roi
ModifyImage roi ctab= {*,*,Rainbow,0}
SetAxis/A/R left
break;
endswitch
break
endswitch
return 0
End
Thanks.
I wrote this code but it doesn't execute. Do I need to do some thing that this part runing?
May 16, 2014 at 07:55 am - Permalink
proc=PopMenuProc
flag in you popup control code, which tells the popup menu the function name to use for execution.May 16, 2014 at 08:11 am - Permalink
Sorry, I forget put here but infact I put in my main code.
you can see in my attachment, I walk in different case of Popmenu but nothing is changes.
Do you have another suggestion please?
May 16, 2014 at 02:32 pm - Permalink
Perhaps you should post the entire experiment file.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
May 16, 2014 at 04:44 pm - Permalink
can I ask a request?
Thanks for your program, now this part of my code is work:
PauseUpdate; Silent 1
NewPanel /W=(150,50,450,250)
PopupMenu popup0,pos={107,72},size={67,20},proc=PopMenuProc
PopupMenu popup0,mode=2,popvalue="Image",value= #"\"Image;Binning;ROI;\""
EndMacro
Function PopMenuProc(pa) : PopupMenuControl
STRUCT WMPopupAction &pa
switch( pa.eventCode )
case 2: // mouse up
Variable popNum = pa.popNum
String popStr = pa.popStr
print "You selected item #"+num2str(popNum)
print "That item has the text \""+popStr+"\""
StrSwitch(popStr)
case "Binning":
imageinterpolate/pxsz={2,2} pixelate wave0
Display /N=new
AppendImage M_PixelatedImage
SetAxis/A/R left
ModifyImage M_PixelatedImage ctab= {*,*,Rainbow,0}
break;
case "Image":
print "Image"
break;
case "ROI":
Duplicate/O/R=[10,50][200,300] wave0,roi
Display /N=ROI
AppendImage roi
ModifyImage roi ctab= {*,*,Rainbow,0}
SetAxis/A/R left
break;
endswitch
break
endswitch
return 0
End
Now I want to run periodically this cod so as you told I need use Background Tasks then I put this code in example 2 but I could not do. May you please send me example with my code?
May 19, 2014 at 08:18 am - Permalink