1 | %'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle
|
---|
2 | %
|
---|
3 | %INPUT:
|
---|
4 | % hObject: object index (if integer) or handle of the graphic object. If
|
---|
5 | % hObject is a subobject, the parent object is detected and deleted.
|
---|
6 |
|
---|
7 | function delete_object(hObject)
|
---|
8 |
|
---|
9 | huvmat=findobj('tag','uvmat');%handles of the uvmat interface
|
---|
10 | UvData=get(huvmat,'UserData');
|
---|
11 | hlist_object=findobj(huvmat,'Tag','list_object_1');%handles of the object liçst in the uvmat interface
|
---|
12 | list_str=get(hlist_object,'String');%objet list
|
---|
13 | ObjectData=[];%default
|
---|
14 | hdisplay=[];
|
---|
15 | if 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},'HandlesDisplay')
|
---|
18 | hdisplay=UvData.Object{hObject}.HandlesDisplay;
|
---|
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 | end
|
---|
33 | for iobj=hObject+1:length(UvData.Object)
|
---|
34 | hdisplay=UvData.Object{iobj}.HandlesDisplay;
|
---|
35 | for iview=1:length(hdisplay)
|
---|
36 | if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
|
---|
37 | PlotData=get(hdisplay(iview),'UserData');
|
---|
38 | PlotData.IndexObj=iobj-1;
|
---|
39 | set(hdisplay(iview),'UserData',PlotData);
|
---|
40 | end
|
---|
41 | end
|
---|
42 | end
|
---|
43 | UvData.Object(hObject)=[];
|
---|
44 | list_str(hObject)=[];
|
---|
45 | end
|
---|
46 | elseif ishandle(hObject)%object handle
|
---|
47 | userdata=get(hObject,'UserData');
|
---|
48 | if ishandle(userdata)%the selected line depends on a parent line
|
---|
49 | hdisplay=userdata;% the parent object becomes the current one
|
---|
50 | else
|
---|
51 | hdisplay=hObject;% the selected object becomes the current one
|
---|
52 | end
|
---|
53 | PlotData=get(hdisplay,'UserData');
|
---|
54 | if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject)
|
---|
55 | delete(PlotData.SubObject);
|
---|
56 | end
|
---|
57 | if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint)
|
---|
58 | delete(PlotData.DeformPoint);
|
---|
59 | end
|
---|
60 | delete(hdisplay);
|
---|
61 | if isfield(PlotData,'IndexObj')
|
---|
62 | IndexObj=PlotData.IndexObj;
|
---|
63 | if isequal(round(IndexObj),IndexObj) & IndexObj>=1 & length(list_str) > IndexObj
|
---|
64 | if isfield(UvData,'Object')& length(UvData.Object) > IndexObj
|
---|
65 | UvData.Object(IndexObj)=[];
|
---|
66 | end
|
---|
67 | list_str(IndexObj)=[];
|
---|
68 | end
|
---|
69 | end
|
---|
70 | end
|
---|
71 | set(huvmat,'UserData',UvData);
|
---|
72 | set(hlist_object,'String',list_str)
|
---|
73 | set(hlist_object,'Value',length(list_str))
|
---|
74 | hlist_object=findobj(huvmat,'Tag','list_object_2');%handles of the object liçst in the uvmat interface
|
---|
75 | set(hlist_object,'String',[list_str {'...'}])
|
---|
76 | set(hlist_object,'Value',length(list_str)+1)
|
---|