source: trunk/src/view_field.m @ 402

Last change on this file since 402 was 402, checked in by sommeria, 13 years ago

bugs corrected and improved procedure for object projection

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