Changeset 156 for trunk/src/mouse_up.m
- Timestamp:
- Dec 19, 2010, 10:11:04 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mouse_up.m
r154 r156 23 23 24 24 function mouse_up(hObject,eventdata,handles) 25 MouseAction='none'; %default25 %MouseAction='none'; %default 26 26 test_zoom=0;%default 27 test_ruler=0;%default 27 28 currentfig=hObject; 28 29 tagfig=get(currentfig,'tag'); 29 30 hhcurrentfig=guidata(currentfig); 30 31 test_zoom=get(hhcurrentfig.zoom,'Value'); 31 if ~exist('handles','var') 32 handles=get(gcbo,'UserData'); 33 end 32 33 % if ~exist('handles','var') 34 % handles=get(gcbo,'UserData'); 35 % end 34 36 huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle 35 37 if ~isempty(huvmat) 36 38 hhuvmat=guidata(huvmat); 37 39 UvData=get(huvmat,'UserData'); 38 if isfield(UvData,'MouseAction')39 MouseAction=UvData.MouseAction;% set the mouse action (edit, create objects...)40 end41 % test_zoom=get(hhuvmat.zoom,'Value'); 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 42 44 end 43 45 currentfig=hObject; … … 48 50 49 51 %% finalize the fabrication or the translation/deformation of an object and plot the corresponding projected field 50 if ~isempty(huvmat) & isfield(AxeData,'Drawing') & ~isequal(AxeData.Drawing,'off')& isfield(AxeData,'CurrentObject')...51 & ishandle(AxeData.CurrentObject)52 if ~isempty(huvmat) && isfield(AxeData,'Drawing') && ~isequal(AxeData.Drawing,'off') && isfield(AxeData,'CurrentObject')... 53 && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject) 52 54 xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 53 55 PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object … … 131 133 % PlotHandles=[];%do not project data on the object during mask creation 132 134 % else 133 PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters135 % PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters 134 136 % end 135 UvData.Object=update_obj(UvData,IndexObj,ObjectData,PlotHandles); 136 if strcmp(tagfig,'uvmat')% uvmat plot selected, projection plot seen on view_field 137 % if strcmp(projview,'view_field') 138 hview_field=findobj(allchild(0),'tag','view_field'); 139 ViewFieldData=get(hview_field,'UserData'); 140 ViewFieldData.axes3=ObjectData; 141 set(hview_field,'UserData',ViewFieldData) 142 else 143 UvData.axes3=ObjectData; 144 end 145 if isfield(UvData.Object{IndexObj},'PlotParam') 146 write_plot_param(PlotHandles,UvData.Object{IndexObj}.PlotParam); %update the display of plotting parameters for the current object 147 end 148 set(hhuvmat.edit,'BackgroundColor',[1 1 0]);% paint the edit text in yellow 149 set(hhuvmat.edit,'Value',1);% 150 set(hhuvmat.edit,'Enable','on');% 137 138 %% update the object representation 139 ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj}.DisplayHandle_uvmat; 140 ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj}.DisplayHandle_view_field; 141 UvData.Object{IndexObj}=ObjectData;%update the current object properties 142 hhuvmat=guidata(huvmat); 143 IndexObj_1=get(hhuvmat.list_object_1,'Value'); 144 IndexObj_2=get(hhuvmat.list_object_2,'Value'); 145 UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2); 146 147 %% plot the field projected on the object and store it on the corresponding figure 148 ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData 149 if ~isempty(ProjData) 150 if strcmp(tagfig,'uvmat')% uvmat plot selected, projection plot seen on view_field 151 % if strcmp(projview,'view_field') 152 hview_field=findobj(allchild(0),'tag','view_field'); 153 if isempty(hview_field) 154 hview_field=view_field; 155 end 156 ViewFieldData=get(hview_field,'UserData'); 157 ViewFieldData.axes3=ProjData; 158 set(hview_field,'UserData',ViewFieldData) 159 PlotHandles=guidata(hview_field); 160 else 161 UvData.axes3=ProjData; 162 PlotHandles=hhuvmat; 163 end 164 [PlotType,PlotParam]=plot_field(ProjData,PlotHandles.axes3,PlotHandles);%update an existing field plot 165 write_plot_param(PlotHandles,PlotParam); %update the display of plotting parameters for the current object 166 end 167 % if isfield(UvData.Object{IndexObj},'PlotParam') 168 % write_plot_param(PlotHandles,UvData.Object{IndexObj}.PlotParam); %update the display of plotting parameters for the current object 169 % end 170 set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow 171 set(hhuvmat.edit_object,'Value',1);% 172 set(hhuvmat.edit_object,'Enable','on');% 151 173 set(hhuvmat.MenuEditObject,'Enable','on');% 152 174 set(hhuvmat.MenuEdit,'Enable','on');% 153 UvData.MouseAction='edit_object'; % set the edit button to 'on'154 175 end 155 176 else … … 171 192 %open or update a new zoom figure if a rectangle has been drawn 172 193 if ishandle(currentaxes); 173 if isfield(AxeData,'CurrentRectZoom') & ishandle(AxeData.CurrentRectZoom)194 if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom) 174 195 PosRect=get(AxeData.CurrentRectZoom,'Position'); 175 if isfield(AxeData,'CurrentVec') & ishandle(AxeData.CurrentVec)196 if isfield(AxeData,'CurrentVec') && ~isempty(AxeData.CurrentVec) && ishandle(AxeData.CurrentVec) 176 197 delete(AxeData.CurrentVec) 177 198 end … … 182 203 map=colormap(currentaxes); 183 204 colormap(map);%transmit the current colormap to the zoom fig 184 get(handles.RootFile,'String')185 205 set(hfig2,'Position',[0.2 0.33 0.6 0.6]); 186 206 if test_replot==0 … … 288 308 289 309 %% editing calibration point 290 if ~test_zoom && strcmp(MouseAction,'calib') 291 h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI 292 hh_geometry_calib=guidata(h_geometry_calib); 293 edit_test=get(hh_geometry_calib.edit_append,'Value'); 294 hh=findobj(currentaxes,'Tag','calib_points');%look for handle of calibration points 295 if ~isempty(hh) && edit_test 296 index_point=get(hh,'UserData'); 297 set(hh,'UserData',[])%remove edit mode 298 h_ListCoord=hh_geometry_calib.ListCoord; %handles of the coordinate list 299 Coord=get(h_ListCoord,'String'); 300 data=read_geometry_calib(Coord); 301 % val=get(h_ListCoord,'Value'); 302 xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 303 data.Coord(index_point,4)=xy(1,1); 304 data.Coord(index_point,5)=xy(1,2); 305 for ipoint=1:size(data.Coord,1) 306 for jcoord=1:5 307 Coord_cell{ipoint,jcoord}=num2str(data.Coord(ipoint,jcoord),4);%display coordiantes with 4 digits 308 end 310 if ~test_zoom && isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'calibration') 311 h_geometry_calib=findobj(allchild(0),'tag','geometry_calib'); %find the geomterty_calib GUI 312 if ~isempty(h_geometry_calib) 313 hh_geometry_calib=guidata(h_geometry_calib); 314 edit_test=get(hh_geometry_calib.edit_append,'Value'); 315 hh=findobj(currentaxes,'tag','calib_points');%look for handle of calibration points 316 if ~isempty(hh) && edit_test 317 index_point=get(hh,'UserData'); 318 set(hh,'UserData',[])%remove edit mode 319 h_ListCoord=hh_geometry_calib.ListCoord; %handles of the coordinate list 320 Coord=get(h_ListCoord,'String'); 321 data=read_geometry_calib(Coord); 322 % val=get(h_ListCoord,'Value'); 323 xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 324 data.Coord(index_point,4)=xy(1,1); 325 data.Coord(index_point,5)=xy(1,2); 326 for ipoint=1:size(data.Coord,1) 327 for jcoord=1:5 328 Coord_cell{ipoint,jcoord}=num2str(data.Coord(ipoint,jcoord),4);%display coordiantes with 4 digits 329 end 330 end 331 Tabchar=cell2tab(Coord_cell,' | '); 332 Tabchar=[Tabchar ;{'......'}]; 333 set(h_ListCoord,'String',Tabchar) 334 % coord_str=Coord{index_point}; %current line (string) 335 % k=findstr('|',coord_str);%find separator indices on the string 336 % blanks=blank 337 % xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 338 % if numel(k)>=3 339 % 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 340 % else 341 % coord_str=[ ' | ' ' | ' ' | ' num2str(xy(1,1),4) ' | ' num2str(xy(1,2),4)]; 342 % end 343 % Coord{index_point}=coord_str; 344 % set(h_ListCoord,'String',Coord) 345 % data=read_geometry_calib(Coord);%transform char cell to numbers 346 set(hh,'XData',data.Coord(:,4)) 347 set(hh,'YData',data.Coord(:,5)) 309 348 end 310 Tabchar=cell2tab(Coord_cell,' | ');311 Tabchar=[Tabchar ;{'......'}];312 set(h_ListCoord,'String',Tabchar)313 % coord_str=Coord{index_point}; %current line (string)314 % k=findstr('|',coord_str);%find separator indices on the string315 % blanks=blank316 % xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates317 % if numel(k)>=3318 % 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 coord319 % else320 % coord_str=[ ' | ' ' | ' ' | ' num2str(xy(1,1),4) ' | ' num2str(xy(1,2),4)];321 % end322 % Coord{index_point}=coord_str;323 % set(h_ListCoord,'String',Coord)324 % data=read_geometry_calib(Coord);%transform char cell to numbers325 set(hh,'XData',data.Coord(:,4))326 set(hh,'YData',data.Coord(:,5))327 349 end 328 350 end … … 330 352 331 353 %% finalising ruler 332 if strcmp(MouseAction,'ruler') 333 UvData.MouseAction='none'; 334 UvData=rmfield(UvData,'RulerHandle'); 335 xy=get(currentaxes,'CurrentPoint'); 336 RulerCoord=[UvData.RulerCoord ;xy(1,1:2)]; 337 set(huvmat,'UserData',UvData) 338 RulerCoord=diff(RulerCoord,1); 354 if test_ruler 355 set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat 356 xy=get(currentaxes,'CurrentPoint');% get the current mouse coordinates 357 RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)];% append the recorded ruler origin to the current mouse coordinates 358 RulerCoord=diff(RulerCoord,1);% coordiante difference between segment end and beginning 339 359 RulerCoord=RulerCoord(1)+i*RulerCoord(2); 340 360 distance=abs(RulerCoord); 341 361 azimuth=(180/pi)*angle(RulerCoord); 342 362 msgbox_uvmat('RULER','',['length: ' num2str(distance,3) ', angle(degrees): ' num2str(azimuth,3)]) 343 hruler=findobj(currentaxes,'Tag','ruler');344 delete(hruler)345 AxeData.Drawing='off';% stop current drawing a363 delete(AxeData.RulerHandle)%delete the ruler graphic object 364 AxeData=rmfield(AxeData,'RulerHandle');%remove the ruler handle in AxeData 365 AxeData.Drawing='off';%exit the ruler drawing mode 346 366 end 347 367
Note: See TracChangeset
for help on using the changeset viewer.