function varargout = progress_bar(varargin)
% PROGRESS_BAR_BAR M-file for progress_bar_bar.fig
%      PROGRESS_BAR_BAR, by itself, creates a new PROGRESS_BAR_BAR or raises the existing
%      singleton*.
%
%      H = PROGRESS_BAR_BAR returns the handle to a new PROGRESS_BAR_BAR or the handle to
%      the existing singleton*.
%
%      PROGRESS_BAR_BAR('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in PROGRESS_BAR_BAR.M with the given input arguments.
%
%      PROGRESS_BAR_BAR('Property','Value',...) creates a new PROGRESS_BAR_BAR or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before progress_bar_bar_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to progress_bar_bar_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 progress_bar_bar

% Last Modified by GUIDE v2.5 26-Apr-2005 16:18:44

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @progress_bar_OpeningFcn, ...
                   'gui_OutputFcn',  @progress_bar_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(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 progress_bar_bar is made visible.
function progress_bar_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 progress_bar_bar (see VARARGIN)

% Choose default command line output for progress_bar_bar
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes progress_bar_bar wait for user response (see UIRESUME)
% uiwait(handles.progress_bar);

bar1val=varargin{1};
bar2val=varargin{2};
text1=varargin{3};
text2=varargin{4};
win_title=varargin{5};
spec=varargin{6};



axes(handles.axes3)
axis off

%colormap([0.16 0.16 0.2; 0.8 0.8 1])
colormap(hot)

if bar1val==0
    bar1=zeros(1,100);
    bar1(1)=1;
elseif bar1val==1
    bar1=ones(1,100);
else    
    bar1=ones(1,100);
    bar1(ceil(bar1val*100):100)=0;
end
axes(handles.axes1)
imagesc(bar1); axis off;


if bar2val==0
    bar2=zeros(1,100);
    bar2(1)=1;
elseif bar2val==1
    bar2=ones(1,100);
else    
    bar2=ones(1,100);
    bar2(ceil(bar2val*100):100)=0;
end
axes(handles.axes2)
imagesc(bar2); axis off;

set(handles.text1,'string',text1);
set(handles.text2,'string',text2);
set(handles.output,'name',win_title);


if ~isempty(spec)
    axes(handles.axes3)
    imagesc(-log(spec))
    axis xy; axis off
else
    axes(handles.axes3)
    axis off
end
drawnow

% --- Outputs from this function are returned to the command line.
function varargout = progress_bar_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;
