source: trunk/src/delete_object.m @ 199

Last change on this file since 199 was 156, checked in by sommeria, 14 years ago

many bug repairs and corrections for mouse action
create_grid: option for black marjkers for grid detection

File size: 3.4 KB
RevLine 
[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
9function delete_object(hObject)
10
[71]11huvmat=findobj('tag','uvmat');%handles of the uvmat interface
[8]12UvData=get(huvmat,'UserData');
[71]13hlist_object=findobj(huvmat,'Tag','list_object_1');%handles of the object liçst in the uvmat interface
[8]14list_str=get(hlist_object,'String');%objet list
15ObjectData=[];%default
16hdisplay=[];
17if isequal(floor(hObject),hObject) %case of an index
18    if  ~isempty(UvData) & isfield(UvData, 'Object') & length(UvData.Object)>=hObject
[156]19        if isfield(UvData.Object{hObject},'DisplayHandle_uvmat')
20            hdisplay=UvData.Object{hObject}.DisplayHandle_uvmat;
[8]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)
[156]36            hdisplay=UvData.Object{iobj}.DisplayHandle_uvmat;
[8]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
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))
[71]76hlist_object=findobj(huvmat,'Tag','list_object_2');%handles of the object liçst in the uvmat interface
[75]77set(hlist_object,'String',[list_str;{'...'}])
[71]78set(hlist_object,'Value',length(list_str)+1)
Note: See TracBrowser for help on using the repository browser.