source: trunk/src/view_field.m @ 353

Last change on this file since 353 was 329, checked in by sommeria, 12 years ago

bugs repaired in series, default size of view_field changed. ';' added in proj_field

File size: 31.3 KB
Line 
1%'view_field': function associated with the GUI 'view_field.fig' for images and data field visualization
2%------------------------------------------------------------------------
3% function huvmat=view_field(input)
4%
5%OUTPUT
6% huvmat=current handles of the GUI view_field.fig
7%%
8%
9%INPUT:
10% input: input file name (if character chain), or input image matrix to
11% visualize, or Matlab structure representing  netcdf fields (with fields
12% ListVarName....)
13%
14%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
15%  Copyright Joel Sommeria,  2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr.
16%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
17%     This open is part of the toolbox VIEW_FIELD.
18%
19%     VIEW_FIELD is free software; you can redistribute it and/or modify
20%     it under the terms of the GNU General Public License as published by
21%     the Free Software Foundation; either version 2 of the License, or
22%     (at your option) any later version.
23%
24%     VIEW_FIELD is distributed in the hope that it will be useful,
25%     but WITHOUT ANY WARRANTY; without even the implied warranty of
26%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27%     GNU General Public License (open VIEW_FIELD/COPYING.txt) for more details.
28%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
29
30%-------------------------------------------------------------------
31%  I - MAIN FUNCTION VIEW_FIELD (DO NOT MODIFY)
32%-------------------------------------------------------------------
33%-------------------------------------------------------------------
34function varargout = view_field(varargin)
35
36% Begin initialization code - DO NOT EDIT
37gui_Singleton = 1;
38gui_State = struct('gui_Name',          mfilename, ...
39                   'gui_Singleton',     gui_Singleton, ...
40                   'gui_OpeningFcn',    @view_field_OpeningFcn, ...
41                   'gui_OutputFcn',     @view_field_OutputFcn, ...
42                   'gui_LayoutFcn',     [], ...
43                   'gui_Callback',      []);
44if nargin && ischar(varargin{1})
45    gui_State.gui_Callback = str2func(varargin{1});
46end
47
48if nargout
49    varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
50else
51    gui_mainfcn(gui_State, varargin{:});
52end
53% End initialization code - DO NOT EDIT
54
55%-------------------------------------------------------------------
56% --- Executes just before view_field is made visible.
57function view_field_OpeningFcn(hObject, eventdata, handles, Field )
58%-------------------------------------------------------------------
59
60% Choose default command menuline output for view_field
61handles.output = handles.view_field;
62
63% Update handles structure
64guidata(hObject, handles);
65
66dircur=pwd; %current working directory
67dir_opening=dircur;
68
69% set the position of colorbar and ancillary GUIs:
70set(hObject,'Units','Normalized')
71handles_mouse=handles;
72huvmat=findobj(allchild(0),'Name','uvmat');
73if ~isempty(huvmat)
74    hhuvmat=guidata(huvmat);
75%     set(hhuvmat.list_object_2,'Visible','on')
76%     set(hhuvmat.view_field_title,'Visible','on')
77    % handles_mouse.create=hhuvmat.create;
78    handles_mouse.edit=hhuvmat.edit_object;
79    pos_view_field=get(hObject,'Position');
80    pos_uvmat=get(huvmat,'Position');
81    pos_view_field(1)=pos_uvmat(1)+pos_uvmat(3)/2;
82    pos_view_field(2)=pos_uvmat(2)-pos_uvmat(3)/4;
83%      pos_view_field(3:4)=pos_uvmat(3:4);
84    set(hObject,'Position',pos_view_field)
85end
86
87%functions for the mouse and keyboard
88set(hObject,'KeyPressFcn',{'keyboard_callback',handles_mouse})%set keyboard action function
89set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles_mouse})%set mouse action functio
90set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
91set(hObject,'WindowButtonUpFcn',{'mouse_up',handles_mouse})
92set(hObject,'CloseRequestFcn',{@closefcn})%
93ViewFieldData.axes3=[];%initiates the record of the current field (will be updated by plot_field)
94set(handles.view_field,'UserData',ViewFieldData);%store the current field
95AxeData.LimEditBox=1; %initialise AxeData, the parent figure sets plot parameters
96set(handles.axes3,'UserData',AxeData)
97if ~exist('Field','var')
98    return
99end
100[PlotType,PlotParamOut]= plot_field(Field,handles.axes3);%,PlotParam,KeepLim,PosColorbar)
101
102if isfield(PlotParamOut,'Vectors')
103    set(handles.Vectors,'Visible','on')
104end
105write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters
106
107%-------------------------------------------------------------------
108% --- Outputs from this function are returned to the command menuline.
109function varargout = view_field_OutputFcn(hObject, eventdata, handles)
110varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
111
112
113%-------------------------------------------------------------------
114%-------------------------------------------------------------------
115% II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
116% automatically sets the global properties when the rootfile name is introduced
117% then activate the view-field action if selected
118% it is activated either by clicking on the RootPath window or by the
119% browser
120%------------------------------------------------------------------
121%------------------------------------------------------------------
122
123%-------------------------------------------------------------------
124function update_mask(handles,num_i1,num_j1)
125%-------------------------------------------------------------------
126
127MaskData=get(handles.mask_test,'UserData');
128if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
129    uistack(MaskData.maskhandle,'top');
130end
131num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
132[MaskName,mdetect]=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
133huvmat=get(handles.mask_test,'parent');
134UvData=get(huvmat,'UserData');
135
136%update mask image if the mask is new
137if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
138    UvData.MaskName=MaskName; %update the recorded name on UvData
139    set(huvmat,'UserData',UvData);
140    if mdetect==0
141        if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
142            delete(MaskData.maskhandle)   
143        end
144    else
145        %read mask image
146        Mask.AName='image';
147        Mask.A=imread(MaskName);
148        npxy=size(Mask.A);
149        Mask.AX=[0.5 npxy(2)-0.5];
150        Mask.AY=[npxy(1)-0.5 0.5 ];
151        Mask.CoordUnit='pixel';
152        if isequal(get(handles.slices,'Value'),1)
153           NbSlice=str2num(get(handles.nb_slice,'String'));
154           num_i1=str2num(get(handles.i1,'String'));
155           Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
156        end
157        %px to phys or other transform on field
158         menu_transform=get(handles.transform_fct,'String');
159        choice_value=get(handles.transform_fct,'Value');
160        transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
161        transform_list=get(handles.transform_fct,'UserData');
162        transform=transform_list{choice_value};
163        if  ~isequal(transform_name,'') && ~isequal(transform_name,'px')
164            if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
165                Calib=UvData.XmlData.GeometryCalib;
166                Mask=transform(Mask,UvData.XmlData);
167            end
168        end
169        flagmask=Mask.A < 200;
170       
171        %make brown color image
172        imflag(:,:,1)=0.9*flagmask;
173        imflag(:,:,2)=0.7*flagmask;
174        imflag(:,:,3)=zeros(size(flagmask));
175       
176        %update mask image
177        hmask=[]; %default
178        if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
179            hmask=MaskData.maskhandle;
180        end
181        if ~isempty(hmask)
182            set(hmask,'CData',imflag)   
183            set(hmask,'AlphaData',flagmask*0.6)
184            set(hmask,'XData',Mask.AX);
185            set(hmask,'YData',Mask.AY);
186%             uistack(hmask,'top')
187        else
188            axes(handles.axes3)
189            hold on   
190            MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
191%             set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
192            set(handles.mask_test,'UserData',MaskData)
193        end
194    end
195end
196
197
198%-------------------------------------------------------------------
199function MenuExportFigure_Callback(hObject, eventdata, handles)
200%-------------------------------------------------------------------
201huvmat=get(handles.MenuExport,'parent');
202UvData=get(huvmat,'UserData');
203hfig=figure;
204newaxes=copyobj(handles.axes3,hfig);
205map=colormap(handles.axes3);
206colormap(map);%transmit the current colormap to the zoom fig
207colorbar
208
209%-------------------------------------------------------------------
210%-------------------------------------------------------------------
211% III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
212%-------------------------------------------------------------------
213%-------------------------------------------------------------------
214
215%Executes on button press in runplus: make one step forward and call
216%run0. The step forward is along the fields series 1 or 2 depending on
217%the scan_i and scan_j check box (exclusive each other)
218%-------------------------------------------------------------------
219function runplus_Callback(hObject, eventdata, handles)
220increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
221runpm(hObject,eventdata,handles,increment)
222
223%-------------------------------------------------------------------
224%Executes on button press in runmin: make one step backward and call
225%run0. The step backward is along the fields series 1 or 2 depending on
226%the scan_i and scan_j check box (exclusive each other)
227%-------------------------------------------------------------------
228function runmin_Callback(hObject, eventdata, handles)
229increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
230runpm(hObject,eventdata,handles,increment)
231
232%-------------------------------------------------------------------
233%Executes on button press in runmin: make one step backward and call
234%run0. The step backward is along the fields series 1 or 2 depending on
235%the scan_i and scan_j check box (exclusive each other)
236%-------------------------------------------------------------------
237function RunMovie_Callback(hObject, eventdata, handles)
238%------------------------------------------------------------------
239set(handles.RunMovie,'BackgroundColor',[1 1 0])%paint the command button in yellow
240drawnow
241increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
242set(handles.STOP,'Visible','on')
243set(handles.speed,'Visible','on')
244set(handles.speed_txt,'Visible','on')
245set(handles.RunMovie,'BusyAction','queue')
246testavi=0;
247UvData=get(handles.view_field,'UserData');
248
249while get(handles.speed,'Value')~=0 & isequal(get(handles.RunMovie,'BusyAction'),'queue') % enable STOP command
250        runpm(hObject,eventdata,handles,increment)
251        pause(1.02-get(handles.speed,'Value'))% wait for next image
252end
253if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
254    UvData.aviobj=close(UvData.aviobj);
255   set(handles.view_field,'UserData',UvData);
256end
257set(handles.RunMovie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
258
259
260
261%-------------------------------------------------------------------
262% --- translate coordinate to matrix index
263%-------------------------------------------------------------------
264function [indx,indy]=pos2ind(x0,rangx0,nxy)
265indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel 
266indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
267
268%-------------------------------------------------------------------
269% --- Executes on button press in 'FixLimits'.
270%-------------------------------------------------------------------
271function CheckFixLimits_Callback(hObject, eventdata, handles)
272test=get(handles.CheckFixLimits,'Value');
273if test
274    set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
275else
276    set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
277end
278update_plot(handles)
279
280%-------------------------------------------------------------------
281% --- Executes on button press in FixEqual.
282function CheckFixEqual_Callback(hObject, eventdata, handles)
283test=get(handles.CheckFixEqual,'Value');
284if test
285    set(handles.CheckFixEqual,'BackgroundColor',[1 1 0])
286    cla(handles.axes3)
287else
288    set(handles.CheckFixEqual,'BackgroundColor',[0.7 0.7 0.7])
289end
290 update_plot(handles)
291
292%-------------------------------------------------------------------
293
294%-------------------------------------------------------------------
295% --- Executes on button press in 'zoom'.
296%-------------------------------------------------------------------
297function zoom_Callback(hObject, eventdata, handles)
298if (get(handles.zoom,'Value') == 1);
299    set(handles.zoom,'BackgroundColor',[1 1 0])
300    set(handles.FixLimits,'Value',1)% propose by default fixed limits for the plotting axes
301    set(handles.FixLimits,'BackgroundColor',[1 1 0])
302else
303    set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
304end
305
306%-------------------------------------------------------------------
307%----Executes on button press in 'record': records the current flags of manual correction.
308%-------------------------------------------------------------------
309function record_Callback(hObject, eventdata, handles)
310% [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
311filename=read_file_boxes(handles);
312AxeData=get(gca,'UserData');
313[erread,message]=fileattrib(filename);
314if ~isempty(message) && ~isequal(message.UserWrite,1)
315     msgbox_view_field('ERROR',['no writting access to ' filename])
316     return
317end
318test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
319test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
320if ~test_civ2 && ~test_civ1
321    msgbox_view_field('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
322end
323if test_civ2
324    nbname='nb_vectors2';
325   flagname='vec2_FixFlag';
326   attrname='fix2';
327end
328if test_civ1
329    nbname='nb_vectors';
330   flagname='vec_FixFlag';
331   attrname='fix';
332end
333%write fix flags in the netcdf file
334hhh=which('netcdf.open');% look for built-in matlab netcdf library
335if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
336    nc=netcdf.open(filename,'NC_WRITE');
337    netcdf.reDef(nc)
338    netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
339    dimid = netcdf.inqDimID(nc,nbname);
340    try
341        varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
342    catch
343        varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
344    end
345    netcdf.endDef(nc)
346    netcdf.putVar(nc,varid,AxeData.FF);
347    netcdf.close(nc) 
348else %old netcdf library
349    netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
350end
351
352function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
353nc=netcdf(filename,'write'); %open netcdf file
354result=redef(nc);
355eval(['nc.' attrname '=1;']);
356theDim=nc(nbname) ;% get the number of velocity vectors
357nb_vectors=size(theDim);
358var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
359var_FixFlag(1:nb_vectors)=AxeData.FF;%
360fin=close(nc);
361
362
363%-------------------------------------------------------------------
364%-------------------------------------------------------------------
365%  - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
366
367%------------------------------------------------------------------
368
369
370%------------------------------------------------------------------
371% --- Executes on selection change in col_vec: choice of the color code.
372%
373function col_vec_Callback(hObject, eventdata, handles)
374%------------------------------------------------------------------
375% edit the choice for color code
376list_code=get(handles.col_vec,'String');% list menu fields
377index_code=get(handles.col_vec,'Value');% selected string index
378col_code= list_code{index_code(1)}; % selected field
379if isequal(col_code,'black') | isequal(col_code,'white')
380   set(handles.slider1,'Visible','off')
381   set(handles.slider2,'Visible','off')
382   set(handles.colcode1,'Visible','off')
383   set(handles.colcode2,'Visible','off')
384   set(handles.AutoVecColor,'Visible','off')
385   set_vec_col_bar(handles)
386else
387   set(handles.slider1,'Visible','on')
388   set(handles.slider2,'Visible','on')
389   set(handles.colcode1,'Visible','on')
390   set(handles.colcode2,'Visible','on')
391   set(handles.AutoVecColor,'Visible','on') 
392   if isequal(col_code,'ima_cor')
393       set(handles.AutoVecColor,'Value',0)%fixed scale by default
394       set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
395       set(handles.slider1,'Min',0);
396       set(handles.slider1,'Max',1);
397       set(handles.slider2,'Min',0);
398       set(handles.slider2,'Max',1);
399 %      set(handles.min_C_title_vec,'String','0')
400       set(handles.max_vec,'String','1')
401       set(handles.colcode1,'String','0.333')
402       colcode1_Callback(hObject, eventdata, handles)
403       set(handles.colcode2,'String','0.666')
404       colcode2_Callback(hObject, eventdata, handles)
405   else
406       set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
407       set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
408       minval=get(handles.slider1,'Min');
409       maxval=get(handles.slider1,'Max');
410       set(handles.slider1,'Value',minval)
411       set(handles.slider2,'Value',maxval)
412       set_vec_col_bar(handles)
413   end
414%    slider_update(handles)
415end
416%replot the current graph
417run0_Callback(hObject, eventdata, handles)
418
419
420%----------------------------------------------------------------
421% -- Executes on slider movement to set the color code
422%
423function slider1_Callback(hObject, eventdata, handles)
424%------------------------------------------------------------------
425slider1=get(handles.slider1,'Value');
426min_val=str2num(get(handles.min_vec,'String'));
427max_val=str2num(get(handles.max_vec,'String'));
428col=min_val+(max_val-min_val)*slider1;
429set(handles.colcode1,'String',num2str(col))
430if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
431    set(handles.slider2,'Value',col)
432    set(handles.colcode2,'String',num2str(col))
433end
434colcode1_Callback(hObject, eventdata, handles)
435
436%----------------------------------------------------------------
437% Executes on slider movement to set the color code
438%----------------------------------------------------------------
439function slider2_Callback(hObject, eventdata, handles)
440slider2=get(handles.slider2,'Value');
441min_val=str2num(get(handles.min_vec,'String'));
442max_val=str2num(get(handles.max_vec,'String'));
443col=min_val+(max_val-min_val)*slider2;
444set(handles.colcode2,'String',num2str(col))
445if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
446    set(handles.slider1,'Value',col)
447    set(handles.colcode1,'String',num2str(col))
448end
449colcode2_Callback(hObject, eventdata, handles)
450
451%----------------------------------------------------------------
452%execute on return carriage on the edit box corresponding to slider 1
453%----------------------------------------------------------------
454function colcode1_Callback(hObject, eventdata, handles)
455% col=str2num(get(handles.colcode1,'String'));
456% set(handles.slider1,'Value',col)
457set_vec_col_bar(handles)
458update_plot(handles)
459
460%----------------------------------------------------------------
461%execute on return carriage on the edit box corresponding to slider 2
462%----------------------------------------------------------------
463function colcode2_Callback(hObject, eventdata, handles)
464% col=str2num(get(handles.colcode2,'String'));
465% set(handles.slider2,'Value',col)
466% slider2_Callback(hObject, eventdata, handles)
467set_vec_col_bar(handles)
468update_plot(handles)
469%------------------------------------------------------------
470%update the slider values after displaying vectors
471%--------------------------------------------------------
472% function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
473% set(handles.slider1,'Min',minC)
474% set(handles.slider1,'Max',maxC)
475% set(handles.slider2,'Min',minC)
476% set(handles.slider2,'Max',maxC)
477% set(handles.min_C_title_vec,'String',num2str(minC))
478% set(handles.max_vec,'String',num2str(maxC))
479% if auto
480%         set(handles.colcode1,'String',num2str(colcode1,3))%update display
481%         set(handles.colcode2,'String',num2str(colcode2,3))
482% end
483% set(handles.slider1,'Value',colcode1)%update slider with constant display
484% set(handles.slider2,'Value',colcode2)
485% set_vec_col_bar(handles)
486
487
488%-------------------------------------------------------
489% --- Executes on button press in AutoVecColor.
490%-------------------------------------------------------
491function vec_col_bar_Callback(hObject, eventdata, handles)
492set_vec_col_bar(handles)
493
494%------------------------------------------------
495%CALLBACKS FOR PLOTTING PARAMETERS
496%-------------------------------------------------
497
498%------------------------------------------------------------------------
499function num_MinX_Callback(hObject, eventdata, handles)
500%------------------------------------------------------------------------
501set(handles.CheckFixLimits,'Value',1) %suppress auto mode
502set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
503update_plot(handles);
504
505%------------------------------------------------------------------------
506function num_MaxX_Callback(hObject, eventdata, handles)
507%------------------------------------------------------------------------
508set(handles.CheckFixLimits,'Value',1) %suppress auto mode
509set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
510update_plot(handles);
511
512%------------------------------------------------------------------------
513function num_MinY_Callback(hObject, eventdata, handles)
514%------------------------------------------
515set(handles.CheckFixLimits,'Value',1) %suppress auto mode
516set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
517update_plot(handles);
518
519%------------------------------------------------------------------------
520function num_MaxY_Callback(hObject, eventdata, handles)
521%------------------------------------------------------------------------
522set(handles.CheckFixLimits,'Value',1) %suppress auto mode
523set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
524update_plot(handles);
525
526%-----------------------------------------------------------------
527function num_MinA_Callback(hObject, eventdata, handles)
528%------------------------------------------
529set(handles.CheckFixScalar,'Value',1) %suppress auto mode
530set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
531update_plot(handles)
532
533%-----------------------------------------------------------------
534function num_MaxA_Callback(hObject, eventdata, handles)
535%--------------------------------------------
536set(handles.CheckFixScalar,'Value',1) %suppress auto mode
537set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
538update_plot(handles)
539
540%-----------------------------------------------
541function CheckFixScalar_Callback(hObject, eventdata, handles)
542%--------------------------------------------
543test=get(handles.CheckFixScalar,'Value');
544if test
545    set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
546else
547    set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
548    update_plot(handles);
549%     set(handles.MinA,'String',num2str(ScalOut.MinA,3))
550%     set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
551end
552
553%-------------------------------------------------------------------
554function CheckBW_Callback(hObject, eventdata, handles)
555%-------------------------------------------------------------------
556update_plot(handles)
557
558%-------------------------------------------------------------------
559function ListContour_Callback(hObject, eventdata, handles)
560%-------------------------------------------------------------------
561val=get(handles.Contours,'Value');
562if val==2
563    set(handles.interval_txt,'Visible','on')
564    set(handles.IncrA,'Visible','on')
565else
566    set(handles.interval_txt,'Visible','off')
567    set(handles.IncrA,'Visible','off')
568end
569update_plot(handles)
570
571%-------------------------------------------------------------------
572function IncrA_Callback(hObject, eventdata, handles)
573%-------------------------------------------------------------------
574update_plot(handles)
575
576%-------------------------------------------------------------------
577function HideWarning_Callback(hObject, eventdata, handles)
578%-------------------------------------------------------------------
579update_plot(handles)
580
581%-------------------------------------------------------------------
582function HideFalse_Callback(hObject, eventdata, handles)
583%-------------------------------------------------------------------
584update_plot(handles)
585
586%-------------------------------------------------------------------
587function VecScale_Callback(hObject, eventdata, handles)
588%-------------------------------------------------------------------
589set(handles.FixVec,'Value',1);
590set(handles.FixVec,'BackgroundColor',[1 1 0])
591update_plot(handles)
592
593%-------------------------------------------------------------------
594function FixVec_Callback(hObject, eventdata, handles)
595%-------------------------------------------------------------------
596test=get(handles.FixVec,'Value');
597if test
598    set(handles.FixVec,'BackgroundColor',[1 1 0])
599else
600    update_plot(handles);
601    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
602    set(handles.FixVec,'BackgroundColor',[0.7 0.7 0.7])
603end
604
605%-------------------------------------------------------
606% --- Executes on selection change in decimate4 (nb_vec/4).
607%-------------------------------------------------------
608function CheckDecimate4_Callback(hObject, eventdata, handles)
609update_plot(handles)
610
611
612%-------------------------------------------------------
613% --- Executes on selection change in color_code menu
614%-------------------------------------------------------
615function color_code_Callback(hObject, eventdata, handles)
616set_vec_col_bar(handles)
617update_plot(handles);
618
619%-------------------------------------------------------
620% --- Executes on button press in AutoVecColor.
621%-------------------------------------------------------
622function AutoVecColor_Callback(hObject, eventdata, handles)
623test=get(handles.AutoVecColor,'Value');
624if test
625    set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
626else
627    update_plot(handles);
628    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
629    set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
630end
631%set_vec_col_bar(handles)
632
633%-------------------------------------------------------
634% --- Executes on selection change in max_vec.
635%-------------------------------------------------------
636function min_vec_Callback(hObject, eventdata, handles)
637max_vec_Callback(hObject, eventdata, handles)
638
639% --- Executes on selection change in max_vec.
640function max_vec_Callback(hObject, eventdata, handles)
641set(handles.AutoVecColor,'Value',1)
642AutoVecColor_Callback(hObject, eventdata, handles)
643min_val=str2num(get(handles.min_vec,'String'));
644max_val=str2num(get(handles.max_vec,'String'));
645slider1=get(handles.slider1,'Value');
646slider2=get(handles.slider2,'Value');
647colcode1=min_val+(max_val-min_val)*slider1;
648colcode2=min_val+(max_val-min_val)*slider2;
649set(handles.colcode1,'String',num2str(colcode1))
650set(handles.colcode2,'String',num2str(colcode2))
651update_plot(handles);
652
653%-------------------------------------------------------------------
654%update the display of color code for vectors
655function set_vec_col_bar(handles)
656%-------------------------------------------------------------------
657%get the image of the color display button 'vec_col_bar' in pixels
658set(handles.vec_col_bar,'Unit','pixel');
659pos_vert=get(handles.vec_col_bar,'Position');
660set(handles.vec_col_bar,'Unit','Normalized');
661width=ceil(pos_vert(3));
662height=ceil(pos_vert(4));
663
664%get slider indications
665list=get(handles.color_code,'String');
666ichoice=get(handles.color_code,'Value');
667colcode.ColorCode=list{ichoice};
668colcode.MinC=str2num(get(handles.min_vec,'String'));
669colcode.MaxC=str2num(get(handles.max_vec,'String'));
670test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
671if test3color
672    colcode.colcode1=str2num(get(handles.colcode1,'String'));
673    colcode.colcode2=str2num(get(handles.colcode2,'String'));
674end
675colcode.FixedCbounds=0;
676colcode.FixedCbounds=1;
677vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
678[colorlist,col_vec]=set_col_vec(colcode,vec_C);
679oneheight=ones(1,height);
680A1=colorlist(col_vec,1)*oneheight;
681A2=colorlist(col_vec,2)*oneheight;
682A3=colorlist(col_vec,3)*oneheight;
683A(:,:,1)=A1';
684A(:,:,2)=A2';
685A(:,:,3)=A3';
686set(handles.vec_col_bar,'Cdata',A)
687
688% %------------------------------------------------------------------------
689% function PlotType=update_plot(handles)
690% %------------------------------------------------------------------------
691% haxes= handles.axes3;
692%
693% %ProjField=get(haxes,'UserData');
694% ViewFieldData=get(handles.view_field,'UserData');
695% ProjField=ViewFieldData.axes3;
696% %ProjField=get(haxes,'UserData');
697% PlotParam=read_GUI(handles.view_field);
698% [PlotType,PlotParamOut]= plot_field(ProjField,haxes,PlotParam,1);
699% write_plot_param(handles,PlotParamOut); %update the auto plot parameters
700
701%-------------------------------------------------------------------
702function update_plot(handles)
703%-------------------------------------------------------------------
704Data=get(handles.view_field,'UserData');
705AxeData=Data.axes3;% retrieve the current plotted data
706PlotParam=read_GUI(handles.view_field);
707[PP,PlotParamOut]= plot_field(AxeData,handles.axes3,PlotParam);
708write_plot_param(handles,PlotParamOut); %update the auto plot parameters
709
710%------------------------------------------------------------------------
711% --- Executes on button press in Menu/Export/field in workspace.
712function MenuExportField_Callback(hObject, eventdata, handles)
713%------------------------------------------------------------------------
714global Data_view_field
715% huvmat=findobj(allchild(0),'Name','uvmat');
716Data_view_field=get(handles.view_field,'UserData');
717Data_view_field=Data_view_field.axes3;
718% Data_view_field=UvData.ProjField_2;
719evalin('base','global Data_view_field')%make CurData global in the workspace
720display(['UserData of view_field :'])
721evalin('base','Data_view_field') %display CurData in the workspace
722commandwindow;
723
724%------------------------------------------------------------------------
725% --- Executes on button press in Menu/Export/extract figure.
726function MenuExport_plot_Callback(hObject, eventdata, handles)
727%------------------------------------------------------------------------
728huvmat=get(handles.MenuExport_plot,'parent');
729UvData=get(huvmat,'UserData');
730hfig=figure;
731newaxes=copyobj(handles.axes3,hfig);
732map=colormap(handles.axes3);
733colormap(map);%transmit the current colormap to the zoom fig
734colorbar
735
736%------------------------------------------------------------------------
737function closefcn(hObject, eventdata, handles)
738%------------------------------------------------------------------------
739huvmat=findobj(allchild(0),'Name','uvmat');
740if ~isempty(huvmat)
741hhuvmat=guidata(huvmat);
742% list_object_2=get(hhuvmat.list_object_2,'String');
743% set(hhuvmat.list_object_2,'Value',1)%select the last value ('...')
744end
745delete(hObject)
746
Note: See TracBrowser for help on using the repository browser.