source: trunk/src/mouse_down.m @ 575

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

various bugs corrected

File size: 22.9 KB
RevLine 
[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
24function xy=mouse_down(hObject,eventdata)
[332]25AxeData=[];%default
[187]26FigData=get(hObject,'UserData');
27if 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');
29else
30    hcurrentfig=hObject;%usual plot
31end
[296]32set(hcurrentfig,'Units','pixels')
33GUI_pos=get(hcurrentfig,'Position');%position of the GUI series (in pixels)
34set(hcurrentfig,'Units','normalized')
[187]35hhcurrentfig=guidata(hcurrentfig);
[309]36if isfield(hhcurrentfig,'CheckZoom')
[332]37    test_zoom=get(hhcurrentfig.CheckZoom,'Value');%test for zoom action, first priority
[309]38else
39    test_zoom=0;
40end
[413]41test_piv=isfield(FigData,'CivHandle');
[332]42
43%% look for parameters set by the GUI uvmat
44test_ruler=0;
45test_edit=0;
46test_create=0;
47huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls theoption of  mouse action
48if ~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
[413]54    %     test_create=isequal(get(hhuvmat.MenuObject,'checked'),'on');% test for object creation,  priority 5
55    %     if test_create
56    test_create=0;
57    hset_object=findobj(allchild(0),'tag','set_object');
[429]58
[413]59    if ~isempty(hset_object)
60        hPLOT=findobj(hset_object,'tag','PLOT');
[429]61        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'
[156]62    end
[413]63   
[332]64    test_cal=isequal(get(hhuvmat.MenuCalib,'checked'),'on');% test for calibration
65    if test_cal% test for calibration popints,  priority 6
66        h_calib=findobj(allchild(0),'tag','geometry_calib');
67        if isempty(h_calib)
68            test_cal=0;
69            set(hhuvmat.MenuCalib,'checked','off');% test for calibration off
70        else
71            hh_calib=guidata(h_calib);
72            test_cal=get(hh_calib.edit_append,'Value');
73        end
74    end
[156]75end
[11]76
[177]77%% determine the currently selected items
[11]78hcurrentobject=gco;% current object handle (selected by the mouse)
[187]79%hcurrentfig=hObject;% current figure handle
[62]80fig_tag=get(hcurrentfig,'Tag');
[177]81tag_obj=get(gco,'Tag');%tag of the currently selected object
[11]82xy=[];%default
[187]83xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
[296]84hchildren=get(hObject,'Children');%handles of all objects in the current figure
[67]85haxes=[];
[156]86
87%% loop on all the objects in the current figure (selected by the last mouse click)
[296]88output_str='';
[309]89state_visible=get(hchildren,'Visible');
90check_visible=strcmp('on',state_visible);%=1 if visible='on', =0 otherwise
91hchildren=hchildren(find(check_visible)); %kkep only the visible children
[296]92for ichild=1:length(hchildren)
[309]93    hchild=hchildren(ichild); %handle of the current obj
[296]94    obj_pos=get(hchild,'Position');%position of the object
[11]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);
[296]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
[543]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)
[296]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)
[512]112                            Field=FigData.(tagaxes);
113                            [CellVarIndex,NbDim,VarType]=find_field_cells(Field);%analyse the physical fields contained in Field
[296]114                            for icell=1:numel(CellVarIndex)%look for all physical fields
115                                if NbDim(icell)==2 % select 2D field
[575]116                                    if  isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& ~isempty(VarType{icell}.coord_x) && ~isempty(VarType{icell}.coord_y)%case of unstructured data
[296]117                                        eval(['X=Field.' Field.ListVarName{VarType{icell}.coord_x} ';'])
118                                        eval(['Y=Field.' Field.ListVarName{VarType{icell}.coord_y} ';'])
[575]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
[296]121                                        ivec=find(flag_vec,1);% search the (first) selected vector index ivec
122                                    end
[156]123                                end
124                            end
125                        end
[78]126                    end
[543]127%                 else
128%                     hchild=[];%mouse out of axes
129%                 end
[296]130                break
[521]131               
[497]132            %if the mouse is over a uicontrol, duplicate the display  in an editable  zoom window
133            case 'uicontrol'
[296]134                if isequal(get(hObject,'SelectionType'),'alt')  && isequal(get(hchild,'Visible'),'on') && ~isequal(get(hchild,'tag'),'frame_object')&&...
[302]135                        ~isequal(get(hchild,'tag'),'ListObject')
[309]136                    if ~strcmp(get(hchild,'Style'),'frame')%do not visualisaze frames
[296]137                        msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
[497]138                        display_str=get(hchild,'TooltipString');
139                        output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],display_str,get(hchild,'String'),msg_pos);
[296]140                        break
141                    end
142                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);
[497]157                            display_str=get(hchild,'TooltipString');
158                            output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],display_str,get(hchild,'String'),msg_pos);
[296]159                            break
160                        end
161                    end
162                end
[11]163        end
[456]164        if ~isempty(output_str)
165            break   %leave the current loop if a uicontrol has been selected
166        end
[11]167    end
168end
[296]169if ~isempty(output_str)               
170    set(hObject,'Units','pixels')
[497]171    if strcmp(get(hchild,'enable'),'on')
[521]172    set(hchild,'String',output_str)% fill the parent uicontrol with the sttring edited in the msgbox
[497]173    end
[296]174end
175   
[187]176%% desable  object creation and vector editing if NbDim different from 2
177if ~(isfield(AxeData,'NbDim') && isequal(AxeData.NbDim,2))
[11]178    test_create=0;
[187]179    test_edit_vect=0;   
[11]180end
[187]181
182%% delete the current zoom rectangle
[534]183if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)
[11]184    delete(AxeData.CurrentRectZoom)
185    AxeData.CurrentRectZoom=[];
186end   
187
[156]188%% zoom has first priority
[150]189if test_zoom %&& ~test_create && ~test_edit && ~test_edit_vect && exist('xy','var')
[11]190     AxeData.Drawing='zoom'; %initiate drawing mode
191     AxeData.CurrentObject=[];%unselect objects
[296]192     set(hchild,'UserData',AxeData);
[67]193     return
194end
[156]195if isempty(huvmat)%further options require the uvmat GUI
196    return
[67]197end
198
[156]199%% ruler has second priority
[71]200if test_ruler
[156]201    AxeData.RulerCoord(1,1)=xy(1,1);
202    AxeData.RulerCoord(1,2)=xy(1,2);
203    AxeData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler');
[71]204    AxeData.Drawing='ruler';
[296]205    set(hchild,'UserData',AxeData);
[71]206    return
207end
208
[413]209%% PIV test
210if test_piv
211    figure
212    newaxes=axes;
213    copyobj(AxeData.CurrentCorrImage,newaxes);
214    set(newaxes,'CLim',[0 1])
215    copyobj(AxeData.CurrentVector,newaxes)
216    copyobj(AxeData.TitleHandle,newaxes)
217    colorbar
218end
219
[156]220%% selection of an existing projection object (third priority)
[67]221if  test_edit && (isequal(tag_obj,'proj_object')||isequal(tag_obj,'DeformPoint'))
222    if ~(isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'create'))
223        userdata=get(hcurrentobject,'UserData');
224        if ishandle(userdata)%the selected line depends on a parent line
225            AxeData.CurrentObject=userdata;% the parent object becomes the current one
226        else
227            AxeData.CurrentObject=hcurrentobject;% the selected object becomes the current one
228        end
229        ObjectData=get(AxeData.CurrentObject,'UserData');
[102]230        if test_edit && isfield(ObjectData,'IndexObj')
[67]231            hother=findobj('Tag','proj_object','Type','line');%find all the proj objects
232            set(hother,'Color','b');%reset all the proj objects in 'blue' by default
233            set(hother,'Selected','off')
234            hother=findobj('Tag','proj_object','Type','rectangle');
235            set(hother,'EdgeColor','b');
236            set(hother,'Selected','off');
237            hother=findobj('Tag','proj_object','Type','image');
238            for iobj=1:length(hother)
239                   Acolor=get(hother(iobj),'CData');
240                   Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
241                   set(hother(iobj),'CData',Acolor);
[11]242            end
[67]243            hother=findobj('Tag','DeformPoint');
244            set(hother,'Color','b');
245            set(hother,'Selected','off')   
246            if isequal(get(AxeData.CurrentObject,'Type'),'line')
247                set(AxeData.CurrentObject,'Color','m'); %set the selected object to magenta color
248            elseif isequal(get(AxeData.CurrentObject,'Type'),'rectangle')
249                 set(AxeData.CurrentObject,'EdgeColor','m'); %set the selected object to magenta color
250            end
251            if isfield(ObjectData,'SubObject')& ishandle(ObjectData.SubObject)
252                for iobj=1:length(ObjectData.SubObject)
253                    hsub=ObjectData.SubObject(iobj);
254                    if isequal(get(hsub,'Type'),'rectangle')
255                        set(hsub,'EdgeColor','m'); %set the selected object to magenta color
256                    elseif isequal(get(hsub,'Type'),'image')
257                       Acolor=get(hsub,'CData');
258                       Acolor(:,:,1)=Acolor(:,:,3);
259                       set(hsub,'CData',Acolor);
260                    else
261                        set(hsub,'Color','m')
[11]262                    end
263                end
[67]264            end
265            if isequal(tag_obj,'DeformPoint')
266                 set(hcurrentobject,'Color','m'); %set the selected DeformPoint to magenta color
267            end
268            IndexObj=ObjectData.IndexObj;
[71]269                    %indicate on the list of the GUI uvmat which object has been selected
270            if strcmp(get(hcurrentfig,'tag'),'uvmat') %if the uvmat graph has been selected, object projection is on the other frame view_field
[410]271%                 IndexObj=get(hhuvmat.ListObject,'Value');
272%                 if IndexObj>IndexObj_old(1)
273%                     IndexObj=[IndexObj_old(1) IndexObj];
274%                 else
275%                     IndexObj=[1 IndexObj];
276%                 end
[302]277                set(hhuvmat.ListObject,'Value',IndexObj);
[410]278%                 set(hhuvmat.ListObject,'UserData',IndexObj);
[71]279            else
[410]280                set(hhuvmat.ListObject_1,'Value',IndexObj);
281                list_str=get(hhuvmat.ListObject_1,'String');
[102]282                UvData.Object{IndexObj}.Name=list_str{IndexObj};
[71]283            end
[424]284%             h_set_object=findobj(allchild(0),'Tag','set_object');
285%             if ~isempty(h_set_object)
286%                 delete(h_set_object)
287%             end
[102]288            set_object(UvData.Object{IndexObj})
[296]289            axes(hchild);%set back the current axes haxes
[67]290            testdeform=0;
291            set(gcbo,'Pointer','circle');
292            AxeData.Drawing='deform';
293            if isequal(tag_obj,'DeformPoint')       
294               if isfield(ObjectData,'DeformPoint')
295                   set(hcurrentobject,'Selected','on')
296                   for ipt=1:length(ObjectData.DeformPoint)
297                       if isequal(ObjectData.DeformPoint(ipt),hcurrentobject)
298                            AxeData.CurrentIndex=ipt;
299                            testdeform=1;
[11]300                       end
301                   end
[67]302               end
[11]303            end
[67]304            if testdeform==0
305                AxeData.Drawing='translate';
306                set(AxeData.CurrentObject,'Selected','on')
307                set(gcbo,'Pointer','fleur');
308            end
[11]309        end
310    end
[67]311end
[156]312
[429]313%%  create  projection  object
314if  test_create && ~isempty(xy) %&& ~(isfield(AxeData,'Drawing')&& isequal(AxeData.Drawing,'create'))
[402]315    hset_object=findobj(allchild(0),'tag','set_object');
[410]316    % activate this option if the GUI set_object is opened
[402]317    if ~isempty(hset_object)
[429]318        sethandles=guidata(hset_object);% handles of the elements in the GUI set_object
[410]319        ObjectData=read_GUI(hset_object); %read object parameters in the GUI set_object
[429]320        IndexObj=length(UvData.Object);
[432]321        %initiate a new object (no data .Coord yet recorded)
322        if ~isfield(UvData.Object{IndexObj},'Coord');
[429]323            ObjectData.Coord=[];
324            ObjectNameNew=ObjectData.Name;
325            if isempty(ObjectNameNew)
326                ObjectNameNew=ObjectData.Type;
327            end
[432]328            % add an index to the object name if the proposed name already exists         
[429]329            vers=0;% index of the name
330            ListObject=get(hhuvmat.ListObject,'String');
331            detectname=1;
332            while ~isempty(detectname)
333                detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
334                if detectname% if the object name already exists
335                    indstr=regexp(ObjectNameNew,'\D');
336                    if indstr(end)<length(ObjectNameNew) %object name ends by a number
337                        vers=str2double(ObjectNameNew(indstr(end)+1:end))+1;
338                        ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)];
339                    else
340                        vers=vers+1;
341                        ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];
342                    end
[402]343                end
[156]344            end
[429]345            ObjectName=ObjectNameNew;
346            set(sethandles.Name,'String',ObjectName)% display the default name in set_object
[534]347            if isempty(ListObject)
348                ListObject={ObjectName};
349            else
[429]350            ListObject{end}=ObjectName;
[534]351            end
[429]352            set(hhuvmat.ListObject,'String',ListObject);%complement the object list
353            set(hhuvmat.ListObject_1,'String',ListObject);%complement the object list
354            set(hhuvmat.ListObject,'Value',IndexObj)
355            set(hhuvmat.ViewObject,'Value',1)
[11]356        end
[429]357        ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the coordinates marked by the mouse to the object
[432]358        hobject=UvData.Object{IndexObj}.DisplayHandle.(fig_tag);
359        if isempty(hobject)
360            hobject=haxes;
361        end
362        ProjObject=UvData.Object{get(hhuvmat.ListObject_1,'Value')};
363        AxeData.CurrentObject=plot_object(ObjectData,ProjObject,hobject,'m');%draw the object and its handle becomes AxeData.CurrentObject
[429]364        UvData.Object{IndexObj}=ObjectData;     
[432]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;
[402]367        set(huvmat,'UserData',UvData)
368        PlotData=get(AxeData.CurrentObject,'UserData');
369        PlotData.IndexObj=IndexObj;
[410]370        set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph (memory used for mouse motion)
371        AxeData.Drawing='create';% flag for mouse motion
[429]372        %show object coordinates in the GUI set_object
373        h_set_object=findobj(allchild(0),'Tag','set_object');
374        hh_set_object=guidata(h_set_object);
375        set(hh_set_object.Coord,'Data',ObjectData.Coord);
[402]376    end
[67]377end
[11]378
[541]379%% create calibration points if the GUI geometry_calib is opened, if the main axes PlotAxes of uvmat has ben selected
380if ~test_zoom && test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'PlotAxes')
[67]381    h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
382    hh_geometry_calib=guidata(h_geometry_calib);
383    h_edit_append=hh_geometry_calib.edit_append;%findobj(h_geometry_calib,'Tag','edit_append');
[78]384    if isequal(get(h_edit_append,'Value'),1) && ~isempty(haxes)
[156]385        h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
[67]386        coord_value=get(hhuvmat.transform_fct,'Value');% set uvmat to pixel coordinates, run it again if not
387        if ~(isequal(coord_value,1)||isequal(coord_value,3)); %active only with no transform or px (no phys)
388            set(hhuvmat.transform_fct,'Value',1)
[71]389            uvmat('transform_fct_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat
[342]390            set(hhuvmat.CheckFixedLimits,'Value',0)% put FixedLimits option to 'off'
391            set(hhuvmat.CheckFixedLimits,'BackgroundColor',[0.7 0.7 0.7])
[67]392            return
[11]393        end
[67]394        Coord=get(h_ListCoord,'String');
[71]395        data=read_geometry_calib(Coord);%transform char cell to numbers
[78]396        xlim=get(haxes,'XLim');
397        ind_range_x=abs((xlim(2)-xlim(1))/50);
398        ylim=get(haxes,'YLim');
399        ind_range_y=abs((ylim(2)-ylim(1))/50);
400        ind_range=sqrt(ind_range_x*ind_range_y);
[67]401        test_newpoint=1;
402        if size(data.Coord,2)>=5 %if calibration points already exist
403            XCoord=(data.Coord(:,4));
404            YCoord=(data.Coord(:,5));
405            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
406                          (YCoord<xy(1,2)+ind_range) & (YCoord>xy(1,2)-ind_range),1);%find the first calibration point in the neighborhood of the mouse
407            test_newpoint=isempty(index_point);%test for no existing calibration point near the mouse position
408        end
[78]409        val=get(h_ListCoord,'Value');
[67]410        %create a new calib point if we are not close to an existing one
411        if test_newpoint                 
412             strline=[ '    |    '  '    |    '  '    |    ' num2str(xy(1,1),4) '    |    ' num2str(xy(1,2),4)];
[78]413           
[67]414             if length(Coord)>=val
[71]415                 Coord(val+1:length(Coord)+1)=Coord(val:length(Coord));% push the list forward beyond the current point
[67]416             end
417             Coord{val}=strline;
418             set(h_ListCoord,'String',Coord)
419             data=read_geometry_calib(Coord);%transform char cell to numbers
420             XCoord=data.Coord(:,4);
421             YCoord=data.Coord(:,5);
422        end
423        hh=findobj('Tag','calib_points');%look for handle of calibration points           
424        if isempty(hh)
425            hh=line(XCoord,YCoord,'Color','m','Tag','calib_points','LineStyle','.','Marker','+');
[11]426        else
[67]427            set(hh,'XData',XCoord)
428            set(hh,'YData',YCoord)
[11]429        end
[78]430        set(hh,'UserData',val)% flag the points to edit mode
[67]431        hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle)
432        if ~isempty(hhh)
[71]433            set(hhh,'Position',[xy(1,1)-ind_range/2 xy(1,2)-ind_range/2 ind_range ind_range])
[67]434        else
[71]435            rectangle('Curvature',[1 1],...
436                  'Position',[xy(1,1)-ind_range/2 xy(1,2)-ind_range/2 ind_range ind_range],'EdgeColor','m',...
437                  'LineStyle','-','Tag','calib_marker');
438           % 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]439        end
[71]440        AxeData.Drawing='calibration';
[60]441    end
[11]442end
[67]443
[429]444%% edit vectors
[156]445if test_edit_vect && ~isempty(ivec)
446    %create the error flag FF if it does not exist
447    if ~isfield(Field,'FF')
448        Field.ListVarName=[Field.ListVarName 'FF'];
449        Field.VarDimName=[Field.VarDimName Field.VarDimName{VarType{icell}.coord_x}];
450        nbvar=length(Field.ListVarName);
451        Field.VarAttribute{nbvar}.Role='errorflag';
452        Field.FF=zeros(size(Field.X));
[67]453    end
[156]454    if isequal(Field.FF(ivec),0)
[177]455        Field.FF(ivec)=100; %mark vector #ivec as false
[67]456    else
[156]457        Field.FF(ivec)=0;
[67]458    end
[292]459    PlotParam=read_GUI(hcurrentfig);
[156]460    plot_field(Field,haxes,PlotParam);
461    eval(['FigData.' tagaxes '=Field;'])%record the modified field in FigData
462    set(hcurrentfig,'UserData',FigData);
[429]463end 
[11]464set(haxes,'UserData',AxeData);
465
Note: See TracBrowser for help on using the repository browser.