[Scilab-users] Refresh plot from Slider
tanthiamhuat
tanthiamhuat at yahoo.com
Wed Sep 10 05:37:04 CEST 2014
Hi CL,
thanks for pointing out my mistake of using the text handles.
even if I add in the code:
if ~isempty(handles.Axes1.children)
delete(handles.Axes1.children);
I see that the previous plot is not deleted, why?
Secondly, is the slider able to display its value when it is slide along? If
yes, that would be wonderful.
Do we need to add in another text to display the slider value?
Below are the full code:
// This GUI file is generated by guibuilder version 3.0
//////////
f=figure('figure_position',[564,97],'figure_size',[656,665],'auto_resize','on','background',[33],'figure_name','Graphic
window number %d');
//////////
delmenu(f.figure_id,gettext('File'))
delmenu(f.figure_id,gettext('?'))
delmenu(f.figure_id,gettext('Tools'))
toolbar(f.figure_id,'off')
handles.dummy = 0;
handles.sliderAmp=uicontrol(f,'unit','normalized','BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left','ListboxTop',[],'Max',[100],'Min',[0],'Position',[0.0984375,0.7583333,0.2421875,0.0583333],'Relief','flat','SliderStep',[10,10],'String','1','Style','slider','Value',[33.45],'VerticalAlignment','middle','Visible','on','Tag','sliderAmp','Callback','sliderAmp_callback(handles)')
handles.sliderFreq=uicontrol(f,'unit','normalized','BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left','ListboxTop',[],'Max',[100],'Min',[0],'Position',[0.0984375,0.5854167,0.2421875,0.0583333],'Relief','default','SliderStep',[0.01,0.1],'String','1','Style','slider','Value',[22.76],'VerticalAlignment','middle','Visible','on','Tag','sliderFreq','Callback','sliderFreq_callback(handles)')
handles.editTime=uicontrol(f,'unit','normalized','BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0984375,0.4291667,0.1175,0.0583333],'Relief','default','SliderStep',[0.01,0.1],'String','0:0.9:10','Style','edit','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','editTime','Callback','')
handles.pbPlot=uicontrol(f,'unit','normalized','BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0984375,0.2645833,0.1121875,0.0583333],'Relief','default','SliderStep',[0.01,0.1],'String','Plot','Style','pushbutton','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','pbPlot','Callback','pbPlot_callback(handles)')
handles.Axes1= newaxes();handles.Axes1.margins = [ 0 0 0
0];handles.Axes1.axes_bounds = [0.415625,0.0770833,0.534375,0.725];
handles.Amp=uicontrol(f,'unit','normalized','BackgroundColor',[-1,-1,-1],'Enable','on','FontAngle','normal','FontName','Tahoma','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[-1,-1,-1],'HorizontalAlignment','left','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.1653125,0.702766,0.094375,0.0425532],'Relief','default','SliderStep',[0.01,0.1],'String','Amplitude','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','Amp','Callback','')
//////////
// Callbacks are defined as below. Please do not delete the comments as it
will be used in coming version
//////////
function sliderAmp_callback(handles)
//Write your callback for sliderAmp here
endfunction
function sliderFreq_callback(handles)
//Write your callback for sliderFreq here
endfunction
function pbPlot_callback(handles)
//Write your callback for pbPlot here
funcprot(0)
amp = get(handles.sliderAmp,'value');
frq = get(handles.sliderFreq,'value');
t= evstr(get(handles.editTime,'String'));
y=amp.*sin(2*%pi*frq.*t);
if ~isempty(handles.Axes1.children)
delete(handles.Axes1.children);
plot(t,y); xgrid();
endfunction
--
View this message in context: http://mailinglists.scilab.org/Refresh-plot-from-Slider-tp4031131p4031137.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
More information about the users
mailing list