source: trunk/src/update_obj.m @ 156

Last change on this file since 156 was 156, checked in by sommeria, 10 years ago

many bug repairs and corrections for mouse action
create_grid: option for black marjkers for grid detection

File size: 5.9 KB
Line 
1%'update_obj': update the object graph representation and its projection field, record it in the uvmat interface
2%-------------------------------------------------------------------
3%Object_out=update_obj(UvData,IndexObj,ObjectData,PlotHandles);
4
5%OUTPUT:
6% Object_out= cell array of structures containing the properties of the existing objects     .
7%
8%INPUT:
9%UvData: structure stored as 'Userdata' on the uvmat interface, it contains:
10%    .Object{1},{2}... description of all the projection objects
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
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
18%-------------------------------------
19
20function Object_out=update_obj(UvData,IndexObj_1,IndexObj_2)
21
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
29Object_out=UvData.Object;
30
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
48
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
73    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
117
118
119
120
Note: See TracBrowser for help on using the repository browser.