www.pudn.com > Closid30.rar > CLCOLOR.M, change:1997-06-06,size:2117b


function clcolor(option) 
% clcolor(option) 
% 
% Sets the colors in the main window, called by Cledicol. 
 
% Functions called: clsetcol,clflpclr,cledicol 
 
% 20-06-1996 
% (c) Paul Van den Hof, Douwe de Vries 
% Mechanical Engineering Systems and Control Group 
% Delft University of Technology 
% Last update: 30-04-1997 
 
global CLIDcols CLIDcolf CLIDmods 
 
% Option 
km=CLIDmods(1,2); 
clr=CLIDcols; 
if strcmp(option,'random') 
   clr(2,:)=rand(1,3); 
   clr(1,:)=clflpclr(clr(2,:)); 
   clr(6,:)=rand(1,3); 
   clr(10+[1:km],:)=rand(km,3); 
elseif strcmp(option,'reset') 
   clr=CLIDcols; 
elseif strcmp(option,'standard') 
   clr=CLIDcolf; 
elseif strcmp(option,'close') 
   clr=get(gcf,'Userdata'); 
   CLIDcols=clr(:,2:size(clr,2)); 
   close(gcf); 
   return 
elseif ~strcmp(option,'apply') 
   error('not a valid option') 
end 
 
if strcmp(option,'apply') 
   FIGUS=get(gcf,'Userdata'); 
   clr(2,:)=eval(get(FIGUS(1,1),'String'));     % text 
   clr(1,:)=clflpclr(clr(2,:));                  % frame 
   clr(6,:)=eval(get(FIGUS(2,1),'String'));     % axes 
   for i=1:km                                   % models 
      clr(10+km,:)=eval(get(FIGUS(2+km,1),'String')); 
   end 
end 
 
% Redraw menu window 
close(gcf); cledicol(clr); 
 
% Get new colors 
[frmcol,txtcol,edicol,pshcol,radcol,axscol,c7,c8,c9,c10,... 
   modcol,edtcol,pubcol,putcol,chbcol,chtcol,txbcol,pstcol]=clsetcol(clr); 
 
% Get main window handles 
MFIG=findobj('TAG','CLMAIN'); 
MFUS=get(MFIG,'Userdata'); 
 
% Set Frame and Text colors in main window 
set(MFIG,'Color',frmcol,'DefaultAxesColor',frmcol); 
set(MFUS(2,1),'Back',frmcol); 
 
% Set Axes colors in main window 
set(MFIG,'DefaultAxesXColor',axscol,'DefaultAxesYColor',axscol,... 
   'DefaultAxesZColor',axscol); 
 
% Set Model, controller and data plot colors in main window 
cm=CLIDmods(1,:); 
for i=1:length(cm) 
   for k=1:cm(i) 
      if CLIDmods(i*5-2,k)==0 
         set(CLIDmods(i*5-1,k),'Color',frmcol); 
      end 
      set(CLIDmods(i*5-1,k),'XColor',axscol,'YColor',axscol,'ZColor',axscol); 
      set(CLIDmods(i*5+1,k),'Color',modcol(k,:)); 
   end 
end