[204] | 1 | %'set_object': GUI to edit a projection object |
---|
| 2 | %------------------------------------------------------------------------ |
---|
| 3 | % function hset_object= set_object(data, PlotHandles,ZBounds) |
---|
| 4 | % associated with the GUI set_object.fig |
---|
| 5 | % |
---|
| 6 | % OUTPUT: |
---|
| 7 | % hset_object: handle of the GUI figure |
---|
| 8 | % |
---|
| 9 | % INPUT: |
---|
| 10 | % data: structure describing the object properties |
---|
| 11 | % .Style=... |
---|
| 12 | % .ProjMode |
---|
| 13 | % .CoordType: 'phys' or 'px' |
---|
| 14 | % .DX,.DY,.DZ : mesh along each dirction |
---|
| 15 | % .RangeX, RangeY |
---|
| 16 | % .Coord(j,i), i=1, 2, 3, components x, y, z of j=1...n position(s) characterizing the object components |
---|
| 17 | % PlotHandles: handles for projection plots NO MORE USED |
---|
| 18 | % Zbounds: bounds on Z ( 3D case) |
---|
| 19 | % |
---|
| 20 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 21 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 22 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 23 | % This file is part of the toolbox UVMAT. |
---|
| 24 | % |
---|
| 25 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 26 | % it under the terms of the GNU General Public License as published by |
---|
| 27 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 28 | % (at your option) any later version. |
---|
| 29 | % |
---|
| 30 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 31 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 32 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 33 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
| 34 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 35 | |
---|
| 36 | function varargout = set_object(varargin) |
---|
| 37 | |
---|
| 38 | % Last Modified by GUIDE v2.5 24-Nov-2008 14:29:06 |
---|
| 39 | |
---|
| 40 | % Begin initialization code - DO NOT PLOT |
---|
| 41 | gui_Singleton = 1; |
---|
| 42 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 43 | 'gui_Singleton', gui_Singleton, ... |
---|
| 44 | 'gui_OpeningFcn', @set_object_OpeningFcn, ... |
---|
| 45 | 'gui_OutputFcn', @set_object_OutputFcn, ... |
---|
| 46 | 'gui_LayoutFcn', [] , ... |
---|
| 47 | 'gui_Callback', []); |
---|
| 48 | if nargin & ischar(varargin{1}) |
---|
| 49 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 50 | end |
---|
| 51 | |
---|
| 52 | if nargout |
---|
| 53 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 54 | else |
---|
| 55 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 56 | end |
---|
| 57 | % End initialization code - DO NOT PLOT |
---|
| 58 | %------------------------------------------------------------------------ |
---|
| 59 | %------------------------------------------------------------------------ |
---|
| 60 | % --- Executes just before set_object is made visible. |
---|
| 61 | %INPUT: |
---|
| 62 | % handles: handles of the set_object interface elements |
---|
| 63 | %'IndexObj': NON USED ANYMORE (To suppress) index of the object (on the UvData list) that set_object will modify |
---|
| 64 | % if =[] or absent: index still undefined (create mode in uvmat) |
---|
| 65 | % if=0; no associated object (used for series), the button 'PLOT' is then unvisible |
---|
| 66 | %'data': read from an existing object selected in the interface |
---|
| 67 | % .TITLE : class of object ('POINTS','LINE',....) |
---|
| 68 | % .DX,DY,DZ; meshes for regular grids |
---|
| 69 | % .Coord: object position coordinates |
---|
| 70 | % .ParentButton: handle of the uicontrol object calling the interface |
---|
| 71 | % PlotHandles: set of handles of the elements contolling the plotting of the projected field: |
---|
| 72 | % if =[] or absent, no plot (mask mode in uvmat) |
---|
| 73 | % parameters on the uvmat interface (obtained by 'get_plot_handle.m') |
---|
| 74 | function set_object_OpeningFcn(hObject, eventdata, handles, data, PlotHandles,ZBounds) |
---|
| 75 | %------------------------------------------------------------------- |
---|
| 76 | % Choose default command line output for set_object |
---|
| 77 | handles.output = hObject; |
---|
| 78 | % Update handles structure |
---|
| 79 | guidata(hObject, handles); |
---|
| 80 | |
---|
| 81 | %default |
---|
[206] | 82 | if ~exist('ZBounds','var') |
---|
| 83 | ZBounds=0; %default |
---|
[204] | 84 | end |
---|
| 85 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front) |
---|
| 86 | enable_plot=0;%default: does not allow plot of object and projection |
---|
| 87 | |
---|
| 88 | % fill the interface as set in the input data: |
---|
| 89 | if exist('data','var') |
---|
| 90 | if isfield(data,'enable_plot') |
---|
| 91 | enable_plot=data.enable_plot;%test to desable button PLOT (display mode) |
---|
| 92 | end |
---|
| 93 | if isfield(data,'Name') |
---|
| 94 | set(handles.TITLE,'String',data.Name) |
---|
| 95 | end |
---|
| 96 | if ~isfield(data,'NbDim')||~isequal(data.NbDim,3)%2D case |
---|
| 97 | set(handles.ZObject,'Visible','off') |
---|
| 98 | set(handles.z_slider,'Visible','off') |
---|
| 99 | else |
---|
| 100 | set(handles.ZObject,'Visible','on') |
---|
| 101 | set(handles.z_slider,'Visible','on') |
---|
| 102 | if isfield(data,'Coord') && size(data.Coord,2)==3 |
---|
| 103 | set(handles.ZObject,'String',num2str(data.Coord(1,3),4)) |
---|
| 104 | end |
---|
| 105 | end |
---|
| 106 | if isfield(data,'StyleMenu') |
---|
| 107 | set(handles.ObjectStyle,'String',data.StyleMenu); |
---|
| 108 | end |
---|
| 109 | if isfield(data,'Style') |
---|
| 110 | menu=get(handles.ObjectStyle,'String'); |
---|
| 111 | for iline=1:length(menu) |
---|
| 112 | if isequal(menu{iline},data.Style) |
---|
| 113 | set(handles.ObjectStyle,'Value',iline) |
---|
| 114 | break |
---|
| 115 | end |
---|
| 116 | end |
---|
| 117 | end |
---|
| 118 | ObjectStyle_Callback(hObject, eventdata, handles) |
---|
| 119 | if isfield(data,'ProjMenu') |
---|
| 120 | set(handles.ProjMode,'String',data.ProjMenu);%overset the standard menu |
---|
| 121 | end |
---|
| 122 | if isfield(data,'ProjMode') |
---|
| 123 | menu=get(handles.ProjMode,'String'); |
---|
| 124 | for iline=1:length(menu) |
---|
| 125 | if isequal(menu{iline},data.ProjMode) |
---|
| 126 | set(handles.ProjMode,'Value',iline) |
---|
| 127 | break |
---|
| 128 | end |
---|
| 129 | end |
---|
| 130 | end |
---|
| 131 | ProjMode_Callback(hObject, eventdata, handles) |
---|
| 132 | if isfield(data,'Coord') |
---|
| 133 | if ischar(data.Coord) |
---|
| 134 | data.Coord=str2num(data.Coord); |
---|
| 135 | elseif iscell(data.Coord) |
---|
| 136 | CoordCell=data.Coord; |
---|
| 137 | data.Coord=zeros(numel(CoordCell),3); |
---|
| 138 | data.Coord(:,3)=zeros(numel(CoordCell),1); % z component set to 0 by default |
---|
| 139 | for iline=1:numel(CoordCell) |
---|
| 140 | line_vec=str2num(CoordCell{iline}); |
---|
| 141 | if numel(line_vec)==2 |
---|
| 142 | data.Coord(iline,1:2)=str2num(CoordCell{iline}); |
---|
| 143 | else |
---|
| 144 | data.Coord(iline,:)=str2num(CoordCell{iline}); |
---|
| 145 | end |
---|
| 146 | end |
---|
| 147 | end |
---|
| 148 | if size(data.Coord,2)>=2 |
---|
| 149 | sizcoord=size(data.Coord); |
---|
| 150 | for i=1:sizcoord(1) |
---|
| 151 | XObject{i}=num2str(data.Coord(i,1),4); |
---|
| 152 | YObject{i}=num2str(data.Coord(i,2),4); |
---|
| 153 | end |
---|
| 154 | set(handles.XObject,'String',XObject) |
---|
| 155 | set(handles.YObject,'String',YObject) |
---|
| 156 | if sizcoord(2)>3 |
---|
| 157 | for i=1:sizcoord(1) |
---|
| 158 | ZObject{i}=num2str(data.Coord(i,3),4); |
---|
| 159 | end |
---|
| 160 | set(handles.ZObject,'String',ZObject) |
---|
| 161 | end |
---|
| 162 | end |
---|
| 163 | end |
---|
| 164 | if isfield(data,'DX') |
---|
| 165 | if ~ischar(handles.DX) |
---|
| 166 | data.DX=num2str(data.DX,3); |
---|
| 167 | end |
---|
| 168 | set(handles.DX,'String',data.DX) |
---|
| 169 | end |
---|
| 170 | if isfield(data,'DY') |
---|
| 171 | if ~ischar(handles.DY) |
---|
| 172 | data.DY=num2str(data.DY,3); |
---|
| 173 | end |
---|
| 174 | set(handles.DY,'String',data.DX) |
---|
| 175 | end |
---|
| 176 | if isfield(data,'RangeZ') && length(ZBounds) >= 2 |
---|
| 177 | set(handles.ZMax,'String',num2str(max(data.RangeZ),3)) |
---|
| 178 | DZ=max(data.RangeZ);%slider step |
---|
[206] | 179 | if ~isnan(ZBounds(1)) && ZBounds(2)~=ZBounds(1) |
---|
[204] | 180 | rel_step(1)=min(DZ/(ZBounds(2)-ZBounds(1)),0.2);%must be smaller than 1 |
---|
| 181 | rel_step(2)=0.1; |
---|
| 182 | set(handles.z_slider,'Visible','on') |
---|
| 183 | set(handles.z_slider,'Min',ZBounds(1)) |
---|
| 184 | set(handles.z_slider,'Max',ZBounds(2)) |
---|
| 185 | set(handles.z_slider,'SliderStep',rel_step) |
---|
| 186 | set(handles.z_slider,'Value',(ZBounds(1)+ZBounds(2))/2) |
---|
| 187 | end |
---|
| 188 | end |
---|
| 189 | if isfield(data,'RangeX') |
---|
| 190 | if ischar(data.RangeX) |
---|
| 191 | data.RangeX=str2num(data.RangeX); |
---|
| 192 | end |
---|
| 193 | set(handles.XMax,'String',num2str(max(data.RangeX),3)) |
---|
| 194 | set(handles.XMin,'String',num2str(min(data.RangeX),3)) |
---|
| 195 | end |
---|
| 196 | if isfield(data,'RangeY') |
---|
| 197 | if ischar(data.RangeY) |
---|
| 198 | data.RangeY=str2num(data.RangeY); |
---|
| 199 | end |
---|
| 200 | set(handles.YMax,'String',num2str(max(data.RangeY),3)) |
---|
| 201 | set(handles.YMin,'String',num2str(min(data.RangeY),3)) |
---|
| 202 | end |
---|
| 203 | if isfield(data,'RangeZ') |
---|
| 204 | if ischar(data.RangeZ) |
---|
| 205 | data.RangeZ=str2num(data.RangeZ); |
---|
| 206 | end |
---|
| 207 | set(handles.ZMax,'String',num2str(max(data.RangeZ),3)) |
---|
| 208 | if numel(data.RangeZ)>=2 |
---|
| 209 | set(handles.ZMin,'String',num2str(min(data.RangeZ),3)) |
---|
| 210 | end |
---|
| 211 | end |
---|
[212] | 212 | if isfield(data,'Angle') && isequal(numel(data.Angle),3) |
---|
| 213 | set(handles.Phi,'String',num2str(data.Angle(1))) |
---|
| 214 | set(handles.Theta,'String',num2str(data.Angle(2))) |
---|
| 215 | set(handles.Psi,'String',num2str(data.Angle(3))) |
---|
[204] | 216 | end |
---|
| 217 | if isfield(data,'DZ') |
---|
| 218 | if ~ischar(handles.DZ) |
---|
| 219 | data.DY=num2str(data.DZ,3); |
---|
| 220 | end |
---|
| 221 | set(handles.DZ,'String',data.DZ) |
---|
| 222 | end |
---|
| 223 | if isfield(data,'CoordUnit') |
---|
| 224 | set(handles.CoordUnit,'String',data.CoordUnit) |
---|
| 225 | end |
---|
| 226 | end |
---|
| 227 | if enable_plot |
---|
| 228 | set(handles.PLOT,'enable','on') |
---|
| 229 | else |
---|
| 230 | set(handles.PLOT,'enable','off') |
---|
| 231 | end |
---|
| 232 | huvmat=findobj(allchild(0),'tag','uvmat'); |
---|
| 233 | UvData=get(huvmat,'UserData'); |
---|
| 234 | pos_uvmat=get(huvmat,'Position'); |
---|
| 235 | %position the set_object GUI with respect to uvmat |
---|
| 236 | if isfield(UvData,'SetObjectOrigin') |
---|
| 237 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2); |
---|
| 238 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4); |
---|
| 239 | set(hObject,'Position',pos_set_object) |
---|
| 240 | end |
---|
| 241 | |
---|
| 242 | %------------------------------------------------------------------------ |
---|
| 243 | % --- Outputs from this function are returned to the command line. |
---|
| 244 | function varargout = set_object_OutputFcn(hObject, eventdata, handles) |
---|
| 245 | %------------------------------------------------------------------------ |
---|
| 246 | % Get default command line output from handles structure |
---|
| 247 | varargout{1} = handles.output; |
---|
| 248 | varargout{2}=handles; |
---|
| 249 | |
---|
| 250 | %------------------------------------------------------------------------ |
---|
| 251 | % --- Executes on selection change in ObjectStyle. |
---|
| 252 | function ObjectStyle_Callback(hObject, eventdata, handles) |
---|
| 253 | %------------------------------------------------------------------------ |
---|
| 254 | style_prev=get(handles.ObjectStyle,'UserData');%previous object style |
---|
| 255 | str=get(handles.ObjectStyle,'String'); |
---|
| 256 | val=get(handles.ObjectStyle,'Value'); |
---|
| 257 | style=str{val}; |
---|
| 258 | % make correspondance between different object styles |
---|
| 259 | Xcolumn=get(handles.XObject,'String'); |
---|
| 260 | Ycolumn=get(handles.YObject,'String'); |
---|
| 261 | if ischar(Xcolumn) |
---|
| 262 | sizchar=size(Xcolumn); |
---|
| 263 | for icol=1:sizchar(1) |
---|
| 264 | Xcolumn_cell{icol}=Xcolumn(icol,:); |
---|
| 265 | end |
---|
| 266 | Xcolumn=Xcolumn_cell; |
---|
| 267 | end |
---|
| 268 | if ischar(Ycolumn) |
---|
| 269 | sizchar=size(Ycolumn); |
---|
| 270 | for icol=1:sizchar(1) |
---|
| 271 | Ycolumn_cell{icol}=Ycolumn(icol,:); |
---|
| 272 | end |
---|
| 273 | Ycolumn=Ycolumn_cell; |
---|
| 274 | end |
---|
| 275 | Zcolumn={};%default |
---|
| 276 | z_new={}; |
---|
| 277 | if isequal(get(handles.ZObject,'Visible'),'on') |
---|
[215] | 278 | %data.NbDim=3; %test 3D object |
---|
[204] | 279 | Zcolumn=get(handles.ZObject,'String'); |
---|
| 280 | if ischar(Zcolumn) |
---|
| 281 | Zcolumn={Zcolumn}; |
---|
| 282 | end |
---|
| 283 | end |
---|
| 284 | x_new{1}=Xcolumn{1}; |
---|
| 285 | y_new{1}=Ycolumn{1}; |
---|
| 286 | if ~isempty(Zcolumn) |
---|
| 287 | z_new{1}=Zcolumn{1}; |
---|
| 288 | end |
---|
| 289 | if isequal(style,'line') |
---|
| 290 | if strcmp(style_prev,'rectangle')||strcmp(style_prev,'ellipse') |
---|
| 291 | XMax=get(handles.XMax,'String'); |
---|
| 292 | YMax=get(handles.YMax,'String'); |
---|
| 293 | x_new{2}=num2str(XMax,4); |
---|
| 294 | y_new{2}=num2str(YMax,4); |
---|
| 295 | set(handles.XObject,'String',x_new) |
---|
| 296 | set(handles.YObject,'String',y_new) |
---|
| 297 | set(handles.ZObject,'String',z_new) |
---|
| 298 | end |
---|
| 299 | elseif isequal(style,'polyline') |
---|
| 300 | elseif strcmp(style,'rectangle')|| strcmp(style,'ellipse') |
---|
| 301 | set(handles.XObject,'String',x_new) |
---|
| 302 | set(handles.YObject,'String',y_new) |
---|
| 303 | set(handles.ZObject,'String',z_new) |
---|
| 304 | end |
---|
| 305 | |
---|
| 306 | switch style |
---|
| 307 | case {'points','line','polyline','plane'} |
---|
| 308 | menu_proj={'projection';'interp';'filter';'none'}; |
---|
| 309 | case {'polygon','rectangle','ellipse'} |
---|
| 310 | menu_proj={'inside';'outside';'mask_inside';'mask_outside'}; |
---|
| 311 | case 'volume' |
---|
| 312 | menu_proj={'interp';'none'}; |
---|
| 313 | end |
---|
| 314 | proj_index=get(handles.ProjMode,'Value'); |
---|
| 315 | if proj_index<numel(menu_proj) |
---|
| 316 | set(handles.ProjMode,'Value',1);% value index must not exceed the menu length |
---|
| 317 | end |
---|
| 318 | set(handles.ProjMode,'String',menu_proj) |
---|
| 319 | ProjMode_Callback(hObject, eventdata, handles) |
---|
| 320 | %store the current option |
---|
| 321 | str=get(handles.ObjectStyle,'String'); |
---|
| 322 | val=get(handles.ObjectStyle,'Value'); |
---|
| 323 | set(handles.ObjectStyle,'UserData',style) |
---|
| 324 | |
---|
| 325 | %------------------------------------------------------------------------ |
---|
| 326 | function xObject_Callback(hObject, eventdata, handles) |
---|
| 327 | |
---|
| 328 | %------------------------------------------------------------------------ |
---|
| 329 | function yObject_Callback(hObject, eventdata, handles) |
---|
| 330 | |
---|
| 331 | %------------------------------------------------------------------------ |
---|
| 332 | % --- Executes on selection change in zObject. |
---|
| 333 | function zObject_Callback(hObject, eventdata, handles) |
---|
| 334 | %------------------------------------------------------------------------ |
---|
| 335 | |
---|
| 336 | %------------------------------------------------------------------------ |
---|
| 337 | % --- Executes on selection change in ProjMode. |
---|
| 338 | function ProjMode_Callback(hObject, eventdata, handles) |
---|
| 339 | menu=get(handles.ProjMode,'String'); |
---|
| 340 | value=get(handles.ProjMode,'Value'); |
---|
| 341 | ProjMode=menu{value}; |
---|
| 342 | menu=get(handles.ObjectStyle,'String'); |
---|
| 343 | value=get(handles.ObjectStyle,'Value'); |
---|
| 344 | ObjectStyle=menu{value}; |
---|
| 345 | test3D=isequal(get(handles.ZObject,'Visible'),'on');%3D case |
---|
| 346 | |
---|
| 347 | %default setting |
---|
| 348 | set(handles.Phi,'Visible','off') |
---|
| 349 | set(handles.Theta,'Visible','off') |
---|
| 350 | set(handles.Psi,'Visible','off') |
---|
| 351 | set(handles.XMin,'Visible','off') |
---|
| 352 | set(handles.XMax,'Visible','off') |
---|
| 353 | set(handles.YMin,'Visible','off') |
---|
| 354 | if isequal(ProjMode,'interp') |
---|
| 355 | set(handles.YMax,'Visible','off') |
---|
| 356 | else |
---|
| 357 | set(handles.YMax,'Visible','on') |
---|
| 358 | end |
---|
| 359 | if strcmp(ObjectStyle,'rectangle')||strcmp(ObjectStyle,'ellipse') |
---|
| 360 | set(handles.XMax,'Visible','on') |
---|
| 361 | else |
---|
| 362 | set(handles.XMax,'Visible','off') |
---|
| 363 | end |
---|
| 364 | set(handles.ZMin,'Visible','off') |
---|
| 365 | set(handles.ZMax,'Visible','off') |
---|
| 366 | set(handles.DX,'Visible','off') |
---|
| 367 | set(handles.DY,'Visible','off') |
---|
| 368 | set(handles.DZ,'Visible','off') |
---|
| 369 | |
---|
| 370 | switch ObjectStyle |
---|
| 371 | case 'points' |
---|
| 372 | set(handles.YMax,'TooltipString','YMax: range of averaging around each point') |
---|
| 373 | set(handles.XObject,'TooltipString','XObject: set of x coordinates of the points') |
---|
| 374 | set(handles.YObject,'TooltipString','YObject: set of y coordinates of the points') |
---|
| 375 | set(handles.ZObject,'TooltipString','ZObject: set of z coordinates of the points') |
---|
| 376 | case {'line','polyline','polygon'} |
---|
| 377 | set(handles.YMax,'TooltipString','YMax: range of averaging around the line') |
---|
| 378 | set(handles.XObject,'TooltipString','XObject: set of x coordinates defining the line') |
---|
| 379 | set(handles.YObject,'TooltipString','YObject: set of y coordinates defining the line') |
---|
| 380 | set(handles.ZObject,'TooltipString','ZObject: set of z coordinates defining the line') |
---|
| 381 | if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter') |
---|
| 382 | set(handles.DX,'Visible','on') |
---|
| 383 | set(handles.DX,'TooltipString','DX: mesh for the interpolated field along the line') |
---|
| 384 | end |
---|
| 385 | case {'rectangle','ellipse'} |
---|
| 386 | set(handles.XMax,'TooltipString',['XMax: half length of the ' ObjectStyle]) |
---|
| 387 | set(handles.YMax,'TooltipString',['YMax: half width of the ' ObjectStyle]) |
---|
| 388 | set(handles.XObject,'TooltipString',['XObject: x coordinate of the ' ObjectStyle ' centre']) |
---|
| 389 | set(handles.YObject,'TooltipString',['YObject: y coordinate of the ' ObjectStyle ' centre']) |
---|
| 390 | case {'plane'} |
---|
[212] | 391 | set(handles.Psi,'Visible','on') |
---|
[204] | 392 | set(handles.XMin,'Visible','on') |
---|
| 393 | set(handles.XMax,'Visible','on') |
---|
| 394 | set(handles.YMin,'Visible','on') |
---|
| 395 | set(handles.YMax,'Visible','on') |
---|
| 396 | set(handles.XObject,'TooltipString',['XObject: x coordinate of the axis origin for the ' ObjectStyle]) |
---|
| 397 | set(handles.YObject,'TooltipString',['YObject: y coordinate of the axis origin for the ' ObjectStyle]) |
---|
| 398 | set(handles.ZMax,'TooltipString','ZMax: range of projection normal to the plane') |
---|
| 399 | if test3D |
---|
| 400 | set(handles.Theta,'Visible','on') |
---|
[212] | 401 | set(handles.Phi,'Visible','on') |
---|
[204] | 402 | set(handles.ZMax,'Visible','on') |
---|
| 403 | end |
---|
| 404 | if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter') |
---|
| 405 | set(handles.DX,'Visible','on') |
---|
| 406 | set(handles.DY,'Visible','on') |
---|
| 407 | else |
---|
| 408 | set(handles.DX,'Visible','off') |
---|
| 409 | set(handles.DY,'Visible','off') |
---|
| 410 | end |
---|
[206] | 411 | if isequal(ProjMode,'interp') |
---|
[204] | 412 | set(handles.DZ,'Visible','on') |
---|
| 413 | end |
---|
| 414 | case {'volume'} |
---|
| 415 | set(handles.XMin,'Visible','on') |
---|
| 416 | set(handles.XMax,'Visible','on') |
---|
| 417 | set(handles.YMin,'Visible','on') |
---|
| 418 | set(handles.YMax,'Visible','on') |
---|
| 419 | set(handles.XObject,'TooltipString',['XObject: x coordinate of the axis origin for the ' ObjectStyle]) |
---|
| 420 | set(handles.YObject,'TooltipString',['YObject: y coordinate of the axis origin for the ' ObjectStyle]) |
---|
[212] | 421 | set(handles.Phi,'Visible','on') |
---|
| 422 | set(handles.Theta,'Visible','on') |
---|
| 423 | set(handles.Psi,'Visible','on') |
---|
| 424 | set(handles.ZMin,'Visible','on') |
---|
| 425 | set(handles.ZMax,'Visible','on') |
---|
[204] | 426 | if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter') |
---|
| 427 | set(handles.DX,'Visible','on') |
---|
| 428 | set(handles.DY,'Visible','on') |
---|
[206] | 429 | set(handles.DZ,'Visible','on') |
---|
[204] | 430 | else |
---|
| 431 | set(handles.DX,'Visible','off') |
---|
| 432 | set(handles.DY,'Visible','off') |
---|
[206] | 433 | set(handles.DZ,'Visible','off') |
---|
[204] | 434 | end |
---|
| 435 | end |
---|
| 436 | %------------------------------------------------------------------------ |
---|
| 437 | |
---|
| 438 | %------------------------------------------------------------------------ |
---|
| 439 | function Phi_Callback(hObject, eventdata, handles) |
---|
| 440 | update_slider(hObject, eventdata,handles) |
---|
| 441 | %------------------------------------------------------------------------ |
---|
| 442 | %------------------------------------------------------------------------ |
---|
| 443 | function Theta_Callback(hObject, eventdata, handles) |
---|
| 444 | update_slider(hObject, eventdata,handles) |
---|
| 445 | %------------------------------------------------------------------------ |
---|
| 446 | function update_slider(hObject, eventdata,handles) |
---|
| 447 | %rotation angles |
---|
[212] | 448 | PlaneAngle(1)=str2num(get(handles.Phi,'String'));%first angle in degrees |
---|
| 449 | PlaneAngle(2)=str2num(get(handles.Theta,'String'));%second angle in degrees |
---|
| 450 | PlaneAngle(3)=str2num(get(handles.Psi,'String'));%second angle in degrees |
---|
| 451 | om=norm(PlaneAngle);%norm of rotation angle in radians |
---|
| 452 | OmAxis=PlaneAngle/om; %unit vector marking the rotation axis |
---|
| 453 | cos_om=cos(pi*om/180); |
---|
| 454 | sin_om=sin(pi*om/180); |
---|
| 455 | coeff=OmAxis(3)*(1-cos_om); |
---|
| 456 | %components of the unity vector norm_plane normal to the projection plane |
---|
| 457 | norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; |
---|
| 458 | norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; |
---|
| 459 | norm_plane(3)=OmAxis(3)*coeff+cos_om; |
---|
[204] | 460 | huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle |
---|
| 461 | UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
---|
| 462 | if isfield(UvData,'X') & isfield(UvData,'Y') & isfield(UvData,'Z') |
---|
[212] | 463 | Z=norm_plane(1)*(UvData.X)+norm_plane(2)*(UvData.Y)+norm_plane(3)*(UvData.Z); |
---|
[204] | 464 | set(handles.z_slider,'Min',min(Z)) |
---|
| 465 | set(handles.z_slider,'Max',max(Z)) |
---|
| 466 | ZMax_Callback(hObject, eventdata, handles) |
---|
| 467 | end |
---|
| 468 | %------------------------------------------------------------------------ |
---|
| 469 | function DX_Callback(hObject, eventdata, handles) |
---|
| 470 | %------------------------------------------------------------------------ |
---|
| 471 | %------------------------------------------------------------------------ |
---|
| 472 | function DY_Callback(hObject, eventdata, handles) |
---|
| 473 | %------------------------------------------------------------------------ |
---|
| 474 | %------------------------------------------------------------------------ |
---|
| 475 | function DZ_Callback(hObject, eventdata, handles) |
---|
| 476 | %------------------------------------------------------------------------ |
---|
| 477 | |
---|
| 478 | %------------------------------------------------------------------------ |
---|
| 479 | %----------------------------------------------------- |
---|
| 480 | % --- Executes on button press in OPEN: DESACTIVATED use uvmat browser |
---|
| 481 | function OPEN_Callback(hObject, eventdata, handles) |
---|
| 482 | %get the object file |
---|
| 483 | oldfile=' '; |
---|
| 484 | huvmat=findobj('Tag','uvmat'); |
---|
| 485 | hchild=get(huvmat,'Children'); |
---|
| 486 | hrootpath=findobj(hchild,'Tag','RootPath'); |
---|
| 487 | if ~isempty(hrootpath) |
---|
| 488 | oldfile=get(hrootpath,'String'); |
---|
| 489 | if iscell(oldfile) |
---|
| 490 | oldfile=oldfile{1}; |
---|
| 491 | end |
---|
| 492 | end |
---|
| 493 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 494 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
| 495 | '*.xml', '.xml files '; ... |
---|
| 496 | '*.mat', '.mat matlab files '}, ... |
---|
| 497 | 'Pick a file',oldfile); |
---|
| 498 | fileinput=[PathName FileName];%complete file name |
---|
| 499 | testblank=findstr(fileinput,' ');%look for blanks |
---|
| 500 | if ~isempty(testblank) |
---|
| 501 | msgbox_uvmat('ERROR','forbidden input file name: contain blanks') |
---|
| 502 | return |
---|
| 503 | end |
---|
| 504 | sizf=size(fileinput); |
---|
| 505 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
| 506 | |
---|
| 507 | %read the file |
---|
| 508 | t=xmltree(fileinput); |
---|
| 509 | s=convert(t); |
---|
| 510 | if ~isfield(s,'Style') |
---|
| 511 | s.Style='points'; |
---|
| 512 | end |
---|
| 513 | if ~isfield(s,'ProjMode') |
---|
| 514 | s.ProjMode='none'; |
---|
| 515 | end |
---|
| 516 | teststyle=0; |
---|
| 517 | |
---|
| 518 | switch s.Style |
---|
| 519 | case {'points','line','polyline','plane'} |
---|
| 520 | menu_proj={'projection';'interp';'filter';'none'}; |
---|
| 521 | case {'polygon','rectangle','ellipse'} |
---|
| 522 | menu_proj={'inside';'outside';'mask_inside';'mask_outside'}; |
---|
| 523 | case 'volume' |
---|
| 524 | menu_proj={'none'}; |
---|
| 525 | end |
---|
| 526 | set(handles.ObjectStyle,'String',menu_proj) |
---|
| 527 | menu=get(handles.ObjectStyle,'String'); |
---|
| 528 | for iline=1:length(menu) |
---|
| 529 | if isequal(menu{iline},s.Style) |
---|
| 530 | set(handles.ObjectStyle,'Value',iline) |
---|
| 531 | teststyle=1; |
---|
| 532 | break |
---|
| 533 | end |
---|
| 534 | end |
---|
| 535 | testmode=0; |
---|
| 536 | %menu=get(handles.ProjMode,'String'); |
---|
| 537 | for iline=1:length(menu_proj) |
---|
| 538 | if isequal(menu_proj{iline},s.ProjMode) |
---|
| 539 | set(handles.ProjMode,'Value',iline) |
---|
| 540 | testmode=1; |
---|
| 541 | break |
---|
| 542 | end |
---|
| 543 | end |
---|
| 544 | |
---|
| 545 | ProjMode_Callback(hObject, eventdata, handles);%visualize the appropriate edit boxes |
---|
| 546 | if isfield(s,'XMax') |
---|
| 547 | set(handles.XMax,'String',s.XMax) |
---|
| 548 | end |
---|
| 549 | if isfield(s,'XMin') |
---|
| 550 | set(handles.XMin,'String',s.XMin) |
---|
| 551 | end |
---|
| 552 | if isfield(s,'YMax') |
---|
| 553 | set(handles.YMax,'String',s.YMax) |
---|
| 554 | end |
---|
| 555 | if isfield(s,'YMin') |
---|
| 556 | set(handles.YMin,'String',s.YMin) |
---|
| 557 | end |
---|
| 558 | Range=0; |
---|
| 559 | if isfield(s,'Range') |
---|
| 560 | if ischar(s.Range) |
---|
| 561 | Range=str2num(s.Range); |
---|
| 562 | else |
---|
| 563 | Range(1,:)=str2num(s.Range{1}); |
---|
| 564 | Range(2,:)=str2num(s.Range{2}); |
---|
| 565 | end |
---|
| 566 | end |
---|
| 567 | if size(Range,2)>=3 |
---|
| 568 | if size(Range,1)>=2 |
---|
| 569 | set(handles.ZMin,'String',num2str(Range(2,3),3)) |
---|
| 570 | end |
---|
| 571 | if size(Range,1)>=2 |
---|
| 572 | set(handles.ZMax,'String',num2str(Range(1,3),3)) |
---|
| 573 | end |
---|
| 574 | end |
---|
| 575 | if size(Range,2)>=2 |
---|
| 576 | if size(Range,1)>=2 |
---|
| 577 | set(handles.YMin,'String',num2str(Range(2,2),3)) |
---|
| 578 | end |
---|
| 579 | if size(Range,1)>=2 |
---|
| 580 | set(handles.YMax,'String',num2str(Range(1,2),3)) |
---|
| 581 | end |
---|
| 582 | end |
---|
| 583 | if size(Range,2)>=1 |
---|
| 584 | if size(Range,1)>=2 |
---|
| 585 | set(handles.XMin,'String',num2str(Range(2,1),3)) |
---|
| 586 | end |
---|
| 587 | if size(Range,1)>=2 |
---|
| 588 | set(handles.XMax,'String',num2str(Range(1,1),3)) |
---|
| 589 | end |
---|
| 590 | end |
---|
| 591 | if isfield(s,'RangeX') & ischar(s.RangeX) |
---|
| 592 | RangeX=str2num(s.RangeX); |
---|
| 593 | set(handles.XMax,'String',num2str(max(RangeX),3)) |
---|
| 594 | set(handles.XMin,'String',num2str(min(RangeX),3)) |
---|
| 595 | end |
---|
| 596 | |
---|
| 597 | if isfield(s,'RangeY') |
---|
| 598 | if ischar(s.RangeY) |
---|
| 599 | RangeY=str2num(s.RangeY); |
---|
| 600 | set(handles.YMax,'String',num2str(max(RangeY),3)) |
---|
| 601 | set(handles.YMin,'String',num2str(min(RangeY),3)) |
---|
| 602 | end |
---|
| 603 | end |
---|
| 604 | if isfield(s,'RangeZ') |
---|
| 605 | if ischar(s.RangeZ) |
---|
| 606 | RangeZ=str2num(s.RangeZ); |
---|
| 607 | set(handles.ZMax,'String',num2str(max(RangeZ),3)) |
---|
| 608 | set(handles.ZMin,'String',num2str(min(RangeZ),3)) |
---|
| 609 | end |
---|
| 610 | end |
---|
| 611 | if isfield(s,'Phi') |
---|
[212] | 612 | set(handles.Psi,'String',s.Phi)%old definition |
---|
[204] | 613 | end |
---|
[212] | 614 | if isfield(s,'Angle')&& isequal(numel(s.Angle),3) |
---|
| 615 | set(handles.Phi,'String',s.Angle(1)) |
---|
| 616 | set(handles.Theta,'String',s.Angle(2)) |
---|
| 617 | set(handles.Psi,'String',s.Angle(3)) |
---|
[204] | 618 | end |
---|
[212] | 619 | % if isfield(s,'Psi') |
---|
| 620 | % set(handles.Psi,'String',s.Psi) |
---|
| 621 | % end |
---|
[204] | 622 | |
---|
| 623 | if isfield(s,'DX') |
---|
| 624 | set(handles.DX,'String',s.DX) |
---|
| 625 | end |
---|
| 626 | if isfield(s,'DY') |
---|
| 627 | set(handles.DY,'String',s.DY) |
---|
| 628 | end |
---|
| 629 | if ~isfield(s,'Coord') |
---|
| 630 | XObject='0';%default |
---|
| 631 | YObject='0'; |
---|
| 632 | elseif ischar(s.Coord) |
---|
| 633 | line=str2num(s.Coord); |
---|
| 634 | XObject=num2str(line(1),4); |
---|
| 635 | YObject=num2str(line(2),4); |
---|
| 636 | else |
---|
| 637 | for i=1:length(s.Coord) |
---|
| 638 | line=str2num(s.Coord{i}); |
---|
| 639 | XObject{i}=num2str(line(1),4); |
---|
| 640 | YObject{i}=num2str(line(2),4); |
---|
| 641 | end |
---|
| 642 | end |
---|
| 643 | set(handles.XObject,'String',XObject) |
---|
| 644 | set(handles.YObject,'String',YObject) |
---|
| 645 | %METTRA A JOUR ASPECT DE L'INTERFACE (COMME set_object_Opening |
---|
| 646 | %------------------------------------------------------------------------ |
---|
| 647 | %---------------------------------------------------- |
---|
| 648 | % executed when closing: set the parent interface button to value 0 |
---|
| 649 | function closefcn(gcbo,eventdata,parent_button) |
---|
| 650 | |
---|
| 651 | huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle |
---|
| 652 | if ~isempty(huvmat) |
---|
| 653 | hhuvmat=guidata(huvmat); |
---|
| 654 | set(hhuvmat.edit,'Value',0) |
---|
| 655 | set(hhuvmat.edit,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree |
---|
| 656 | end |
---|
| 657 | hseries=findobj(allchild(0),'Name','series');%find the current series interface handle |
---|
| 658 | if ~isempty(hseries) |
---|
| 659 | hhseries=guidata(hseries); |
---|
| 660 | set(hhseries.GetObject,'Value',0) |
---|
| 661 | set(hhseries.GetObject,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
---|
| 662 | end |
---|
| 663 | |
---|
| 664 | %------------------------------------------------------------------------ |
---|
| 665 | % --- Executes on button press in PLOT: PLOT the defined object and its projected field |
---|
| 666 | function PLOT_Callback(hObject, eventdata, handles) |
---|
| 667 | |
---|
| 668 | %% reading the object parameters on the GUI uvmat |
---|
| 669 | huvmat=findobj('tag','uvmat');%find the current uvmat interface handle |
---|
| 670 | UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat |
---|
| 671 | hhuvmat=guidata(huvmat);%handles in the uvmat GUI |
---|
| 672 | ObjectName=get(handles.TITLE,'String');%name of the current object |
---|
| 673 | ListObject=get(hhuvmat.list_object_1,'String');%position in the objet list |
---|
| 674 | IndexObj_1=get(hhuvmat.list_object_1,'Value'); |
---|
| 675 | if isequal(get(hhuvmat.list_object_2,'Visible'),'on') |
---|
| 676 | IndexObj_2=get(hhuvmat.list_object_2,'Value'); |
---|
| 677 | List2=get(hhuvmat.list_object_2,'String'); |
---|
| 678 | else |
---|
| 679 | IndexObj_2=[]; |
---|
| 680 | end |
---|
| 681 | testnew=0; |
---|
| 682 | ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object |
---|
[233] | 683 | if ~isempty(ListObject) && strcmp(ListObject{IndexObj_1},ObjectName)% we are editing the object whose projection is viewed in the uvmat frame |
---|
[204] | 684 | IndexObj=IndexObj_1; |
---|
| 685 | projview='uvmat'; |
---|
| 686 | elseif ~isempty(IndexObj_2) && IndexObj_2<=numel(ListObject)&& strcmp(ListObject{IndexObj_2},ObjectName)% we are editing the object whose projection is viewed in view_field |
---|
| 687 | IndexObj=IndexObj_2; |
---|
| 688 | projview='view_field'; |
---|
| 689 | else %new object |
---|
| 690 | testnew=1; |
---|
| 691 | IndexObj=numel(ListObject)+1; |
---|
| 692 | projview='view_field'; |
---|
| 693 | end |
---|
| 694 | if strcmp(projview,'view_field') |
---|
| 695 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 696 | if isempty(hview_field) |
---|
| 697 | hview_field=view_field; |
---|
| 698 | end |
---|
| 699 | PlotHandles=guidata(hview_field); |
---|
| 700 | plotaxes=PlotHandles.axes3;%handle of axes3 in view_field |
---|
| 701 | else |
---|
| 702 | PlotHandles=hhuvmat; |
---|
| 703 | plotaxes=hhuvmat.axes3;%handle of axes3 in view_field |
---|
[231] | 704 | |
---|
[204] | 705 | end |
---|
| 706 | |
---|
| 707 | %% naming the object |
---|
| 708 | if length(ObjectName)<1% name of object not defined in set_object |
---|
| 709 | ObjectName=[num2str(IndexObj) '-' ObjectData.Style];%default name |
---|
| 710 | elseif ~get(hhuvmat.edit_object,'Value')%not in edit mode (new object created) |
---|
| 711 | detectname=1; |
---|
| 712 | ObjectNameNew=ObjectName; |
---|
| 713 | vers=0; |
---|
| 714 | while detectname==1 |
---|
| 715 | detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list |
---|
| 716 | if detectname% if the object name already exists |
---|
| 717 | indstr=regexp(ObjectNameNew,'\D'); |
---|
| 718 | if indstr(end)<length(ObjectNameNew) %object name ends by a number |
---|
| 719 | vers=str2double(ObjectNameNew(indstr(end)+1:end))+1; |
---|
| 720 | ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)]; |
---|
| 721 | else |
---|
| 722 | vers=vers+1; |
---|
| 723 | ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)]; |
---|
| 724 | end |
---|
| 725 | end |
---|
| 726 | end |
---|
| 727 | ObjectName=ObjectNameNew; |
---|
| 728 | end |
---|
| 729 | ListObject{IndexObj,1}=ObjectName; |
---|
| 730 | set(hhuvmat.list_object_1,'String',ListObject) |
---|
[231] | 731 | set(hhuvmat.list_object_2,'String',ListObject) |
---|
[204] | 732 | |
---|
| 733 | %% update the object plot and projection field |
---|
| 734 | if testnew |
---|
| 735 | set(hhuvmat.list_object_2,'Value',IndexObj) |
---|
| 736 | ObjectData.DisplayHandle_uvmat=hhuvmat.axes3; |
---|
| 737 | ObjectData.DisplayHandle_view_field=[]; |
---|
| 738 | else |
---|
| 739 | if isfield(UvData.Object{IndexObj},'DisplayHandle_uvmat')% save the previous object graph handles |
---|
| 740 | ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj}.DisplayHandle_uvmat; |
---|
| 741 | else |
---|
| 742 | ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;%there is no object handle, than the axes handles is used as input |
---|
| 743 | end |
---|
| 744 | if isfield(UvData.Object{IndexObj},'DisplayHandle_view_field')% save the previous object graph handles |
---|
| 745 | ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj}.DisplayHandle_view_field; |
---|
| 746 | else |
---|
| 747 | ObjectData.DisplayHandle_view_field=[]; |
---|
| 748 | end |
---|
| 749 | end |
---|
| 750 | UvData.Object{IndexObj}=ObjectData;%update the current object properties |
---|
| 751 | UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2); |
---|
| 752 | set(huvmat,'UserData',UvData) |
---|
| 753 | |
---|
| 754 | %% plot the field projected on the object and store in the corresponding figue |
---|
[227] | 755 | [ProjData,errormsg]= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData |
---|
| 756 | if ~isempty(errormsg) |
---|
| 757 | msgbox_uvmat('ERROR', errormsg) |
---|
| 758 | return |
---|
| 759 | end |
---|
[204] | 760 | PlotParam=read_plot_param(PlotHandles); |
---|
| 761 | [PlotType,Object_out{IndexObj}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotParam);%update an existing field plot |
---|
| 762 | |
---|
| 763 | %% update the GUI uvmat |
---|
| 764 | hhuvmat=guidata(huvmat);%handles of elements in the uvmat GUI |
---|
| 765 | set(hhuvmat.MenuEditObject,'enable','on') |
---|
| 766 | set(hhuvmat.edit_object,'Value',1) % set uvmat to object edit mode to allow further object update |
---|
| 767 | set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow |
---|
| 768 | %UvData.MouseAction='edit_object'; % set the edit button to 'on' |
---|
| 769 | |
---|
| 770 | %------------------------------------------------------------------------ |
---|
| 771 | % --- Executes on button press in MenuCoord. |
---|
| 772 | function MenuCoord_Callback(hObject, eventdata, handles) |
---|
| 773 | %------------------------------------------------------------------------ |
---|
| 774 | %---------------------------------------------------- |
---|
| 775 | function YMin_Callback(hObject, eventdata, handles) |
---|
| 776 | %------------------------------------------------------------------------ |
---|
| 777 | |
---|
| 778 | function ZMin_Callback(hObject, eventdata, handles) |
---|
| 779 | %------------------------------------------------------------------------ |
---|
| 780 | |
---|
| 781 | function ZMax_Callback(hObject, eventdata, handles) |
---|
| 782 | DZ=str2num(get(handles.ZMax,'String')); |
---|
| 783 | ZMin=get(handles.z_slider,'Min'); |
---|
| 784 | ZMax=get(handles.z_slider,'Max'); |
---|
| 785 | if ~isequal(ZMax-ZMin,0) |
---|
| 786 | rel_step(1)=DZ/(ZMax-ZMin); |
---|
| 787 | rel_step(2)=0.2; |
---|
| 788 | set(handles.z_slider,'SliderStep',rel_step) |
---|
| 789 | end |
---|
| 790 | %------------------------------------------------------------------------ |
---|
| 791 | function YMax_Callback(hObject, eventdata, handles) |
---|
| 792 | %------------------------------------------------------------------------ |
---|
| 793 | |
---|
| 794 | function XMin_Callback(hObject, eventdata, handles) |
---|
| 795 | %------------------------------------------------------------------------ |
---|
| 796 | |
---|
| 797 | function XMax_Callback(hObject, eventdata, handles) |
---|
| 798 | %------------------------------------------------------------------------ |
---|
| 799 | %------------------------------------------------------------------------ |
---|
| 800 | function SAVE_Callback(hObject, eventdata, handles) |
---|
| 801 | % ------------------------------------------------------ |
---|
| 802 | Object=read_set_object(handles); |
---|
| 803 | huvmat=findobj('Tag','uvmat'); |
---|
| 804 | % UvData=get(huvmat,'UserData'); |
---|
| 805 | if isempty(huvmat) |
---|
| 806 | huvmat=findobj(allchild(0),'Name','series'); |
---|
| 807 | end |
---|
| 808 | hchild=get(huvmat,'Children'); |
---|
| 809 | hrootpath=findobj(hchild,'Tag','RootPath'); |
---|
| 810 | if isempty(hrootpath) |
---|
| 811 | RootPath=''; |
---|
| 812 | else |
---|
| 813 | RootPath=get(hrootpath,'String'); |
---|
| 814 | if iscell(RootPath) |
---|
| 815 | RootPath=RootPath{1}; |
---|
| 816 | end |
---|
| 817 | end |
---|
| 818 | title={'object name'}; |
---|
| 819 | dir_save=uigetdir(RootPath); |
---|
| 820 | ObjectName=get(handles.TITLE,'String'); |
---|
| 821 | if ~isempty(ObjectName)&&~strcmp(ObjectName,'') |
---|
| 822 | def={fullfile(dir_save,[ObjectName '.xml'])}; |
---|
| 823 | else |
---|
| 824 | def={fullfile(dir_save,[Object.Style '.xml'])}; |
---|
| 825 | end |
---|
| 826 | displ_txt='save object as an .xml file';%default display |
---|
| 827 | menu=get(handles.ProjMode,'String'); |
---|
| 828 | value=get(handles.ProjMode,'Value'); |
---|
| 829 | ProjMode=menu{value}; |
---|
| 830 | if strcmp(ProjMode,'mask_inside')||strcmp(ProjMode,'mask_outside') |
---|
| 831 | displ_txt='save mask contour as an .xml file: to create a mask image, use save_mask on the GUI uvmat (lower right)'; |
---|
| 832 | end |
---|
| 833 | answer=msgbox_uvmat('INPUT_TXT','save object as an .xml file',def); |
---|
| 834 | if ~isempty(answer) |
---|
| 835 | t=struct2xml(Object); |
---|
| 836 | save(t,answer{1}) |
---|
| 837 | end |
---|
| 838 | msgbox_uvmat('CONFIRMATION',[answer{1} ' saved']) |
---|
[227] | 839 | |
---|
[204] | 840 | %------------------------------------------------------------------------ |
---|
| 841 | % --- Executes on slider movement. |
---|
| 842 | function z_slider_Callback(hObject, eventdata, handles) |
---|
| 843 | %--------------------------------------------------------- |
---|
| 844 | Z_value=get(handles.z_slider,'Value'); |
---|
| 845 | %rotation angles |
---|
[227] | 846 | PlaneAngle=[0 0 0]; |
---|
| 847 | norm_plane=[0 0 1]; |
---|
| 848 | cos_om=1; |
---|
| 849 | sin_om=0; |
---|
| 850 | |
---|
| 851 | PlaneAngle(1)=str2double(get(handles.Phi,'String'));%first angle in degrees |
---|
| 852 | PlaneAngle(2)=str2double(get(handles.Theta,'String'));%second angle in degrees |
---|
| 853 | PlaneAngle(3)=str2double(get(handles.Psi,'String'));%second angle in degrees |
---|
| 854 | PlaneAngle=(pi/180)*PlaneAngle; |
---|
[212] | 855 | om=norm(PlaneAngle);%norm of rotation angle in radians |
---|
[227] | 856 | if isequal(om,0) |
---|
| 857 | norm_plane=[0 0 1]; |
---|
| 858 | else |
---|
| 859 | OmAxis=PlaneAngle/om; %unit vector marking the rotation axis |
---|
| 860 | cos_om=cos(om); |
---|
| 861 | sin_om=sin(om); |
---|
| 862 | coeff=OmAxis(3)*(1-cos_om); |
---|
| 863 | %components of the unity vector norm_plane normal to the projection plane |
---|
| 864 | norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; |
---|
| 865 | norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; |
---|
| 866 | norm_plane(3)=OmAxis(3)*coeff+cos_om; |
---|
| 867 | end |
---|
[204] | 868 | |
---|
| 869 | %set new plane position and update graph |
---|
[212] | 870 | set(handles.XObject,'String',num2str(norm_plane(1)*Z_value,4)) |
---|
| 871 | set(handles.YObject,'String',num2str(norm_plane(2)*Z_value,4)) |
---|
| 872 | set(handles.ZObject,'String',num2str(norm_plane(3)*Z_value,4)) |
---|
[204] | 873 | PLOT_Callback(hObject, eventdata, handles) |
---|
[227] | 874 | |
---|
[204] | 875 | %------------------------------------------------------------------------ |
---|
| 876 | % --- Executes on button press in HELP. |
---|
| 877 | function HELP_Callback(hObject, eventdata, handles) |
---|
[227] | 878 | %------------------------------------------------------------------------ |
---|
[204] | 879 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 880 | pathelp=fileparts(path_to_uvmat); |
---|
| 881 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
| 882 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
| 883 | else |
---|
| 884 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 885 | web([helpfile '#set_object']) |
---|
| 886 | end |
---|
| 887 | %------------------------------------------------------------------------ |
---|
| 888 | |
---|
| 889 | |
---|