[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 |
|
---|
| 9 | function delete_object(hObject)
|
---|
| 10 |
|
---|
[71] | 11 | huvmat=findobj('tag','uvmat');%handles of the uvmat interface
|
---|
[8] | 12 | UvData=get(huvmat,'UserData');
|
---|
[410] | 13 | hlist_object=findobj(huvmat,'Tag','ListObject');%handles of the object list in the uvmat interface
|
---|
[8] | 14 | list_str=get(hlist_object,'String');%objet list
|
---|
| 15 | if isequal(floor(hObject),hObject) %case of an index
|
---|
[499] | 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;
|
---|
[8] | 19 | for iview=1:length(hdisplay)
|
---|
[499] | 20 | if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
|
---|
[8] | 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
|
---|
[499] | 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
|
---|
[8] | 40 | end
|
---|
| 41 | end
|
---|
| 42 | end
|
---|
| 43 | UvData.Object(hObject)=[];
|
---|
[227] | 44 | if ~isempty(list_str)
|
---|
| 45 | list_str(hObject)=[];
|
---|
| 46 | end
|
---|
[8] | 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))
|
---|
[410] | 76 | hlist_object_1=findobj(huvmat,'Tag','ListObject_1');%handles of the first object list in the uvmat interface
|
---|
| 77 | old_index=get(hlist_object_1,'Value');
|
---|
| 78 | set(hlist_object_1,'String',list_str)
|
---|
| 79 | if hObject<=old_index
|
---|
| 80 | set(hlist_object_1,'Value',old_index-1)
|
---|
| 81 | end
|
---|
[499] | 82 | % hlist_object=findobj(huvmat,'Tag','list_object_2');%handles of the object liï¿œst in the uvmat interface
|
---|
[410] | 83 | % set(hlist_object,'String',[list_str;{'...'}])
|
---|
| 84 | % set(hlist_object,'Value',length(list_str)+1)
|
---|