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