1 | function view(tree) |
---|
2 | % XMLTREE/VIEW View Method |
---|
3 | % FORMAT view(tree) |
---|
4 | % |
---|
5 | % tree - XMLTree object |
---|
6 | %_______________________________________________________________________ |
---|
7 | % |
---|
8 | % Display an XML tree in a graphical interface |
---|
9 | %_______________________________________________________________________ |
---|
10 | % @(#)view.m Guillaume Flandin 02/04/08 |
---|
11 | |
---|
12 | error(nargchk(1,1,nargin)); |
---|
13 | |
---|
14 | %-Build the Graphical User Interface |
---|
15 | %----------------------------------------------------------------------- |
---|
16 | figH = findobj('Tag','mlBatchFigure'); %this tag doesn't exist so a new |
---|
17 | % window is created .... |
---|
18 | if isempty(figH) |
---|
19 | h = xmltree_build_ui; |
---|
20 | figH = h.fig; |
---|
21 | else |
---|
22 | set(figH,'Visible','on'); |
---|
23 | % recover all the handles |
---|
24 | % h = struct(...); |
---|
25 | end |
---|
26 | drawnow; |
---|
27 | |
---|
28 | %-New title for the main window |
---|
29 | %----------------------------------------------------------------------- |
---|
30 | set(figH,'Name',['XML TreeViewer:' getfilename(tree)]); |
---|
31 | |
---|
32 | |
---|
33 | %-Initialize batch listbox |
---|
34 | %----------------------------------------------------------------------- |
---|
35 | tree = set(tree,root(tree),'show',1); |
---|
36 | builtin('set',figH,'UserData',tree); |
---|
37 | |
---|
38 | view_ui('update',figH); |
---|
39 | |
---|
40 | %======================================================================= |
---|
41 | function handleStruct = xmltree_build_ui |
---|
42 | |
---|
43 | %- Create Figure |
---|
44 | pixfactor = 72 / get(0,'screenpixelsperinch'); |
---|
45 | %- Figure window size and position |
---|
46 | oldRootUnits = get(0,'Units'); |
---|
47 | set(0, 'Units', 'points'); |
---|
48 | figurePos = get(0,'DefaultFigurePosition'); |
---|
49 | figurePos(3:4) = [560 420]; |
---|
50 | figurePos = figurePos * pixfactor; |
---|
51 | rootScreenSize = get(0,'ScreenSize'); |
---|
52 | if ((figurePos(1) < 1) ... |
---|
53 | | (figurePos(1)+figurePos(3) > rootScreenSize(3))) |
---|
54 | figurePos(1) = 30; |
---|
55 | end |
---|
56 | set(0, 'Units', oldRootUnits); |
---|
57 | if ((figurePos(2)+figurePos(4)+60 > rootScreenSize(4)) ... |
---|
58 | | (figurePos(2) < 1)) |
---|
59 | figurePos(2) = rootScreenSize(4) - figurePos(4) - 60; |
---|
60 | end |
---|
61 | %- Create Figure Window |
---|
62 | handleStruct.fig = figure(... |
---|
63 | 'Name','XML TreeViewer', ... |
---|
64 | 'Units', 'points', ... |
---|
65 | 'NumberTitle','off', ... |
---|
66 | 'Resize','on', ... |
---|
67 | 'Color',[0.8 0.8 0.8],... |
---|
68 | 'Position',figurePos, ... |
---|
69 | 'MenuBar','none', ... |
---|
70 | 'Tag', 'BatchFigure', ... |
---|
71 | 'CloseRequestFcn','view_ui close'); |
---|
72 | |
---|
73 | %- Build batch listbox |
---|
74 | batchListPos = [20 55 160 345] * pixfactor; |
---|
75 | batchString = ' '; |
---|
76 | handleStruct.batchList = uicontrol( ... |
---|
77 | 'Parent',handleStruct.fig, ... |
---|
78 | 'Style', 'listbox', ... |
---|
79 | 'HorizontalAlignment','left', ... |
---|
80 | 'Units','points', ... |
---|
81 | 'Visible','on',... |
---|
82 | 'BackgroundColor', [1 1 1], ... |
---|
83 | 'Max', 1, ... |
---|
84 | 'Value', 1 , ... |
---|
85 | 'Enable', 'on', ... |
---|
86 | 'Position', batchListPos, ... |
---|
87 | 'Callback', 'view_ui batchlist', ... |
---|
88 | 'String', batchString, ... |
---|
89 | 'Tag', 'BatchListbox'); |
---|
90 | |
---|
91 | %- Build About listbox |
---|
92 | aboutListPos = [200 220 340 180] * pixfactor; |
---|
93 | aboutString = ' '; |
---|
94 | handleStruct.aboutList = uicontrol( ... |
---|
95 | 'Parent',handleStruct.fig, ... |
---|
96 | 'Style', 'list', ... |
---|
97 | 'HorizontalAlignment','left', ... |
---|
98 | 'Units','points', ... |
---|
99 | 'Visible','on',... |
---|
100 | 'BackgroundColor', [0.8 0.8 0.8], ... |
---|
101 | 'Min', 0, ... |
---|
102 | 'Max', 2, ... |
---|
103 | 'Value', [], ... |
---|
104 | 'Enable', 'inactive', ... |
---|
105 | 'Position', aboutListPos, ... |
---|
106 | 'Callback', '', ... |
---|
107 | 'String', aboutString, ... |
---|
108 | 'Tag', 'AboutListbox'); |
---|
109 | |
---|
110 | %- The Add button |
---|
111 | addBtnPos = [20 20 70 25] * pixfactor; |
---|
112 | handleStruct.add = uicontrol( ... |
---|
113 | 'Parent',handleStruct.fig, ... |
---|
114 | 'Style', 'pushbutton', ... |
---|
115 | 'Units', 'points', ... |
---|
116 | 'Position', addBtnPos, ... |
---|
117 | 'String', 'Add', ... |
---|
118 | 'Visible', 'on', ... |
---|
119 | 'Enable','on',... |
---|
120 | 'Tag', 'Add', ... |
---|
121 | 'Callback', 'view_ui add'); |
---|
122 | %'TooltipString', 'Add batch', ... |
---|
123 | |
---|
124 | %- The modify button |
---|
125 | modifyBtnPos = [95 20 70 25] * pixfactor; |
---|
126 | handleStruct.modify = uicontrol( ... |
---|
127 | 'Parent',handleStruct.fig, ... |
---|
128 | 'Style', 'pushbutton', ... |
---|
129 | 'Units', 'points', ... |
---|
130 | 'Position', modifyBtnPos, ... |
---|
131 | 'String', 'Modify', ... |
---|
132 | 'Visible', 'on', ... |
---|
133 | 'Enable','on',... |
---|
134 | 'Tag', 'Modify', ... |
---|
135 | 'Callback', 'view_ui modify'); |
---|
136 | %'TooltipString', 'Modify batch', ... |
---|
137 | |
---|
138 | %- The Copy button |
---|
139 | copyBtnPos = [170 20 70 25] * pixfactor; |
---|
140 | handleStruct.copy = uicontrol( ... |
---|
141 | 'Parent',handleStruct.fig, ... |
---|
142 | 'Style', 'pushbutton', ... |
---|
143 | 'Units', 'points', ... |
---|
144 | 'Position', copyBtnPos, ... |
---|
145 | 'String', 'Copy', ... |
---|
146 | 'Visible', 'on', ... |
---|
147 | 'Enable','on',... |
---|
148 | 'Tag', 'Copy', ... |
---|
149 | 'Callback', 'view_ui copy'); |
---|
150 | %'TooltipString', 'Copy batch', ... |
---|
151 | |
---|
152 | %- The delete button |
---|
153 | deleteBtnPos = [245 20 70 25] * pixfactor; |
---|
154 | handleStruct.delete = uicontrol( ... |
---|
155 | 'Parent',handleStruct.fig, ... |
---|
156 | 'Style', 'pushbutton', ... |
---|
157 | 'Units', 'points', ... |
---|
158 | 'Position', deleteBtnPos, ... |
---|
159 | 'String', 'Delete', ... |
---|
160 | 'Visible', 'on', ... |
---|
161 | 'Enable','on',... |
---|
162 | 'Tag', 'Delete', ... |
---|
163 | 'Callback', 'view_ui delete'); |
---|
164 | %'TooltipString', 'Delete batch', ... |
---|
165 | |
---|
166 | %- The save button |
---|
167 | saveBtnPos = [320 20 70 25] * pixfactor; |
---|
168 | handleStruct.save = uicontrol( ... |
---|
169 | 'Parent',handleStruct.fig, ... |
---|
170 | 'Style', 'pushbutton', ... |
---|
171 | 'Units', 'points', ... |
---|
172 | 'Position', saveBtnPos, ... |
---|
173 | 'String', 'Save', ... |
---|
174 | 'Visible', 'on', ... |
---|
175 | 'UserData',0,... |
---|
176 | 'Tag', 'Save', ... |
---|
177 | 'Callback', 'view_ui save'); |
---|
178 | %'TooltipString', 'Save batch', ... |
---|
179 | |
---|
180 | %- The run button |
---|
181 | runBtnPos = [395 20 70 25] * pixfactor; |
---|
182 | handleStruct.run = uicontrol( ... |
---|
183 | 'Parent',handleStruct.fig, ... |
---|
184 | 'Style', 'pushbutton', ... |
---|
185 | 'Units', 'points', ... |
---|
186 | 'Position', runBtnPos, ... |
---|
187 | 'String', 'Run', ... |
---|
188 | 'Visible', 'on', ... |
---|
189 | 'Enable', 'on', ... |
---|
190 | 'Tag', 'Run', ... |
---|
191 | 'Callback', 'view_ui run'); |
---|
192 | %'TooltipString', 'Run batch', ... |
---|
193 | |
---|
194 | %- The close button |
---|
195 | closeBtnPos = [470 20 70 25] * pixfactor; |
---|
196 | handleStruct.close = uicontrol( ... |
---|
197 | 'Parent',handleStruct.fig, ... |
---|
198 | 'Style', 'pushbutton', ... |
---|
199 | 'Units', 'points', ... |
---|
200 | 'Position', closeBtnPos, ... |
---|
201 | 'String', 'Close', ... |
---|
202 | 'Visible', 'on', ... |
---|
203 | 'Tag', 'Close', ... |
---|
204 | 'Callback', 'view_ui close'); |
---|
205 | %'TooltipString', 'Close window', ... |
---|
206 | |
---|
207 | handleArray = [handleStruct.fig handleStruct.batchList handleStruct.aboutList handleStruct.add handleStruct.modify handleStruct.copy handleStruct.delete handleStruct.save handleStruct.run handleStruct.close]; |
---|
208 | |
---|
209 | set(handleArray,'Units', 'normalized'); |
---|