function mplaut(filename,compose,cbopt) 

% mplaut(filebase,compose)
%
% Interactive environment for the graphical analysis of p- and q-files
% generated by AUTO97.
% If ``compose'' is zero it read the files p.filebase and q.filebase that are
% in the current directory and show them interactively in a graphic user
% interface (GUI). If ``compose'' is nonzero it composes the files
% p.filebase.bw[fw] and q.filebase.bw[fw] that are in the current directory
% before showing them in the GUI.
%
% The Graphic User Interface (GUI) is composed of two parts, a first one
% (upper) is dedicated to the ``bifurcations diagram'' (data contained
% in p-files). The second one (lower) is dedicated to the ``solutions diagram''
% (data contained in q-files) corresponding to the solutions at the special
% points of the bifurcations diagram.
% The user can choose interactively the variables to show, the dimension of
% the diagram (2D/3D), the solutions shown etc...
% Note that the solution corresponding to a special point in the bifurcation
% diagram can be shown in the solution diagram using the ``Label context menu''
% that appear pressing the right mouse button over the special point or its label.
%
%
% SEE ALSO
%
% READP READQ COMPOSEP COMPOSEQ
%
% For further informations refer to th AUTO97 user manual and to its source code.
%
% (C)Copyright Oscar De Feo 1999
%


% Service variables
markerstr={ '+','o', '*', '.', 'x', 'square', 'diamond', 'v', '^', '>', '<', 'pentagram', 'hexagram', 'none'};
sizestr={'2','4','6','8','10','12','14','16','18','20','22','24'};
stylestr={'-', '--', ':', '-.', 'none'};
distancestr={'1', '2', '3', '5', '6', '7', '8', '9', '10'};
specialtypelongname={'Standard','User','Branch','Hopf','Fold','Flip','Torus','End point','Error'};
specialtype={'std','uz','branch','hopf','fold','flip','ns','ep','mx'};
specialnumb=[   4   -4        1      3      2     7     8    9   -9; ...
                4   -4        6      3      5     7     8    9   -9  ...
            ];
stdopt.facecolor=[...
                  %R G B
                  [0 0 0]; ...
                  [0 1 0]; ...
                  [0 0 1]; ...
                  [0 1 0]; ...
                  [1 0 0]; ...
                  [0 1 1]; ...
                  [1 1 0]; ...
                  [1 0 1]; ...
                  [1 0 0]; ...
                 ];
stdopt.edgecolor=[...
                  %R G B
                  [0 0 0]; ...
                  [0 0 0]; ...
                  [0 0 1]; ...
                  [0 1 0]; ...
                  [1 0 0]; ...
                  [0 1 1]; ...
                  [1 1 0]; ...
                  [1 0 1]; ...
                  [0 0 0]; ...
                 ];

stdopt.size=4*ones(1,9);
stdopt.marker=char('o'*ones(9,1)) ;
stdopt.labeldistance=0.05;
stdopt.labelsize=12;
stdopt.stablecolor=[0 1 0];
stdopt.unstablecolor=[1 0 0];
stdopt.stablestyle='-';
stdopt.unstablestyle='--';

    
if nargin==2,
   % Reading the curves
   if compose==0,
      [bif.curve, pnames]=readp(filename);
      sol.curve=readq(filename);
   elseif compose==1
      [bif.curve, pnames]=composep(filename);
      sol.curve=composeq(filename);
   end;

   % Detecting the stable/unstable branches
   chs=[2*sign(bif.curve(1,2)); diff(sign(bif.curve(:,2)))];
   h=find(chs);
   chs=[chs; -chs(h(end))];
   if bif.curve(1,2)>0
      bif.unstable=[find(chs(1:(end-1))==2) find(chs==-2)-1];
      bif.stable=[find(chs(1:(end-1))==-2) find(chs(2:end)==2)];
   else,
      bif.stable=[find(chs(1:(end-1))==-2) find(chs==2)-1];
      bif.unstable=[find(chs(1:(end-1))==2) find(chs(2:end)==-2)];
   end;
   [bif.stablesegment n]=size(bif.stable);
   [bif.unstablesegment n]=size(bif.unstable);

   % Detecting and classifing the special points
   special.index=find(bif.curve(:,3));
   special.typeall=bif.curve(find(bif.curve(:,3)),3);
   nlab=floor(log10(max(abs(special.typeall(:)))));
   for i=nlab:-1:0,
       special.type(:,i+1)=fix(abs(special.typeall)./(10^i));
       special.type(find(special.type(:,i+1)==9),i+1)=sign(special.typeall(find(special.type(:,i+1)==9),1)).*special.type(find(special.type(:,i+1)==9),i+1);
       special.typeall(find(special.type(:,i+1)==9))=abs(special.typeall(find(special.type(:,i+1)==9),1));
       special.type(find(special.type(:,i+1)==4),i+1)=sign(special.typeall(find(special.type(:,i+1)==4),1)).*special.type(find(special.type(:,i+1)==4),i+1);
       special.typeall=rem(special.typeall,10^i);
   end;
   for typ=1:9,
       special.lab=find(any((special.type==specialnumb(1,typ)*ones(size(special.type)))|(special.type==specialnumb(2,typ)*ones(size(special.type))),2));
       special.pts=special.index(special.lab);
       eval(['bif.' specialtype{typ} '.pts=special.pts;']);
       eval(['sol.' specialtype{typ} '.pts=[special.lab bif.curve(special.pts,4) sign(bif.curve(special.pts,2))];']);
   end;

   % Create the GUI
   ex=1;
   seqnum=[];
   while ex,
     [ex, fig]=figflag(['Matlab plaut ' num2str(seqnum)]);
     if ex,
        if isempty(seqnum),
           seqnum=1;
         else,
           seqnum=seqnum+1;
        end;
     end;
   end;
   [Data,fig]=mainscreen(num2str(seqnum));

   % The standard options
   Data.bif.stablecolor=stdopt.stablecolor;
   Data.bif.stablestyle=stdopt.stablestyle;
   Data.bif.unstablecolor=stdopt.unstablecolor;
   Data.bif.unstablestyle=stdopt.unstablestyle;
   Data.sol.stablecolor=stdopt.stablecolor;
   Data.sol.stablestyle=stdopt.stablestyle;
   Data.sol.unstablecolor=stdopt.unstablecolor;
   Data.sol.unstablestyle=stdopt.unstablestyle;
   for typ=1:9,
       eval(['Data.bif.' specialtype{typ} '.marker=stdopt.marker(typ);']);
       eval(['Data.bif.' specialtype{typ} '.size=stdopt.size(typ);']);
       eval(['Data.bif.' specialtype{typ} '.facecolor=stdopt.facecolor(typ,:);']);
       eval(['Data.bif.' specialtype{typ} '.edgecolor=stdopt.edgecolor(typ,:);']);
       eval(['Data.sol.' specialtype{typ} '.marker=stdopt.marker(typ);']);
       eval(['Data.sol.' specialtype{typ} '.size=stdopt.size(typ);']);
       eval(['Data.sol.' specialtype{typ} '.facecolor=stdopt.facecolor(typ,:);']);
       eval(['Data.sol.' specialtype{typ} '.edgecolor=stdopt.edgecolor(typ,:);']);
   end;
   Data.bif.labeldistance=stdopt.labeldistance;
   Data.bif.labelsize=stdopt.labelsize;
   Data.sol.labeldistance=stdopt.labeldistance;
   Data.sol.labelsize=stdopt.labelsize;

   % Extract the names for the axis
   lett=~isspace(pnames);
   dlett=diff(lett);
   in=find(dlett==1);
   en=find(dlett==-1);
   st=[];
   for i=1:length(in),
       st=strvcat(st,pnames(in(i)+1:en(i)));
   end;
   st=cellstr(st);
   for i=1:4, st(1)=[]; end;
   i=1;
   n=length(st);
   while i<n,
       switch st{i}
         case {'MIN', 'MAX', 'INTEGRAL'},
              st{i}=[st{i}(1:3) ' ' st{i+1}];
              st(i+1)=[];
              n=n-1;
       end;
       i=i+1;
   end;

   % Assign the name of the axis to the popup menu for bifurcation
   set(Data.bif.x_axis,'String',st,'value',1);
   set(Data.bif.y_axis,'String',st,'value',2);
   set(Data.bif.z_axis,'String',st,'value',3);

   % Assign the name of the axis to the popup menu for solutions
   dim=size(sol.curve);
   st=[ones(dim(2),1)*'U(' num2str([0:dim(2)-1]') ones(dim(2),1)*')'];
   set(Data.sol.x_axis,'String',st,'value',1);
   set(Data.sol.y_axis,'String',st,'value',2);
   set(Data.sol.z_axis,'String',st,'value',3);

   % All the labels active
   set(Data.sol.solutionslist,'string',mat2str(bif.curve(find(bif.curve(:,3)),4)'));

   % Save all the handles in the GUI
   Data.sol.curve=sol.curve;
   Data.bif.curve=bif.curve;
   Data.bif.stable=bif.stable;
   Data.bif.unstable=bif.unstable;
   Data.bif.stablesegment=bif.stablesegment;
   Data.bif.unstablesegment=bif.unstablesegment;
   for typ=1:9,
       eval(['Data.bif.' specialtype{typ} '.pts=bif.' specialtype{typ} '.pts;']);
       eval(['Data.sol.' specialtype{typ} '.pts=sol.' specialtype{typ} '.pts;']);
   end;
   set(fig,'UserData',Data);

   % First draw
   mplaut(num2str(seqnum),[],'dim_bif');
   mplaut(num2str(seqnum),[],'axis_auto_bif');
   mplaut(num2str(seqnum),[],'dim_sol');
   mplaut(num2str(seqnum),[],'axis_auto_sol');

   % END
   return;

elseif nargin==3,
   % Find the fig handle of the GUI
   [ex, fig]=figflag(['Matlab plaut ' filename]);
   if ~ex,
      error(['The window ''Matlab plaut ' filename  ''' does not exist anymore.']);
   end;
   Data=get(fig,'UserData');

   switch cbopt
     case 'dim_bif',
          if get(Data.bif.dim,'value')==1,
             % GUI of the bifurcation part in 2D mode
             set(Data.bif.z_axis,'visible','off');
             set(Data.bif.z_label,'visible','off');
             set(Data.bif.az,'visible','off');
             set(Data.bif.el,'visible','off');
             set(Data.bif.z_label_text,'visible','off');
             set(Data.bif.az_label_text,'visible','off');
             set(Data.bif.el_label_text,'visible','off');
             set(Data.bif.ax,'view',[0 90]);
          elseif get(Data.bif.dim,'value')==2,
             % GUI of the bifurcation part in 3D mode
             set(Data.bif.z_axis,'visible','on');
             set(Data.bif.z_label,'visible','on');
             set(Data.bif.az,'visible','on','value',-37.5);
             set(Data.bif.el,'visible','on','value',30);
             set(Data.bif.z_label_text,'visible','on');
             set(Data.bif.az_label_text,'visible','on');
             set(Data.bif.el_label_text,'visible','on');
             set(Data.bif.ax,'view',[-37.5 30]);
          end;
          % When switching put always in auto axis mode
          set(Data.bif.auto_axis,'value',1);
          mplaut(filename,compose,'axis_auto_bif');
          % Redraw the bifurcation part
          mplaut(filename,compose,'draw_bif');
   
     case 'grid_bif',
          % GRID ON/OFF on the bifurcation diagram
          if get(Data.bif.grid,'value')==0,
             set(Data.bif.ax,'XGrid', 'off');
             set(Data.bif.ax,'YGrid', 'off');
             set(Data.bif.ax,'ZGrid', 'off');
          elseif get(Data.bif.grid,'value')==1,
             set(Data.bif.ax,'XGrid', 'on');
             set(Data.bif.ax,'YGrid', 'on');
             set(Data.bif.ax,'ZGrid', 'on');
          end;
   
     case 'axis_auto_bif',
          % AUTO AXIS ON/OFF on the bifurcation diagram
          if get(Data.bif.auto_axis,'value')==0,
             set(Data.bif.ax,'XLimMode','manual');
             set(Data.bif.ax,'YLimMode','manual');
             set(Data.bif.ax,'ZLimMode','manual');
   
             % Visible axis_range field
             if get(Data.bif.dim,'value')==1,
                ax=[get(Data.bif.ax,'XLim') get(Data.bif.ax,'YLim')];
             elseif get(Data.bif.dim,'value')==2,
                ax=[get(Data.bif.ax,'XLim') get(Data.bif.ax,'YLim') get(Data.bif.ax,'ZLim')];
             end;
             set(Data.bif.axis_range,'visible','on','string',mat2str(ax));
             set(Data.bif.axis_label_text,'visible','on');
                    
          elseif get(Data.bif.auto_axis,'value')==1,
             set(Data.bif.ax,'XLimMode','auto');
             set(Data.bif.ax,'YLimMode','auto');
             set(Data.bif.ax,'ZLimMode','auto');
   
             % Invisible axis_range field
             set(Data.bif.axis_range,'visible','off');
             set(Data.bif.axis_label_text,'visible','off');
          end;
   
     case 'axis_range_bif',
          % Error control
          ax=str2num(get(Data.bif.axis_range,'string'));
          if (get(Data.bif.dim,'value')==1)&(~all(size(ax)==[1 4])|(ax(1)>=ax(2))|(ax(3)>=ax(4))),
             errordlg({'The axis ranges must be a 1x4 matrix', 'with the elemnts in ascending order', 'two by two.'},'Axis error');
             return;
          elseif (get(Data.bif.dim,'value')==2)&(~all(size(ax)==[1 6])|(ax(1)>=ax(2))|(ax(3)>=ax(4))|(ax(5)>=ax(6))),
             errordlg({'The axis ranges must be a 1x6 matrix', 'with the elemnts in ascending order', 'two by two.'},'Axis error');
             return;
          end;
          % Set the axis ranges
          set(Data.bif.ax,'XLim',ax(1:2));
          set(Data.bif.ax,'YLim',ax(3:4));
          if get(Data.bif.dim,'value')==2,
             set(Data.bif.ax,'ZLim',ax(5:6));
          end;
   
     case 'azel_bif',
          set(Data.bif.ax,'view',[get(Data.bif.az,'value') get(Data.bif.el,'value')]);
   
     case 'draw_bif',
          % Clearing the axis
          delete(findobj(get(Data.bif.ax,'Children'),'flat','HandleVisibility','on'))
   
          % Stable and unstable manifolds colors
          stbclr=Data.bif.stablecolor;
          stbsty=Data.bif.stablestyle;
          if get(Data.bif.stability,'value')==0,
             ustbclr=Data.bif.stablecolor;
             ustbsty=Data.bif.stablestyle;
          elseif get(Data.bif.stability,'value')==1,
             ustbclr=Data.bif.unstablecolor;
             ustbsty=Data.bif.unstablestyle;
          end;
   
          if get(Data.bif.dim,'value')==1, % 2D
             c1=get(Data.bif.x_axis,'value')+4;
             c2=get(Data.bif.y_axis,'value')+4;
             % The Curve
             for i=1:Data.bif.stablesegment,
                 line(Data.bif.curve(Data.bif.stable(i,1):Data.bif.stable(i,2),c1),Data.bif.curve(Data.bif.stable(i,1):Data.bif.stable(i,2),c2),'color',stbclr,'linestyle',stbsty,'parent',Data.bif.ax);
             end
             for i=1:Data.bif.unstablesegment,
                  line(Data.bif.curve(Data.bif.unstable(i,1):Data.bif.unstable(i,2),c1),Data.bif.curve(Data.bif.unstable(i,1):Data.bif.unstable(i,2),c2),'color',ustbclr,'linestyle',ustbsty,'parent',Data.bif.ax);
             end
             % Determine the normals at the labeled points
             m=-(diff(Data.bif.curve(:,c1))./(diff(Data.bif.curve(:,c2))+1e-308))';
             m=[m(1) m];
             dx=[zeros(1,length(m)); Data.bif.labeldistance*diff(get(Data.bif.ax,'Xlim'))./sqrt(1+m.^2)];
             dy=[zeros(1,length(m)); m.*dx(2,:)*diff(get(Data.bif.ax,'Ylim'))./diff(get(Data.bif.ax,'Xlim'))];
             dxt=(1+0.65).*dx(2,:);
             dyt=(1+0.65).*dy(2,:);
             % The Special points
             for typ=1:9,
                 eval(['special.pts=Data.bif.' specialtype{typ} '.pts;']);
                 eval(['special.marker=Data.bif.' specialtype{typ} '.marker;']);
                 eval(['special.size=Data.bif.' specialtype{typ} '.size;']);
                 eval(['special.facecolor=Data.bif.' specialtype{typ} '.facecolor;']);
                 eval(['special.edgecolor=Data.bif.' specialtype{typ} '.edgecolor;']);
                 for i=1:length(special.pts),
                     line(Data.bif.curve(special.pts(i),c1),Data.bif.curve(special.pts(i),c2),'UserData',Data.bif.curve(special.pts(i),4),'linestyle','none','marker',special.marker,'MarkerSize',special.size,'MarkerFaceColor',special.facecolor,'MarkerEdgeColor',special.edgecolor,'UIContextMenu',Data.bif.labelcontextmenu,'UIContextMenu',Data.bif.labelcontextmenu,'parent',Data.bif.ax);
                     % Lables printing
                     if get(Data.bif.labels,'value')==1,
                        line((Data.bif.curve(special.pts(i),c1)*ones(2,1))+dx(:,special.pts(i)),(Data.bif.curve(special.pts(i),c2)*ones(2,1))+dy(:,special.pts(i)),'linestyle','-','Color',special.edgecolor,'parent',Data.bif.ax);
                        text(Data.bif.curve(special.pts(i),c1)+dxt(1,special.pts(i)),Data.bif.curve(special.pts(i),c2)+dyt(1,special.pts(i)),num2str(Data.bif.curve(special.pts(i),4)),'UserData',Data.bif.curve(special.pts(i),4),'HorizontalAlignment','center','VerticalAlignment','middle','FontSize',Data.bif.labelsize,'UIContextMenu',Data.bif.labelcontextmenu,'parent',Data.bif.ax);
                     end;
                 end;
             end;
             % The labels
             set(get(Data.bif.ax,'XLabel'),'string',get(Data.bif.x_label,'String'),'fontsize',get(Data.bif.ax,'fontsize'),'fontname',get(Data.bif.ax,'fontname'),'fontweight',get(Data.bif.ax,'fontweight'),'fontangle',get(Data.bif.ax,'fontangle'));
             set(get(Data.bif.ax,'YLabel'),'string',get(Data.bif.y_label,'String'),'fontsize',get(Data.bif.ax,'fontsize'),'fontname',get(Data.bif.ax,'fontname'),'fontweight',get(Data.bif.ax,'fontweight'),'fontangle',get(Data.bif.ax,'fontangle'));
             set(get(Data.bif.ax,'ZLabel'),'visible','off');
          elseif get(Data.bif.dim,'value')==2, % 3D
             c1=get(Data.bif.x_axis,'value')+4;
             c2=get(Data.bif.y_axis,'value')+4;
             c3=get(Data.bif.z_axis,'value')+4;
             % The Curve
             for i=1:Data.bif.stablesegment,
                 line(Data.bif.curve(Data.bif.stable(i,1):Data.bif.stable(i,2),c1),Data.bif.curve(Data.bif.stable(i,1):Data.bif.stable(i,2),c2),Data.bif.curve(Data.bif.stable(i,1):Data.bif.stable(i,2),c3),'color',stbclr,'linestyle',stbsty,'parent',Data.bif.ax);
             end
             for i=1:Data.bif.unstablesegment,
                  line(Data.bif.curve(Data.bif.unstable(i,1):Data.bif.unstable(i,2),c1),Data.bif.curve(Data.bif.unstable(i,1):Data.bif.unstable(i,2),c2),Data.bif.curve(Data.bif.unstable(i,1):Data.bif.unstable(i,2),c3),'color',ustbclr,'linestyle',ustbsty,'parent',Data.bif.ax);
             end
             % Determine the normals at the labeled points
             m1=-(diff(Data.bif.curve(:,c1))./(diff(Data.bif.curve(:,c2))+1e-308))';
             m1=[m1(1) m1];
             m2=-(diff(Data.bif.curve(:,c1))./(diff(Data.bif.curve(:,c3))+1e-308))';
             m2=[m2(1) m2];
             dx=[zeros(1,length(m1)); Data.bif.labeldistance*diff(get(Data.bif.ax,'Xlim'))./sqrt(1+m1.^2+m2.^2)];
             dy=[zeros(1,length(m1)); m1.*dx(2,:)*diff(get(Data.bif.ax,'Ylim'))./diff(get(Data.bif.ax,'Xlim'))];
             dz=[zeros(1,length(m1)); m2.*dx(2,:)*diff(get(Data.bif.ax,'Zlim'))./diff(get(Data.bif.ax,'Xlim'))];
             dxt=(1+0.65).*dx(2,:);
             dyt=(1+0.65).*dy(2,:);
             dzt=(1+0.65).*dz(2,:);
             % The Special points
             for typ=1:9,
                 eval(['special.pts=Data.bif.' specialtype{typ} '.pts;']);
                 eval(['special.marker=Data.bif.' specialtype{typ} '.marker;']);
                 eval(['special.size=Data.bif.' specialtype{typ} '.size;']);
                 eval(['special.facecolor=Data.bif.' specialtype{typ} '.facecolor;']);
                 eval(['special.edgecolor=Data.bif.' specialtype{typ} '.edgecolor;']);
                 for i=1:length(special.pts),
                     line(Data.bif.curve(special.pts(i),c1),Data.bif.curve(special.pts(i),c2),Data.bif.curve(special.pts(i),c3),'UserData',Data.bif.curve(special.pts(i),4),'linestyle','none','marker',special.marker,'MarkerSize',special.size,'MarkerFaceColor',special.facecolor,'MarkerEdgeColor',special.edgecolor,'UIContextMenu',Data.bif.labelcontextmenu,'UIContextMenu',Data.bif.labelcontextmenu,'parent',Data.bif.ax);
                     % Lables printing
                     if get(Data.bif.labels,'value')==1,
                        line((Data.bif.curve(special.pts(i),c1)*ones(2,1))+dx(:,special.pts(i)),(Data.bif.curve(special.pts(i),c2)*ones(2,1))+dy(:,special.pts(i)),(Data.bif.curve(special.pts(i),c3)*ones(2,1))+dz(:,special.pts(i)),'linestyle','-','Color',special.edgecolor,'parent',Data.bif.ax);
                        text(Data.bif.curve(special.pts(i),c1)+dxt(1,special.pts(i)),Data.bif.curve(special.pts(i),c2)+dyt(1,special.pts(i)),Data.bif.curve(special.pts(i),c3)+dzt(1,special.pts(i)),num2str(Data.bif.curve(special.pts(i),4)),'UserData',Data.bif.curve(special.pts(i),4),'HorizontalAlignment','center','VerticalAlignment','middle','FontSize',Data.bif.labelsize,'UIContextMenu',Data.bif.labelcontextmenu,'parent',Data.bif.ax);
                     end;
                 end;
             end;
             % The labels
             set(get(Data.bif.ax,'XLabel'),'string',get(Data.bif.x_label,'String'),'fontsize',get(Data.bif.ax,'fontsize'),'fontname',get(Data.bif.ax,'fontname'),'fontweight',get(Data.bif.ax,'fontweight'),'fontangle',get(Data.bif.ax,'fontangle'));
             set(get(Data.bif.ax,'YLabel'),'string',get(Data.bif.y_label,'String'),'fontsize',get(Data.bif.ax,'fontsize'),'fontname',get(Data.bif.ax,'fontname'),'fontweight',get(Data.bif.ax,'fontweight'),'fontangle',get(Data.bif.ax,'fontangle'));
             set(get(Data.bif.ax,'ZLabel'),'visible','on','string',get(Data.bif.z_label,'String'),'fontsize',get(Data.bif.ax,'fontsize'),'fontname',get(Data.bif.ax,'fontname'),'fontweight',get(Data.bif.ax,'fontweight'),'fontangle',get(Data.bif.ax,'fontangle'));
          end;
   
     case 'save_bif',
          set(copyobj(Data.bif.ax,figure),'Position',[0.1300    0.1100    0.7750    0.8150],'view',get(Data.bif.ax,'view'));

     case 'option_bif',
          % Find the fig handle of the GUI
          [ex, figopt]=figflag(['Graphic options for bifurcations diagram ' filename]);
          if ~ex,
             optionscreen(filename,'bif');
          end;

     case 'option_apply_bif',
          % Find the fig handle of the GUI
          [ex, figopt]=figflag(['Graphic options for bifurcations diagram ' filename]);
          if ~ex,
             error(['The window ''Graphic options for bifurcations diagram ' filename ''' does not exist anymore.']);
          end;
          OptionData=get(figopt,'UserData');

          % Set the current option
          Data.bif.stablecolor=get(OptionData.stablecolor,'Backgroundcolor');
          Data.bif.stablestyle=stylestr{get(OptionData.stablestyle,'value')};
          Data.bif.unstablecolor=get(OptionData.unstablecolor,'Backgroundcolor');
          Data.bif.unstablestyle=stylestr{get(OptionData.unstablestyle,'value')};
          for typ=1:9,
              eval(['Data.bif.' specialtype{typ} '.marker=markerstr{get(OptionData.spcpts.marker(typ),''value'')};']);
              eval(['Data.bif.' specialtype{typ} '.size=str2num(sizestr{get(OptionData.spcpts.size(typ),''value'')});']);
              eval(['Data.bif.' specialtype{typ} '.facecolor=get(OptionData.spcpts.facecolor(typ),''Backgroundcolor'');']);
              eval(['Data.bif.' specialtype{typ} '.edgecolor=get(OptionData.spcpts.edgecolor(typ),''Backgroundcolor'');']);
          end;
          Data.bif.labeldistance=str2num(distancestr{get(OptionData.labeldistance,'value')})/100;
          Data.bif.labelsize=str2num(sizestr{get(OptionData.labelsize,'value')});
          set(fig,'UserData',Data);
          mplaut(filename,compose,'draw_bif');
          figure(figopt);

     case 'dim_sol',
          if get(Data.sol.dim,'value')==1,
             % GUI of the solutions part in 2D mode
             set(Data.sol.z_axis,'visible','off');
             set(Data.sol.z_label,'visible','off');
             set(Data.sol.az,'visible','off');
             set(Data.sol.el,'visible','off');
             set(Data.sol.z_label_text,'visible','off');
             set(Data.sol.az_label_text,'visible','off');
             set(Data.sol.el_label_text,'visible','off');
             set(Data.sol.ax,'view',[0 90]);
          elseif get(Data.sol.dim,'value')==2,
             % GUI of the solutions part in 3D mode
             set(Data.sol.z_axis,'visible','on');
             set(Data.sol.z_label,'visible','on');
             set(Data.sol.az,'visible','on','value',-37.5);
             set(Data.sol.el,'visible','on','value',30);
             set(Data.sol.z_label_text,'visible','on');
             set(Data.sol.az_label_text,'visible','on');
             set(Data.sol.el_label_text,'visible','on');
             set(Data.sol.ax,'view',[-37.5 30]);
          end;
          % When switching put always in auto axis mode
          set(Data.sol.auto_axis,'value',1);
          mplaut(filename,compose,'axis_auto_sol');
          % Redraw the solutions part
          mplaut(filename,compose,'draw_sol');
   
     case 'grid_sol',
          % GRID ON/OFF on the solutions diagram
          if get(Data.sol.grid,'value')==0,
             set(Data.sol.ax,'XGrid', 'off');
             set(Data.sol.ax,'YGrid', 'off');
             set(Data.sol.ax,'ZGrid', 'off');
          elseif get(Data.sol.grid,'value')==1,
             set(Data.sol.ax,'XGrid', 'on');
             set(Data.sol.ax,'YGrid', 'on');
             set(Data.sol.ax,'ZGrid', 'on');
          end;
   
     case 'axis_auto_sol',
          % AUTO AXIS ON/OFF on the solution diagram
          if get(Data.sol.auto_axis,'value')==0,
             set(Data.sol.ax,'XLimMode','manual');
             set(Data.sol.ax,'YLimMode','manual');
             set(Data.sol.ax,'ZLimMode','manual');
   
             % Visible axis_range field
             if get(Data.sol.dim,'value')==1,
                ax=[get(Data.sol.ax,'XLim') get(Data.sol.ax,'YLim')];
             elseif get(Data.sol.dim,'value')==2,
                ax=[get(Data.sol.ax,'XLim') get(Data.sol.ax,'YLim') get(Data.sol.ax,'ZLim')];
             end;
             set(Data.sol.axis_range,'visible','on','string',mat2str(ax));
             set(Data.sol.axis_label_text,'visible','on');
                    
          elseif get(Data.sol.auto_axis,'value')==1,
             set(Data.sol.ax,'XLimMode','auto');
             set(Data.sol.ax,'YLimMode','auto');
             set(Data.sol.ax,'ZLimMode','auto');
   
             % Invisible axis_range field
             set(Data.sol.axis_range,'visible','off');
             set(Data.sol.axis_label_text,'visible','off');
          end;
   
     case 'axis_range_sol',
          % Error control
          ax=str2num(get(Data.sol.axis_range,'string'));
          if (get(Data.sol.dim,'value')==1)&(~all(size(ax)==[1 4])|(ax(1)>=ax(2))|(ax(3)>=ax(4))),
             errordlg({'The axis ranges must be a 1x4 matrix', 'with the elemnts in ascending order', 'two by two.'},'Axis error');
             return;
          elseif (get(Data.sol.dim,'value')==2)&(~all(size(ax)==[1 6])|(ax(1)>=ax(2))|(ax(3)>=ax(4))|(ax(5)>=ax(6))),
             errordlg({'The axis ranges must be a 1x6 matrix', 'with the elemnts in ascending order', 'two by two.'},'Axis error');
             return;
          end;
          % Set the axis ranges
          set(Data.sol.ax,'XLim',ax(1:2));
          set(Data.sol.ax,'YLim',ax(3:4));
          if get(Data.sol.dim,'value')==2,
             set(Data.sol.ax,'ZLim',ax(5:6));
          end;
   
     case 'azel_sol',
          set(Data.sol.ax,'view',[get(Data.sol.az,'value') get(Data.sol.el,'value')]);
   
     case 'draw_sol',
          % Clearing the axis
          delete(findobj(get(Data.sol.ax,'Children'),'flat','HandleVisibility','on'))

          % The solution list
          sollist=str2num(get(Data.sol.solutionslist,'string'));
          nlab=length(sollist);
          if nlab==0,
             return;
          end;

          % Stable and unstable manifolds colors
          stbclr=Data.sol.stablecolor;
          stbsty=Data.sol.stablestyle;
          if get(Data.sol.stability,'value')==0,
             ustbclr=Data.sol.stablecolor;
             ustbsty=Data.sol.stablestyle;
          elseif get(Data.sol.stability,'value')==1,
             ustbclr=Data.sol.unstablecolor;
             ustbsty=Data.sol.unstablestyle;
          end;
   
          if get(Data.sol.dim,'value')==1, % 2D
             c1=get(Data.sol.x_axis,'value');
             c2=get(Data.sol.y_axis,'value');
             % The Solutions are only at special points
             for typ=1:9,
                 eval(['special.pts=Data.sol.' specialtype{typ} '.pts;']);
                 eval(['special.marker=Data.sol.' specialtype{typ} '.marker;']);
                 eval(['special.size=Data.sol.' specialtype{typ} '.size;']);
                 eval(['special.facecolor=Data.sol.' specialtype{typ} '.facecolor;']);
                 eval(['special.edgecolor=Data.sol.' specialtype{typ} '.edgecolor;']);
                 % Detect if the current solutions are in the solution list
                 labmemb=find(ismember(special.pts(:,2),sollist))';
                 for sol=labmemb,
                     % Decide if stable or unstable
                     if special.pts(sol,3)>0,
                       clr=ustbclr;
                       sty=ustbsty;
                     else
                       clr=stbclr;
                       sty=stbsty;
                     end;
                     % Curve plotting
                     line(Data.sol.curve(:,c1,special.pts(sol,1)),Data.sol.curve(:,c2,special.pts(sol,1)),'color',clr,'linestyle',sty,'marker',special.marker,'MarkerSize',special.size,'MarkerFaceColor',special.facecolor,'MarkerEdgeColor',special.edgecolor,'parent',Data.sol.ax);
                     % Lables printing
                     if get(Data.sol.labels,'value')==1,
                        % Random point for the label
                        sz=size(Data.sol.curve);
                        i=ceil(rand(1,1)*(sz(1)-2))+1;
                        p=polyfit(Data.sol.curve([i-1 i i+1],c1,special.pts(sol,1)),Data.sol.curve([i-1 i i+1],c2,special.pts(sol,1)),2);
                        m=-1/(2*p(1)*Data.sol.curve(i,c1,special.pts(sol,1))+p(2));
                        d=sign(p(1));
                        dx=[0; d*Data.sol.labeldistance*diff(get(Data.sol.ax,'Xlim'))/sqrt(1+m^2)];
                        dy=[0; m*dx(2,:)*diff(get(Data.sol.ax,'Ylim'))/diff(get(Data.sol.ax,'Xlim'))];
                        dxt=(1+0.65).*dx(2);
                        dyt=(1+0.65).*dy(2);
                        line(Data.sol.curve(i,c1,special.pts(sol,1))*ones(2,1)+dx,Data.sol.curve(i,c2,special.pts(sol,1))*ones(2,1)+dy,'linestyle','-','Color',special.edgecolor,'parent',Data.sol.ax);
                        text(Data.sol.curve(i,c1,special.pts(sol,1))+dxt,Data.sol.curve(i,c2,special.pts(sol,1))+dyt,num2str(special.pts(sol,2)),'HorizontalAlignment','center','VerticalAlignment','middle','FontSize',Data.sol.labelsize,'parent',Data.sol.ax);
                     end;
                 end;
             end;
             % The labels
             set(get(Data.sol.ax,'XLabel'),'string',get(Data.sol.x_label,'String'),'fontsize',get(Data.sol.ax,'fontsize'),'fontname',get(Data.sol.ax,'fontname'),'fontweight',get(Data.sol.ax,'fontweight'),'fontangle',get(Data.sol.ax,'fontangle'));
             set(get(Data.sol.ax,'YLabel'),'string',get(Data.sol.y_label,'String'),'fontsize',get(Data.sol.ax,'fontsize'),'fontname',get(Data.sol.ax,'fontname'),'fontweight',get(Data.sol.ax,'fontweight'),'fontangle',get(Data.sol.ax,'fontangle'));
             set(get(Data.sol.ax,'ZLabel'),'visible','off');
          elseif get(Data.sol.dim,'value')==2, % 3D
             c1=get(Data.sol.x_axis,'value');
             c2=get(Data.sol.y_axis,'value');
             c3=get(Data.sol.z_axis,'value');
             % The Solutions are only at special points
             for typ=1:9,
                 eval(['special.pts=Data.sol.' specialtype{typ} '.pts;']);
                 eval(['special.marker=Data.sol.' specialtype{typ} '.marker;']);
                 eval(['special.size=Data.sol.' specialtype{typ} '.size;']);
                 eval(['special.facecolor=Data.sol.' specialtype{typ} '.facecolor;']);
                 eval(['special.edgecolor=Data.sol.' specialtype{typ} '.edgecolor;']);
                 % Detect if the current solutions are in the solution list
                 labmemb=find(ismember(special.pts(:,2),sollist))';
                 for sol=labmemb,
                     % Decide if stable or unstable
                     if special.pts(sol,3)>0,
                       clr=ustbclr;
                       sty=ustbsty;
                     else
                       clr=stbclr;
                       sty=stbsty;
                     end;
                     % Curve plotting
                     line(Data.sol.curve(:,c1,special.pts(sol,1)),Data.sol.curve(:,c2,special.pts(sol,1)),Data.sol.curve(:,c3,special.pts(sol,1)),'color',clr,'linestyle',sty,'marker',special.marker,'MarkerSize',special.size,'MarkerFaceColor',special.facecolor,'MarkerEdgeColor',special.edgecolor,'parent',Data.sol.ax);
                     % Lables printing
                     if get(Data.sol.labels,'value')==1,
                        % Random point for the label
                        sz=size(Data.sol.curve);
                        i=ceil(rand(1,1)*(sz(1)-2))+1;
                        p1=polyfit(Data.sol.curve([i-1 i i+1],c1,special.pts(sol,1)),Data.sol.curve([i-1 i i+1],c2,special.pts(sol,1)),2);
                        p2=polyfit(Data.sol.curve([i-1 i i+1],c1,special.pts(sol,1)),Data.sol.curve([i-1 i i+1],c3,special.pts(sol,1)),2);
                        m1=-1/(2*p1(1)*Data.sol.curve(i,c1,special.pts(sol,1))+p1(2));
                        m2=-1/(2*p2(1)*Data.sol.curve(i,c1,special.pts(sol,1))+p2(2));
                        d1=sign(p1(1));
                        d2=sign(p2(1));
                        dx=[0; Data.sol.labeldistance*diff(get(Data.sol.ax,'Xlim'))/sqrt(1+m1^2+m2^2)];
                        dy=[0; d1*m1*dx(2,:)*diff(get(Data.sol.ax,'Ylim'))/diff(get(Data.sol.ax,'Xlim'))];
                        dz=[0; d2*m2*dx(2,:)*diff(get(Data.sol.ax,'Zlim'))/diff(get(Data.sol.ax,'Xlim'))];
                        dxt=(1+0.65).*dx(2);
                        dyt=(1+0.65).*dy(2);
                        dzt=(1+0.65).*dz(2);
                        line(Data.sol.curve(i,c1,special.pts(sol,1))*ones(2,1)+dx,Data.sol.curve(i,c2,special.pts(sol,1))*ones(2,1)+dy,Data.sol.curve(i,c3,special.pts(sol,1))*ones(2,1)+dz,'linestyle','-','Color',special.edgecolor,'parent',Data.sol.ax);
                        text(Data.sol.curve(i,c1,special.pts(sol,1))+dxt,Data.sol.curve(i,c2,special.pts(sol,1))+dyt,Data.sol.curve(i,c3,special.pts(sol,1))+dzt,num2str(special.pts(sol,2)),'HorizontalAlignment','center','VerticalAlignment','middle','FontSize',Data.sol.labelsize,'parent',Data.sol.ax);
                     end;
                 end;
             end;
             % The labels
             set(get(Data.sol.ax,'XLabel'),'string',get(Data.sol.x_label,'String'),'fontsize',get(Data.sol.ax,'fontsize'),'fontname',get(Data.sol.ax,'fontname'),'fontweight',get(Data.sol.ax,'fontweight'),'fontangle',get(Data.sol.ax,'fontangle'));
             set(get(Data.sol.ax,'YLabel'),'string',get(Data.sol.y_label,'String'),'fontsize',get(Data.sol.ax,'fontsize'),'fontname',get(Data.sol.ax,'fontname'),'fontweight',get(Data.sol.ax,'fontweight'),'fontangle',get(Data.sol.ax,'fontangle'));
             set(get(Data.sol.ax,'ZLabel'),'visible','on','string',get(Data.sol.z_label,'String'),'fontsize',get(Data.sol.ax,'fontsize'),'fontname',get(Data.sol.ax,'fontname'),'fontweight',get(Data.sol.ax,'fontweight'),'fontangle',get(Data.sol.ax,'fontangle'));
          end;
   
     case 'label_list_sol',
          % get the label list
          sollist=str2num(get(Data.sol.solutionslist,'string'));
          % Check that the label list is in the right format
          sz=size(sollist);
          if sz(1)>1,
             errordlg('The list of labels must be a row vector.','Label list error');
             return;
          end;
          % Check that all the label required are available
          sollist=unique(sollist);
          lablist=Data.bif.curve(find(Data.bif.curve(:,3)),4);
          notin=setdiff(sollist,lablist);
          if ~isempty(notin),
             errordlg({'The following label does not exist:', mat2str(notin)},'Label list error');
             return;
          end;
          % Clean list of solutions
          set(Data.sol.solutionslist,'string',mat2str(sollist));
          % Redraw the solutions part
          mplaut(filename,compose,'draw_sol');

     case 'save_sol',
          set(copyobj(Data.sol.ax,figure),'Position',[0.1300    0.1100    0.7750    0.8150],'view',get(Data.sol.ax,'view'));

     case 'context_create',
          set(Data.bif.labelcontextmenulabel,'Label',['Label: ' compose]);

     case 'context_show',
          set(Data.sol.solutionslist,'String',[ '[' compose ']']);
          mplaut(filename,compose,'label_list_sol');

     case 'context_add',
          set(Data.sol.solutionslist,'String',num2str([str2num(get(Data.sol.solutionslist,'string')) str2num(compose)]));
          mplaut(filename,compose,'label_list_sol');

     case 'option_sol',
          % Find the fig handle of the GUI
          [ex, figopt]=figflag(['Graphic options for solutions diagram ' filename]);
          if ~ex,
             optionscreen(filename,'sol');
          end;

     case 'option_apply_sol',
          % Find the fig handle of the GUI
          [ex, figopt]=figflag(['Graphic options for solutions diagram ' filename]);
          if ~ex,
             error(['The window ''Graphic options for solutions diagram ' filename ''' does not exist anymore.']);
          end;
          OptionData=get(figopt,'UserData');

          % Set the current option
          Data.sol.stablecolor=get(OptionData.stablecolor,'Backgroundcolor');
          Data.sol.stablestyle=stylestr{get(OptionData.stablestyle,'value')};
          Data.sol.unstablecolor=get(OptionData.unstablecolor,'Backgroundcolor');
          Data.sol.unstablestyle=stylestr{get(OptionData.unstablestyle,'value')};
          for typ=1:9,
              eval(['Data.sol.' specialtype{typ} '.marker=markerstr{get(OptionData.spcpts.marker(typ),''value'')};']);
              eval(['Data.sol.' specialtype{typ} '.size=str2num(sizestr{get(OptionData.spcpts.size(typ),''value'')});']);
              eval(['Data.sol.' specialtype{typ} '.facecolor=get(OptionData.spcpts.facecolor(typ),''Backgroundcolor'');']);
              eval(['Data.sol.' specialtype{typ} '.edgecolor=get(OptionData.spcpts.edgecolor(typ),''Backgroundcolor'');']);
          end;
          Data.sol.labeldistance=str2num(distancestr{get(OptionData.labeldistance,'value')})/100;
          Data.sol.labelsize=str2num(sizestr{get(OptionData.labelsize,'value')});
          set(fig,'UserData',Data);
          mplaut(filename,compose,'draw_sol');
          figure(figopt);

   end

end;

return;


function [Data,fig] = mainscreen(number)

% Local size and variables
oldunit=get(0,'Units');
set(0,'Units','Pixels');
screensize=get(0,'ScreenSize');
screensize=screensize(3:4);
set(0,'Units',oldunit);

fnt=round(0.75*[ 13 16 ]*1024/screensize(2));

clr=[...
     [0 0 0] ;...
     [0.8 0.8 0.8] ;...
     [1 1 1] ;...
     [0.6484473945220109 0.6484473945220109 0.6484473945220109] ;...
     [0.701960784313725 0.701960784313725 0.701960784313725] ;...
    ];

ax=[600 450];

sk=[...
    [20 20] ;... % Windows base
    [60 60] ;... % From the corner to the axis, axis skip
    [ 1 -2] ;... % From buttons to their labels
    [20 20] ;... % Standard Hz and Vt skip
    [ 5  5] ;... % Medium Hz and Vt skip
    [ 0  0] ;... % Small Hz and Vt skip
   ];

button=[
        [100 25] ;...
        [ 90 25] ;...
        [ 90 30] ;...
        [230 25] ;...
       ];

txt=[...
     [230 20] ;...
     [ 50 20] ;...
     [ 70 20] ;...
     [ 90 20] ;...
    ];

dyfig=0.95;
dyratio=(2*sk(2,2)+ax(2)*2+sk(4,2))/1024/dyfig;
dxfig=(sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)+sk(4,1)+sk(4,1))/1280/dyratio;
figpos=[(1-dxfig)/2 (1-dyfig)/2 dxfig  dyfig];

dxframe=sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)+sk(4,1)+sk(4,1);
dyframe=2*sk(2,2)+ax(2)*2+sk(4,2);

ax(:,1)=ax(:,1)./dxframe;
ax(:,2)=ax(:,2)./dyframe;
sk(:,1)=sk(:,1)./dxframe;
sk(:,2)=sk(:,2)./dyframe;
button(:,1)=button(:,1)./dxframe;
button(:,2)=button(:,2)./dyframe;
txt(:,1)=txt(:,1)./dxframe;
txt(:,2)=txt(:,2)./dyframe;


dimstr={'2 Dim','3 Dim'};
% Ex fig pos
% [sk(1,:) sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)+sk(4,1)+sk(4,1)  2*sk(2,2)+ax(2)*2+sk(4,2)]

% The Figure
h0 = figure('Color',clr(2,:), ...
            'Units','normal', ...
            'MenuBar','none', ...
            'Position',figpos, ...
            'Resize','off', ...
            'Name',['Matlab plaut ' number], ...
            'NumberTitle','off', ...
            'Tag',['Matlabplaut' number 'Tag']);

% Frames
uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1) sk(2,2) sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)+sk(4,1) ax(2)], ...
          'Style','frame', ...
          'Tag','FrameSolution');

uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1) sk(2,2)+ax(2)+sk(2,2) sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)+sk(4,1) ax(2)], ...
          'Style','frame', ...
          'Tag','FrameBifurcation');

% Texts
uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(2), ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(5,2)+sk(4,2) txt(1,:)], ...
          'String','Solutions diagram', ...
          'Style','text', ...
          'Tag','TitleSolutions');

uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(2), ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(5,2)+sk(4,2) txt(1,:)], ...
          'String','Bifurcation diagram', ...
          'Style','text', ...
          'Tag','BifurcationSolutions');

uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)-txt(2,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+2*button(1,2)+2*sk(5,2) txt(2,:)], ...
          'String','X:', ...
          'Style','text', ...
          'Tag','XSol');

uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)-txt(2,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+button(1,2)+sk(5,2) txt(2,:)], ...
          'String','Y:', ...
          'Style','text', ...
          'Tag','YSol');

Data.sol.z_label_text = ...
uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)-txt(2,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2) txt(2,:)], ...
          'String','Z:', ...
          'Style','text', ...
          'Tag','ZSol');

uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)-txt(2,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+2*button(1,2)+2*sk(5,2) txt(2,:)], ...
          'String','X:', ...
          'Style','text', ...
          'Tag','XBif');

uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)-txt(2,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+button(1,2)+sk(5,2) txt(2,:)], ...
          'String','Y:', ...
          'Style','text', ...
          'Tag','YBif');

Data.bif.z_label_text = ...
uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)-txt(2,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2) txt(2,:)], ...
          'String','Z:', ...
          'Style','text', ...
          'Tag','ZBif');

uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','center', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-txt(4,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+3*button(1,2)+3*sk(5,2) txt(4,:)], ...
          'String','Axis label', ...
          'Style','text', ...
          'Tag','AxisLabSol');

uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','center', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-txt(4,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+3*button(1,2)+3*sk(5,2) txt(4,:)], ...
          'String','Axis label', ...
          'Style','text', ...
          'Tag','AxisLabBif');

Data.sol.axis_label_text = ...
uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+2*button(4,2)+2*sk(6,2) txt(3,:)], ...
          'String','Axis:', ...
          'Style','text', ...
          'Tag','AxisFieldSol');

Data.sol.az_label_text = ...
uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+button(4,2)+sk(6,2) txt(3,:)], ...
          'String','Azimuth:', ...
          'Style','text', ...
          'Tag','AzimuthSol');

Data.sol.el_label_text = ...
uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2) txt(3,:)], ...
          'String','Elevation:', ...
          'Style','text', ...
          'Tag','ElevationSol');

uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1) sk(2,2)+sk(4,2) txt(3,:)], ...
          'String','Solutions:', ...
          'Style','text', ...
          'Tag','SolutionFieldSol');

Data.bif.axis_label_text = ...
uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+2*button(4,2)+2*sk(6,2) txt(3,:)], ...
          'String','Axis:', ...
          'Style','text', ...
          'Tag','AxisFieldBif');

Data.bif.az_label_text = ...
uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+button(4,2)+sk(6,2) txt(3,:)], ...
          'String','Azimuth:', ...
          'Style','text', ...
          'Tag','AzimuthBif');

Data.bif.el_label_text = ...
uicontrol('Parent',h0, ... 
          'Units','normal', ...
          'BackgroundColor',clr(4,:), ...
          'FontSize',fnt(1), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2) txt(3,:)], ...
          'String','Elevation:', ...
          'Style','text', ...
          'Tag','ElevationBif');


% Pop Down
Data.sol.dim = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''dim_sol'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+3*button(1,2)+3*sk(5,2) button(1,:)], ...
            'String',dimstr, ...
            'Style','popupmenu', ...
            'Tag','SolDimPop', ...
            'Value',2);

Data.sol.x_axis = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_sol'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+2*button(1,2)+2*sk(5,2) button(1,:)], ...
            'String',' ', ...
            'Style','popupmenu', ...
            'Tag','SolXPop', ...
            'Value',1);

Data.sol.y_axis = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_sol'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+button(1,2)+sk(5,2) button(1,:)], ...
            'String',' ', ...
            'Style','popupmenu', ...
            'Tag','SolYPop', ...
            'Value',1);

Data.sol.z_axis = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_sol'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2) button(1,:)], ...
            'String',' ', ...
            'Style','popupmenu', ...
            'Tag','SolZPop', ...
            'Value',1);

Data.bif.dim = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''dim_bif'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+3*button(1,2)+3*sk(5,2) button(1,:)], ...
            'String',dimstr, ...
            'Style','popupmenu', ...
            'Tag','BifDimPop', ...
            'Value',2);

Data.bif.x_axis = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_bif'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+2*button(1,2)+2*sk(5,2) button(1,:)], ...
            'String',' ', ...
            'Style','popupmenu', ...
            'Tag','BifXPop', ...
            'Value',1);

Data.bif.y_axis = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_bif'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+button(1,2)+sk(5,2) button(1,:)], ...
            'String',' ', ...
            'Style','popupmenu', ...
            'Tag','BifYPop', ...
            'Value',1);

Data.bif.z_axis = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_bif'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2) button(1,:)], ...
            'String',' ', ...
            'Style','popupmenu', ...
            'Tag','BifZPop', ...
            'Value',1);

% Check Buttons
Data.sol.labels = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_sol'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+3*button(1,2)+3*sk(6,2) button(1,:)], ...
            'String','Labels', ...
            'Style','checkbox', ...
            'Tag','SolLabels');

Data.sol.stability = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_sol'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+2*button(1,2)+2*sk(6,2) button(1,:)], ...
            'String','Stability', ...
            'Style','checkbox', ...
            'Tag','SolStability');

Data.sol.grid = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''grid_sol'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+button(1,2)+sk(6,2) button(1,:)], ...
            'String','Grid', ...
            'Style','checkbox', ...
            'Tag','SolGrid');

Data.sol.auto_axis = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''axis_auto_sol'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2) button(1,:)], ...
            'Value',1, ...
            'String','Auto axis', ...
            'Style','checkbox', ...
            'Tag','SolAxisAuto');

Data.bif.labels = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_bif'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+3*button(1,2)+3*sk(6,2) button(1,:)], ...
            'String','Labels', ...
            'Style','checkbox', ...
            'Tag','BifLabels');

Data.bif.stability = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_bif'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+2*button(1,2)+2*sk(6,2) button(1,:)], ...
            'String','Stability', ...
            'Style','checkbox', ...
            'Tag','BifStability');

Data.bif.grid = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''grid_bif'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+button(1,2)+sk(6,2) button(1,:)], ...
            'String','Grid', ...
            'Style','checkbox', ...
            'Tag','BifGrid');

Data.bif.auto_axis = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''axis_auto_bif'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2) button(1,:)], ...
            'Value',1, ...
            'String','Auto axis', ...
            'Style','checkbox', ...
            'Tag','BifAxisAuto');

% Push Buttons
Data.sol.options =...
  uicontrol('Parent',h0, ...
            'CallBack',['mplaut(''' number ''',[],''option_sol'');'], ...
            'Units','normal', ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-button(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)-button(3,2) button(3,:)], ...
            'String','Options', ...
            'Tag','SolOptions');

Data.sol.redraw =...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_sol'');'], ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-button(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)-2*button(3,2)-sk(5,2) button(3,:)], ...
            'String','Redraw', ...
            'Tag','SolRedraw');

Data.sol.save =...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''save_sol'');'], ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-button(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)-3*button(3,2)-2*sk(5,2) button(3,:)], ...
            'String','Save', ...
            'Tag','SolRedraw');

Data.bif.options =...
  uicontrol('Parent',h0, ...
            'CallBack',['mplaut(''' number ''',[],''option_bif'');'], ...
            'Units','normal', ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-button(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)-button(3,2) button(3,:)], ...
            'String','Options', ...
            'Tag','BifOptions');

Data.bif.redraw =...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_bif'');'], ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-button(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)-2*button(3,2)-sk(5,2) button(3,:)], ...
            'String','Redraw', ...
            'Tag','BifRedraw');

Data.bif.save =...
  uicontrol('Parent',h0, ...
            'CallBack',['mplaut(''' number ''',[],''save_bif'');'], ...
            'Units','normal', ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-button(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)-3*button(3,2)-2*sk(5,2) button(3,:)], ...
            'String','Save', ...
            'Tag','BifRedraw');

% Sliders
Data.sol.az = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''azel_sol'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Min',-180,...
            'Max', 180,...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+button(4,2)+sk(6,2) button(4,:)], ...
            'Style','slider', ...
            'Tag','SolAz');

Data.sol.el = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''azel_sol'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Min',-90,...
            'Max', 90,...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2) button(4,:)], ...
            'Style','slider', ...
            'Tag','SolEl');

Data.bif.az = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''azel_bif'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Min',-180,...
            'Max', 180,...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+button(4,2)+sk(6,2) button(4,:)], ...
            'Style','slider', ...
            'Tag','BifAz');

Data.bif.el = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''azel_bif'');'], ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Min',-90,...
            'Max', 90,...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2) button(4,:)], ...
            'Style','slider', ...
            'Tag','BifEl');

% Edit fields
Data.sol.x_label = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_sol'');'], ...
            'BackgroundColor',clr(3,:), ...
            'FontSize',fnt(1), ...
            'HorizontalAlignment','left', ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-button(2,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+2*button(1,2)+2*sk(5,2) button(2,:)], ...
            'Style','edit', ...
            'Tag','SolXlabel');

Data.sol.y_label = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_sol'');'], ...
            'BackgroundColor',clr(3,:), ...
            'FontSize',fnt(1), ...
            'HorizontalAlignment','left', ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-button(2,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+button(1,2)+sk(5,2) button(2,:)], ...
            'Style','edit', ...
            'Tag','SolYlabel');

Data.sol.z_label = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_sol'');'], ...
            'BackgroundColor',clr(3,:), ...
            'FontSize',fnt(1), ...
            'HorizontalAlignment','left', ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-button(2,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2) button(2,:)], ...
            'Style','edit', ...
            'Tag','SolZlabel');

Data.sol.axis_range = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''axis_range_sol'');'], ...
            'BackgroundColor',clr(3,:), ...
            'FontSize',fnt(1), ...
            'HorizontalAlignment','left', ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+2*button(4,2)+2*sk(6,2) button(4,:)], ...
            'Style','edit', ...
            'Tag','SolAxRange');

Data.sol.solutionslist = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''label_list_sol'');'], ...
            'BackgroundColor',clr(3,:), ...
            'FontSize',fnt(1), ...
            'HorizontalAlignment','left', ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+sk(4,2) button(4,:)], ...
            'Style','edit', ...
            'Tag','SolSolList');

Data.bif.x_label = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_bif'');'], ...
            'BackgroundColor',clr(3,:), ...
            'FontSize',fnt(1), ...
            'HorizontalAlignment','left', ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-button(2,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+2*button(1,2)+2*sk(5,2) button(2,:)], ...
            'Style','edit', ...
            'Tag','BifXlabel');

Data.bif.y_label = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_bif'');'], ...
            'BackgroundColor',clr(3,:), ...
            'FontSize',fnt(1), ...
            'HorizontalAlignment','left', ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-button(2,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2)+button(1,2)+sk(5,2) button(2,:)], ...
            'Style','edit', ...
            'Tag','BifYlabel');

Data.bif.z_label = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''draw_bif'');'], ...
            'BackgroundColor',clr(3,:), ...
            'FontSize',fnt(1), ...
            'HorizontalAlignment','left', ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1)+button(4,1)-button(2,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+3*button(4,2)+2*sk(6,2)+sk(4,2)+4*button(1,2)+3*sk(6,2)+sk(4,2) button(2,:)], ...
            'Style','edit', ...
            'Tag','BifZlabel');

Data.bif.axis_range = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'CallBack',['mplaut(''' number ''',[],''axis_range_bif'');'], ...
            'BackgroundColor',clr(3,:), ...
            'FontSize',fnt(1), ...
            'HorizontalAlignment','left', ...
            'ListboxTop',0, ...
            'Position',[sk(2,1)+ax(1)+sk(2,1)+sk(4,1)+txt(3,1)+sk(3,1) sk(2,2)+ax(2)+sk(2,2)+sk(4,2)+button(4,2)+sk(4,2)+2*button(4,2)+2*sk(6,2) button(4,:)], ...
            'Style','edit', ...
            'Tag','BifAxRange');

% Context Menu
Data.bif.labelcontextmenu = ...
  uicontextmenu('Parent',h0, ...
                'CallBack',['mplaut(''' number ''',num2str(get(gco,''UserData'')),''context_create'');'], ...
                'Tag','BifLabelContextMenu');

Data.bif.labelcontextmenulabel = ...
  uimenu(Data.bif.labelcontextmenu, ...
         'SelectionHighlight','off', ...
         'HitTest','off', ...
         'Label','Label: ' ...
        );
  uimenu(Data.bif.labelcontextmenu, ...
         'Separator','on', ...
         'CallBack',['mplaut(''' number ''',num2str(get(gco,''UserData'')),''context_show'');'], ...
         'Label','Show alone ' ...
        );
  uimenu(Data.bif.labelcontextmenu, ...
         'CallBack',['mplaut(''' number ''',num2str(get(gco,''UserData'')),''context_add'');'], ...
         'Label','Add to list ' ...
        );

% Axis
Data.sol.ax = ...
  axes('Parent',h0, ...
       'Units','normal', ...
       'DrawMode','fast', ...
       'Box','on', ...
       'Color',clr(3,:), ...
       'FontSize',fnt(1), ...
       'Position',[sk(2,:) ax], ...
       'Tag','AxesSolutions', ...
       'XColor',clr(1,:), ...
       'YColor',clr(1,:), ...
       'ZColor',clr(1,:));

Data.bif.ax = ...
  axes('Parent',h0, ...
       'Units','normal', ...
       'DrawMode','fast', ...
       'Box','on', ...
       'Color',clr(3,:), ...
       'FontSize',fnt(1), ...
       'Position',[sk(2,1) sk(2,2)+ax(2)+sk(2,2) ax], ...
       'Tag','AxesBifurcations', ...
       'XColor',clr(1,:), ...
       'YColor',clr(1,:), ...
       'ZColor',clr(1,:));


% END
fig=h0;
return;






function optionscreen(number,type)

% Strings
markerstr={ '+','o', '*', '.', 'x', 'square', 'diamond', 'v', '^', '>', '<', 'pentagram', 'hexagram', 'none'};
sizestr={'2','4','6','8','10','12','14','16','18','20','22','24'};
stylestr={'-', '--', ':', '-.', 'none'};
distancestr={'1', '2', '3', '5', '6', '7', '8', '9', '10'};
specialtype={'std','uz','branch','hopf','fold','flip','ns','ep','mx'};
specialtypelongname={'Standard','User','Branch','Hopf','Fold','Flip','Torus','End point','Error'};

% Type of options
switch type
   case 'bif',
         kind='bifurcations';
   case 'sol',
         kind='solutions';
end;

% Find the fig handle of the GUI
  [ex, fig]=figflag(['Matlab plaut ' number]);
  if ~ex,
     error(['The window ''Matlab plaut ' number  ''' does not exist anymore.']);
  end;
  Data=get(fig,'UserData');

% Read the current options
  eval(['stdopt.stablecolor=Data.' type '.stablecolor;']);
  eval(['stdopt.stablestyle=Data.' type '.stablestyle;']);
  [a,b,c]=intersect(stylestr,stdopt.stablestyle);
  stdopt.stablestylev=b;
  eval(['stdopt.unstablecolor=Data.' type '.unstablecolor;']);
  eval(['stdopt.unstablestyle=Data.' type '.unstablestyle;']);
  [a,b,c]=intersect(stylestr,stdopt.unstablestyle);
  stdopt.unstablestylev=b;
  for typ=1:9,
      eval(['stdopt.marker(' num2str(typ) ')=Data.' type '.' specialtype{typ} '.marker;']);
      [a,b,c]=intersect(markerstr,stdopt.marker(typ));
      stdopt.markerv(typ)=b;
      eval(['stdopt.size(' num2str(typ) ')=Data.' type '.' specialtype{typ} '.size;']);
      [a,b,c]=intersect(sizestr,num2str(stdopt.size(typ)));
      stdopt.sizev(typ)=b;
      eval(['stdopt.facecolor(' num2str(typ) ',:)=Data.' type '.' specialtype{typ} '.facecolor;']);
      eval(['stdopt.edgecolor(' num2str(typ) ',:)=Data.' type '.' specialtype{typ} '.edgecolor;']);
  end;
  eval(['stdopt.labeldistance=Data.' type '.labeldistance;']);
  [a,b,c]=intersect(distancestr,num2str(stdopt.labeldistance*100));
  stdopt.labeldistancev=b;
  eval(['stdopt.labelsize=Data.' type '.labelsize;']);
  [a,b,c]=intersect(sizestr,num2str(stdopt.labelsize));
  stdopt.labelsizev=b;

% Units of the screen
oldunit=get(0,'Units');
set(0,'Units','Pixels');
screensize=get(0,'ScreenSize');
screensize=screensize(3:4);
set(0,'Units',oldunit);

% Colors
clr=[...
     [0 0 0] ;...
     [0.8 0.8 0.8] ;...
     [1 1 1] ;...
     [0.6484473945220109 0.6484473945220109 0.6484473945220109] ;...
     [0.701960784313725 0.701960784313725 0.701960784313725] ;...
    ];

% Size
sz=[22 37];

% Skips
sk=[
    1 1   ;...
    1 2   ;...
    1 5/3 ;...
    6 1   ;...
   ];

% Text label
txt=[...
     4 1 ;...
     3 1 ;...
    ];

% Frames
frm=[...
     3 1 ;...
    ];

% Pop down
pop=[...
     3 1 ;...
    ];

% Buttons
but=[...
     3 2 ; ...
    ];

sk(:,1)=sk(:,1)./sz(1);
sk(:,2)=sk(:,2)./sz(2);
txt(:,1)=txt(:,1)./sz(1);
txt(:,2)=txt(:,2)./sz(2);
frm(:,1)=frm(:,1)./sz(1);
frm(:,2)=frm(:,2)./sz(2);
pop(:,1)=pop(:,1)./sz(1);
pop(:,2)=pop(:,2)./sz(2);
but(:,1)=but(:,1)./sz(1);
but(:,2)=but(:,2)./sz(2);

% Figure
figwidth=9/24;
figheight=figwidth*sz(2)/sz(1);
figpos=[(1-figwidth)/2 (1-figheight)/2 figwidth figheight];

% Fonts
fnt=round(0.75*[10 16 14]*1024/screensize(2));

% The Figure
h0 = figure('Color',clr(2,:), ...
            'Units','normal', ...
            'MenuBar','none', ...
            'Position',figpos, ...
            'Resize','off', ...
            'Name',['Graphic options for ' kind ' diagram ' number], ...
            'NumberTitle','off', ...
            'Tag',['Options' kind 'Tag']);

% Text
n=length(specialtype);
for i=1:n,
    uicontrol('Parent',h0, ...
              'Units','normal', ...
              'BackgroundColor',clr(2,:), ...
              'FontSize',fnt(2), ...
              'HorizontalAlignment','right', ...
              'ListboxTop',0, ...
              'Position',[sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+5*sk(1,2)+sk(2,2)+2*(i-1)*sk(1,2) txt(1,:)], ...
              'String',[specialtypelongname{n+1-i} ':'], ...
              'Style','text',...
              'Tag',['TextLabel' specialtypelongname{n+1-i} 'Tag']);

    OptionData.spcpts.edgecolor(n+1-i) = ...
      uicontrol('Parent',h0, ...
                'Callback',['set(gcbo,''Backgroundcolor'',uisetcolor(get(gcbo,''Backgroundcolor''),[''Edge of ' specialtypelongname{n+1-i} ' in ' kind ' diagram ' number ''']));'], ...
                'Units','normal', ...
                'BackgroundColor',stdopt.edgecolor(n+1-i,:), ...
                'FontSize',fnt(1), ...
                'ListboxTop',0, ...
                'Position',[sk(1,1)+txt(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+5*sk(1,2)+sk(2,2)+2*(i-1)*sk(1,2) frm(1,:)], ...
                'Style','pushbutton', ...
                'Tag',['ECFrame' specialtypelongname{n+1-i} 'Tag']);

    OptionData.spcpts.facecolor(n+1-i) = ...
      uicontrol('Parent',h0, ...
                'Callback',['set(gcbo,''Backgroundcolor'',uisetcolor(get(gcbo,''Backgroundcolor''),[''Face of ' specialtypelongname{n+1-i} ' in ' kind ' diagram ' number ''']));'], ...
                'Units','normal', ...
                'BackgroundColor',stdopt.facecolor(n+1-i,:), ...
                'FontSize',fnt(1), ...
                'ListboxTop',0, ...
                'Position',[sk(1,1)+txt(1,1)+sk(1,1)+frm(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+5*sk(1,2)+sk(2,2)+2*(i-1)*sk(1,2) frm(1,:)], ...
                'Style','pushbutton', ...
                'Tag',['FCFrame' specialtypelongname{n+1-i} 'Tag']);

    OptionData.spcpts.marker(n+1-i) = ...
      uicontrol('Parent',h0, ...
                'Units','normal', ...
                'BackgroundColor',clr(5,:), ...
                'FontSize',fnt(1), ...
                'ListboxTop',0, ...
                'Position',[sk(1,1)+txt(1,1)+sk(1,1)+frm(1,1)+sk(1,1)+frm(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+5*sk(1,2)+sk(2,2)+2*(i-1)*sk(1,2) pop(1,:)], ...
                'String',markerstr, ...
                'Value',stdopt.markerv(i), ...
                'Style','popupmenu', ...
                'Tag',['Marker' specialtypelongname{n+1-i} 'Tag']);

    OptionData.spcpts.size(n+1-i) = ...
      uicontrol('Parent',h0, ...
                'Units','normal', ...
                'BackgroundColor',clr(5,:), ...
                'FontSize',fnt(1), ...
                'ListboxTop',0, ...
                'Position',[sk(1,1)+txt(1,1)+sk(1,1)+frm(1,1)+sk(1,1)+frm(1,1)+sk(1,1)+pop(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+5*sk(1,2)+sk(2,2)+2*(i-1)*sk(1,2) pop(1,:)], ...
                'String',sizestr, ...
                'Value',stdopt.sizev(i), ...
                'Style','popupmenu', ...
                'Tag',['Size' specialtypelongname{n+1-i} 'Tag']);

end;

uicontrol('Parent',h0, ...
          'Units','normal', ...
          'BackgroundColor',clr(2,:), ...
          'FontSize',fnt(2), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+2*sk(1,2) txt(1,:)], ...
          'String','Stable:', ...
          'Style','text', ...
          'Tag','StableTextTag');

uicontrol('Parent',h0, ...
          'Units','normal', ...
          'BackgroundColor',clr(2,:), ...
          'FontSize',fnt(2), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2) txt(1,:)], ...
          'String','Unstable:', ...
          'Style','text', ...
          'Tag','UnstableTextTag');

uicontrol('Parent',h0, ...
          'Units','normal', ...
          'BackgroundColor',clr(2,:), ...
          'FontSize',fnt(2), ...
          'HorizontalAlignment','right', ...
          'ListboxTop',0, ...
          'Position',[sk(1,1) sk(1,2)+but(1,2)+sk(2,2) txt(1,:)], ...
          'String','Labels:', ...
          'Style','text', ...
          'Tag','LablesTextTag');

uicontrol('Parent',h0, ...
          'Units','normal', ...
          'BackgroundColor',clr(2,:), ...
          'FontSize',fnt(3), ...
          'HorizontalAlignment','center', ...
          'ListboxTop',0, ...
          'Position',[sk(1,1)+txt(1,1)+sk(1,1)+frm(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+5*sk(1,2)+sk(2,2)+18*sk(1,2) txt(2,:)], ...
          'String','Face', ...
          'Style','text', ...
          'Tag','SpecialFaceTag');

uicontrol('Parent',h0, ...
          'Units','normal', ...
          'BackgroundColor',clr(2,:), ...
          'FontSize',fnt(3), ...
          'HorizontalAlignment','center', ...
          'ListboxTop',0, ...
          'Position',[sk(1,1)+txt(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+5*sk(1,2)+sk(2,2)+18*sk(1,2) txt(2,:)], ...
          'String','Edge', ...
          'Style','text', ...
          'Tag','SpecialEdgeTag');

uicontrol('Parent',h0, ...
          'Units','normal', ...
          'BackgroundColor',clr(2,:), ...
          'FontSize',fnt(3), ...
          'HorizontalAlignment','center', ...
          'ListboxTop',0, ...
          'Position',[sk(1,1)+txt(1,1)+sk(1,1)+frm(1,1)+sk(1,1)+frm(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+5*sk(1,2)+sk(2,2)+18*sk(1,2) txt(2,:)], ...
          'String','Marker', ...
          'Style','text', ...
          'Tag','SpecialMarkerTag');

uicontrol('Parent',h0, ...
          'Units','normal', ...
          'BackgroundColor',clr(2,:), ...
          'FontSize',fnt(3), ...
          'HorizontalAlignment','center', ...
          'ListboxTop',0, ...
          'Position',[sk(1,1)+txt(1,1)+sk(1,1)+frm(1,1)+sk(1,1)+frm(1,1)+sk(1,1)+pop(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+5*sk(1,2)+sk(2,2)+18*sk(1,2) txt(2,:)], ...
          'String','Size', ...
          'Style','text', ...
          'Tag','SpecialSizeTag');

uicontrol('Parent',h0, ...
          'Units','normal', ...
          'BackgroundColor',clr(2,:), ...
          'FontSize',fnt(3), ...
          'HorizontalAlignment','center', ...
          'ListboxTop',0, ...
          'Position',[sk(1,1)+txt(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+4*sk(1,2) txt(2,:)], ...
          'String','Color', ...
          'Style','text', ...
          'Tag','StabStyleTag');

uicontrol('Parent',h0, ...
          'Units','normal', ...
          'BackgroundColor',clr(2,:), ...
          'FontSize',fnt(3), ...
          'HorizontalAlignment','center', ...
          'ListboxTop',0, ...
          'Position',[sk(1,1)+txt(1,1)+sk(1,1)+frm(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+4*sk(1,2) txt(2,:)], ...
          'String','Style', ...
          'Style','text', ...
          'Tag','StabColTag');

uicontrol('Parent',h0, ...
          'Units','normal', ...
          'BackgroundColor',clr(2,:), ...
          'FontSize',fnt(3), ...
          'HorizontalAlignment','center', ...
          'ListboxTop',0, ...
          'Position',[sk(1,1)+txt(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+2*sk(1,2) txt(2,:)], ...
          'String','Distance %', ...
          'Style','text', ...
          'Tag','LabDisTag');

uicontrol('Parent',h0, ...
          'Units','normal', ...
          'BackgroundColor',clr(2,:), ...
          'FontSize',fnt(3), ...
          'HorizontalAlignment','center', ...
          'ListboxTop',0, ...
          'Position',[sk(1,1)+txt(1,1)+sk(1,1)+frm(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+2*sk(1,2) txt(2,:)], ...
          'String','Size', ...
          'Style','text', ...
          'Tag','LabSizeTag');

OptionData.stablecolor = ...
  uicontrol('Parent',h0, ...
            'Callback',['set(gcbo,''Backgroundcolor'',uisetcolor(get(gcbo,''Backgroundcolor''),[''Stable color in ' kind ' diagram ' number ''']));'], ...
            'Units','normal', ...
            'BackgroundColor',stdopt.stablecolor, ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(1,1)+txt(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+2*sk(1,2) frm(1,:)], ...
            'Style','pushbutton', ...
            'Tag','StableColorTag');

OptionData.unstablecolor = ...
  uicontrol('Parent',h0, ...
            'Callback',['set(gcbo,''Backgroundcolor'',uisetcolor(get(gcbo,''Backgroundcolor''),[''Unstable color in ' kind ' diagram ' number ''']));'], ...
            'Units','normal', ...
            'BackgroundColor',stdopt.unstablecolor, ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(1,1)+txt(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2) frm(1,:)], ...
            'Style','pushbutton', ...
            'Tag','UnstableColorTag');


OptionData.stablestyle = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(1,1)+txt(1,1)+sk(1,1)+frm(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2)+2*sk(1,2) pop(1,:)], ...
            'String',stylestr, ...
            'Value',stdopt.stablestylev, ...
            'Style','popupmenu', ...
            'Tag','StableStyleTag');

OptionData.unstablestyle = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(1,1)+txt(1,1)+sk(1,1)+frm(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2)+3*sk(1,2)+sk(2,2) pop(1,:)], ...
            'String',stylestr, ...
            'Value',stdopt.unstablestylev, ...
            'Style','popupmenu', ...
            'Tag','UnstableStyleTag');

OptionData.labelsize = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(1,1)+txt(1,1)+sk(1,1)+frm(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2) pop(1,:)], ...
            'String',sizestr, ...
            'Value',stdopt.labelsizev, ...
            'Style','popupmenu', ...
            'Tag','LabelSizeTag');

OptionData.labeldistance = ...
  uicontrol('Parent',h0, ...
            'Units','normal', ...
            'BackgroundColor',clr(5,:), ...
            'FontSize',fnt(1), ...
            'ListboxTop',0, ...
            'Position',[sk(1,1)+txt(1,1)+sk(1,1) sk(1,2)+but(1,2)+sk(2,2) pop(1,:)], ...
            'String',distancestr, ...
            'Value',stdopt.labeldistancev, ...
            'Style','popupmenu', ...
            'Tag','LabelSizeTag');

uicontrol('Parent',h0, ...
          'CallBack',['mplaut(''' number ''',[],''option_apply_' type '''); closereq'], ...
          'Units','normal', ...
          'FontSize',fnt(3), ...
          'Position',[sk(4,1) sk(4,2) but(1,:)], ...
          'String','OK', ...
          'Tag','OKTag');

uicontrol('Parent',h0, ...
          'CallBack',['mplaut(''' number ''',[],''option_apply_' type ''');'], ...
          'Units','normal', ...
          'FontSize',fnt(3), ...
          'Position',[sk(4,1)+but(1,1)+sk(1,1) sk(4,2) but(1,:)], ...
          'String','Apply', ...
          'Tag','ApplyTag');

uicontrol('Parent',h0, ...
          'Callback','closereq', ...
          'Units','normal', ...
          'FontSize',fnt(3), ...
          'Position',[sk(4,1)+2*(but(1,1)+sk(1,1)) sk(4,2) but(1,:)], ...
          'String','Cancel', ...
          'Tag','CancelTag');

set(h0,'UserData',OptionData);

return;
