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 | %UvData: structure stored as 'Userdata' on the uvmat interface, it contains
|
---|
12 | % .Object{1},{2}... description of all the projection objects
|
---|
13 | % .Object{iview}.plotaxes: axes for the plot of the field projected on this object
|
---|
14 | % .Object{iview}.HandlesDisplay(ih): array of handles for plots representing the object #iview in the field #ih
|
---|
15 | %IndexObjIn: object index for an existing objects stored in UvData
|
---|
16 | %ObjectData: structure containing the input object properties
|
---|
17 | % .Style: style of the object: 'line', 'rectangle'...
|
---|
18 | %PlotHandles: structure containing the handles of the plotting parameter buttons on the uvmat or view_field interface
|
---|
19 | %-------------------------------------
|
---|
20 |
|
---|
21 | function Object_out=update_obj(UvData,IndexObj,ObjectData,PlotHandles)
|
---|
22 |
|
---|
23 | %default input and output
|
---|
24 | Object_out=ObjectData;%default
|
---|
25 | if isfield(UvData,'Object')
|
---|
26 | Object_set=UvData.Object;
|
---|
27 | else
|
---|
28 | Object_set={};%create the object
|
---|
29 | end
|
---|
30 |
|
---|
31 | % object representation in the different projected field plots
|
---|
32 | for iview=1:length(Object_set) %loop on projection planes iview
|
---|
33 | if isfield(Object_set{iview},'plotaxes')
|
---|
34 | haxes=Object_set{iview}.plotaxes% axes for the field plot
|
---|
35 | if ishandle(haxes) & isequal(get(haxes,'Type'),'axes')% update the representation of the object IndexObj on this axes if it exists
|
---|
36 | testupdate=0;
|
---|
37 | HandlesDisplay=[];%default
|
---|
38 | if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'HandlesDisplay')
|
---|
39 | HandlesDisplay=Object_set{IndexObj}.HandlesDisplay;%list of handles of object representations
|
---|
40 | end
|
---|
41 | hplot_list=findobj(haxes,'Tag','proj_object');%list of projection objects on the axes
|
---|
42 | for ih=1:length(HandlesDisplay)
|
---|
43 | plot_detect=find(hplot_list==HandlesDisplay(ih));
|
---|
44 | if ~isempty(plot_detect)
|
---|
45 | Object_out.HandlesDisplay(ih)=plot_object(ObjectData,Object_set{iview},HandlesDisplay(ih),'m');%update the the object representation
|
---|
46 | testupdate=1;
|
---|
47 | break
|
---|
48 | end
|
---|
49 | end
|
---|
50 | if ~testupdate% draw new object plot
|
---|
51 | hh=plot_object(ObjectData,Object_set{iview},haxes,'m');%draw the object with the new object data
|
---|
52 | if isfield(Object_out,'HandlesDisplay')
|
---|
53 | Object_out.HandlesDisplay=[Object_out.HandlesDisplay hh];
|
---|
54 | else
|
---|
55 | Object_out.HandlesDisplay=hh;
|
---|
56 | end
|
---|
57 | PlotData=get(hh,'UserData');
|
---|
58 | PlotData.IndexObj=IndexObj;
|
---|
59 | set(hh,'UserData',PlotData); %record the object index in the graph
|
---|
60 | end
|
---|
61 | end
|
---|
62 | end
|
---|
63 | end
|
---|
64 |
|
---|
65 | % plot the field projected on the object
|
---|
66 | ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
|
---|
67 | if ~isempty(ProjData)
|
---|
68 | plotaxes=[];%default
|
---|
69 | if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'plotaxes')
|
---|
70 | plotaxes=Object_set{IndexObj}.plotaxes;
|
---|
71 | [PlotType,Object_out.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);
|
---|
72 | else
|
---|
73 | [plotaxes]=view_field(ProjData);
|
---|
74 | end
|
---|
75 | Object_out.plotaxes=plotaxes;
|
---|
76 | end
|
---|
77 |
|
---|
78 |
|
---|
79 |
|
---|