[8] | 1 | %'update_obj': update the object graph representation and its projection field, record it in the uvmat interface
|
---|
| 2 | %-------------------------------------------------------------------
|
---|
[156] | 3 | %Object_out=update_obj(UvData,IndexObj,ObjectData,PlotHandles);
|
---|
| 4 |
|
---|
[8] | 5 | %OUTPUT:
|
---|
[156] | 6 | % Object_out= cell array of structures containing the properties of the existing objects .
|
---|
[8] | 7 | %
|
---|
| 8 | %INPUT:
|
---|
[156] | 9 | %UvData: structure stored as 'Userdata' on the uvmat interface, it contains:
|
---|
[71] | 10 | % .Object{1},{2}... description of all the projection objects
|
---|
[156] | 11 | % .Field , the current input field to be projected on the object
|
---|
| 12 | % .Object{IndexObj}.DisplayHandle_uvmat: handles of the object plot on uvmat, =[] if it does not exist
|
---|
| 13 | % .Object{IndexObj}.DisplayHandle_view_field: handles of the object plot on view_field, =[] if it does not exist
|
---|
| 14 | %IndexObj: object index of UvData.Object correspopnding to the updated object
|
---|
| 15 | %ObjectData: structure containing the input object properties to be attributed to the object #IndexObj
|
---|
[71] | 16 | % .Style: style of the object: 'line', 'rectangle'...
|
---|
| 17 | %PlotHandles: structure containing the handles of the plotting parameter buttons on the uvmat or view_field interface
|
---|
[8] | 18 | %-------------------------------------
|
---|
| 19 |
|
---|
[156] | 20 | function Object_out=update_obj(UvData,IndexObj_1,IndexObj_2)
|
---|
[8] | 21 |
|
---|
[156] | 22 | %% default input and output
|
---|
| 23 | % Object_out{IndexObj}=ObjectData;%default
|
---|
| 24 | % if isfield(UvData,'Object')
|
---|
| 25 | % Object_set=UvData.Object;
|
---|
| 26 | % else
|
---|
| 27 | % Object_set={};%create the object
|
---|
| 28 | % end
|
---|
| 29 | Object_out=UvData.Object;
|
---|
[8] | 30 |
|
---|
[156] | 31 | %% plot the field projected on the object
|
---|
| 32 | % ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
|
---|
| 33 | % if ~isempty(ProjData)
|
---|
| 34 | % plotaxes=[];%default
|
---|
| 35 | % if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'plotaxes')
|
---|
| 36 | % plotaxes=Object_set{IndexObj}.plotaxes;
|
---|
| 37 | % [PlotType,Object_out{IndexObj}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);%update an existing field plot
|
---|
| 38 | % plotfig=get(plotaxes,'parent');
|
---|
| 39 | % ViewData=get(plotfig,'UserData');
|
---|
| 40 | % eval(
|
---|
| 41 | % else
|
---|
| 42 | % hview_field=view_field(ProjData);%create a new field plot with view_field
|
---|
| 43 | % hhview_field=guidata(hview_field);
|
---|
| 44 | % plotaxes=hhview_field.axes3;
|
---|
| 45 | % end
|
---|
| 46 | % Object_out{IndexObj}.plotaxes=plotaxes;
|
---|
| 47 | % end
|
---|
[82] | 48 |
|
---|
[156] | 49 | %% representation of the different objects in the plots uvmat and view_field
|
---|
| 50 |
|
---|
[159] | 51 | %plot uvmat
|
---|
[156] | 52 | for iobj=1:length(Object_out) %change the view of all existing objects on the updated current object #IndexObj_1
|
---|
| 53 | hobject=[];
|
---|
| 54 | if isfield(Object_out{iobj},'DisplayHandle_uvmat') && ~isempty(Object_out{iobj}.DisplayHandle_uvmat) && ishandle(Object_out{iobj}.DisplayHandle_uvmat)
|
---|
| 55 | hobject=Object_out{iobj}.DisplayHandle_uvmat;
|
---|
| 56 | end
|
---|
| 57 | Object_out{iobj}.DisplayHandle_uvmat=plot_object(Object_out{iobj},Object_out{IndexObj_1},hobject,'m');%update the object representation
|
---|
[82] | 58 | end
|
---|
[159] | 59 | % plot view_field
|
---|
| 60 | if ~isempty(IndexObj_2)
|
---|
[156] | 61 | for iobj=1:length(Object_out) %change the view of all existing objects on the updated current object #IndexObj_2
|
---|
| 62 | hobject=[];
|
---|
| 63 | if isfield(Object_out{iobj},'DisplayHandle_view_field') && ~isempty(Object_out{iobj}.DisplayHandle_view_field) && ishandle(Object_out{iobj}.DisplayHandle_view_field)
|
---|
| 64 | hobject=Object_out{iobj}.DisplayHandle_view_field;
|
---|
| 65 | % else
|
---|
| 66 | % hobject=plotaxes;
|
---|
| 67 | end
|
---|
| 68 | Object_out{iobj}.DisplayHandle_view_field=plot_object(Object_out{iobj},Object_out{IndexObj_2},hobject,'m');%update the object representation
|
---|
| 69 | end
|
---|
[159] | 70 | end
|
---|
[156] | 71 | % end
|
---|
[8] | 72 |
|
---|
[156] | 73 | % if isfield(Object_set{iobj},'plotaxes')
|
---|
| 74 | % haxes=Object_set{iobj}.plotaxes;% axes for the field plot
|
---|
| 75 | % if ishandle(haxes) && isequal(get(haxes,'Type'),'axes')% update the representation of the object IndexObj on this axes if it exists
|
---|
| 76 | % testupdate=0;
|
---|
| 77 | % HandlesDisplay=[];%default
|
---|
| 78 | % if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'HandlesDisplay')
|
---|
| 79 | % HandlesDisplay=Object_set{IndexObj}.HandlesDisplay;%list of handles of object representations
|
---|
| 80 | % end
|
---|
| 81 | % hplot_list=findobj(haxes,'Tag','proj_object');%list of projection objects on the axes
|
---|
| 82 | % for ih=1:length(HandlesDisplay)
|
---|
| 83 | % plot_detect=find(hplot_list==HandlesDisplay(ih));
|
---|
| 84 | % if ~isempty(plot_detect)
|
---|
| 85 | % Object_out.HandlesDisplay(ih)=plot_object(ObjectData,Object_set{iobj},HandlesDisplay(ih),'m');%update the the object representation
|
---|
| 86 | % testupdate=1;
|
---|
| 87 | % break
|
---|
| 88 | % end
|
---|
| 89 | % end
|
---|
| 90 | % if ~testupdate% draw new object plot
|
---|
| 91 | % hh=plot_object(ObjectData,Object_set{iobj},haxes,'m');%draw the object with the new object data
|
---|
| 92 | % if isfield(Object_out,'HandlesDisplay')
|
---|
| 93 | % Object_out.HandlesDisplay=[Object_out.HandlesDisplay hh];
|
---|
| 94 | % else
|
---|
| 95 | % Object_out.HandlesDisplay=hh;
|
---|
| 96 | % end
|
---|
| 97 | % PlotData=get(hh,'UserData');
|
---|
| 98 | % PlotData.IndexObj=IndexObj;
|
---|
| 99 | % set(hh,'UserData',PlotData); %record the object index in the graph
|
---|
| 100 | % end
|
---|
| 101 | % end
|
---|
| 102 | % end
|
---|
| 103 | % end
|
---|
[8] | 104 |
|
---|
[82] | 105 |
|
---|
[156] | 106 |
|
---|
| 107 |
|
---|