wolffd@0: function vis_trajgui(trajStruct,arg) wolffd@0: wolffd@0: % VIS_TRAJGUI subfuntion for SOM_TRAJECTORY wolffd@0: % wolffd@0: % This function is the actual GUI called by SOM_TRAJECTORY wolffd@0: % function. wolffd@0: % wolffd@0: % See also SOM_TRAJECTORY. wolffd@0: wolffd@0: % Contributed code to SOM Toolbox 2.0, February 11th, 2000 by Juha Parhankangas wolffd@0: % Copyright (c) by Juha Parhankangas. wolffd@0: % http://www.cis.hut.fi/projects/somtoolbox/ wolffd@0: wolffd@0: % Version 2.0beta juha 180699 wolffd@0: wolffd@0: if nargin == 1 wolffd@0: wolffd@0: sM_h=trajStruct.figure; wolffd@0: wolffd@0: if size(trajStruct.bmus,1) ~= 1 & size(trajStruct.bmus,2) ~= 1 wolffd@0: fuzzy_traj(trajStruct,[]); wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: wolffd@0: if size(trajStruct.bmus,1) == 1 | size(trajStruct.bmus,2) == 1 wolffd@0: wolffd@0: udata.bmus = trajStruct.bmus; wolffd@0: udata.a_h=[findobj(get(sM_h,'Children'),'Tag','Uplane');... wolffd@0: findobj(get(sM_h,'Children'),'Tag','Cplane')]; wolffd@0: udata.sM_h=trajStruct.figure; wolffd@0: udata.traj=[]; wolffd@0: data1 = trajStruct.primary_data; wolffd@0: if ~isempty(trajStruct.primary_names) wolffd@0: names=trajStruct.primary_names; wolffd@0: else wolffd@0: for i=1:size(data1,2) wolffd@0: names{i,1}=sprintf('Var%d',i); wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: udata.lattice=trajStruct.lattice; wolffd@0: form = 0.7*vis_patch(udata.lattice); wolffd@0: udata.msize = trajStruct.msize; wolffd@0: wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: % wolffd@0: % forming a patch object, which is placed above every component plane wolffd@0: % wolffd@0: wolffd@0: wolffd@0: l = size(form,1); wolffd@0: wolffd@0: nx = repmat(form(:,1),1,prod(udata.msize)); wolffd@0: ny = repmat(form(:,2),1,prod(udata.msize)); wolffd@0: wolffd@0: x=reshape(repmat(1:udata.msize(2),l*udata.msize(1),1),l,prod(udata.msize)); wolffd@0: y=repmat(repmat(1:udata.msize(1),l,1),1,udata.msize(2)); wolffd@0: wolffd@0: if strcmp(udata.lattice,'hexa') wolffd@0: t = find(~rem(y(1,:),2)); wolffd@0: x(:,t)=x(:,t)+.5; wolffd@0: end wolffd@0: x=x+nx; wolffd@0: y=y+ny; wolffd@0: wolffd@0: colors=reshape(ones(prod(udata.msize),1)*[NaN NaN NaN],... wolffd@0: [1 prod(udata.msize) 3]); wolffd@0: wolffd@0: set(0,'CurrentFigure',udata.sM_h); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%% wolffd@0: % wolffd@0: % drawing patch wolffd@0: % wolffd@0: % caxis -commands keep the colormap of the original patch unchanged. wolffd@0: % wolffd@0: wolffd@0: for i=1:length(udata.a_h) wolffd@0: udata.real_patch(i)=get(udata.a_h(i),'Children'); wolffd@0: set(udata.real_patch(i),'ButtonDownFcn',... wolffd@0: 'vis_trajgui([],''click'')'); wolffd@0: subplot(udata.a_h(i)); wolffd@0: v=caxis; wolffd@0: udata.tmp_patch(i)=patch(x,y,colors,'EdgeColor','none',... wolffd@0: 'ButtonDownFcn',... wolffd@0: 'vis_trajgui([],''click'')',... wolffd@0: 'Tag','TmpPatch'); wolffd@0: caxis(v); wolffd@0: end wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: wolffd@0: wolffd@0: udata.length_of_traj=length(trajStruct.size); wolffd@0: udata.size=trajStruct.size; wolffd@0: udata.color=trajStruct.color; wolffd@0: udata.poly.x=[]; wolffd@0: udata.poly.y=[]; wolffd@0: udata.poly.h=[]; wolffd@0: udata.new_marks=[]; wolffd@0: udata.all_marks=[]; wolffd@0: udata.d_mark2=[]; wolffd@0: udata.fig1 = figure; wolffd@0: set(udata.fig1,'KeyPressFcn','vis_trajgui([],''key'')',... wolffd@0: 'Name','Primary Data'); wolffd@0: wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%% wolffd@0: % wolffd@0: % making the 'Tools' -menu wolffd@0: % wolffd@0: wolffd@0: udata.m_i=uimenu(udata.fig1,'Label','Trajectoy T&ools'); wolffd@0: udata.m_i(2)=uimenu(udata.m_i,'Label','&Remove Trajectory',... wolffd@0: 'Callback',... wolffd@0: 'vis_trajgui([],''remove_traj'')'); wolffd@0: udata.m_i(3)=uimenu(udata.m_i(1),'Label','&Dye Nodes',... wolffd@0: 'Callback',... wolffd@0: 'vis_trajgui([],''dye_gui'')'); wolffd@0: udata.m_i(4)=uimenu(udata.m_i(1),'Label','&Clear Markers',... wolffd@0: 'Callback',... wolffd@0: 'vis_trajgui([],''clear'')'); wolffd@0: udata.m_i(5)=uimenu(udata.m_i(1),'Label','&Save',... wolffd@0: 'Callback',... wolffd@0: 'vis_trajgui([],''save'')'); wolffd@0: udata.m_i(6)=uimenu(udata.m_i(1),'Label','&Load',... wolffd@0: 'Callback',... wolffd@0: 'vis_trajgui([],''load'')'); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: % wolffd@0: % drawing data components to the figure .... wolffd@0: % wolffd@0: % wolffd@0: wolffd@0: if nargin < 5 | isempty(comps) | (isstr(comps) & strcmp(comps,'all')) wolffd@0: comps = 1:size(data1,2); wolffd@0: end wolffd@0: wolffd@0: x=1:size(data1,1); wolffd@0: wolffd@0: for i=1:length(comps) wolffd@0: subplot(length(comps),1,i); wolffd@0: udata.h(i)=gca; wolffd@0: udata.d_mark(i).h=[]; wolffd@0: wolffd@0: udata.d(i)=plot(x,data1(:,comps(i)),... wolffd@0: 'ButtonDownFcn',... wolffd@0: 'vis_trajgui([],''line_down'')'); wolffd@0: set(gca,'XLim',[1 size(data1,1)],... wolffd@0: 'XTick',[],... wolffd@0: 'ButtonDownFcn','vis_trajgui([],''line_down'')'); %,... wolffd@0: %'YLim',[min(data1(:,comps(i))) max(data1(:,comps(i)))]); wolffd@0: wolffd@0: ylabel(names{comps(i)}); wolffd@0: hold on; wolffd@0: ymin=get(udata.h(i),'YLim'); wolffd@0: pos=mean(get(udata.h(i),'XLim')); wolffd@0: udata.l(i) = line([pos pos],[ymin(1) ymin(2)],... wolffd@0: 'Color','red',... wolffd@0: 'ButtonDownFcn',... wolffd@0: 'vis_trajgui([],''down'')'); wolffd@0: end wolffd@0: udata.text1=[]; wolffd@0: wolffd@0: udata.fig2=[]; wolffd@0: udata.h2=[]; wolffd@0: udata.l2=[]; wolffd@0: udata.text2=[]; wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: % wolffd@0: % ... and to the figure 2. wolffd@0: % wolffd@0: wolffd@0: wolffd@0: if ~isempty(trajStruct.secondary_data) wolffd@0: data2=trajStruct.secondary_data; wolffd@0: if isempty(trajStruct.secondary_names) wolffd@0: for i=1:size(data1,2) wolffd@0: names2{i,1}=sprintf('Var%d',i); wolffd@0: end wolffd@0: else wolffd@0: names2=trajStruct.secondary_names; wolffd@0: end wolffd@0: wolffd@0: udata.fig2 = figure; wolffd@0: set(udata.fig2,'Name','Secondary Data'); wolffd@0: set(udata.fig2,'KeyPressFcn',... wolffd@0: 'vis_trajgui([],''key'')'); wolffd@0: for i=1:size(data2,2) wolffd@0: subplot(size(data2,2),1,i); wolffd@0: udata.h2(i) = gca; wolffd@0: udata.d_mark2(i).h=[]; wolffd@0: udata.d2(i) = plot(x,data2(:,i),... wolffd@0: 'ButtonDownFcn',... wolffd@0: 'vis_trajgui([],''line_down'')'); wolffd@0: set(gca,'XLim',[1 size(data1,1)],'XTick',[],'ButtonDownFcn',... wolffd@0: 'vis_trajgui([],[],[],[],[],[],''line_down'')'); wolffd@0: ylabel(names2{i}); wolffd@0: hold on; wolffd@0: ymin = get(udata.h2(i),'YLim'); wolffd@0: pos = mean(get(udata.h2(i),'XLim')); wolffd@0: udata.l2(i) = line([pos pos],ymin,'Color','red',... wolffd@0: 'ButtonDownFcn','vis_trajgui([],''down'')'); wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: if ~isempty(udata.fig2); wolffd@0: tmp.fig1=udata.fig1; wolffd@0: set(udata.fig2,'UserData',tmp); wolffd@0: end wolffd@0: tmp=get(udata.sM_h,'UserData'); wolffd@0: tmp.fig1=udata.fig1; wolffd@0: set(udata.sM_h,'UserData',tmp); wolffd@0: set_numbers(round(pos)); wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: end wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%% wolffd@0: % wolffd@0: % if figures have been drawn, the only function calls that may exist wolffd@0: % are the ones that change the state of the application. wolffd@0: % wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: switch arg wolffd@0: case 'fuzzy' wolffd@0: fuzzy_traj(tS,[]); wolffd@0: return; wolffd@0: case 'move_fuzzy' wolffd@0: fuzzy_traj([],'move'); wolffd@0: return; wolffd@0: case 'remove_traj' wolffd@0: remove_traj; wolffd@0: return; wolffd@0: case 'line_down' wolffd@0: line_bdf('down'); wolffd@0: return; wolffd@0: case 'line_drag' wolffd@0: line_bdf('drag'); wolffd@0: return; wolffd@0: case 'line_up' wolffd@0: line_bdf('up'); wolffd@0: return; wolffd@0: case 'dye_gui'; wolffd@0: color_gui(udata.fig1); wolffd@0: return; wolffd@0: case {'dye','cyan','magenta','yellow','red','green','blue','white','grey'} wolffd@0: dye_nodes(arg); wolffd@0: return; wolffd@0: case 'clear' wolffd@0: clear_markers; wolffd@0: return; wolffd@0: case 'key' wolffd@0: key_bdf; wolffd@0: return; wolffd@0: case 'click' wolffd@0: click; wolffd@0: return; wolffd@0: case 'save' wolffd@0: save_data; wolffd@0: return; wolffd@0: case 'load' wolffd@0: load_data; wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: wolffd@0: %%%%%%%%%% wolffd@0: % wolffd@0: % lines in the data figure(s) are dragged ... wolffd@0: % wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: wolffd@0: lims=get(gca,'XLim'); wolffd@0: x = getfield(get(gca,'CurrentPoint'),{1}); % the location of the line wolffd@0: wolffd@0: if x < lims(1) wolffd@0: x=lims(1); wolffd@0: elseif x > lims(2) wolffd@0: x=lims(2); wolffd@0: end wolffd@0: wolffd@0: old = gcf; wolffd@0: wolffd@0: switch arg wolffd@0: case 'down',... wolffd@0: wolffd@0: % mouse button is pressed down above the line wolffd@0: wolffd@0: set(gcf,'WindowButtonMotionFcn','vis_trajgui([],''drag'')'); wolffd@0: set(gcf,'WindowButtonUpFcn','vis_trajgui([],''up'')'); wolffd@0: set(udata.l,'EraseMode','xor'); wolffd@0: delete(udata.text1); wolffd@0: if ~isempty(udata.l2); wolffd@0: set(udata.l2,'EraseMode','xor'); wolffd@0: delete(udata.text2); wolffd@0: end wolffd@0: set(gcf,'Pointer','crosshair'); wolffd@0: wolffd@0: case 'drag' wolffd@0: % change the location of the lines wolffd@0: wolffd@0: set(0,'CurrentFigure',udata.fig1); wolffd@0: set(udata.l,'XData',[x x]); wolffd@0: if ~isempty(udata.fig2) wolffd@0: set(0,'CurrentFigure',udata.fig2); wolffd@0: set(udata.l2,'XData',[x x]); wolffd@0: end wolffd@0: draw_traj(round(x)); wolffd@0: set(0,'CurrentFigure',old); wolffd@0: case 'up' wolffd@0: wolffd@0: % draw trajectory and set figure to the normal state. wolffd@0: wolffd@0: set(udata.l,'EraseMode','normal'); wolffd@0: set(gcf,'Pointer','arrow','WindowButtonMotionFcn','',... wolffd@0: 'WindowButtonUpFcn',''); wolffd@0: draw_traj(round(x)); wolffd@0: set_numbers(round(x)); wolffd@0: end wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function draw_traj(point) wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: color=udata.color; wolffd@0: eMode='normal'; wolffd@0: if isstr(udata.color) & strcmp(udata.color,'xor') wolffd@0: eMode='xor'; wolffd@0: color='black'; wolffd@0: end wolffd@0: ind=udata.bmus(point); wolffd@0: [i j] = ind2sub(udata.msize,ind); wolffd@0: if ~mod(i,2) wolffd@0: j=j+0.5; wolffd@0: end wolffd@0: old = gcf; wolffd@0: set(0,'CurrentFigure',udata.sM_h); wolffd@0: hold on; wolffd@0: if isempty(udata.traj) | length(udata.traj.h) ~= length(udata.a_h) wolffd@0: wolffd@0: % trajectory does not exist wolffd@0: wolffd@0: for i=1:length(udata.a_h) wolffd@0: subplot(udata.a_h(i)); wolffd@0: hold on; wolffd@0: new.h = plot(j,i,'Color',color,'EraseMode',eMode,'LineStyle','none'); wolffd@0: udata.traj.h(i)=new; wolffd@0: udata.traj.j=j; wolffd@0: udata.traj.i=i; wolffd@0: end wolffd@0: else wolffd@0: if length(udata.traj.j) == udata.length_of_traj wolffd@0: % if the length of trajectory == ..., wolffd@0: udata.traj.j(1) = []; % the first (the oldest) coordinate pair wolffd@0: udata.traj.i(1) = []; % is removed. wolffd@0: end wolffd@0: udata.traj.j=[udata.traj.j;j]; % the new point is added to the wolffd@0: udata.traj.i=[udata.traj.i;i]; % end of coordinate vectors (i and j) wolffd@0: for i=1:length(udata.a_h) wolffd@0: subplot(udata.a_h(i)); % remove the existing trajectory wolffd@0: delete(udata.traj.h(i).h); % and plot the new one. wolffd@0: for j=1:length(udata.traj.j) wolffd@0: udata.traj.h(i).h(j)=plot(udata.traj.j(j),udata.traj.i(j),... wolffd@0: 'Color',color,... wolffd@0: 'EraseMode',eMode,'Marker','o','LineWidth',2,... wolffd@0: 'MarkerSize',udata.size(udata.length_of_traj-j+1),... wolffd@0: 'LineStyle','none'); wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: set(0,'CurrentFigure',udata.fig1); wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function set_numbers(x); wolffd@0: wolffd@0: % This function writes the numbers beside of the pointer lines wolffd@0: wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: xlim = get(gca,'XLim'); wolffd@0: ylim = get(gca,'YLim'); wolffd@0: p = ylim(1) + 0.9*(ylim(2)-ylim(1)); wolffd@0: wolffd@0: old = gcf; wolffd@0: set(0,'CurrentFigure',udata.fig1); wolffd@0: wolffd@0: wolffd@0: for i=1:length(udata.h) wolffd@0: subplot(udata.h(i)); wolffd@0: wolffd@0: % check if the text is placed to the left side of the line... wolffd@0: wolffd@0: if abs(x-xlim(1)) > (abs(x-xlim(2))) wolffd@0: udata.text1(i)=text(x-1,p,sprintf('%d ->',x),... wolffd@0: 'VerticalAlignment','top',... wolffd@0: 'HorizontalAlignment','right',... wolffd@0: 'FontWeight','demi'); wolffd@0: else wolffd@0: wolffd@0: % or to the right side. wolffd@0: wolffd@0: udata.text1(i)=text(x+1,p,sprintf('<- %d',x),... wolffd@0: 'VerticalAlignment','top',... wolffd@0: 'FontWeight','demi'); wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if ~isempty(udata.fig2) wolffd@0: set(0,'CurrentFigure',udata.fig2); wolffd@0: wolffd@0: for i=1:length(udata.h2) wolffd@0: subplot(udata.h2(i)); wolffd@0: wolffd@0: if abs(x-xlim(1)) > (abs(x-xlim(2))) wolffd@0: udata.text2(i)=text(x-1,p,sprintf('%d ->',x),... wolffd@0: 'VerticalAlignment','top',... wolffd@0: 'HorizontalAlignment','right',... wolffd@0: 'FontWeight','demi'); wolffd@0: else wolffd@0: udata.text2(i)=text(x+1,p,sprintf('<- %d',x),... wolffd@0: 'VerticalAlignment','top',... wolffd@0: 'FontWeight','demi'); wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: set(0,'CurrentFigure',old); wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function remove_traj() wolffd@0: wolffd@0: % delete trajectory -object from every component plane. wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: if isempty(udata.traj) wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: wolffd@0: for i=1:length(udata.traj.h) wolffd@0: delete(udata.traj.h(i).h); wolffd@0: end wolffd@0: wolffd@0: udata.traj=[]; wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function line_bdf(arg) wolffd@0: wolffd@0: % this function takes care of action when region is selected in the wolffd@0: % data figure. wolffd@0: wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: xlim=get(gca,'XLim'); wolffd@0: wolffd@0: if ~(any(strcmp('THIS',fieldnames(udata)))) wolffd@0: p = getfield(get(gca,'CurrentPoint'),{1}); wolffd@0: else wolffd@0: p = getfield(get(udata.THIS,'CurrentPoint'),{1}); wolffd@0: end wolffd@0: wolffd@0: if p < xlim(1) wolffd@0: p = xlim(1); wolffd@0: elseif p > xlim(2) wolffd@0: p = xlim(2); wolffd@0: end wolffd@0: wolffd@0: wolffd@0: wolffd@0: switch arg wolffd@0: case 'down' wolffd@0: wolffd@0: % the mouse button is pressed down, the pointer lines are drawn. wolffd@0: % and the state of the figure is changed. wolffd@0: wolffd@0: udata.THIS=gca; wolffd@0: set(gcf,'WindowButtonMotionFcn',... wolffd@0: 'vis_trajgui([],''line_drag'')',... wolffd@0: 'WindowButtonUpFcn','vis_trajgui([],''line_up'')'); wolffd@0: udata.start_p=p; wolffd@0: wolffd@0: old = gcf; wolffd@0: set(0,'CurrentFigure',udata.fig1); wolffd@0: wolffd@0: for i=1:length(udata.h) wolffd@0: subplot(udata.h(i)); wolffd@0: udata.t_line.h(i)=line([p p],get(gca,'YLim'),'Color','red'); wolffd@0: udata.t_line.h2(i)=line([p p],get(gca,'YLim'),'Color','red',... wolffd@0: 'EraseMode','xor'); wolffd@0: end wolffd@0: if ~isempty(udata.h2) wolffd@0: set(0,'CurrentFigure',udata.fig2); wolffd@0: for i=1:length(udata.h2) wolffd@0: subplot(udata.h2(i)); wolffd@0: udata.t_line2.h(i)=line([p p],get(gca,'YLim'),'Color','red'); wolffd@0: udata.t_line2.h2(i)=line([p p],get(gca,'YLim'),'Color','red',... wolffd@0: 'EraseMode','xor'); wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: case 'drag' wolffd@0: wolffd@0: % change the position of the pointer lines wolffd@0: wolffd@0: old = gcf; wolffd@0: set(0,'CurrentFigure',udata.fig1); wolffd@0: set(udata.t_line.h2,'XData',[p p]); wolffd@0: if ~isempty(udata.fig2) wolffd@0: set(0,'CurrentFigure',udata.fig2); wolffd@0: set(udata.t_line2.h2,'XData',[p p]); wolffd@0: end wolffd@0: set(0,'CurrentFigure',old); wolffd@0: case 'up' wolffd@0: wolffd@0: wolffd@0: % sort the 'points' -vector and draw the markers to the data and nodes wolffd@0: wolffd@0: points=sort([round(udata.start_p) round(p)]); wolffd@0: draw_markers(points(1):points(2)); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: udata.new_marks=unique([udata.new_marks ;(points(1):points(2))']); wolffd@0: delete([udata.t_line.h2 udata.t_line.h]); wolffd@0: if ~isempty(udata.fig2) wolffd@0: delete([udata.t_line2.h2 udata.t_line2.h]); wolffd@0: end wolffd@0: set(get(udata.THIS,'Parent'),'WindowButtonMotionFcn','',... wolffd@0: 'WindowButtonUpFcn',''); wolffd@0: udata=rmfield(udata,'THIS'); wolffd@0: end wolffd@0: wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function draw_markers(x); wolffd@0: wolffd@0: plot2data(x); wolffd@0: plot2plane(x); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function plot2data(x); wolffd@0: wolffd@0: % plot black markers to the data figure(s) wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: old = gcf; wolffd@0: wolffd@0: set(0,'CurrentFigure',udata.fig1); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: % if there already exist points in the positions that are members wolffd@0: % of the set x, then the old points are removed from data figures... wolffd@0: wolffd@0: for i=1:length(udata.d_mark(1).h) wolffd@0: tmp1 = get(udata.d_mark(1).h(i),'XData'); wolffd@0: tmp2 = setdiff(tmp1,x); wolffd@0: if length(tmp1) ~= length(tmp2) wolffd@0: inds=[]; wolffd@0: for j=1:length(tmp2); wolffd@0: inds=[inds find(tmp2(j)==tmp1)]; wolffd@0: end wolffd@0: for j=1:length(udata.d_mark) wolffd@0: ydata=getfield(get(udata.d_mark(j).h(i),'YData'),{inds}); wolffd@0: set(udata.d_mark(j).h(i),'XData',tmp2,'YData',ydata); wolffd@0: end wolffd@0: if ~isempty(udata.fig2) wolffd@0: for j=1:length(udata.d_mark2) wolffd@0: ydata=getfield(get(udata.d_mark2(j).h(i),'YData'),{inds}); wolffd@0: set(udata.d_mark2(j).h(i),'XData',tmp2,'YData',ydata); wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: % ... and the new ones are plotted. wolffd@0: wolffd@0: for i=1:length(udata.h) wolffd@0: subplot(udata.h(i)); wolffd@0: h=plot(x,getfield(get(udata.d(i),'YData'),{x}),'oblack',... wolffd@0: 'ButtonDownFcn',... wolffd@0: 'vis_trajgui([],''line_down'')'); wolffd@0: udata.d_mark(i).h=[udata.d_mark(i).h;h]; wolffd@0: end wolffd@0: wolffd@0: if ~isempty(udata.h2) wolffd@0: set(0,'CurrentFigure',udata.fig2); wolffd@0: wolffd@0: for i=1:length(udata.h2) wolffd@0: subplot(udata.h2(i)); wolffd@0: h=plot(x,getfield(get(udata.d2(i),'YData'),{x}),'oblack',... wolffd@0: 'ButtonDownFcn',... wolffd@0: 'vis_trajgui([],''line_down'')'); wolffd@0: udata.d_mark2(i).h=[udata.d_mark2(i).h;h]; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: set(0,'CurrentFigure',old); wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function plot2plane(x); wolffd@0: wolffd@0: % sets markers to the component planes. wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: % wolffd@0: % actually new markers are never plotted, but the color of the patch wolffd@0: % lying above the original component plane patch is changed black in wolffd@0: % the right positions. wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: udata.new_marks=unique([udata.new_marks ;x']); wolffd@0: wolffd@0: for i=1:length(udata.a_h) wolffd@0: col=get(udata.tmp_patch(i),'FaceVertexCData'); wolffd@0: if length(size(col)) == 3 wolffd@0: col = reshape(col,[size(col,1) 3]); wolffd@0: end wolffd@0: for j=1:length(udata.new_marks) wolffd@0: col(udata.bmus(udata.new_marks(j)),:)=[0 0 0]; wolffd@0: end wolffd@0: set(udata.tmp_patch(i),'FaceVertexCData',col); wolffd@0: end wolffd@0: wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function color_gui(fig1) wolffd@0: wolffd@0: % construct the graphical user interface for changing the color of the wolffd@0: % black (marked) nodes. wolffd@0: wolffd@0: wolffd@0: udata=get(fig1,'UserData'); wolffd@0: wolffd@0: a = figure('Color',[0.8 0.8 0.8], ... wolffd@0: 'Name','Colors', ... wolffd@0: 'PaperType','a4letter', ... wolffd@0: 'Position',[518 456 120 311], ... wolffd@0: 'Tag','Fig1'); wolffd@0: wolffd@0: udata.c_struct.fig=a; wolffd@0: wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'BackgroundColor',[0.701961 0.701961 0.701961], ... wolffd@0: 'Position',[0.0700415 0.28956 0.830492 0.594566], ... wolffd@0: 'Style','frame', ... wolffd@0: 'Tag','Frame1'); wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'BackgroundColor',[0.8 0.8 0.8], ... wolffd@0: 'Position',[0.100059 0.301143 0.770456 0.571399], ... wolffd@0: 'Style','frame', ... wolffd@0: 'Tag','Frame2'); wolffd@0: wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'Callback','vis_trajgui([],''cyan'')', ... wolffd@0: 'Position',[0.130077 0.795326 0.170101 0.0617729], ... wolffd@0: 'Style','radiobutton', ... wolffd@0: 'Tag','cyan', ... wolffd@0: 'Value',1); wolffd@0: wolffd@0: wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'Callback','vis_trajgui([],''magenta'')', ... wolffd@0: 'Position',[0.130077 0.733553 0.170101 0.057912], ... wolffd@0: 'Style','radiobutton', ... wolffd@0: 'Tag','magenta'); wolffd@0: wolffd@0: wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'Callback','vis_trajgui([],''yellow'')', ... wolffd@0: 'Position',[0.130077 0.664059 0.170101 0.0617729], ... wolffd@0: 'Style','radiobutton', ... wolffd@0: 'Tag','yellow'); wolffd@0: wolffd@0: wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'Callback','vis_trajgui([],''red'')', ... wolffd@0: 'Position',[0.130077 0.590703 0.170101 0.0617729], ... wolffd@0: 'Style','radiobutton', ... wolffd@0: 'Tag','red'); wolffd@0: wolffd@0: wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'Callback','vis_trajgui([],''green'')', ... wolffd@0: 'Position',[0.130077 0.525068 0.170101 0.057912], ... wolffd@0: 'Style','radiobutton', ... wolffd@0: 'Tag','green'); wolffd@0: wolffd@0: wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'Callback','vis_trajgui([],''blue'')', ... wolffd@0: 'Position',[0.130077 0.455575 0.170101 0.0617729], ... wolffd@0: 'Style','radiobutton', ... wolffd@0: 'Tag','blue'); wolffd@0: wolffd@0: wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'Callback','vis_trajgui([],''white'')', ... wolffd@0: 'Position',[0.130077 0.38608 0.170101 0.0617729], ... wolffd@0: 'Style','radiobutton', ... wolffd@0: 'Tag','white'); wolffd@0: wolffd@0: wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'Callback','vis_trajgui([],''grey'')', ... wolffd@0: 'Position',[0.130077 0.320447 0.170101 0.057912], ... wolffd@0: 'Style','radiobutton', ... wolffd@0: 'Tag','grey'); wolffd@0: wolffd@0: wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'BackgroundColor',[0.8 0.8 0.8], ... wolffd@0: 'FontWeight','demi', ... wolffd@0: 'HorizontalAlignment','left', ... wolffd@0: 'Position',[0.32019 0.795326 0.470278 0.0501905], ... wolffd@0: 'String','Cyan', ... wolffd@0: 'Style','text', ... wolffd@0: 'Tag','StaticText1'); wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'BackgroundColor',[0.8 0.8 0.8], ... wolffd@0: 'FontWeight','demi', ... wolffd@0: 'HorizontalAlignment','left', ... wolffd@0: 'Position',[0.32019 0.733553 0.520308 0.0463296], ... wolffd@0: 'String','Magenta', ... wolffd@0: 'Style','text', ... wolffd@0: 'Tag','StaticText2'); wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'BackgroundColor',[0.8 0.8 0.8], ... wolffd@0: 'FontWeight','demi', ... wolffd@0: 'HorizontalAlignment','left', ... wolffd@0: 'Position',[0.32019 0.664059 0.470278 0.0501905], ... wolffd@0: 'String','Yellow', ... wolffd@0: 'Style','text', ... wolffd@0: 'Tag','StaticText3'); wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'BackgroundColor',[0.8 0.8 0.8], ... wolffd@0: 'FontWeight','demi', ... wolffd@0: 'HorizontalAlignment','left', ... wolffd@0: 'Position',[0.32019 0.590703 0.470278 0.0501905], ... wolffd@0: 'String','Red', ... wolffd@0: 'Style','text', ... wolffd@0: 'Tag','StaticText4'); wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'BackgroundColor',[0.8 0.8 0.8], ... wolffd@0: 'FontWeight','demi', ... wolffd@0: 'HorizontalAlignment','left', ... wolffd@0: 'Position',[0.32019 0.525068 0.470278 0.0463296], ... wolffd@0: 'String','Green', ... wolffd@0: 'Style','text', ... wolffd@0: 'Tag','StaticText5'); wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'BackgroundColor',[0.8 0.8 0.8], ... wolffd@0: 'FontWeight','demi', ... wolffd@0: 'HorizontalAlignment','left', ... wolffd@0: 'Position',[0.32019 0.455575 0.470278 0.0463296], ... wolffd@0: 'String','Blue', ... wolffd@0: 'Style','text', ... wolffd@0: 'Tag','StaticText6'); wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'BackgroundColor',[0.8 0.8 0.8], ... wolffd@0: 'FontWeight','demi', ... wolffd@0: 'HorizontalAlignment','left', ... wolffd@0: 'Position',[0.32019 0.38608 0.470278 0.0501905], ... wolffd@0: 'String','White', ... wolffd@0: 'Style','text', ... wolffd@0: 'Tag','StaticText7'); wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'BackgroundColor',[0.8 0.8 0.8], ... wolffd@0: 'FontWeight','demi', ... wolffd@0: 'HorizontalAlignment','left', ... wolffd@0: 'Position',[0.32019 0.320447 0.470278 0.0463296], ... wolffd@0: 'String','Grey', ... wolffd@0: 'Style','text', ... wolffd@0: 'Tag','StaticText8'); wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'Position',[0.0700415 0.146711 0.830492 0.135128], ... wolffd@0: 'Style','frame', ... wolffd@0: 'Tag','Frame3'); wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'BackgroundColor',[0.8 0.8 0.8], ... wolffd@0: 'Position',[0.100059 0.158293 0.770456 0.111963], ... wolffd@0: 'Style','frame', ... wolffd@0: 'Tag','Frame4'); wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'BackgroundColor',[0.8 0.8 0.8], ... wolffd@0: 'FontWeight','demi', ... wolffd@0: 'HorizontalAlignment','left', ... wolffd@0: 'Position',[0.130077 0.177597 0.270833 0.0617729], ... wolffd@0: 'String','RGB', ... wolffd@0: 'Style','text', ... wolffd@0: 'Tag','StaticText9'); wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'BackgroundColor',[1 1 1], ... wolffd@0: 'Position',[0.410243 0.173736 0.420249 0.0810768], ... wolffd@0: 'Style','edit', ... wolffd@0: 'Tag','EditText1'); wolffd@0: wolffd@0: udata.c_struct.RGB=b; wolffd@0: wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'Callback','vis_trajgui([],''dye'')', ... wolffd@0: 'FontWeight','demi', ... wolffd@0: 'Position',[0.0700415 0.0270256 0.360214 0.0772162], ... wolffd@0: 'String','OK', ... wolffd@0: 'Tag','Pushbutton1'); wolffd@0: b = uicontrol('Parent',a, ... wolffd@0: 'Units','normalized', ... wolffd@0: 'Callback','close gcf', ... wolffd@0: 'FontWeight','demi', ... wolffd@0: 'Position',[0.54032 0.0270256 0.360214 0.0772162], ... wolffd@0: 'String','Close', ... wolffd@0: 'Tag','Pushbutton2'); wolffd@0: wolffd@0: udata.c_struct.color=[0 1 1]; wolffd@0: wolffd@0: tmp.fig1=fig1; wolffd@0: set(a,'UserData',tmp); wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function dye_nodes(arg) wolffd@0: wolffd@0: % takes care of the action, when radiobuttons are pressed wolffd@0: % (or the RGB value is set) in the color_gui -figure. wolffd@0: % It also handles the starting of dying nodes and plots. wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: wolffd@0: switch arg wolffd@0: case {'cyan','magenta','yellow','red','green','blue','white','grey'} wolffd@0: h=findobj(get(gcf,'Children'),'Style','radiobutton'); wolffd@0: set(h,'Value',0); wolffd@0: set(gcbo,'Value',1); wolffd@0: end wolffd@0: wolffd@0: wolffd@0: switch arg wolffd@0: case 'cyan' wolffd@0: RGB = [0 1 1]; wolffd@0: case 'magenta' wolffd@0: RGB = [1 0 1]; wolffd@0: case 'yellow' wolffd@0: RGB = [1 1 0]; wolffd@0: case 'red' wolffd@0: RGB = [1 0 0]; wolffd@0: case 'green' wolffd@0: RGB = [0 1 0]; wolffd@0: case 'blue' wolffd@0: RGB = [0 0 1]; wolffd@0: case 'white' wolffd@0: RGB = [1 1 1]; wolffd@0: case 'grey' wolffd@0: RGB = [0.4 0.4 0.4]; wolffd@0: case 'dye' wolffd@0: wolffd@0: RGB = get(udata.c_struct.RGB,'String'); wolffd@0: if isempty(RGB) wolffd@0: dye; wolffd@0: return; wolffd@0: else wolffd@0: str1='The value of RGB must be vector containing three scalars'; wolffd@0: str2='between 0 and 1.'; wolffd@0: color = str2num(RGB); wolffd@0: set(udata.c_struct.RGB,'String',''); wolffd@0: if isempty(color) wolffd@0: close gcf; wolffd@0: udata=rmfield(udata,'c_struct'); wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: errordlg([{str1};{str2}]); wolffd@0: return; wolffd@0: end wolffd@0: if ~all([1 3] == size(color)) & ~all([3 1] == size(color)) wolffd@0: close gcf; wolffd@0: errordlg([{str1};{str2}]); wolffd@0: udata=rmfield(udata,'c_struct',udata); wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: return; wolffd@0: end wolffd@0: if ~isempty(cat(2,find(color>1),find(color<0))) wolffd@0: close gcf wolffd@0: errordlg([{str1};{str2}]); wolffd@0: udata=rmfield(udata,'c_struct',udata); wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: return; wolffd@0: end wolffd@0: udata.c_struct.color=color; wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: dye; wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: udata.c_struct.color=RGB; wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function dye() wolffd@0: wolffd@0: % dyes black markers in the component planes and in the data figures wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: inds=unique([udata.all_marks ; udata.new_marks]); wolffd@0: wolffd@0: wolffd@0: for i=1:length(udata.d_mark); wolffd@0: for j=1:length(udata.d_mark(i).h) wolffd@0: if all(get(udata.d_mark(i).h(j),'Color') == [0 0 0]) wolffd@0: set(udata.d_mark(i).h(j),'Color',udata.c_struct.color); wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if ~isempty(udata.fig2); wolffd@0: for i=1:length(udata.d_mark2) wolffd@0: for j=1:length(udata.d_mark2(i).h) wolffd@0: if all(get(udata.d_mark2(i).h(j),'Color') == [0 0 0]) wolffd@0: set(udata.d_mark2(i).h(j),'Color',udata.c_struct.color); wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: wolffd@0: for i=1:length(udata.a_h) wolffd@0: col=get(udata.tmp_patch(i),'FaceVertexCData'); wolffd@0: for j=1:length(udata.new_marks) wolffd@0: col(udata.bmus(udata.new_marks(j)),:)=udata.c_struct.color; wolffd@0: end wolffd@0: set(udata.tmp_patch(i),'FaceVertexCData',col); wolffd@0: end wolffd@0: wolffd@0: wolffd@0: udata.all_marks=unique([udata.all_marks;udata.new_marks]); wolffd@0: udata.new_marks=[]; wolffd@0: close gcf; wolffd@0: udata=rmfield(udata,'c_struct'); wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function clear_markers() wolffd@0: wolffd@0: % removes markers from the componentplanes and the data figure(s). wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: for i=1:length(udata.d_mark) wolffd@0: delete(udata.d_mark(i).h); wolffd@0: udata.d_mark(i).h=[]; wolffd@0: end wolffd@0: wolffd@0: for i=1:length(udata.d_mark2) wolffd@0: delete(udata.d_mark2(i).h); wolffd@0: udata.d_mark2(i).h=[]; wolffd@0: end wolffd@0: wolffd@0: col=NaN*get(udata.tmp_patch(1),'FaceVertexCData'); wolffd@0: col=reshape(col,[size(col,1) 3]); wolffd@0: wolffd@0: for i=1:length(udata.tmp_patch) wolffd@0: set(udata.tmp_patch(i),'FaceVertexCData',col); wolffd@0: end wolffd@0: wolffd@0: udata.new_marks=[]; wolffd@0: udata.all_marks=[]; wolffd@0: wolffd@0: wolffd@0: if any(strcmp('c_struct',fieldnames(udata))) wolffd@0: udata=rmfield(udata,'c_struct'); wolffd@0: end wolffd@0: wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function key_bdf wolffd@0: wolffd@0: % moves trajectory and pointer lines, when either of wolffd@0: % the keys '>' or '<' is pressed. wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: key=get(gcbo,'CurrentCharacter'); wolffd@0: wolffd@0: % The easiest way to get a new coordinates is to get them from the texts... wolffd@0: % The texts are either '<- x' or 'x ->' wolffd@0: wolffd@0: x=get(udata.text1(1),'String'); wolffd@0: x=str2num(x(4:length(x))); wolffd@0: wolffd@0: if isempty(x) wolffd@0: x=get(udata.text1(1),'String'); wolffd@0: x=str2num(x(1:length(x)-3)); wolffd@0: end wolffd@0: wolffd@0: switch(key) wolffd@0: case '<' wolffd@0: if x ~= 1 wolffd@0: x= x-1; wolffd@0: end wolffd@0: case '>' wolffd@0: if x ~= getfield(get(get(udata.text1(1),'Parent'),'XLim'),{2}) wolffd@0: x = x+1; wolffd@0: end wolffd@0: otherwise wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: set(udata.l,'XData',[x x]); wolffd@0: if ~isempty(udata.fig2) wolffd@0: set(udata.l2,'XData',[x x]); wolffd@0: end wolffd@0: wolffd@0: delete(udata.text1); wolffd@0: delete(udata.text2); wolffd@0: wolffd@0: set_numbers(x); wolffd@0: draw_traj(x); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function click() wolffd@0: wolffd@0: wolffd@0: switch get(gcf,'SelectionType') wolffd@0: case 'open' wolffd@0: return; wolffd@0: case {'normal','alt'} wolffd@0: draw_poly; wolffd@0: case 'extend' wolffd@0: click_node; wolffd@0: end wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function click_node() wolffd@0: wolffd@0: % takes care of the action, when the middle mouse button is wolffd@0: % pressed (mouse pointer is above some component plane). wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: new_marks=[]; wolffd@0: wolffd@0: old=gcf; wolffd@0: wolffd@0: NEW=0; wolffd@0: AGAIN = 0; wolffd@0: wolffd@0: wolffd@0: coords=get(gca,'CurrentPoint'); wolffd@0: row=round(coords(1,2)); wolffd@0: wolffd@0: if strcmp(udata.lattice,'hexa') & ~mod(row,2) wolffd@0: col = round(coords(1,1) - 0.5); wolffd@0: else wolffd@0: col = round(coords(1,1)); wolffd@0: end wolffd@0: wolffd@0: ind = sub2ind(udata.msize,row,col); wolffd@0: new_marks=find(udata.bmus==ind); wolffd@0: wolffd@0: if strcmp(get(gcbo,'Tag'),'TmpPatch'); wolffd@0: wolffd@0: % if the callback is made via temporary patch object, node is marked wolffd@0: % (node is black) => the mark is to be removed wolffd@0: wolffd@0: node_color = getfield(get(gcbo,'FaceVertexCData'),{ind,[1:3]}); wolffd@0: AGAIN = 1; wolffd@0: end wolffd@0: wolffd@0: wolffd@0: wolffd@0: for i=1:length(udata.tmp_patch) wolffd@0: color = get(udata.tmp_patch(i),'FaceVertexCData'); wolffd@0: if length(size(color)) ~= 2 wolffd@0: color = reshape(color,[size(color,1) 3]); wolffd@0: end wolffd@0: if all(isnan(color(ind,:))) wolffd@0: NEW=1; wolffd@0: color(ind,:)=[0 0 0]; wolffd@0: else wolffd@0: color(ind,:)=[NaN NaN NaN]; wolffd@0: end wolffd@0: set(udata.tmp_patch(i),'FaceVertexCData',color); wolffd@0: end wolffd@0: wolffd@0: set(0,'CurrentFigure',udata.fig1); wolffd@0: wolffd@0: for j=1:length(udata.h) wolffd@0: subplot(udata.h(j)); wolffd@0: if NEW wolffd@0: y=getfield(get(udata.d(j),'YData'),{new_marks}); wolffd@0: udata.d_mark(j).h=[udata.d_mark(j).h;plot(new_marks,y,'Color',[0 0 0],... wolffd@0: 'LineStyle','none',... wolffd@0: 'Marker','o')]; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: wolffd@0: if ~isempty(udata.fig2) wolffd@0: set(0,'CurrentFigure',udata.fig2); wolffd@0: for j=1:length(udata.h2); wolffd@0: subplot(udata.h2(j)); wolffd@0: if NEW wolffd@0: y=getfield(get(udata.d2(j),'YData'),{new_marks}); wolffd@0: udata.d_mark2(j).h=[udata.d_mark2(j).h;plot(new_marks,y,... wolffd@0: 'LineStyle','none',... wolffd@0: 'Color','black',... wolffd@0: 'Marker','o')]; wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if NEW wolffd@0: udata.new_marks=[udata.new_marks; new_marks]; wolffd@0: end wolffd@0: wolffd@0: if AGAIN wolffd@0: wolffd@0: % find marks from the data that map to the clicked node. if the color wolffd@0: % of the mark(s) is the same as the node's color, remove mark(s), else wolffd@0: % let mark be unchanged. wolffd@0: wolffd@0: for i=1:length(udata.d_mark(1).h) wolffd@0: if all(node_color==get(udata.d_mark(1).h(i),'Color')) wolffd@0: tmp1 = get(udata.d_mark(1).h(i),'XData'); wolffd@0: tmp2 = setdiff(tmp1,new_marks); wolffd@0: if length(tmp1) ~= length(tmp2) wolffd@0: inds=[]; wolffd@0: for j=1:length(tmp2); wolffd@0: inds=[inds find(tmp2(j)==tmp1)]; wolffd@0: end wolffd@0: for j=1:length(udata.d_mark) wolffd@0: ydata=getfield(get(udata.d_mark(j).h(i),'YData'),{inds}); wolffd@0: set(udata.d_mark(j).h(i),'XData',tmp2,'YData',ydata); wolffd@0: end wolffd@0: if ~isempty(udata.fig2) wolffd@0: for j=1:length(udata.d_mark2) wolffd@0: ydata=getfield(get(udata.d_mark2(j).h(i),'YData'),{inds}); wolffd@0: set(udata.d_mark2(j).h(i),'XData',tmp2,'YData',ydata); wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: udata.new_marks=setdiff(udata.new_marks, new_marks); wolffd@0: udata.all_marks=setdiff(udata.all_marks,new_marks); wolffd@0: end wolffd@0: wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: set(0,'CurrentFigure',old); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function draw_poly() wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: if isempty(udata.poly.x) wolffd@0: if strcmp(get(gcf,'SelectionType'),'alt') wolffd@0: return; wolffd@0: end wolffd@0: udata.poly.THIS = gca; wolffd@0: end wolffd@0: wolffd@0: % 'THIS' indicates what was the axes where the polygon was meant to wolffd@0: % drawn. It is not possible to add points, that lie in another axes, to the wolffd@0: % polygon. wolffd@0: wolffd@0: wolffd@0: if gca ~= udata.poly.THIS wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: coords(1,1) = getfield(get(gca,'CurrentPoint'),{3}); wolffd@0: coords(1,2) = getfield(get(gca,'CurrentPoint'),{1}); wolffd@0: wolffd@0: udata.poly.x=cat(1,udata.poly.x,coords(2)); wolffd@0: udata.poly.y=cat(1,udata.poly.y,coords(1)); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: % remove old 'polygon' from axis wolffd@0: wolffd@0: delete(udata.poly.h); wolffd@0: wolffd@0: wolffd@0: switch get(gcf,'SelectionType') wolffd@0: case 'normal' wolffd@0: wolffd@0: % add point to the 'polygon' and draw it wolffd@0: wolffd@0: for i=1:length(udata.a_h) wolffd@0: subplot(udata.a_h(i)); wolffd@0: hold on; wolffd@0: udata.poly.h(i) = plot(udata.poly.x,udata.poly.y,'black',... wolffd@0: 'EraseMode','xor',... wolffd@0: 'ButtonDownFcn',... wolffd@0: 'vis_trajgui([],''click'')',... wolffd@0: 'LineWidth',2); wolffd@0: end wolffd@0: case 'alt' wolffd@0: wolffd@0: % The polygon is ready. wolffd@0: wolffd@0: wolffd@0: udata.poly.x=cat(1,udata.poly.x,udata.poly.x(1)); wolffd@0: udata.poly.y=cat(1,udata.poly.y,udata.poly.y(1)); wolffd@0: wolffd@0: for i=1:length(udata.a_h) wolffd@0: subplot(udata.a_h(i)); wolffd@0: udata.poly.h(i) = plot(udata.poly.x,udata.poly.y,'black',... wolffd@0: 'EraseMode','xor',... wolffd@0: 'ButtonDownFcn',... wolffd@0: 'vis_trajgui([],''click'')',... wolffd@0: 'LineWidth',2); wolffd@0: end wolffd@0: wolffd@0: tmp=sort(repmat((1:udata.msize(1))',udata.msize(2),1)); wolffd@0: tmp(:,2)=repmat((1:udata.msize(2))',udata.msize(1),1); wolffd@0: tmp2=tmp; wolffd@0: if strcmp(udata.lattice,'hexa'); wolffd@0: t=find(~rem(tmp(:,1),2)); wolffd@0: tmp(t,2)=tmp(t,2)+0.5; wolffd@0: end wolffd@0: wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: % find the nodes that lie inside polygon and change coordinates to wolffd@0: % linear indices. wolffd@0: wolffd@0: in = find(inpolygon(tmp(:,2),tmp(:,1),udata.poly.x,udata.poly.y)); wolffd@0: in = sub2ind(udata.msize,tmp2(in,1),tmp2(in,2)); wolffd@0: wolffd@0: colors=get(udata.tmp_patch(1),'FaceVertexCData'); wolffd@0: colors=reshape(colors,[size(colors,1) 3]); wolffd@0: tmp=ones(length(in),1); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: % set the color of the nodes just selected, black. wolffd@0: wolffd@0: colors(in,:)=tmp*[0 0 0]; wolffd@0: set(udata.tmp_patch,'FaceVertexCData',colors); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: % find the points mapping to the nodes from data wolffd@0: wolffd@0: inds = []; wolffd@0: for i=1:length(in) wolffd@0: inds=[inds;find(in(i) == udata.bmus)]; wolffd@0: end wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%% wolffd@0: % plot marks to data wolffd@0: wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: plot2data(inds); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: udata.new_marks=union(udata.new_marks,inds); wolffd@0: delete(udata.poly.h); wolffd@0: udata.poly.h=[]; wolffd@0: udata.poly.x=[]; wolffd@0: udata.poly.y=[]; wolffd@0: udata.poly.THIS=[]; wolffd@0: end wolffd@0: wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function save_data() wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: data.points=[]; wolffd@0: data.nodes=[]; wolffd@0: k=1; wolffd@0: wolffd@0: for i=1:length(udata.d_mark(1).h) wolffd@0: data.points(i).inds=get(udata.d_mark(1).h(i),'XData'); wolffd@0: data.points(i).color=get(udata.d_mark(1).h(i),'Color'); wolffd@0: end wolffd@0: wolffd@0: color=get(udata.tmp_patch(1),'FaceVertexCData'); wolffd@0: color=reshape(color,[size(color,1) 3]); wolffd@0: wolffd@0: for i=1:size(color,1) wolffd@0: if all(~isnan(color(i,:))) wolffd@0: tmp.ind=i; wolffd@0: tmp.color=color(i,:); wolffd@0: data.nodes(k)=tmp; wolffd@0: k=k+1; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: answer=inputdlg('Enter the name of the output variable:','',1); wolffd@0: wolffd@0: if isempty(answer) | isempty(answer{1}) wolffd@0: msgbox('Output is not set to workspace.'); wolffd@0: return; wolffd@0: else wolffd@0: assignin('base',answer{1},data); wolffd@0: disp(sprintf('Struct is set to the workspace as ''%s''.',answer{1})); wolffd@0: end wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function load_data() wolffd@0: wolffd@0: answer = inputdlg('Enter the name of the struct to be loaded:','',1); wolffd@0: wolffd@0: if isempty(answer) | isempty(answer{1}) wolffd@0: msgbox('Data is not loaded.'); wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: data=evalin('base',answer{1}); wolffd@0: wolffd@0: if ~isstruct(data) wolffd@0: errordlg('Input variable must be a struct.'); wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: tmp1 = fieldnames(data); wolffd@0: tmp2 = {'nodes','points'}; wolffd@0: wolffd@0: for i=1:length(tmp1) wolffd@0: for j=1:length(tmp2); wolffd@0: if ~any(strcmp(tmp2{j},tmp1)) wolffd@0: errordlg('Wrong type of struct.'); wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: if ~isempty(data.points) wolffd@0: tmp1=fieldnames(data.points(1)); wolffd@0: end wolffd@0: if ~isempty(data.nodes) wolffd@0: tmp2=fieldnames(data.nodes(1)); wolffd@0: end wolffd@0: wolffd@0: for i=1:length(tmp1) wolffd@0: if ~any(strcmp(tmp1{i},{'inds','color'})) wolffd@0: errordlg('Wrong type of struct.'); wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: for i=1:length(tmp2) wolffd@0: if ~any(strcmp(tmp2{i},{'ind','color'})) wolffd@0: errordlg('Wrong type of struct.'); wolffd@0: return; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: clear_markers; wolffd@0: remove_traj; wolffd@0: wolffd@0: old = gcf; wolffd@0: wolffd@0: for i=1:length(data.points) wolffd@0: for j=1:length(udata.h); wolffd@0: set(0,'CurrentFigure',udata.fig1); wolffd@0: subplot(udata.h(j)); wolffd@0: ydata=getfield(get(udata.d(j),'YData'),{data.points(i).inds}); wolffd@0: udata.d_mark(j).h=[udata.d_mark(j).h;... wolffd@0: plot(data.points(i).inds,ydata,... wolffd@0: 'Color',data.points(i).color,... wolffd@0: 'LineStyle','none',... wolffd@0: 'Marker','o',... wolffd@0: 'ButtonDownFcn',... wolffd@0: 'vis_trajgui([],''line_down'')')]; wolffd@0: if all(data.points(i).color == [0 0 0]) wolffd@0: udata.new_marks=unique([udata.new_marks; (data.points(i).inds)']); wolffd@0: else wolffd@0: udata.all_marks=unique([udata.all_marks; (data.points(i).inds)']); wolffd@0: end wolffd@0: end wolffd@0: if ~isempty(udata.fig2) wolffd@0: set(0,'CurrentFigure',udata.fig2); wolffd@0: for j=1:length(udata.h2) wolffd@0: subplot(udata.h2(j)); wolffd@0: ydata=getfield(get(udata.d2(j),'YData'),{data.points(i).inds}); wolffd@0: udata.d_mark2(j).h=[udata.d_mark2(j).h;... wolffd@0: plot(data.points(i).inds,ydata,... wolffd@0: 'Color',data.points(i).color,... wolffd@0: 'LineStyle','none',... wolffd@0: 'Marker','o',... wolffd@0: 'ButtonDownFcn',... wolffd@0: 'vis_trajgui([],''line_down'')')]; wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: wolffd@0: set(0,'CurrentFigure',udata.sM_h); wolffd@0: color=get(udata.tmp_patch(1),'FaceVertexCData'); wolffd@0: color=reshape(color,[size(color,1) 3]); wolffd@0: for i=1:length(data.nodes) wolffd@0: color(data.nodes(i).ind,:)=data.nodes(i).color; wolffd@0: end wolffd@0: for i=1:length(udata.tmp_patch); wolffd@0: set(udata.tmp_patch(i),'FaceVertexCData',color); wolffd@0: end wolffd@0: wolffd@0: set(0,'CurrentFigure',old); wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function fuzzy_traj(trajStruct,arg); wolffd@0: %function fuzzy_traj(sM_h,sM,sD,interval,arg) wolffd@0: wolffd@0: wolffd@0: if isempty(arg) wolffd@0: wolffd@0: if strcmp(trajStruct.lattice,'hexa') wolffd@0: udata.lattice='hexa'; wolffd@0: udata.form=vis_patch('hexa'); wolffd@0: else wolffd@0: data.lattice='rect'; wolffd@0: udata.form=vis_patch('rect'); wolffd@0: end wolffd@0: wolffd@0: % interval=[1 size(trajStruct.primary_data,1)]; wolffd@0: wolffd@0: l=size(udata.form,1); wolffd@0: dim = size(trajStruct.primary_data,2); wolffd@0: udata.a_h=[findobj(get(trajStruct.figure,'Children'),'Tag','Uplane');... wolffd@0: findobj(get(trajStruct.figure,'Children'),'Tag','Cplane')]; wolffd@0: wolffd@0: udata.sM_h=trajStruct.figure; wolffd@0: udata.msize=trajStruct.msize; wolffd@0: wolffd@0: %%%%%%%%%%%%%%% wolffd@0: % wolffd@0: % constructing patch that is drawn above every plane in map wolffd@0: % wolffd@0: wolffd@0: nx = repmat(udata.form(:,1),1,prod(udata.msize)); wolffd@0: ny = repmat(udata.form(:,2),1,prod(udata.msize)); wolffd@0: wolffd@0: x_c=reshape(repmat(1:udata.msize(2),l*udata.msize(1),1),l,prod(udata.msize)); wolffd@0: y_c=repmat(repmat(1:udata.msize(1),l,1),1,udata.msize(2)); wolffd@0: wolffd@0: if strcmp(udata.lattice,'hexa') wolffd@0: t = find(~rem(y_c(1,:),2)); wolffd@0: x_c(:,t)=x_c(:,t)+.5; wolffd@0: end wolffd@0: wolffd@0: x_c=x_c+nx; wolffd@0: y_c=y_c+ny; wolffd@0: wolffd@0: udata.orig_c=ones(prod(udata.msize),1)*[NaN NaN NaN]; wolffd@0: colors=reshape(udata.orig_c,[1 size(udata.orig_c,1) 3]); wolffd@0: set(0,'CurrentFigure',trajStruct.figure); wolffd@0: wolffd@0: %%%%%%%%% wolffd@0: % drawing wolffd@0: wolffd@0: for i=1:length(udata.a_h); wolffd@0: subplot(udata.a_h(i)); wolffd@0: v=caxis; wolffd@0: udata.patch_h(i) =patch(x_c,y_c,colors,'EdgeColor','none'); wolffd@0: caxis(v); wolffd@0: end wolffd@0: wolffd@0: wolffd@0: udata.orig_x=get(udata.patch_h(1),'XData'); wolffd@0: udata.orig_y=get(udata.patch_h(1),'YData'); wolffd@0: wolffd@0: % if interval(1) < 1 | interval(2) > size(trajStruct.primary_data,1) wolffd@0: % error('Invalid argument ''interval''.'); wolffd@0: % end wolffd@0: wolffd@0: x=1:size(trajStruct.primary_data,1); wolffd@0: udata.fig1=figure; wolffd@0: set(udata.fig1,'KeyPressFcn',... wolffd@0: 'vis_trajgui([],''move_fuzzy'')'); wolffd@0: for i=1:size(trajStruct.primary_data,2) wolffd@0: subplot(size(trajStruct.primary_data,2),1,i); wolffd@0: udata.h(i)=gca; wolffd@0: set(udata.h(1),'XTick',[]); wolffd@0: udata.d(i)=plot(x,trajStruct.primary_data(:,i)); wolffd@0: l_x=1; wolffd@0: lims(1) = round(min(trajStruct.primary_data(:,i))); wolffd@0: lims(2) = round(max(trajStruct.primary_data(:,i))); wolffd@0: udata.l(i) = line([l_x l_x],lims,'Color','red','EraseMode','xor'); wolffd@0: end wolffd@0: wolffd@0: udata.l_x = l_x; wolffd@0: udata.interval=[1 size(trajStruct.bmus,2)]; wolffd@0: wolffd@0: tmp.fig1=udata.fig1; wolffd@0: % [K,P] = estimate_kernels(sM,sD); wolffd@0: % udata.K=K; wolffd@0: % udata.P=P; wolffd@0: % udata.codebook=sM.codebook; wolffd@0: % udata.data=sD.data; wolffd@0: udata.bmus=trajStruct.bmus; wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: set(trajStruct.figure,'UserData',tmp); wolffd@0: draw_fuzzy(l_x); wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: move_fuzzy; wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function draw_fuzzy(x) wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: inds = find(udata.bmus(:,x)); wolffd@0: [row col] = ind2sub(udata.msize,inds); wolffd@0: if strcmp(udata.lattice,'hexa') wolffd@0: t=find(~mod(row,2)); wolffd@0: col(t)=col(t)+0.5; wolffd@0: end wolffd@0: wolffd@0: color=udata.orig_c; wolffd@0: color=reshape(color,[size(color,1) 3]); wolffd@0: xdata=udata.orig_x; wolffd@0: ydata=udata.orig_y; wolffd@0: tmp= ones(size(xdata(:,1),1),1)*udata.bmus(inds,x)'; wolffd@0: color(inds,:) = ones(length(inds),1)*[0 0 0]; wolffd@0: xdata(:,inds) = udata.form(:,1)*ones(1,length(inds)).*tmp+ones(6,1)*col'; wolffd@0: ydata(:,inds) = udata.form(:,2)*ones(1,length(inds)).*tmp+ones(6,1)*row'; wolffd@0: wolffd@0: set(udata.patch_h,'FaceVertexCData',color,'XData',xdata,'YData',ydata); wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: function move_fuzzy wolffd@0: wolffd@0: % moves pointer lines and draws fuzzy response. wolffd@0: wolffd@0: udata=get(gcf,'UserData'); wolffd@0: udata=get(udata.fig1,'UserData'); wolffd@0: wolffd@0: switch get(gcf,'CurrentCharacter'); wolffd@0: case {'<','>'} wolffd@0: key = get(gcf,'CurrentCharacter'); wolffd@0: if key == '>' wolffd@0: if udata.l_x + 1 > udata.interval(2) wolffd@0: return; wolffd@0: end wolffd@0: l_x = udata.l_x + 1; wolffd@0: else wolffd@0: if udata.l_x - 1 < udata.interval(1) wolffd@0: return; wolffd@0: end wolffd@0: l_x = udata.l_x - 1; wolffd@0: end wolffd@0: draw_fuzzy(l_x); wolffd@0: set(udata.l,'XData',[l_x l_x]); wolffd@0: udata.l_x=l_x; wolffd@0: set(udata.fig1,'UserData',udata); wolffd@0: otherwise wolffd@0: return; wolffd@0: end wolffd@0: wolffd@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: wolffd@0: wolffd@0: