[11] | 1 | %'mouse_up': function activated when the mouse button is released |
---|
[89] | 2 | %------------------------------------------------------------------------ |
---|
[71] | 3 | % function mouse_up(hObject,eventdata,handles) |
---|
[11] | 4 | % activated by the command: |
---|
| 5 | % set(hObject,'WindowButtonUpFcn',{'mouse_up'}), |
---|
| 6 | % where hObject is the handle of the figure |
---|
[89] | 7 | |
---|
| 8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
[11] | 9 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
[89] | 10 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
[11] | 11 | % This file is part of the toolbox UVMAT. |
---|
| 12 | % |
---|
| 13 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 14 | % it under the terms of the GNU General Public License as published by |
---|
| 15 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 16 | % (at your option) any later version. |
---|
| 17 | % |
---|
| 18 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 21 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
[89] | 22 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
[11] | 23 | |
---|
[71] | 24 | function mouse_up(hObject,eventdata,handles) |
---|
[156] | 25 | %MouseAction='none'; %default |
---|
[150] | 26 | test_zoom=0;%default |
---|
[156] | 27 | test_ruler=0;%default |
---|
[150] | 28 | currentfig=hObject; |
---|
[154] | 29 | tagfig=get(currentfig,'tag'); |
---|
[150] | 30 | hhcurrentfig=guidata(currentfig); |
---|
| 31 | test_zoom=get(hhcurrentfig.zoom,'Value'); |
---|
[156] | 32 | |
---|
| 33 | % if ~exist('handles','var') |
---|
| 34 | % handles=get(gcbo,'UserData'); |
---|
| 35 | % end |
---|
[102] | 36 | huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle |
---|
[11] | 37 | if ~isempty(huvmat) |
---|
| 38 | hhuvmat=guidata(huvmat); |
---|
| 39 | UvData=get(huvmat,'UserData'); |
---|
[156] | 40 | % if isfield(UvData,'MouseAction') |
---|
| 41 | % MouseAction=UvData.MouseAction;% set the mouse action (edit, create objects...) |
---|
| 42 | % end |
---|
| 43 | test_ruler=~test_zoom && isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler action, second priority |
---|
[11] | 44 | end |
---|
[71] | 45 | currentfig=hObject; |
---|
[11] | 46 | currentaxes=gca; %store the current axes handle |
---|
[71] | 47 | AxeData=get(currentaxes,'UserData'); |
---|
| 48 | |
---|
[11] | 49 | test_drawing=0;%default |
---|
| 50 | |
---|
[154] | 51 | %% finalize the fabrication or the translation/deformation of an object and plot the corresponding projected field |
---|
[156] | 52 | if ~isempty(huvmat) && isfield(AxeData,'Drawing') && ~isequal(AxeData.Drawing,'off') && isfield(AxeData,'CurrentObject')... |
---|
| 53 | && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject) |
---|
[11] | 54 | xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates |
---|
| 55 | PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object |
---|
| 56 | IndexObj=PlotData.IndexObj; |
---|
| 57 | ObjectData=UvData.Object{IndexObj}; |
---|
[71] | 58 | ObjectData.enable_plot=1; |
---|
[154] | 59 | |
---|
| 60 | % ending translation |
---|
[11] | 61 | if isequal(AxeData.Drawing,'translate') |
---|
| 62 | XYData=AxeData.CurrentOrigin; |
---|
| 63 | DX=xy(1,1)-XYData(1);%translation from initial position |
---|
| 64 | DY=xy(1,2)-XYData(2); |
---|
| 65 | ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX; |
---|
| 66 | ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY; |
---|
[154] | 67 | |
---|
| 68 | %ending object deformation |
---|
[11] | 69 | elseif isequal(AxeData.Drawing,'deform') |
---|
| 70 | ind_move=AxeData.CurrentIndex; |
---|
| 71 | ObjectData.Coord(ind_move,1)=xy(1,1); |
---|
| 72 | ObjectData.Coord(ind_move,2)=xy(1,2); |
---|
[154] | 73 | |
---|
| 74 | %creating object |
---|
| 75 | else |
---|
[102] | 76 | if strcmp(ObjectData.Style,'line')||strcmp(ObjectData.Style,'polyline')||... |
---|
| 77 | strcmp(ObjectData.Style,'polygon')||strcmp(ObjectData.Style,'points') |
---|
[11] | 78 | if isfield(AxeData,'ObjectCoord') && size(AxeData.ObjectCoord,2)==3 |
---|
| 79 | xy(1,3)=AxeData.ObjectCoord(1,3); % z coordinate of the mouse: to generalise ... |
---|
| 80 | else |
---|
| 81 | xy(1,3)=0; % z coordinate set to 0 by default |
---|
| 82 | end |
---|
| 83 | if ~isequal(ObjectData.Coord,xy(1,:)) |
---|
| 84 | ObjectData.Coord=[ObjectData.Coord ;xy(1,:)];% append the coordiantes marked by the mouse to the eobject |
---|
| 85 | end |
---|
| 86 | elseif isequal(ObjectData.Style,'rectangle')||isequal(ObjectData.Style,'ellipse')||isequal(ObjectData.Style,'volume') |
---|
| 87 | XYData=AxeData.CurrentOrigin; |
---|
| 88 | ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate |
---|
| 89 | ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2; |
---|
| 90 | ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width |
---|
| 91 | ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height |
---|
| 92 | elseif isequal(ObjectData.Style,'plane') %case of 'plane' |
---|
| 93 | DX=(xy(1,1)-ObjectData.Coord(1,1)); |
---|
| 94 | DY=(xy(1,2)-ObjectData.Coord(1,2)); |
---|
[154] | 95 | ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle width |
---|
[11] | 96 | if isfield(ObjectData,'RangeX') |
---|
| 97 | XMax=sqrt(DX*DX+DY*DY); |
---|
| 98 | if XMax>max(ObjectData.RangeX) |
---|
| 99 | ObjectData.RangeX=[min(ObjectData.RangeX) XMax]; |
---|
| 100 | end |
---|
| 101 | end |
---|
| 102 | end |
---|
| 103 | end |
---|
[102] | 104 | if strcmp(ObjectData.Style,'rectangle')||strcmp(ObjectData.Style,'ellipse') |
---|
[11] | 105 | NbDefPoint=1; |
---|
[102] | 106 | elseif strcmp(ObjectData.Style,'line')|| strcmp(ObjectData.Style,'plane'); |
---|
[11] | 107 | NbDefPoint=2; |
---|
| 108 | else |
---|
| 109 | NbDefPoint=3; |
---|
| 110 | end |
---|
| 111 | |
---|
| 112 | %show object coordinates in the GUI set_object |
---|
[102] | 113 | h_set_object=findobj(allchild(0),'Tag','set_object'); |
---|
| 114 | hh_set_object=guidata(h_set_object); |
---|
| 115 | set(hh_set_object.XObject,'String',num2str(ObjectData.Coord(:,1),4)); |
---|
| 116 | set(hh_set_object.YObject,'String',num2str(ObjectData.Coord(:,2),4)); |
---|
| 117 | set(hh_set_object.ZObject,'String',num2str(ObjectData.Coord(:,3),4)); |
---|
[183] | 118 | if strcmp(ObjectData.Style,'rectangle')||strcmp(ObjectData.Style,'ellipse') |
---|
| 119 | set(hh_set_object.XMax,'String',num2str(ObjectData.RangeX,4)); |
---|
| 120 | set(hh_set_object.YMax,'String',num2str(ObjectData.RangeY,4)); |
---|
| 121 | end |
---|
[11] | 122 | if NbDefPoint<=2 || isequal(get(currentfig,'SelectionType'),'alt') ||... |
---|
[102] | 123 | strcmp(AxeData.Drawing,'translate') || strcmp(AxeData.Drawing,'deform');%stop drawing |
---|
[11] | 124 | AxeData.CurrentOrigin=[]; %suppress the current origin |
---|
| 125 | if isequal(ObjectData.Style,'line') && size(ObjectData.Coord,1)<=1 |
---|
| 126 | AxeData.Drawing='off'; |
---|
| 127 | set(currentaxes,'UserData',AxeData); |
---|
| 128 | return % line needs at leqst two points |
---|
| 129 | end |
---|
| 130 | if ~isempty(ObjectData) |
---|
[154] | 131 | % testmask=0; |
---|
| 132 | % hmask=findobj(huvmat,'Tag','makemask'); |
---|
| 133 | % if ~isempty(hmask) |
---|
| 134 | % testmask=get(hmask,'Value'); |
---|
| 135 | % end |
---|
| 136 | % if testmask |
---|
| 137 | % PlotHandles=[];%do not project data on the object during mask creation |
---|
| 138 | % else |
---|
[156] | 139 | % PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters |
---|
[154] | 140 | % end |
---|
[156] | 141 | |
---|
| 142 | %% update the object representation |
---|
| 143 | ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj}.DisplayHandle_uvmat; |
---|
| 144 | ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj}.DisplayHandle_view_field; |
---|
| 145 | UvData.Object{IndexObj}=ObjectData;%update the current object properties |
---|
| 146 | hhuvmat=guidata(huvmat); |
---|
| 147 | IndexObj_1=get(hhuvmat.list_object_1,'Value'); |
---|
| 148 | IndexObj_2=get(hhuvmat.list_object_2,'Value'); |
---|
| 149 | UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2); |
---|
| 150 | |
---|
| 151 | %% plot the field projected on the object and store it on the corresponding figure |
---|
| 152 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData |
---|
| 153 | if ~isempty(ProjData) |
---|
| 154 | if strcmp(tagfig,'uvmat')% uvmat plot selected, projection plot seen on view_field |
---|
| 155 | % if strcmp(projview,'view_field') |
---|
| 156 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 157 | if isempty(hview_field) |
---|
| 158 | hview_field=view_field; |
---|
| 159 | end |
---|
| 160 | ViewFieldData=get(hview_field,'UserData'); |
---|
| 161 | ViewFieldData.axes3=ProjData; |
---|
| 162 | set(hview_field,'UserData',ViewFieldData) |
---|
| 163 | PlotHandles=guidata(hview_field); |
---|
| 164 | else |
---|
| 165 | UvData.axes3=ProjData; |
---|
| 166 | PlotHandles=hhuvmat; |
---|
| 167 | end |
---|
| 168 | [PlotType,PlotParam]=plot_field(ProjData,PlotHandles.axes3,PlotHandles);%update an existing field plot |
---|
| 169 | write_plot_param(PlotHandles,PlotParam); %update the display of plotting parameters for the current object |
---|
[154] | 170 | end |
---|
[156] | 171 | % if isfield(UvData.Object{IndexObj},'PlotParam') |
---|
| 172 | % write_plot_param(PlotHandles,UvData.Object{IndexObj}.PlotParam); %update the display of plotting parameters for the current object |
---|
| 173 | % end |
---|
| 174 | set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow |
---|
| 175 | set(hhuvmat.edit_object,'Value',1);% |
---|
| 176 | set(hhuvmat.edit_object,'Enable','on');% |
---|
[67] | 177 | set(hhuvmat.MenuEditObject,'Enable','on');% |
---|
[11] | 178 | set(hhuvmat.MenuEdit,'Enable','on');% |
---|
| 179 | end |
---|
| 180 | else |
---|
| 181 | AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the new current origin |
---|
| 182 | test_drawing=1;%allow continuation of drawing object |
---|
| 183 | UvData.Object{IndexObj}=ObjectData; |
---|
| 184 | end |
---|
| 185 | hother=findobj('Tag','deformpoint');%find all the deformpoints |
---|
| 186 | set(hother,'Color','b');%reset all the deformpoints in 'blue' |
---|
| 187 | else |
---|
| 188 | test_drawing=0; |
---|
| 189 | end |
---|
[154] | 190 | |
---|
| 191 | %% creation of a new zoom plot |
---|
[11] | 192 | test_replot=0; |
---|
| 193 | if isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed |
---|
| 194 | % FigData=get(currentfig,'UserData'); |
---|
| 195 | hparentfig=currentfig; |
---|
| 196 | %open or update a new zoom figure if a rectangle has been drawn |
---|
| 197 | if ishandle(currentaxes); |
---|
[156] | 198 | if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom) |
---|
[11] | 199 | PosRect=get(AxeData.CurrentRectZoom,'Position'); |
---|
[156] | 200 | if isfield(AxeData,'CurrentVec') && ~isempty(AxeData.CurrentVec) && ishandle(AxeData.CurrentVec) |
---|
[11] | 201 | delete(AxeData.CurrentVec) |
---|
| 202 | end |
---|
[61] | 203 | hfig2=figure;%create new figure |
---|
| 204 | set(hfig2,'name','zoom') |
---|
| 205 | set(hfig2,'Units','normalized') |
---|
[11] | 206 | set(hfig2,'Position',[0.2 0.33 0.6 0.6]); |
---|
[61] | 207 | map=colormap(currentaxes); |
---|
| 208 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 209 | set(hfig2,'Position',[0.2 0.33 0.6 0.6]); |
---|
[11] | 210 | if test_replot==0 |
---|
| 211 | set(hfig2,'Unit','normalized') |
---|
| 212 | set(hfig2,'KeyPressFcn',{@keyboard_callback,handles})%set keyboard action function |
---|
| 213 | set(hfig2,'WindowButtonMotionFcn',{@mouse_motion,handles})%set mouse action function |
---|
| 214 | set(hfig2,'WindowButtonDownFcn',{@mouse_down})%set mouse click action function |
---|
| 215 | set(hfig2,'WindowButtonUpFcn',{@mouse_up,handles}) |
---|
| 216 | set(hfig2,'DeleteFcn',{@close_fig,AxeData.CurrentRectZoom,'zoom'}) |
---|
| 217 | set(hfig2,'UserData',AxeData.CurrentRectZoom)% record the parent object (zoom rectangle) in the new fig |
---|
| 218 | AxeData.ZoomAxes=copyobj(currentaxes,hfig2); %copy the current graph axes to the zoom figure |
---|
| 219 | figure(hfig2) |
---|
| 220 | set(AxeData.ZoomAxes,'Position',[0.1300 0.1100 0.7750 0.8150])% standard axes position on a figure |
---|
| 221 | hcol=findobj(hparentfig,'Tag','Colorbar'); %look for colorbar axes |
---|
| 222 | if ~isempty(hcol) |
---|
| 223 | hcol_new=colorbar; |
---|
| 224 | YTick=get(hcol,'YTick'); |
---|
| 225 | YTicklabel=get(hcol,'Yticklabel'); |
---|
| 226 | colbarlim=get(hcol,'YLim'); |
---|
| 227 | newcolbarlim=get(hcol_new,'YLim'); |
---|
| 228 | scale_bar=(newcolbarlim(2)-newcolbarlim(1))/(colbarlim(2)-colbarlim(1)); |
---|
| 229 | YTick_rescaled=newcolbarlim(1)+scale_bar*(YTick-colbarlim(1)); |
---|
| 230 | set(hcol_new,'YTick',YTick_rescaled); |
---|
| 231 | set(hcol_new,'Yticklabel',YTicklabel); |
---|
| 232 | end |
---|
| 233 | end |
---|
| 234 | if ishandle(AxeData.ZoomAxes) |
---|
| 235 | hnew_rect=findobj(AxeData.ZoomAxes,'Tag','rect_zoom'); |
---|
| 236 | if ~isempty(hnew_rect) |
---|
| 237 | delete(hnew_rect); |
---|
| 238 | ChildAxeData=get(AxeData.ZoomAxes,'UserData'); |
---|
| 239 | ChildAxeData.CurrentRectZoom=[]; % no rect zoom in the new window |
---|
| 240 | ChildAxeData.Drawing='off'; |
---|
| 241 | ChildAxeData.ParentRect=AxeData.CurrentRectZoom;%set the rectangle as a 'parent' associated to the new axes |
---|
| 242 | set(AxeData.ZoomAxes,'UserData',ChildAxeData);%update the AxeData of the new axes |
---|
| 243 | set(AxeData.ZoomAxes,'Xlim',[PosRect(1) PosRect(1)+PosRect(3)]) |
---|
| 244 | set(AxeData.ZoomAxes,'Ylim',[PosRect(2) PosRect(2)+PosRect(4)]) |
---|
| 245 | end |
---|
| 246 | end |
---|
| 247 | end |
---|
| 248 | end |
---|
| 249 | end |
---|
[154] | 250 | |
---|
| 251 | %% zoom in by a factor 2 if no new figure is created |
---|
[150] | 252 | if test_zoom |
---|
[82] | 253 | xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates |
---|
[11] | 254 | if isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed |
---|
| 255 | xlim=get(currentaxes,'XLim'); |
---|
[82] | 256 | xlim_new(2)=0.5*xy(1,1)+0.5*xlim(2); |
---|
| 257 | xlim_new(1)=0.5*xy(1,1)+0.5*xlim(1); |
---|
[11] | 258 | set(currentaxes,'XLim',xlim_new) |
---|
| 259 | ylim=get(currentaxes,'YLim'); |
---|
[82] | 260 | ylim_new(2)=0.5*xy(1,2)+0.5*ylim(2); |
---|
| 261 | ylim_new(1)=0.5*xy(1,2)+0.5*ylim(1); |
---|
[11] | 262 | set(currentaxes,'YLim',ylim_new) |
---|
| 263 | if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field |
---|
| 264 | hparentrect=AxeData.ParentRect; |
---|
| 265 | xlim=get(currentaxes,'XLim'); |
---|
| 266 | ylim=get(currentaxes,'YLim'); |
---|
| 267 | rect([1 2])=[xlim(1) ylim(1)]; |
---|
| 268 | rect([3 4])=[xlim(2)-xlim(1) ylim(2)-ylim(1)]; |
---|
| 269 | set(hparentrect,'Position',rect) |
---|
| 270 | end |
---|
[82] | 271 | %zoom out by a factor of 2 out when the right mouse button has been used |
---|
[11] | 272 | elseif isequal(get(currentfig,'SelectionType'),'alt'); %if right button has been pressed |
---|
[102] | 273 | % alpha=2; %zoom factor (zoom out by a factor 2) |
---|
[11] | 274 | xlim=get(currentaxes,'XLim'); |
---|
[82] | 275 | xlim_new(1)=2*xlim(1)-xy(1,1); |
---|
| 276 | xlim_new(2)=2*xlim(2)-xy(1,1); |
---|
| 277 | % xlim_new(1)=(1+alpha)*xlim(1)/2+(1-alpha)*xlim(2)/2; |
---|
| 278 | % xlim_new(2)=(1-alpha)*xlim(1)/2+(1+alpha)*xlim(2)/2; |
---|
[11] | 279 | ylim=get(currentaxes,'YLim'); |
---|
[82] | 280 | ylim_new(1)=2*ylim(1)-xy(1,2); |
---|
| 281 | ylim_new(2)=2*ylim(2)-xy(1,2); |
---|
| 282 | % ylim_new(1)=(1+alpha)*ylim(1)/2+(1-alpha)*ylim(2)/2; |
---|
| 283 | % ylim_new(2)=(1-alpha)*ylim(1)/2+(1+alpha)*ylim(2)/2; |
---|
| 284 | if isfield(AxeData,'RangeX') && isfield(AxeData,'RangeY') |
---|
| 285 | xlim_new(1)=max(AxeData.RangeX(1),xlim_new(1)); |
---|
| 286 | xlim_new(2)=min(AxeData.RangeX(2),xlim_new(2)); |
---|
| 287 | ylim_new(1)=max(AxeData.RangeY(1),ylim_new(1)); |
---|
| 288 | ylim_new(2)=min(AxeData.RangeY(2),ylim_new(2)); |
---|
| 289 | if isequal(xlim_new,AxeData.RangeX) && isequal(ylim_new,AxeData.RangeY) |
---|
| 290 | set(hhuvmat.zoom,'Value',0) |
---|
| 291 | set(hhuvmat.zoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 292 | set(hhuvmat.FixedLimits,'Value',0) |
---|
| 293 | set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 294 | end |
---|
| 295 | end |
---|
[11] | 296 | set(currentaxes,'XLim',xlim_new) |
---|
| 297 | set(currentaxes,'YLim',ylim_new) |
---|
| 298 | %test whther zoom out is operating (to inactivate AxedAta |
---|
[82] | 299 | if ~isfield(AxeData,'CurrentXLim')|| ~isequal(xlim,AxeData.CurrentXLim) |
---|
[11] | 300 | AxeData.CurrentXLim=xlim;% |
---|
| 301 | end |
---|
| 302 | if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field |
---|
| 303 | hparentrect=AxeData.ParentRect; |
---|
| 304 | xlim=get(currentaxes,'XLim'); |
---|
| 305 | ylim=get(currentaxes,'YLim'); |
---|
| 306 | rect([1 2])=[xlim(1) ylim(1)]; |
---|
| 307 | rect([3 4])=[xlim(2)-xlim(1) ylim(2)-ylim(1)]; |
---|
| 308 | set(hparentrect,'Position',rect) |
---|
| 309 | end |
---|
| 310 | end |
---|
| 311 | end |
---|
[67] | 312 | |
---|
[154] | 313 | %% editing calibration point |
---|
[156] | 314 | if ~test_zoom && isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'calibration') |
---|
| 315 | h_geometry_calib=findobj(allchild(0),'tag','geometry_calib'); %find the geomterty_calib GUI |
---|
| 316 | if ~isempty(h_geometry_calib) |
---|
| 317 | hh_geometry_calib=guidata(h_geometry_calib); |
---|
| 318 | edit_test=get(hh_geometry_calib.edit_append,'Value'); |
---|
| 319 | hh=findobj(currentaxes,'tag','calib_points');%look for handle of calibration points |
---|
| 320 | if ~isempty(hh) && edit_test |
---|
| 321 | index_point=get(hh,'UserData'); |
---|
| 322 | set(hh,'UserData',[])%remove edit mode |
---|
| 323 | h_ListCoord=hh_geometry_calib.ListCoord; %handles of the coordinate list |
---|
| 324 | Coord=get(h_ListCoord,'String'); |
---|
| 325 | data=read_geometry_calib(Coord); |
---|
| 326 | % val=get(h_ListCoord,'Value'); |
---|
| 327 | xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates |
---|
| 328 | data.Coord(index_point,4)=xy(1,1); |
---|
| 329 | data.Coord(index_point,5)=xy(1,2); |
---|
| 330 | for ipoint=1:size(data.Coord,1) |
---|
| 331 | for jcoord=1:5 |
---|
| 332 | Coord_cell{ipoint,jcoord}=num2str(data.Coord(ipoint,jcoord),4);%display coordiantes with 4 digits |
---|
| 333 | end |
---|
[154] | 334 | end |
---|
[156] | 335 | Tabchar=cell2tab(Coord_cell,' | '); |
---|
| 336 | Tabchar=[Tabchar ;{'......'}]; |
---|
| 337 | set(h_ListCoord,'String',Tabchar) |
---|
| 338 | % coord_str=Coord{index_point}; %current line (string) |
---|
| 339 | % k=findstr('|',coord_str);%find separator indices on the string |
---|
| 340 | % blanks=blank |
---|
| 341 | % xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates |
---|
| 342 | % if numel(k)>=3 |
---|
| 343 | % coord_str=[coord_str(1:k(3)-1) ' | ' num2str(xy(1,1),4) ' | ' num2str(xy(1,2),4)]; %update the pixel information while preserving phys coord |
---|
| 344 | % else |
---|
| 345 | % coord_str=[ ' | ' ' | ' ' | ' num2str(xy(1,1),4) ' | ' num2str(xy(1,2),4)]; |
---|
| 346 | % end |
---|
| 347 | % Coord{index_point}=coord_str; |
---|
| 348 | % set(h_ListCoord,'String',Coord) |
---|
| 349 | % data=read_geometry_calib(Coord);%transform char cell to numbers |
---|
| 350 | set(hh,'XData',data.Coord(:,4)) |
---|
| 351 | set(hh,'YData',data.Coord(:,5)) |
---|
[71] | 352 | end |
---|
| 353 | end |
---|
[67] | 354 | end |
---|
| 355 | |
---|
[154] | 356 | |
---|
| 357 | %% finalising ruler |
---|
[156] | 358 | if test_ruler |
---|
| 359 | set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat |
---|
| 360 | xy=get(currentaxes,'CurrentPoint');% get the current mouse coordinates |
---|
| 361 | RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)];% append the recorded ruler origin to the current mouse coordinates |
---|
| 362 | RulerCoord=diff(RulerCoord,1);% coordiante difference between segment end and beginning |
---|
[60] | 363 | RulerCoord=RulerCoord(1)+i*RulerCoord(2); |
---|
[61] | 364 | distance=abs(RulerCoord); |
---|
| 365 | azimuth=(180/pi)*angle(RulerCoord); |
---|
[60] | 366 | msgbox_uvmat('RULER','',['length: ' num2str(distance,3) ', angle(degrees): ' num2str(azimuth,3)]) |
---|
[156] | 367 | delete(AxeData.RulerHandle)%delete the ruler graphic object |
---|
| 368 | AxeData=rmfield(AxeData,'RulerHandle');%remove the ruler handle in AxeData |
---|
| 369 | AxeData.Drawing='off';%exit the ruler drawing mode |
---|
[60] | 370 | end |
---|
[11] | 371 | |
---|
[154] | 372 | %% display the data of the current object selected with the mouse right click |
---|
[150] | 373 | if isequal(get(currentfig,'SelectionType'),'alt') && ~test_zoom && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create')) |
---|
[11] | 374 | hother=findobj('Tag','proj_object');%find all the proj objects |
---|
| 375 | nbselect=0; |
---|
| 376 | %test the existence of selected objects: |
---|
| 377 | for iproj=1:length(hother); |
---|
| 378 | iselect=isequal(get(hother(iproj),'Selected'),'on');%reset all the proj objects in 'blue' by default |
---|
| 379 | nbselect=nbselect+iselect; |
---|
| 380 | end |
---|
| 381 | hother=findobj('Tag','proj_object','Type','line');%find all the proj objects |
---|
| 382 | set(hother,'Color','b');%reset all the proj objects in 'blue' by default |
---|
| 383 | set(hother,'Selected','off') |
---|
| 384 | hother=findobj('Tag','proj_object','Type','rectangle'); |
---|
| 385 | set(hother,'EdgeColor','b'); |
---|
| 386 | set(hother,'Selected','off') |
---|
| 387 | hother=findobj('Tag','proj_object','Type','patch'); |
---|
| 388 | set(hother,'FaceColor','b'); |
---|
| 389 | if isequal(get(gco,'Type'),'image') |
---|
| 390 | currentobj=get(gco,'parent');%parent axes of the image |
---|
| 391 | else |
---|
| 392 | currentobj=gco;%default |
---|
| 393 | end |
---|
| 394 | if ((nbselect==0) && isequal(get(currentobj,'Type'),'axes')) || isequal(currentobj,huvmat) |
---|
[102] | 395 | currentfig=get(currentobj,'parent'); |
---|
| 396 | figname=get(currentfig,'name'); |
---|
| 397 | eval(['global Data_' figname]) |
---|
| 398 | eval(['Data_' figname '=get(currentobj,''UserData'')']); |
---|
| 399 | evalin('base',['global Data_' figname])%make CurData global in the workspace |
---|
[11] | 400 | objtype=get(currentobj,'Type'); |
---|
| 401 | display(['UserData of ' objtype ':']) |
---|
[102] | 402 | evalin('base',['Data_' figname]) %display CurData in the workspace |
---|
[82] | 403 | commandwindow %brings the Matlab command window to the front |
---|
[11] | 404 | end |
---|
| 405 | end |
---|
[154] | 406 | |
---|
| 407 | %% update |
---|
[11] | 408 | if test_drawing==0 |
---|
| 409 | AxeData.Drawing='off';%stop current drawing action |
---|
| 410 | end |
---|
| 411 | set(currentaxes,'UserData',AxeData); |
---|
| 412 | if ~isempty(huvmat) |
---|
| 413 | set(huvmat,'UserData',UvData); |
---|
| 414 | end |
---|
| 415 | |
---|
| 416 | |
---|
| 417 | |
---|