- Timestamp:
- Sep 29, 2013, 1:19:30 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_field_cells.m
r675 r690 209 209 VarDimName=Data.VarDimName(~check_select);%dimensions of remaining variables 210 210 check_coord_select= cellfun(@numel,VarDimName)==1|cellfun(@ischar,VarDimName)==1;% find remaining variables with a single dimension 211 check_coord_select=check_coord_select & ~strcmp('ancillary',Role(~check_select));% do not select ancillary variables as coordinates 211 212 %check_coord(~check_select)=check_coord_select; 212 213 ListCoordIndex=ivar_remain(check_coord_select);% indices of remaining variables with a single dimension -
trunk/src/plot_field.m
r688 r690 112 112 113 113 %% check input structure 114 index_2D=[];115 index_1D=[];116 index_0D=[];117 114 % check the cells of fields : 118 115 [CellInfo,NbDimArray,errormsg]=find_field_cells(Data); 119 %[CellVarIndex,NbDim,CoordType,VarRole,errormsg]=find_field_cells(Data);120 116 if ~isempty(errormsg) 121 117 msgbox_uvmat('ERROR',['input of plot_field/find_field_cells: ' errormsg]); … … 171 167 set(haxes,'YLimMode', 'auto') 172 168 end 173 % if ~isfield(PlotParam.Coordinates,'CheckFixAspectRatio')&& isfield(Data,'CoordUnit')174 % PlotParam.Coordinates.CheckFixAspectRatio=1;% if CoordUnit is defined, the two coordiantes should be plotted with equal scale by default175 % end176 169 errormsg=''; 177 %PlotParamOut.Coordinates=[]; %default output178 170 AxeData=get(haxes,'UserData'); 179 171 … … 210 202 211 203 %% text display 212 if isempty(index_2D) && isempty(index_1D)%text display alone 213 htext=findobj(hfig,'Tag','TableDisplay'); 214 else %text display added to plot 215 htext=findobj(hfig,'Tag','text_display'); 216 end 217 if ~isempty(htext) 204 205 htext=findobj(hfig,'Tag','TableDisplay'); 206 hchecktable=findobj(hfig,'Tag','CheckTable'); 207 % if isempty(index_2D) && isempty(index_1D)%text display alone 208 % htext=findobj(hfig,'Tag','TableDisplay'); 209 % else %text display added to plot 210 % %htext=findobj(hfig,'Tag','text_display'); 211 % end 212 if ~isempty(htext)&&~isempty(hchecktable) 218 213 if isempty(index_0D) 219 if strcmp(get(htext,'Type'),'uitable') 220 set(htext,'Data',{}) 221 else 222 set(htext,'String',{''}) 223 end 214 set(htext,'Data',{}) 215 set(htext,'visible','off') 216 set(hchecktable,'visible','off') 217 set(hchecktable,'Value',0) 224 218 else 225 [errormsg]=plot_text(Data,CellInfo(index_0D),htext); 219 errormsg=plot_text(Data,CellInfo(index_0D),htext); 220 set(htext,'visible','on') 221 set(hchecktable,'visible','on') 222 set(hchecktable,'Value',1) 223 end 224 set(hfig,'Unit','pixels'); 225 set(htext,'Unit','pixels') 226 PosFig=get(hfig,'Position'); 227 % case of no plot with view_field: only text display 228 if strcmp(get(hfig,'Tag'),'view_field') 229 if isempty(index_1D) && isempty(index_2D)% case of no plot: only text display 230 set(haxes,'Visible','off') 231 PosTable=get(htext,'Position'); 232 set(hfig,'Position',[PosFig(1) PosFig(2) PosTable(3) PosTable(4)]) 233 else 234 set(haxes,'Visible','on') 235 set(hfig,'Position',[PosFig(1) PosFig(2) 877 677])%default size for view_field 236 end 226 237 end 227 238 end … … 252 263 253 264 %------------------------------------------------------------------- 265 % --- plot 0D fields: display data values without plot 266 %------------------------------------------------------------------ 254 267 function errormsg=plot_text(FieldData,CellInfo,htext) 255 %------------------------------------------------------------------- 268 256 269 errormsg=''; 257 270 txt_cell={}; 258 271 Data={}; 272 VarIndex=[]; 259 273 for icell=1:length(CellInfo) 260 274 … … 267 281 end 268 282 end 269 VarIndex=find(check_proj); 270 % 271 % VarIndex=CellInfo{icell}.VarIndex;% indices of the selected variables in the list data.ListVarName 272 % for ivar=1:length(VarIndex) 273 % checkancillary=0; 274 % if length(FieldData.VarAttribute)>=VarIndex(ivar) 275 % VarAttribute=FieldData.VarAttribute{VarIndex(ivar)}; 276 % if isfield(VarAttribute,'Role')&&(strcmp(VarAttribute.Role,'ancillary')||strcmp(VarAttribute.Role,'coord_tps')... 277 % ||strcmp(VarAttribute.Role,'vector_x_tps')||strcmp(VarAttribute.Role,'vector_y_tps')) 278 % checkancillary=1; 279 % end 280 % end 281 % if ~checkancillary% does not display variables with attribute '.Role=ancillary' 282 for ivar=1:length(VarIndex) 283 VarName=FieldData.ListVarName{VarIndex(ivar)}; 284 VarValue=FieldData.(VarName); 285 if isvector(VarValue') 286 VarValue=VarValue';% put the different values on a line 287 end 288 if numel(VarValue)>1 && numel(VarValue)<10 289 for ind=1:numel(VarValue) 290 VarNameCell{1,ind}=[VarName '_' num2str(ilist)]; 291 end 292 else 293 VarNameCell={VarName}; 294 end 295 if numel(VarValue)<10 296 if isempty(VarValue) 297 VarValueCell={'[]'}; 298 else 299 VarValueCell=num2cell(VarValue); 300 end 301 if isempty(Data) 302 Data =[VarNameCell; VarValueCell]; 303 else 304 Data =[Data [VarNameCell; VarValueCell]]; 305 end 306 else 307 if isempty(Data) 308 Data =[VarNameCell; num2cell(VarValue)]; 309 else 310 Data =[Data [VarNameCell; {['size ' num2str(size(VarValue))]}]]; 311 end 312 end 313 if size(VarValue,1)==1 314 txt=[VarName '=' num2str(VarValue)]; 315 txt_cell=[txt_cell;{txt}]; 316 end 317 end 318 end 319 if strcmp(get(htext,'Type'),'uitable') 320 get(htext,'ColumnName') 321 set(htext,'ColumnName',Data(1,:)) 322 set(htext,'Data',Data(2:end,:)) 323 else 324 set(htext,'String',txt_cell) 325 set(htext,'UserData',txt_cell)% for storage during mouse display 326 end 327 328 283 VarIndex=[VarIndex find(check_proj)]; 284 end 285 286 % data need to be displayed in a table 287 if strcmp(get(htext,'Type'),'uitable')% display data in a table 288 VarNameCell=cell(1,numel(VarIndex));% prepare list of variable names to display (titles of columns) 289 VarLength=zeros(1,numel(VarIndex)); % default number of values for each variable 290 for ivar=1:numel(VarIndex) 291 VarNameCell{ivar}=FieldData.ListVarName{VarIndex(ivar)}; 292 VarLength(ivar)=numel(FieldData.(VarNameCell{ivar})); 293 end 294 set(htext,'ColumnName',VarNameCell) 295 Data=cell(max(VarLength),numel(VarIndex));% prepare the table of data display 296 297 for ivar=1:numel(VarIndex) 298 VarValue=FieldData.(VarNameCell{ivar}); 299 VarValue=reshape(VarValue,[],1);% reshape values array in a column 300 Data(1:numel(VarValue),ivar)=num2cell(VarValue); 301 end 302 set(htext,'Data',Data) 303 end 304 % if numel(VarValue)>1 && numel(VarValue)<10 % case of a variable with several values 305 % for ind=1:numel(VarValue) 306 % VarNameCell{1,ind}=[VarName '_' num2str(ind)];% indicate each value by an index 307 % end 308 % else 309 % VarNameCell={VarName}; 310 % end 311 % if numel(VarValue)<10 312 % if isempty(VarValue) 313 % VarValueCell={'[]'}; 314 % else 315 % VarValueCell=num2cell(VarValue); 316 % end 317 % if isempty(Data) 318 % Data =[VarNameCell VarValueCell]; 319 % else 320 % Data =[Data [VarNameCell VarValueCell]]; 321 % end 322 % else 323 % if isempty(Data) 324 % Data =[VarNameCell; num2cell(VarValue)]; 325 % else 326 % Data =[Data [VarNameCell; {['size ' num2str(size(VarValue))]}]]; 327 % end 328 % end 329 % if size(VarValue,1)==1 330 % txt=[VarName '=' num2str(VarValue)]; 331 % txt_cell=[txt_cell;{txt}]; 332 % end 333 % end 334 % end 335 % if strcmp(get(htext,'Type'),'uitable')% display data in a table 336 % 337 % 338 % set(htext,'Data',Data(2:end,:)) 339 % else % display in a text edit box 340 % set(htext,'String',txt_cell) 341 % set(htext,'UserData',txt_cell)% for temporary storage when the edit box is used for mouse display 342 % end 343 344 345 %------------------------------------------------------------------- 346 % --- plot 1D fields (usual x,y plots) 329 347 %------------------------------------------------------------------- 330 348 function CoordinatesOut=plot_profile(data,CellInfo,haxes,Coordinates,CheckHold) 331 %-------------------------------------------------------------------332 349 333 350 %% initialization … … 359 376 % end 360 377 if CheckHold 361 378 set(haxes,'NextPlot','add') 362 379 else 363 380 set(haxes,'NextPlot','replace') … … 446 463 end 447 464 if ~isempty(MinY) 448 MinY_cell(icell)=min(MinY);449 MaxY_cell(icell)=max(MaxY);465 MinY_cell(icell)=min(MinY); 466 MaxY_cell(icell)=max(MaxY); 450 467 end 451 468 end -
trunk/src/proj_field.m
r684 r690 306 306 [ProjData,errormsg]=proj_heading(FieldData,ObjectData); 307 307 308 objectfield=fieldnames(ObjectData);308 %objectfield=fieldnames(ObjectData); 309 309 widthx=0; 310 310 widthy=0; 311 if isfield(ObjectData,'RangeX') &~isempty(ObjectData.RangeX)311 if isfield(ObjectData,'RangeX') && ~isempty(ObjectData.RangeX) 312 312 widthx=max(ObjectData.RangeX); 313 313 end 314 if isfield(ObjectData,'RangeY') &~isempty(ObjectData.RangeY)314 if isfield(ObjectData,'RangeY') && ~isempty(ObjectData.RangeY) 315 315 widthy=max(ObjectData.RangeY); 316 316 end … … 324 324 CoordMesh=zeros(1,numel(FieldData.ListVarName)); 325 325 if isfield (FieldData,'VarAttribute') 326 %ProjData.VarAttribute=FieldData.VarAttribute;%list of variable attribute names327 326 for iattr=1:length(FieldData.VarAttribute)%initialization of variable attribute values 328 % ProjData.VarAttribute{iattr}={};329 327 if isfield(FieldData.VarAttribute{iattr},'Unit') 330 328 unit{iattr}=FieldData.VarAttribute{iattr}.Unit; … … 374 372 ivar_Z=CellInfo{icell}.CoordIndex(1); 375 373 end 376 if strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured coordinates 377 %nbpoint=numel(FieldData.(FieldData.ListVarName{VarIndex(1)})); 378 for ivar=[VarIndex ivar_X ivar_Y ivar_FF] 379 VarName=FieldData.ListVarName{ivar}; 380 FieldData.(VarName)=reshape(FieldData.(VarName),[],1); 381 end 382 XName=FieldData.ListVarName{ivar_X}; 383 YName=FieldData.ListVarName{ivar_Y}; 384 coord_x=FieldData.(XName); 385 coord_y=FieldData.(YName); 386 end 387 % image or 2D matrix 388 if strcmp(CellInfo{icell}.CoordType,'grid')%case of structured coordinates 389 test_Amat=1;% test for image or 2D matrix 390 AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 391 AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}; 392 eval(['AX=FieldData.' AXName ';'])% x coordinate 393 eval(['AY=FieldData.' AYName ';'])% y coordinate 394 VarName=FieldData.ListVarName{VarIndex(1)}; 395 DimValue=size(FieldData.(VarName)); 396 if length(AX)==2 397 AX=linspace(AX(1),AX(end),DimValue(2)); 398 end 399 if length(AY)==2 400 AY=linspace(AY(1),AY(end),DimValue(1)); 401 end 402 if length(DimValue)==3 403 testcolor=1; 404 npxy(3)=3; 405 else 406 testcolor=0; 407 npxy(3)=1; 408 end 409 [Xi,Yi]=meshgrid(AX,AY); 410 npxy(1)=length(AY); 411 npxy(2)=length(AX); 412 Xi=reshape(Xi,npxy(1)*npxy(2),1); 413 Yi=reshape(Yi,npxy(1)*npxy(2),1); 414 for ivar=1:length(VarIndex) 415 VarName=FieldData.ListVarName{VarIndex(ivar)}; 416 FieldData.(VarName)=reshape(FieldData.(VarName),npxy(1)*npxy(2),npxy(3)); % keep only non false vectors 417 end 374 switch CellInfo{icell}.CoordType 375 case 'scattered' %case of unstructured coordinates 376 for ivar=[VarIndex ivar_X ivar_Y ivar_FF] 377 VarName=FieldData.ListVarName{ivar}; 378 FieldData.(VarName)=reshape(FieldData.(VarName),[],1); 379 end 380 XName=FieldData.ListVarName{ivar_X}; 381 YName=FieldData.ListVarName{ivar_Y}; 382 coord_x=FieldData.(XName); 383 coord_y=FieldData.(YName); 384 % image or 2D matrix 385 case 'grid' %case of structured coordinates 386 test_Amat=1;% test for image or 2D matrix 387 AYName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 388 AXName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}; 389 AX=FieldData.(AXName);% x coordinate 390 AY=FieldData.(AYName);% y coordinate 391 VarName=FieldData.ListVarName{VarIndex(1)}; 392 DimValue=size(FieldData.(VarName)); 393 if length(AX)==2 394 AX=linspace(AX(1),AX(end),DimValue(2)); 395 end 396 if length(AY)==2 397 AY=linspace(AY(1),AY(end),DimValue(1)); 398 end 399 if length(DimValue)==3 400 testcolor=1; 401 npxy(3)=3; 402 else 403 testcolor=0; 404 npxy(3)=1; 405 end 406 [Xi,Yi]=meshgrid(AX,AY); 407 npxy(1)=length(AY); 408 npxy(2)=length(AX); 409 Xi=reshape(Xi,npxy(1)*npxy(2),1); 410 Yi=reshape(Yi,npxy(1)*npxy(2),1); 411 for ivar=1:length(VarIndex) 412 VarName=FieldData.ListVarName{VarIndex(ivar)}; 413 FieldData.(VarName)=reshape(FieldData.(VarName),npxy(1)*npxy(2),npxy(3)); % keep only non false vectors 414 end 418 415 end 419 416 %select the indices in the range of action … … 476 473 end 477 474 if isfield(FieldData,'VarAttribute')&& numel(FieldData.VarAttribute)>=ivar 478 ProjData.VarAttribute=[ProjData.VarAttribute FieldData.VarAttribute{ivar} {[]} {[]} {[]} {[]}];475 ProjData.VarAttribute=[ProjData.VarAttribute FieldData.VarAttribute{ivar} {[]} {[]} {[]} {[]}]; 479 476 end 480 477 end -
trunk/src/uvmat.m
r689 r690 356 356 set(handles.InputFile,'Position',pos_InputFile);% [lower x lower y width height] for text_display 357 357 358 %% reset position of text_display orTableDisplay359 if strcmp(get(handles.TableDisplay,'Visible'),'off')358 %% reset position of text_display and TableDisplay 359 % if strcmp(get(handles.TableDisplay,'Visible'),'off') 360 360 set(handles.text_display,'Units','pixels') 361 361 pos_1=get(handles.text_display,'Position');% [lower x lower y width height] for text_display … … 365 365 set(handles.text_display,'Position',pos_1) 366 366 % reset position of TableDisplay 367 else368 set(handles.TableDisplay,'Units','pixels')369 pos_1=get(handles.TableDisplay,'Position');370 pos_1(3)=1.2*ColumnWidth;371 pos_1(1)=size_fig(3)-pos_1(3);372 pos_1(2)=size_fig(4)-pos_InputFile(4)-pos_1(4);367 % else 368 % set(handles.TableDisplay,'Units','pixels') 369 % pos_1=get(handles.TableDisplay,'Position'); 370 % pos_1(3)=1.2*ColumnWidth; 371 % pos_1(1)=size_fig(3)-pos_1(3); 372 % pos_1(2)=size_fig(4)-pos_InputFile(4)-pos_1(4); 373 373 set(handles.TableDisplay,'Position',pos_1) 374 end 374 % reset position of CheckTable 375 set(handles.CheckTable,'Unit','pixels') 376 pos_CheckTable=get(handles.CheckTable,'Position');% [lower x lower y width height] for CheckHold 377 pos_CheckTable(1)=pos_1(1)-pos_CheckTable(3); % set 'CheckHold' to the right of the fig 378 pos_CheckTable(2)=pos_InputFile(2)-pos_CheckTable(4); % set 'CheckHold' to the lower edge of text display 379 set(handles.CheckTable,'Position',pos_CheckTable) 380 % end 375 381 376 382 %% reset position of CheckHold … … 2846 2852 %------------------------------------------------------------------------ 2847 2853 2848 if get(handles.CheckFixAspectRatio,'Value')2854 % if get(handles.CheckFixAspectRatio,'Value') 2849 2855 update_plot(handles); 2850 else2851 update_plot(handles);2852 end2856 % else 2857 % update_plot(handles); 2858 % end 2853 2859 2854 2860 %------------------------------------------------------------------------ … … 4044 4050 function update_plot(handles) 4045 4051 %------------------------------------------------------------------- 4046 set(handles.run0,'BackgroundColor',[1 1 0]);% indicateplot activity by yellow color4052 set(handles.run0,'BackgroundColor',[1 1 0]);% display plot activity by yellow color 4047 4053 drawnow 4048 4054 UvData=get(handles.uvmat,'UserData'); … … 4055 4061 return 4056 4062 end 4057 % RUNColor=get(handles.run0,'BackgroundColor');%4058 % if isequal(RUNColor,[1 0 1])% suppress magenta color (indicate that plot is updated)4059 % set(handles.run0,'BackgroundColor',[1 0 0]);4060 % end4061 4063 set(handles.run0,'BackgroundColor',[1 0 0]); 4062 4064 … … 4377 4379 if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) 4378 4380 ObjectData=get(hdisplay(iview),'UserData'); 4379 if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject)4381 if isfield(ObjectData,'SubObject') && ishandle(ObjectData.SubObject) 4380 4382 delete(ObjectData.SubObject);% delete the graphic 'sub-objects (e.g. projection bounds) 4381 4383 end 4382 check_suppress= isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint)4384 check_suppress= isfield(ObjectData,'DeformPoint') && ishandle(ObjectData.DeformPoint); 4383 4385 delete(ObjectData.DeformPoint(check_suppress));% delete the graphic deformation points 4384 4386 delete(hdisplay(iview))% delete the main graphic representation of the object … … 5312 5314 end 5313 5315 end 5316 5317 5318 % --- Executes on button press in CheckTable. 5319 function CheckTable_Callback(hObject, eventdata, handles) 5320 if get(handles.CheckTable,'Value') 5321 set(handles.TableDisplay,'Visible','on') 5322 else 5323 set(handles.TableDisplay,'Visible','off') 5324 end -
trunk/src/view_field.m
r681 r690 117 117 set(handles.view_field,'UserData',Data) 118 118 119 %% reset position of text_display orTableDisplay120 if strcmp(get(handles.TableDisplay,'Visible'),'off') 119 %% reset position of text_display and TableDisplay 120 % reset position of text_display 121 121 pos_1=get(handles.text_display,'Position');% [lower x lower y width height] for text_display 122 122 pos_1(1)=size_fig(3)-pos_1(3); % set text display to the right of the fig … … 124 124 set(handles.text_display,'Position',pos_1) 125 125 % reset position of TableDisplay 126 else 127 pos_1=get(handles.TableDisplay,'Position'); 128 pos_1(1)=size_fig(3)-pos_1(3); 129 pos_1(2)=size_fig(4)-pos_1(4); 126 % pos_1=get(handles.TableDisplay,'Position'); 127 % pos_1(1)=size_fig(3)-pos_1(3); 128 % pos_1(2)=size_fig(4)-pos_1(4); 130 129 set(handles.TableDisplay,'Position',pos_1) 131 end 130 % end 131 % reset position of CheckTable 132 pos_CheckTable=get(handles.CheckTable,'Position');% [lower x lower y width height] for CheckHold 133 pos_CheckTable(1)=pos_1(1)-pos_CheckTable(3); % set 'CheckHold' to the right of the fig 134 pos_CheckTable(2)=size_fig(4)-pos_CheckTable(4); % set 'CheckHold' to the lower edge of text display 135 set(handles.CheckTable,'Position',pos_CheckTable) 132 136 133 137 %% reset position of CheckHold … … 841 845 function num_ColCode2_Callback(hObject, eventdata, handles) 842 846 847 848 849 % --- Executes on button press in CheckTable. 850 function CheckTable_Callback(hObject, eventdata, handles) 851 if get(handles.CheckTable,'Value') 852 set(handles.TableDisplay,'Visible','on') 853 else 854 set(handles.TableDisplay,'Visible','off') 855 end 856
Note: See TracChangeset
for help on using the changeset viewer.