source: trunk/src/view_field.m @ 466

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

system of projection object manipulation with uvmat improved.

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