source: trunk/src/delete_object.m @ 71

Last change on this file since 71 was 71, checked in by sommeria, 15 years ago

civ3D updated: introduction of image size
imadoc2struct: reding of image size from the xml file
set_object, view_field and related functions: improvement of projection object editing
mouse: possibility of adjusting the calibrations points with the mouse

File size: 3.3 KB
Line 
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
7function delete_object(hObject)
8
9huvmat=findobj('tag','uvmat');%handles of the uvmat interface
10UvData=get(huvmat,'UserData');
11hlist_object=findobj(huvmat,'Tag','list_object_1');%handles of the object liçst in the uvmat interface
12list_str=get(hlist_object,'String');%objet list
13ObjectData=[];%default
14hdisplay=[];
15if 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
46elseif 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
70end
71set(huvmat,'UserData',UvData);
72set(hlist_object,'String',list_str)
73set(hlist_object,'Value',length(list_str))
74hlist_object=findobj(huvmat,'Tag','list_object_2');%handles of the object liçst in the uvmat interface
75set(hlist_object,'String',[list_str {'...'}])
76set(hlist_object,'Value',length(list_str)+1)
Note: See TracBrowser for help on using the repository browser.