source: trunk/src/update_obj.m @ 71

Last change on this file since 71 was 71, checked in by sommeria, 15 years ago

civ3D updated: introduction of image size
imadoc2struct: reding of image size from the xml file
set_object, view_field and related functions: improvement of projection object editing
mouse: possibility of adjusting the calibrations points with the mouse

File size: 4.2 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%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
21function Object_out=update_obj(UvData,IndexObj,ObjectData,PlotHandles)
22
23%default input and output
24Object_out=ObjectData;%default
25if  isfield(UvData,'Object')
26    Object_set=UvData.Object;
27else
28    Object_set={};%create the object
29end
30
31% object representation in the different projected field plots
32for 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
63end
64% plot the field projected on the object
65% if ~isempty(PlotHandles) %&& ~testmask
66    ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
67    if ~isempty(ProjData)   
68        plotaxes=[];%default
69%         get(Object_set{IndexObj}.plotaxes)
70        if length(Object_set)>= IndexObj && isfield(Object_set{IndexObj},'plotaxes')
71            plotaxes=Object_set{IndexObj}.plotaxes;
72            [PlotType,Object_out.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);
73        else
74             [plotaxes]=view_field(ProjData);
75        end
76%         [PlotType,Object_out.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);
77        Object_out.plotaxes=plotaxes;
78        plotfig=get(plotaxes,'parent');
79        name_str=get(plotfig,'Name');
80        if ~isequal(name_str,'uvmat')
81            set(plotfig,'Name',['Projection on' num2str(IndexObj) '-' ObjectData.Style]);
82        end
83    end
84% end
85
86
Note: See TracBrowser for help on using the repository browser.