VMT_GraphicsControl

PURPOSE ^

--- THE VELOCITY MAPPING TOOLBOX ---

SYNOPSIS ^

function varargout = VMT_GraphicsControl(varargin)

DESCRIPTION ^

 --- THE VELOCITY MAPPING TOOLBOX ---
 VMT_GRAPHICSCONTROL is a sub-GUI of VMT which allows the user to
 dynamically adjust the figures.
__________________________________________________________________________
 Frank L. Engel, U.S. Geological Survey, Illinois Water Science Center
 (fengel@usgs.gov)

 Code contributed by P.R. Jackson, D. Parsons, D. Mueller, and J. Czuba.
__________________________________________________________________________

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = VMT_GraphicsControl(varargin)
0002 % --- THE VELOCITY MAPPING TOOLBOX ---
0003 % VMT_GRAPHICSCONTROL is a sub-GUI of VMT which allows the user to
0004 % dynamically adjust the figures.
0005 %__________________________________________________________________________
0006 % Frank L. Engel, U.S. Geological Survey, Illinois Water Science Center
0007 % (fengel@usgs.gov)
0008 %
0009 % Code contributed by P.R. Jackson, D. Parsons, D. Mueller, and J. Czuba.
0010 %__________________________________________________________________________
0011 
0012 % Last Modified by GUIDE v2.5 24-Jul-2013 14:55:36
0013 
0014 % Begin initialization code - DO NOT EDIT
0015 gui_Singleton = 1;
0016 gui_State = struct('gui_Name',       mfilename, ...
0017     'gui_Singleton',  gui_Singleton, ...
0018     'gui_OpeningFcn', @VMT_GraphicsControl_OpeningFcn, ...
0019     'gui_OutputFcn',  @VMT_GraphicsControl_OutputFcn, ...
0020     'gui_LayoutFcn',  [] , ...
0021     'gui_Callback',   []);
0022 if nargin && ischar(varargin{1})
0023     gui_State.gui_Callback = str2func(varargin{1});
0024 end
0025 
0026 if nargout
0027     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0028 else
0029     gui_mainfcn(gui_State, varargin{:});
0030 end
0031 % End initialization code - DO NOT EDIT
0032 
0033 
0034 % --- Executes just before VMT_GraphicsControl is made visible.
0035 function VMT_GraphicsControl_OpeningFcn(hObject, eventdata, handles, varargin)
0036 % This function has no output args, see OutputFcn.
0037 % hObject    handle to figure
0038 % eventdata  reserved - to be defined in a future version of MATLAB
0039 % handles    structure with handles and user data (see GUIDATA)
0040 % varargin   command line arguments to VMT_GraphicsControl (see VARARGIN)
0041 
0042 % Choose default command line output for VMT_GraphicsControl
0043 handles.output = hObject;
0044 
0045 % Update handles structure
0046 guidata(hObject, handles);
0047 
0048 % Initialize the GUI parameters:
0049 % ------------------------------
0050 guiparams = createGUIparams;
0051 
0052 % Store the application data
0053 % --------------------------
0054 setappdata(handles.figure1,'guiparams',guiparams)
0055 
0056 % Load the GUI preferences:
0057 % -------------------------
0058 load_prefs(handles.figure1)
0059 
0060 % Initialize the GUI:
0061 % -------------------
0062 initGUI(handles)
0063 % set_enable(handles,'init')
0064 
0065 % UIWAIT makes VMT_GraphicsControl wait for user response (see UIRESUME)
0066 % uiwait(handles.figure1);
0067 
0068 % [EOF] VMT_GraphicsControl_OpeningFcn
0069 
0070 
0071 % --- Outputs from this function are returned to the command line.
0072 function varargout = VMT_GraphicsControl_OutputFcn(hObject, eventdata, handles)
0073 % varargout  cell array for returning output args (see VARARGOUT);
0074 % hObject    handle to figure
0075 % eventdata  reserved - to be defined in a future version of MATLAB
0076 % handles    structure with handles and user data (see GUIDATA)
0077 
0078 % Get default command line output from handles structure
0079 varargout{1} = handles.output;
0080 
0081 
0082 % --- Executes on button press in UseDataLimitsPlanview.
0083 function UseDataLimitsPlanview_Callback(hObject, eventdata, handles)
0084 
0085 % Get the Application Data
0086 % ------------------------
0087 guiparams = getappdata(handles.figure1,'guiparams');
0088 
0089 % Modify the Application data:
0090 % ----------------------------
0091 guiparams.use_data_limits_planview = logical(get(hObject,'Value')); % boolean
0092 
0093 if ~guiparams.use_data_limits_planview % User wants to set limits
0094     % Update the GUI:
0095     % ---------------
0096     set_enable(handles,'setplanviewon')
0097 else
0098     % Re-populate edit boxes with the data limits
0099     % -------------------------------------------
0100     % Compute the data limits to populate edit boxes
0101     PVdata = guiparams.gp_vmt.iric_anv_planview_data.outmat';
0102     PVdata(:,4:5) = PVdata(:,4:5).*100; % in cm/s
0103     vr = sqrt(PVdata(:,4).^2+PVdata(:,5).^2);
0104     guiparams.min_velocity_planview  = nanmin(vr);
0105     guiparams.max_velocity_planview  = nanmax(vr);
0106     
0107     % Ensure correct units
0108     if ~guiparams.gp_vmt.english_units
0109         % No further action
0110     else
0111         guiparams.min_velocity_planview = guiparams.min_velocity_planview*0.03281;
0112         guiparams.max_velocity_planview = guiparams.max_velocity_planview*0.03281;
0113         %guiparams.min_velocity_mcs      = guiparams.min_velocity_mcs*0.03281;
0114         %guiparams.max_velocity_mcs      = guiparams.max_velocity_mcs*0.03281;
0115     end
0116     set(handles.MinVelocityPlanview, 'String', guiparams.min_velocity_planview);
0117     set(handles.MaxVelocityPlanview, 'String', guiparams.max_velocity_planview);
0118     
0119     % Update the GUI:
0120     % ---------------
0121     set_enable(handles,'setplanviewoff')
0122 end
0123 
0124 % Re-store the Application data:
0125 % ------------------------------
0126 setappdata(handles.figure1,'guiparams',guiparams)
0127 
0128 % [EOF] VMT_GraphicsControl_OutputFcn
0129 
0130 
0131 
0132 
0133 
0134 function MinVelocityPlanview_Callback(hObject, eventdata, handles)
0135 % Get the Application data:
0136 % -------------------------
0137 guiparams = getappdata(handles.figure1,'guiparams');
0138 
0139 % Get the new entry and make sure it is valid (numeric, positive):
0140 % ----------------------------------------------------------------
0141 new_value = str2double(get(hObject,'String'));
0142 is_a_number = ~isnan(new_value);
0143 
0144 % Modify the Application data:
0145 % ----------------------------
0146 if is_a_number
0147     guiparams.min_velocity_planview = new_value;
0148     
0149     % Re-store the Application data:
0150     % ------------------------------
0151     setappdata(handles.figure1,'guiparams',guiparams)
0152     
0153 else % Reject the (incorrect) input
0154     set(hObject,'String',guiparams.min_velocity_planview)
0155 end
0156 % [EOF] MinVelocityPlanview_Callback
0157 
0158 
0159 
0160 
0161 
0162 function MaxVelocityPlanview_Callback(hObject, eventdata, handles)
0163 % Get the Application data:
0164 % -------------------------
0165 guiparams = getappdata(handles.figure1,'guiparams');
0166 
0167 % Get the new entry and make sure it is valid (numeric, positive):
0168 % ----------------------------------------------------------------
0169 new_value = str2double(get(hObject,'String'));
0170 is_a_number = ~isnan(new_value);
0171 
0172 % Modify the Application data:
0173 % ----------------------------
0174 if is_a_number
0175     guiparams.max_velocity_planview = new_value;
0176     
0177     % Re-store the Application data:
0178     % ------------------------------
0179     setappdata(handles.figure1,'guiparams',guiparams)
0180     
0181 else % Reject the (incorrect) input
0182     set(hObject,'String',guiparams.max_velocity_planview)
0183 end
0184 % [EOF] MaxVelocityPlanview_Callback
0185 
0186 
0187 
0188 % --- Executes on selection change in ColormapPlanview.
0189 function ColormapPlanview_Callback(hObject, eventdata, handles)
0190 % Get the Application data:
0191 % -------------------------
0192 guiparams = getappdata(handles.figure1,'guiparams');
0193 guiprefs  = getappdata(handles.figure1,'guiprefs');
0194 
0195 % Modify the Application data:
0196 % ----------------------------
0197 idx_variable = get(hObject,'Value');
0198 guiparams.idx_colormap_planview = idx_variable;
0199 guiparams.colormap_planview = guiparams.colormaps_planview(idx_variable).string;
0200 
0201 if strcmpi('Browse for more (cpt)...',guiparams.colormap_planview)
0202     [FileName,PathName] = uigetfile('*.cpt','Select the cpt colormap file',...
0203         fullfile(guiprefs.cpt_path,guiprefs.cpt_file));
0204     guiparams.cpt_planview = fullfile(PathName,FileName);
0205     
0206     % Update the preferences:
0207     % -----------------------
0208     guiprefs.cpt_path = PathName;
0209     guiprefs.cpt_file = FileName;
0210     setappdata(handles.figure1,'guiprefs',guiprefs)
0211     store_prefs(handles.figure1,'cptplanview')
0212 end
0213 
0214 % Re-store the Application data:
0215 % ------------------------------
0216 setappdata(handles.figure1,'guiparams',guiparams)
0217 
0218 % [EOF] ColormapPlanview_Callback
0219 
0220 
0221 
0222 % --- Executes on button press in UseDataLimitsMCS.
0223 function UseDataLimitsMCS_Callback(hObject, eventdata, handles)
0224 % Get the Application Data
0225 % ------------------------
0226 guiparams = getappdata(handles.figure1,'guiparams');
0227 
0228 % Modify the Application data:
0229 % ----------------------------
0230 guiparams.use_data_limits_mcs = logical(get(hObject,'Value')); % boolean
0231 
0232 if ~guiparams.use_data_limits_mcs % User wants to set limits
0233     % Update the GUI:
0234     % ---------------
0235     set_enable(handles,'setmcson')
0236 else
0237     % Re-populate edit boxes with the data limits
0238     % -------------------------------------------
0239     % Compute the data limits to populate edit boxes
0240     switch guiparams.gp_vmt.contour
0241         case 'streamwise'
0242             vmin = nanmin(guiparams.gp_vmt.V.uSmooth(:));
0243             vmax = nanmax(guiparams.gp_vmt.V.uSmooth(:));
0244         case 'transverse'
0245             vmin = nanmin(guiparams.gp_vmt.V.vSmooth(:));
0246             vmax = nanmax(guiparams.gp_vmt.V.vSmooth(:));
0247         case 'vertical'
0248             vmin = nanmin(guiparams.gp_vmt.V.wSmooth(:));
0249             vmax = nanmax(guiparams.gp_vmt.V.wSmooth(:));
0250         case 'mag'
0251             vmin = nanmin(guiparams.gp_vmt.V.mcsMagSmooth(:));
0252             vmax = nanmax(guiparams.gp_vmt.V.mcsMagSmooth(:));
0253         case 'east'
0254             vmin = nanmin(guiparams.gp_vmt.V.mcsMagSmooth(:));
0255             vmax = nanmax(guiparams.gp_vmt.V.mcsMagSmooth(:));
0256         case 'north'
0257             vmin = nanmin(guiparams.gp_vmt.V.mcsEastSmooth(:));
0258             vmax = nanmax(guiparams.gp_vmt.V.mcsNorthSmooth(:));
0259         case 'primary_zsd'
0260             vmin = nanmin(guiparams.gp_vmt.V.vpSmooth(:));
0261             vmax = nanmax(guiparams.gp_vmt.V.vpSmooth(:));
0262         case 'secondary_zsd'
0263             vmin = nanmin(guiparams.gp_vmt.V.vsSmooth(:));
0264             vmax = nanmax(guiparams.gp_vmt.V.vsSmooth(:));
0265         case 'primary_roz'
0266             vmin = nanmin(guiparams.gp_vmt.V.Roz.upSmooth(:));
0267             vmax = nanmax(guiparams.gp_vmt.V.Roz.upSmooth(:));
0268         case 'secondary_roz'
0269             vmin = nanmin(guiparams.gp_vmt.V.Roz.usSmooth(:));
0270             vmax = nanmax(guiparams.gp_vmt.V.Roz.usSmooth(:));
0271         case 'primary_roz_x'
0272             vmin = nanmin(guiparams.gp_vmt.V.Roz.upxSmooth(:));
0273             vmax = nanmax(guiparams.gp_vmt.V.Roz.upxSmooth(:));
0274         case 'primary_roz_y'
0275             vmin = nanmin(guiparams.gp_vmt.V.Roz.upySmooth(:));
0276             vmax = nanmax(guiparams.gp_vmt.V.Roz.upySmooth(:));
0277         case 'secondary_roz_x'
0278             vmin = nanmin(guiparams.gp_vmt.V.Roz.usxSmooth(:));
0279             vmax = nanmax(guiparams.gp_vmt.V.Roz.usxSmooth(:));
0280         case 'secondary_roz_y'
0281             vmin = nanmin(guiparams.gp_vmt.V.Roz.usySmooth(:));
0282             vmax = nanmax(guiparams.gp_vmt.V.Roz.usySmooth(:));
0283         case 'backscatter'
0284             vmin = nanmin(guiparams.gp_vmt.V.mcsBackSmooth(:));
0285             vmax = nanmax(guiparams.gp_vmt.V.mcsBackSmooth(:));
0286         case 'flowangle'
0287             vmin = nanmin(guiparams.gp_vmt.V.mcsDirSmooth(:));
0288             vmax = nanmax(guiparams.gp_vmt.V.mcsDirSmooth(:));
0289     end
0290     guiparams.min_velocity_mcs              = vmin;
0291     guiparams.max_velocity_mcs              = vmax;
0292     
0293     % Ensure correct units
0294     if ~guiparams.gp_vmt.english_units
0295         % No further action
0296     else
0297         %guiparams.min_velocity_planview = guiparams.min_velocity_planview*0.03281;
0298         %guiparams.max_velocity_planview = guiparams.max_velocity_planview*0.03281;
0299         guiparams.min_velocity_mcs      = guiparams.min_velocity_mcs*0.03281;
0300         guiparams.max_velocity_mcs      = guiparams.max_velocity_mcs*0.03281;
0301     end
0302     set(handles.MinVelocityMCS, 'String', guiparams.min_velocity_mcs);
0303     set(handles.MaxVelocityMCS, 'String', guiparams.max_velocity_mcs);
0304     
0305     % Update the GUI:
0306     % ---------------
0307     set_enable(handles,'setmcsoff')
0308 end
0309 
0310 % Re-store the Application data:
0311 % ------------------------------
0312 setappdata(handles.figure1,'guiparams',guiparams)
0313 
0314 % [EOF] UseDataLimitsMCS_Callback
0315 
0316 
0317 function MinVelocityMCS_Callback(hObject, eventdata, handles)
0318 % Get the Application data:
0319 % -------------------------
0320 guiparams = getappdata(handles.figure1,'guiparams');
0321 
0322 % Get the new entry and make sure it is valid (numeric):
0323 % ----------------------------------------------------------------
0324 new_value = str2double(get(hObject,'String'));
0325 is_a_number = ~isnan(new_value);
0326 
0327 % Modify the Application data:
0328 % ----------------------------
0329 if is_a_number
0330     guiparams.min_velocity_mcs = new_value;
0331     
0332     % Re-store the Application data:
0333     % ------------------------------
0334     setappdata(handles.figure1,'guiparams',guiparams)
0335     
0336 else % Reject the (incorrect) input
0337     set(hObject,'String',guiparams.min_velocity_mcs)
0338 end
0339 % [EOF] MinVelocityMCS_Callback
0340 
0341 
0342 
0343 
0344 function MaxVelocityMCS_Callback(hObject, eventdata, handles)
0345 % Get the Application data:
0346 % -------------------------
0347 guiparams = getappdata(handles.figure1,'guiparams');
0348 
0349 % Get the new entry and make sure it is valid (numeric):
0350 % ----------------------------------------------------------------
0351 new_value = str2double(get(hObject,'String'));
0352 is_a_number = ~isnan(new_value);
0353 
0354 % Modify the Application data:
0355 % ----------------------------
0356 if is_a_number
0357     guiparams.max_velocity_mcs = new_value;
0358     
0359     % Re-store the Application data:
0360     % ------------------------------
0361     setappdata(handles.figure1,'guiparams',guiparams)
0362     
0363 else % Reject the (incorrect) input
0364     set(hObject,'String',guiparams.max_velocity_mcs)
0365 end
0366 % [EOF] MaxVelocityMCS_Callback
0367 
0368 
0369 
0370 % --- Executes on selection change in ColormapMCS.
0371 function ColormapMCS_Callback(hObject, eventdata, handles)
0372 % Get the Application data:
0373 % -------------------------
0374 guiparams = getappdata(handles.figure1,'guiparams');
0375 guiprefs  = getappdata(handles.figure1,'guiprefs');
0376 
0377 % Modify the Application data:
0378 % ----------------------------
0379 idx_variable = get(hObject,'Value');
0380 guiparams.idx_colormap_mcs = idx_variable;
0381 guiparams.colormap_mcs = guiparams.colormaps_mcs(idx_variable).string;
0382 
0383 if strcmpi('Browse for more (cpt)...',guiparams.colormap_mcs)
0384     [FileName,PathName] = uigetfile('*.cpt','Select the cpt colormap file',...
0385         fullfile(guiprefs.cpt_path,guiprefs.cpt_file));
0386     guiparams.cpt_mcs = fullfile(PathName,FileName);
0387     
0388     % Update the preferences:
0389     % -----------------------
0390     guiprefs.cpt_path = PathName;
0391     guiprefs.cpt_file = FileName;
0392     setappdata(handles.figure1,'guiprefs',guiprefs)
0393     store_prefs(handles.figure1,'cptmcs')
0394 end
0395 
0396 % Re-store the Application data:
0397 % ------------------------------
0398 setappdata(handles.figure1,'guiparams',guiparams)
0399 
0400 % [EOF] ColormapMCS_Callback
0401 
0402 
0403 
0404 function ReferenceVelocity_Callback(hObject, eventdata, handles)
0405 % Get the Application data:
0406 % -------------------------
0407 guiparams = getappdata(handles.figure1,'guiparams');
0408 
0409 % Get the new entry and make sure it is valid (numeric, positive):
0410 % ----------------------------------------------------------------
0411 new_value = str2double(get(hObject,'String'));
0412 is_a_number = ~isnan(new_value);
0413 is_positive = new_value>=0;
0414 
0415 % Modify the Application data:
0416 % ----------------------------
0417 if is_a_number && is_positive
0418     guiparams.reference_velocity = new_value;
0419     
0420     % Re-store the Application data:
0421     % ------------------------------
0422     setappdata(handles.figure1,'guiparams',guiparams)
0423     
0424 else % Reject the (incorrect) input
0425     set(hObject,'String',guiparams.reference_velocity)
0426 end
0427 % [EOF] ReferenceVelocity_Callback
0428 
0429 
0430 
0431 
0432 % --- Executes on button press in UseDefaults.
0433 function UseDefaults_Callback(hObject, eventdata, handles)
0434 % Get the Application Data
0435 % ------------------------
0436 guiparams = getappdata(handles.figure1,'guiparams');
0437 
0438 % Modify the Application data:
0439 % ----------------------------
0440 guiparams.use_defaults = logical(get(hObject,'Value')); % boolean
0441 
0442 if ~guiparams.use_defaults % User wants to set limits
0443     % Update the GUI:
0444     % ---------------
0445     set_enable(handles,'setrefon')
0446 else
0447     [~,J] = ind2sub(size(guiparams.gp_vmt.V.vp(1,:)),find(~isnan(guiparams.gp_vmt.V.vp(1,:))==1));
0448     et = J(1):guiparams.gp_vmt.horizontal_vector_spacing:J(end);
0449     [r, ~]=size(guiparams.gp_vmt.V.vp);
0450     bi = 1:guiparams.gp_vmt.vertical_vector_spacing:r;
0451     switch guiparams.gp_vmt.secondary_flow_vector_variable
0452         case 'transverse'
0453             reference_velocity = ceil(max(max(abs(guiparams.gp_vmt.V.vSmooth(bi,et)))));
0454         case 'secondary_zsd'
0455             reference_velocity = ceil(max(max(abs(guiparams.gp_vmt.V.vsSmooth(bi,et)))));
0456         case 'secondary_roz'
0457             reference_velocity = ceil(max(max(abs(guiparams.gp_vmt.V.Roz.usSmooth(bi,et)))));
0458         case 'secondary_roz_y'
0459             reference_velocity = ceil(max(max(abs(guiparams.gp_vmt.V.Roz.usySmooth(bi,et)))));
0460         case 'primary_roz_y'
0461             reference_velocity = ceil(max(max(abs(guiparams.gp_vmt.V.Roz.upySmooth(bi,et)))));
0462     end
0463     
0464     distance = 0.06*max(guiparams.gp_vmt.V.mcsDist(:));
0465     depth    = 0.95*max(guiparams.gp_vmt.V.mcsBed(:));
0466     if guiparams.gp_vmt.english_units
0467         reference_velocity = reference_velocity*0.03281; % cm/s to ft/s
0468         distance = distance*3.281;
0469         depth    = depth*3.281;
0470     end
0471     
0472     
0473     set(handles.ReferenceVelocity, 'String', num2str(reference_velocity))
0474     set(handles.Distance,          'String', num2str(distance))
0475     set(handles.Depth,             'String', num2str(depth))
0476     
0477     % Re-store the Application data:
0478     % ------------------------------
0479     guiparams.reference_velocity = reference_velocity;
0480     guiparams.distance           = distance;
0481     guiparams.depth              = depth;
0482     setappdata(handles.figure1,'guiparams',guiparams)
0483     
0484     % Update the GUI:
0485     % ---------------
0486     set_enable(handles,'setrefoff')
0487 end
0488 
0489 
0490 % [EOF] UseDefaults_Callback
0491 
0492 
0493 function Distance_Callback(hObject, eventdata, handles)
0494 % Get the Application data:
0495 % -------------------------
0496 guiparams = getappdata(handles.figure1,'guiparams');
0497 
0498 % Get the new entry and make sure it is valid (numeric, positive):
0499 % ----------------------------------------------------------------
0500 new_value = str2double(get(hObject,'String'));
0501 is_a_number = ~isnan(new_value);
0502 is_positive = new_value>=0;
0503 
0504 % Modify the Application data:
0505 % ----------------------------
0506 if is_a_number && is_positive
0507     guiparams.distance = new_value;
0508     
0509     % Re-store the Application data:
0510     % ------------------------------
0511     setappdata(handles.figure1,'guiparams',guiparams)
0512     
0513 else % Reject the (incorrect) input
0514     set(hObject,'String',guiparams.distance)
0515 end
0516 % [EOF] Distance_Callback
0517 
0518 
0519 
0520 
0521 
0522 function Depth_Callback(hObject, eventdata, handles)
0523 % Get the Application data:
0524 % -------------------------
0525 guiparams = getappdata(handles.figure1,'guiparams');
0526 
0527 % Get the new entry and make sure it is valid (numeric, positive):
0528 % ----------------------------------------------------------------
0529 new_value = str2double(get(hObject,'String'));
0530 is_a_number = ~isnan(new_value);
0531 is_positive = new_value>=0;
0532 
0533 % Modify the Application data:
0534 % ----------------------------
0535 if is_a_number && is_positive
0536     guiparams.depth = new_value;
0537     
0538     % Re-store the Application data:
0539     % ------------------------------
0540     setappdata(handles.figure1,'guiparams',guiparams)
0541     
0542 else % Reject the (incorrect) input
0543     set(hObject,'String',guiparams.depth)
0544 end
0545 % [EOF] Depth_Callback
0546 
0547 
0548 
0549 
0550 % --- Executes on button press in ApplyChanges.
0551 function ApplyChanges_Callback(hObject, eventdata, handles)
0552 % Get the Application data:
0553 % -------------------------
0554 guiparams = getappdata(handles.figure1,'guiparams');
0555 guiprefs  = getappdata(handles.figure1,'guiprefs');
0556 z   = guiparams.gp_vmt.z;
0557 A   = guiparams.gp_vmt.A;
0558 V   = guiparams.gp_vmt.V;
0559 Map = guiparams.gp_vmt.Map;
0560 
0561 % See if PLOT 1 exists already, if so grab the handle.
0562 fig_planview_handle = findobj(0,'name','Plan View Map');
0563 
0564 % If PLOT 1 exists, go ahead and apply any changes
0565 if ~isempty(fig_planview_handle) &&  ishandle(fig_planview_handle)
0566     figure(fig_planview_handle);
0567     % Plot the data:
0568     % --------------
0569     %msgbox('Plotting Plan View','VMT Status','help','replace');
0570     depth_range = [guiparams.gp_vmt.depth_range_min guiparams.gp_vmt.depth_range_max];
0571     
0572     minrng = guiparams.min_velocity_planview;
0573     maxrng = guiparams.max_velocity_planview;
0574     usecolormap = guiparams.colormap_planview;
0575     cptfullfile = guiparams.cpt_planview;
0576     [~,~,~] = VMT_PlotPlanViewQuivers(z,A,V,Map, ...
0577         depth_range, ...
0578         guiparams.gp_vmt.vector_scale_plan_view, ...
0579         guiparams.gp_vmt.vector_spacing_plan_view, ...
0580         guiparams.gp_vmt.smoothing_window_size, ...
0581         guiparams.gp_vmt.display_shoreline, ...
0582         guiparams.gp_vmt.english_units,...
0583         guiparams.gp_vmt.mat_file, ...
0584         guiparams.gp_vmt.mat_path,...
0585         minrng,...
0586         maxrng,...
0587         usecolormap,...
0588         cptfullfile); % PLOT2
0589     
0590     % Plot Shoreline
0591     if guiparams.gp_vmt.display_shoreline
0592         
0593         if ischar(guiprefs.shoreline_file) % User did not hit cancel
0594             mapdata = dlmread(fullfile(guiprefs.shoreline_path,guiprefs.shoreline_file));
0595             Map.UTMe   = mapdata(:,1);
0596             Map.UTMn   = mapdata(:,2);
0597             Map.infile = fullfile(guiprefs.shoreline_path,guiprefs.shoreline_file);
0598             %Map.UTMzone = zone;
0599         else
0600             Map = [];
0601         end
0602         VMT_PlotShoreline(Map)
0603     end
0604     
0605     % Overlay DOQQ
0606     if guiparams.gp_vmt.add_background
0607         [~,~] = VMT_OverlayDOQQ(guiprefs,true);
0608     end
0609 end
0610 
0611 % See if PLOT 3 exists already, if so clear the figure
0612 fig_contour_handle = findobj(0,'name','Mean Cross Section Contour');
0613 
0614 % If PLOT 3 exists, go ahead and apply any changes
0615 if ~isempty(fig_contour_handle) &&  ishandle(fig_contour_handle)
0616     figure(fig_contour_handle);
0617     
0618     % Modify reference vector, only if it's already being plotted
0619     if guiparams.gp_vmt.plot_secondary_flow_vectors
0620         if ~guiparams.gp_vmt.english_units
0621             [~,A,V,plot_cont_log_text] = VMT_PlotXSContQuiver(z,A,V, ...
0622                 guiparams.gp_vmt.contour, ...
0623                 guiparams.gp_vmt.vector_scale_cross_section, ...
0624                 guiparams.gp_vmt.vertical_exaggeration, ...
0625                 guiparams.gp_vmt.horizontal_vector_spacing, ...
0626                 guiparams.gp_vmt.vertical_vector_spacing, ...
0627                 guiparams.gp_vmt.secondary_flow_vector_variable, ...
0628                 guiparams.gp_vmt.include_vertical_velocity, ...
0629                 guiparams.gp_vmt.english_units,...
0630                 guiparams.reference_velocity,...
0631                 guiparams.distance,...
0632                 guiparams.depth); %#ok<ASGLU> % PLOT3
0633         else
0634             [~,A,V,plot_cont_log_text] = VMT_PlotXSContQuiver(z,A,V, ...
0635                 guiparams.gp_vmt.contour, ...
0636                 guiparams.gp_vmt.vector_scale_cross_section, ...
0637                 guiparams.gp_vmt.vertical_exaggeration, ...
0638                 guiparams.gp_vmt.horizontal_vector_spacing, ...
0639                 guiparams.gp_vmt.vertical_vector_spacing, ...
0640                 guiparams.gp_vmt.secondary_flow_vector_variable, ...
0641                 guiparams.gp_vmt.include_vertical_velocity, ...
0642                 guiparams.gp_vmt.english_units,...
0643                 guiparams.reference_velocity.*30.48,... %cm/s
0644                 guiparams.distance.*0.3048,...          %m
0645                 guiparams.depth.*0.3048); %#ok<ASGLU> % PLOT3
0646         end
0647     end
0648     
0649     % Set data limits
0650     caxis([
0651         guiparams.min_velocity_mcs
0652         guiparams.max_velocity_mcs])
0653     
0654     % Apply the color map
0655     if ~strcmpi('Browse for more (cpt)...',guiparams.colormap_mcs)
0656         colormap(guiparams.colormap_mcs)
0657     else
0658         cptcmap(guiparams.cpt_mcs)
0659     end
0660 end
0661 
0662 % Force plots to be formated properly
0663 % -----------------------------------
0664 if guiparams.gp_vmt.presentation
0665     UpdatePlotStyle(hObject, eventdata, handles)
0666 else
0667     UpdatePlotStyle(hObject, eventdata, handles)
0668 end
0669 % [EOF] ApplyChanges_Callback
0670 
0671 
0672 % --- Executes on button press in Close.
0673 function Close_Callback(hObject, eventdata, handles)
0674 
0675 close(handles.figure1)
0676 
0677 % [EOF] Close_Callback
0678 
0679 % --------------------------------------------------------------------
0680 function initGUI(handles)
0681 % Initialize the UI controls in the GUI.
0682 
0683 guiparams = getappdata(handles.figure1,'guiparams');
0684 
0685 % Plan View Map Panel
0686 set(handles.UseDataLimitsPlanview,    'Value',  guiparams.use_data_limits_planview);
0687 set(handles.MinVelocityPlanview,      'String', guiparams.min_velocity_planview);
0688 set(handles.MinVelocityPlanviewUnits, 'String', guiparams.min_velocity_planview_units);
0689 set(handles.MaxVelocityPlanview,      'String', guiparams.max_velocity_planview);
0690 set(handles.MaxVelocityPlanviewUnits, 'String', guiparams.max_velocity_planview_units);
0691 set(handles.ColormapPlanview,         'String',{guiparams.colormaps_planview.string}, ...
0692     'Value', guiparams.idx_colormap_planview)
0693 
0694 % Mean Cross Section Contours
0695 set(handles.UseDataLimitsMCS,           'Value',  guiparams.use_data_limits_mcs);
0696 set(handles.MinVelocityMCS,             'String', guiparams.min_velocity_mcs);
0697 set(handles.MinVelocityMCSUnits,        'String', guiparams.min_velocity_mcs_units);
0698 set(handles.MaxVelocityMCS,             'String', guiparams.max_velocity_mcs);
0699 set(handles.MaxVelocityMCSUnits,        'String', guiparams.max_velocity_mcs_units);
0700 set(handles.UseDefaults,                'Value',  guiparams.use_defaults);
0701 set(handles.ReferenceVelocity,          'String', guiparams.reference_velocity);
0702 set(handles.ReferenceVelocityUnits,     'String', guiparams.reference_velocity_units);
0703 set(handles.Distance,                   'String', guiparams.distance);
0704 set(handles.DistanceUnits,              'String', guiparams.distance_units);
0705 set(handles.Depth,                      'String', guiparams.depth);
0706 set(handles.DepthUnits,                 'String', guiparams.depth_units);
0707 set(handles.ColormapMCS,                'String',{guiparams.colormaps_mcs.string}, ...
0708     'Value', guiparams.idx_colormap_mcs);
0709 
0710 % Update the GUI:
0711 % ---------------
0712 if iscell(guiparams.gp_vmt.mat_file) % Multiple mat files loaded
0713     set_enable(handles,'initmultiple')
0714 else
0715     set_enable(handles,'init')
0716 end
0717 % [EOF] initGUI
0718 
0719 function [guiparams] = createGUIparams
0720 
0721 % Get the VMT current state for use by the sub-GUI
0722 % ------------------------------------------------
0723 hVMTgui                 = getappdata(0,'hVMTgui');
0724 guiparams_vmt           = getappdata(hVMTgui,'guiparams');
0725 guiparams.gp_vmt        = guiparams_vmt;
0726 
0727 % Check to see what plots already exist
0728 % -------------------------------------
0729 fig_planview_handle = findobj(0,'name','Plan View Map');
0730 fig_mcs_handle = findobj(0,'name','Mean Cross Section Contour');
0731 % if ~isempty(fig_planview_handle) &&  ishandle(fig_planview_handle)
0732 %     figure(fig_planview_handle); clf
0733 % else
0734 %     fig_planview_handle = figure('name','Plan View Map'); clf
0735 %     %set(gca,'DataAspectRatio',[1 1 1],'PlotBoxAspectRatio',[1 1 1])
0736 % end
0737 
0738 %%%%%%%%%%%%%%%%%
0739 % Plan View Map %
0740 %%%%%%%%%%%%%%%%%
0741 guiparams.use_data_limits_planview      = 1;
0742 
0743 if ~isempty(fig_planview_handle) && ishandle(fig_planview_handle)
0744     % Compute the data limits to populate edit boxes
0745     PVdata = guiparams.gp_vmt.iric_anv_planview_data.outmat';
0746     PVdata(:,4:5) = PVdata(:,4:5).*100; % in cm/s
0747     vr = sqrt(PVdata(:,4).^2+PVdata(:,5).^2);
0748     guiparams.min_velocity_planview  = nanmin(vr);
0749     guiparams.max_velocity_planview  = nanmax(vr);
0750 else
0751     guiparams.min_velocity_planview  = 0;
0752     guiparams.max_velocity_planview  = 0;
0753 end
0754 
0755 % Colormap choices
0756 guiparams.idx_colormap_planview  = 1;
0757 idx = 1;
0758 guiparams.colormaps_planview(idx).string   = 'Jet';
0759 idx = idx + 1;
0760 guiparams.colormaps_planview(idx).string   = 'HSV';
0761 idx = idx + 1;
0762 guiparams.colormaps_planview(idx).string   = 'Hot';
0763 idx = idx + 1;
0764 guiparams.colormaps_planview(idx).string   = 'Cool';
0765 idx = idx + 1;
0766 guiparams.colormaps_planview(idx).string   = 'Spring';
0767 idx = idx + 1;
0768 guiparams.colormaps_planview(idx).string   = 'Summer';
0769 idx = idx + 1;
0770 guiparams.colormaps_planview(idx).string   = 'Autumn';
0771 idx = idx + 1;
0772 guiparams.colormaps_planview(idx).string   = 'Winter';
0773 idx = idx + 1;
0774 guiparams.colormaps_planview(idx).string   = 'Gray';
0775 idx = idx + 1;
0776 guiparams.colormaps_planview(idx).string   = 'Bone';
0777 idx = idx + 1;
0778 guiparams.colormaps_planview(idx).string   = 'Copper';
0779 idx = idx + 1;
0780 guiparams.colormaps_planview(idx).string   = 'Pink';
0781 idx = idx + 1;
0782 guiparams.colormaps_planview(idx).string   = 'Browse for more (cpt)...';
0783 guiparams.colormap_planview = ...
0784     guiparams.colormaps_planview(guiparams.idx_colormap_planview).string;
0785 guiparams.cpt_planview                     = [];
0786 
0787 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0788 % Mean Cross Section Contours %
0789 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0790 guiparams.use_data_limits_mcs           = 1;
0791 guiparams.use_defaults                  = 1;
0792 
0793 if ~isempty(fig_mcs_handle) && ishandle(fig_mcs_handle)
0794 if iscell(guiparams.gp_vmt.mat_file) % Multiple mat files loaded
0795     guiparams.min_velocity_mcs   = 0;
0796     guiparams.max_velocity_mcs   = 0;
0797     guiparams.distance           = 0;
0798     guiparams.depth              = 0;
0799     guiparams.reference_velocity = 0; % cm/s to ft/s
0800 else
0801     % Compute the data limits for the edit box, based on the currently selected
0802     % contour plot variable
0803     switch guiparams.gp_vmt.contour
0804         case 'streamwise'
0805             vmin = nanmin(guiparams.gp_vmt.V.uSmooth(:));
0806             vmax = nanmax(guiparams.gp_vmt.V.uSmooth(:));
0807         case 'transverse'
0808             vmin = nanmin(guiparams.gp_vmt.V.vSmooth(:));
0809             vmax = nanmax(guiparams.gp_vmt.V.vSmooth(:));
0810         case 'vertical'
0811             vmin = nanmin(guiparams.gp_vmt.V.wSmooth(:));
0812             vmax = nanmax(guiparams.gp_vmt.V.wSmooth(:));
0813         case 'mag'
0814             vmin = nanmin(guiparams.gp_vmt.V.mcsMagSmooth(:));
0815             vmax = nanmax(guiparams.gp_vmt.V.mcsMagSmooth(:));
0816         case 'east'
0817             vmin = nanmin(guiparams.gp_vmt.V.mcsMagSmooth(:));
0818             vmax = nanmax(guiparams.gp_vmt.V.mcsMagSmooth(:));
0819         case 'north'
0820             vmin = nanmin(guiparams.gp_vmt.V.mcsEastSmooth(:));
0821             vmax = nanmax(guiparams.gp_vmt.V.mcsNorthSmooth(:));
0822         case 'error'
0823             vmin = nanmin(guiparams.gp_vmt.V.mcsError(:));
0824             vmax = nanmax(guiparams.gp_vmt.V.mcsError(:));
0825         case 'primary_zsd'
0826             vmin = nanmin(guiparams.gp_vmt.V.vpSmooth(:));
0827             vmax = nanmax(guiparams.gp_vmt.V.vpSmooth(:));
0828         case 'secondary_zsd'
0829             vmin = nanmin(guiparams.gp_vmt.V.vsSmooth(:));
0830             vmax = nanmax(guiparams.gp_vmt.V.vsSmooth(:));
0831         case 'primary_roz'
0832             vmin = nanmin(guiparams.gp_vmt.V.Roz.upSmooth(:));
0833             vmax = nanmax(guiparams.gp_vmt.V.Roz.upSmooth(:));
0834         case 'secondary_roz'
0835             vmin = nanmin(guiparams.gp_vmt.V.Roz.usSmooth(:));
0836             vmax = nanmax(guiparams.gp_vmt.V.Roz.usSmooth(:));
0837         case 'primary_roz_x'
0838             vmin = nanmin(guiparams.gp_vmt.V.Roz.upxSmooth(:));
0839             vmax = nanmax(guiparams.gp_vmt.V.Roz.upxSmooth(:));
0840         case 'primary_roz_y'
0841             vmin = nanmin(guiparams.gp_vmt.V.Roz.upySmooth(:));
0842             vmax = nanmax(guiparams.gp_vmt.V.Roz.upySmooth(:));
0843         case 'secondary_roz_x'
0844             vmin = nanmin(guiparams.gp_vmt.V.Roz.usxSmooth(:));
0845             vmax = nanmax(guiparams.gp_vmt.V.Roz.usxSmooth(:));
0846         case 'secondary_roz_y'
0847             vmin = nanmin(guiparams.gp_vmt.V.Roz.usySmooth(:));
0848             vmax = nanmax(guiparams.gp_vmt.V.Roz.usySmooth(:));
0849         case 'backscatter'
0850             vmin = nanmin(guiparams.gp_vmt.V.mcsBackSmooth(:));
0851             vmax = nanmax(guiparams.gp_vmt.V.mcsBackSmooth(:));
0852         case 'flowangle'
0853             vmin = nanmin(guiparams.gp_vmt.V.mcsDirSmooth(:));
0854             vmax = nanmax(guiparams.gp_vmt.V.mcsDirSmooth(:));
0855     end
0856     guiparams.min_velocity_mcs              = vmin;
0857     guiparams.max_velocity_mcs              = vmax;
0858     
0859     % Reference arrow
0860     % Find first full row of data. Typically this is row 1 with RG data,
0861     % however it may not be for M9 and/or RR data.
0862     i = 1;
0863     while any(isnan(guiparams.gp_vmt.V.vp(i,:)))
0864         i=i+1;
0865         if i > size(guiparams.gp_vmt.V.vp,1)
0866             break
0867         end
0868     end
0869     % If a bad ensemble exists, the above while loop might not find a
0870     % result. If that happens, just use row 1 anyway
0871 %     try
0872 %         [I,J] = ind2sub(size(guiparams.gp_vmt.V.vp(i,:)),find(~isnan(guiparams.gp_vmt.V.vp(i,:))==1));
0873 %     catch err
0874 %         [I,J] = ind2sub(size(guiparams.gp_vmt.V.vp(1,:)),find(~isnan(guiparams.gp_vmt.V.vp(1,:))==1));
0875 %     end
0876     
0877     % Find first full row of data. Typically this is row 1 with RG data,
0878     % however it may not be for M9 and/or RR data.
0879     i = 1;
0880     while any(isnan(guiparams.gp_vmt.V.vp(i,:)))
0881         i=i+1;
0882         if i > size(guiparams.gp_vmt.V.vp,1)
0883             break
0884         end
0885     end
0886     i=5; % This is a temporary fix
0887     % If a bad ensemble exists, the above while loop might not find a
0888     % result. If that happens, just use row 1 anyway
0889     try
0890         [I,J] = ind2sub(size(guiparams.gp_vmt.V.vp(i,:)),find(~isnan(guiparams.gp_vmt.V.vp(i,:))==1));
0891     catch err
0892         [I,J] = ind2sub(size(guiparams.gp_vmt.V.vp(1,:)),find(~isnan(guiparams.gp_vmt.V.vp(1,:))==1));
0893     end
0894     
0895     et = J(1):guiparams.gp_vmt.horizontal_vector_spacing:J(end);
0896     [r, ~]=size(guiparams.gp_vmt.V.vp);
0897     bi = 1:guiparams.gp_vmt.vertical_vector_spacing:r;
0898     switch guiparams.gp_vmt.secondary_flow_vector_variable
0899         case 'transverse'
0900             guiparams.reference_velocity = ceil(max(max(abs(guiparams.gp_vmt.V.vSmooth(bi,et)))));
0901         case 'secondary_zsd'
0902             guiparams.reference_velocity = ceil(max(max(abs(guiparams.gp_vmt.V.vsSmooth(bi,et)))));
0903         case 'secondary_roz'
0904             guiparams.reference_velocity = ceil(max(max(abs(guiparams.gp_vmt.V.Roz.usSmooth(bi,et)))));
0905         case 'secondary_roz_y'
0906             guiparams.reference_velocity = ceil(max(max(abs(guiparams.gp_vmt.V.Roz.usySmooth(bi,et)))));
0907         case 'primary_roz_y'
0908             guiparams.reference_velocity = ceil(max(max(abs(guiparams.gp_vmt.V.Roz.upySmooth(bi,et)))));
0909     end
0910     
0911     guiparams.distance = 0.06*max(guiparams.gp_vmt.V.mcsDist(:));
0912     guiparams.depth    = 0.95*max(guiparams.gp_vmt.V.mcsBed(:));
0913     if guiparams.gp_vmt.english_units
0914         guiparams.reference_velocity = guiparams.reference_velocity*0.03281; % cm/s to ft/s
0915         guiparams.distance           = guiparams.distance*3.281;
0916         guiparams.depth              = guiparams.depth*3.281;
0917     end
0918 end
0919 else
0920     guiparams.min_velocity_mcs   = 0;
0921     guiparams.max_velocity_mcs   = 0;
0922     guiparams.distance           = 0;
0923     guiparams.depth              = 0;
0924     guiparams.reference_velocity = 0; % cm/s to ft/s
0925 end
0926 
0927 guiparams.idx_colormap_mcs              = 1;
0928 
0929 % Colormap choices
0930 idx = 1;
0931 guiparams.colormaps_mcs(idx).string   = 'Jet';
0932 idx = idx + 1;
0933 guiparams.colormaps_mcs(idx).string   = 'HSV';
0934 idx = idx + 1;
0935 guiparams.colormaps_mcs(idx).string   = 'Hot';
0936 idx = idx + 1;
0937 guiparams.colormaps_mcs(idx).string   = 'Cool';
0938 idx = idx + 1;
0939 guiparams.colormaps_mcs(idx).string   = 'Spring';
0940 idx = idx + 1;
0941 guiparams.colormaps_mcs(idx).string   = 'Summer';
0942 idx = idx + 1;
0943 guiparams.colormaps_mcs(idx).string   = 'Autumn';
0944 idx = idx + 1;
0945 guiparams.colormaps_mcs(idx).string   = 'Winter';
0946 idx = idx + 1;
0947 guiparams.colormaps_mcs(idx).string   = 'Gray';
0948 idx = idx + 1;
0949 guiparams.colormaps_mcs(idx).string   = 'Bone';
0950 idx = idx + 1;
0951 guiparams.colormaps_mcs(idx).string   = 'Copper';
0952 idx = idx + 1;
0953 guiparams.colormaps_mcs(idx).string   = 'Pink';
0954 idx = idx + 1;
0955 guiparams.colormaps_mcs(idx).string   = 'Browse for more (cpt)...';
0956 guiparams.colormap_mcs = ...
0957     guiparams.colormaps_mcs(guiparams.idx_colormap_mcs).string;
0958 guiparams.cpt_mcs                      = [];
0959 
0960 % Set the units
0961 switch guiparams.gp_vmt.contour
0962     case 'backscatter'
0963         guiparams.min_velocity_mcs_units   = 'dB';
0964         guiparams.max_velocity_mcs_units   = 'dB';
0965         if ~guiparams.gp_vmt.english_units
0966             guiparams.min_velocity_planview_units   = 'cm/s';
0967             guiparams.max_velocity_planview_units   = 'cm/s';
0968             %guiparams.min_velocity_mcs_units        = 'cm/s';
0969             %guiparams.max_velocity_mcs_units        = 'cm/s';
0970             guiparams.reference_velocity_units      = 'cm/s';
0971             guiparams.distance_units                = 'm';
0972             guiparams.depth_units                   = 'm';
0973         else
0974             guiparams.min_velocity_planview_units   = 'ft/s';
0975             guiparams.max_velocity_planview_units   = 'ft/s';
0976             %guiparams.min_velocity_mcs_units        = 'ft/s';
0977             %guiparams.max_velocity_mcs_units        = 'ft/s';
0978             guiparams.reference_velocity_units      = 'ft/s';
0979             guiparams.distance_units                = 'ft';
0980             guiparams.depth_units                   = 'ft';
0981         end
0982     case 'flowangle'
0983         guiparams.min_velocity_mcs_units   = 'deg';
0984         guiparams.max_velocity_mcs_units   = 'deg';
0985         if ~guiparams.gp_vmt.english_units
0986             guiparams.min_velocity_planview_units   = 'cm/s';
0987             guiparams.max_velocity_planview_units   = 'cm/s';
0988             %guiparams.min_velocity_mcs_units        = 'cm/s';
0989             %guiparams.max_velocity_mcs_units        = 'cm/s';
0990             guiparams.reference_velocity_units      = 'cm/s';
0991             guiparams.distance_units                = 'm';
0992             guiparams.depth_units                   = 'm';
0993         else
0994             guiparams.min_velocity_planview_units   = 'ft/s';
0995             guiparams.max_velocity_planview_units   = 'ft/s';
0996             %guiparams.min_velocity_mcs_units        = 'ft/s';
0997             %guiparams.max_velocity_mcs_units        = 'ft/s';
0998             guiparams.reference_velocity_units      = 'ft/s';
0999             guiparams.distance_units                = 'ft';
1000             guiparams.depth_units                   = 'ft';
1001         end
1002     otherwise
1003         if ~guiparams.gp_vmt.english_units
1004             guiparams.min_velocity_planview_units   = 'cm/s';
1005             guiparams.max_velocity_planview_units   = 'cm/s';
1006             
1007             guiparams.min_velocity_mcs_units        = 'cm/s';
1008             guiparams.max_velocity_mcs_units        = 'cm/s';
1009             guiparams.reference_velocity_units      = 'cm/s';
1010             guiparams.distance_units                = 'm';
1011             guiparams.depth_units                   = 'm';
1012         else
1013             guiparams.min_velocity_planview_units   = 'ft/s';
1014             guiparams.max_velocity_planview_units   = 'ft/s';
1015             
1016             guiparams.min_velocity_mcs_units        = 'ft/s';
1017             guiparams.max_velocity_mcs_units        = 'ft/s';
1018             guiparams.reference_velocity_units      = 'ft/s';
1019             guiparams.distance_units                = 'ft';
1020             guiparams.depth_units                   = 'ft';
1021             
1022             guiparams.min_velocity_planview = guiparams.min_velocity_planview*0.03281;
1023             guiparams.max_velocity_planview = guiparams.max_velocity_planview*0.03281;
1024             guiparams.min_velocity_mcs      = guiparams.min_velocity_mcs*0.03281;
1025             guiparams.max_velocity_mcs      = guiparams.max_velocity_mcs*0.03281;
1026         end
1027 end
1028 % [EOF] createGUIparams
1029 
1030 % --------------------------------------------------------------------
1031 function set_enable(handles,enable_state)
1032 
1033 guiparams = getappdata(handles.figure1,'guiparams');
1034 
1035 switch enable_state
1036     case 'init'
1037         % Plan View Map Panel
1038         set([handles.UseDataLimitsPlanview
1039             handles.ColormapPlanview],'Enable', 'on');
1040         set([handles.MinVelocityPlanview
1041             handles.MinVelocityPlanviewUnits
1042             handles.MaxVelocityPlanview
1043             handles.MaxVelocityPlanviewUnits], 'Enable', 'off');
1044         
1045         % Mean Cross Section Contours
1046         set([handles.UseDataLimitsMCS
1047             handles.UseDefaults
1048             handles.ColormapMCS],'Enable', 'on');
1049         set([handles.MinVelocityMCS
1050             handles.MinVelocityMCSUnits
1051             handles.MaxVelocityMCS
1052             handles.MaxVelocityMCSUnits
1053             handles.ReferenceVelocity
1054             handles.ReferenceVelocityUnits
1055             handles.Distance
1056             handles.DistanceUnits
1057             handles.Depth
1058             handles.DepthUnits], 'Enable', 'off');
1059     case 'initmultiple'
1060         % Plan View Map Panel
1061         set([handles.UseDataLimitsPlanview
1062             handles.ColormapPlanview],'Enable', 'on');
1063         set([handles.MinVelocityPlanview
1064             handles.MinVelocityPlanviewUnits
1065             handles.MaxVelocityPlanview
1066             handles.MaxVelocityPlanviewUnits], 'Enable', 'off');
1067         
1068         % Mean Cross Section Contours
1069         set([handles.UseDataLimitsMCS
1070             handles.UseDefaults
1071             handles.ColormapMCS],'Enable', 'off');
1072         set([handles.MinVelocityMCS
1073             handles.MinVelocityMCSUnits
1074             handles.MaxVelocityMCS
1075             handles.MaxVelocityMCSUnits
1076             handles.ReferenceVelocity
1077             handles.ReferenceVelocityUnits
1078             handles.Distance
1079             handles.DistanceUnits
1080             handles.Depth
1081             handles.DepthUnits], 'Enable', 'off');
1082     case 'setplanviewon'
1083         % Plan View Map Panel
1084         set([handles.UseDataLimitsPlanview
1085             handles.ColormapPlanview],'Enable', 'on');
1086         set([handles.MinVelocityPlanview
1087             handles.MinVelocityPlanviewUnits
1088             handles.MaxVelocityPlanview
1089             handles.MaxVelocityPlanviewUnits], 'Enable', 'on');
1090     case 'setplanviewoff'
1091         % Plan View Map Panel
1092         set([handles.UseDataLimitsPlanview
1093             handles.ColormapPlanview],'Enable', 'on');
1094         set([handles.MinVelocityPlanview
1095             handles.MinVelocityPlanviewUnits
1096             handles.MaxVelocityPlanview
1097             handles.MaxVelocityPlanviewUnits], 'Enable', 'off');
1098     case 'setmcson'
1099         % Mean Cross Section Contours
1100         set([handles.UseDataLimitsMCS
1101             handles.ColormapMCS],'Enable', 'on');
1102         set([handles.MinVelocityMCS
1103             handles.MinVelocityMCSUnits
1104             handles.MaxVelocityMCS
1105             handles.MaxVelocityMCSUnits
1106             ], 'Enable', 'on');
1107     case 'setmcsoff'
1108         % Mean Cross Section Contours
1109         set([handles.UseDataLimitsMCS
1110             handles.ColormapMCS],'Enable', 'on');
1111         set([handles.MinVelocityMCS
1112             handles.MinVelocityMCSUnits
1113             handles.MaxVelocityMCS
1114             handles.MaxVelocityMCSUnits
1115             ], 'Enable', 'off');
1116     case 'setrefon'
1117         set([handles.ReferenceVelocity
1118             handles.ReferenceVelocityUnits
1119             handles.Distance
1120             handles.DistanceUnits
1121             handles.Depth
1122             handles.DepthUnits], 'Enable', 'on');
1123     case 'setrefoff'
1124         set([handles.ReferenceVelocity
1125             handles.ReferenceVelocityUnits
1126             handles.Distance
1127             handles.DistanceUnits
1128             handles.Depth
1129             handles.DepthUnits], 'Enable', 'off');
1130     otherwise
1131 end
1132 % [EOF] set_enable
1133 
1134 % --------------------------------------------------------------------
1135 function UpdatePlotStyle(hObject, eventdata, handles)
1136 % Get the Application Data:
1137 % -------------------------
1138 guiparams = getappdata(handles.figure1,'guiparams');
1139 
1140 % Modify the existing figures
1141 % ---------------------------
1142 % Find what plots exist already
1143 hf = findobj('type','figure');
1144 valid_names = {'Plan View Map'; 'Mean Cross Section Contour'};
1145 
1146 if guiparams.gp_vmt.presentation
1147     % Defaults for Presentation Stlye Figure
1148     BkgdColor   = 'black';
1149     AxColor     = 'white';
1150     FigColor    = 'black'; % [0.3 0.3 0.3]
1151     FntSize     = 14;
1152 else
1153     % Defaults for Print Stlye Figure
1154     BkgdColor   = 'white';
1155     AxColor     = 'black';
1156     FigColor    = 'white'; % [0.3 0.3 0.3]
1157     FntSize     = 14;
1158 end
1159 % Loop through valid figures and adjust
1160 % -------------------------------------
1161 if ~isempty(hf) &&  any(ishandle(hf))
1162     
1163     for i = 1:length(valid_names)
1164         switch valid_names{i}
1165             case 'Plan View Map'
1166                 % Focus the figure
1167                 hff = findobj('name','Plan View Map');
1168                 if ~isempty(hff) &&  ishandle(hff)
1169                     figure(hff)
1170                     
1171                     % Make the changes to figure
1172                     set(gcf,'Color',BkgdColor);
1173                     set(gca,'FontSize',FntSize)
1174                     set(get(gca,'Title'),'FontSize',FntSize)
1175                     set(gca,'Color',FigColor)
1176                     set(gca,'XColor',AxColor)
1177                     set(gca,'YColor',AxColor)
1178                     set(gca,'ZColor',AxColor)
1179                     set(findobj(gcf,'tag','Colorbar'),'FontSize',FntSize,'XColor',AxColor,'YColor',AxColor);
1180                     set(get(gca,'Title'),'FontSize',FntSize,'Color',AxColor)
1181                     set(get(gca,'xLabel'),'FontSize',FntSize,'Color',AxColor)
1182                     set(get(gca,'yLabel'),'FontSize',FntSize,'Color',AxColor)
1183                 end
1184             case 'Mean Cross Section Contour'
1185                 % Focus the figure
1186                 hff = findobj('name','Mean Cross Section Contour');
1187                 if ~isempty(hff) &&  ishandle(hff)
1188                     figure(hff)
1189                     
1190                     % Make the changes to figure
1191                     set(gcf,'Color',BkgdColor);
1192                     set(gca,'FontSize',FntSize)
1193                     set(get(gca,'Title'),'FontSize',FntSize)
1194                     set(gca,'Color',[0.3 0.3 0.3]) %FigColor)
1195                     set(gca,'XColor',AxColor)
1196                     set(gca,'YColor',AxColor)
1197                     set(gca,'ZColor',AxColor)
1198                     set(findobj(gcf,'tag','Colorbar'),'FontSize',FntSize,'XColor',AxColor,'YColor',AxColor);
1199                     set(get(gca,'Title'),'FontSize',FntSize,'Color',AxColor)
1200                     set(get(gca,'xLabel'),'FontSize',FntSize,'Color',AxColor)
1201                     set(get(gca,'yLabel'),'FontSize',FntSize,'Color',AxColor)
1202                     set(findobj(gca,'tag','PlotBedElevation')   ,'color'    ,AxColor)
1203                     set(findobj(gca,'tag','ReferenceVectorText'),'color'    ,AxColor)
1204                 end
1205             otherwise
1206         end
1207     end
1208     
1209     
1210 end
1211 
1212 % [EOF] UpdatePlotStyle
1213 % --------------------------------------------------------------------
1214 
1215 % --------------------------------------------------------------------
1216 function load_prefs(hfigure)
1217 % Load the GUI preferences.  Also, initialize preferences if they don't
1218 % already exist.
1219 
1220 % Preferences:
1221 % 'cptplanview'     Path and filenames of current graphic (cpt) files for planview
1222 % 'cptmcs'          Path and filenames of current graphic (cpt) files for MCS
1223 % 'shoreline;
1224 % 'aerial'
1225 
1226 if ispref('VMT','cptplanview')
1227     cptplanview = getpref('VMT','cptplanview');
1228     if exist(cptplanview.path,'dir')
1229         guiprefs.cpt_path = cptplanview.path;
1230     else
1231         guiprefs.cpt_path = pwd;
1232     end
1233     
1234     if exist(fullfile(cptplanview.path,cptplanview.file),'file')
1235         guiprefs.cpt_file = cptplanview.file;
1236     else
1237         guiprefs.cpt_file = [];
1238     end
1239     
1240 else % Initialize graphics
1241     guiprefs.cpt_path = pwd;
1242     guiprefs.cpt_file = [];
1243     
1244     cptplanview.path = pwd;
1245     cptplanview.file = [];
1246     setpref('VMT','cptplanview',cptplanview)
1247 end
1248 
1249 if ispref('VMT','cptmcs')
1250     cptmcs = getpref('VMT','cptmcs');
1251     if exist(cptmcs.path,'dir')
1252         guiprefs.cpt_path = cptmcs.path;
1253     else
1254         guiprefs.cpt_path = pwd;
1255     end
1256     
1257     if exist(fullfile(cptmcs.path,cptmcs.file),'file')
1258         guiprefs.cpt_file = cptmcs.file;
1259     else
1260         guiprefs.cpt_file = [];
1261     end
1262     
1263 else % Initialize graphics
1264     guiprefs.cpt_path = pwd;
1265     guiprefs.cpt_file = [];
1266     
1267     cptmcs.path = pwd;
1268     cptmcs.file = [];
1269     setpref('VMT','cptplanview',cptplanview)
1270 end
1271 if ispref('VMT','shoreline')
1272     shoreline = getpref('VMT','shoreline');
1273     if exist(shoreline.path,'dir')
1274         guiprefs.shoreline_path = shoreline.path;
1275     else
1276         guiprefs.shoreline_path = pwd;
1277     end
1278     
1279     if exist(fullfile(shoreline.path,shoreline.file),'file')
1280         guiprefs.shoreline_file = shoreline.file;
1281     else
1282         guiprefs.shoreline_file = [];
1283     end
1284 end
1285 if ispref('VMT','aerial')
1286     aerial = getpref('VMT','aerial');
1287     if exist(aerial.path,'dir')
1288         guiprefs.aerial_path = aerial.path;
1289     else
1290         guiprefs.aerial_path = pwd;
1291     end
1292     if iscell(aerial.file)
1293         if exist(fullfile(aerial.path,aerial.file{1}),'file')
1294             guiprefs.aerial_file = aerial.file;
1295         else
1296             guiprefs.aerial_file = [];
1297         end
1298     else
1299         if exist(fullfile(aerial.path,aerial.file),'file')
1300             guiprefs.aerial_file = aerial.file;
1301         else
1302             guiprefs.aerial_file = [];
1303         end
1304     end
1305 end
1306 
1307 % Store the prefs
1308 % ---------------
1309 setappdata(hfigure,'guiprefs',guiprefs)
1310 
1311 function store_prefs(hfigure,pref)
1312 % Store preferences in the Application data and in the persistent
1313 % preferences data.
1314 
1315 % Preferences:
1316 % 'cptplanview'     Path and filenames of current graphic (cpt) files for planview
1317 % 'cptmcs'          Path and filenames of current graphic (cpt) files for MCS
1318 
1319 guiprefs = getappdata(hfigure,'guiprefs');
1320 
1321 switch pref
1322     case 'cptplanview'
1323         cptplanview.path = guiprefs.cpt_path;
1324         cptplanview.file = guiprefs.cpt_file;
1325         setpref('VMT','cptplanview',cptplanview)
1326     case 'cptmcs'
1327         cptmcs.path = guiprefs.cpt_path;
1328         cptmcs.file = guiprefs.cpt_file;
1329         setpref('VMT','cptmcs',cptmcs)
1330     otherwise
1331 end
1332 
1333 % [EOF] store_prefs

Generated on Thu 21-Aug-2014 10:40:31 by m2html © 2005