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

% Last Modified by GUIDE v2.5 25-Oct-2014 11:10:37

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

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

% Update handles structure
guidata(hObject, handles);

%misc setup stuff
clear functions
delete(instrfindall);

%f = figure();
% layout = uix.TabPanel('Parent', handles.figure1);
% uicontrol( 'String', 'Button 1', 'Parent', layout );
% uicontrol( 'String', 'Button 2', 'Parent', layout );
% uicontrol( 'String', 'Button 3', 'Parent', layout );

%Setup map axes
utmstruct = defaultm('utm'); 
utmstruct.zone = '10S';
wgs84 = wgs84Ellipsoid;
ellipsoid = [wgs84.SemimajorAxis wgs84.Eccentricity];
utmstruct.geoid = ellipsoid; 
utmstruct = defaultm(utmstruct);
setappdata(hObject, 'utmstruct', utmstruct);

fprintf('Setup map axes \n');
%Define ship outline
shipLOA = 100;
shipBeam = 28;
shipShapeY = [0, shipBeam/2  shipBeam/2 -shipBeam/2 -shipBeam/2   0];
shipShapeX = [0 -(.3*shipLOA) -shipLOA,   -shipLOA     -(.3*shipLOA) 0];
shipShapeXY = [shipShapeX; shipShapeY];
setappdata(hObject, 'shipShapeXY', shipShapeXY);

%Define float marker outline
starScale = 40.0;
floatStarX = starScale * [0 .5 3 .5 0 -.5 -3 -.5 0];
floatStarY = starScale * [3 .5 0 -.5 -3 -.5 0 .5 3];
floatStarXY = [floatStarX; floatStarY];
setappdata(hObject, 'floatStarXY', floatStarXY);

fprintf('Loading mc15 data set \n');
load('mc15.mat');
setappdata(hObject, 'mc15', mc15);

radius = 200;
x = -radius:10:radius;
y = sqrt(radius^2 - x.^2);
x = x + 607000;
y = y + 4073000;
z = 1:length(y);
z = -z;
CPFTrack = struct('x', x, 'y', y, 'z', z);
setappdata(hObject, 'CPFTrack', CPFTrack);

mca.SClat = [(36+51/60) (36+51/60) (36 + 48/60) (36 + 48/60) (36 + 51/60)];
mca.SClon = [-(121+56/60) -(122+3.8/60) -(122+2.88/60) -(121 + 56/60) -(121 + 56/60)];
mca.PLlat = [(36+43/60) (36+43/60) (36 + 41/60) (36 + 41/60) (36 + 43/60)];
mca.PLlon = [-(121+56/60) -(122+1.3/60) -(122+0.8/60) -(121 + 56/60) -(121 + 56/60)];
[mca.SCeast, mca.SCnorth] = mfwdtran(utmstruct, mca.SClat, mca.SClon);
[mca.PLeast, mca.PLnorth] = mfwdtran(utmstruct, mca.PLlat, mca.PLlon);
setappdata(hObject, 'mcaData', mca);

zone = '10S';
wgs84 = wgs84Ellipsoid;
ellipsoid = [wgs84.SemimajorAxis wgs84.Eccentricity];

axes(handles.chartAxes);
setappdata(hObject, 'chartAxesHandle', handles.chartAxes);
% axesm utm
% setm(gca,'zone', utmstruct.zone, 'geoid', ellipsoid, 'LabelUnits', 'dm', ...
%     'FFill', 1000, 'FLineWidth', 0.5,  ...
%     'meridianlabel','on','parallellabel','on', ...
%     'MLineLocation', 0.016667, 'PLineLocation', 0.016667, ...
%     'MLabelLocation', 0.083333, 'PLabelLocation', 0.083333);
% 
% [lat1, lon1] = minvtran(mc15.x(1), mc15.y(end));
% [lat2, lon2] = minvtran(mc15.x(end), mc15.y(1));
% setm(gca,'maplatlimit',[lat1 lat2], 'maplonlimit', [lon1 lon2]);


% set(hF, 'ShowText', 'on', 'LabelSpacing', 1e6);
% fillm(mca.SClat, mca.SClon, 'r');
% fillm(mca.PLlat, mca.PLlon, 'r');
% set(gca,'DataAspectRatio',[1 1 1]);
% hFrame = framem('on');
% hGrid = gridm('on');
% set(hFrame,'Clipping','on');
% set(hGrid,'Clipping','on');

surf(mc15.x, mc15.y, mc15.z, 'FaceColor', 'interp', ...
                'LineStyle', 'none', ...
                'FaceLighting', 'gouraud')
cm = haxby(256);
colormap(cm);
daspect([1, 1, .25])
axis tight
camlight left

hold on

V = [0:10:100 200:100:1000];
V = -V;
fprintf('Starting contourf\n');
[C, hF] = contour3(mc15.x, mc15.y, mc15.z, V, '-k');
fprintf('contourf done \n');

grid ON;
xlabel('Easting');
ylabel('Northing')
zlabel('Depth');

setappdata(hObject, 'startStatus', 'false');
set(handles.startButton, 'BackgroundColor', [.941 .941 .941]);
SPTimer = timer('ExecutionMode','fixedRate',...
            'Period', 5,...  % Update the time every 60 seconds.
            'TimerFcn',{@timerCallback, handles}); 
setappdata(hObject,'hSPTimer',SPTimer);
guidata(hObject, handles);

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

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

function [] = timerCallback(varargin)
handles = varargin{3};
SP = serial( 'COM1', ...
    'BaudRate',9600, ...
    'Parity','none', ...
    'DataBits', 8, ...
    'StopBits',1, ...
    'ReadAsyncMode','continuous',...
    'InputBufferSize',8192);
fopen(SP);
%closeSP = onCleanup(@() fclose(SP));

fprintf('Sending PUBX\n');
fprintf(SP,'$PUBX,00*33');
%msg = fscanf(SP);
msg = '$PUBX,00,213104.00,3648.16621,N,12147.27846,W,0.000,G2,66,36,0.398,318.52,0.000,,2.39,1.00,1.02,3,0,0*70'

pause(1);

fclose(SP);
delete(SP);

PUBXfields = strsplit(msg,',');

temp = char(PUBXfields(4));
lat = str2double(temp(1:2)) + (str2double(temp(3:end))/60.00);
if( strcmp(PUBXfields(5),'S') )
    lat = -1.0 * lat;
end
temp = char(PUBXfields(6));
lon = str2double(temp(1:3)) + (str2double(temp(4:end))/60.00);
if( strcmp(PUBXfields(7),'W') )
    lon = -1.0 * lon;
end

fprintf('Lat = %f   Lon = %f\n', lat, lon);

plotShip(handles, lat, lon, 0);

persistent index;
if isempty(index)
    index = 1;
end

% mc15 = getappdata(hObject, 'mc15');
% chartAxesHandle = getappdata(hObject, 'chartAxesHandle');

%plot3(mc15.x(index), mc15.y(index), mc15.z(index), 'or', 'MarkerFaceColor', 'r', 'Parent', chartAxesHandle);
index = index + 1;


function plotShip(handles, lat, lon, heading)
persistent oldShipShapeX;
persistent oldShipShapeY;

persistent firstCall
if isempty(firstCall)
    firstCall = true;
end

persistent offset
if isempty(offset)
    offset = 0
end

utmstruct = getappdata(handles.figure1, 'utmstruct');

%[x, y] = mfwdtran(utmstruct, lat, lon);
% x = x + (606000 - 604728);
% y = y - (4094079 - 4073500);
x = 606000
y = 4073500 + offset;

fprintf('Ship Easting = %f   Ship Northing = %f\n', x, y)

M = makehgtform('zrotate', degtorad(heading));
M = M(1:2, 1:2);
shipShapeXY = getappdata(handles.figure1, 'shipShapeXY');
shipShapeXYRot = M * shipShapeXY;

shipShapeXYNew = [x + shipShapeXYRot(1,:); y + shipShapeXYRot(2,:)];

if firstCall == true
    ship = patch(shipShapeXYNew(1,:), shipShapeXYNew(2,:) + offset, 'r', 'Parent', handles.chartAxes);
    setappdata(handles.chartAxes,'ship',ship);
    hold off
    firstCall = false;
else
    ship = getappdata(handles.chartAxes,'ship');
    delete(ship);
    ship = patch(shipShapeXYNew(1,:), shipShapeXYNew(2,:) + offset, 'r', 'Parent', handles.chartAxes);
    setappdata(handles.chartAxes,'ship',ship);
    drawnow update
end

% if firstCall == true
%     %hold on
%     ship = fill(shipShapeXYNew(1,:), shipShapeXYNew(2,:) + offset, 'r', 'Parent', handles.chartAxes);
%     hold off
%     firstCall = false;
% else
%     ship.XData = shipShapeXYNew(1,:);
%     ship.YData = shipShapeXYNew(2,:)
%     ship = fill(shipShapeXYNew(1,:), shipShapeXYNew(2,:) + offset, 'r', 'Parent', handles.chartAxes);
%     drawnow update
% end
offset = offset + 10;

% fill(shipShapeXYNew(1,:), shipShapeXYNew(2,:), 'green', 'Parent', handles.chartAxes, 'EraseMode','xor');
% 
% oldShipShapeX = shipShapeXYNew(1,:);
% oldShipShapeY = shipShapeXYNew(2,:);

function plotFloat(handles, lat, lon)
persistent oldFloatStarX;
persistent oldFloatStarY;

persistent firstCall
if isempty(firstCall)
    firstCall = true;
end

persistent offset
if isempty(offset)
    offset = 0;
end

% utmstruct = defaultm('utm');
% utmstruct.zone = '10S';
% wgs84 = wgs84Ellipsoid;
% ellipsoid = [wgs84.SemimajorAxis wgs84.Eccentricity];
% utmstruct.geoid = ellipsoid;
% utmstruct = defaultm(utmstruct);
utmstruct = getappdata(handles.figure1, 'utmstruct');
[x, y] = mfwdtran(utmstruct, lat, lon);

floatStarXY = getappdata(handles.figure1, 'floatStarXY');

floatStarXYNew = [x + floatStarXY(1,:); y + floatStarXY(2,:) + offset];
offset = offset + 10;

if firstCall == true
    firstCall = false;
    hold on
else
    hold off
%    fill(oldFloatStarX, oldFloatStarY, 'blue', 'Parent',  handles.chartAxes, 'EraseMode', 'xor');
end
%fill(floatStarXYNew(1,:), floatStarXYNew(2,:), 'blue', 'Parent', handles.chartAxes, 'EraseMode','xor');

oldFloatStarX = floatStarXYNew(1,:);
oldFloatStarY = floatStarXYNew(2,:);

% --- Executes on button press in startButton.
function startButton_Callback(hObject, eventdata, handles)
% hObject    handle to startButton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
startStatus = getappdata(handles.figure1, 'startStatus');
if (strcmp(startStatus, 'false'))
    SPTimer = getappdata(handles.figure1, 'hSPTimer');
    start(SPTimer);
    set(handles.startButton, 'BackgroundColor', [.4 .8 0]);
    setappdata(handles.figure1, 'startStatus', 'true');
else
    SPTimer = getappdata(handles.figure1, 'hSPTimer');
    stop(SPTimer);
    set(handles.startButton, 'BackgroundColor', [.941 .941 .941]);
    setappdata(handles.figure1, 'startStatus', 'false');
end

% --- Executes on button press in ginputButton.
function ginputButton_Callback(hObject, eventdata, handles)
% hObject    handle to ginputButton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[x, y] = ginput(1);
mc15 = getappdata(handles.figure1, 'mc15');
[xIndex xIndex] = min(abs(mc15.x - x))
[yIndex yIndex] = min(abs(mc15.y - y))
depth = mc15.z(yIndex, xIndex)
set(handles.depthMeter, 'String', depth);

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

% --- Executes on button press in HUButton.
function HUButton_Callback(hObject, eventdata, handles)
% hObject    handle to HUButton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
rotatem(handles.chartAxes,[0 0 1],30);

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

% Hint: place code in OpeningFcn to populate chartAxes

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

% --- 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)

SPTimer = getappdata(hObject, 'hSPTimer');
try
    stop(SPTimer);
catch
end
try 
    delete(SPTimer);
catch
end    

function GPSString_Callback(hObject, eventdata, handles)
% hObject    handle to GPSString (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 GPSString as text
%        str2double(get(hObject,'String')) returns contents of GPSString as a double

% --- Executes during object creation, after setting all properties.
function GPSString_CreateFcn(hObject, eventdata, handles)
% hObject    handle to GPSString (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 mouse press over axes background.
function chartAxes_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to chartAxes (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
zoom2cursor();

function depthMeter_Callback(hObject, eventdata, handles)
% hObject    handle to depthMeter (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 depthMeter as text
%        str2double(get(hObject,'String')) returns contents of depthMeter as a double


% --- Executes during object creation, after setting all properties.
function depthMeter_CreateFcn(hObject, eventdata, handles)
% hObject    handle to depthMeter (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:	p_poly_dist
% Description:	distance from point to polygon whose vertices are specified by the
%              vectors xv and yv
% Input:  
%    x - point's x coordinate
%    y - point's y coordinate
%    xv - vector of polygon vertices x coordinates
%    yv - vector of polygon vertices x coordinates
% Output: 
%    d - distance from point to polygon (defined as a minimal distance from 
%        point to any of polygon's ribs, positive if the point is outside the
%        polygon and negative otherwise)
%    x_poly: x coordinate of the point in the polygon closest to x,y
%    y_poly: y coordinate of the point in the polygon closest to x,y
%
% Routines: p_poly_dist.m
% Revision history:
%    03/31/2008 - return the point of the polygon closest to x,y
%               - added the test for the case where a polygon rib is 
%                 either horizontal or vertical. From Eric Schmitz.
%               - Changes by Alejandro Weinstein
%    7/9/2006  - case when all projections are outside of polygon ribs
%    23/5/2004 - created by Michael Yoshpe 
% Remarks:
%*******************************************************************************
function [d,x_poly,y_poly] = p_poly_dist(x, y, xv, yv) 

% If (xv,yv) is not closed, close it.
xv = xv(:);
yv = yv(:);
Nv = length(xv);
if ((xv(1) ~= xv(Nv)) || (yv(1) ~= yv(Nv)))
    xv = [xv ; xv(1)];
    yv = [yv ; yv(1)];
%     Nv = Nv + 1;
end

% linear parameters of segments that connect the vertices
% Ax + By + C = 0
A = -diff(yv);
B =  diff(xv);
C = yv(2:end).*xv(1:end-1) - xv(2:end).*yv(1:end-1);

% find the projection of point (x,y) on each rib
AB = 1./(A.^2 + B.^2);
vv = (A*x+B*y+C);
xp = x - (A.*AB).*vv;
yp = y - (B.*AB).*vv;

% Test for the case where a polygon rib is 
% either horizontal or vertical. From Eric Schmitz
id = find(diff(xv)==0);
xp(id)=xv(id);
clear id
id = find(diff(yv)==0);
yp(id)=yv(id);

% find all cases where projected point is inside the segment
idx_x = (((xp>=xv(1:end-1)) & (xp<=xv(2:end))) | ((xp>=xv(2:end)) & (xp<=xv(1:end-1))));
idx_y = (((yp>=yv(1:end-1)) & (yp<=yv(2:end))) | ((yp>=yv(2:end)) & (yp<=yv(1:end-1))));
idx = idx_x & idx_y;

% distance from point (x,y) to the vertices
dv = sqrt((xv(1:end-1)-x).^2 + (yv(1:end-1)-y).^2);

if(~any(idx)) % all projections are outside of polygon ribs
   [d,I] = min(dv);
   x_poly = xv(I);
   y_poly = yv(I);
else
   % distance from point (x,y) to the projection on ribs
   dp = sqrt((xp(idx)-x).^2 + (yp(idx)-y).^2);
   [min_dv,I1] = min(dv);
   [min_dp,I2] = min(dp);
   [d,I] = min([min_dv min_dp]);
   if I==1, %the closest point is one of the vertices
       x_poly = xv(I1);
       y_poly = yv(I1);
   elseif I==2, %the closest point is one of the projections
       idxs = find(idx);
       x_poly = xp(idxs(I2));
       y_poly = yp(idxs(I2));
   end
end

if(inpolygon(x, y, xv, yv)) 
   d = -d;
end

% --- Executes during object creation, after setting all properties.
function rangePL_CreateFcn(hObject, eventdata, handles)
% hObject    handle to rangePL (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 resetViewButton.
function resetViewButton_Callback(hObject, eventdata, handles)
% hObject    handle to resetViewButton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
zoom RESET;

function usblZMeter_Callback(hObject, eventdata, handles)
% hObject    handle to usblZMeter (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 usblZMeter as text
%        str2double(get(hObject,'String')) returns contents of usblZMeter as a double

% --- Executes during object creation, after setting all properties.
function usblZMeter_CreateFcn(hObject, eventdata, handles)
% hObject    handle to usblZMeter (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 usblYMeter_Callback(hObject, eventdata, handles)
% hObject    handle to usblYMeter (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 usblYMeter as text
%        str2double(get(hObject,'String')) returns contents of usblYMeter as a double

% --- Executes during object creation, after setting all properties.
function usblYMeter_CreateFcn(hObject, eventdata, handles)
% hObject    handle to usblYMeter (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 usblXMeter_Callback(hObject, eventdata, handles)
% hObject    handle to usblXMeter (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 usblXMeter as text
%        str2double(get(hObject,'String')) returns contents of usblXMeter as a double

% --- Executes during object creation, after setting all properties.
function usblXMeter_CreateFcn(hObject, eventdata, handles)
% hObject    handle to usblXMeter (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
