source: trunk/src/view_field.m @ 429

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

improvements in object drawing and projection on points

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