%Prepared by R.A.Garaev for UHF labs
set(windM1,'Color',[ 0 0 1]);  
ha = axes('pos',[0 0 1 1],'Visible','off');

text(.5,.95,captionM,'horizontalalignment','center','Color',[1 1 1]);

fig = gcf;  
% Общие кнопки ===========================
Check_button = uicontrol('Style','Pushbutton','Units','normalized',...
        'Position',[.74 .92 .1 .07],...
        'Callback',UActionCheck,'String','Проба');

sClose= ['close(windM1); close(windG1);'];

Exit_button = uicontrol('Style','Pushbutton','Units','normalized',...
        'Position',[.85 .92 .1 .07],...
        'Callback',sClose,'String','Выход');

% First set of controls %=================
if strcmp(Ctrl1,'on'),
txM1(1) = text(.4,.9,captnPar1,'horizontalalignment','center');
txM1(2) = text(.27,.82,sprintf('%6.2g',Slider1Min),'hor','right');
txM1(3) = text(.72,.82,sprintf('%6.2g',Slider1Max),'hor','right');
nM1= (Slider1Val-Slider1Min)/(Slider1Max - Slider1Min) * 100;
%txM1(4)=text(.50,.82,int2str(round(nM1)),'horizontalalignment','right'); 
txM1(4)=text(.80,.87,int2str(round(nM1)),'horizontalalignment','right'); 
set(txM1,'visible','on');     

ss1 = ['delete(txM1(4));' ...
       'nM1= (Slider1Val-Slider1Min)/(Slider1Max - Slider1Min) * 100;'...
       'txM1(4)=text(.80,.87,int2str(round(nM1)),''hor'',''right'');'... 
       'set(Edit1_field,''String'',num2str(Edit1Val));'...
        UAction1];
global  Edit1Val;

sSlide1= ['Slider1Val = get(NSlider1,''Value'');Edit1Val=Slider1Val;'...
         ss1];
sEdit1 = ['Edit1Val=sscanf(get(Edit1_field,''String''),''%f'');'...
        'Slider1Val= Edit1Val; set(NSlider1,''Value'',Slider1Val);'...
         ss1];
sPopup1 = ['popup1Val=get(popup1,''Value'');'...
           UsActPopup1];

NSlider1 = uicontrol(fig,'Style','slider','Units', 'normalized',...
        'Position',[0.25 0.85 0.45 0.03],...
	'Min',Slider1Min,'Max',Slider1Max,...
	'Value',Slider1Val,'CallBack',sSlide1);   %'SliderStep',[0.01 0.1],
Edit1Val=Slider1Val;
%get(NSlider1) 

Edit1_field = uicontrol('Style','edit','Units','normalized',...
        'Position',[.85 .82 .12 .07],...
        'String',num2str(Slider1Val),...
        'CallBack',sEdit1);      
end;

if popup1Val~=0
popup1=uicontrol('Style','Popup','String',popup1Opts,'Value',popup1Val,...
        'Units','normalized','Position',[.03 .82 .17 .07],...
        'CallBack',sPopup1);
end;

% Second set of controls  %=================
if strcmp(Ctrl2,'on'),
txM2(1) = text(.4,.8,captnPar2,'horizontalalignment','center');
txM2(2) = text(.27,.72,sprintf('%6.2g',Slider2Min),'hor','right');
txM2(3) = text(.72,.72,sprintf('%6.2g',Slider2Max),'hor','right');
nM2= (Slider2Val-Slider2Min)/(Slider2Max - Slider2Min) * 100;
txM2(4)=text(.80,.77,int2str(round(nM2)),'hor','right'); 
set(txM2,'visible','on');     

ss2 = ['delete(txM2(4));' ...
       'nM2= (Slider2Val-Slider2Min)/(Slider2Max - Slider2Min) * 100;'...
       'txM2(4)=text(.80,.77,num2str(round(nM2)),''hor'',''right'');'... 
       'set(Edit2_field,''String'',num2str(Edit2Val));'...
        UAction2];
global  Edit2Val;

sSlide2= ['Slider2Val = get(NSlider2,''Value'');Edit2Val=Slider2Val;'...
         ss2];
sEdit2 = ['Edit2Val=sscanf(get(Edit2_field,''String''),''%f'');'...
        'Slider2Val= Edit2Val; set(NSlider2,''Value'',Slider2Val);'...
         ss2];
sPopup2 = ['popup2Val=get(popup2,''Value'');'...
           UsActPopup2];

NSlider2 = uicontrol(fig,'Style','slider','Units', 'normalized',...
        'Position',[0.25 0.75 0.45 0.03],...
	'Min',Slider2Min,'Max',Slider2Max,...
	'Value',Slider2Val,'CallBack',sSlide2);
Edit2Val=Slider2Val;

Edit2_field = uicontrol('Style','edit','Units','normalized',...
        'Position',[.85 .72 .12 .07],...
        'String',num2str(Slider2Val),...
        'CallBack',sEdit2);      
end;
if popup2Val~=0
popup2=uicontrol('Style','Popup','String',popup2Opts,...
        'Units','normalized','Position',[.03 .72 .17 .07],...
        'Value',popup2Val,'CallBack',sPopup2);
end;

% Third set of controls %=================
if strcmp(Ctrl3,'on'),
txM3(1) = text(.4,.7,captnPar3,'horizontalalignment','center');
txM3(2) = text(.27,.62,sprintf('%6.2g',Slider3Min),'hor','right');
txM3(3) = text(.72,.62,sprintf('%6.2g',Slider3Max),'hor','right');
nM3= (Slider3Val-Slider3Min)/(Slider3Max - Slider3Min) * 100;
txM3(4)=text(.80,.67,int2str(round(nM3)),'hor','right'); 
set(txM3,'visible','on');     

ss3 = ['delete(txM3(4));' ...
       'nM3= (Slider3Val-Slider3Min)/(Slider3Max - Slider3Min) * 100;'...
       'txM3(4)=text(.80,.67,int2str(round(nM3)),''hor'',''right'');'... 
       'set(Edit3_field,''String'',num2str(Edit3Val));'...
        UAction3];
global  Edit3Val;

sSlide3= ['Slider3Val = get(NSlider3,''Value'');Edit3Val=Slider3Val;'...
         ss3];
sEdit3 = ['Edit3Val=sscanf(get(Edit3_field,''String''),''%f'');'...
        'Slider3Val= Edit3Val; set(NSlider3,''Value'',Slider3Val);'...
         ss3];
sPopup3 = ['popup3Val=get(popup3,''Value'');'...
           UsActPopup3];

NSlider3 = uicontrol(fig,'Style','slider','Units', 'normalized',...
        'Position',[0.25 0.65 0.45 0.03],...
	'Min',Slider3Min,'Max',Slider3Max,...
	'Value',Slider3Val,'CallBack',sSlide3);
Edit3Val=Slider3Val;

Edit3_field = uicontrol('Style','edit','Units','normalized',...
        'Position',[.85 .62 .12 .07],...
        'String',num2str(Slider3Val),...
        'CallBack',sEdit3);      
end;
if popup3Val~=0
popup3=uicontrol('Style','Popup','String',popup3Opts,...
        'Units','normalized','Position',[.03 .62 .17 .07],...
        'Value',popup3Val,'CallBack',sPopup3);
end;


% Fourth set of controls %=================
if strcmp(Ctrl4,'on'),
txM4(1) = text(.4,.6,captnPar4,'horizontalalignment','center');
txM4(2) = text(.27,.52,sprintf('%6.2g',Slider4Min),'hor','right');
txM4(3) = text(.72,.52,sprintf('%6.2g',Slider4Max),'hor','right');
nM4= (Slider4Val-Slider4Min)/(Slider4Max - Slider4Min) * 100;
txM4(4)=text(.80,.57,int2str(round(nM4)),'hor','right'); 
set(txM4,'visible','on');     

ss4 = ['delete(txM4(4));' ...
       'nM4= (Slider4Val-Slider4Min)/(Slider4Max - Slider4Min) * 100;'...
       'txM4(4)=text(.80,.57,int2str(round(nM4)),''hor'',''right'');'... 
       'set(Edit4_field,''String'',num2str(Edit4Val));'...
        UAction4];
global  Edit4Val;

sSlide4= ['Slider4Val = get(NSlider4,''Value'');Edit4Val=Slider4Val;'...
         ss4];
sEdit4 = ['Edit4Val=sscanf(get(Edit4_field,''String''),''%f'');'...
        'Slider4Val= Edit4Val; set(NSlider4,''Value'',Slider4Val);'...
         ss4];
sPopup4 = ['popup4Val=get(popup4,''Value'');'...
           UsActPopup4];

NSlider4 = uicontrol(fig,'Style','slider','Units', 'normalized',...
        'Position',[0.25 0.55 0.45 0.03],...
	'Min',Slider4Min,'Max',Slider4Max,...
	'Value',Slider4Val,'CallBack',sSlide4);
Edit4Val=Slider4Val;

Edit4_field = uicontrol('Style','edit','Units','normalized',...
        'Position',[.85 .52 .12 .07],...
        'String',num2str(Slider4Val),...
        'CallBack',sEdit4);      
end;
if popup4Val~=0
popup4=uicontrol('Style','Popup','String',popup4Opts,...
        'Units','normalized','Position',[.03 .52 .17 .07],...
        'Value',popup4Val,'CallBack',sPopup4);
end;

% 5 set of controls %=================
if strcmp(Ctrl5,'on'),
txM5(1) = text(.4,.5,captnPar5,'horizontalalignment','center');
txM5(2) = text(.27,.42,sprintf('%6.2g',Slider5Min),'hor','right');
txM5(3) = text(.72,.42,sprintf('%6.2g',Slider5Max),'hor','right');
nM5= (Slider5Val-Slider5Min)/(Slider5Max - Slider5Min) * 100;
txM5(4)=text(.80,.47,int2str(round(nM5)),'hor','right'); 
set(txM5,'visible','on');     

ss5 = ['delete(txM5(4));' ...
       'nM5= (Slider5Val-Slider5Min)/(Slider5Max - Slider5Min) * 100;'...
       'txM5(4)=text(.80,.47,int2str(round(nM5)),''hor'',''right'');'... 
       'set(Edit5_field,''String'',num2str(Edit5Val));'...
        UAction5];
global  Edit5Val;

sSlide5= ['Slider5Val = get(NSlider5,''Value'');Edit5Val=Slider5Val;'...
         ss5];
sEdit5 = ['Edit5Val=sscanf(get(Edit5_field,''String''),''%f'');'...
        'Slider5Val= Edit5Val; set(NSlider5,''Value'',Slider5Val);'...
         ss5];
sPopup5 = ['popup5Val=get(popup5,''Value'');'...
           UsActPopup5];

NSlider5 = uicontrol(fig,'Style','slider','Units', 'normalized',...
        'Position',[0.25 0.45 0.45 0.03],...
	'Min',Slider5Min,'Max',Slider5Max,...
	'Value',Slider5Val,'CallBack',sSlide5);
Edit5Val=Slider5Val;

Edit5_field = uicontrol('Style','edit','Units','normalized',...
        'Position',[.85 .42 .12 .07],...
        'String',num2str(Slider5Val),...
        'CallBack',sEdit5);      
end;
if popup5Val~=0
popup5=uicontrol('Style','Popup','String',popup5Opts,...
        'Units','normalized','Position',[.03 .42 .17 .07],...
        'Value',popup5Val,'CallBack',sPopup5);
end;

% 6 set of controls  %=================
if strcmp(Ctrl6,'on'),
txM6(1) = text(.4,.4,captnPar6,'horizontalalignment','center');
txM6(2) = text(.27,.32,sprintf('%6.2g',Slider6Min),'hor','right');
txM6(3) = text(.72,.32,sprintf('%6.2g',Slider6Max),'hor','right');
nM6= (Slider6Val-Slider6Min)/(Slider6Max - Slider6Min) * 100;
txM6(4)=text(.80,.37,int2str(round(nM6)),'hor','right'); 
set(txM6,'visible','on');     

ss6 = ['delete(txM6(4));' ...
       'nM6= (Slider6Val-Slider6Min)/(Slider6Max - Slider6Min) * 100;'...
       'txM6(4)=text(.80,.37,int2str(round(nM6)),''hor'',''right'');'... 
       'set(Edit6_field,''String'',num2str(Edit6Val));'...
        UAction6];
global  Edit6Val;

sSlide6= ['Slider6Val = get(NSlider6,''Value'');Edit6Val=Slider6Val;'...
         ss6];
sEdit6 = ['Edit6Val=sscanf(get(Edit6_field,''String''),''%f'');'...
        'Slider6Val= Edit6Val; set(NSlider6,''Value'',Slider6Val);'...
         ss6];
sPopup6 = ['popup6Val=get(popup6,''Value'');'...
           UsActPopup6];

NSlider6 = uicontrol(fig,'Style','slider','Units', 'normalized',...
        'Position',[0.25 0.35 0.45 0.03],...
	'Min',Slider6Min,'Max',Slider6Max,...
	'Value',Slider6Val,'CallBack',sSlide6);
Edit6Val=Slider6Val;

Edit6_field = uicontrol('Style','edit','Units','normalized',...
        'Position',[.85 .32 .12 .07],...
        'String',num2str(Slider6Val),...
        'CallBack',sEdit6);      
end;
if popup6Val~=0
popup6=uicontrol('Style','Popup','String',popup6Opts,...
        'Units','normalized','Position',[.03 .32 .17 .07],...
        'Value',popup6Val,'CallBack',sPopup6);
end;

% 7 набор органов  %=================
if strcmp(Ctrl7,'on'),
txM7(1) = text(.4,.3,captnPar7,'horizontalalignment','center');
txM7(2) = text(.27,.22,sprintf('%6.2g',Slider7Min),'hor','right');
txM7(3) = text(.72,.22,sprintf('%6.2g',Slider7Max),'hor','right');
nM7= (Slider7Val-Slider7Min)/(Slider7Max - Slider7Min) * 100;
txM7(4)=text(.80,.27,int2str(round(nM7)),'hor','right'); 
set(txM7,'visible','on');     

ss7 = ['delete(txM7(4));' ...
       'nM7= (Slider7Val-Slider7Min)/(Slider7Max - Slider7Min) * 100;'...
       'txM7(4)=text(.80,.27,int2str(round(nM7)),''hor'',''right'');'... 
       'set(Edit7_field,''String'',num2str(Edit7Val));'...
        UAction7];
global  Edit7Val;

sSlide7= ['Slider7Val = get(NSlider7,''Value'');Edit7Val=Slider7Val;'...
         ss7];
sEdit7 = ['Edit7Val=sscanf(get(Edit7_field,''String''),''%f'');'...
        'Slider7Val= Edit7Val; set(NSlider7,''Value'',Slider7Val);'...
         ss7];
sPopup7 = ['popup7Val=get(popup7,''Value'');'...
           UsActPopup7];

NSlider7 = uicontrol(fig,'Style','slider','Units', 'normalized',...
        'Position',[0.25 0.25 0.45 0.03],...
	'Min',Slider7Min,'Max',Slider7Max,...
	'Value',Slider7Val,'CallBack',sSlide7);
Edit7Val=Slider7Val;

Edit7_field = uicontrol('Style','edit','Units','normalized',...
        'Position',[.85 .22 .12 .07],...
        'String',num2str(Slider7Val),...
        'CallBack',sEdit7);      
end;
if popup7Val~=0
popup7=uicontrol('Style','Popup','String',popup7Opts,...
        'Units','normalized','Position',[.03 .22 .17 .07],...
        'Value',popup7Val,'CallBack',sPopup7);
end;

% 8 set of controls  %=================
if strcmp(Ctrl8,'on'),
txM8(1) = text(.4,.2,captnPar8,'horizontalalignment','center');
txM8(2) = text(.27,.12,sprintf('%6.2g',Slider8Min),'hor','right');
txM8(3) = text(.72,.12,sprintf('%6.2g',Slider8Max),'hor','right');
nM8= (Slider8Val-Slider8Min)/(Slider8Max - Slider8Min) * 100;
txM8(4)=text(.80,.17,int2str(round(nM8)),'hor','right'); 
set(txM8,'visible','on');     

ss8 = ['delete(txM8(4));' ...
       'nM8= (Slider8Val-Slider8Min)/(Slider8Max - Slider8Min) * 100;'...
       'txM8(4)=text(.80,.17,int2str(round(nM8)),''hor'',''right'');'... 
       'set(Edit8_field,''String'',num2str(Edit8Val));'...
        UAction8];
global  Edit8Val;

sSlide8= ['Slider8Val = get(NSlider8,''Value'');Edit8Val=Slider8Val;'...
         ss8];
sEdit8 = ['Edit8Val=sscanf(get(Edit8_field,''String''),''%f'');'...
        'Slider8Val= Edit8Val; set(NSlider8,''Value'',Slider4Val);'...
         ss8];
sPopup8 = ['popup8Val=get(popup8,''Value'');'...
           UsActPopup8];

NSlider8 = uicontrol(fig,'Style','slider','Units', 'normalized',...
        'Position',[0.25 0.15 0.45 0.03],...
	'Min',Slider8Min,'Max',Slider8Max,...
	'Value',Slider8Val,'CallBack',sSlide8);
Edit8Val=Slider8Val;

Edit8_field = uicontrol('Style','edit','Units','normalized',...
        'Position',[.85 .12 .12 .07],...
        'String',num2str(Slider8Val),...
        'CallBack',sEdit8);      
end;
if popup8Val~=0
popup8=uicontrol('Style','Popup','String',popup8Opts,...
        'Units','normalized','Position',[.03 .12 .17 .07],...
        'Value',popup8Val,'CallBack',sPopup8);
end;


