Hi
I have a few axes and sliders to run through a stack of images. 15 images in total in a stack should be accessed by sliding the slider back and forth, an image should change for every sliding
I use uicontrols to put the sliders and also the WindowScrollWheelFcn to synchronise the mouse scrolling with the slider movement. I use
axes(handles.axes1)
handles.SliderFrame1 = uicontrol('Style','slider','Position',[382 453 130 20],'Min',1,'Max',sno_a,'Value',slice3,'SliderStep',[1/(sno_a-1) 10/(sno_a-1)],'Callback',@XSliderCallback);
axes(handles.axes2)
handles.SliderFrame2 = uicontrol('Style','slider','Position',[1150 453 156 21],'Min',1,'Max',sno_s,'Value',slice2,'SliderStep',[1/(sno_s-1) 10/(sno_s-1)],'Callback',@XSliderCallback);
axes(handles.axes3)
handles.SliderFrame3 = uicontrol('Style','slider','Position',[400 44 160 22],'Min',1,'Max',sno_c,'Value',slice1,'SliderStep',[1/(sno_c-1) 10/(sno_c-1)],'Callback',@XSliderCallback);
The sliders are placed fine and when manually drag them by their arrow ends the images are perfectly changed following the XSliderCallback function. So there is no problem at all by manually drag the sliders
I also use the command
set (hFig, 'WindowScrollWheelFcn', @mouseScroll);
guidata(hFig,handles);
Where hFig is the main Figure window with the three axes embedded on it.
mouseScroll funciton for synchronizing the wheel with the slider moving is this
function mouseScroll(~,eventdata,I)
handles = guidata(gcf);
S = round((get(handles.SliderFrame1,'Value')));
sno = size(MyMatrix);
UPDN = eventdata.VerticalScrollCount;
S = S - UPDN;
if (S < 1)
S = 1;
elseif (S > sno)
S = sno;
end
if sno > 1 | sno <= 15
if S > get(handles.SliderFrame1,'Max')
S = get(handles.SliderFrame1,'Max');
elseif S < get(handles.SliderFrame1,'Min')
S = get(handles.SliderFrame1,'Min');
end
set(handles.SliderFrame1,'Value',S);
set(handles.Edit1, 'String', sprintf('Slice# %d / %d',S, sno));
else
set(handles.Edit1, 'String', '2D image');
end
guidata(hFig,handles);
end
And although the slider indeed moves along with the mouse scrolling wheel the problem is that the images are not changing. There is something I do wrong. Can you please indicate my lacking or where am I doing wrong? The slider movement is fine but how do I connect this movement with the display of images? One slice at each sliding and 15 sliding in total?
looking to your feedback.
Regards
Stelios F