Changeset 156 for trunk/src/update_obj.m
- Timestamp:
- Dec 19, 2010, 10:11:04 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/update_obj.m
r102 r156 1 1 %'update_obj': update the object graph representation and its projection field, record it in the uvmat interface 2 2 %------------------------------------------------------------------- 3 %Object =update_obj(UvData,IndexObj,ObjectData,PlotHandles);4 % 3 %Object_out=update_obj(UvData,IndexObj,ObjectData,PlotHandles); 4 5 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 6 % Object_out= cell array of structures containing the properties of the existing objects . 9 7 % 10 8 %INPUT: 11 %UvData: structure stored as 'Userdata' on the uvmat interface, it contains 9 %UvData: structure stored as 'Userdata' on the uvmat interface, it contains: 12 10 % .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 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 17 16 % .Style: style of the object: 'line', 'rectangle'... 18 17 %PlotHandles: structure containing the handles of the plotting parameter buttons on the uvmat or view_field interface 19 18 %------------------------------------- 20 19 21 function Object_out=update_obj(UvData,IndexObj ,ObjectData,PlotHandles)20 function Object_out=update_obj(UvData,IndexObj_1,IndexObj_2) 22 21 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 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; 30 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 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 64 48 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); 49 %% representation of the different objects in the plots uvmat and view_field 50 %hfig=get(plotaxes,'parent'); 51 %tagfig=get(hfig,'tag'); 52 % if length(Object_set)<IndexObj 53 %Object_set{IndexObj}=ObjectData; 54 % end 55 % plot the updated object in uvmat 56 % hobject=[]; 57 % if isfield(Object_set{IndexObj},'DisplayHandle_uvmat') && ~isempty(Object_set{IndexObj}.DisplayHandle_uvmat) && ishandle(Object_set{IndexObj}.DisplayHandle_uvmat) 58 % hobject=Object_set{IndexObj}.DisplayHandle_uvmat; 59 % % else 60 % % hobject=plotaxes; 61 % end 62 % Object_out{IndexObj}.DisplayHandle_uvmat=plot_object(Object_set{IndexObj},Object_set{1},hobject,'m');%update the object representation 63 64 % if strcmp(tagfig,'uvmat')%plot uvmat 65 for iobj=1:length(Object_out) %change the view of all existing objects on the updated current object #IndexObj_1 66 hobject=[]; 67 if isfield(Object_out{iobj},'DisplayHandle_uvmat') && ~isempty(Object_out{iobj}.DisplayHandle_uvmat) && ishandle(Object_out{iobj}.DisplayHandle_uvmat) 68 hobject=Object_out{iobj}.DisplayHandle_uvmat; 69 % else 70 % hobject=plotaxes; 71 end 72 Object_out{iobj}.DisplayHandle_uvmat=plot_object(Object_out{iobj},Object_out{IndexObj_1},hobject,'m');%update the object representation 74 73 end 75 Object_out.plotaxes=plotaxes; 76 end 74 % else%plot view_field 75 for iobj=1:length(Object_out) %change the view of all existing objects on the updated current object #IndexObj_2 76 hobject=[]; 77 if isfield(Object_out{iobj},'DisplayHandle_view_field') && ~isempty(Object_out{iobj}.DisplayHandle_view_field) && ishandle(Object_out{iobj}.DisplayHandle_view_field) 78 hobject=Object_out{iobj}.DisplayHandle_view_field; 79 % else 80 % hobject=plotaxes; 81 end 82 Object_out{iobj}.DisplayHandle_view_field=plot_object(Object_out{iobj},Object_out{IndexObj_2},hobject,'m');%update the object representation 83 end 84 % end 85 86 % if isfield(Object_set{iobj},'plotaxes') 87 % haxes=Object_set{iobj}.plotaxes;% axes for the field plot 88 % if ishandle(haxes) && isequal(get(haxes,'Type'),'axes')% update the representation of the object IndexObj on this axes if it exists 89 % testupdate=0; 90 % HandlesDisplay=[];%default 91 % if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'HandlesDisplay') 92 % HandlesDisplay=Object_set{IndexObj}.HandlesDisplay;%list of handles of object representations 93 % end 94 % hplot_list=findobj(haxes,'Tag','proj_object');%list of projection objects on the axes 95 % for ih=1:length(HandlesDisplay) 96 % plot_detect=find(hplot_list==HandlesDisplay(ih)); 97 % if ~isempty(plot_detect) 98 % Object_out.HandlesDisplay(ih)=plot_object(ObjectData,Object_set{iobj},HandlesDisplay(ih),'m');%update the the object representation 99 % testupdate=1; 100 % break 101 % end 102 % end 103 % if ~testupdate% draw new object plot 104 % hh=plot_object(ObjectData,Object_set{iobj},haxes,'m');%draw the object with the new object data 105 % if isfield(Object_out,'HandlesDisplay') 106 % Object_out.HandlesDisplay=[Object_out.HandlesDisplay hh]; 107 % else 108 % Object_out.HandlesDisplay=hh; 109 % end 110 % PlotData=get(hh,'UserData'); 111 % PlotData.IndexObj=IndexObj; 112 % set(hh,'UserData',PlotData); %record the object index in the graph 113 % end 114 % end 115 % end 116 % end 77 117 78 118 79 119 120
Note: See TracChangeset
for help on using the changeset viewer.