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