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