| 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 | % INTPUT: |
|---|
| 10 | % data: structure describing the object properties |
|---|
| 11 | % PlotHandles: handles for projection plots |
|---|
| 12 | % Zbounds: bounds on Z ( 3D case) |
|---|
| 13 | % |
|---|
| 14 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
|---|
| 15 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
|---|
| 16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
|---|
| 17 | % This file is part of the toolbox UVMAT. |
|---|
| 18 | % |
|---|
| 19 | % UVMAT is free software; you can redistribute it and/or modify |
|---|
| 20 | % it under the terms of the GNU General Public License as published by |
|---|
| 21 | % the Free Software Foundation; either version 2 of the License, or |
|---|
| 22 | % (at your option) any later version. |
|---|
| 23 | % |
|---|
| 24 | % UVMAT is distributed in the hope that it will be useful, |
|---|
| 25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 27 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
|---|
| 28 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
|---|
| 29 | |
|---|
| 30 | function varargout = set_object(varargin) |
|---|
| 31 | |
|---|
| 32 | % Last Modified by GUIDE v2.5 24-Nov-2008 14:29:06 |
|---|
| 33 | |
|---|
| 34 | % Begin initialization code - DO NOT PLOT |
|---|
| 35 | gui_Singleton = 1; |
|---|
| 36 | gui_State = struct('gui_Name', mfilename, ... |
|---|
| 37 | 'gui_Singleton', gui_Singleton, ... |
|---|
| 38 | 'gui_OpeningFcn', @set_object_OpeningFcn, ... |
|---|
| 39 | 'gui_OutputFcn', @set_object_OutputFcn, ... |
|---|
| 40 | 'gui_LayoutFcn', [] , ... |
|---|
| 41 | 'gui_Callback', []); |
|---|
| 42 | if nargin & isstr(varargin{1}) |
|---|
| 43 | gui_State.gui_Callback = str2func(varargin{1}); |
|---|
| 44 | end |
|---|
| 45 | |
|---|
| 46 | if nargout |
|---|
| 47 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
|---|
| 48 | else |
|---|
| 49 | gui_mainfcn(gui_State, varargin{:}); |
|---|
| 50 | end |
|---|
| 51 | % End initialization code - DO NOT PLOT |
|---|
| 52 | |
|---|
| 53 | %------------------------------------------------------------------- |
|---|
| 54 | % --- Executes just before set_object is made visible. |
|---|
| 55 | %INPUT: |
|---|
| 56 | % handles: handles of the set_object interface elements |
|---|
| 57 | %'IndexObj': NON USED ANYMORE (To suppress) index of the object (on the UvData list) that set_object will modify |
|---|
| 58 | % if =[] or absent: index still undefined (create mode in uvmat) |
|---|
| 59 | % if=0; no associated object (used for series), the button 'PLOT' is then unvisible |
|---|
| 60 | %'data': read from an existing object selected in the interface |
|---|
| 61 | % .TITLE : class of object ('POINTS','LINE',....) |
|---|
| 62 | % .DX,DY,DZ; meshes for regular grids |
|---|
| 63 | % .Coord: object position coordinates |
|---|
| 64 | % .ParentButton: handle of the uicontrol object calling the interface |
|---|
| 65 | % PlotHandles: set of handles of the elements contolling the plotting of the projected field: |
|---|
| 66 | % if =[] or absent, no plot (mask mode in uvmat) |
|---|
| 67 | % parameters on the uvmat interface (obtained by 'get_plot_handle.m') |
|---|
| 68 | function set_object_OpeningFcn(hObject, eventdata, handles, data, PlotHandles,ZBounds) |
|---|
| 69 | |
|---|
| 70 | % Choose default command line output for set_object |
|---|
| 71 | handles.output = hObject; |
|---|
| 72 | |
|---|
| 73 | % Update handles structure |
|---|
| 74 | guidata(hObject, handles); |
|---|
| 75 | |
|---|
| 76 | %default |
|---|
| 77 | if ~exist('ZBound','var') |
|---|
| 78 | ZBound=0; %default |
|---|
| 79 | end |
|---|
| 80 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front) |
|---|
| 81 | set(handles.MenuCoord,'ListboxTop',1) |
|---|
| 82 | if ~exist('PlotHandles','var') |
|---|
| 83 | PlotHandles=[]; |
|---|
| 84 | end |
|---|
| 85 | desable_open=0;%default: allow reading of object from xml file |
|---|
| 86 | desable_plot=0;%default |
|---|
| 87 | SetData.PlotHandles=PlotHandles; |
|---|
| 88 | if exist('data','var') & isfield(data,'ParentButton') |
|---|
| 89 | SetData.ParentButton=data.ParentButton; |
|---|
| 90 | set(hObject,'DeleteFcn',{@closefcn,SetData.ParentButton})% |
|---|
| 91 | end |
|---|
| 92 | set(hObject,'UserData',SetData) |
|---|
| 93 | |
|---|
| 94 | % fill the interface as set in the input data: |
|---|
| 95 | if exist('data','var') |
|---|
| 96 | if isfield(data,'desable_open') |
|---|
| 97 | desable_open=data.desable_open;%test to desable button OPEN (edit or display mode) |
|---|
| 98 | end |
|---|
| 99 | if isfield(data,'desable_plot') |
|---|
| 100 | desable_plot=data.desable_plot;%test to desable button PLOT (display mode) |
|---|
| 101 | end |
|---|
| 102 | if ~isfield(data,'NbDim')|~isequal(data.NbDim,3)%2D case |
|---|
| 103 | set(handles.ZObject,'Visible','off') |
|---|
| 104 | set(handles.z_slider,'Visible','off') |
|---|
| 105 | else |
|---|
| 106 | set(handles.ZObject,'Visible','on') |
|---|
| 107 | set(handles.z_slider,'Visible','on') |
|---|
| 108 | if isfield(data,'Coord') && size(data.Coord,2)==3 |
|---|
| 109 | set(handles.ZObject,'String',num2str(data.Coord(1,3),4)) |
|---|
| 110 | end |
|---|
| 111 | end |
|---|
| 112 | if isfield(data,'ProjMode') && isfield(data,'Style') |
|---|
| 113 | data.TITLE=set_title(data.Style,data.ProjMode);% define TITLE in set_object (POINTS, LINE, PATCH,...) |
|---|
| 114 | end |
|---|
| 115 | if isfield(data,'TITLE') |
|---|
| 116 | menutitle=get(handles.TITLE,'String'); |
|---|
| 117 | for iline=1:length(menutitle) |
|---|
| 118 | strmenu=menutitle{iline}; |
|---|
| 119 | if isequal(data.TITLE,strmenu) |
|---|
| 120 | set(handles.TITLE,'Value',iline) |
|---|
| 121 | break |
|---|
| 122 | end |
|---|
| 123 | end |
|---|
| 124 | TITLE_Callback(hObject, eventdata, handles)% enable edit boxes depending on TITLE |
|---|
| 125 | end |
|---|
| 126 | if isfield(data,'fixedtitle')&isequal(data.fixedtitle,1) |
|---|
| 127 | set(handles.TITLE,'enable','off') |
|---|
| 128 | end |
|---|
| 129 | if isfield(data,'Style') |
|---|
| 130 | menu=get(handles.ObjectStyle,'String'); |
|---|
| 131 | for iline=1:length(menu) |
|---|
| 132 | if isequal(menu{iline},data.Style) |
|---|
| 133 | set(handles.ObjectStyle,'Value',iline) |
|---|
| 134 | break |
|---|
| 135 | end |
|---|
| 136 | end |
|---|
| 137 | end |
|---|
| 138 | if isfield(data,'ProjMode') |
|---|
| 139 | menu=get(handles.ProjMode,'String'); |
|---|
| 140 | for iline=1:length(menu) |
|---|
| 141 | if isequal(menu{iline},data.ProjMode) |
|---|
| 142 | set(handles.ProjMode,'Value',iline) |
|---|
| 143 | break |
|---|
| 144 | end |
|---|
| 145 | end |
|---|
| 146 | end |
|---|
| 147 | if isfield(data,'Coord') & size(data.Coord,2)>=2 |
|---|
| 148 | sizcoord=size(data.Coord); |
|---|
| 149 | for i=1:sizcoord(1) |
|---|
| 150 | XObject{i}=num2str(data.Coord(i,1),4); |
|---|
| 151 | YObject{i}=num2str(data.Coord(i,2),4); |
|---|
| 152 | end |
|---|
| 153 | set(handles.XObject,'String',XObject) |
|---|
| 154 | set(handles.YObject,'String',YObject) |
|---|
| 155 | %set(handles.XObject,'String',mat2cell(data.Coord(:,1),sizcoord(1))) |
|---|
| 156 | %set(handles.YObject,'String',mat2cell(data.Coord(:,2),sizcoord(1))) |
|---|
| 157 | if sizcoord(2)>3 |
|---|
| 158 | for i=1:sizcoord(1) |
|---|
| 159 | ZObject{i}=num2str(data.Coord(i,3),4); |
|---|
| 160 | end |
|---|
| 161 | set(handles.ZObject,'String',ZObject) |
|---|
| 162 | end |
|---|
| 163 | end |
|---|
| 164 | if isfield(data,'DX') |
|---|
| 165 | set(handles.DX,'String',num2str(data.DX,3)) |
|---|
| 166 | end |
|---|
| 167 | if isfield(data,'DY') |
|---|
| 168 | set(handles.DY,'String',num2str(data.DY,3)) |
|---|
| 169 | end |
|---|
| 170 | %OBSOLETE (replaced by Range) |
|---|
| 171 | % if isfield(data,'XMin') |
|---|
| 172 | % set(handles.XMin,'String',num2str(data.XMin,3)) |
|---|
| 173 | % end |
|---|
| 174 | % if isfield(data,'XMax') |
|---|
| 175 | % set(handles.XMax,'String',num2str(data.XMax,3)) |
|---|
| 176 | % end |
|---|
| 177 | % if isfield(data,'YMin') |
|---|
| 178 | % set(handles.YMin,'String',num2str(data.YMin,3)) |
|---|
| 179 | % end |
|---|
| 180 | % if isfield(data,'YMax') |
|---|
| 181 | % set(handles.YMax,'String',num2str(data.YMax,3)) |
|---|
| 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') |
|---|
| 197 | set(handles.XMax,'String',num2str(max(data.RangeX),3)) |
|---|
| 198 | set(handles.XMin,'String',num2str(min(data.RangeX),3)) |
|---|
| 199 | end |
|---|
| 200 | if isfield(data,'RangeY') |
|---|
| 201 | set(handles.YMax,'String',num2str(max(data.RangeY),3)) |
|---|
| 202 | set(handles.YMin,'String',num2str(min(data.RangeY),3)) |
|---|
| 203 | end |
|---|
| 204 | if isfield(data,'RangeZ') |
|---|
| 205 | set(handles.ZMax,'String',num2str(max(data.RangeZ),3)) |
|---|
| 206 | set(handles.ZMin,'String',num2str(min(data.RangeZ),3)) |
|---|
| 207 | end |
|---|
| 208 | if isfield(data,'Phi') |
|---|
| 209 | set(handles.Phi,'String',num2str(data.Phi,3)) |
|---|
| 210 | end |
|---|
| 211 | if isfield(data,'Theta') |
|---|
| 212 | set(handles.Theta,'String',num2str(data.Theta,3)) |
|---|
| 213 | end |
|---|
| 214 | if isfield(data,'Psi') |
|---|
| 215 | set(handles.Psi,'String',num2str(data.Psi,3)) |
|---|
| 216 | end |
|---|
| 217 | if isfield(data,'DZ') |
|---|
| 218 | set(handles.DZ,'String',num2str(data.DZ,3)) |
|---|
| 219 | end |
|---|
| 220 | if isfield(data,'CoordType') |
|---|
| 221 | if isequal(data.CoordType,'phys') |
|---|
| 222 | set(handles.MenuCoord,'Value',1) |
|---|
| 223 | elseif isequal(data.CoordType,'px') |
|---|
| 224 | set(handles.MenuCoord,'Value',2) |
|---|
| 225 | end |
|---|
| 226 | end |
|---|
| 227 | end |
|---|
| 228 | if desable_open |
|---|
| 229 | set(handles.OPEN,'Visible','off') |
|---|
| 230 | else |
|---|
| 231 | set(handles.OPEN,'Visible','on') |
|---|
| 232 | end |
|---|
| 233 | if desable_plot |
|---|
| 234 | set(handles.PLOT,'Visible','off') |
|---|
| 235 | else |
|---|
| 236 | set(handles.PLOT,'Visible','on') |
|---|
| 237 | end |
|---|
| 238 | |
|---|
| 239 | |
|---|
| 240 | % --- Outputs from this function are returned to the command line. |
|---|
| 241 | function varargout = set_object_OutputFcn(hObject, eventdata, handles) |
|---|
| 242 | % varargout cell array for returning output args (see VARARGOUT); |
|---|
| 243 | % hObject handle to figure |
|---|
| 244 | % eventdata reserved - to be defined in a future version of MATLAB |
|---|
| 245 | % handles structure with handles and user data (see GUIDATA) |
|---|
| 246 | |
|---|
| 247 | % Get default command line output from handles structure |
|---|
| 248 | varargout{1} = handles.output; |
|---|
| 249 | varargout{2}=handles; |
|---|
| 250 | |
|---|
| 251 | %----------------------------------------------- |
|---|
| 252 | % --- Executes on selection change in ObjectStyle. |
|---|
| 253 | function ObjectStyle_Callback(hObject, eventdata, handles) |
|---|
| 254 | style_prev=get(handles.ObjectStyle,'UserData'); |
|---|
| 255 | str=get(handles.ObjectStyle,'String'); |
|---|
| 256 | val=get(handles.ObjectStyle,'Value'); |
|---|
| 257 | % make correspondance between different object styles |
|---|
| 258 | % if ~isequal(str{val},style_prev) |
|---|
| 259 | Xcolumn=get(handles.XObject,'String'); |
|---|
| 260 | Ycolumn=get(handles.YObject,'String'); |
|---|
| 261 | if ischar(Xcolumn) |
|---|
| 262 | sizchar=size(Xcolumn); |
|---|
| 263 | for icol=1:sizchar(1) |
|---|
| 264 | Xcolumn_cell{icol}=Xcolumn(icol,:); |
|---|
| 265 | end |
|---|
| 266 | Xcolumn=Xcolumn_cell; |
|---|
| 267 | end |
|---|
| 268 | if ischar(Ycolumn) |
|---|
| 269 | sizchar=size(Ycolumn); |
|---|
| 270 | for icol=1:sizchar(1) |
|---|
| 271 | Ycolumn_cell{icol}=Ycolumn(icol,:); |
|---|
| 272 | end |
|---|
| 273 | Ycolumn=Ycolumn_cell; |
|---|
| 274 | end |
|---|
| 275 | Zcolumn={};%default |
|---|
| 276 | z_new={}; |
|---|
| 277 | if isequal(get(handles.ZObject,'Visible'),'on') |
|---|
| 278 | data.NbDim=3; %test 3D object |
|---|
| 279 | Zcolumn=get(handles.ZObject,'String'); |
|---|
| 280 | if ischar(Zcolumn) |
|---|
| 281 | Zcolumn={Zcolumn}; |
|---|
| 282 | end |
|---|
| 283 | end |
|---|
| 284 | x_new{1}=Xcolumn{1}; |
|---|
| 285 | y_new{1}=Ycolumn{1}; |
|---|
| 286 | if ~isempty(Zcolumn) |
|---|
| 287 | z_new{1}=Zcolumn{1}; |
|---|
| 288 | end |
|---|
| 289 | if isequal(str{val},'line') |
|---|
| 290 | if isequal(style_prev,'rectangle')|isequal(style_prev,'ellipse') |
|---|
| 291 | XMax=get(handles.XMax,'String'); |
|---|
| 292 | YMax=get(handles.YMax,'String'); |
|---|
| 293 | x_new{2}=num2str(XMax,4); |
|---|
| 294 | y_new{2}=num2str(YMax,4); |
|---|
| 295 | set(handles.XObject,'String',x_new) |
|---|
| 296 | set(handles.YObject,'String',y_new) |
|---|
| 297 | set(handles.ZObject,'String',z_new) |
|---|
| 298 | end |
|---|
| 299 | elseif isequal(str{val},'polyline') |
|---|
| 300 | elseif isequal(str{val},'rectangle')| isequal(str{val},'ellipse') |
|---|
| 301 | set(handles.XObject,'String',x_new) |
|---|
| 302 | set(handles.YObject,'String',y_new) |
|---|
| 303 | set(handles.ZObject,'String',z_new) |
|---|
| 304 | end |
|---|
| 305 | % end |
|---|
| 306 | |
|---|
| 307 | |
|---|
| 308 | |
|---|
| 309 | ProjMode_Callback(hObject, eventdata, handles) |
|---|
| 310 | %store the current option |
|---|
| 311 | str=get(handles.ObjectStyle,'String'); |
|---|
| 312 | val=get(handles.ObjectStyle,'Value'); |
|---|
| 313 | set(handles.ObjectStyle,'UserData',str{val}) |
|---|
| 314 | |
|---|
| 315 | %---------------------------------------------- |
|---|
| 316 | function xObject_Callback(hObject, eventdata, handles) |
|---|
| 317 | |
|---|
| 318 | |
|---|
| 319 | function yObject_Callback(hObject, eventdata, handles) |
|---|
| 320 | |
|---|
| 321 | |
|---|
| 322 | % --- Executes on selection change in zObject. |
|---|
| 323 | function zObject_Callback(hObject, eventdata, handles) |
|---|
| 324 | |
|---|
| 325 | |
|---|
| 326 | |
|---|
| 327 | % --- Executes on selection change in ProjMode. |
|---|
| 328 | function ProjMode_Callback(hObject, eventdata, handles) |
|---|
| 329 | menu=get(handles.ProjMode,'String'); |
|---|
| 330 | value=get(handles.ProjMode,'Value'); |
|---|
| 331 | ProjMode=menu{value}; |
|---|
| 332 | menu=get(handles.ObjectStyle,'String'); |
|---|
| 333 | value=get(handles.ObjectStyle,'Value'); |
|---|
| 334 | ObjectStyle=menu{value}; |
|---|
| 335 | test3D=isequal(get(handles.ZObject,'Visible'),'on');%3D case |
|---|
| 336 | if isequal(ObjectStyle,'plane')|isequal(ObjectStyle,'volume') |
|---|
| 337 | set(handles.Phi,'Visible','on') |
|---|
| 338 | if test3D%3D case |
|---|
| 339 | set(handles.Theta,'Visible','on') |
|---|
| 340 | set(handles.Psi,'Visible','on') |
|---|
| 341 | end |
|---|
| 342 | set(handles.XMin,'Visible','on') |
|---|
| 343 | set(handles.XMax,'Visible','on') |
|---|
| 344 | set(handles.YMin,'Visible','on') |
|---|
| 345 | set(handles.YMax,'Visible','on') |
|---|
| 346 | if test3D |
|---|
| 347 | set(handles.Theta,'Visible','on') |
|---|
| 348 | set(handles.Psi,'Visible','on') |
|---|
| 349 | set(handles.ZMin,'Visible','on') |
|---|
| 350 | set(handles.ZMax,'Visible','on') |
|---|
| 351 | end |
|---|
| 352 | else |
|---|
| 353 | set(handles.Phi,'Visible','off') |
|---|
| 354 | set(handles.Theta,'Visible','off') |
|---|
| 355 | set(handles.Psi,'Visible','off') |
|---|
| 356 | set(handles.XMin,'Visible','off') |
|---|
| 357 | set(handles.XMax,'Visible','off') |
|---|
| 358 | set(handles.YMin,'Visible','off') |
|---|
| 359 | if isequal(ProjMode,'interp') |
|---|
| 360 | set(handles.YMax,'Visible','off') |
|---|
| 361 | else |
|---|
| 362 | set(handles.YMax,'Visible','on') |
|---|
| 363 | end |
|---|
| 364 | if isequal(ObjectStyle,'rectangle')|isequal(ObjectStyle,'ellipse') |
|---|
| 365 | set(handles.XMax,'Visible','on') |
|---|
| 366 | else |
|---|
| 367 | set(handles.XMax,'Visible','off') |
|---|
| 368 | end |
|---|
| 369 | set(handles.ZMin,'Visible','off') |
|---|
| 370 | set(handles.ZMax,'Visible','off') |
|---|
| 371 | end |
|---|
| 372 | TITLE_list=get(handles.TITLE,'String'); |
|---|
| 373 | val=get(handles.TITLE,'Value'); |
|---|
| 374 | TITLE=TITLE_list{val}; |
|---|
| 375 | switch TITLE |
|---|
| 376 | case {'POINTS','PATCH','MASK'} |
|---|
| 377 | set(handles.DX,'Visible','off') |
|---|
| 378 | set(handles.DY,'Visible','off') |
|---|
| 379 | set(handles.DZ,'Visible','off') |
|---|
| 380 | case {'LINE'} |
|---|
| 381 | if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter') |
|---|
| 382 | set(handles.DX,'Visible','on') |
|---|
| 383 | else |
|---|
| 384 | set(handles.DX,'Visible','off') |
|---|
| 385 | end |
|---|
| 386 | case {'PLANE'} |
|---|
| 387 | if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter') |
|---|
| 388 | set(handles.DX,'Visible','on') |
|---|
| 389 | set(handles.DY,'Visible','on') |
|---|
| 390 | else |
|---|
| 391 | set(handles.DX,'Visible','off') |
|---|
| 392 | set(handles.DY,'Visible','off') |
|---|
| 393 | end |
|---|
| 394 | case {'VOLUME'} |
|---|
| 395 | if isequal(ProjMode,'interp') |
|---|
| 396 | set(handles.DX,'Visible','on') |
|---|
| 397 | set(handles.DY,'Visible','on') |
|---|
| 398 | set(handles.DZ,'Visible','on') |
|---|
| 399 | else |
|---|
| 400 | set(handles.DX,'Visible','off') |
|---|
| 401 | set(handles.DY,'Visible','off') |
|---|
| 402 | set(handles.DZ,'Visible','off') |
|---|
| 403 | end |
|---|
| 404 | end |
|---|
| 405 | |
|---|
| 406 | %--------------------------------------------- |
|---|
| 407 | % --- Executes on selection change in TITLE. |
|---|
| 408 | function TITLE_Callback(hObject, eventdata, handles) |
|---|
| 409 | %--------------------------------------------- |
|---|
| 410 | hsetobject=get(handles.TITLE,'parent'); |
|---|
| 411 | SetData=get(hsetobject,'UserData');%get the hidden interface data |
|---|
| 412 | % function named CALLBACK in UNTITLED.M with the given input arguments. |
|---|
| 413 | menu=get(handles.TITLE,'String'); |
|---|
| 414 | value=get(handles.TITLE,'Value'); |
|---|
| 415 | titl=menu{value}; |
|---|
| 416 | if isequal(titl,'POINTS'); |
|---|
| 417 | menu_style={'points'}; |
|---|
| 418 | menu_proj={'projection';'interp';'filter';'none'}; |
|---|
| 419 | elseif isequal(titl,'LINE') |
|---|
| 420 | menu_style={'line';'polyline';'rectangle';'polygon';'ellipse'};%'line' =default |
|---|
| 421 | menu_proj={'projection';'interp';'filter';'none'}; |
|---|
| 422 | elseif isequal(titl,'PATCH') |
|---|
| 423 | menu_style={'rectangle';'polygon';'ellipse'};%'line' =default |
|---|
| 424 | menu_proj={'inside';'outside'}; |
|---|
| 425 | elseif isequal(titl,'MASK') |
|---|
| 426 | menu_style={'polygon'};%'line' =default |
|---|
| 427 | menu_proj={'mask_inside';'mask_outside'}; |
|---|
| 428 | elseif isequal(titl,'PLANE') |
|---|
| 429 | menu_style={'plane'}; |
|---|
| 430 | menu_proj={'projection';'interp';'filter';'none'}; |
|---|
| 431 | elseif isequal(titl,'VOLUME') |
|---|
| 432 | menu_style={'volume'}; |
|---|
| 433 | menu_proj={'none'}; |
|---|
| 434 | |
|---|
| 435 | end |
|---|
| 436 | old_menu=get(handles.ObjectStyle,'String'); |
|---|
| 437 | value=get(handles.ObjectStyle,'Value'); |
|---|
| 438 | old_style=old_menu{value}; |
|---|
| 439 | teststyle=0; |
|---|
| 440 | for iline=1:length(menu_style) |
|---|
| 441 | if isequal(menu_style{iline},old_style) |
|---|
| 442 | styleval=iline; |
|---|
| 443 | teststyle=1; |
|---|
| 444 | break |
|---|
| 445 | end |
|---|
| 446 | end |
|---|
| 447 | if ~teststyle |
|---|
| 448 | new_style=[];%default |
|---|
| 449 | switch old_style |
|---|
| 450 | case 'polyline' |
|---|
| 451 | new_style='polygon'; |
|---|
| 452 | case 'polygon' |
|---|
| 453 | new_style='polyline'; |
|---|
| 454 | end |
|---|
| 455 | if ~isempty(new_style) |
|---|
| 456 | for iline=1:length(menu_style) |
|---|
| 457 | if isequal(menu_style{iline},new_style) |
|---|
| 458 | styleval=iline; |
|---|
| 459 | teststyle=1; |
|---|
| 460 | break |
|---|
| 461 | end |
|---|
| 462 | end |
|---|
| 463 | end |
|---|
| 464 | end |
|---|
| 465 | if ~teststyle |
|---|
| 466 | styleval=1; |
|---|
| 467 | end |
|---|
| 468 | set(handles.ObjectStyle,'String',menu_style) |
|---|
| 469 | set(handles.ObjectStyle,'Value',styleval) |
|---|
| 470 | set(handles.ProjMode,'String',menu_proj) |
|---|
| 471 | set(handles.ProjMode,'Value',1) |
|---|
| 472 | ObjectStyle_Callback(hObject, eventdata, handles) |
|---|
| 473 | |
|---|
| 474 | %--------------------------------------------- |
|---|
| 475 | function Phi_Callback(hObject, eventdata, handles) |
|---|
| 476 | update_slider(hObject, eventdata,handles) |
|---|
| 477 | %--------------------------------------------- |
|---|
| 478 | |
|---|
| 479 | function Theta_Callback(hObject, eventdata, handles) |
|---|
| 480 | update_slider(hObject, eventdata,handles) |
|---|
| 481 | |
|---|
| 482 | function update_slider(hObject, eventdata,handles) |
|---|
| 483 | %rotation angles |
|---|
| 484 | Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian |
|---|
| 485 | Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian |
|---|
| 486 | |
|---|
| 487 | %components of the unitiy vector normal to the projection plane |
|---|
| 488 | NormVec_X=-sin(Phi)*sin(Theta); |
|---|
| 489 | NormVec_Y=cos(Phi)*sin(Theta); |
|---|
| 490 | NormVec_Z=cos(Theta); |
|---|
| 491 | huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle |
|---|
| 492 | UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
|---|
| 493 | if isfield(UvData,'X') & isfield(UvData,'Y') & isfield(UvData,'Z') |
|---|
| 494 | Z=NormVec_X *(UvData.X)+NormVec_Y *(UvData.Y)+NormVec_Z *(UvData.Z); |
|---|
| 495 | set(handles.z_slider,'Min',min(Z)) |
|---|
| 496 | set(handles.z_slider,'Max',max(Z)) |
|---|
| 497 | ZMax_Callback(hObject, eventdata, handles) |
|---|
| 498 | end |
|---|
| 499 | |
|---|
| 500 | function DX_Callback(hObject, eventdata, handles) |
|---|
| 501 | |
|---|
| 502 | |
|---|
| 503 | function DY_Callback(hObject, eventdata, handles) |
|---|
| 504 | |
|---|
| 505 | |
|---|
| 506 | function DZ_Callback(hObject, eventdata, handles) |
|---|
| 507 | |
|---|
| 508 | |
|---|
| 509 | |
|---|
| 510 | %----------------------------------------------------- |
|---|
| 511 | % --- Executes on button press in OPEN. |
|---|
| 512 | function OPEN_Callback(hObject, eventdata, handles) |
|---|
| 513 | %get the object file |
|---|
| 514 | oldfile=' '; |
|---|
| 515 | huvmat=findobj('Tag','uvmat'); |
|---|
| 516 | % if isempty(huvmat) |
|---|
| 517 | % huvmat=findobj(allchild(0),'Name','series'); |
|---|
| 518 | % end |
|---|
| 519 | hchild=get(huvmat,'Children'); |
|---|
| 520 | hrootpath=findobj(hchild,'Tag','RootPath'); |
|---|
| 521 | if ~isempty(hrootpath) |
|---|
| 522 | oldfile=get(hrootpath,'String'); |
|---|
| 523 | if iscell(oldfile) |
|---|
| 524 | oldfile=oldfile{1}; |
|---|
| 525 | end |
|---|
| 526 | end |
|---|
| 527 | %[FileName,PathName] = uigetfile('*.civ','Select a .civ file',oldfile) |
|---|
| 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) |
|---|
| 536 | errordlg('forbidden input file name: contain blanks') |
|---|
| 537 | return |
|---|
| 538 | end |
|---|
| 539 | sizf=size(fileinput); |
|---|
| 540 | if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end |
|---|
| 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 |
|---|
| 552 | title=set_title(s.Style,s.ProjMode);%update the title |
|---|
| 553 | if ~isempty(huvmat) |
|---|
| 554 | hhuvmat=guidata(huvmat); |
|---|
| 555 | % set(hhuvmat.POINTS,'Value',0) |
|---|
| 556 | % set(hhuvmat.POINTS,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 557 | % set(hhuvmat.LINE,'Value',0) |
|---|
| 558 | % set(hhuvmat.LINE,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 559 | % set(hhuvmat.PATCH,'Value',0) |
|---|
| 560 | % set(hhuvmat.PATCH,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 561 | % set(hhuvmat.PLANE,'Value',0) |
|---|
| 562 | % set(hhuvmat.PLANE,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 563 | % set(hhuvmat.VOLUME,'Value',0) |
|---|
| 564 | % set(hhuvmat.VOLUME,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 565 | % if ~isequal(title,'MASK') |
|---|
| 566 | % eval(['set(hhuvmat.' title ',''Value'',1)']) |
|---|
| 567 | % eval(['set(hhuvmat.' title ',''BackgroundColor'',[1 1 0])']) |
|---|
| 568 | % end |
|---|
| 569 | end |
|---|
| 570 | menu=get(handles.TITLE,'String'); |
|---|
| 571 | for iline=1:length(menu) |
|---|
| 572 | if isequal(menu{iline},title) |
|---|
| 573 | set(handles.TITLE,'Value',iline) |
|---|
| 574 | break |
|---|
| 575 | end |
|---|
| 576 | end |
|---|
| 577 | TITLE_Callback(hObject, eventdata, handles) |
|---|
| 578 | teststyle=0; |
|---|
| 579 | % if isfield(s,'Style') |
|---|
| 580 | menu=get(handles.ObjectStyle,'String'); |
|---|
| 581 | for iline=1:length(menu) |
|---|
| 582 | if isequal(menu{iline},s.Style) |
|---|
| 583 | set(handles.ObjectStyle,'Value',iline) |
|---|
| 584 | teststyle=1; |
|---|
| 585 | break |
|---|
| 586 | end |
|---|
| 587 | end |
|---|
| 588 | testmode=0; |
|---|
| 589 | menu=get(handles.ProjMode,'String'); |
|---|
| 590 | for iline=1:length(menu) |
|---|
| 591 | if isequal(menu{iline},s.ProjMode) |
|---|
| 592 | set(handles.ProjMode,'Value',iline) |
|---|
| 593 | testmode=1; |
|---|
| 594 | break |
|---|
| 595 | end |
|---|
| 596 | end |
|---|
| 597 | |
|---|
| 598 | ProjMode_Callback(hObject, eventdata, handles);%visualize the appropriate edit boxes |
|---|
| 599 | if isfield(s,'CoordType') |
|---|
| 600 | if isequal(s.CoordType,'phys') |
|---|
| 601 | set(handles.MenuCoord,'Value',1) |
|---|
| 602 | elseif isequal(s.CoordType,'px') |
|---|
| 603 | set(handles.MenuCoord,'Value',2) |
|---|
| 604 | else |
|---|
| 605 | warndlg('unknown CoordType (px or phys) in set_object.m') |
|---|
| 606 | end |
|---|
| 607 | end |
|---|
| 608 | if isfield(s,'XMax') |
|---|
| 609 | set(handles.XMax,'String',s.XMax) |
|---|
| 610 | end |
|---|
| 611 | if isfield(s,'XMin') |
|---|
| 612 | set(handles.XMin,'String',s.XMin) |
|---|
| 613 | end |
|---|
| 614 | if isfield(s,'YMax') |
|---|
| 615 | set(handles.YMax,'String',s.YMax) |
|---|
| 616 | end |
|---|
| 617 | if isfield(s,'YMin') |
|---|
| 618 | set(handles.YMin,'String',s.YMin) |
|---|
| 619 | end |
|---|
| 620 | Range=0; |
|---|
| 621 | if isfield(s,'Range') |
|---|
| 622 | if ischar(s.Range) |
|---|
| 623 | Range=str2num(s.Range); |
|---|
| 624 | else |
|---|
| 625 | Range(1,:)=str2num(s.Range{1}); |
|---|
| 626 | Range(2,:)=str2num(s.Range{2}); |
|---|
| 627 | end |
|---|
| 628 | end |
|---|
| 629 | if size(Range,2)>=3 |
|---|
| 630 | if size(Range,1)>=2 |
|---|
| 631 | set(handles.ZMin,'String',num2str(Range(2,3),3)) |
|---|
| 632 | end |
|---|
| 633 | if size(Range,1)>=2 |
|---|
| 634 | set(handles.ZMax,'String',num2str(Range(1,3),3)) |
|---|
| 635 | end |
|---|
| 636 | end |
|---|
| 637 | if size(Range,2)>=2 |
|---|
| 638 | if size(Range,1)>=2 |
|---|
| 639 | set(handles.YMin,'String',num2str(Range(2,2),3)) |
|---|
| 640 | end |
|---|
| 641 | if size(Range,1)>=2 |
|---|
| 642 | set(handles.YMax,'String',num2str(Range(1,2),3)) |
|---|
| 643 | end |
|---|
| 644 | end |
|---|
| 645 | if size(Range,2)>=1 |
|---|
| 646 | if size(Range,1)>=2 |
|---|
| 647 | set(handles.XMin,'String',num2str(Range(2,1),3)) |
|---|
| 648 | end |
|---|
| 649 | if size(Range,1)>=2 |
|---|
| 650 | set(handles.XMax,'String',num2str(Range(1,1),3)) |
|---|
| 651 | end |
|---|
| 652 | end |
|---|
| 653 | if isfield(s,'RangeX') & ischar(s.RangeX) |
|---|
| 654 | RangeX=str2num(s.RangeX); |
|---|
| 655 | set(handles.XMax,'String',num2str(max(RangeX),3)) |
|---|
| 656 | set(handles.XMin,'String',num2str(min(RangeX),3)) |
|---|
| 657 | end |
|---|
| 658 | |
|---|
| 659 | if isfield(s,'RangeY') |
|---|
| 660 | if ischar(s.RangeY) |
|---|
| 661 | RangeY=str2num(s.RangeY); |
|---|
| 662 | set(handles.YMax,'String',num2str(max(RangeY),3)) |
|---|
| 663 | set(handles.YMin,'String',num2str(min(RangeY),3)) |
|---|
| 664 | end |
|---|
| 665 | end |
|---|
| 666 | if isfield(s,'RangeZ') |
|---|
| 667 | if ischar(s.RangeZ) |
|---|
| 668 | RangeZ=str2num(s.RangeZ); |
|---|
| 669 | set(handles.ZMax,'String',num2str(max(RangeZ),3)) |
|---|
| 670 | set(handles.ZMin,'String',num2str(min(RangeZ),3)) |
|---|
| 671 | end |
|---|
| 672 | end |
|---|
| 673 | if isfield(s,'Phi') |
|---|
| 674 | set(handles.Phi,'String',s.Phi) |
|---|
| 675 | end |
|---|
| 676 | if isfield(s,'Theta') |
|---|
| 677 | set(handles.Theta,'String',s.Theta) |
|---|
| 678 | end |
|---|
| 679 | if isfield(s,'Psi') |
|---|
| 680 | set(handles.Psi,'String',s.Psi) |
|---|
| 681 | end |
|---|
| 682 | |
|---|
| 683 | if isfield(s,'DX') |
|---|
| 684 | set(handles.DX,'String',s.DX) |
|---|
| 685 | end |
|---|
| 686 | if isfield(s,'DY') |
|---|
| 687 | set(handles.DY,'String',s.DY) |
|---|
| 688 | end |
|---|
| 689 | if ~isfield(s,'Coord') |
|---|
| 690 | XObject='0';%default |
|---|
| 691 | YObject='0'; |
|---|
| 692 | elseif ischar(s.Coord) |
|---|
| 693 | line=str2num(s.Coord); |
|---|
| 694 | XObject=num2str(line(1),4); |
|---|
| 695 | YObject=num2str(line(2),4); |
|---|
| 696 | else |
|---|
| 697 | for i=1:length(s.Coord) |
|---|
| 698 | line=str2num(s.Coord{i}); |
|---|
| 699 | XObject{i}=num2str(line(1),4); |
|---|
| 700 | YObject{i}=num2str(line(2),4); |
|---|
| 701 | end |
|---|
| 702 | end |
|---|
| 703 | set(handles.XObject,'String',XObject) |
|---|
| 704 | set(handles.YObject,'String',YObject) |
|---|
| 705 | %METTRA A JOUR ASPECT DE L'INTERFACE (COMME set_object_Opening |
|---|
| 706 | |
|---|
| 707 | %---------------------------------------------------- |
|---|
| 708 | % executed when closing: set the parent interface button to value 0 |
|---|
| 709 | function closefcn(gcbo,eventdata,parent_button) |
|---|
| 710 | |
|---|
| 711 | huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle |
|---|
| 712 | if ~isempty(huvmat) |
|---|
| 713 | hhuvmat=guidata(huvmat); |
|---|
| 714 | set(hhuvmat.create,'Value',0) |
|---|
| 715 | set(hhuvmat.create,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 716 | % set(hhuvmat.LINE,'Value',0) |
|---|
| 717 | % set(hhuvmat.LINE,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 718 | % set(hhuvmat.PATCH,'Value',0) |
|---|
| 719 | % set(hhuvmat.PATCH,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 720 | % set(hhuvmat.PLANE,'Value',0) |
|---|
| 721 | % set(hhuvmat.PLANE,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 722 | % set(hhuvmat.VOLUME,'Value',0) |
|---|
| 723 | % set(hhuvmat.VOLUME,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 724 | set(hhuvmat.edit,'Value',0) |
|---|
| 725 | set(hhuvmat.edit,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree |
|---|
| 726 | end |
|---|
| 727 | hseries=findobj(allchild(0),'Name','series');%find the current series interface handle |
|---|
| 728 | if ~isempty(hseries) |
|---|
| 729 | hhseries=guidata(hseries); |
|---|
| 730 | set(hhseries.GetObject,'Value',0) |
|---|
| 731 | set(hhseries.GetObject,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 732 | end |
|---|
| 733 | |
|---|
| 734 | %----------------------------------------------------------------------- |
|---|
| 735 | % --- Executes on button press in PLOT: PLOT the defined object and its projected field |
|---|
| 736 | function PLOT_Callback(hObject, eventdata, handles) |
|---|
| 737 | |
|---|
| 738 | hsetobject=get(handles.PLOT,'parent'); |
|---|
| 739 | SetData=get(hsetobject,'UserData');%get the hidden interface data |
|---|
| 740 | huvmat=findobj('Name','uvmat');%find the current uvmat interface handle |
|---|
| 741 | hlist_object=findobj(huvmat,'Tag','list_object');%handles of the object list in the GUI uvmat |
|---|
| 742 | IndexObj=get(hlist_object,'Value');%position in the objet list |
|---|
| 743 | UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat |
|---|
| 744 | ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object |
|---|
| 745 | ObjectData.HandlesDisplay=[]; % new object plot by default |
|---|
| 746 | if length(UvData.Object) >= IndexObj && isfield(UvData.Object{IndexObj},'HandlesDisplay') |
|---|
| 747 | hdisplay=UvData.Object{IndexObj}.HandlesDisplay; |
|---|
| 748 | if isequal(UvData.Object{IndexObj}.Style, ObjectData.Style) && isequal(UvData.Object{IndexObj}.ProjMode, ObjectData.ProjMode) |
|---|
| 749 | ObjectData.HandlesDisplay=UvData.Object{IndexObj}.HandlesDisplay; |
|---|
| 750 | else % for a new object styl, delete the existing object plots |
|---|
| 751 | for ih=1:length(hdisplay) |
|---|
| 752 | PlotData=get(hdisplay(ih),'UserData'); |
|---|
| 753 | if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject) |
|---|
| 754 | delete(PlotData.SubObject); |
|---|
| 755 | end |
|---|
| 756 | if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint) |
|---|
| 757 | delete(PlotData.DeformPoint); |
|---|
| 758 | end |
|---|
| 759 | if ~isequal(hdisplay(ih),0) |
|---|
| 760 | delete(hdisplay(ih)); |
|---|
| 761 | end |
|---|
| 762 | end |
|---|
| 763 | if isfield(ObjectData,'plotaxes') && ishandle(ObjectData.plotaxes) |
|---|
| 764 | delete(ObjectData.plotaxes)%delete the axes for plotting the current projection result |
|---|
| 765 | end |
|---|
| 766 | end |
|---|
| 767 | end |
|---|
| 768 | |
|---|
| 769 | % update the object plot and projection field |
|---|
| 770 | UvData.Object{IndexObj}=update_obj(UvData,IndexObj,ObjectData,SetData.PlotHandles); |
|---|
| 771 | |
|---|
| 772 | set(huvmat,'UserData',UvData)%update the data in the uvmat interface |
|---|
| 773 | list_str=get(hlist_object,'String'); |
|---|
| 774 | TITLE=set_title(ObjectData.Style,ObjectData.ProjMode); |
|---|
| 775 | list_str{IndexObj}=[num2str(IndexObj) '-' TITLE]; |
|---|
| 776 | if isequal(length(list_str),IndexObj) |
|---|
| 777 | list_str{IndexObj+1}='more...'; |
|---|
| 778 | end |
|---|
| 779 | set(hlist_object,'String',list_str) |
|---|
| 780 | set(hlist_object,'Value',IndexObj) |
|---|
| 781 | |
|---|
| 782 | %update create buttons on the GUI uvmat: set to object edit mode after object plotting |
|---|
| 783 | hhuvmat=guidata(huvmat);%handles of elements in the uvmat GUI |
|---|
| 784 | %desactivate all create buttons in mode edit |
|---|
| 785 | % if isequal(get(hhuvmat.edit,'Value'),0) |
|---|
| 786 | set(hhuvmat.create,'Value',0) |
|---|
| 787 | set(hhuvmat.create,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 788 | % set(hhuvmat.LINE,'Value',0) |
|---|
| 789 | % set(hhuvmat.LINE,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 790 | % set(hhuvmat.PATCH,'Value',0) |
|---|
| 791 | % set(hhuvmat.PATCH,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 792 | % set(hhuvmat.PLANE,'Value',0) |
|---|
| 793 | % set(hhuvmat.PLANE,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 794 | % set(hhuvmat.VOLUME,'Value',0) |
|---|
| 795 | % set(hhuvmat.VOLUME,'BackgroundColor',[0 1 0])%put unactivated buttons to green |
|---|
| 796 | % end |
|---|
| 797 | set(hhuvmat.edit,'Value',1) |
|---|
| 798 | set(hhuvmat.edit,'BackgroundColor',[1 1 0]);% paint the edit text in yellow |
|---|
| 799 | set(hhuvmat.edit,'Value',1);% |
|---|
| 800 | UvData.MouseAction='edit_object'; % set the edit button to 'on' |
|---|
| 801 | set(huvmat,'UserData',UvData) |
|---|
| 802 | |
|---|
| 803 | % --- Executes on button press in MenuCoord. |
|---|
| 804 | function MenuCoord_Callback(hObject, eventdata, handles) |
|---|
| 805 | |
|---|
| 806 | %---------------------------------------------------- |
|---|
| 807 | function YMin_Callback(hObject, eventdata, handles) |
|---|
| 808 | |
|---|
| 809 | |
|---|
| 810 | function ZMin_Callback(hObject, eventdata, handles) |
|---|
| 811 | |
|---|
| 812 | |
|---|
| 813 | function ZMax_Callback(hObject, eventdata, handles) |
|---|
| 814 | DZ=str2num(get(handles.ZMax,'String')); |
|---|
| 815 | ZMin=get(handles.z_slider,'Min'); |
|---|
| 816 | ZMax=get(handles.z_slider,'Max'); |
|---|
| 817 | if ~isequal(ZMax-ZMin,0) |
|---|
| 818 | rel_step(1)=DZ/(ZMax-ZMin); |
|---|
| 819 | rel_step(2)=0.2; |
|---|
| 820 | set(handles.z_slider,'SliderStep',rel_step) |
|---|
| 821 | end |
|---|
| 822 | |
|---|
| 823 | function YMax_Callback(hObject, eventdata, handles) |
|---|
| 824 | |
|---|
| 825 | |
|---|
| 826 | function XMin_Callback(hObject, eventdata, handles) |
|---|
| 827 | |
|---|
| 828 | |
|---|
| 829 | function XMax_Callback(hObject, eventdata, handles) |
|---|
| 830 | |
|---|
| 831 | |
|---|
| 832 | % ------------------------------------------------------ |
|---|
| 833 | function SAVE_Callback(hObject, eventdata, handles) |
|---|
| 834 | % ------------------------------------------------------ |
|---|
| 835 | Object=read_set_object(handles); |
|---|
| 836 | huvmat=findobj('Tag','uvmat'); |
|---|
| 837 | % UvData=get(huvmat,'UserData'); |
|---|
| 838 | if isempty(huvmat) |
|---|
| 839 | huvmat=findobj(allchild(0),'Name','series'); |
|---|
| 840 | end |
|---|
| 841 | hchild=get(huvmat,'Children'); |
|---|
| 842 | hrootpath=findobj(hchild,'Tag','RootPath'); |
|---|
| 843 | if isempty(hrootpath) |
|---|
| 844 | RootPath=''; |
|---|
| 845 | else |
|---|
| 846 | RootPath=get(hrootpath,'String'); |
|---|
| 847 | if iscell(RootPath) |
|---|
| 848 | RootPath=RootPath{1}; |
|---|
| 849 | end |
|---|
| 850 | end |
|---|
| 851 | title={'object name'}; |
|---|
| 852 | dir_save=uigetdir(RootPath); |
|---|
| 853 | def={fullfile(dir_save,['Object' Object.CoordType '.xml'])}; |
|---|
| 854 | options.Resize='on'; |
|---|
| 855 | displ_txt='save object as an .xml file';%default display |
|---|
| 856 | menu=get(handles.ProjMode,'String'); |
|---|
| 857 | value=get(handles.ProjMode,'Value'); |
|---|
| 858 | ProjMode=menu{value}; |
|---|
| 859 | if strcmp(ProjMode,'mask_inside')||strcmp(ProjMode,'mask_outside') |
|---|
| 860 | displ_txt='save mask contour as an .xml file: to create a mask image, use save_mask on the GUI uvmat (lower right)'; |
|---|
| 861 | end |
|---|
| 862 | answer=msgbox_uvmat('INPUT_TXT','save object as an .xml file',def); |
|---|
| 863 | %answer=inputdlg('','save object in a new .xml file',1,def,'on'); |
|---|
| 864 | if ~isempty(answer) |
|---|
| 865 | t=struct2xml(Object); |
|---|
| 866 | save(t,answer{1}) |
|---|
| 867 | end |
|---|
| 868 | msgbox_uvmat('CONFIRMATION',[answer{1} ' saved']) |
|---|
| 869 | %--------------------------------------------------------- |
|---|
| 870 | % --- Executes on slider movement. |
|---|
| 871 | function z_slider_Callback(hObject, eventdata, handles) |
|---|
| 872 | %--------------------------------------------------------- |
|---|
| 873 | %A ADAPTER |
|---|
| 874 | Z_value=get(handles.z_slider,'Value'); |
|---|
| 875 | |
|---|
| 876 | %rotation angles |
|---|
| 877 | Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian |
|---|
| 878 | Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian |
|---|
| 879 | |
|---|
| 880 | %components of the unity vector normal to the projection plane |
|---|
| 881 | NormVec_X=-sin(Phi)*sin(Theta); |
|---|
| 882 | NormVec_Y=cos(Phi)*sin(Theta); |
|---|
| 883 | NormVec_Z=cos(Theta); |
|---|
| 884 | |
|---|
| 885 | %set new plane position and update graph |
|---|
| 886 | set(handles.XObject,'String',num2str(NormVec_X*Z_value,4)) |
|---|
| 887 | set(handles.YObject,'String',num2str(NormVec_Y*Z_value,4)) |
|---|
| 888 | set(handles.ZObject,'String',num2str(NormVec_Z*Z_value,4)) |
|---|
| 889 | PLOT_Callback(hObject, eventdata, handles) |
|---|
| 890 | |
|---|
| 891 | |
|---|
| 892 | |
|---|
| 893 | function XObject_Callback(hObject, eventdata, handles) |
|---|
| 894 | |
|---|
| 895 | |
|---|
| 896 | function YObject_Callback(hObject, eventdata, handles) |
|---|
| 897 | |
|---|
| 898 | |
|---|
| 899 | |
|---|
| 900 | |
|---|
| 901 | function ZObject_Callback(hObject, eventdata, handles) |
|---|
| 902 | |
|---|
| 903 | |
|---|
| 904 | % --- Executes on button press in HELP. |
|---|
| 905 | function HELP_Callback(hObject, eventdata, handles) |
|---|
| 906 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
|---|
| 907 | pathelp=fileparts(path_to_uvmat); |
|---|
| 908 | helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html'); |
|---|
| 909 | if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') |
|---|
| 910 | else |
|---|
| 911 | web([helpfile '#set_object']) |
|---|
| 912 | end |
|---|
| 913 | |
|---|
| 914 | |
|---|
| 915 | |
|---|
| 916 | |
|---|