source: MML/trunk/applications/orbit/lib/updateicons.m

Last change on this file was 4, checked in by zhangj, 11 years ago

Initial import--MML version from SOLEIL@2013

File size: 4.1 KB
Line 
1function UpdateIcons(SYS, BPM)
2
3%update icons in display bar
4ElementIcons=getappdata(0,'ElementIcons');
5
6%define number of icons to display
7num=size(SYS.elhndl,1)/2;    %defined as x2 in elementiconinit
8nicon=2*num;
9len=length(SYS.elemind);
10
11%get BPM index in the AT lattice
12if     SYS.plane==1
13indx=BPM(1).ATindex(BPM(1).id);
14elseif SYS.plane==2
15indx=family2atindex('BPMy',BPM(2).id);
16end
17
18%locate where BPM is in drift-free list of elements
19indx=find(SYS.elemind==indx);
20
21%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22%if BPM index closer to 'num' from beginning, set it to 'num+1'
23if indx-num<0
24  indx=num+1;
25end
26
27%if BPM index closer to 'num' from end, set it to 'len-num'
28if indx+num>len
29  indx=len-num+1;
30end
31
32for ii=1:nicon   
33xpos=(ii-0.5)/(nicon+1);    %...SYS.ahpos has x limits 0 to 1
34ind=SYS.elemind(indx+ii-(num+1));        %...back up from BPM index
35set(SYS.elhndl(ii),     'XData', xpos+ElementIcons{ind}.xpts,...
36                        'YData', ElementIcons{ind}.ypts,...
37                        'FaceColor', ElementIcons{ind}.color,...
38                        'UserData',ind);             %Userdata stores element index in THERING
39end
40
41% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42% % %if BPM index closer to 'num' from beginning, set it to 'num+1'
43% % if indx-num<0
44% %   indx=num+1;
45% % end
46% %
47% % %if BPM index closer to 'num' from end, set it to 'len-num'
48% % if indx+num>len
49% %   indx=len-num+1;
50% % end
51% %
52% % for ii=1:nicon   
53% % xpos=(ii-0.5)/(nicon+1);    %...SYS.ahpos has x limits 0 to 1
54% % ind=indx+ii-(num+1);        %...back up from BPM index
55% % set(SYS.elhndl(ii),     'XData', xpos+THERING{ind}.xpts,...
56% %                         'YData', THERING{ind}.ypts,...
57% %                         'FaceColor', THERING{ind}.color,...
58% %                         'UserData',ind);             %Userdata stores element index in THERING
59% % end
60% % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61% % % %alternative method that does not show drift sections
62% % % %indx=BPM index
63% % % %num=number of elements to display
64% % %
65% % % ibehind=zeros(num,1);  %pre-allocate
66% % % iahead=zeros(num,1);
67% % %
68% % % %====================================
69% % % %locate non-drift elements behind BPM
70% % % %====================================
71% % % %look behind, stop if encounter beginning of ring
72% % % jj=0;  ii=indx;
73% % % while jj<=num-1 && ii>1
74% % %     ii=ii-1;
75% % %         if ~strcmp(THERING{ii}.PassMethod,'DriftPass');
76% % %             jj=jj+1;
77% % %             ibehind(jj)=ii;
78% % %         end
79% % % end
80% % % ibehind=flipud(ibehind(find(ibehind)));
81% % %
82% % % %enlarge range ahead if needed
83% % % if length(ibehind)<num-1
84% % %     num=2*num-length(ibehind);
85% % % end
86% % %     
87% % % %======================================
88% % % %locate non-drift elements ahead of BPM
89% % % %======================================
90% % % jj=0;  ii=indx;
91% % % while jj<=num-2 && ii<len   %take one less ahead of BPM so BPM can be in handle array
92% % %     ii=ii+1;
93% % %         if ~strcmp(THERING{ii}.PassMethod,'DriftPass');
94% % %             jj=jj+1;
95% % %             iahead(jj)=ii;
96% % %         end
97% % % end
98% % % iahead=iahead(find(iahead));
99% % %
100% % % %enlarge range behind if needed
101% % % if length(iahead)<num-1
102% % %     num=2*num-length(iahead);
103% % %
104% % % jj=0;  ii=indx; ibehind=[];
105% % % while jj<=num-2 && ii>1
106% % %     ii=ii-1;
107% % %         if ~strcmp(THERING{ii}.PassMethod,'DriftPass');
108% % %             jj=jj+1;
109% % %             ibehind(jj)=ii;
110% % %         end
111% % % end
112% % % ibehind=flipud(ibehind(find(ibehind)));
113% % % end
114% % %
115% % % elem=[ibehind(:); indx; iahead(:)];
116% % %
117% % % for ii=1:length(elem)   
118% % % xpos=(ii-0.5)/(nicon+1);    %...SYS.ahpos has x limits 0 to 1
119% % % ind=elem(ii)    ;        %...behind BPM index
120% % % set(SYS.elhndl(ii),     'XData', xpos+THERING{ind}.xpts,...
121% % %                         'YData', THERING{ind}.ypts,...
122% % %                         'FaceColor', THERING{ind}.color,...
123% % %                         'UserData',ind);             %Userdata stores element index in THERING
124% % % end
125
126
Note: See TracBrowser for help on using the repository browser.