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-2014, LEGI UMR 5519 / CNRS UJF 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);%,PlotParam,KeepLim,PosColorbar)
|
---|
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 |
|
---|
95 | errormsg=fill_GUI(PlotParamOut,hObject);
|
---|
96 | if ~isempty(errormsg)
|
---|
97 | msgbox_uvmat('ERROR',errormsg)
|
---|
98 | return
|
---|
99 | end
|
---|
100 | %write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters
|
---|
101 | end
|
---|
102 |
|
---|
103 | %put the GUI on the lower right of the sceen
|
---|
104 | pos_view_field=get(hObject,'Position');
|
---|
105 | set(0,'Unit','pixel')
|
---|
106 | ScreenSize=get(0,'ScreenSize');
|
---|
107 | pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3);
|
---|
108 | pos_view_field(2)=ScreenSize(2);
|
---|
109 | set(hObject,'Position',pos_view_field)
|
---|
110 |
|
---|
111 | %------------------------------------------------------------------------
|
---|
112 | %--- activated when resizing the GUI view_field
|
---|
113 | function ResizeFcn(gcbo,eventdata,handles)
|
---|
114 | %------------------------------------------------------------------------
|
---|
115 | set(handles.view_field,'Units','pixels')
|
---|
116 | size_fig=get(handles.view_field,'Position');
|
---|
117 | Data=get(handles.view_field,'UserData');
|
---|
118 | Data.GUISize=size_fig;
|
---|
119 | set(handles.view_field,'UserData',Data)
|
---|
120 |
|
---|
121 | %% reset position of text_display and TableDisplay
|
---|
122 | % reset position of text_display
|
---|
123 | set(handles.text_display,'Units','pixels');
|
---|
124 | pos_1=get(handles.text_display,'Position');% [lower x lower y width height] for text_display
|
---|
125 | pos_1(1)=size_fig(3)-pos_1(3); % set text display to the right of the fig
|
---|
126 | pos_1(2)=size_fig(4)-pos_1(4); % set text display to the top of the fig
|
---|
127 | set(handles.text_display,'Position',pos_1)
|
---|
128 | % reset position of TableDisplay
|
---|
129 | set(handles.TableDisplay,'Position',pos_1)
|
---|
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)=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 | FigName=['figure ' num2str(ListFig(ilist))];
|
---|
339 | end
|
---|
340 | if ~strcmp(FigName,'uvmat')
|
---|
341 | ListAxes=findobj(ListFig(ilist),'Type','axes');
|
---|
342 | ListTags=get(ListAxes,'Tag');
|
---|
343 | if ~isempty(ListTags) && ~isempty(find(~strcmp('Colorbar',ListTags), 1))
|
---|
344 | ListAxes=ListAxes(~strcmp('Colorbar',ListTags));
|
---|
345 | if numel(ListAxes)==1
|
---|
346 | nb_option=nb_option+1;
|
---|
347 | menu{nb_option}=FigName ;
|
---|
348 | AxesHandle(nb_option)=ListAxes;
|
---|
349 | else
|
---|
350 | nb_axis=0;
|
---|
351 | for iaxes=1:numel(ListAxes)
|
---|
352 | nb_axis=nb_axis+1;
|
---|
353 | nb_option=nb_option+1;
|
---|
354 | menu{nb_option}=[FigName '_' num2str(nb_axis)];
|
---|
355 | AxesHandle(nb_option)=ListAxes(nb_axis);
|
---|
356 | end
|
---|
357 | end
|
---|
358 | end
|
---|
359 | end
|
---|
360 | end
|
---|
361 | if isempty(menu)
|
---|
362 | answer=msgbox_uvmat('INPUT_Y-N','no existing plotting axes available, create new figure?');
|
---|
363 | if strcmp(answer,'Yes')
|
---|
364 | hfig=figure;
|
---|
365 | copyobj(handles.PlotAxes,hfig);
|
---|
366 | else
|
---|
367 | return
|
---|
368 | end
|
---|
369 | map=colormap(handles.PlotAxes);
|
---|
370 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
371 | colorbar
|
---|
372 | else
|
---|
373 | answer=msgbox_uvmat('INPUT_MENU','select a figure/axis on which the current uvmat plot will be exported',menu);
|
---|
374 | if isempty(answer)
|
---|
375 | return
|
---|
376 | else
|
---|
377 | axes(AxesHandle(answer))
|
---|
378 | hold on
|
---|
379 | hchild=get(handles.PlotAxes,'children');
|
---|
380 | copyobj(hchild,gca);
|
---|
381 | end
|
---|
382 | end
|
---|
383 |
|
---|
384 | %-------------------------------------------------------------------
|
---|
385 | %-------------------------------------------------------------------
|
---|
386 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
387 | %-------------------------------------------------------------------
|
---|
388 | %-------------------------------------------------------------------
|
---|
389 |
|
---|
390 | %Executes on button press in runplus: make one step forward and call
|
---|
391 | %run0. The step forward is along the fields series 1 or 2 depending on
|
---|
392 | %the scan_i and scan_j check box (exclusive each other)
|
---|
393 | %-------------------------------------------------------------------
|
---|
394 | function runplus_Callback(hObject, eventdata, handles)
|
---|
395 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
396 | runpm(hObject,eventdata,handles,increment)
|
---|
397 |
|
---|
398 | %-------------------------------------------------------------------
|
---|
399 | %Executes on button press in runmin: make one step backward and call
|
---|
400 | %run0. The step backward is along the fields series 1 or 2 depending on
|
---|
401 | %the scan_i and scan_j check box (exclusive each other)
|
---|
402 | %-------------------------------------------------------------------
|
---|
403 | function runmin_Callback(hObject, eventdata, handles)
|
---|
404 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
405 | runpm(hObject,eventdata,handles,increment)
|
---|
406 |
|
---|
407 | %------------------------------------------------------------------------
|
---|
408 | % --- translate coordinate to matrix index
|
---|
409 | %------------------------------------------------------------------------
|
---|
410 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
411 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
412 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
413 |
|
---|
414 | %------------------------------------------------------------------------
|
---|
415 | % --- Executes on button press in 'CheckZoom'.
|
---|
416 | %------------------------------------------------------------------------
|
---|
417 | function CheckZoom_Callback(hObject, eventdata, handles)
|
---|
418 |
|
---|
419 | if get(handles.CheckZoom,'Value')
|
---|
420 | set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
421 | set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig
|
---|
422 | end
|
---|
423 |
|
---|
424 | %------------------------------------------------------------------------
|
---|
425 | % --- Executes on button press in CheckZoomFig.
|
---|
426 | %------------------------------------------------------------------------
|
---|
427 | function CheckZoomFig_Callback(hObject, eventdata, handles)
|
---|
428 | if get(handles.CheckZoomFig,'Value')
|
---|
429 | set(handles.CheckZoom,'value',0)
|
---|
430 | end
|
---|
431 |
|
---|
432 | %------------------------------------------------------------------------
|
---|
433 | % --- Executes on button press in 'FixLimits'.
|
---|
434 | %------------------------------------------------------------------------
|
---|
435 | function CheckFixLimits_Callback(hObject, eventdata, handles)
|
---|
436 | test=get(handles.CheckFixLimits,'Value');
|
---|
437 | update_plot(handles)
|
---|
438 |
|
---|
439 | %------------------------------------------------------------------------
|
---|
440 | % --- Executes on button press in CheckFixAspectRatio.
|
---|
441 | %------------------------------------------------------------------------
|
---|
442 | function CheckFixAspectRatio_Callback(hObject, eventdata, handles)
|
---|
443 | if get(handles.CheckFixAspectRatio,'Value')
|
---|
444 | update_plot(handles);
|
---|
445 | else
|
---|
446 | update_plot(handles);
|
---|
447 | end
|
---|
448 |
|
---|
449 | %------------------------------------------------------------------------
|
---|
450 | function num_AspectRatio_Callback(hObject, eventdata, handles)
|
---|
451 | %------------------------------------------------------------------------
|
---|
452 | set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button
|
---|
453 | update_plot(handles);
|
---|
454 |
|
---|
455 | %-------------------------------------------------------------------
|
---|
456 | %-------------------------------------------------------------------
|
---|
457 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
458 |
|
---|
459 | %------------------------------------------------------------------
|
---|
460 |
|
---|
461 |
|
---|
462 | %------------------------------------------------------------------
|
---|
463 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
464 | %
|
---|
465 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
466 | %------------------------------------------------------------------
|
---|
467 | % edit the choice for color code
|
---|
468 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
469 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
470 | col_code= list_code{index_code(1)}; % selected field
|
---|
471 | if isequal(col_code,'black') | isequal(col_code,'white')
|
---|
472 | set(handles.slider1,'Visible','off')
|
---|
473 | set(handles.slider2,'Visible','off')
|
---|
474 | set(handles.colcode1,'Visible','off')
|
---|
475 | set(handles.colcode2,'Visible','off')
|
---|
476 | set(handles.AutoVecColor,'Visible','off')
|
---|
477 | set_vec_col_bar(handles)
|
---|
478 | else
|
---|
479 | set(handles.slider1,'Visible','on')
|
---|
480 | set(handles.slider2,'Visible','on')
|
---|
481 | set(handles.colcode1,'Visible','on')
|
---|
482 | set(handles.colcode2,'Visible','on')
|
---|
483 | set(handles.AutoVecColor,'Visible','on')
|
---|
484 | if isequal(col_code,'ima_cor')
|
---|
485 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
486 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
487 | set(handles.slider1,'Min',0);
|
---|
488 | set(handles.slider1,'Max',1);
|
---|
489 | set(handles.slider2,'Min',0);
|
---|
490 | set(handles.slider2,'Max',1);
|
---|
491 | % set(handles.min_C_title_vec,'String','0')
|
---|
492 | set(handles.max_vec,'String','1')
|
---|
493 | set(handles.colcode1,'String','0.333')
|
---|
494 | colcode1_Callback(hObject, eventdata, handles)
|
---|
495 | set(handles.colcode2,'String','0.666')
|
---|
496 | colcode2_Callback(hObject, eventdata, handles)
|
---|
497 | else
|
---|
498 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
499 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
500 | minval=get(handles.slider1,'Min');
|
---|
501 | maxval=get(handles.slider1,'Max');
|
---|
502 | set(handles.slider1,'Value',minval)
|
---|
503 | set(handles.slider2,'Value',maxval)
|
---|
504 | set_vec_col_bar(handles)
|
---|
505 | end
|
---|
506 | % slider_update(handles)
|
---|
507 | end
|
---|
508 | %replot the current graph
|
---|
509 | run0_Callback(hObject, eventdata, handles)
|
---|
510 |
|
---|
511 |
|
---|
512 | %----------------------------------------------------------------
|
---|
513 | % -- Executes on slider movement to set the color code
|
---|
514 | %
|
---|
515 | function slider1_Callback(hObject, eventdata, handles)
|
---|
516 | %------------------------------------------------------------------
|
---|
517 | slider1=get(handles.slider1,'Value');
|
---|
518 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
519 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
520 | col=min_val+(max_val-min_val)*slider1;
|
---|
521 | set(handles.colcode1,'String',num2str(col))
|
---|
522 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
523 | set(handles.slider2,'Value',col)
|
---|
524 | set(handles.colcode2,'String',num2str(col))
|
---|
525 | end
|
---|
526 | colcode1_Callback(hObject, eventdata, handles)
|
---|
527 |
|
---|
528 | %----------------------------------------------------------------
|
---|
529 | % Executes on slider movement to set the color code
|
---|
530 | %----------------------------------------------------------------
|
---|
531 | function slider2_Callback(hObject, eventdata, handles)
|
---|
532 | slider2=get(handles.slider2,'Value');
|
---|
533 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
534 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
535 | col=min_val+(max_val-min_val)*slider2;
|
---|
536 | set(handles.colcode2,'String',num2str(col))
|
---|
537 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
538 | set(handles.slider1,'Value',col)
|
---|
539 | set(handles.colcode1,'String',num2str(col))
|
---|
540 | end
|
---|
541 | colcode2_Callback(hObject, eventdata, handles)
|
---|
542 |
|
---|
543 | %----------------------------------------------------------------
|
---|
544 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
545 | %----------------------------------------------------------------
|
---|
546 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
547 | % col=str2num(get(handles.colcode1,'String'));
|
---|
548 | % set(handles.slider1,'Value',col)
|
---|
549 | set_vec_col_bar(handles)
|
---|
550 | update_plot(handles)
|
---|
551 |
|
---|
552 | %----------------------------------------------------------------
|
---|
553 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
554 | %----------------------------------------------------------------
|
---|
555 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
556 | % col=str2num(get(handles.colcode2,'String'));
|
---|
557 | % set(handles.slider2,'Value',col)
|
---|
558 | % slider2_Callback(hObject, eventdata, handles)
|
---|
559 | set_vec_col_bar(handles)
|
---|
560 | update_plot(handles)
|
---|
561 |
|
---|
562 | %-------------------------------------------------------
|
---|
563 | % --- Executes on button press in AutoVecColor.
|
---|
564 | %-------------------------------------------------------
|
---|
565 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
566 | set_vec_col_bar(handles)
|
---|
567 |
|
---|
568 | %------------------------------------------------
|
---|
569 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
570 | %-------------------------------------------------
|
---|
571 |
|
---|
572 | %------------------------------------------------------------------------
|
---|
573 | function num_MinX_Callback(hObject, eventdata, handles)
|
---|
574 | %------------------------------------------------------------------------
|
---|
575 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
576 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
577 | update_plot(handles);
|
---|
578 |
|
---|
579 | %------------------------------------------------------------------------
|
---|
580 | function num_MaxX_Callback(hObject, eventdata, handles)
|
---|
581 | %------------------------------------------------------------------------
|
---|
582 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
583 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
584 | update_plot(handles);
|
---|
585 |
|
---|
586 | %------------------------------------------------------------------------
|
---|
587 | function num_MinY_Callback(hObject, eventdata, handles)
|
---|
588 | %------------------------------------------
|
---|
589 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
590 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
591 | update_plot(handles);
|
---|
592 |
|
---|
593 | %------------------------------------------------------------------------
|
---|
594 | function num_MaxY_Callback(hObject, eventdata, handles)
|
---|
595 | %------------------------------------------------------------------------
|
---|
596 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
597 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
598 | update_plot(handles);
|
---|
599 |
|
---|
600 | %-----------------------------------------------------------------
|
---|
601 | function num_MinA_Callback(hObject, eventdata, handles)
|
---|
602 | %------------------------------------------
|
---|
603 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode
|
---|
604 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
|
---|
605 | update_plot(handles)
|
---|
606 |
|
---|
607 | %-----------------------------------------------------------------
|
---|
608 | function num_MaxA_Callback(hObject, eventdata, handles)
|
---|
609 | %--------------------------------------------
|
---|
610 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode
|
---|
611 | % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
|
---|
612 | update_plot(handles)
|
---|
613 |
|
---|
614 | %-----------------------------------------------
|
---|
615 | function CheckFixScalar_Callback(hObject, eventdata, handles)
|
---|
616 | %--------------------------------------------
|
---|
617 | test=get(handles.CheckFixScalar,'Value');
|
---|
618 | % if test
|
---|
619 | % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
|
---|
620 | % else
|
---|
621 | % set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
|
---|
622 | % update_plot(handles);
|
---|
623 | % % set(handles.MinA,'String',num2str(ScalOut.MinA,3))
|
---|
624 | % % set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
|
---|
625 | % end
|
---|
626 |
|
---|
627 | %-------------------------------------------------------------------
|
---|
628 | function CheckBW_Callback(hObject, eventdata, handles)
|
---|
629 | %-------------------------------------------------------------------
|
---|
630 | update_plot(handles)
|
---|
631 |
|
---|
632 | %-------------------------------------------------------------------
|
---|
633 | function ListContour_Callback(hObject, eventdata, handles)
|
---|
634 | %-------------------------------------------------------------------
|
---|
635 | val=get(handles.Contours,'Value');
|
---|
636 | if val==2
|
---|
637 | set(handles.interval_txt,'Visible','on')
|
---|
638 | set(handles.IncrA,'Visible','on')
|
---|
639 | else
|
---|
640 | set(handles.interval_txt,'Visible','off')
|
---|
641 | set(handles.IncrA,'Visible','off')
|
---|
642 | end
|
---|
643 | update_plot(handles)
|
---|
644 |
|
---|
645 | %-------------------------------------------------------------------
|
---|
646 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
647 | %-------------------------------------------------------------------
|
---|
648 | update_plot(handles)
|
---|
649 |
|
---|
650 | %-------------------------------------------------------------------
|
---|
651 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
652 | %-------------------------------------------------------------------
|
---|
653 | update_plot(handles)
|
---|
654 |
|
---|
655 | %-------------------------------------------------------------------
|
---|
656 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
657 | %-------------------------------------------------------------------
|
---|
658 | update_plot(handles)
|
---|
659 |
|
---|
660 | %-------------------------------------------------------------------
|
---|
661 | function num_VecScale_Callback(hObject, eventdata, handles)
|
---|
662 | %-------------------------------------------------------------------
|
---|
663 | set(handles.CheckFixVectors,'Value',1);
|
---|
664 | update_plot(handles)
|
---|
665 |
|
---|
666 | %-------------------------------------------------------------------
|
---|
667 | function FixVec_Callback(hObject, eventdata, handles)
|
---|
668 | %-------------------------------------------------------------------
|
---|
669 | test=get(handles.FixVec,'Value');
|
---|
670 | if test
|
---|
671 | set(handles.FixVec,'BackgroundColor',[1 1 0])
|
---|
672 | else
|
---|
673 | update_plot(handles);
|
---|
674 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
675 | % set(handles.FixVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
676 | end
|
---|
677 |
|
---|
678 | %-------------------------------------------------------
|
---|
679 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
680 | %-------------------------------------------------------
|
---|
681 | function CheckDecimate4_Callback(hObject, eventdata, handles)
|
---|
682 | update_plot(handles)
|
---|
683 |
|
---|
684 |
|
---|
685 | %-------------------------------------------------------
|
---|
686 | % --- Executes on selection change in color_code menu
|
---|
687 | %-------------------------------------------------------
|
---|
688 | function color_code_Callback(hObject, eventdata, handles)
|
---|
689 | set_vec_col_bar(handles)
|
---|
690 | update_plot(handles);
|
---|
691 |
|
---|
692 | %-------------------------------------------------------
|
---|
693 | % --- Executes on button press in AutoVecColor.
|
---|
694 | %-------------------------------------------------------
|
---|
695 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
696 | test=get(handles.AutoVecColor,'Value');
|
---|
697 | if test
|
---|
698 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
699 | else
|
---|
700 | update_plot(handles);
|
---|
701 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
702 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
703 | end
|
---|
704 | %set_vec_col_bar(handles)
|
---|
705 |
|
---|
706 | %-------------------------------------------------------
|
---|
707 | % --- Executes on selection change in max_vec.
|
---|
708 | %-------------------------------------------------------
|
---|
709 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
710 | max_vec_Callback(hObject, eventdata, handles)
|
---|
711 |
|
---|
712 | % --- Executes on selection change in max_vec.
|
---|
713 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
714 | set(handles.AutoVecColor,'Value',1)
|
---|
715 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
716 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
717 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
718 | slider1=get(handles.slider1,'Value');
|
---|
719 | slider2=get(handles.slider2,'Value');
|
---|
720 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
721 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
722 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
723 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
724 | update_plot(handles);
|
---|
725 |
|
---|
726 | %-------------------------------------------------------------------
|
---|
727 | %update the display of color code for vectors
|
---|
728 | function set_vec_col_bar(handles)
|
---|
729 | %-------------------------------------------------------------------
|
---|
730 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
731 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
732 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
733 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
734 | width=ceil(pos_vert(3));
|
---|
735 | height=ceil(pos_vert(4));
|
---|
736 |
|
---|
737 | %get slider indications
|
---|
738 | list=get(handles.color_code,'String');
|
---|
739 | ichoice=get(handles.color_code,'Value');
|
---|
740 | colcode.ColorCode=list{ichoice};
|
---|
741 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
742 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
743 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
744 | if test3color
|
---|
745 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
746 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
747 | end
|
---|
748 | colcode.FixedCbounds=0;
|
---|
749 | colcode.FixedCbounds=1;
|
---|
750 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
751 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
752 | oneheight=ones(1,height);
|
---|
753 | A1=colorlist(col_vec,1)*oneheight;
|
---|
754 | A2=colorlist(col_vec,2)*oneheight;
|
---|
755 | A3=colorlist(col_vec,3)*oneheight;
|
---|
756 | A(:,:,1)=A1';
|
---|
757 | A(:,:,2)=A2';
|
---|
758 | A(:,:,3)=A3';
|
---|
759 | set(handles.vec_col_bar,'Cdata',A)
|
---|
760 |
|
---|
761 | %-------------------------------------------------------------------
|
---|
762 | function update_plot(handles)
|
---|
763 | %-------------------------------------------------------------------
|
---|
764 | Data=get(handles.view_field,'UserData');
|
---|
765 | AxeData=Data.PlotAxes;% retrieve the current plotted data
|
---|
766 | PlotParam=read_GUI(handles.view_field);
|
---|
767 | [PP,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam);
|
---|
768 | errormsg=fill_GUI(PlotParamOut,handles.view_field);
|
---|
769 | if ~isempty(errormsg)
|
---|
770 | msgbox_uvmat('ERROR',errormsg)
|
---|
771 | return
|
---|
772 | end
|
---|
773 | hedit=findobj(handles.view_field,'Style','edit');
|
---|
774 | set(hedit,'BackgroundColor',[1 1 1])
|
---|
775 |
|
---|
776 | %------------------------------------------------------------------------
|
---|
777 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
778 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
779 | %------------------------------------------------------------------------
|
---|
780 | global Data_view_field
|
---|
781 | % huvmat=findobj(allchild(0),'Name','uvmat');
|
---|
782 | Data_view_field=get(handles.view_field,'UserData');
|
---|
783 | Data_view_field=Data_view_field.PlotAxes;
|
---|
784 | % Data_view_field=UvData.ProjField_2;
|
---|
785 | evalin('base','global Data_view_field')%make CurData global in the workspace
|
---|
786 | display(['UserData of view_field :'])
|
---|
787 | evalin('base','Data_view_field') %display CurData in the workspace
|
---|
788 | commandwindow;
|
---|
789 |
|
---|
790 | %------------------------------------------------------------------------
|
---|
791 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
792 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
793 | %------------------------------------------------------------------------
|
---|
794 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
795 | UvData=get(huvmat,'UserData');
|
---|
796 | hfig=figure;
|
---|
797 | newaxes=copyobj(handles.PlotAxes,hfig);
|
---|
798 | map=colormap(handles.PlotAxes);
|
---|
799 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
800 | colorbar
|
---|
801 |
|
---|
802 |
|
---|
803 | % --- Executes on selection change in ColorCode.
|
---|
804 | function ColorCode_Callback(hObject, eventdata, handles)
|
---|
805 |
|
---|
806 |
|
---|
807 | % --- Executes on selection change in ColorScalar.
|
---|
808 | function ColorScalar_Callback(hObject, eventdata, handles)
|
---|
809 |
|
---|
810 |
|
---|
811 | function num_ColCode2_Callback(hObject, eventdata, handles)
|
---|
812 |
|
---|
813 |
|
---|
814 |
|
---|
815 | % --- Executes on button press in CheckTable.
|
---|
816 | function CheckTable_Callback(hObject, eventdata, handles)
|
---|
817 | if get(handles.CheckTable,'Value')
|
---|
818 | set(handles.TableDisplay,'Visible','on')
|
---|
819 | else
|
---|
820 | set(handles.TableDisplay,'Visible','off')
|
---|
821 | end
|
---|
822 |
|
---|