Home > . > delete_object.m

delete_object

PURPOSE ^

'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle

SYNOPSIS ^

function delete_object(hObject)

DESCRIPTION ^

'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle

INPUT:
 hObject: object index (if integer) or handle of the graphic object. If
 hObject is a subobject, the parent object is detected and deleted.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle
0002 %
0003 %INPUT:
0004 % hObject: object index (if integer) or handle of the graphic object. If
0005 % hObject is a subobject, the parent object is detected and deleted.
0006 
0007 function delete_object(hObject)
0008 
0009 huvmat=findobj('Name','uvmat');%handles of the uvmat interface
0010 UvData=get(huvmat,'UserData');
0011 hlist_object=findobj(huvmat,'Tag','list_object');%handles of the object liçst in the uvmat interface
0012 list_str=get(hlist_object,'String');%objet list
0013 ObjectData=[];%default
0014 hdisplay=[];
0015 if isequal(floor(hObject),hObject) %case of an index
0016     if  ~isempty(UvData) & isfield(UvData, 'Object') & length(UvData.Object)>=hObject 
0017         if isfield(UvData.Object{hObject},'HandlesDisplay') 
0018             hdisplay=UvData.Object{hObject}.HandlesDisplay;
0019             for iview=1:length(hdisplay)
0020                 if ishandle(hdisplay(iview)) & ~isequal(hdisplay(iview),0)
0021                     ObjectData=get(hdisplay(iview),'UserData');
0022                     if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject)
0023                         delete(ObjectData.SubObject);
0024                     end
0025                     if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint)
0026                         delete(ObjectData.DeformPoint);
0027                     end
0028                     delete(hdisplay(iview))
0029                 end
0030                 ishandle(hdisplay(iview))
0031             end
0032         end   
0033         for iobj=hObject+1:length(UvData.Object)
0034             hdisplay=UvData.Object{iobj}.HandlesDisplay;
0035             for iview=1:length(hdisplay)
0036                 if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
0037                     PlotData=get(hdisplay(iview),'UserData');
0038                     PlotData.IndexObj=iobj-1;
0039                     set(hdisplay(iview),'UserData',PlotData);
0040                 end
0041             end
0042         end
0043         UvData.Object(hObject)=[];  
0044         list_str(hObject)=[];
0045     end
0046 elseif ishandle(hObject)%object handle
0047     userdata=get(hObject,'UserData');
0048     if ishandle(userdata)%the selected line depends on a parent line
0049         hdisplay=userdata;% the parent object becomes the current one
0050     else
0051         hdisplay=hObject;% the selected object becomes the current one
0052     end
0053     PlotData=get(hdisplay,'UserData');
0054     if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject)
0055             delete(PlotData.SubObject);
0056     end
0057     if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint)
0058            delete(PlotData.DeformPoint);
0059     end
0060     delete(hdisplay);
0061     if isfield(PlotData,'IndexObj')
0062         IndexObj=PlotData.IndexObj;
0063         if  isequal(round(IndexObj),IndexObj) & IndexObj>=1 & length(list_str) > IndexObj
0064             if isfield(UvData,'Object')& length(UvData.Object) > IndexObj
0065                UvData.Object(IndexObj)=[];
0066             end
0067             list_str(IndexObj)=[];
0068         end
0069     end
0070 end
0071 set(huvmat,'UserData',UvData);
0072 set(hlist_object,'String',list_str)
0073 set(hlist_object,'Value',length(list_str))

Generated on Fri 13-Nov-2009 11:17:03 by m2html © 2003