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