1 |
function vizicq4_slicer(command,option) |
---|
2 |
|
---|
3 |
get_VIZICQ4_handles; |
---|
4 |
setptr(VIZICQ4_Figure,'watch') |
---|
5 |
|
---|
6 |
switch command |
---|
7 |
|
---|
8 |
case 'SelRegion' |
---|
9 |
% Mouse-driven region selection |
---|
10 |
|
---|
11 |
% delete(findobj(VIZICQ4_Figure,'Type','line','Tag','VIZICQ4_Transect_Line')) |
---|
12 |
|
---|
13 |
%FORCE AXES ROTATION OFF |
---|
14 |
set(VIZICQ4_Slicer_Rotation,'ToolTipString','Deactivate 3-D Rotation') |
---|
15 |
set(VIZICQ4_Slicer_Rotation,'String','Rotate On') |
---|
16 |
axes(VIZICQ4_Slice_Axes) |
---|
17 |
rotate3d off |
---|
18 |
|
---|
19 |
%Make GRID Axes vis and current |
---|
20 |
% move axes off-screen |
---|
21 |
invisaxstdpos=get(VIZICQ4_LabCont,'UserData'); |
---|
22 |
axstdpos=get(VIZICQ4_DelCont,'UserData'); |
---|
23 |
set(VIZICQ4_Grid_Axes,'Position',axstdpos) |
---|
24 |
set(VIZICQ4_Slice_Axes,'Position',invisaxstdpos) |
---|
25 |
set(VIZICQ4_Grid_Axes,'Visible','on') |
---|
26 |
set(VIZICQ4_Slice_Axes,'Visible','off') |
---|
27 |
axes(VIZICQ4_Grid_Axes) |
---|
28 |
|
---|
29 |
fem_grid_struct=get(VIZICQ4_Grid_Axes,'UserData'); |
---|
30 |
|
---|
31 |
switch option |
---|
32 |
case 'ArbSlice' |
---|
33 |
str='Click and drag mouse to select region (lower-left to upper-right)'; |
---|
34 |
vizicq4_guts('Info',str) |
---|
35 |
waitforbuttonpress; |
---|
36 |
Pt1=get(gca,'CurrentPoint'); |
---|
37 |
rbbox([get(gcf,'CurrentPoint') 0 0],get(gcf,'CurrentPoint')); |
---|
38 |
Pt2=get(gca,'CurrentPoint'); |
---|
39 |
vizicq4_guts('Info',['']) |
---|
40 |
|
---|
41 |
x1=Pt1(1); |
---|
42 |
y1=Pt1(3); |
---|
43 |
x2=Pt2(1); |
---|
44 |
y2=Pt2(3); |
---|
45 |
|
---|
46 |
case {'XSlice','YSlice'} |
---|
47 |
str='Click mouse at Minimum (X|Y)-Location to make slice'; |
---|
48 |
vizicq4_guts('Info',str) |
---|
49 |
waitforbuttonpress; |
---|
50 |
Pt1=get(gca,'CurrentPoint'); |
---|
51 |
x1=Pt1(1);y1=Pt1(3); |
---|
52 |
|
---|
53 |
minx=min(fem_grid_struct.x); |
---|
54 |
maxx=max(fem_grid_struct.x); |
---|
55 |
miny=min(fem_grid_struct.y); |
---|
56 |
maxy=max(fem_grid_struct.y); |
---|
57 |
switch option |
---|
58 |
case 'XSlice' |
---|
59 |
% verify x1 |
---|
60 |
if x1<minx | x1>maxx |
---|
61 |
vizicq4_guts('Error','Selected X not within Domain X- Range') |
---|
62 |
setptr(VIZICQ4_Figure,'arrow') |
---|
63 |
return |
---|
64 |
end |
---|
65 |
x2=x1; |
---|
66 |
y2=max(fem_grid_struct.y); |
---|
67 |
case 'YSlice' |
---|
68 |
% verify y |
---|
69 |
if y1<miny | y1>maxy |
---|
70 |
vizicq4_guts('Error','Selected Y not within Domain Y- Range') |
---|
71 |
setptr(VIZICQ4_Figure,'arrow') |
---|
72 |
return |
---|
73 |
end |
---|
74 |
y2=y1; |
---|
75 |
x2=max(fem_grid_struct.x); |
---|
76 |
otherwise, |
---|
77 |
vizicq4_guts('Error','Bad option to SelRegion') |
---|
78 |
setptr(VIZICQ4_Figure,'arrow') |
---|
79 |
return |
---|
80 |
end |
---|
81 |
otherwise, |
---|
82 |
vizicq4_guts('Error','Bad option to SelRegion') |
---|
83 |
setptr(VIZICQ4_Figure,'arrow') |
---|
84 |
return |
---|
85 |
end |
---|
86 |
|
---|
87 |
% Make sure atleast one end-point is within domain |
---|
88 |
if all(isnan([findelem(fem_grid_struct,[x1 y1]); |
---|
89 |
findelem(fem_grid_struct,[x2 y2])])) |
---|
90 |
vizicq4_guts('Error',['Both end-points are outsize of domain.' ... |
---|
91 |
' Try again.']) |
---|
92 |
setptr(VIZICQ4_Figure,'arrow') |
---|
93 |
return |
---|
94 |
end |
---|
95 |
% Draw line for transect position |
---|
96 |
line([x1 x2],[y1 y2],'Tag','VIZICQ4_Transect_Line') |
---|
97 |
set(VIZICQ4_Slice_X1,'String',x1,'Enable','on') |
---|
98 |
set(VIZICQ4_Slice_X2,'String',x2,'Enable','on') |
---|
99 |
set(VIZICQ4_Slice_Y1,'String',y1,'Enable','on') |
---|
100 |
set(VIZICQ4_Slice_Y2,'String',y2,'Enable','on') |
---|
101 |
set(VIZICQ4_Slice_DL,'Enable','on') |
---|
102 |
|
---|
103 |
case 'MakeVSlice' |
---|
104 |
|
---|
105 |
% Determine which component of the .icq4 has been selected. |
---|
106 |
state=get(VIZICQ4_icq4_select_button,'Value'); |
---|
107 |
field=[]; |
---|
108 |
for i=1:length(state) |
---|
109 |
if state{i}==1 |
---|
110 |
field=get(VIZICQ4_icq4_select_button(i),'String'); |
---|
111 |
break |
---|
112 |
end |
---|
113 |
end |
---|
114 |
if isempty(field) |
---|
115 |
vizicq4_guts('Error','No Icq4 Var selected.'); |
---|
116 |
break |
---|
117 |
end |
---|
118 |
vizicq4_guts('Error',['']); |
---|
119 |
|
---|
120 |
fem_icq4_struct=get(VIZICQ4_Slice_Axes,'UserData'); |
---|
121 |
eval(['scalar=fem_icq4_struct.' eval('field') ';']) |
---|
122 |
|
---|
123 |
fem_grid_struct=get(VIZICQ4_Grid_Axes,'UserData'); |
---|
124 |
|
---|
125 |
% Get transect endpoints |
---|
126 |
x1=get(VIZICQ4_Slice_X1,'String'); |
---|
127 |
if (isempty(x1) | strcmp(x1,'<>')) |
---|
128 |
vizicq4_guts('Error',['No Transect Coords. Defined']); |
---|
129 |
setptr(VIZICQ4_Figure,'arrow') |
---|
130 |
break |
---|
131 |
end |
---|
132 |
x1=eval(x1); |
---|
133 |
x2=eval(get(VIZICQ4_Slice_X2,'String')); |
---|
134 |
y1=eval(get(VIZICQ4_Slice_Y1,'String')); |
---|
135 |
y2=eval(get(VIZICQ4_Slice_Y2,'String')); |
---|
136 |
dl=eval(get(VIZICQ4_Slice_DL,'String')); |
---|
137 |
nc=eval(get(VIZICQ4_Slice_NC,'String')); |
---|
138 |
|
---|
139 |
R=searibbon2(fem_icq4_struct,fem_grid_struct,[x1 x2],[y1 y2],dl); |
---|
140 |
|
---|
141 |
% move grid axes off-screen, slice axes on screen |
---|
142 |
invisaxstdpos=get(VIZICQ4_LabCont,'UserData'); |
---|
143 |
axstdpos=get(VIZICQ4_DelCont,'UserData'); |
---|
144 |
set(VIZICQ4_Grid_Axes,'Position',invisaxstdpos) |
---|
145 |
set(VIZICQ4_Slice_Axes,'Position',axstdpos) |
---|
146 |
set(VIZICQ4_Grid_Axes,'Visible','off') |
---|
147 |
set(VIZICQ4_Slice_Axes,'Visible','on') |
---|
148 |
axes(VIZICQ4_Slice_Axes) |
---|
149 |
|
---|
150 |
hold on |
---|
151 |
eval(['scalar=R.' eval('field') ';']) |
---|
152 |
h=surf(R.x,R.y,R.ZMID,scalar); |
---|
153 |
colormap(jet(nc)) |
---|
154 |
set(h,'Tag','VIZICQ4_Ribbon_VSlice') |
---|
155 |
|
---|
156 |
% Compute some rotated velocity information |
---|
157 |
%%%%%%%%%%%%%% ROTATE VELOCITY INTO TRANSECT PLANE %%%%%%%%%%%%%%%%% |
---|
158 |
ind=find(~isnan(R.UZMID(:,1))); |
---|
159 |
ind1=find(~isnan(R.UZMID(:))); |
---|
160 |
if (abs(x2-x1)<1e-7) % x-cut basically vertical (constant x) |
---|
161 |
tgv=pi/2; |
---|
162 |
else |
---|
163 |
tgv=atan((y2-y1)/(x2-x1)); |
---|
164 |
end |
---|
165 |
u=R.UZMID(ind,:); |
---|
166 |
v=R.VZMID(ind,:); |
---|
167 |
[u,v]=rot(u,v,tgv); |
---|
168 |
xx=R.x(:);yy=R.y(:);zz=R.ZMID(ind1); |
---|
169 |
uu=R.UZMID(ind,:);uu=uu(:); |
---|
170 |
vv=R.VZMID(ind,:);vv=vv(:); |
---|
171 |
ww=R.WZMID(ind,:);ww=ww(:); |
---|
172 |
|
---|
173 |
if (get(VIZICQ4_Slice_VVectors,'Value')) |
---|
174 |
hvec=quiver3(xx,yy,zz,uu,vv,ww,2); |
---|
175 |
set(hvec,'Tag','VIZICQ4_Vectors','Color','k') |
---|
176 |
end |
---|
177 |
% Also display transect in a new figure, dist vs. depth |
---|
178 |
figure |
---|
179 |
set(gcf,'Name','VIZICQ4 - Slice') |
---|
180 |
|
---|
181 |
% U POSITIVE TO RIGHT OF TRANSECT DIRECTION (OUT OF SCREEN) |
---|
182 |
% V POSITIVE ALONG TRANSECT |
---|
183 |
pcolor(R.d(ind,:),R.ZMID(ind,:),reshape(u,size(R.ZMID(ind,:)))) |
---|
184 |
xlabel('Distance along transect (meters)') |
---|
185 |
ylabel('Depth (meters)') |
---|
186 |
shading interp |
---|
187 |
hcb=colorbar; |
---|
188 |
curax=gca; |
---|
189 |
axes(hcb) |
---|
190 |
ylabel('Through-Transect Velocity (m/sec)') |
---|
191 |
axes(curax) |
---|
192 |
ind1=find(~isnan(R.UZMID(:))); |
---|
193 |
hvec=vecplotstick(R.d(ind1),R.ZMID(ind1),v,R.WZMID(ind1),.5,'k',10,'m/s'); |
---|
194 |
title('Transect ') |
---|
195 |
line(R.d(:,1),R.ZMID(:,1),'Color','k','LineStyle','-','linewidth',2) |
---|
196 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
197 |
hold on |
---|
198 |
[c,h]=contour(R.d(ind,:),R.ZMID(ind,:),R.TMPMID(ind,:),[5:.5:15],'y'); |
---|
199 |
if ~isempty(h) |
---|
200 |
ht=clabel(c,h); |
---|
201 |
set(ht,'FontSize',15,'FontWeight','bold') |
---|
202 |
set(h,'linewidth',2) |
---|
203 |
end |
---|
204 |
[c,h]=contour(R.d(ind,:),R.ZMID(ind,:),R.SALMID(ind,:),[20:.5:40],'w'); |
---|
205 |
if ~isempty(h) |
---|
206 |
ht=clabel(c,h); |
---|
207 |
set(ht,'FontSize',15,'FontWeight','bold') |
---|
208 |
set(h,'linewidth',2) |
---|
209 |
end |
---|
210 |
% Add KILL button |
---|
211 |
uicontrol(gcf,'Style','push',... |
---|
212 |
'Units','normalized',... |
---|
213 |
'Position',[.9 0 .1 .1],'String','KILL','CallBack','close(gcf)'); |
---|
214 |
drawnow |
---|
215 |
|
---|
216 |
case 'MakeHSlice' |
---|
217 |
% Determine which component of the .icq4 has been selected. |
---|
218 |
state=get(VIZICQ4_icq4_select_button,'Value'); |
---|
219 |
field=[]; |
---|
220 |
for i=1:length(state) |
---|
221 |
if state{i}==1 |
---|
222 |
field=get(VIZICQ4_icq4_select_button(i),'String'); |
---|
223 |
break |
---|
224 |
end |
---|
225 |
end |
---|
226 |
if isempty(field) |
---|
227 |
vizicq4_guts('Error','No Icq4 Var selected.'); |
---|
228 |
break |
---|
229 |
end |
---|
230 |
vizicq4_guts('Error',['']); |
---|
231 |
|
---|
232 |
fem_icq4_struct=get(VIZICQ4_Slice_Axes,'UserData'); |
---|
233 |
eval(['scalar=fem_icq4_struct.' eval('field') ';']) |
---|
234 |
fem_grid_struct=get(VIZICQ4_Grid_Axes,'UserData'); |
---|
235 |
|
---|
236 |
% Loop over depth vector zval |
---|
237 |
% Get slice depth |
---|
238 |
zval=get(VIZICQ4_Slice_Z,'String'); |
---|
239 |
if isempty(zval)| strcmp(zval,'<>') |
---|
240 |
vizicq4_guts('Error','No depth values specified.') |
---|
241 |
setptr(VIZICQ4_Figure,'arrow') |
---|
242 |
return |
---|
243 |
end |
---|
244 |
zval=eval(zval); |
---|
245 |
|
---|
246 |
% Make sure zval between zmax,zmin |
---|
247 |
maxz=max(max(fem_icq4_struct.ZMID)); |
---|
248 |
minz=min(min(fem_icq4_struct.ZMID)); |
---|
249 |
if zval<minz | zval>maxz |
---|
250 |
str=['Zval of ' num2str(zval) ' not within' ... |
---|
251 |
' Depth Range; [' num2str(minz) ',' num2str(maxz) ']']; |
---|
252 |
vizicq4_guts('Error',str) |
---|
253 |
setptr(VIZICQ4_Figure,'arrow') |
---|
254 |
return |
---|
255 |
end |
---|
256 |
|
---|
257 |
qlev=horzslicefem(fem_icq4_struct.ZMID,scalar,zval); |
---|
258 |
qlevu=horzslicefem(fem_icq4_struct.ZMID,fem_icq4_struct.UZMID,zval); |
---|
259 |
qlevv=horzslicefem(fem_icq4_struct.ZMID,fem_icq4_struct.VZMID,zval); |
---|
260 |
qlevw=horzslicefem(fem_icq4_struct.ZMID,fem_icq4_struct.WZMID,zval); |
---|
261 |
|
---|
262 |
% move grid axes off-screen, slice axes on screen |
---|
263 |
invisaxstdpos=get(VIZICQ4_LabCont,'UserData'); |
---|
264 |
axstdpos=get(VIZICQ4_DelCont,'UserData'); |
---|
265 |
set(VIZICQ4_Grid_Axes,'Position',invisaxstdpos) |
---|
266 |
set(VIZICQ4_Slice_Axes,'Position',axstdpos) |
---|
267 |
set(VIZICQ4_Grid_Axes,'Visible','off') |
---|
268 |
set(VIZICQ4_Slice_Axes,'Visible','on') |
---|
269 |
axes(VIZICQ4_Slice_Axes) |
---|
270 |
|
---|
271 |
nc=eval(get(VIZICQ4_Slice_NC,'String')); |
---|
272 |
colormap(jet(nc)) |
---|
273 |
hp=colormesh2d(fem_grid_struct,qlev,nc); |
---|
274 |
set(hp,'ZData',zval*ones(size(get(hp,'XData')))); |
---|
275 |
set(hp,'Tag','VIZICQ4_Ribbon_HSlice') |
---|
276 |
if (get(VIZICQ4_Slice_HVectors,'Value')) |
---|
277 |
hold on |
---|
278 |
hvec3=quiver3(fem_grid_struct.x,... |
---|
279 |
fem_grid_struct.y,... |
---|
280 |
zval*ones(size(fem_grid_struct.x)),... |
---|
281 |
qlevu,qlevv,qlevw); |
---|
282 |
hold off |
---|
283 |
set(hvec3,'Color','k','Tag','VIZICQ4_Vectors') |
---|
284 |
end |
---|
285 |
|
---|
286 |
case 'Rotate_Toggle' |
---|
287 |
state=get(VIZICQ4_Rotation,'String'); |
---|
288 |
if strcmp(state,'Rotate On') |
---|
289 |
% move axes off-screen |
---|
290 |
invisaxstdpos=get(VIZICQ4_LabCont,'UserData'); |
---|
291 |
axstdpos=get(VIZICQ4_DelCont,'UserData'); |
---|
292 |
set(VIZICQ4_Grid_Axes,'Position',invisaxstdpos) |
---|
293 |
set(VIZICQ4_Slice_Axes,'Position',axstdpos) |
---|
294 |
set(VIZICQ4_Grid_Axes,'Visible','off') |
---|
295 |
set(VIZICQ4_Slice_Axes,'Visible','on') |
---|
296 |
set(VIZICQ4_Slicer_Rotation,'String','Rotate Off') |
---|
297 |
set(VIZICQ4_Slicer_Rotation,'ToolTipString','Activate 3-D Rotation') |
---|
298 |
axes(VIZICQ4_Slice_Axes) |
---|
299 |
rotate3d on |
---|
300 |
else |
---|
301 |
set(VIZICQ4_Slicer_Rotation,'ToolTipString','Deactivate 3-D Rotation') |
---|
302 |
set(VIZICQ4_Slicer_Rotation,'String','Rotate On') |
---|
303 |
axes(VIZICQ4_Slice_Axes) |
---|
304 |
rotate3d off |
---|
305 |
end |
---|
306 |
|
---|
307 |
case 'Reset_View' |
---|
308 |
axes(VIZICQ4_Grid_Axes);view(2) |
---|
309 |
axes(VIZICQ4_Slice_Axes);view(2) |
---|
310 |
|
---|
311 |
case 'Shading' |
---|
312 |
% move axes off-screen |
---|
313 |
invisaxstdpos=get(VIZICQ4_LabCont,'UserData'); |
---|
314 |
axstdpos=get(VIZICQ4_DelCont,'UserData'); |
---|
315 |
set(VIZICQ4_Grid_Axes,'Position',invisaxstdpos) |
---|
316 |
set(VIZICQ4_Slice_Axes,'Position',axstdpos) |
---|
317 |
set(VIZICQ4_Grid_Axes,'Visible','off') |
---|
318 |
set(VIZICQ4_Slice_Axes,'Visible','on') |
---|
319 |
axes(VIZICQ4_Slice_Axes) |
---|
320 |
switch option |
---|
321 |
case 'Flat' |
---|
322 |
shading flat |
---|
323 |
set(VIZICQ4_Slicer_Shading_Faceted,'Value',0) |
---|
324 |
set(VIZICQ4_Slicer_Shading_Interp,'Value',0) |
---|
325 |
case 'Interp' |
---|
326 |
shading interp |
---|
327 |
set(VIZICQ4_Slicer_Shading_Faceted,'Value',0) |
---|
328 |
set(VIZICQ4_Slicer_Shading_Flat,'Value',0) |
---|
329 |
case 'Faceted' |
---|
330 |
shading faceted |
---|
331 |
set(VIZICQ4_Slicer_Shading_Interp,'Value',0) |
---|
332 |
set(VIZICQ4_Slicer_Shading_Flat,'Value',0) |
---|
333 |
end |
---|
334 |
|
---|
335 |
case 'Pop' |
---|
336 |
% Toggle the visibility of the slicer popup figure |
---|
337 |
% Get current visibility state. |
---|
338 |
state=get(VIZICQ4_Slicer_Fig,'Visible'); |
---|
339 |
if strcmp(state,'on') |
---|
340 |
set(VIZICQ4_Slicer_Fig,'Visible','off'); |
---|
341 |
else |
---|
342 |
set(VIZICQ4_Slicer_Fig,'Visible','on'); |
---|
343 |
end |
---|
344 |
|
---|
345 |
case 'Colorbar' |
---|
346 |
delete(VIZICQ4_Colorbar_Axes) |
---|
347 |
h=axes('Parent',VIZICQ4_Figure,... |
---|
348 |
'Units','normalized',... |
---|
349 |
'Position',[.825 .15 .15 .025],... |
---|
350 |
'Tag','VIZICQ4_Colorbar_Axes'); |
---|
351 |
|
---|
352 |
axes(VIZICQ4_Slice_Axes) |
---|
353 |
colorbar(h) |
---|
354 |
set(h,'Tag','VIZICQ4_Colorbar_Axes') |
---|
355 |
|
---|
356 |
case 'DelSlice' |
---|
357 |
VIZICQ4_Slice=findobj(VIZICQ4_Slice_Axes,'Tag','VIZICQ4_Ribbon_HSlice'); |
---|
358 |
VIZICQ4_Slice=[VIZICQ4_Slice;findobj(VIZICQ4_Slice_Axes,'Tag','VIZICQ4_Ribbon_VSlice')]; |
---|
359 |
if isempty(VIZICQ4_Slice) |
---|
360 |
vizicq4_guts('Info','No Slices to Delete'); |
---|
361 |
else |
---|
362 |
set(VIZICQ4_Rotation,'ToolTipString','Deactivate 3-D Rotation') |
---|
363 |
set(VIZICQ4_Rotation,'String','Rotate On') |
---|
364 |
rotate3d off |
---|
365 |
switch option |
---|
366 |
case 'one' |
---|
367 |
vizicq4_guts('Info','Click on Slice to Delete'); |
---|
368 |
waitforbuttonpress; |
---|
369 |
target=get(gco,'Tag'); |
---|
370 |
if strcmp(target,'VIZICQ4_Ribbon_HSlice') | strcmp(target,'VIZICQ4_Ribbon_VSlice') |
---|
371 |
delete(gco) |
---|
372 |
else |
---|
373 |
vizicq4_guts('Info','Target NOT a VIZICQ4_Ribbon_{H|V}Slice'); |
---|
374 |
end |
---|
375 |
case 'all' |
---|
376 |
delete(VIZICQ4_Slice) |
---|
377 |
end |
---|
378 |
end |
---|
379 |
case 'Close' |
---|
380 |
set(VIZICQ4_Slicer_Fig','Visible','off') |
---|
381 |
|
---|
382 |
case 'Help' |
---|
383 |
disp('Help on Slicer not yet available') |
---|
384 |
|
---|
385 |
otherwise |
---|
386 |
disp('Argument fallthrough in vizicq4_slicer') |
---|
387 |
end |
---|
388 |
setptr(VIZICQ4_Figure,'arrow') |
---|