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

% Last Modified by GUIDE v2.5 22-Nov-2010 03:15:35

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

modelo=varargin{1};
handles.modelo=modelo{1};
set(handles.textmodelo,'String',handles.modelo);
perfil=varargin{2};

set(handles.popupmenuforma1,'String',{'Punto';'Círculo';'X';'Cuadrado';'Triángulo'});
set(handles.popupmenucolor1,'String',{'Rojo';'Negro';'Azul';'Amarillo';'Verde'});
set(handles.popupmenuforma2,'String',{'Punto';'Círculo';'X';'Cuadrado';'Triángulo'});
set(handles.popupmenucolor2,'String',{'Rojo';'Negro';'Azul';'Amarillo';'Verde'});
set(handles.popupmenuforma3,'String',{'Punto';'Círculo';'X';'Cuadrado';'Triángulo'});
set(handles.popupmenucolor3,'String',{'Rojo';'Negro';'Azul';'Amarillo';'Verde'});
set(handles.popupmenuforma4,'String',{'Punto';'Círculo';'X';'Cuadrado';'Triángulo'});
set(handles.popupmenucolor4,'String',{'Rojo';'Negro';'Azul';'Amarillo';'Verde'});
set(handles.popupmenuforma5,'String',{'Punto';'Círculo';'X';'Cuadrado';'Triángulo'});
set(handles.popupmenucolor5,'String',{'Rojo';'Negro';'Azul';'Amarillo';'Verde'});

if perfil==0
    handles.nombreperfil='';
    handles.set='';
    handles.evento1='';
    handles.evento2='';
    handles.evento3='';
    handles.evento4='';
    handles.evento5='';
    handles.grafeve=[0 1 1;
                     0 1 1;
                     0 1 1;
                     0 1 1;
                     0 1 1];
else
    %CARGA DE PERFIL, COMPROBAR MODELO
end

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = crearperfil_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 pushbuttonguardar.
function pushbuttonguardar_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonguardar (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

[nombrearchivo,ruta,filtro] = uiputfile(['.\',handles.modelo,'\Perfiles\',handles.nombreperfil,'.per'], 'Elija un nombre para guardar el perfil');

if nombrearchivo~=0
    directrabajo=cd;
    cd(ruta);

    uiresume(handles.figure1);
    fid=fopen(nombrearchivo,'wt');

    fprintf(fid,'%s,',handles.nombreperfil);
    fprintf(fid,'%s,',handles.modelo);
    fprintf(fid,'%s,',handles.set);
    fprintf(fid,'%s,',handles.evento1);
    fprintf(fid,'%s,',handles.evento2);
    fprintf(fid,'%s,',handles.evento3);
    fprintf(fid,'%s,',handles.evento4);
    fprintf(fid,'%s,',handles.evento5);
    fprintf(fid,'%d,',handles.grafeve(1,1));
    fprintf(fid,'%d,',handles.grafeve(1,2));
    fprintf(fid,'%d,',handles.grafeve(1,3));
    fprintf(fid,'%d,',handles.grafeve(2,1));
    fprintf(fid,'%d,',handles.grafeve(2,2));
    fprintf(fid,'%d,',handles.grafeve(2,3));
    fprintf(fid,'%d,',handles.grafeve(3,1));
    fprintf(fid,'%d,',handles.grafeve(3,2));
    fprintf(fid,'%d,',handles.grafeve(3,3));
    fprintf(fid,'%d,',handles.grafeve(4,1));
    fprintf(fid,'%d,',handles.grafeve(4,2));
    fprintf(fid,'%d,',handles.grafeve(4,3));
    fprintf(fid,'%d,',handles.grafeve(5,1));
    fprintf(fid,'%d,',handles.grafeve(5,2));
    fprintf(fid,'%d,',handles.grafeve(5,3));

    fclose(fid);

    cd(directrabajo)
    uiwait(handles.figure1);
end

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

[nombrearchivo,ruta,filtro] = uigetfile(['.\',handles.modelo,'\Perfiles\*.per'], 'Seleccione un archivo de perfil');

if nombrearchivo~=0
    try 
        fid=fopen([ruta,nombrearchivo]);
        perfil=textscan(fid,'%s%s%s%s%s%s%s%s%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d',1,'Delimiter',',');
        fclose(fid);
        
        intermedio=perfil{2};
        if strcmp(intermedio{1},handles.modelo)==0
            warndlg('El perfil se corresponde con un modelo de avión distinto del actual.','Error de evento','modal');
        else
            intermedio=perfil{1};
            handles.nombreperfil=intermedio{1};

            intermedio=perfil{3};
            handles.set=intermedio{1};

            intermedio=perfil{4};
            handles.evento1=intermedio{1};

            intermedio=perfil{5};
            handles.evento2=intermedio{1};

            intermedio=perfil{6};
            handles.evento3=intermedio{1};

            intermedio=perfil{7};
            handles.evento4=intermedio{1};

            intermedio=perfil{8};
            handles.evento5=intermedio{1};
            
            handles.grafeve(1,1)=perfil{9};
            handles.grafeve(1,2)=perfil{10};
            handles.grafeve(1,3)=perfil{11};
            handles.grafeve(2,1)=perfil{12};
            handles.grafeve(2,2)=perfil{13};
            handles.grafeve(2,3)=perfil{14};
            handles.grafeve(3,1)=perfil{15};
            handles.grafeve(3,2)=perfil{16};
            handles.grafeve(3,3)=perfil{17};
            handles.grafeve(4,1)=perfil{18};
            handles.grafeve(4,2)=perfil{19};
            handles.grafeve(4,3)=perfil{20};
            handles.grafeve(5,1)=perfil{21};
            handles.grafeve(5,2)=perfil{22};
            handles.grafeve(5,3)=perfil{23};
            
            set(handles.editnombreperfil,'String',handles.nombreperfil);
            set(handles.textmodelo,'String',handles.modelo);
            set(handles.editset,'String',handles.set);
            set(handles.editevento1,'String',handles.evento1);
            set(handles.editevento2,'String',handles.evento2);
            set(handles.editevento3,'String',handles.evento3);
            set(handles.editevento4,'String',handles.evento4);
            set(handles.editevento5,'String',handles.evento5);
            
            set(handles.checkboxmarcar1,'Value',handles.grafeve(1,1));
            set(handles.popupmenuforma1,'Value',handles.grafeve(1,2));
            set(handles.popupmenucolor1,'Value',handles.grafeve(1,3));
            set(handles.checkboxmarcar2,'Value',handles.grafeve(2,1));
            set(handles.popupmenuforma2,'Value',handles.grafeve(2,2));
            set(handles.popupmenucolor2,'Value',handles.grafeve(2,3));
            set(handles.checkboxmarcar3,'Value',handles.grafeve(3,1));
            set(handles.popupmenuforma3,'Value',handles.grafeve(3,2));
            set(handles.popupmenucolor3,'Value',handles.grafeve(3,3));
            set(handles.checkboxmarcar4,'Value',handles.grafeve(4,1));
            set(handles.popupmenuforma4,'Value',handles.grafeve(4,2));
            set(handles.popupmenucolor4,'Value',handles.grafeve(4,3));
            set(handles.checkboxmarcar5,'Value',handles.grafeve(5,1));
            set(handles.popupmenuforma5,'Value',handles.grafeve(5,2));
            set(handles.popupmenucolor5,'Value',handles.grafeve(5,3));
            
        end
    end
end

guidata(hObject,handles);
            
function editnombreperfil_Callback(hObject, eventdata, handles)
% hObject    handle to editnombreperfil (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editnombreperfil as text
%        str2double(get(hObject,'String')) returns contents of editnombreperfil as a double

handles.nombreperfil=get(handles.editnombreperfil,'String');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function editnombreperfil_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editnombreperfil (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editset_Callback(hObject, eventdata, handles)
% hObject    handle to editset (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editset as text
%        str2double(get(hObject,'String')) returns contents of editset as a double

handles.set=get(handles.editset,'String');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function editset_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editset (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


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

directrabajo=cd;
cd(['.\',handles.modelo,'\Sets\']);

[nombreset,ruta,filtro] = uigetfile('*.set', 'Seleccione un archivo de set de variables:');

if nombreset~=0
    intermedio=textscan(nombreset,'%s','Delimiter','.');
    nombreset=intermedio{1}{1};
    set(handles.editset,'String',nombreset);
    handles.set=nombreset;
end

cd(directrabajo);

guidata(hObject, handles);



function editevento1_Callback(hObject, eventdata, handles)
% hObject    handle to editevento1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editevento1 as text
%        str2double(get(hObject,'String')) returns contents of editevento1 as a double

handles.evento1=get(handles.editevento1,'String');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function editevento1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editevento1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


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

directrabajo=cd;
cd(['.\',handles.modelo,'\Eventos\']);

[nombreevento,ruta,filtro] = uigetfile('*.eve', 'Seleccione un archivo evento:');

if nombreevento~=0
    intermedio=textscan(nombreevento,'%s','Delimiter','.');
    nombreevento=intermedio{1}{1};
    set(handles.editevento1,'String',nombreevento);
    handles.evento1=nombreevento;
end

cd(directrabajo);

guidata(hObject, handles);


% --- Executes on button press in checkboxmarcar1.
function checkboxmarcar1_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxmarcar1 (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 checkboxmarcar1

handles.grafeve(1,1)=get(handles.checkboxmarcar1,'Value');

guidata(hObject,handles);

% --- Executes on selection change in popupmenuforma1.
function popupmenuforma1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenuforma1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenuforma1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenuforma1

handles.grafeve(1,2)=get(handles.popupmenuforma1,'Value');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function popupmenuforma1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenuforma1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in popupmenucolor1.
function popupmenucolor1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenucolor1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenucolor1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenucolor1

handles.grafeve(1,3)=get(handles.popupmenucolor1,'Value');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function popupmenucolor1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenucolor1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editevento2_Callback(hObject, eventdata, handles)
% hObject    handle to editevento2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editevento2 as text
%        str2double(get(hObject,'String')) returns contents of editevento2 as a double

handles.evento2=get(handles.editevento2,'String');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function editevento2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editevento2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


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

directrabajo=cd;
cd(['.\',handles.modelo,'\Eventos\']);

[nombreevento,ruta,filtro] = uigetfile('*.eve', 'Seleccione un archivo evento:');

if nombreevento~=0
    intermedio=textscan(nombreevento,'%s','Delimiter','.');
    nombreevento=intermedio{1}{1};
    set(handles.editevento2,'String',nombreevento);
    handles.evento2=nombreevento;
end

cd(directrabajo);

guidata(hObject, handles);

% --- Executes on button press in checkboxmarcar2.
function checkboxmarcar2_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxmarcar2 (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 checkboxmarcar2

handles.grafeve(2,1)=get(handles.checkboxmarcar2,'Value');

guidata(hObject,handles);

% --- Executes on selection change in popupmenuforma2.
function popupmenuforma2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenuforma2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenuforma2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenuforma2

handles.grafeve(2,2)=get(handles.popupmenuforma2,'Value');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function popupmenuforma2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenuforma2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in popupmenucolor2.
function popupmenucolor2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenucolor2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenucolor2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenucolor2

handles.grafeve(2,3)=get(handles.popupmenucolor2,'Value');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function popupmenucolor2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenucolor2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editevento3_Callback(hObject, eventdata, handles)
% hObject    handle to editevento3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editevento3 as text
%        str2double(get(hObject,'String')) returns contents of editevento3 as a double

handles.evento3=get(handles.editevento3,'String');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function editevento3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editevento3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


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

directrabajo=cd;
cd(['.\',handles.modelo,'\Eventos\']);

[nombreevento,ruta,filtro] = uigetfile('*.eve', 'Seleccione un archivo evento:');

if nombreevento~=0
    intermedio=textscan(nombreevento,'%s','Delimiter','.');
    nombreevento=intermedio{1}{1};
    set(handles.editevento3,'String',nombreevento);
    handles.evento3=nombreevento;
end

cd(directrabajo);

guidata(hObject, handles);

% --- Executes on button press in checkboxmarcar3.
function checkboxmarcar3_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxmarcar3 (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 checkboxmarcar3

handles.grafeve(3,1)=get(handles.checkboxmarcar3,'Value');

guidata(hObject,handles);

% --- Executes on selection change in popupmenuforma3.
function popupmenuforma3_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenuforma3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenuforma3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenuforma3

handles.grafeve(3,2)=get(handles.popupmenuforma3,'Value');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function popupmenuforma3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenuforma3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in popupmenucolor3.
function popupmenucolor3_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenucolor3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenucolor3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenucolor3

handles.grafeve(3,3)=get(handles.popupmenucolor3,'Value');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function popupmenucolor3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenucolor3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editevento4_Callback(hObject, eventdata, handles)
% hObject    handle to editevento4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editevento4 as text
%        str2double(get(hObject,'String')) returns contents of editevento4 as a double

handles.evento4=get(handles.editevento4,'String');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function editevento4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editevento4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


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

directrabajo=cd;
cd(['.\',handles.modelo,'\Eventos\']);

[nombreevento,ruta,filtro] = uigetfile('*.eve', 'Seleccione un archivo evento:');

if nombreevento~=0
    intermedio=textscan(nombreevento,'%s','Delimiter','.');
    nombreevento=intermedio{1}{1};
    set(handles.editevento4,'String',nombreevento);
    handles.evento4=nombreevento;
end

cd(directrabajo);

guidata(hObject, handles);


% --- Executes on button press in checkboxmarcar4.
function checkboxmarcar4_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxmarcar4 (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 checkboxmarcar4

handles.grafeve(4,1)=get(handles.checkboxmarcar4,'Value');

guidata(hObject,handles);

% --- Executes on selection change in popupmenuforma4.
function popupmenuforma4_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenuforma4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenuforma4 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenuforma4

handles.grafeve(4,2)=get(handles.popupmenuforma4,'Value');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function popupmenuforma4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenuforma4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in popupmenucolor4.
function popupmenucolor4_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenucolor4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenucolor4 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenucolor4

handles.grafeve(4,3)=get(handles.popupmenucolor4,'Value');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function popupmenucolor4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenucolor4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editevento5_Callback(hObject, eventdata, handles)
% hObject    handle to editevento5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editevento5 as text
%        str2double(get(hObject,'String')) returns contents of editevento5 as a double

handles.evento5=get(handles.editevento5,'String');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function editevento5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editevento5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


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

directrabajo=cd;
cd(['.\',handles.modelo,'\Eventos\']);

[nombreevento,ruta,filtro] = uigetfile('*.eve', 'Seleccione un archivo evento:');

if nombreevento~=0
    intermedio=textscan(nombreevento,'%s','Delimiter','.');
    nombreevento=intermedio{1}{1};
    set(handles.editevento5,'String',nombreevento);
    handles.evento5=nombreevento;
end

cd(directrabajo);

guidata(hObject, handles);

% --- Executes on button press in checkboxmarcar5.
function checkboxmarcar5_Callback(hObject, eventdata, handles)
% hObject    handle to checkboxmarcar5 (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 checkboxmarcar5

handles.grafeve(5,1)=get(handles.checkboxmarcar5,'Value');

guidata(hObject,handles);

% --- Executes on selection change in popupmenuforma5.
function popupmenuforma5_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenuforma5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenuforma5 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenuforma5

handles.grafeve(5,2)=get(handles.popupmenuforma5,'Value');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function popupmenuforma5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenuforma5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in popupmenucolor5.
function popupmenucolor5_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenucolor5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenucolor5 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenucolor5

handles.grafeve(5,3)=get(handles.popupmenucolor5,'Value');

guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function popupmenucolor5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenucolor5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
