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