source: trunk/src/view_field.m @ 622

Last change on this file since 622 was 622, checked in by sommeria, 11 years ago

mouse system for uvmat imrpoved

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