www.pudn.com > Closid30.rar > CLEDICOL.M, change:1997-04-30,size:3615b


function cledicol(clr) 
% cledicol(clr) 
% 
% Will open a window to interactively change colors of 
% the objects defined in the main window, and subwindows 
% opened thereafter. 
 
% Functions called: clsetcol, clcolor 
 
% 01-11-1996  
% (c) Paul Van den Hof, Douwe de Vries 
% Mechanical Engineering Systems and Control Group 
% Delft University of Technology 
% Last update: 30-04-1997. 
 
% Globals 
global CLIDmods CLIDcols 
 
% Defaults 
if nargin<1 
   clr=CLIDcols; 
end 
 
% Colors 
[frmcol,txtcol,edicol,pshcol,radcol,axscol,c7,c8,c9,c10,... 
modcol,edtcol,pubcol,putcol,chbcol,chtcol,txbcol,pstcol]=clsetcol(clr); 
 
% Sizes 
km=CLIDmods(1,2); 
DX=0.05;  MX=0.02;  TX=0.4;  BX=0.2; EX=0.6; 
DY=0.05;  MY=0.02;  YY=0.07; 
DPX=max([2*MX+DX+TX+EX 2*MX+4*DX+5*BX]); 
DPY=2*MY+(2+km)*DY+(3+km)*YY; 
qx=1/DPX; 
qy=1/DPY; 
DX=DX*qx; MX=MX*qx; TX=TX*qx; BX=BX*qx; EX=EX*qx; 
YY=YY*qy; DY=DY*qy; MY=MY*qy; 
DPX=0.4;  PX=0.1;   DPY=0.5; PY=0.95-DPY; 
 
% Detect the presence of the window first 
hsc=findobj(get(0,'children'),'Tag','CLSETCLR'); 
if ~isempty(hsc), 
    figure(hsc); 
else 
   clfgclr=figure('Units','Norm','Position',[PX PY DPX DPY], ... 
      'Color',frmcol,'MenuBar','none', ... 
      'NumberTitle','off','Name','Colors', ... 
      'TAG','CLSETCLR','resize','on'); 
 
   % Create editable text 
   fmclr=zeros(2+km,1); 
   uicontrol(clfgclr,'style','text','String','text','Units','norm', ... 
      'Position',[MX 1-MY-YY TX YY], ... 
      'Back',txbcol,'Fore',txtcol); 
   txt=mat2str(clr(2,:),2); 
   fmclr(1)=uicontrol(clfgclr,'style','edit','String',txt,'Units','norm', ... 
      'Position',[MX+TX+DX 1-MY-YY EX YY], ... 
      'Back',edicol,'Fore',edtcol); 
   uicontrol(clfgclr,'style','text','String','axis','Units','norm', ... 
      'Position',[MX 1-MY-2*YY-DY TX YY], ... 
      'Back',txbcol,'Fore',txtcol); 
   txt=mat2str(clr(6,:),2); 
   fmclr(2)=uicontrol(clfgclr,'style','edit','String',txt,'Units','norm', ... 
      'Position',[MX+TX+DX 1-MY-2*YY-DY EX YY], ... 
      'Back',edicol,'Fore',edtcol); 
   for i=1:km 
      mdi=['model ' int2str(i)]; 
      uicontrol(clfgclr,'style','text','String',mdi,'Units','norm', ... 
         'Position',[MX 1-MY-(2+i)*YY-(1+i)*DY TX YY], ... 
         'Back',txbcol,'Fore',txtcol); 
      txt=mat2str(clr(10+i,:),2); 
      fmclr(2+i)=uicontrol(clfgclr,'style','edit','String',txt,'Units','norm', ... 
         'Position',[MX+TX+DX 1-MY-(2+i)*YY-(1+i)*DY EX YY], ... 
         'Back',edicol,'Fore',edtcol); 
   end 
 
   % Create buttons 
   uicontrol(clfgclr,'Style','push', ... 
      'Position',[MX MY BX YY],'Back',pshcol,'Fore',pstcol, ... 
      'String','random','Units','norm','Callback','clcolor(''random'')'); 
   uicontrol(clfgclr,'Style','push', ... 
      'Position',[MX+DX+BX MY BX YY],'Back',pshcol,'Fore',pstcol, ... 
      'String','reset','Units','norm','Callback','clcolor(''reset'')'); 
   uicontrol(clfgclr,'Style','push','Back',pshcol,'Fore',pstcol, ... 
      'Position',[MX+2*DX+2*BX MY BX YY], ... 
      'String','standard','Units','norm','Callback','clcolor(''standard'')'); 
   uicontrol(clfgclr,'Style','push','Back',pshcol,'Fore',pstcol, ... 
      'Position',[MX+3*DX+3*BX MY BX YY], ... 
      'String','apply','Units','norm','Callback','clcolor(''apply'')'); 
   uicontrol(clfgclr,'Style','push','Back',pshcol,'Fore',pstcol, ... 
      'Position',[MX+4*DX+4*BX MY BX YY], ... 
      'String','CLOSE','Units','norm','Callback','clcolor(''close'')'); 
 
   % Put handles and clr in userdata of figure 
   us=[zeros(size(clr,1),1) clr]; 
   us(1:length(fmclr),1)=fmclr; 
   set(gcf,'Userdata',us); 
end