Button press required twice to update values
masheroz
The plot updates on the first button push. The variables xrdYAxisMin and xrdYAxisMax don't update until I push the button again.
I want to track the values of the axes so I can do other things with them.
What am I doing wrong?
A minimised version of the code is:
//---------------------------------------------------------------------------
function updateCWTWindowProc(ctrlName) : ButtonControl
String ctrlName
NVAR xAxisMin =root:Packages:PeakPanelFolder:xAxisMin
NVAR xAxisMax =root:Packages:PeakPanelFolder:xAxisMax
NVAR xrdYAxisMin =root:Packages:PeakPanelFolder:xrdYAxisMin
NVAR xrdYAxisMax =root:Packages:PeakPanelFolder:xrdYAxisMax
//Data window
SetActiveSubwindow PeakPanel#G1
SetAxis/A=2 //autoscales the Y axis to match the values in the current X range
SetAxis bottom xAxisMin,xAxisMax
GetAxis /Q left
xrdYAxisMin = V_min
xrdYAxisMax = V_max
end
//---------------------------------------------------------------------------
function updateCWTWindowProc(ctrlName) : ButtonControl
String ctrlName
NVAR xAxisMin =root:Packages:PeakPanelFolder:xAxisMin
NVAR xAxisMax =root:Packages:PeakPanelFolder:xAxisMax
NVAR xrdYAxisMin =root:Packages:PeakPanelFolder:xrdYAxisMin
NVAR xrdYAxisMax =root:Packages:PeakPanelFolder:xrdYAxisMax
//Data window
SetActiveSubwindow PeakPanel#G1
SetAxis/A=2 //autoscales the Y axis to match the values in the current X range
SetAxis bottom xAxisMin,xAxisMax
GetAxis /Q left
xrdYAxisMin = V_min
xrdYAxisMax = V_max
end
//---------------------------------------------------------------------------
.
Full code for the button if I mangle the above:
//---------------------------------------------------------------------------
function updateCWTWindowProc(ctrlName) : ButtonControl
String ctrlName
Variable autoScaleInt=0
ControlInfo/W=PeakPanel peakAutoScaleIntCheck
if(V_Value)
autoScaleInt=1
endif
NVAR cwtColour =root:Packages:PeakPanelFolder:cwtColour
NVAR xAxisMin =root:Packages:PeakPanelFolder:xAxisMin
NVAR xAxisMax =root:Packages:PeakPanelFolder:xAxisMax
NVAR xrdYAxisMin =root:Packages:PeakPanelFolder:xrdYAxisMin
NVAR xrdYAxisMax =root:Packages:PeakPanelFolder:xrdYAxisMax
NVAR cwtYAxisMin =root:Packages:PeakPanelFolder:cwtYAxisMin
NVAR cwtYAxisMax =root:Packages:PeakPanelFolder:cwtYAxisMax
//CWT window
SetActiveSubwindow PeakPanel#G0
ModifyImage M_CWT ctab= {-cwtColour,cwtColour,RedWhiteBlue,0}
SetAxis bottom xAxisMin,xAxisMax
SetAxis left cwtYAxisMin, cwtYAxisMax
//Data window
SetActiveSubwindow PeakPanel#G1
if(autoScaleInt)
SetAxis/A=2 //autoscales the Y axis to match the values in the current X range
SetAxis bottom xAxisMin,xAxisMax
GetAxis left
xrdYAxisMin = V_min
xrdYAxisMax = V_max
else
//Need a way to preserve the values that I already have
SetAxis /A //clears any previous autoscaling
SetAxis left xrdYAxisMin, xrdYAxisMax
SetAxis bottom xAxisMin,xAxisMax
endif
SetActiveSubwindow PeakPanel
end
//---------------------------------------------------------------------------
function updateCWTWindowProc(ctrlName) : ButtonControl
String ctrlName
Variable autoScaleInt=0
ControlInfo/W=PeakPanel peakAutoScaleIntCheck
if(V_Value)
autoScaleInt=1
endif
NVAR cwtColour =root:Packages:PeakPanelFolder:cwtColour
NVAR xAxisMin =root:Packages:PeakPanelFolder:xAxisMin
NVAR xAxisMax =root:Packages:PeakPanelFolder:xAxisMax
NVAR xrdYAxisMin =root:Packages:PeakPanelFolder:xrdYAxisMin
NVAR xrdYAxisMax =root:Packages:PeakPanelFolder:xrdYAxisMax
NVAR cwtYAxisMin =root:Packages:PeakPanelFolder:cwtYAxisMin
NVAR cwtYAxisMax =root:Packages:PeakPanelFolder:cwtYAxisMax
//CWT window
SetActiveSubwindow PeakPanel#G0
ModifyImage M_CWT ctab= {-cwtColour,cwtColour,RedWhiteBlue,0}
SetAxis bottom xAxisMin,xAxisMax
SetAxis left cwtYAxisMin, cwtYAxisMax
//Data window
SetActiveSubwindow PeakPanel#G1
if(autoScaleInt)
SetAxis/A=2 //autoscales the Y axis to match the values in the current X range
SetAxis bottom xAxisMin,xAxisMax
GetAxis left
xrdYAxisMin = V_min
xrdYAxisMax = V_max
else
//Need a way to preserve the values that I already have
SetAxis /A //clears any previous autoscaling
SetAxis left xrdYAxisMin, xrdYAxisMax
SetAxis bottom xAxisMin,xAxisMax
endif
SetActiveSubwindow PeakPanel
end
//---------------------------------------------------------------------------
GetAxis
before the update happens (which is after the function ends). You need to force the graph (and with it the axis range) to update before fetching the new values withGetAxis
(or else you will get the old ones). Squeeze aDoUpdate
in before and you should be good to go. By the way, you don't useGetAxis/Q
not litter the history window?September 2, 2015 at 06:57 pm - Permalink
DoUpdate
works a charm.Yes it does litter, but I was trying to debug, so I wanted the rubbish.
/Q
is now inserted.September 2, 2015 at 08:45 pm - Permalink