Changeset 187
- Timestamp:
- Feb 1, 2011, 1:07:28 AM (14 years ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_field_indices.m
r105 r187 155 155 end 156 156 %NbDim(icell)=0;% nbre of space dimensions 157 NbDim(icell)=numel(DimCell); 157 % NbDim(icell)=numel(DimCell); 158 NbDim(icell)=0; 158 159 test_coord=0; 159 160 if numel(VarIndex)>1 -
trunk/src/get_field.m
r180 r187 262 262 end 263 263 if ~isempty(VarType{imax}.coord) 264 if numel(VarType{imax}.coord)>=maxdim-2 264 if numel(VarType{imax}.coord)>=maxdim-2 && maxdim>=3 265 265 set(handles.coord_z_scalar,'Value',VarType{imax}.coord(maxdim-2)+1) 266 266 end … … 1214 1214 dir_perso=prefdir; 1215 1215 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 1216 get_field_fct={}; 1216 1217 for ilist=nb_builtin+1:length(menu_str)-1 1217 1218 ff=functions(list_func_handles{ilist}); -
trunk/src/mouse_down.m
r177 r187 30 30 hhuvmat=guidata(huvmat);%handles of elements in uvmat 31 31 UvData=get(huvmat,'UserData'); 32 currentfig=hObject; 33 hhcurrentfig=guidata(currentfig); 32 FigData=get(hObject,'UserData'); 33 if ishandle(FigData)% case of a zoom plot, the handle of the parent rectangle is stored in UserData, its parent is the plotting axes of the rectangle 34 hcurrentfig=get(get(FigData,'parent'),'parent'); 35 else 36 hcurrentfig=hObject;%usual plot 37 end 38 hhcurrentfig=guidata(hcurrentfig); 34 39 test_zoom=get(hhcurrentfig.zoom,'Value');%test for zoom action, first priority 35 40 test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler action, second priority; … … 58 63 %% determine the currently selected items 59 64 hcurrentobject=gco;% current object handle (selected by the mouse) 60 hcurrentfig=hObject;% current figure handle65 %hcurrentfig=hObject;% current figure handle 61 66 fig_tag=get(hcurrentfig,'Tag'); 62 67 tag_obj=get(gco,'Tag');%tag of the currently selected object 63 68 xy=[];%default 64 xy_fig=get(h currentfig,'CurrentPoint');% current point of the current figure (gcbo)65 hchild=get(h currentfig,'Children');%handles of all objects in the current figure69 xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo) 70 hchild=get(hObject,'Children');%handles of all objects in the current figure 66 71 haxes=[]; 67 72 … … 106 111 end 107 112 end 108 test2D=0; 109 if isfield(AxeData,'NbDim') 110 if isequal(AxeData.NbDim,2) 111 test2D=1; 112 end 113 end 114 if ~test2D %desable object creation and vector editing if NbDim different from 2 113 114 %% desable object creation and vector editing if NbDim different from 2 115 if ~(isfield(AxeData,'NbDim') && isequal(AxeData.NbDim,2)) 115 116 test_create=0; 116 test_edit_vect=0; 117 end 118 %delete the current zoom rectangle 117 test_edit_vect=0; 118 end 119 120 %% delete the current zoom rectangle 119 121 if isfield(AxeData,'CurrentRectZoom') & ishandle(AxeData.CurrentRectZoom) 120 122 delete(AxeData.CurrentRectZoom) -
trunk/src/mouse_motion.m
r173 r187 28 28 return 29 29 end 30 currentfig=hObject; 30 FigData=get(hObject,'UserData'); 31 if ishandle(FigData)% case of a zoom plot, the handle of the parent rectangle is stored in UserData, its parent is the plotting axes of the rectangle 32 currentfig=get(get(FigData,'parent'),'parent'); 33 else 34 currentfig=hObject;%usual plot 35 end 31 36 hhcurrentfig=guidata(currentfig); 32 37 test_zoom=get(hhcurrentfig.zoom,'Value');%test for zoom activated on the current figure … … 61 66 pointershape='arrow';% default pointer is an arrow 62 67 63 xy_fig=get( currentfig,'CurrentPoint');% current point of the current figure (gcbo)64 hchild=get( currentfig,'Children');%handles of all objects in the current figure68 xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo) 69 hchild=get(hObject,'Children');%handles of all objects in the current figure 65 70 66 71 %% loop on all the objects in the current figure and detect whether the mouse is over a plot axes … … 74 79 htype=get(hchild(ichild),'Type');%type of the crrent child 75 80 %if the mouse is over an axis, look at the data 76 if isequal(htype,'axes')81 if strcmp(htype,'axes') 77 82 haxes=hchild(ichild); 78 83 xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates … … 144 149 VarName=Field.ListVarName{CellVarIndex{icell}(1)}; 145 150 eval(['nxy=size(Field.' VarName ');']); 146 % nxy(1)=numel(y);147 % nxy(2)=numel(x);148 151 MaxAY=max(y(1),y(end)); %#ok<COLND> 149 152 MinAY=min(y(1),y(end)); %#ok<COLND> -
trunk/src/plot_field.m
r186 r187 101 101 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 102 102 103 function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam, htext,PosColorbar)103 function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,PosColorbar) 104 104 % TODO: 105 105 % use htext: handles of the text edit box (uicontrol) 106 106 % introduce PlotParam.Hold: 'on' or 'off' (for curves) 107 108 107 %default output 109 108 if ~exist('PlotParam','var'),PlotParam=[];end; 110 if ~exist('htext','var'),htext=[];end;111 109 if ~exist('PosColorbar','var'),PosColorbar=[];end; 112 110 PlotType='text'; %default 113 111 PlotParamOut=PlotParam;%default 114 if isempty(Data) 115 PlotType='none'; 116 return 117 end 118 % check input structure 119 [Data,errormsg]=check_field_structure(Data); 120 121 if ~isempty(errormsg) 122 msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg]) 123 display(['input of plot_field/check_field_structure:: ' errormsg]) 124 return 125 end 126 112 113 %% test axes and figure 127 114 testnewfig=1;%test to create a new figure (default) 128 115 testzoomaxes=0;%test for the existence of a zoom secondary figure attached to the plotting axes … … 130 117 if ishandle(haxes) 131 118 if isequal(get(haxes,'Type'),'axes') 132 % axes(haxes)133 119 testnewfig=0; 134 120 AxeData=get(haxes,'UserData'); … … 145 131 PlotParam=read_plot_param(PlotParam); 146 132 end 147 if testnewfig% create a new figure and axes if the plotting axes does not exist 133 % create a new figure and axes if the plotting axes does not exist 134 if testnewfig 148 135 hfig=figure; 149 136 if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1) … … 163 150 end 164 151 165 if isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1) 166 set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio 167 end 168 169 %% check the cells of fields : 170 [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data); 152 %% check input structure 153 if ~isempty(Data) 154 [Data,errormsg]=check_field_structure(Data); 155 156 if ~isempty(errormsg) 157 msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg]) 158 display(['input of plot_field/check_field_structure:: ' errormsg]) 159 return 160 end 161 162 %% check the cells of fields : 163 [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data); 164 165 if ~isempty(errormsg) 166 msgbox_uvmat('ERROR',['input of plot_field/find_field_indices: ' errormsg]); 167 return 168 end 169 index_3D=find(NbDim>2,1); 170 if ~isempty(index_3D) 171 msgbox_uvmat('ERROR','volume plot not implemented yet'); 172 return 173 end 174 index_2D=find(NbDim==2,2);%find 2D fields (at most 2) 175 index_1D=find(NbDim==1); 176 index_0D=find(NbDim==0); 177 178 %% set axes properties 179 if isfield(PlotParam,'FixedLimits') && isequal(PlotParam.FixedLimits,1) %adjust the graph limits* 180 set(haxes,'XLimMode', 'manual') 181 set(haxes,'YLimMode', 'manual') 182 else 183 set(haxes,'XLimMode', 'auto') 184 set(haxes,'YLimMode', 'auto') 185 end 186 if isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1) 187 set(haxes,'DataAspectRatioMode','auto')%automatic aspect ratio 188 else 189 set(haxes,'DataAspectRatioMode','manual') 190 end 191 else 192 index_2D=[]; 193 index_1D=[]; 194 index_0D=[]; 195 end 171 196 172 197 %% plot if the input field is valid 198 PlotType='text'; 199 errormsg=[]; 200 AxeData=get(haxes,'UserData'); 201 if isempty(index_2D) 202 plot_plane([],[],[],haxes);%removes images or vector plots if any 203 else 204 [xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),haxes,PlotParam,PosColorbar); 205 AxeData.NbDim=2; 206 if testzoomaxes && isempty(errormsg) 207 [zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(index_2D),VarType(index_2D),zoomaxes,PlotParam,PosColorbar); 208 AxeData.ZoomAxes=zoomaxes; 209 end 210 end 211 if isempty(index_1D) 212 plot_profile([],[],[],haxes);% 213 else 214 plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),haxes,PlotParam);% 215 if testzoomaxes 216 [zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex(index_1D),VarType(index_1D),zoomaxes,PlotParam); 217 AxeData.ZoomAxes=zoomaxes; 218 end 219 PlotType='line'; 220 end 221 htext=findobj(hfig,'Tag','text_display'); 222 if ~isempty(htext) 223 if isempty(index_0D) 224 set(htext,'String',{''}) 225 else 226 [errormsg]=plot_text(Data,CellVarIndex(index_0D),htext); 227 end 228 end 229 173 230 if ~isempty(errormsg) 174 errormsg=['input of plot_field/find_field_indices: ' errormsg];175 else176 if ~isfield(Data,'NbDim') %& ~isfield(Data,'Style')%determine the space dimensionb if not defined: choose the kind of plot177 [Data.NbDim]=max(NbDim);178 end179 if isequal(Data.NbDim,0)180 AxeData=plot_text(Data,htext);181 PlotType='text';182 errormsg=[];183 elseif isequal(Data.NbDim,1)184 [AxeData]=plot_profile(Data,CellVarIndex,VarType,haxes,PlotParam);%185 if testzoomaxes186 [AxeData,zoomaxes,PlotParamOut]=plot_profile(Data,CellVarIndex,VarType,zoomaxes,PlotParam);187 AxeData.ZoomAxes=zoomaxes;188 end189 PlotType='line';190 errormsg=[];191 elseif isequal(Data.NbDim,2)192 ind_select=find(NbDim>=2);193 if numel(ind_select)>2194 errormsg='more than two fields to map';195 else196 [AxeData,xx,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),haxes,PlotParam,htext,PosColorbar);197 if testzoomaxes && isempty(errormsg)198 [AxeData,zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar);199 Data.ZoomAxes=zoomaxes;200 end201 end202 elseif isequal(Data.NbDim,3)203 errormsg='volume plot not implemented yet';204 end205 end206 if isempty(errormsg)207 set(haxes,'UserData',Data)208 else209 231 msgbox_uvmat('ERROR', errormsg) 210 232 end 211 233 212 234 %% update the parameters stored in AxeData 235 set(haxes,'UserData',AxeData) 236 237 %% update the parameters stored in parent figure 238 FigData=get(hfig,'UserData'); 239 tagaxes=get(haxes,'tag'); 240 if isfield(FigData,tagaxes) 241 eval(['FigData.' tagaxes '=Data']) 242 set(hfig,'UserData',FigData) 243 end 244 213 245 %------------------------------------------------------------------- 214 function hdisplay=plot_text(FieldData,hdisplay_in)246 function errormsg=plot_text(FieldData,CellVarIndex,htext) 215 247 %------------------------------------------------------------------- 216 if exist('hdisplay_in','var') && ~isempty(hdisplay_in) && ishandle(hdisplay_in) && isequal(get(hdisplay_in,'Type'),'uicontrol') 217 hdisplay=hdisplay_in; 218 else 219 figure;%create new figure 220 hdisplay=uicontrol('Style','edit', 'Units','normalized','Position', [0 0 1 1],'Max',2,'FontName','monospaced'); 221 end 222 223 ff=fields(FieldData);%list of field names 224 vv=struct2cell(FieldData);%list of field values 225 226 for icell=1:length(vv) 227 Tabcell{icell,1}=ff{icell}; 228 ss=vv{icell}; 229 sizss=size(ss); 230 if isnumeric(ss) 231 if sizss(1)<=1 && length(ss)<5 232 displ{icell}=num2str(ss); 233 else 234 displ{icell}=[class(ss) ', size ' num2str(size(ss))]; 235 end 236 elseif ischar(ss) 237 displ{icell}=ss; 238 elseif iscell(ss) 239 sizcell=size(ss); 240 if sizcell(1)==1 && length(sizcell)==2 %line cell 241 ssline='{'''; 242 for icolumn=1:sizcell(2) 243 if isnumeric(ss{icolumn}) 244 if size(ss{icolumn},1)<=1 && length(ss{icolumn})<5 245 sscolumn=num2str(ss{icolumn});%line vector 246 else 247 sscolumn=[class(ss{icolumn}) ', size ' num2str(size(ss{icolumn}))]; 248 end 249 elseif ischar(ss{icolumn}) 250 sscolumn=ss{icolumn}; 251 else 252 sscolumn=class(ss{icolumn}); 253 end 254 if icolumn==1 255 ssline=[ssline sscolumn]; 256 else 257 ssline=[ssline ''',''' sscolumn]; 258 end 259 end 260 displ{icell}=[ssline '''}']; 261 else 262 displ{icell}=[class(ss) ', size ' num2str(sizcell)]; 263 end 264 else 265 displ{icell}=class(ss); 266 end 267 Tabcell{icell,2}=displ{icell}; 268 end 269 Tabchar=cell2tab(Tabcell,': '); 270 set(hdisplay,'String', Tabchar) 248 % if exist('hdisplay_in','var') && ~isempty(hdisplay_in) && ishandle(hdisplay_in) && isequal(get(hdisplay_in,'Type'),'uicontrol') 249 % hdisplay=hdisplay_in; 250 % else 251 % figure;%create new figure 252 % hdisplay=uicontrol('Style','edit', 'Units','normalized','Position', [0 0 1 1],'Max',2,'FontName','monospaced'); 253 % end 254 errormsg=[]; 255 txt_cell={}; 256 for icell=1:length(CellVarIndex) 257 VarIndex=CellVarIndex{icell};% indices of the selected variables in the list data.ListVarName 258 % ff=fields(FieldData);%list of field names 259 % vv=struct2cell(FieldData);%list of field values 260 % 261 % for icell=1:length(vv) 262 for ivar=1:length(VarIndex) 263 VarName=FieldData.ListVarName{VarIndex(ivar)}; 264 eval(['VarValue=FieldData.' VarName ';']) 265 if size(VarValue,1)~=1 266 VarValue=VarValue'; 267 end 268 txt=[VarName '=' num2str(VarValue)]; 269 txt_cell=[txt_cell;{txt}]; 270 end 271 end 272 273 set(htext,'String',txt_cell) 274 % txt_cell=[txt_cell {num2str( 275 % Tabcell{icell,1}=ff{icell}; 276 % ss=vv{icell}; 277 % sizss=size(ss); 278 % if isnumeric(ss) 279 % if sizss(1)<=1 && length(ss)<5 280 % displ{icell}=num2str(ss); 281 % else 282 % displ{icell}=[class(ss) ', size ' num2str(size(ss))]; 283 % end 284 % elseif ischar(ss) 285 % displ{icell}=ss; 286 % elseif iscell(ss) 287 % sizcell=size(ss); 288 % if sizcell(1)==1 && length(sizcell)==2 %line cell 289 % ssline='{'''; 290 % for icolumn=1:sizcell(2) 291 % if isnumeric(ss{icolumn}) 292 % if size(ss{icolumn},1)<=1 && length(ss{icolumn})<5 293 % sscolumn=num2str(ss{icolumn});%line vector 294 % else 295 % sscolumn=[class(ss{icolumn}) ', size ' num2str(size(ss{icolumn}))]; 296 % end 297 % elseif ischar(ss{icolumn}) 298 % sscolumn=ss{icolumn}; 299 % else 300 % sscolumn=class(ss{icolumn}); 301 % end 302 % if icolumn==1 303 % ssline=[ssline sscolumn]; 304 % else 305 % ssline=[ssline ''',''' sscolumn]; 306 % end 307 % end 308 % displ{icell}=[ssline '''}']; 309 % else 310 % displ{icell}=[class(ss) ', size ' num2str(sizcell)]; 311 % end 312 % else 313 % displ{icell}=class(ss); 314 % end 315 % Tabcell{icell,2}=displ{icell}; 316 % end 317 % Tabchar=cell2tab(Tabcell,': '); 318 % set(hdisplay,'String', Tabchar) 271 319 272 320 273 321 %------------------------------------------------------------------- 274 function [ AxeData,haxes]=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam)322 function [haxes]=plot_profile(data,CellVarIndex,VarType,haxes,PlotParam) 275 323 %------------------------------------------------------------------- 276 %TODO: modify existing plot if it exists277 278 324 hfig=get(haxes,'parent'); 279 AxeData=[];%data; 325 %suppress existing plot isf empty data 326 if isempty(data) 327 hplot=findobj(haxes,'tag','plot_line'); 328 if ~isempty(hplot) 329 delete(hplot) 330 end 331 hlegend=findobj(hfig,'tag','legend'); 332 if ~isempty(hlegend) 333 delete(hlegend) 334 end 335 return 336 end 337 280 338 281 339 ColorOrder=[1 0 0;0 0.5 0;0 0 1;0 0.75 0.75;0.75 0 0.75;0.75 0.75 0;0.25 0.25 0.25]; … … 285 343 end 286 344 % adjust the size of the plot to include the whole field, 287 if isfield(PlotParam,'FixedLimits') && isequal(PlotParam.FixedLimits,1) %adjust the graph limits* 288 set(haxes,'XLimMode', 'manual') 289 set(haxes,'YLimMode', 'manual') 290 else 291 set(haxes,'XLimMode', 'auto') 292 set(haxes,'YLimMode', 'auto') 293 end 345 294 346 legend_str={}; 295 347 … … 297 349 %initiate the plot command 298 350 plotstr='hhh=plot('; 299 textmean={};351 % textmean={}; 300 352 coord_x_index=[]; 353 xtitle=''; 354 ytitle=''; 301 355 test_newplot=1; 302 % hh=findobj(haxes,'tag','plot_line');303 % num_curve=numel(hh);304 % icurve=0;305 356 306 357 %loop on input fields … … 311 362 else 312 363 coord_x_index_cell=VarType{icell}.coord(1); 313 if isequal(coord_x_index_cell,0) 314 continue % the cell has no abscissa, skip it 315 end 316 if ~isempty(coord_x_index)&&~isequal(coord_x_index_cell,coord_x_index) 317 continue %all the selected variables must have the same first dimension 318 else 319 coord_x_index=coord_x_index_cell; 320 end 364 if isequal(coord_x_index_cell,0) 365 continue % the cell has no abscissa, skip it 366 end 367 % if ~isempty(coord_x_index)&&~isequal(coord_x_index_cell,coord_x_index) 368 % %continue %all the selected variables must have the same first dimension 369 % else 370 % coord_x_index=coord_x_index_cell; 371 % end 372 coord_x_index=coord_x_index_cell; 321 373 end 322 374 testplot=ones(size(data.ListVarName));%default test for plotted variables 323 xtitle= data.ListVarName{coord_x_index};375 xtitle=[xtitle data.ListVarName{coord_x_index}]; 324 376 eval(['coord_x{icell}=data.' data.ListVarName{coord_x_index} ';']);%coordinate variable set as coord_x 325 377 if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=coord_x_index && isfield(data.VarAttribute{coord_x_index},'units') 326 xtitle=[xtitle '(' data.VarAttribute{coord_x_index}.units ')']; 378 xtitle=[xtitle '(' data.VarAttribute{coord_x_index}.units '), ']; 379 else 380 xtitle=[xtitle ', ']; 327 381 end 328 382 eval(['coord_x{icell}=data.' data.ListVarName{coord_x_index} ';']);%coordinate variable set as coord_x … … 344 398 end 345 399 end 346 % test_newplot=0;%default347 % if num_curve>=icurve+numel(find(testplot(VarIndex)))%update existing curves348 % if ~isempty(VarType{icell}.discrete')349 % charplot_0='+';350 % LineStyle='none';351 % else352 % charplot_0='none';353 % LineStyle='-';354 % end355 % for ivar=1:length(VarIndex)356 % if testplot(VarIndex(ivar))357 % icurve=icurve+1;358 % VarName=data.ListVarName{VarIndex(ivar)};359 % eval(['data.' VarName '=squeeze(data.' VarName ');'])360 % set(hh(icurve),'LineStyle',LineStyle)361 % set(hh(icurve),'Marker',charplot_0)362 % set(hh(icurve),'XData',coord_x{icell})363 % eval(['yy=data.' VarName ';'])364 % set(hh(icurve),'YData',yy);365 % end366 % end367 % else% new plot368 400 if ~isempty(VarType{icell}.discrete') 369 401 charplot_0='''+'''; … … 374 406 if testplot(VarIndex(ivar)) 375 407 VarName=data.ListVarName{VarIndex(ivar)}; 408 ytitle=[ytitle VarName]; 409 if isfield(data,'VarAttribute')&& numel(data.VarAttribute)>=VarIndex(ivar) && isfield(data.VarAttribute{VarIndex(ivar)},'units') 410 ytitle=[ytitle '(' data.VarAttribute{VarIndex(ivar)}.units '), ']; 411 else 412 ytitle=[ytitle ', ']; 413 end 376 414 eval(['data.' VarName '=squeeze(data.' VarName ');']) 377 415 plotstr=[plotstr 'coord_x{' num2str(icell) '},data.' VarName ',' charplot_0 ',']; … … 381 419 coord_x{icell}=linspace(coord_x{icell}(1),coord_x{icell}(2),nbcomponent1); 382 420 end 383 eval(['varmean=mean(double(data.' VarName '));']);%mean value384 textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}];421 %eval(['varmean=mean(double(data.' VarName '));']);%mean value 422 %textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}]; 385 423 if nbcomponent1==1|| nbcomponent2==1 386 424 legend_str=[legend_str {VarName}]; %variable with one component … … 395 433 396 434 %% activate the plot 397 if test_newplot && ~isequal(plotstr,'hhh=plot(') 398 plotstr=[plotstr '''tag'',''plot_line'');']; 399 %execute plot (instruction plotstr) 400 % set(hfig,'CurrentAxes',haxes) 401 % axes(haxes)% select the plotting axes for plot operation 402 eval(plotstr) 403 404 %%%%% 435 if test_newplot && ~isequal(plotstr,'hhh=plot(') 436 set(hfig,'CurrentAxes',haxes) 437 tag=get(haxes,'tag'); 438 439 %%% 440 plotstr=[plotstr '''tag'',''plot_line'');']; 441 eval(plotstr) %execute plot (instruction plotstr) 442 %%% 443 444 set(haxes,'tag',tag) 405 445 grid(haxes, 'on') 406 hxlabel=xlabel(xtitle );446 hxlabel=xlabel(xtitle(1:end-2));% xlabel (removes ', ' at the end) 407 447 set(hxlabel,'Interpreter','none')% desable tex interpreter 408 448 if length(legend_str)>=1 409 hylabel=ylabel( legend_str{end});449 hylabel=ylabel(ytitle(1:end-2));% ylabel (removes ', ' at the end) 410 450 set(hylabel,'Interpreter','none')% desable tex interpreter 411 451 end … … 445 485 set(htitle,'Interpreter','none')% desable tex interpreter 446 486 end 447 % A REPRENDRE Mean448 % hlist=findobj(gcf,'Style','listbox','Tag','liststat');449 % if isempty(hlist)450 % 'text'451 % textmean452 % set(gca,'position',[0.13,0.2,0.775,0.73])453 % uicontrol('Style','popupmenu','Position',[20 20 200 20],'String',textmean,'Tag','liststat');454 % else455 % set(hlist(1),'String',textmean)456 % end457 487 end 458 488 459 489 460 490 %------------------------------------------------------------------- 461 function [ AxeData,haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,htext,PosColorbar)491 function [haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellVarIndex,VarTypeCell,haxes,PlotParam,PosColorbar) 462 492 %------------------------------------------------------------------- 463 493 … … 478 508 hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes 479 509 hima=findobj(haxes,'Tag','ima');% search existing image in the current axes 480 AxeData=get(haxes,'UserData'); %default481 if ~isstruct(AxeData)% AxeData must be a structure482 AxeData=[];483 end484 AxeData.NbDim=2;510 % AxeData=get(haxes,'UserData'); %default 511 % if ~isstruct(AxeData)% AxeData must be a structure 512 % AxeData=[]; 513 % end 514 % AxeData.NbDim=2; 485 515 % if isfield(Data,'ObjectCoord') 486 516 % AxeData.ObjectCoord=Data.ObjectCoord; … … 816 846 end 817 847 set(hima,'Tag','ima','HitTest','off') 818 set(haxes,'Tag',tag);%preserve the axes tag (removed by image fct !!!) 848 set(haxes,'Tag',tag);%preserve the axes tag (removed by image fct !!!) 849 uistack(hima, 'bottom') 819 850 % update an existing image 820 851 else … … 831 862 end 832 863 end 833 if ~isstruct(AxeData)834 AxeData=[];835 end864 % if ~isstruct(AxeData) 865 % AxeData=[]; 866 % end 836 867 test_ima=1; 837 868 … … 885 916 delete(hcol) 886 917 end 887 % AxeData.A=[];888 % AxeData.AX=[];889 % AxeData.AY=[];890 918 PlotParamOut=rmfield(PlotParamOut,'Scalar'); 891 919 end … … 902 930 vec_V=reshape(vec_V,1,numel(vec_V)); 903 931 MinMaxX=max(vec_X)-min(vec_X); 904 % MinMaxY=max(vec_Y)-min(vec_Y);905 % AxeData.Mesh=sqrt((MinMaxX*MinMaxY)/length(vec_X));906 932 if ~isfield(PlotParam.Vectors,'AutoVec') || isequal(PlotParam.Vectors.AutoVec,0)|| ~isfield(PlotParam.Vectors,'VecScale')... 907 933 ||isempty(PlotParam.Vectors.VecScale)||~isa(PlotParam.Vectors.VecScale,'double') %automatic vector scale 908 934 % scale=[]; 909 935 if test_false %remove false vectors 910 indsel=find(AxeData.FF==0);%indsel =indices of good vectors936 %indsel=find(AxeData.FF==0);%indsel =indices of good vectors 911 937 else 912 938 indsel=1:numel(vec_X);% … … 1002 1028 1003 1029 %store the coordinate extrema occupied by the field 1004 test_lim=0; 1005 if test_vec 1006 Xlim=[min(vec_X) max(vec_X)]; 1007 Ylim=[min(vec_Y) max(vec_Y)]; 1008 test_lim=1; 1009 if test_ima%both background image and vectors coexist, take the wider bound 1010 Xlim(1)=min(AX(1),Xlim(1)); 1011 Xlim(2)=max(AX(end),Xlim(2)); 1012 Ylim(1)=min(AY(end),Ylim(1)); 1013 Ylim(2)=max(AY(1),Ylim(2)); 1014 end 1015 elseif test_ima %only image plot 1016 Xlim(1)=min(AX(1),AX(end)); 1017 Xlim(2)=max(AX(1),AX(end)); 1018 Ylim(1)=min(AY(1),AY(end)); 1019 Ylim(2)=max(AY(1),AY(end)); 1020 test_lim=1; 1021 end 1022 AxeData.RangeX=Xlim; 1023 AxeData.RangeY=Ylim; 1024 % adjust the size of the plot to include the whole field, except if PlotParam.FixedLimits=1 1025 if ~(isfield(PlotParam,'FixedLimits') && PlotParam.FixedLimits) && test_lim 1026 if Xlim(2)>Xlim(1) 1027 set(haxes,'XLim',Xlim);% set x limits of frame in axes coordinates 1028 end 1029 if Ylim(2)>Ylim(1) 1030 set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate 1031 end 1032 end 1033 if ~(isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1)) 1034 set(haxes,'DataAspectRatio',[1 1 1]) 1035 end 1036 set(haxes,'YDir','normal') 1037 set(get(haxes,'XLabel'),'String',[XName ' (' x_units ')']); 1038 set(get(haxes,'YLabel'),'String',[YName ' (' y_units ')']); 1039 PlotParamOut.x_units=x_units; 1040 PlotParamOut.y_units=y_units; 1041 1030 if ~isempty(Data) 1031 test_lim=0; 1032 if test_vec 1033 Xlim=[min(vec_X) max(vec_X)]; 1034 Ylim=[min(vec_Y) max(vec_Y)]; 1035 test_lim=1; 1036 if test_ima%both background image and vectors coexist, take the wider bound 1037 Xlim(1)=min(AX(1),Xlim(1)); 1038 Xlim(2)=max(AX(end),Xlim(2)); 1039 Ylim(1)=min(AY(end),Ylim(1)); 1040 Ylim(2)=max(AY(1),Ylim(2)); 1041 end 1042 elseif test_ima %only image plot 1043 Xlim(1)=min(AX(1),AX(end)); 1044 Xlim(2)=max(AX(1),AX(end)); 1045 Ylim(1)=min(AY(1),AY(end)); 1046 Ylim(2)=max(AY(1),AY(end)); 1047 test_lim=1; 1048 end 1049 AxeData.RangeX=Xlim; 1050 AxeData.RangeY=Ylim; 1051 % adjust the size of the plot to include the whole field, except if PlotParam.FixedLimits=1 1052 if ~(isfield(PlotParam,'FixedLimits') && PlotParam.FixedLimits) && test_lim 1053 if Xlim(2)>Xlim(1) 1054 set(haxes,'XLim',Xlim);% set x limits of frame in axes coordinates 1055 end 1056 if Ylim(2)>Ylim(1) 1057 set(haxes,'YLim',Ylim);% set y limits of frame in axes coordinate 1058 end 1059 end 1060 if ~(isfield(PlotParam,'Auto_xy') && isequal(PlotParam.Auto_xy,1)) 1061 set(haxes,'DataAspectRatio',[1 1 1]) 1062 end 1063 set(haxes,'YDir','normal') 1064 set(get(haxes,'XLabel'),'String',[XName ' (' x_units ')']); 1065 set(get(haxes,'YLabel'),'String',[YName ' (' y_units ')']); 1066 PlotParamOut.x_units=x_units; 1067 PlotParamOut.y_units=y_units; 1068 end 1042 1069 %------------------------------------------------------------------- 1043 1070 % --- function for plotting vectors -
trunk/src/plot_object.m
r183 r187 194 194 theta=0; 195 195 else 196 theta=angle(diff(xline)+ i*diff(yline));196 theta=angle(diff(xline)+1i*diff(yline)); 197 197 theta(length(xline))=theta(length(xline)-1); 198 198 end … … 386 386 end 387 387 set(hh,'Tag','proj_object') 388 if test_patch389 hold on388 if test_patch 389 hold on 390 390 hhh=image([xlim(1)+dx/2 xlim(2)-dx/2],[ylim(1)+dy/2 ylim(2)-dy/2],imflag,'Tag','proj_object','HitTest','off'); 391 392 PlotData.SubObject=hhh;393 end391 set(hhh,'AlphaData',(flag)*0.2)% set partial transparency to the filling color 392 PlotData.SubObject=hhh; 393 end 394 394 if isfield(PlotData,'SubObject') 395 395 set(PlotData.SubObject,'UserData',hh)%record the parent handles in the SubObjects -
trunk/src/proj_field.m
r186 r187 139 139 end 140 140 141 142 141 %----------------------------------------------------------------- 143 142 %project on a set of points … … 346 345 ProjData.X(ipoint,1)=ObjectData.Coord(ipoint,1); 347 346 ProjData.Y(ipoint,1)=ObjectData.Coord(ipoint,2); 348 i_int= [i_min:i_plus];349 j_int= [j_min:j_plus];347 i_int=(i_min:i_plus); 348 j_int=(j_min:j_plus); 350 349 ProjData.NbVal(ipoint,1)=length(j_int)*length(i_int); 351 if isempty(i_int) | isempty(j_int)350 if isempty(i_int) || isempty(j_int) 352 351 for ivar=VarIndex 353 352 eval(['ProjData.' FieldData.ListVarName{ivar} '(ipoint,:)=NaN;']); … … 387 386 ProjData.ListVarName={}; 388 387 ProjData.VarDimName={}; 388 ProjData.VarAttribute={}; 389 389 390 390 Mesh=zeros(1,numel(FieldData.ListVarName)); 391 391 if isfield (FieldData,'VarAttribute') 392 ProjData.VarAttribute=FieldData.VarAttribute;%list of variable attribute names393 for iattr=1:length( ProjData.VarAttribute)%initialization of variable attribute values392 %ProjData.VarAttribute=FieldData.VarAttribute;%list of variable attribute names 393 for iattr=1:length(FieldData.VarAttribute)%initialization of variable attribute values 394 394 % ProjData.VarAttribute{iattr}={}; 395 if isfield( ProjData.VarAttribute{iattr},'Unit')396 unit{iattr}= ProjData.VarAttribute{iattr}.Unit;397 end 398 if isfield( ProjData.VarAttribute{iattr},'Mesh')399 Mesh(iattr)= ProjData.VarAttribute{iattr}.Mesh;395 if isfield(FieldData.VarAttribute{iattr},'Unit') 396 unit{iattr}=FieldData.VarAttribute{iattr}.Unit; 397 end 398 if isfield(FieldData.VarAttribute{iattr},'Mesh') 399 Mesh(iattr)=FieldData.VarAttribute{iattr}.Mesh; 400 400 end 401 401 end … … 549 549 eval(['ProjData.' VarName 'Histo=hist(double(FieldData.' VarName '(indsel,:)),ProjData.' VarName ');']); % histogram at predefined bin positions 550 550 end 551 ProjData.ListVarName=[ProjData.ListVarName {VarName} {[VarName 'Histo']} {[VarName 'Mean']} ];551 ProjData.ListVarName=[ProjData.ListVarName {VarName} {[VarName 'Histo']} {[VarName 'Mean']} {[VarName 'Min']} {[VarName 'Max']}]; 552 552 if test_Amat && testcolor 553 553 ProjData.VarDimName=[ProjData.VarDimName {VarName} {{VarName,'rgb'}} {'rgb'}];%{{'nb_point','rgb'}}; 554 554 else 555 ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName} {'nbpoint'}]; 556 end 555 ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName} {'nbpoint'} {'nbpoint'} {'nbpoint'}]; 556 end 557 ProjData.VarAttribute=[ProjData.VarAttribute FieldData.VarAttribute{ivar} {[]} {[]} {[]} {[]}]; 557 558 end 558 559 end … … 2076 2077 eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,:,:));'])% select the z index iz 2077 2078 %TODO : do a vertical average for a thick plane 2078 if test_interp(2) | test_interp(3)2079 if test_interp(2) || test_interp(3) 2079 2080 eval(['ProjData.' VarName '=interp2(Coord{3},Coord{2},ProjData.' VarName ',Coord_x,Coord_y'');']) 2080 2081 end -
trunk/src/set_object.m
r186 r187 776 776 UvData.Object{IndexObj}=ObjectData;%update the current object properties 777 777 UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2); 778 779 %% plot the field projected on the object and store it the corresponding figue 780 get(plotaxes,'tag') 778 set(huvmat,'UserData',UvData) 779 780 %% plot the field projected on the object and store in the corresponding figue 781 781 ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData 782 782 [PlotType,Object_out{IndexObj}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);%update an existing field plot 783 if strcmp(projview,'view_field')784 ViewFieldData=get(hview_field,'UserData');785 ViewFieldData.axes3=ObjectData;786 set(hview_field,'UserData',ViewFieldData)787 else788 UvData.axes3=ObjectData;789 end790 783 791 784 %% update the GUI uvmat … … 795 788 set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow 796 789 %UvData.MouseAction='edit_object'; % set the edit button to 'on' 797 set(huvmat,'UserData',UvData) 790 798 791 %------------------------------------------------------------------------ 799 792 % --- Executes on button press in MenuCoord. -
trunk/src/uvmat.m
r183 r187 217 217 UvData.OpenParam.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE) 218 218 UvData.OpenParam.CalSize=[0.28 1]; 219 UvData.axes3=[];%initiate the record of plotted field 220 UvData.axes2=[]; 221 UvData.axes1=[]; 219 222 220 223 %functions for the mouse and keyboard … … 2520 2523 UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis 2521 2524 end 2525 UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback) 2526 set(handles.uvmat,'UserData',UvData) 2522 2527 2523 2528 %% reset the min and max of scalar if only the mask is displayed(TODO: check the need) … … 2612 2617 view_field(ObjectData) 2613 2618 else 2614 [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap}, keeplim(imap),PosColorbar{imap});2619 [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap}); 2615 2620 write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters 2616 2621 if isfield(Field,'Mesh')&&~isempty(Field.Mesh) 2617 2622 ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot) 2618 2623 end 2619 if imap==12620 UvData.axes3=ObjectData;2621 else2622 ViewFieldData=get(view_field_handle,'UserData');2623 ViewFieldData.axes3=ObjectData;2624 set(view_field_handle,'UserData',ViewFieldData)2625 end2624 % if imap==1 2625 % UvData.axes3=ObjectData; 2626 % else 2627 % ViewFieldData=get(view_field_handle,'UserData'); 2628 % ViewFieldData.axes3=ObjectData; 2629 % set(view_field_handle,'UserData',ViewFieldData) 2630 % end 2626 2631 end 2627 2632 if isequal(PlotType,'none') … … 2636 2641 end 2637 2642 2638 %write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters2639 UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)2640 set(handles.uvmat,'UserData',UvData)2641 2643 2642 2644 %% update the mask … … 3928 3930 histo_value=get(handles.histo1_menu,'Value'); 3929 3931 FieldName=histo_menu{histo_value}; 3930 % UvData=get(huvmat,'UserData');3931 3932 update_histo(handles.histo_u,huvmat,FieldName) 3932 3933 … … 3939 3940 histo_value=get(handles.histo2_menu,'Value'); 3940 3941 FieldName=histo_menu{histo_value}; 3941 % UvData=get(huvmat,'UserData');3942 3942 update_histo(handles.histo_v,huvmat,FieldName) 3943 3943 … … 4002 4002 end 4003 4003 end 4004 set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect) 4005 set(haxes,'YLimMode','auto') 4006 plot_field(Histo,haxes); 4004 % set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect) 4005 % set(haxes,'YLimMode','auto') 4006 PlotParam.Auto_xy=1; 4007 plot_field(Histo,haxes,PlotParam); 4007 4008 end 4008 4009 end … … 4186 4187 AxeData=UvData.axes3; 4187 4188 PlotParam=read_plot_param(handles); 4188 [P lotType,PlotParamOut]= plot_field(AxeData,haxes,PlotParam,1);4189 [PP,PlotParamOut]= plot_field(AxeData,haxes,PlotParam); 4189 4190 write_plot_param(handles,PlotParamOut); %update the auto plot parameters 4190 4191 … … 4307 4308 PlotHandles=guidata(hview_field); 4308 4309 end 4309 if ~isempty(ProjData) 4310 % if ~isempty(ProjData) 4311 'TEST' 4312 ProjData 4310 4313 plot_field(ProjData,PlotHandles.axes3,PlotHandles); 4311 end4314 % end 4312 4315 set(handles.uvmat,'UserData',UvData) 4313 4316 hother=findobj('Tag','proj_object');%find all the proj objects … … 4363 4366 % end 4364 4367 end 4365 pause(0.1)4368 % pause(0.1) 4366 4369 figure(hset_object)%put set_object in front 4367 4370 -
trunk/src/view_field.m
r180 r187 90 90 set(hObject,'WindowButtonUpFcn',{'mouse_up',handles_mouse}) 91 91 set(hObject,'CloseRequestFcn',{@closefcn})% 92 ViewFieldData.axes3=[];%initiates the record of the current field (will be updated by plot_field) 93 set(handles.view_field,'UserData',ViewFieldData);%store the current field 92 94 if ~exist('Field','var') 93 95 return 94 96 end 95 97 'TESviewfield' 96 98 [PlotType,PlotParamOut]= plot_field(Field,handles.axes3);%,PlotParam,KeepLim,PosColorbar) 97 ViewFieldData.axes3=Field; 98 set(handles.view_field,'UserData',ViewFieldData);%store the current field 99 99 100 if isfield(PlotParamOut,'Vectors') 100 101 set(handles.VECT_title,'Visible','on') … … 285 286 set(handles.auto_xy,'BackgroundColor',[0.7 0.7 0.7]) 286 287 update_plot(handles) 287 % axis(handles.axes3,'image')288 288 end 289 289 … … 699 699 %------------------------------------------------------------------- 700 700 haxes= handles.axes3; 701 %huvmat=findobj(allchild(0),'tag','uvmat'); 702 ProjField=get(haxes,'UserData'); 701 702 %ProjField=get(haxes,'UserData'); 703 ViewFieldData=get(handles.view_field,'UserData'); 704 ProjField=ViewFieldData.axes3; 705 %ProjField=get(haxes,'UserData'); 703 706 PlotParam=read_plot_param(handles); 704 707 [PlotType,PlotParamOut]= plot_field(ProjField,haxes,PlotParam,1);
Note: See TracChangeset
for help on using the changeset viewer.