Changeset 84 for trunk/src/set_grid.m
- Timestamp:
- Apr 24, 2010, 2:07:22 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.