- Timestamp:
- Apr 24, 2010, 2:07:22 PM (15 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r82 r84 51 51 % handles structure with handles and user data (see GUIDATA) 52 52 % varargin command line arguments to civ (see VARARGIN) 53 global test_batch patch_newBin CivBin%=1 ifpatch processing available53 global patch_newBin %=1 if new patch processing available 54 54 %filebase: root name 55 55 %nom_type: nomencalture used ('png_old','_i_j'...) … … 127 127 test_batch=strcmp(sparam.BatchParam.BatchMode,'sge'); %sge is currently the only implemented batch mod 128 128 end 129 % if isfield(sparam,'PatchNewBin')130 % patch_newBin=sparam.PatchNewBin;131 % end132 % if isfield(sparam,'SGE')133 % sge=str2double(sparam.SGE);134 % end135 % test_batch=sge;%default136 129 if test_batch==0 130 set(handles.BATCH,'Enable','off')% put the BATCH button in grey (unactivated) 137 131 set(handles.BATCH,'BackgroundColor',[0.831 0.816 0.784])% put the BATCH button in grey (unactivated) 138 132 end … … 297 291 [RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput); 298 292 filebase=fullfile(RootPath,RootFile); 299 % if isequal(nom_type,'*')% all fields in a single file ( movie files)300 % num_i1=1;num_i2=1;num_j1=1;num_j2=1;301 % else302 293 num_i1=stra2num(str1); 303 294 if isempty(num_i1),num_i1=1;end … … 318 309 browse.nom_type_ima=nom_type; 319 310 browse.field_count=num_i1; 320 % A=imread(fileinput);321 % npxy=size(A);322 % set(handles.ImaExt,'UserData',npxy)323 311 end 324 312 set(handles.ImaDoc,'String',ext); … … 437 425 function RootName_Callback(hObject, eventdata, handles) 438 426 %------------------------------------------------------------------------ 439 global test_batch440 427 set(handles.compare,'Visible','on') 441 428 ext_ima=get(handles.ImaExt,'String'); … … 510 497 511 498 %%%%%%%% read image documentation file %%%%%%%%%%%%%%%%%%%%%%%%%%% 512 mode=''; %default 513 set(handles.ImaDoc,'BackgroundColor',[1 1 0]) 514 drawnow 515 %read the image documentation file if found 499 mode=''; %default 500 set(handles.ImaDoc,'BackgroundColor',[1 1 0]) 501 drawnow 516 502 if isequal(ext,'.civxml') || isequal(ext,'.xml')|| isequal(ext,'.civ') 517 503 set(handles.ref_i,'Visible','On')%use a reference index 518 504 set(handles.ref_j,'Visible','On') 519 % set(handles.dt,'Visible','Off')520 % set(handles.root_txt,'String','')521 505 elseif isequal(ext,'.avi') || isequal(ext,'.AVI') 522 506 set(handles.ref_j,'Visible','Off') 523 % set(handles.dt,'Visible','Off')524 % set(handles.root_txt,'String','ref. ind.')525 507 else 526 508 set(handles.ref_i,'Visible','Off') 527 509 set(handles.ref_j,'Visible','Off') 528 % set(handles.dt,'Visible','On')529 % set(handles.root_txt,'String','dt(ms)=')530 510 end 531 511 testima_xml=0; … … 538 518 elseif isequal(ext,'.xml') 539 519 [XmlData,warntext]=imadoc2struct([filebase '.xml']); 540 if isfield(XmlData,'Time')541 time=XmlData.Time;542 nbfield=size(time,1);543 nburst=size(time,2);544 end545 520 ext_ima_read=[]; 546 521 nom_type_read=[]; … … 550 525 if ~exist(fullname,'file') 551 526 msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist']) 527 end 528 end 529 if isfield(XmlData,'Time') 530 time=XmlData.Time 531 nbfield=size(time,1); 532 nburst=size(time,2); 533 %transform .Time to a column vector if it is a line vector the nomenclature uses a single index 534 if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector 535 if numel(nom_type_read)>=2 && (strcmp(nom_type_read,'_i')||strcmp(nom_type_read(1:2),'%0')||strcmp(nom_type_read(1:2),'_%')) 536 time=time'; 537 nbfield=nburst; 538 nburst=1; 539 end 552 540 end 553 541 end … … 748 736 set(handles.RUN, 'Enable','On') 749 737 set(handles.RUN,'BackgroundColor',[1 0 0]) 750 if isequal(test_batch,1)%if batch installation is available 751 set(handles.BATCH, 'Enable','On') 738 if isequal(get(handles.BATCH, 'Enable'),'On') 752 739 set(handles.BATCH,'BackgroundColor',[1 0 0]) 753 740 end … … 3374 3361 filename=name_generator(filebase_ima1,num1_civ2(ifile),num_a_civ2(j),'.png',nom_type_imanew1); 3375 3362 if ~exist(filename,'file') 3376 A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)), nom_type_ima2,num1_civ2(ifile));3363 A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,num1_civ2(ifile)); 3377 3364 imwrite(A,filename,'BitDepth',16); 3378 3365 end … … 3380 3367 filename=name_generator(filebase_ima2, num2_civ2(ifile),num_b_civ2(j),'.png',nom_type_imanew2); 3381 3368 if ~exist(filename,'file') 3382 A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)), nom_type_ima2,num2.civ1(ifile));3369 A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,num2_civ2(ifile)); 3383 3370 imwrite(A,filename,'BitDepth',16); 3384 3371 end -
trunk/src/geometry_calib.m
r83 r84 160 160 case 'tsai' 161 161 set(handles.calib_type,'Value',3) 162 case 'tsai_matlab' 163 set(handles.calib_type,'Value',4) 162 164 end 163 165 end … … 255 257 Coord_cell=get(handles.ListCoord,'String'); 256 258 Object=read_geometry_calib(Coord_cell); 257 259 X=Object.Coord(:,1); 260 Y=Object.Coord(:,2); 261 Z=Object.Coord(:,3); 258 262 if isequal(calib_type,'rescale') 259 263 GeometryCalib=calib_rescale(Object.Coord); 264 Z=0;%Z not taken into account 260 265 elseif isequal(calib_type,'linear') 261 266 GeometryCalib=calib_linear(Object.Coord); 267 Z=0; %Z not taken into account 262 268 elseif isequal(calib_type,'tsai_cpp') 263 269 GeometryCalib=calib_tsai(Object.Coord); … … 265 271 GeometryCalib=calib_tsai2(Object.Coord); 266 272 end 273 274 %check error 275 if isfield(GeometryCalib,'dpx_dpy') 276 Calib.dpx=GeometryCalib.dpx_dpy(1); 277 Calib.dpy=GeometryCalib.dpx_dpy(2); 278 end 279 if isfield(GeometryCalib,'sx') 280 Calib.sx=GeometryCalib.sx; 281 end 282 if isfield(GeometryCalib,'Cx_Cy') 283 Calib.Cx=GeometryCalib.Cx_Cy(1); 284 Calib.Cy=GeometryCalib.Cx_Cy(2); 285 end 286 if isfield(GeometryCalib,'kappa1') 287 Calib.kappa1=GeometryCalib.kappa1; 288 end 289 if isfield(GeometryCalib,'focal') 290 Calib.f=GeometryCalib.focal; 291 end 292 if isfield(GeometryCalib,'Tx_Ty_Tz') 293 Calib.Tx=GeometryCalib.Tx_Ty_Tz(1); 294 Calib.Ty=GeometryCalib.Tx_Ty_Tz(2); 295 Calib.Tz=GeometryCalib.Tx_Ty_Tz(3); 296 end 297 if isfield(GeometryCalib,'R') 298 Calib.R=GeometryCalib.R; 299 end 300 x_ima=Object.Coord(:,4); 301 y_ima=Object.Coord(:,5); 302 [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,Z); 303 GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima))); 304 [GeometryCalib.ErrorMax(1),index(1)]=max(abs(Xpoints-x_ima)); 305 GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); 306 [GeometryCalib.ErrorMax(2),index(2)]=max(abs(Ypoints-y_ima)); 307 [EM,ind_dim]=max(GeometryCalib.ErrorMax); 308 index=index(ind_dim); 309 267 310 unitlist=get(handles.CoordUnit,'String'); 268 311 unit=unitlist{get(handles.CoordUnit,'value')}; … … 286 329 outputfile=answer{1}; 287 330 end 288 update_imadoc(GeometryCalib,outputfile) 289 msgbox_uvmat('CONFIRMATION',{[outputfile ' updated with calibration data'];... 331 answer=msgbox_uvmat('INPUT_Y-N',{[outputfile ' updated with calibration data'];... 290 332 ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];... 291 ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']}) 292 293 %display image with new calibration in the currently opened uvmat interface 294 hhh=findobj(hhuvmat.axes3,'Tag','calib_marker');% delete calib points and markers 295 if ~isempty(hhh) 296 delete(hhh); 297 end 298 hhh=findobj(hhuvmat.axes3,'Tag','calib_points'); 299 if ~isempty(hhh) 300 delete(hhh); 301 end 302 set(hhuvmat.FixedLimits,'Value',0)% put FixedLimits option to 'off' 303 set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7]) 304 uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat 305 MenuPlot_Callback(hObject, eventdata, handles) 306 figure(handles.geometry_calib) 333 ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']}); 334 if isequal(answer,'Yes') 335 update_imadoc(GeometryCalib,outputfile) 336 %display image with new calibration in the currently opened uvmat interface 337 hhh=findobj(hhuvmat.axes3,'Tag','calib_marker');% delete calib points and markers 338 if ~isempty(hhh) 339 delete(hhh); 340 end 341 hhh=findobj(hhuvmat.axes3,'Tag','calib_points'); 342 if ~isempty(hhh) 343 delete(hhh); 344 end 345 set(hhuvmat.FixedLimits,'Value',0)% put FixedLimits option to 'off' 346 set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7]) 347 uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat 348 MenuPlot_Callback(hObject, eventdata, handles) 349 set(handles.ListCoord,'Value',index)% indicate in the list the point with max deviation (possible mistake) 350 ListCoord_Callback(hObject, eventdata, handles) 351 figure(handles.geometry_calib) 352 end 307 353 308 354 %------------------------------------------------------------------ … … 395 441 GeometryCalib.R=[px(1),0,0;0,py(1),0;0,0,1]; 396 442 397 % check error398 Calib.dpx=1;399 Calib.dpy=1;400 Calib.sx=1;401 Calib.Cx=0;402 Calib.Cy=0;403 Calib.Tz=1;404 Calib.kappa1=0;405 Calib.f=GeometryCalib.focal;406 Calib.Tx=T_x;407 Calib.Ty=T_y;408 Calib.R=GeometryCalib.R;409 [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,0);410 GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima)));411 GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima));412 GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));413 GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima));443 % %check error 444 % Calib.dpx=1; 445 % Calib.dpy=1; 446 % Calib.sx=1; 447 % Calib.Cx=0; 448 % Calib.Cy=0; 449 % Calib.Tz=1; 450 % Calib.kappa1=0; 451 % Calib.f=GeometryCalib.focal; 452 % Calib.Tx=T_x; 453 % Calib.Ty=T_y; 454 % Calib.R=GeometryCalib.R; 455 % [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,0); 456 % GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima))); 457 % GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima)); 458 % GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); 459 % GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima)); 414 460 415 461 %------------------------------------------------------------------------ … … 436 482 GeometryCalib.R=[a_X1(2),a_X1(3),0;a_Y1(2),a_Y1(3),0;0,0,1]; 437 483 438 % check error439 GeometryCalib.ErrorRms(1)=sqrt(mean((x1-x_ima).*(x1-x_ima)));440 GeometryCalib.ErrorMax(1)=max(abs(x1-x_ima));441 GeometryCalib.ErrorRms(2)=sqrt(mean((y1-y_ima).*(y1-y_ima)));442 GeometryCalib.ErrorMax(2)=max(abs(y1-y_ima));484 % %check error 485 % GeometryCalib.ErrorRms(1)=sqrt(mean((x1-x_ima).*(x1-x_ima))); 486 % GeometryCalib.ErrorMax(1)=max(abs(x1-x_ima)); 487 % GeometryCalib.ErrorRms(2)=sqrt(mean((y1-y_ima).*(y1-y_ima))); 488 % GeometryCalib.ErrorMax(2)=max(abs(y1-y_ima)); 443 489 444 490 %------------------------------------------------------------------------ … … 463 509 run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim')); 464 510 465 GeometryCalib.CalibrationType='tsai ';511 GeometryCalib.CalibrationType='tsai_matlab'; 466 512 GeometryCalib.focal=f(2); 467 513 GeometryCalib.dpx_dpy=[1 1]; … … 472 518 GeometryCalib.Tx_Ty_Tz=Tc_1'; 473 519 GeometryCalib.R=Rc_1; 474 Calib.dpx=GeometryCalib.dpx_dpy(1);475 Calib.dpy=GeometryCalib.dpx_dpy(2);476 Calib.sx=GeometryCalib.sx;477 Calib.Cx=GeometryCalib.Cx_Cy(1);478 Calib.Cy=GeometryCalib.Cx_Cy(2);479 Calib.kappa1=GeometryCalib.kappa1;480 Calib.f=GeometryCalib.focal;481 Calib.Tx=GeometryCalib.Tx_Ty_Tz(1);482 Calib.Ty=GeometryCalib.Tx_Ty_Tz(2);483 Calib.Tz=GeometryCalib.Tx_Ty_Tz(3);484 Calib.R=GeometryCalib.R;485 X=Coord(:,1);486 Y=Coord(:,2);487 Z=Coord(:,3);488 x_ima=Coord(:,4);489 y_ima=Coord(:,5);490 [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,Z);491 492 GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima)));493 GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima));494 GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima)));495 GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima));520 % Calib.dpx=GeometryCalib.dpx_dpy(1); 521 % Calib.dpy=GeometryCalib.dpx_dpy(2); 522 % Calib.sx=GeometryCalib.sx; 523 % Calib.Cx=GeometryCalib.Cx_Cy(1); 524 % Calib.Cy=GeometryCalib.Cx_Cy(2); 525 % Calib.kappa1=GeometryCalib.kappa1; 526 % Calib.f=GeometryCalib.focal; 527 % Calib.Tx=GeometryCalib.Tx_Ty_Tz(1); 528 % Calib.Ty=GeometryCalib.Tx_Ty_Tz(2); 529 % Calib.Tz=GeometryCalib.Tx_Ty_Tz(3); 530 % Calib.R=GeometryCalib.R; 531 % X=Coord(:,1); 532 % Y=Coord(:,2); 533 % Z=Coord(:,3); 534 % x_ima=Coord(:,4); 535 % y_ima=Coord(:,5); 536 % [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,Z); 537 % 538 % GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima))); 539 % [GeometryCalib.ErrorMax(1),GeometryCalib.IndexMax(1)]=max(abs(Xpoints-x_ima)); 540 % GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); 541 % [GeometryCalib.ErrorMax(2),GeometryCalib.IndexMax(2)]=max(abs(Ypoints-y_ima)); 496 542 497 543 function GeometryCalib=calib_tsai(Coord) … … 558 604 GeometryCalib.R=[r1,r2,r3;r4,r5,r6;r7,r8,r9]; 559 605 %erreur a caracteriser? 560 %check error 561 Calib.dpx=GeometryCalib.dpx_dpy(1); 562 Calib.dpy=GeometryCalib.dpx_dpy(2); 563 Calib.sx=GeometryCalib.sx; 564 Calib.Cx=GeometryCalib.Cx_Cy(1); 565 Calib.Cy=GeometryCalib.Cx_Cy(2); 566 Calib.kappa1=GeometryCalib.kappa1; 567 Calib.f=GeometryCalib.focal; 568 Calib.Tx=GeometryCalib.Tx_Ty_Tz(1); 569 Calib.Ty=GeometryCalib.Tx_Ty_Tz(2); 570 Calib.Tz=GeometryCalib.Tx_Ty_Tz(3); 571 Calib.R=GeometryCalib.R; 572 X=Coord(:,1); 573 Y=Coord(:,2); 574 Z=Coord(:,3); 575 x_ima=Coord(:,4); 576 y_ima=Coord(:,5); 577 [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,Z); 578 579 GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima))); 580 GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima)); 581 GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); 582 GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima)); 583 % Nfx 584 % dx 585 % dy 586 % 5 dpx 587 % 6 dpy 588 % cx 589 % cy 590 % sx 591 % f 592 % kappa1 593 % tx 594 % ty 595 % tz 596 % rx 597 % ry 598 % rz 599 % p1 600 % p2 601 602 %calibcoeff=str2num(calibdat) 606 % %check error 607 % Calib.dpx=GeometryCalib.dpx_dpy(1); 608 % Calib.dpy=GeometryCalib.dpx_dpy(2); 609 % Calib.sx=GeometryCalib.sx; 610 % Calib.Cx=GeometryCalib.Cx_Cy(1); 611 % Calib.Cy=GeometryCalib.Cx_Cy(2); 612 % Calib.kappa1=GeometryCalib.kappa1; 613 % Calib.f=GeometryCalib.focal; 614 % Calib.Tx=GeometryCalib.Tx_Ty_Tz(1); 615 % Calib.Ty=GeometryCalib.Tx_Ty_Tz(2); 616 % Calib.Tz=GeometryCalib.Tx_Ty_Tz(3); 617 % Calib.R=GeometryCalib.R; 618 % X=Coord(:,1); 619 % Y=Coord(:,2); 620 % Z=Coord(:,3); 621 % x_ima=Coord(:,4); 622 % y_ima=Coord(:,5); 623 % [Xpoints,Ypoints]=px_XYZ(Calib,X,Y,Z); 624 % 625 % GeometryCalib.ErrorRms(1)=sqrt(mean((Xpoints-x_ima).*(Xpoints-x_ima))); 626 % GeometryCalib.ErrorMax(1)=max(abs(Xpoints-x_ima)); 627 % GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); 628 % GeometryCalib.ErrorMax(2)=max(abs(Ypoints-y_ima)); 603 629 604 630 -
trunk/src/px_XYZ.m
r40 r84 13 13 Zphys=0; 14 14 end 15 15 if ~isfield(Calib,'f') 16 Calib.f=1; 17 end 18 if ~isfield(Calib,'kappa1') 19 Calib.kappa1=0; 20 end 21 if ~isfield(Calib,'sx') 22 Calib.sx=1; 23 end 24 if ~isfield(Calib,'dpx') 25 Calib.dpx=1; 26 end 27 if ~isfield(Calib,'dpy') 28 Calib.dpy=1; 29 end 30 if ~isfield(Calib,'Cx') 31 Calib.Cx=0; 32 end 33 if ~isfield(Calib,'Cy') 34 Calib.Cy=0; 35 end 16 36 %%%%%%%%%%%%% 17 37 if isfield(Calib,'R') -
trunk/src/set_grid.m
r73 r84 22 22 function varargout = set_grid(varargin) 23 23 24 % Last Modified by GUIDE v2.5 04-Feb-2008 16:05:0225 26 % Begin initialization code - DO NOT EDIT24 % Last Modified by GUIDE v2.5 23-Apr-2010 15:44:47 25 26 % Begin initialization code - DO NOT PLOT 27 27 gui_Singleton = 1; 28 28 gui_State = struct('gui_Name', mfilename, ... … … 41 41 gui_mainfcn(gui_State, varargin{:}); 42 42 end 43 % End initialization code - DO NOT EDIT43 % End initialization code - DO NOT PLOT 44 44 45 45 %------------------------------------------------------------------- … … 58 58 % if =[] or absent, no plot (mask mode in uvmat) 59 59 % parameters on the uvmat interface (obtained by 'get_plot_handle.m') 60 function set_grid_OpeningFcn(hObject, eventdata, handles,inputfile )60 function set_grid_OpeningFcn(hObject, eventdata, handles,inputfile,CoordType) 61 61 62 62 % Choose default command line output for set_grid … … 70 70 % set(hObject,'Position',[0.7 0.1 0.25 0.5])%set the position of the set_grid interface 71 71 set(hObject,'DeleteFcn',@closefcn) 72 set(handles.TITLE,'Value',1)73 set(handles.ObjectStyle,'Value',1)74 set(handles.ProjMode,'Value',1)72 % set(handles.TITLE,'Value',1) 73 %set(handles.ObjectStyle,'Value',1) 74 %set(handles.ProjMode,'Value',1) 75 75 set(handles.MenuCoord,'ListboxTop',1) 76 76 set(handles.MenuCoord,'Value',1); … … 80 80 set(handles.image_2,'String',inputfile) 81 81 end 82 82 if exist('CoordType','var') 83 if strcmp(CoordType,'px') 84 set(handles.MenuCoord,'Value',2) 85 end 86 end 83 87 84 88 % --- Outputs from this function are returned to the command line. 85 89 function varargout = set_grid_OutputFcn(hObject, eventdata, handles) 86 % varargout cell array for returning output args (see VARARGOUT);87 % hObject handle to figure88 % eventdata reserved - to be defined in a future version of MATLAB89 % handles structure with handles and user data (see GUIDATA)90 91 90 % Get default command line output from handles structure 92 91 varargout{1} = handles.output; 93 92 varargout{2}=handles; 94 95 % --- Executes on selection change in ObjectStyle.96 function ObjectStyle_Callback(hObject, eventdata, handles)97 98 ProjMode_Callback(hObject, eventdata, handles)99 100 %----------------------------------------------101 function xObject_Callback(hObject, eventdata, handles)102 103 104 function yObject_Callback(hObject, eventdata, handles)105 106 107 % --- Executes on selection change in zObject.108 function zObject_Callback(hObject, eventdata, handles)109 110 111 %---------------------------------------------------112 % --- Executes on selection change in ProjMode.113 function ProjMode_Callback(hObject, eventdata, handles)114 menu=get(handles.ProjMode,'String');115 value=get(handles.ProjMode,'Value');116 ProjMode=menu{value};117 menu=get(handles.ObjectStyle,'String');118 value=get(handles.ObjectStyle,'Value');119 ObjectStyle=menu{value};120 test3D=isequal(get(handles.ZObject,'Visible'),'on');%3D case121 if isequal(ObjectStyle,'plane')||isequal(ObjectStyle,'volume')122 set(handles.Phi,'Visible','on')123 if test3D%3D case124 set(handles.Theta,'Visible','on')125 set(handles.Psi,'Visible','on')126 end127 set(handles.XMin,'Visible','on')128 set(handles.XMax,'Visible','on')129 set(handles.YMin,'Visible','on')130 set(handles.YMax,'Visible','on')131 if test3D132 set(handles.Theta,'Visible','on')133 set(handles.Psi,'Visible','on')134 set(handles.ZMin,'Visible','on')135 set(handles.ZMax,'Visible','on')136 end137 else138 set(handles.Phi,'Visible','off')139 set(handles.Theta,'Visible','off')140 set(handles.Psi,'Visible','off')141 set(handles.XMin,'Visible','off')142 set(handles.XMax,'Visible','off')143 set(handles.YMin,'Visible','off')144 if isequal(ProjMode,'interp')145 set(handles.YMax,'Visible','off')146 else147 set(handles.YMax,'Visible','on')148 end149 if isequal(ObjectStyle,'rectangle')|isequal(ObjectStyle,'ellipse')150 set(handles.XMax,'Visible','on')151 else152 set(handles.XMax,'Visible','off')153 end154 set(handles.ZMin,'Visible','off')155 set(handles.ZMax,'Visible','off')156 end157 if isequal(ProjMode,'projection')|isequal(ProjMode,'inside')|isequal(ProjMode,'outside')|isequal(ObjectStyle,'points')158 set(handles.DX,'Visible','off')159 set(handles.DY,'Visible','off')160 set(handles.DZ,'Visible','off')161 else162 set(handles.DX,'Visible','on')163 set(handles.DY,'Visible','on')164 if test3D%3D case165 set(handles.DZ,'Visible','on')166 end167 end168 169 %---------------------------------------------170 % --- Executes on selection change in TITLE.171 function TITLE_Callback(hObject, eventdata, handles)172 hsetobject=get(handles.TITLE,'parent');173 SetData=get(hsetobject,'UserData');%get the hidden interface data174 % function named CALLBACK in UNTITLED.M with the given input arguments.175 menu=get(handles.TITLE,'String');176 value=get(handles.TITLE,'Value');177 titl=menu{value};178 if isequal(titl,'POINTS')179 menu_style={'points'};180 menu_proj={'projection';'interp';'filter';'none'};181 elseif isequal(titl,'LINE')182 menu_style={'line';'polyline';'rectangle';'polygon';'ellipse'};%'line' =default183 menu_proj={'projection';'interp';'filter';'none'};184 elseif isequal(titl,'PATCH')185 menu_style={'rectangle';'polygon';'ellipse'};%'line' =default186 menu_proj={'inside';'outside';'none'};187 elseif isequal(titl,'PLANE')188 menu_style={'plane'};189 menu_proj={'projection';'interp'};190 elseif isequal(titl,'VOLUME')191 menu_style={'volume'};192 menu_proj={'none'};193 194 end195 set(handles.ObjectStyle,'String',menu_style)196 set(handles.ObjectStyle,'Value',1)197 set(handles.ProjMode,'String',menu_proj)198 set(handles.ProjMode,'Value',1)199 if isfield(SetData,'ParentButton')200 update_parentbutton(SetData.ParentButton,titl)201 end202 ObjectStyle_Callback(hObject, eventdata, handles)203 204 %-----------205 function update_parentbutton(ParentButton,titl)206 207 if isstruct(ParentButton)208 parentfields=fields(ParentButton);209 for ibutton=1:length(parentfields)210 buttonhandle=eval(['ParentButton.' parentfields{ibutton}]);211 if ishandle(buttonhandle)212 set(buttonhandle,'Value',0)213 set(buttonhandle,'BackgroundColor',[0 1 0])%put unactivated buttons to green214 end215 end216 if isfield(ParentButton,titl)217 buttonhandle=eval(['ParentButton.' titl]);218 if ishandle(buttonhandle)219 set(buttonhandle,'Value',1)220 set(buttonhandle,'BackgroundColor',[1 1 0])%put activated button to yellow221 end222 end223 end224 %------------225 function Phi_Callback(hObject, eventdata, handles)226 update_slider(hObject, eventdata,handles)227 228 function Theta_Callback(hObject, eventdata, handles)229 update_slider(hObject, eventdata,handles)230 231 function update_slider(hObject, eventdata,handles)232 %rotation angles233 Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian234 Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian235 236 %components of the unitiy vector normal to the projection plane237 NormVec_X=-sin(Phi)*sin(Theta);238 NormVec_Y=cos(Phi)*sin(Theta);239 NormVec_Z=cos(Theta);240 huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle241 UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface242 Z=NormVec_X *(UvData.X)+NormVec_Y *(UvData.Y)+NormVec_Z *(UvData.Z);243 set(handles.z_slider,'Min',min(Z))244 set(handles.z_slider,'Max',max(Z))245 ZMax_Callback(hObject, eventdata, handles)246 247 function DX_Callback(hObject, eventdata, handles)248 249 250 function DY_Callback(hObject, eventdata, handles)251 252 253 function DZ_Callback(hObject, eventdata, handles)254 255 93 256 94 … … 362 200 363 201 %----------------------------------------------------------------------- 364 % --- Executes on button press in edit: PLOT the defined object and its projected field 365 function edit_Callback(hObject, eventdata, handles) 366 hsetobject=get(hObject,'parent'); 367 SetData=get(hsetobject,'UserData');%get the hidden interface data 368 %IndexObj=SetData.IndexObj%index of the current projection object in the list of projection objects (UvData.ProjObject) 369 huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle 370 UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface 371 if isfield(UvData,'CuurentObjectIndex') 372 IndexObj=UvData.CurrentObjectIndex; 373 else 374 IndexObj=[]; 375 end 376 ObjectData=read_set_grid(handles);%read the interface input parameters defining the object 377 [UvData,IndexObj]=update_obj(UvData,IndexObj,ObjectData,SetData.PlotHandles); 378 uvmat('write_plot_param',PlotHandles,UvData.Object{IndexObj}.PlotParam); %update the display of plotting parameters for the current object 379 SetData.IndexObj=IndexObj; 380 set(gcbf,'UserData',SetData)%update object index in the set_grid interface 381 set(huvmat,'UserData',UvData)%update the data in the uvmat interface 202 % --- Executes on button press in plot: PLOT the defined object and its projected field 203 function plot_Callback(hObject, eventdata, handles) 204 grid_pix_A=get_grid(handles); 205 huvmat=uvmat(get(handles.image_1,'String')); 206 hhuvmat=guidata(huvmat); 207 set(hhuvmat.transform_fct,'Value',1) 208 uvmat('run0_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat 209 axes(hhuvmat.axes3); 210 hold on 211 plot(grid_pix_A(:,1),grid_pix_A(:,2),'.') 212 213 % --- Executes on button press in plot_2. 214 function plot_2_Callback(hObject, eventdata, handles) 215 [grid_pix_A,grid_pix_B]=get_grid(handles); 216 huvmat=uvmat(get(handles.image_2,'String')); 217 hhuvmat=guidata(huvmat); 218 set(hhuvmat.transform_fct,'Value',1) 219 uvmat('run0_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat 220 axes(hhuvmat.axes3); 221 hold on 222 plot(grid_pix_B(:,1),grid_pix_B(:,2),'.') 223 382 224 383 225 … … 401 243 delete_object(IndexObj); 402 244 403 %----------------------------------------------------404 function YMin_Callback(hObject, eventdata, handles)405 % hObject handle to YMin (see GCBO)406 % eventdata reserved - to be defined in a future version of MATLAB407 % handles structure with handles and user data (see GUIDATA)408 409 % Hints: get(hObject,'String') returns contents of YMin as text410 % str2double(get(hObject,'String')) returns contents of YMin as a double411 412 413 function ZMin_Callback(hObject, eventdata, handles)414 415 416 function ZMax_Callback(hObject, eventdata, handles)417 DZ=str2num(get(handles.ZMax,'String'));418 ZMin=get(handles.z_slider,'Min');419 ZMax=get(handles.z_slider,'Max');420 rel_step(1)=DZ/(ZMax-ZMin);421 rel_step(2)=0.2;422 set(handles.z_slider,'SliderStep',rel_step)423 424 function YMax_Callback(hObject, eventdata, handles)425 426 427 function XMin_Callback(hObject, eventdata, handles)428 429 430 function XMax_Callback(hObject, eventdata, handles)431 432 245 433 246 % ------------------------------------------------------ 434 247 function save_Callback(hObject, eventdata, handles) 435 248 % ------------------------------------------------------ 436 Object=read_set_object(handles);%read the set_grid interface; 437 DX=Object.DX; 438 DY=Object.DY; 439 RangeX=Object.RangeX; 440 RangeY=Object.RangeY; 441 array_realx=[RangeX(2):DX:RangeX(1)]; 442 array_realy=[RangeY(2):DY:RangeY(1)]; 443 nx_patch=length(array_realx); 444 ny_patch=length(array_realy); 445 [grid_realx,grid_realy]=meshgrid(array_realx,array_realy); 446 grid_real(:,1)=reshape(grid_realx,nx_patch*ny_patch,1); 447 grid_real(:,2)=reshape(grid_realy,nx_patch*ny_patch,1); 448 grid_real(:,3)=zeros(nx_patch*ny_patch,1); 249 [grid_pix_A,grid_pix_B]=get_grid(handles); 250 251 %ECRIRE FICHIERS 252 nbpointsA=size(grid_pix_A); 253 XA=grid_pix_A(:,1); 254 YA=grid_pix_A(:,2); 255 unitcolumn=32*ones(size(XA)); 256 Xchar=num2str(XA); 257 blanc=char(unitcolumn); 258 Ychar=num2str(YA); 259 tete=['1 ' num2str(nbpointsA(1))]; 260 txt=[Xchar blanc Ychar]; 261 textgrid={tete;txt}; 262 textout=char(textgrid); 263 imageA=get(handles.image_1,'String'); 264 [Pathsub]=name2display(imageA); 265 Answer = msgbox_uvmat('INPUT_TXT','grid file name (*.grid)',fullfile(Pathsub,'gridA.grid')); 266 % Answer = inputdlg('grid file name (*.grid)',' ',1,{fullfile(Pathsub,'gridA.grid')},'on'); 267 dlmwrite(Answer,textout,''); 268 msgbox_uvmat('CONFIRMATION',[Answer ' written as ASCII text file']); 269 if ~isempty(grid_pix_B) 270 nbpointsB=size(grid_pix_B); 271 XB=grid_pix_B(:,1); 272 YB=grid_pix_B(:,2); 273 unitcolumn=32*ones(size(XB)); 274 Xchar=num2str(XB); 275 blanc=char(unitcolumn); 276 Ychar=num2str(YB); 277 tete=['1 ' num2str(nbpointsB(1))]; 278 txt=[Xchar blanc Ychar]; 279 textgrid={tete;txt}; 280 textout=char(textgrid); 281 Answer = msgbox_uvmat('INPUT_TXT','grid file name (*.grid)',fullfile(Pathsub,'gridB.grid')); 282 dlmwrite(Answer,textout,''); 283 msgbox_uvmat('CONFIRMATION',[Answer ' written as ASCII text file']); 284 end 285 286 %------------------------- 287 function [grid_pix_A,grid_pix_B]=get_grid(handles); 288 %Object=read_set_object(handles);%read the set_grid interface; 289 grid_pix_B=[];%default 290 DX=str2num(get(handles.DX,'String')); 291 DY=str2num(get(handles.DY,'String')); 292 XMin=str2num(get(handles.XMin,'String')); 293 XMax=str2num(get(handles.XMax,'String')); 294 YMin=str2num(get(handles.YMin,'String')); 295 YMax=str2num(get(handles.YMax,'String')); 296 array_realx=[XMin:DX:XMax]; 297 array_realy=[YMin:DY:YMax]; 298 nx_patch=length(array_realx); 299 ny_patch=length(array_realy); 300 [grid_realx,grid_realy]=meshgrid(array_realx,array_realy); 301 grid_real(:,1)=reshape(grid_realx,nx_patch*ny_patch,1); 302 grid_real(:,2)=reshape(grid_realy,nx_patch*ny_patch,1); 303 grid_real(:,3)=zeros(nx_patch*ny_patch,1); 449 304 450 305 imageA=get(handles.image_1,'String'); … … 482 337 tsaiA=[]; 483 338 end 484 size(grid_real) 485 tsaiA 486 if isempty(tsaiA) 339 MenuCoord=get(handles.MenuCoord,'String'); 340 val=get(handles.MenuCoord,'Value'); 341 if isempty(tsaiA)||strcmp(MenuCoord{val},'px') 487 342 grid_imaA(:,1)=grid_real(:,1); 488 343 grid_imaA(:,2)=grid_real(:,2); … … 544 399 grid_real2(:,2)=grid_real_y; 545 400 grid_real2(:,3)=zeros(nx_patch_new,1); 546 if isempty(tsaiA) 401 if isempty(tsaiA)||strcmp(MenuCoord{val},'px') 547 402 grid_pix_A(:,1)=grid_real2(:,1); 548 403 grid_pix_A(:,2)= grid_real2(:,2); … … 554 409 end 555 410 556 %ECRIRE FICHIERS 557 nbpointsA=size(grid_pix_A); 558 XA=grid_pix_A(:,1); 559 YA=grid_pix_A(:,2); 560 unitcolumn=32*ones(size(XA)); 561 Xchar=num2str(XA); 562 blanc=char(unitcolumn); 563 Ychar=num2str(YA); 564 tete=['1 ' num2str(nbpointsA(1))]; 565 txt=[Xchar blanc Ychar]; 566 textgrid={tete;txt}; 567 textout=char(textgrid); 568 Answer = msgbox_uvmat('INPUT_TXT','grid file name (*.grid)',fullfile(Pathsub,'gridA.grid')); 569 % Answer = inputdlg('grid file name (*.grid)',' ',1,{fullfile(Pathsub,'gridA.grid')},'on'); 570 dlmwrite(Answer,textout,''); 571 msgbox_uvmat('CONFIRMATION',[Answer ' written as ASCII text file']); 572 if testB 573 nbpointsB=size(grid_pix_B); 574 XB=grid_pix_B(:,1); 575 YB=grid_pix_B(:,2); 576 unitcolumn=32*ones(size(XB)); 577 Xchar=num2str(XB); 578 blanc=char(unitcolumn); 579 Ychar=num2str(YB); 580 tete=['1 ' num2str(nbpointsB(1))]; 581 txt=[Xchar blanc Ychar]; 582 textgrid={tete;txt}; 583 textout=char(textgrid); 584 Answer = msgbox_uvmat('INPUT_TXT','grid file name (*.grid)',fullfile(Pathsub,'gridB.grid')); 585 dlmwrite(Answer,textout,''); 586 msgbox_uvmat('CONFIRMATION',[Answer ' written as ASCII text file']); 587 end 588 589 590 % --- Executes on slider movement. 591 function z_slider_Callback(hObject, eventdata, handles) 592 %A ADAPTER 593 Z_value=get(handles.z_slider,'Value'); 594 595 %rotation angles 596 Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian 597 Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian 598 599 %components of the unity vector normal to the projection plane 600 NormVec_X=-sin(Phi)*sin(Theta); 601 NormVec_Y=cos(Phi)*sin(Theta); 602 NormVec_Z=cos(Theta); 603 604 %set new plane position and update graph 605 set(handles.XObject,'String',num2str(NormVec_X*Z_value)) 606 set(handles.YObject,'String',num2str(NormVec_Y*Z_value)) 607 set(handles.ZObject,'String',num2str(NormVec_Z*Z_value)) 608 edit_Callback(hObject, eventdata, handles) 609 610 611 612 function XObject_Callback(hObject, eventdata, handles) 613 614 615 function YObject_Callback(hObject, eventdata, handles) 616 617 618 619 620 function ZObject_Callback(hObject, eventdata, handles) 621 622 623 function image_2_Callback(hObject, eventdata, handles) 624 % hObject handle to image_2 (see GCBO) 625 % eventdata reserved - to be defined in a future version of MATLAB 626 % handles structure with handles and user data (see GUIDATA) 627 628 % Hints: get(hObject,'String') returns contents of image_2 as text 629 % str2double(get(hObject,'String')) returns contents of image_2 as a double 630 631 632 633 function image_1_Callback(hObject, eventdata, handles) 634 % hObject handle to image_1 (see GCBO) 635 % eventdata reserved - to be defined in a future version of MATLAB 636 % handles structure with handles and user data (see GUIDATA) 637 638 % Hints: get(hObject,'String') returns contents of image_1 as text 639 % str2double(get(hObject,'String')) returns contents of image_1 as a double 640 641 411 412 413 %------------------------------------------------------------------------ 642 414 % --- Executes on button press in HELP. 643 415 function HELP_Callback(hObject, eventdata, handles) 416 %------------------------------------------------------------------------ 644 417 path_to_uvmat=which ('uvmat');% check the path of uvmat 645 418 pathelp=fileparts(path_to_uvmat); 646 helpfile=fullfile(pathelp,' UVMAT_DOC','uvmat_doc.html');419 helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); 647 420 if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') 648 421 else … … 650 423 end 651 424 425 426 -
trunk/src/update_imadoc.m
r29 r84 38 38 end 39 39 end 40 %create a new xml file 40 41 if ~testappend 41 42 t=xmltree; 42 43 t=set(t,1,'name','ImaDoc'); 43 [t,uid_calib]=add(t,1,'element','GeometryCalib'); 44 % in case of movie (avi file), copy timing info in the new xml file 45 [pp,outputroot]=fileparts(outputfile); 46 info=[]; 47 if exist(fullfile(pp,[outputroot '.avi']),'file') 48 info=aviinfo(fullfile(pp,[outputroot '.avi'])); 49 elseif exist(fullfile(pp,[outputroot '.AVI']),'file') 50 info=fullfile(pp,[outputroot '.AVI']); 51 end 52 if ~isempty(info) 53 [t,uid_camera]=add(t,1,'element','Camera'); 54 Camera.TimeUnit='s'; 55 % Camera.BurstTiming.FrameFrequency=info.FramesPerSecond; 56 Camera.BurstTiming.Time=0; 57 Camera.BurstTiming.Dti=1/info.FramesPerSecond; 58 Camera.BurstTiming.NbDti=info.NumFrames-1; 59 t=struct2xml(Camera,t,uid_camera) 60 end 61 [t,uid_calib]=add(t,1,'element','GeometryCalib'); 44 62 end 45 63 t=struct2xml(GeometryCalib,t,uid_calib); -
trunk/src/uvmat.m
r82 r84 788 788 nbfield=size(XmlData.Time,1); 789 789 nburst=size(XmlData.Time,2); 790 %transform .Time to a column vector if it is a line vector the nomenclature uses a single index 791 if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector 792 NomType=get(handles.FileIndex,'UserData'); 793 if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%')) 794 XmlData.Time=(XmlData.Time)'; 795 nbfield=nburst; 796 nburst=1; 797 end 798 end 790 799 end 791 800 last_i_cell=get(handles.last_i,'String'); … … 822 831 set(handles.pycm,'String',num2str(pixcmy)) 823 832 end 824 set(handles.transform_fct,'Value',2); % phys transform by default 833 if ~get(handles.FixedLimits,'Value') 834 set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off 835 end 825 836 if isfield(GeometryCalib,'SliceCoord') 826 837 siz=size(GeometryCalib.SliceCoord); … … 2122 2133 switch FileType 2123 2134 case 'movie' 2124 A=read(UvData.MovieObject,num_i1); 2135 try 2136 A=read(UvData.MovieObject,num_i1); 2137 catch 2138 errormsg=lasterr; 2139 return 2140 end 2125 2141 case 'avi' 2126 mov=aviread(filename,num_i1); 2142 try 2143 mov=aviread(filename,num_i1); 2144 catch 2145 errormsg=lasterr; 2146 return 2147 end 2127 2148 A=frame2im(mov(1)); 2128 2149 case 'vol' … … 2814 2835 else 2815 2836 set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7]) 2837 update_plot(handles); 2816 2838 end 2817 2839 … … 4208 4230 % --- Executes on button press in grid. 4209 4231 function grid_Callback(hObject, eventdata, handles) 4210 %------------------------------------------------------------------- 4211 4212 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 4213 4214 %suppress the other options if grid is chosen 4215 set(handles.edit_vect,'Value',0) 4216 edit_vect_Callback(hObject, eventdata, handles) 4217 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7]) 4218 set(handles.edit_vect,'Value',0) 4219 edit_vect_Callback(hObject, eventdata, handles) 4220 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7]) 4221 set(handles.list_object_1,'Value',1) 4222 4223 %prepare display of the set_grid GUI 4224 data.fixedtitle=1; 4225 FileName=read_file_boxes(handles); 4226 [hset_object,UvData.sethandles]=set_grid(FileName);% call the set_object interface 4227 set(handles.uvmat,'UserData',UvData); 4232 4228 4233 4229 4234 … … 4706 4711 %-- open the GUI set_grid.fig to create grid 4707 4712 function MenuGrid_Callback(hObject, eventdata, handles) 4708 set(handles.TOOLS_txt,'Visible','on') 4709 set(handles.frame_tools,'Visible','on') 4710 grid_Callback(hObject,eventdata,handles) 4713 %UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 4714 4715 %suppress the other options if grid is chosen 4716 set(handles.edit_vect,'Value',0) 4717 edit_vect_Callback(hObject, eventdata, handles) 4718 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7]) 4719 set(handles.edit_vect,'Value',0) 4720 edit_vect_Callback(hObject, eventdata, handles) 4721 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7]) 4722 set(handles.list_object_1,'Value',1) 4723 4724 %prepare display of the set_grid GUI 4725 FileName=read_file_boxes(handles); 4726 CoordList=get(handles.transform_fct,'String'); 4727 val=get(handles.transform_fct,'Value'); 4728 set_grid(FileName,CoordList{val});% call the set_object interface 4729 %set(handles.uvmat,'UserData',UvData); 4711 4730 4712 4731 %----------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.