source: trunk/src/delete_object.m @ 323

Last change on this file since 323 was 302, checked in by sommeria, 13 years ago

improve the display of projection objects

File size: 3.4 KB
Line 
1%'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle
2%------------------------------------------------------------------------
3% function delete_object(hObject)
4%
5% INPUT:
6% hObject: object index (if integer) or handle of the graphic object. If
7%          hObject is a subobject, the parent object is detected and deleted.
8
9function delete_object(hObject)
10
11huvmat=findobj('tag','uvmat');%handles of the uvmat interface
12UvData=get(huvmat,'UserData');
13hlist_object=findobj(huvmat,'Tag','ListObject');%handles of the object liçst in the uvmat interface
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
19        if isfield(UvData.Object{hObject},'DisplayHandle_uvmat')
20            hdisplay=UvData.Object{hObject}.DisplayHandle_uvmat;
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)
36            hdisplay=UvData.Object{iobj}.DisplayHandle_uvmat;
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)=[]; 
46        if ~isempty(list_str)
47            list_str(hObject)=[];
48        end
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))
78hlist_object=findobj(huvmat,'Tag','list_object_2');%handles of the object liçst in the uvmat interface
79set(hlist_object,'String',[list_str;{'...'}])
80set(hlist_object,'Value',length(list_str)+1)
Note: See TracBrowser for help on using the repository browser.