[204] | 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 | % |
---|
[445] | 9 | % INPUT:u |
---|
[204] | 10 | % data: structure describing the object properties |
---|
| 11 | % .Style=... |
---|
| 12 | % .ProjMode |
---|
| 13 | % .CoordType: 'phys' or 'px' |
---|
[379] | 14 | % .num_DX,.num_DY,.num_DZ : mesh along each dirction |
---|
[204] | 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 NO MORE USED |
---|
| 18 | % Zbounds: bounds on Z ( 3D case) |
---|
[809] | 19 | |
---|
| 20 | %======================================================================= |
---|
[924] | 21 | % Copyright 2008-2016, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France |
---|
[809] | 22 | % http://www.legi.grenoble-inp.fr |
---|
| 23 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
---|
[204] | 24 | % |
---|
| 25 | % This file is part of the toolbox UVMAT. |
---|
[809] | 26 | % |
---|
[204] | 27 | % UVMAT is free software; you can redistribute it and/or modify |
---|
[809] | 28 | % it under the terms of the GNU General Public License as published |
---|
| 29 | % by the Free Software Foundation; either version 2 of the license, |
---|
| 30 | % or (at your option) any later version. |
---|
| 31 | % |
---|
[204] | 32 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 33 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 34 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[809] | 35 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
| 36 | %======================================================================= |
---|
[204] | 37 | |
---|
| 38 | function varargout = set_object(varargin) |
---|
| 39 | |
---|
[912] | 40 | % Last Modified by GUIDE v2.5 16-Jun-2015 00:33:59 |
---|
[204] | 41 | |
---|
[680] | 42 | % Begin initialization code - DO NOT REFRESH |
---|
[204] | 43 | gui_Singleton = 1; |
---|
| 44 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 45 | 'gui_Singleton', gui_Singleton, ... |
---|
| 46 | 'gui_OpeningFcn', @set_object_OpeningFcn, ... |
---|
| 47 | 'gui_OutputFcn', @set_object_OutputFcn, ... |
---|
| 48 | 'gui_LayoutFcn', [] , ... |
---|
| 49 | 'gui_Callback', []); |
---|
| 50 | if nargin & ischar(varargin{1}) |
---|
| 51 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 52 | end |
---|
| 53 | |
---|
| 54 | if nargout |
---|
| 55 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 56 | else |
---|
| 57 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 58 | end |
---|
[680] | 59 | % End initialization code - DO NOT REFRESH |
---|
[204] | 60 | %------------------------------------------------------------------------ |
---|
| 61 | %------------------------------------------------------------------------ |
---|
| 62 | % --- Executes just before set_object is made visible. |
---|
| 63 | %INPUT: |
---|
| 64 | % handles: handles of the set_object interface elements |
---|
| 65 | %'IndexObj': NON USED ANYMORE (To suppress) index of the object (on the UvData list) that set_object will modify |
---|
| 66 | % if =[] or absent: index still undefined (create mode in uvmat) |
---|
[680] | 67 | % if=0; no associated object (used for series), the button 'REFRESH' is then unvisible |
---|
[204] | 68 | %'data': read from an existing object selected in the interface |
---|
[379] | 69 | % .Name : class of object ('POINTS','LINE',....) |
---|
| 70 | % .num_DX,num_DY,num_DZ; meshes for regular grids |
---|
[204] | 71 | % .Coord: object position coordinates |
---|
| 72 | % .ParentButton: handle of the uicontrol object calling the interface |
---|
| 73 | % PlotHandles: set of handles of the elements contolling the plotting of the projected field: |
---|
[680] | 74 | % if =[] or absent, no refresh (mask mode in uvmat) |
---|
[204] | 75 | % parameters on the uvmat interface (obtained by 'get_plot_handle.m') |
---|
| 76 | function set_object_OpeningFcn(hObject, eventdata, handles, data, PlotHandles,ZBounds) |
---|
| 77 | %------------------------------------------------------------------- |
---|
| 78 | % Choose default command line output for set_object |
---|
| 79 | handles.output = hObject; |
---|
| 80 | % Update handles structure |
---|
| 81 | guidata(hObject, handles); |
---|
| 82 | |
---|
[613] | 83 | %% position |
---|
[657] | 84 | set(0,'Unit','pixels') |
---|
[613] | 85 | ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right |
---|
[705] | 86 | PosGUI=get(handles.set_object,'Position');% fig width in pixels |
---|
| 87 | Width=PosGUI(3);%width of the gui set_object in pixels |
---|
| 88 | Height=PosGUI(4); |
---|
[613] | 89 | Left=ScreenSize(3)- Width-40; %right edge close to the right, with margin=40 |
---|
| 90 | Bottom=ScreenSize(4)-Height-40; %put fig at top right |
---|
[657] | 91 | set(handles.set_object,'Unit','pixels') |
---|
[613] | 92 | set(handles.set_object,'Position',[Left Bottom Width Height]) |
---|
| 93 | |
---|
[204] | 94 | %default |
---|
[206] | 95 | if ~exist('ZBounds','var') |
---|
| 96 | ZBounds=0; %default |
---|
[204] | 97 | end |
---|
[309] | 98 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function |
---|
[402] | 99 | set(hObject,'DeleteFcn',{@closefcn}) |
---|
[204] | 100 | |
---|
| 101 | % fill the interface as set in the input data: |
---|
| 102 | if exist('data','var') |
---|
[379] | 103 | if isfield(data,'Coord') &&size(data.Coord,2)==3 |
---|
| 104 | set(handles.z_slider,'Visible','on') |
---|
| 105 | else |
---|
[204] | 106 | set(handles.z_slider,'Visible','off') |
---|
| 107 | end |
---|
[387] | 108 | if isfield(data,'TypeMenu') |
---|
| 109 | set(handles.Type,'String',data.TypeMenu) |
---|
| 110 | end |
---|
| 111 | if isfield(data,'ProjModeMenu') |
---|
| 112 | set(handles.ProjMode,'UserData',data.ProjModeMenu)% data.ProjModeMenu as default menu (used in Type_Callback) |
---|
[954] | 113 | end |
---|
[591] | 114 | errormsg=fill_GUI(data,handles.set_object); |
---|
[410] | 115 | if ~isempty(errormsg) |
---|
| 116 | msgbox_uvmat('ERROR','bad data input in set_object') |
---|
| 117 | return |
---|
| 118 | end |
---|
[387] | 119 | Type_Callback(hObject, eventdata, handles)% update the GUI set_object depending on the object type |
---|
[681] | 120 | set(handles.REFRESH,'BackgroundColor',[1 0 0]) |
---|
[204] | 121 | if isfield(data,'RangeZ') && length(ZBounds) >= 2 |
---|
[379] | 122 | set(handles.num_RangeZ_2,'String',num2str(max(data.RangeZ),3)) |
---|
[204] | 123 | DZ=max(data.RangeZ);%slider step |
---|
[206] | 124 | if ~isnan(ZBounds(1)) && ZBounds(2)~=ZBounds(1) |
---|
[204] | 125 | rel_step(1)=min(DZ/(ZBounds(2)-ZBounds(1)),0.2);%must be smaller than 1 |
---|
| 126 | rel_step(2)=0.1; |
---|
| 127 | set(handles.z_slider,'Visible','on') |
---|
| 128 | set(handles.z_slider,'Min',ZBounds(1)) |
---|
| 129 | set(handles.z_slider,'Max',ZBounds(2)) |
---|
| 130 | set(handles.z_slider,'SliderStep',rel_step) |
---|
| 131 | set(handles.z_slider,'Value',(ZBounds(1)+ZBounds(2))/2) |
---|
| 132 | end |
---|
| 133 | end |
---|
[954] | 134 | if isfield(data,'RangeX')&& ~strcmp(data.Type,'plane_z')%TODO: generalise |
---|
[204] | 135 | if ischar(data.RangeX) |
---|
| 136 | data.RangeX=str2num(data.RangeX); |
---|
| 137 | end |
---|
[379] | 138 | set(handles.num_RangeX_2,'String',num2str(max(data.RangeX),3)) |
---|
| 139 | set(handles.num_RangeX_1,'String',num2str(min(data.RangeX),3)) |
---|
[204] | 140 | end |
---|
[954] | 141 | if isfield(data,'RangeY')&& ~strcmp(data.Type,'plane_z')%TODO: generalise |
---|
[204] | 142 | if ischar(data.RangeY) |
---|
| 143 | data.RangeY=str2num(data.RangeY); |
---|
| 144 | end |
---|
[379] | 145 | set(handles.num_RangeY_2,'String',num2str(max(data.RangeY),3)) |
---|
| 146 | set(handles.num_RangeY_1,'String',num2str(min(data.RangeY),3)) |
---|
[204] | 147 | end |
---|
[954] | 148 | if isfield(data,'RangeZ')&& ~strcmp(data.Type,'plane_z')%TODO: generalise |
---|
[204] | 149 | if ischar(data.RangeZ) |
---|
| 150 | data.RangeZ=str2num(data.RangeZ); |
---|
| 151 | end |
---|
[379] | 152 | set(handles.num_RangeZ_2,'String',num2str(max(data.RangeZ),3)) |
---|
[204] | 153 | if numel(data.RangeZ)>=2 |
---|
[379] | 154 | set(handles.num_RangeZ_1,'String',num2str(min(data.RangeZ),3)) |
---|
[204] | 155 | end |
---|
| 156 | end |
---|
[625] | 157 | if ~isfield(data,'Angle') |
---|
| 158 | data.Angle=[0 0 0]; |
---|
| 159 | end |
---|
| 160 | % if isfield(data,'Angle') && isequal(numel(data.Angle),3) |
---|
[379] | 161 | set(handles.num_Angle_1,'String',num2str(data.Angle(1))) |
---|
| 162 | set(handles.num_Angle_2,'String',num2str(data.Angle(2))) |
---|
| 163 | set(handles.num_Angle_3,'String',num2str(data.Angle(3))) |
---|
[625] | 164 | % end |
---|
[204] | 165 | end |
---|
[625] | 166 | set(get(handles.set_object,'children'),'enable','off') |
---|
| 167 | set(handles.SAVE,'enable','on') |
---|
[680] | 168 | % set(handles.REFRESH,'enable','off') |
---|
[204] | 169 | |
---|
[625] | 170 | |
---|
[204] | 171 | %------------------------------------------------------------------------ |
---|
| 172 | % --- Outputs from this function are returned to the command line. |
---|
| 173 | function varargout = set_object_OutputFcn(hObject, eventdata, handles) |
---|
| 174 | %------------------------------------------------------------------------ |
---|
| 175 | % Get default command line output from handles structure |
---|
| 176 | varargout{1} = handles.output; |
---|
| 177 | varargout{2}=handles; |
---|
| 178 | |
---|
| 179 | %------------------------------------------------------------------------ |
---|
[402] | 180 | % executed when closing the GUI set_object |
---|
| 181 | function closefcn(gcbo,eventdata) |
---|
| 182 | %------------------------------------------------------------------------ |
---|
| 183 | huvmat=findobj(allchild(0),'Tag','uvmat');%find the current uvmat interface handle |
---|
| 184 | if ~isempty(huvmat) |
---|
| 185 | hhuvmat=guidata(huvmat); |
---|
[650] | 186 | set(hhuvmat.CheckViewObject,'value',0)% |
---|
| 187 | set(hhuvmat.CheckEditObject,'Value',0)% desactivate the edit option |
---|
[402] | 188 | % deselect the object in ListObject when view_field is closed |
---|
| 189 | if isempty(findobj(allchild(0),'Tag','view_field')) |
---|
| 190 | ObjIndex=get(hhuvmat.ListObject,'Value'); |
---|
| 191 | ObjIndex=ObjIndex(1);%keep only the first object selected |
---|
| 192 | set(hhuvmat.ListObject,'Value',ObjIndex) |
---|
| 193 | % draw all object colors in blue (unselected) in uvmat |
---|
[511] | 194 | hother=[findobj(hhuvmat.PlotAxes,'Tag','proj_object');findobj(hhuvmat.PlotAxes,'Tag','DeformPoint')];%find all the proj object and deform point representations |
---|
[402] | 195 | for iobj=1:length(hother) |
---|
| 196 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') |
---|
| 197 | set(hother(iobj),'EdgeColor','b') |
---|
| 198 | if isequal(get(hother(iobj),'FaceColor'),'m') |
---|
| 199 | set(hother(iobj),'FaceColor','b') |
---|
| 200 | end |
---|
| 201 | elseif isequal(get(hother(iobj),'Type'),'image') |
---|
| 202 | Acolor=get(hother(iobj),'CData'); |
---|
| 203 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); |
---|
| 204 | set(hother(iobj),'CData',Acolor); |
---|
| 205 | else |
---|
| 206 | set(hother(iobj),'Color','b') |
---|
| 207 | end |
---|
| 208 | set(hother(iobj),'Selected','off') |
---|
| 209 | end |
---|
| 210 | end |
---|
| 211 | end |
---|
| 212 | hseries=findobj(allchild(0),'Name','series');%find the current series interface handle |
---|
| 213 | if ~isempty(hseries) |
---|
| 214 | hhseries=guidata(hseries); |
---|
[667] | 215 | set(hhseries.EditObject,'Value',0) |
---|
[402] | 216 | end |
---|
| 217 | |
---|
| 218 | |
---|
| 219 | %------------------------------------------------------------------------ |
---|
[379] | 220 | % --- Executes on selection change in Type. |
---|
| 221 | function Type_Callback(hObject, eventdata, handles) |
---|
[204] | 222 | %------------------------------------------------------------------------ |
---|
[681] | 223 | |
---|
[379] | 224 | ListType=get(handles.Type,'String'); |
---|
| 225 | Type=ListType{get(handles.Type,'Value')}; |
---|
[204] | 226 | % make correspondance between different object styles |
---|
[379] | 227 | Coord=get(handles.Coord,'Data'); |
---|
| 228 | |
---|
| 229 | %% set the number of lines in the Coord table depending on object type |
---|
| 230 | switch Type |
---|
| 231 | case{'line'} |
---|
| 232 | if size(Coord,1)<2 |
---|
| 233 | if isequal(size(Coord,2),3) |
---|
| 234 | Coord=[Coord; 0 0 0];%add a line for edition (3D case) |
---|
| 235 | else |
---|
| 236 | Coord=[Coord; 0 0]; %add a line for edition (2D case) |
---|
| 237 | end |
---|
| 238 | else |
---|
| 239 | Coord=Coord(1:2,:); |
---|
| 240 | end |
---|
| 241 | case{'rectangle','ellipse','plane','volume'} |
---|
| 242 | Coord=Coord(1,:); |
---|
[204] | 243 | end |
---|
[379] | 244 | set(handles.Coord,'Data',Coord) |
---|
[204] | 245 | |
---|
[379] | 246 | %% set the projection menu and the corresponding options |
---|
[387] | 247 | if isempty(get(handles.ProjMode,'UserData')) |
---|
| 248 | switch Type |
---|
[648] | 249 | case 'polyline' |
---|
| 250 | menu_proj={'interp_lin';'interp_tps';'none'}; |
---|
[387] | 251 | case {'polygon','rectangle','ellipse'} |
---|
[648] | 252 | menu_proj={'inside';'outside';'mask_inside';'mask_outside';'interp_lin';'interp_tps';'none'}; |
---|
[387] | 253 | case 'volume' |
---|
[581] | 254 | menu_proj={'interp_lin';'none'}; |
---|
[387] | 255 | otherwise |
---|
[581] | 256 | menu_proj={'projection';'interp_lin';'interp_tps';'none'};%default |
---|
[387] | 257 | end |
---|
| 258 | else |
---|
| 259 | menu_proj=get(handles.ProjMode,'UserData'); |
---|
| 260 | end |
---|
[410] | 261 | ProjModeList=get(handles.ProjMode,'String'); |
---|
| 262 | menu_index=find(strcmp(ProjModeList{get(handles.ProjMode,'Value')},menu_proj)); |
---|
| 263 | if isempty(menu_index) |
---|
| 264 | menu_index=1;% |
---|
[204] | 265 | end |
---|
[410] | 266 | set(handles.ProjMode,'Value',menu_index);% value index must not exceed the menu length |
---|
[204] | 267 | set(handles.ProjMode,'String',menu_proj) |
---|
| 268 | ProjMode_Callback(hObject, eventdata, handles) |
---|
[379] | 269 | |
---|
[204] | 270 | %------------------------------------------------------------------------ |
---|
| 271 | % --- Executes on selection change in ProjMode. |
---|
[675] | 272 | %------------------------------------------------------------------------ |
---|
[681] | 273 | function ProjMode_Callback(hObject, eventdata, handles) |
---|
[675] | 274 | |
---|
[681] | 275 | set(handles.REFRESH,'BackgroundColor',[1 0 1]) |
---|
[204] | 276 | menu=get(handles.ProjMode,'String'); |
---|
| 277 | value=get(handles.ProjMode,'Value'); |
---|
| 278 | ProjMode=menu{value}; |
---|
[379] | 279 | menu=get(handles.Type,'String'); |
---|
| 280 | value=get(handles.Type,'Value'); |
---|
[204] | 281 | ObjectStyle=menu{value}; |
---|
[379] | 282 | %%%%%%%%% TODO |
---|
| 283 | test3D=0; %TODO: update test3D=isequal(get(handles.ZObject,'Visible'),'on');%3D case |
---|
| 284 | %%%%%%%%% |
---|
[204] | 285 | %default setting |
---|
[379] | 286 | set(handles.num_Angle_1,'Visible','off') |
---|
| 287 | set(handles.num_Angle_2,'Visible','off') |
---|
| 288 | set(handles.num_Angle_3,'Visible','off') |
---|
| 289 | set(handles.num_RangeX_1,'Visible','off') |
---|
| 290 | set(handles.num_RangeX_2,'Visible','off') |
---|
| 291 | set(handles.num_RangeY_1,'Visible','off') |
---|
[589] | 292 | if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps') |
---|
[379] | 293 | set(handles.num_RangeY_2,'Visible','off') |
---|
[204] | 294 | else |
---|
[379] | 295 | set(handles.num_RangeY_2,'Visible','on') |
---|
[204] | 296 | end |
---|
| 297 | if strcmp(ObjectStyle,'rectangle')||strcmp(ObjectStyle,'ellipse') |
---|
[379] | 298 | set(handles.num_RangeX_2,'Visible','on') |
---|
[204] | 299 | else |
---|
[379] | 300 | set(handles.num_RangeX_2,'Visible','off') |
---|
[204] | 301 | end |
---|
[379] | 302 | set(handles.num_RangeZ_1,'Visible','off') |
---|
| 303 | set(handles.num_RangeZ_2,'Visible','off') |
---|
| 304 | set(handles.num_DX,'Visible','off') |
---|
| 305 | set(handles.num_DY,'Visible','off') |
---|
| 306 | set(handles.num_DZ,'Visible','off') |
---|
[912] | 307 | set(handles.num_RangeInterp,'Visible','off') |
---|
[204] | 308 | |
---|
| 309 | switch ObjectStyle |
---|
| 310 | case 'points' |
---|
[675] | 311 | set(handles.num_RangeY_2,'TooltipString','num_RangeY_2: range of projection around each point') |
---|
[379] | 312 | % set(handles.XObject,'TooltipString','XObject: set of x coordinates of the points') |
---|
| 313 | % set(handles.YObject,'TooltipString','YObject: set of y coordinates of the points') |
---|
| 314 | % set(handles.ZObject,'TooltipString','ZObject: set of z coordinates of the points') |
---|
[204] | 315 | case {'line','polyline','polygon'} |
---|
[675] | 316 | set(handles.num_RangeY_2,'TooltipString','num_RangeY_2: range of projection around the line') |
---|
[379] | 317 | set(handles.Coord,'TooltipString','Coord: table of x,y, z coordinates defining the line') |
---|
| 318 | % set(handles.YObject,'TooltipString','YObject: set of y coordinates defining the line') |
---|
| 319 | % set(handles.ZObject,'TooltipString','ZObject: set of z coordinates defining the line') |
---|
[581] | 320 | if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps') |
---|
[379] | 321 | set(handles.num_DX,'Visible','on') |
---|
| 322 | set(handles.num_DX,'TooltipString','num_DX: mesh for the interpolated field along the line') |
---|
[912] | 323 | set(handles.num_RangeInterp,'Visible','on') |
---|
[204] | 324 | end |
---|
| 325 | case {'rectangle','ellipse'} |
---|
[675] | 326 | set(handles.num_RangeX_2,'TooltipString',['num_RangeX_2: half length of the ' ObjectStyle]) |
---|
| 327 | set(handles.num_RangeY_2,'TooltipString',['num_RangeY_2: half width of the ' ObjectStyle]) |
---|
[954] | 328 | case {'plane','plane_z'} |
---|
[379] | 329 | set(handles.num_Angle_3,'Visible','on') |
---|
| 330 | set(handles.num_RangeX_1,'Visible','on') |
---|
| 331 | set(handles.num_RangeX_2,'Visible','on') |
---|
| 332 | set(handles.num_RangeY_1,'Visible','on') |
---|
| 333 | set(handles.num_RangeY_2,'Visible','on') |
---|
| 334 | set(handles.num_RangeZ_2,'TooltipString','num_ZMax: range of projection normal to the plane') |
---|
[204] | 335 | if test3D |
---|
[379] | 336 | set(handles.num_Angle_2,'Visible','on') |
---|
| 337 | set(handles.num_Angle_1,'Visible','on') |
---|
| 338 | set(handles.num_RangeZ_2,'Visible','on') |
---|
[204] | 339 | end |
---|
[581] | 340 | if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps') |
---|
[379] | 341 | set(handles.num_DX,'Visible','on') |
---|
| 342 | set(handles.num_DY,'Visible','on') |
---|
[912] | 343 | set(handles.num_RangeInterp,'Visible','on') |
---|
[204] | 344 | else |
---|
[379] | 345 | set(handles.num_DX,'Visible','off') |
---|
| 346 | set(handles.num_DY,'Visible','off') |
---|
[204] | 347 | end |
---|
[912] | 348 | % if isequal(ProjMode,'interp_lin') |
---|
| 349 | % set(handles.num_DZ,'Visible','on') |
---|
| 350 | % end |
---|
[204] | 351 | case {'volume'} |
---|
[379] | 352 | set(handles.num_RangeX_1,'Visible','on') |
---|
| 353 | set(handles.num_RangeX_2,'Visible','on') |
---|
| 354 | set(handles.num_RangeY_1,'Visible','on') |
---|
| 355 | set(handles.num_RangeY_2,'Visible','on') |
---|
[204] | 356 | set(handles.XObject,'TooltipString',['XObject: x coordinate of the axis origin for the ' ObjectStyle]) |
---|
| 357 | set(handles.YObject,'TooltipString',['YObject: y coordinate of the axis origin for the ' ObjectStyle]) |
---|
[379] | 358 | set(handles.num_Angle_1,'Visible','on') |
---|
| 359 | set(handles.num_Angle_2,'Visible','on') |
---|
| 360 | set(handles.num_Angle_3,'Visible','on') |
---|
| 361 | set(handles.num_RangeZ_1,'Visible','on') |
---|
| 362 | set(handles.num_RangeZ_2,'Visible','on') |
---|
[581] | 363 | if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps') |
---|
[379] | 364 | set(handles.num_DX,'Visible','on') |
---|
| 365 | set(handles.num_DY,'Visible','on') |
---|
| 366 | set(handles.num_DZ,'Visible','on') |
---|
[204] | 367 | else |
---|
[379] | 368 | set(handles.num_DX,'Visible','off') |
---|
| 369 | set(handles.num_DY,'Visible','off') |
---|
| 370 | set(handles.num_DZ,'Visible','off') |
---|
[204] | 371 | end |
---|
| 372 | end |
---|
[864] | 373 | % set default values read in the plot of uvmat to initiate the mesh |
---|
| 374 | if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps') |
---|
[912] | 375 | huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle |
---|
| 376 | UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
---|
[864] | 377 | if isempty(str2num(get(handles.num_DX,'String')))||isempty(str2num(get(handles.num_DY,'String'))); |
---|
[912] | 378 | % Field=UvData.Field; |
---|
[864] | 379 | if isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh) |
---|
| 380 | set(handles.num_DX,'String',num2str(UvData.Field.CoordMesh)) |
---|
| 381 | set(handles.num_DY,'String',num2str(UvData.Field.CoordMesh)) |
---|
| 382 | set(handles.num_RangeX_1,'String',num2str(UvData.Field.XMin)) |
---|
| 383 | set(handles.num_RangeX_2,'String',num2str(UvData.Field.XMax)) |
---|
| 384 | set(handles.num_RangeY_1,'String',num2str(UvData.Field.YMin)) |
---|
| 385 | set(handles.num_RangeY_2,'String',num2str(UvData.Field.YMax)) |
---|
| 386 | end |
---|
[954] | 387 | if isempty(get(handles.CoordUnit,'String'))&& isfield(UvData.Field,'CoordUnit') |
---|
| 388 | set(handles.CoordUnit,'String',UvData.Field.CoordUnit) |
---|
[864] | 389 | end |
---|
| 390 | end |
---|
[922] | 391 | if isempty(str2num(get(handles.num_RangeInterp,'String'))) && isfield(UvData,'Field') |
---|
[912] | 392 | set(handles.num_RangeInterp,'String',num2str(3*UvData.Field.CoordMesh))% default interpolationlength= 3 meshes |
---|
| 393 | end |
---|
[864] | 394 | end |
---|
| 395 | |
---|
[204] | 396 | %------------------------------------------------------------------------ |
---|
| 397 | |
---|
| 398 | %------------------------------------------------------------------------ |
---|
[379] | 399 | function num_Angle_1_Callback(hObject, eventdata, handles) |
---|
[204] | 400 | update_slider(hObject, eventdata,handles) |
---|
| 401 | %------------------------------------------------------------------------ |
---|
| 402 | %------------------------------------------------------------------------ |
---|
[379] | 403 | function num_Angle_2_Callback(hObject, eventdata, handles) |
---|
[204] | 404 | update_slider(hObject, eventdata,handles) |
---|
| 405 | %------------------------------------------------------------------------ |
---|
| 406 | function update_slider(hObject, eventdata,handles) |
---|
| 407 | %rotation angles |
---|
[379] | 408 | PlaneAngle(1)=str2num(get(handles.num_Angle_1,'String'));%first angle in degrees |
---|
| 409 | PlaneAngle(2)=str2num(get(handles.num_Angle_2,'String'));%second angle in degrees |
---|
| 410 | PlaneAngle(3)=str2num(get(handles.num_Angle_3,'String'));%second angle in degrees |
---|
[212] | 411 | om=norm(PlaneAngle);%norm of rotation angle in radians |
---|
| 412 | OmAxis=PlaneAngle/om; %unit vector marking the rotation axis |
---|
| 413 | cos_om=cos(pi*om/180); |
---|
| 414 | sin_om=sin(pi*om/180); |
---|
| 415 | coeff=OmAxis(3)*(1-cos_om); |
---|
| 416 | %components of the unity vector norm_plane normal to the projection plane |
---|
| 417 | norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; |
---|
| 418 | norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; |
---|
| 419 | norm_plane(3)=OmAxis(3)*coeff+cos_om; |
---|
[204] | 420 | huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle |
---|
| 421 | UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface |
---|
[912] | 422 | if isfield(UvData,'X') && isfield(UvData,'Y') && isfield(UvData,'Z') |
---|
[212] | 423 | Z=norm_plane(1)*(UvData.X)+norm_plane(2)*(UvData.Y)+norm_plane(3)*(UvData.Z); |
---|
[204] | 424 | set(handles.z_slider,'Min',min(Z)) |
---|
| 425 | set(handles.z_slider,'Max',max(Z)) |
---|
| 426 | ZMax_Callback(hObject, eventdata, handles) |
---|
| 427 | end |
---|
| 428 | %------------------------------------------------------------------------ |
---|
[379] | 429 | function num_DX_Callback(hObject, eventdata, handles) |
---|
[204] | 430 | %------------------------------------------------------------------------ |
---|
| 431 | %------------------------------------------------------------------------ |
---|
[379] | 432 | function num_DY_Callback(hObject, eventdata, handles) |
---|
[204] | 433 | %------------------------------------------------------------------------ |
---|
| 434 | %------------------------------------------------------------------------ |
---|
[379] | 435 | function num_DZ_Callback(hObject, eventdata, handles) |
---|
[204] | 436 | %------------------------------------------------------------------------ |
---|
| 437 | |
---|
| 438 | |
---|
| 439 | %------------------------------------------------------------------------ |
---|
[680] | 440 | % --- Executes on button press in REFRESH: refresh the current object , refresh the object and its projected field |
---|
| 441 | %------------------------------------------------------------------------ |
---|
| 442 | function REFRESH_Callback(hObject, eventdata, handles) |
---|
[204] | 443 | |
---|
[681] | 444 | set(handles.REFRESH,'BackgroundColor',[1 1 0])% indicate activation of REFRESH |
---|
[508] | 445 | drawnow |
---|
| 446 | |
---|
[630] | 447 | %% update the object in the GUI series if relevant |
---|
| 448 | if strcmp(get(handles.set_object,'Name'),'edit_object_series') |
---|
| 449 | hseries=findobj(allchild(0),'Tag','series'); |
---|
| 450 | if ~isempty(hseries) |
---|
| 451 | SeriesData=get(hseries,'UserData'); |
---|
| 452 | SeriesData.ProjObject=read_GUI(handles.set_object);%read the parameters defining the object in the GUI set_object |
---|
| 453 | set(hseries,'UserData',SeriesData); |
---|
| 454 | end |
---|
[680] | 455 | set(handles.REFRESH,'BackgroundColor',[1 0 0]) |
---|
[630] | 456 | return |
---|
| 457 | end |
---|
| 458 | |
---|
[410] | 459 | %% read the object parameters in the GUI set_object |
---|
[388] | 460 | ObjectData=read_GUI(handles.set_object);%read the parameters defining the object in the GUI set_object |
---|
[871] | 461 | if isfield(ObjectData,'CoordLine')% remove CoordLine (not used as object feature) |
---|
| 462 | ObjectData=rmfield(ObjectData,'CoordLine'); |
---|
| 463 | end |
---|
[397] | 464 | if iscell(ObjectData.Coord)%check for empty line |
---|
| 465 | ObjectData.Coord=[0 0 0]; |
---|
| 466 | hhset_object=guidata(handles.set_object); |
---|
| 467 | set(hhset_object.Coord,'Data',ObjectData.Coord) |
---|
| 468 | end |
---|
[388] | 469 | checknan=isnan(sum(ObjectData.Coord,2));%check for NaN lines |
---|
| 470 | if ~isempty(checknan) |
---|
| 471 | ObjectData.Coord(checknan,:)=[];%remove the NaN lines |
---|
| 472 | end |
---|
[402] | 473 | ObjectName=ObjectData.Name;%name of the current object defined in set_object |
---|
[309] | 474 | if isempty(ObjectName) |
---|
[432] | 475 | ObjectName=ObjectData.Type;% name the object by the object type type by default |
---|
[204] | 476 | end |
---|
[413] | 477 | |
---|
[432] | 478 | %% read the current object selection in the GUI uvmat |
---|
[413] | 479 | huvmat=findobj('tag','uvmat');%find the current uvmat GUI handle |
---|
| 480 | UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat |
---|
| 481 | hhuvmat=guidata(huvmat);%handles of the objects children of the GUI uvmat |
---|
[432] | 482 | ListObject=get(hhuvmat.ListObject,'String');% list of objects displayed in uvmat |
---|
[625] | 483 | |
---|
[650] | 484 | if isequal(get(hhuvmat.CheckEditObject,'Value'),0) %we append a new object |
---|
[625] | 485 | ListObject=[ListObject;{''}]; |
---|
| 486 | IndexObj=length(ListObject); |
---|
| 487 | set(hhuvmat.ListObject,'String',ListObject) |
---|
| 488 | set(hhuvmat.ListObject,'Value',IndexObj) |
---|
| 489 | UvData.ProjObject{IndexObj}=[]; %create a new empty object |
---|
| 490 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; % axes for plot_object |
---|
| 491 | UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
[630] | 492 | else |
---|
[625] | 493 | IndexObj=get(hhuvmat.ListObject,'Value');% index of the selected object for display in uvmat |
---|
| 494 | end |
---|
| 495 | |
---|
[630] | 496 | %set or modify(edit mode) the name of the currently selected object |
---|
[445] | 497 | detectname=1; |
---|
| 498 | ObjectNameNew=ObjectName; |
---|
| 499 | vers=0;% index of the name |
---|
| 500 | ListOther=ListObject; |
---|
| 501 | ListOther(IndexObj)=[]; |
---|
| 502 | while ~isempty(detectname) |
---|
| 503 | detectname=find(strcmp(ObjectNameNew,ListOther),1);%test the existence of the proposed name in the list |
---|
| 504 | if detectname% if the object name already exists |
---|
| 505 | indstr=regexp(ObjectNameNew,'\D');%indices of non number characters |
---|
| 506 | if indstr(end)<length(ObjectNameNew) %object name ends by a number |
---|
| 507 | vers=str2double(ObjectNameNew(indstr(end)+1:end))+1; |
---|
| 508 | ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)]; |
---|
| 509 | else |
---|
| 510 | vers=vers+1; |
---|
| 511 | ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)]; |
---|
[204] | 512 | end |
---|
| 513 | end |
---|
[445] | 514 | end |
---|
| 515 | ObjectName=ObjectNameNew; |
---|
| 516 | set(handles.Name,'String',ObjectName)% display the default name in set_object |
---|
| 517 | ListObject{IndexObj}=ObjectName; |
---|
| 518 | set(hhuvmat.ListObject,'String',ListObject);%complement the object list |
---|
[625] | 519 | set(hhuvmat.ListObject_1,'String',ListObject);%complement the object list |
---|
[650] | 520 | set(hhuvmat.CheckViewObject,'Value',1)% indicate that the currently selected objected is viewed on set_object |
---|
[622] | 521 | check_handle=isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat')... |
---|
| 522 | && ~isempty(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat) && ishandle(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat); |
---|
[445] | 523 | if check_handle |
---|
[622] | 524 | obj_handle=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; |
---|
[445] | 525 | end |
---|
[622] | 526 | UvData.ProjObject{IndexObj}=ObjectData;%record the current object properties in uvmat |
---|
[445] | 527 | if check_handle |
---|
[622] | 528 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=obj_handle; %preserve the object plot handle if valid |
---|
[445] | 529 | else |
---|
[622] | 530 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; %axes taken as object display handle by defualt |
---|
[204] | 531 | end |
---|
[309] | 532 | |
---|
[680] | 533 | %% refresh the field projected on the object |
---|
[432] | 534 | hview_field=[];%default |
---|
[445] | 535 | IndexObj_1=get(hhuvmat.ListObject_1,'Value'); |
---|
[388] | 536 | if strcmp(ObjectData.ProjMode,'mask_inside')||strcmp(ObjectData.ProjMode,'mask_outside')||strcmp(ObjectData.ProjMode,'none') |
---|
| 537 | PlotType='text'; |
---|
| 538 | else |
---|
[581] | 539 | % create tps coeff if needed for ProjMode 'interp_tps' |
---|
[586] | 540 | if strcmp(ObjectData.ProjMode,'interp_tps')&&~isfield(UvData.Field,'Coord_tps') |
---|
| 541 | %UvData.Field=calc_tps(UvData.Field,1); |
---|
| 542 | [UvData.Field,errormsg]=tps_coeff_field(UvData.Field,1); |
---|
| 543 | if ~isempty(errormsg) |
---|
| 544 | msgbox_uvmat('ERROR', ['set_object/tps_coeff_field/' errormsg]) |
---|
[680] | 545 | set(handles.REFRESH,'enable','on') |
---|
[586] | 546 | return |
---|
| 547 | end |
---|
[508] | 548 | end |
---|
[388] | 549 | [ProjData,errormsg]= proj_field(UvData.Field,ObjectData);%project the current field of uvmat on ObjectData |
---|
| 550 | if ~isempty(errormsg) |
---|
[586] | 551 | msgbox_uvmat('ERROR', ['set_object/proj_field/' errormsg]) |
---|
[680] | 552 | set(handles.REFRESH,'enable','on') |
---|
[388] | 553 | return |
---|
[586] | 554 | end |
---|
[445] | 555 | if isequal(IndexObj_1,IndexObj) % if the projection is in uvmat |
---|
[586] | 556 | PlotType=plot_field(ProjData,hhuvmat.PlotAxes,read_GUI(get(hhuvmat.PlotAxes,'parent')));%update the current uvmat plot |
---|
[491] | 557 | else % if the projection is in view_field |
---|
[413] | 558 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 559 | if isempty(hview_field) |
---|
[429] | 560 | hview_field=view_field(ProjData); %open the view_field GUI for plot |
---|
[413] | 561 | else |
---|
| 562 | hhview_field=guidata(hview_field); |
---|
[511] | 563 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%update an existing plot in view_field |
---|
[591] | 564 | errormsg=fill_GUI(PlotParam,hview_field); |
---|
[569] | 565 | if ~isempty(errormsg) |
---|
| 566 | msgbox_uvmat('ERROR',errormsg) |
---|
| 567 | return |
---|
| 568 | end |
---|
[586] | 569 | % write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
[413] | 570 | end |
---|
[429] | 571 | haxes=findobj(hview_field,'tag','axes3'); |
---|
| 572 | Data=get(hview_field,'UserData'); |
---|
| 573 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
| 574 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
| 575 | pos_table=get(h_TableDisplay,'Position'); |
---|
| 576 | pos=get(hview_field,'Position'); |
---|
| 577 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
| 578 | drawnow |
---|
| 579 | set(hview_field,'UserData',Data);% restore the previously stored GUI position after GUI resizing |
---|
| 580 | else |
---|
| 581 | set(hview_field,'Position',Data.GUISize) |
---|
| 582 | end |
---|
[388] | 583 | end |
---|
[227] | 584 | end |
---|
[429] | 585 | |
---|
[680] | 586 | %% update the object refresh |
---|
[622] | 587 | hobject=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; |
---|
[445] | 588 | % if we are editing the object used for projection in uvmat |
---|
| 589 | if isequal(IndexObj_1,IndexObj) |
---|
| 590 | %update the representation of the current object for projection field represented in view_field |
---|
[622] | 591 | for iobj=1:numel(UvData.ProjObject) |
---|
| 592 | UvData.ProjObject{iobj}.DisplayHandle.uvmat=... |
---|
| 593 | plot_object(UvData.ProjObject{iobj},UvData.ProjObject{IndexObj_1},UvData.ProjObject{iobj}.DisplayHandle.uvmat,'b'); |
---|
[432] | 594 | end |
---|
[445] | 595 | else % we are editing the object used for projection field represented in view_field |
---|
| 596 | %update the representation of the current object in uvmat |
---|
[622] | 597 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=... |
---|
| 598 | plot_object(UvData.ProjObject{IndexObj},UvData.ProjObject{IndexObj_1},UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'m'); |
---|
[680] | 599 | %indicate the object index in the user data of the object refresh (needed for further mouse editing) |
---|
[622] | 600 | ObjectInfo=get(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'UserData'); |
---|
[445] | 601 | ObjectInfo.IndexObj=IndexObj; |
---|
[622] | 602 | set(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'UserData',ObjectInfo) |
---|
[445] | 603 | % update the representation of all objects in view_field |
---|
[622] | 604 | for iobj=1:numel(UvData.ProjObject) |
---|
[729] | 605 | if isfield(UvData.ProjObject{iobj},'DisplayHandle') && isfield(UvData.ProjObject{iobj}.DisplayHandle,'view_field') |
---|
[622] | 606 | UvData.ProjObject{iobj}.DisplayHandle.view_field=... |
---|
| 607 | plot_object(UvData.ProjObject{iobj},UvData.ProjObject{iobj},UvData.ProjObject{iobj}.DisplayHandle.view_field,'b'); |
---|
[445] | 608 | end |
---|
[432] | 609 | end |
---|
| 610 | end |
---|
| 611 | set(huvmat,'UserData',UvData) |
---|
| 612 | |
---|
[204] | 613 | %% update the GUI uvmat |
---|
[650] | 614 | set(hhuvmat.CheckEditObject,'Value',1) % set uvmat to object edit mode to allow further object update |
---|
| 615 | set(hhuvmat.CheckViewField,'Value',1) |
---|
[681] | 616 | |
---|
[680] | 617 | set(handles.REFRESH,'BackgroundColor',[1 0 0]) |
---|
[681] | 618 | set(handles.num_RangeY_2,'BackgroundColor',[1 1 1]) |
---|
| 619 | |
---|
[772] | 620 | % --- Executes on button press in DisplayCoord. |
---|
| 621 | function DisplayCoord_Callback(hObject, eventdata, handles) |
---|
[738] | 622 | global Coord |
---|
| 623 | Coord=get(handles.Coord,'Data'); |
---|
| 624 | evalin('base','global Coord')%make Coord global in the workspace |
---|
| 625 | display('object coordinates:') |
---|
| 626 | evalin('base','Coord') %display Coord in the workspace |
---|
| 627 | commandwindow; %brings the Matlab command window to the front |
---|
| 628 | |
---|
[204] | 629 | %---------------------------------------------------- |
---|
[379] | 630 | function num_RangeY_1_Callback(hObject, eventdata, handles) |
---|
[204] | 631 | %------------------------------------------------------------------------ |
---|
| 632 | |
---|
[379] | 633 | function num_RangeZ_1_Callback(hObject, eventdata, handles) |
---|
[204] | 634 | %------------------------------------------------------------------------ |
---|
| 635 | |
---|
[379] | 636 | function num_RangeZ_2_Callback(hObject, eventdata, handles) |
---|
| 637 | DZ=str2num(get(handles.num_RangeZ_2,'String')); |
---|
[204] | 638 | ZMin=get(handles.z_slider,'Min'); |
---|
| 639 | ZMax=get(handles.z_slider,'Max'); |
---|
| 640 | if ~isequal(ZMax-ZMin,0) |
---|
| 641 | rel_step(1)=DZ/(ZMax-ZMin); |
---|
| 642 | rel_step(2)=0.2; |
---|
| 643 | set(handles.z_slider,'SliderStep',rel_step) |
---|
| 644 | end |
---|
| 645 | %------------------------------------------------------------------------ |
---|
[379] | 646 | function num_RangeY_2_Callback(hObject, eventdata, handles) |
---|
[204] | 647 | %------------------------------------------------------------------------ |
---|
| 648 | |
---|
[379] | 649 | function num_RangeX_1_Callback(hObject, eventdata, handles) |
---|
[204] | 650 | %------------------------------------------------------------------------ |
---|
| 651 | |
---|
[379] | 652 | function num_RangeX_2_Callback(hObject, eventdata, handles) |
---|
[681] | 653 | |
---|
[204] | 654 | %------------------------------------------------------------------------ |
---|
| 655 | %------------------------------------------------------------------------ |
---|
| 656 | function SAVE_Callback(hObject, eventdata, handles) |
---|
| 657 | % ------------------------------------------------------ |
---|
[379] | 658 | Object=read_GUI(handles.set_object); |
---|
[871] | 659 | if isfield(Object,'CoordLine')% remove CoordLine (not used as object feature) |
---|
| 660 | Object=rmfield(Object,'CoordLine'); |
---|
| 661 | end |
---|
[204] | 662 | huvmat=findobj('Tag','uvmat'); |
---|
| 663 | if isempty(huvmat) |
---|
| 664 | huvmat=findobj(allchild(0),'Name','series'); |
---|
| 665 | end |
---|
| 666 | hchild=get(huvmat,'Children'); |
---|
| 667 | hrootpath=findobj(hchild,'Tag','RootPath'); |
---|
| 668 | if isempty(hrootpath) |
---|
| 669 | RootPath=''; |
---|
| 670 | else |
---|
| 671 | RootPath=get(hrootpath,'String'); |
---|
| 672 | if iscell(RootPath) |
---|
| 673 | RootPath=RootPath{1}; |
---|
| 674 | end |
---|
| 675 | end |
---|
| 676 | title={'object name'}; |
---|
[667] | 677 | dir_save=uigetfile_uvmat('select the folder for the new xml object file:',RootPath,'uigetdir'); |
---|
| 678 | if ~isempty(dir_save) |
---|
| 679 | ObjectName=get(handles.Name,'String'); |
---|
| 680 | if ~isempty(ObjectName)&&~strcmp(ObjectName,'') |
---|
[675] | 681 | def=[ObjectName '.xml']; |
---|
[667] | 682 | else |
---|
[675] | 683 | def=[Object.Style '.xml']; |
---|
[667] | 684 | end |
---|
[705] | 685 | displ_txt={['save object in' dir_save]; 'with file name (.xml):'};%default display |
---|
[667] | 686 | menu=get(handles.ProjMode,'String'); |
---|
| 687 | value=get(handles.ProjMode,'Value'); |
---|
| 688 | ProjMode=menu{value}; |
---|
| 689 | if strcmp(ProjMode,'mask_inside')||strcmp(ProjMode,'mask_outside') |
---|
[745] | 690 | displ_txt=[displ_txt; '(note: to create a mask image, use ''Tools/make mask'' on the upper bar menu of uvmat)']; |
---|
[667] | 691 | end |
---|
[675] | 692 | answer=msgbox_uvmat('INPUT_TXT',displ_txt,def); |
---|
[705] | 693 | if ischar(answer) |
---|
| 694 | FullName=fullfile(dir_save,answer); |
---|
[667] | 695 | t=struct2xml(Object); |
---|
| 696 | t=set(t,1,'name','ProjObject'); |
---|
[912] | 697 | try |
---|
| 698 | save(t,FullName) |
---|
| 699 | msgbox_uvmat('CONFIRMATION',[FullName ' saved']) |
---|
| 700 | catch ME |
---|
| 701 | msgbox_uvmat('ERROR',ME.message) |
---|
| 702 | end |
---|
[667] | 703 | end |
---|
[204] | 704 | end |
---|
[227] | 705 | |
---|
[204] | 706 | %------------------------------------------------------------------------ |
---|
| 707 | % --- Executes on slider movement. |
---|
| 708 | function z_slider_Callback(hObject, eventdata, handles) |
---|
| 709 | %--------------------------------------------------------- |
---|
| 710 | Z_value=get(handles.z_slider,'Value'); |
---|
| 711 | %rotation angles |
---|
[227] | 712 | PlaneAngle=[0 0 0]; |
---|
| 713 | norm_plane=[0 0 1]; |
---|
| 714 | cos_om=1; |
---|
| 715 | sin_om=0; |
---|
| 716 | |
---|
[379] | 717 | PlaneAngle(1)=str2double(get(handles.num_Angle_1,'String'));%first angle in degrees |
---|
| 718 | PlaneAngle(2)=str2double(get(handles.num_Angle_2,'String'));%second angle in degrees |
---|
| 719 | PlaneAngle(3)=str2double(get(handles.num_Angle_3,'String'));%second angle in degrees |
---|
[227] | 720 | PlaneAngle=(pi/180)*PlaneAngle; |
---|
[212] | 721 | om=norm(PlaneAngle);%norm of rotation angle in radians |
---|
[227] | 722 | if isequal(om,0) |
---|
| 723 | norm_plane=[0 0 1]; |
---|
| 724 | else |
---|
| 725 | OmAxis=PlaneAngle/om; %unit vector marking the rotation axis |
---|
| 726 | cos_om=cos(om); |
---|
| 727 | sin_om=sin(om); |
---|
| 728 | coeff=OmAxis(3)*(1-cos_om); |
---|
| 729 | %components of the unity vector norm_plane normal to the projection plane |
---|
| 730 | norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; |
---|
| 731 | norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; |
---|
| 732 | norm_plane(3)=OmAxis(3)*coeff+cos_om; |
---|
| 733 | end |
---|
[747] | 734 | Coord=get(handles.Coord,'Data'); |
---|
| 735 | Coord(3)=Z_value; |
---|
| 736 | set(handles.Coord,'Data',Coord) |
---|
[204] | 737 | |
---|
[388] | 738 | % update graph |
---|
[680] | 739 | REFRESH_Callback(hObject, eventdata, handles) |
---|
[227] | 740 | |
---|
[204] | 741 | %------------------------------------------------------------------------ |
---|
| 742 | % --- Executes on button press in HELP. |
---|
| 743 | function HELP_Callback(hObject, eventdata, handles) |
---|
[227] | 744 | %------------------------------------------------------------------------ |
---|
[773] | 745 | web('http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp#ProjObject') |
---|
[204] | 746 | |
---|
[850] | 747 | %------------------------------------------------------------------------ |
---|
[674] | 748 | % --- Executes when selected cell(s) is changed in ListCoord. |
---|
[850] | 749 | %------------------------------------------------------------------------ |
---|
[674] | 750 | function Coord_CellSelectionCallback(hObject, eventdata, handles) |
---|
| 751 | if ~isempty(eventdata.Indices) |
---|
| 752 | iline=eventdata.Indices(1);% selected line number |
---|
[850] | 753 | set(handles.CoordLine,'String',num2str(iline)) |
---|
[674] | 754 | end |
---|
[379] | 755 | |
---|
[681] | 756 | |
---|
| 757 | function num_Angle_3_Callback(hObject, eventdata, handles) |
---|
| 758 | |
---|
[674] | 759 | %------------------------------------------------------------------------ |
---|
[681] | 760 | % --- Executes on key press with selection of a uicontrol |
---|
[674] | 761 | %------------------------------------------------------------------------ |
---|
[681] | 762 | function KeyPressFcn(hObject, eventdata, handles) |
---|
| 763 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% se REFRESH to magenta color, indicates that refresh needs to be done |
---|
[684] | 764 | if strcmp(get(hObject,'Tag'),'num_Angle_3') |
---|
| 765 | set(handles.num_RangeX_1,'String','') |
---|
| 766 | set(handles.num_RangeX_2,'String','') |
---|
| 767 | set(handles.num_RangeY_1,'String','') |
---|
| 768 | set(handles.num_RangeY_2,'String','') |
---|
| 769 | end |
---|
[674] | 770 | |
---|
[681] | 771 | %------------------------------------------------------------------------ |
---|
| 772 | % --- Executes on key press with focus on Coord and none of its controls. |
---|
| 773 | %------------------------------------------------------------------------ |
---|
| 774 | function Coord_KeyPressFcn(hObject, eventdata, handles) |
---|
| 775 | |
---|
| 776 | set(handles.REFRESH,'BackgroundColor',[1 0 1]) |
---|
[674] | 777 | xx=double(get(handles.set_object,'CurrentCharacter')); %get the keyboard character |
---|
[680] | 778 | if ismember(xx,[127 31])% delete, or downward |
---|
[674] | 779 | Coord=get(handles.Coord,'Data'); |
---|
[850] | 780 | iline=str2double(get(handles.CoordLine,'String')); |
---|
[674] | 781 | if isequal(xx, 31) |
---|
| 782 | if isequal(iline,size(Coord,1))% arrow downward |
---|
| 783 | Coord=[Coord;zeros(1,size(Coord,2))]; |
---|
| 784 | end |
---|
| 785 | else |
---|
| 786 | Coord(iline,:)=[];% suppress the current line |
---|
| 787 | end |
---|
| 788 | set(handles.Coord,'Data',Coord); |
---|
| 789 | end |
---|
[850] | 790 | |
---|
| 791 | %------------------------------------------------------------------------ |
---|
| 792 | % --- Executes on button press in clear_line. |
---|
| 793 | %------------------------------------------------------------------------ |
---|
| 794 | function clear_line_Callback(hObject, eventdata, handles) |
---|
| 795 | |
---|
| 796 | Coord=get(handles.Coord,'Data'); |
---|
| 797 | iline=str2double(get(handles.CoordLine,'String')); |
---|
| 798 | if isempty(iline) |
---|
| 799 | msgbox_uvmat('WARNING','no line suppressed, select a line in the table') |
---|
| 800 | else |
---|
| 801 | Coord(iline,:)=[]; |
---|
| 802 | set(handles.REFRESH,'BackgroundColor',[1 0 1]) |
---|
| 803 | set(handles.Coord,'Data',Coord); |
---|
| 804 | set(handles.CoordLine,'String','') |
---|
| 805 | REFRESH_Callback(hObject,eventdata,handles) |
---|
| 806 | end |
---|
[911] | 807 | |
---|
| 808 | |
---|
| 809 | |
---|
| 810 | function num_RangeInterp_Callback(hObject, eventdata, handles) |
---|