source: trunk/src/set_grid.m @ 73

Last change on this file since 73 was 73, checked in by sommeria, 11 years ago

ima2vol: provides volume images in 16 bit (presently needed for the software 3D3C)
set_grid: small bug repairs
uvmat: small bug repairs.
civ: bug repair following previous changes (RUN and BATCH functions merged)
plot_field: cleaning of parameter transmission. Introduction of a parameter handle of a text box (not yet used)

File size: 22.0 KB
Line 
1%'set_grid':produce grid for PIV with one or two images (stereo case)
2%------------------------------------------------------------------------
3% function varargout = set_grid(varargin)
4% associated with the GUI set_grid.fig
5%
6%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
7%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
8%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
9%     This file is part of the toolbox UVMAT.
10%
11%     UVMAT is free software; you can redistribute it and/or modify
12%     it under the terms of the GNU General Public License as published by
13%     the Free Software Foundation; either version 2 of the License, or
14%     (at your option) any later version.
15%
16%     UVMAT is distributed in the hope that it will be useful,
17%     but WITHOUT ANY WARRANTY; without even the implied warranty of
18%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
20%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
21
22function varargout = set_grid(varargin)
23
24% Last Modified by GUIDE v2.5 04-Feb-2008 16:05:02
25
26% Begin initialization code - DO NOT EDIT
27gui_Singleton = 1;
28gui_State = struct('gui_Name',       mfilename, ...
29                   'gui_Singleton',  gui_Singleton, ...
30                   'gui_OpeningFcn', @set_grid_OpeningFcn, ...
31                   'gui_OutputFcn',  @set_grid_OutputFcn, ...
32                   'gui_LayoutFcn',  [] , ...
33                   'gui_Callback',   []);
34if nargin & isstr(varargin{1})
35    gui_State.gui_Callback = str2func(varargin{1});
36end
37
38if nargout
39    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
40else
41    gui_mainfcn(gui_State, varargin{:});
42end
43% End initialization code - DO NOT EDIT
44
45%-------------------------------------------------------------------
46% --- Executes just before set_grid is made visible.
47%INPUT:
48% handles: handles of the set_grid interface elements
49%'IndexObj': index of the object (on the UvData list) that set_grid will modify
50%        if =[] or absent: index still undefined (create mode in uvmat)
51%        if=0; no associated object (used for series), the button 'PLOT' is  then unvisible
52%'data': read from an existing object selected in the interface
53%      .TITLE : class of object ('POINTS','LINE',....)
54%      .DX,DY,DZ; meshes for regular grids
55%      .Coord: object position coordinates
56%      .ParentButton: handle of the uicontrol object calling the interface
57% PlotHandles: set of handles of the elements contolling the plotting of the projected field:
58%  if =[] or absent, no plot (mask mode in uvmat)
59% parameters on the uvmat interface (obtained by 'get_plot_handle.m')
60function set_grid_OpeningFcn(hObject, eventdata, handles,inputfile)
61
62% Choose default command line output for set_grid
63handles.output = hObject;
64
65% Update handles structure
66guidata(hObject, handles);
67
68%default
69% set(hObject,'Unit','Normalized')% set the unit normalized to the screen size
70% set(hObject,'Position',[0.7 0.1 0.25 0.5])%set the position of the set_grid interface
71set(hObject,'DeleteFcn',@closefcn)
72set(handles.TITLE,'Value',1)
73set(handles.ObjectStyle,'Value',1)
74set(handles.ProjMode,'Value',1)
75set(handles.MenuCoord,'ListboxTop',1)
76set(handles.MenuCoord,'Value',1);
77set(handles.MenuCoord,'String',{'phys';'px'});
78if exist('inputfile','var')& ~isempty(inputfile)
79   set(handles.image_1,'String',inputfile)
80   set(handles.image_2,'String',inputfile)
81end
82
83
84% --- Outputs from this function are returned to the command line.
85function varargout = set_grid_OutputFcn(hObject, eventdata, handles)
86% varargout  cell array for returning output args (see VARARGOUT);
87% hObject    handle to figure
88% eventdata  reserved - to be defined in a future version of MATLAB
89% handles    structure with handles and user data (see GUIDATA)
90
91% Get default command line output from handles structure
92varargout{1} = handles.output;
93varargout{2}=handles;
94
95% --- Executes on selection change in ObjectStyle.
96function ObjectStyle_Callback(hObject, eventdata, handles)
97
98ProjMode_Callback(hObject, eventdata, handles)
99
100%----------------------------------------------
101function xObject_Callback(hObject, eventdata, handles)
102
103
104function yObject_Callback(hObject, eventdata, handles)
105
106
107% --- Executes on selection change in zObject.
108function zObject_Callback(hObject, eventdata, handles)
109
110
111%---------------------------------------------------
112% --- Executes on selection change in ProjMode.
113function ProjMode_Callback(hObject, eventdata, handles)
114menu=get(handles.ProjMode,'String');
115value=get(handles.ProjMode,'Value');
116ProjMode=menu{value};
117menu=get(handles.ObjectStyle,'String');
118value=get(handles.ObjectStyle,'Value');
119ObjectStyle=menu{value};
120test3D=isequal(get(handles.ZObject,'Visible'),'on');%3D case
121if isequal(ObjectStyle,'plane')||isequal(ObjectStyle,'volume')
122    set(handles.Phi,'Visible','on')
123    if test3D%3D case
124        set(handles.Theta,'Visible','on')
125        set(handles.Psi,'Visible','on')
126    end
127    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 test3D
132        set(handles.Theta,'Visible','on')
133        set(handles.Psi,'Visible','on')
134        set(handles.ZMin,'Visible','on')
135        set(handles.ZMax,'Visible','on')
136    end
137else
138    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    else
147        set(handles.YMax,'Visible','on')
148    end
149    if isequal(ObjectStyle,'rectangle')|isequal(ObjectStyle,'ellipse')
150        set(handles.XMax,'Visible','on')
151    else
152       set(handles.XMax,'Visible','off')
153    end
154    set(handles.ZMin,'Visible','off')
155    set(handles.ZMax,'Visible','off')
156end
157if 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')   
161else
162    set(handles.DX,'Visible','on')
163    set(handles.DY,'Visible','on')
164    if test3D%3D case
165        set(handles.DZ,'Visible','on')
166    end
167end
168
169%---------------------------------------------
170% --- Executes on selection change in TITLE.
171function TITLE_Callback(hObject, eventdata, handles)
172hsetobject=get(handles.TITLE,'parent');
173SetData=get(hsetobject,'UserData');%get the hidden interface data
174%      function named CALLBACK in UNTITLED.M with the given input arguments.
175menu=get(handles.TITLE,'String');
176value=get(handles.TITLE,'Value');
177titl=menu{value};
178if isequal(titl,'POINTS')
179     menu_style={'points'};
180     menu_proj={'projection';'interp';'filter';'none'};
181elseif isequal(titl,'LINE')
182     menu_style={'line';'polyline';'rectangle';'polygon';'ellipse'};%'line' =default
183     menu_proj={'projection';'interp';'filter';'none'};
184elseif isequal(titl,'PATCH')
185     menu_style={'rectangle';'polygon';'ellipse'};%'line' =default
186     menu_proj={'inside';'outside';'none'};
187 elseif isequal(titl,'PLANE')
188     menu_style={'plane'};
189     menu_proj={'projection';'interp'};
190elseif isequal(titl,'VOLUME')
191     menu_style={'volume'};
192     menu_proj={'none'};
193 
194end
195set(handles.ObjectStyle,'String',menu_style)
196set(handles.ObjectStyle,'Value',1)
197set(handles.ProjMode,'String',menu_proj)
198set(handles.ProjMode,'Value',1)
199if isfield(SetData,'ParentButton')
200    update_parentbutton(SetData.ParentButton,titl)
201end
202ObjectStyle_Callback(hObject, eventdata, handles) 
203
204%-----------
205function update_parentbutton(ParentButton,titl)
206
207if 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 green
214        end
215    end
216    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 yellow
221       end
222    end
223end
224%------------
225function Phi_Callback(hObject, eventdata, handles)
226update_slider(hObject, eventdata,handles)
227
228function Theta_Callback(hObject, eventdata, handles)
229update_slider(hObject, eventdata,handles)
230
231function update_slider(hObject, eventdata,handles)
232%rotation angles
233Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian
234Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian
235
236%components of the unitiy vector normal to the projection plane
237NormVec_X=-sin(Phi)*sin(Theta);
238NormVec_Y=cos(Phi)*sin(Theta);
239NormVec_Z=cos(Theta);
240huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle
241UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
242Z=NormVec_X *(UvData.X)+NormVec_Y *(UvData.Y)+NormVec_Z *(UvData.Z);
243set(handles.z_slider,'Min',min(Z))
244set(handles.z_slider,'Max',max(Z))
245ZMax_Callback(hObject, eventdata, handles)
246
247function DX_Callback(hObject, eventdata, handles)
248
249
250function DY_Callback(hObject, eventdata, handles)
251
252
253function DZ_Callback(hObject, eventdata, handles)
254
255
256
257%-----------------------------------------------------
258% --- Executes on button press in import.
259function import_Callback(hObject, eventdata, handles)
260%get the object file
261oldfile='';
262huvmat=findobj('Tag','uvmat');
263if isempty(huvmat)
264    huvmat=findobj(allchild(0),'Name','series');
265end
266hchild=get(huvmat,'Children');
267hrootpath=findobj(hchild,'Tag','RootPath');
268oldfile=get(hrootpath,'String');
269if iscell(oldfile)
270    oldfile=oldfile{1};
271end
272%[FileName,PathName] = uigetfile('*.civ','Select a .civ file',oldfile)
273[FileName, PathName, filterindex] = uigetfile( ...
274       {'*.xml;*.mat', ' (*.xml,*.mat)';
275       '*.xml',  '.xml files '; ...
276        '*.mat',  '.mat matlab files '}, ...
277        'Pick a file',oldfile);
278fileinput=[PathName FileName];%complete file name
279testblank=findstr(fileinput,' ');%look for blanks
280if ~isempty(testblank)
281    errordlg('forbidden input file name: contain blanks')
282    return
283end
284sizf=size(fileinput);
285if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
286
287%read the file
288 t=xmltree(fileinput);
289 s=convert(t);
290testmode=0;
291if isfield(s,'ProjMode')
292        menu=get(handles.ProjMode,'String');
293        for iline=1:length(menu)
294            if isequal(menu{iline},s.ProjMode)
295                set(handles.ProjMode,'Value',iline)
296                testmode=1;
297                break
298            end
299        end
300end
301
302ProjMode_Callback(hObject, eventdata, handles);%visualize the appropriate edit boxes
303if isfield(s,'CoordType')
304    if isequal(s.CoordType,'phys')
305        set(handles.MenuCoord,'Value',1)
306    elseif isequal(s.CoordType,'px')
307        set(handles.MenuCoord,'Value',2)
308    else
309        warndlg('unknown CoordType (px or phys) in set_grid.m')
310    end
311end
312if isfield(s,'XMax')
313    set(handles.XMax,'String',s.XMax)
314end
315if isfield(s,'XMin')
316    set(handles.XMin,'String',s.XMin)
317end
318if isfield(s,'YMax')
319    set(handles.YMax,'String',s.YMax)
320end
321if isfield(s,'YMin')
322    set(handles.YMin,'String',s.YMin)
323end
324if isfield(s,'DX')
325    set(handles.DX,'String',s.DX)
326end
327if isfield(s,'DY')
328    set(handles.DY,'String',s.DY)
329end
330if ~isfield(s,'Coord')
331    XObject='0';%default
332    YObject='0';
333elseif ischar(s.Coord)
334    line=str2num(s.Coord);
335    XObject=num2str(line(1));
336    YObject=num2str(line(2));
337else
338    for i=1:length(s.Coord)
339        line=str2num(s.Coord{i});
340        XObject{i}=num2str(line(1));
341        YObject{i}=num2str(line(2));
342    end
343end
344set(handles.XObject,'String',XObject)
345set(handles.YObject,'String',YObject)
346%METTRA A JOUR ASPECT DE L'INTERFACE (COMME set_grid_Opening
347
348%----------------------------------------------------
349% executed when closing: set the parent interface button to value 0
350function closefcn(gcbo,eventdata)
351huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
352parent_button=findobj(huvmat,'Tag','grid');
353if ~isempty(parent_button)
354    set(parent_button,'Value',0)%put unactivated buttons to green
355    tag=get(parent_button,'Tag');
356    if isequal(tag,'edit')
357        set(parent_button,'BackgroundColor',[0.7 0.7 0.7]);
358    else
359        set(parent_button,'BackgroundColor',[0 1 0]);
360    end
361end
362
363%-----------------------------------------------------------------------
364% --- Executes on button press in edit: PLOT the defined object and its projected field
365function edit_Callback(hObject, eventdata, handles)
366hsetobject=get(hObject,'parent');
367SetData=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)
369huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle
370UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
371if isfield(UvData,'CuurentObjectIndex')
372    IndexObj=UvData.CurrentObjectIndex;
373else
374    IndexObj=[];
375end
376ObjectData=read_set_grid(handles);%read the interface input parameters defining the object
377[UvData,IndexObj]=update_obj(UvData,IndexObj,ObjectData,SetData.PlotHandles);
378uvmat('write_plot_param',PlotHandles,UvData.Object{IndexObj}.PlotParam); %update the display of plotting parameters for the current object
379SetData.IndexObj=IndexObj;
380set(gcbf,'UserData',SetData)%update object index in the set_grid interface
381set(huvmat,'UserData',UvData)%update the data in the uvmat interface
382
383
384% --- Executes on button press in MenuCoord.
385function MenuCoord_Callback(hObject, eventdata, handles)
386
387
388%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
389% --- Executes on button press in delete.
390function delete_Callback(hObject, eventdata, handles)
391
392%SetData=get(gcbf,'UserData');%get the interface data
393%IndexObj=SetData.IndexObj;
394huvmat=findobj('Name','uvmat');%find the current uvmat interface handle
395UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
396if isfield(UvData,'CurrentObjectIndex')
397    IndexObj=UvData.CurrentObjectIndex;
398else
399    IndexObj=[];
400end
401delete_object(IndexObj);
402
403%----------------------------------------------------
404function YMin_Callback(hObject, eventdata, handles)
405% hObject    handle to YMin (see GCBO)
406% eventdata  reserved - to be defined in a future version of MATLAB
407% handles    structure with handles and user data (see GUIDATA)
408
409% Hints: get(hObject,'String') returns contents of YMin as text
410%        str2double(get(hObject,'String')) returns contents of YMin as a double
411
412
413function ZMin_Callback(hObject, eventdata, handles)
414
415
416function ZMax_Callback(hObject, eventdata, handles)
417DZ=str2num(get(handles.ZMax,'String'));
418ZMin=get(handles.z_slider,'Min');
419ZMax=get(handles.z_slider,'Max');
420rel_step(1)=DZ/(ZMax-ZMin);
421rel_step(2)=0.2;
422set(handles.z_slider,'SliderStep',rel_step)
423
424function YMax_Callback(hObject, eventdata, handles)
425
426
427function XMin_Callback(hObject, eventdata, handles)
428
429
430function XMax_Callback(hObject, eventdata, handles)
431
432
433% ------------------------------------------------------
434function save_Callback(hObject, eventdata, handles)
435% ------------------------------------------------------
436Object=read_set_object(handles);%read the set_grid interface;
437DX=Object.DX;
438DY=Object.DY;
439RangeX=Object.RangeX;
440RangeY=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);
449 
450imageA=get(handles.image_1,'String');
451imageB=get(handles.image_2,'String');
452testB=1;
453if isempty(imageA) || isequal(imageA,'')
454    if isempty(imageB) || isequal(imageB,'')
455        msgbox_uvmat('ERROR','at least one image file name must be introduced')
456    else
457        imageA=imageB;
458        testB=0;
459    end
460end
461if isempty(imageB) || isequal(imageB,'') || isequal(imageA,imageB)
462    testB=0;
463end
464
465testexist=exist(imageA,'file');
466if isequal(testexist,0)
467    msgbox_uvmat('ERROR',['input image file' imageA 'does not exist'])
468    return
469end
470[Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(imageA);
471form=imformats(ext(2:end));
472if isempty(form)% if the extension corresponds to an image format recognized by Matlab
473     msgbox_uvmat('ERROR',['error: ' imageA ' is not an image name recognized by Matlab '])
474     return
475end
476fileAxml=[fullfile(Pathsub,RootFile) '.xml'];
477[XmlDataA,error]=imadoc2struct(fileAxml);
478if isfield(XmlDataA,'GeometryCalib')
479     tsaiA=XmlDataA.GeometryCalib;
480 else
481     msgbox_uvmat('WARNING','no geometric calibration available for image A')
482     tsaiA=[];
483end
484size(grid_real)
485tsaiA
486if isempty(tsaiA)
487    grid_imaA(:,1)=grid_real(:,1);
488    grid_imaA(:,2)=grid_real(:,2);
489else
490    [grid_imaA(:,1),grid_imaA(:,2)]=px_XYZ(tsaiA,grid_real(:,1),grid_real(:,2),0);
491end
492    A=imread(imageA);
493   siz=size(A);
494   npxA=siz(2);
495   npyA=siz(1);
496
497flagA=grid_imaA(:,1)>0 & grid_imaA(:,1)<npxA & grid_imaA(:,2)>0 & grid_imaA(:,2)<npyA;
498
499if testB
500    testexist=exist(imageB,'file');
501    if isequal(testexist,0)
502        msgbox_uvmat('ERROR',['input image file' imageB 'does not exist'])
503        return
504    end
505    [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(imageB);
506    form=imformats(ext([2:end]));
507    if isempty(form)% if the extension corresponds to an image format recognized by Matlab
508         msgbox_uvmat('ERROR',['error: ' imageB ' is not an image name recognized by Matlab '])
509         return
510    end
511    fileBxml=[fullfile(Pathsub,RootFile) '.xml'];
512    [XmlDataB,error]=imadoc2struct(fileBxml);
513    if isfield(XmlDataB,'GeometryCalib')
514     tsaiB=XmlDataB.GeometryCalib;
515    else
516     msgbox_uvmat('WARNING','no geometric calibration available for image B')
517     tsaiB=[];
518 end
519    %[error,Heading,nom_type_read,ext_ima_read,time,TimeUnit,mode,NbSlice,...
520    %     npxB,npyB,tsaiB]=read_imadoc(fileBxml,0);
521    [grid_imaB(:,1),grid_imaB(:,2)]=px_XYZ(tsaiB,grid_real(:,1),grid_real(:,2),0);
522%     if isempty(npxB)|isempty(npyB)
523        B=imread(imageB);
524       siz=size(B);
525       npxB=siz(2);
526       npyB=siz(1);
527%     end
528    flagB=grid_imaB(:,1)>0 & grid_imaB(:,1)<npxB & grid_imaB(:,2)>0 & grid_imaB(:,2)<npyB;
529end
530if testB
531    ind_good=find(flagA==1&flagB==1);
532    XimaB=grid_imaB(ind_good,1);
533    YimaB=grid_imaB(ind_good,2);
534else
535    ind_good=find(flagA==1);
536end
537XimaA=grid_imaA(ind_good,1);
538YimaA=grid_imaA(ind_good,2);
539
540grid_real_x=grid_real(ind_good,1);
541grid_real_y=grid_real(ind_good,2);
542nx_patch_new=length(grid_real_x);
543grid_real2(:,1)=grid_real_x;
544grid_real2(:,2)=grid_real_y;
545grid_real2(:,3)=zeros(nx_patch_new,1);
546if isempty(tsaiA)
547    grid_pix_A(:,1)=grid_real2(:,1);
548   grid_pix_A(:,2)= grid_real2(:,2);
549else
550    [grid_pix_A(:,1),grid_pix_A(:,2)]=px_XYZ(tsaiA,grid_real2(:,1),grid_real2(:,2));
551end
552if testB
553    [grid_pix_B(:,1),grid_pix_B(:,2)]=px_XYZ(tsaiB,grid_real2(:,1),grid_real2(:,2));
554end
555
556 %ECRIRE FICHIERS
557nbpointsA=size(grid_pix_A);
558XA=grid_pix_A(:,1);
559YA=grid_pix_A(:,2);
560unitcolumn=32*ones(size(XA));
561Xchar=num2str(XA);
562blanc=char(unitcolumn);
563Ychar=num2str(YA);
564tete=['1 ' num2str(nbpointsA(1))];
565txt=[Xchar blanc Ychar];
566textgrid={tete;txt};
567textout=char(textgrid);
568Answer = 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');
570dlmwrite(Answer,textout,'');
571msgbox_uvmat('CONFIRMATION',[Answer ' written as ASCII text file']);
572if 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']);
587end
588
589
590% --- Executes on slider movement.
591function z_slider_Callback(hObject, eventdata, handles)
592%A ADAPTER
593Z_value=get(handles.z_slider,'Value');
594
595%rotation angles
596Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian
597Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian
598
599%components of the unity vector normal to the projection plane
600NormVec_X=-sin(Phi)*sin(Theta);
601NormVec_Y=cos(Phi)*sin(Theta);
602NormVec_Z=cos(Theta);
603
604%set new plane position and update graph
605set(handles.XObject,'String',num2str(NormVec_X*Z_value))
606set(handles.YObject,'String',num2str(NormVec_Y*Z_value))
607set(handles.ZObject,'String',num2str(NormVec_Z*Z_value))
608edit_Callback(hObject, eventdata, handles)
609
610
611
612function XObject_Callback(hObject, eventdata, handles)
613
614
615function YObject_Callback(hObject, eventdata, handles)
616
617
618
619
620function ZObject_Callback(hObject, eventdata, handles)
621
622
623function 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
633function 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
642% --- Executes on button press in HELP.
643function HELP_Callback(hObject, eventdata, handles)
644path_to_uvmat=which ('uvmat');% check the path of uvmat
645pathelp=fileparts(path_to_uvmat);
646helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
647if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
648else
649web([helpfile '#set_grid'])   
650end
651
Note: See TracBrowser for help on using the repository browser.