source: trunk/src/private/update_obj.m @ 8

Last change on this file since 8 was 8, checked in by gostiaux, 11 years ago
File size: 3.5 KB
Line 
1%'update_obj': update the object graph representation and its projection field, record it in the uvmat interface
2%-------------------------------------------------------------------
3%Object=update_obj(UvData,IndexObj,ObjectData,PlotHandles);
4%
5%OUTPUT:
6%UvData: data to be stored as 'Userdata' on the uvmat interface
7%IndexObj: object index for a new object added to the list in UvData
8%   the function updates UvData.Object{IndexObj}, and possibly adds a new plot (UvData.Plane or Line) in the list atached to the interface
9%
10%INPUT:
11%UvIn: structure stored as 'Userdata' on the uvmat interface
12%IndexObjIn: object index for an existing objects stored in UvData
13%ObjectData: structure containing the input object properties
14%PlotHandles: structure containing the handles of the plotting parameter buttons on the uvmat interface (obtained by get_plot_handles.m)
15%-------------------------------------
16
17function Object_out=update_obj(UvData,IndexObj,ObjectData,PlotHandles)
18
19%default input and output
20Object_out=ObjectData;%default
21if  isfield(UvData,'Object')
22    Object_set=UvData.Object;
23else
24    Object_set={};%create the object
25end
26
27% object representation in the different projected field plots
28for iview=1:length(Object_set) %loop on projection planes iview
29      if isfield(Object_set{iview},'plotaxes')
30         haxes=Object_set{iview}.plotaxes;% axes for the field plot
31         if ishandle(haxes) & isequal(get(haxes,'Type'),'axes')% update the representation of the object IndexObj on this axes if it exists
32             testupdate=0;
33             HandlesDisplay=[];%default
34             if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'HandlesDisplay')
35                 HandlesDisplay=Object_set{IndexObj}.HandlesDisplay;%list of handles of object representations
36             end
37             hplot_list=findobj(haxes,'Tag','proj_object');
38             for ih=1:length(HandlesDisplay)
39                 plot_detect=find(hplot_list==HandlesDisplay(ih));
40                 if ~isempty(plot_detect)
41                     Object_out.HandlesDisplay(ih)=plot_object(ObjectData,Object_set{iview},HandlesDisplay(ih),'m');%update the the object representation
42                     testupdate=1;
43                     break
44                 end
45             end
46             if ~testupdate% draw new object plot
47                hh=plot_object(ObjectData,Object_set{iview},haxes,'m');%draw the object with the new object data
48                Object_out.HandlesDisplay=[Object_out.HandlesDisplay hh];
49                PlotData=get(hh,'UserData');
50                PlotData.IndexObj=IndexObj;
51                set(hh,'UserData',PlotData); %record the object index in the graph
52             end
53         end
54      end
55end
56
57% plot the field projected on the object
58if ~isempty(PlotHandles) %&& ~testmask
59    ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
60    if ~isempty(ProjData)   
61        plotaxes=[];%default
62        if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'plotaxes')
63            plotaxes=Object_set{IndexObj}.plotaxes;
64        end
65        [PlotType,Object_out.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);
66        Object_out.plotaxes=plotaxes;
67        plotfig=get(plotaxes,'parent');
68        name_str=get(plotfig,'Name');
69        if ~isequal(name_str,'uvmat')
70            set(plotfig,'Name',['Projection on' num2str(IndexObj) '-' set_title(ObjectData.Style,ObjectData.ProjMode)]);
71        end
72    end
73end
74
75
Note: See TracBrowser for help on using the repository browser.