source: trunk/src/view_field.m @ 418

Last change on this file since 418 was 413, checked in by sommeria, 12 years ago

various bugs corrected and improvement in civ1_TEST

File size: 33.2 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    handles_mouse.edit=hhuvmat.edit_object;
76    pos_view_field=get(hObject,'Position');
77    pos_uvmat=get(huvmat,'Position');
78    pos_view_field(1)=pos_uvmat(1)+pos_uvmat(3)/2;
79    pos_view_field(2)=pos_uvmat(2)-pos_uvmat(3)/4;
80%      pos_view_field(3:4)=pos_uvmat(3:4);
81    set(hObject,'Position',pos_view_field)
82end
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})
89set(hObject,'DeleteFcn',{@closefcn})%
90ViewFieldData.axes3=[];%initiates the record of the current field (will be updated by plot_field)
91set(handles.view_field,'UserData',ViewFieldData);%store the current field
92AxeData.LimEditBox=1; %initialise AxeData, the parent figure sets plot parameters
93set(handles.axes3,'UserData',AxeData)
94if exist('Field','var')
95    [PlotType,PlotParamOut]= plot_field(Field,handles.axes3);%,PlotParam,KeepLim,PosColorbar)
96    set(handles.Coordinates,'Visible','on')
97    if isfield(PlotParamOut,'Vectors')
98        set(handles.Vectors,'Visible','on')
99    end
100    write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters
101end
102%------------------------------------------------------------------------
103% --- Outputs from this function are returned to the command menuline.
104function varargout = view_field_OutputFcn(hObject, eventdata, handles)
105%------------------------------------------------------------------------
106varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
107
108%------------------------------------------------------------------------
109%--- activated when closing the GUI view_field
110function closefcn(gcbo,eventdata)
111%------------------------------------------------------------------------
112huvmat=findobj(allchild(0),'Tag','uvmat');%find the current uvmat interface handle
113if ~isempty(huvmat)
114    hhuvmat=guidata(huvmat);
115    set(hhuvmat.edit_object,'Value',0)
116    set(hhuvmat.edit_object,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree
117    % deselect the object in ListObject when view_field is closed
118    if isempty(findobj(allchild(0),'Tag','set_object'))
119        ObjIndex=get(hhuvmat.ListObject,'Value');
120        ObjIndex=ObjIndex(1);%keep only the first object selected
121        set(hhuvmat.ListObject,'Value',ObjIndex)
122        % draw all object colors in blue (unselected) in uvmat
123        hother=[findobj(hhuvmat.axes3,'Tag','proj_object');findobj(hhuvmat.axes3,'Tag','DeformPoint')];%find all the proj object and deform point representations
124        for iobj=1:length(hother)
125            if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
126                set(hother(iobj),'EdgeColor','b')
127                if isequal(get(hother(iobj),'FaceColor'),'m')
128                    set(hother(iobj),'FaceColor','b')
129                end
130            elseif isequal(get(hother(iobj),'Type'),'image')
131                Acolor=get(hother(iobj),'CData');
132                Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
133                set(hother(iobj),'CData',Acolor);
134            else
135                set(hother(iobj),'Color','b')
136            end
137            set(hother(iobj),'Selected','off')
138        end
139    end
140end
141hciv=findobj(allchild(0),'Tag','civ');%find the current civ GUI
142if ~isempty(hciv)
143    hhciv=guidata(hciv);
144    set(hhciv.TestCiv1,'Value',0)% desactivate  TestCiv1 if on
145    set(hhciv.TestCiv1,'BackgroundColor',[1 0 0])%
146end
147corrfig=findobj(allchild(0),'tag','corrfig');% look for a civ correlation window used with TesCiv1
148if ~isempty(corrfig)
149    delete(corrfig)
150end
151
152%-------------------------------------------------------------------
153%-------------------------------------------------------------------
154% II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
155% automatically sets the global properties when the rootfile name is introduced
156% then activate the view-field action if selected
157% it is activated either by clicking on the RootPath window or by the
158% browser
159%------------------------------------------------------------------
160%------------------------------------------------------------------
161
162%-------------------------------------------------------------------
163function update_mask(handles,num_i1,num_j1)
164%-------------------------------------------------------------------
165
166MaskData=get(handles.mask_test,'UserData');
167if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
168    uistack(MaskData.maskhandle,'top');
169end
170num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
171[RootPath,RootFile]=fullfile(MaskData.Base);
172MaskName=fullfile_uvmat(RootPath,'',RootFile,'.png',MaskData.NomType,num_i1_mask,[],num_j1);
173%[MaskName,mdetect]=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
174huvmat=get(handles.mask_test,'parent');
175UvData=get(huvmat,'UserData');
176
177%update mask image if the mask is new
178if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
179    UvData.MaskName=MaskName; %update the recorded name on UvData
180    set(huvmat,'UserData',UvData);
181    if mdetect==0
182        if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
183            delete(MaskData.maskhandle)   
184        end
185    else
186        %read mask image
187        Mask.AName='image';
188        Mask.A=imread(MaskName);
189        npxy=size(Mask.A);
190        Mask.AX=[0.5 npxy(2)-0.5];
191        Mask.AY=[npxy(1)-0.5 0.5 ];
192        Mask.CoordUnit='pixel';
193        if isequal(get(handles.slices,'Value'),1)
194           NbSlice=str2num(get(handles.nb_slice,'String'));
195           num_i1=str2num(get(handles.i1,'String'));
196           Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
197        end
198        %px to phys or other transform on field
199         menu_transform=get(handles.transform_fct,'String');
200        choice_value=get(handles.transform_fct,'Value');
201        transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
202        transform_list=get(handles.transform_fct,'UserData');
203        transform=transform_list{choice_value};
204        if  ~isequal(transform_name,'') && ~isequal(transform_name,'px')
205            if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
206                Calib=UvData.XmlData.GeometryCalib;
207                Mask=transform(Mask,UvData.XmlData);
208            end
209        end
210        flagmask=Mask.A < 200;
211       
212        %make brown color image
213        imflag(:,:,1)=0.9*flagmask;
214        imflag(:,:,2)=0.7*flagmask;
215        imflag(:,:,3)=zeros(size(flagmask));
216       
217        %update mask image
218        hmask=[]; %default
219        if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
220            hmask=MaskData.maskhandle;
221        end
222        if ~isempty(hmask)
223            set(hmask,'CData',imflag)   
224            set(hmask,'AlphaData',flagmask*0.6)
225            set(hmask,'XData',Mask.AX);
226            set(hmask,'YData',Mask.AY);
227%             uistack(hmask,'top')
228        else
229            axes(handles.axes3)
230            hold on   
231            MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
232%             set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
233            set(handles.mask_test,'UserData',MaskData)
234        end
235    end
236end
237
238
239%-------------------------------------------------------------------
240function MenuExportFigure_Callback(hObject, eventdata, handles)
241%-------------------------------------------------------------------
242huvmat=get(handles.MenuExport,'parent');
243UvData=get(huvmat,'UserData');
244hfig=figure;
245newaxes=copyobj(handles.axes3,hfig);
246map=colormap(handles.axes3);
247colormap(map);%transmit the current colormap to the zoom fig
248colorbar
249
250%-------------------------------------------------------------------
251%-------------------------------------------------------------------
252% III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
253%-------------------------------------------------------------------
254%-------------------------------------------------------------------
255
256%Executes on button press in runplus: make one step forward and call
257%run0. The step forward is along the fields series 1 or 2 depending on
258%the scan_i and scan_j check box (exclusive each other)
259%-------------------------------------------------------------------
260function runplus_Callback(hObject, eventdata, handles)
261increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
262runpm(hObject,eventdata,handles,increment)
263
264%-------------------------------------------------------------------
265%Executes on button press in runmin: make one step backward and call
266%run0. The step backward is along the fields series 1 or 2 depending on
267%the scan_i and scan_j check box (exclusive each other)
268%-------------------------------------------------------------------
269function runmin_Callback(hObject, eventdata, handles)
270increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
271runpm(hObject,eventdata,handles,increment)
272
273%-------------------------------------------------------------------
274%Executes on button press in runmin: make one step backward and call
275%run0. The step backward is along the fields series 1 or 2 depending on
276%the scan_i and scan_j check box (exclusive each other)
277%-------------------------------------------------------------------
278function RunMovie_Callback(hObject, eventdata, handles)
279%------------------------------------------------------------------
280set(handles.RunMovie,'BackgroundColor',[1 1 0])%paint the command button in yellow
281drawnow
282increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
283set(handles.STOP,'Visible','on')
284set(handles.speed,'Visible','on')
285set(handles.speed_txt,'Visible','on')
286set(handles.RunMovie,'BusyAction','queue')
287testavi=0;
288UvData=get(handles.view_field,'UserData');
289
290while get(handles.speed,'Value')~=0 & isequal(get(handles.RunMovie,'BusyAction'),'queue') % enable STOP command
291        runpm(hObject,eventdata,handles,increment)
292        pause(1.02-get(handles.speed,'Value'))% wait for next image
293end
294if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
295    UvData.aviobj=close(UvData.aviobj);
296   set(handles.view_field,'UserData',UvData);
297end
298set(handles.RunMovie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
299
300
301
302%-------------------------------------------------------------------
303% --- translate coordinate to matrix index
304%-------------------------------------------------------------------
305function [indx,indy]=pos2ind(x0,rangx0,nxy)
306indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel 
307indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
308
309%-------------------------------------------------------------------
310% --- Executes on button press in 'FixLimits'.
311%-------------------------------------------------------------------
312function CheckFixLimits_Callback(hObject, eventdata, handles)
313test=get(handles.CheckFixLimits,'Value');
314if test
315    set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
316else
317    set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
318end
319update_plot(handles)
320
321%-------------------------------------------------------------------
322% --- Executes on button press in FixEqual.
323function CheckFixEqual_Callback(hObject, eventdata, handles)
324test=get(handles.CheckFixEqual,'Value');
325if test
326    set(handles.CheckFixEqual,'BackgroundColor',[1 1 0])
327else
328    set(handles.CheckFixEqual,'BackgroundColor',[0.7 0.7 0.7])
329end
330 update_plot(handles)
331
332%-------------------------------------------------------------------
333
334%-------------------------------------------------------------------
335% --- Executes on button press in 'zoom'.
336%-------------------------------------------------------------------
337function CheckZoom_Callback(hObject, eventdata, handles)
338if (get(handles.CheckZoom,'Value') == 1);
339    set(handles.CheckZoom,'BackgroundColor',[1 1 0])
340    set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes
341    set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
342else
343    set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
344end
345
346% %-------------------------------------------------------------------
347% %----Executes on button press in 'record': records the current flags of manual correction.
348% %-------------------------------------------------------------------
349% function record_Callback(hObject, eventdata, handles)
350% % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
351% filename=read_file_boxes(handles);
352% AxeData=get(gca,'UserData');
353% [erread,message]=fileattrib(filename);
354% if ~isempty(message) && ~isequal(message.UserWrite,1)
355%      msgbox_view_field('ERROR',['no writting access to ' filename])
356%      return
357% end
358% test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
359% test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
360% if ~test_civ2 && ~test_civ1
361%     msgbox_view_field('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
362% end
363% if test_civ2
364%     nbname='nb_vectors2';
365%    flagname='vec2_FixFlag';
366%    attrname='fix2';
367% end
368% if test_civ1
369%     nbname='nb_vectors';
370%    flagname='vec_FixFlag';
371%    attrname='fix';
372% end
373% %write fix flags in the netcdf file
374% hhh=which('netcdf.open');% look for built-in matlab netcdf library
375% if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
376%     nc=netcdf.open(filename,'NC_WRITE');
377%     netcdf.reDef(nc)
378%     netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
379%     dimid = netcdf.inqDimID(nc,nbname);
380%     try
381%         varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
382%     catch
383%         varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
384%     end
385%     netcdf.endDef(nc)
386%     netcdf.putVar(nc,varid,AxeData.FF);
387%     netcdf.close(nc) 
388% else %old netcdf library
389%     netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
390% end
391%
392% function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
393% nc=netcdf(filename,'write'); %open netcdf file
394% result=redef(nc);
395% eval(['nc.' attrname '=1;']);
396% theDim=nc(nbname) ;% get the number of velocity vectors
397% nb_vectors=size(theDim);
398% var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
399% var_FixFlag(1:nb_vectors)=AxeData.FF;%
400% fin=close(nc);
401
402
403%-------------------------------------------------------------------
404%-------------------------------------------------------------------
405%  - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
406
407%------------------------------------------------------------------
408
409
410%------------------------------------------------------------------
411% --- Executes on selection change in col_vec: choice of the color code.
412%
413function col_vec_Callback(hObject, eventdata, handles)
414%------------------------------------------------------------------
415% edit the choice for color code
416list_code=get(handles.col_vec,'String');% list menu fields
417index_code=get(handles.col_vec,'Value');% selected string index
418col_code= list_code{index_code(1)}; % selected field
419if isequal(col_code,'black') | isequal(col_code,'white')
420   set(handles.slider1,'Visible','off')
421   set(handles.slider2,'Visible','off')
422   set(handles.colcode1,'Visible','off')
423   set(handles.colcode2,'Visible','off')
424   set(handles.AutoVecColor,'Visible','off')
425   set_vec_col_bar(handles)
426else
427   set(handles.slider1,'Visible','on')
428   set(handles.slider2,'Visible','on')
429   set(handles.colcode1,'Visible','on')
430   set(handles.colcode2,'Visible','on')
431   set(handles.AutoVecColor,'Visible','on') 
432   if isequal(col_code,'ima_cor')
433       set(handles.AutoVecColor,'Value',0)%fixed scale by default
434       set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
435       set(handles.slider1,'Min',0);
436       set(handles.slider1,'Max',1);
437       set(handles.slider2,'Min',0);
438       set(handles.slider2,'Max',1);
439 %      set(handles.min_C_title_vec,'String','0')
440       set(handles.max_vec,'String','1')
441       set(handles.colcode1,'String','0.333')
442       colcode1_Callback(hObject, eventdata, handles)
443       set(handles.colcode2,'String','0.666')
444       colcode2_Callback(hObject, eventdata, handles)
445   else
446       set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
447       set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
448       minval=get(handles.slider1,'Min');
449       maxval=get(handles.slider1,'Max');
450       set(handles.slider1,'Value',minval)
451       set(handles.slider2,'Value',maxval)
452       set_vec_col_bar(handles)
453   end
454%    slider_update(handles)
455end
456%replot the current graph
457run0_Callback(hObject, eventdata, handles)
458
459
460%----------------------------------------------------------------
461% -- Executes on slider movement to set the color code
462%
463function slider1_Callback(hObject, eventdata, handles)
464%------------------------------------------------------------------
465slider1=get(handles.slider1,'Value');
466min_val=str2num(get(handles.min_vec,'String'));
467max_val=str2num(get(handles.max_vec,'String'));
468col=min_val+(max_val-min_val)*slider1;
469set(handles.colcode1,'String',num2str(col))
470if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
471    set(handles.slider2,'Value',col)
472    set(handles.colcode2,'String',num2str(col))
473end
474colcode1_Callback(hObject, eventdata, handles)
475
476%----------------------------------------------------------------
477% Executes on slider movement to set the color code
478%----------------------------------------------------------------
479function slider2_Callback(hObject, eventdata, handles)
480slider2=get(handles.slider2,'Value');
481min_val=str2num(get(handles.min_vec,'String'));
482max_val=str2num(get(handles.max_vec,'String'));
483col=min_val+(max_val-min_val)*slider2;
484set(handles.colcode2,'String',num2str(col))
485if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
486    set(handles.slider1,'Value',col)
487    set(handles.colcode1,'String',num2str(col))
488end
489colcode2_Callback(hObject, eventdata, handles)
490
491%----------------------------------------------------------------
492%execute on return carriage on the edit box corresponding to slider 1
493%----------------------------------------------------------------
494function colcode1_Callback(hObject, eventdata, handles)
495% col=str2num(get(handles.colcode1,'String'));
496% set(handles.slider1,'Value',col)
497set_vec_col_bar(handles)
498update_plot(handles)
499
500%----------------------------------------------------------------
501%execute on return carriage on the edit box corresponding to slider 2
502%----------------------------------------------------------------
503function colcode2_Callback(hObject, eventdata, handles)
504% col=str2num(get(handles.colcode2,'String'));
505% set(handles.slider2,'Value',col)
506% slider2_Callback(hObject, eventdata, handles)
507set_vec_col_bar(handles)
508update_plot(handles)
509
510%-------------------------------------------------------
511% --- Executes on button press in AutoVecColor.
512%-------------------------------------------------------
513function vec_col_bar_Callback(hObject, eventdata, handles)
514set_vec_col_bar(handles)
515
516%------------------------------------------------
517%CALLBACKS FOR PLOTTING PARAMETERS
518%-------------------------------------------------
519
520%------------------------------------------------------------------------
521function num_MinX_Callback(hObject, eventdata, handles)
522%------------------------------------------------------------------------
523set(handles.CheckFixLimits,'Value',1) %suppress auto mode
524set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
525update_plot(handles);
526
527%------------------------------------------------------------------------
528function num_MaxX_Callback(hObject, eventdata, handles)
529%------------------------------------------------------------------------
530set(handles.CheckFixLimits,'Value',1) %suppress auto mode
531set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
532update_plot(handles);
533
534%------------------------------------------------------------------------
535function num_MinY_Callback(hObject, eventdata, handles)
536%------------------------------------------
537set(handles.CheckFixLimits,'Value',1) %suppress auto mode
538set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
539update_plot(handles);
540
541%------------------------------------------------------------------------
542function num_MaxY_Callback(hObject, eventdata, handles)
543%------------------------------------------------------------------------
544set(handles.CheckFixLimits,'Value',1) %suppress auto mode
545set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
546update_plot(handles);
547
548%-----------------------------------------------------------------
549function num_MinA_Callback(hObject, eventdata, handles)
550%------------------------------------------
551set(handles.CheckFixScalar,'Value',1) %suppress auto mode
552set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
553update_plot(handles)
554
555%-----------------------------------------------------------------
556function num_MaxA_Callback(hObject, eventdata, handles)
557%--------------------------------------------
558set(handles.CheckFixScalar,'Value',1) %suppress auto mode
559set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
560update_plot(handles)
561
562%-----------------------------------------------
563function CheckFixScalar_Callback(hObject, eventdata, handles)
564%--------------------------------------------
565test=get(handles.CheckFixScalar,'Value');
566if test
567    set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
568else
569    set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
570    update_plot(handles);
571%     set(handles.MinA,'String',num2str(ScalOut.MinA,3))
572%     set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
573end
574
575%-------------------------------------------------------------------
576function CheckBW_Callback(hObject, eventdata, handles)
577%-------------------------------------------------------------------
578update_plot(handles)
579
580%-------------------------------------------------------------------
581function ListContour_Callback(hObject, eventdata, handles)
582%-------------------------------------------------------------------
583val=get(handles.Contours,'Value');
584if val==2
585    set(handles.interval_txt,'Visible','on')
586    set(handles.IncrA,'Visible','on')
587else
588    set(handles.interval_txt,'Visible','off')
589    set(handles.IncrA,'Visible','off')
590end
591update_plot(handles)
592
593%-------------------------------------------------------------------
594function IncrA_Callback(hObject, eventdata, handles)
595%-------------------------------------------------------------------
596update_plot(handles)
597
598%-------------------------------------------------------------------
599function HideWarning_Callback(hObject, eventdata, handles)
600%-------------------------------------------------------------------
601update_plot(handles)
602
603%-------------------------------------------------------------------
604function HideFalse_Callback(hObject, eventdata, handles)
605%-------------------------------------------------------------------
606update_plot(handles)
607
608%-------------------------------------------------------------------
609function VecScale_Callback(hObject, eventdata, handles)
610%-------------------------------------------------------------------
611set(handles.FixVec,'Value',1);
612set(handles.FixVec,'BackgroundColor',[1 1 0])
613update_plot(handles)
614
615%-------------------------------------------------------------------
616function FixVec_Callback(hObject, eventdata, handles)
617%-------------------------------------------------------------------
618test=get(handles.FixVec,'Value');
619if test
620    set(handles.FixVec,'BackgroundColor',[1 1 0])
621else
622    update_plot(handles);
623    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
624    set(handles.FixVec,'BackgroundColor',[0.7 0.7 0.7])
625end
626
627%-------------------------------------------------------
628% --- Executes on selection change in decimate4 (nb_vec/4).
629%-------------------------------------------------------
630function CheckDecimate4_Callback(hObject, eventdata, handles)
631update_plot(handles)
632
633
634%-------------------------------------------------------
635% --- Executes on selection change in color_code menu
636%-------------------------------------------------------
637function color_code_Callback(hObject, eventdata, handles)
638set_vec_col_bar(handles)
639update_plot(handles);
640
641%-------------------------------------------------------
642% --- Executes on button press in AutoVecColor.
643%-------------------------------------------------------
644function AutoVecColor_Callback(hObject, eventdata, handles)
645test=get(handles.AutoVecColor,'Value');
646if test
647    set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
648else
649    update_plot(handles);
650    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
651    set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
652end
653%set_vec_col_bar(handles)
654
655%-------------------------------------------------------
656% --- Executes on selection change in max_vec.
657%-------------------------------------------------------
658function min_vec_Callback(hObject, eventdata, handles)
659max_vec_Callback(hObject, eventdata, handles)
660
661% --- Executes on selection change in max_vec.
662function max_vec_Callback(hObject, eventdata, handles)
663set(handles.AutoVecColor,'Value',1)
664AutoVecColor_Callback(hObject, eventdata, handles)
665min_val=str2num(get(handles.min_vec,'String'));
666max_val=str2num(get(handles.max_vec,'String'));
667slider1=get(handles.slider1,'Value');
668slider2=get(handles.slider2,'Value');
669colcode1=min_val+(max_val-min_val)*slider1;
670colcode2=min_val+(max_val-min_val)*slider2;
671set(handles.colcode1,'String',num2str(colcode1))
672set(handles.colcode2,'String',num2str(colcode2))
673update_plot(handles);
674
675%-------------------------------------------------------------------
676%update the display of color code for vectors
677function set_vec_col_bar(handles)
678%-------------------------------------------------------------------
679%get the image of the color display button 'vec_col_bar' in pixels
680set(handles.vec_col_bar,'Unit','pixel');
681pos_vert=get(handles.vec_col_bar,'Position');
682set(handles.vec_col_bar,'Unit','Normalized');
683width=ceil(pos_vert(3));
684height=ceil(pos_vert(4));
685
686%get slider indications
687list=get(handles.color_code,'String');
688ichoice=get(handles.color_code,'Value');
689colcode.ColorCode=list{ichoice};
690colcode.MinC=str2num(get(handles.min_vec,'String'));
691colcode.MaxC=str2num(get(handles.max_vec,'String'));
692test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
693if test3color
694    colcode.colcode1=str2num(get(handles.colcode1,'String'));
695    colcode.colcode2=str2num(get(handles.colcode2,'String'));
696end
697colcode.FixedCbounds=0;
698colcode.FixedCbounds=1;
699vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
700[colorlist,col_vec]=set_col_vec(colcode,vec_C);
701oneheight=ones(1,height);
702A1=colorlist(col_vec,1)*oneheight;
703A2=colorlist(col_vec,2)*oneheight;
704A3=colorlist(col_vec,3)*oneheight;
705A(:,:,1)=A1';
706A(:,:,2)=A2';
707A(:,:,3)=A3';
708set(handles.vec_col_bar,'Cdata',A)
709
710%-------------------------------------------------------------------
711function update_plot(handles)
712%-------------------------------------------------------------------
713Data=get(handles.view_field,'UserData');
714AxeData=Data.axes3;% retrieve the current plotted data
715PlotParam=read_GUI(handles.view_field);
716[PP,PlotParamOut]= plot_field(AxeData,handles.axes3,PlotParam);
717write_plot_param(handles,PlotParamOut); %update the auto plot parameters
718
719%------------------------------------------------------------------------
720% --- Executes on button press in Menu/Export/field in workspace.
721function MenuExportField_Callback(hObject, eventdata, handles)
722%------------------------------------------------------------------------
723global Data_view_field
724% huvmat=findobj(allchild(0),'Name','uvmat');
725Data_view_field=get(handles.view_field,'UserData');
726Data_view_field=Data_view_field.axes3;
727% Data_view_field=UvData.ProjField_2;
728evalin('base','global Data_view_field')%make CurData global in the workspace
729display(['UserData of view_field :'])
730evalin('base','Data_view_field') %display CurData in the workspace
731commandwindow;
732
733%------------------------------------------------------------------------
734% --- Executes on button press in Menu/Export/extract figure.
735function MenuExport_plot_Callback(hObject, eventdata, handles)
736%------------------------------------------------------------------------
737huvmat=get(handles.MenuExport_plot,'parent');
738UvData=get(huvmat,'UserData');
739hfig=figure;
740newaxes=copyobj(handles.axes3,hfig);
741map=colormap(handles.axes3);
742colormap(map);%transmit the current colormap to the zoom fig
743colorbar
744
745
746% --- Executes on selection change in ColorCode.
747function ColorCode_Callback(hObject, eventdata, handles)
748% hObject    handle to ColorCode (see GCBO)
749% eventdata  reserved - to be defined in a future version of MATLAB
750% handles    structure with handles and user data (see GUIDATA)
751
752% Hints: contents = cellstr(get(hObject,'String')) returns ColorCode contents as cell array
753%        contents{get(hObject,'Value')} returns selected item from ColorCode
754
755
756% --- Executes on selection change in ColorScalar.
757function ColorScalar_Callback(hObject, eventdata, handles)
758% hObject    handle to ColorScalar (see GCBO)
759% eventdata  reserved - to be defined in a future version of MATLAB
760% handles    structure with handles and user data (see GUIDATA)
761
762% Hints: contents = cellstr(get(hObject,'String')) returns ColorScalar contents as cell array
763%        contents{get(hObject,'Value')} returns selected item from ColorScalar
764
765
766
767function num_ColCode2_Callback(hObject, eventdata, handles)
768% hObject    handle to num_colcode2 (see GCBO)
769% eventdata  reserved - to be defined in a future version of MATLAB
770% handles    structure with handles and user data (see GUIDATA)
771
772% Hints: get(hObject,'String') returns contents of num_colcode2 as text
773%        str2double(get(hObject,'String')) returns contents of num_colcode2 as a double
Note: See TracBrowser for help on using the repository browser.