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

% Last Modified by GUIDE v2.5 08-Apr-2013 16:53:20

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Graf_mapovani_OpeningFcn, ...
                   'gui_OutputFcn',  @Graf_mapovani_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 Graf_mapovani is made visible.
function Graf_mapovani_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 Graf_mapovani (see VARARGIN)

load('parameters.mat');
handles.res = varargin{1};
handles.par = par;
res = handles.res;
% Choose default command line output for Graf_mapovani
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);


% UIWAIT makes Graf_mapovani wait for user response (see UIRESUME)
% uiwait(handles.figure1);



I = size(res.BMAP,2)/14;

set(handles.radiobutton_podrobnosti, 'Value', 1);
set(handles.radiobutton_modul, 'Value', 0);
set(handles.radiobutton_faze, 'Value', 0);
set(handles.radiobutton_Rxm, 'Value', 0);
set(handles.radiobutton_Rxf, 'Value', 0);
set(handles.radiobutton_kanal, 'Value', 0);
set(handles.fig2, 'Visible', 'on');
axes(handles.fig2);
if(strcmp(res.model_sys,'DL'))
    imshow(imread('legenda_mapper.png'));
else
    imshow(imread('legenda_mapperUL.png'));
end
set(handles.fig1, 'Visible', 'on');
axes(handles.fig1);
surf(res.BMAP,'MarkerSize',0.5,'Marker','.','LineStyle','none',...
    'FaceColor','texturemap');
set(handles.fig1,'YTickLabel',{'0','12','24','36','28','60','71'},...
    'YTick',[1 13 25 37 49 61 72],'XTickLabel',0:1:I,...
    'XTick',1:14:14*(I));
xlim(handles.fig1,[1 14*(I)]);
ylim(handles.fig1,[1 72]);
view(handles.fig1,[-0.5 90]);
grid(handles.fig1,'on');
title('Struktura rádiového rámce, schématicky, B = 1,4MHz (6 x 12 subnosných)');
xlabel('Subrámec [-]');
ylabel('Subnosná [-]');



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


% --- Executes on button press in radiobutton_podrobnosti.
function radiobutton_podrobnosti_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton_podrobnosti (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
res = handles.res;
par = handles.par;
hold(handles.fig1,'off');
% Hint: get(hObject,'Value') returns toggle state of radiobutton_podrobnosti

I = size(res.BMAP,2)/14;

set(handles.radiobutton_podrobnosti, 'Value', 1);
set(handles.radiobutton_modul, 'Value', 0);
set(handles.radiobutton_faze, 'Value', 0);
set(handles.radiobutton_Rxm, 'Value', 0);
set(handles.radiobutton_Rxf, 'Value', 0);
set(handles.radiobutton_kanal, 'Value', 0);
set(handles.fig2, 'Visible', 'on');
axes(handles.fig2);
if(strcmp(res.model_sys,'DL'))
    imshow(imread('legenda_mapper.png'));
else
    imshow(imread('legenda_mapperUL.png'));
end
set(handles.fig1, 'Visible', 'on');
axes(handles.fig1);
surf(res.BMAP,'MarkerSize',0.5,'Marker','.','LineStyle','none',...
    'FaceColor','texturemap');
set(handles.fig1,'YTickLabel',{'0','12','24','36','28','60','71'},...
    'YTick',[1 13 25 37 49 61 72],'XTickLabel',0:1:I,...
    'XTick',1:14:14*(I));
xlim(handles.fig1,[1 14*(I)]);
ylim(handles.fig1,[1 72]);
view(handles.fig1,[-0.5 90]);
grid(handles.fig1,'on');
title('Struktura rádiového rámce, schématicky, B = 1,4MHz (6 x 12 subnosných)');
xlabel('Subrámec [-]');
xlabel('Subrámec [-]');
ylabel('Subnosná [-]');


% --- Executes on button press in radiobutton_modul.
function radiobutton_modul_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton_modul (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
hold(handles.fig1,'off');
% Hint: get(hObject,'Value') returns toggle state of radiobutton_modul
% load('results.mat'); % - now res is global
% load('parameters.mat'); % - now res is global
res = handles.res;
par = handles.par;

I = size(res.BMAP,2)/14;

set(handles.radiobutton_podrobnosti, 'Value', 0);
set(handles.radiobutton_modul, 'Value', 1);
set(handles.radiobutton_faze, 'Value', 0);
set(handles.radiobutton_Rxm, 'Value', 0);
set(handles.radiobutton_Rxf, 'Value', 0);
set(handles.radiobutton_kanal, 'Value', 0);
set(handles.fig2, 'Visible', 'off');
gray(1,1,1) = 212/255;gray(1,1,2) = 208/255;
gray(1,1,3) = 200/255;
axes(handles.fig2);
imshow(gray)
axes(handles.fig1);
set(handles.fig1, 'Visible', 'on');
surf(abs(res.B),'MarkerSize',0.5,'Marker','.','LineStyle','none',...
    'FaceColor','texturemap');
set(handles.fig1,'YTickLabel',{'0','12','24','36','28','60','71'},...
    'YTick',[1 13 25 37 49 61 72],'XTickLabel',0:1:I,...
    'XTick',1:14:14*(I));
xlim(handles.fig1,[1 14*(I)]);
ylim(handles.fig1,[1 72]);
view(handles.fig1,[-0.5 90]);
grid(handles.fig1,'on');
title('Struktura rádiového rámce, modul vysílaného signálu, B = 1,4MHz (6 x 12 subnosných)');
xlabel('Subrámec [-]');
ylabel('Subnosná [-]');
axes(handles.fig1);



% --- Executes on button press in radiobutton_faze.
function radiobutton_faze_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton_faze (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
hold(handles.fig1,'off');
% Hint: get(hObject,'Value') returns toggle state of radiobutton_faze
% load('results.mat'); % - now res is global
% load('parameters.mat'); % - now res is global
res = handles.res;
par = handles.par;
I = size(res.BMAP,2)/14;

set(handles.radiobutton_podrobnosti, 'Value', 0);
set(handles.radiobutton_modul, 'Value', 0);
set(handles.radiobutton_faze, 'Value', 1);
set(handles.radiobutton_Rxm, 'Value', 0);
set(handles.radiobutton_Rxf, 'Value', 0);
set(handles.radiobutton_kanal, 'Value', 0);
set(handles.fig2, 'Visible', 'off');
gray(1,1,1) = 212/255;gray(1,1,2) = 208/255;
gray(1,1,3) = 200/255;
axes(handles.fig2);
imshow(gray)
set(handles.fig1, 'Visible', 'on');
axes(handles.fig1);
surf(angle(res.B),'MarkerSize',0.5,'Marker','.','LineStyle','none',...
    'FaceColor','texturemap');
set(handles.fig1,'YTickLabel',{'0','12','24','36','28','60','71'},...
    'YTick',[1 13 25 37 49 61 72],'XTickLabel',0:1:I,...
    'XTick',1:14:14*(I));
xlim(handles.fig1,[1 14*(I)]);
ylim(handles.fig1,[1 72]);
view(handles.fig1,[-0.5 90]);
grid(handles.fig1,'on');
title('Struktura rádiového rámce, fáze vysílaného signálu, B = 1,4MHz (6 x 12 subnosných)');
xlabel('Subrámec [-]');
ylabel('Subnosná [-]');


% --- Executes on button press in radiobutton_kanal.
function radiobutton_kanal_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton_kanal (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton_kanal
% load('results.mat'); % - now res is global
% load('parameters.mat'); % - now res is global
res = handles.res;
par = handles.par;
I = size(res.B,2)/14;

set(handles.radiobutton_podrobnosti, 'Value', 0);
set(handles.radiobutton_modul, 'Value', 0);
set(handles.radiobutton_faze, 'Value', 0);
set(handles.radiobutton_Rxm, 'Value', 0);
set(handles.radiobutton_Rxf, 'Value', 0);
set(handles.radiobutton_kanal, 'Value', 1);
set(handles.fig2, 'Visible', 'off');
gray(1,1,1) = 212/255;gray(1,1,2) = 208/255;
gray(1,1,3) = 200/255;
axes(handles.fig2);
imshow(gray)
set(handles.fig1, 'Visible', 'on');
axes(handles.fig1);
surf(10*log10(abs(res.B_./res.B)),'MarkerSize',0.5,'Marker','.','LineStyle','none',...
    'FaceColor','texturemap');
set(handles.fig1,'YTickLabel',{'0','12','24','36','28','60','71'},...
    'YTick',[1 13 25 37 49 61 72],'XTickLabel',0:1:I,...
    'XTick',1:14:14*(I));
xlim(handles.fig1,[1 14*(I)]);
ylim(handles.fig1,[1 72]);
view(handles.fig1,[-0.5 90]);
grid(handles.fig1,'on');
title('Struktura rádiového rámce, přenos rádiového kanálu, B = 1,4MHz (6 x 12 subnosných)');
xlabel('Subrámec [-]');
ylabel('Subnosná [-]');
colorbar('peer',handles.fig1);

% --- Executes on button press in radiobutton_Rxm.
function radiobutton_Rxm_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton_Rxm (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton_Rxm
% load('results.mat'); % - now res is global
% load('parameters.mat'); % - now res is global
res = handles.res;
par = handles.par;
I = size(res.B_,2)/14;

set(handles.radiobutton_podrobnosti, 'Value', 0);
set(handles.radiobutton_modul, 'Value', 0);
set(handles.radiobutton_faze, 'Value', 0);
set(handles.radiobutton_Rxm, 'Value', 1);
set(handles.radiobutton_Rxf, 'Value', 0);
set(handles.radiobutton_kanal, 'Value', 0);
set(handles.fig2, 'Visible', 'off');
gray(1,1,1) = 212/255;gray(1,1,2) = 208/255;
gray(1,1,3) = 200/255;
axes(handles.fig2);
imshow(gray)
set(handles.fig1, 'Visible', 'on');
axes(handles.fig1);
surf(abs(res.B_),'MarkerSize',0.5,'Marker','.','LineStyle','none',...
    'FaceColor','texturemap');
set(handles.fig1,'YTickLabel',{'0','12','24','36','28','60','71'},...
    'YTick',[1 13 25 37 49 61 72],'XTickLabel',0:1:I,...
    'XTick',1:14:14*(I));
xlim(handles.fig1,[1 14*(I)]);
ylim(handles.fig1,[1 72]);
view(handles.fig1,[-0.5 90]);
grid(handles.fig1,'on');
title('Struktura rádiového rámce, modul přijatého signálu, B = 1,4MHz (6 x 12 subnosných)');
xlabel('Subrámec [-]');
ylabel('Subnosná [-]');
colorbar('peer',handles.fig1);

% --- Executes on button press in radiobutton_Rxf.
function radiobutton_Rxf_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton_Rxf (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton_Rxf
% load('results.mat'); % - now res is global
res = handles.res;
par = handles.par;

I = size(res.B_,2)/14;

set(handles.radiobutton_podrobnosti, 'Value', 0);
set(handles.radiobutton_modul, 'Value', 0);
set(handles.radiobutton_faze, 'Value', 0);
set(handles.radiobutton_Rxm, 'Value', 0);
set(handles.radiobutton_Rxf, 'Value', 1);
set(handles.radiobutton_kanal, 'Value', 0);
set(handles.fig2, 'Visible', 'off');
gray(1,1,1) = 212/255;gray(1,1,2) = 208/255;
gray(1,1,3) = 200/255;
axes(handles.fig2);
imshow(gray)
set(handles.fig1, 'Visible', 'on');
axes(handles.fig1);
surf(angle(res.B_),'MarkerSize',0.5,'Marker','.','LineStyle','none',...
    'FaceColor','texturemap');
set(handles.fig1,'YTickLabel',{'0','12','24','36','28','60','71'},...
    'YTick',[1 13 25 37 49 61 72],'XTickLabel',0:1:I,...
    'XTick',1:14:14*(I));
xlim(handles.fig1,[1 14*(I)]);
ylim(handles.fig1,[1 72]);
view(handles.fig1,[-0.5 90]);
grid(handles.fig1,'on');
title('Struktura rádiového rámce, fáze přijatého signálu, B = 1,4MHz (6 x 12 subnosných)');
xlabel('Subrámec [-]');
ylabel('Subnosná [-]');
colorbar('peer',handles.fig1);
