1 |
function EditAxis(command, subcommand) |
---|
2 |
% |
---|
3 |
% function EditAxis(command, subcommand) |
---|
4 |
% |
---|
5 |
% Abstract: |
---|
6 |
% Edit axis limits and tick marks. Use with Prmenu |
---|
7 |
% |
---|
8 |
% Commands and subcommands |
---|
9 |
% initialize |
---|
10 |
% editlim |
---|
11 |
% whichaxis |
---|
12 |
% editvalues |
---|
13 |
% editmode |
---|
14 |
% editmark |
---|
15 |
% editlabel |
---|
16 |
% aspect |
---|
17 |
% data |
---|
18 |
% axes |
---|
19 |
% default |
---|
20 |
% reset |
---|
21 |
% done |
---|
22 |
% reset |
---|
23 |
% cancel |
---|
24 |
% newaxestouched |
---|
25 |
% info |
---|
26 |
% |
---|
27 |
% The following commands and subcommands are used for changes |
---|
28 |
% to the curaxes but not as part of the Edit Limits Figure |
---|
29 |
% axis |
---|
30 |
% equal |
---|
31 |
% square |
---|
32 |
% normal |
---|
33 |
% auto |
---|
34 |
% image |
---|
35 |
% scale |
---|
36 |
% linear |
---|
37 |
% semilogx |
---|
38 |
% semilogy |
---|
39 |
% loglog |
---|
40 |
% grid |
---|
41 |
% majgrid |
---|
42 |
% minortick |
---|
43 |
% minorgrid |
---|
44 |
% |
---|
45 |
% History: |
---|
46 |
% o Original concepts, template, and design from Brian Blanton |
---|
47 |
% and Keith Rogers |
---|
48 |
% o 13 April, 1995 re-create figure window with edit limits, |
---|
49 |
% aspect ratio, and tick marks, and tick labels. |
---|
50 |
% |
---|
51 |
% |
---|
52 |
|
---|
53 |
% get needed globals and define variable used throughout |
---|
54 |
global LASTAXIS LASTFIGURE |
---|
55 |
axestr = ['XYZ']; |
---|
56 |
|
---|
57 |
curfig=LASTFIGURE; |
---|
58 |
set(curfig,'Pointer','watch') |
---|
59 |
|
---|
60 |
if isempty(LASTAXIS) |
---|
61 |
curaxes=gca; |
---|
62 |
else |
---|
63 |
curaxes=LASTAXIS; |
---|
64 |
end |
---|
65 |
|
---|
66 |
if nargin < 1 |
---|
67 |
command = 'initialize'; |
---|
68 |
end |
---|
69 |
|
---|
70 |
if strcmp(command, 'initialize') |
---|
71 |
|
---|
72 |
EditAxisFig=findobj(0,'Type','figure','Tag','EditAxisFig'); |
---|
73 |
if ~isempty(EditAxisFig),return,end |
---|
74 |
|
---|
75 |
EditAxisFig = figure('Position',[150 350 435 303],... |
---|
76 |
'NumberTitle','off',... |
---|
77 |
'Name','Edit Axis Limits',... |
---|
78 |
'NextPlot','new',... |
---|
79 |
'Tag','EditAxisFig'); |
---|
80 |
|
---|
81 |
% choose axis to edit |
---|
82 |
ChooseFrame=uicontrol('Parent',EditAxisFig, ... |
---|
83 |
'CallBack','', ... |
---|
84 |
'Style','frame',... |
---|
85 |
'String','Axes Limits', ... |
---|
86 |
'Horiz', 'center', ... |
---|
87 |
'Position',[13 170 90 120], ... |
---|
88 |
'Tag','ChooseFrame'); |
---|
89 |
|
---|
90 |
ChooseText=uicontrol('Parent',EditAxisFig, ... |
---|
91 |
'CallBack','', ... |
---|
92 |
'Style','text',... |
---|
93 |
'String','Choose an axis', ... |
---|
94 |
'Horiz', 'center', ... |
---|
95 |
'Position',[13 155+110 90 20], ... |
---|
96 |
'Tag','ChooseText'); |
---|
97 |
|
---|
98 |
ChooseMenu=uicontrol('Parent',EditAxisFig, ... |
---|
99 |
'CallBack','EditAxis(''editlim'')', ... |
---|
100 |
'Style','popupmenu',... |
---|
101 |
'String',' X | Y | Z ', ... |
---|
102 |
'Horiz', 'center', ... |
---|
103 |
'Position',[13+10 155+80 70 20], ... |
---|
104 |
'Tag','ChooseMenu'); |
---|
105 |
|
---|
106 |
|
---|
107 |
% edit limits |
---|
108 |
LimFrame=uicontrol('Parent',EditAxisFig, ... |
---|
109 |
'CallBack','', ... |
---|
110 |
'Style','frame',... |
---|
111 |
'String','Axes Limits', ... |
---|
112 |
'Horiz', 'center', ... |
---|
113 |
'Position',[13+105 170 95 120], ... |
---|
114 |
'Tag','LimFrame'); |
---|
115 |
|
---|
116 |
LimText=uicontrol('Parent',EditAxisFig, ... |
---|
117 |
'CallBack','', ... |
---|
118 |
'Style','text',... |
---|
119 |
'String','Axes Limits', ... |
---|
120 |
'Horiz', 'center', ... |
---|
121 |
'Position',[13+105 155+110 95 20], ... |
---|
122 |
'Tag','LimText'); |
---|
123 |
|
---|
124 |
xl=get(curaxes,'Xlim'); |
---|
125 |
|
---|
126 |
LimEdit=uicontrol('Parent',EditAxisFig, ... |
---|
127 |
'CallBack','EditAxis(''editlim'',''editvalues'')', ... |
---|
128 |
'Style','edit',... |
---|
129 |
'Background', 'w', ... |
---|
130 |
'Foreground', 'r', ... |
---|
131 |
'Max', 2, ... |
---|
132 |
'String',vec2str(xl), ... |
---|
133 |
'HorizontalAlignment', 'center', ... |
---|
134 |
'Position',[13+115 155+30 70 30], ... |
---|
135 |
'Tag','LimEdit'); |
---|
136 |
|
---|
137 |
LimMode=uicontrol('Parent',EditAxisFig, ... |
---|
138 |
'CallBack','EditAxis(''editlim'',''editmode'')', ... |
---|
139 |
'Style','checkbox',... |
---|
140 |
'String','Auto', ... |
---|
141 |
'Horiz', 'center', ... |
---|
142 |
'Position',[13+115 155+80 70 20], ... |
---|
143 |
'Tag','LimMode'); |
---|
144 |
|
---|
145 |
if (strcmp('auto',get(curaxes,'XLimMode')) ) |
---|
146 |
set(LimMode, ... |
---|
147 |
'Value', 1, ... |
---|
148 |
'String', 'Auto=on'); |
---|
149 |
else |
---|
150 |
set(LimMode, ... |
---|
151 |
'Value', 0, ... |
---|
152 |
'String', 'Auto=off'); |
---|
153 |
end |
---|
154 |
|
---|
155 |
|
---|
156 |
|
---|
157 |
% edit ticks |
---|
158 |
TicFrame=uicontrol('Parent',EditAxisFig, ... |
---|
159 |
'CallBack','', ... |
---|
160 |
'Style','frame',... |
---|
161 |
'String','Tick Marks & Labels', ... |
---|
162 |
'Horiz', 'center', ... |
---|
163 |
'Position',[226 10 190 280], ... |
---|
164 |
'Tag','TicFrame'); |
---|
165 |
|
---|
166 |
TicText1=uicontrol('Parent',EditAxisFig, ... |
---|
167 |
'CallBack','', ... |
---|
168 |
'Style','text',... |
---|
169 |
'String','Tick Marks', ... |
---|
170 |
'Horiz', 'center', ... |
---|
171 |
'Position',[226+10 10+230 80 20], ... |
---|
172 |
'Tag','TicText1'); |
---|
173 |
|
---|
174 |
TicText2=uicontrol('Parent',EditAxisFig, ... |
---|
175 |
'CallBack','', ... |
---|
176 |
'Style','text',... |
---|
177 |
'String','Labels', ... |
---|
178 |
'Horiz', 'center', ... |
---|
179 |
'Position',[226+100 10+230 80 20], ... |
---|
180 |
'Tag','TicText2'); |
---|
181 |
|
---|
182 |
TicText3=uicontrol('Parent',EditAxisFig, ... |
---|
183 |
'CallBack','', ... |
---|
184 |
'Style','text',... |
---|
185 |
'String','Press ''Cntl-Return'' ', ... |
---|
186 |
'Horiz', 'center', ... |
---|
187 |
'Position',[226 10+10 190 20], ... |
---|
188 |
'Tag','TicText3'); |
---|
189 |
|
---|
190 |
xticmarks = get(curaxes,'XTick'); |
---|
191 |
xticlabels = get(curaxes,'XTickLabels'); |
---|
192 |
TicMarkEdit=uicontrol('Parent',EditAxisFig, ... |
---|
193 |
'CallBack','EditAxis(''editlim'',''editmark'')', ... |
---|
194 |
'Style','edit',... |
---|
195 |
'Background', 'w', ... |
---|
196 |
'Foreground', 'r', ... |
---|
197 |
'Max', 2, ... |
---|
198 |
'String',vec2str(xticmarks), ... |
---|
199 |
'HorizontalAlignment', 'center', ... |
---|
200 |
'Position',[226+10 10+30 80 200], ... |
---|
201 |
'Tag','TicMarkEdit'); |
---|
202 |
|
---|
203 |
TicLabelEdit=uicontrol('Parent',EditAxisFig, ... |
---|
204 |
'CallBack','EditAxis(''editlim'',''editlabel'')', ... |
---|
205 |
'Style','edit',... |
---|
206 |
'Background', 'w', ... |
---|
207 |
'Foreground', 'r', ... |
---|
208 |
'Max', 2, ... |
---|
209 |
'String',xticlabels, ... |
---|
210 |
'HorizontalAlignment', 'center', ... |
---|
211 |
'Position',[226+100 10+30 80 200], ... |
---|
212 |
'Tag','TicLabelEdit'); |
---|
213 |
|
---|
214 |
|
---|
215 |
% edit aspect |
---|
216 |
AspFrame=uicontrol('Parent',EditAxisFig, ... |
---|
217 |
'CallBack','', ... |
---|
218 |
'Style','frame',... |
---|
219 |
'String','Aspect', ... |
---|
220 |
'Horiz', 'center', ... |
---|
221 |
'Position',[13 63 200 95], ... |
---|
222 |
'Tag','AspFrame'); |
---|
223 |
|
---|
224 |
AspText1=uicontrol('Parent',EditAxisFig, ... |
---|
225 |
'CallBack','', ... |
---|
226 |
'Style','text',... |
---|
227 |
'String','Aspect Ratio (H/W)', ... |
---|
228 |
'Horiz', 'center', ... |
---|
229 |
'Position',[13+2 63+75 196 20], ... |
---|
230 |
'Tag','AspText1'); |
---|
231 |
|
---|
232 |
AspText2=uicontrol('Parent',EditAxisFig, ... |
---|
233 |
'CallBack','', ... |
---|
234 |
'Style','text',... |
---|
235 |
'String','Data: ', ... |
---|
236 |
'Horiz', 'right', ... |
---|
237 |
'Position',[13+5 63+50 40 20], ... |
---|
238 |
'Tag','AspText2'); |
---|
239 |
|
---|
240 |
AspText3=uicontrol('Parent',EditAxisFig, ... |
---|
241 |
'CallBack','', ... |
---|
242 |
'Style','text',... |
---|
243 |
'String','Axes: ', ... |
---|
244 |
'Horiz', 'right', ... |
---|
245 |
'Position',[13+5 63+25 40 20], ... |
---|
246 |
'Tag','AspText3'); |
---|
247 |
|
---|
248 |
asp = get(curaxes, 'Aspect'); |
---|
249 |
AspDataEdit=uicontrol('Parent',EditAxisFig, ... |
---|
250 |
'CallBack','EditAxis(''aspect'',''data'')', ... |
---|
251 |
'Background', 'w', ... |
---|
252 |
'Foreground', 'r', ... |
---|
253 |
'Style','edit',... |
---|
254 |
'String',num2str(asp(2)), ... |
---|
255 |
'Horiz', 'center', ... |
---|
256 |
'Position',[13+5+40 63+50 70 20], ... |
---|
257 |
'Tag','AspDataEdit'); |
---|
258 |
|
---|
259 |
AspAxesEdit=uicontrol('Parent',EditAxisFig, ... |
---|
260 |
'CallBack','EditAxis(''aspect'',''axes'')', ... |
---|
261 |
'Background', 'w', ... |
---|
262 |
'Foreground', 'r', ... |
---|
263 |
'Style','edit',... |
---|
264 |
'String',num2str(asp(1)), ... |
---|
265 |
'Horiz', 'center', ... |
---|
266 |
'Position',[13+5+40 63+25 70 20], ... |
---|
267 |
'Tag','AspAxesEdit'); |
---|
268 |
|
---|
269 |
AspDefault = uicontrol('Parent',EditAxisFig,... |
---|
270 |
'Style','pushbutton',... |
---|
271 |
'String','Default',... |
---|
272 |
'Position',[13+5+125 63+38 50 20],... |
---|
273 |
'Callback','EditAxis(''aspect'',''default'')',... |
---|
274 |
'Tag','AspDefault'); |
---|
275 |
|
---|
276 |
|
---|
277 |
% Done, cancel, and reset buttons |
---|
278 |
DoneButton = uicontrol('Parent',EditAxisFig,... |
---|
279 |
'BackgroundColor',[0;1;0],... |
---|
280 |
'Style','pushbutton',... |
---|
281 |
'String','Done',... |
---|
282 |
'Position',[23 35 50 20],... |
---|
283 |
'Callback','EditAxis(''reset'',''done'')',... |
---|
284 |
'Tag','DoneButton'); |
---|
285 |
|
---|
286 |
ResetButton = uicontrol('Parent',EditAxisFig,... |
---|
287 |
'BackgroundColor',[1;1;0],... |
---|
288 |
'Style','pushbutton',... |
---|
289 |
'String','Reset',... |
---|
290 |
'Position',[23+63 35 50 20],... |
---|
291 |
'Callback','EditAxis(''reset'',''reset'')',... |
---|
292 |
'Tag','ResetButton'); |
---|
293 |
|
---|
294 |
CancelButton = uicontrol('Parent',EditAxisFig,... |
---|
295 |
'BackgroundColor',[1;0;0],... |
---|
296 |
'Style','pushbutton',... |
---|
297 |
'String','Cancel',... |
---|
298 |
'Position',[23+63+63 35 50 20],... |
---|
299 |
'Callback','EditAxis(''reset'',''cancel'')',... |
---|
300 |
'Tag','CancelButton'); |
---|
301 |
|
---|
302 |
HelpButton = uicontrol('Parent',EditAxisFig,... |
---|
303 |
'BackgroundColor',[1;1;1],... |
---|
304 |
'ForegroundColor',[0;0;0],... |
---|
305 |
'Style','pushbutton',... |
---|
306 |
'String','HELP',... |
---|
307 |
'Position',[23+63 10 50 20],... |
---|
308 |
'Callback','EditAxis(''info'')',... |
---|
309 |
'Tag','HelpButton'); |
---|
310 |
|
---|
311 |
% Use hidden axes (non-visible) to store original data about the limits |
---|
312 |
% so that original limits can be restored by user if it is desired |
---|
313 |
HiddenAxes = axes('Parent',EditAxisFig,... |
---|
314 |
'Visible', 'off', ... |
---|
315 |
'Tag', 'HiddenAxes'); |
---|
316 |
|
---|
317 |
% get aspect data and set to in HiddenAxes |
---|
318 |
set(HiddenAxes, 'Aspect', get(curaxes, 'Aspect')); |
---|
319 |
|
---|
320 |
% for each axiss get limits, ticks, labels, and modes (auto or manual) |
---|
321 |
% of limits, ticks, and labels and set these to the HiddenAxes |
---|
322 |
for i=1:3 |
---|
323 |
set(HiddenAxes, [axestr(i) 'Lim'], get(curaxes, [axestr(i) 'Lim'])); |
---|
324 |
set(HiddenAxes, [axestr(i) 'LimMode'], ... |
---|
325 |
get(curaxes, [axestr(i) 'LimMode'])); |
---|
326 |
set(HiddenAxes, [axestr(i) 'Tick'], get(curaxes, [axestr(i) 'Tick'])); |
---|
327 |
set(HiddenAxes, [axestr(i) 'TickMode'], ... |
---|
328 |
get(curaxes, [axestr(i) 'TickMode'])); |
---|
329 |
newlabel = get(curaxes, [axestr(i) 'TickLabels']); |
---|
330 |
if ~isempty(newlabel) |
---|
331 |
set(HiddenAxes, [axestr(i) 'TickLabels'], newlabel); |
---|
332 |
end |
---|
333 |
set(HiddenAxes, [axestr(i) 'TickLabelMode'], ... |
---|
334 |
get(curaxes, [axestr(i) 'TickLabelMode'])); |
---|
335 |
end % for each axis |
---|
336 |
|
---|
337 |
elseif strcmp(command, 'editlim') |
---|
338 |
|
---|
339 |
% keeps track of user changes to limits, marks and labels |
---|
340 |
|
---|
341 |
if nargin < 2 |
---|
342 |
subcommand = 'whichaxis'; |
---|
343 |
end |
---|
344 |
|
---|
345 |
ChooseMenu=findobj(0,'Type','uicontrol','Tag','ChooseMenu'); |
---|
346 |
LimEdit=findobj(0,'Type','uicontrol','Tag','LimEdit'); |
---|
347 |
LimMode=findobj(0,'Type','uicontrol','Tag','LimMode'); |
---|
348 |
TicMarkEdit=findobj(0,'Type','uicontrol','Tag','TicMarkEdit'); |
---|
349 |
TicLabelEdit=findobj(0,'Type','uicontrol','Tag','TicLabelEdit'); |
---|
350 |
|
---|
351 |
whichaxis = get(ChooseMenu,'Value'); % 1=X,2=Y,3=Z |
---|
352 |
|
---|
353 |
if strcmp(subcommand,'whichaxis') |
---|
354 |
|
---|
355 |
% depending on which axis user is concerned with get |
---|
356 |
% limits and limit mode from curraxes and then show them on |
---|
357 |
% uicontrols for editing limits, tick marks, and labels |
---|
358 |
|
---|
359 |
%show limits |
---|
360 |
lim = get(curaxes, [axestr(whichaxis),'lim']); |
---|
361 |
set(LimEdit, 'String', vec2str(lim)); |
---|
362 |
|
---|
363 |
% show limit mode |
---|
364 |
if ( strcmp('auto',get(curaxes,[axestr(whichaxis),'LimMode'])) ) |
---|
365 |
set(LimMode, ... |
---|
366 |
'Value', 1, ... |
---|
367 |
'String', 'Auto=on'); |
---|
368 |
else |
---|
369 |
set(LimMode, ... |
---|
370 |
'Value', 0, ... |
---|
371 |
'String', 'Auto=off'); |
---|
372 |
end |
---|
373 |
|
---|
374 |
% show tick marks and tick labels |
---|
375 |
marks = get(curaxes, [axestr(whichaxis),'Tick']); |
---|
376 |
set(TicMarkEdit, 'String', vec2str(marks)); |
---|
377 |
labels = get(curaxes, [axestr(whichaxis),'TickLabels']); |
---|
378 |
set(TicLabelEdit, 'String', labels); |
---|
379 |
|
---|
380 |
elseif strcmp(subcommand, 'editvalues') |
---|
381 |
|
---|
382 |
% set current axes to limits specified by user after |
---|
383 |
% 'enter' or 'cntrl-return' is hit |
---|
384 |
newlim = str2vec(get(LimEdit,'String')); |
---|
385 |
set(curaxes, [axestr(whichaxis),'lim'], newlim); |
---|
386 |
|
---|
387 |
% if set by user then auto limit mode is manual |
---|
388 |
if ( strcmp('auto',get(curaxes,[axestr(whichaxis),'LimMode'])) ) |
---|
389 |
set(LimMode, ... |
---|
390 |
'Value', 1, ... |
---|
391 |
'String', 'Auto=on'); |
---|
392 |
else |
---|
393 |
set(LimMode, ... |
---|
394 |
'Value', 0, ... |
---|
395 |
'String', 'Auto=off'); |
---|
396 |
end |
---|
397 |
|
---|
398 |
% show new tick marks and tick labels |
---|
399 |
set(curaxes, [axestr(whichaxis),'TickMode'], 'auto'); |
---|
400 |
set(curaxes, [axestr(whichaxis),'TickLabelMode'], 'auto'); |
---|
401 |
marks = get(curaxes, [axestr(whichaxis),'Tick']); |
---|
402 |
set(TicMarkEdit, 'String', vec2str(marks)); |
---|
403 |
labels = get(curaxes, [axestr(whichaxis),'TickLabels']); |
---|
404 |
set(TicLabelEdit, 'String', labels); |
---|
405 |
|
---|
406 |
|
---|
407 |
elseif strcmp(subcommand, 'editmode') |
---|
408 |
|
---|
409 |
% set auto or manual mode if chosen |
---|
410 |
if ( get(LimMode, 'Value')==1 ) |
---|
411 |
set(LimMode, ... |
---|
412 |
'String', 'Auto=on'); |
---|
413 |
set(curaxes, [axestr(whichaxis),'LimMode'], 'auto') |
---|
414 |
|
---|
415 |
% now get auto limits and show them in LimEdit |
---|
416 |
lim = get(curaxes, [axestr(whichaxis),'lim']); |
---|
417 |
set(LimEdit, 'String', vec2str(lim)); |
---|
418 |
|
---|
419 |
% show new tick marks and tick labels |
---|
420 |
set(curaxes, [axestr(whichaxis),'TickMode'], 'auto'); |
---|
421 |
set(curaxes, [axestr(whichaxis),'TickLabelMode'], 'auto'); |
---|
422 |
marks = get(curaxes, [axestr(whichaxis),'Tick']); |
---|
423 |
set(TicMarkEdit, 'String', vec2str(marks)); |
---|
424 |
labels = get(curaxes, [axestr(whichaxis),'TickLabels']); |
---|
425 |
set(TicLabelEdit, 'String', labels); |
---|
426 |
else |
---|
427 |
set(LimMode, ... |
---|
428 |
'String', 'Auto=off'); |
---|
429 |
set(curaxes, [axestr(whichaxis),'LimMode'], 'manual') |
---|
430 |
end |
---|
431 |
|
---|
432 |
elseif strcmp(subcommand, 'editmark') |
---|
433 |
|
---|
434 |
% set current axes to tick marks specified by user after |
---|
435 |
% 'enter' or 'cntrl-return' is hit |
---|
436 |
newmarks = str2vec(get(TicMarkEdit,'String')); |
---|
437 |
set(curaxes, [axestr(whichaxis),'Tick'], newmarks); |
---|
438 |
labels = get(curaxes, [axestr(whichaxis),'TickLabels']); |
---|
439 |
set(TicLabelEdit, 'String', labels); |
---|
440 |
|
---|
441 |
elseif strcmp(subcommand, 'editlabel') |
---|
442 |
|
---|
443 |
% set current axes to tick marks specified by user after |
---|
444 |
% 'enter' or 'cntrl-return' is hit |
---|
445 |
newlabels = get(TicLabelEdit,'String'); |
---|
446 |
set(curaxes, [axestr(whichaxis),'TickLabels'], newlabels); |
---|
447 |
|
---|
448 |
end % editlim subcommands |
---|
449 |
|
---|
450 |
elseif strcmp(command, 'aspect') |
---|
451 |
|
---|
452 |
% find Edit Axis Figure and hidden axes of original axes data |
---|
453 |
EditAxisFig=findobj(0,'Type','figure','Tag','EditAxisFig'); |
---|
454 |
|
---|
455 |
AspDataEdit=findobj(0,'Type','uicontrol','Tag','AspDataEdit'); |
---|
456 |
AspAxesEdit=findobj(0,'Type','uicontrol','Tag','AspAxesEdit'); |
---|
457 |
|
---|
458 |
aspData = str2num(get(AspDataEdit, 'String')); |
---|
459 |
aspAxes = str2num(get(AspAxesEdit, 'String')); |
---|
460 |
|
---|
461 |
if strcmp(subcommand, 'data') |
---|
462 |
set(curaxes, 'Aspect', [aspAxes, aspData]); |
---|
463 |
elseif strcmp(subcommand, 'axes') |
---|
464 |
set(curaxes, 'Aspect', [aspAxes, aspData]); |
---|
465 |
elseif strcmp(subcommand, 'default') |
---|
466 |
set(curaxes, 'Aspect', [NaN, NaN]); |
---|
467 |
set(AspDataEdit, 'String', num2str(NaN)); |
---|
468 |
set(AspAxesEdit, 'String', num2str(NaN)); |
---|
469 |
end |
---|
470 |
|
---|
471 |
elseif strcmp(command, 'reset') |
---|
472 |
|
---|
473 |
% find Edit Axis Figure and hidden axes of original axes data |
---|
474 |
EditAxisFig=findobj(0,'Type','figure','Tag','EditAxisFig'); |
---|
475 |
|
---|
476 |
ChooseMenu=findobj(0,'Type','uicontrol','Tag','ChooseMenu'); |
---|
477 |
LimEdit=findobj(0,'Type','uicontrol','Tag','LimEdit'); |
---|
478 |
LimMode=findobj(0,'Type','uicontrol','Tag','LimMode'); |
---|
479 |
TicMarkEdit=findobj(0,'Type','uicontrol','Tag','TicMarkEdit'); |
---|
480 |
TicLabelEdit=findobj(0,'Type','uicontrol','Tag','TicLabelEdit'); |
---|
481 |
|
---|
482 |
AspDataEdit=findobj(0,'Type','uicontrol','Tag','AspDataEdit'); |
---|
483 |
AspAxesEdit=findobj(0,'Type','uicontrol','Tag','AspAxesEdit'); |
---|
484 |
|
---|
485 |
HiddenAxes=findobj(0,'Type','axes','Tag','HiddenAxes'); |
---|
486 |
|
---|
487 |
whichaxis = get(ChooseMenu,'Value'); % 1=X,2=Y,3=Z |
---|
488 |
|
---|
489 |
|
---|
490 |
if strcmp(subcommand, 'done') |
---|
491 |
|
---|
492 |
% close Edit Axis Figure window and retain all changes to curaxes |
---|
493 |
|
---|
494 |
% close Edit Axis Figure (hidden axes is child of this figure |
---|
495 |
% so it deleted as well |
---|
496 |
delete(EditAxisFig) |
---|
497 |
|
---|
498 |
elseif strcmp(subcommand, 'show') |
---|
499 |
|
---|
500 |
% show data of curaxes in uicontrols |
---|
501 |
set(ChooseMenu, 'Value', 1); |
---|
502 |
whichaxis=1; % reset to X |
---|
503 |
|
---|
504 |
% set lim |
---|
505 |
lim = get(curaxes, [axestr(whichaxis),'Lim']); |
---|
506 |
set(LimEdit, 'String', vec2str(lim)); |
---|
507 |
|
---|
508 |
% if set by user then auto limit mode is manual |
---|
509 |
if ( strcmp('auto',get(curaxes,[axestr(whichaxis),'LimMode'])) ) |
---|
510 |
set(LimMode, ... |
---|
511 |
'Value', 1, ... |
---|
512 |
'String', 'Auto=on'); |
---|
513 |
else |
---|
514 |
set(LimMode, ... |
---|
515 |
'Value', 0, ... |
---|
516 |
'String', 'Auto=off'); |
---|
517 |
end |
---|
518 |
|
---|
519 |
% show new tick marks and tick labels |
---|
520 |
marks = get(curaxes, [axestr(whichaxis),'Tick']); |
---|
521 |
set(TicMarkEdit, 'String', vec2str(marks)); |
---|
522 |
labels = get(curaxes, [axestr(whichaxis),'TickLabels']); |
---|
523 |
set(TicLabelEdit, 'String', labels); |
---|
524 |
|
---|
525 |
% aspect |
---|
526 |
asp = get(curaxes, 'Aspect'); |
---|
527 |
set(AspDataEdit, 'String', num2str(asp(2))); |
---|
528 |
set(AspAxesEdit, 'String', num2str(asp(1))); |
---|
529 |
|
---|
530 |
elseif strcmp(subcommand, 'reset') |
---|
531 |
|
---|
532 |
% get original axes data from hidden axes and reset current axes |
---|
533 |
% data to this data |
---|
534 |
|
---|
535 |
set(curaxes, 'Aspect', get(HiddenAxes, 'Aspect')); |
---|
536 |
|
---|
537 |
% for each axis get limits, ticks, labels, and modes (auto or manual) |
---|
538 |
% of limits, ticks, and labels and set these to the HiddenAxes |
---|
539 |
for i=1:3 |
---|
540 |
set(curaxes, [axestr(i) 'Lim'], get(HiddenAxes, [axestr(i) 'Lim'])); |
---|
541 |
set(curaxes, [axestr(i) 'LimMode'], ... |
---|
542 |
get(HiddenAxes, [axestr(i) 'LimMode'])); |
---|
543 |
set(curaxes, [axestr(i) 'Tick'], get(HiddenAxes, [axestr(i) 'Tick'])); |
---|
544 |
set(curaxes, [axestr(i) 'TickMode'], ... |
---|
545 |
get(HiddenAxes, [axestr(i) 'TickMode'])); |
---|
546 |
newlabel = get(HiddenAxes, [axestr(i) 'TickLabels']); |
---|
547 |
if ~isempty(newlabel) |
---|
548 |
set(curaxes, [axestr(i) 'TickLabels'], newlabel); |
---|
549 |
end |
---|
550 |
set(curaxes, [axestr(i) 'TickLabelMode'], ... |
---|
551 |
get(HiddenAxes, [axestr(i) 'TickLabelMode'])); |
---|
552 |
end % for each axis |
---|
553 |
|
---|
554 |
% reset data in uicontrols of Edit Axes to reflect this |
---|
555 |
% show all new axes related data in Edit Axis Figure |
---|
556 |
EditAxis('reset', 'show'); |
---|
557 |
|
---|
558 |
elseif strcmp(subcommand, 'cancel') |
---|
559 |
|
---|
560 |
% get original axes data from hidden axes and reset current axes |
---|
561 |
% to this data |
---|
562 |
|
---|
563 |
set(curaxes, 'Aspect', get(HiddenAxes, 'Aspect')); |
---|
564 |
|
---|
565 |
% for each axis get limits, ticks, labels, and modes (auto or manual) |
---|
566 |
% of limits, ticks, and labels and set these to the HiddenAxes |
---|
567 |
for i=1:3 |
---|
568 |
set(curaxes, [axestr(i) 'Lim'], get(HiddenAxes, [axestr(i) 'Lim'])); |
---|
569 |
set(curaxes, [axestr(i) 'LimMode'], ... |
---|
570 |
get(HiddenAxes, [axestr(i) 'LimMode'])); |
---|
571 |
set(curaxes, [axestr(i) 'Tick'], get(HiddenAxes, [axestr(i) 'Tick'])); |
---|
572 |
set(curaxes, [axestr(i) 'TickMode'], ... |
---|
573 |
get(HiddenAxes, [axestr(i) 'TickMode'])); |
---|
574 |
newlabel = get(HiddenAxes, [axestr(i) 'TickLabels']); |
---|
575 |
if ~isempty(newlabel) |
---|
576 |
set(curaxes, [axestr(i) 'TickLabels'], newlabel); |
---|
577 |
end |
---|
578 |
set(curaxes, [axestr(i) 'TickLabelMode'], ... |
---|
579 |
get(HiddenAxes, [axestr(i) 'TickLabelMode'])); |
---|
580 |
end % for each axis |
---|
581 |
|
---|
582 |
% close Edit Axis Figure |
---|
583 |
delete(EditAxisFig) |
---|
584 |
|
---|
585 |
elseif strcmp(subcommand, 'newaxestouched') |
---|
586 |
|
---|
587 |
% reset hidden axes to hold new data of last axes touched |
---|
588 |
set(HiddenAxes, 'Aspect', get(curaxes, 'Aspect')); |
---|
589 |
|
---|
590 |
% for each axis |
---|
591 |
for i=1:3 |
---|
592 |
set(HiddenAxes, [axestr(i) 'Lim'], get(curaxes, [axestr(i) 'Lim'])); |
---|
593 |
set(HiddenAxes, [axestr(i) 'LimMode'], ... |
---|
594 |
get(curaxes, [axestr(i) 'LimMode'])); |
---|
595 |
set(HiddenAxes, [axestr(i) 'Tick'], get(curaxes, [axestr(i) 'Tick'])); |
---|
596 |
set(HiddenAxes, [axestr(i) 'TickMode'], ... |
---|
597 |
get(curaxes, [axestr(i) 'TickMode'])); |
---|
598 |
newlabel = get(curaxes, [axestr(i) 'TickLabels']); |
---|
599 |
if ~isempty(newlabel) |
---|
600 |
set(HiddenAxes, [axestr(i) 'TickLabels'], newlabel); |
---|
601 |
end |
---|
602 |
set(HiddenAxes, [axestr(i) 'TickLabelMode'], ... |
---|
603 |
get(curaxes, [axestr(i) 'TickLabelMode'])); |
---|
604 |
end % for each axis |
---|
605 |
|
---|
606 |
% show all new axes related data in Edit Axis Figure |
---|
607 |
EditAxis('reset', 'show'); |
---|
608 |
|
---|
609 |
end % reset subcommands |
---|
610 |
|
---|
611 |
elseif strcmp(command,'info'); |
---|
612 |
ttlStr='Edit Axis Help'; |
---|
613 |
hlpStr= ... |
---|
614 |
[' ' |
---|
615 |
' ' |
---|
616 |
' ']; |
---|
617 |
PrHelp(ttlStr,hlpStr); |
---|
618 |
|
---|
619 |
elseif strcmp(command, 'axis') |
---|
620 |
|
---|
621 |
EditAxisFig=findobj(0,'Type','figure','Tag','EditAxisFig'); |
---|
622 |
|
---|
623 |
gca=curaxes; |
---|
624 |
axis(subcommand) |
---|
625 |
if ~isempty(EditAxisFig) |
---|
626 |
EditAxis('reset', 'show') |
---|
627 |
end |
---|
628 |
|
---|
629 |
elseif strcmp(command, 'scale') |
---|
630 |
|
---|
631 |
EditAxisFig=findobj(0,'Type','figure','Tag','EditAxisFig'); |
---|
632 |
|
---|
633 |
if strcmp(subcommand, 'linear') |
---|
634 |
set(curaxes, 'xscale', 'linear', 'yscale', 'linear'); |
---|
635 |
|
---|
636 |
elseif strcmp(subcommand, 'semilogx') |
---|
637 |
set(curaxes, 'xscale', 'log', 'yscale', 'linear'); |
---|
638 |
|
---|
639 |
elseif strcmp(subcommand, 'semilogy') |
---|
640 |
set(curaxes, 'xscale', 'linear', 'yscale', 'log'); |
---|
641 |
|
---|
642 |
elseif strcmp(subcommand, 'loglog') |
---|
643 |
set(curaxes, 'xscale', 'log', 'yscale', 'log'); |
---|
644 |
|
---|
645 |
end |
---|
646 |
|
---|
647 |
if ~isempty(EditAxisFig) |
---|
648 |
EditAxis('reset', 'show') |
---|
649 |
end |
---|
650 |
|
---|
651 |
elseif strcmp(command, 'grid') |
---|
652 |
|
---|
653 |
EditAxisFig=findobj(0,'Type','figure','Tag','EditAxisFig'); |
---|
654 |
|
---|
655 |
if strcmp(subcommand, 'majgrid') |
---|
656 |
|
---|
657 |
PrMajGrid = findobj(0,'Type','uimenu','Tag','PrMajGrid'); |
---|
658 |
if strcmp(get(curaxes, 'XGrid'), 'off') |
---|
659 |
set(curaxes, 'XGrid','on','YGrid','on', 'ZGrid', 'on'); |
---|
660 |
%set(PrMajGrid, 'checked', 'on'); |
---|
661 |
else |
---|
662 |
set(curaxes, 'XGrid','off','YGrid','off', 'ZGrid', 'off'); |
---|
663 |
%set(PrMajGrid, 'checked', 'off'); |
---|
664 |
end |
---|
665 |
|
---|
666 |
|
---|
667 |
|
---|
668 |
elseif strcmp(subcommand, 'minortick') |
---|
669 |
|
---|
670 |
if strcmp(get(curaxes, 'XMinorTicks'), 'off') |
---|
671 |
set(curaxes, 'XMinorTicks','on','YMinorTicks','on',... |
---|
672 |
'ZMinorTicks', 'on'); |
---|
673 |
else |
---|
674 |
set(curaxes, 'XMinorTicks','off','YMinorTicks','off', ... |
---|
675 |
'ZMinorTicks', 'off'); |
---|
676 |
end |
---|
677 |
|
---|
678 |
elseif strcmp(subcommand, 'minorgrid') |
---|
679 |
|
---|
680 |
if strcmp(get(curaxes, 'XMinorGrid'), 'off') |
---|
681 |
set(curaxes, 'XMinorGrid','on','YMinorGrid','on', 'ZMinorGrid', 'on'); |
---|
682 |
else |
---|
683 |
set(curaxes, 'XMinorGrid','off','YMinorGrid','off', 'ZMinorGrid', 'off'); |
---|
684 |
end |
---|
685 |
|
---|
686 |
end |
---|
687 |
|
---|
688 |
elseif strcmp(command, 'box') |
---|
689 |
|
---|
690 |
EditAxisFig=findobj(0,'Type','figure','Tag','EditAxisFig'); |
---|
691 |
if strcmp(get(curaxes, 'box'), 'off') |
---|
692 |
set(curaxes, 'box', 'on'); |
---|
693 |
else |
---|
694 |
set(curaxes, 'box', 'off') |
---|
695 |
end |
---|
696 |
|
---|
697 |
end % EditAxis commands |
---|
698 |
|
---|
699 |
if ~isnan(curfig), |
---|
700 |
set(curfig,'Pointer','arrow'); |
---|
701 |
end |
---|