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