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