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