source: trunk/src/delete_object.m @ 575

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

various bugs corrected. PARAM.xml complemented to provide info for 'RUN' mode

File size: 3.8 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 list in the uvmat interface
14list_str=get(hlist_object,'String');%objet list
15if isequal(floor(hObject),hObject) %case of an index
16    if  ~isempty(UvData) && isfield(UvData, 'Object') && length(UvData.Object)>=hObject
17        if isfield(UvData.Object{hObject},'DisplayHandle') && isfield(UvData.Object{hObject}.DisplayHandle,'uvmat')
18            hdisplay=UvData.Object{hObject}.DisplayHandle.uvmat;
19            for iview=1:length(hdisplay)
20                if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
21                    ObjectData=get(hdisplay(iview),'UserData');
22                    if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject)
23                        delete(ObjectData.SubObject);
24                    end
25                    if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint)
26                        delete(ObjectData.DeformPoint);
27                    end
28                    delete(hdisplay(iview))
29                end
30                ishandle(hdisplay(iview))
31            end
32            for iobj=hObject+1:length(UvData.Object)
33                hdisplay=UvData.Object{iobj}.DisplayHandle.uvmat;
34                for iview=1:length(hdisplay)
35                    if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
36                        PlotData=get(hdisplay(iview),'UserData');
37                        PlotData.IndexObj=iobj-1;
38                        set(hdisplay(iview),'UserData',PlotData);
39                    end
40                end
41            end
42        end
43        UvData.Object(hObject)=[]; 
44        if ~isempty(list_str)
45            list_str(hObject)=[];
46        end
47    end
48elseif ishandle(hObject)%object handle
49    userdata=get(hObject,'UserData');
50    if ishandle(userdata)%the selected line depends on a parent line
51        hdisplay=userdata;% the parent object becomes the current one
52    else
53        hdisplay=hObject;% the selected object becomes the current one
54    end
55    PlotData=get(hdisplay,'UserData');
56    if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject)
57            delete(PlotData.SubObject);
58    end
59    if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint)
60           delete(PlotData.DeformPoint);
61    end
62    delete(hdisplay);
63    if isfield(PlotData,'IndexObj')
64        IndexObj=PlotData.IndexObj;
65        if  isequal(round(IndexObj),IndexObj) & IndexObj>=1 & length(list_str) > IndexObj
66            if isfield(UvData,'Object')& length(UvData.Object) > IndexObj
67               UvData.Object(IndexObj)=[];
68            end
69            list_str(IndexObj)=[];
70        end
71    end
72end
73set(huvmat,'UserData',UvData);
74set(hlist_object,'String',list_str)
75set(hlist_object,'Value',length(list_str))
76hlist_object_1=findobj(huvmat,'Tag','ListObject_1');%handles of the first object list in the uvmat interface
77old_index=get(hlist_object_1,'Value');
78set(hlist_object_1,'String',list_str)
79if hObject<=old_index
80    set(hlist_object_1,'Value',old_index-1)
81end
82% hlist_object=findobj(huvmat,'Tag','list_object_2');%handles of the object liï¿œst in the uvmat interface
83% set(hlist_object,'String',[list_str;{'...'}])
84% set(hlist_object,'Value',length(list_str)+1)
Note: See TracBrowser for help on using the repository browser.