wolffd@0
|
1 function vis_trajgui(trajStruct,arg)
|
wolffd@0
|
2
|
wolffd@0
|
3 % VIS_TRAJGUI subfuntion for SOM_TRAJECTORY
|
wolffd@0
|
4 %
|
wolffd@0
|
5 % This function is the actual GUI called by SOM_TRAJECTORY
|
wolffd@0
|
6 % function.
|
wolffd@0
|
7 %
|
wolffd@0
|
8 % See also SOM_TRAJECTORY.
|
wolffd@0
|
9
|
wolffd@0
|
10 % Contributed code to SOM Toolbox 2.0, February 11th, 2000 by Juha Parhankangas
|
wolffd@0
|
11 % Copyright (c) by Juha Parhankangas.
|
wolffd@0
|
12 % http://www.cis.hut.fi/projects/somtoolbox/
|
wolffd@0
|
13
|
wolffd@0
|
14 % Version 2.0beta juha 180699
|
wolffd@0
|
15
|
wolffd@0
|
16 if nargin == 1
|
wolffd@0
|
17
|
wolffd@0
|
18 sM_h=trajStruct.figure;
|
wolffd@0
|
19
|
wolffd@0
|
20 if size(trajStruct.bmus,1) ~= 1 & size(trajStruct.bmus,2) ~= 1
|
wolffd@0
|
21 fuzzy_traj(trajStruct,[]);
|
wolffd@0
|
22 return;
|
wolffd@0
|
23 end
|
wolffd@0
|
24
|
wolffd@0
|
25
|
wolffd@0
|
26 if size(trajStruct.bmus,1) == 1 | size(trajStruct.bmus,2) == 1
|
wolffd@0
|
27
|
wolffd@0
|
28 udata.bmus = trajStruct.bmus;
|
wolffd@0
|
29 udata.a_h=[findobj(get(sM_h,'Children'),'Tag','Uplane');...
|
wolffd@0
|
30 findobj(get(sM_h,'Children'),'Tag','Cplane')];
|
wolffd@0
|
31 udata.sM_h=trajStruct.figure;
|
wolffd@0
|
32 udata.traj=[];
|
wolffd@0
|
33 data1 = trajStruct.primary_data;
|
wolffd@0
|
34 if ~isempty(trajStruct.primary_names)
|
wolffd@0
|
35 names=trajStruct.primary_names;
|
wolffd@0
|
36 else
|
wolffd@0
|
37 for i=1:size(data1,2)
|
wolffd@0
|
38 names{i,1}=sprintf('Var%d',i);
|
wolffd@0
|
39 end
|
wolffd@0
|
40 end
|
wolffd@0
|
41
|
wolffd@0
|
42 udata.lattice=trajStruct.lattice;
|
wolffd@0
|
43 form = 0.7*vis_patch(udata.lattice);
|
wolffd@0
|
44 udata.msize = trajStruct.msize;
|
wolffd@0
|
45
|
wolffd@0
|
46
|
wolffd@0
|
47 %%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
48 %
|
wolffd@0
|
49 % forming a patch object, which is placed above every component plane
|
wolffd@0
|
50 %
|
wolffd@0
|
51
|
wolffd@0
|
52
|
wolffd@0
|
53 l = size(form,1);
|
wolffd@0
|
54
|
wolffd@0
|
55 nx = repmat(form(:,1),1,prod(udata.msize));
|
wolffd@0
|
56 ny = repmat(form(:,2),1,prod(udata.msize));
|
wolffd@0
|
57
|
wolffd@0
|
58 x=reshape(repmat(1:udata.msize(2),l*udata.msize(1),1),l,prod(udata.msize));
|
wolffd@0
|
59 y=repmat(repmat(1:udata.msize(1),l,1),1,udata.msize(2));
|
wolffd@0
|
60
|
wolffd@0
|
61 if strcmp(udata.lattice,'hexa')
|
wolffd@0
|
62 t = find(~rem(y(1,:),2));
|
wolffd@0
|
63 x(:,t)=x(:,t)+.5;
|
wolffd@0
|
64 end
|
wolffd@0
|
65 x=x+nx;
|
wolffd@0
|
66 y=y+ny;
|
wolffd@0
|
67
|
wolffd@0
|
68 colors=reshape(ones(prod(udata.msize),1)*[NaN NaN NaN],...
|
wolffd@0
|
69 [1 prod(udata.msize) 3]);
|
wolffd@0
|
70
|
wolffd@0
|
71 set(0,'CurrentFigure',udata.sM_h);
|
wolffd@0
|
72
|
wolffd@0
|
73 %%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
74 %
|
wolffd@0
|
75 % drawing patch
|
wolffd@0
|
76 %
|
wolffd@0
|
77 % caxis -commands keep the colormap of the original patch unchanged.
|
wolffd@0
|
78 %
|
wolffd@0
|
79
|
wolffd@0
|
80 for i=1:length(udata.a_h)
|
wolffd@0
|
81 udata.real_patch(i)=get(udata.a_h(i),'Children');
|
wolffd@0
|
82 set(udata.real_patch(i),'ButtonDownFcn',...
|
wolffd@0
|
83 'vis_trajgui([],''click'')');
|
wolffd@0
|
84 subplot(udata.a_h(i));
|
wolffd@0
|
85 v=caxis;
|
wolffd@0
|
86 udata.tmp_patch(i)=patch(x,y,colors,'EdgeColor','none',...
|
wolffd@0
|
87 'ButtonDownFcn',...
|
wolffd@0
|
88 'vis_trajgui([],''click'')',...
|
wolffd@0
|
89 'Tag','TmpPatch');
|
wolffd@0
|
90 caxis(v);
|
wolffd@0
|
91 end
|
wolffd@0
|
92
|
wolffd@0
|
93 %%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
94
|
wolffd@0
|
95
|
wolffd@0
|
96
|
wolffd@0
|
97 udata.length_of_traj=length(trajStruct.size);
|
wolffd@0
|
98 udata.size=trajStruct.size;
|
wolffd@0
|
99 udata.color=trajStruct.color;
|
wolffd@0
|
100 udata.poly.x=[];
|
wolffd@0
|
101 udata.poly.y=[];
|
wolffd@0
|
102 udata.poly.h=[];
|
wolffd@0
|
103 udata.new_marks=[];
|
wolffd@0
|
104 udata.all_marks=[];
|
wolffd@0
|
105 udata.d_mark2=[];
|
wolffd@0
|
106 udata.fig1 = figure;
|
wolffd@0
|
107 set(udata.fig1,'KeyPressFcn','vis_trajgui([],''key'')',...
|
wolffd@0
|
108 'Name','Primary Data');
|
wolffd@0
|
109
|
wolffd@0
|
110
|
wolffd@0
|
111 %%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
112 %
|
wolffd@0
|
113 % making the 'Tools' -menu
|
wolffd@0
|
114 %
|
wolffd@0
|
115
|
wolffd@0
|
116 udata.m_i=uimenu(udata.fig1,'Label','Trajectoy T&ools');
|
wolffd@0
|
117 udata.m_i(2)=uimenu(udata.m_i,'Label','&Remove Trajectory',...
|
wolffd@0
|
118 'Callback',...
|
wolffd@0
|
119 'vis_trajgui([],''remove_traj'')');
|
wolffd@0
|
120 udata.m_i(3)=uimenu(udata.m_i(1),'Label','&Dye Nodes',...
|
wolffd@0
|
121 'Callback',...
|
wolffd@0
|
122 'vis_trajgui([],''dye_gui'')');
|
wolffd@0
|
123 udata.m_i(4)=uimenu(udata.m_i(1),'Label','&Clear Markers',...
|
wolffd@0
|
124 'Callback',...
|
wolffd@0
|
125 'vis_trajgui([],''clear'')');
|
wolffd@0
|
126 udata.m_i(5)=uimenu(udata.m_i(1),'Label','&Save',...
|
wolffd@0
|
127 'Callback',...
|
wolffd@0
|
128 'vis_trajgui([],''save'')');
|
wolffd@0
|
129 udata.m_i(6)=uimenu(udata.m_i(1),'Label','&Load',...
|
wolffd@0
|
130 'Callback',...
|
wolffd@0
|
131 'vis_trajgui([],''load'')');
|
wolffd@0
|
132
|
wolffd@0
|
133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
134 %
|
wolffd@0
|
135 % drawing data components to the figure ....
|
wolffd@0
|
136 %
|
wolffd@0
|
137 %
|
wolffd@0
|
138
|
wolffd@0
|
139 if nargin < 5 | isempty(comps) | (isstr(comps) & strcmp(comps,'all'))
|
wolffd@0
|
140 comps = 1:size(data1,2);
|
wolffd@0
|
141 end
|
wolffd@0
|
142
|
wolffd@0
|
143 x=1:size(data1,1);
|
wolffd@0
|
144
|
wolffd@0
|
145 for i=1:length(comps)
|
wolffd@0
|
146 subplot(length(comps),1,i);
|
wolffd@0
|
147 udata.h(i)=gca;
|
wolffd@0
|
148 udata.d_mark(i).h=[];
|
wolffd@0
|
149
|
wolffd@0
|
150 udata.d(i)=plot(x,data1(:,comps(i)),...
|
wolffd@0
|
151 'ButtonDownFcn',...
|
wolffd@0
|
152 'vis_trajgui([],''line_down'')');
|
wolffd@0
|
153 set(gca,'XLim',[1 size(data1,1)],...
|
wolffd@0
|
154 'XTick',[],...
|
wolffd@0
|
155 'ButtonDownFcn','vis_trajgui([],''line_down'')'); %,...
|
wolffd@0
|
156 %'YLim',[min(data1(:,comps(i))) max(data1(:,comps(i)))]);
|
wolffd@0
|
157
|
wolffd@0
|
158 ylabel(names{comps(i)});
|
wolffd@0
|
159 hold on;
|
wolffd@0
|
160 ymin=get(udata.h(i),'YLim');
|
wolffd@0
|
161 pos=mean(get(udata.h(i),'XLim'));
|
wolffd@0
|
162 udata.l(i) = line([pos pos],[ymin(1) ymin(2)],...
|
wolffd@0
|
163 'Color','red',...
|
wolffd@0
|
164 'ButtonDownFcn',...
|
wolffd@0
|
165 'vis_trajgui([],''down'')');
|
wolffd@0
|
166 end
|
wolffd@0
|
167 udata.text1=[];
|
wolffd@0
|
168
|
wolffd@0
|
169 udata.fig2=[];
|
wolffd@0
|
170 udata.h2=[];
|
wolffd@0
|
171 udata.l2=[];
|
wolffd@0
|
172 udata.text2=[];
|
wolffd@0
|
173
|
wolffd@0
|
174 %%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
175 %
|
wolffd@0
|
176 % ... and to the figure 2.
|
wolffd@0
|
177 %
|
wolffd@0
|
178
|
wolffd@0
|
179
|
wolffd@0
|
180 if ~isempty(trajStruct.secondary_data)
|
wolffd@0
|
181 data2=trajStruct.secondary_data;
|
wolffd@0
|
182 if isempty(trajStruct.secondary_names)
|
wolffd@0
|
183 for i=1:size(data1,2)
|
wolffd@0
|
184 names2{i,1}=sprintf('Var%d',i);
|
wolffd@0
|
185 end
|
wolffd@0
|
186 else
|
wolffd@0
|
187 names2=trajStruct.secondary_names;
|
wolffd@0
|
188 end
|
wolffd@0
|
189
|
wolffd@0
|
190 udata.fig2 = figure;
|
wolffd@0
|
191 set(udata.fig2,'Name','Secondary Data');
|
wolffd@0
|
192 set(udata.fig2,'KeyPressFcn',...
|
wolffd@0
|
193 'vis_trajgui([],''key'')');
|
wolffd@0
|
194 for i=1:size(data2,2)
|
wolffd@0
|
195 subplot(size(data2,2),1,i);
|
wolffd@0
|
196 udata.h2(i) = gca;
|
wolffd@0
|
197 udata.d_mark2(i).h=[];
|
wolffd@0
|
198 udata.d2(i) = plot(x,data2(:,i),...
|
wolffd@0
|
199 'ButtonDownFcn',...
|
wolffd@0
|
200 'vis_trajgui([],''line_down'')');
|
wolffd@0
|
201 set(gca,'XLim',[1 size(data1,1)],'XTick',[],'ButtonDownFcn',...
|
wolffd@0
|
202 'vis_trajgui([],[],[],[],[],[],''line_down'')');
|
wolffd@0
|
203 ylabel(names2{i});
|
wolffd@0
|
204 hold on;
|
wolffd@0
|
205 ymin = get(udata.h2(i),'YLim');
|
wolffd@0
|
206 pos = mean(get(udata.h2(i),'XLim'));
|
wolffd@0
|
207 udata.l2(i) = line([pos pos],ymin,'Color','red',...
|
wolffd@0
|
208 'ButtonDownFcn','vis_trajgui([],''down'')');
|
wolffd@0
|
209 end
|
wolffd@0
|
210 end
|
wolffd@0
|
211
|
wolffd@0
|
212 %%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
213
|
wolffd@0
|
214 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
215 if ~isempty(udata.fig2);
|
wolffd@0
|
216 tmp.fig1=udata.fig1;
|
wolffd@0
|
217 set(udata.fig2,'UserData',tmp);
|
wolffd@0
|
218 end
|
wolffd@0
|
219 tmp=get(udata.sM_h,'UserData');
|
wolffd@0
|
220 tmp.fig1=udata.fig1;
|
wolffd@0
|
221 set(udata.sM_h,'UserData',tmp);
|
wolffd@0
|
222 set_numbers(round(pos));
|
wolffd@0
|
223 return;
|
wolffd@0
|
224 end
|
wolffd@0
|
225
|
wolffd@0
|
226 end
|
wolffd@0
|
227
|
wolffd@0
|
228 %%%%%%%%%%%%%%%%%
|
wolffd@0
|
229 %
|
wolffd@0
|
230 % if figures have been drawn, the only function calls that may exist
|
wolffd@0
|
231 % are the ones that change the state of the application.
|
wolffd@0
|
232 %
|
wolffd@0
|
233 udata=get(gcf,'UserData');
|
wolffd@0
|
234 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
235
|
wolffd@0
|
236 switch arg
|
wolffd@0
|
237 case 'fuzzy'
|
wolffd@0
|
238 fuzzy_traj(tS,[]);
|
wolffd@0
|
239 return;
|
wolffd@0
|
240 case 'move_fuzzy'
|
wolffd@0
|
241 fuzzy_traj([],'move');
|
wolffd@0
|
242 return;
|
wolffd@0
|
243 case 'remove_traj'
|
wolffd@0
|
244 remove_traj;
|
wolffd@0
|
245 return;
|
wolffd@0
|
246 case 'line_down'
|
wolffd@0
|
247 line_bdf('down');
|
wolffd@0
|
248 return;
|
wolffd@0
|
249 case 'line_drag'
|
wolffd@0
|
250 line_bdf('drag');
|
wolffd@0
|
251 return;
|
wolffd@0
|
252 case 'line_up'
|
wolffd@0
|
253 line_bdf('up');
|
wolffd@0
|
254 return;
|
wolffd@0
|
255 case 'dye_gui';
|
wolffd@0
|
256 color_gui(udata.fig1);
|
wolffd@0
|
257 return;
|
wolffd@0
|
258 case {'dye','cyan','magenta','yellow','red','green','blue','white','grey'}
|
wolffd@0
|
259 dye_nodes(arg);
|
wolffd@0
|
260 return;
|
wolffd@0
|
261 case 'clear'
|
wolffd@0
|
262 clear_markers;
|
wolffd@0
|
263 return;
|
wolffd@0
|
264 case 'key'
|
wolffd@0
|
265 key_bdf;
|
wolffd@0
|
266 return;
|
wolffd@0
|
267 case 'click'
|
wolffd@0
|
268 click;
|
wolffd@0
|
269 return;
|
wolffd@0
|
270 case 'save'
|
wolffd@0
|
271 save_data;
|
wolffd@0
|
272 return;
|
wolffd@0
|
273 case 'load'
|
wolffd@0
|
274 load_data;
|
wolffd@0
|
275 return;
|
wolffd@0
|
276 end
|
wolffd@0
|
277
|
wolffd@0
|
278
|
wolffd@0
|
279 %%%%%%%%%%
|
wolffd@0
|
280 %
|
wolffd@0
|
281 % lines in the data figure(s) are dragged ...
|
wolffd@0
|
282 %
|
wolffd@0
|
283
|
wolffd@0
|
284 udata=get(gcf,'UserData');
|
wolffd@0
|
285 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
286
|
wolffd@0
|
287
|
wolffd@0
|
288 lims=get(gca,'XLim');
|
wolffd@0
|
289 x = getfield(get(gca,'CurrentPoint'),{1}); % the location of the line
|
wolffd@0
|
290
|
wolffd@0
|
291 if x < lims(1)
|
wolffd@0
|
292 x=lims(1);
|
wolffd@0
|
293 elseif x > lims(2)
|
wolffd@0
|
294 x=lims(2);
|
wolffd@0
|
295 end
|
wolffd@0
|
296
|
wolffd@0
|
297 old = gcf;
|
wolffd@0
|
298
|
wolffd@0
|
299 switch arg
|
wolffd@0
|
300 case 'down',...
|
wolffd@0
|
301
|
wolffd@0
|
302 % mouse button is pressed down above the line
|
wolffd@0
|
303
|
wolffd@0
|
304 set(gcf,'WindowButtonMotionFcn','vis_trajgui([],''drag'')');
|
wolffd@0
|
305 set(gcf,'WindowButtonUpFcn','vis_trajgui([],''up'')');
|
wolffd@0
|
306 set(udata.l,'EraseMode','xor');
|
wolffd@0
|
307 delete(udata.text1);
|
wolffd@0
|
308 if ~isempty(udata.l2);
|
wolffd@0
|
309 set(udata.l2,'EraseMode','xor');
|
wolffd@0
|
310 delete(udata.text2);
|
wolffd@0
|
311 end
|
wolffd@0
|
312 set(gcf,'Pointer','crosshair');
|
wolffd@0
|
313
|
wolffd@0
|
314 case 'drag'
|
wolffd@0
|
315 % change the location of the lines
|
wolffd@0
|
316
|
wolffd@0
|
317 set(0,'CurrentFigure',udata.fig1);
|
wolffd@0
|
318 set(udata.l,'XData',[x x]);
|
wolffd@0
|
319 if ~isempty(udata.fig2)
|
wolffd@0
|
320 set(0,'CurrentFigure',udata.fig2);
|
wolffd@0
|
321 set(udata.l2,'XData',[x x]);
|
wolffd@0
|
322 end
|
wolffd@0
|
323 draw_traj(round(x));
|
wolffd@0
|
324 set(0,'CurrentFigure',old);
|
wolffd@0
|
325 case 'up'
|
wolffd@0
|
326
|
wolffd@0
|
327 % draw trajectory and set figure to the normal state.
|
wolffd@0
|
328
|
wolffd@0
|
329 set(udata.l,'EraseMode','normal');
|
wolffd@0
|
330 set(gcf,'Pointer','arrow','WindowButtonMotionFcn','',...
|
wolffd@0
|
331 'WindowButtonUpFcn','');
|
wolffd@0
|
332 draw_traj(round(x));
|
wolffd@0
|
333 set_numbers(round(x));
|
wolffd@0
|
334 end
|
wolffd@0
|
335
|
wolffd@0
|
336 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
337
|
wolffd@0
|
338 function draw_traj(point)
|
wolffd@0
|
339
|
wolffd@0
|
340 udata=get(gcf,'UserData');
|
wolffd@0
|
341 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
342 color=udata.color;
|
wolffd@0
|
343 eMode='normal';
|
wolffd@0
|
344 if isstr(udata.color) & strcmp(udata.color,'xor')
|
wolffd@0
|
345 eMode='xor';
|
wolffd@0
|
346 color='black';
|
wolffd@0
|
347 end
|
wolffd@0
|
348 ind=udata.bmus(point);
|
wolffd@0
|
349 [i j] = ind2sub(udata.msize,ind);
|
wolffd@0
|
350 if ~mod(i,2)
|
wolffd@0
|
351 j=j+0.5;
|
wolffd@0
|
352 end
|
wolffd@0
|
353 old = gcf;
|
wolffd@0
|
354 set(0,'CurrentFigure',udata.sM_h);
|
wolffd@0
|
355 hold on;
|
wolffd@0
|
356 if isempty(udata.traj) | length(udata.traj.h) ~= length(udata.a_h)
|
wolffd@0
|
357
|
wolffd@0
|
358 % trajectory does not exist
|
wolffd@0
|
359
|
wolffd@0
|
360 for i=1:length(udata.a_h)
|
wolffd@0
|
361 subplot(udata.a_h(i));
|
wolffd@0
|
362 hold on;
|
wolffd@0
|
363 new.h = plot(j,i,'Color',color,'EraseMode',eMode,'LineStyle','none');
|
wolffd@0
|
364 udata.traj.h(i)=new;
|
wolffd@0
|
365 udata.traj.j=j;
|
wolffd@0
|
366 udata.traj.i=i;
|
wolffd@0
|
367 end
|
wolffd@0
|
368 else
|
wolffd@0
|
369 if length(udata.traj.j) == udata.length_of_traj
|
wolffd@0
|
370 % if the length of trajectory == ...,
|
wolffd@0
|
371 udata.traj.j(1) = []; % the first (the oldest) coordinate pair
|
wolffd@0
|
372 udata.traj.i(1) = []; % is removed.
|
wolffd@0
|
373 end
|
wolffd@0
|
374 udata.traj.j=[udata.traj.j;j]; % the new point is added to the
|
wolffd@0
|
375 udata.traj.i=[udata.traj.i;i]; % end of coordinate vectors (i and j)
|
wolffd@0
|
376 for i=1:length(udata.a_h)
|
wolffd@0
|
377 subplot(udata.a_h(i)); % remove the existing trajectory
|
wolffd@0
|
378 delete(udata.traj.h(i).h); % and plot the new one.
|
wolffd@0
|
379 for j=1:length(udata.traj.j)
|
wolffd@0
|
380 udata.traj.h(i).h(j)=plot(udata.traj.j(j),udata.traj.i(j),...
|
wolffd@0
|
381 'Color',color,...
|
wolffd@0
|
382 'EraseMode',eMode,'Marker','o','LineWidth',2,...
|
wolffd@0
|
383 'MarkerSize',udata.size(udata.length_of_traj-j+1),...
|
wolffd@0
|
384 'LineStyle','none');
|
wolffd@0
|
385 end
|
wolffd@0
|
386 end
|
wolffd@0
|
387 end
|
wolffd@0
|
388 set(0,'CurrentFigure',udata.fig1);
|
wolffd@0
|
389 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
390
|
wolffd@0
|
391
|
wolffd@0
|
392 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
393
|
wolffd@0
|
394 function set_numbers(x);
|
wolffd@0
|
395
|
wolffd@0
|
396 % This function writes the numbers beside of the pointer lines
|
wolffd@0
|
397
|
wolffd@0
|
398
|
wolffd@0
|
399 udata=get(gcf,'UserData');
|
wolffd@0
|
400 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
401
|
wolffd@0
|
402 xlim = get(gca,'XLim');
|
wolffd@0
|
403 ylim = get(gca,'YLim');
|
wolffd@0
|
404 p = ylim(1) + 0.9*(ylim(2)-ylim(1));
|
wolffd@0
|
405
|
wolffd@0
|
406 old = gcf;
|
wolffd@0
|
407 set(0,'CurrentFigure',udata.fig1);
|
wolffd@0
|
408
|
wolffd@0
|
409
|
wolffd@0
|
410 for i=1:length(udata.h)
|
wolffd@0
|
411 subplot(udata.h(i));
|
wolffd@0
|
412
|
wolffd@0
|
413 % check if the text is placed to the left side of the line...
|
wolffd@0
|
414
|
wolffd@0
|
415 if abs(x-xlim(1)) > (abs(x-xlim(2)))
|
wolffd@0
|
416 udata.text1(i)=text(x-1,p,sprintf('%d ->',x),...
|
wolffd@0
|
417 'VerticalAlignment','top',...
|
wolffd@0
|
418 'HorizontalAlignment','right',...
|
wolffd@0
|
419 'FontWeight','demi');
|
wolffd@0
|
420 else
|
wolffd@0
|
421
|
wolffd@0
|
422 % or to the right side.
|
wolffd@0
|
423
|
wolffd@0
|
424 udata.text1(i)=text(x+1,p,sprintf('<- %d',x),...
|
wolffd@0
|
425 'VerticalAlignment','top',...
|
wolffd@0
|
426 'FontWeight','demi');
|
wolffd@0
|
427 end
|
wolffd@0
|
428 end
|
wolffd@0
|
429
|
wolffd@0
|
430 if ~isempty(udata.fig2)
|
wolffd@0
|
431 set(0,'CurrentFigure',udata.fig2);
|
wolffd@0
|
432
|
wolffd@0
|
433 for i=1:length(udata.h2)
|
wolffd@0
|
434 subplot(udata.h2(i));
|
wolffd@0
|
435
|
wolffd@0
|
436 if abs(x-xlim(1)) > (abs(x-xlim(2)))
|
wolffd@0
|
437 udata.text2(i)=text(x-1,p,sprintf('%d ->',x),...
|
wolffd@0
|
438 'VerticalAlignment','top',...
|
wolffd@0
|
439 'HorizontalAlignment','right',...
|
wolffd@0
|
440 'FontWeight','demi');
|
wolffd@0
|
441 else
|
wolffd@0
|
442 udata.text2(i)=text(x+1,p,sprintf('<- %d',x),...
|
wolffd@0
|
443 'VerticalAlignment','top',...
|
wolffd@0
|
444 'FontWeight','demi');
|
wolffd@0
|
445 end
|
wolffd@0
|
446 end
|
wolffd@0
|
447 end
|
wolffd@0
|
448
|
wolffd@0
|
449 set(0,'CurrentFigure',old);
|
wolffd@0
|
450 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
451
|
wolffd@0
|
452 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
453
|
wolffd@0
|
454 function remove_traj()
|
wolffd@0
|
455
|
wolffd@0
|
456 % delete trajectory -object from every component plane.
|
wolffd@0
|
457
|
wolffd@0
|
458 udata=get(gcf,'UserData');
|
wolffd@0
|
459 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
460
|
wolffd@0
|
461 if isempty(udata.traj)
|
wolffd@0
|
462 return;
|
wolffd@0
|
463 end
|
wolffd@0
|
464
|
wolffd@0
|
465
|
wolffd@0
|
466 for i=1:length(udata.traj.h)
|
wolffd@0
|
467 delete(udata.traj.h(i).h);
|
wolffd@0
|
468 end
|
wolffd@0
|
469
|
wolffd@0
|
470 udata.traj=[];
|
wolffd@0
|
471 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
472
|
wolffd@0
|
473 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
474
|
wolffd@0
|
475 function line_bdf(arg)
|
wolffd@0
|
476
|
wolffd@0
|
477 % this function takes care of action when region is selected in the
|
wolffd@0
|
478 % data figure.
|
wolffd@0
|
479
|
wolffd@0
|
480
|
wolffd@0
|
481 udata=get(gcf,'UserData');
|
wolffd@0
|
482 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
483 xlim=get(gca,'XLim');
|
wolffd@0
|
484
|
wolffd@0
|
485 if ~(any(strcmp('THIS',fieldnames(udata))))
|
wolffd@0
|
486 p = getfield(get(gca,'CurrentPoint'),{1});
|
wolffd@0
|
487 else
|
wolffd@0
|
488 p = getfield(get(udata.THIS,'CurrentPoint'),{1});
|
wolffd@0
|
489 end
|
wolffd@0
|
490
|
wolffd@0
|
491 if p < xlim(1)
|
wolffd@0
|
492 p = xlim(1);
|
wolffd@0
|
493 elseif p > xlim(2)
|
wolffd@0
|
494 p = xlim(2);
|
wolffd@0
|
495 end
|
wolffd@0
|
496
|
wolffd@0
|
497
|
wolffd@0
|
498
|
wolffd@0
|
499 switch arg
|
wolffd@0
|
500 case 'down'
|
wolffd@0
|
501
|
wolffd@0
|
502 % the mouse button is pressed down, the pointer lines are drawn.
|
wolffd@0
|
503 % and the state of the figure is changed.
|
wolffd@0
|
504
|
wolffd@0
|
505 udata.THIS=gca;
|
wolffd@0
|
506 set(gcf,'WindowButtonMotionFcn',...
|
wolffd@0
|
507 'vis_trajgui([],''line_drag'')',...
|
wolffd@0
|
508 'WindowButtonUpFcn','vis_trajgui([],''line_up'')');
|
wolffd@0
|
509 udata.start_p=p;
|
wolffd@0
|
510
|
wolffd@0
|
511 old = gcf;
|
wolffd@0
|
512 set(0,'CurrentFigure',udata.fig1);
|
wolffd@0
|
513
|
wolffd@0
|
514 for i=1:length(udata.h)
|
wolffd@0
|
515 subplot(udata.h(i));
|
wolffd@0
|
516 udata.t_line.h(i)=line([p p],get(gca,'YLim'),'Color','red');
|
wolffd@0
|
517 udata.t_line.h2(i)=line([p p],get(gca,'YLim'),'Color','red',...
|
wolffd@0
|
518 'EraseMode','xor');
|
wolffd@0
|
519 end
|
wolffd@0
|
520 if ~isempty(udata.h2)
|
wolffd@0
|
521 set(0,'CurrentFigure',udata.fig2);
|
wolffd@0
|
522 for i=1:length(udata.h2)
|
wolffd@0
|
523 subplot(udata.h2(i));
|
wolffd@0
|
524 udata.t_line2.h(i)=line([p p],get(gca,'YLim'),'Color','red');
|
wolffd@0
|
525 udata.t_line2.h2(i)=line([p p],get(gca,'YLim'),'Color','red',...
|
wolffd@0
|
526 'EraseMode','xor');
|
wolffd@0
|
527 end
|
wolffd@0
|
528 end
|
wolffd@0
|
529
|
wolffd@0
|
530 case 'drag'
|
wolffd@0
|
531
|
wolffd@0
|
532 % change the position of the pointer lines
|
wolffd@0
|
533
|
wolffd@0
|
534 old = gcf;
|
wolffd@0
|
535 set(0,'CurrentFigure',udata.fig1);
|
wolffd@0
|
536 set(udata.t_line.h2,'XData',[p p]);
|
wolffd@0
|
537 if ~isempty(udata.fig2)
|
wolffd@0
|
538 set(0,'CurrentFigure',udata.fig2);
|
wolffd@0
|
539 set(udata.t_line2.h2,'XData',[p p]);
|
wolffd@0
|
540 end
|
wolffd@0
|
541 set(0,'CurrentFigure',old);
|
wolffd@0
|
542 case 'up'
|
wolffd@0
|
543
|
wolffd@0
|
544
|
wolffd@0
|
545 % sort the 'points' -vector and draw the markers to the data and nodes
|
wolffd@0
|
546
|
wolffd@0
|
547 points=sort([round(udata.start_p) round(p)]);
|
wolffd@0
|
548 draw_markers(points(1):points(2));
|
wolffd@0
|
549 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
550 udata.new_marks=unique([udata.new_marks ;(points(1):points(2))']);
|
wolffd@0
|
551 delete([udata.t_line.h2 udata.t_line.h]);
|
wolffd@0
|
552 if ~isempty(udata.fig2)
|
wolffd@0
|
553 delete([udata.t_line2.h2 udata.t_line2.h]);
|
wolffd@0
|
554 end
|
wolffd@0
|
555 set(get(udata.THIS,'Parent'),'WindowButtonMotionFcn','',...
|
wolffd@0
|
556 'WindowButtonUpFcn','');
|
wolffd@0
|
557 udata=rmfield(udata,'THIS');
|
wolffd@0
|
558 end
|
wolffd@0
|
559
|
wolffd@0
|
560 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
561
|
wolffd@0
|
562 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
563
|
wolffd@0
|
564 function draw_markers(x);
|
wolffd@0
|
565
|
wolffd@0
|
566 plot2data(x);
|
wolffd@0
|
567 plot2plane(x);
|
wolffd@0
|
568
|
wolffd@0
|
569 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
570
|
wolffd@0
|
571 function plot2data(x);
|
wolffd@0
|
572
|
wolffd@0
|
573 % plot black markers to the data figure(s)
|
wolffd@0
|
574
|
wolffd@0
|
575 udata=get(gcf,'UserData');
|
wolffd@0
|
576 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
577
|
wolffd@0
|
578 old = gcf;
|
wolffd@0
|
579
|
wolffd@0
|
580 set(0,'CurrentFigure',udata.fig1);
|
wolffd@0
|
581
|
wolffd@0
|
582 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
583
|
wolffd@0
|
584 % if there already exist points in the positions that are members
|
wolffd@0
|
585 % of the set x, then the old points are removed from data figures...
|
wolffd@0
|
586
|
wolffd@0
|
587 for i=1:length(udata.d_mark(1).h)
|
wolffd@0
|
588 tmp1 = get(udata.d_mark(1).h(i),'XData');
|
wolffd@0
|
589 tmp2 = setdiff(tmp1,x);
|
wolffd@0
|
590 if length(tmp1) ~= length(tmp2)
|
wolffd@0
|
591 inds=[];
|
wolffd@0
|
592 for j=1:length(tmp2);
|
wolffd@0
|
593 inds=[inds find(tmp2(j)==tmp1)];
|
wolffd@0
|
594 end
|
wolffd@0
|
595 for j=1:length(udata.d_mark)
|
wolffd@0
|
596 ydata=getfield(get(udata.d_mark(j).h(i),'YData'),{inds});
|
wolffd@0
|
597 set(udata.d_mark(j).h(i),'XData',tmp2,'YData',ydata);
|
wolffd@0
|
598 end
|
wolffd@0
|
599 if ~isempty(udata.fig2)
|
wolffd@0
|
600 for j=1:length(udata.d_mark2)
|
wolffd@0
|
601 ydata=getfield(get(udata.d_mark2(j).h(i),'YData'),{inds});
|
wolffd@0
|
602 set(udata.d_mark2(j).h(i),'XData',tmp2,'YData',ydata);
|
wolffd@0
|
603 end
|
wolffd@0
|
604 end
|
wolffd@0
|
605 end
|
wolffd@0
|
606 end
|
wolffd@0
|
607
|
wolffd@0
|
608
|
wolffd@0
|
609 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
610
|
wolffd@0
|
611 % ... and the new ones are plotted.
|
wolffd@0
|
612
|
wolffd@0
|
613 for i=1:length(udata.h)
|
wolffd@0
|
614 subplot(udata.h(i));
|
wolffd@0
|
615 h=plot(x,getfield(get(udata.d(i),'YData'),{x}),'oblack',...
|
wolffd@0
|
616 'ButtonDownFcn',...
|
wolffd@0
|
617 'vis_trajgui([],''line_down'')');
|
wolffd@0
|
618 udata.d_mark(i).h=[udata.d_mark(i).h;h];
|
wolffd@0
|
619 end
|
wolffd@0
|
620
|
wolffd@0
|
621 if ~isempty(udata.h2)
|
wolffd@0
|
622 set(0,'CurrentFigure',udata.fig2);
|
wolffd@0
|
623
|
wolffd@0
|
624 for i=1:length(udata.h2)
|
wolffd@0
|
625 subplot(udata.h2(i));
|
wolffd@0
|
626 h=plot(x,getfield(get(udata.d2(i),'YData'),{x}),'oblack',...
|
wolffd@0
|
627 'ButtonDownFcn',...
|
wolffd@0
|
628 'vis_trajgui([],''line_down'')');
|
wolffd@0
|
629 udata.d_mark2(i).h=[udata.d_mark2(i).h;h];
|
wolffd@0
|
630 end
|
wolffd@0
|
631 end
|
wolffd@0
|
632
|
wolffd@0
|
633 set(0,'CurrentFigure',old);
|
wolffd@0
|
634 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
635
|
wolffd@0
|
636
|
wolffd@0
|
637 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
638
|
wolffd@0
|
639 function plot2plane(x);
|
wolffd@0
|
640
|
wolffd@0
|
641 % sets markers to the component planes.
|
wolffd@0
|
642
|
wolffd@0
|
643 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
644 %
|
wolffd@0
|
645 % actually new markers are never plotted, but the color of the patch
|
wolffd@0
|
646 % lying above the original component plane patch is changed black in
|
wolffd@0
|
647 % the right positions.
|
wolffd@0
|
648
|
wolffd@0
|
649 udata=get(gcf,'UserData');
|
wolffd@0
|
650 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
651
|
wolffd@0
|
652 udata.new_marks=unique([udata.new_marks ;x']);
|
wolffd@0
|
653
|
wolffd@0
|
654 for i=1:length(udata.a_h)
|
wolffd@0
|
655 col=get(udata.tmp_patch(i),'FaceVertexCData');
|
wolffd@0
|
656 if length(size(col)) == 3
|
wolffd@0
|
657 col = reshape(col,[size(col,1) 3]);
|
wolffd@0
|
658 end
|
wolffd@0
|
659 for j=1:length(udata.new_marks)
|
wolffd@0
|
660 col(udata.bmus(udata.new_marks(j)),:)=[0 0 0];
|
wolffd@0
|
661 end
|
wolffd@0
|
662 set(udata.tmp_patch(i),'FaceVertexCData',col);
|
wolffd@0
|
663 end
|
wolffd@0
|
664
|
wolffd@0
|
665 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
666
|
wolffd@0
|
667 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
668
|
wolffd@0
|
669 function color_gui(fig1)
|
wolffd@0
|
670
|
wolffd@0
|
671 % construct the graphical user interface for changing the color of the
|
wolffd@0
|
672 % black (marked) nodes.
|
wolffd@0
|
673
|
wolffd@0
|
674
|
wolffd@0
|
675 udata=get(fig1,'UserData');
|
wolffd@0
|
676
|
wolffd@0
|
677 a = figure('Color',[0.8 0.8 0.8], ...
|
wolffd@0
|
678 'Name','Colors', ...
|
wolffd@0
|
679 'PaperType','a4letter', ...
|
wolffd@0
|
680 'Position',[518 456 120 311], ...
|
wolffd@0
|
681 'Tag','Fig1');
|
wolffd@0
|
682
|
wolffd@0
|
683 udata.c_struct.fig=a;
|
wolffd@0
|
684
|
wolffd@0
|
685 b = uicontrol('Parent',a, ...
|
wolffd@0
|
686 'Units','normalized', ...
|
wolffd@0
|
687 'BackgroundColor',[0.701961 0.701961 0.701961], ...
|
wolffd@0
|
688 'Position',[0.0700415 0.28956 0.830492 0.594566], ...
|
wolffd@0
|
689 'Style','frame', ...
|
wolffd@0
|
690 'Tag','Frame1');
|
wolffd@0
|
691 b = uicontrol('Parent',a, ...
|
wolffd@0
|
692 'Units','normalized', ...
|
wolffd@0
|
693 'BackgroundColor',[0.8 0.8 0.8], ...
|
wolffd@0
|
694 'Position',[0.100059 0.301143 0.770456 0.571399], ...
|
wolffd@0
|
695 'Style','frame', ...
|
wolffd@0
|
696 'Tag','Frame2');
|
wolffd@0
|
697
|
wolffd@0
|
698 b = uicontrol('Parent',a, ...
|
wolffd@0
|
699 'Units','normalized', ...
|
wolffd@0
|
700 'Callback','vis_trajgui([],''cyan'')', ...
|
wolffd@0
|
701 'Position',[0.130077 0.795326 0.170101 0.0617729], ...
|
wolffd@0
|
702 'Style','radiobutton', ...
|
wolffd@0
|
703 'Tag','cyan', ...
|
wolffd@0
|
704 'Value',1);
|
wolffd@0
|
705
|
wolffd@0
|
706
|
wolffd@0
|
707 b = uicontrol('Parent',a, ...
|
wolffd@0
|
708 'Units','normalized', ...
|
wolffd@0
|
709 'Callback','vis_trajgui([],''magenta'')', ...
|
wolffd@0
|
710 'Position',[0.130077 0.733553 0.170101 0.057912], ...
|
wolffd@0
|
711 'Style','radiobutton', ...
|
wolffd@0
|
712 'Tag','magenta');
|
wolffd@0
|
713
|
wolffd@0
|
714
|
wolffd@0
|
715 b = uicontrol('Parent',a, ...
|
wolffd@0
|
716 'Units','normalized', ...
|
wolffd@0
|
717 'Callback','vis_trajgui([],''yellow'')', ...
|
wolffd@0
|
718 'Position',[0.130077 0.664059 0.170101 0.0617729], ...
|
wolffd@0
|
719 'Style','radiobutton', ...
|
wolffd@0
|
720 'Tag','yellow');
|
wolffd@0
|
721
|
wolffd@0
|
722
|
wolffd@0
|
723 b = uicontrol('Parent',a, ...
|
wolffd@0
|
724 'Units','normalized', ...
|
wolffd@0
|
725 'Callback','vis_trajgui([],''red'')', ...
|
wolffd@0
|
726 'Position',[0.130077 0.590703 0.170101 0.0617729], ...
|
wolffd@0
|
727 'Style','radiobutton', ...
|
wolffd@0
|
728 'Tag','red');
|
wolffd@0
|
729
|
wolffd@0
|
730
|
wolffd@0
|
731 b = uicontrol('Parent',a, ...
|
wolffd@0
|
732 'Units','normalized', ...
|
wolffd@0
|
733 'Callback','vis_trajgui([],''green'')', ...
|
wolffd@0
|
734 'Position',[0.130077 0.525068 0.170101 0.057912], ...
|
wolffd@0
|
735 'Style','radiobutton', ...
|
wolffd@0
|
736 'Tag','green');
|
wolffd@0
|
737
|
wolffd@0
|
738
|
wolffd@0
|
739 b = uicontrol('Parent',a, ...
|
wolffd@0
|
740 'Units','normalized', ...
|
wolffd@0
|
741 'Callback','vis_trajgui([],''blue'')', ...
|
wolffd@0
|
742 'Position',[0.130077 0.455575 0.170101 0.0617729], ...
|
wolffd@0
|
743 'Style','radiobutton', ...
|
wolffd@0
|
744 'Tag','blue');
|
wolffd@0
|
745
|
wolffd@0
|
746
|
wolffd@0
|
747 b = uicontrol('Parent',a, ...
|
wolffd@0
|
748 'Units','normalized', ...
|
wolffd@0
|
749 'Callback','vis_trajgui([],''white'')', ...
|
wolffd@0
|
750 'Position',[0.130077 0.38608 0.170101 0.0617729], ...
|
wolffd@0
|
751 'Style','radiobutton', ...
|
wolffd@0
|
752 'Tag','white');
|
wolffd@0
|
753
|
wolffd@0
|
754
|
wolffd@0
|
755 b = uicontrol('Parent',a, ...
|
wolffd@0
|
756 'Units','normalized', ...
|
wolffd@0
|
757 'Callback','vis_trajgui([],''grey'')', ...
|
wolffd@0
|
758 'Position',[0.130077 0.320447 0.170101 0.057912], ...
|
wolffd@0
|
759 'Style','radiobutton', ...
|
wolffd@0
|
760 'Tag','grey');
|
wolffd@0
|
761
|
wolffd@0
|
762
|
wolffd@0
|
763 b = uicontrol('Parent',a, ...
|
wolffd@0
|
764 'Units','normalized', ...
|
wolffd@0
|
765 'BackgroundColor',[0.8 0.8 0.8], ...
|
wolffd@0
|
766 'FontWeight','demi', ...
|
wolffd@0
|
767 'HorizontalAlignment','left', ...
|
wolffd@0
|
768 'Position',[0.32019 0.795326 0.470278 0.0501905], ...
|
wolffd@0
|
769 'String','Cyan', ...
|
wolffd@0
|
770 'Style','text', ...
|
wolffd@0
|
771 'Tag','StaticText1');
|
wolffd@0
|
772 b = uicontrol('Parent',a, ...
|
wolffd@0
|
773 'Units','normalized', ...
|
wolffd@0
|
774 'BackgroundColor',[0.8 0.8 0.8], ...
|
wolffd@0
|
775 'FontWeight','demi', ...
|
wolffd@0
|
776 'HorizontalAlignment','left', ...
|
wolffd@0
|
777 'Position',[0.32019 0.733553 0.520308 0.0463296], ...
|
wolffd@0
|
778 'String','Magenta', ...
|
wolffd@0
|
779 'Style','text', ...
|
wolffd@0
|
780 'Tag','StaticText2');
|
wolffd@0
|
781 b = uicontrol('Parent',a, ...
|
wolffd@0
|
782 'Units','normalized', ...
|
wolffd@0
|
783 'BackgroundColor',[0.8 0.8 0.8], ...
|
wolffd@0
|
784 'FontWeight','demi', ...
|
wolffd@0
|
785 'HorizontalAlignment','left', ...
|
wolffd@0
|
786 'Position',[0.32019 0.664059 0.470278 0.0501905], ...
|
wolffd@0
|
787 'String','Yellow', ...
|
wolffd@0
|
788 'Style','text', ...
|
wolffd@0
|
789 'Tag','StaticText3');
|
wolffd@0
|
790 b = uicontrol('Parent',a, ...
|
wolffd@0
|
791 'Units','normalized', ...
|
wolffd@0
|
792 'BackgroundColor',[0.8 0.8 0.8], ...
|
wolffd@0
|
793 'FontWeight','demi', ...
|
wolffd@0
|
794 'HorizontalAlignment','left', ...
|
wolffd@0
|
795 'Position',[0.32019 0.590703 0.470278 0.0501905], ...
|
wolffd@0
|
796 'String','Red', ...
|
wolffd@0
|
797 'Style','text', ...
|
wolffd@0
|
798 'Tag','StaticText4');
|
wolffd@0
|
799 b = uicontrol('Parent',a, ...
|
wolffd@0
|
800 'Units','normalized', ...
|
wolffd@0
|
801 'BackgroundColor',[0.8 0.8 0.8], ...
|
wolffd@0
|
802 'FontWeight','demi', ...
|
wolffd@0
|
803 'HorizontalAlignment','left', ...
|
wolffd@0
|
804 'Position',[0.32019 0.525068 0.470278 0.0463296], ...
|
wolffd@0
|
805 'String','Green', ...
|
wolffd@0
|
806 'Style','text', ...
|
wolffd@0
|
807 'Tag','StaticText5');
|
wolffd@0
|
808 b = uicontrol('Parent',a, ...
|
wolffd@0
|
809 'Units','normalized', ...
|
wolffd@0
|
810 'BackgroundColor',[0.8 0.8 0.8], ...
|
wolffd@0
|
811 'FontWeight','demi', ...
|
wolffd@0
|
812 'HorizontalAlignment','left', ...
|
wolffd@0
|
813 'Position',[0.32019 0.455575 0.470278 0.0463296], ...
|
wolffd@0
|
814 'String','Blue', ...
|
wolffd@0
|
815 'Style','text', ...
|
wolffd@0
|
816 'Tag','StaticText6');
|
wolffd@0
|
817 b = uicontrol('Parent',a, ...
|
wolffd@0
|
818 'Units','normalized', ...
|
wolffd@0
|
819 'BackgroundColor',[0.8 0.8 0.8], ...
|
wolffd@0
|
820 'FontWeight','demi', ...
|
wolffd@0
|
821 'HorizontalAlignment','left', ...
|
wolffd@0
|
822 'Position',[0.32019 0.38608 0.470278 0.0501905], ...
|
wolffd@0
|
823 'String','White', ...
|
wolffd@0
|
824 'Style','text', ...
|
wolffd@0
|
825 'Tag','StaticText7');
|
wolffd@0
|
826 b = uicontrol('Parent',a, ...
|
wolffd@0
|
827 'Units','normalized', ...
|
wolffd@0
|
828 'BackgroundColor',[0.8 0.8 0.8], ...
|
wolffd@0
|
829 'FontWeight','demi', ...
|
wolffd@0
|
830 'HorizontalAlignment','left', ...
|
wolffd@0
|
831 'Position',[0.32019 0.320447 0.470278 0.0463296], ...
|
wolffd@0
|
832 'String','Grey', ...
|
wolffd@0
|
833 'Style','text', ...
|
wolffd@0
|
834 'Tag','StaticText8');
|
wolffd@0
|
835 b = uicontrol('Parent',a, ...
|
wolffd@0
|
836 'Units','normalized', ...
|
wolffd@0
|
837 'Position',[0.0700415 0.146711 0.830492 0.135128], ...
|
wolffd@0
|
838 'Style','frame', ...
|
wolffd@0
|
839 'Tag','Frame3');
|
wolffd@0
|
840 b = uicontrol('Parent',a, ...
|
wolffd@0
|
841 'Units','normalized', ...
|
wolffd@0
|
842 'BackgroundColor',[0.8 0.8 0.8], ...
|
wolffd@0
|
843 'Position',[0.100059 0.158293 0.770456 0.111963], ...
|
wolffd@0
|
844 'Style','frame', ...
|
wolffd@0
|
845 'Tag','Frame4');
|
wolffd@0
|
846 b = uicontrol('Parent',a, ...
|
wolffd@0
|
847 'Units','normalized', ...
|
wolffd@0
|
848 'BackgroundColor',[0.8 0.8 0.8], ...
|
wolffd@0
|
849 'FontWeight','demi', ...
|
wolffd@0
|
850 'HorizontalAlignment','left', ...
|
wolffd@0
|
851 'Position',[0.130077 0.177597 0.270833 0.0617729], ...
|
wolffd@0
|
852 'String','RGB', ...
|
wolffd@0
|
853 'Style','text', ...
|
wolffd@0
|
854 'Tag','StaticText9');
|
wolffd@0
|
855 b = uicontrol('Parent',a, ...
|
wolffd@0
|
856 'Units','normalized', ...
|
wolffd@0
|
857 'BackgroundColor',[1 1 1], ...
|
wolffd@0
|
858 'Position',[0.410243 0.173736 0.420249 0.0810768], ...
|
wolffd@0
|
859 'Style','edit', ...
|
wolffd@0
|
860 'Tag','EditText1');
|
wolffd@0
|
861
|
wolffd@0
|
862 udata.c_struct.RGB=b;
|
wolffd@0
|
863
|
wolffd@0
|
864 b = uicontrol('Parent',a, ...
|
wolffd@0
|
865 'Units','normalized', ...
|
wolffd@0
|
866 'Callback','vis_trajgui([],''dye'')', ...
|
wolffd@0
|
867 'FontWeight','demi', ...
|
wolffd@0
|
868 'Position',[0.0700415 0.0270256 0.360214 0.0772162], ...
|
wolffd@0
|
869 'String','OK', ...
|
wolffd@0
|
870 'Tag','Pushbutton1');
|
wolffd@0
|
871 b = uicontrol('Parent',a, ...
|
wolffd@0
|
872 'Units','normalized', ...
|
wolffd@0
|
873 'Callback','close gcf', ...
|
wolffd@0
|
874 'FontWeight','demi', ...
|
wolffd@0
|
875 'Position',[0.54032 0.0270256 0.360214 0.0772162], ...
|
wolffd@0
|
876 'String','Close', ...
|
wolffd@0
|
877 'Tag','Pushbutton2');
|
wolffd@0
|
878
|
wolffd@0
|
879 udata.c_struct.color=[0 1 1];
|
wolffd@0
|
880
|
wolffd@0
|
881 tmp.fig1=fig1;
|
wolffd@0
|
882 set(a,'UserData',tmp);
|
wolffd@0
|
883 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
884
|
wolffd@0
|
885 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
886
|
wolffd@0
|
887 function dye_nodes(arg)
|
wolffd@0
|
888
|
wolffd@0
|
889 % takes care of the action, when radiobuttons are pressed
|
wolffd@0
|
890 % (or the RGB value is set) in the color_gui -figure.
|
wolffd@0
|
891 % It also handles the starting of dying nodes and plots.
|
wolffd@0
|
892
|
wolffd@0
|
893 udata=get(gcf,'UserData');
|
wolffd@0
|
894 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
895
|
wolffd@0
|
896
|
wolffd@0
|
897 switch arg
|
wolffd@0
|
898 case {'cyan','magenta','yellow','red','green','blue','white','grey'}
|
wolffd@0
|
899 h=findobj(get(gcf,'Children'),'Style','radiobutton');
|
wolffd@0
|
900 set(h,'Value',0);
|
wolffd@0
|
901 set(gcbo,'Value',1);
|
wolffd@0
|
902 end
|
wolffd@0
|
903
|
wolffd@0
|
904
|
wolffd@0
|
905 switch arg
|
wolffd@0
|
906 case 'cyan'
|
wolffd@0
|
907 RGB = [0 1 1];
|
wolffd@0
|
908 case 'magenta'
|
wolffd@0
|
909 RGB = [1 0 1];
|
wolffd@0
|
910 case 'yellow'
|
wolffd@0
|
911 RGB = [1 1 0];
|
wolffd@0
|
912 case 'red'
|
wolffd@0
|
913 RGB = [1 0 0];
|
wolffd@0
|
914 case 'green'
|
wolffd@0
|
915 RGB = [0 1 0];
|
wolffd@0
|
916 case 'blue'
|
wolffd@0
|
917 RGB = [0 0 1];
|
wolffd@0
|
918 case 'white'
|
wolffd@0
|
919 RGB = [1 1 1];
|
wolffd@0
|
920 case 'grey'
|
wolffd@0
|
921 RGB = [0.4 0.4 0.4];
|
wolffd@0
|
922 case 'dye'
|
wolffd@0
|
923
|
wolffd@0
|
924 RGB = get(udata.c_struct.RGB,'String');
|
wolffd@0
|
925 if isempty(RGB)
|
wolffd@0
|
926 dye;
|
wolffd@0
|
927 return;
|
wolffd@0
|
928 else
|
wolffd@0
|
929 str1='The value of RGB must be vector containing three scalars';
|
wolffd@0
|
930 str2='between 0 and 1.';
|
wolffd@0
|
931 color = str2num(RGB);
|
wolffd@0
|
932 set(udata.c_struct.RGB,'String','');
|
wolffd@0
|
933 if isempty(color)
|
wolffd@0
|
934 close gcf;
|
wolffd@0
|
935 udata=rmfield(udata,'c_struct');
|
wolffd@0
|
936 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
937 errordlg([{str1};{str2}]);
|
wolffd@0
|
938 return;
|
wolffd@0
|
939 end
|
wolffd@0
|
940 if ~all([1 3] == size(color)) & ~all([3 1] == size(color))
|
wolffd@0
|
941 close gcf;
|
wolffd@0
|
942 errordlg([{str1};{str2}]);
|
wolffd@0
|
943 udata=rmfield(udata,'c_struct',udata);
|
wolffd@0
|
944 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
945 return;
|
wolffd@0
|
946 end
|
wolffd@0
|
947 if ~isempty(cat(2,find(color>1),find(color<0)))
|
wolffd@0
|
948 close gcf
|
wolffd@0
|
949 errordlg([{str1};{str2}]);
|
wolffd@0
|
950 udata=rmfield(udata,'c_struct',udata);
|
wolffd@0
|
951 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
952 return;
|
wolffd@0
|
953 end
|
wolffd@0
|
954 udata.c_struct.color=color;
|
wolffd@0
|
955 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
956 dye;
|
wolffd@0
|
957 return;
|
wolffd@0
|
958 end
|
wolffd@0
|
959 end
|
wolffd@0
|
960
|
wolffd@0
|
961 udata.c_struct.color=RGB;
|
wolffd@0
|
962 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
963
|
wolffd@0
|
964 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
965
|
wolffd@0
|
966 function dye()
|
wolffd@0
|
967
|
wolffd@0
|
968 % dyes black markers in the component planes and in the data figures
|
wolffd@0
|
969
|
wolffd@0
|
970 udata=get(gcf,'UserData');
|
wolffd@0
|
971 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
972
|
wolffd@0
|
973 inds=unique([udata.all_marks ; udata.new_marks]);
|
wolffd@0
|
974
|
wolffd@0
|
975
|
wolffd@0
|
976 for i=1:length(udata.d_mark);
|
wolffd@0
|
977 for j=1:length(udata.d_mark(i).h)
|
wolffd@0
|
978 if all(get(udata.d_mark(i).h(j),'Color') == [0 0 0])
|
wolffd@0
|
979 set(udata.d_mark(i).h(j),'Color',udata.c_struct.color);
|
wolffd@0
|
980 end
|
wolffd@0
|
981 end
|
wolffd@0
|
982 end
|
wolffd@0
|
983
|
wolffd@0
|
984 if ~isempty(udata.fig2);
|
wolffd@0
|
985 for i=1:length(udata.d_mark2)
|
wolffd@0
|
986 for j=1:length(udata.d_mark2(i).h)
|
wolffd@0
|
987 if all(get(udata.d_mark2(i).h(j),'Color') == [0 0 0])
|
wolffd@0
|
988 set(udata.d_mark2(i).h(j),'Color',udata.c_struct.color);
|
wolffd@0
|
989 end
|
wolffd@0
|
990 end
|
wolffd@0
|
991 end
|
wolffd@0
|
992 end
|
wolffd@0
|
993
|
wolffd@0
|
994
|
wolffd@0
|
995 for i=1:length(udata.a_h)
|
wolffd@0
|
996 col=get(udata.tmp_patch(i),'FaceVertexCData');
|
wolffd@0
|
997 for j=1:length(udata.new_marks)
|
wolffd@0
|
998 col(udata.bmus(udata.new_marks(j)),:)=udata.c_struct.color;
|
wolffd@0
|
999 end
|
wolffd@0
|
1000 set(udata.tmp_patch(i),'FaceVertexCData',col);
|
wolffd@0
|
1001 end
|
wolffd@0
|
1002
|
wolffd@0
|
1003
|
wolffd@0
|
1004 udata.all_marks=unique([udata.all_marks;udata.new_marks]);
|
wolffd@0
|
1005 udata.new_marks=[];
|
wolffd@0
|
1006 close gcf;
|
wolffd@0
|
1007 udata=rmfield(udata,'c_struct');
|
wolffd@0
|
1008 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
1009
|
wolffd@0
|
1010 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1011
|
wolffd@0
|
1012 function clear_markers()
|
wolffd@0
|
1013
|
wolffd@0
|
1014 % removes markers from the componentplanes and the data figure(s).
|
wolffd@0
|
1015
|
wolffd@0
|
1016 udata=get(gcf,'UserData');
|
wolffd@0
|
1017 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
1018
|
wolffd@0
|
1019 for i=1:length(udata.d_mark)
|
wolffd@0
|
1020 delete(udata.d_mark(i).h);
|
wolffd@0
|
1021 udata.d_mark(i).h=[];
|
wolffd@0
|
1022 end
|
wolffd@0
|
1023
|
wolffd@0
|
1024 for i=1:length(udata.d_mark2)
|
wolffd@0
|
1025 delete(udata.d_mark2(i).h);
|
wolffd@0
|
1026 udata.d_mark2(i).h=[];
|
wolffd@0
|
1027 end
|
wolffd@0
|
1028
|
wolffd@0
|
1029 col=NaN*get(udata.tmp_patch(1),'FaceVertexCData');
|
wolffd@0
|
1030 col=reshape(col,[size(col,1) 3]);
|
wolffd@0
|
1031
|
wolffd@0
|
1032 for i=1:length(udata.tmp_patch)
|
wolffd@0
|
1033 set(udata.tmp_patch(i),'FaceVertexCData',col);
|
wolffd@0
|
1034 end
|
wolffd@0
|
1035
|
wolffd@0
|
1036 udata.new_marks=[];
|
wolffd@0
|
1037 udata.all_marks=[];
|
wolffd@0
|
1038
|
wolffd@0
|
1039
|
wolffd@0
|
1040 if any(strcmp('c_struct',fieldnames(udata)))
|
wolffd@0
|
1041 udata=rmfield(udata,'c_struct');
|
wolffd@0
|
1042 end
|
wolffd@0
|
1043
|
wolffd@0
|
1044 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
1045
|
wolffd@0
|
1046 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1047
|
wolffd@0
|
1048 function key_bdf
|
wolffd@0
|
1049
|
wolffd@0
|
1050 % moves trajectory and pointer lines, when either of
|
wolffd@0
|
1051 % the keys '>' or '<' is pressed.
|
wolffd@0
|
1052
|
wolffd@0
|
1053 udata=get(gcf,'UserData');
|
wolffd@0
|
1054 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
1055
|
wolffd@0
|
1056 key=get(gcbo,'CurrentCharacter');
|
wolffd@0
|
1057
|
wolffd@0
|
1058 % The easiest way to get a new coordinates is to get them from the texts...
|
wolffd@0
|
1059 % The texts are either '<- x' or 'x ->'
|
wolffd@0
|
1060
|
wolffd@0
|
1061 x=get(udata.text1(1),'String');
|
wolffd@0
|
1062 x=str2num(x(4:length(x)));
|
wolffd@0
|
1063
|
wolffd@0
|
1064 if isempty(x)
|
wolffd@0
|
1065 x=get(udata.text1(1),'String');
|
wolffd@0
|
1066 x=str2num(x(1:length(x)-3));
|
wolffd@0
|
1067 end
|
wolffd@0
|
1068
|
wolffd@0
|
1069 switch(key)
|
wolffd@0
|
1070 case '<'
|
wolffd@0
|
1071 if x ~= 1
|
wolffd@0
|
1072 x= x-1;
|
wolffd@0
|
1073 end
|
wolffd@0
|
1074 case '>'
|
wolffd@0
|
1075 if x ~= getfield(get(get(udata.text1(1),'Parent'),'XLim'),{2})
|
wolffd@0
|
1076 x = x+1;
|
wolffd@0
|
1077 end
|
wolffd@0
|
1078 otherwise
|
wolffd@0
|
1079 return;
|
wolffd@0
|
1080 end
|
wolffd@0
|
1081
|
wolffd@0
|
1082 set(udata.l,'XData',[x x]);
|
wolffd@0
|
1083 if ~isempty(udata.fig2)
|
wolffd@0
|
1084 set(udata.l2,'XData',[x x]);
|
wolffd@0
|
1085 end
|
wolffd@0
|
1086
|
wolffd@0
|
1087 delete(udata.text1);
|
wolffd@0
|
1088 delete(udata.text2);
|
wolffd@0
|
1089
|
wolffd@0
|
1090 set_numbers(x);
|
wolffd@0
|
1091 draw_traj(x);
|
wolffd@0
|
1092
|
wolffd@0
|
1093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1094
|
wolffd@0
|
1095 function click()
|
wolffd@0
|
1096
|
wolffd@0
|
1097
|
wolffd@0
|
1098 switch get(gcf,'SelectionType')
|
wolffd@0
|
1099 case 'open'
|
wolffd@0
|
1100 return;
|
wolffd@0
|
1101 case {'normal','alt'}
|
wolffd@0
|
1102 draw_poly;
|
wolffd@0
|
1103 case 'extend'
|
wolffd@0
|
1104 click_node;
|
wolffd@0
|
1105 end
|
wolffd@0
|
1106
|
wolffd@0
|
1107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1108
|
wolffd@0
|
1109 function click_node()
|
wolffd@0
|
1110
|
wolffd@0
|
1111 % takes care of the action, when the middle mouse button is
|
wolffd@0
|
1112 % pressed (mouse pointer is above some component plane).
|
wolffd@0
|
1113
|
wolffd@0
|
1114 udata=get(gcf,'UserData');
|
wolffd@0
|
1115 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
1116 new_marks=[];
|
wolffd@0
|
1117
|
wolffd@0
|
1118 old=gcf;
|
wolffd@0
|
1119
|
wolffd@0
|
1120 NEW=0;
|
wolffd@0
|
1121 AGAIN = 0;
|
wolffd@0
|
1122
|
wolffd@0
|
1123
|
wolffd@0
|
1124 coords=get(gca,'CurrentPoint');
|
wolffd@0
|
1125 row=round(coords(1,2));
|
wolffd@0
|
1126
|
wolffd@0
|
1127 if strcmp(udata.lattice,'hexa') & ~mod(row,2)
|
wolffd@0
|
1128 col = round(coords(1,1) - 0.5);
|
wolffd@0
|
1129 else
|
wolffd@0
|
1130 col = round(coords(1,1));
|
wolffd@0
|
1131 end
|
wolffd@0
|
1132
|
wolffd@0
|
1133 ind = sub2ind(udata.msize,row,col);
|
wolffd@0
|
1134 new_marks=find(udata.bmus==ind);
|
wolffd@0
|
1135
|
wolffd@0
|
1136 if strcmp(get(gcbo,'Tag'),'TmpPatch');
|
wolffd@0
|
1137
|
wolffd@0
|
1138 % if the callback is made via temporary patch object, node is marked
|
wolffd@0
|
1139 % (node is black) => the mark is to be removed
|
wolffd@0
|
1140
|
wolffd@0
|
1141 node_color = getfield(get(gcbo,'FaceVertexCData'),{ind,[1:3]});
|
wolffd@0
|
1142 AGAIN = 1;
|
wolffd@0
|
1143 end
|
wolffd@0
|
1144
|
wolffd@0
|
1145
|
wolffd@0
|
1146
|
wolffd@0
|
1147 for i=1:length(udata.tmp_patch)
|
wolffd@0
|
1148 color = get(udata.tmp_patch(i),'FaceVertexCData');
|
wolffd@0
|
1149 if length(size(color)) ~= 2
|
wolffd@0
|
1150 color = reshape(color,[size(color,1) 3]);
|
wolffd@0
|
1151 end
|
wolffd@0
|
1152 if all(isnan(color(ind,:)))
|
wolffd@0
|
1153 NEW=1;
|
wolffd@0
|
1154 color(ind,:)=[0 0 0];
|
wolffd@0
|
1155 else
|
wolffd@0
|
1156 color(ind,:)=[NaN NaN NaN];
|
wolffd@0
|
1157 end
|
wolffd@0
|
1158 set(udata.tmp_patch(i),'FaceVertexCData',color);
|
wolffd@0
|
1159 end
|
wolffd@0
|
1160
|
wolffd@0
|
1161 set(0,'CurrentFigure',udata.fig1);
|
wolffd@0
|
1162
|
wolffd@0
|
1163 for j=1:length(udata.h)
|
wolffd@0
|
1164 subplot(udata.h(j));
|
wolffd@0
|
1165 if NEW
|
wolffd@0
|
1166 y=getfield(get(udata.d(j),'YData'),{new_marks});
|
wolffd@0
|
1167 udata.d_mark(j).h=[udata.d_mark(j).h;plot(new_marks,y,'Color',[0 0 0],...
|
wolffd@0
|
1168 'LineStyle','none',...
|
wolffd@0
|
1169 'Marker','o')];
|
wolffd@0
|
1170 end
|
wolffd@0
|
1171 end
|
wolffd@0
|
1172
|
wolffd@0
|
1173
|
wolffd@0
|
1174 if ~isempty(udata.fig2)
|
wolffd@0
|
1175 set(0,'CurrentFigure',udata.fig2);
|
wolffd@0
|
1176 for j=1:length(udata.h2);
|
wolffd@0
|
1177 subplot(udata.h2(j));
|
wolffd@0
|
1178 if NEW
|
wolffd@0
|
1179 y=getfield(get(udata.d2(j),'YData'),{new_marks});
|
wolffd@0
|
1180 udata.d_mark2(j).h=[udata.d_mark2(j).h;plot(new_marks,y,...
|
wolffd@0
|
1181 'LineStyle','none',...
|
wolffd@0
|
1182 'Color','black',...
|
wolffd@0
|
1183 'Marker','o')];
|
wolffd@0
|
1184 end
|
wolffd@0
|
1185 end
|
wolffd@0
|
1186 end
|
wolffd@0
|
1187
|
wolffd@0
|
1188 if NEW
|
wolffd@0
|
1189 udata.new_marks=[udata.new_marks; new_marks];
|
wolffd@0
|
1190 end
|
wolffd@0
|
1191
|
wolffd@0
|
1192 if AGAIN
|
wolffd@0
|
1193
|
wolffd@0
|
1194 % find marks from the data that map to the clicked node. if the color
|
wolffd@0
|
1195 % of the mark(s) is the same as the node's color, remove mark(s), else
|
wolffd@0
|
1196 % let mark be unchanged.
|
wolffd@0
|
1197
|
wolffd@0
|
1198 for i=1:length(udata.d_mark(1).h)
|
wolffd@0
|
1199 if all(node_color==get(udata.d_mark(1).h(i),'Color'))
|
wolffd@0
|
1200 tmp1 = get(udata.d_mark(1).h(i),'XData');
|
wolffd@0
|
1201 tmp2 = setdiff(tmp1,new_marks);
|
wolffd@0
|
1202 if length(tmp1) ~= length(tmp2)
|
wolffd@0
|
1203 inds=[];
|
wolffd@0
|
1204 for j=1:length(tmp2);
|
wolffd@0
|
1205 inds=[inds find(tmp2(j)==tmp1)];
|
wolffd@0
|
1206 end
|
wolffd@0
|
1207 for j=1:length(udata.d_mark)
|
wolffd@0
|
1208 ydata=getfield(get(udata.d_mark(j).h(i),'YData'),{inds});
|
wolffd@0
|
1209 set(udata.d_mark(j).h(i),'XData',tmp2,'YData',ydata);
|
wolffd@0
|
1210 end
|
wolffd@0
|
1211 if ~isempty(udata.fig2)
|
wolffd@0
|
1212 for j=1:length(udata.d_mark2)
|
wolffd@0
|
1213 ydata=getfield(get(udata.d_mark2(j).h(i),'YData'),{inds});
|
wolffd@0
|
1214 set(udata.d_mark2(j).h(i),'XData',tmp2,'YData',ydata);
|
wolffd@0
|
1215 end
|
wolffd@0
|
1216 end
|
wolffd@0
|
1217 end
|
wolffd@0
|
1218 end
|
wolffd@0
|
1219 end
|
wolffd@0
|
1220 udata.new_marks=setdiff(udata.new_marks, new_marks);
|
wolffd@0
|
1221 udata.all_marks=setdiff(udata.all_marks,new_marks);
|
wolffd@0
|
1222 end
|
wolffd@0
|
1223
|
wolffd@0
|
1224 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
1225 set(0,'CurrentFigure',old);
|
wolffd@0
|
1226
|
wolffd@0
|
1227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1228
|
wolffd@0
|
1229 function draw_poly()
|
wolffd@0
|
1230
|
wolffd@0
|
1231 udata=get(gcf,'UserData');
|
wolffd@0
|
1232 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
1233
|
wolffd@0
|
1234 if isempty(udata.poly.x)
|
wolffd@0
|
1235 if strcmp(get(gcf,'SelectionType'),'alt')
|
wolffd@0
|
1236 return;
|
wolffd@0
|
1237 end
|
wolffd@0
|
1238 udata.poly.THIS = gca;
|
wolffd@0
|
1239 end
|
wolffd@0
|
1240
|
wolffd@0
|
1241 % 'THIS' indicates what was the axes where the polygon was meant to
|
wolffd@0
|
1242 % drawn. It is not possible to add points, that lie in another axes, to the
|
wolffd@0
|
1243 % polygon.
|
wolffd@0
|
1244
|
wolffd@0
|
1245
|
wolffd@0
|
1246 if gca ~= udata.poly.THIS
|
wolffd@0
|
1247 return;
|
wolffd@0
|
1248 end
|
wolffd@0
|
1249
|
wolffd@0
|
1250 coords(1,1) = getfield(get(gca,'CurrentPoint'),{3});
|
wolffd@0
|
1251 coords(1,2) = getfield(get(gca,'CurrentPoint'),{1});
|
wolffd@0
|
1252
|
wolffd@0
|
1253 udata.poly.x=cat(1,udata.poly.x,coords(2));
|
wolffd@0
|
1254 udata.poly.y=cat(1,udata.poly.y,coords(1));
|
wolffd@0
|
1255
|
wolffd@0
|
1256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1257 % remove old 'polygon' from axis
|
wolffd@0
|
1258
|
wolffd@0
|
1259 delete(udata.poly.h);
|
wolffd@0
|
1260
|
wolffd@0
|
1261
|
wolffd@0
|
1262 switch get(gcf,'SelectionType')
|
wolffd@0
|
1263 case 'normal'
|
wolffd@0
|
1264
|
wolffd@0
|
1265 % add point to the 'polygon' and draw it
|
wolffd@0
|
1266
|
wolffd@0
|
1267 for i=1:length(udata.a_h)
|
wolffd@0
|
1268 subplot(udata.a_h(i));
|
wolffd@0
|
1269 hold on;
|
wolffd@0
|
1270 udata.poly.h(i) = plot(udata.poly.x,udata.poly.y,'black',...
|
wolffd@0
|
1271 'EraseMode','xor',...
|
wolffd@0
|
1272 'ButtonDownFcn',...
|
wolffd@0
|
1273 'vis_trajgui([],''click'')',...
|
wolffd@0
|
1274 'LineWidth',2);
|
wolffd@0
|
1275 end
|
wolffd@0
|
1276 case 'alt'
|
wolffd@0
|
1277
|
wolffd@0
|
1278 % The polygon is ready.
|
wolffd@0
|
1279
|
wolffd@0
|
1280
|
wolffd@0
|
1281 udata.poly.x=cat(1,udata.poly.x,udata.poly.x(1));
|
wolffd@0
|
1282 udata.poly.y=cat(1,udata.poly.y,udata.poly.y(1));
|
wolffd@0
|
1283
|
wolffd@0
|
1284 for i=1:length(udata.a_h)
|
wolffd@0
|
1285 subplot(udata.a_h(i));
|
wolffd@0
|
1286 udata.poly.h(i) = plot(udata.poly.x,udata.poly.y,'black',...
|
wolffd@0
|
1287 'EraseMode','xor',...
|
wolffd@0
|
1288 'ButtonDownFcn',...
|
wolffd@0
|
1289 'vis_trajgui([],''click'')',...
|
wolffd@0
|
1290 'LineWidth',2);
|
wolffd@0
|
1291 end
|
wolffd@0
|
1292
|
wolffd@0
|
1293 tmp=sort(repmat((1:udata.msize(1))',udata.msize(2),1));
|
wolffd@0
|
1294 tmp(:,2)=repmat((1:udata.msize(2))',udata.msize(1),1);
|
wolffd@0
|
1295 tmp2=tmp;
|
wolffd@0
|
1296 if strcmp(udata.lattice,'hexa');
|
wolffd@0
|
1297 t=find(~rem(tmp(:,1),2));
|
wolffd@0
|
1298 tmp(t,2)=tmp(t,2)+0.5;
|
wolffd@0
|
1299 end
|
wolffd@0
|
1300
|
wolffd@0
|
1301
|
wolffd@0
|
1302 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1303 % find the nodes that lie inside polygon and change coordinates to
|
wolffd@0
|
1304 % linear indices.
|
wolffd@0
|
1305
|
wolffd@0
|
1306 in = find(inpolygon(tmp(:,2),tmp(:,1),udata.poly.x,udata.poly.y));
|
wolffd@0
|
1307 in = sub2ind(udata.msize,tmp2(in,1),tmp2(in,2));
|
wolffd@0
|
1308
|
wolffd@0
|
1309 colors=get(udata.tmp_patch(1),'FaceVertexCData');
|
wolffd@0
|
1310 colors=reshape(colors,[size(colors,1) 3]);
|
wolffd@0
|
1311 tmp=ones(length(in),1);
|
wolffd@0
|
1312
|
wolffd@0
|
1313 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1314 % set the color of the nodes just selected, black.
|
wolffd@0
|
1315
|
wolffd@0
|
1316 colors(in,:)=tmp*[0 0 0];
|
wolffd@0
|
1317 set(udata.tmp_patch,'FaceVertexCData',colors);
|
wolffd@0
|
1318
|
wolffd@0
|
1319 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1320 % find the points mapping to the nodes from data
|
wolffd@0
|
1321
|
wolffd@0
|
1322 inds = [];
|
wolffd@0
|
1323 for i=1:length(in)
|
wolffd@0
|
1324 inds=[inds;find(in(i) == udata.bmus)];
|
wolffd@0
|
1325 end
|
wolffd@0
|
1326
|
wolffd@0
|
1327 %%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1328 % plot marks to data
|
wolffd@0
|
1329
|
wolffd@0
|
1330 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
1331 plot2data(inds);
|
wolffd@0
|
1332 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
1333 udata.new_marks=union(udata.new_marks,inds);
|
wolffd@0
|
1334 delete(udata.poly.h);
|
wolffd@0
|
1335 udata.poly.h=[];
|
wolffd@0
|
1336 udata.poly.x=[];
|
wolffd@0
|
1337 udata.poly.y=[];
|
wolffd@0
|
1338 udata.poly.THIS=[];
|
wolffd@0
|
1339 end
|
wolffd@0
|
1340
|
wolffd@0
|
1341 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
1342
|
wolffd@0
|
1343 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1344
|
wolffd@0
|
1345 function save_data()
|
wolffd@0
|
1346
|
wolffd@0
|
1347 udata=get(gcf,'UserData');
|
wolffd@0
|
1348 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
1349
|
wolffd@0
|
1350 data.points=[];
|
wolffd@0
|
1351 data.nodes=[];
|
wolffd@0
|
1352 k=1;
|
wolffd@0
|
1353
|
wolffd@0
|
1354 for i=1:length(udata.d_mark(1).h)
|
wolffd@0
|
1355 data.points(i).inds=get(udata.d_mark(1).h(i),'XData');
|
wolffd@0
|
1356 data.points(i).color=get(udata.d_mark(1).h(i),'Color');
|
wolffd@0
|
1357 end
|
wolffd@0
|
1358
|
wolffd@0
|
1359 color=get(udata.tmp_patch(1),'FaceVertexCData');
|
wolffd@0
|
1360 color=reshape(color,[size(color,1) 3]);
|
wolffd@0
|
1361
|
wolffd@0
|
1362 for i=1:size(color,1)
|
wolffd@0
|
1363 if all(~isnan(color(i,:)))
|
wolffd@0
|
1364 tmp.ind=i;
|
wolffd@0
|
1365 tmp.color=color(i,:);
|
wolffd@0
|
1366 data.nodes(k)=tmp;
|
wolffd@0
|
1367 k=k+1;
|
wolffd@0
|
1368 end
|
wolffd@0
|
1369 end
|
wolffd@0
|
1370
|
wolffd@0
|
1371 answer=inputdlg('Enter the name of the output variable:','',1);
|
wolffd@0
|
1372
|
wolffd@0
|
1373 if isempty(answer) | isempty(answer{1})
|
wolffd@0
|
1374 msgbox('Output is not set to workspace.');
|
wolffd@0
|
1375 return;
|
wolffd@0
|
1376 else
|
wolffd@0
|
1377 assignin('base',answer{1},data);
|
wolffd@0
|
1378 disp(sprintf('Struct is set to the workspace as ''%s''.',answer{1}));
|
wolffd@0
|
1379 end
|
wolffd@0
|
1380
|
wolffd@0
|
1381 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1382
|
wolffd@0
|
1383 function load_data()
|
wolffd@0
|
1384
|
wolffd@0
|
1385 answer = inputdlg('Enter the name of the struct to be loaded:','',1);
|
wolffd@0
|
1386
|
wolffd@0
|
1387 if isempty(answer) | isempty(answer{1})
|
wolffd@0
|
1388 msgbox('Data is not loaded.');
|
wolffd@0
|
1389 return;
|
wolffd@0
|
1390 end
|
wolffd@0
|
1391
|
wolffd@0
|
1392 data=evalin('base',answer{1});
|
wolffd@0
|
1393
|
wolffd@0
|
1394 if ~isstruct(data)
|
wolffd@0
|
1395 errordlg('Input variable must be a struct.');
|
wolffd@0
|
1396 return;
|
wolffd@0
|
1397 end
|
wolffd@0
|
1398
|
wolffd@0
|
1399 tmp1 = fieldnames(data);
|
wolffd@0
|
1400 tmp2 = {'nodes','points'};
|
wolffd@0
|
1401
|
wolffd@0
|
1402 for i=1:length(tmp1)
|
wolffd@0
|
1403 for j=1:length(tmp2);
|
wolffd@0
|
1404 if ~any(strcmp(tmp2{j},tmp1))
|
wolffd@0
|
1405 errordlg('Wrong type of struct.');
|
wolffd@0
|
1406 return;
|
wolffd@0
|
1407 end
|
wolffd@0
|
1408 end
|
wolffd@0
|
1409 end
|
wolffd@0
|
1410
|
wolffd@0
|
1411 if ~isempty(data.points)
|
wolffd@0
|
1412 tmp1=fieldnames(data.points(1));
|
wolffd@0
|
1413 end
|
wolffd@0
|
1414 if ~isempty(data.nodes)
|
wolffd@0
|
1415 tmp2=fieldnames(data.nodes(1));
|
wolffd@0
|
1416 end
|
wolffd@0
|
1417
|
wolffd@0
|
1418 for i=1:length(tmp1)
|
wolffd@0
|
1419 if ~any(strcmp(tmp1{i},{'inds','color'}))
|
wolffd@0
|
1420 errordlg('Wrong type of struct.');
|
wolffd@0
|
1421 return;
|
wolffd@0
|
1422 end
|
wolffd@0
|
1423 end
|
wolffd@0
|
1424
|
wolffd@0
|
1425 for i=1:length(tmp2)
|
wolffd@0
|
1426 if ~any(strcmp(tmp2{i},{'ind','color'}))
|
wolffd@0
|
1427 errordlg('Wrong type of struct.');
|
wolffd@0
|
1428 return;
|
wolffd@0
|
1429 end
|
wolffd@0
|
1430 end
|
wolffd@0
|
1431
|
wolffd@0
|
1432 udata=get(gcf,'UserData');
|
wolffd@0
|
1433 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
1434
|
wolffd@0
|
1435 clear_markers;
|
wolffd@0
|
1436 remove_traj;
|
wolffd@0
|
1437
|
wolffd@0
|
1438 old = gcf;
|
wolffd@0
|
1439
|
wolffd@0
|
1440 for i=1:length(data.points)
|
wolffd@0
|
1441 for j=1:length(udata.h);
|
wolffd@0
|
1442 set(0,'CurrentFigure',udata.fig1);
|
wolffd@0
|
1443 subplot(udata.h(j));
|
wolffd@0
|
1444 ydata=getfield(get(udata.d(j),'YData'),{data.points(i).inds});
|
wolffd@0
|
1445 udata.d_mark(j).h=[udata.d_mark(j).h;...
|
wolffd@0
|
1446 plot(data.points(i).inds,ydata,...
|
wolffd@0
|
1447 'Color',data.points(i).color,...
|
wolffd@0
|
1448 'LineStyle','none',...
|
wolffd@0
|
1449 'Marker','o',...
|
wolffd@0
|
1450 'ButtonDownFcn',...
|
wolffd@0
|
1451 'vis_trajgui([],''line_down'')')];
|
wolffd@0
|
1452 if all(data.points(i).color == [0 0 0])
|
wolffd@0
|
1453 udata.new_marks=unique([udata.new_marks; (data.points(i).inds)']);
|
wolffd@0
|
1454 else
|
wolffd@0
|
1455 udata.all_marks=unique([udata.all_marks; (data.points(i).inds)']);
|
wolffd@0
|
1456 end
|
wolffd@0
|
1457 end
|
wolffd@0
|
1458 if ~isempty(udata.fig2)
|
wolffd@0
|
1459 set(0,'CurrentFigure',udata.fig2);
|
wolffd@0
|
1460 for j=1:length(udata.h2)
|
wolffd@0
|
1461 subplot(udata.h2(j));
|
wolffd@0
|
1462 ydata=getfield(get(udata.d2(j),'YData'),{data.points(i).inds});
|
wolffd@0
|
1463 udata.d_mark2(j).h=[udata.d_mark2(j).h;...
|
wolffd@0
|
1464 plot(data.points(i).inds,ydata,...
|
wolffd@0
|
1465 'Color',data.points(i).color,...
|
wolffd@0
|
1466 'LineStyle','none',...
|
wolffd@0
|
1467 'Marker','o',...
|
wolffd@0
|
1468 'ButtonDownFcn',...
|
wolffd@0
|
1469 'vis_trajgui([],''line_down'')')];
|
wolffd@0
|
1470 end
|
wolffd@0
|
1471 end
|
wolffd@0
|
1472 end
|
wolffd@0
|
1473
|
wolffd@0
|
1474
|
wolffd@0
|
1475 set(0,'CurrentFigure',udata.sM_h);
|
wolffd@0
|
1476 color=get(udata.tmp_patch(1),'FaceVertexCData');
|
wolffd@0
|
1477 color=reshape(color,[size(color,1) 3]);
|
wolffd@0
|
1478 for i=1:length(data.nodes)
|
wolffd@0
|
1479 color(data.nodes(i).ind,:)=data.nodes(i).color;
|
wolffd@0
|
1480 end
|
wolffd@0
|
1481 for i=1:length(udata.tmp_patch);
|
wolffd@0
|
1482 set(udata.tmp_patch(i),'FaceVertexCData',color);
|
wolffd@0
|
1483 end
|
wolffd@0
|
1484
|
wolffd@0
|
1485 set(0,'CurrentFigure',old);
|
wolffd@0
|
1486 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
1487
|
wolffd@0
|
1488 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1489
|
wolffd@0
|
1490 function fuzzy_traj(trajStruct,arg);
|
wolffd@0
|
1491 %function fuzzy_traj(sM_h,sM,sD,interval,arg)
|
wolffd@0
|
1492
|
wolffd@0
|
1493
|
wolffd@0
|
1494 if isempty(arg)
|
wolffd@0
|
1495
|
wolffd@0
|
1496 if strcmp(trajStruct.lattice,'hexa')
|
wolffd@0
|
1497 udata.lattice='hexa';
|
wolffd@0
|
1498 udata.form=vis_patch('hexa');
|
wolffd@0
|
1499 else
|
wolffd@0
|
1500 data.lattice='rect';
|
wolffd@0
|
1501 udata.form=vis_patch('rect');
|
wolffd@0
|
1502 end
|
wolffd@0
|
1503
|
wolffd@0
|
1504 % interval=[1 size(trajStruct.primary_data,1)];
|
wolffd@0
|
1505
|
wolffd@0
|
1506 l=size(udata.form,1);
|
wolffd@0
|
1507 dim = size(trajStruct.primary_data,2);
|
wolffd@0
|
1508 udata.a_h=[findobj(get(trajStruct.figure,'Children'),'Tag','Uplane');...
|
wolffd@0
|
1509 findobj(get(trajStruct.figure,'Children'),'Tag','Cplane')];
|
wolffd@0
|
1510
|
wolffd@0
|
1511 udata.sM_h=trajStruct.figure;
|
wolffd@0
|
1512 udata.msize=trajStruct.msize;
|
wolffd@0
|
1513
|
wolffd@0
|
1514 %%%%%%%%%%%%%%%
|
wolffd@0
|
1515 %
|
wolffd@0
|
1516 % constructing patch that is drawn above every plane in map
|
wolffd@0
|
1517 %
|
wolffd@0
|
1518
|
wolffd@0
|
1519 nx = repmat(udata.form(:,1),1,prod(udata.msize));
|
wolffd@0
|
1520 ny = repmat(udata.form(:,2),1,prod(udata.msize));
|
wolffd@0
|
1521
|
wolffd@0
|
1522 x_c=reshape(repmat(1:udata.msize(2),l*udata.msize(1),1),l,prod(udata.msize));
|
wolffd@0
|
1523 y_c=repmat(repmat(1:udata.msize(1),l,1),1,udata.msize(2));
|
wolffd@0
|
1524
|
wolffd@0
|
1525 if strcmp(udata.lattice,'hexa')
|
wolffd@0
|
1526 t = find(~rem(y_c(1,:),2));
|
wolffd@0
|
1527 x_c(:,t)=x_c(:,t)+.5;
|
wolffd@0
|
1528 end
|
wolffd@0
|
1529
|
wolffd@0
|
1530 x_c=x_c+nx;
|
wolffd@0
|
1531 y_c=y_c+ny;
|
wolffd@0
|
1532
|
wolffd@0
|
1533 udata.orig_c=ones(prod(udata.msize),1)*[NaN NaN NaN];
|
wolffd@0
|
1534 colors=reshape(udata.orig_c,[1 size(udata.orig_c,1) 3]);
|
wolffd@0
|
1535 set(0,'CurrentFigure',trajStruct.figure);
|
wolffd@0
|
1536
|
wolffd@0
|
1537 %%%%%%%%%
|
wolffd@0
|
1538 % drawing
|
wolffd@0
|
1539
|
wolffd@0
|
1540 for i=1:length(udata.a_h);
|
wolffd@0
|
1541 subplot(udata.a_h(i));
|
wolffd@0
|
1542 v=caxis;
|
wolffd@0
|
1543 udata.patch_h(i) =patch(x_c,y_c,colors,'EdgeColor','none');
|
wolffd@0
|
1544 caxis(v);
|
wolffd@0
|
1545 end
|
wolffd@0
|
1546
|
wolffd@0
|
1547
|
wolffd@0
|
1548 udata.orig_x=get(udata.patch_h(1),'XData');
|
wolffd@0
|
1549 udata.orig_y=get(udata.patch_h(1),'YData');
|
wolffd@0
|
1550
|
wolffd@0
|
1551 % if interval(1) < 1 | interval(2) > size(trajStruct.primary_data,1)
|
wolffd@0
|
1552 % error('Invalid argument ''interval''.');
|
wolffd@0
|
1553 % end
|
wolffd@0
|
1554
|
wolffd@0
|
1555 x=1:size(trajStruct.primary_data,1);
|
wolffd@0
|
1556 udata.fig1=figure;
|
wolffd@0
|
1557 set(udata.fig1,'KeyPressFcn',...
|
wolffd@0
|
1558 'vis_trajgui([],''move_fuzzy'')');
|
wolffd@0
|
1559 for i=1:size(trajStruct.primary_data,2)
|
wolffd@0
|
1560 subplot(size(trajStruct.primary_data,2),1,i);
|
wolffd@0
|
1561 udata.h(i)=gca;
|
wolffd@0
|
1562 set(udata.h(1),'XTick',[]);
|
wolffd@0
|
1563 udata.d(i)=plot(x,trajStruct.primary_data(:,i));
|
wolffd@0
|
1564 l_x=1;
|
wolffd@0
|
1565 lims(1) = round(min(trajStruct.primary_data(:,i)));
|
wolffd@0
|
1566 lims(2) = round(max(trajStruct.primary_data(:,i)));
|
wolffd@0
|
1567 udata.l(i) = line([l_x l_x],lims,'Color','red','EraseMode','xor');
|
wolffd@0
|
1568 end
|
wolffd@0
|
1569
|
wolffd@0
|
1570 udata.l_x = l_x;
|
wolffd@0
|
1571 udata.interval=[1 size(trajStruct.bmus,2)];
|
wolffd@0
|
1572
|
wolffd@0
|
1573 tmp.fig1=udata.fig1;
|
wolffd@0
|
1574 % [K,P] = estimate_kernels(sM,sD);
|
wolffd@0
|
1575 % udata.K=K;
|
wolffd@0
|
1576 % udata.P=P;
|
wolffd@0
|
1577 % udata.codebook=sM.codebook;
|
wolffd@0
|
1578 % udata.data=sD.data;
|
wolffd@0
|
1579 udata.bmus=trajStruct.bmus;
|
wolffd@0
|
1580 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
1581 set(trajStruct.figure,'UserData',tmp);
|
wolffd@0
|
1582 draw_fuzzy(l_x);
|
wolffd@0
|
1583 return;
|
wolffd@0
|
1584 end
|
wolffd@0
|
1585
|
wolffd@0
|
1586 move_fuzzy;
|
wolffd@0
|
1587
|
wolffd@0
|
1588 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1589
|
wolffd@0
|
1590 function draw_fuzzy(x)
|
wolffd@0
|
1591
|
wolffd@0
|
1592 udata=get(gcf,'UserData');
|
wolffd@0
|
1593 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
1594
|
wolffd@0
|
1595 inds = find(udata.bmus(:,x));
|
wolffd@0
|
1596 [row col] = ind2sub(udata.msize,inds);
|
wolffd@0
|
1597 if strcmp(udata.lattice,'hexa')
|
wolffd@0
|
1598 t=find(~mod(row,2));
|
wolffd@0
|
1599 col(t)=col(t)+0.5;
|
wolffd@0
|
1600 end
|
wolffd@0
|
1601
|
wolffd@0
|
1602 color=udata.orig_c;
|
wolffd@0
|
1603 color=reshape(color,[size(color,1) 3]);
|
wolffd@0
|
1604 xdata=udata.orig_x;
|
wolffd@0
|
1605 ydata=udata.orig_y;
|
wolffd@0
|
1606 tmp= ones(size(xdata(:,1),1),1)*udata.bmus(inds,x)';
|
wolffd@0
|
1607 color(inds,:) = ones(length(inds),1)*[0 0 0];
|
wolffd@0
|
1608 xdata(:,inds) = udata.form(:,1)*ones(1,length(inds)).*tmp+ones(6,1)*col';
|
wolffd@0
|
1609 ydata(:,inds) = udata.form(:,2)*ones(1,length(inds)).*tmp+ones(6,1)*row';
|
wolffd@0
|
1610
|
wolffd@0
|
1611 set(udata.patch_h,'FaceVertexCData',color,'XData',xdata,'YData',ydata);
|
wolffd@0
|
1612
|
wolffd@0
|
1613 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1614
|
wolffd@0
|
1615 function move_fuzzy
|
wolffd@0
|
1616
|
wolffd@0
|
1617 % moves pointer lines and draws fuzzy response.
|
wolffd@0
|
1618
|
wolffd@0
|
1619 udata=get(gcf,'UserData');
|
wolffd@0
|
1620 udata=get(udata.fig1,'UserData');
|
wolffd@0
|
1621
|
wolffd@0
|
1622 switch get(gcf,'CurrentCharacter');
|
wolffd@0
|
1623 case {'<','>'}
|
wolffd@0
|
1624 key = get(gcf,'CurrentCharacter');
|
wolffd@0
|
1625 if key == '>'
|
wolffd@0
|
1626 if udata.l_x + 1 > udata.interval(2)
|
wolffd@0
|
1627 return;
|
wolffd@0
|
1628 end
|
wolffd@0
|
1629 l_x = udata.l_x + 1;
|
wolffd@0
|
1630 else
|
wolffd@0
|
1631 if udata.l_x - 1 < udata.interval(1)
|
wolffd@0
|
1632 return;
|
wolffd@0
|
1633 end
|
wolffd@0
|
1634 l_x = udata.l_x - 1;
|
wolffd@0
|
1635 end
|
wolffd@0
|
1636 draw_fuzzy(l_x);
|
wolffd@0
|
1637 set(udata.l,'XData',[l_x l_x]);
|
wolffd@0
|
1638 udata.l_x=l_x;
|
wolffd@0
|
1639 set(udata.fig1,'UserData',udata);
|
wolffd@0
|
1640 otherwise
|
wolffd@0
|
1641 return;
|
wolffd@0
|
1642 end
|
wolffd@0
|
1643
|
wolffd@0
|
1644 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
wolffd@0
|
1645
|
wolffd@0
|
1646
|
wolffd@0
|
1647
|