Skip to content

Commit 47cf582

Browse files
committed
Working with pre/post 8.4 animated lines.
1 parent 5fc4084 commit 47cf582

File tree

8 files changed

+1406
-931
lines changed

8 files changed

+1406
-931
lines changed

crplot.m

+173-115
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
% H = CRPLOT(...) returns a vector of handles to all the curves drawn
1818
% in the interior of the polygon. [H,R,THETA] = CRPLOT(...) also
1919
% returns the moduli and arguments of the curves comprising the grid.
20-
%
20+
%
2121
% See also SCPLTOPT, CRPARAM, CRFIXWC, CRMAP.
2222

2323
% Copyright 1998 by Toby Driscoll.
@@ -30,31 +30,31 @@
3030

3131
% Parse input
3232
if nargin < 9
33-
options = [];
34-
if nargin < 8
35-
theta = [];
36-
if nargin < 7
37-
R = [];
33+
options = [];
34+
if nargin < 8
35+
theta = [];
36+
if nargin < 7
37+
R = [];
38+
end
3839
end
39-
end
4040
end
4141

4242
% Empty arguments default to 10
4343
if isempty([R(:);theta(:)])
44-
R = 10;
45-
theta = 10;
44+
R = 10;
45+
theta = 10;
4646
end
4747

4848
% Integer arguments must be converted to specific values
4949
if (length(R)==1) && (R == round(R))
50-
m = R+2;
51-
R = linspace(0,1,m);
52-
R([1,m]) = [];
50+
m = R+2;
51+
R = linspace(0,1,m);
52+
R([1,m]) = [];
5353
end
5454
if (length(theta)==1) && (theta == round(theta))
55-
m = theta+1;
56-
theta = linspace(0,2*pi,m);
57-
theta(m) = [];
55+
m = theta+1;
56+
theta = linspace(0,2*pi,m);
57+
theta(m) = [];
5858
end
5959

6060
% Prepare figure
@@ -63,14 +63,14 @@
6363

6464
% If figure has two tagged axes, draw in both
6565
ax = [findobj(fig,'tag','PhysicalAxes');...
66-
findobj(fig,'tag','CanonicalAxes')];
66+
findobj(fig,'tag','CanonicalAxes')];
6767
if length(ax)==2
68-
draw2 = true;
69-
vis = get(ax,'vis');
68+
draw2 = true;
69+
vis = get(ax,'vis');
7070
else
71-
draw2 = false;
72-
ax = gca;
73-
vis = {'on'};
71+
draw2 = false;
72+
ax = gca;
73+
vis = {'on'};
7474
end
7575

7676
% Prepare axes
@@ -95,117 +95,175 @@
9595
% Plot circles...
9696
linh = gobjects(length(R),2);
9797
for j = 1:length(R)
98-
% Start with evenly spaced theta
99-
tp = linspace(0,2*pi,20)';
100-
new = true(length(tp),1);
101-
wp = NaN*new;
102-
103-
% The individual points will be shown as they are found
104-
linh(j,1) = animatedline('parent',ax(1),'color',color,'vis',vis{1},...
105-
'linestyle','none','marker','.','markersize',7);
106-
if draw2
107-
linh(j,2) = animatedline('parent',ax(2),'color',color,'vis',vis{2},...
108-
'linestyle','none','marker','.','markersize',7);
109-
end
110-
111-
% Adaptively refine theta to get smooth curve
112-
iter = 0;
113-
while (any(new)) && (iter < maxrefn)
114-
drawnow
115-
neww = crmap(R(j)*exp(1i*tp(new)),w,beta,cr,aff,wcfix,Q,qdat);
116-
wp(new) = neww;
117-
iter = iter + 1;
118-
119-
% Update the points to show progress
120-
addpoints(linh(j,1),real(wp(new)),imag(wp(new)))
121-
if draw2
122-
addpoints(linh(j,2),R(j)*cos(tp(new)),R(j)*sin(tp(new)))
98+
% Start with evenly spaced theta
99+
tp = linspace(0,2*pi,20)';
100+
new = true(length(tp),1);
101+
wp = NaN*new;
102+
103+
% The individual points will be shown as they are found
104+
if verLessThan('matlab','8.4')
105+
106+
% The individual points will be shown as they are found
107+
linh(j,1) = line(NaN,NaN,'parent',ax(1),'color',color,'vis',vis{1},...
108+
'linestyle','none','marker','.','markersize',7,'erasemode','none');
109+
if draw2
110+
linh(j,2) = line(NaN,NaN,'parent',ax(2),'color',color,'vis',vis{2},...
111+
'linestyle','none','marker','.','markersize',7,'erasemode','none');
112+
end
113+
114+
else
115+
linh(j,1) = animatedline('parent',ax(1),'color',color,'vis',vis{1},...
116+
'linestyle','none','marker','.','markersize',7);
117+
if draw2
118+
linh(j,2) = animatedline('parent',ax(2),'color',color,'vis',vis{2},...
119+
'linestyle','none','marker','.','markersize',7);
120+
end
123121
end
124-
drawnow update
125122

126-
% Add points to zp where necessary to make smooth curves
127-
[tp,wp,new] = scpadapt(tp,wp,minlen,maxlen,axlim);
128-
end
129-
% Set the lines to be solid
130-
% To ensure smooth closure, we erase and redraw all the points
131-
% in order.
132-
clearpoints(linh(j,1))
133-
addpoints(linh(j,1),real(wp),imag(wp));
134-
set(linh(j,1),'marker','none','linestyle','-','user',R(j)*exp(1i*tp))
135-
if draw2
136-
% Replace the points with (hopefully) a smooth circle
137-
tp = linspace(0,2*pi,361);
138-
clearpoints(linh(j,2))
139-
addpoints(linh(j,2),R(j)*cos(tp),R(j)*sin(tp));
140-
set(linh(j,2),'marker','none','linestyle','-')
141-
end
142-
drawnow
123+
% Adaptively refine theta to get smooth curve
124+
iter = 0;
125+
while (any(new)) && (iter < maxrefn)
126+
drawnow
127+
neww = crmap(R(j)*exp(1i*tp(new)),w,beta,cr,aff,wcfix,Q,qdat);
128+
wp(new) = neww;
129+
iter = iter + 1;
130+
131+
% Update the points to show progress
132+
if verLessThan('matlab','8.4')
133+
set(linh(j,1),'xdata',real(wp),'ydata',imag(wp))
134+
if draw2
135+
set(linh(j,2),'xdata',R(j)*cos(tp),'ydata',R(j)*sin(tp))
136+
end
137+
else
138+
addpoints(linh(j,1),real(wp(new)),imag(wp(new)))
139+
if draw2
140+
addpoints(linh(j,1),R(j)*cos(tp(new)),R(j)*sin(tp(new)))
141+
end
142+
end
143+
drawnow
144+
145+
% Add points to zp where necessary to make smooth curves
146+
[tp,wp,new] = scpadapt(tp,wp,minlen,maxlen,axlim);
147+
end
148+
% Set the lines to be solid
149+
if verLessThan('matlab','8.4')
150+
set(linh(j,1),'erasemode','back')
151+
set(linh(j,1),'marker','none','linestyle','-','user',R(j)*exp(1i*tp))
152+
if draw2
153+
% Replace the points with (hopefully) a smooth circle
154+
tp = linspace(0,2*pi,101);
155+
set(linh(j,2),'erasemode','back')
156+
set(linh(j,2),'marker','none','linestyle','-',...
157+
'xdata',R(j)*cos(tp),'ydata',R(j)*sin(tp))
158+
end
159+
160+
else
161+
162+
clearpoints(linh(j,1))
163+
addpoints(linh(j,1),real(wp),imag(wp));
164+
set(linh(j,1),'marker','none','linestyle','-','user',R(j)*exp(1i*tp))
165+
if draw2
166+
% Replace the points with (hopefully) a smooth circle
167+
tp = linspace(0,2*pi,361);
168+
clearpoints(linh(j,2))
169+
addpoints(linh(j,2),R(j)*cos(tp),R(j)*sin(tp))
170+
set(linh(j,2),'marker','none','linestyle','-')
171+
end
172+
end
173+
drawnow
143174
end
144175

145176
% Plot radii...
146177
linh1 = linh;
147178
linh = gobjects(length(theta),2);
148179
for j = 1:length(theta)
149-
% Start with evenly spaced radii
150-
Rp = linspace(0,1,12)';
151-
Rp = [Rp(1:11);.95;.98;Rp(12)];
152-
zp = Rp*exp(1i*theta(j));
153-
new = true(length(zp),1);
154-
wp = NaN*new;
155-
156-
% The individual points will be shown as they are found
157-
linh(j,1) = animatedline('parent',ax(1),'color',color,'vis',vis{1},...
158-
'linestyle','none','marker','.','markersize',7);
159-
if draw2
160-
linh(j,2) = animatedline('parent',ax(2),'color',color,'vis',vis{2},...
161-
'linestyle','none','marker','.','markersize',7);
162-
end
163-
164-
% Adaptively refine to make smooth curves
165-
iter = 0;
166-
while (any(new)) && (iter < maxrefn)
167-
drawnow
168-
neww = crmap(zp(new),w,beta,cr,aff,wcfix,Q,qdat);
169-
wp(new) = neww;
170-
iter = iter + 1;
171-
172-
% Update the points to show progress
173-
addpoints(linh(j,1),real(wp(new)),imag(wp(new)))
174-
if draw2
175-
addpoints(linh(j,1),real(zp(new)),imag(zp(new)))
180+
% Start with evenly spaced radii
181+
Rp = linspace(0,1,12)';
182+
Rp = [Rp(1:11);.95;.98;Rp(12)];
183+
zp = Rp*exp(1i*theta(j));
184+
new = true(length(zp),1);
185+
wp = NaN*new;
186+
187+
% The individual points will be shown as they are found
188+
if verLessThan('matlab','8.4')
189+
linh(j,1) = line(NaN,NaN,'parent',ax(1),'color',color,'vis',vis{1},...
190+
'linestyle','none','marker','.','markersize',7,'erasemode','none');
191+
if draw2
192+
linh(j,2) = line(NaN,NaN,'parent',ax(2),'color',color,'vis',vis{2},...
193+
'linestyle','none','marker','.','markersize',7,'erasemode','none');
194+
end
195+
else
196+
linh(j,1) = animatedline('parent',ax(1),'color',color,'vis',vis{1},...
197+
'linestyle','none','marker','.','markersize',7);
198+
if draw2
199+
linh(j,2) = animatedline('parent',ax(2),'color',color,'vis',vis{2},...
200+
'linestyle','none','marker','.','markersize',7);
201+
end
176202
end
177-
drawnow update
178203

179-
% Add points to zp where necessary to make smooth curves
180-
[zp,wp,new] = scpadapt(zp,wp,minlen,maxlen,axlim);
181-
end
182-
% Set the lines to be solid
183-
clearpoints(linh(j,1))
184-
addpoints(linh(j,1),real(wp),imag(wp));
185-
set(linh(j,1),'marker','none','linestyle','-','user',zp)
186-
if draw2
187-
% Replace the points with just the ends
188-
clearpoints(linh(j,2))
189-
addpoints(linh(j,2),[0 1]*cos(theta(j)),[0 1]*sin(theta(j)))
190-
set(linh(j,2),'marker','none','linestyle','-')
191-
end
192-
drawnow
204+
% Adaptively refine to make smooth curves
205+
iter = 0;
206+
while (any(new)) && (iter < maxrefn)
207+
drawnow
208+
neww = crmap(zp(new),w,beta,cr,aff,wcfix,Q,qdat);
209+
wp(new) = neww;
210+
iter = iter + 1;
211+
212+
% Update the points to show progress
213+
if verLessThan('matlab','8.4')
214+
set(linh(j,1),'xdata',real(wp),'ydata',imag(wp))
215+
if draw2
216+
set(linh(j,2),'xdata',real(zp),'ydata',imag(zp))
217+
end
218+
else
219+
addpoints(linh(j,1),real(wp(new)),imag(wp(new)))
220+
if draw2
221+
addpoints(linh(j,1),real(zp(new)),imag(zp(new)))
222+
end
223+
end
224+
225+
% Add points to zp where necessary to make smooth curves
226+
[zp,wp,new] = scpadapt(zp,wp,minlen,maxlen,axlim);
227+
end
228+
% Set the lines to be solid
229+
if verLessThan('matlab','8.4')
230+
set(linh(j,1),'erasemode','back')
231+
set(linh(j,1),'marker','none','linestyle','-','user',zp)
232+
if draw2
233+
% Replace the points with just the ends
234+
set(linh(j,2),'erasemode','back')
235+
set(linh(j,2),'marker','none','linestyle','-',...
236+
'xdata',[0 1]*cos(theta(j)),'ydata',[0 1]*sin(theta(j)))
237+
end
238+
else
239+
clearpoints(linh(j,1))
240+
addpoints(linh(j,1),real(wp),imag(wp));
241+
set(linh(j,1),'marker','none','linestyle','-','user',zp)
242+
if draw2
243+
% Replace the points with just the ends
244+
clearpoints(linh(j,2))
245+
addpoints(linh(j,2),[0 1]*cos(theta(j)),[0 1]*sin(theta(j)))
246+
set(linh(j,2),'marker','none','linestyle','-')
247+
end
248+
end
249+
drawnow
193250
end
194251

195252
linh = [linh1;linh];
196253
if ~draw2
197-
linh = linh(:,1);
254+
linh = linh(:,1);
198255
end
199256

200-
refresh
257+
if verLessThan('matlab','8.4'), set(linh,'erasemode','normal'),end
258+
drawnow
201259

202260
if turn_off_hold, hold off, end;
203261
if nargout > 0
204-
H = linh;
205-
if nargout > 1
206-
R2 = R;
207-
if nargout > 2
208-
THETA = theta;
262+
H = linh;
263+
if nargout > 1
264+
R2 = R;
265+
if nargout > 2
266+
THETA = theta;
267+
end
209268
end
210-
end
211-
end
269+
end

0 commit comments

Comments
 (0)