source: trunk/src/view_field.m @ 60

Last change on this file since 60 was 60, checked in by sommeria, 14 years ago

-plot projections on a new specific GUI view_field, to avoid the multiplication of active figures
-introduce a ruler in uvmat (in menu/Tools), to measure distances and angles
-insert automatic detection of points for geometric calibration: tool 'detect_grid'. Four points, deliminating the grid to determine, must be marked with the mouse, as well as the physical grid. Then the points inside are automatically detected.
-reading plane positions in ImaDoc? improved to deal with volume scans

File size: 136.5 KB
Line 
1
2%'view_field': function associated with the GUI 'view_field.fig' for images and data field visualization
3%------------------------------------------------------------------------
4% function huvmat=view_field(input)
5%
6%OUTPUT
7% huvmat=current handles of the GUI view_field.fig
8%%
9%
10%INPUT:
11% input: input file name (if character chain), or input image matrix to
12% visualize, or Matlab structure representing  netcdf fields (with fields
13% ListVarName....)
14%
15%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
16%  Copyright Joel Sommeria,  2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr.
17%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
18%     This open is part of the toolbox VIEW_FIELD.
19%
20%     VIEW_FIELD is free software; you can redistribute it and/or modify
21%     it under the terms of the GNU General Public License as published by
22%     the Free Software Foundation; either version 2 of the License, or
23%     (at your option) any later version.
24%
25%     VIEW_FIELD is distributed in the hope that it will be useful,
26%     but WITHOUT ANY WARRANTY; without even the implied warranty of
27%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28%     GNU General Public License (open VIEW_FIELD/COPYING.txt) for more details.
29%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
30
31%-------------------------------------------------------------------
32%  I - MAIN FUNCTION VIEW_FIELD (DO NOT MODIFY)
33%-------------------------------------------------------------------
34%-------------------------------------------------------------------
35function varargout = view_field(varargin)
36
37% Begin initialization code - DO NOT EDIT
38gui_Singleton = 1;
39gui_State = struct('gui_Name',          mfilename, ...
40                   'gui_Singleton',     gui_Singleton, ...
41                   'gui_OpeningFcn',    @view_field_OpeningFcn, ...
42                   'gui_OutputFcn',     @view_field_OutputFcn, ...
43                   'gui_LayoutFcn',     [], ...
44                   'gui_Callback',      []);
45if nargin && ischar(varargin{1})
46    gui_State.gui_Callback = str2func(varargin{1});
47end
48
49if nargout
50    varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
51else
52    gui_mainfcn(gui_State, varargin{:});
53end
54% End initialization code - DO NOT EDIT
55
56%-------------------------------------------------------------------
57% --- Executes just before view_field is made visible.
58function view_field_OpeningFcn(hObject, eventdata, handles, Field )
59%-------------------------------------------------------------------
60
61% Choose default command menuline output for view_field
62handles.output = handles.axes3;
63
64% Update handles structure
65guidata(hObject, handles);
66
67dircur=pwd; %current working directory
68dir_opening=dircur;
69
70% set the position of colorbar and ancillary GUIs:
71set(hObject,'Units','Normalized')
72movegui(hObject,'center')
73UvData.PosColorbar=[0.805 0.022 0.019 0.445];
74UvData.SetObjectOrigin=[-0.05 -0.03]; %position for set_object
75UvData.SetObjectSize=[0.3 0.7];
76UvData.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)
77UvData.CalSize=[0.28 1];
78handles_mouse=handles;
79huvmat=findobj(allchild(0),'Name','uvmat');
80hhuvmat=guidata(huvmat);
81handles_mouse.create=hhuvmat.create;
82handles_mouse.edit=hhuvmat.edit;
83
84%functions for the mouse and keyboard
85set(hObject,'KeyPressFcn',{'keyboard_callback',handles_mouse})%set keyboard action function
86set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles_mouse})%set mouse action functio
87set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
88set(hObject,'WindowButtonUpFcn',{'mouse_up',handles_mouse})
89
90
91[PlotType,PlotParamOut,haxes]= plot_field(Field,handles.axes3)%,PlotParam,KeepLim,PosColorbar)
92%-------------------------------------------------------------------
93% --- Outputs from this function are returned to the command menuline.
94function varargout = view_field_OutputFcn(hObject, eventdata, handles)
95varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
96
97%-------------------------------------------------------------------
98%-------------------------------------------------------------------
99% II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
100% automatically sets the global properties when the rootfile name is introduced
101% then activate the view-field action if selected
102% it is activated either by clicking on the RootPath window or by the
103% browser
104%------------------------------------------------------------------
105%------------------------------------------------------------------
106
107%-------------------------------------------------------------------
108function update_mask(handles,num_i1,num_j1)
109%-------------------------------------------------------------------
110
111MaskData=get(handles.mask_test,'UserData');
112if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
113    uistack(MaskData.maskhandle,'top');
114end
115num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
116[MaskName,mdetect]=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
117huvmat=get(handles.mask_test,'parent');
118UvData=get(huvmat,'UserData');
119
120%update mask image if the mask is new
121if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
122    UvData.MaskName=MaskName; %update the recorded name on UvData
123    set(huvmat,'UserData',UvData);
124    if mdetect==0
125        if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
126            delete(MaskData.maskhandle)   
127        end
128    else
129        %read mask image
130        Mask.AName='image';
131        Mask.A=imread(MaskName);
132        npxy=size(Mask.A);
133        Mask.AX=[0.5 npxy(2)-0.5];
134        Mask.AY=[npxy(1)-0.5 0.5 ];
135        Mask.CoordType='px';
136        if isequal(get(handles.slices,'Value'),1)
137           NbSlice=str2num(get(handles.nb_slice,'String'));
138           num_i1=str2num(get(handles.i1,'String'));
139           Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
140        end
141        %px to phys or other transform on field
142         menu_transform=get(handles.transform_fct,'String');
143        choice_value=get(handles.transform_fct,'Value');
144        transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
145        transform_list=get(handles.transform_fct,'UserData');
146        transform=transform_list{choice_value};
147        if  ~isequal(transform_name,'') && ~isequal(transform_name,'px')
148            if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
149                Calib=UvData.XmlData.GeometryCalib;
150                Mask=transform(Mask,UvData.XmlData);
151            end
152        end
153        flagmask=Mask.A < 200;
154       
155        %make brown color image
156        imflag(:,:,1)=0.9*flagmask;
157        imflag(:,:,2)=0.7*flagmask;
158        imflag(:,:,3)=zeros(size(flagmask));
159       
160        %update mask image
161        hmask=[]; %default
162        if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
163            hmask=MaskData.maskhandle;
164        end
165        if ~isempty(hmask)
166            set(hmask,'CData',imflag)   
167            set(hmask,'AlphaData',flagmask*0.6)
168            set(hmask,'XData',Mask.AX);
169            set(hmask,'YData',Mask.AY);
170%             uistack(hmask,'top')
171        else
172            axes(handles.axes3)
173            hold on   
174            MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
175%             set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
176            set(handles.mask_test,'UserData',MaskData)
177        end
178    end
179end
180
181
182%-------------------------------------------------------------------
183function MenuExportFigure_Callback(hObject, eventdata, handles)
184%-------------------------------------------------------------------
185huvmat=get(handles.MenuExport,'parent');
186UvData=get(huvmat,'UserData');
187hfig=figure;
188newaxes=copyobj(handles.axes3,hfig);
189map=colormap(handles.axes3);
190colormap(map);%transmit the current colormap to the zoom fig
191colorbar
192
193%-------------------------------------------------------------------
194%-------------------------------------------------------------------
195% III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
196%-------------------------------------------------------------------
197%-------------------------------------------------------------------
198
199%Executes on button press in runplus: make one step forward and call
200%run0. The step forward is along the fields series 1 or 2 depending on
201%the scan_i and scan_j check box (exclusive each other)
202%-------------------------------------------------------------------
203function runplus_Callback(hObject, eventdata, handles)
204increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
205runpm(hObject,eventdata,handles,increment)
206
207%-------------------------------------------------------------------
208%Executes on button press in runmin: make one step backward and call
209%run0. The step backward is along the fields series 1 or 2 depending on
210%the scan_i and scan_j check box (exclusive each other)
211%-------------------------------------------------------------------
212function runmin_Callback(hObject, eventdata, handles)
213increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
214runpm(hObject,eventdata,handles,increment)
215
216%-------------------------------------------------------------------
217%Executes on button press in runmin: make one step backward and call
218%run0. The step backward is along the fields series 1 or 2 depending on
219%the scan_i and scan_j check box (exclusive each other)
220%-------------------------------------------------------------------
221function RunMovie_Callback(hObject, eventdata, handles)
222%------------------------------------------------------------------
223set(handles.RunMovie,'BackgroundColor',[1 1 0])%paint the command button in yellow
224drawnow
225increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
226set(handles.STOP,'Visible','on')
227set(handles.speed,'Visible','on')
228set(handles.speed_txt,'Visible','on')
229set(handles.RunMovie,'BusyAction','queue')
230testavi=0;
231UvData=get(handles.view_field,'UserData');
232
233while get(handles.speed,'Value')~=0 & isequal(get(handles.RunMovie,'BusyAction'),'queue') % enable STOP command
234        runpm(hObject,eventdata,handles,increment)
235        pause(1.02-get(handles.speed,'Value'))% wait for next image
236end
237if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
238    UvData.aviobj=close(UvData.aviobj);
239   set(handles.view_field,'UserData',UvData);
240end
241set(handles.RunMovie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
242
243%-------------------------------------------------------------------
244function STOP_Callback(hObject, eventdata, handles)
245%-------------------------------------------------------------------
246set(handles.movie_pair,'BusyAction','Cancel')
247set(handles.movie_pair,'value',0)
248set(handles.RunMovie,'BusyAction','Cancel')
249set(handles.MenuExportMovie,'BusyAction','Cancel')
250
251
252%------------------------------------------------------------------
253function runpm(hObject,eventdata,handles,increment)
254%------------------------------------------------------------------
255%check for mùovie pair status
256movie_status=get(handles.movie_pair,'Value');
257if isequal(movie_status,1)
258    STOP_Callback(hObject, eventdata, handles)
259end
260%read the data on the current input rootfile(s)
261
262[FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
263NomType=get(handles.FileIndex,'UserData');
264
265num1=stra2num(get(handles.i1,'String'));
266num2=stra2num(get(handles.i2,'String'));
267num_a=stra2num(get(handles.j1,'String'));
268num_b=stra2num(get(handles.j2,'String'));
269
270sub_value= get(handles.SubField,'Value');
271if sub_value ==1
272    [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
273end   
274
275comp_input=get(handles.fix_pair,'Value');
276if isequal(NomType,'_i1-i2')|isequal(NomType,'_i1-i2_j')
277    comp_input=1; %impose a fixed pair interval
278    set(handles.fix_pair,'Value',1)
279end
280
281%case of scanning along the first direction (rootfile numbers)
282if get(handles.scan_i,'Value')==1% case of scanning along field numbers   
283     num1=num1+increment;
284     num2=num2+increment;
285    if comp_input==0% find a free pair
286        [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out]=...
287           name_generator(filebase,num1,num_a,FileExt,NomType,0,num2,num_b,subdir);
288        if exist(filename,'file')
289            num_a=num_j1_out;
290            num_b=num_j2_out;
291        end
292    end
293    if sub_value>=2
294        num_i1=num_i1+increment;
295        num_i2=num_i2+increment;
296    end   
297else % case of scanning along the second direction (burst numbers)
298    lastfield_cell=get(handles.last_j,'String'); % get the last field number
299    lastfield=str2num(lastfield_cell{1});
300    num_a=num_a+increment;
301    num_b=num_b+increment;
302    if sub_value >=2
303      num_j1=num_j1+increment;
304      num_j2=num_j2+increment;
305    elseif ~isempty(lastfield) && num_a>lastfield
306        num_a=1;
307        num1=num1+1;
308        num2=num2+1;
309    end
310end
311
312% display the new open numbers
313set(handles.i1,'String',num2stra(num1,NomType,1));
314set(handles.i2,'String',num2stra(num2,NomType,1));
315set(handles.j1,'String',num2stra(num_a,NomType,2));
316set(handles.j2,'String',num2stra(num_b,NomType,2));
317[indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
318set(handles.FileIndex,'String',indices);
319if sub_value ==1
320    NomType_1=get(handles.FileIndex_1,'UserData');
321     [indices]=...
322           name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
323     set(handles.FileIndex_1,'String',indices);
324end
325
326if isequal(movie_status,1)
327    set(handles.movie_pair,'Value',1)
328    movie_pair_Callback(hObject, eventdata, handles); %run
329else
330% refresh plots
331    run0_Callback(hObject, eventdata, handles); %run
332end
333
334
335%-------------------------------------------------------
336% --- Executes on button press in movie_pair: create an alternating movie with two view
337%-------------------------------------------------------
338function movie_pair_Callback(hObject, eventdata, handles)
339status=get(handles.movie_pair,'value');
340if isequal(status,0)
341    set(handles.movie_pair,'BusyAction','Cancel')
342    return
343else
344    set(handles.movie_pair,'BusyAction','queue')
345end
346%initialisation
347set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
348drawnow
349list_fields=get(handles.Fields,'String');% list menu fields
350index_fields=get(handles.Fields,'Value');% selected string index
351FieldName=list_fields{index_fields}; % selected field
352if isequal(FieldName,'image')
353    run0_Callback(hObject, eventdata, handles)%display the first image
354    UvData=get(handles.view_field,'UserData');
355else
356    msgbox_view_field('ERROR','an image or movie must be first introduced as input')
357    return
358end
359[ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
360NomType=get(handles.FileIndex,'UserData');
361num_i1=stra2num(get(handles.i1,'String'));
362num_j1=stra2num(get(handles.j1,'String'));
363num_i2=stra2num(get(handles.i2,'String'));
364num_j2=stra2num(get(handles.j2,'String'));
365if isempty(num_j2)
366    if isempty(num_i2)   
367        msgbox_view_field('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
368        return
369    else
370        num_j2=num_j1;%repeat the index i1 by default
371    end
372end
373if isempty(num_i2)
374    num_i2=num_i1;%repeat the index i1 by default
375end
376imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
377if ~exist(imaname_1,'file')
378      msgbox_view_field('ERROR',['second input open (-)  ' imaname_1 ' not found']);
379      return
380end
381% set(handles.i2,'String',''); % indicates that the second index i2 is not used
382% set(handles.j2,'String',''); % indicates that the second index i2 is not used
383
384%read the second image
385Field.AName='image';
386Field.AX=UvData.Field.AX;
387Field.AY=UvData.Field.AY;
388% z index
389nbslice=str2double(get(handles.nb_slice,'String'));
390if ~isempty(nbslice)
391    Field.ZIndex=mod(num_i2-1,nbslice)+1;
392end
393Field.CoordType='px';
394%determine the input file type
395if isfield(UvData,'MovieObject')
396    FileType='movie';
397elseif isequal(lower(Ext),'.avi')
398    FileType='avi';
399elseif isequal(lower(Ext),'.vol')
400    FileType='vol';
401else
402   form=imformats(Ext([2:end]));
403   if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
404       if isequal(NomType,'*');
405           FileType='multimage';
406       else
407           FileType='image';
408       end
409   end
410end
411switch FileType
412        case 'movie'
413            Field.A=read(UvData.MovieObject,num_i2);
414        case 'avi'
415            mov=aviread(imaname_1,num_i2);
416            Field.A=frame2im(mov(1));
417        case 'vol'
418            Field.A=imread(imaname_1);
419        case 'multimage'
420            Field.A=imread(imaname_1,num_i2);
421        case 'image'
422            Field.A=imread(imaname_1);
423end
424
425%px to phys or other transform on field
426menu_transform=get(handles.transform_fct,'String');
427choice_value=get(handles.transform_fct,'Value');
428transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
429transform_list=get(handles.transform_fct,'UserData');
430transform=transform_list{choice_value};
431if  ~isequal(transform_name,'') && ~isequal(transform_name,'px')
432    if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
433        Field=transform(Field,UvData.XmlData);
434    end
435end
436
437 % make movie until movie speed is set to 0 or STOP is activated
438hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
439set(handles.STOP,'Visible','on')
440set(handles.speed,'Visible','on')
441set(handles.speed_txt,'Visible','on')
442while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
443    % read and plot the series of images in non erase mode
444    set(hima,'CData',Field.A);
445    pause(1.02-get(handles.speed,'Value'));% wait for next image
446    set(hima,'CData',UvData.Field.A);
447    pause(1.02-get(handles.speed,'Value'));% wait for next image
448end
449set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
450
451%-------------------------------------------------------
452% --- Executes on button press in run0.
453%-------------------------------------------------
454function run0_Callback(hObject, eventdata, handles)
455
456%initialisation
457set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
458drawnow
459abstime=[];
460abstime_1=[];
461dt=[];
462Field={};
463UvData=get(handles.view_field,'UserData');
464if isfield(UvData,'Txt')
465    UvData=rmfield(UvData,'Txt');%erase previous error message
466end
467%set(handles.run0,'BusyAction','queue');
468if ishandle(handles.VIEW_FIELD_title) %remove title panel on view_field
469    delete(handles.VIEW_FIELD_title)
470end
471
472% determine the main input file information for action
473TestInputFile=1;%default
474if isfield(UvData,'TestInputFile')&& isequal(UvData.TestInputFile,0),
475    TestInputFile=0;
476end
477num_i1=[];%default
478FileType=[];%default
479if TestInputFile
480    [filename,RootPath,filebase,xx,Ext]=read_file_boxes(handles);
481    if ~exist(filename,'file')
482        msgbox_view_field('ERROR',['input file ' filename ' does not exist'])
483        return
484    end
485    num_i1=stra2num(get(handles.i1,'String'));
486    num_i2=stra2num(get(handles.i2,'String'));
487    num_j1=stra2num(get(handles.j1,'String'));
488    num_j2=stra2num(get(handles.j2,'String'));
489    NomType=get(handles.FileIndex,'UserData');
490    %update the z position index
491    nbslice=str2double(get(handles.nb_slice,'String'));
492    if ~isnan(nbslice)
493        z_index=mod(num_i1-1,nbslice)+1;
494        set(handles.z_index,'String',num2str(z_index))
495        % refresh menu for save_mask if relevant
496        masknumber=get(handles.masklevel,'String');
497        if length(masknumber)>=z_index
498            set(handles.masklevel,'Value',z_index)
499        end
500    end
501    % determine the input file type
502    if isequal(Ext,'.nc')||isequal(Ext,'.cdf')
503        FileType='netcdf';
504    elseif isfield(UvData,'MovieObject')
505        FileType='movie';
506        FieldName='image';
507    elseif isequal(lower(Ext),'.avi')
508        FileType='avi';
509        FieldName='image';
510    elseif isequal(lower(Ext),'.vol')
511        FileType='vol';
512        FieldName='image';
513    else
514       form=imformats(Ext([2:end]));
515       if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
516           if isequal(NomType,'*');
517               FileType='multimage';
518           else
519               FileType='image';
520           end
521           FieldName='image';
522       end
523    end
524else
525    filename=[];
526    FileType='netcdf';
527    FieldName='get_field...';
528end
529VelType=[];%default
530if isequal(FileType,'netcdf')
531    list_fields=get(handles.Fields,'String');% list menu fields
532    index_fields=get(handles.Fields,'Value');% selected string index
533    FieldName= list_fields{index_fields}; % selected field
534    if isequal(FieldName,'get_field...')% read the field names on the interface get_field...
535        VelType=get(handles.Fields,'UserData');
536        Field{1}=get(handles.Fields,'UserData');
537    else
538       VelType=setfield(handles);
539    end
540end
541
542% choose a second field if Subfield option is 'on'
543filename_1=[];
544FieldName_1=[];
545scal_color=[];
546VelType_1=setfield_1(handles);
547sub_value=get(handles.SubField,'Value');
548FileType_1='none';%default
549if sub_value==1
550    filename_1=read_file_boxes_1(handles);
551    if ~exist(filename_1,'file')
552        msgbox_view_field('ERROR',['second file ' filename_1 ' does not exist'])
553        return
554    end
555    NomType_1=get(handles.FileIndex_1,'UserData');
556    Ext_1=get(handles.FileExt_1,'String');
557    % determine the input file type
558    if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
559        FileType_1='netcdf';
560    elseif isfield(UvData,'MovieObject_1')
561        FileType_1='movie';
562        FieldName_1='image';
563    elseif isequal(lower(Ext_1),'.avi')
564        FileType='avi';
565        FieldName_1='image';
566    elseif isequal(lower(Ext_1),'.vol')
567        FileType_1='vol';
568        FieldName_1='image';
569    else
570       form=imformats(Ext([2:end]));
571       if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
572           if isequal(NomType_1,'*');
573               FileType_1='multimage';
574           else
575               FileType_1='image';
576           end
577           FieldName_1='image';
578       end
579    end
580    if ~isequal(FieldName_1,'image')
581        list_fields=get(handles.Fields_1,'String');% list menu fields
582        index_fields=get(handles.Fields_1,'Value');% selected string index
583        FieldName_1= list_fields{index_fields}; % selected field
584        if isequal(VelType_1,'*')% free veltype choice
585            VelType_1=[];
586        elseif isequal(VelType_1,'"')% veltype the same as for the first field
587            if isempty(VelType)
588                VelType_1=[];
589            else
590                VelType_1=VelType;
591            end
592        end
593    end
594end
595
596% test for keeping the previous stored data if the input files are unchanged
597test_keepdata_1=0;%defautl
598test_keepdata=0;
599if sub_value>=2
600    if ~isequal(NomType_1,'*')%in cas of a series of files (not avi movie)
601        if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
602            test_keepdata_1= isequal(filename_1,UvData.filename_1)&&...
603                isequal(VelType_1,UvData.filename_1) && isequal(FieldName_1,UvData.FieldName_1);
604
605        end
606    end
607end
608
609%read the input field(s)
610
611%read images
612if ~isempty(filename) && isequal(FieldName,'image')
613     switch FileType
614        case 'movie'
615            A=read(UvData.MovieObject,num_i1);
616        case 'avi'
617            mov=aviread(filename,num_i1);
618            A=frame2im(mov(1));
619        case 'vol'
620            A=imread(filename);
621        case 'multimage'
622            A=imread(filename,num_i1);
623        case 'image'
624            A=imread(filename);
625    end
626    npxy=size(A);
627    set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
628    set(handles.npy,'String',num2str(npxy(1)));
629    Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
630    Rangy=[npxy(1)-0.5 0.5]; %
631    Field{1}.AName='image';
632    Field{1}.ListVarName={'AY','AX','A'}; %
633    if size(A,3)==3;%color
634        Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
635    else
636        Field{1}.VarDimName={'AY','AX',{'AY','AX'}}; %
637    end
638    Field{1}.AY=Rangy;
639    Field{1}.AX=Rangx;
640    Field{1}.A=A;
641    Field{1}.CoordType='px'; %used for mouse_motion
642    Field{1}.CoordUnit='pixel'; %used for mouse_motion
643end
644
645%read a second image
646if ~isfield(UvData,'Txt')&& ~isempty(filename_1) && isequal(FieldName_1,'image')
647    switch FileType_1
648        case 'movie'
649            A=read(UvData.MovieObject_1,num_i1);
650        case 'avi'
651            mov=aviread(filename,num_i1);
652            A=frame2im(mov(1));
653        case 'vol'
654            A=imread(filename);
655        case 'multimage'
656            A=imread(filename,num_i1);
657        case 'image'
658            A=imread(filename);
659    end
660    npxy=size(A);
661    set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
662    set(handles.npy,'String',num2str(npxy(1)));
663    Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
664    Rangy=[npxy(1)-0.5 0.5]; %
665    Field{2}.AName='image';
666    Field{2}.ListVarName={'AY','AX','A'}; %
667    if size(A,3)==3;%color
668        Field{2}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
669    else
670        Field{2}.VarDimName={'AY','AX',{'AY','AX'}}; %
671    end
672    Field{2}.AY=Rangy;
673    Field{2}.AX=Rangx;
674    Field{2}.A=A;
675    Field{2}.CoordType='px'; %used for mouse_motion
676    Field{2}.CoordUnit='px'; %used for move_mou
677end
678
679%read ncfile(s)
680CivStage_1=0;%default
681VelType_out_1=[];
682InputField={FieldName};
683InputField_1={FieldName_1};
684if ~isfield(UvData,'Txt') && ((~isempty(filename)&& isequal(FileType,'netcdf')) || (~isempty(filename_1)&& isequal(FileType,'netcdf'))) ;
685    %read the velocity field(s) from netcdf rootfile(s)
686    list_code=get(handles.col_vec,'String');% list menu fields
687    index_code=get(handles.col_vec,'Value');% selected string index
688    scal_color= list_code{index_code(1)}; % selected field
689    if isequal(FieldName,'velocity')&& ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
690        InputField=[InputField scal_color];
691    end
692    if isequal(FieldName_1,'velocity') && ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
693        InputField_1=[InputField_1 scal_color];
694    end
695    if isequal(FileType,'netcdf')  %read the first nc field
696        if isequal(FieldName,'get_field...')% read the field names on the interface get_field.
697            VelType=get(handles.Fields,'UserData');
698            hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI
699            if isempty(hget_field)
700                hget_field= get_field(filename);%open the get_field GUI   
701            end
702            hhget_field=guidata(hget_field);
703            set(hhget_field.inputfile,'String',filename)% update the list of input fields in get_field
704            set(hhget_field.ACTION,'Value',1)% PLOT option selected
705            set(hhget_field.list_fig,'Value',2)% plotting axes =view_field selected
706            [Field{1},errormsg]=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
707            if ~isempty(errormsg)
708                msgbox_view_field('ERROR',['error in view_field/run0_Callback/read_get_field: ' errormsg])
709                return
710            end
711            CivStage=0;
712            VelType_out=[];         
713        else
714            [Field{1},VelType_out]=read_civxdata(filename,InputField,VelType);
715            if isfield(Field{1},'Txt')
716                msgbox_view_field('ERROR',Field{1}.Txt)
717                return
718            end
719            CivStage=Field{1}.CivStage;
720            UvData.NbDim=Field{1}.nb_dim;
721        end
722    end
723    if ~isempty(filename_1) && isequal(FileType_1,'netcdf') %read the second file
724        if isequal(FieldName_1,'get_field...')% read the field names on the interface get_field.
725            hget_field=findobj(allchild(0),'Name','get_field_1');%find the get_field... GUI
726             if isempty(hget_field)
727                 hget_field= get_field(filename_1);%open the get_field GUI
728                 set(hget_field,'name','get_field_1')
729%                 enable_transform(handles,'off')% no field transform (possible transform in the GUI get_field)
730             end
731            hhget_field=guidata(hget_field);%handles of GUI elements in get_field
732            SubField=get_field('read_var_names',hObject,eventdata,hhget_field); %read the names of the variables to plot in the get_field GUI
733            [Field{2},var_detect]=nc2struct(filename_1,SubField.ListVarName); %read the corresponding input data               
734            Field{2}.VarAttribute=SubField.VarAttribute;
735            %update the display on get_field
736            set(hhget_field.inputfile,'String',filename_1)
737            set(hhget_field.variables,'Value',1)
738            Tabchar={''};%default
739            Tabcell=[];
740            if isfield(Field{2},'ListGlobalAttribute')& ~isempty(Field{2}.ListGlobalAttribute)
741                for iline=1:length(Field{2}.ListGlobalAttribute)
742                    Tabcell{iline,1}=Field{2}.ListGlobalAttribute{iline};
743                    if isfield(Field{2}, Field{2}.ListGlobalAttribute{iline})
744                        eval(['val=Field{2}.' Field{2}.ListGlobalAttribute{iline} ';'])
745                        if ischar(val);
746                            Tabcell{iline,2}=val;
747                        else
748                            Tabcell{iline,2}=num2str(val);
749                        end
750                    end
751                end
752                if ~isempty(Tabcell)
753                    Tabchar=cell2tab(Tabcell,'=');
754                    Tabchar=[{''};Tabchar];
755                end
756            end
757            set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field
758        else
759            [Field{2},VelType_out_1]=read_civxdata(filename_1,[],VelType_1);
760            CivStage_1=Field{2}.CivStage;
761        end
762        if ~isequal(FileType,'netcdf')
763            VelType_out=VelType_out_1;
764        end
765    end
766end
767
768%update the display buttons for the first velocity type (first menuline)
769veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
770if ~isequal(FileType,'netcdf')
771    reset_vel_type(veltype_handles)
772elseif isempty(VelType)
773    set_veltype_display(veltype_handles,CivStage)%update the display of available velocity types for the first field
774    if isempty(VelType_out)
775        reset_vel_type(veltype_handles)
776    else
777        handle1=eval(['handles.' VelType_out]);
778        reset_vel_type(veltype_handles,handle1)
779    end
780end
781
782%update the display buttons for the second velocity type (second menuline)
783veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
784if ~isequal(FileType_1,'netcdf')
785    reset_vel_type(veltype_handles_1)
786elseif isempty(VelType_1)
787    set_veltype_display(veltype_handles_1,CivStage_1)%update the display of available velocity types for the first field
788    if isempty(VelType_out_1)
789        reset_vel_type(veltype_handles_1)
790    else
791        handle1=eval(['handles.' VelType_out_1 '_1']);
792        reset_vel_type(veltype_handles_1,handle1)
793    end
794end
795
796%introduce w as background image by default for a new series (only for nbdim=2)
797if ~isfield(UvData,'NewSeries')
798    UvData.NewSeries=1;
799end
800%put W as background image by default if NbDim=2:
801if ~isfield(UvData,'NbDim')||isempty(UvData.NbDim)||~isequal(UvData.NbDim,3)
802    if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W);
803        set(handles.SubField,'Value',1);
804        %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
805        set(handles.RootPath_1,'String','"')
806        set(handles.RootFile_1,'String','"')
807        set(handles.SubDir_1,'String','"');
808        [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
809        set(handles.FileIndex_1,'String',indices)
810        set(handles.FileExt_1,'String','"');
811        set(handles.Fields_1,'Visible','on');
812        set(handles.Fields_1,'Visible','on');
813        set(handles.RootPath_1,'Visible','on')
814        set(handles.RootFile_1,'Visible','on')
815        set(handles.SubDir_1,'Visible','on');
816        set(handles.FileIndex_1,'Visible','on');
817        set(handles.FileExt_1,'Visible','on');
818        set(handles.Fields_1,'Visible','on');
819        Field{1}.AName='w';
820        testscal=1;
821    end
822end           
823
824%multislice case
825if TestInputFile &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case
826      isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
827%     nbfield2=str2num(get(handles.last_j,'String'));
828       siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
829       if siz(1)>1
830           NbSlice=siz(1);
831           set(handles.slices,'Visible','on')
832           set(handles.slices,'Value',1)
833       else
834           NbSlice=1;
835       end
836       set(handles.nb_slice,'String',num2str(NbSlice))
837       slices_Callback(hObject, eventdata, handles)
838%        Coord=UvData.XmlData.GeometryCalib.SliceCoord;
839%        ZIndex=num_i1-NbSlice*(floor((num_i1-1)/NbSlice));
840%        Field{1}.Z=ZIndex;
841end
842
843%store the current open names, fields and vel types in view_field interface
844UvData.filename=filename;
845UvData.filename_1=filename_1;
846UvData.VelType=VelType;
847UvData.VelType_1=VelType_1;
848UvData.FieldName=FieldName;
849UvData.FieldName_1=FieldName_1;
850if ~isempty(scal_color)
851    UvData.CName=scal_color;
852end
853
854%coordinate transform or user fct
855XmlData=[];%default
856if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
857    XmlData=UvData.XmlData;
858end
859XmlData_1=[];%default
860if isfield(UvData,'XmlData_1')
861   XmlData_1=UvData.XmlData_1;
862end
863menu_transform=get(handles.transform_fct,'String');
864choice_value=get(handles.transform_fct,'Value');
865%transform=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
866transform_list=get(handles.transform_fct,'UserData');
867transform=transform_list{choice_value};%selected function handles
868
869% z index
870if TestInputFile
871    Field{1}.ZIndex=mod(num_i1-1,nbslice)+1;
872end
873%px to phys or other transform on field
874if  ~isempty(transform)
875    if length(Field)>=2
876        Field{2}.ZIndex=mod(num_i1-1,nbslice)+1;
877        [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
878        if isempty(Field{2})
879            Field(2)=[];
880        end
881    else
882        Field{1}=transform(Field{1},XmlData);
883    end
884end
885
886%calculate scalar
887if isequal(FileType,'netcdf') && ~isequal(FieldName,'get_field...')%
888    Field{1}=calc_field(InputField,Field{1});
889end
890if length(Field)==2 && isequal(FileType_1,'netcdf') && ~isequal(FieldName_1,'get_field...')
891    Field{2}=calc_field(InputField_1,Field{2});
892end
893
894% combine the two input fields (e.g. substract velocity fields)
895if numel(Field)==2
896    if ~(isequal(get(handles.movie_pair,'Value'),1) && isequal(FieldName,'image') && isequal(FieldName_1,'image')) %combine fields if not viewing image pairs
897        UvData.Field=sub_field(Field{1},Field{2}); %TO UPDATE FOR MORE GENERAL INPUT
898    end
899else
900   UvData.Field=Field{1};
901end
902UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
903% test 3D , default projection menuplane and typical mesh (needed to menuopen set_object)
904test_x=0;
905test_z=0;% test for unstructured z coordinate
906UvData.ZMax=0;
907UvData.ZMin=0;%default
908UvData.Mesh=1; %default
909[UvData.Field,errormsg]=check_field_structure(UvData.Field);
910if ~isempty(errormsg)
911    msgbox_view_field('ERROR',['error in view_field/run0_Callback/check_field_structure: ' errormsg])
912    return
913end
914[CellVarIndex,NbDim,VarType]=find_field_indices(UvData.Field);
915[NbDim,imax]=max(NbDim);
916if isempty(imax)
917%    DimVarIndex=0;   
918    coord_x=[];
919else
920%     VarIndex=CellVarIndex{imax};
921    coord_x=VarType{imax}.coord_x;
922end
923if isfield(UvData,'NbDim') && ~isempty(UvData.NbDim)
924    NbDim=UvData.NbDim;
925else 
926    UvData.NbDim=NbDim;
927end
928if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_x)  && ~isempty(VarType{imax}.coord_y)    %unstructured coordinate z
929    XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
930    YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
931    test_x=1;
932elseif isfield(UvData.Field,'X') && isfield(UvData.Field,'Y')
933    XName='X';
934    YName='Y';
935    test_x=1;
936end
937if test_x
938    eval(['UvData.XMax=max(UvData.Field.' XName ');'])
939    eval(['UvData.XMin=min(UvData.Field.' XName ');'])
940    eval(['UvData.YMax=max(UvData.Field.' YName ');'])
941    eval(['UvData.YMin=min(UvData.Field.' YName ');'])
942    eval(['nbvec=length(UvData.Field.' XName ');'])
943    if NbDim==3%
944        if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_z)%unstructured coordinate z
945            ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
946            eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
947            eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
948            test_z=1;   
949        elseif isfield(UvData,'Z')% usual civ data
950            UvData.ZMax=max(UvData.Z);
951            UvData.ZMin=min(UvData.Z);
952            test_z=1;
953        end
954    end
955    if isequal(UvData.ZMin,UvData.ZMax)%no z dependency
956        NbDim=2;
957        test_z=0;
958    end   
959    if test_z
960         UvData.Mesh=((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)*(UvData.ZMax-UvData.ZMin))/nbvec;% volume per vector
961         UvData.Mesh=(UvData.Mesh)^(1/3);
962    else
963        UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/nbvec);%2D
964    end
965end
966%case of structured coordinates
967if isfield(UvData.Field,'AX') & isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')
968    UvData.XMax=max(UvData.Field.AX);
969    UvData.XMin=min(UvData.Field.AX);
970    UvData.YMax=max(UvData.Field.AY);
971    UvData.YMin=min(UvData.Field.AY);
972    np_A=size(UvData.Field.A);
973    UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/((np_A(1)-1) * (np_A(2)-1))) ;
974end
975if  isempty(coord_x)&~isempty(CellVarIndex)
976    VarIndex=CellVarIndex{imax}; % list of variable indices
977    DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
978    if NbDim==3
979        nbpoints=UvData.Field.DimValue(DimIndex(1));
980        %Zvar=DimVarIndex(DimIndex(1));
981         %Zvar=DimVarIndex(1);
982         Zvar=VarType{imax}.coord_3;
983        if Zvar~=0 % z is a dimension variable
984            ZName=UvData.Field.ListVarName{Zvar};
985            eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
986            eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
987        else
988            testcoord_z=0;
989            if length(UvData.Field.VarAttribute)>=VarIndex(1)
990                if isfield(UvData.Field.VarAttribute{VarIndex(1)},'Coord_1')%regular grid
991                    Coord_z=UvData.Field.VarAttribute{VarIndex(1)}.Coord_1;
992                    UvData.ZMax=max(Coord_z);
993                    UvData.ZMin=min(Coord_z);
994                    testcoord_z=1;
995                end
996            end
997            if ~testcoord_z
998                  UvData.ZMin=1;
999                  UvData.ZMax=UvData.Field.DimValue(DimIndex(1));
1000            end
1001        end
1002        UvData.Mesh=(UvData.ZMax-UvData.ZMin)/(nbpoints-1);
1003    elseif NbDim==2
1004        nbpoints_y=UvData.Field.DimValue(DimIndex(1));       
1005        Yvar=VarType{imax}.coord_y;
1006        if Yvar~=0  % x is a dimension variable
1007            YName=UvData.Field.ListVarName{Yvar};
1008            eval(['UvData.YMax=max(UvData.Field.' YName ');'])
1009            eval(['UvData.YMin=min(UvData.Field.' YName ');'])
1010        else
1011            testcoord_y=0;
1012            if ~testcoord_y
1013                  UvData.YMin=1;
1014                  UvData.YMax=UvData.Field.DimValue(DimIndex(1));
1015            end
1016        end
1017        DY=(UvData.YMax-UvData.YMin)/(nbpoints_y-1);
1018        nbpoints_x=UvData.Field.DimValue(DimIndex(2));
1019        Xvar=VarType{imax}.coord_x;
1020        if Xvar~=0  % x is a dimension variable
1021            XName=UvData.Field.ListVarName{Xvar};
1022            eval(['UvData.XMax=max(UvData.Field.' XName ');'])
1023            eval(['UvData.XMin=min(UvData.Field.' XName ');'])
1024        else
1025            testcoord_x=0;
1026            if ~testcoord_x
1027                  UvData.XMin=1;
1028                  UvData.XMax=UvData.Field.DimValue(DimIndex(2));
1029            end
1030        end
1031        DX=(UvData.XMax-UvData.XMin)/(nbpoints_x-1);
1032        UvData.Mesh= sqrt(DX*DY);
1033    end
1034end
1035
1036%create a default projection menuplane
1037UvData.Object{1}.Style='plane';%main plotting plane
1038UvData.Object{1}.ProjMode='projection';%main plotting plane
1039if ~isfield(UvData.Object{1},'plotaxes')
1040    UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
1041    set(handles.list_object,'String',{'1-PLANE';'...'});
1042    set(handles.list_object,'Value',1);
1043end
1044
1045%3D case (menuvolume)
1046if NbDim==3
1047    UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects
1048    UvData.Object{1}.RangeZ=UvData.Mesh;%main plotting plane
1049    UvData.Object{1}.Coord(1,3)=(UvData.ZMin+UvData.ZMax)/2;%section at a middle plane chosen
1050    UvData.Object{1}.Phi=0;
1051    UvData.Object{1}.Theta=0;
1052    UvData.Object{1}.Psi=0;
1053    UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR 
1054    PlotHandles=get_plot_handles(handles);
1055    ZBounds(1)=UvData.ZMin; %minimum for the Z slider
1056    ZBounds(2)=UvData.ZMax;%maximum for the Z slider
1057    set_object(UvData.Object{1},PlotHandles,ZBounds);
1058    set(handles.list_object,'Value',1);
1059%multilevel case (single menuplane in a 3D space)
1060elseif isfield(UvData,'Z')
1061    if isfield(UvData,'CoordType')& isequal(UvData.CoordType,'phys') & isfield(UvData,'XmlData')
1062        XmlData=UvData.XmlData;
1063        if isfield(XmlData,'PlanePos')
1064             UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
1065        end
1066        if isfield(XmlData,'PlaneAngle')
1067            siz=size(XmlData.PlaneAngle);
1068            indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)             
1069            UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1);
1070            UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2);
1071            UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3);
1072        end
1073    elseif isfield(UvData,'ZIndex')
1074        UvData.Object{1}.ZObject=UvData.ZIndex;
1075    end
1076end
1077
1078%Plot the projections on all existing  projection objects
1079keeplim=get(handles.FixedLimits,'Value');
1080%reset the min and max of scalar if only the mask is displayed
1081if isfield(UvData,'Mask')&~isfield(UvData,'A')
1082    set(handles.MinA,'String','0')
1083    set(handles.MaxA,'String','255')
1084end
1085
1086Object=UvData.Object;
1087for iobj=1:length(Object)
1088    if ~isempty(Object{iobj})%& isfield(Object{iobj},'plotaxes')& ishandle(Object{iobj}.plotaxes)
1089        %Projeter les champs sur l'objet:*
1090        ObjectData=proj_field(UvData.Field,Object{iobj},iobj);
1091   
1092        %use of mask
1093        if isfield(ObjectData,'NbDim')&isequal(ObjectData.NbDim,2)
1094            if isfield(ObjectData,'Mask') & isfield(ObjectData,'A')
1095                 flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
1096                 AX=ObjectData.AX;
1097                 AY=ObjectData.AY;
1098                 MaskX=ObjectData.MaskX;
1099                 MaskY=ObjectData.MaskY;
1100                 if ~isequal(MaskX,AX)|~isequal(MaskY,AY)
1101                     nxy=size(flag_mask);
1102                     sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
1103                     sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
1104                     x_mask=[ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end)]; % pixel x coordinates for image display
1105                     y_mask=[ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end)];% pixel x coordinates for image display
1106                     %project on the positions of the scalar
1107                     npxy=size(ObjectData.A);
1108                     dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
1109                     dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
1110                     xi=[ObjectData.AX(1):dxy(2):ObjectData.AX(end)];
1111                     yi=[ObjectData.AY(1):dxy(1):ObjectData.AY(end)];     
1112                     [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
1113                    flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
1114                 end
1115                 AClass=class(ObjectData.A);
1116                 ObjectData.A=flag_mask.*double(ObjectData.A);
1117                 ObjectData.A=feval(AClass,ObjectData.A);
1118                 ind_off=[];
1119                 if isfield(ObjectData,'ListVarName')
1120                      for ilist=1:length(ObjectData.ListVarName)
1121                           if isequal(ObjectData.ListVarName{ilist},'Mask')|isequal(ObjectData.ListVarName{ilist},'MaskX')|isequal(ObjectData.ListVarName{ilist},'MaskY')
1122                               ind_off=[ind_off ilist];
1123                           end
1124                      end
1125                      ObjectData.ListVarName(ind_off)=[];
1126                      ObjectData.VarDimIndex(ind_off)=[];
1127                      ind_off=[];       
1128                      for ilist=1:length(ObjectData.ListDimName)       
1129                           if isequal(ObjectData.ListDimName{ilist},'MaskX')|isequal(ObjectData.ListDimName{ilist},'MaskY')
1130                               ind_off=[ind_off ilist];
1131                           end
1132                      end
1133                      ObjectData.ListDimName(ind_off)=[];
1134                      ObjectData.DimValue(ind_off)=[];
1135                 end
1136            end 
1137        end
1138        if ~isempty(ObjectData)
1139            haxes=[];%default
1140            if isfield(Object{iobj},'plotaxes')
1141                haxes=Object{iobj}.plotaxes;%axes used for representing the projection on the object
1142            end
1143            PosColorbar=[];%default: no colorbar
1144            if ishandle(haxes) & isequal(get(haxes,'Tag'),'axes3')& isfield(UvData,'PosColorbar')
1145                PosColorbar=UvData.PosColorbar;%prescribe the colorbar position on the view_field interface
1146            else
1147                PosColorbar='*';%default position
1148            end
1149            PlotParam=read_plot_param(handles);%read plotting parameters on the view_field interface
1150            [PlotType,ScalOut,UvData.Object{iobj}.plotaxes]=plot_field(ObjectData,haxes,PlotParam,keeplim,PosColorbar);
1151            if isequal(PlotType,'none')
1152                hget_field=findobj(allchild(0),'name','get_field');
1153                if isempty(hget_field)
1154                    get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
1155                else
1156                    msgbox_view_field('ERROR','The field defined by get_field cannot be plotted')
1157                end
1158            end 
1159            UvData.Object{iobj}.PlotParam=ScalOut; %record the plotting parameters
1160        end
1161       
1162    end
1163end
1164
1165%display the updated plotting parameters for the base menuplane
1166write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
1167set(handles.view_field,'UserData',UvData)
1168
1169%update the mask
1170if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
1171   update_mask(handles,num_i1,num_i2);
1172end
1173
1174%prepare the menus of histograms (for the whole menuvolume in 3D case)
1175menu_histo=(UvData.Field.ListVarName)';
1176ind_bad=[];
1177nb_histo=1;
1178for ivar=1:numel(menu_histo)
1179    if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
1180        Role=UvData.Field.VarAttribute{ivar}.Role;
1181        switch Role
1182            case {'coord_x','coord_y','coord_z','dimvar'}
1183                ind_bad=[ind_bad ivar];
1184            case {'vector_y'}
1185                nb_histo=nb_histo+1;
1186        end
1187    end
1188    DimCell=UvData.Field.VarDimName{ivar};
1189    DimName='';
1190    if ischar(DimCell)
1191        DimName=DimCell;
1192    elseif iscell(DimCell)&& numel(DimCell)==1
1193        DimName=DimCell{1};
1194    end
1195    if strcmp(DimName,menu_histo{ivar})
1196        ind_bad=[ind_bad ivar];
1197    end
1198end
1199menu_histo(ind_bad)=[];
1200test_v=0;
1201if ~isempty(menu_histo)
1202    set(handles.histo1_menu,'Value',1)
1203    set(handles.histo1_menu,'String',menu_histo)
1204    histo1_menu_Callback(hObject, eventdata, handles)
1205    if nb_histo > 1
1206        test_v=1;
1207        set(handles.histo2_menu,'Visible','on')
1208        set(handles.histo_v,'Visible','on')
1209        set(handles.histo2_menu,'String',menu_histo)
1210        set(handles.histo2_menu,'Value',2)
1211        histo2_menu_Callback(hObject, eventdata, handles)
1212    end
1213end
1214if ~test_v
1215    set(handles.histo2_menu,'Visible','off')
1216    set(handles.histo_v,'Visible','off')
1217    cla(handles.histo_v)
1218    set(handles.histo2_menu,'Value',1)
1219end
1220
1221%display time
1222testimedoc=0;
1223if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
1224    if isempty(num_i2)
1225        num_i2=num_i1;
1226    end
1227    if isempty(num_j1)
1228        num_j1=1;
1229    end
1230    if isempty(num_j2)
1231        num_j2=num_j1;
1232    end
1233    siz=size(UvData.XmlData.Time);
1234    if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
1235        abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
1236        dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
1237        testimedoc=1;
1238    end
1239end
1240if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
1241    [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
1242    num_i2=str2num(str2);
1243    if isempty(num_i2)
1244        num_i2=num_i1;
1245    end
1246    num_j1=str2num(str_a);
1247    if isempty(num_j1)
1248        num_j1=1;
1249    end
1250    num_j2=str2num(str_b);
1251    if isempty(num_j2)
1252        num_j2=num_j1;
1253    end
1254    num_i1=str2num(str1);
1255    siz=size(UvData.XmlData_1.Time);
1256    if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
1257        abstime_1=(UvData.XmlData_1.Time(num_i1,num_j1)+UvData.XmlData_1.Time(num_i2,num_j2))/2;%overset the time read from files
1258    end
1259end
1260set(handles.abs_time,'String',num2str(abstime,4))
1261set(handles.abs_time_1,'String',num2str(abstime_1,4))
1262if testimedoc && isfield(UvData,'dt')
1263    dt=UvData.dt;
1264end
1265if isequal(dt,0)
1266    set(handles.Dt_txt,'String','')
1267else
1268    if ~(isfield(UvData,'TimeUnit') && ~isempty(UvData.TimeUnit))
1269        set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  10^(-3)'] )
1270    else
1271        set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  m' UvData.TimeUnit] )
1272    end
1273end
1274set(handles.run0,'BackgroundColor',[1 0 0])
1275
1276
1277
1278%-------------------------------------------------------------------
1279% --- translate coordinate to matrix index
1280%-------------------------------------------------------------------
1281function [indx,indy]=pos2ind(x0,rangx0,nxy)
1282indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel 
1283indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
1284
1285%-------------------------------------------------------------------
1286% --- Executes on button press in 'FixedLimits'.
1287%-------------------------------------------------------------------
1288function FixedLimits_Callback(hObject, eventdata, handles)
1289test=get(handles.FixedLimits,'Value');
1290if test
1291    set(handles.FixedLimits,'BackgroundColor',[1 1 0])
1292else
1293    set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
1294end
1295
1296%-------------------------------------------------------------------
1297% --- Executes on button press in auto_xy.
1298function auto_xy_Callback(hObject, eventdata, handles)
1299test=get(handles.auto_xy,'Value');
1300if test
1301    set(handles.auto_xy,'BackgroundColor',[1 1 0])
1302    cla(handles.axes3)
1303    update_plot(handles)
1304else
1305    set(handles.auto_xy,'BackgroundColor',[0.7 0.7 0.7])
1306    update_plot(handles)
1307%     axis(handles.axes3,'image')
1308end
1309
1310
1311%-------------------------------------------------------------------
1312
1313%-------------------------------------------------------------------
1314% --- Executes on button press in 'zoom'.
1315%-------------------------------------------------------------------
1316function zoom_Callback(hObject, eventdata, handles)
1317if (get(handles.zoom,'Value') == 1);
1318    set(handles.zoom,'BackgroundColor',[1 1 0])
1319    set(handles.FixedLimits,'Value',1)% propose by default fixed limits for the plotting axes
1320    set(handles.FixedLimits,'BackgroundColor',[1 1 0])
1321else
1322    set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
1323end
1324
1325%-------------------------------------------------------------------
1326%----Executes on button press in 'record': records the current flags of manual correction.
1327%-------------------------------------------------------------------
1328function record_Callback(hObject, eventdata, handles)
1329% [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
1330filename=read_file_boxes(handles);
1331AxeData=get(gca,'UserData');
1332[erread,message]=fileattrib(filename);
1333if ~isempty(message) && ~isequal(message.UserWrite,1)
1334     msgbox_view_field('ERROR',['no writting access to ' filename])
1335     return
1336end
1337test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
1338test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
1339if ~test_civ2 && ~test_civ1
1340    msgbox_view_field('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
1341end
1342if test_civ2
1343    nbname='nb_vectors2';
1344   flagname='vec2_FixFlag';
1345   attrname='fix2';
1346end
1347if test_civ1
1348    nbname='nb_vectors';
1349   flagname='vec_FixFlag';
1350   attrname='fix';
1351end
1352%write fix flags in the netcdf file
1353hhh=which('netcdf.open');% look for built-in matlab netcdf library
1354if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
1355    nc=netcdf.open(filename,'NC_WRITE');
1356    netcdf.reDef(nc)
1357    netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
1358    dimid = netcdf.inqDimID(nc,nbname);
1359    try
1360        varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
1361    catch
1362        varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
1363    end
1364    netcdf.endDef(nc)
1365    netcdf.putVar(nc,varid,AxeData.FF);
1366    netcdf.close(nc) 
1367else %old netcdf library
1368    netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
1369end
1370
1371function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
1372nc=netcdf(filename,'write'); %open netcdf file
1373result=redef(nc);
1374eval(['nc.' attrname '=1;']);
1375theDim=nc(nbname) ;% get the number of velocity vectors
1376nb_vectors=size(theDim);
1377var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
1378var_FixFlag(1:nb_vectors)=AxeData.FF;%
1379fin=close(nc);
1380
1381
1382%-------------------------------------------------------------------
1383%determines the fields to read from the interface
1384%------------------------------------------------------------------
1385function [VelType,civ]=setfield(handles)
1386
1387VelType=[]; %default
1388if (get(handles.civ1,'Value') == 1);
1389        VelType='civ1';
1390% interp1   
1391elseif (get(handles.interp1,'Value') == 1);
1392    VelType='interp1';
1393% filter1   
1394elseif (get(handles.filter1,'Value') == 1);
1395    VelType='filter1'; 
1396% CIV2
1397elseif (get(handles.civ2,'Value') == 1);
1398    VelType='civ2';
1399% interp2   
1400elseif (get(handles.interp2,'Value') == 1);
1401    VelType='interp2';
1402% filter2   
1403elseif (get(handles.filter2,'Value') == 1); 
1404    VelType='filter2';
1405end
1406
1407if isequal(get(handles.filter2,'Visible'),'on');
1408    civ=6;
1409% interp1   
1410elseif isequal(get(handles.interp2,'Visible'),'on');
1411    civ=5;
1412% filter1   
1413elseif isequal(get(handles.civ2,'Visible'),'on');
1414    civ=4; 
1415% CIV2
1416elseif isequal(get(handles.filter1,'Visible'),'on');
1417   civ=3;
1418% interp2   
1419elseif isequal(get(handles.interp1,'Visible'),'on');
1420    civ=2;
1421% filter2   
1422elseif isequal(get(handles.civ1,'Visible'),'on'); 
1423    civ=1;
1424else
1425    civ=0;
1426end
1427
1428%-------------------------------------------------------------------
1429%determines the veltype of the second field to read from the iinterface
1430%------------------------------------------------------------------
1431function VelType=setfield_1(handles)
1432
1433VelType=[]; %default
1434if (get(handles.civ1_1,'Value') == 1);
1435    VelType='civ1';
1436% interp1   
1437elseif (get(handles.interp1_1,'Value') == 1);
1438    VelType='interp1';
1439% filter1   
1440elseif (get(handles.filter1_1,'Value') == 1);
1441    VelType='filter1'; 
1442% CIV2
1443elseif (get(handles.civ2_1,'Value') == 1);
1444    VelType='civ2';
1445% interp2   
1446elseif (get(handles.interp2_1,'Value') == 1);
1447    VelType='interp2';
1448% filter2   
1449elseif (get(handles.filter2_1,'Value') == 1); 
1450    VelType='filter2';
1451end
1452
1453
1454%---------------------------------------------------
1455% --- Executes on button press in SubField
1456function SubField_Callback(hObject, eventdata, handles)
1457huvmat=get(handles.run0,'parent');
1458UvData=get(huvmat,'UserData');
1459if get(handles.SubField,'Value')==0% if the subfield button is desactivated   
1460    set(handles.RootPath_1,'String','')
1461    set(handles.RootFile_1,'String','')
1462    set(handles.SubDir_1,'String','');
1463    set(handles.FileIndex_1,'String','');
1464    set(handles.FileExt_1,'String','');
1465    set(handles.RootPath_1,'Visible','off')
1466    set(handles.RootFile_1,'Visible','off')
1467    set(handles.SubDir_1,'Visible','off');
1468    set(handles.FileIndex_1,'Visible','off');
1469    set(handles.FileExt_1,'Visible','off');
1470    set(handles.Fields_1,'Value',1);%set to blank state
1471    set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ...
1472            handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
1473    if isfield(UvData,'XmlData_1')
1474        UvData=rmfield(UvData,'XmlData_1');
1475    end
1476    set(huvmat,'UserData',UvData);
1477    run0_Callback(hObject, eventdata, handles); %run
1478else
1479    MenuBrowse_1_Callback(hObject, eventdata, handles)
1480end
1481
1482% %----------------------------------------------
1483% %read the data displayed for the input rootfile windows (new)
1484% %-------------------------------------------------
1485function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
1486RootPath=get(handles.RootPath,'String');
1487FileName=RootPath; %default
1488SubDir=get(handles.SubDir,'String');
1489if ~isempty(SubDir) && ~isequal(SubDir,'')
1490    if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
1491        SubDir(1)=[]; %suppress possible / or \ separator
1492    end
1493    FileName=fullfile(RootPath,SubDir);
1494end
1495RootFile=get(handles.RootFile,'String');
1496if ~isempty(RootFile) && ~isequal(RootFile,'')
1497    if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
1498        RootFile(1)=[]; %suppress possible / or \ separator
1499    end
1500    FileName=fullfile(FileName,RootFile);
1501end
1502FileBase=fullfile(RootPath,RootFile);
1503FileIndices=get(handles.FileIndex,'String');
1504FileExt=get(handles.FileExt,'String');
1505FileName=[FileName FileIndices FileExt];
1506
1507%----------------------------------------------
1508%read the data displayed for the second input rootfile windows
1509%-------------------------------------------------
1510function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
1511RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
1512if isequal(RootPath_1,'"'),RootPath_1=get(handles.RootPath,'String'); end;
1513FileName_1=RootPath_1; %default
1514SubDir_1=get(handles.SubDir_1,'String');
1515if isequal(SubDir_1,'"')
1516    SubDir_1=get(handles.SubDir,'String');
1517end
1518if ~isempty(SubDir_1) && ~isequal(SubDir_1,'')
1519    if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
1520        SubDir_1(1)=[]; %suppress possible / or \ separator
1521    end
1522    FileName_1=fullfile(RootPath_1,SubDir_1);
1523end
1524RootFile_1=get(handles.RootFile_1,'String');
1525if isequal(RootFile_1,'"'),RootFile_1=get(handles.RootFile,'String'); end;
1526if ~isempty(RootFile_1) && ~isequal(RootFile_1,'')
1527    if ~(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
1528        RootFile_1(1)=[];%suppress possible / or \ separator
1529    end
1530    FileName_1=fullfile(FileName_1,RootFile_1);
1531end
1532FileBase_1=fullfile(RootPath_1,RootFile_1);
1533FileIndices_1=get(handles.FileIndex_1,'String');
1534FileExt_1=get(handles.FileExt_1,'String');
1535if isequal(FileExt_1,'"'),FileExt_1=get(handles.FileExt,'String'); end;
1536FileName_1=[FileName_1 FileIndices_1 FileExt_1];
1537
1538%---------------------------------------------------
1539% --- Executes on menu selection Fields
1540function Fields_Callback(hObject, eventdata, handles)
1541%-------------------------------------------------
1542huvmat=get(handles.Fields,'parent');
1543list_fields=get(handles.Fields,'String');% list menu fields
1544index_fields=get(handles.Fields,'Value');% selected string index
1545field= list_fields{index_fields(1)}; % selected string
1546if isequal(field,'get_field...')
1547     veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
1548     set_veltype_display(veltype_handles,0) % unvisible civ buttons
1549     filename=read_file_boxes(handles);
1550     hget_field=findobj(allchild(0),'name','get_field');
1551     if ~isempty(hget_field)
1552         delete(hget_field)
1553     end
1554     get_field(filename)
1555    return %no action
1556end
1557list_fields=get(handles.Fields_1,'String');% list menu fields
1558index_fields=get(handles.Fields_1,'Value');% selected string index
1559field_1= list_fields{index_fields(1)}; % selected string
1560UvData=get(huvmat,'UserData');
1561
1562%read the rootfile input display
1563FileExt=get(handles.FileExt,'String');
1564[P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
1565NomTypeNew=NomType;%default
1566if isequal(field,'image')
1567    % transform netc type to the corresponding image type
1568    if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
1569        UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
1570        if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')||isequal(UvData.SubDir(1),'/'))
1571            UvData.SubDir(1)=[];
1572        end
1573        set(handles.SubDir,'String','')
1574        set(handles.FileExt,'String','.png');
1575        if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')
1576            NomTypeNew='_i_j';
1577        elseif isequal(NomType,'#_ab')
1578            NomTypeNew='#a';
1579        elseif isequal(NomType,'_i1-i2')
1580            NomTypeNew='_i';
1581        end 
1582    end
1583    veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
1584    set_veltype_display(veltype_handles,0) % unvisible civ buttons
1585else
1586    ext=get(handles.FileExt,'String');
1587    if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
1588         MenuBrowse_Callback(hObject, eventdata, handles)
1589    end
1590    if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
1591        set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
1592        set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
1593        set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
1594        set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
1595    elseif isequal(field,'more...');
1596        set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
1597        set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
1598        str=calc_field;%get the list of available scalars by the function calc_scal
1599        [ind_answer] = listdlg('PromptString','Select a file:',...
1600                'SelectionMode','single',...
1601                'ListString',str);
1602       % edit the choice in the field and action menu
1603        scalar=cell2mat(str(ind_answer));
1604        menu=update_menu(handles.Fields,scalar);
1605        menu=[{''};menu];
1606        set(handles.Fields_1,'String',menu);% store the selected scalar type
1607    end
1608end
1609indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
1610set(handles.FileIndex,'String',indices)
1611set(handles.FileIndex,'UserData',NomTypeNew)
1612%common to Fields_1_Callback
1613if isequal(field,'image')||isequal(field_1,'image')
1614    set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
1615    set(handles.npy_title,'Visible','on')
1616    set(handles.npx,'Visible','on')
1617    set(handles.npy,'Visible','on')
1618    set(handles.fix_pair,'Value',0)
1619else
1620    set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
1621    set(handles.npy_title,'Visible','off')
1622    set(handles.npx,'Visible','off')
1623    set(handles.npy,'Visible','off')
1624    set(handles.fix_pair,'Value',1)
1625end
1626% if isequal(field,'velocity')|isequal(field_1,'velocity');
1627%     state_vect='on';
1628% else
1629%     state_vect='off';
1630% end
1631% if ~isequal(field,'velocity')|(~isequal(field_1,'velocity'));
1632%     state_scal='on';
1633% else
1634%     state_scal='off';
1635% end
1636setfield(handles);% update the field structure ('civ1'....)
1637
1638if ~isfield(UvData,'NewSeries')||isequal(UvData.NewSeries,0)
1639    run0_Callback(hObject, eventdata, handles)
1640end
1641
1642%---------------------------------------------------
1643% --- Executes on menu selection Fields
1644function Fields_1_Callback(hObject, eventdata, handles)
1645%-------------------------------------------------
1646huvmat=get(handles.Fields_1,'parent');
1647list_fields=get(handles.Fields,'String');% list menu fields
1648index_fields=get(handles.Fields,'Value');% selected string index
1649field= list_fields{index_fields(1)}; % selected string
1650list_fields=get(handles.Fields_1,'String');% list menu fields
1651index_fields=get(handles.Fields_1,'Value');% selected string index
1652field_1= list_fields{index_fields(1)}; % selected string for the second field
1653if isequal(field_1,'') %remove second field if 'blank' field is selected
1654    set(handles.SubField,'Value',0)
1655    SubField_Callback(hObject, eventdata, handles)
1656    return
1657end
1658UvData=get(huvmat,'UserData');
1659
1660%read the rootfile input display
1661FileExt_prev=get(handles.FileExt_1,'String');
1662if isempty(FileExt_prev)|isequal(FileExt_prev,'')
1663    FileExt_1=get(handles.FileExt,'String');
1664else
1665    FileExt_1=FileExt_prev;
1666end
1667NomType_1=get(handles.FileIndex_1,'UserData');
1668if isempty(NomType_1)|isequal(NomType_1,'')
1669    NomType_1=get(handles.FileIndex,'UserData');
1670end
1671NomTypeNew=NomType_1;%default
1672
1673set(handles.SubField,'Value',1)%introduce second field
1674if isfield(UvData,'XmlData')
1675    UvData.XmlData_1=UvData.XmlData;
1676end
1677set(handles.FileIndex_1,'Visible','on')
1678set(handles.FileExt_1,'Visible','on')
1679RootPath_1=get(handles.RootPath_1,'String');
1680RootFile_1=get(handles.RootFile_1,'String');
1681if isempty(RootPath_1)|isequal(RootPath_1,'')
1682    set(handles.RootPath_1,'String','"')
1683end
1684if isempty(RootFile_1) | isequal(RootFile_1,'')
1685    set(handles.RootFile_1,'String','"')
1686end
1687if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
1688    RootFile_1(1)=[];
1689end
1690
1691if isequal(field_1,'get_field...')
1692     veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
1693     set_veltype_display(veltype_handles,0) % unvisible civ buttons
1694     filename=read_file_boxes_1(handles);
1695     hget_field=findobj(allchild(0),'name','get_field_1');
1696     if ~isempty(hget_field)
1697         delete(hget_field)
1698     end
1699     hget_field=get_field(filename);
1700     set(hget_field,'name','get_field_1')
1701    return %no action
1702end
1703if isequal(field_1,'image')
1704    % transform netc type to the corresponding image type
1705    set(handles.FileExt_1,'String','.png');
1706    if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')| isequal(NomType_1,'#_ab')| isequal(NomType_1,'_i1-i2')
1707        UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
1708        set(handles.SubDir_1,'String','')
1709%         set(handles.FileExt_1,'String','.png');       
1710        if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')
1711            NomTypeNew='_i_j';
1712        elseif isequal(NomType_1,'#_ab')
1713            NomTypeNew='#a';
1714        elseif isequal(NomType_1,'_i1-i2')
1715            NomTypeNew='_i';
1716        end 
1717    end
1718    veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
1719    set_veltype_display(veltype_handles,0) % unvisible civ buttons
1720else
1721    set(handles.SubDir_1,'Visible','on')
1722    if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file
1723        veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
1724        set_veltype_display(veltype_handles,6); % make all civ buttons visible
1725        RootPath_1=get(handles.RootPath_1,'String');
1726        RootFile_1=get(handles.RootFile_1,'String');
1727        if isempty(RootPath_1)|isequal(RootPath_1,'')
1728            set(handles.RootPath_1,'String','"')
1729        end
1730        if isempty(RootFile_1) | isequal(RootFile_1,'')
1731            set(handles.RootFile_1,'String','"')
1732        end
1733        if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
1734            RootFile_1(1)=[];
1735        end
1736        filebase_1=fullfile(RootPath_1,RootFile_1);
1737        SubDir_1=get(handles.SubDir,'String');
1738        if isempty(SubDir_1)|isequal(SubDir_1,'')
1739            if isfield(UvData,'SubDir_1')
1740                SubDir_1=UvData.SubDir_1;%retrieve previous subdir
1741            else
1742                SubDir_1='?';
1743            end
1744        end
1745        if isequal(NomType_1,'#_ab')|isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')|isequal(NomType_1,'_i1-i2')
1746            NomTypeNew=NomType_1;
1747        elseif isequal(NomType_1,'#a')
1748             [filename,idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),str2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
1749             NomTypeNew='#_ab';
1750        elseif isequal(NomType_1,'_i_j')
1751             [filename,idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),str2num(str_a),'.nc','_i1-i2_j',0,str2num(str1),[],SubDir_1);
1752            if idetect==1
1753                NomTypeNew='_i1-i2_j';
1754            else
1755                NomTypeNew='_i_j1-j2';
1756            end
1757        else %for instance avi files or any ima_num series
1758            [filename,idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),str2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1);
1759            NomTypeNew='_i1-i2';
1760        end           
1761        [Path,Name]=fileparts(filebase_1);
1762        set(handles.FileExt_1,'String','.nc');
1763        if ~isempty(SubDir_1) & ~isequal(SubDir_1,'''')& ~isequal(SubDir_1,'"')
1764            SubDir_1=['/' SubDir_1];
1765        end
1766        set(handles.SubDir_1,'String',SubDir_1);
1767    end
1768    if isequal(field,'vort') | isequal(field,'div') | isequal(field,'strain')
1769        set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
1770        set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
1771        set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
1772        set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
1773    elseif isequal(field_1,'more...'); %add new item to the menu
1774        set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
1775        set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
1776        str=calc_field;%get the list of available scalars by the function calc_scal
1777        [ind_answer,v] = listdlg('PromptString','Select a file:',...
1778                'SelectionMode','single',...
1779                'ListString',str);
1780       % edit the choice in the field and action menu
1781        scalar=cell2mat(str(ind_answer));
1782        menu=update_menu(handles.Fields_1,scalar);
1783        set(handles.Fields_1,'String',menu);% store the selected scalar type
1784    end
1785end
1786str1=get(handles.i1,'String');
1787str2=get(handles.i2,'String');
1788str_a=get(handles.j1,'String');
1789str_b=get(handles.j2,'String');
1790indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
1791set(handles.FileIndex_1,'String',indices)
1792set(handles.FileIndex_1,'UserData',NomTypeNew)
1793
1794%common to Fields_Callback
1795if isequal(field,'image')|isequal(field_1,'image')
1796    set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
1797    set(handles.npy_title,'Visible','on')
1798    set(handles.npx,'Visible','on')
1799    set(handles.npy,'Visible','on')
1800    set(handles.fix_pair,'Value',0)
1801else
1802    set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
1803    set(handles.npy_title,'Visible','off')
1804    set(handles.npx,'Visible','off')
1805    set(handles.npy,'Visible','off')
1806    set(handles.fix_pair,'Value',1)
1807end
1808if isequal(field,'velocity')|isequal(field_1,'velocity');
1809    state_vect='on';
1810else
1811    state_vect='off';
1812end
1813if ~isequal(field,'velocity')|(~isequal(field_1,'velocity')&~isequal(field_1,''));
1814    state_scal='on';
1815else
1816    state_scal='off';
1817end
1818set(huvmat,'UserData',UvData)
1819setfield(handles);% update the field structure ('civ1'....)
1820if ~isfield(UvData,'NewSeries')|isequal(UvData.NewSeries,0)
1821    run0_Callback(hObject, eventdata, handles)
1822end
1823
1824%------------------------------------------------------------------------
1825% --- set the visibility of relevant velocity type menus:
1826function set_veltype_display(handles,Civ)
1827%------------------------------------------------------------------------
1828%Civ=0; all states 'off'
1829%Civ=6; all states 'on'
1830if isequal(Civ,0)
1831    imax=0;
1832%    set(handles(1),'Visible','on')  % unvisible civ buttons
1833% else
1834%    set(handles(1),'String','civ1')
1835% end
1836elseif isequal(Civ,1) || isequal(Civ,2)
1837   imax=1;
1838elseif isequal(Civ,3)
1839    imax=3;
1840elseif isequal(Civ,4) || isequal(Civ,5)
1841    imax=4;
1842elseif isequal(Civ,6) %patch2
1843    imax=6;
1844end
1845for ibutton=1:imax;
1846    set(handles(ibutton),'Visible','on')  % unvisible civ buttons
1847end
1848% for ibutton=max(imax+1,2):6;
1849for ibutton=imax+1:6;
1850    set(handles(ibutton),'Visible','off')  % unvisible civ buttons
1851    set(handles(ibutton),'Value',0)%unactivate unvisible buttons
1852end
1853
1854%-------------------------------------------------------------------
1855% --- Executes on button press in civ1.
1856function civ1_Callback(hObject, eventdata, handles)
1857%-------------------------------------------------------------------
1858if get(handles.civ1,'Value')==1
1859    reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1)
1860else
1861    reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
1862end
1863run0_Callback(hObject, eventdata, handles)
1864
1865%-------------------------------------------------------------------
1866% --- Executes on button press in interp1.
1867function interp1_Callback(hObject, eventdata, handles)
1868%-------------------------------------------------------------------
1869if get(handles.interp1,'Value')==1
1870    reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)
1871else
1872     reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
1873end
1874run0_Callback(hObject, eventdata, handles)
1875
1876%-------------------------------------------------------------------
1877% --- Executes on button press in filter1.
1878function filter1_Callback(hObject, eventdata, handles)
1879%-------------------------------------------------------------------
1880if get(handles.filter1,'Value')==1
1881    reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)
1882else
1883     reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
1884end
1885run0_Callback(hObject, eventdata, handles)
1886
1887%-------------------------------------------------------------------
1888% --- Executes on button press in civ2.
1889function civ2_Callback(hObject, eventdata, handles)
1890%-------------------------------------------------------------------
1891if get(handles.civ2,'Value')==1
1892    reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)
1893else
1894     reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
1895end
1896run0_Callback(hObject, eventdata, handles)
1897
1898%-----------------------------------------
1899% --- Executes on button press in interp2.
1900%-------------------------------------------
1901function interp2_Callback(hObject, eventdata, handles)
1902if get(handles.interp2,'Value')==1
1903    reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)
1904else
1905     reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
1906end
1907run0_Callback(hObject, eventdata, handles)
1908%---------------------------------------------
1909% --- Executes on button press in filter2.
1910%-------------------------------------------
1911function filter2_Callback(hObject, eventdata, handles)
1912if get(handles.filter2,'Value')==1
1913    reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2)
1914else
1915     reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
1916end
1917run0_Callback(hObject, eventdata, handles)
1918
1919%---------------------------------------------
1920function civ1_1_Callback(hObject, eventdata, handles)
1921%---------------------------------------------
1922if get(handles.civ1_1,'Value')==1
1923    reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1)
1924else
1925     reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
1926end
1927run0_Callback(hObject, eventdata, handles)
1928
1929%--------------------------------------------
1930function interp1_1_Callback(hObject, eventdata, handles)
1931%--------------------------------------------
1932if get(handles.interp1_1,'Value')==1
1933    reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1)
1934else
1935    reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
1936end
1937run0_Callback(hObject, eventdata, handles)
1938
1939%--------------------------------------------
1940function filter1_1_Callback(hObject, eventdata, handles)
1941%--------------------------------------------
1942if get(handles.filter1_1,'Value')==1
1943    reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1)
1944else
1945    reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
1946end
1947run0_Callback(hObject, eventdata, handles)
1948
1949%--------------------------------------------
1950function civ2_1_Callback(hObject, eventdata, handles)
1951%--------------------------------------------
1952if get(handles.civ2_1,'Value')==1
1953    reset_vel_type([handles.civ1_1 handles.interp1_1  handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1)
1954else
1955    reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
1956end
1957run0_Callback(hObject, eventdata, handles)
1958
1959%--------------------------------------------
1960function interp2_1_Callback(hObject, eventdata, handles)
1961%--------------------------------------------
1962if get(handles.interp2_1,'Value')==1
1963    reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1)
1964else
1965    reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
1966end
1967run0_Callback(hObject, eventdata, handles)
1968
1969%--------------------------------------------
1970function filter2_1_Callback(hObject, eventdata, handles)
1971%--------------------------------------------
1972if get(handles.filter2_1,'Value')==1
1973    reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1)
1974else
1975    reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
1976end
1977run0_Callback(hObject, eventdata, handles)
1978
1979%-----------------------------------------------
1980% --- reset civ buttons
1981function reset_vel_type(handles_civ0,handle1)
1982for ibutton=1:length(handles_civ0)
1983    set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
1984    set(handles_civ0(ibutton),'Value',0)
1985end
1986if exist('handle1','var')%handles of selected button
1987        set(handle1,'BackgroundColor',[1 1 0]) 
1988end
1989
1990%------------------------------------------------
1991function create_Callback(hObject,eventdata,handles)
1992%------------------------------------------------
1993if ishandle(handles.VIEW_FIELD_title)
1994    delete(handles.VIEW_FIELD_title)
1995end
1996huvmat=get(handles.create,'parent');
1997UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface (handles huvmat)
1998if isequal(get(handles.create,'Value'),1)
1999    set(handles.zoom,'Value',0)
2000    zoom_Callback(hObject, eventdata, handles)
2001     set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow
2002    set(handles.edit_vect,'Value',0) 
2003    edit_vect_Callback(hObject, eventdata, handles)
2004    set(handles.edit,'Value',0)
2005    set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
2006    list_object=get(handles.list_object,'String');
2007    if ~isempty(list_object)
2008        set(handles.list_object,'Value',length(list_object))
2009    end
2010    MouseAction='create_object';
2011    hset_object=findobj(allchild(0),'Name','set_object');
2012    uistack(hset_object,'top')
2013else
2014    set(handles.create,'BackgroundColor',[0 1 0])
2015    set(handles.edit,'Value',1)
2016    set(handles.edit,'BackgroundColor',[1 1 0])
2017    MouseAction='none';
2018end
2019
2020UvData.MouseAction=MouseAction;
2021set(huvmat,'UserData',UvData);
2022
2023%------------------------------------------------
2024function POINTS_Callback(hObject,eventdata,handles)
2025%------------------------------------------------
2026if ishandle(handles.VIEW_FIELD_title)
2027    delete(handles.VIEW_FIELD_title)
2028end
2029huvmat=get(handles.create,'parent');
2030UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface (handles huvmat)
2031if isequal(get(handles.create,'Value'),1)
2032    set(handles.zoom,'Value',0)
2033    zoom_Callback(hObject, eventdata, handles)
2034    set(handles.edit_vect,'Value',0) 
2035    edit_vect_Callback(hObject, eventdata, handles)
2036    set(handles.edit,'Value',0)
2037    set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
2038    %set(handles.grid,'Value',0)
2039    %set(handles.grid,'BackgroundColor',[0 1 0])
2040    % initiate set_object GUI
2041     data.TITLE='POINTS';
2042    if isfield(UvData,'CoordType')
2043        data.CoordType=UvData.CoordType;
2044    end
2045    if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
2046        data.RangeY=UvData.Mesh;
2047    elseif isfield(UvData,'AX')&isfield(UvData,'AY')& isfield(UvData,'A')%only image
2048        np=size(UvData.Field.A);
2049        meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
2050        meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
2051        data.RangeY=max(meshx,meshy);
2052        data.DX=max(meshx,meshy);
2053    end
2054    data.Coord=[0 0 0]; %default
2055    data.ParentButton=handles.create;
2056    PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
2057    [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
2058    if isfield(UvData,'SetObjectOrigin')
2059    pos_view_field=get(huvmat,'Position');
2060    pos_set_object(1:2)=UvData.SetObjectOrigin + pos_view_field(1:2);
2061    pos_set_object(3:4)=UvData.SetObjectSize .* pos_view_field(3:4);
2062    set(hset_object,'Position',pos_set_object)
2063    end
2064    %set(hset_object,'Position',[pos_view_field(1) pos_view_field(2)-0.05*pos_view_field(4) 0.2*pos_view_field(3)  0.5*pos_view_field(4)]);
2065    list_object=get(handles.list_object,'String');
2066    if ~isempty(list_object)
2067        set(handles.list_object,'Value',length(list_object))
2068    end
2069    MouseAction='create_object';
2070    %UvData.ZoomOn=0;
2071else
2072    set(handles.create,'BackgroundColor',[0 1 0])
2073    set(handles.edit,'Value',1)
2074    set(handles.edit,'BackgroundColor',[1 1 0])
2075    MouseAction='none';
2076end
2077
2078UvData.MouseAction=MouseAction;
2079set(huvmat,'UserData',UvData);
2080
2081%-----------------------------------------------------------
2082function LINE_Callback(hObject, eventdata, handles)
2083%-------------------------------------------------
2084if ishandle(handles.VIEW_FIELD_title)
2085    delete(handles.VIEW_FIELD_title)
2086end
2087% handles.view_field
2088huvmat=get(handles.create,'parent');
2089UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface
2090set(handles.zoom,'Value',0)
2091zoom_Callback(hObject, eventdata, handles)
2092set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
2093set(handles.edit_vect,'Value',0)
2094edit_vect_Callback(hObject, eventdata, handles)
2095set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
2096set(handles.edit,'Value',0)
2097set(handles.list_object,'Value',1);
2098edit_vect_Callback(hObject, eventdata, handles)
2099set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
2100set(handles.cal,'Value',0)
2101set(handles.cal,'BackgroundColor',[0 1 0])
2102%  initiate the set_object GUI
2103data.TITLE='LINE';
2104if isfield(UvData,'CoordType')
2105    data.CoordType=UvData.CoordType;
2106end
2107if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
2108    data.RangeX=UvData.Mesh;
2109    data.RangeY=UvData.Mesh;
2110    data.DX=UvData.Mesh;
2111    data.DY=UvData.Mesh;
2112elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
2113    np=size(UvData.Field.A);
2114    meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
2115    meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
2116    data.RangeY=max(meshx,meshy);
2117    data.RangeX=max(meshx,meshy);
2118    data.DX=max(meshx,meshy);
2119end
2120if isfield(data,'DX')
2121    data.Coord=[[0 0 0];[data.DX 0 0]]; %default
2122else
2123    data.Coord=[[0 0 0];[1 0 0]]; %default
2124end
2125data.ParentButton=handles.create;
2126PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
2127[hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
2128                                                  % associate the set_edit interface handle to the plotting axes
2129pos_view_field=get(huvmat,'Position');
2130if isfield(UvData,'SetObjectOrigin')
2131    pos_set_object(1:2)=UvData.SetObjectOrigin + pos_view_field(1:2);
2132    pos_set_object(3:4)=UvData.SetObjectSize .* pos_view_field(3:4); 
2133    set(hset_object,'Position',pos_set_object)
2134end
2135list_object=get(handles.list_object,'String');
2136if ~isempty(list_object)
2137    set(handles.list_object,'Value',length(list_object))
2138end
2139MouseAction='create_object';
2140UvData.MouseAction=MouseAction;
2141set(huvmat,'UserData',UvData)
2142
2143%-----------------------------------------------------------
2144function PATCH_Callback(hObject, eventdata, handles)
2145%-----------------------------------------------------------
2146if ishandle(handles.VIEW_FIELD_title)
2147    delete(handles.VIEW_FIELD_title)
2148end
2149huvmat=get(handles.create,'parent');
2150UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface
2151% if isequal(get(handles.PATCH,'Value'),1)
2152    set(handles.zoom,'Value',0)
2153    set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
2154%     set(handles.create,'Value',0)%suppress the other options if LINE is chosen
2155%     set(handles.create,'BackgroundColor',[0 1 0])
2156%     set(handles.LINE,'Value',0)
2157%     set(handles.LINE,'BackgroundColor',[0 1 0])
2158%     set(handles.PATCH,'Value',1)
2159%     set(handles.PATCH,'BackgroundColor',[1 1 0])
2160%     set(handles.PLANE,'Value',0)
2161%     set(handles.PLANE,'BackgroundColor',[0 1 0])%put activated buttons to yellow
2162%     set(handles.VOLUME,'Value',0)
2163%     set(handles.VOLUME,'BackgroundColor',[0 1 0])
2164    %set(handles.makemask,'Value',0)
2165    %makemask_Callback(hObject, eventdata, handles)
2166    set(handles.edit_vect,'Value',0)
2167    edit_vect_Callback(hObject, eventdata, handles)
2168    set(handles.edit,'Value',0)
2169    set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
2170    set(handles.edit_vect,'Value',0) 
2171    edit_vect_Callback(hObject, eventdata, handles)
2172    set(handles.cal,'Value',0)
2173    set(handles.cal,'BackgroundColor',[0 1 0])
2174    %set(handles.grid,'Value',0)
2175    %set(handles.grid,'BackgroundColor',[0 1 0])
2176    %initiate set_object GUI
2177    data.TITLE='PATCH';
2178    if isfield(UvData,'CoordType')
2179        data.CoordType=UvData.CoordType;
2180    end
2181    if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
2182        data.YMax=UvData.Mesh;
2183    elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
2184        np=size(UvData.Field.A);
2185        meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
2186        meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
2187        data.YMax=max(meshx,meshy);
2188        data.DX=max(meshx,meshy);
2189    end
2190    data.Coord=[0 0 0]; %default
2191    data.ParentButton=handles.create;
2192    PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
2193    [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
2194    pos_view_field=get(huvmat,'Position');
2195    if isfield(UvData,'SetObjectOrigin')
2196        pos_set_object(1:2)=UvData.SetObjectOrigin + pos_view_field(1:2);
2197        pos_set_object(3:4)=UvData.SetObjectSize .* pos_view_field(3:4);
2198        set(hset_object,'Position',pos_set_object)
2199    end
2200    list_object=get(handles.list_object,'String');
2201    if ~isempty(list_object)
2202        set(handles.list_object,'Value',length(list_object))
2203    end
2204    UvData.MouseAction='create_object';
2205    set(huvmat,'UserData',UvData);
2206%-------------------------------------------------------
2207function PLANE_Callback(hObject, eventdata, handles)
2208%-------------------------------------------------------
2209if ishandle(handles.VIEW_FIELD_title)
2210    delete(handles.VIEW_FIELD_title)
2211end
2212huvmat=get(handles.create,'parent');
2213UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface
2214set(handles.zoom,'Value',0)
2215set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
2216set(handles.edit_vect,'Value',0)
2217edit_vect_Callback(hObject, eventdata, handles)
2218set(handles.edit,'Value',0)
2219set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
2220set(handles.cal,'Value',0)
2221set(handles.cal,'BackgroundColor',[0 1 0])
2222%set(handles.grid,'Value',0)
2223%set(handles.grid,'BackgroundColor',[0 1 0])
2224%initiate set_object GUI
2225data.TITLE='PLANE';
2226if isfield(UvData,'CoordType')
2227    data.CoordType=UvData.CoordType;
2228end
2229%Si 3D data.nbdim=3;
2230%Si 2D
2231if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
2232    data.ZMax=UvData.Mesh;
2233    data.DX=UvData.Mesh;
2234    data.DY=UvData.Mesh;
2235elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
2236    np=size(UvData.Field.A);
2237    meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
2238    meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
2239    data.DX=max(meshx,meshy);
2240end
2241if isfield(UvData,'DX')
2242    data.DX=UvData.DX;
2243end
2244if isfield(UvData,'DY')
2245    data.DY=UvData.DY;
2246elseif isfield(UvData,'Mesh')
2247    data.DY=UvData.Mesh;
2248end
2249if isfield(UvData.Field,'X')& isfield(UvData.Field,'Y')
2250    data.Coord=[0 0 0];
2251    data.Style='plane';
2252    data.Phi=0;
2253    data.IndexObj=1; %act on the first reference plane by default
2254    haxes= handles.axes3;%GENERALISER
2255    plot_object(data,[],haxes,'m'); %plot the axes of the default plane 
2256end
2257data.ParentButton=handles.create;
2258PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
2259ZBounds=0; % default
2260if isfield(UvData,'ZMin') && isfield(UvData,'ZMax')
2261    ZBounds(1)=UvData.ZMin; %minimum for the Z slider
2262    ZBounds(2)=UvData.ZMax;%maximum for the Z slider
2263end
2264[hset_object,UvData.sethandles]=set_object(data,PlotHandles,ZBounds);% call the set_object interface with action on haxes,
2265if isfield(UvData,'SetObjectOrigin')
2266pos_view_field=get(huvmat,'Position');
2267pos_set_object(1:2)=UvData.SetObjectOrigin + pos_view_field(1:2);
2268pos_set_object(3:4)=UvData.SetObjectSize .* pos_view_field(3:4); 
2269set(hset_object,'Position',pos_set_object)
2270end
2271list_object=get(handles.list_object,'String');
2272nbobject=length(list_object);
2273set(handles.list_object,'Value',nbobject)
2274UvData.MouseAction='create_object';
2275set(huvmat,'UserData',UvData)
2276
2277%-------------------------------------------------------
2278% --- Executes on button press in MENUVOLUME.
2279%-------------------------------------------------------
2280function VOLUME_Callback(hObject, eventdata, handles)
2281%errordlg('command VOL not implemented yet')
2282if ishandle(handles.VIEW_FIELD_title)
2283    delete(handles.VIEW_FIELD_title)
2284end
2285huvmat=get(handles.create,'parent');
2286UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface
2287if isequal(get(handles.VOLUME,'Value'),1)
2288    set(handles.zoom,'Value',0)
2289    set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
2290    set(handles.edit_vect,'Value',0)
2291    edit_vect_Callback(hObject, eventdata, handles)
2292    set(handles.edit,'Value',0)
2293    set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
2294    set(handles.cal,'Value',0)
2295    set(handles.cal,'BackgroundColor',[0 1 0])
2296    set(handles.edit_vect,'Value',0)
2297    edit_vect_Callback(hObject, eventdata, handles)
2298    %initiate set_object GUI
2299    data.TITLE='VOLUME';
2300    if isfield(UvData,'CoordType')
2301        data.CoordType=UvData.CoordType;
2302    end
2303    if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
2304        data.RangeY=UvData.Mesh;
2305        data.RangeX=UvData.Mesh;
2306        data.DX=UvData.Mesh;
2307        data.DY=UvData.Mesh;
2308    elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
2309        np=size(UvData.Field.A);
2310        meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
2311        meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
2312        data.RangeY=max(meshx,meshy);
2313        data.RangeX=max(meshx,meshy);
2314        data.DX=max(meshx,meshy);
2315    end
2316    data.ParentButton=handles.VOLUME;
2317    PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
2318    [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
2319                                                      % associate the set_edit interface handle to the plotting axes
2320    if isfield(UvData,'SetObjectOrigin')                                               
2321    pos_view_field=get(huvmat,'Position');
2322    pos_set_object(1:2)=UvData.SetObjectOrigin + pos_view_field(1:2);
2323    pos_set_object(3:4)=UvData.SetObjectSize .* pos_view_field(3:4); 
2324    set(hset_object,'Position',pos_set_object)
2325    end
2326    UvData.MouseAction='create_object';
2327else
2328    set(handles.VOLUME,'BackgroundColor',[0 1 0])
2329    UvData.MouseAction='none';
2330end
2331set(huvmat,'UserData',UvData)
2332
2333%-------------------------------------------------------
2334function edit_vect_Callback(hObject, eventdata, handles)
2335%-------------------------------------------------------
2336
2337UvData=get(handles.view_field,'UserData');%read UvData properties stored on the view_field interface
2338if isequal(get(handles.edit_vect,'Value'),1)
2339    test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
2340    test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
2341    if ~test_civ2 && ~test_civ1
2342        msgbox_view_field('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
2343    end
2344    set(handles.record,'Visible','on')
2345    set(handles.edit_vect,'BackgroundColor',[1 1 0])
2346    set(handles.edit,'Value',0)
2347    set(handles.create,'Value',0)
2348    set(handles.create,'BackgroundColor',[0 1 0])
2349    set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
2350    set(gcf,'Pointer','arrow')
2351    UvData.MouseAction='edit_vect';
2352else
2353    set(handles.record,'Visible','off')
2354    set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
2355    UvData.MouseAction='none';
2356end
2357set(handles.view_field,'UserData',UvData)
2358
2359%----------------------------------------------
2360function save_mask_Callback(hObject, eventdata, handles)
2361%-----------------------------------------------------------------------
2362huvmat=get(handles.save_mask,'parent');
2363UvData=get(huvmat,'UserData');
2364
2365hpatch=findobj(huvmat,'Type','patch');
2366flag=1;
2367npx=size(UvData.Field.A,2);
2368npy=size(UvData.Field.A,1);
2369xi=[0.5:npx-0.5];
2370yi=[0.5:npy-0.5];
2371[Xi,Yi]=meshgrid(xi,yi);
2372if isfield(UvData,'Object')
2373    for iobj=1:length(UvData.Object)
2374        ObjectData=UvData.Object{iobj};
2375        if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
2376            flagobj=1;
2377            testphys=0; %coordinates in pixels by default
2378            if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
2379                if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
2380                    Calib=UvData.XmlData.GeometryCalib;
2381                    testphys=1;
2382                end
2383            end
2384            if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
2385                if isequal(ObjectData.Style,'polygon')
2386                    X=ObjectData.Coord(:,1);
2387                    Y=ObjectData.Coord(:,2);
2388                    if testphys
2389                        [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
2390                    end
2391                    flagobj=~inpolygon(Xi,Yi,X,Y);%=0 inside the polygon, 1 outside                 
2392                elseif isequal(ObjectData.Style,'ellipse')
2393                    if testphys
2394                        %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
2395                    end
2396                    RangeX=max(ObjectData.RangeX);
2397                    RangeY=max(ObjectData.RangeY);
2398                    X2Max=RangeX*RangeX;
2399                    Y2Max=RangeY*RangeY;
2400                    distX=(Xi-ObjectData.Coord(1,1));
2401                    distY=(Yi-ObjectData.Coord(1,2));
2402                    flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
2403                elseif isequal(ObjectData.Style,'rectangle')
2404                    if testphys
2405                        %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
2406                    end
2407                    distX=abs(Xi-ObjectData.Coord(1,1));
2408                    distY=abs(Yi-ObjectData.Coord(1,2));
2409                    flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
2410                end
2411                if isequal(ObjectData.ProjMode,'mask_outside')
2412                    flagobj=~flagobj;
2413                end
2414                flag=flag & flagobj;
2415            end
2416        end
2417    end
2418end
2419% flag=~flag;
2420%mask name
2421RootPath=get(handles.RootPath,'String');
2422RootFile=get(handles.RootFile,'String');
2423if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
2424        RootFile(1)=[];
2425end
2426filebase=fullfile(RootPath,RootFile);
2427list=get(handles.masklevel,'String');
2428masknumber=num2str(length(list));
2429maskindex=get(handles.masklevel,'Value');
2430mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
2431imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
2432imflag=flipdim(imflag,1);
2433% imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
2434msgbox_view_field('CONFIRMATION',[mask_name ' saved'])
2435imwrite(imflag,mask_name,'BitDepth',8);
2436
2437%display the mask
2438%update_mask(handles,num_i1,num_j1)
2439figure;
2440vec=linspace(0,1,256);%define a linear greyscale colormap
2441map=[vec' vec' vec'];
2442colormap(map)
2443
2444image(imflag);
2445
2446%-------------------------------------------------------------------
2447%-------------------------------------------------------------------
2448%  - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
2449
2450%------------------------------------------------------------------
2451
2452
2453
2454%------------------------------------------------------------------
2455% --- Executes on selection change in col_vec: choice of the color code.
2456%
2457function col_vec_Callback(hObject, eventdata, handles)
2458%------------------------------------------------------------------
2459% edit the choice for color code
2460list_code=get(handles.col_vec,'String');% list menu fields
2461index_code=get(handles.col_vec,'Value');% selected string index
2462col_code= list_code{index_code(1)}; % selected field
2463if isequal(col_code,'black') | isequal(col_code,'white')
2464   set(handles.slider1,'Visible','off')
2465   set(handles.slider2,'Visible','off')
2466   set(handles.colcode1,'Visible','off')
2467   set(handles.colcode2,'Visible','off')
2468   set(handles.AutoVecColor,'Visible','off')
2469   set_vec_col_bar(handles)
2470else
2471   set(handles.slider1,'Visible','on')
2472   set(handles.slider2,'Visible','on')
2473   set(handles.colcode1,'Visible','on')
2474   set(handles.colcode2,'Visible','on')
2475   set(handles.AutoVecColor,'Visible','on') 
2476   if isequal(col_code,'ima_cor')
2477       set(handles.AutoVecColor,'Value',0)%fixed scale by default
2478       set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
2479       set(handles.slider1,'Min',0);
2480       set(handles.slider1,'Max',1);
2481       set(handles.slider2,'Min',0);
2482       set(handles.slider2,'Max',1);
2483 %      set(handles.min_title_vec,'String','0')
2484       set(handles.max_vec,'String','1')
2485       set(handles.colcode1,'String','0.333')
2486       colcode1_Callback(hObject, eventdata, handles)
2487       set(handles.colcode2,'String','0.666')
2488       colcode2_Callback(hObject, eventdata, handles)
2489   else
2490       set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
2491       set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
2492       minval=get(handles.slider1,'Min');
2493       maxval=get(handles.slider1,'Max');
2494       set(handles.slider1,'Value',minval)
2495       set(handles.slider2,'Value',maxval)
2496       set_vec_col_bar(handles)
2497   end
2498%    slider_update(handles)
2499end
2500%replot the current graph
2501run0_Callback(hObject, eventdata, handles)
2502
2503
2504%----------------------------------------------------------------
2505% -- Executes on slider movement to set the color code
2506%
2507function slider1_Callback(hObject, eventdata, handles)
2508%------------------------------------------------------------------
2509slider1=get(handles.slider1,'Value');
2510min_val=str2num(get(handles.min_vec,'String'));
2511max_val=str2num(get(handles.max_vec,'String'));
2512col=min_val+(max_val-min_val)*slider1;
2513set(handles.colcode1,'String',num2str(col))
2514if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
2515    set(handles.slider2,'Value',col)
2516    set(handles.colcode2,'String',num2str(col))
2517end
2518colcode1_Callback(hObject, eventdata, handles)
2519
2520%----------------------------------------------------------------
2521% Executes on slider movement to set the color code
2522%----------------------------------------------------------------
2523function slider2_Callback(hObject, eventdata, handles)
2524slider2=get(handles.slider2,'Value');
2525min_val=str2num(get(handles.min_vec,'String'));
2526max_val=str2num(get(handles.max_vec,'String'));
2527col=min_val+(max_val-min_val)*slider2;
2528set(handles.colcode2,'String',num2str(col))
2529if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
2530    set(handles.slider1,'Value',col)
2531    set(handles.colcode1,'String',num2str(col))
2532end
2533colcode2_Callback(hObject, eventdata, handles)
2534
2535%----------------------------------------------------------------
2536%execute on return carriage on the edit box corresponding to slider 1
2537%----------------------------------------------------------------
2538function colcode1_Callback(hObject, eventdata, handles)
2539% col=str2num(get(handles.colcode1,'String'));
2540% set(handles.slider1,'Value',col)
2541set_vec_col_bar(handles)
2542update_plot(handles)
2543
2544%----------------------------------------------------------------
2545%execute on return carriage on the edit box corresponding to slider 2
2546%----------------------------------------------------------------
2547function colcode2_Callback(hObject, eventdata, handles)
2548% col=str2num(get(handles.colcode2,'String'));
2549% set(handles.slider2,'Value',col)
2550% slider2_Callback(hObject, eventdata, handles)
2551set_vec_col_bar(handles)
2552update_plot(handles)
2553%------------------------------------------------------------
2554%update the slider values after displaying vectors
2555%--------------------------------------------------------
2556% function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
2557% set(handles.slider1,'Min',minC)
2558% set(handles.slider1,'Max',maxC)
2559% set(handles.slider2,'Min',minC)
2560% set(handles.slider2,'Max',maxC)
2561% set(handles.min_title_vec,'String',num2str(minC))
2562% set(handles.max_vec,'String',num2str(maxC))
2563% if auto
2564%         set(handles.colcode1,'String',num2str(colcode1,3))%update display
2565%         set(handles.colcode2,'String',num2str(colcode2,3))
2566% end
2567% set(handles.slider1,'Value',colcode1)%update slider with constant display
2568% set(handles.slider2,'Value',colcode2)
2569% set_vec_col_bar(handles)
2570
2571
2572%-------------------------------------------------------
2573% --- Executes on button press in AutoVecColor.
2574%-------------------------------------------------------
2575function vec_col_bar_Callback(hObject, eventdata, handles)
2576set_vec_col_bar(handles)
2577
2578% %--------------------------------------------
2579% %update the display of color code for vectors
2580% %--------------------------------------------
2581% function set_vec_col_bar(handles)
2582% %get the image of the color display button 'vec_col_bar' in pixels
2583% uni=get(handles.vec_col_bar,'Unit');
2584% set(handles.vec_col_bar,'Unit','pixel')
2585% pos_vert=get(handles.vec_col_bar,'Position');
2586% set(handles.vec_col_bar,'Unit','Normalized')
2587% width=ceil(pos_vert(3));
2588% height=ceil(pos_vert(4));
2589% %get slider indications
2590% colcode.min=get(handles.slider1,'Min');
2591% colcode.max=get(handles.slider1,'Max');
2592% colcode.colcode1=get(handles.slider1,'Value');
2593% colcode.colcode2=get(handles.slider2,'Value');
2594% colcode.option=get(handles.vec_col_bar,'Value');
2595% colcode.auto=1;
2596% list_code=get(handles.col_vec,'String');% list menu fields
2597% index_code=get(handles.col_vec,'Value');% selected string index
2598% colcode.CName= list_code{index_code(1)}; % selected field used for vector color
2599% vec_C=colcode.min+(colcode.max-colcode.min)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
2600% [colorlist,col_vec]=set_col_vec(colcode,vec_C);
2601% oneheight=ones(1,height);
2602% A1=colorlist(col_vec,1)*oneheight;
2603% A2=colorlist(col_vec,2)*oneheight;
2604% A3=colorlist(col_vec,3)*oneheight;
2605% A(:,:,1)=A1';
2606% A(:,:,2)=A2';
2607% A(:,:,3)=A3';
2608% set(handles.vec_col_bar,'Cdata',A)
2609
2610%--------------------------------------------------------
2611% --- Executes on button press in cal.
2612function cal_Callback(hObject, eventdata, handles)
2613
2614huvmat=get(handles.cal,'parent');%handles of the view_field interface
2615UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface
2616%reinitialize the edit interface associated with view_field
2617value=get(handles.cal,'Value');
2618if value
2619        set(handles.cal,'BackgroundColor',[1 1 0])
2620        %suppress the other options if MENULINE is chosen
2621        set(handles.zoom,'Value',0)
2622        set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
2623        set(handles.create,'Value',0)
2624        set(handles.create,'BackgroundColor',[0 1 0])
2625        set(handles.create,'enable','off')     
2626        set(handles.edit_vect,'Value',0)
2627        set(handles.edit_vect,'enable','off')
2628        edit_vect_Callback(hObject, eventdata, handles)
2629        set(handles.edit,'Value',0)
2630        set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
2631        set(handles.edit,'enable','off')
2632        set(handles.list_object,'Value',1)     
2633        % initiate display of GUI geometry_calib
2634        data=[]; %default
2635                if isfield(UvData,'CoordType')
2636            data.CoordType=UvData.CoordType;
2637        end
2638        %data.ParentButton=handles.cal; % transmit the handles of the calling button to the GUI geometry_calib
2639                pos=get(huvmat,'Position');
2640                pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
2641                pos(2)=pos(2)-0.02;
2642        [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
2643%         [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
2644%         [inputfile,idetect]=name_generator(filebase,num_i1,num_j1,Ext,NomType,1,num_i2,num_j2,SubDir);
2645                [UvData.hset_object,UvData.sethandles]=geometry_calib(handles,pos,FileName);% call the set_object interface     
2646        pos_view_field=get(huvmat,'Position');
2647        %pos_cal(1:2)=UvData.CalOrigin + pos_view_field(1:2);
2648        if isfield(UvData,'CalOrigin')
2649            pos_cal(1)=pos_view_field(1)+UvData.CalOrigin(1)*pos_view_field(3);
2650            pos_cal(2)=pos_view_field(2)+UvData.CalOrigin(2)*pos_view_field(4);
2651            pos_cal(3:4)=UvData.CalSize .* pos_view_field(3:4);
2652            set(UvData.hset_object,'Position',pos_cal)
2653        end
2654        UvData.MouseAction='calib';
2655else
2656     UvData.MouseAction='none';     
2657     hgeometry_calib=findobj(allchild(0),'Name','geometry_calib');
2658%      if ~isempty(hgeometry_calib)
2659%          answer=questdlg('close the GUI geometry-calib?');
2660%          if isequal(answer,'Yes')
2661%              delete(hgeometry_calib)
2662%              set(handles.cal,'BackgroundColor',[0 1 0])
2663%          else
2664%              set(handles.cal,'Value',1)% keep the calibration function active
2665%          end
2666%      end
2667     set(handles.edit_vect,'enable','on')
2668     set(handles.edit,'enable','on')
2669     set(handles.create,'enable','on')
2670%      set(handles.LINE,'enable','on')
2671%      set(handles.PATCH,'enable','on')
2672%      set(handles.PLANE,'enable','on')
2673%      set(handles.VOLUME,'enable','on')
2674     %set(handles.makemask,'enable','on')
2675     hh=findobj(handles.axes3,'Tag','calib_points');
2676     if ~isempty(hh)
2677         delete(hh)
2678     end
2679     hhh=findobj(handles.axes3,'Tag','calib_marker');
2680     if ~isempty(hhh)
2681         delete(hhh)
2682     end   
2683end
2684set(huvmat,'UserData',UvData);
2685
2686%-------------------------------------------------------------
2687% --- Executes on selection change in transform_fct.
2688function transform_fct_Callback(hObject, eventdata, handles)
2689%-------------------------------------------------------------
2690global nb_builtin
2691
2692huvmat=get(handles.transform_fct,'parent');
2693menu=get(handles.transform_fct,'String');
2694ind_coord=get(handles.transform_fct,'Value');
2695coord_option=menu{ind_coord};
2696list_transform=get(handles.transform_fct,'UserData');
2697ff=functions(list_transform{end}); 
2698if isequal(coord_option,'more...');
2699    coord_fct='';
2700
2701%     if exist(profil_perso,'file')
2702%           h=load (profil_perso);
2703%          if isfield(h,'transform_fct')
2704%                 transform_fct=h.transform_fct;
2705%          end
2706%     end
2707    prompt = {'Enter the name of the transform function'};
2708    dlg_title = 'user defined transform';
2709    num_lines= 1;
2710    [FileName, PathName, filterindex] = uigetfile( ...
2711       {'*.m', ' (*.m)';
2712        '*.m',  '.m files '; ...
2713        '*.*', 'All Files (*.*)'}, ...
2714        'Pick a file', ff.file);
2715    if isequal(PathName(end),'/')||isequal(PathName(end),'\')
2716        PathName(end)=[];
2717    end
2718    transform_selected =fullfile(PathName,FileName);
2719    if ~exist(transform_selected,'file')
2720%            msgbox_view_field('ERROR',['procesing fct ' transform_selected ' not found'])
2721           return
2722    end
2723   [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
2724   if ~isequal(ext_fct,'.m')
2725        msgbox_view_field('ERROR','a Matlab function .m must be introduced');
2726        return
2727   end
2728   menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
2729   ind_coord=get(handles.transform_fct,'Value');
2730   addpath(PathName)
2731   list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
2732   set(handles.transform_fct,'UserData',list_transform)
2733   rmpath(PathName)
2734   % save the new menu in the personal file 'view_field_perso.mat'
2735   dir_perso=prefdir;%personal Matalb directory
2736   profil_perso=fullfile(dir_perso,'view_field_perso.mat');
2737   if exist(profil_perso,'file')
2738       for ilist=nb_builtin+1:numel(list_transform)
2739           ff=functions(list_transform{ilist});
2740           transform_fct{ilist-nb_builtin}=ff.file;
2741       end
2742        save (profil_perso,'transform_fct','-append'); %store the root name for future opening of view_field
2743   end   
2744end
2745
2746%check the current path to the selected function
2747if isa(list_transform{ind_coord},'function_handle')
2748    func=functions(list_transform{ind_coord});
2749    set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
2750else
2751    set(handles.path_transform,'String','')
2752end
2753%CurrentPath=fileparts(which(coord_option));
2754% if ~isequal(PathName,CurrentPath)
2755%     addpath(PathName)
2756%     errormsg=check_functions;
2757%     msgbox_view_field('WARNING',[['path ' PathName ' added to the current Matlab pathes'];errormsg])
2758% end
2759%set(handles.path_transform,'String',fullfile(PathName,' ')); %show the path to the senlected function
2760set(handles.FixedLimits,'Value',0)
2761set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
2762
2763UvData=get(huvmat,'UserData');
2764
2765%delete drawn objects
2766hother=findobj('Tag','proj_object');%find all the proj objects
2767for iobj=1:length(hother)
2768    delete_object(hother(iobj))
2769end
2770hother=findobj('Tag','DeformPoint');%find all the proj objects
2771for iobj=1:length(hother)
2772    delete_object(hother(iobj))
2773end
2774hh=findobj('Tag','calib_points');
2775if ~isempty(hh)
2776    delete(hh)
2777end
2778hhh=findobj('Tag','calib_marker');
2779if ~isempty(hhh)
2780    delete(hhh)
2781end
2782if isfield(UvData,'Object')
2783    nbobject=length(UvData.Object);
2784    UvData.Object([2:nbobject])=[];
2785end
2786
2787%delete mask if it is displayed
2788if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
2789   UvData=rmfield(UvData,'MaskName'); %will impose mask refresh 
2790end
2791set(huvmat,'UserData',UvData)
2792run0_Callback(hObject, eventdata, handles)
2793
2794%--------------------------------------------
2795function histo1_menu_Callback(hObject, eventdata, handles)
2796%--------------------------------------------
2797%plot first histo
2798huvmat=get(handles.histo1_menu,'parent');
2799histo_menu=get(handles.histo1_menu,'String');
2800histo_value=get(handles.histo1_menu,'Value');
2801FieldName=histo_menu{histo_value};
2802UvData=get(huvmat,'UserData');
2803update_histo(handles.histo_u,huvmat,FieldName)
2804
2805%----------------------------------------------
2806function histo2_menu_Callback(hObject, eventdata, handles)
2807%----------------------------------------------
2808%plot second histo
2809huvmat=get(handles.histo2_menu,'parent');
2810histo_menu=get(handles.histo2_menu,'String');
2811histo_value=get(handles.histo2_menu,'Value');
2812FieldName=histo_menu{histo_value};
2813UvData=get(huvmat,'UserData');
2814update_histo(handles.histo_v,huvmat,FieldName)
2815
2816
2817%--------------------------------------------
2818%read the field .Fieldname stored in UvData and plot its histogram
2819function update_histo(haxes,huvmat,FieldName)
2820UvData=get(huvmat,'UserData');
2821
2822if ~isfield(UvData.Field,FieldName)
2823    msgbox_view_field('ERROR',['no field  ' FieldName ' for histogram'])
2824    return
2825end
2826Field=UvData.Field;
2827FieldHisto=eval(['Field.' FieldName]);
2828if isfield(Field,'FF') & ~isempty(Field.FF) & isequal(size(Field.FF),size(FieldHisto))
2829    indsel=find(Field.FF==0);%find values marked as false
2830    if ~isempty(indsel)
2831        FieldHisto=FieldHisto(indsel);
2832    end
2833end
2834if isempty(Field)
2835    msgbox_view_field('ERROR',['empty field ' FieldName])
2836else
2837    nxy=size(FieldHisto);
2838    Amin=double(min(min(min(FieldHisto))));%min of image
2839    Amax=double(max(max(max(FieldHisto))));%max of image
2840    if isequal(Amin,Amax)
2841       Histo.Txt=['uniform field =' num2str(Amin)];
2842    else
2843    Histo.ListVarName={FieldName,'histo'};
2844    if numel(nxy)==2
2845        Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
2846    else %color images
2847        Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
2848    end
2849    %unit
2850    units=[]; %default
2851    for ivar=1:numel(Field.ListVarName)   
2852        if strcmp(Field.ListVarName{ivar},FieldName)
2853            if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
2854                units=Field.VarAttribute{ivar}.units;
2855                break
2856            end
2857        end
2858    end
2859    if ~isempty(units)
2860        Histo.VarAttribute{1}.units=units;
2861    end
2862    eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
2863    for col=1:size(FieldHisto,3)
2864        B=FieldHisto(:,:,col);
2865        C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
2866       eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']);  %calculate histogram
2867    end
2868    set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
2869    set(haxes,'YLimMode','auto')
2870    plot_field(Histo,haxes);
2871    end
2872end
2873
2874
2875
2876%------------------------------------------------
2877%CALLBACKS FOR PLOTTING PARAMETERS
2878%-------------------------------------------------
2879
2880%-----------------------------------------------------------------
2881function MinA_Callback(hObject, eventdata, handles)
2882%------------------------------------------
2883set(handles.AutoScal,'Value',1) %suppress auto mode
2884set(handles.AutoScal,'BackgroundColor',[1 1 0])
2885update_plot(handles)
2886
2887%-----------------------------------------------------------------
2888function MaxA_Callback(hObject, eventdata, handles)
2889%--------------------------------------------
2890set(handles.AutoScal,'Value',1) %suppress auto mode
2891set(handles.AutoScal,'BackgroundColor',[1 1 0])
2892update_plot(handles)
2893
2894%-----------------------------------------------
2895function AutoScal_Callback(hObject, eventdata, handles)
2896%--------------------------------------------
2897test=get(handles.AutoScal,'Value');
2898if test
2899    set(handles.AutoScal,'BackgroundColor',[1 1 0])
2900else
2901    set(handles.AutoScal,'BackgroundColor',[0.7 0.7 0.7])
2902    update_plot(handles);
2903%     set(handles.MinA,'String',num2str(ScalOut.MinA,3))
2904%     set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
2905end
2906
2907%-------------------------------------------------------------------
2908function BW_Callback(hObject, eventdata, handles)
2909%-------------------------------------------------------------------
2910update_plot(handles)
2911
2912%-------------------------------------------------------------------
2913function Contours_Callback(hObject, eventdata, handles)
2914%-------------------------------------------------------------------
2915val=get(handles.Contours,'Value');
2916if val==2
2917    set(handles.interval_txt,'Visible','on')
2918    set(handles.IncrA,'Visible','on')
2919else
2920    set(handles.interval_txt,'Visible','off')
2921    set(handles.IncrA,'Visible','off')
2922end
2923update_plot(handles)
2924
2925%-------------------------------------------------------------------
2926function IncrA_Callback(hObject, eventdata, handles)
2927%-------------------------------------------------------------------
2928update_plot(handles)
2929
2930%-------------------------------------------------------------------
2931function HideWarning_Callback(hObject, eventdata, handles)
2932%-------------------------------------------------------------------
2933update_plot(handles)
2934
2935%-------------------------------------------------------------------
2936function HideFalse_Callback(hObject, eventdata, handles)
2937%-------------------------------------------------------------------
2938update_plot(handles)
2939
2940%-------------------------------------------------------------------
2941function VecScale_Callback(hObject, eventdata, handles)
2942%-------------------------------------------------------------------
2943set(handles.AutoVec,'Value',1);
2944set(handles.AutoVec,'BackgroundColor',[1 1 0])
2945update_plot(handles)
2946
2947%-------------------------------------------------------------------
2948function AutoVec_Callback(hObject, eventdata, handles)
2949%-------------------------------------------------------------------
2950test=get(handles.AutoVec,'Value');
2951if test
2952    set(handles.AutoVec,'BackgroundColor',[1 1 0])
2953else
2954    update_plot(handles);
2955    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
2956    set(handles.AutoVec,'BackgroundColor',[0.7 0.7 0.7])
2957end
2958
2959%-------------------------------------------------------
2960% --- Executes on selection change in decimate4 (nb_vec/4).
2961%-------------------------------------------------------
2962function decimate4_Callback(hObject, eventdata, handles)
2963update_plot(handles)
2964
2965
2966%-------------------------------------------------------
2967% --- Executes on selection change in color_code menu
2968%-------------------------------------------------------
2969function color_code_Callback(hObject, eventdata, handles)
2970set_vec_col_bar(handles)
2971update_plot(handles);
2972
2973%-------------------------------------------------------
2974% --- Executes on button press in AutoVecColor.
2975%-------------------------------------------------------
2976function AutoVecColor_Callback(hObject, eventdata, handles)
2977test=get(handles.AutoVecColor,'Value');
2978if test
2979    set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
2980else
2981    update_plot(handles);
2982    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
2983    set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
2984end
2985%set_vec_col_bar(handles)
2986
2987%-------------------------------------------------------
2988% --- Executes on selection change in max_vec.
2989%-------------------------------------------------------
2990function min_vec_Callback(hObject, eventdata, handles)
2991max_vec_Callback(hObject, eventdata, handles)
2992
2993% --- Executes on selection change in max_vec.
2994function max_vec_Callback(hObject, eventdata, handles)
2995set(handles.AutoVecColor,'Value',1)
2996AutoVecColor_Callback(hObject, eventdata, handles)
2997min_val=str2num(get(handles.min_vec,'String'));
2998max_val=str2num(get(handles.max_vec,'String'));
2999slider1=get(handles.slider1,'Value');
3000slider2=get(handles.slider2,'Value');
3001colcode1=min_val+(max_val-min_val)*slider1;
3002colcode2=min_val+(max_val-min_val)*slider2;
3003set(handles.colcode1,'String',num2str(colcode1))
3004set(handles.colcode2,'String',num2str(colcode2))
3005update_plot(handles);
3006
3007%-------------------------------------------------------------------
3008%update the display of color code for vectors
3009function set_vec_col_bar(handles)
3010%-------------------------------------------------------------------
3011%get the image of the color display button 'vec_col_bar' in pixels
3012set(handles.vec_col_bar,'Unit','pixel');
3013pos_vert=get(handles.vec_col_bar,'Position');
3014set(handles.vec_col_bar,'Unit','Normalized');
3015width=ceil(pos_vert(3));
3016height=ceil(pos_vert(4));
3017
3018%get slider indications
3019list=get(handles.color_code,'String');
3020ichoice=get(handles.color_code,'Value');
3021colcode.ColorCode=list{ichoice};
3022colcode.MinC=str2num(get(handles.min_vec,'String'));
3023colcode.MaxC=str2num(get(handles.max_vec,'String'));
3024test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
3025if test3color
3026    colcode.colcode1=str2num(get(handles.colcode1,'String'));
3027    colcode.colcode2=str2num(get(handles.colcode2,'String'));
3028end
3029% colcode.option=get(handles.vec_col_bar,'Value');
3030colcode.FixedCbounds=0;
3031% list_code=get(handles.col_vec,'String');% list menu fields
3032% index_code=get(handles.col_vec,'Value');% selected string index
3033% colcode.CName= list_code{index_code(1)}; % selected field used for vector color
3034colcode.FixedCbounds=1;
3035vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
3036[colorlist,col_vec]=set_col_vec(colcode,vec_C);
3037oneheight=ones(1,height);
3038A1=colorlist(col_vec,1)*oneheight;
3039A2=colorlist(col_vec,2)*oneheight;
3040A3=colorlist(col_vec,3)*oneheight;
3041A(:,:,1)=A1';
3042A(:,:,2)=A2';
3043A(:,:,3)=A3';
3044set(handles.vec_col_bar,'Cdata',A)
3045
3046
3047%-------------------------------------------------------------------
3048function [PlotType,ScalOut]=update_plot(handles)
3049%-------------------------------------------------------------------
3050haxes= handles.axes3;
3051AxeData=get(haxes,'UserData');
3052PlotParam=read_plot_param(handles);
3053[PlotType,PlotParamOut]= plot_field(AxeData,haxes,PlotParam,1);
3054write_plot_param(handles,PlotParamOut); %update the auto plot parameters
3055
3056
3057
3058%------------------------------------------------------
3059% --- Executes on button press in Menu/Export/field in workspace.
3060%------------------------------------------------------
3061function MenuExportField_Callback(hObject, eventdata, handles)
3062
3063global CurData
3064huvmat=findobj(allchild(0),'Name','uvmat');
3065CurData=get(huvmat,'UserData');
3066evalin('base','global CurData')%make CurData global in the workspace
3067display(['UserData of view_field :'])
3068evalin('base','CurData') %display CurData in the workspace
3069commandwindow;
3070
3071%------------------------------------------------------
3072% --- Executes on button press in Menu/Export/extract figure.
3073%------------------------------------------------------
3074function MenuExport_plot_Callback(hObject, eventdata, handles)
3075huvmat=get(handles.MenuExport_plot,'parent');
3076UvData=get(huvmat,'UserData');
3077hfig=figure;
3078newaxes=copyobj(handles.axes3,hfig);
3079map=colormap(handles.axes3);
3080colormap(map);%transmit the current colormap to the zoom fig
3081colorbar
3082
3083
3084
3085function edit84_Callback(hObject, eventdata, handles)
3086% hObject    handle to edit84 (see GCBO)
3087% eventdata  reserved - to be defined in a future version of MATLAB
3088% handles    structure with handles and user data (see GUIDATA)
3089
3090% Hints: get(hObject,'String') returns contents of edit84 as text
3091%        str2double(get(hObject,'String')) returns contents of edit84 as a double
3092
3093
3094% --- Executes during object creation, after setting all properties.
3095function edit84_CreateFcn(hObject, eventdata, handles)
3096% hObject    handle to edit84 (see GCBO)
3097% eventdata  reserved - to be defined in a future version of MATLAB
3098% handles    empty - handles not created until after all CreateFcns called
3099
3100% Hint: edit controls usually have a white background on Windows.
3101%       See ISPC and COMPUTER.
3102if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3103    set(hObject,'BackgroundColor','white');
3104end
3105
3106
3107
3108function edit85_Callback(hObject, eventdata, handles)
3109% hObject    handle to edit85 (see GCBO)
3110% eventdata  reserved - to be defined in a future version of MATLAB
3111% handles    structure with handles and user data (see GUIDATA)
3112
3113% Hints: get(hObject,'String') returns contents of edit85 as text
3114%        str2double(get(hObject,'String')) returns contents of edit85 as a double
3115
3116
3117% --- Executes during object creation, after setting all properties.
3118function edit85_CreateFcn(hObject, eventdata, handles)
3119% hObject    handle to edit85 (see GCBO)
3120% eventdata  reserved - to be defined in a future version of MATLAB
3121% handles    empty - handles not created until after all CreateFcns called
3122
3123% Hint: edit controls usually have a white background on Windows.
3124%       See ISPC and COMPUTER.
3125if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3126    set(hObject,'BackgroundColor','white');
3127end
3128
3129
3130
3131function edit86_Callback(hObject, eventdata, handles)
3132% hObject    handle to edit86 (see GCBO)
3133% eventdata  reserved - to be defined in a future version of MATLAB
3134% handles    structure with handles and user data (see GUIDATA)
3135
3136% Hints: get(hObject,'String') returns contents of edit86 as text
3137%        str2double(get(hObject,'String')) returns contents of edit86 as a double
3138
3139
3140% --- Executes during object creation, after setting all properties.
3141function edit86_CreateFcn(hObject, eventdata, handles)
3142% hObject    handle to edit86 (see GCBO)
3143% eventdata  reserved - to be defined in a future version of MATLAB
3144% handles    empty - handles not created until after all CreateFcns called
3145
3146% Hint: edit controls usually have a white background on Windows.
3147%       See ISPC and COMPUTER.
3148if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3149    set(hObject,'BackgroundColor','white');
3150end
3151
3152
3153
3154function edit87_Callback(hObject, eventdata, handles)
3155% hObject    handle to edit87 (see GCBO)
3156% eventdata  reserved - to be defined in a future version of MATLAB
3157% handles    structure with handles and user data (see GUIDATA)
3158
3159% Hints: get(hObject,'String') returns contents of edit87 as text
3160%        str2double(get(hObject,'String')) returns contents of edit87 as a double
3161
3162
3163% --- Executes during object creation, after setting all properties.
3164function edit87_CreateFcn(hObject, eventdata, handles)
3165% hObject    handle to edit87 (see GCBO)
3166% eventdata  reserved - to be defined in a future version of MATLAB
3167% handles    empty - handles not created until after all CreateFcns called
3168
3169% Hint: edit controls usually have a white background on Windows.
3170%       See ISPC and COMPUTER.
3171if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3172    set(hObject,'BackgroundColor','white');
3173end
3174
3175
3176% --- Executes on button press in checkbox39.
3177function checkbox39_Callback(hObject, eventdata, handles)
3178% hObject    handle to checkbox39 (see GCBO)
3179% eventdata  reserved - to be defined in a future version of MATLAB
3180% handles    structure with handles and user data (see GUIDATA)
3181
3182% Hint: get(hObject,'Value') returns toggle state of checkbox39
3183
3184
3185
3186function edit88_Callback(hObject, eventdata, handles)
3187% hObject    handle to edit88 (see GCBO)
3188% eventdata  reserved - to be defined in a future version of MATLAB
3189% handles    structure with handles and user data (see GUIDATA)
3190
3191% Hints: get(hObject,'String') returns contents of edit88 as text
3192%        str2double(get(hObject,'String')) returns contents of edit88 as a double
3193
3194
3195% --- Executes during object creation, after setting all properties.
3196function edit88_CreateFcn(hObject, eventdata, handles)
3197% hObject    handle to edit88 (see GCBO)
3198% eventdata  reserved - to be defined in a future version of MATLAB
3199% handles    empty - handles not created until after all CreateFcns called
3200
3201% Hint: edit controls usually have a white background on Windows.
3202%       See ISPC and COMPUTER.
3203if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3204    set(hObject,'BackgroundColor','white');
3205end
3206
3207
3208% --- Executes on button press in checkbox40.
3209function checkbox40_Callback(hObject, eventdata, handles)
3210% hObject    handle to checkbox40 (see GCBO)
3211% eventdata  reserved - to be defined in a future version of MATLAB
3212% handles    structure with handles and user data (see GUIDATA)
3213
3214% Hint: get(hObject,'Value') returns toggle state of checkbox40
3215
3216
3217
3218function edit82_Callback(hObject, eventdata, handles)
3219% hObject    handle to edit82 (see GCBO)
3220% eventdata  reserved - to be defined in a future version of MATLAB
3221% handles    structure with handles and user data (see GUIDATA)
3222
3223% Hints: get(hObject,'String') returns contents of edit82 as text
3224%        str2double(get(hObject,'String')) returns contents of edit82 as a double
3225
3226
3227% --- Executes during object creation, after setting all properties.
3228function edit82_CreateFcn(hObject, eventdata, handles)
3229% hObject    handle to edit82 (see GCBO)
3230% eventdata  reserved - to be defined in a future version of MATLAB
3231% handles    empty - handles not created until after all CreateFcns called
3232
3233% Hint: edit controls usually have a white background on Windows.
3234%       See ISPC and COMPUTER.
3235if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3236    set(hObject,'BackgroundColor','white');
3237end
3238
3239
3240
3241function edit83_Callback(hObject, eventdata, handles)
3242% hObject    handle to edit83 (see GCBO)
3243% eventdata  reserved - to be defined in a future version of MATLAB
3244% handles    structure with handles and user data (see GUIDATA)
3245
3246% Hints: get(hObject,'String') returns contents of edit83 as text
3247%        str2double(get(hObject,'String')) returns contents of edit83 as a double
3248
3249
3250% --- Executes during object creation, after setting all properties.
3251function edit83_CreateFcn(hObject, eventdata, handles)
3252% hObject    handle to edit83 (see GCBO)
3253% eventdata  reserved - to be defined in a future version of MATLAB
3254% handles    empty - handles not created until after all CreateFcns called
3255
3256% Hint: edit controls usually have a white background on Windows.
3257%       See ISPC and COMPUTER.
3258if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3259    set(hObject,'BackgroundColor','white');
3260end
3261
3262
3263% --- Executes on slider movement.
3264function slider9_Callback(hObject, eventdata, handles)
3265% hObject    handle to slider9 (see GCBO)
3266% eventdata  reserved - to be defined in a future version of MATLAB
3267% handles    structure with handles and user data (see GUIDATA)
3268
3269% Hints: get(hObject,'Value') returns position of slider
3270%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
3271
3272
3273% --- Executes during object creation, after setting all properties.
3274function slider9_CreateFcn(hObject, eventdata, handles)
3275% hObject    handle to slider9 (see GCBO)
3276% eventdata  reserved - to be defined in a future version of MATLAB
3277% handles    empty - handles not created until after all CreateFcns called
3278
3279% Hint: slider controls usually have a light gray background.
3280if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3281    set(hObject,'BackgroundColor',[.9 .9 .9]);
3282end
3283
3284
3285% --- Executes on slider movement.
3286function slider10_Callback(hObject, eventdata, handles)
3287% hObject    handle to slider10 (see GCBO)
3288% eventdata  reserved - to be defined in a future version of MATLAB
3289% handles    structure with handles and user data (see GUIDATA)
3290
3291% Hints: get(hObject,'Value') returns position of slider
3292%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
3293
3294
3295% --- Executes during object creation, after setting all properties.
3296function slider10_CreateFcn(hObject, eventdata, handles)
3297% hObject    handle to slider10 (see GCBO)
3298% eventdata  reserved - to be defined in a future version of MATLAB
3299% handles    empty - handles not created until after all CreateFcns called
3300
3301% Hint: slider controls usually have a light gray background.
3302if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3303    set(hObject,'BackgroundColor',[.9 .9 .9]);
3304end
3305
3306
3307% --- Executes on button press in checkbox41.
3308function checkbox41_Callback(hObject, eventdata, handles)
3309% hObject    handle to checkbox41 (see GCBO)
3310% eventdata  reserved - to be defined in a future version of MATLAB
3311% handles    structure with handles and user data (see GUIDATA)
3312
3313% Hint: get(hObject,'Value') returns toggle state of checkbox41
3314
3315
3316
3317function edit89_Callback(hObject, eventdata, handles)
3318% hObject    handle to edit89 (see GCBO)
3319% eventdata  reserved - to be defined in a future version of MATLAB
3320% handles    structure with handles and user data (see GUIDATA)
3321
3322% Hints: get(hObject,'String') returns contents of edit89 as text
3323%        str2double(get(hObject,'String')) returns contents of edit89 as a double
3324
3325
3326% --- Executes during object creation, after setting all properties.
3327function edit89_CreateFcn(hObject, eventdata, handles)
3328% hObject    handle to edit89 (see GCBO)
3329% eventdata  reserved - to be defined in a future version of MATLAB
3330% handles    empty - handles not created until after all CreateFcns called
3331
3332% Hint: edit controls usually have a white background on Windows.
3333%       See ISPC and COMPUTER.
3334if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3335    set(hObject,'BackgroundColor','white');
3336end
3337
3338
3339
3340function edit90_Callback(hObject, eventdata, handles)
3341% hObject    handle to edit90 (see GCBO)
3342% eventdata  reserved - to be defined in a future version of MATLAB
3343% handles    structure with handles and user data (see GUIDATA)
3344
3345% Hints: get(hObject,'String') returns contents of edit90 as text
3346%        str2double(get(hObject,'String')) returns contents of edit90 as a double
3347
3348
3349% --- Executes during object creation, after setting all properties.
3350function edit90_CreateFcn(hObject, eventdata, handles)
3351% hObject    handle to edit90 (see GCBO)
3352% eventdata  reserved - to be defined in a future version of MATLAB
3353% handles    empty - handles not created until after all CreateFcns called
3354
3355% Hint: edit controls usually have a white background on Windows.
3356%       See ISPC and COMPUTER.
3357if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
3358    set(hObject,'BackgroundColor','white');
3359end
3360
3361
3362% --- Executes on button press in pushbutton35.
3363function pushbutton35_Callback(hObject, eventdata, handles)
3364% hObject    handle to pushbutton35 (see GCBO)
3365% eventdata  reserved - to be defined in a future version of MATLAB
3366% handles    structure with handles and user data (see GUIDATA)
3367
3368
Note: See TracBrowser for help on using the repository browser.