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