source: trunk/src/set_grid.m @ 35

Last change on this file since 35 was 2, checked in by gostiaux, 15 years ago
  • Initial import
  • Add .m files in src
  • Add .fig files in src
  • Add .xml config files
File size: 23.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);
290%Display title
291title=set_title(s.Style,s.ProjMode);%update the title
292% menu=get(handles.TITLE,'String')
293% for iline=1:length(menu)
294%      if isequal(menu{iline},title)
295%          set(handles.TITLE,'Value',iline)
296%          break
297%      end
298% end
299% TITLE_Callback(hObject, eventdata, handles)
300% teststyle=0;
301% if isfield(s,'Style')
302%         menu=get(handles.ObjectStyle,'String');
303%         for iline=1:length(menu)
304%             if isequal(menu{iline},s.Style)
305%                 set(handles.ObjectStyle,'Value',iline)
306%                 teststyle=1;
307%                 break
308%             end
309%         end
310% end
311% if teststyle==0;
312%        s.Style='points';
313%        set(handles.ObjectStyle,'Value',1); %default (points)
314% end
315testmode=0;
316if isfield(s,'ProjMode')
317        menu=get(handles.ProjMode,'String');
318        for iline=1:length(menu)
319            if isequal(menu{iline},s.ProjMode)
320                set(handles.ProjMode,'Value',iline)
321                testmode=1;
322                break
323            end
324        end
325end
326
327ProjMode_Callback(hObject, eventdata, handles);%visualize the appropriate edit boxes
328if isfield(s,'CoordType')
329    if isequal(s.CoordType,'phys')
330        set(handles.MenuCoord,'Value',1)
331    elseif isequal(s.CoordType,'px')
332        set(handles.MenuCoord,'Value',2)
333    else
334        warndlg('unknown CoordType (px or phys) in set_grid.m')
335    end
336end
337if isfield(s,'XMax')
338    set(handles.XMax,'String',s.XMax)
339end
340if isfield(s,'XMin')
341    set(handles.XMin,'String',s.XMin)
342end
343if isfield(s,'YMax')
344    set(handles.YMax,'String',s.YMax)
345end
346if isfield(s,'YMin')
347    set(handles.YMin,'String',s.YMin)
348end
349if isfield(s,'DX')
350    set(handles.DX,'String',s.DX)
351end
352if isfield(s,'DY')
353    set(handles.DY,'String',s.DY)
354end
355if ~isfield(s,'Coord')
356    XObject='0';%default
357    YObject='0';
358elseif ischar(s.Coord)
359    line=str2num(s.Coord);
360    XObject=num2str(line(1));
361    YObject=num2str(line(2));
362else
363    for i=1:length(s.Coord)
364        line=str2num(s.Coord{i});
365        XObject{i}=num2str(line(1));
366        YObject{i}=num2str(line(2));
367    end
368end
369set(handles.XObject,'String',XObject)
370set(handles.YObject,'String',YObject)
371%METTRA A JOUR ASPECT DE L'INTERFACE (COMME set_grid_Opening
372
373%----------------------------------------------------
374% executed when closing: set the parent interface button to value 0
375function closefcn(gcbo,eventdata)
376huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
377parent_button=findobj(huvmat,'Tag','grid');
378if ~isempty(parent_button)
379    set(parent_button,'Value',0)%put unactivated buttons to green
380    tag=get(parent_button,'Tag');
381    if isequal(tag,'edit')
382        set(parent_button,'BackgroundColor',[0.7 0.7 0.7]);
383    else
384        set(parent_button,'BackgroundColor',[0 1 0]);
385    end
386end
387
388%-----------------------------------------------------------------------
389% --- Executes on button press in edit: PLOT the defined object and its projected field
390function edit_Callback(hObject, eventdata, handles)
391hsetobject=get(hObject,'parent');
392SetData=get(hsetobject,'UserData');%get the hidden interface data
393%IndexObj=SetData.IndexObj%index of the current projection object in the list of projection objects (UvData.ProjObject)
394huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle
395UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
396if isfield(UvData,'CuurentObjectIndex')
397    IndexObj=UvData.CurrentObjectIndex;
398else
399    IndexObj=[];
400end
401ObjectData=read_set_grid(handles);%read the interface input parameters defining the object
402[UvData,IndexObj]=update_obj(UvData,IndexObj,ObjectData,SetData.PlotHandles);
403uvmat('write_plot_param',PlotHandles,UvData.Object{IndexObj}.PlotParam); %update the display of plotting parameters for the current object
404SetData.IndexObj=IndexObj;
405set(gcbf,'UserData',SetData)%update object index in the set_grid interface
406set(huvmat,'UserData',UvData)%update the data in the uvmat interface
407
408
409% --- Executes on button press in MenuCoord.
410function MenuCoord_Callback(hObject, eventdata, handles)
411
412
413%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
414% --- Executes on button press in delete.
415function delete_Callback(hObject, eventdata, handles)
416
417%SetData=get(gcbf,'UserData');%get the interface data
418%IndexObj=SetData.IndexObj;
419huvmat=findobj('Name','uvmat');%find the current uvmat interface handle
420UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
421if isfield(UvData,'CurrentObjectIndex')
422    IndexObj=UvData.CurrentObjectIndex;
423else
424    IndexObj=[];
425end
426delete_object(IndexObj);
427
428%----------------------------------------------------
429function YMin_Callback(hObject, eventdata, handles)
430% hObject    handle to YMin (see GCBO)
431% eventdata  reserved - to be defined in a future version of MATLAB
432% handles    structure with handles and user data (see GUIDATA)
433
434% Hints: get(hObject,'String') returns contents of YMin as text
435%        str2double(get(hObject,'String')) returns contents of YMin as a double
436
437
438function ZMin_Callback(hObject, eventdata, handles)
439
440
441function ZMax_Callback(hObject, eventdata, handles)
442DZ=str2num(get(handles.ZMax,'String'));
443ZMin=get(handles.z_slider,'Min');
444ZMax=get(handles.z_slider,'Max');
445rel_step(1)=DZ/(ZMax-ZMin);
446rel_step(2)=0.2;
447set(handles.z_slider,'SliderStep',rel_step)
448
449function YMax_Callback(hObject, eventdata, handles)
450
451
452function XMin_Callback(hObject, eventdata, handles)
453
454
455function XMax_Callback(hObject, eventdata, handles)
456
457
458% ------------------------------------------------------
459function save_Callback(hObject, eventdata, handles)
460% ------------------------------------------------------
461Object=read_set_object(handles);%read the set_grid interface;
462DX=Object.DX;
463DY=Object.DY;
464RangeX=Object.RangeX;
465RangeY=Object.RangeY;
466 array_realx=[RangeX(2):DX:RangeX(1)];
467 array_realy=[RangeY(2):DY:RangeY(1)];
468 nx_patch=length(array_realx);
469 ny_patch=length(array_realy);
470 [grid_realx,grid_realy]=meshgrid(array_realx,array_realy);
471 grid_real(:,1)=reshape(grid_realx,nx_patch*ny_patch,1);
472 grid_real(:,2)=reshape(grid_realy,nx_patch*ny_patch,1);
473 grid_real(:,3)=zeros(nx_patch*ny_patch,1);
474 
475imageA=get(handles.image_1,'String');
476imageB=get(handles.image_2,'String');
477testB=1;
478if isempty(imageA) | isequal(imageA,'')
479    if isempty(imageB) | isequal(imageB,'')
480        warndlg_uvmat('at least one image file name must be introduced','ERROR')
481    else
482        imageA=imageB;
483        testB=0;
484    end
485end
486if isempty(imageB) || isequal(imageB,'') || isequal(imageA,imageB)
487    testB=0;
488end
489
490testexist=exist(imageA,'file');
491if isequal(testexist,0)
492    msgbox_uvmat('ERROR',['input image file' imageA 'does not exist'])
493    return
494end
495[Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(imageA);
496form=imformats(ext([2:end]));
497if isempty(form)% if the extension corresponds to an image format recognized by Matlab
498     msgbox_uvmat('ERROR',['error in read_image.m: ' imageA ' is not an image name recognized by Matlab '])
499     return
500end
501fileAxml=[fullfile(Pathsub,RootFile) '.xml'];
502[XmlDataA,error]=imadoc2struct(fileAxml);
503if isfield(XmlDataA,'GeometryCalib')
504     tsaiA=XmlDataA.GeometryCalib;
505 else
506     msgbox_uvmat('WARNING','no geometric calibration available for image A')
507     tsaiA=[];
508end
509[grid_imaA(:,1),grid_imaA(:,2)]=px_XYZ(tsaiA,grid_real(:,1),grid_real(:,2),0);
510    A=imread(imageA);
511   siz=size(A);
512   npxA=siz(2);
513   npyA=siz(1);
514
515flagA=grid_imaA(:,1)>0 & grid_imaA(:,1)<npxA & grid_imaA(:,2)>0 & grid_imaA(:,2)<npyA;
516
517if testB
518    testexist=exist(imageB,'file');
519    if isequal(testexist,0)
520        warndlg_uvmat(['input image file' imageB 'does not exist'],'ERROR')
521        return
522    end
523    [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(imageB);
524    form=imformats(ext([2:end]));
525    if isempty(form)% if the extension corresponds to an image format recognized by Matlab
526         warndlg_uvmat(['error in read_image.m: ' imageB ' is not an image name recognized by Matlab '],'ERROR')
527         return
528    end
529    fileBxml=[fullfile(Pathsub,RootFile) '.xml'];
530    [XmlDataB,error]=imadoc2struct(fileBxml);
531    if isfield(XmlDataB,'GeometryCalib')
532     tsaiB=XmlDataB.GeometryCalib;
533    else
534     warndlg_uvmat('no geometric calibration available for image B','WARNING')
535     tsaiB=[];
536 end
537    %[error,Heading,nom_type_read,ext_ima_read,time,TimeUnit,mode,NbSlice,...
538    %     npxB,npyB,tsaiB]=read_imadoc(fileBxml,0);
539    [grid_imaB(:,1),grid_imaB(:,2)]=px_XYZ(tsaiB,grid_real(:,1),grid_real(:,2),0);
540%     if isempty(npxB)|isempty(npyB)
541        B=imread(imageB);
542       siz=size(B);
543       npxB=siz(2);
544       npyB=siz(1);
545%     end
546    flagB=grid_imaB(:,1)>0 & grid_imaB(:,1)<npxB & grid_imaB(:,2)>0 & grid_imaB(:,2)<npyB;
547end
548if testB
549    ind_good=find(flagA==1&flagB==1);
550    XimaB=grid_imaB(ind_good,1);
551    YimaB=grid_imaB(ind_good,2);
552else
553    ind_good=find(flagA==1);
554end
555XimaA=grid_imaA(ind_good,1);
556YimaA=grid_imaA(ind_good,2);
557
558grid_real_x=grid_real(ind_good,1);
559grid_real_y=grid_real(ind_good,2);
560nx_patch_new=length(grid_real_x);
561grid_real2(:,1)=grid_real_x;
562grid_real2(:,2)=grid_real_y;
563grid_real2(:,3)=zeros(nx_patch_new,1);
564[grid_pix_A(:,1),grid_pix_A(:,2)]=px_XYZ(tsaiA,grid_real2(:,1),grid_real2(:,2));
565if testB
566    [grid_pix_B(:,1),grid_pix_B(:,2)]=px_XYZ(tsaiB,grid_real2(:,1),grid_real2(:,2));
567end
568
569 %ECRIRE FICHIERS
570nbpointsA=size(grid_pix_A);
571XA=grid_pix_A(:,1);
572YA=grid_pix_A(:,2);
573unitcolumn=32*ones(size(XA));
574Xchar=num2str(XA);
575blanc=char(unitcolumn);
576Ychar=num2str(YA);
577tete=['1 ' num2str(nbpointsA(1))];
578txt=[Xchar blanc Ychar];
579textgrid={tete;txt};
580textout=char(textgrid);
581Answer = msgbox_uvmat('INPUT_TXT','grid file name (*.grid)',fullfile(Pathsub,'gridA.grid'));
582% Answer = inputdlg('grid file name (*.grid)',' ',1,{fullfile(Pathsub,'gridA.grid')},'on');
583dlmwrite(Answer,textout,'');
584msgbox_uvmat('CONFIRMATION',[Answer ' written as ASCII text file']);
585if testB
586    nbpointsB=size(grid_pix_B);
587    XB=grid_pix_B(:,1);
588    YB=grid_pix_B(:,2);
589    unitcolumn=32*ones(size(XB));
590    Xchar=num2str(XB);
591    blanc=char(unitcolumn);
592    Ychar=num2str(YB);
593    tete=['1 ' num2str(nbpointsB(1))];
594    txt=[Xchar blanc Ychar];
595    textgrid={tete;txt};
596    textout=char(textgrid);
597    Answer = msgbox_uvmat('INPUT_TXT','grid file name (*.grid)',fullfile(Pathsub,'gridB.grid'));
598    dlmwrite(Answer,textout,'');
599    msgbox_uvmat('CONFIRMATION',[Answer ' written as ASCII text file']);
600end
601
602
603%------------------------------------------------
604function TITLE=set_title(Style,ProjMode)
605%------------------------------------------------
606if isequal(Style,'points')
607    TITLE='POINTS';
608elseif isequal(Style,'line')|isequal(Style,'polyline')
609    TITLE='LINE';
610elseif isequal(Style,'plane')
611    TITLE='PLANE';
612elseif isequal(Style,'volume')
613    TITLE='VOLUME';
614elseif isequal(Style,'polygon')|isequal(Style,'rectangle')|isequal(Style,'ellipse')
615    if isequal(ProjMode,'inside')|isequal(ProjMode,'outside')
616        TITLE='PATCH';
617    else
618        TITLE='LINE';
619    end
620end
621
622
623% --- Executes on slider movement.
624function z_slider_Callback(hObject, eventdata, handles)
625%A ADAPTER
626Z_value=get(handles.z_slider,'Value');
627
628%rotation angles
629Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian
630Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian
631
632%components of the unity vector normal to the projection plane
633NormVec_X=-sin(Phi)*sin(Theta);
634NormVec_Y=cos(Phi)*sin(Theta);
635NormVec_Z=cos(Theta);
636
637%set new plane position and update graph
638set(handles.XObject,'String',num2str(NormVec_X*Z_value))
639set(handles.YObject,'String',num2str(NormVec_Y*Z_value))
640set(handles.ZObject,'String',num2str(NormVec_Z*Z_value))
641edit_Callback(hObject, eventdata, handles)
642
643
644
645function XObject_Callback(hObject, eventdata, handles)
646
647
648function YObject_Callback(hObject, eventdata, handles)
649
650
651
652
653function ZObject_Callback(hObject, eventdata, handles)
654
655
656function image_2_Callback(hObject, eventdata, handles)
657% hObject    handle to image_2 (see GCBO)
658% eventdata  reserved - to be defined in a future version of MATLAB
659% handles    structure with handles and user data (see GUIDATA)
660
661% Hints: get(hObject,'String') returns contents of image_2 as text
662%        str2double(get(hObject,'String')) returns contents of image_2 as a double
663
664
665
666function image_1_Callback(hObject, eventdata, handles)
667% hObject    handle to image_1 (see GCBO)
668% eventdata  reserved - to be defined in a future version of MATLAB
669% handles    structure with handles and user data (see GUIDATA)
670
671% Hints: get(hObject,'String') returns contents of image_1 as text
672%        str2double(get(hObject,'String')) returns contents of image_1 as a double
673
674
675% --- Executes on button press in HELP.
676function HELP_Callback(hObject, eventdata, handles)
677path_to_uvmat=which ('uvmat');% check the path of uvmat
678pathelp=fileparts(path_to_uvmat);
679helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
680if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
681else
682web([helpfile '#set_grid'])   
683end
684
Note: See TracBrowser for help on using the repository browser.