[11] | 1 | %'mouse_down': function activated when the mouse button is pressed on a figure (callback for 'WindowButtonDownFcn' |
---|
| 2 | %-------------------------------------------------------------- |
---|
| 3 | % xy=mouse_down(hObject,eventdata) |
---|
| 4 | % activated by the command: |
---|
| 5 | % set(hObject,'WindowButtonDownFcn',{'mouse_down'}), |
---|
| 6 | % where hObject is the handle of the figure |
---|
| 7 | % |
---|
| 8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 9 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 10 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 11 | % This file is part of the toolbox UVMAT. |
---|
| 12 | % |
---|
| 13 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 14 | % it under the terms of the GNU General Public License as published by |
---|
| 15 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 16 | % (at your option) any later version. |
---|
| 17 | % |
---|
| 18 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 21 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
| 22 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 23 | |
---|
| 24 | function xy=mouse_down(hObject,eventdata) |
---|
[67] | 25 | |
---|
[332] | 26 | AxeData=[];%default |
---|
[187] | 27 | FigData=get(hObject,'UserData'); |
---|
| 28 | 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 |
---|
| 29 | hcurrentfig=get(get(FigData,'parent'),'parent'); |
---|
| 30 | else |
---|
| 31 | hcurrentfig=hObject;%usual plot |
---|
| 32 | end |
---|
[296] | 33 | set(hcurrentfig,'Units','pixels') |
---|
| 34 | GUI_pos=get(hcurrentfig,'Position');%position of the GUI series (in pixels) |
---|
| 35 | set(hcurrentfig,'Units','normalized') |
---|
[187] | 36 | hhcurrentfig=guidata(hcurrentfig); |
---|
[309] | 37 | if isfield(hhcurrentfig,'CheckZoom') |
---|
[332] | 38 | test_zoom=get(hhcurrentfig.CheckZoom,'Value');%test for zoom action, first priority |
---|
[309] | 39 | else |
---|
| 40 | test_zoom=0; |
---|
| 41 | end |
---|
[332] | 42 | |
---|
| 43 | %% look for parameters set by the GUI uvmat |
---|
| 44 | test_ruler=0; |
---|
| 45 | test_edit=0; |
---|
| 46 | test_create=0; |
---|
| 47 | huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls theoption of mouse action |
---|
| 48 | if ~isempty(huvmat) |
---|
| 49 | hhuvmat=guidata(huvmat);%handles of elements in uvmat |
---|
| 50 | UvData=get(huvmat,'UserData'); |
---|
| 51 | 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 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 57 | test_create=~isempty(hset_object)&&~test_edit; |
---|
[156] | 58 | end |
---|
[332] | 59 | test_cal=isequal(get(hhuvmat.MenuCalib,'checked'),'on');% test for calibration |
---|
| 60 | if test_cal% test for calibration popints, priority 6 |
---|
| 61 | h_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 62 | if isempty(h_calib) |
---|
| 63 | test_cal=0; |
---|
| 64 | set(hhuvmat.MenuCalib,'checked','off');% test for calibration off |
---|
| 65 | else |
---|
| 66 | hh_calib=guidata(h_calib); |
---|
| 67 | test_cal=get(hh_calib.edit_append,'Value'); |
---|
| 68 | end |
---|
| 69 | end |
---|
[156] | 70 | end |
---|
[11] | 71 | |
---|
[177] | 72 | %% determine the currently selected items |
---|
[11] | 73 | hcurrentobject=gco;% current object handle (selected by the mouse) |
---|
[187] | 74 | %hcurrentfig=hObject;% current figure handle |
---|
[62] | 75 | fig_tag=get(hcurrentfig,'Tag'); |
---|
[177] | 76 | tag_obj=get(gco,'Tag');%tag of the currently selected object |
---|
[11] | 77 | xy=[];%default |
---|
[187] | 78 | xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo) |
---|
[296] | 79 | hchildren=get(hObject,'Children');%handles of all objects in the current figure |
---|
[67] | 80 | haxes=[]; |
---|
[156] | 81 | |
---|
| 82 | %% loop on all the objects in the current figure (selected by the last mouse click) |
---|
[296] | 83 | output_str=''; |
---|
[309] | 84 | state_visible=get(hchildren,'Visible'); |
---|
| 85 | check_visible=strcmp('on',state_visible);%=1 if visible='on', =0 otherwise |
---|
| 86 | hchildren=hchildren(find(check_visible)); %kkep only the visible children |
---|
[296] | 87 | for ichild=1:length(hchildren) |
---|
[309] | 88 | hchild=hchildren(ichild); %handle of the current obj |
---|
[296] | 89 | obj_pos=get(hchild,'Position');%position of the object |
---|
[11] | 90 | 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); |
---|
[296] | 91 | htype=get(hchild,'Type');%type of object child of the current figure |
---|
| 92 | |
---|
| 93 | switch htype |
---|
| 94 | %if the mouse is over an axis, look at the data |
---|
| 95 | case 'axes' |
---|
| 96 | y_lim=get(hchild,'YLim'); |
---|
| 97 | x_lim=get(hchild,'XLim'); |
---|
| 98 | haxes=hchild; |
---|
| 99 | xy=get(hchild,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates |
---|
| 100 | 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) |
---|
| 101 | AxeData=get(hchild,'UserData');% data attached to the axis |
---|
| 102 | AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin |
---|
| 103 | if test_edit_vect && ~isequal(tag_obj,'proj_object') & ~test_create |
---|
| 104 | ivec=[]; |
---|
| 105 | FigData=get(hcurrentfig,'UserData'); |
---|
| 106 | tagaxes=get(hchild,'tag'); |
---|
| 107 | if isfield(FigData,tagaxes) |
---|
| 108 | eval(['Field=FigData.' tagaxes ';']) |
---|
| 109 | [CellVarIndex,NbDim,VarType]=find_field_indices(Field);%analyse the physical fields contained in Field |
---|
| 110 | for icell=1:numel(CellVarIndex)%look for all physical fields |
---|
| 111 | if NbDim(icell)==2 % select 2D field |
---|
| 112 | if isfield(Field,'Mesh') && ~isempty(Field.Mesh)&& ~isempty(VarType{icell}.coord_x) && ~isempty(VarType{icell}.coord_y)%case of unstructured data |
---|
| 113 | eval(['X=Field.' Field.ListVarName{VarType{icell}.coord_x} ';']) |
---|
| 114 | eval(['Y=Field.' Field.ListVarName{VarType{icell}.coord_y} ';']) |
---|
| 115 | flag_vec=(X<(xy(1,1)+Field.Mesh/4) & X>(xy(1,1)-Field.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse |
---|
| 116 | (Y<(xy(1,2)+Field.Mesh/4) & Y>(xy(1,2)-Field.Mesh/4));%f |
---|
| 117 | ivec=find(flag_vec,1);% search the (first) selected vector index ivec |
---|
| 118 | end |
---|
[156] | 119 | end |
---|
| 120 | end |
---|
| 121 | end |
---|
[78] | 122 | end |
---|
[296] | 123 | else |
---|
| 124 | hchild=[];%mouse out of axes |
---|
[11] | 125 | end |
---|
[296] | 126 | break |
---|
| 127 | case 'uicontrol' %if the mouse is over a uicontrol, duplicate the display in an editable zoom window |
---|
| 128 | if isequal(get(hObject,'SelectionType'),'alt') && isequal(get(hchild,'Visible'),'on') && ~isequal(get(hchild,'tag'),'frame_object')&&... |
---|
[302] | 129 | ~isequal(get(hchild,'tag'),'ListObject') |
---|
[309] | 130 | % if strcmp(get(hchild,'Visible'),'on') |
---|
| 131 | if ~strcmp(get(hchild,'Style'),'frame')%do not visualisaze frames |
---|
[296] | 132 | msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4); |
---|
| 133 | output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],'',get(hchild,'String'),msg_pos); |
---|
| 134 | break |
---|
| 135 | end |
---|
| 136 | end |
---|
| 137 | case 'uipanel' |
---|
| 138 | panel_pos=obj_pos;%position of the panel |
---|
| 139 | hhchildren=get(hchild,'Children');%handles of all objects in the current GUI |
---|
| 140 | %% loop on all the objects in the current figure (selected by the last mouse click) |
---|
| 141 | for iichild=1:length(hhchildren) |
---|
| 142 | hchild=hhchildren(iichild); |
---|
| 143 | rel_pos=get(hchild,'Position');%position of the object relative to the uipanel |
---|
| 144 | obj_pos(1:2)=panel_pos(1:2)+rel_pos(1:2).*panel_pos(3:4); |
---|
| 145 | obj_pos(3:4)=panel_pos(3:4).*rel_pos(3:4); |
---|
| 146 | 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); |
---|
| 147 | htype=get(hchild,'Type');%type of object child of the current figure |
---|
| 148 | %if the mouse is over a uicontrol, look at the data |
---|
| 149 | if strcmp(htype,'uicontrol') && strcmp(get(hchild,'Visible'),'on') |
---|
| 150 | msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4); |
---|
| 151 | output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],'',get(hchild,'String'),msg_pos); |
---|
| 152 | break |
---|
| 153 | end |
---|
| 154 | end |
---|
| 155 | end |
---|
[11] | 156 | end |
---|
| 157 | end |
---|
| 158 | end |
---|
[296] | 159 | if ~isempty(output_str) |
---|
| 160 | set(hObject,'Units','pixels') |
---|
| 161 | set(hchild,'String',output_str) |
---|
| 162 | end |
---|
| 163 | |
---|
[187] | 164 | %% desable object creation and vector editing if NbDim different from 2 |
---|
| 165 | if ~(isfield(AxeData,'NbDim') && isequal(AxeData.NbDim,2)) |
---|
[11] | 166 | test_create=0; |
---|
[187] | 167 | test_edit_vect=0; |
---|
[11] | 168 | end |
---|
[187] | 169 | |
---|
| 170 | %% delete the current zoom rectangle |
---|
[11] | 171 | if isfield(AxeData,'CurrentRectZoom') & ishandle(AxeData.CurrentRectZoom) |
---|
| 172 | delete(AxeData.CurrentRectZoom) |
---|
| 173 | AxeData.CurrentRectZoom=[]; |
---|
| 174 | end |
---|
| 175 | |
---|
[156] | 176 | %% zoom has first priority |
---|
[150] | 177 | if test_zoom %&& ~test_create && ~test_edit && ~test_edit_vect && exist('xy','var') |
---|
[11] | 178 | AxeData.Drawing='zoom'; %initiate drawing mode |
---|
| 179 | AxeData.CurrentObject=[];%unselect objects |
---|
[296] | 180 | set(hchild,'UserData',AxeData); |
---|
[67] | 181 | return |
---|
| 182 | end |
---|
[156] | 183 | if isempty(huvmat)%further options require the uvmat GUI |
---|
| 184 | return |
---|
[67] | 185 | end |
---|
| 186 | |
---|
[156] | 187 | %% ruler has second priority |
---|
[71] | 188 | if test_ruler |
---|
[156] | 189 | AxeData.RulerCoord(1,1)=xy(1,1); |
---|
| 190 | AxeData.RulerCoord(1,2)=xy(1,2); |
---|
| 191 | AxeData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler'); |
---|
[71] | 192 | AxeData.Drawing='ruler'; |
---|
[296] | 193 | set(hchild,'UserData',AxeData); |
---|
[71] | 194 | return |
---|
| 195 | end |
---|
| 196 | |
---|
[156] | 197 | %% selection of an existing projection object (third priority) |
---|
[67] | 198 | if test_edit && (isequal(tag_obj,'proj_object')||isequal(tag_obj,'DeformPoint')) |
---|
| 199 | if ~(isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'create')) |
---|
| 200 | userdata=get(hcurrentobject,'UserData'); |
---|
| 201 | if ishandle(userdata)%the selected line depends on a parent line |
---|
| 202 | AxeData.CurrentObject=userdata;% the parent object becomes the current one |
---|
| 203 | else |
---|
| 204 | AxeData.CurrentObject=hcurrentobject;% the selected object becomes the current one |
---|
| 205 | end |
---|
| 206 | ObjectData=get(AxeData.CurrentObject,'UserData'); |
---|
[102] | 207 | if test_edit && isfield(ObjectData,'IndexObj') |
---|
[67] | 208 | hother=findobj('Tag','proj_object','Type','line');%find all the proj objects |
---|
| 209 | set(hother,'Color','b');%reset all the proj objects in 'blue' by default |
---|
| 210 | set(hother,'Selected','off') |
---|
| 211 | hother=findobj('Tag','proj_object','Type','rectangle'); |
---|
| 212 | set(hother,'EdgeColor','b'); |
---|
| 213 | set(hother,'Selected','off'); |
---|
| 214 | hother=findobj('Tag','proj_object','Type','image'); |
---|
| 215 | for iobj=1:length(hother) |
---|
| 216 | Acolor=get(hother(iobj),'CData'); |
---|
| 217 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); |
---|
| 218 | set(hother(iobj),'CData',Acolor); |
---|
[11] | 219 | end |
---|
[67] | 220 | hother=findobj('Tag','DeformPoint'); |
---|
| 221 | set(hother,'Color','b'); |
---|
| 222 | set(hother,'Selected','off') |
---|
| 223 | if isequal(get(AxeData.CurrentObject,'Type'),'line') |
---|
| 224 | set(AxeData.CurrentObject,'Color','m'); %set the selected object to magenta color |
---|
| 225 | elseif isequal(get(AxeData.CurrentObject,'Type'),'rectangle') |
---|
| 226 | set(AxeData.CurrentObject,'EdgeColor','m'); %set the selected object to magenta color |
---|
| 227 | end |
---|
| 228 | if isfield(ObjectData,'SubObject')& ishandle(ObjectData.SubObject) |
---|
| 229 | for iobj=1:length(ObjectData.SubObject) |
---|
| 230 | hsub=ObjectData.SubObject(iobj); |
---|
| 231 | if isequal(get(hsub,'Type'),'rectangle') |
---|
| 232 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color |
---|
| 233 | elseif isequal(get(hsub,'Type'),'image') |
---|
| 234 | Acolor=get(hsub,'CData'); |
---|
| 235 | Acolor(:,:,1)=Acolor(:,:,3); |
---|
| 236 | set(hsub,'CData',Acolor); |
---|
| 237 | else |
---|
| 238 | set(hsub,'Color','m') |
---|
[11] | 239 | end |
---|
| 240 | end |
---|
[67] | 241 | end |
---|
| 242 | if isequal(tag_obj,'DeformPoint') |
---|
| 243 | set(hcurrentobject,'Color','m'); %set the selected DeformPoint to magenta color |
---|
| 244 | end |
---|
| 245 | IndexObj=ObjectData.IndexObj; |
---|
[71] | 246 | %indicate on the list of the GUI uvmat which object has been selected |
---|
| 247 | if strcmp(get(hcurrentfig,'tag'),'uvmat') %if the uvmat graph has been selected, object projection is on the other frame view_field |
---|
[302] | 248 | IndexObj_old=get(hhuvmat.ListObject,'Value'); |
---|
| 249 | if IndexObj>IndexObj_old(1) |
---|
| 250 | IndexObj=[IndexObj_old(1) IndexObj]; |
---|
| 251 | else |
---|
| 252 | IndexObj=[1 IndexObj]; |
---|
| 253 | end |
---|
| 254 | set(hhuvmat.ListObject,'Value',IndexObj); |
---|
| 255 | set(hhuvmat.ListObject,'UserData',IndexObj); |
---|
| 256 | % list_str=get(hhuvmat.list_object_2,'String'); |
---|
| 257 | % UvData.Object{IndexObj(2)}.Name=list_str{IndexObj}; |
---|
[71] | 258 | else |
---|
[302] | 259 | set(hhuvmat.ListObject,'Value',IndexObj); |
---|
| 260 | list_str=get(hhuvmat.ListObject,'String'); |
---|
[102] | 261 | UvData.Object{IndexObj}.Name=list_str{IndexObj}; |
---|
[71] | 262 | end |
---|
[102] | 263 | h_set_object=findobj(allchild(0),'Tag','set_object'); |
---|
| 264 | if ~isempty(h_set_object) |
---|
| 265 | delete(h_set_object) |
---|
| 266 | end |
---|
| 267 | set_object(UvData.Object{IndexObj}) |
---|
[296] | 268 | axes(hchild);%set back the current axes haxes |
---|
[67] | 269 | testdeform=0; |
---|
| 270 | set(gcbo,'Pointer','circle'); |
---|
| 271 | AxeData.Drawing='deform'; |
---|
| 272 | if isequal(tag_obj,'DeformPoint') |
---|
| 273 | if isfield(ObjectData,'DeformPoint') |
---|
| 274 | set(hcurrentobject,'Selected','on') |
---|
| 275 | for ipt=1:length(ObjectData.DeformPoint) |
---|
| 276 | if isequal(ObjectData.DeformPoint(ipt),hcurrentobject) |
---|
| 277 | AxeData.CurrentIndex=ipt; |
---|
| 278 | testdeform=1; |
---|
[11] | 279 | end |
---|
| 280 | end |
---|
[67] | 281 | end |
---|
[11] | 282 | end |
---|
[67] | 283 | if testdeform==0 |
---|
| 284 | AxeData.Drawing='translate'; |
---|
| 285 | set(AxeData.CurrentObject,'Selected','on') |
---|
| 286 | set(gcbo,'Pointer','fleur'); |
---|
| 287 | end |
---|
[11] | 288 | end |
---|
| 289 | end |
---|
[67] | 290 | end |
---|
[156] | 291 | |
---|
| 292 | %% create new projection object |
---|
[67] | 293 | if test_create && ~isempty(xy) && ~(isfield(AxeData,'Drawing')&& isequal(AxeData.Drawing,'create')) |
---|
[156] | 294 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 295 | if ~isempty(hset_object) |
---|
| 296 | sethandles=guidata(hset_object); |
---|
[231] | 297 | ObjectData=read_set_object(sethandles); %read object features in the GUI set_object |
---|
[156] | 298 | ObjectData.Coord=[]; %reset previous object coordinates |
---|
| 299 | ObjectData.Coord(1,1)=xy(1,1); |
---|
| 300 | ObjectData.Coord(1,2)=xy(1,2); |
---|
| 301 | ObjectData.Coord(1,3)=0; |
---|
| 302 | if isfield(AxeData,'ObjectCoord') & size(AxeData.ObjectCoord,2)==3 |
---|
| 303 | ObjectData.Coord(1,3)=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle |
---|
| 304 | end |
---|
| 305 | AxeData.CurrentObject=plot_object(ObjectData,[],haxes,'m');%draw the object and its handle becomes AxeData.CurrentObject |
---|
| 306 | if isfield(UvData,'Object') |
---|
| 307 | IndexObj=length(UvData.Object)+1;% add the object as index IndexObj on the list of the interface |
---|
| 308 | else |
---|
| 309 | IndexObj=2; |
---|
| 310 | end |
---|
| 311 | UvData.Object{IndexObj}=ObjectData; |
---|
[302] | 312 | list_str=get(hhuvmat.ListObject,'String'); |
---|
| 313 | IndexObj_old=get(hhuvmat.ListObject,'Value'); |
---|
| 314 | set(hhuvmat.ListObject,'Value',[IndexObj_old(1) IndexObj] ); |
---|
| 315 | UvData.Object{IndexObj}.DisplayHandle_uvmat=AxeData.CurrentObject; |
---|
[156] | 316 | object_name=get(sethandles.TITLE,'String'); |
---|
| 317 | if isempty(object_name)|| strcmp(object_name,'') |
---|
| 318 | list_str{IndexObj}=[num2str(IndexObj) '-' ObjectData.Style]; |
---|
| 319 | set(sethandles.TITLE,'String',list_str{IndexObj}) |
---|
| 320 | else |
---|
| 321 | list_str{IndexObj}=object_name; |
---|
| 322 | end |
---|
[302] | 323 | set(hhuvmat.ListObject,'String',list_str) |
---|
| 324 | UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject; |
---|
[231] | 325 | %list_str{end+1}='...'; |
---|
[302] | 326 | % set(hhuvmat.list_object_2,'String',list_str) |
---|
| 327 | % if strcmp(fig_tag,'view_field')%we are in view_field plot |
---|
| 328 | % set(hhuvmat.list_object_1,'Value',IndexObj)% the projection field will be plotted in uvmat frame |
---|
| 329 | % UvData.Object{IndexObj}.DisplayHandle_uvmat=[]; |
---|
| 330 | % UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject; |
---|
| 331 | % else%we are in uvmat plot |
---|
| 332 | % set(hhuvmat.list_object_2,'Value',IndexObj) |
---|
| 333 | % UvData.Object{IndexObj}.DisplayHandle_uvmat=AxeData.CurrentObject; |
---|
| 334 | % UvData.Object{IndexObj}.DisplayHandle_view_field=[]; |
---|
| 335 | % end |
---|
[156] | 336 | set(huvmat,'UserData',UvData) |
---|
| 337 | PlotData=get(AxeData.CurrentObject,'UserData'); |
---|
| 338 | PlotData.IndexObj=IndexObj; |
---|
| 339 | set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph |
---|
| 340 | AxeData.Drawing='create'; |
---|
[11] | 341 | end |
---|
[67] | 342 | end |
---|
[11] | 343 | |
---|
[67] | 344 | % create calibration points if the GUI geometry_calib is opened, if the main axes axes3 of uvmat has ben selected |
---|
[150] | 345 | if ~test_zoom && test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'axes3') |
---|
[67] | 346 | h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI |
---|
| 347 | hh_geometry_calib=guidata(h_geometry_calib); |
---|
| 348 | h_edit_append=hh_geometry_calib.edit_append;%findobj(h_geometry_calib,'Tag','edit_append'); |
---|
[78] | 349 | if isequal(get(h_edit_append,'Value'),1) && ~isempty(haxes) |
---|
[156] | 350 | h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord'); |
---|
[67] | 351 | coord_value=get(hhuvmat.transform_fct,'Value');% set uvmat to pixel coordinates, run it again if not |
---|
| 352 | if ~(isequal(coord_value,1)||isequal(coord_value,3)); %active only with no transform or px (no phys) |
---|
| 353 | set(hhuvmat.transform_fct,'Value',1) |
---|
[71] | 354 | uvmat('transform_fct_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat |
---|
[67] | 355 | set(hhuvmat.FixedLimits,'Value',0)% put FixedLimits option to 'off' |
---|
| 356 | set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 357 | return |
---|
[11] | 358 | end |
---|
[67] | 359 | Coord=get(h_ListCoord,'String'); |
---|
[71] | 360 | data=read_geometry_calib(Coord);%transform char cell to numbers |
---|
[78] | 361 | xlim=get(haxes,'XLim'); |
---|
| 362 | ind_range_x=abs((xlim(2)-xlim(1))/50); |
---|
| 363 | ylim=get(haxes,'YLim'); |
---|
| 364 | ind_range_y=abs((ylim(2)-ylim(1))/50); |
---|
| 365 | ind_range=sqrt(ind_range_x*ind_range_y); |
---|
[67] | 366 | test_newpoint=1; |
---|
| 367 | if size(data.Coord,2)>=5 %if calibration points already exist |
---|
| 368 | XCoord=(data.Coord(:,4)); |
---|
| 369 | YCoord=(data.Coord(:,5)); |
---|
| 370 | index_point=find((XCoord<xy(1,1)+ind_range) & (XCoord>xy(1,1)-ind_range) & ...%flagx=1 for the vectors with x position selected by the mouse |
---|
| 371 | (YCoord<xy(1,2)+ind_range) & (YCoord>xy(1,2)-ind_range),1);%find the first calibration point in the neighborhood of the mouse |
---|
| 372 | test_newpoint=isempty(index_point);%test for no existing calibration point near the mouse position |
---|
| 373 | end |
---|
[78] | 374 | val=get(h_ListCoord,'Value'); |
---|
[67] | 375 | %create a new calib point if we are not close to an existing one |
---|
| 376 | if test_newpoint |
---|
| 377 | strline=[ ' | ' ' | ' ' | ' num2str(xy(1,1),4) ' | ' num2str(xy(1,2),4)]; |
---|
[78] | 378 | |
---|
[67] | 379 | if length(Coord)>=val |
---|
[71] | 380 | Coord(val+1:length(Coord)+1)=Coord(val:length(Coord));% push the list forward beyond the current point |
---|
[67] | 381 | end |
---|
| 382 | Coord{val}=strline; |
---|
| 383 | set(h_ListCoord,'String',Coord) |
---|
| 384 | data=read_geometry_calib(Coord);%transform char cell to numbers |
---|
| 385 | XCoord=data.Coord(:,4); |
---|
| 386 | YCoord=data.Coord(:,5); |
---|
| 387 | end |
---|
| 388 | hh=findobj('Tag','calib_points');%look for handle of calibration points |
---|
| 389 | if isempty(hh) |
---|
| 390 | hh=line(XCoord,YCoord,'Color','m','Tag','calib_points','LineStyle','.','Marker','+'); |
---|
[11] | 391 | else |
---|
[67] | 392 | set(hh,'XData',XCoord) |
---|
| 393 | set(hh,'YData',YCoord) |
---|
[11] | 394 | end |
---|
[78] | 395 | set(hh,'UserData',val)% flag the points to edit mode |
---|
[67] | 396 | hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle) |
---|
| 397 | if ~isempty(hhh) |
---|
[71] | 398 | set(hhh,'Position',[xy(1,1)-ind_range/2 xy(1,2)-ind_range/2 ind_range ind_range]) |
---|
[67] | 399 | else |
---|
[71] | 400 | rectangle('Curvature',[1 1],... |
---|
| 401 | 'Position',[xy(1,1)-ind_range/2 xy(1,2)-ind_range/2 ind_range ind_range],'EdgeColor','m',... |
---|
| 402 | 'LineStyle','-','Tag','calib_marker'); |
---|
| 403 | % line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','calib_marker','LineStyle','.','Marker','o','MarkerSize',ind_range); |
---|
[67] | 404 | end |
---|
[71] | 405 | AxeData.Drawing='calibration'; |
---|
[60] | 406 | end |
---|
[11] | 407 | end |
---|
[67] | 408 | |
---|
| 409 | % edit vectors |
---|
[156] | 410 | if test_edit_vect && ~isempty(ivec) |
---|
| 411 | %create the error flag FF if it does not exist |
---|
| 412 | if ~isfield(Field,'FF') |
---|
| 413 | Field.ListVarName=[Field.ListVarName 'FF']; |
---|
| 414 | Field.VarDimName=[Field.VarDimName Field.VarDimName{VarType{icell}.coord_x}]; |
---|
| 415 | nbvar=length(Field.ListVarName); |
---|
| 416 | Field.VarAttribute{nbvar}.Role='errorflag'; |
---|
| 417 | Field.FF=zeros(size(Field.X)); |
---|
[67] | 418 | end |
---|
[156] | 419 | if isequal(Field.FF(ivec),0) |
---|
[177] | 420 | Field.FF(ivec)=100; %mark vector #ivec as false |
---|
[67] | 421 | else |
---|
[156] | 422 | Field.FF(ivec)=0; |
---|
[67] | 423 | end |
---|
[292] | 424 | PlotParam=read_GUI(hcurrentfig); |
---|
[156] | 425 | plot_field(Field,haxes,PlotParam); |
---|
| 426 | eval(['FigData.' tagaxes '=Field;'])%record the modified field in FigData |
---|
| 427 | set(hcurrentfig,'UserData',FigData); |
---|
[67] | 428 | end |
---|
[11] | 429 | set(haxes,'UserData',AxeData); |
---|
| 430 | |
---|