1 | function showelem |
---|
2 | %response to the buttondownfcn for elements in the display bar |
---|
3 | |
---|
4 | ElementIcons=getappdata(0,'ElementIcons'); |
---|
5 | |
---|
6 | index=get(gcbo,'Userdata'); %userdata holds index of element in THERING |
---|
7 | %userdata loaded in function elementiconpatch |
---|
8 | AO=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 | |
---|
21 | p = findobj(0,'tag','hobj'); |
---|
22 | if ~isempty(p) delete(p); end |
---|
23 | |
---|
24 | h0 = 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 |
---|
31 | global THERING |
---|
32 | Element=structmerge(ElementIcons{index},THERING{index}); |
---|
33 | |
---|
34 | %get number of fields for Element, eliminate coordinates, Roll |
---|
35 | Names = fieldnames(Element); |
---|
36 | names=cell2struct(Names',Names',2); |
---|
37 | names=rmfield(names,{'xpts'; 'ypts'; 'color'; 'elementimage';}); |
---|
38 | if isfield(names,'R1') | isfield(names,'R2') names=rmfield(names,{'R1'; 'R2';}); end %remove rotation matrices for now |
---|
39 | Names=struct2cell(names); |
---|
40 | NumFields = 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 | |
---|
47 | Handles = cell(1,NumFields); |
---|
48 | TextHandles = 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 | |
---|
112 | H = get(h0,'Position'); |
---|
113 | H(4) = LastPos+40; |
---|
114 | set(h0,'Position',H); |
---|
115 | |
---|
116 | %make pushbutton to show elememt image |
---|
117 | uicontrol('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 |
---|
121 | ha = 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',[]); |
---|