source: trunk/src/mouse_down.m @ 622

Last change on this file since 622 was 622, checked in by sommeria, 11 years ago

mouse system for uvmat imrpoved

File size: 24.2 KB
Line 
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
24function xy=mouse_down(hObject,eventdata)
25
26%% look for parameters set by the current figure (handle=input parameter hObject)
27AxeData=[];%default data stored on the current axes
28FigData=get(hObject,'UserData'); %default data stored on the current object
29if 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
30    hcurrentfig=get(get(FigData,'parent'),'parent');%handle of the current GUI: zoom plot
31else
32    hcurrentfig=hObject; % handle of the current GUI: usual plot
33end
34hhcurrentfig=guidata(hcurrentfig);% tags of the children of the current GUI
35CheckZoom=0;
36if isfield(hhcurrentfig,'CheckZoom') && get(hhcurrentfig.CheckZoom,'Value');%test for zoom action, first priority
37    CheckZoom=1;
38end
39test_piv=isfield(FigData,'CivHandle');
40set(hcurrentfig,'Units','pixels')
41GUI_pos=get(hcurrentfig,'Position');%position of the GUI series on the screen (in pixels), used to position message boxes
42set(hcurrentfig,'Units','normalized')% back to current unit for fig position
43
44%% determine the currently selected items
45hcurrentobject=gco;% current object handle (selected by the mouse)
46fig_tag=get(hcurrentfig,'Tag');
47obj_tag=get(gco,'Tag');%tag of the currently selected object
48xy=[];%default
49xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
50haxes=[];
51
52%% look for parameters set by the GUI uvmat
53test_ruler=0;
54test_edit=0;
55test_create=0;
56huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls the option of  mouse action
57if ~isempty(huvmat)
58    hhuvmat=guidata(huvmat);%handles of elements in uvmat
59    UvData=get(huvmat,'UserData');
60    test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler  action, second priority;
61    test_edit=get(hhuvmat.edit_object,'Value')&& (isequal(obj_tag,'proj_object')||isequal(obj_tag,'DeformPoint'));%test for object editing, third priority
62    hset_object=findobj(allchild(0),'tag','set_object');
63    if ~isempty(hset_object)
64        hPLOT=findobj(hset_object,'tag','PLOT');
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'
66    end
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
68    test_cal=isequal(get(hhuvmat.MenuCalib,'checked'),'on');% test for calibration
69    if test_cal% test for calibration popints,  priority 6
70        h_calib=findobj(allchild(0),'tag','geometry_calib');
71        if isempty(h_calib)
72            test_cal=0;
73            set(hhuvmat.MenuCalib,'checked','off');% test for calibration off
74        else
75            hh_calib=guidata(h_calib);
76            test_cal=get(hh_calib.edit_append,'Value');
77        end
78    end
79end
80
81%% loop on all the objects in the current figure (selected by the last mouse click)
82hchildren=get(hObject,'Children');%handles of all objects in the current figure
83check_visible=strcmp(get(hchildren,'Visible'),'on');% if visible='on', =0 otherwise
84hchildren=hchildren(check_visible); %kkep only the visible children
85PosChildren=get(hchildren,'Position');% set of object positions
86if 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
90end
91if size(PosChildren,2)~=4
92    return
93end
94xy_fig_mat=ones(size(PosChildren,1),1)*xy_fig;% mouse position set to a matrix
95check_pos=xy_fig_mat >= PosChildren(:,1:2) & xy_fig_mat <= PosChildren(:,1:2)+PosChildren(:,3:4);% compare object to mouse position
96ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse
97hchild=hchildren(ind_object);% corresponding object handle
98if 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
114else
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
144                            end
145                        end
146                    end
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
168               
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);
183                    end
184                end
185            end
186            %   return %leave the function once a uicontrol has been selected
187    end
188end
189
190%% delete the current zoom rectangle
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
197if CheckZoom
198    return
199end
200
201%% creation of a zoom subfig
202if get(hhcurrentfig.CheckZoomFig,'Value')
203    AxeData.Drawing='zoom'; %initiate drawing mode
204    AxeData.CurrentObject=[];%unselect objects
205    set(hchild,'UserData',AxeData);
206    return
207end
208
209if isempty(huvmat)%further options require the uvmat GUI
210    return
211end
212
213%% ruler has second priority
214if test_ruler
215    AxeData.RulerCoord(1,1:2)=xy(1,1:2);
216    AxeData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler');
217    AxeData.Drawing='ruler';
218    set(hchild,'UserData',AxeData);
219    return
220end
221
222%% PIV test
223if test_piv
224    figure
225    newaxes=axes;
226    copyobj(AxeData.CurrentCorrImage,newaxes);
227    set(newaxes,'CLim',[0 1])
228    copyobj(AxeData.CurrentVector,newaxes)
229    copyobj(AxeData.TitleHandle,newaxes)
230    colorbar
231end
232
233%% desable  object creation and vector editing if NbDim different from 2
234if ~(isfield(AxeData,'NbDim') && isequal(AxeData.NbDim,2))
235    test_create=0;
236    test_edit_vect=0;
237end
238
239%% selection of an existing projection object (third priority)
240if  test_edit
241    if ~(isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'create'))
242        userdata=get(hcurrentobject,'UserData');
243        if ishandle(userdata)%the selected line depends on a parent line
244            AxeData.CurrentObject=userdata;% the parent object becomes the current one
245        else
246            AxeData.CurrentObject=hcurrentobject;% the selected object becomes the current one
247        end
248        ObjectData=get(AxeData.CurrentObject,'UserData');
249        if isfield(ObjectData,'IndexObj')
250            hother=findobj('Tag','proj_object','Type','line');%find all the proj objects
251            set(hother,'Color','b');%reset all the proj objects in 'blue' by default
252            set(hother,'Selected','off')
253            hother=findobj('Tag','proj_object','Type','rectangle');
254            set(hother,'EdgeColor','b');
255            set(hother,'Selected','off');
256            hother=findobj('Tag','proj_object','Type','image');
257            for iobj=1:length(hother)
258                   Acolor=get(hother(iobj),'CData');
259                   Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
260                   set(hother(iobj),'CData',Acolor);
261            end
262            hother=findobj('Tag','DeformPoint');
263            set(hother,'Color','b');
264            set(hother,'Selected','off')   
265            if isequal(get(AxeData.CurrentObject,'Type'),'line')
266                set(AxeData.CurrentObject,'Color','m'); %set the selected object to magenta color
267            elseif isequal(get(AxeData.CurrentObject,'Type'),'rectangle')
268                 set(AxeData.CurrentObject,'EdgeColor','m'); %set the selected object to magenta color
269            end
270            if isfield(ObjectData,'SubObject')& ishandle(ObjectData.SubObject)
271                for iobj=1:length(ObjectData.SubObject)
272                    hsub=ObjectData.SubObject(iobj);
273                    if isequal(get(hsub,'Type'),'rectangle')
274                        set(hsub,'EdgeColor','m'); %set the selected object to magenta color
275                    elseif isequal(get(hsub,'Type'),'image')
276                       Acolor=get(hsub,'CData');
277                       Acolor(:,:,1)=Acolor(:,:,3);
278                       set(hsub,'CData',Acolor);
279                    else
280                        set(hsub,'Color','m')
281                    end
282                end
283            end
284            if isequal(obj_tag,'DeformPoint')
285                 set(hcurrentobject,'Color','m'); %set the selected DeformPoint to magenta color
286            end
287            IndexObj=ObjectData.IndexObj;
288                    %indicate on the list of the GUI uvmat which object has been selected
289            if strcmp(get(hcurrentfig,'tag'),'uvmat') %if the uvmat graph has been selected, object projection is on the other frame view_field
290%                 IndexObj=get(hhuvmat.ListObject,'Value');
291%                 if IndexObj>IndexObj_old(1)
292%                     IndexObj=[IndexObj_old(1) IndexObj];
293%                 else
294%                     IndexObj=[1 IndexObj];
295%                 end
296                set(hhuvmat.ListObject,'Value',IndexObj);
297%                 set(hhuvmat.ListObject,'UserData',IndexObj);
298            else
299                set(hhuvmat.ListObject_1,'Value',IndexObj);
300                list_str=get(hhuvmat.ListObject_1,'String');
301                UvData.ProjObject{IndexObj}.Name=list_str{IndexObj};
302            end
303%             h_set_object=findobj(allchild(0),'Tag','set_object');
304%             if ~isempty(h_set_object)
305%                 delete(h_set_object)
306%             end
307            set_object(UvData.ProjObject{IndexObj})
308            axes(hchild);%set back the current axes haxes
309            testdeform=0;
310            set(gcbo,'Pointer','circle');
311            AxeData.Drawing='deform';
312            if isequal(obj_tag,'DeformPoint')       
313               if isfield(ObjectData,'DeformPoint')
314                   set(hcurrentobject,'Selected','on')
315                   for ipt=1:length(ObjectData.DeformPoint)
316                       if isequal(ObjectData.DeformPoint(ipt),hcurrentobject)
317                            AxeData.CurrentIndex=ipt;
318                            testdeform=1;
319                       end
320                   end
321               end
322            end
323            if testdeform==0
324                AxeData.Drawing='translate';
325                set(AxeData.CurrentObject,'Selected','on')
326                set(gcbo,'Pointer','fleur');
327            end
328        end
329    end
330end
331
332%%  create  projection  object
333if  test_create && ~isempty(xy)
334    % activate this option if the GUI set_object is opened
335    if ~isempty(hset_object) && ~strcmp(get(hcurrentfig,'SelectionType'),'alt')
336        sethandles=guidata(hset_object);% handles of the elements in the GUI set_object
337        ObjectData=read_GUI(hset_object); %read object parameters in the GUI set_object
338        IndexObj=length(UvData.ProjObject);
339        %initiate a new object (no data .Coord yet recorded)
340        if ~isfield(UvData.ProjObject{IndexObj},'Coord');
341            ObjectData.Coord=[];
342            ObjectNameNew=ObjectData.Name;
343            if isempty(ObjectNameNew)
344                ObjectNameNew=ObjectData.Type;
345            end
346            % add an index to the object name if the proposed name already exists
347            vers=0;% index of the name
348            ListObject=get(hhuvmat.ListObject,'String');
349            detectname=1;
350            while ~isempty(detectname)
351                detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
352                if detectname% if the object name already exists
353                    indstr=regexp(ObjectNameNew,'\D');
354                    if indstr(end)<length(ObjectNameNew) %object name ends by a number
355                        vers=str2double(ObjectNameNew(indstr(end)+1:end))+1;
356                        ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)];
357                    else
358                        vers=vers+1;
359                        ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];
360                    end
361                end
362            end
363            ObjectName=ObjectNameNew;
364            set(sethandles.Name,'String',ObjectName)% display the default name in set_object
365            if isempty(ListObject)
366                ListObject={ObjectName};
367            else
368                ListObject{end}=ObjectName;
369            end
370            set(hhuvmat.ListObject,'String',ListObject);%complement the object list
371            set(hhuvmat.ListObject_1,'String',ListObject);%complement the object list
372            set(hhuvmat.ListObject,'Value',IndexObj)
373            set(hhuvmat.ViewObject,'Value',1)
374        end
375        ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the coordinates marked by the mouse to the object
376                                                         %TODO replace 0 by z coord for 3D       
377        hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(fig_tag);
378        if isempty(hobject)
379            hobject=haxes;
380        end
381        ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')};
382        AxeData.CurrentObject=plot_object(ObjectData,ProjObject,hobject,'m');%draw the object and its handle becomes 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
385        set(huvmat,'UserData',UvData)
386        PlotData=get(AxeData.CurrentObject,'UserData');
387        PlotData.IndexObj=IndexObj;
388        set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph (memory used for mouse motion)
389        AxeData.Drawing='create';% flag for mouse motion
390        %show object coordinates in the GUI set_object
391        h_set_object=findobj(allchild(0),'Tag','set_object');
392        hh_set_object=guidata(h_set_object);
393        set(hh_set_object.Coord,'Data',ObjectData.Coord);
394    end
395end
396
397%% create calibration points if the GUI geometry_calib is opened, if the main axes PlotAxes of uvmat has ben selected
398if  test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'PlotAxes')
399    h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
400    hh_geometry_calib=guidata(h_geometry_calib);
401    h_edit_append=hh_geometry_calib.edit_append;%findobj(h_geometry_calib,'Tag','edit_append');
402    if isequal(get(h_edit_append,'Value'),1) && ~isempty(haxes)
403        h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
404        coord_value=get(hhuvmat.TransformName,'Value');% set uvmat to pixel coordinates, run it again if not
405        if ~(isequal(coord_value,1)||isequal(coord_value,3)); %active only with no transform or px (no phys)
406            set(hhuvmat.TransformName,'Value',1)
407            uvmat('TransformName_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat
408            set(hhuvmat.CheckFixedLimits,'Value',0)% put FixedLimits option to 'off'
409            set(hhuvmat.CheckFixedLimits,'BackgroundColor',[0.7 0.7 0.7])
410            return
411        end
412        Coord=get(h_ListCoord,'String');
413        data=read_geometry_calib(Coord);%transform char cell to numbers
414        xlim=get(haxes,'XLim');
415        ind_range_x=abs((xlim(2)-xlim(1))/50);
416        ylim=get(haxes,'YLim');
417        ind_range_y=abs((ylim(2)-ylim(1))/50);
418        ind_range=sqrt(ind_range_x*ind_range_y);
419        test_newpoint=1;
420        if size(data.Coord,2)>=5 %if calibration points already exist
421            XCoord=(data.Coord(:,4));
422            YCoord=(data.Coord(:,5));
423            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
424                          (YCoord<xy(1,2)+ind_range) & (YCoord>xy(1,2)-ind_range),1);%find the first calibration point in the neighborhood of the mouse
425            test_newpoint=isempty(index_point);%test for no existing calibration point near the mouse position
426        end
427        val=get(h_ListCoord,'Value');
428        %create a new calib point if we are not close to an existing one
429        if test_newpoint                 
430             strline=[ '    |    '  '    |    '  '    |    ' num2str(xy(1,1),4) '    |    ' num2str(xy(1,2),4)];
431           
432             if length(Coord)>=val
433                 Coord(val+1:length(Coord)+1)=Coord(val:length(Coord));% push the list forward beyond the current point
434             end
435             Coord{val}=strline;
436             set(h_ListCoord,'String',Coord)
437             data=read_geometry_calib(Coord);%transform char cell to numbers
438             XCoord=data.Coord(:,4);
439             YCoord=data.Coord(:,5);
440        end
441        hh=findobj('Tag','calib_points');%look for handle of calibration points           
442        if isempty(hh)
443            hh=line(XCoord,YCoord,'Color','m','Tag','calib_points','LineStyle','.','Marker','+');
444        else
445            set(hh,'XData',XCoord)
446            set(hh,'YData',YCoord)
447        end
448        set(hh,'UserData',val)% flag the points to edit mode
449        hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle)
450        if ~isempty(hhh)
451            set(hhh,'Position',[xy(1,1)-ind_range/2 xy(1,2)-ind_range/2 ind_range ind_range])
452        else
453            rectangle('Curvature',[1 1],...
454                  'Position',[xy(1,1)-ind_range/2 xy(1,2)-ind_range/2 ind_range ind_range],'EdgeColor','m',...
455                  'LineStyle','-','Tag','calib_marker');
456           % line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','calib_marker','LineStyle','.','Marker','o','MarkerSize',ind_range);
457        end
458        AxeData.Drawing='calibration';
459    end
460end
461
462%% edit vectors
463if test_edit_vect && ~isempty(ivec)
464    %create the error flag FF if it does not exist
465    if ~isfield(Field,'FF')
466        Field.ListVarName=[Field.ListVarName 'FF'];
467        Field.VarDimName=[Field.VarDimName Field.VarDimName{VarType{icell}.coord_x}];
468        nbvar=length(Field.ListVarName);
469        Field.VarAttribute{nbvar}.Role='errorflag';
470        Field.FF=zeros(size(Field.X));
471    end
472    if isequal(Field.FF(ivec),0)
473        Field.FF(ivec)=100; %mark vector #ivec as false
474    else
475        Field.FF(ivec)=0;
476    end
477    PlotParam=read_GUI(hcurrentfig);
478    plot_field(Field,haxes,PlotParam);
479    eval(['FigData.' tagaxes '=Field;'])%record the modified field in FigData
480    set(hcurrentfig,'UserData',FigData);
481end 
482set(haxes,'UserData',AxeData);
483
Note: See TracBrowser for help on using the repository browser.