[204] | 1 | %'mouse_up': function activated when the mouse button is released |
---|
| 2 | %------------------------------------------------------------------------ |
---|
| 3 | % function mouse_up(hObject,eventdata,handles) |
---|
| 4 | % activated by the command: |
---|
| 5 | % set(hObject,'WindowButtonUpFcn',{'mouse_up'}), |
---|
| 6 | % where hObject is the handle of the figure |
---|
| 7 | |
---|
| 8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 9 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 10 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 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. |
---|
| 22 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 23 | |
---|
| 24 | function mouse_up(hObject,eventdata,handles) |
---|
[622] | 25 | |
---|
[204] | 26 | test_ruler=0;%default |
---|
[682] | 27 | hcurrentaxes=get(hObject,'CurrentAxes'); |
---|
| 28 | if isempty(hcurrentaxes) |
---|
| 29 | return % no axes in the current figure |
---|
| 30 | end |
---|
| 31 | AxeData=get(hcurrentaxes,'UserData'); |
---|
[625] | 32 | if isfield(AxeData,'ParentAxes')% case of a zoom plot as current axis |
---|
| 33 | hcurrentaxes=AxeData.ParentAxes; |
---|
| 34 | AxeData=get(hcurrentaxes,'UserData'); |
---|
| 35 | hcurrentfig=get(hcurrentaxes,'parent');%handles of the GUI parent of the zoom plot |
---|
| 36 | testsubplot=1;% mouse selection is on a zoom subplot |
---|
| 37 | else |
---|
| 38 | hcurrentfig=hObject; |
---|
| 39 | testsubplot=0; |
---|
| 40 | end |
---|
[699] | 41 | %set(get(hcurrentfig,'CurrentObject'),'Selected','off') |
---|
| 42 | |
---|
[622] | 43 | CurrentOrigin=[]; |
---|
[204] | 44 | if isfield(AxeData,'CurrentOrigin') |
---|
| 45 | CurrentOrigin=AxeData.CurrentOrigin; |
---|
| 46 | end |
---|
[625] | 47 | FigTag=get(hcurrentfig,'tag'); |
---|
| 48 | hhcurrentfig=guidata(hcurrentfig);%the current figure is a GUI (uvmat or view_field) |
---|
| 49 | CheckZoom=get(hhcurrentfig.CheckZoom,'Value'); |
---|
| 50 | CheckZoomFig=get(hhcurrentfig.CheckZoomFig,'Value');%exclusive to CheckZoom |
---|
[204] | 51 | huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle |
---|
| 52 | if ~isempty(huvmat) |
---|
| 53 | hhuvmat=guidata(huvmat); |
---|
| 54 | UvData=get(huvmat,'UserData'); |
---|
[625] | 55 | test_ruler=~CheckZoom && isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler action, second priority |
---|
[204] | 56 | end |
---|
[625] | 57 | test_drawing=0;%default, =1 to allow drawing by further mouse action |
---|
[681] | 58 | if ~(isfield(AxeData,'Enable')&& strcmp(AxeData.Enable,'on')) |
---|
| 59 | return |
---|
| 60 | end |
---|
[699] | 61 | |
---|
[682] | 62 | xy=get(hcurrentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates |
---|
[204] | 63 | |
---|
[625] | 64 | |
---|
| 65 | %% proceed with the creation or editing (translation/deformation) of an object |
---|
[204] | 66 | if ~isempty(huvmat) && isfield(AxeData,'Drawing') && ~isequal(AxeData.Drawing,'off') && isfield(AxeData,'CurrentObject')... |
---|
[444] | 67 | && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject) |
---|
[699] | 68 | set(AxeData.CurrentObject,'Selected','off') |
---|
[444] | 69 | PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object |
---|
[204] | 70 | IndexObj=PlotData.IndexObj; |
---|
[622] | 71 | ObjectData=UvData.ProjObject{IndexObj}; |
---|
[444] | 72 | check_multiple=0; |
---|
[625] | 73 | |
---|
| 74 | h_set_object=findobj(allchild(0),'Tag','set_object'); |
---|
| 75 | hh_set_object=guidata(h_set_object); |
---|
| 76 | ObjectData.Coord=get(hh_set_object.Coord,'Data'); |
---|
| 77 | |
---|
[204] | 78 | % ending translation |
---|
| 79 | if isequal(AxeData.Drawing,'translate') |
---|
| 80 | XYData=AxeData.CurrentOrigin; |
---|
| 81 | DX=xy(1,1)-XYData(1);%translation from initial position |
---|
| 82 | DY=xy(1,2)-XYData(2); |
---|
| 83 | ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX; |
---|
| 84 | ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY; |
---|
[681] | 85 | set(hh_set_object.Coord,'Data',ObjectData.Coord); |
---|
[625] | 86 | %ending object deformation |
---|
[204] | 87 | elseif isequal(AxeData.Drawing,'deform') |
---|
| 88 | ind_move=AxeData.CurrentIndex; |
---|
| 89 | ObjectData.Coord(ind_move,1)=xy(1,1); |
---|
| 90 | ObjectData.Coord(ind_move,2)=xy(1,2); |
---|
[681] | 91 | set(hh_set_object.Coord,'Data',ObjectData.Coord); |
---|
[625] | 92 | %creating object |
---|
[444] | 93 | else |
---|
[429] | 94 | switch ObjectData.Type |
---|
| 95 | case {'line'} |
---|
[622] | 96 | if size(ObjectData.Coord,1)==1 % this is the mouse up for the first point, continue until next click |
---|
| 97 | check_multiple=1; |
---|
[204] | 98 | end |
---|
[622] | 99 | case {'rectangle','ellipse','volume'} |
---|
[625] | 100 | ObjectData.Coord=(CurrentOrigin+xy(1,1:2))/2;% keep only the first point coordinate |
---|
[622] | 101 | ObjectData.RangeX=abs(ObjectData.Coord(1,1)-xy(1,1));%rectangle width |
---|
[625] | 102 | ObjectData.RangeY=abs(ObjectData.Coord(1,2)-xy(1,2));%rectangle height |
---|
[622] | 103 | if isequal(ObjectData.RangeX,0)||isequal(ObjectData.RangeY,0) |
---|
| 104 | check_multiple=1;% pass to next mous up if width of height=0 |
---|
[444] | 105 | end |
---|
[429] | 106 | case 'plane' %case of 'plane' |
---|
| 107 | DX=(xy(1,1)-ObjectData.Coord(1,1)); |
---|
| 108 | DY=(xy(1,2)-ObjectData.Coord(1,2)); |
---|
| 109 | ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle width |
---|
| 110 | if isfield(ObjectData,'RangeX') |
---|
| 111 | XMax=sqrt(DX*DX+DY*DY); |
---|
| 112 | if XMax>max(ObjectData.RangeX) |
---|
| 113 | ObjectData.RangeX=[min(ObjectData.RangeX) XMax]; |
---|
| 114 | end |
---|
| 115 | end |
---|
[444] | 116 | otherwise |
---|
[625] | 117 | check_multiple=1; |
---|
[204] | 118 | end |
---|
| 119 | end |
---|
| 120 | |
---|
| 121 | %show object coordinates in the GUI set_object |
---|
[379] | 122 | if strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse') |
---|
[388] | 123 | set(hh_set_object.num_RangeX_2,'String',num2str(ObjectData.RangeX,4)); |
---|
| 124 | set(hh_set_object.num_RangeY_2,'String',num2str(ObjectData.RangeY,4)); |
---|
[204] | 125 | end |
---|
[625] | 126 | |
---|
| 127 | %% stop drawing and plot the projected field if the object manipulation is finished |
---|
[622] | 128 | if check_multiple==0 || isequal(get(hcurrentfig,'SelectionType'),'alt') |
---|
[714] | 129 | pointer=get(hcurrentfig,'Pointer');%memorize the current pointer shape |
---|
| 130 | set(hcurrentfig,'Pointer','watch')% set the pointer shape to watch to prevent further mouse action |
---|
[204] | 131 | AxeData.CurrentOrigin=[]; %suppress the current origin |
---|
[625] | 132 | hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(FigTag); |
---|
[622] | 133 | if ~isempty(hObject) |
---|
[625] | 134 | ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')}; |
---|
| 135 | AxeData.CurrentObject=plot_object(ObjectData,ProjObject,hobject,'m');%draw the object and its handle becomes AxeData.CurrentObject |
---|
[622] | 136 | end |
---|
| 137 | %% |
---|
[444] | 138 | if ~isempty(ObjectData) |
---|
| 139 | % plot the field projected on the object |
---|
[204] | 140 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData |
---|
| 141 | if ~isempty(ProjData) |
---|
[625] | 142 | if strcmp(FigTag,'uvmat')% uvmat plot selected, projection plot seen in view_field |
---|
[444] | 143 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
[204] | 144 | if isempty(hview_field) |
---|
[429] | 145 | hview_field=view_field(ProjData); %open the view_field GUI for plot |
---|
[413] | 146 | else |
---|
[429] | 147 | hhview_field=guidata(hview_field); |
---|
[511] | 148 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%update an existing plot in view_field |
---|
[608] | 149 | errormsg=fill_GUI(PlotParam,hview_field); |
---|
[204] | 150 | end |
---|
| 151 | ViewFieldData=get(hview_field,'UserData'); |
---|
[429] | 152 | haxes=findobj(hview_field,'tag','axes3'); |
---|
| 153 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
| 154 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
| 155 | pos_table=get(h_TableDisplay,'Position'); |
---|
| 156 | pos=get(hview_field,'Position'); |
---|
| 157 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
| 158 | drawnow |
---|
| 159 | set(hview_field,'UserData',ViewFieldData);% restore the previously stored GUI position after GUI resizing |
---|
[681] | 160 | elseif isfield(ViewFieldData,'GUISize') |
---|
[429] | 161 | set(hview_field,'Position',ViewFieldData.GUISize) |
---|
| 162 | end |
---|
[204] | 163 | else |
---|
[511] | 164 | UvData.PlotAxes=ProjData; |
---|
[625] | 165 | [PlotType,PlotParam]=plot_field(ProjData,hhuvmat.PlotAxes,read_GUI(huvmat));%update an existing field plot |
---|
[608] | 166 | errormsg=fill_GUI(PlotParam,huvmat); |
---|
[204] | 167 | end |
---|
| 168 | end |
---|
[650] | 169 | set(hhuvmat.CheckViewField,'Value',1);% |
---|
[701] | 170 | set(hhuvmat.CheckEditObject,'Value',1);% |
---|
| 171 | set(hhuvmat.MenuObject,'checked','off'); %desactivate object creation mode |
---|
[650] | 172 | set(hhuvmat.CheckEditObject,'Enable','on');% |
---|
[625] | 173 | set(get(h_set_object,'children'),'Enable','on') |
---|
[204] | 174 | end |
---|
[625] | 175 | UvData.ProjObject{IndexObj}=ObjectData; |
---|
| 176 | if isfield(UvData.ProjObject{IndexObj},'CreateMode') |
---|
| 177 | UvData.ProjObject{IndexObj}=rmfield(UvData.ProjObject{IndexObj},'CreateMode');%remove createMode to mark the object as finished |
---|
| 178 | end |
---|
[714] | 179 | set(hcurrentfig,'Pointer',pointer)% % revert the pointer shape to allow further mouse action |
---|
[444] | 180 | else |
---|
[625] | 181 | test_drawing=1;%allow continuation of drawing object |
---|
| 182 | AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the next current origin |
---|
[444] | 183 | end |
---|
[625] | 184 | % UvData.ProjObject{IndexObj}=ObjectData; |
---|
[204] | 185 | hother=findobj('Tag','deformpoint');%find all the deformpoints |
---|
[444] | 186 | set(hother,'Color','b');%reset all the deformpoints in 'blue' |
---|
[204] | 187 | end |
---|
| 188 | |
---|
[625] | 189 | %% creation or update of a zoom sub-plot |
---|
| 190 | if CheckZoomFig && isequal(get(hcurrentfig,'SelectionType'),'normal')&&...%if left button has been pressed |
---|
| 191 | ~isempty(CurrentOrigin) && ~isequal(CurrentOrigin(1),xy(1,1)) && ~isequal(CurrentOrigin(2),xy(1,2))%if mouse moved in x and y since presed down |
---|
[622] | 192 | hparentfig=hcurrentfig; |
---|
[204] | 193 | %open or update a new zoom figure if a rectangle has been drawn |
---|
[625] | 194 | if ishandle(hcurrentaxes); |
---|
[204] | 195 | if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom) |
---|
[625] | 196 | %PosRect=get(AxeData.CurrentRectZoom,'Position'); |
---|
[204] | 197 | if isfield(AxeData,'CurrentVec') && ~isempty(AxeData.CurrentVec) && ishandle(AxeData.CurrentVec) |
---|
| 198 | delete(AxeData.CurrentVec) |
---|
| 199 | end |
---|
[625] | 200 | if ~testsubplot% if we are not already on a zoom plot |
---|
| 201 | hfig2=findobj(allchild(0),'Tag','zoom_fig'); |
---|
| 202 | if isempty(hfig2)% create zoom sub plot if absent |
---|
| 203 | hfig2=figure('name',['zoom_' FigTag],'tag','zoom_fig');%create new figure (unit='pixels' by default) |
---|
| 204 | set(0,'Unit','pixels') |
---|
| 205 | FigPos=get(hfig2,'Position');%get the standard width and height of the fig |
---|
| 206 | ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right |
---|
| 207 | Left=ScreenSize(3)- FigPos(3)-40; %right edge close to the right, with margin=40 |
---|
| 208 | Bottom=ScreenSize(4)-FigPos(4)-40; %put fig at top right |
---|
| 209 | FigPos(1:2)=[Left Bottom]; |
---|
| 210 | set(hfig2,'Position',FigPos);% put the zoom fig close to the upper right of the screen |
---|
| 211 | map=colormap(hcurrentaxes); |
---|
| 212 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 213 | set(hfig2,'KeyPressFcn',{@keyboard_callback,handles})%set keyboard action function |
---|
| 214 | set(hfig2,'WindowButtonMotionFcn',{@mouse_motion,handles})%set mouse action function |
---|
| 215 | set(hfig2,'WindowButtonDownFcn',{@mouse_down})%set mouse click action function |
---|
| 216 | set(hfig2,'WindowButtonUpFcn',{@mouse_up,handles}) |
---|
| 217 | else |
---|
| 218 | zoom_axes=findobj(hfig2,'Type','axes');%delete existing axes |
---|
| 219 | axes(zoom_axes);%make the zoom axes apparent |
---|
| 220 | delete(zoom_axes) |
---|
| 221 | end |
---|
| 222 | set(hfig2,'DeleteFcn',{@close_fig,AxeData.CurrentRectZoom}) |
---|
| 223 | set(hfig2,'UserData',AxeData.CurrentRectZoom)% record the parent object (zoom rectangle) in the new fig |
---|
| 224 | AxeData.ZoomAxes=copyobj(hcurrentaxes,hfig2); %copy the current graph axes to the zoom figure |
---|
[622] | 225 | hrect_zoom=findobj(AxeData.ZoomAxes,'Tag','rect_zoom');%find and delete the copy of the rect_zoom rectangle |
---|
| 226 | delete(hrect_zoom) |
---|
[204] | 227 | hcol=findobj(hparentfig,'Tag','Colorbar'); %look for colorbar axes |
---|
| 228 | if ~isempty(hcol) |
---|
| 229 | hcol_new=colorbar; |
---|
| 230 | YTick=get(hcol,'YTick'); |
---|
| 231 | YTicklabel=get(hcol,'Yticklabel'); |
---|
| 232 | colbarlim=get(hcol,'YLim'); |
---|
| 233 | newcolbarlim=get(hcol_new,'YLim'); |
---|
| 234 | scale_bar=(newcolbarlim(2)-newcolbarlim(1))/(colbarlim(2)-colbarlim(1)); |
---|
| 235 | YTick_rescaled=newcolbarlim(1)+scale_bar*(YTick-colbarlim(1)); |
---|
| 236 | set(hcol_new,'YTick',YTick_rescaled); |
---|
| 237 | set(hcol_new,'Yticklabel',YTicklabel); |
---|
| 238 | end |
---|
[625] | 239 | ChildAxeData=get(AxeData.ZoomAxes,'UserData'); |
---|
| 240 | end |
---|
| 241 | ChildAxeData.CurrentOrigin=[];% forget the current origin |
---|
[221] | 242 | ChildAxeData.CurrentRectZoom=[]; % no rect zoom in the new window |
---|
| 243 | ChildAxeData.Drawing='off'; |
---|
[625] | 244 | ChildAxeData.ParentAxes=hcurrentaxes; |
---|
| 245 | ChildAxeData.ParentRect=AxeData.CurrentRectZoom;%set the rectangle drawing as a 'parent' associated to the new axe |
---|
| 246 | if xy(1,1)>CurrentOrigin(1) |
---|
| 247 | set(AxeData.ZoomAxes,'Xlim',[CurrentOrigin(1) xy(1,1)]) |
---|
| 248 | else |
---|
| 249 | set(AxeData.ZoomAxes,'Xlim',[xy(1,1) CurrentOrigin(1)]) |
---|
| 250 | end |
---|
| 251 | if xy(1,2)>CurrentOrigin(2) |
---|
| 252 | set(AxeData.ZoomAxes,'Ylim',[CurrentOrigin(2) xy(1,2)]) |
---|
| 253 | else |
---|
| 254 | set(AxeData.ZoomAxes,'Ylim',[xy(1,2) CurrentOrigin(2)]) |
---|
| 255 | end |
---|
[204] | 256 | set(AxeData.ZoomAxes,'UserData',ChildAxeData);%update the AxeData of the new axes |
---|
| 257 | end |
---|
| 258 | end |
---|
| 259 | end |
---|
| 260 | |
---|
[210] | 261 | %% zoom in or out by a factor 2 if no new figure is created |
---|
[625] | 262 | if CheckZoom |
---|
| 263 | if testsubplot |
---|
| 264 | haxes=gca;% zoom on a zoom sub-plot |
---|
| 265 | else |
---|
| 266 | haxes=hcurrentaxes;% zoom on the main plot |
---|
| 267 | end |
---|
| 268 | % xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates |
---|
| 269 | xlim=get(haxes,'XLim'); |
---|
| 270 | ylim=get(haxes,'YLim'); |
---|
[483] | 271 | % if left mouse button has been pressed, zoom in by a factor of 2 |
---|
[625] | 272 | if isequal(get(gcf,'SelectionType'),'normal');%if left button has been pressed, zoom in by a factor of 2 |
---|
| 273 | PlotBoxAspectRatio=get(haxes,'PlotBoxAspectRatio'); |
---|
[483] | 274 | yoverx=PlotBoxAspectRatio(2)/PlotBoxAspectRatio(1); |
---|
| 275 | if yoverx <2 |
---|
| 276 | xlim(1)=0.5*xy(1,1)+0.5*xlim(1); |
---|
| 277 | xlim(2)=0.5*xy(1,1)+0.5*xlim(2);%double the field whith the middle at the selected points |
---|
[625] | 278 | set(haxes,'XLim',xlim) |
---|
[483] | 279 | end |
---|
| 280 | if yoverx >0.5 |
---|
| 281 | ylim(2)=0.5*xy(1,2)+0.5*ylim(2); |
---|
| 282 | ylim(1)=0.5*xy(1,2)+0.5*ylim(1); |
---|
[625] | 283 | set(haxes,'YLim',ylim) |
---|
[483] | 284 | end |
---|
| 285 | |
---|
| 286 | % if right mouse button has been pressed, zoom out by a factor of 2 |
---|
[221] | 287 | else |
---|
[252] | 288 | xlim(1)=2*xlim(1)-xy(1,1);% reverse of the zoom on action |
---|
[204] | 289 | xlim(2)=2*xlim(2)-xy(1,1); |
---|
| 290 | ylim(1)=2*ylim(1)-xy(1,2); |
---|
| 291 | ylim(2)=2*ylim(2)-xy(1,2); |
---|
[625] | 292 | % adjust the zoom out to the available field |
---|
| 293 | if ~testsubplot && isfield(AxeData,'RangeX')&& isfield(AxeData,'RangeY') |
---|
[204] | 294 | xlim(1)=max(AxeData.RangeX(1),xlim(1)); |
---|
| 295 | xlim(2)=min(AxeData.RangeX(2),xlim(2)); |
---|
| 296 | ylim(1)=max(AxeData.RangeY(1),ylim(1)); |
---|
| 297 | ylim(2)=min(AxeData.RangeY(2),ylim(2)); |
---|
[252] | 298 | if ylim(1)>=ylim(2)|| xlim(1)>=xlim(2) |
---|
| 299 | xlim=AxeData.RangeX; |
---|
| 300 | ylim=AxeData.RangeY; |
---|
| 301 | end |
---|
[483] | 302 | % desactivate the zoom if the full field is visible within the axes |
---|
[204] | 303 | if isequal(xlim,AxeData.RangeX) && isequal(ylim,AxeData.RangeY) |
---|
[292] | 304 | set(hhuvmat.CheckZoom,'Value',0) |
---|
[625] | 305 | % set(hhuvmat.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[292] | 306 | set(hhuvmat.CheckFixLimits,'Value',0) |
---|
[625] | 307 | % set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[204] | 308 | end |
---|
| 309 | end |
---|
[625] | 310 | set(haxes,'XLim',xlim) |
---|
| 311 | set(haxes,'YLim',ylim) |
---|
[204] | 312 | %test whther zoom out is operating (to inactivate AxedAta |
---|
| 313 | if ~isfield(AxeData,'CurrentXLim')|| ~isequal(xlim,AxeData.CurrentXLim) |
---|
| 314 | AxeData.CurrentXLim=xlim;% |
---|
| 315 | end |
---|
| 316 | end |
---|
[625] | 317 | %if isfield(AxeData,'LimEditBox')&& AxeData.LimEditBox% update display of the GUI containing the axis (uvmat or view_field) |
---|
| 318 | if testsubplot |
---|
| 319 | set(AxeData.CurrentRectZoom,'Position',[xlim(1) ylim(1) xlim(2)-xlim(1) ylim(2)-ylim(1)]) |
---|
| 320 | else |
---|
[292] | 321 | set(hhcurrentfig.num_MinX,'String',num2str(xlim(1))) |
---|
| 322 | set(hhcurrentfig.num_MaxX,'String',num2str(xlim(2))) |
---|
| 323 | set(hhcurrentfig.num_MinY,'String',num2str(ylim(1))) |
---|
| 324 | set(hhcurrentfig.num_MaxY,'String',num2str(ylim(2))) |
---|
[204] | 325 | end |
---|
| 326 | end |
---|
| 327 | |
---|
| 328 | %% editing calibration point |
---|
[625] | 329 | if ~CheckZoom && isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'calibration') |
---|
[204] | 330 | h_geometry_calib=findobj(allchild(0),'tag','geometry_calib'); %find the geomterty_calib GUI |
---|
| 331 | if ~isempty(h_geometry_calib) |
---|
| 332 | hh_geometry_calib=guidata(h_geometry_calib); |
---|
[660] | 333 | edit_test=get(hh_geometry_calib.CheckEnableMouse,'Value'); |
---|
[625] | 334 | hh=findobj(hcurrentaxes,'tag','calib_points');%look for handle of calibration points |
---|
[204] | 335 | if ~isempty(hh) && edit_test |
---|
| 336 | index_point=get(hh,'UserData'); |
---|
| 337 | set(hh,'UserData',[])%remove edit mode |
---|
| 338 | h_ListCoord=hh_geometry_calib.ListCoord; %handles of the coordinate list |
---|
[657] | 339 | Coord=get(h_ListCoord,'Data'); |
---|
| 340 | Coord(index_point,4)=xy(1,1); |
---|
| 341 | Coord(index_point,5)=xy(1,2); |
---|
| 342 | set(h_ListCoord,'Data',Coord) |
---|
| 343 | set(hh,'XData',Coord(:,4)) |
---|
| 344 | set(hh,'YData',Coord(:,5)) |
---|
[204] | 345 | end |
---|
| 346 | end |
---|
| 347 | end |
---|
| 348 | |
---|
| 349 | %% finalising ruler |
---|
[625] | 350 | if test_ruler && ~isempty(xy) |
---|
[738] | 351 | %set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat |
---|
[625] | 352 | xy=get(hcurrentaxes,'CurrentPoint');% get the current mouse coordinates |
---|
[483] | 353 | RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)];% append the recorded ruler origin to the current mouse coordinates |
---|
[204] | 354 | RulerCoord=diff(RulerCoord,1);% coordiante difference between segment end and beginning |
---|
| 355 | RulerCoord=RulerCoord(1)+i*RulerCoord(2); |
---|
| 356 | distance=abs(RulerCoord); |
---|
| 357 | azimuth=(180/pi)*angle(RulerCoord); |
---|
| 358 | msgbox_uvmat('RULER','',['length: ' num2str(distance,3) ', angle(degrees): ' num2str(azimuth,3)]) |
---|
| 359 | delete(AxeData.RulerHandle)%delete the ruler graphic object |
---|
| 360 | AxeData=rmfield(AxeData,'RulerHandle');%remove the ruler handle in AxeData |
---|
| 361 | AxeData.Drawing='off';%exit the ruler drawing mode |
---|
| 362 | end |
---|
| 363 | |
---|
| 364 | |
---|
| 365 | %% update |
---|
| 366 | if test_drawing==0 |
---|
| 367 | AxeData.Drawing='off';%stop current drawing action |
---|
| 368 | end |
---|
[625] | 369 | set(hcurrentaxes,'UserData',AxeData); |
---|
[204] | 370 | if ~isempty(huvmat) |
---|
| 371 | set(huvmat,'UserData',UvData); |
---|
| 372 | end |
---|
| 373 | |
---|
[625] | 374 | %------------------------------------------------------------------------ |
---|
| 375 | % --- 'close_fig': function activated when a zoom figure is closed |
---|
| 376 | %------------------------------------------------------------------------ |
---|
| 377 | function close_fig(ggg,eventdata,hparent) |
---|
[204] | 378 | |
---|
[625] | 379 | hfig=get(get(hparent,'parent'),'parent'); |
---|
| 380 | hbutton=findobj(hfig,'Tag','CheckZoomFig'); |
---|
| 381 | if ~isempty(hbutton) |
---|
| 382 | set(hbutton,'Value',0)% desactivate the zoom fig option |
---|
| 383 | end |
---|
| 384 | delete(hparent) % delete the rectangle showing the zoom graph in the parent fig |
---|
| 385 | |
---|