- Timestamp:
- Apr 29, 2012, 11:29:24 AM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mouse_down.m
r387 r402 253 253 set(hhuvmat.ListObject,'Value',IndexObj); 254 254 set(hhuvmat.ListObject,'UserData',IndexObj); 255 % list_str=get(hhuvmat.list_object_2,'String');256 % UvData.Object{IndexObj(2)}.Name=list_str{IndexObj};257 255 else 258 256 set(hhuvmat.ListObject,'Value',IndexObj); … … 291 289 %% create new projection object 292 290 if test_create && ~isempty(xy) && ~(isfield(AxeData,'Drawing')&& isequal(AxeData.Drawing,'create')) 293 hset_object=findobj(allchild(0),'tag','set_object'); 294 if ~isempty(hset_object) 295 %ObjectData=read_set_object(sethandles); %read object features in the GUI set_object 296 ObjectData=read_GUI(hset_object); 297 ObjectData.Coord=[]; %reset previous object coordinates 298 ObjectData.Coord(1,1)=xy(1,1); 299 ObjectData.Coord(1,2)=xy(1,2); 300 % ObjectData.Coord(1,3)=0; 301 if isfield(AxeData,'ObjectCoord') & size(AxeData.ObjectCoord,2)==3 302 ObjectData.Coord(1,3)=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle 303 end 304 AxeData.CurrentObject=plot_object(ObjectData,[],haxes,'m');%draw the object and its handle becomes AxeData.CurrentObject 305 if isfield(UvData,'Object') 306 IndexObj=length(UvData.Object)+1;% add the object as index IndexObj on the list of the interface 307 else 308 IndexObj=2; 309 end 310 UvData.Object{IndexObj}=ObjectData; 311 list_str=get(hhuvmat.ListObject,'String'); 312 IndexObj_old=get(hhuvmat.ListObject,'Value'); 313 % set(hhuvmat.ListObject,'Value',[IndexObj_old(1) IndexObj] ); 314 UvData.Object{IndexObj}.DisplayHandle_uvmat=AxeData.CurrentObject; 315 object_name=ObjectData.Name; 316 sethandles=guidata(hset_object); 317 if isempty(object_name) 318 list_str{IndexObj}=[num2str(IndexObj) '-' ObjectData.Type]; 319 set(sethandles.Name,'String',list_str{IndexObj}) 320 else 321 list_str{IndexObj}=object_name; 322 end 323 set(hhuvmat.ListObject,'String',list_str) 324 set(hhuvmat.ListObject,'Value',[IndexObj_old(1) IndexObj] ); 325 UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject; 326 set(huvmat,'UserData',UvData) 327 PlotData=get(AxeData.CurrentObject,'UserData'); 328 PlotData.IndexObj=IndexObj; 329 set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph 330 AxeData.Drawing='create'; 331 end 291 hset_object=findobj(allchild(0),'tag','set_object'); 292 if ~isempty(hset_object) 293 sethandles=guidata(hset_object); 294 ObjectData=read_GUI(hset_object); %read object features in the GUI set_object 295 ObjectData.Coord=[]; %reset previous object coordinates 296 ObjectData.Coord(1,1)=xy(1,1); 297 ObjectData.Coord(1,2)=xy(1,2); 298 if isfield(AxeData,'ObjectCoord') & size(AxeData.ObjectCoord,2)==3 299 ObjectData.Coord(1,3)=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle 300 end 301 AxeData.CurrentObject=plot_object(ObjectData,[],haxes,'m');%draw the object and its handle becomes AxeData.CurrentObject 302 if isfield(UvData,'Object') 303 IndexObj=length(UvData.Object)+1;% add the object as index IndexObj on the list of the interface 304 else 305 IndexObj=2; 306 end 307 UvData.Object{IndexObj}=ObjectData; 308 ListObject=get(hhuvmat.ListObject,'String'); 309 IndexObj_old=get(hhuvmat.ListObject,'Value'); 310 UvData.Object{IndexObj}.DisplayHandle_uvmat=AxeData.CurrentObject; 311 ObjectNameNew=ObjectData.Name; 312 if isempty(ObjectNameNew) 313 ObjectNameNew=ObjectData.Type; 314 end 315 vers=0;% index of the name 316 detectname=1; 317 while detectname==1 318 detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list 319 if detectname% if the object name already exists 320 indstr=regexp(ObjectNameNew,'\D'); 321 if indstr(end)<length(ObjectNameNew) %object name ends by a number 322 vers=str2double(ObjectNameNew(indstr(end)+1:end))+1; 323 ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)]; 324 else 325 vers=vers+1; 326 ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)]; 327 end 328 end 329 end 330 ObjectName=ObjectNameNew; 331 set(sethandles.Name,'String',ObjectName)% display the default name in set_object 332 IndexObj=numel(ListObject)+1;% append an object to the list in uvmat 333 set(hhuvmat.ListObject,'String',[ListObject;{ObjectName}]);%complement the object list 334 set(hhuvmat.ListObject,'Value',[IndexObj_old(1) IndexObj]) 335 % if isempty(object_name) 336 % list_str{IndexObj}=[num2str(IndexObj) '-' ObjectData.Type]; 337 % set(sethandles.Name,'String',list_str{IndexObj}) 338 % else 339 % list_str{IndexObj}=object_name; 340 % end 341 % set(hhuvmat.ListObject,'String',list_str) 342 UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject; 343 set(huvmat,'UserData',UvData) 344 PlotData=get(AxeData.CurrentObject,'UserData'); 345 PlotData.IndexObj=IndexObj; 346 set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph 347 AxeData.Drawing='create'; 348 end 332 349 end 333 350 -
trunk/src/plot_field.m
r397 r402 531 531 for icell=1:length(CellVarIndex) % length(CellVarIndex) =1 or 2 (from the calling function) 532 532 VarType=VarTypeCell{icell}; 533 if ~isempty(VarType.coord_tps) 534 continue 535 end 533 536 ivar_X=VarType.coord_x; % defines (unique) index for the variable representing unstructured x coordinate (default =[]) 534 537 ivar_Y=VarType.coord_y; % defines (unique)index for the variable representing unstructured y coordinate (default =[]) -
trunk/src/proj_field.m
r399 r402 82 82 function [ProjData,errormsg]=proj_field(FieldData,ObjectData) 83 83 errormsg='';%default 84 if ~exist('FieldName','var')85 FieldName='';86 end84 % if ~exist('FieldName','var') 85 % FieldName=''; 86 % end 87 87 %% case of no projection (object is used only as graph display) 88 88 if isfield(ObjectData,'ProjMode') && (isequal(ObjectData.ProjMode,'none')||isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')) … … 1195 1195 case 'filter' 1196 1196 if ~isempty(VarType.coord_tps) 1197 VarType.coord_tps 1197 %Coord_tps=FieldData.ListVarName{VarType.coord_tps}; 1198 %TODO: possibly translate and rotate coordiantes translate initial coordinates 1198 1199 coord_x_proj=XMin:DX:XMax; 1199 1200 coord_y_proj=YMin:DY:YMax; … … 1201 1202 np_y=numel(coord_y_proj); 1202 1203 [XI,YI]=meshgrid(coord_x_proj,coord_y_proj'); 1203 XI=reshape(XI,[],1) ;1204 YI=reshape(YI,[],1) ;1204 XI=reshape(XI,[],1)+ObjectData.Coord(1,1); 1205 YI=reshape(YI,[],1)+ObjectData.Coord(1,2); 1205 1206 ProjData=calc_field(FieldData.FieldList,FieldData,[XI YI]); 1206 1207 for ilist=3:length(ProjData.ListVarName)% reshape data, excluding coordinates (ilist=1-2), TODO: rationalise -
trunk/src/read_get_field.m
r231 r402 450 450 end 451 451 452 453 454 452 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 455 453 %% get the input field 456 454 inputfield=get(handles.inputfile,'String'); 457 455 if exist(inputfield,'file')% read the input data corresponding to the list of selected varaibles 458 SubField=nc2struct(inputfield,ListVarName); 456 SubField=nc2struct(inputfield,ListVarName);%read the list of variables ListVarName from the input file 459 457 else % subfield stored in memory 460 458 SubField.ListGlobalAttribute={}; … … 639 637 VarNameU=Field.ListVarName{VarIndexU}; % name of u component variable 640 638 DimCellU=Field.VarDimName{VarIndexU}; % list of dimensions for u component 641 eval(['npxy=size(SubField.' VarNameU ');']) % npxy= dimension values for the u component 639 % eval(['npxy=size(SubField.' VarNameU ');']) % npxy= dimension values for the u component 640 npxy=size(SubField.(VarNameU)); % npxy= dimension values for the u componen 642 641 SingleCellU={}; 643 642 if numel(npxy) < numel(DimCellU) -
trunk/src/set_object.m
r397 r402 85 85 set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front) 86 86 set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function 87 set(hObject,'DeleteFcn',{@closefcn}) 87 88 enable_plot=0;%default: does not allow plot of object and projection 88 89 89 90 % fill the interface as set in the input data: 90 91 if exist('data','var') 91 if isfield(data,'enable_plot')92 enable_plot=data.enable_plot;%test to desable button PLOT (display mode)93 end92 % if isfield(data,'enable_plot') 93 % enable_plot=data.enable_plot;%test to desable button PLOT (display mode) 94 % end 94 95 if isfield(data,'Coord') &&size(data.Coord,2)==3 95 96 set(handles.z_slider,'Visible','on') … … 149 150 end 150 151 end 151 if enable_plot 152 set(handles.PLOT,'enable','on') 153 else 152 % if enable_plot 153 % set(handles.PLOT,'enable','on') 154 % else 155 % enable the PLOT (REFRESH) button by default 154 156 set(handles.PLOT,'enable','off') 155 end157 % end 156 158 huvmat=findobj(allchild(0),'tag','uvmat'); 157 159 UvData=get(huvmat,'UserData'); … … 171 173 varargout{1} = handles.output; 172 174 varargout{2}=handles; 175 176 %------------------------------------------------------------------------ 177 % executed when closing the GUI set_object 178 function closefcn(gcbo,eventdata) 179 %------------------------------------------------------------------------ 180 huvmat=findobj(allchild(0),'Tag','uvmat');%find the current uvmat interface handle 181 if ~isempty(huvmat) 182 hhuvmat=guidata(huvmat); 183 set(hhuvmat.edit_object,'Value',0) 184 set(hhuvmat.edit_object,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree 185 % deselect the object in ListObject when view_field is closed 186 if isempty(findobj(allchild(0),'Tag','view_field')) 187 ObjIndex=get(hhuvmat.ListObject,'Value'); 188 ObjIndex=ObjIndex(1);%keep only the first object selected 189 set(hhuvmat.ListObject,'Value',ObjIndex) 190 % draw all object colors in blue (unselected) in uvmat 191 hother=[findobj(hhuvmat.axes3,'Tag','proj_object');findobj(hhuvmat.axes3,'Tag','DeformPoint')];%find all the proj object and deform point representations 192 for iobj=1:length(hother) 193 if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') 194 set(hother(iobj),'EdgeColor','b') 195 if isequal(get(hother(iobj),'FaceColor'),'m') 196 set(hother(iobj),'FaceColor','b') 197 end 198 elseif isequal(get(hother(iobj),'Type'),'image') 199 Acolor=get(hother(iobj),'CData'); 200 Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); 201 set(hother(iobj),'CData',Acolor); 202 else 203 set(hother(iobj),'Color','b') 204 end 205 set(hother(iobj),'Selected','off') 206 end 207 end 208 end 209 hseries=findobj(allchild(0),'Name','series');%find the current series interface handle 210 if ~isempty(hseries) 211 hhseries=guidata(hseries); 212 set(hhseries.GetObject,'Value',0) 213 set(hhseries.GetObject,'BackgroundColor',[0 1 0])%put unactivated buttons to green 214 end 215 173 216 174 217 %------------------------------------------------------------------------ … … 364 407 %------------------------------------------------------------------------ 365 408 366 %------------------------------------------------------------------------367 %------------------------------------------------------------------------368 %----------------------------------------------------369 % executed when closing: set the parent interface button to value 0370 function closefcn(gcbo,eventdata,parent_button)371 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle372 if ~isempty(huvmat)373 hhuvmat=guidata(huvmat);374 set(hhuvmat.edit,'Value',0)375 set(hhuvmat.edit,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree376 end377 hseries=findobj(allchild(0),'Name','series');%find the current series interface handle378 if ~isempty(hseries)379 hhseries=guidata(hseries);380 set(hhseries.GetObject,'Value',0)381 set(hhseries.GetObject,'BackgroundColor',[0 1 0])%put unactivated buttons to green382 end383 409 384 410 %------------------------------------------------------------------------ … … 396 422 %% read the object on the GUI set_object 397 423 ObjectData=read_GUI(handles.set_object);%read the parameters defining the object in the GUI set_object 398 ObjectName=ObjectData.Name;%name of the current object defined in set_object399 424 if iscell(ObjectData.Coord)%check for empty line 400 425 ObjectData.Coord=[0 0 0]; … … 406 431 ObjectData.Coord(checknan,:)=[];%remove the NaN lines 407 432 end 433 ObjectName=ObjectData.Name;%name of the current object defined in set_object 408 434 if isempty(ObjectName) 409 435 if get(hhuvmat.edit_object,'Value')% edit mode … … 411 437 ObjectName='Plane'; 412 438 else 413 ObjectName=ListObject{IndexObj(end)};%take the name of the last (second) selected item439 ObjectName=ListObject{IndexObj(end)};%take the name of the last (second) selected item 414 440 end 415 441 else %new object 416 StyleList=get(handles.Type,'String'); 417 StyleVal=get(handles.Type,'Value'); 418 ObjectName=StyleList{StyleVal}; 442 ObjectName=ObjectData.Type; 419 443 end 420 444 end … … 422 446 detectname=1; 423 447 ObjectNameNew=ObjectName; 424 vers=0; 448 vers=0;% index of the name 425 449 while detectname==1 426 450 detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list -
trunk/src/sub_field.m
r180 r402 72 72 end 73 73 iselect=find(NbDim==2); 74 for icell=iselect 75 if ~isempty(VarTypeCell{icell}.coord_tps) 76 NbDim(icell)=0; 77 end 78 end 79 iselect=find(NbDim==2); 74 80 if ~isequal(numel(iselect),1) 75 81 errormsg='invalid first input to sub_field: it must contain a single 2D field cell'; 76 82 return 83 end 84 iselect_1=find(NbDim_1==2); 85 for icell=iselect_1 86 if ~isempty(VarTypeCell_1{icell}.coord_tps) 87 NbDim_1(icell)=0; 88 end 77 89 end 78 90 iselect_1=find(NbDim_1==2); -
trunk/src/uvmat.m
r399 r402 168 168 %------------------------------------------------------------------------ 169 169 %------------------------------------------------------------------------ 170 % I - MAIN FUNCTION UVMAT (DO NOT MODIFY)170 % I - MAIN FUNCTION UVMAT 171 171 %------------------------------------------------------------------------ 172 172 %------------------------------------------------------------------------ … … 234 234 %% refresh projection plane 235 235 UvData.Object{1}.ProjMode='projection';%main plotting plane 236 set(handles.ListObject,'Value',1)% default: empty projection object 237 set(handles.ListObject,'String',{''}) 236 238 set(handles.Fields,'Value',1) 237 239 set(handles.Fields,'string',{''}) … … 374 376 375 377 %------------------------------------------------------------------------ 378 % --- executed when closing uvmat: delete or desactivate the associated figures if exist 379 function closefcn(gcbo,eventdata) 380 %------------------------------------------------------------------------ 381 hh=findobj(allchild(0),'tag','view_field'); 382 if ~isempty(hh) 383 delete(hh) 384 end 385 hh=findobj(allchild(0),'tag','geometry_calib'); 386 if ~isempty(hh) 387 delete(hh) 388 end 389 hh=findobj(allchild(0),'tag','set_object'); 390 if ~isempty(hh) 391 hhh=findobj(hh,'tag','PLOT'); 392 set(hhh,'enable','off') 393 end 394 395 %------------------------------------------------------------------------ 376 396 %------------------------------------------------------------------------ 377 397 % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES … … 458 478 fileinput=get(handles.MenuFile_5,'Label'); 459 479 display_file_name(hObject, eventdata, handles,fileinput) 480 481 %------------------------------------------------------------------------ 482 % --- Executes on the menu Open/Browse_1 for the second input field, 483 % search the files, recognize their type according to their name and fill the rootfile input windows 484 function MenuBrowse_1_Callback(hObject, eventdata, handles) 485 %------------------------------------------------------------------------ 486 % huvmat=get(handles.run0,'parent'); 487 UvData=get(handles.uvmat,'UserData'); 488 489 RootPath=get(handles.RootPath,'String'); 490 [FileName, PathName, filterindex] = uigetfile( ... 491 {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)'; 492 '*.xml', '.xml files '; ... 493 '*.xls', '.xls files '; ... 494 '*.civ', '.civ files '; ... 495 '*.jpg','.jpg image files'; ... 496 '*.png','.png image files'; ... 497 '*.avi;*.AVI','.avi movie files'; ... 498 '*.nc','.netcdf files'; ... 499 '*.cdf','.netcdf files'; ... 500 '*.cmx','.cmx text files';... 501 '*.cmx2','.cmx2 text files';... 502 '*.fig','.fig files (matlab fig)';... 503 '*.log','.log text files ';... 504 '*.dat','.dat text files ';... 505 '*.*', 'All Files (*.*)'}, ... 506 'Pick a second file for comparison',RootPath); 507 fileinput_1=[PathName FileName];%complete file name 508 sizf=size(fileinput_1); 509 if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end 510 511 % refresh the current displayed field 512 set(handles.SubField,'Value',1) 513 display_file_name(hObject,eventdata,handles,fileinput_1,2) 514 515 %update list of recent files in the menubar 516 MenuFile_1=fileinput_1; 517 MenuFile_2=get(handles.MenuFile_1,'Label'); 518 MenuFile_3=get(handles.MenuFile_2,'Label'); 519 MenuFile_4=get(handles.MenuFile_3,'Label'); 520 MenuFile_5=get(handles.MenuFile_4,'Label'); 521 set(handles.MenuFile_1,'Label',MenuFile_1) 522 set(handles.MenuFile_2,'Label',MenuFile_2) 523 set(handles.MenuFile_3,'Label',MenuFile_3) 524 set(handles.MenuFile_4,'Label',MenuFile_4) 525 set(handles.MenuFile_5,'Label',MenuFile_5) 526 set(handles.MenuFile_1_1,'Label',MenuFile_1) 527 set(handles.MenuFile_2_1,'Label',MenuFile_2) 528 set(handles.MenuFile_3_1,'Label',MenuFile_3) 529 set(handles.MenuFile_4_1,'Label',MenuFile_4) 530 set(handles.MenuFile_5_1,'Label',MenuFile_5) 531 dir_perso=prefdir; 532 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 533 if exist(profil_perso,'file') 534 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat 535 else 536 txt=ver('MATLAB'); 537 Release=txt.Release; 538 relnumb=str2double(Release(3:4)); 539 if relnumb >= 14 540 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat 541 else 542 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat 543 end 544 end 545 546 % ----------------------------------------------------------------------- 547 % --- Open again as second field the file whose name has been recorded in MenuFile_1 548 function MenuFile_1_1_Callback(hObject, eventdata, handles) 549 % ----------------------------------------------------------------------- 550 fileinput_1=get(handles.MenuFile_1_1,'Label'); 551 set(handles.SubField,'Value',1) 552 display_file_name(hObject,eventdata,handles,fileinput_1,2) 553 554 % ----------------------------------------------------------------------- 555 % --- Open again as second field the file whose name has been recorded in MenuFile_2 556 function MenuFile_2_1_Callback(hObject, eventdata, handles) 557 % ----------------------------------------------------------------------- 558 fileinput_1=get(handles.MenuFile_2_1,'Label'); 559 set(handles.SubField,'Value',1) 560 display_file_name(hObject,eventdata,handles,fileinput_1,2) 561 562 % ----------------------------------------------------------------------- 563 % --- Open again as second field the file whose name has been recorded in MenuFile_3 564 function MenuFile_3_1_Callback(hObject, eventdata, handles) 565 % ----------------------------------------------------------------------- 566 fileinput_1=get(handles.MenuFile_3_1,'Label'); 567 set(handles.SubField,'Value',1) 568 display_file_name(hObject,eventdata,handles,fileinput_1,2) 569 570 % ----------------------------------------------------------------------- 571 % --- Open again as second field the file whose name has been recorded in MenuFile_4 572 function MenuFile_4_1_Callback(hObject, eventdata, handles) 573 % ----------------------------------------------------------------------- 574 fileinput_1=get(handles.MenuFile_4_1,'Label'); 575 set(handles.SubField,'Value',1) 576 display_file_name(hObject,eventdata,handles,fileinput_1,2) 577 578 % ----------------------------------------------------------------------- 579 % --- Open again as second field the file whose name has been recorded in MenuFile_5 580 function MenuFile_5_1_Callback(hObject, eventdata, handles) 581 % ----------------------------------------------------------------------- 582 fileinput_1=get(handles.MenuFile_5_1,'Label'); 583 set(handles.SubField,'Value',1) 584 display_file_name(hObject,eventdata,handles,fileinput_1,2) 585 586 %------------------------------------------------------------------------ 587 % --- Called by action in RootPath edit box 588 function RootPath_Callback(hObject,eventdata,handles) 589 %------------------------------------------------------------------------ 590 % read the current input file name: 591 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 592 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 593 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); 594 % initiate the input file series and refresh the current field view: 595 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject); 596 597 %----------------------------------------------------------------------- 598 % --- Called by action in RootPath_1 edit box 599 function RootPath_1_Callback(hObject,eventdata,handles) 600 % ----------------------------------------------------------------------- 601 % update_rootinfo_1(hObject,eventdata,handles) 602 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); 603 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 604 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); 605 % initiate the input file series and refresh the current field view: 606 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2); 607 608 %------------------------------------------------------------------------ 609 % --- Called by action in RootFile edit box 610 function SubDir_Callback(hObject, eventdata, handles) 611 %------------------------------------------------------------------------ 612 %refresh the menu of input fields 613 Fields_Callback(hObject, eventdata, handles); 614 % refresh the current field view 615 run0_Callback(hObject, eventdata, handles); 616 617 %------------------------------------------------------------------------ 618 % --- Called by action in RootFile edit box 619 function RootFile_Callback(hObject, eventdata, handles) 620 %------------------------------------------------------------------------ 621 RootPath_Callback(hObject,eventdata,handles) 622 623 %----------------------------------------------------------------------- 624 % --- Called by action in RootFile_1 edit box 625 function RootFile_1_Callback(hObject, eventdata, handles) 626 % ----------------------------------------------------------------------- 627 RootPath_1_Callback(hObject,eventdata,handles) 628 629 %------------------------------------------------------------------------ 630 % --- Called by action in FileIndex edit box 631 function FileIndex_Callback(hObject, eventdata, handles) 632 %------------------------------------------------------------------------ 633 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); 634 set(handles.i1,'String',num2str(i1)); 635 set(handles.i2,'String',num2str(i2)); 636 set(handles.j1,'String',num2str(j1)); 637 set(handles.j2,'String',num2str(j2)); 638 639 % refresh the current field view 640 run0_Callback(hObject, eventdata, handles) 641 642 %------------------------------------------------------------------------ 643 % --- Called by action in FileIndex_1 edit box 644 function FileIndex_1_Callback(hObject, eventdata, handles) 645 %------------------------------------------------------------------------ 646 run0_Callback(hObject, eventdata, handles) 647 648 %------------------------------------------------------------------------ 649 % --- Called by action in NomType edit box 650 function NomType_Callback(hObject, eventdata, handles) 651 %------------------------------------------------------------------------ 652 i1=str2num(get(handles.i1,'String')); 653 i2=str2num(get(handles.i2,'String')); 654 j1=str2num(get(handles.j1,'String')); 655 j2=str2num(get(handles.j2,'String')); 656 FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2); 657 set(handles.FileIndex,'String',FileIndex) 658 % refresh the current settings and refresh the field view 659 RootPath_Callback(hObject,eventdata,handles) 660 661 %------------------------------------------------------------------------ 662 % --- Called by action in NomType edit box 663 function NomType_1_Callback(hObject, eventdata, handles) 664 %------------------------------------------------------------------------ 665 i1=str2num(get(handles.i1,'String')); 666 i2=str2num(get(handles.i2,'String')); 667 j1=str2num(get(handles.j1,'String')); 668 j2=str2num(get(handles.j2,'String')); 669 FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2); 670 set(handles.FileIndex_1,'String',FileIndex) 671 % refresh the current settings and refresh the field view 672 RootPath_1_Callback(hObject,eventdata,handles) 460 673 461 674 %------------------------------------------------------------------------ … … 591 804 set(handles.uvmat,'Pointer','arrow') 592 805 593 %------------------------------------------------------------------------594 % --- Called by action in RootPath edit box595 function RootPath_Callback(hObject,eventdata,handles)596 %------------------------------------------------------------------------597 % read the current input file name:598 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);599 %fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];600 % detect the file type, get the movie object if relevant, and look for the corresponding file series:601 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);602 % initiate the input file series and refresh the current field view:603 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject);604 605 %------------------------------------------------------------------------606 % --- Called by action in RootFile edit box607 function SubDir_Callback(hObject, eventdata, handles)608 %------------------------------------------------------------------------609 %refresh the menu of input fields610 Fields_Callback(hObject, eventdata, handles);611 % refresh the current field view612 run0_Callback(hObject, eventdata, handles);613 614 %------------------------------------------------------------------------615 % --- Called by action in RootFile edit box616 function RootFile_Callback(hObject, eventdata, handles)617 %------------------------------------------------------------------------618 RootPath_Callback(hObject,eventdata,handles)619 620 %------------------------------------------------------------------------621 % --- Called by action in FileIndex edit box622 function FileIndex_Callback(hObject, eventdata, handles)623 %------------------------------------------------------------------------624 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));625 set(handles.i1,'String',num2str(i1));626 set(handles.i2,'String',num2str(i2));627 set(handles.j1,'String',num2str(j1));628 set(handles.j2,'String',num2str(j2));629 630 % refresh the current field view631 run0_Callback(hObject, eventdata, handles)632 806 633 807 %------------------------------------------------------------------------ … … 971 1145 end 972 1146 973 974 %------------------------------------------------------------------------975 % --- Executes on the menu Open/Browse_1 for the second input field,976 % search the files, recognize their type according to their name and fill the rootfile input windows977 function MenuBrowse_1_Callback(hObject, eventdata, handles)978 %------------------------------------------------------------------------979 % huvmat=get(handles.run0,'parent');980 UvData=get(handles.uvmat,'UserData');981 982 RootPath=get(handles.RootPath,'String');983 [FileName, PathName, filterindex] = uigetfile( ...984 {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';985 '*.xml', '.xml files '; ...986 '*.xls', '.xls files '; ...987 '*.civ', '.civ files '; ...988 '*.jpg','.jpg image files'; ...989 '*.png','.png image files'; ...990 '*.avi;*.AVI','.avi movie files'; ...991 '*.nc','.netcdf files'; ...992 '*.cdf','.netcdf files'; ...993 '*.cmx','.cmx text files';...994 '*.cmx2','.cmx2 text files';...995 '*.fig','.fig files (matlab fig)';...996 '*.log','.log text files ';...997 '*.dat','.dat text files ';...998 '*.*', 'All Files (*.*)'}, ...999 'Pick a second file for comparison',RootPath);1000 fileinput_1=[PathName FileName];%complete file name1001 sizf=size(fileinput_1);1002 if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end1003 1004 % refresh the current displayed field1005 set(handles.SubField,'Value',1)1006 display_file_name(hObject,eventdata,handles,fileinput_1,2)1007 1008 %update list of recent files in the menubar1009 MenuFile_1=fileinput_1;1010 MenuFile_2=get(handles.MenuFile_1,'Label');1011 MenuFile_3=get(handles.MenuFile_2,'Label');1012 MenuFile_4=get(handles.MenuFile_3,'Label');1013 MenuFile_5=get(handles.MenuFile_4,'Label');1014 set(handles.MenuFile_1,'Label',MenuFile_1)1015 set(handles.MenuFile_2,'Label',MenuFile_2)1016 set(handles.MenuFile_3,'Label',MenuFile_3)1017 set(handles.MenuFile_4,'Label',MenuFile_4)1018 set(handles.MenuFile_5,'Label',MenuFile_5)1019 set(handles.MenuFile_1_1,'Label',MenuFile_1)1020 set(handles.MenuFile_2_1,'Label',MenuFile_2)1021 set(handles.MenuFile_3_1,'Label',MenuFile_3)1022 set(handles.MenuFile_4_1,'Label',MenuFile_4)1023 set(handles.MenuFile_5_1,'Label',MenuFile_5)1024 dir_perso=prefdir;1025 profil_perso=fullfile(dir_perso,'uvmat_perso.mat');1026 if exist(profil_perso,'file')1027 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat1028 else1029 txt=ver('MATLAB');1030 Release=txt.Release;1031 relnumb=str2double(Release(3:4));1032 if relnumb >= 141033 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat1034 else1035 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat1036 end1037 end1038 1039 % -----------------------------------------------------------------------1040 % --- Open again as second field the file whose name has been recorded in MenuFile_11041 function MenuFile_1_1_Callback(hObject, eventdata, handles)1042 % -----------------------------------------------------------------------1043 fileinput_1=get(handles.MenuFile_1_1,'Label');1044 set(handles.SubField,'Value',1)1045 display_file_name(hObject,eventdata,handles,fileinput_1,2)1046 1047 % -----------------------------------------------------------------------1048 % --- Open again as second field the file whose name has been recorded in MenuFile_21049 function MenuFile_2_1_Callback(hObject, eventdata, handles)1050 % -----------------------------------------------------------------------1051 fileinput_1=get(handles.MenuFile_2_1,'Label');1052 set(handles.SubField,'Value',1)1053 display_file_name(hObject,eventdata,handles,fileinput_1,2)1054 1055 % -----------------------------------------------------------------------1056 % --- Open again as second field the file whose name has been recorded in MenuFile_31057 function MenuFile_3_1_Callback(hObject, eventdata, handles)1058 % -----------------------------------------------------------------------1059 fileinput_1=get(handles.MenuFile_3_1,'Label');1060 set(handles.SubField,'Value',1)1061 display_file_name(hObject,eventdata,handles,fileinput_1,2)1062 1063 % -----------------------------------------------------------------------1064 % --- Open again as second field the file whose name has been recorded in MenuFile_41065 function MenuFile_4_1_Callback(hObject, eventdata, handles)1066 % -----------------------------------------------------------------------1067 fileinput_1=get(handles.MenuFile_4_1,'Label');1068 set(handles.SubField,'Value',1)1069 display_file_name(hObject,eventdata,handles,fileinput_1,2)1070 1071 % -----------------------------------------------------------------------1072 % --- Open again as second field the file whose name has been recorded in MenuFile_51073 function MenuFile_5_1_Callback(hObject, eventdata, handles)1074 % -----------------------------------------------------------------------1075 fileinput_1=get(handles.MenuFile_5_1,'Label');1076 set(handles.SubField,'Value',1)1077 display_file_name(hObject,eventdata,handles,fileinput_1,2)1078 1079 %-----------------------------------------------------------------------1080 % --- Called by action in RootPath_1 edit box1081 function RootPath_1_Callback(hObject,eventdata,handles)1082 % -----------------------------------------------------------------------1083 % update_rootinfo_1(hObject,eventdata,handles)1084 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);1085 %fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];1086 % detect the file type, get the movie object if relevant, and look for the corresponding file series:1087 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);1088 % initiate the input file series and refresh the current field view:1089 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2);1090 %-----------------------------------------------------------------------1091 % --- Called by action in RootFile_1 edit box1092 function RootFile_1_Callback(hObject, eventdata, handles)1093 % -----------------------------------------------------------------------1094 RootPath_1_Callback(hObject,eventdata,handles)1095 1096 %------------------------------------------------------------------------1097 % --- Called by action in FileIndex_1 edit box1098 function FileIndex_1_Callback(hObject, eventdata, handles)1099 %------------------------------------------------------------------------1100 run0_Callback(hObject, eventdata, handles)1101 1147 1102 1148 %------------------------------------------------------------------------ … … 1407 1453 end 1408 1454 end 1409 1410 1411 %------------------------------------------------------------------------1412 function MenuExportFigure_Callback(hObject, eventdata, handles)1413 %------------------------------------------------------------------------1414 % huvmat=get(handles.MenuExport,'parent');1415 hfig=figure;1416 copyobj(handles.axes3,hfig);1417 map=colormap(handles.axes3);1418 colormap(map);%transmit the current colormap to the zoom fig1419 colorbar1420 1455 1421 1456 %------------------------------------------------------------------------ … … 2222 2257 %% combine the two input fields (e.g. substract velocity fields) 2223 2258 if numel(Field)==2 2224 UvData.Field=sub_field(Field{1},Field{2});2259 [UvData.Field,errormsg]=sub_field(Field{1},Field{2}); 2225 2260 else 2226 2261 UvData.Field=Field{1}; 2262 end 2263 if ~isempty(errormsg) 2264 errormsg=['error in uvmat/refresh_field/sub_field:' errormsg]; 2265 return 2227 2266 end 2228 2267 UvData.Field.FieldList={FieldName}; % TODO: to generalise, used for proj_field with tps interpolation … … 2440 2479 for imap=1:numel(IndexObj) 2441 2480 iobj=IndexObj(imap); 2442 [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object 2443 2481 if iobj==1 && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object) 2482 ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude 2483 if UvData.Field.Mesh/ord>=5 2484 mesh=5*ord; 2485 elseif UvData.Field.Mesh/ord>=2 2486 mesh=2*ord; 2487 else 2488 mesh=ord; 2489 end 2490 coord_x=UvData.Field.XMin:mesh:UvData.Field.XMax; 2491 coord_y=UvData.Field.YMin:mesh:UvData.Field.YMax; 2492 [XI,YI]=meshgrid(coord_x,coord_y); 2493 XI=reshape(XI,[],1); 2494 YI=reshape(YI,[],1); 2495 [ObjectData,errormsg]=calc_field({FieldName},UvData.Field,[XI YI]); 2496 else 2497 [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object 2498 end 2444 2499 if ~isempty(errormsg) 2445 2500 return 2446 2501 end 2447 2502 % if testnewseries && isfield(ObjectData,'CoordUnit')&& isfield(PlotParam{imap},'Coordinates') 2448 % PlotParam{imap}.Coordinates=rmfield(PlotParam{imap}.Coordinates,'CheckFixEqual'); %set FixEqual to depend on the field (=1 if Data.CoordUnit=1 in plot_field)2449 % end 2503 % PlotParam{imap}.Coordinates=rmfield(PlotParam{imap}.Coordinates,'CheckFixEqual'); %set FixEqual to depend on the field (=1 if Data.CoordUnit=1 in plot_field) 2504 % end 2450 2505 if testnewseries && isfield(ObjectData,'CoordUnit') 2451 2506 PlotParam{imap}.Coordinates.CheckFixEqual=1; … … 2494 2549 ObjectData.DimValue(ind_off)=[]; 2495 2550 end 2496 end 2551 end 2497 2552 if ~isempty(ObjectData) 2498 2553 PlotType='none'; %default … … 2949 3004 UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read) 2950 3005 end 3006 UvData.filename_1='';% desactivate the use of a constant second file 2951 3007 list_fields=get(handles.Fields,'String');% list menu fields 2952 3008 index_fields=get(handles.Fields,'Value');% selected string index … … 3077 3133 3078 3134 %------------------------------------------------------------------------ 3135 % --- Executes on button press in FixVelType. 3136 function FixVelType_Callback(hObject, eventdata, handles) 3137 %------------------------------------------------------------------------ 3138 val=get(handles.FixVelType,'Value'); 3139 if ~val 3140 run0_Callback(hObject, eventdata, handles) 3141 end 3142 3143 %------------------------------------------------------------------------ 3079 3144 % --- Executes on button press in VelType. 3080 3145 function VelType_Callback(hObject, eventdata, handles) … … 3084 3149 3085 3150 %------------------------------------------------------------------------ 3086 % --- Executes on button press in VelType .3151 % --- Executes on button press in VelType_1. 3087 3152 function VelType_1_Callback(hObject, eventdata, handles) 3088 3153 %------------------------------------------------------------------------ … … 3115 3180 UvData=rmfield(UvData,'Field_1');% removes the stored second field if it exists 3116 3181 end 3182 UvData.filename_1='';% desactivate the use of a constant second file 3117 3183 set(handles.uvmat,'UserData',UvData) 3118 3184 num_i1=stra2num(get(handles.i1,'String')); … … 3814 3880 write_plot_param(handles,PlotParamOut); %update the auto plot parameters 3815 3881 3882 %------------------------------------------------------------------------ 3883 %------------------------------------------------------------------------ 3884 % SELECTION AND EDITION OF PROJECTION OBJECTS 3885 %------------------------------------------------------------------------ 3886 %------------------------------------------------------------------------ 3887 3888 %------------------------------------------------------------------------ 3889 % --- Executes on selection change in ListObject. 3890 function ListObject_Callback(hObject, eventdata, handles) 3891 %------------------------------------------------------------------------ 3892 list_str=get(handles.ListObject,'String'); 3893 IndexObj_old=get(handles.ListObject,'UserData');%retrieve previous selection 3894 IndexObj=get(handles.ListObject,'Value');%present object selection 3895 3896 %% we select two objects or more at once (using the Ctrl key), keep only the last two items: the first is projected on uvmat, the second on view_field 3897 if length(IndexObj)>2 3898 IndexObj=[IndexObj(end-1) IndexObj(end)];%keeps only the last two selected items at most 3899 end 3900 3901 %% we select one object 3902 if length(IndexObj)==1% 3903 if length(IndexObj_old)>=2 && isequal(IndexObj_old(1),IndexObj) % we select the first previously selected object-> 3904 IndexObj=[1 IndexObj_old(2)];% it desactivates this object and selects the first object for uvmat 3905 elseif length(IndexObj_old)>=2 && isequal(IndexObj_old(2),IndexObj) % we select the second previously selected object-> 3906 IndexObj=IndexObj_old(1);% it desactivates this object and keeps only the first previously selected object (uvmat) 3907 else % 3908 IndexObj=[IndexObj_old(1) IndexObj];% activates a second object while keeping the first previously selected one 3909 end 3910 end 3911 3912 %% The second object is selected, it is displayed in set_object if this GUI is already opened 3913 UvData=get(handles.uvmat,'UserData'); 3914 ObjectData=UvData.Object{IndexObj(end)}; 3915 hset_object=findobj(allchild(0),'tag','set_object'); 3916 if ~isempty(hset_object) 3917 delete(hset_object)% delete to refesh the content 3918 ZBounds=0; % default 3919 if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') 3920 ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider 3921 ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider 3922 end 3923 ObjectData.Name=list_str{IndexObj(end)}; 3924 set_object(ObjectData,[],ZBounds); 3925 end 3926 % desactivate the edit object mode 3927 set(handles.edit_object,'Value',0) 3928 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 3929 3930 %% update the object value stored in ListObject 3931 set(handles.ListObject,'Value',IndexObj); % marks the selected objects in the list 3932 set(handles.ListObject,'UserData',IndexObj)% keep the current object selection in memory for next time 3933 % 3934 % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 3935 % if numel(UvData.Object)<max(IndexObj); 3936 % msgbox_uvmat('ERROR','invalid object list') 3937 % return 3938 % end 3939 % if numel(IndexObj)>=2 3940 % UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));%update the current object graphic representation 3941 % set(handles.uvmat,'UserData',UvData) 3942 % end 3943 3944 %% update the main plot (on uvmat) if the first selected object has been changed 3945 if ~isequal(IndexObj(1),IndexObj_old(1)) 3946 ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on UvData.Object{IndexObj(1)} 3947 plot_field(ProjData,handles.axes3,read_GUI(handles.uvmat));%read plotting parameters on the uvmat interfacPlotHandles); 3948 end 3949 3950 %% update the second plot (on view_field) if view_field is already openened 3951 axes_view_field=[];%default 3952 if length(IndexObj)==2 && (length(IndexObj_old)==1 || ~isequal(IndexObj(2),IndexObj_old(2))) 3953 hview_field=findobj(allchild(0),'tag','view_field'); 3954 if ~isempty(hview_field) 3955 PlotHandles=guidata(hview_field); 3956 ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData 3957 axes_view_field=PlotHandles.axes3; 3958 plot_field(ProjData,axes_view_field,read_GUI(hview_field));%read plotting parameters on the uvmat interfacPlotHandles); 3959 end 3960 end 3961 3962 %% update the color of the graphic object representation: the selected object in magenta, others in blue 3963 update_object_color(handles.axes3,axes_view_field,UvData.Object{IndexObj(end)}.DisplayHandle_uvmat) 3964 3965 %------------------------------------------------------------------------ 3966 %--- update the color representation of objects (indicating the selected ones) 3967 function update_object_color(axes_uvmat,axes_view_field,DisplayHandle) 3968 %------------------------------------------------------------------------ 3969 if isempty(axes_view_field)% case with no view_field plot 3970 hother=[findobj(axes_uvmat,'Tag','proj_object');findobj(axes_uvmat,'Tag','DeformPoint')];%find all the proj object and deform point representations 3971 else 3972 hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object');... %find all the proj object representations 3973 findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];%find all the deform point representations 3974 end 3975 for iobj=1:length(hother) 3976 if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') 3977 set(hother(iobj),'EdgeColor','b') 3978 if isequal(get(hother(iobj),'FaceColor'),'m') 3979 set(hother(iobj),'FaceColor','b') 3980 end 3981 elseif isequal(get(hother(iobj),'Type'),'image') 3982 Acolor=get(hother(iobj),'CData'); 3983 Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); 3984 set(hother(iobj),'CData',Acolor); 3985 else 3986 set(hother(iobj),'Color','b') 3987 end 3988 set(hother(iobj),'Selected','off') 3989 end 3990 if ~isempty(DisplayHandle) 3991 linetype=get(DisplayHandle,'Type'); 3992 if isequal(linetype,'line') 3993 set(DisplayHandle,'Color','m'); %set the selected object to magenta color 3994 elseif isequal(linetype,'rectangle') 3995 set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color 3996 elseif isequal(linetype,'patch') 3997 set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color 3998 end 3999 SubObjectData=get(DisplayHandle,'UserData'); 4000 if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject) 4001 for iobj=1:length(SubObjectData.SubObject) 4002 hsub=SubObjectData.SubObject(iobj); 4003 if isequal(get(hsub,'Type'),'rectangle') 4004 set(hsub,'EdgeColor','m'); %set the selected object to magenta color 4005 elseif isequal(get(hsub,'Type'),'image') 4006 Acolor=get(hsub,'CData'); 4007 Acolor(:,:,1)=Acolor(:,:,3); 4008 set(hsub,'CData',Acolor); 4009 else 4010 set(hsub,'Color','m') 4011 end 4012 end 4013 end 4014 if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint) 4015 set(SubObjectData.DeformPoint,'Color','m') 4016 end 4017 end 4018 4019 %------------------------------------------------------------------------ 4020 % --- Executes on button press in ViewObject. 4021 function ViewObject_Callback(hObject, eventdata, handles) 4022 %------------------------------------------------------------------------ 4023 IndexObj=get(handles.ListObject,'Value'); 4024 % IndexObj=IndexObj(end); %keeps only the second value 4025 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 4026 if numel(UvData.Object)<IndexObj(end);% error in UvData 4027 msgbox_uvmat('ERROR','invalid object list') 4028 return 4029 end 4030 % ObjectData=UvData.Object{IndexObj(}; 4031 ZBounds=0; % default 4032 if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') 4033 ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider 4034 ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider 4035 end 4036 hset_object=findobj(allchild(0),'tag','set_object'); 4037 if ~isempty(hset_object) 4038 delete(hset_object)% delete existing version of set_object 4039 end 4040 set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion 4041 if ~isfield(UvData.Object{IndexObj(1)},'Type')% default plane 4042 UvData.Object{IndexObj(1)}.Type='plane'; 4043 end 4044 list_object=get(handles.ListObject,'String'); 4045 UvData.Object{IndexObj(end)}.Name=list_object{IndexObj(end)}; 4046 hset_object=set_object(UvData.Object{IndexObj(end)},[],ZBounds); 4047 hhset_object=guidata(hset_object); 4048 if get(handles.edit_object,'Value')% edit mode 4049 set(hhset_object.PLOT,'Enable','on') 4050 else 4051 set(hhset_object.PLOT,'Enable','off') 4052 end 4053 4054 %% show the second plot (on view_field) 4055 if length(IndexObj)==2 4056 ProjData= proj_field(UvData.Field,UvData.Object{IndexObj(2)});%project the current field on ObjectData 4057 hview_field=findobj(allchild(0),'tag','view_field'); 4058 if isempty(hview_field) 4059 hview_field=view_field; 4060 end 4061 PlotHandles=guidata(hview_field); 4062 plot_field(ProjData,PlotHandles.axes3,read_GUI(hview_field));%read plotting parameters on the uvmat interfacPlotHandles); 4063 end 4064 3816 4065 %------------------------------------------------------------------- 3817 4066 % --- Executes on selection change in edit_object. … … 3838 4087 set(hhset_object.PLOT,'enable','on'); 3839 4088 else 3840 UvData.MouseAction='none';3841 4089 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 3842 4090 hset_object=findobj(allchild(0),'Tag','set_object'); … … 3848 4096 3849 4097 %------------------------------------------------------------------------ 3850 % --- Executes on selection change in ListObject. 3851 function ListObject_Callback(hObject, eventdata, handles) 3852 %------------------------------------------------------------------------ 3853 3854 list_str=get(handles.ListObject,'String'); 3855 IndexObj_old=get(handles.ListObject,'UserData');%retrieve previous selection 3856 IndexObj=get(handles.ListObject,'Value');%present object selection 3857 3858 %% we select two objects or more at once (using the Ctrl key), keep only the last two items: the first is projected on uvmat, the second on view_field 3859 if length(IndexObj)>2 3860 IndexObj=[IndexObj(end-1) IndexObj(end)];%keeps only the last two selected items at most 3861 end 3862 3863 %% we select one object 3864 if length(IndexObj)==1% 3865 if length(IndexObj_old)>=2 && isequal(IndexObj_old(1),IndexObj) % we select the first previously selected object-> 3866 IndexObj=[1 IndexObj_old(2)];% it desactivates this object and selects the first object for uvmat 3867 elseif length(IndexObj_old)>=2 && isequal(IndexObj_old(2),IndexObj) % we select the second previously selected object-> 3868 IndexObj=IndexObj_old(1);% it desactivates this object and keeps only the first previously selected object (uvmat) 3869 else % 3870 IndexObj=[IndexObj_old(1) IndexObj];% activates a second object while keeping the first previously selected one 3871 end 3872 end 3873 set(handles.ListObject,'Value',IndexObj); % marks the selected objects in the list 3874 set(handles.ListObject,'UserData',IndexObj)% keep the current object selection in memory for next time 3875 3876 %% update the object representation 3877 set(handles.edit_object,'Value',0) % desactivate the edit object mode 3878 edit_object_Callback(hObject, eventdata, handles) 3879 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 3880 if numel(UvData.Object)<max(IndexObj); 3881 msgbox_uvmat('ERROR','invalid object list') 3882 return 3883 end 3884 if numel(IndexObj)>=2 3885 UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));%update the current object graphic representation 3886 set(handles.uvmat,'UserData',UvData) 3887 end 3888 3889 %% project on the selected object and update the corresponding plot 3890 % hview_field=findobj(allchild(0),'tag','view_field'); 3891 % ViewObjectAxes=[];%default 3892 if ~isequal(IndexObj(1),IndexObj_old(1)) 3893 update_object(handles,IndexObj(1),handles.axes3,list_str{IndexObj(1)})%plot the projection in uvmat 3894 end 3895 hview_field=findobj(allchild(0),'tag','view_field'); 3896 if length(IndexObj)==2 && (length(IndexObj_old)==1 || ~isequal(IndexObj(2),IndexObj_old(2))) 3897 if isempty(hview_field) 3898 hview_field=view_field; 3899 end 3900 PlotHandles=guidata(hview_field); 3901 update_object(handles,IndexObj(2),PlotHandles.axes3,list_str{IndexObj(2)})%plot the projection in view_field 3902 update_object_color(handles.axes3,PlotHandles.axes3,UvData.Object{IndexObj(2)}.DisplayHandle_uvmat) 3903 else 3904 if ~isempty(hview_field) 3905 delete(hview_field) 3906 end 3907 hset_object=findobj(allchild(0),'tag','set_object'); 3908 if ~isempty(hset_object) 3909 delete(hset_object) 3910 end 3911 update_object_color(handles.axes3,handles.axes3,[]) 3912 end 3913 3914 %% update the color of the gfraphic object representation: the selected object in magenta, others in blue 3915 % update_object_color(handles.axes3,PlotHandles.axes3,UvData.Object{IndexObj(2)}.DisplayHandle_uvmat) 3916 3917 %------------------------------------------------------------------------ 3918 function update_object(handles,IndexObj,ViewObjectAxes,ObjectName) 3919 %------------------------------------------------------------------------ 3920 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 3921 ObjectData=UvData.Object{IndexObj}; 3922 ObjectData.Name=ObjectName; 3923 if isequal(get(handles.edit_object,'Value'),1) 3924 ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode 3925 end 3926 ZBounds=0; % default 3927 if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') 3928 ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider 3929 ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider 3930 end 3931 hset_object=findobj(allchild(0),'tag','set_object'); 3932 if ~isempty(hset_object) 3933 delete(hset_object)% delete existing version of set_object 3934 end 3935 hset_object=set_object(ObjectData,[],ZBounds); 3936 % end 3937 edit_test=get(handles.edit_object,'Value'); 3938 if edit_test 3939 ObjectData.enable_plot=1; 3940 else 3941 if isfield(ObjectData,'enable_plot') 3942 ObjectData=rmfield(ObjectData,'enable_plot'); 3943 end 3944 end 3945 3946 uistack(ViewObjectAxes,'top')% display the plotting axes at the top 3947 ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData 3948 plot_field(ProjData,ViewObjectAxes,read_GUI(get(ViewObjectAxes,'Parent')));%read plotting parameters on the uvmat interfacPlotHandles); 3949 3950 %------------------------------------------------------------------------ 3951 %--- update the representation of objects 3952 function update_object_color(axes_uvmat,axes_view_field,DisplayHandle) 3953 %------------------------------------------------------------------------ 3954 hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object')] ;%find all the proj objects 3955 hother=[hother ;findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')]; 3956 for iobj=1:length(hother) 3957 if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') 3958 set(hother(iobj),'EdgeColor','b') 3959 if isequal(get(hother(iobj),'FaceColor'),'m') 3960 set(hother(iobj),'FaceColor','b') 3961 end 3962 elseif isequal(get(hother(iobj),'Type'),'image') 3963 Acolor=get(hother(iobj),'CData'); 3964 Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); 3965 set(hother(iobj),'CData',Acolor); 3966 else 3967 set(hother(iobj),'Color','b') 3968 end 3969 set(hother(iobj),'Selected','off') 3970 end 3971 if ~isempty(DisplayHandle) 3972 linetype=get(DisplayHandle,'Type'); 3973 if isequal(linetype,'line') 3974 set(DisplayHandle,'Color','m'); %set the selected object to magenta color 3975 elseif isequal(linetype,'rectangle') 3976 set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color 3977 elseif isequal(linetype,'patch') 3978 set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color 3979 end 3980 SubObjectData=get(DisplayHandle,'UserData'); 3981 if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject) 3982 for iobj=1:length(SubObjectData.SubObject) 3983 hsub=SubObjectData.SubObject(iobj); 3984 if isequal(get(hsub,'Type'),'rectangle') 3985 set(hsub,'EdgeColor','m'); %set the selected object to magenta color 3986 elseif isequal(get(hsub,'Type'),'image') 3987 Acolor=get(hsub,'CData'); 3988 Acolor(:,:,1)=Acolor(:,:,3); 3989 set(hsub,'CData',Acolor); 3990 else 3991 set(hsub,'Color','m') 3992 end 3993 end 3994 end 3995 if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint) 3996 set(SubObjectData.DeformPoint,'Color','m') 3997 end 3998 end 3999 4000 %------------------------------------------------------ 4098 % --- Executes on button press in delete_object. 4099 function delete_object_Callback(hObject, eventdata, handles) 4100 %------------------------------------------------------------------------ 4101 IndexObj=get(handles.ListObject,'Value'); 4102 if IndexObj(end)>1 4103 delete_object(IndexObj(end)) 4104 end 4105 4106 %------------------------------------------------------------------------ 4107 %------------------------------------------------------------------------ 4108 % II - TOOLS FROM THE UPPER MENU BAR 4109 %------------------------------------------------------------------------ 4110 %------------------------------------------------------------------------ 4111 4112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4113 % Export Menu Callbacks 4114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4115 %------------------------------------------------------------------------ 4001 4116 % --- Executes on button press in Menu/Export/field in workspace. 4002 %------------------------------------------------------4003 4117 function MenuExportField_Callback(hObject, eventdata, handles) 4118 %------------------------------------------------------------------------ 4004 4119 global Data_uvmat 4005 4120 Data_uvmat=get(handles.uvmat,'UserData'); … … 4009 4124 commandwindow; %brings the Matlab command window to the front 4010 4125 4011 %------------------------------------------------------ 4126 %------------------------------------------------------------------------ 4012 4127 % --- Executes on button press in Menu/Export/extract figure. 4013 %------------------------------------------------------ 4014 function MenuExport_plot_Callback(hObject, eventdata, handles) 4015 huvmat=get(handles.MenuExport_plot,'parent'); 4016 UvData=get(huvmat,'UserData'); 4128 function MenuExportFigure_Callback(hObject, eventdata, handles) 4129 %------------------------------------------------------------------------ 4130 % huvmat=get(handles.MenuExport,'parent'); 4017 4131 hfig=figure; 4018 newaxes=copyobj(handles.axes3,hfig);4132 copyobj(handles.axes3,hfig); 4019 4133 map=colormap(handles.axes3); 4020 4134 colormap(map);%transmit the current colormap to the zoom fig 4021 4135 colorbar 4022 4136 4023 4024 % --------------------------------------------------------------------4025 function Insert_Callback(hObject, eventdata, handles) 4026 4027 4028 % --------------------------------------------------------------------4029 function MenuHelp_Callback(hObject, eventdata, handles) 4030 % --------------------------------------------------------------------4031 path_to_uvmat=which ('uvmat');% check the path of uvmat 4032 pathelp=fileparts(path_to_uvmat); 4033 helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); 4034 if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') 4035 else 4036 addpath (fullfile(pathelp,'uvmat_doc')) 4037 web(helpfile); 4038 end 4137 % %------------------------------------------------------ 4138 % % --- Executes on button press in Menu/Export/extract figure. 4139 % %------------------------------------------------------ 4140 % function MenuExport_plot_Callback(hObject, eventdata, handles) 4141 % huvmat=get(handles.MenuExport_plot,'parent'); 4142 % UvData=get(huvmat,'UserData'); 4143 % hfig=figure; 4144 % newaxes=copyobj(handles.axes3,hfig); 4145 % map=colormap(handles.axes3); 4146 % colormap(map);%transmit the current colormap to the zoom fig 4147 % colorbar 4148 4149 % 4150 % % -------------------------------------------------------------------- 4151 % function Insert_Callback(hObject, eventdata, handles) 4152 % 4039 4153 4040 4154 %------------------------------------------------------------------------ … … 4123 4237 msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']}) 4124 4238 4239 4240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4241 % Projection Objects Menu Callbacks 4242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4243 4244 % ----------------------------------------------------------------------- 4245 function Menupoints_Callback(hObject, eventdata, handles) 4246 %------------------------------------------------------------------------ 4247 data.Type='points'; 4248 data.ProjMode='projection';%default 4249 create_object(data,handles) 4250 4251 % ----------------------------------------------------------------------- 4252 function Menuline_Callback(hObject, eventdata, handles) 4253 %------------------------------------------------------------------------ 4254 data.Type='line'; 4255 data.ProjMode='projection';%default 4256 create_object(data,handles) 4257 4258 %------------------------------------------------------------------------ 4259 function Menupolyline_Callback(hObject, eventdata, handles) 4260 %------------------------------------------------------------------------ 4261 data.Type='polyline'; 4262 data.ProjMode='projection';%default 4263 create_object(data,handles) 4264 4265 %------------------------------------------------------------------------ 4266 function Menupolygon_Callback(hObject, eventdata, handles) 4267 %------------------------------------------------------------------------ 4268 data.Type='polygon'; 4269 data.ProjMode='inside';%default 4270 create_object(data,handles) 4271 4272 %------------------------------------------------------------------------ 4273 function Menurectangle_Callback(hObject, eventdata, handles) 4274 %------------------------------------------------------------------------ 4275 data.Type='rectangle'; 4276 data.ProjMode='inside';%default 4277 create_object(data,handles) 4278 4279 %------------------------------------------------------------------------ 4280 function Menuellipse_Callback(hObject, eventdata, handles) 4281 %------------------------------------------------------------------------ 4282 data.Type='ellipse'; 4283 data.ProjMode='inside';%default 4284 create_object(data,handles) 4285 4286 %------------------------------------------------------------------------ 4287 function MenuMaskObject_Callback(hObject, eventdata, handles) 4288 %------------------------------------------------------------------------ 4289 data.Type='polygon'; 4290 data.TypeMenu={'polygon'}; 4291 data.ProjMode='mask_inside';%default 4292 data.ProjModeMenu={'mask_inside';'mask_outside'}; 4293 create_object(data,handles) 4294 4295 %------------------------------------------------------------------------ 4296 function Menuplane_Callback(hObject, eventdata, handles) 4297 %------------------------------------------------------------------------ 4298 data.Type='plane'; 4299 data.ProjMode='projection';%default 4300 create_object(data,handles) 4301 4302 %------------------------------------------------------------------------ 4303 function Menuvolume_Callback(hObject, eventdata, handles) 4304 %------------------------------------------------------------------------ 4305 data.Type='volume'; 4306 data.ProjMode='interp';%default 4307 % set(handles.create,'Visible','on') 4308 % set(handles.create,'Value',1) 4309 % VOLUME_Callback(hObject,eventdata,handles) 4310 create_object(data,handles) 4311 4312 %------------------------------------------------------------------------ 4313 % --- generic function used for the creation of a projection object 4314 function create_object(data,handles) 4315 %------------------------------------------------------------------------ 4316 4317 hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); 4318 if ishandle(hgeometry_calib) 4319 hhgeometry_calib=guidata(hgeometry_calib); 4320 set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib 4321 set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) 4322 end 4323 UvData=get(handles.uvmat,'UserData'); 4324 set(handles.edit_object,'Value',0); %suppress the object edit mode 4325 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 4326 % data.enable_plot=1; 4327 data.Coord=[0 0]; %default 4328 if isfield(UvData,'Field') 4329 Field=UvData.Field; 4330 if isfield(Field,'Mesh')&&~isempty(Field.Mesh) 4331 ord=10^(floor(log10(Field.Mesh)));%order of magnitude 4332 if Field.Mesh/ord>=5 4333 mesh=5*ord; 4334 elseif Field.Mesh/ord>=2 4335 mesh=2*ord; 4336 else 4337 mesh=ord; 4338 end 4339 data.RangeX=mesh; 4340 data.RangeY=mesh; 4341 data.DX=mesh; 4342 data.DY=mesh; 4343 elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image 4344 np=size(Field.A); 4345 meshx=(Field.AX(end)-Field.AX(1))/np(2); 4346 meshy=abs(Field.AY(end)-Field.AY(1))/np(1); 4347 data.RangeY=max(meshx,meshy); 4348 data.RangeX=max(meshx,meshy); 4349 data.DX=max(meshx,meshy); 4350 end 4351 if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) 4352 data.Coord=[0 0 0]; %default 4353 end 4354 if isfield(Field,'CoordUnit') 4355 data.CoordUnit=Field.CoordUnit; 4356 end 4357 end 4358 if ishandle(handles.UVMAT_title) 4359 delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered 4360 end 4361 hset_object=findobj(allchild(0),'tag','set_object'); 4362 IndexObj=get(handles.ListObject,'Value') 4363 if ~isempty(hset_object) 4364 delete(hset_object)% delete existing version of set_object 4365 end 4366 set(handles.ListObject,'Value',IndexObj) 4367 hset_object=set_object(data,handles);% call the set_object interface 4368 hhset_object=guidata(hset_object); 4369 set(hhset_object.PLOT,'enable','on')% activate the refresh button 4370 set(handles.MenuObject,'checked','on') 4371 set(handles.uvmat,'UserData',UvData) 4372 set(handles.CheckZoom,'Value',0) 4373 CheckZoom_Callback(handles.uvmat, [], handles) 4374 set(handles.delete_object,'Visible','on') 4375 4376 4377 %------------------------------------------------------------------------ 4378 function MenuBrowseObject_Callback(hObject, eventdata, handles) 4379 %------------------------------------------------------------------------ 4380 %get the object file 4381 [FileName, PathName, filterindex] = uigetfile( ... 4382 {'*.xml;*.mat', ' (*.xml,*.mat)'; 4383 '*.xml', '.xml files '; ... 4384 '*.mat', '.mat matlab files '}, ... 4385 'Pick an xml Object file',get(handles.RootPath,'String')); 4386 fileinput=[PathName FileName];%complete file name 4387 sizf=size(fileinput); 4388 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end 4389 4390 %read the file 4391 data=xml2struct(fileinput); 4392 data.enable_plot=1; 4393 [tild,data.Name]=fileparts(FileName); 4394 hset_object=findobj(allchild(0),'tag','set_object'); 4395 if ~isempty(hset_object) 4396 delete(hset_object)% delete existing version of set_object 4397 end 4398 set_object(data);% call the set_object interface 4399 set(handles.edit_object,'Value',0); %suppress the object edit mode 4400 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 4401 set(handles.MenuObject,'checked','on') 4402 set(handles.delete_object,'Visible','on') 4403 4404 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4405 % MenuEdit Callbacks 4406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4407 %------------------------------------------------------------------------ 4408 function MenuEditObject_Callback(hObject, eventdata, handles) 4409 %------------------------------------------------------------------------ 4410 set(handles.edit_object,'Value',1) 4411 edit_Callback(hObject, eventdata, handles) 4412 4413 % %------------------------------------------------------------------------ 4414 % function enable_transform(handles,state) 4415 % %------------------------------------------------------------------------ 4416 % set(handles.transform_fct,'Visible',state) 4417 % set(handles.TRANSFORM_txt,'Visible',state) 4418 % set(handles.transform_fct,'Visible',state) 4419 % set(handles.path_transform,'Visible',state) 4420 % set(handles.pxcmx_txt,'Visible',state) 4421 % set(handles.pxcmy_txt,'Visible',state) 4422 % set(handles.pxcm,'Visible',state) 4423 % set(handles.pycm,'Visible',state) 4424 4425 %------------------------------------------------------------------------ 4426 function MenuEditVectors_Callback(hObject, eventdata, handles) 4427 %------------------------------------------------------------------------ 4428 set(handles.edit_vect,'Visible','on') 4429 set(handles.edit_vect,'Value',1) 4430 edit_vect_Callback(hObject, eventdata, handles) 4431 4432 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4433 % MenuTools Callbacks 4434 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4125 4435 %------------------------------------------------------------------------ 4126 4436 function MenuCalib_Callback(hObject, eventdata, handles) … … 4141 4451 pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen) 4142 4452 pos(2)=pos(2)-0.02; 4143 %[FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);4144 4453 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 4145 4454 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; … … 4278 4587 set_grid(FileName,CoordList{val});% call the set_object interface 4279 4588 4589 4590 %------------------------------------------------------------------------ 4591 function MenuRuler_Callback(hObject, eventdata, handles) 4592 %------------------------------------------------------------------------ 4593 set(handles.CheckZoom,'Value',0) 4594 CheckZoom_Callback(handles.uvmat, [], handles) 4595 set(handles.MenuRuler,'checked','on') 4596 UvData=get(handles.uvmat,'UserData'); 4597 UvData.MouseAction='ruler'; 4598 set(handles.uvmat,'UserData',UvData); 4599 4600 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4601 % MenuRun Callbacks 4602 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4603 4280 4604 %------------------------------------------------------------------------ 4281 4605 % open the GUI 'series' … … 4288 4612 [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles); 4289 4613 FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1]; 4290 %FileName_1=read_file_boxes_1(handles);%4291 4614 if ~isequal(FileName_1,param.FileName) 4292 4615 param.FileName_1=FileName_1; … … 4294 4617 end 4295 4618 param.NomType=get(handles.NomType,'String'); 4296 % param.NomType=get(handles.FileIndex,'UserData');4297 4619 param.NomType_1=get(handles.NomType_1,'String'); 4298 % param.NomType_1=get(handles.FileIndex_1,'UserData');4299 4620 param.CheckFixPair=get(handles.CheckFixPair,'Value'); 4300 4621 huvmat=get(handles.MenuSeries,'parent'); … … 4325 4646 4326 4647 %------------------------------------------------------------------------ 4327 % -- open the GUI civ.fig for civx (PIV)4648 % -- open the GUI civ.fig for PIV 4328 4649 function MenuPIV_Callback(hObject, eventdata, handles) 4329 4650 %------------------------------------------------------------------------ … … 4332 4653 civ(FileName);% interface de civ(not in the uvmat file) 4333 4654 4334 %------------------------------------------------------------------------ 4335 function MenuTools_Callback(hObject, eventdata, handles) 4336 %------------------------------------------------------------------------ 4337 4338 %------------------------------------------------------------------------ 4339 function MenuEditObject_Callback(hObject, eventdata, handles) 4340 %------------------------------------------------------------------------ 4341 set(handles.edit_object,'Value',1) 4342 edit_Callback(hObject, eventdata, handles) 4343 4344 %------------------------------------------------------------------------ 4345 function enable_transform(handles,state) 4346 %------------------------------------------------------------------------ 4347 set(handles.transform_fct,'Visible',state) 4348 set(handles.TRANSFORM_txt,'Visible',state) 4349 set(handles.transform_fct,'Visible',state) 4350 set(handles.path_transform,'Visible',state) 4351 set(handles.pxcmx_txt,'Visible',state) 4352 set(handles.pxcmy_txt,'Visible',state) 4353 set(handles.pxcm,'Visible',state) 4354 set(handles.pycm,'Visible',state) 4355 4356 %------------------------------------------------------------------------ 4357 function MenuEditVectors_Callback(hObject, eventdata, handles) 4358 %------------------------------------------------------------------------ 4359 set(handles.edit_vect,'Visible','on') 4360 set(handles.edit_vect,'Value',1) 4361 edit_vect_Callback(hObject, eventdata, handles) 4362 4363 % ----------------------------------------------------------------------- 4364 function Menupoints_Callback(hObject, eventdata, handles) 4365 %------------------------------------------------------------------------ 4366 data.Type='points'; 4367 data.ProjMode='projection';%default 4368 create_object(data,handles) 4369 4370 % ----------------------------------------------------------------------- 4371 function Menuline_Callback(hObject, eventdata, handles) 4372 %------------------------------------------------------------------------ 4373 data.Type='line'; 4374 data.ProjMode='projection';%default 4375 create_object(data,handles) 4376 4377 %------------------------------------------------------------------------ 4378 function Menupolyline_Callback(hObject, eventdata, handles) 4379 %------------------------------------------------------------------------ 4380 data.Type='polyline'; 4381 data.ProjMode='projection';%default 4382 create_object(data,handles) 4383 4384 %------------------------------------------------------------------------ 4385 function Menupolygon_Callback(hObject, eventdata, handles) 4386 %------------------------------------------------------------------------ 4387 data.Type='polygon'; 4388 data.ProjMode='inside';%default 4389 create_object(data,handles) 4390 4391 %------------------------------------------------------------------------ 4392 function Menurectangle_Callback(hObject, eventdata, handles) 4393 %------------------------------------------------------------------------ 4394 data.Type='rectangle'; 4395 data.ProjMode='inside';%default 4396 create_object(data,handles) 4397 4398 %------------------------------------------------------------------------ 4399 function Menuellipse_Callback(hObject, eventdata, handles) 4400 %------------------------------------------------------------------------ 4401 data.Type='ellipse'; 4402 data.ProjMode='inside';%default 4403 create_object(data,handles) 4404 4405 %------------------------------------------------------------------------ 4406 function MenuMaskObject_Callback(hObject, eventdata, handles) 4407 %------------------------------------------------------------------------ 4408 data.Type='polygon'; 4409 data.TypeMenu={'polygon'}; 4410 data.ProjMode='mask_inside';%default 4411 data.ProjModeMenu={'mask_inside';'mask_outside'}; 4412 create_object(data,handles) 4413 4414 %------------------------------------------------------------------------ 4415 function Menuplane_Callback(hObject, eventdata, handles) 4416 %------------------------------------------------------------------------ 4417 data.Type='plane'; 4418 data.ProjMode='projection';%default 4419 4420 create_object(data,handles) 4421 4422 %------------------------------------------------------------------------ 4423 function Menuvolume_Callback(hObject, eventdata, handles) 4424 %------------------------------------------------------------------------ 4425 data.Type='volume'; 4426 data.ProjMode='interp';%default 4427 % set(handles.create,'Visible','on') 4428 % set(handles.create,'Value',1) 4429 % VOLUME_Callback(hObject,eventdata,handles) 4430 create_object(data,handles) 4431 4432 %------------------------------------------------------------------------ 4433 function MenuBrowseObject_Callback(hObject, eventdata, handles) 4434 %------------------------------------------------------------------------ 4435 %get the object file 4436 [FileName, PathName, filterindex] = uigetfile( ... 4437 {'*.xml;*.mat', ' (*.xml,*.mat)'; 4438 '*.xml', '.xml files '; ... 4439 '*.mat', '.mat matlab files '}, ... 4440 'Pick an xml Object file',get(handles.RootPath,'String')); 4441 fileinput=[PathName FileName];%complete file name 4442 sizf=size(fileinput); 4443 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end 4444 4445 %read the file 4446 data=xml2struct(fileinput); 4447 data.enable_plot=1; 4448 [tild,data.Name]=fileparts(FileName); 4449 hset_object=findobj(allchild(0),'tag','set_object'); 4450 if ~isempty(hset_object) 4451 delete(hset_object)% delete existing version of set_object 4452 end 4453 set_object(data);% call the set_object interface 4454 set(handles.edit_object,'Value',0); %suppress the object edit mode 4455 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 4456 set(handles.MenuObject,'checked','on') 4457 set(handles.delete_object,'Visible','on') 4458 4459 %------------------------------------------------------------------------ 4460 % --- generic function used for the creation of a projection object 4461 function create_object(data,handles) 4462 %------------------------------------------------------------------------ 4463 hset_object=findobj(allchild(0),'tag','set_object'); 4464 if ~isempty(hset_object) 4465 delete(hset_object)% delete existing version of set_object 4466 end 4467 hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); 4468 if ishandle(hgeometry_calib) 4469 hhgeometry_calib=guidata(hgeometry_calib); 4470 set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib 4471 set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) 4472 end 4473 UvData=get(handles.uvmat,'UserData'); 4474 set(handles.edit_object,'Value',0); %suppress the object edit mode 4475 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 4476 data.enable_plot=1; 4477 data.Coord=[0 0]; %default 4478 if isfield(UvData,'Field') 4479 Field=UvData.Field; 4480 if isfield(Field,'Mesh')&&~isempty(Field.Mesh) 4481 ord=10^(floor(log10(Field.Mesh)));%order of magnitude 4482 if Field.Mesh/ord>=5 4483 mesh=5*ord; 4484 elseif Field.Mesh/ord>=2 4485 mesh=2*ord; 4486 else 4487 mesh=ord; 4488 end 4489 data.RangeX=mesh; 4490 data.RangeY=mesh; 4491 data.DX=mesh; 4492 data.DY=mesh; 4493 elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image 4494 np=size(Field.A); 4495 meshx=(Field.AX(end)-Field.AX(1))/np(2); 4496 meshy=abs(Field.AY(end)-Field.AY(1))/np(1); 4497 data.RangeY=max(meshx,meshy); 4498 data.RangeX=max(meshx,meshy); 4499 data.DX=max(meshx,meshy); 4500 end 4501 if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) 4502 data.Coord=[0 0 0]; %default 4503 end 4504 if isfield(Field,'CoordUnit') 4505 data.CoordUnit=Field.CoordUnit; 4506 end 4507 end 4508 if ishandle(handles.UVMAT_title) 4509 delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered 4510 end 4511 set_object(data,handles);% call the set_object interface 4512 set(handles.MenuObject,'checked','on') 4513 set(handles.uvmat,'UserData',UvData) 4514 set(handles.CheckZoom,'Value',0) 4515 CheckZoom_Callback(handles.uvmat, [], handles) 4516 set(handles.delete_object,'Visible','on') 4517 4518 %------------------------------------------------------------------------ 4519 function MenuRuler_Callback(hObject, eventdata, handles) 4520 %------------------------------------------------------------------------ 4521 set(handles.CheckZoom,'Value',0) 4522 CheckZoom_Callback(handles.uvmat, [], handles) 4523 set(handles.MenuRuler,'checked','on') 4524 UvData=get(handles.uvmat,'UserData'); 4525 UvData.MouseAction='ruler'; 4526 set(handles.uvmat,'UserData',UvData); 4527 4528 %------------------------------------------------------------------------ 4529 % --- executed when closing: set the parent interface button to value 0 4530 function closefcn(gcbo,eventdata) 4531 %------------------------------------------------------------------------ 4532 %delete all the associated figures if exist 4533 hh=findobj(allchild(0),'tag','view_field'); 4534 if ~isempty(hh) 4535 delete(hh) 4536 end 4537 hh=findobj(allchild(0),'tag','geometry_calib'); 4538 if ~isempty(hh) 4539 delete(hh) 4540 end 4541 hh=findobj(allchild(0),'tag','set_object'); 4542 if ~isempty(hh) 4543 hhh=findobj(hh,'tag','PLOT'); 4544 set(hhh,'enable','off') 4545 end 4546 4547 %------------------------------------------------------------------------ 4548 % --- Executes on button press in delete_object. 4549 function delete_object_Callback(hObject, eventdata, handles) 4550 %------------------------------------------------------------------------ 4551 IndexObj=get(handles.ListObject,'Value'); 4552 if IndexObj(end)>1 4553 delete_object(IndexObj(end)) 4554 end 4555 4556 % --- Executes on button press in FixVelType. 4557 function FixVelType_Callback(hObject, eventdata, handles) 4558 val=get(handles.FixVelType,'Value'); 4559 if ~val 4560 run0_Callback(hObject, eventdata, handles) 4561 end 4562 4563 %------------------------------------------------------------------------ 4564 % --- Executes on button press in ViewObject. 4565 function ViewObject_Callback(hObject, eventdata, handles) 4566 %------------------------------------------------------------------------ 4567 IndexObj=get(handles.ListObject,'Value'); 4568 IndexObj=IndexObj(end); %keeps only the secodn value 4569 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 4570 if numel(UvData.Object)<IndexObj;% error in UvData 4571 msgbox_uvmat('ERROR','invalid object list') 4572 return 4573 end 4574 ObjectData=UvData.Object{IndexObj}; 4575 ZBounds=0; % default 4576 if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') 4577 ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider 4578 ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider 4579 end 4580 hset_object=findobj(allchild(0),'tag','set_object'); 4581 if ~isempty(hset_object) 4582 delete(hset_object)% delete existing version of set_object 4583 end 4584 if ~isfield(ObjectData,'Type')% default plane 4585 ObjectData.Type='plane'; 4586 end 4587 hset_object=set_object(ObjectData,[],ZBounds); 4588 if get(handles.edit_object,'Value')% edit mode 4589 hhset_object=guidata(hset_object); 4590 set(hhset_object.PLOT,'Enable','on') 4591 end 4592 4593 4594 function NomType_Callback(hObject, eventdata, handles) 4595 4596 4597 function NomType_1_Callback(hObject, eventdata, handles) 4598 4655 % -------------------------------------------------------------------- 4656 function MenuHelp_Callback(hObject, eventdata, handles) 4657 % -------------------------------------------------------------------- 4658 path_to_uvmat=which ('uvmat');% check the path of uvmat 4659 pathelp=fileparts(path_to_uvmat); 4660 helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); 4661 if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') 4662 else 4663 addpath (fullfile(pathelp,'uvmat_doc')) 4664 web(helpfile); 4665 end 4666 4667 4668 4669 -
trunk/src/view_field.m
r387 r402 102 102 write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters 103 103 104 %------------------------------------------------------------------- 104 %------------------------------------------------------------------------ 105 105 % --- Outputs from this function are returned to the command menuline. 106 106 function varargout = view_field_OutputFcn(hObject, eventdata, handles) 107 %------------------------------------------------------------------------ 107 108 varargout{1} = handles.output;% the only output argument is the handle to the GUI figure 108 109 110 %------------------------------------------------------------------------ 111 %--- activated when closing the GUI view_field 112 function closefcn(gcbo,eventdata) 113 %------------------------------------------------------------------------ 114 huvmat=findobj(allchild(0),'Tag','uvmat');%find the current uvmat interface handle 115 if ~isempty(huvmat) 116 hhuvmat=guidata(huvmat); 117 set(hhuvmat.edit_object,'Value',0) 118 set(hhuvmat.edit_object,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree 119 % deselect the object in ListObject when view_field is closed 120 if isempty(findobj(allchild(0),'Tag','set_object')) 121 ObjIndex=get(hhuvmat.ListObject,'Value'); 122 ObjIndex=ObjIndex(1);%keep only the first object selected 123 set(hhuvmat.ListObject,'Value',ObjIndex) 124 % draw all object colors in blue (unselected) in uvmat 125 hother=[findobj(hhuvmat.axes3,'Tag','proj_object');findobj(hhuvmat.axes3,'Tag','DeformPoint')];%find all the proj object and deform point representations 126 for iobj=1:length(hother) 127 if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') 128 set(hother(iobj),'EdgeColor','b') 129 if isequal(get(hother(iobj),'FaceColor'),'m') 130 set(hother(iobj),'FaceColor','b') 131 end 132 elseif isequal(get(hother(iobj),'Type'),'image') 133 Acolor=get(hother(iobj),'CData'); 134 Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); 135 set(hother(iobj),'CData',Acolor); 136 else 137 set(hother(iobj),'Color','b') 138 end 139 set(hother(iobj),'Selected','off') 140 end 141 end 142 end 109 143 110 144 %------------------------------------------------------------------- … … 733 767 colorbar 734 768 735 %------------------------------------------------------------------------ 736 function closefcn(hObject, eventdata, handles) 737 %------------------------------------------------------------------------ 738 huvmat=findobj(allchild(0),'Name','uvmat'); 739 if ~isempty(huvmat) 740 hhuvmat=guidata(huvmat); 741 % list_object_2=get(hhuvmat.list_object_2,'String'); 742 % set(hhuvmat.list_object_2,'Value',1)%select the last value ('...') 743 end 744 delete(hObject) 745 769
Note: See TracChangeset
for help on using the changeset viewer.