source: trunk/src/delete_object.m @ 243

Last change on this file since 243 was 227, checked in by sommeria, 14 years ago

add function sub_field_series to apply the sub_field operation to a series of fileds (for instance subtracting a background to an image series)

File size: 3.4 KB
RevLine 
[8]1%'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle
[89]2%------------------------------------------------------------------------
3% function delete_object(hObject)
[8]4%
[89]5% INPUT:
[8]6% hObject: object index (if integer) or handle of the graphic object. If
[89]7%          hObject is a subobject, the parent object is detected and deleted.
[8]8
9function delete_object(hObject)
10
[71]11huvmat=findobj('tag','uvmat');%handles of the uvmat interface
[8]12UvData=get(huvmat,'UserData');
[71]13hlist_object=findobj(huvmat,'Tag','list_object_1');%handles of the object liçst in the uvmat interface
[8]14list_str=get(hlist_object,'String');%objet list
15ObjectData=[];%default
16hdisplay=[];
17if isequal(floor(hObject),hObject) %case of an index
18    if  ~isempty(UvData) & isfield(UvData, 'Object') & length(UvData.Object)>=hObject
[156]19        if isfield(UvData.Object{hObject},'DisplayHandle_uvmat')
20            hdisplay=UvData.Object{hObject}.DisplayHandle_uvmat;
[8]21            for iview=1:length(hdisplay)
22                if ishandle(hdisplay(iview)) & ~isequal(hdisplay(iview),0)
23                    ObjectData=get(hdisplay(iview),'UserData');
24                    if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject)
25                        delete(ObjectData.SubObject);
26                    end
27                    if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint)
28                        delete(ObjectData.DeformPoint);
29                    end
30                    delete(hdisplay(iview))
31                end
32                ishandle(hdisplay(iview))
33            end
34        end   
35        for iobj=hObject+1:length(UvData.Object)
[156]36            hdisplay=UvData.Object{iobj}.DisplayHandle_uvmat;
[8]37            for iview=1:length(hdisplay)
38                if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
39                    PlotData=get(hdisplay(iview),'UserData');
40                    PlotData.IndexObj=iobj-1;
41                    set(hdisplay(iview),'UserData',PlotData);
42                end
43            end
44        end
45        UvData.Object(hObject)=[]; 
[227]46        if ~isempty(list_str)
47            list_str(hObject)=[];
48        end
[8]49    end
50elseif ishandle(hObject)%object handle
51    userdata=get(hObject,'UserData');
52    if ishandle(userdata)%the selected line depends on a parent line
53        hdisplay=userdata;% the parent object becomes the current one
54    else
55        hdisplay=hObject;% the selected object becomes the current one
56    end
57    PlotData=get(hdisplay,'UserData');
58    if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject)
59            delete(PlotData.SubObject);
60    end
61    if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint)
62           delete(PlotData.DeformPoint);
63    end
64    delete(hdisplay);
65    if isfield(PlotData,'IndexObj')
66        IndexObj=PlotData.IndexObj;
67        if  isequal(round(IndexObj),IndexObj) & IndexObj>=1 & length(list_str) > IndexObj
68            if isfield(UvData,'Object')& length(UvData.Object) > IndexObj
69               UvData.Object(IndexObj)=[];
70            end
71            list_str(IndexObj)=[];
72        end
73    end
74end
75set(huvmat,'UserData',UvData);
76set(hlist_object,'String',list_str)
77set(hlist_object,'Value',length(list_str))
[71]78hlist_object=findobj(huvmat,'Tag','list_object_2');%handles of the object liçst in the uvmat interface
[75]79set(hlist_object,'String',[list_str;{'...'}])
[71]80set(hlist_object,'Value',length(list_str)+1)
Note: See TracBrowser for help on using the repository browser.