source: MML/trunk/applications/orbit/lib/showelem.m @ 4

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

Initial import--MML version from SOLEIL@2013

File size: 4.4 KB
Line 
1function showelem
2%response to the buttondownfcn for elements in the display bar
3
4ElementIcons=getappdata(0,'ElementIcons');
5
6index=get(gcbo,'Userdata');           %userdata holds index of element in THERING
7                                      %userdata loaded in function elementiconpatch
8AO=getao;
9
10
11    NameBoxWidth = 70;
12    NameBoxHeight = 14;
13
14    EditBoxWidth = 60;
15    EditBoxWidth2 = 40;
16    EditBoxHeight = 14;
17
18    SpaceX =20;
19    SpaceY = 15;
20   
21p = findobj(0,'tag','hobj');
22if ~isempty(p) delete(p); end
23   
24h0 = figure('Color', [0.8 0.8 0.8], ...
25            'PaperPosition',[18 180 576 432], 'Units','points', 'Position',[30 30 600 200], ...
26            'Tag', 'hobj',...
27        'ToolBar','none','MenuBar','none','NumberTitle','off','Visible','off',...
28        'Name','Element Display');
29   
30%Get Names for THERING(index) and ElementIcon(index) combined
31global THERING
32Element=structmerge(ElementIcons{index},THERING{index});
33
34%get number of fields for Element, eliminate coordinates, Roll
35Names = fieldnames(Element);
36names=cell2struct(Names',Names',2);
37names=rmfield(names,{'xpts'; 'ypts'; 'color'; 'elementimage';});
38if isfield(names,'R1') | isfield(names,'R2') names=rmfield(names,{'R1'; 'R2';}); end  %remove rotation matrices for now
39Names=struct2cell(names);
40NumFields = length(Names); 
41
42%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43% the following block of code is taken verbatim from intelem
44% 9/13/03 changed THERING{index} to Element
45%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46
47Handles = cell(1,NumFields);
48TextHandles = zeros(1,NumFields);
49   
50    % Create editable text controls for each field
51    % If a field is an MxN  matrix (Multipole coefficients)
52    % create MxN text controls for each element of the matrix
53
54    LastPos = 0;
55
56    for i = 1:NumFields
57   
58        FieldData = getfield(Element,Names{NumFields-i+1});
59        [M,N] = size(FieldData);
60        Name = Names{NumFields-i+1};
61        UD.FieldName = Name;
62   
63        LastPos = LastPos + SpaceY  + (M-1)*EditBoxHeight;
64   
65        % One Static Text control per field
66        TextHandles(i) = uicontrol('Parent',h0, 'Units','points', ...
67                'BackgroundColor',[0.8 0.8 0.8], ...
68            'FontSize',8, ...
69                'FontSize',8 , ...
70                'ListboxTop',0, ...
71                'Position',[SpaceX  LastPos  NameBoxWidth  NameBoxHeight], ...
72            'String',Name, ...
73            'HorizontalAlignment','right', ...
74                'Style','text', ...
75            'Tag','StaticText1');
76
77       
78            if isnumeric(FieldData)
79            for m = 1:M
80                UD.M = m;
81                for n = 1:N
82                    UD.N = n;
83                    EditHandles{i}(m,n)=uicontrol('Parent',h0, 'Units','points', ...
84                        'BackgroundColor',[1 1 1], 'FontSize',8 , ...
85                                'Position',[2*SpaceX+NameBoxWidth+(n-1)*EditBoxWidth2 ,  LastPos-(m-1)*EditBoxHeight,  EditBoxWidth2, EditBoxHeight], ...
86                        'Style','edit', ...
87                        'String',sprintf('%.6f',FieldData(m,n)),'HorizontalAlignment','right', ...     
88                        'UserData',UD,...
89                        'Callback','intelem sync', ...
90                        'Tag','EditText1');
91                end
92                end 
93        elseif ischar(FieldData)
94            UD.M = 1;
95            UD.N = 1;
96            EditHandles{i}=uicontrol('Parent',h0,'Units','points', ...
97                'BackgroundColor',[1 1 1],'FontSize',8 , ...
98                'Position',[2*SpaceX+NameBoxWidth LastPos  100 EditBoxHeight],'Style','edit', ...
99                'String',FieldData, 'HorizontalAlignment','left', ...
100                'UserData',UD, ...
101                'Callback','intelem sync', ...
102                'Tag','EditText1');
103        end     
104    end
105
106    set(h0,'HandleVisibility','on','Visible','on');
107
108%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109% end block of code from intelem
110%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111
112H = get(h0,'Position');
113H(4) = LastPos+40;
114set(h0,'Position',H);
115
116%make pushbutton to show elememt image
117uicontrol('Style', 'Pushbutton', 'Units', 'Normalized', 'Position', [.8 .5 .1 .1],...
118'Tag', 'showimage', 'String', 'Show Image', 'Callback', 'showimage(''showimage'')','Userdata',index);
119
120%axes for jpeg image display
121ha = axes('Units','pixels',...
122    'Color', [1 1 1], ...   
123    'Box','on',...
124    'Visible','Off',...
125    'Position',[600 10 100 100],...
126    'XTickLabelMode','Manual',...
127    'XTickLabel',[],...
128    'YTickLabelMode','Manual',...
129    'YTickLabel',[]);
Note: See TracBrowser for help on using the repository browser.