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 |
|
---|
9 | function delete_object(hObject)
|
---|
10 |
|
---|
11 | huvmat=findobj('tag','uvmat');%handles of the uvmat interface
|
---|
12 | UvData=get(huvmat,'UserData');
|
---|
13 | hlist_object=findobj(huvmat,'Tag','list_object_1');%handles of the object liçst in the uvmat interface
|
---|
14 | list_str=get(hlist_object,'String');%objet list
|
---|
15 | ObjectData=[];%default
|
---|
16 | hdisplay=[];
|
---|
17 | if 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 | list_str(hObject)=[];
|
---|
47 | end
|
---|
48 | elseif 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
|
---|
72 | end
|
---|
73 | set(huvmat,'UserData',UvData);
|
---|
74 | set(hlist_object,'String',list_str)
|
---|
75 | set(hlist_object,'Value',length(list_str))
|
---|
76 | hlist_object=findobj(huvmat,'Tag','list_object_2');%handles of the object liçst in the uvmat interface
|
---|
77 | set(hlist_object,'String',[list_str;{'...'}])
|
---|
78 | set(hlist_object,'Value',length(list_str)+1)
|
---|