- Timestamp:
- Apr 29, 2013, 11:35:27 AM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/keyboard_callback.m
r342 r622 3 3 function keyboard_callback(hObject,eventdata,handleshaxes) 4 4 cur_axes=get(hObject,'CurrentAxes');%current plotting axes of the figure with handle hObject 5 if ~isempty(eventdata) && isnumeric(eventdata) 6 xx=eventdata; % keyboard_callback called by mouse_down 7 else 5 8 xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character 9 end 6 10 switch xx 7 11 case {29,28,30,31} %arrows for displacement -
trunk/src/mouse_down.m
r594 r622 23 23 24 24 function xy=mouse_down(hObject,eventdata) 25 AxeData=[];%default 26 FigData=get(hObject,'UserData'); 25 26 %% look for parameters set by the current figure (handle=input parameter hObject) 27 AxeData=[];%default data stored on the current axes 28 FigData=get(hObject,'UserData'); %default data stored on the current object 27 29 if ishandle(FigData)% case of a zoom plot, the handle of the parent rectangle is stored in UserData, its parent is the plotting axes of the rectangle 28 hcurrentfig=get(get(FigData,'parent'),'parent'); 30 hcurrentfig=get(get(FigData,'parent'),'parent');%handle of the current GUI: zoom plot 29 31 else 30 hcurrentfig=hObject;%usual plot 31 end 32 hcurrentfig=hObject; % handle of the current GUI: usual plot 33 end 34 hhcurrentfig=guidata(hcurrentfig);% tags of the children of the current GUI 35 CheckZoom=0; 36 if isfield(hhcurrentfig,'CheckZoom') && get(hhcurrentfig.CheckZoom,'Value');%test for zoom action, first priority 37 CheckZoom=1; 38 end 39 test_piv=isfield(FigData,'CivHandle'); 32 40 set(hcurrentfig,'Units','pixels') 33 GUI_pos=get(hcurrentfig,'Position');%position of the GUI series (in pixels) 34 set(hcurrentfig,'Units','normalized') 35 hhcurrentfig=guidata(hcurrentfig); 36 if isfield(hhcurrentfig,'CheckZoom') 37 test_zoom=get(hhcurrentfig.CheckZoom,'Value');%test for zoom action, first priority 38 else 39 test_zoom=0; 40 end 41 test_piv=isfield(FigData,'CivHandle'); 41 GUI_pos=get(hcurrentfig,'Position');%position of the GUI series on the screen (in pixels), used to position message boxes 42 set(hcurrentfig,'Units','normalized')% back to current unit for fig position 43 44 %% determine the currently selected items 45 hcurrentobject=gco;% current object handle (selected by the mouse) 46 fig_tag=get(hcurrentfig,'Tag'); 47 obj_tag=get(gco,'Tag');%tag of the currently selected object 48 xy=[];%default 49 xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo) 50 haxes=[]; 42 51 43 52 %% look for parameters set by the GUI uvmat … … 45 54 test_edit=0; 46 55 test_create=0; 47 huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls the option of mouse action56 huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls the option of mouse action 48 57 if ~isempty(huvmat) 49 58 hhuvmat=guidata(huvmat);%handles of elements in uvmat 50 59 UvData=get(huvmat,'UserData'); 51 60 test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler action, second priority; 52 test_edit=get(hhuvmat.edit_object,'Value');%test for object editing, third priority 53 test_edit_vect=get(hhuvmat.edit_vect,'Value');%test for vector editing, priority 4 54 % test_create=isequal(get(hhuvmat.MenuObject,'checked'),'on');% test for object creation, priority 5 55 % if test_create 56 test_create=0; 61 test_edit=get(hhuvmat.edit_object,'Value')&& (isequal(obj_tag,'proj_object')||isequal(obj_tag,'DeformPoint'));%test for object editing, third priority 57 62 hset_object=findobj(allchild(0),'tag','set_object'); 58 59 63 if ~isempty(hset_object) 60 64 hPLOT=findobj(hset_object,'tag','PLOT'); 61 65 test_create=strcmp(get(hPLOT,'enable'),'on') &&~test_edit;% create new object if set_object is in mode enable and uvmat not in mode 'edit_object' 62 66 end 63 67 test_edit_vect=get(hhuvmat.edit_vect,'Value') && ~test_create && ~(isequal(obj_tag,'proj_object')||isequal(obj_tag,'DeformPoint')) ;%test for vector editing, priority 4 64 68 test_cal=isequal(get(hhuvmat.MenuCalib,'checked'),'on');% test for calibration 65 69 if test_cal% test for calibration popints, priority 6 … … 75 79 end 76 80 77 %% determine the currently selected items 78 hcurrentobject=gco;% current object handle (selected by the mouse) 79 %hcurrentfig=hObject;% current figure handle 80 fig_tag=get(hcurrentfig,'Tag'); 81 tag_obj=get(gco,'Tag');%tag of the currently selected object 82 xy=[];%default 83 xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo) 81 %% loop on all the objects in the current figure (selected by the last mouse click) 84 82 hchildren=get(hObject,'Children');%handles of all objects in the current figure 85 haxes=[]; 86 87 %% loop on all the objects in the current figure (selected by the last mouse click) 88 output_str=''; 89 state_visible=get(hchildren,'Visible'); 90 check_visible=strcmp('on',state_visible);%=1 if visible='on', =0 otherwise 91 hchildren=hchildren(find(check_visible)); %kkep only the visible children 92 for ichild=1:length(hchildren) 93 hchild=hchildren(ichild); %handle of the current obj 94 obj_pos=get(hchild,'Position');%position of the object 95 if xy_fig(1) >=obj_pos(1) & xy_fig(2) >= obj_pos(2)& xy_fig(1) <=obj_pos(1)+obj_pos(3) & xy_fig(2) <= obj_pos(2)+obj_pos(4); 96 htype=get(hchild,'Type');%type of object child of the current figure 97 switch htype 98 %if the mouse is over an axis, look at the data 99 case 'axes' 100 y_lim=get(hchild,'YLim'); 101 x_lim=get(hchild,'XLim'); 102 haxes=hchild; 103 xy=get(hchild,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 104 % if xy(1,1)>x_lim(1) && xy(1,1)<x_lim(2) && xy(1,2)>y_lim(1) && xy(1,2)<y_lim(2) 105 AxeData=get(hchild,'UserData');% data attached to the axis 106 AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin 107 if test_edit_vect && ~isequal(tag_obj,'proj_object') & ~test_create 108 ivec=[]; 109 FigData=get(hcurrentfig,'UserData'); 110 tagaxes=get(hchild,'tag'); 111 if isfield(FigData,tagaxes) 112 Field=FigData.(tagaxes); 113 [CellVarIndex,NbDim,VarType]=find_field_cells(Field);%analyse the physical fields contained in Field 114 for icell=1:numel(CellVarIndex)%look for all physical fields 115 if NbDim(icell)==2 % select 2D field 116 if isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& ~isempty(VarType{icell}.coord_x) && ~isempty(VarType{icell}.coord_y)%case of unstructured data 117 eval(['X=Field.' Field.ListVarName{VarType{icell}.coord_x} ';']) 118 eval(['Y=Field.' Field.ListVarName{VarType{icell}.coord_y} ';']) 119 flag_vec=(X<(xy(1,1)+Field.CoordMesh/4) & X>(xy(1,1)-Field.CoordMesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse 120 (Y<(xy(1,2)+Field.CoordMesh/4) & Y>(xy(1,2)-Field.CoordMesh/4));%f 121 ivec=find(flag_vec,1);% search the (first) selected vector index ivec 122 end 123 end 83 check_visible=strcmp(get(hchildren,'Visible'),'on');% if visible='on', =0 otherwise 84 hchildren=hchildren(check_visible); %kkep only the visible children 85 PosChildren=get(hchildren,'Position');% set of object positions 86 if iscell(PosChildren)% only one child 87 PosLength=cellfun('length',PosChildren);% set of vector lengths for object positions 88 hchildren=hchildren(PosLength==4);% keep only objects with position defined by a 4 element vector 89 PosChildren=cell2mat(PosChildren(PosLength==4));% convert cells to matrix of positions 90 end 91 if size(PosChildren,2)~=4 92 return 93 end 94 xy_fig_mat=ones(size(PosChildren,1),1)*xy_fig;% mouse position set to a matrix 95 check_pos=xy_fig_mat >= PosChildren(:,1:2) & xy_fig_mat <= PosChildren(:,1:2)+PosChildren(:,3:4);% compare object to mouse position 96 ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse 97 hchild=hchildren(ind_object);% corresponding object handle 98 if isempty(hchild) 99 % if test_edit||test_create 100 % hPlotAxes=findobj(hcurrentfig,'Tag','PlotAxes'); 101 % if ~isempty( hPlotAxes) 102 % PosPlotAxes=get(hPlotAxes,'Position'); 103 % PosDiff(1)=xy_fig(1)-PosPlotAxes(1)-PosPlotAxes(3);% distance to the right axes edge 104 % PosDiff(2)=PosPlotAxes(1)-xy_fig(1);% distance to the left axes edge 105 % PosDiff(3)=xy_fig(2)-PosPlotAxes(1)-PosPlotAxes(3);% distance to the top axes edge 106 % PosDiff(4)=PosPlotAxes(2)-xy_fig(2);% distance to the low axes edge 107 % [tild,ind_sel]=max(PosDiff); 108 % list_arrow=[29 28 30 31]; 109 % arrow_option=list_arrow(ind_sel); 110 % keyboard_callback(hcurrentfig,arrow_option) 111 % return 112 % end 113 % end 114 else 115 htype=get(hchild,'Type');%type of object child of the current figure 116 switch htype 117 %if the mouse is over an axis, look at the data 118 case 'axes' 119 haxes=hchild; 120 xy=get(hchild,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 121 AxeData=get(hchild,'UserData');% data attached to the axis 122 % if isfield(AxeData,'ObjectCoord') && size(AxeData.ProjObjectCoord,2)==3 123 % xy(1,3)=AxeData.ProjObjectCoord(1,3); % z coordinate of the mouse: to generalise ... 124 % else 125 % xy(1,3)=0; % z coordinate set to 0 by default 126 % end 127 AxeData.CurrentOrigin=xy(1,1:2);% The current point set by the mouse becomes the current origin 128 129 if test_edit_vect 130 ivec=[]; 131 FigData=get(hcurrentfig,'UserData'); 132 tagaxes=get(hchild,'tag'); 133 if isfield(FigData,tagaxes) 134 Field=FigData.(tagaxes); 135 [CellVarIndex,NbDim,VarType]=find_field_cells(Field);%analyse the physical fields contained in Field 136 for icell=1:numel(CellVarIndex)%look for all physical fields 137 if NbDim(icell)==2 % select 2D field 138 if isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& ~isempty(VarType{icell}.coord_x) && ~isempty(VarType{icell}.coord_y)%case of unstructured data 139 X=Field.(Field.ListVarName{VarType{icell}.coord_x}); 140 Y=Field.(Field.ListVarName{VarType{icell}.coord_y}); 141 flag_vec=(X<(xy(1,1)+Field.CoordMesh/4) & X>(xy(1,1)-Field.CoordMesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse 142 (Y<(xy(1,2)+Field.CoordMesh/4) & Y>(xy(1,2)-Field.CoordMesh/4));%f 143 ivec=find(flag_vec,1);% search the (first) selected vector index ivec 124 144 end 125 145 end 126 146 end 127 % else 128 % hchild=[];%mouse out of axes 129 % end 130 break 147 end 148 end 149 %break% leave the loop once an axes has been selected 150 151 %if the mouse is over a uicontrol, with right mouse button activated, duplicate the display in an editable zoom window 152 case 'uicontrol' 153 if isequal(get(hObject,'SelectionType'),'alt') %% && ~isequal(get(hchild,'tag'),'frame_object') 154 obj_pos=PosChildren(ind_object,:); 155 msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4); 156 display_str=get(hchild,'TooltipString'); 157 msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],display_str,get(hchild,'String'),msg_pos); 158 return %leave the function once a uicontrol has been selected 159 end 160 161 %if the mouse is over a uipanel, look at the children of the uipanel 162 case 'uipanel' 163 if isequal(get(hObject,'SelectionType'),'alt') 164 panel_pos=PosChildren(ind_object,:);%position of the panel 165 hhchildren=get(hchild,'Children');%handles of all objects in the selected panel 166 check_visible=strcmp(get(hhchildren,'Visible'),'on');%=1 if visible='on', =0 otherwise 167 hhchildren=hhchildren(check_visible); %keep only the visible children 131 168 132 %if the mouse is over a uicontrol, duplicate the display in an editable zoom window 133 case 'uicontrol' 134 if isequal(get(hObject,'SelectionType'),'alt') && isequal(get(hchild,'Visible'),'on') && ~isequal(get(hchild,'tag'),'frame_object')&&... 135 ~isequal(get(hchild,'tag'),'ListObject') 136 if ~strcmp(get(hchild,'Style'),'frame')%do not visualisaze frames 137 msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4); 138 display_str=get(hchild,'TooltipString'); 139 output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],display_str,get(hchild,'String'),msg_pos); 140 break 169 PosChildren=get(hhchildren,'Position'); 170 PosLength=cellfun('length',PosChildren); 171 hhchildren=hhchildren(PosLength==4);% keep only object with position defined by a 4 element vector 172 PosChildren=cell2mat(PosChildren(PosLength==4));% transform cell array to a matrix of positions 173 xy_panel=(xy_fig-panel_pos(1:2))./panel_pos(3:4);% mouse position relative to the panel 174 xy_panel_mat=ones(size(PosChildren,1),1)*xy_panel;% mouse position on the figure transformed to a matrix 175 check_pos=xy_panel_mat >= PosChildren(:,1:2) & xy_panel_mat <= PosChildren(:,1:2)+PosChildren(:,3:4);% compare object to mouse position 176 ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse 177 if ~isempty(ind_object) 178 hhchild=hhchildren(ind_object);% corresponding object handle 179 if strcmp(get(hhchild,'Type'),'uicontrol') 180 msg_pos=GUI_pos(1:2)+panel_pos(1:2).*GUI_pos(3:4)+PosChildren(ind_object,1:2).*panel_pos(3:4).*GUI_pos(3:4); 181 display_str=get(hhchild,'TooltipString'); 182 msgbox_uvmat(['uicontrol: ' get(hhchild,'Tag')],display_str,get(hhchild,'String'),msg_pos); 141 183 end 142 184 end 143 case 'uipanel' 144 panel_pos=obj_pos;%position of the panel 145 hhchildren=get(hchild,'Children');%handles of all objects in the current GUI 146 %% loop on all the objects in the current figure (selected by the last mouse click) 147 for iichild=1:length(hhchildren) 148 hchild=hhchildren(iichild); 149 rel_pos=get(hchild,'Position');%position of the object relative to the uipanel 150 obj_pos(1:2)=panel_pos(1:2)+rel_pos(1:2).*panel_pos(3:4); 151 obj_pos(3:4)=panel_pos(3:4).*rel_pos(3:4); 152 if numel(obj_pos)>=4 && xy_fig(1) >=obj_pos(1) && xy_fig(2) >= obj_pos(2)&& xy_fig(1) <=obj_pos(1)+obj_pos(3) && xy_fig(2) <= obj_pos(2)+obj_pos(4); 153 htype=get(hchild,'Type');%type of object child of the current figure 154 %if the mouse is over a uicontrol, look at the data 155 if strcmp(htype,'uicontrol') && strcmp(get(hchild,'Visible'),'on') 156 msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4); 157 display_str=get(hchild,'TooltipString'); 158 output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],display_str,get(hchild,'String'),msg_pos); 159 break 160 end 161 end 162 end 163 end 164 if ~isempty(output_str) 165 break %leave the current loop if a uicontrol has been selected 166 end 167 end 168 end 169 if ~isempty(output_str) 170 set(hObject,'Units','pixels') 171 if strcmp(get(hchild,'enable'),'on') 172 set(hchild,'String',output_str)% fill the parent uicontrol with the sttring edited in the msgbox 173 end 174 end 175 176 %% desable object creation and vector editing if NbDim different from 2 177 if ~(isfield(AxeData,'NbDim') && isequal(AxeData.NbDim,2)) 178 test_create=0; 179 test_edit_vect=0; 185 end 186 % return %leave the function once a uicontrol has been selected 187 end 180 188 end 181 189 182 190 %% delete the current zoom rectangle 183 if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom) 184 delete(AxeData.CurrentRectZoom) 185 AxeData.CurrentRectZoom=[]; 186 end 187 188 %% zoom has first priority 189 if test_zoom %&& ~test_create && ~test_edit && ~test_edit_vect && exist('xy','var') 190 AxeData.Drawing='zoom'; %initiate drawing mode 191 AxeData.CurrentObject=[];%unselect objects 192 set(hchild,'UserData',AxeData); 193 return 194 end 191 % if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom) 192 % delete(AxeData.CurrentRectZoom) 193 % AxeData.CurrentRectZoom=[]; 194 % end 195 196 %% zoom has first priority, stop here 197 if CheckZoom 198 return 199 end 200 201 %% creation of a zoom subfig 202 if get(hhcurrentfig.CheckZoomFig,'Value') 203 AxeData.Drawing='zoom'; %initiate drawing mode 204 AxeData.CurrentObject=[];%unselect objects 205 set(hchild,'UserData',AxeData); 206 return 207 end 208 195 209 if isempty(huvmat)%further options require the uvmat GUI 196 210 return … … 199 213 %% ruler has second priority 200 214 if test_ruler 201 AxeData.RulerCoord(1,1)=xy(1,1); 202 AxeData.RulerCoord(1,2)=xy(1,2); 215 AxeData.RulerCoord(1,1:2)=xy(1,1:2); 203 216 AxeData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler'); 204 217 AxeData.Drawing='ruler'; … … 218 231 end 219 232 233 %% desable object creation and vector editing if NbDim different from 2 234 if ~(isfield(AxeData,'NbDim') && isequal(AxeData.NbDim,2)) 235 test_create=0; 236 test_edit_vect=0; 237 end 238 220 239 %% selection of an existing projection object (third priority) 221 if test_edit && (isequal(tag_obj,'proj_object')||isequal(tag_obj,'DeformPoint'))240 if test_edit 222 241 if ~(isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'create')) 223 242 userdata=get(hcurrentobject,'UserData'); … … 228 247 end 229 248 ObjectData=get(AxeData.CurrentObject,'UserData'); 230 if test_edit &&isfield(ObjectData,'IndexObj')249 if isfield(ObjectData,'IndexObj') 231 250 hother=findobj('Tag','proj_object','Type','line');%find all the proj objects 232 251 set(hother,'Color','b');%reset all the proj objects in 'blue' by default … … 263 282 end 264 283 end 265 if isequal( tag_obj,'DeformPoint')284 if isequal(obj_tag,'DeformPoint') 266 285 set(hcurrentobject,'Color','m'); %set the selected DeformPoint to magenta color 267 286 end … … 280 299 set(hhuvmat.ListObject_1,'Value',IndexObj); 281 300 list_str=get(hhuvmat.ListObject_1,'String'); 282 UvData. Object{IndexObj}.Name=list_str{IndexObj};301 UvData.ProjObject{IndexObj}.Name=list_str{IndexObj}; 283 302 end 284 303 % h_set_object=findobj(allchild(0),'Tag','set_object'); … … 286 305 % delete(h_set_object) 287 306 % end 288 set_object(UvData. Object{IndexObj})307 set_object(UvData.ProjObject{IndexObj}) 289 308 axes(hchild);%set back the current axes haxes 290 309 testdeform=0; 291 310 set(gcbo,'Pointer','circle'); 292 311 AxeData.Drawing='deform'; 293 if isequal( tag_obj,'DeformPoint')312 if isequal(obj_tag,'DeformPoint') 294 313 if isfield(ObjectData,'DeformPoint') 295 314 set(hcurrentobject,'Selected','on') … … 312 331 313 332 %% create projection object 314 if test_create && ~isempty(xy) %&& ~(isfield(AxeData,'Drawing')&& isequal(AxeData.Drawing,'create')) 315 hset_object=findobj(allchild(0),'tag','set_object'); 333 if test_create && ~isempty(xy) 316 334 % activate this option if the GUI set_object is opened 317 if ~isempty(hset_object) 335 if ~isempty(hset_object) && ~strcmp(get(hcurrentfig,'SelectionType'),'alt') 318 336 sethandles=guidata(hset_object);% handles of the elements in the GUI set_object 319 337 ObjectData=read_GUI(hset_object); %read object parameters in the GUI set_object 320 IndexObj=length(UvData. Object);338 IndexObj=length(UvData.ProjObject); 321 339 %initiate a new object (no data .Coord yet recorded) 322 if ~isfield(UvData. Object{IndexObj},'Coord');340 if ~isfield(UvData.ProjObject{IndexObj},'Coord'); 323 341 ObjectData.Coord=[]; 324 342 ObjectNameNew=ObjectData.Name; … … 326 344 ObjectNameNew=ObjectData.Type; 327 345 end 328 % add an index to the object name if the proposed name already exists 346 % add an index to the object name if the proposed name already exists 329 347 vers=0;% index of the name 330 348 ListObject=get(hhuvmat.ListObject,'String'); … … 348 366 ListObject={ObjectName}; 349 367 else 350 ListObject{end}=ObjectName;368 ListObject{end}=ObjectName; 351 369 end 352 370 set(hhuvmat.ListObject,'String',ListObject);%complement the object list … … 356 374 end 357 375 ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the coordinates marked by the mouse to the object 358 hobject=UvData.Object{IndexObj}.DisplayHandle.(fig_tag); 376 %TODO replace 0 by z coord for 3D 377 hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(fig_tag); 359 378 if isempty(hobject) 360 379 hobject=haxes; 361 380 end 362 ProjObject=UvData. Object{get(hhuvmat.ListObject_1,'Value')};381 ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')}; 363 382 AxeData.CurrentObject=plot_object(ObjectData,ProjObject,hobject,'m');%draw the object and its handle becomes AxeData.CurrentObject 364 UvData.Object{IndexObj}=ObjectData; 365 UvData.Object{IndexObj}.DisplayHandle.(fig_tag)=AxeData.CurrentObject;% attribute the current plot object handle to the Object 366 %UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject; 383 UvData.ProjObject{IndexObj}=ObjectData; 384 UvData.ProjObject{IndexObj}.DisplayHandle.(fig_tag)=AxeData.CurrentObject;% attribute the current plot object handle to the Object 367 385 set(huvmat,'UserData',UvData) 368 386 PlotData=get(AxeData.CurrentObject,'UserData'); … … 378 396 379 397 %% create calibration points if the GUI geometry_calib is opened, if the main axes PlotAxes of uvmat has ben selected 380 if ~test_zoom &&test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'PlotAxes')398 if test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'PlotAxes') 381 399 h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI 382 400 hh_geometry_calib=guidata(h_geometry_calib); -
trunk/src/mouse_motion.m
r575 r622 35 35 end 36 36 hhCurrentFig=guidata(CurrentFig);%handles of the elements in the GUI containing the current figure (uvmat or view_field) 37 test_zoom=get(hhCurrentFig.CheckZoom,'Value');%test for zoom activated on the current figure 37 CheckZoom=get(hhCurrentFig.CheckZoom,'Value');% check for zoom on mode 38 CheckZoomFig=get(hhCurrentFig.CheckZoomFig,'Value');% check for zoom sub fig creation mode 39 test_zoom_draw=0; 38 40 test_draw=0;%test for mouse drawing of object, =0 by default 39 41 test_object=0; %test for object editing or creation 40 42 test_edit_object=0;% edit test for mouse shap: an arrow 41 test_zoom_draw=0; % test for zoom drawing42 43 test_ruler=0;%test for active ruler 43 44 huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle … … 64 65 65 66 AxeData=[];%default 66 mouse=[];67 67 xy=[];%default 68 68 xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo) 69 69 pointershape='arrow';% default pointer is an arrow 70 70 71 xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)72 hchild=get(hObject,'Children');%handles of all objects in the current figure73 74 71 %% loop on all the objects in the current figure, detect whether the mouse is over a plot axes 72 hchildren=get(hObject,'Children');%handles of all objects in the current figure 73 check_visible=strcmp(get(hchildren,'Visible'),'on');% if visible='on', =0 otherwise 74 hchildren=hchildren(check_visible); %kkep only the visible children 75 PosChildren=get(hchildren,'Position');% set of object positions 76 if iscell(PosChildren)% only one child 77 PosLength=cellfun('length',PosChildren);% set of vector lengths for object positions 78 hchildren=hchildren(PosLength==4);% keep only objects with position defined by a 4 element vector 79 PosChildren=cell2mat(PosChildren(PosLength==4));% convert cells to matrix of positions 80 end 81 if size(PosChildren,2)~=4 82 return 83 end 84 xy_fig_mat=ones(size(PosChildren,1),1)*xy_fig;% mouse position set to a matrix 85 check_pos=xy_fig_mat >= PosChildren(:,1:2) & xy_fig_mat <= PosChildren(:,1:2)+PosChildren(:,3:4);% compare object to mouse position 86 ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse 87 hchild=hchildren(ind_object);% corresponding object handle 75 88 CurrentAxes=[]; 76 for ichild=1:length(hchild) 77 obj_pos=get(hchild(ichild),'Position'); 78 if numel(obj_pos)~=4% for some versions of matlab a uicontextmenu appears 79 continue 80 end%position of the object 81 if xy_fig(1) >=obj_pos(1) && xy_fig(2) >= obj_pos(2)&& xy_fig(1) <=obj_pos(1)+obj_pos(3) && xy_fig(2) <= obj_pos(2)+obj_pos(4); 82 htype=get(hchild(ichild),'Type');%type of the crrent child 83 %if the mouse is over an axis, look at the data 84 if strcmp(htype,'axes') 85 CurrentAxes=hchild(ichild); 86 xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 87 AxeData=get(CurrentAxes,'UserData');% data attached to the axis 88 if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing) 89 test_draw=~isequal(AxeData.Drawing,'off');%=1 if mouse drawing of object is active 90 end 91 test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal'); 92 test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject); 93 if ~test_edit_object && ~test_zoom_draw && ~test_ruler 94 pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis) 95 end 96 FigData=get(CurrentFig,'UserData'); 97 tagaxes=get(CurrentAxes,'tag'); 98 if isfield(FigData,tagaxes) 99 Field=FigData.(tagaxes); 100 if isfield(Field,'ListVarName') 101 [CellInfo,NbDimArray]=find_field_cells(Field);%analyse the physical fields contained in Field 102 text_displ_1=''; 103 text_displ_2=''; 104 text_displ_3=''; 105 text_displ_4=''; 106 text_displ_5=''; 107 ivec=[]; 108 xName=''; 109 z=[]; 110 for icell=1:numel(CellInfo)%look for all physical fields 111 if NbDimArray(icell)>=2 % select 2D field 112 if isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured data 113 X=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end)}); 114 Y=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end-1)}); 115 flag_vec=(X<(xy(1,1)+Field.CoordMesh/3) & X>(xy(1,1)-Field.CoordMesh/3)) & ...%flagx=1 for the vectors with x position selected by the mouse 116 (Y<(xy(1,2)+Field.CoordMesh/3) & Y>(xy(1,2)-Field.CoordMesh/3));%f 117 ivec=find(flag_vec,1);% search the (first) selected vector index ivec 118 hhh=findobj(CurrentAxes,'Tag','vector_marker'); 119 if ~isempty(ivec) 120 % mark the vectors with a circle in the absence of other operations 121 if ~test_object && ~test_edit_object && ~test_ruler 122 pointershape='arrow'; %mouse indicates the detection of a vector 123 if isempty(hhh) 124 set(0,'CurrentFigure',CurrentFig) 125 set(CurrentFig,'CurrentAxes',CurrentAxes) 126 rectangle('Curvature',[1 1],... 127 'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh],'EdgeColor','m',... 128 'LineStyle','-','Tag','vector_marker'); 129 else 130 set(hhh,'Visible','on') 131 set(hhh,'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh]) 132 end 133 end 134 %display the field values 135 for ivar=1:numel(CellInfo{icell}.VarIndex) 136 VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)}; 137 VarVal=Field.(VarName)(ivec); 138 var_text=[VarName '=' num2str(VarVal,4) ',']; 139 if isequal(ivar,CellInfo{icell}.CoordIndex(end))||isequal(ivar,CellInfo{icell}.CoordIndex(end-1))||isequal(ivar,CellInfo{icell}.CoordIndex(1)) 140 text_displ_1=[text_displ_1 var_text]; 141 elseif (isfield(CellInfo{icell},'VarIndex_vector_x') && isequal(ivar,CellInfo{icell}.VarIndex_vector_x))||isequal(ivar,CellInfo{icell}.VarIndex_vector_y)||... 142 (isfield(CellInfo{icell},'VarIndex_vector_z') && isequal(ivar,CellInfo{icell}.VarIndex_vector_z)) 143 text_displ_4=[text_displ_4 var_text]; 144 else 145 text_displ_5=[text_displ_5 var_text]; 146 end 147 end 89 90 %if the mouse is over an axis, look at the data 91 if strcmp(get(hchild,'Type'),'axes') 92 CurrentAxes=hchild; 93 xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates 94 AxeData=get(CurrentAxes,'UserData');% data attached to the axis 95 if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing) 96 test_draw=~isequal(AxeData.Drawing,'off');%=1 if mouse drawing of object is active 97 end 98 test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal'); 99 test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject); 100 %if ~test_edit_object && ~test_zoom_draw && ~test_ruler 101 if ~test_edit_object && ~test_ruler && ~CheckZoom 102 pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis) 103 end 104 FigData=get(CurrentFig,'UserData'); 105 tagaxes=get(CurrentAxes,'tag'); 106 if isfield(FigData,tagaxes) 107 Field=FigData.(tagaxes); 108 if isfield(Field,'ListVarName') 109 [CellInfo,NbDimArray]=find_field_cells(Field);%analyse the physical fields contained in Field 110 text_displ_1=''; 111 text_displ_2=''; 112 text_displ_3=''; 113 text_displ_4=''; 114 text_displ_5=''; 115 ivec=[]; 116 xName=''; 117 z=[]; 118 for icell=1:numel(CellInfo)%look for all physical fields 119 if NbDimArray(icell)>=2 % select 2D field 120 if isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured data 121 X=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end)}); 122 Y=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end-1)}); 123 flag_vec=(X<(xy(1,1)+Field.CoordMesh/3) & X>(xy(1,1)-Field.CoordMesh/3)) & ...%flagx=1 for the vectors with x position selected by the mouse 124 (Y<(xy(1,2)+Field.CoordMesh/3) & Y>(xy(1,2)-Field.CoordMesh/3));%f 125 ivec=find(flag_vec,1);% search the (first) selected vector index ivec 126 hhh=findobj(CurrentAxes,'Tag','vector_marker'); 127 if ~isempty(ivec) 128 % mark the vectors with a circle in the absence of other operations 129 if ~test_object && ~test_edit_object && ~test_ruler && ~CheckZoomFig 130 pointershape='arrow'; %mouse indicates the detection of a vector 131 if isempty(hhh) 132 set(0,'CurrentFigure',CurrentFig) 133 set(CurrentFig,'CurrentAxes',CurrentAxes) 134 rectangle('Curvature',[1 1],... 135 'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh],'EdgeColor','m',... 136 'LineStyle','-','Tag','vector_marker'); 148 137 else 149 if ~isempty(hhh) 150 set(hhh,'Visible','off') 151 end 138 set(hhh,'Visible','on') 139 set(hhh,'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh]) 152 140 end 153 elseif strcmp(CellInfo{icell}.CoordType,'grid') %structured coordinates 154 yName=Field.ListVarName{CellInfo{icell}.CoordIndex(1)}; 155 xName=Field.ListVarName{CellInfo{icell}.CoordIndex(2)}; 156 y=Field.(yName); 157 x=Field.(xName); 158 VarName=Field.ListVarName{CellInfo{icell}.VarIndex(1)}; 159 nxy=size(Field.(VarName)); 160 MaxAY=max(y(1),y(end)); %#ok<COLND> 161 MinAY=min(y(1),y(end)); %#ok<COLND> 162 if (xy(1,1)>x(1))&(xy(1,1)<x(end))&(xy(1,2)<MaxAY)&(xy(1,2)>MinAY) %#ok<COLND> 163 indx0=1+round((nxy(2)-1)*(xy(1,1)-x(1))/(x(end)-x(1)));%#ok<COLND> % index x of pixel 164 indy0=1+round((nxy(1)-1)*(xy(1,2)-y(1))/(y(end)-y(1)));%#ok<COLND> % index y of pixel 165 if indx0>=1 & indx0<=nxy(2) & indy0>=1 & indy0<=nxy(1) 166 text_displ_2=['i=' num2str(indx0) ',j=' num2str(indy0) ',']; 167 for ivar=1:numel(CellInfo{icell}.VarIndex) 168 VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)}; 169 VarVal=Field.(VarName)(indy0,indx0,:); 170 var_text=[VarName '=' num2str(VarVal) ',']; 171 text_displ_4=[text_displ_4 var_text]; 172 end 173 end 141 end 142 %display the field values 143 for ivar=1:numel(CellInfo{icell}.VarIndex) 144 VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)}; 145 VarVal=Field.(VarName)(ivec); 146 var_text=[VarName '=' num2str(VarVal,4) ',']; 147 if isequal(ivar,CellInfo{icell}.CoordIndex(end))||isequal(ivar,CellInfo{icell}.CoordIndex(end-1))||isequal(ivar,CellInfo{icell}.CoordIndex(1)) 148 text_displ_1=[text_displ_1 var_text]; 149 elseif (isfield(CellInfo{icell},'VarIndex_vector_x') && isequal(ivar,CellInfo{icell}.VarIndex_vector_x))||isequal(ivar,CellInfo{icell}.VarIndex_vector_y)||... 150 (isfield(CellInfo{icell},'VarIndex_vector_z') && isequal(ivar,CellInfo{icell}.VarIndex_vector_z)) 151 text_displ_4=[text_displ_4 var_text]; 152 else 153 text_displ_5=[text_displ_5 var_text]; 154 end 155 end 156 else 157 if ~isempty(hhh) 158 set(hhh,'Visible','off') 159 end 160 end 161 elseif strcmp(CellInfo{icell}.CoordType,'grid') %structured coordinates 162 yName=Field.ListVarName{CellInfo{icell}.CoordIndex(1)}; 163 xName=Field.ListVarName{CellInfo{icell}.CoordIndex(2)}; 164 y=Field.(yName); 165 x=Field.(xName); 166 VarName=Field.ListVarName{CellInfo{icell}.VarIndex(1)}; 167 nxy=size(Field.(VarName)); 168 MaxAY=max(y(1),y(end)); 169 MinAY=min(y(1),y(end)); 170 if (xy(1,1)>x(1))&(xy(1,1)<x(end))&(xy(1,2)<MaxAY)&(xy(1,2)>MinAY) 171 indx0=1+round((nxy(2)-1)*(xy(1,1)-x(1))/(x(end)-x(1))); % index x of pixel 172 indy0=1+round((nxy(1)-1)*(xy(1,2)-y(1))/(y(end)-y(1))); % index y of pixel 173 if indx0>=1 & indx0<=nxy(2) & indy0>=1 & indy0<=nxy(1) 174 text_displ_2=['i=' num2str(indx0) ',j=' num2str(indy0) ',']; 175 for ivar=1:numel(CellInfo{icell}.VarIndex) 176 VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)}; 177 VarVal=Field.(VarName)(indy0,indx0,:); 178 var_text=[VarName '=' num2str(VarVal) ',']; 179 text_displ_4=[text_displ_4 var_text]; 174 180 end 175 181 end 176 182 end 177 183 end 178 % display the current x,y plot coordinates in the absence of detected vector 179 if isempty(ivec) 180 if isempty(xName) 181 xName='x'; 182 yName='y'; 184 end 185 end 186 % display the current x,y plot coordinates in the absence of detected vector 187 if isempty(ivec) 188 if isempty(xName) 189 xName='x'; 190 yName='y'; 191 end 192 text_displ_1=[xName '=' num2str(xy(1,1),4) ', ' yName '=' num2str(xy(1,2),4) ',']; 193 end 194 %display the z coordinate if defined by the projection plane 195 if isfield(Field,'ObjectType') && strcmp(Field.ObjectType,'plane') && isfield(Field,'ObjectCoord') && length(Field.ObjectCoord)>=3 196 pos=[xy(1,1) xy(1,2) 0]; 197 if isfield(Field,'ObjectAngle')&&~isequal(Field.ObjectAngle,[0 0 0]) 198 om=norm(Field.ObjectAngle);%norm of rotation angle in radians 199 OmAxis=Field.ObjectAngle/om; %unit vector marking the rotation axis 200 cos_om=cos(pi*om/180); 201 sin_om=sin(pi*om/180); 202 pos=[xy(1,1) xy(1,2) 0]; 203 pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis; 204 end 205 pos=pos+[Field.ObjectCoord 0]; 206 text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)]; 207 end 208 % if ~isempty(z) 209 % text_displ_1=[text_displ_1 ' z=' num2str(z,4)]; 210 % end 211 % case of PIV correlation display 212 if test_piv 213 par=read_GUI(hhciv.Civ1); 214 [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2))); 215 xround=Field.X(ind_pt); 216 yround=Field.Y(ind_pt); 217 % par.Grid=[xround size(Field.A,1)-yround+1]; 218 par.Grid=[xround yround]; 219 % mark the correlation box with a rectangle 220 par.ImageA=Field.A; 221 par.ImageB=Field.B; 222 par.ImageHeight=size(par.ImageA,1); 223 par.ImageWidth=size(par.ImageA,2); 224 Param.Civ1=par; 225 ibx2=floor((par.CorrBoxSize(1)-1)/2); 226 iby2=floor((par.CorrBoxSize(2)-1)/2); 227 isx2=floor((par.SearchBoxSize(1)-1)/2); 228 isy2=floor((par.SearchBoxSize(2)-1)/2); 229 shiftx=par.SearchBoxShift(1); 230 shifty=par.SearchBoxShift(2); 231 hhh=findobj(CurrentAxes,'Tag','PIV_box_marker'); 232 hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker'); 233 if isempty(hhh) 234 set(0,'CurrentFigure',CurrentFig) 235 set(CurrentFig,'CurrentAxes',CurrentAxes) 236 rectangle('Curvature',[0 0],... 237 'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',... 238 'LineStyle','-','Tag','PIV_box_marker'); 239 rectangle('Curvature',[0 0],... 240 'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2],'EdgeColor','m',... 241 'LineStyle','- -','Tag','PIV_search_marker'); 242 else 243 set(hhh,'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2]) 244 set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2]) 245 end 246 [Data,errormsg,result_conv]= civ_matlab(Param); 247 if ~isempty(errormsg) 248 text_displ_5=errormsg; 249 else 250 rangx(1)=-(isx2-ibx2)+shiftx; 251 rangx(2)=isx2-ibx2+shiftx; 252 rangy(1)=-(isy2-iby2)-shifty; 253 rangy(2)=(isy2-iby2)-shifty; 254 hcorr=[]; 255 if isfield(AxeData,'CurrentCorrImage') 256 hcorr=AxeData.CurrentCorrImage; 257 if ~ishandle(hcorr) 258 hcorr=[]; 183 259 end 184 text_displ_1=[xName '=' num2str(xy(1,1),4) ', ' yName '=' num2str(xy(1,2),4) ','];185 260 end 186 %display the z coordinate if defined by the projection plane187 if isfield(Field,'ObjectCoord') && length(Field.ObjectCoord)>=3188 pos=[xy(1,1) xy(1,2) 0];189 if isfield(Field,'ObjectAngle')&&~isequal(Field.ObjectAngle,[0 0 0])190 om=norm(Field.ObjectAngle);%norm of rotation angle in radians191 OmAxis=Field.ObjectAngle/om; %unit vector marking the rotation axis192 cos_om=cos(pi*om/180);193 sin_om=sin(pi*om/180);194 pos=[xy(1,1) xy(1,2) 0];195 pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;261 if isempty(hcorr) 262 corrfig=findobj(allchild(0),'tag','corrfig'); 263 if ~isempty(corrfig) 264 set(0,'CurrentFigure',corrfig(1)) 265 AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]); 266 AxeData.CurrentVector=line([0 Data.Civ1_U],[0 Data.Civ1_V],'Tag','vector'); 267 AxeData.TitleHandle=title(num2str(par.Grid)); 268 colorbar 269 set(CurrentAxes,'UserData',AxeData) 270 set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal') 196 271 end 197 pos=pos+Field.ObjectCoord; 198 text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)]; 199 end 200 % if ~isempty(z) 201 % text_displ_1=[text_displ_1 ' z=' num2str(z,4)]; 202 % end 203 % case of PIV correlation display 204 if test_piv 205 par=read_GUI(hhciv.Civ1); 206 [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2))); 207 xround=Field.X(ind_pt); 208 yround=Field.Y(ind_pt); 209 % par.Grid=[xround size(Field.A,1)-yround+1]; 210 par.Grid=[xround yround]; 211 % mark the correlation box with a rectangle 212 par.ImageA=Field.A; 213 par.ImageB=Field.B; 214 par.ImageHeight=size(par.ImageA,1); 215 par.ImageWidth=size(par.ImageA,2); 216 Param.Civ1=par; 217 ibx2=floor((par.CorrBoxSize(1)-1)/2); 218 iby2=floor((par.CorrBoxSize(2)-1)/2); 219 isx2=floor((par.SearchBoxSize(1)-1)/2); 220 isy2=floor((par.SearchBoxSize(2)-1)/2); 221 shiftx=par.SearchBoxShift(1); 222 shifty=par.SearchBoxShift(2); 223 hhh=findobj(CurrentAxes,'Tag','PIV_box_marker'); 224 hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker'); 225 if isempty(hhh) 226 set(0,'CurrentFigure',CurrentFig) 227 set(CurrentFig,'CurrentAxes',CurrentAxes) 228 rectangle('Curvature',[0 0],... 229 'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',... 230 'LineStyle','-','Tag','PIV_box_marker'); 231 rectangle('Curvature',[0 0],... 232 'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2],'EdgeColor','m',... 233 'LineStyle','- -','Tag','PIV_search_marker'); 234 else 235 set(hhh,'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2]) 236 set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2]) 237 end 238 [Data,errormsg,result_conv]= civ_matlab(Param); 239 if ~isempty(errormsg) 240 text_displ_5=errormsg; 241 else 242 rangx(1)=-(isx2-ibx2)+shiftx; 243 rangx(2)=isx2-ibx2+shiftx; 244 rangy(1)=-(isy2-iby2)-shifty; 245 rangy(2)=(isy2-iby2)-shifty; 246 hcorr=[]; 247 if isfield(AxeData,'CurrentCorrImage') 248 hcorr=AxeData.CurrentCorrImage; 249 if ~ishandle(hcorr) 250 hcorr=[]; 251 end 252 end 253 if isempty(hcorr) 254 corrfig=findobj(allchild(0),'tag','corrfig'); 255 if ~isempty(corrfig) 256 set(0,'CurrentFigure',corrfig(1)) 257 AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]); 258 AxeData.CurrentVector=line([0 Data.Civ1_U],[0 Data.Civ1_V],'Tag','vector'); 259 AxeData.TitleHandle=title(num2str(par.Grid)); 260 colorbar 261 set(CurrentAxes,'UserData',AxeData) 262 set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal') 263 end 264 else 265 set(AxeData.CurrentCorrImage,'CData',result_conv) 266 set(AxeData.CurrentCorrImage,'XData',rangx) 267 set(AxeData.CurrentCorrImage,'YData',-rangy) 268 set(AxeData.CurrentVector,'XData',[0 Data.Civ1_U],'YData',[0 Data.Civ1_V]) 269 set(AxeData.TitleHandle,'String',num2str(par.Grid)) 270 end 271 end 272 else 273 set(AxeData.CurrentCorrImage,'CData',result_conv) 274 set(AxeData.CurrentCorrImage,'XData',rangx) 275 set(AxeData.CurrentCorrImage,'YData',-rangy) 276 set(AxeData.CurrentVector,'XData',[0 Data.Civ1_U],'YData',[0 Data.Civ1_V]) 277 set(AxeData.TitleHandle,'String',num2str(par.Grid)) 272 278 end 273 279 end … … 288 294 289 295 %%%%%%%%%%%%% 290 %% draw a zoom rectangle if no object creation isselected296 %% draw a zoom rectangle if checkZoomFig has been selected 291 297 if test_zoom_draw 292 xy_rect=AxeData.CurrentOrigin; 298 xy_rect=AxeData.CurrentOrigin;% mark the previous position from mouse down 293 299 if ~isempty(xy_rect) 294 300 rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate … … 296 302 rect(3)=abs(xy(1,1)-xy_rect(1));%rectangle width 297 303 rect(4)=abs(xy(1,2)-xy_rect(2));%rectangle height 298 if rect(3)>0 & rect(4)>0299 if isfield(AxeData,'CurrentRectZoom')& ishandle(AxeData.CurrentRectZoom)304 if rect(3)>0 && rect(4)>0 305 if isfield(AxeData,'CurrentRectZoom')&& ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom) 300 306 set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position 301 307 else 302 AxeData.CurrentRectZoom=rectangle('Position',rect,' LineStyle',':','Tag','rect_zoom');308 AxeData.CurrentRectZoom=rectangle('Position',rect,'Tag','rect_zoom','EdgeColor','b'); 303 309 set(CurrentAxes,'UserData',AxeData) 304 310 end 305 311 end 306 312 end 307 pointershape='arrow';308 313 end 309 314 … … 316 321 return 317 322 end 318 ObjectData=UvData.Object{PlotData.IndexObj}; 319 ProjObject=[];% object (plane) whose projection is represented on the current axes 323 ObjectData=UvData.ProjObject{PlotData.IndexObj}; 320 324 if isequal(hObject,huvmat)% if the mouse ifs over the GUI uvmat 321 ProjObject=UvData. Object{get(hhuvmat.ListObject_1,'Value')};325 ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')}; 322 326 else 323 ProjObject=UvData. Object{get(hhuvmat.ListObject,'Value')};327 ProjObject=UvData.ProjObject{get(hhuvmat.ListObject,'Value')}; 324 328 end 325 329 XYData=AxeData.CurrentOrigin; … … 329 333 % ObjectData.Coord(end,:)=xy(1,:); 330 334 elseif strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')||strcmp(ObjectData.Type,'volume') 331 ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate 332 ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2; 333 ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width 334 ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height 335 ObjectData.Coord=(AxeData.CurrentOrigin+xy(1,1:2))/2;% keep only the first point coordinate 336 ObjectData.RangeX=abs(ObjectData.Coord(1,1)-xy(1,1));%rectangle width 337 ObjectData.RangeY=abs(ObjectData.Coord(1,2)-xy(1,2));%rectangle height 335 338 elseif isequal(ObjectData.Type,'plane') %case of 'plane' 336 339 DX=(xy(1,1)-ObjectData.Coord(1,1)); … … 364 367 %% detect calibration points if the GUI geometry_calib is opened 365 368 h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI 366 if ~ test_zoom && ~isempty(h_geometry_calib)369 if ~CheckZoom && ~isempty(h_geometry_calib) 367 370 pointershape='crosshair';%default for geometry_calib: ready to create new points 368 371 hh_geometry_calib=guidata(h_geometry_calib); -
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'')']); -
trunk/src/plot_object.m
r534 r622 115 115 end 116 116 case {'rectangle','ellipse','volume'} 117 if isequal(YMax,0)118 ylim=get(haxes,'YLim');119 YMax=(ylim(2)-ylim(1))/100;120 end121 if isequal(XMax,0)122 XMax=YMax;%default123 end117 % if isequal(YMax,0) 118 % ylim=get(haxes,'YLim'); 119 % YMax=(ylim(2)-ylim(1))/100; 120 % end 121 % if isequal(XMax,0) 122 % XMax=YMax;%default 123 % end 124 124 case 'plane' 125 125 if isequal(XMax,0) … … 274 274 end 275 275 %complement missing points 276 if size(ObjectData.Coord,1)>length(PlotData.SubObject) 277 for ipt=length(PlotData.SubObject)+1:size(ObjectData.Coord,1) 276 if length(PlotData.SubObject)>nbpoints% fpoints in excess on the graph 277 for ii=nbpoints+1: length(PlotData.SubObject); 278 if ishandle(PlotData.SubObject(ii)) 279 delete(PlotData.SubObject(ii)) 280 end 281 end 282 % NbDeformPoint=nbpoints; 283 end 284 if nbpoints>length(PlotData.SubObject) 285 for ipt=length(PlotData.SubObject)+1:nbpoints 278 286 PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],... 279 287 'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,... … … 284 292 end 285 293 if isfield(PlotData,'DeformPoint') 286 for ipt=1:length(PlotData.DeformPoint) 294 NbDeformPoint=length(PlotData.DeformPoint); 295 if NbDeformPoint>nbpoints% fpoints in excess on the graph 296 for ii=nbpoints+1:NbDeformPoint; 297 if ishandle(PlotData.DeformPoint(ii)) 298 delete(PlotData.DeformPoint(ii)) 299 end 300 end 301 NbDeformPoint=nbpoints; 302 end 303 for ipt=1:NbDeformPoint 287 304 if ishandle(PlotData.DeformPoint(ipt)) 288 305 if nbpoints>=ipt … … 299 316 end 300 317 end 301 elseif isequal(ObjectData.Type,'rectangle')||isequal(ObjectData.Type,'ellipse')318 elseif (isequal(ObjectData.Type,'rectangle')||isequal(ObjectData.Type,'ellipse'))&&XMax>0 && YMax>0 302 319 set(hplot,'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax]) 303 320 end -
trunk/src/set_grid.m
r591 r622 170 170 set(handles.TxtWarning,'visible','on') 171 171 end 172 173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%174 % --- Executes on button press in delete.175 function delete_Callback(hObject, eventdata, handles)176 177 %SetData=get(gcbf,'UserData');%get the interface data178 %IndexObj=SetData.IndexObj;179 huvmat=findobj('Name','uvmat');%find the current uvmat interface handle180 UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface181 if isfield(UvData,'CurrentObjectIndex')182 IndexObj=UvData.CurrentObjectIndex;183 else184 IndexObj=[];185 end186 delete_object(IndexObj);187 188 172 189 173 % ------------------------------------------------------ -
trunk/src/set_object.m
r613 r622 475 475 set(hhuvmat.ListObject,'String',ListObject);%complement the object list 476 476 set(hhuvmat.ViewObject,'Value',1)% indicate that the currently selected objected is viewed on set_object 477 check_handle=isfield(UvData. Object{IndexObj},'DisplayHandle') && isfield(UvData.Object{IndexObj}.DisplayHandle,'uvmat')...478 && ~isempty(UvData. Object{IndexObj}.DisplayHandle.uvmat) && ishandle(UvData.Object{IndexObj}.DisplayHandle.uvmat);477 check_handle=isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat')... 478 && ~isempty(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat) && ishandle(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat); 479 479 if check_handle 480 obj_handle=UvData. Object{IndexObj}.DisplayHandle.uvmat;481 end 482 UvData. Object{IndexObj}=ObjectData;%record the current object properties in uvmat480 obj_handle=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; 481 end 482 UvData.ProjObject{IndexObj}=ObjectData;%record the current object properties in uvmat 483 483 if check_handle 484 UvData. Object{IndexObj}.DisplayHandle.uvmat=obj_handle; %preserve the object plot handle if valid485 else 486 UvData. Object{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; %axes taken as object display handle by defualt484 UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=obj_handle; %preserve the object plot handle if valid 485 else 486 UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; %axes taken as object display handle by defualt 487 487 end 488 488 %set(hhuvmat.edit_object,'Value',1)% set the current object to edit mode … … 543 543 544 544 %% update the object plot 545 hobject=UvData. Object{IndexObj}.DisplayHandle.uvmat;545 hobject=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; 546 546 % if we are editing the object used for projection in uvmat 547 547 if isequal(IndexObj_1,IndexObj) 548 548 %update the representation of the current object for projection field represented in view_field 549 for iobj=1:numel(UvData. Object)550 UvData. Object{iobj}.DisplayHandle.uvmat=...551 plot_object(UvData. Object{iobj},UvData.Object{IndexObj_1},UvData.Object{iobj}.DisplayHandle.uvmat,'b');549 for iobj=1:numel(UvData.ProjObject) 550 UvData.ProjObject{iobj}.DisplayHandle.uvmat=... 551 plot_object(UvData.ProjObject{iobj},UvData.ProjObject{IndexObj_1},UvData.ProjObject{iobj}.DisplayHandle.uvmat,'b'); 552 552 end 553 553 else % we are editing the object used for projection field represented in view_field 554 554 %update the representation of the current object in uvmat 555 UvData. Object{IndexObj}.DisplayHandle.uvmat=...556 plot_object(UvData. Object{IndexObj},UvData.Object{IndexObj_1},UvData.Object{IndexObj}.DisplayHandle.uvmat,'m');555 UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=... 556 plot_object(UvData.ProjObject{IndexObj},UvData.ProjObject{IndexObj_1},UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'m'); 557 557 %indicate the object index in the user data of the object plot (needed for further mouse editing) 558 ObjectInfo=get(UvData. Object{IndexObj}.DisplayHandle.uvmat,'UserData');558 ObjectInfo=get(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'UserData'); 559 559 ObjectInfo.IndexObj=IndexObj; 560 set(UvData. Object{IndexObj}.DisplayHandle.uvmat,'UserData',ObjectInfo)560 set(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'UserData',ObjectInfo) 561 561 % update the representation of all objects in view_field 562 for iobj=1:numel(UvData. Object)563 if isfield(UvData. Object{iobj}.DisplayHandle,'view_field')564 UvData. Object{iobj}.DisplayHandle.view_field=...565 plot_object(UvData. Object{iobj},UvData.Object{iobj},UvData.Object{iobj}.DisplayHandle.view_field,'b');562 for iobj=1:numel(UvData.ProjObject) 563 if isfield(UvData.ProjObject{iobj}.DisplayHandle,'view_field') 564 UvData.ProjObject{iobj}.DisplayHandle.view_field=... 565 plot_object(UvData.ProjObject{iobj},UvData.ProjObject{iobj},UvData.ProjObject{iobj}.DisplayHandle.view_field,'b'); 566 566 end 567 567 end -
trunk/src/uvmat.m
r620 r622 34 34 % .PosGeometryCalib: size of set_object 35 35 % .NbBuiltin: nbre of functions always displayed in TransformName menu 36 % . Object: cell array of structures representing the current projection objects, as produced by 'set_object.m'={[]} by default36 % .ProjObject: cell array of structures representing the current projection objects, as produced by 'set_object.m'={[]} by default 37 37 % .NewSeries: =0/1 flag telling whether a new field series has been opened 38 38 % .FileName_1: name of the current second field (used to detect a constant field during file scanning) … … 126 126 % .Phi, .Theta, .Psi : Euler angles 127 127 % .X,.Y,.U,.V.... : field data projected on the object 128 % .IndexObj: index in the list of UvData. Object128 % .IndexObj: index in the list of UvData.ProjObject 129 129 %during plotting 130 130 % .plotaxes: handles of the current axes used to plot the result of field projection on the object … … 214 214 set(handles.FieldName,'Value',1) 215 215 set(handles.FieldName,'string',{''}) 216 UvData. Object={[]};216 UvData.ProjObject={[]}; 217 217 218 218 %% TRANSFORM menu: builtin fcts … … 1809 1809 function movie_pair_Callback(hObject, eventdata, handles) 1810 1810 %------------------------------------------------------------------------ 1811 1811 1812 %% stop movie action if the movie_pair button is off 1812 1813 if ~get(handles.movie_pair,'value') … … 2065 2066 check_proj_tps=0; 2066 2067 if (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx')) 2067 for iobj=1:numel(UvData. Object)2068 if isfield(UvData. Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'interp_tps')2068 for iobj=1:numel(UvData.ProjObject) 2069 if isfield(UvData.ProjObject{iobj},'ProjMode')&& strcmp(UvData.ProjObject{iobj}.ProjMode,'interp_tps') 2069 2070 check_proj_tps=1; 2070 2071 break … … 2547 2548 end 2548 2549 % default projection plane 2549 if isempty(UvData. Object{1})2550 UvData. Object{1}.Type='plane';%main plotting plane2551 UvData. Object{1}.ProjMode='projection';%main plotting plane2552 UvData. Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat2553 UvData. Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat2550 if isempty(UvData.ProjObject{1}) 2551 UvData.ProjObject{1}.Type='plane';%main plotting plane 2552 UvData.ProjObject{1}.ProjMode='projection';%main plotting plane 2553 UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat 2554 UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat 2554 2555 end 2555 2556 %% 3D case (menuvolume) … … 2563 2564 end 2564 2565 if test_set_object% reinitiate the GUI set_object 2565 delete_object(1);% delete the current projection object in the list UvData. Object, delete its graphic representations and update the list displayed in handles.ListObject and 22566 UvData. Object{1}.NbDim=NbDim;%test for 3D objects2567 UvData. Object{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane2568 UvData. Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen2569 UvData. Object{1}.Angle=[0 0 0];2570 UvData. Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR2571 UvData. Object{1}.Name='1-PLANE';2572 UvData. Object{1}.enable_plot=1;2573 set_object(UvData. Object{1},handles,ZBounds);2566 delete_object(1);% delete the current projection object in the list UvData.ProjObject, delete its graphic representations and update the list displayed in handles.ListObject and 2 2567 UvData.ProjObject{1}.NbDim=NbDim;%test for 3D objects 2568 UvData.ProjObject{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane 2569 UvData.ProjObject{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen 2570 UvData.ProjObject{1}.Angle=[0 0 0]; 2571 UvData.ProjObject{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR 2572 UvData.ProjObject{1}.Name='1-PLANE'; 2573 UvData.ProjObject{1}.enable_plot=1; 2574 set_object(UvData.ProjObject{1},handles,ZBounds); 2574 2575 set(handles.ListObject,'Value',1); 2575 2576 set(handles.ListObject,'String',{'1-PLANE'}); … … 2582 2583 XmlData=UvData.XmlData{1}; 2583 2584 if isfield(XmlData,'PlanePos') 2584 UvData. Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);2585 UvData.ProjObject{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); 2585 2586 end 2586 2587 if isfield(XmlData,'PlaneAngle') 2587 2588 siz=size(XmlData.PlaneAngle); 2588 2589 indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) 2589 UvData. Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);2590 UvData.ProjObject{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:); 2590 2591 end 2591 2592 elseif isfield(UvData,'ZIndex') 2592 UvData. Object{1}.ZObject=UvData.ZIndex;2593 UvData.ProjObject{1}.ZObject=UvData.ZIndex; 2593 2594 end 2594 2595 end … … 2631 2632 set(handles.ListObject,'Value',1) 2632 2633 set(handles.ListObject,'String',{'plane'}) 2633 UvData. Object{1}.Type='plane';%main plotting plane2634 UvData. Object{1}.ProjMode='projection';%main plotting plane2635 UvData. Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat2636 UvData. Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat2634 UvData.ProjObject{1}.Type='plane';%main plotting plane 2635 UvData.ProjObject{1}.ProjMode='projection';%main plotting plane 2636 UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat 2637 UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat 2637 2638 set(handles.ListObject_1,'Value',1) 2638 2639 set(handles.ListObject_1,'String',{'plane'}) 2639 2640 end 2640 2641 IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view 2641 if IndexObj(1)> numel(UvData. Object)2642 if IndexObj(1)> numel(UvData.ProjObject) 2642 2643 IndexObj(1)=1;%select the first object if the selected one does not exist 2643 2644 set(handles.ListObject_1,'Value',1) … … 2682 2683 for imap=1:numel(IndexObj) 2683 2684 iobj=IndexObj(imap); 2684 if numel(UvData. Object)<iobj2685 if numel(UvData.ProjObject)<iobj 2685 2686 break 2686 2687 end 2687 [ObjectData,errormsg]=proj_field(UvData.Field,UvData. Object{iobj});% project field on the object2688 [ObjectData,errormsg]=proj_field(UvData.Field,UvData.ProjObject{iobj});% project field on the object 2688 2689 if ~isempty(errormsg) 2689 2690 return … … 2879 2880 end 2880 2881 2881 %------------------------------------------------------------------- 2882 %------------------------------------------------------------------------ 2882 2883 % --- translate coordinate to matrix index 2883 %------------------------------------------------------------------- 2884 %------------------------------------------------------------------------ 2884 2885 function [indx,indy]=pos2ind(x0,rangx0,nxy) 2885 2886 indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel 2886 2887 indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel 2887 2888 2888 2889 %------------------------------------------------------------------- 2889 %------------------------------------------------------------------------ 2890 2890 % --- Executes on button press in 'CheckZoom'. 2891 %------------------------------------------------------------------- 2891 %------------------------------------------------------------------------ 2892 2892 function CheckZoom_Callback(hObject, eventdata, handles) 2893 2893 2894 if (get(handles.CheckZoom,'Value') == 1); 2895 set(handles.CheckZoom,'BackgroundColor',[1 1 0]) 2894 if get(handles.CheckZoom,'Value') 2896 2895 set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes 2897 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) 2898 else 2899 set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) 2900 end 2901 2902 %------------------------------------------------------------------- 2896 set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig 2897 end 2898 2899 %------------------------------------------------------------------------ 2900 % --- Executes on button press in CheckZoomFig. 2901 %------------------------------------------------------------------------ 2902 function CheckZoomFig_Callback(hObject, eventdata, handles) 2903 2904 if get(handles.CheckZoomFig,'Value') 2905 set(handles.CheckZoom,'value',0) 2906 end 2907 2908 %------------------------------------------------------------------------ 2903 2909 % --- Executes on button press in 'CheckFixLimits'. 2904 %------------------------------------------------------------------- 2910 %------------------------------------------------------------------------ 2905 2911 function CheckFixLimits_Callback(hObject, eventdata, handles) 2906 test=get(handles.CheckFixLimits,'Value'); 2907 if test 2908 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) 2909 else 2910 set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) 2912 2913 if ~get(handles.CheckFixLimits,'Value') 2911 2914 update_plot(handles); 2912 2915 end 2913 2916 2914 %------------------------------------------------------------------- 2917 %------------------------------------------------------------------------ 2915 2918 % --- Executes on button press in CheckFixAspectRatio. 2916 2919 function CheckFixAspectRatio_Callback(hObject, eventdata, handles) 2917 %------------------------------------------------------------------- 2920 %------------------------------------------------------------------------ 2921 2918 2922 if get(handles.CheckFixAspectRatio,'Value') 2919 % set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0])2920 2923 update_plot(handles); 2921 2924 else 2922 % set(handles.CheckFixAspectRatio,'BackgroundColor',[0.7 0.7 0.7])2923 2925 update_plot(handles); 2924 2926 end 2925 2927 2926 %------------------------------------------------------------------- 2928 %------------------------------------------------------------------------ 2927 2929 function num_AspectRatio_Callback(hObject, eventdata, handles) 2928 %------------------------------------------------------------------- 2930 %------------------------------------------------------------------------ 2929 2931 set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button 2930 % set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0])% mark in yellow2931 2932 update_plot(handles); 2932 %------------------------------------------------------------------- 2933 2934 %------------------------------------------------------------------- 2935 2936 2937 2938 %------------------------------------------------------------------- 2933 2934 %------------------------------------------------------------------------ 2939 2935 %----Executes on button press in 'record': records the current flags of manual correction. 2940 %------------------------------------------------------------------- 2936 %------------------------------------------------------------------------ 2941 2937 function record_Callback(hObject, eventdata, handles) 2942 % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles); 2938 2943 2939 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 2944 2940 FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; 2945 %FileName=read_file_boxes(handles);2946 2941 [erread,message]=fileattrib(FileName); 2947 2942 if ~isempty(message) && ~isequal(message.UserWrite,1) … … 3233 3228 end 3234 3229 3235 %--------------------------------------------------- 3230 %---------------------------------------------------------------- 3236 3231 % --- Executes on menu selection FieldName 3237 3232 function FieldName_1_Callback(hObject, eventdata, handles) … … 3452 3447 3453 3448 3454 %----------------------------------------------------------------------- 3449 %------------------------------------------------------------------------ 3455 3450 % --- reset civ buttons 3456 3451 function reset_vel_type(handles_civ0,handle1) 3457 %----------------------------------------------------------------------- 3452 %------------------------------------------------------------------------ 3458 3453 for ibutton=1:length(handles_civ0) 3459 3454 set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784]) … … 3546 3541 yi=0.5:npy-0.5; 3547 3542 [Xi,Yi]=meshgrid(xi,yi); 3548 if isfield(UvData,' Object')3549 for iobj=1:length(UvData. Object)3550 ObjectData=UvData. Object{iobj};3543 if isfield(UvData,'ProjObject') 3544 for iobj=1:length(UvData.ProjObject) 3545 ObjectData=UvData.ProjObject{iobj}; 3551 3546 if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); 3552 3547 flagobj=1; … … 3618 3613 image(imflag); 3619 3614 3620 %------------------------------------------------------------------- 3621 %------------------------------------------------------------------- 3615 %------------------------------------------------------------------------ 3616 %------------------------------------------------------------------------ 3622 3617 % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS 3623 3618 3624 %------------------------------------------------------------------ 3625 %------------------------------------------------------------- 3619 %------------------------------------------------------------------------ 3620 %------------------------------------------------------------------------ 3626 3621 % --- Executes on selection change in TransformName. 3627 3622 3628 3623 function TransformName_Callback(hObject, eventdata, handles) 3629 %------------------------------------------------------------- 3624 %------------------------------------------------------------------------ 3630 3625 UvData=get(handles.uvmat,'UserData'); 3631 3626 menu=get(handles.TransformName,'String');refresh … … 3749 3744 delete(hhh) 3750 3745 end 3751 % if isfield(UvData,'Object')3752 % UvData.Object=UvData.Object(1);3753 % end3754 3746 set(handles.ListObject,'Value',1) 3755 3747 set(handles.ListObject,'String',{''}) … … 3762 3754 set(handles.edit_object,'Value',0) 3763 3755 edit_object_Callback(hObject, eventdata, handles) 3764 UvData. Object={[]};3756 UvData.ProjObject={[]}; 3765 3757 end 3766 3758 set(handles.uvmat,'UserData',UvData) … … 3917 3909 %------------------------------------------------------------------------ 3918 3910 % --- Executes on selection change in CheckDecimate4 (nb_vec/4). 3911 %------------------------------------------------------------------------ 3919 3912 function CheckDecimate4_Callback(hObject, eventdata, handles) 3920 %------------------------------------------------------------------------ 3913 3921 3914 if isequal(get(handles.CheckDecimate4,'Value'),1) 3922 3915 set(handles.CheckDecimate16,'Value',0) … … 3926 3919 %------------------------------------------------------------------------ 3927 3920 % --- Executes on selection change in CheckDecimate16 (nb_vec/16). 3921 %------------------------------------------------------------------------ 3928 3922 function CheckDecimate16_Callback(hObject, eventdata, handles) 3929 %------------------------------------------------------------------------ 3923 3930 3924 if isequal(get(handles.CheckDecimate16,'Value'),1) 3931 3925 set(handles.CheckDecimate4,'Value',0) … … 4132 4126 list_str=get(handles.ListObject,'String'); 4133 4127 UvData=get(handles.uvmat,'UserData'); 4134 ObjectData=UvData. Object{get(handles.ListObject_1,'Value')};4128 ObjectData=UvData.ProjObject{get(handles.ListObject_1,'Value')}; 4135 4129 4136 4130 %% update the projection plot on uvmat … … 4139 4133 %replot all the objects within the new projected field 4140 4134 for IndexObj=1:numel(list_str) 4141 hobject=UvData. Object{IndexObj}.DisplayHandle.uvmat;4135 hobject=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; 4142 4136 if isempty(hobject) || ~ishandle(hobject) 4143 4137 hobject=handles.PlotAxes; … … 4148 4142 objectcolor='b'; 4149 4143 end 4150 UvData. Object{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.Object{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat4144 UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.ProjObject{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat 4151 4145 end 4152 4146 set(handles.uvmat,'UserData',UvData) … … 4177 4171 %% The object is displayed in set_object if this GUI is already opened 4178 4172 UvData=get(handles.uvmat,'UserData'); 4179 ObjectData=UvData. Object{IndexObj};4173 ObjectData=UvData.ProjObject{IndexObj}; 4180 4174 hset_object=findobj(allchild(0),'tag','set_object'); 4181 4175 if ~isempty(hset_object) … … 4219 4213 4220 4214 %% update the color of the graphic object representation: the selected object in magenta, others in blue 4221 update_object_color(handles.PlotAxes,hhview_field.PlotAxes,UvData. Object{IndexObj}.DisplayHandle.uvmat)4215 update_object_color(handles.PlotAxes,hhview_field.PlotAxes,UvData.ProjObject{IndexObj}.DisplayHandle.uvmat) 4222 4216 4223 4217 %------------------------------------------------------------------------ … … 4313 4307 list_object=get(handles.ListObject,'String'); 4314 4308 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 4315 UvData. Object{IndexObj}.Name=list_object{IndexObj};4316 if numel(UvData. Object)<IndexObj;% error in UvData4309 UvData.ProjObject{IndexObj}.Name=list_object{IndexObj}; 4310 if numel(UvData.ProjObject)<IndexObj;% error in UvData 4317 4311 msgbox_uvmat('ERROR','invalid object list') 4318 4312 return … … 4324 4318 end 4325 4319 % set(handles.ListObject_1,'Value',IndexObj);%restore ListObject selection after set_object deletion 4326 data=UvData. Object{IndexObj};4320 data=UvData.ProjObject{IndexObj}; 4327 4321 if ~isfield(data,'Type')% default plane 4328 4322 data.Type='plane'; … … 4374 4368 IndexObj=get(handles.ListObject,'Value'); 4375 4369 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 4376 if numel(UvData. Object)<IndexObj(end);% error in UvData4370 if numel(UvData.ProjObject)<IndexObj(end);% error in UvData 4377 4371 msgbox_uvmat('ERROR','invalid object list') 4378 4372 return … … 4384 4378 end 4385 4379 set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion 4386 if ~isfield(UvData. Object{IndexObj(1)},'Type')% default plane4387 UvData. Object{IndexObj(1)}.Type='plane';4380 if ~isfield(UvData.ProjObject{IndexObj(1)},'Type')% default plane 4381 UvData.ProjObject{IndexObj(1)}.Type='plane'; 4388 4382 end 4389 4383 list_object=get(handles.ListObject,'String'); 4390 UvData. Object{IndexObj(end)}.Name=list_object{IndexObj(end)};4384 UvData.ProjObject{IndexObj(end)}.Name=list_object{IndexObj(end)}; 4391 4385 4392 4386 %% show the projection of the selected object on view_field 4393 ProjData= proj_field(UvData.Field,UvData. Object{IndexObj});%project the current field on ObjectData4387 ProjData= proj_field(UvData.Field,UvData.ProjObject{IndexObj});%project the current field on ObjectData 4394 4388 hview_field=findobj(allchild(0),'tag','view_field'); 4395 4389 if isempty(hview_field) … … 4425 4419 %------------------------------------------------------------------------ 4426 4420 % --- Executes on button press in delete_object. 4421 %------------------------------------------------------------------------ 4427 4422 function delete_object_Callback(hObject, eventdata, handles) 4428 %------------------------------------------------------------------------ 4423 4429 4424 IndexObj=get(handles.ListObject,'Value');%projection object selected for view_field 4430 4425 IndexObj_1=get(handles.ListObject_1,'Value');%projection object selected for uvmat plot 4431 4426 if IndexObj>1 && ~isequal(IndexObj,IndexObj_1) % do not delete the object used for the uvmat plot 4432 4427 delete_object(IndexObj) 4428 end 4429 4430 %'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle 4431 %------------------------------------------------------------------------ 4432 % function delete_object(hObject) 4433 % 4434 % INPUT: 4435 % hObject: object index (if integer) or handle of the graphic object. If 4436 % hObject is a subobject, the parent object is detected and deleted. 4437 4438 function delete_object(IndexObj) 4439 4440 huvmat=findobj('tag','uvmat');%handles of the uvmat interface 4441 UvData=get(huvmat,'UserData'); 4442 hlist_object=findobj(huvmat,'Tag','ListObject');%handles of the object list in the uvmat interface 4443 list_str=get(hlist_object,'String');%objet list 4444 % if isequal(floor(hObject),hObject) %case of an index 4445 if ~isempty(UvData) && isfield(UvData, 'ProjObject') && length(UvData.ProjObject)>=IndexObj 4446 if isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat') 4447 hdisplay=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; 4448 for iview=1:length(hdisplay) 4449 if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) 4450 ObjectData=get(hdisplay(iview),'UserData'); 4451 if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject) 4452 delete(ObjectData.SubObject); 4453 end 4454 if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint) 4455 delete(ObjectData.DeformPoint); 4456 end 4457 delete(hdisplay(iview)) 4458 end 4459 ishandle(hdisplay(iview)) 4460 end 4461 for iobj=IndexObj+1:length(UvData.ProjObject) 4462 hdisplay=UvData.ProjObject{iobj}.DisplayHandle.uvmat; 4463 for iview=1:length(hdisplay) 4464 if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) 4465 PlotData=get(hdisplay(iview),'UserData'); 4466 PlotData.IndexObj=iobj-1; 4467 set(hdisplay(iview),'UserData',PlotData); 4468 end 4469 end 4470 end 4471 end 4472 UvData.ProjObject(IndexObj)=[]; 4473 if ~isempty(list_str) 4474 list_str(IndexObj)=[]; 4475 end 4476 end 4477 % elseif ishandle(hObject)%object handle 4478 % userdata=get(hObject,'UserData'); 4479 % if ishandle(userdata)%the selected line depends on a parent line 4480 % hdisplay=userdata;% the parent object becomes the current one 4481 % else 4482 % hdisplay=hObject;% the selected object becomes the current one 4483 % end 4484 % PlotData=get(hdisplay,'UserData'); 4485 % if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject) 4486 % delete(PlotData.SubObject); 4487 % end 4488 % if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint) 4489 % delete(PlotData.DeformPoint); 4490 % end 4491 % delete(hdisplay); 4492 % if isfield(PlotData,'IndexObj') 4493 % IndexObj=PlotData.IndexObj; 4494 % if isequal(round(IndexObj),IndexObj) & IndexObj>=1 & length(list_str) > IndexObj 4495 % if isfield(UvData,'ProjObject')& length(UvData.ProjObject) > IndexObj 4496 % UvData.ProjObject(IndexObj)=[]; 4497 % end 4498 % list_str(IndexObj)=[]; 4499 % end 4500 % end 4501 % end 4502 set(huvmat,'UserData',UvData); 4503 set(hlist_object,'String',list_str) 4504 set(hlist_object,'Value',length(list_str)) 4505 hlist_object_1=findobj(huvmat,'Tag','ListObject_1');%handles of the first object list in the uvmat interface 4506 old_index=get(hlist_object_1,'Value'); 4507 set(hlist_object_1,'String',list_str) 4508 if IndexObj<=old_index 4509 set(hlist_object_1,'Value',old_index-1) 4433 4510 end 4434 4511 … … 4599 4676 aviobj=close(aviobj); 4600 4677 UvData=rmfield(UvData,'plotaxes'); 4601 %UvData.Object{1}.plotaxes=handles.PlotAxes;4602 4678 set(huvmat,'UserData',UvData); 4603 4679 msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']}) … … 4688 4764 function create_object(data,handles) 4689 4765 %------------------------------------------------------------------------ 4690 % desactivate geometric calibration if opened4691 hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); 4766 %% desactivate concurrent tools 4767 hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');% search the GUI geometric calibration 4692 4768 if ishandle(hgeometry_calib) 4693 4769 hhgeometry_calib=guidata(hgeometry_calib); 4694 4770 set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib 4695 set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) 4696 end 4697 set(handles.edit_object,'Value',0); %suppress the object edit mode 4698 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 4771 end 4772 set(handles.edit_object,'Value',0) %desactivate the object edit mode 4773 set(handles.CheckZoomFig,'Value',0) %desactivate zoom sub fig 4774 set(handles.CheckZoom,'Value',0) %desactivate the zoom action 4775 if ishandle(handles.UVMAT_title) 4776 delete(handles.UVMAT_title) %delete the initial display of uvmat if no field has been entered yet 4777 end 4778 4779 %% append a new line to the list of projection objects 4699 4780 ListObject=get(handles.ListObject,'String'); 4700 4781 if isempty(ListObject) … … 4708 4789 set(handles.ListObject,'Value',IndexObj) 4709 4790 UvData=get(handles.uvmat,'UserData'); 4710 UvData.Object{IndexObj}=[]; %create a new empty object 4711 UvData.Object{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object 4712 UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation 4791 UvData.ProjObject{IndexObj}=[]; %create a new empty object 4792 UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object 4793 UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation 4794 set(handles.uvmat,'UserData',UvData) 4795 4796 %% initiate the new projection object 4713 4797 data.Name=data.Type;% default name=type 4714 4798 data.Coord=[0 0]; %default … … 4724 4808 data.DX=UvData.Field.CoordMesh; 4725 4809 data.DY=UvData.Field.CoordMesh; 4810 if strcmp(data.Type,'rectangle')||strcmp(data.Type,'ellipse') 4811 data.RangeX=UvData.Field.CoordMesh; 4812 data.RangeY=UvData.Field.CoordMesh; 4813 end 4726 4814 end 4727 4815 if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) … … 4732 4820 end 4733 4821 end 4734 if ishandle(handles.UVMAT_title) 4735 delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered 4736 end 4737 hset_object=set_object(data,handles);% call the set_object interface 4738 hhset_object=guidata(hset_object); 4822 hset_object=set_object(data,handles);% call the GUI set_object 4739 4823 hchild=get(hset_object,'children'); 4740 4824 set(hchild,'enable','on') 4741 set(handles.uvmat,'UserData',UvData) 4742 set(handles.CheckZoom,'Value',0) %desactivate the zoom for object creation by the mouse 4743 CheckZoom_Callback(handles.uvmat, [], handles) 4825 4826 4744 4827 set(handles.delete_object,'Visible','on') 4745 4828 … … 4771 4854 4772 4855 UvData=get(handles.uvmat,'UserData'); 4773 UvData. Object{IndexObj}=[]; %create a new empty object4774 UvData. Object{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation4775 UvData. Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation4856 UvData.ProjObject{IndexObj}=[]; %create a new empty object 4857 UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation 4858 UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation 4776 4859 set(handles.uvmat,'UserData',UvData) 4777 4860 set(handles.ListObject,'Value',IndexObj) … … 4842 4925 4843 4926 %% read lines currently drawn 4844 ListObj=UvData. Object;4927 ListObj=UvData.ProjObject; 4845 4928 select=zeros(1,numel(ListObj)); 4846 4929 for iobj=1:numel(ListObj); … … 4855 4938 else 4856 4939 set(handles.ListObject,'Value',val);% show the selected lines on the list 4857 ObjectData=UvData. Object(val);4940 ObjectData=UvData.ProjObject(val); 4858 4941 for iobj=1:length(ObjectData) 4859 4942 % if isfield(ObjectData{iobj},'Coord') … … 4962 5045 %------------------------------------------------------------------------ 4963 5046 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 4964 ListObj=UvData. Object;5047 ListObj=UvData.ProjObject; 4965 5048 select=zeros(1,numel(ListObj)); 4966 5049 for iobj=1:numel(ListObj); … … 4981 5064 yi=0.5:npy-0.5; 4982 5065 [Xi,Yi]=meshgrid(xi,yi); 4983 % if isfield(UvData,'Object') 4984 for iobj=1:length(UvData.Object) 4985 ObjectData=UvData.Object{iobj}; 5066 for iobj=1:length(UvData.ProjObject) 5067 ObjectData=UvData.ProjObject{iobj}; 4986 5068 if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); 4987 5069 flagobj=1; … … 5307 5389 5308 5390 5309 % --- Executes on button press in CheckZoomFig.5310 function CheckZoomFig_Callback(hObject, eventdata, handles)5311 % hObject handle to CheckZoomFig (see GCBO)5312 % eventdata reserved - to be defined in a future version of MATLAB5313 % handles structure with handles and user data (see GUIDATA)5314 5315 % Hint: get(hObject,'Value') returns toggle state of CheckZoomFig -
trunk/src/view_field.m
r612 r622 363 363 % set(handles.RunMovie,'BackgroundColor',[1 0 0])%paint the command buttonback to red 364 364 365 366 %------------------------------------------------------------------- 365 %------------------------------------------------------------------------ 367 366 % --- translate coordinate to matrix index 368 %------------------------------------------------------------------- 367 %------------------------------------------------------------------------ 369 368 function [indx,indy]=pos2ind(x0,rangx0,nxy) 370 369 indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel 371 370 indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel 372 371 373 %------------------------------------------------------------------- 374 % --- Executes on button press in ' zoom'.375 %------------------------------------------------------------------- 372 %------------------------------------------------------------------------ 373 % --- Executes on button press in 'CheckZoom'. 374 %------------------------------------------------------------------------ 376 375 function CheckZoom_Callback(hObject, eventdata, handles) 377 if (get(handles.CheckZoom,'Value') == 1); 378 set(handles.CheckZoom,'BackgroundColor',[1 1 0]) 376 377 if get(handles.CheckZoom,'Value') 379 378 set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes 380 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) 381 else 382 set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) 379 set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig 380 end 381 382 %------------------------------------------------------------------------ 383 % --- Executes on button press in CheckZoomFig. 384 %------------------------------------------------------------------------ 385 function CheckZoomFig_Callback(hObject, eventdata, handles) 386 387 if get(handles.CheckZoomFig,'Value') 388 set(handles.CheckZoom,'value',0) 383 389 end 384 390 … … 839 845 % % eventdata reserved - to be defined in a future version of MATLAB 840 846 % % handles structure with handles and user data (see GUIDATA) 847 848 849 850
Note: See TracChangeset
for help on using the changeset viewer.