function varargout = RBAnimation(varargin)
% RBANIMATION M-file for RBAnimation.fig
% RBANIMATION, by itself, creates a new RBANIMATION or raises the existing
% singleton*.
%
% H = RBANIMATION returns the handle to a new RBANIMATION or the handle to
% the existing singleton*.
%
% RBANIMATION('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in RBANIMATION.M with the given input arguments.
%
% RBANIMATION('Property','Value',...) creates a new RBANIMATION or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before RBAnimation_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to RBAnimation_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help RBAnimation
% Last Modified by GUIDE v2.5 23-Nov-2011 15:17:24
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @RBAnimation_OpeningFcn, ...
'gui_OutputFcn', @RBAnimation_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before RBAnimation is made visible.
function RBAnimation_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to RBAnimation (see VARARGIN)
% Choose default command line output for RBAnimation
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes RBAnimation wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = RBAnimation_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
global st
global check
check = false;
dt = get_rb(st, 'dt') * 10 ;
set(handles.slider1, 'SliderStep', [dt dt])
% --- Executes on button press in slider1.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global step
max_step = get(handles.slider1,'SliderStep');
max_step = 1 / max_step(1,1);
step = ceil(get(handles.slider1,'Value')*max_step) ;
% --- Executes on button press in checkbox2.
function checkbox2_Callback(hObject, eventdata, handles)
% hObject handle to checkbox2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global hh;
if ishandle(hh)
delete(hh);
hh = line([0 0 0 ],[0 0 0 ],[0 0 0 ],'Color', [0 0 0], 'LineWidth',2);
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.pushbutton2, 'Enable','off');
set(handles.pushbutton6, 'Enable','on');
global at st ct
global hh
global tr
global step
global stop
global reset
reset = false;
global check;
max_step = get(handles.slider1,'SliderStep');
max_step = 1 / max_step(1,1);
newCount = cputime;
lastCount = newCount;
newC = newCount;
frameCount = 0;
fpsRate = 1;
hh = line([0 0 0 ],[0 0 0 ],[0 0 0 ],'Color', [0 0 0], 'LineWidth',2);
handle_ = findobj('Tag','popupmenu1');
popup_sel_index = get(handle_, 'Value');
set_ = [ 2 3 4 8 9 10 ];
if ismember(popup_sel_index, set_)
rm = get_rb(st, 'rm');
ct = st;
else
rm = get_rb(at, 'rm');
ct = at;
end
n = get_rb(ct, 'n');
dt = get_rb(ct, 'dt');
i = 1;
step = 1;
while i < n-step
if reset == true
i = 1;
reset = false;
newC = cputime;
end
i = i + step;
set(get_rb(ct, 'hgo'), 'Matrix', reshape(rm(:,i),4,4) );
newCount = cputime;
frameCount = frameCount + 1;
if ( newCount - lastCount > 1 )
fpsRate = frameCount / (newCount - lastCount);
lastCount= newCount;
frameCount = 0;
end
control = (1/fpsRate)/(step*dt);
if check == true
if abs(control-1)>0.01
if control > 1
step = step + 1;
else
step = step - 1;
end
set(handles.slider1, 'Value', min(step/max_step, 1));
end
end
set(handles.text1, 'String', num2str(floor(fpsRate)));
set(handles.text6, 'String', num2str(i*dt,'%6.2f'));
set(handles.text7, 'String', num2str(cputime - newC,'%6.2f'));
set(handles.text8, 'String', num2str(step*dt,'%6.5f'));
if get(handles.checkbox2, 'Value') == 1.0
delete(hh);
hh = draw_tr(tr,i);
end
drawnow;
if stop == true
if ishandle(handles.pushbutton2)
set(handles.pushbutton2, 'Enable', 'on');
set(handles.pushbutton6, 'Enable', 'off');
end
if ishandle(hh)
delete(hh);
end
stop = false;
return
end
end
delete(hh);
set(handles.pushbutton2, 'Enable', 'on');
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global check;
if check == true
check = false;
set(handles.pushbutton3, 'String', 'Real Time ON');
else
check = true;
set(handles.pushbutton3, 'String', 'Real Time OFF');
end
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global reset
if reset == true
reset = false;
else
reset = true;
end
set(handles.text6,'String','0');
set(handles.text7,'String','0');
% --- Executes during object deletion, before destroying properties.
function figure1_DeleteFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global stop
stop = true;
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global stop
stop = true;