function moordesign(command);
% GUI Program to HELP design and evaluate an oceanographic mooring.
% Use: moordesign
%
% This program will ASSIST in the design and evaluation of oceanographic moorings
% in order to determine 1) wire tensions and anchor requirements, and
% 2) the anticipated depth and horizontal excursions of mooring elements
% forced by currents U(z) [V(z) W(z)], where V and W are optional. 
%
% Time varying currents can be fed to moordyn.m (the engine) by user written MATLAB
% code in order to simulate and even make movies of element positions.
% A preliminary data base of mooring components has been included (c/o C.Darnall of APL UW).
% Advanced users can add and modify the text mooring database (mdcodes.mat), which
% includes the component names, their buoyancy/mass [in kg], their dimensions 
%  (Length/height, Cylinder Width, Sphere Diameter, all in [m]), and Drag
%   Coefficients (0.65-0.95 for spheres, 1.1-1.3 for cylinders).
% The mooring motion/dynamics engine solves the 3-D wire tension problem 
% from the top of the mooring to the bottom (anchor). 
% Simple current profiles can be entered manually, more detailed current 
% profiles should be saved in user mat files: U(z) z [V(z) W(z)].
% Menu lay-out may varying depending on screen resolution/monitor size.
% Additional program help and use is documented in moordyn.txt
%
% No liability is assumed, and users of this code must take full responsability
% for actual mooring design and potential mooring damage and/or loss.
%
% R.Dewey, U.of Victoria, 12/97 

% Please forward improvements/suggestions/bugs to rdewey@uvic.ca
% The latest version of Mooring Dynamics is available at: ftp://canuck.seos.uvic.ca/moordyn
% This code has been tested on Windows 95, NT (4.0), and HP-UNIX, but is not idiot proof.

global U V W z rho
global H B Cd ME moorele
global handle_list

if nargin == 0,
   H=[];B=[];Cd=[];moorele=[];
   U=[];V=[];W=[];z=[];
   command=0;
figure(1);clf;
set(gcf,'Units', 'Normalized','Position',...
   [.05 .625 .3 .3],'Name','Mooring Design','Color',[.2 .6 .9]);
hmain1=uicontrol('Style','Pushbutton','String',...
   'Design New Mooring',...
   'Units','normalized',...
   'Position',[.25 .85 .5 .08],...
   'Callback','modmoor(-1)');
hmain2=uicontrol('Style','Pushbutton','String',...
   'Load Existing Mooring',...
   'Units','normalized',...
   'Position',[.1 .75 .45 .08],...
   'Callback','loadmd');
hmain3=uicontrol('Style','Pushbutton','String',...
   'Save Mooring',...
   'Units','normalized',...
   'Position',[.6 .75 .3 .08],...
   'Callback','savemd');
hmain4=uicontrol('Style','Pushbutton','String',...
   'Add/Modify Mooring Elements',...
   'Units','normalized',...
   'Position',[.2 .65 .6 .08],...
   'Callback','modmoor(0)');
hmain5=uicontrol('Style','Pushbutton','String',...
   'Set/Load Currents',...
   'Units','normalized',...
   'Position',[.1 .55 .35 .08],...
   'Callback','getvelocity');
hmain6=uicontrol('Style','Pushbutton','String',...
   'Display Currents',...
   'Units','normalized',...
   'Position',[.55 .55 .35 .08],...
   'Callback','getvelocity(40)');
hmain7=uicontrol('Style','Pushbutton','String',...
   'Evaluate and Plot Mooring',...
   'Units','normalized',...
   'Position',[.15 .4 .7 .12],...
   'Callback','mdplot',...
   'FontWeight','bold');
hmain8=uicontrol('Style','Pushbutton',...
   'String','Display Positions & Tensions',...
   'Units','normalized',...
   'Position',[.1 .3 .6 .08],...
   'Callback','dismoor(0)');
hmain9=uicontrol('Style','Pushbutton',...
   'String','Print',...
   'Units','normalized',...
   'Position',[.75 .3 .15 .08],...
   'Callback','dismoor(1)');
hmain10=uicontrol('Style','Pushbutton',...
   'String','Add/Examine Elements in Database',...
   'Units','normalized',...
   'Position',[.1 .2 .8 .08],...
   'Callback','addelement');
hmainclr=uicontrol('Style','Pushbutton',...
   'String','Clear All',...
   'Units','normalized',...
   'Position',[.2 .02 .2 .08],...
   'Callback','moordesign(1)');
hmaincls=uicontrol('Style','Pushbutton',...
   'String','Close',...
   'Units','normalized',...
   'Position',[.6 .02 .2 .08],...
   'Callback','close all');
end
if command==1,
   clear all
   close all;
   moordesign;
end
% fini
