function SetUniLevel(action)

global UniLevel

switch(action)

case 'start'
   set(gcbf,'WindowButtonMotionFcn','SetUniLevel move');
   set(gcbf,'WindowButtonUpFcn','SetUniLevel stop');

case 'move'
   currentPoint = get(gca,'CurrentPoint');
   newY = currentPoint(3);
   newY = min(25,max(0,newY));
   LocalSetDisplay(newY)

case 'stop'
   set(gcf,'WindowButtonMotionFcn','');
   set(gcf,'WindowButtonUpFcn','');

case 'enter'
   newY = eval(get(gcbo,'String'));
   newY = min(25,max(0,newY));
   LocalSetDisplay(newY);

end

function LocalSetDisplay(newY)

global UniLevel

pointerHandle = findobj(gcbf,'Tag','redline2');
newY = round(newY);
set(pointerHandle,'YData',[0 newY]);
newYHndl = get(findobj('Tag','uniformityText'),'Value');
set(newYHndl,'String',sprintf('%3.0f',newY))
UniLevel = newY;

