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