0001 function h0 = intelem(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 global THERING
0032
0033 if isnumeric(varargin{1})
0034 index = varargin{1};
0035 UD.LatticeIndex = index;
0036
0037 ElementRecordCopy = THERING{index};
0038 if nargin > 1
0039 NumFields = 0;
0040 Names = {};
0041 for i = 1:length(varargin{2})
0042 if isfield(THERING{index},varargin{2}{i})
0043 NumFields = NumFields+1;
0044 Names{NumFields} = varargin{2}{i};
0045 end
0046 end
0047 else
0048 Names = fieldnames(THERING{index});
0049 NumFields = length(Names);
0050 end
0051
0052
0053
0054 NameBoxWidth = 70;
0055 NameBoxHeight = 14;
0056
0057 EditBoxWidth = 60;
0058 EditBoxWidth2 = 40;
0059 EditBoxHeight = 14;
0060
0061 SpaceX =20;
0062 SpaceY = 15;
0063
0064 FamilyIndexes = findcells(THERING,'FamName',THERING{index}.FamName);
0065 KidNum = find(FamilyIndexes == index);
0066 h0 = figure('Color', [0.8 0.8 0.8], ...
0067 'PaperPosition',[18 180 576 432], 'Units','points', 'Position',[30 30 600 200], ...
0068 'ToolBar','none','MenuBar','none','NumberTitle','off','Visible','off',...
0069 'Name',['Lattice Position: ',int2str(index),' Elemenet # ',int2str(KidNum),...
0070 ' Element Family: ',THERING{index}.FamName]);
0071
0072 Handles = cell(1,NumFields);
0073 TextHandles = zeros(1,NumFields);
0074
0075
0076
0077
0078
0079 LastPos = 0;
0080
0081 for i = 1:NumFields
0082
0083 FieldData = getfield(THERING{index},Names{NumFields-i+1});
0084 if ~isempty(FieldData)
0085 [M,N] = size(FieldData);
0086 Name = Names{NumFields-i+1};
0087 UD.FieldName = Name;
0088
0089 LastPos = LastPos + SpaceY + (M-1)*EditBoxHeight;
0090
0091
0092 TextHandles(i) = uicontrol('Parent',h0, 'Units','points', ...
0093 'BackgroundColor',[0.8 0.8 0.8], ...
0094 'FontSize',8, ...
0095 'FontSize',8 , ...
0096 'ListboxTop',0, ...
0097 'Position',[SpaceX LastPos NameBoxWidth NameBoxHeight], ...
0098 'String',Name, ...
0099 'HorizontalAlignment','right', ...
0100 'Style','text', ...
0101 'Tag','StaticText1');
0102
0103
0104 if isnumeric(FieldData)
0105 for m = 1:M
0106 UD.M = m;
0107 for n = 1:N
0108 UD.N = n;
0109 EditHandles{i}(m,n)=uicontrol('Parent',h0, 'Units','points', ...
0110 'BackgroundColor',[1 1 1], 'FontSize',8 , ...
0111 'Position',[2*SpaceX+NameBoxWidth+(n-1)*EditBoxWidth2 , LastPos-(m-1)*EditBoxHeight, EditBoxWidth2, EditBoxHeight], ...
0112 'Style','edit', ...
0113 'String',sprintf('%.6f',FieldData(m,n)),'HorizontalAlignment','right', ...
0114 'UserData',UD,...
0115 'Callback','intelem sync', ...
0116 'Tag','EditText1');
0117 end
0118 end
0119 elseif ischar(FieldData)
0120 UD.M = 1;
0121 UD.N = 1;
0122 EditHandles{i}=uicontrol('Parent',h0,'Units','points', ...
0123 'BackgroundColor',[1 1 1],'FontSize',8 , ...
0124 'Position',[2*SpaceX+NameBoxWidth LastPos 100 EditBoxHeight],'Style','edit', ...
0125 'String',FieldData, 'HorizontalAlignment','left', ...
0126 'UserData',UD, ...
0127 'Callback','intelem sync', ...
0128 'Tag','EditText1');
0129 end
0130 end
0131 end
0132
0133 H = get(h0,'Position');
0134 H(4) = LastPos+40;
0135 set(h0,'Position',H);
0136 set(h0,'HandleVisibility','off','Visible','on');
0137
0138 elseif ischar(varargin{1})
0139
0140 switch varargin{1}
0141 case 'sync'
0142 UD = get(gcbo,'UserData');
0143 OldValue = getfield(THERING{UD.LatticeIndex},UD.FieldName);
0144 if ischar(OldValue)
0145 THERING{UD.LatticeIndex}=setfield(THERING{UD.LatticeIndex},UD.FieldName,get(gcbo,'String'));
0146 elseif isnumeric(OldValue)
0147 st = get(gcbo,'String');
0148 NewValue = sscanf(st,'%f');
0149 THERING{UD.LatticeIndex}=setfield(THERING{UD.LatticeIndex},UD.FieldName,{UD.M,UD.N},NewValue);
0150 end
0151
0152 end
0153 end