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