Changeset 622 for trunk/src/mouse_up.m
- Timestamp:
- Apr 29, 2013, 11:35:27 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mouse_up.m
r608 r622 23 23 24 24 function mouse_up(hObject,eventdata,handles) 25 %MouseAction='none'; %default 26 test_zoom=0;%default 25 27 26 test_ruler=0;%default 28 currentfig=hObject;29 tagfig=get(currentfig,'tag');27 hcurrentfig=hObject; 28 fig_tag=get(hcurrentfig,'tag'); 30 29 currentaxes=gca; %store the current axes handle 31 30 AxeData=get(currentaxes,'UserData'); 31 CurrentOrigin=[]; 32 32 if isfield(AxeData,'CurrentOrigin') 33 33 CurrentOrigin=AxeData.CurrentOrigin; … … 40 40 testsubplot=1; 41 41 else 42 hhcurrentfig=guidata( currentfig);%the current figure is a GUI (uvmat or view_field)42 hhcurrentfig=guidata(hcurrentfig);%the current figure is a GUI (uvmat or view_field) 43 43 testsubplot=0; 44 44 end … … 59 59 PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object 60 60 IndexObj=PlotData.IndexObj; 61 ObjectData=UvData. Object{IndexObj};61 ObjectData=UvData.ProjObject{IndexObj}; 62 62 check_multiple=0; 63 63 % ending translation … … 79 79 switch ObjectData.Type 80 80 case {'line'} 81 if isfield(AxeData,'ObjectCoord') && size(AxeData.ObjectCoord,2)==382 xy(1,3)=AxeData.ObjectCoord(1,3); % z coordinate of the mouse: to generalise ...81 if size(ObjectData.Coord,1)==1 % this is the mouse up for the first point, continue until next click 82 check_multiple=1; 83 83 else 84 xy(1,3)=0; % z coordinate set to 0 by default 85 end 86 % if ~isequal(ObjectData.Coord,xy(1,:)) 87 if ~isequal(ObjectData.Coord(end,1:2),xy(1,1:2)) 88 ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the second point of the line if different from the first one 89 end 90 % end 84 %ObjectData.Coord=[ObjectData.Coord ;CurrentOrigin];% append the second point of the line (the last pointed position during mouse down) 85 end 91 86 case {'rectangle','ellipse','volume'} 92 XYData=AxeData.CurrentOrigin; 93 ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate 94 ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2; 95 ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width 96 ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height 87 % if size(ObjectData.Coord,1)==1 % this is the mouse up for the first point, continue until next click 88 % check_multiple=1; 89 % else 90 ObjectData.Coord=(CurrentOrigin+xy(1,1:2))/2;% keep only the first point coordinate 91 ObjectData.RangeX=abs(ObjectData.Coord(1,1)-xy(1,1));%rectangle width 92 ObjectData.RangeY=abs(ObjectData.Coord(1,2)-xy(1,2));%rectangle height 93 if isequal(ObjectData.RangeX,0)||isequal(ObjectData.RangeY,0) 94 check_multiple=1;% pass to next mous up if width of height=0 95 end 96 % ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate 97 % ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2; 98 % ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width 99 % ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height 100 % end 97 101 case 'plane' %case of 'plane' 98 102 DX=(xy(1,1)-ObjectData.Coord(1,1)); … … 106 110 end 107 111 otherwise 108 check_multiple=1; 112 check_multiple=1; 109 113 end 110 114 end … … 120 124 121 125 %stop drawing and plot projected field if the object manipulation is finished 122 if check_multiple==0 || isequal(get( currentfig,'SelectionType'),'alt')126 if check_multiple==0 || isequal(get(hcurrentfig,'SelectionType'),'alt') 123 127 AxeData.CurrentOrigin=[]; %suppress the current origin 124 % if isequal(ObjectData.Type,'line') && size(ObjectData.Coord,1)>=2 125 % % AxeData.Drawing='off'; 126 % % set(currentaxes,'UserData',AxeData); 127 % 128 % end 128 hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(fig_tag); 129 if ~isempty(hObject) 130 ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')}; 131 AxeData.CurrentObject=plot_object(ObjectData,ProjObject,hobject,'m');%draw the object and its handle becomes AxeData.CurrentObject 132 end 133 %% 129 134 if ~isempty(ObjectData) 130 % testmask=0;131 % hmask=findobj(huvmat,'Tag','makemask');132 % if ~isempty(hmask)133 % testmask=get(hmask,'Value');134 % end135 136 135 % plot the field projected on the object 137 136 ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData 138 137 if ~isempty(ProjData) 139 if strcmp( tagfig,'uvmat')% uvmat plot selected, projection plot seen in view_field138 if strcmp(fig_tag,'uvmat')% uvmat plot selected, projection plot seen in view_field 140 139 hview_field=findobj(allchild(0),'tag','view_field'); 141 140 if isempty(hview_field) … … 144 143 hhview_field=guidata(hview_field); 145 144 [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%update an existing plot in view_field 146 %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object147 145 errormsg=fill_GUI(PlotParam,hview_field); 148 146 end 149 147 ViewFieldData=get(hview_field,'UserData'); 150 % ViewFieldData.PlotAxes=ProjData;151 148 haxes=findobj(hview_field,'tag','axes3'); 152 149 if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) … … 164 161 [PlotType,PlotParam]=plot_field(ProjData,hhuvmat.PlotAxes,read_GUI(hhuvmat));%update an existing field plot 165 162 errormsg=fill_GUI(PlotParam,huvmat); 166 % write_plot_param(hhuvmat,PlotParam); %update the display of plotting parameters for the current object167 163 end 168 164 end … … 176 172 else 177 173 test_drawing=1;%allow continuation of drawing object 178 AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the next current origin179 end 180 UvData. Object{IndexObj}=ObjectData;174 AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the next current origin 175 end 176 UvData.ProjObject{IndexObj}=ObjectData; 181 177 hother=findobj('Tag','deformpoint');%find all the deformpoints 182 178 set(hother,'Color','b');%reset all the deformpoints in 'blue' … … 184 180 185 181 %% creation of a new zoom plot 186 if isequal(get( currentfig,'SelectionType'),'normal');%if left button has been pressed187 hparentfig= currentfig;182 if isequal(get(hcurrentfig,'SelectionType'),'normal');%if left button has been pressed 183 hparentfig=hcurrentfig; 188 184 %open or update a new zoom figure if a rectangle has been drawn 189 185 if ishandle(currentaxes); … … 196 192 hfig2=figure;%create new figure 197 193 set(hfig2,'name','zoom') 198 set(hfig2,'Units','normalized') 199 set(hfig2,'Position',[0.2 0.33 0.6 0.6]); 194 set(0,'Unit','pixels') 195 set(hfig2,'Unit','pixels') 196 FigPos=get(hfig2,'Position'); 197 ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right 198 Left=ScreenSize(3)- FigPos(3)-40; %right edge close to the right, with margin=40 199 Bottom=ScreenSize(4)-FigPos(4)-40; %put fig at top right 200 FigPos(1:2)=[Left Bottom]; 201 set(hfig2,'Position',FigPos); 200 202 map=colormap(currentaxes); 201 203 colormap(map);%transmit the current colormap to the zoom fig 202 set(hfig2,'Position',[0.2 0.33 0.6 0.6]);203 set(hfig2,'Unit','normalized')204 204 set(hfig2,'KeyPressFcn',{@keyboard_callback,handles})%set keyboard action function 205 205 set(hfig2,'WindowButtonMotionFcn',{@mouse_motion,handles})%set mouse action function … … 209 209 set(hfig2,'UserData',AxeData.CurrentRectZoom)% record the parent object (zoom rectangle) in the new fig 210 210 AxeData.ZoomAxes=copyobj(currentaxes,hfig2); %copy the current graph axes to the zoom figure 211 hrect_zoom=findobj(AxeData.ZoomAxes,'Tag','rect_zoom');%find and delete the copy of the rect_zoom rectangle 212 delete(hrect_zoom) 211 213 ChildAxeData=get(AxeData.ZoomAxes,'UserData'); 212 214 if isfield(ChildAxeData,'ParentGUI') 213 215 ChildAxeData=rmfield(ChildAxeData,'ParentGUI');%no parent GUI, e.g. uvmat, for the new plot 214 216 end 215 %figure(hfig2)216 %set(0,'CurrentFigure',hfig2)% the zoom figure becomes the current figure217 217 set(AxeData.ZoomAxes,'Position',[0.1300 0.1100 0.7750 0.8150])% standard axes position on a figure 218 218 hcol=findobj(hparentfig,'Tag','Colorbar'); %look for colorbar axes … … 247 247 ylim=get(currentaxes,'YLim'); 248 248 % if left mouse button has been pressed, zoom in by a factor of 2 249 if isequal(get( currentfig,'SelectionType'),'normal');%if left button has been pressed, zoom in by a factor of 2249 if isequal(get(hcurrentfig,'SelectionType'),'normal');%if left button has been pressed, zoom in by a factor of 2 250 250 PlotBoxAspectRatio=get(currentaxes,'PlotBoxAspectRatio'); 251 251 yoverx=PlotBoxAspectRatio(2)/PlotBoxAspectRatio(1); … … 346 346 347 347 %% display the data of the current object selected with the mouse right click 348 if isequal(get( currentfig,'SelectionType'),'alt') && ~test_zoom && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create'))348 if isequal(get(hcurrentfig,'SelectionType'),'alt') && ~test_zoom && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create')) 349 349 hother=findobj('Tag','proj_object');%find all the proj objects 350 350 nbselect=0; … … 368 368 end 369 369 % if ((nbselect==0) && isequal(get(currentobj,'Type'),'axes')) || isequal(currentobj,huvmat) 370 % currentfig=get(currentobj,'parent');371 % figname=get( currentfig,'name');370 % hcurrentfig=get(currentobj,'parent'); 371 % figname=get(hcurrentfig,'name'); 372 372 % eval(['global Data_' figname]) 373 373 % eval(['Data_' figname '=get(currentobj,''UserData'')']);
Note: See TracChangeset
for help on using the changeset viewer.