Home > . > read_set_object.m

# read_set_object

## PURPOSE

'read_set_object': read the data on the 'set_object' interface

## SYNOPSIS

function data=read_set_object(handles)

## DESCRIPTION

    'read_set_object': read the data on the 'set_object' interface
    --------------------------------------------------------
     data=read_set_object(handles)
    --------------------------------------------------------
    OUTPUT
    data: structure of data read on the set_object interface
        .Style : style of projection object
        .Coord(nbpos,3): set of coordinates defining the object position;
        .ProjMode=type of projection ;
        .Phi=angle of projection;
        .DX,.DY,.DZ=increments;
        .YMax,YMin: min and max Y
    INPUT:
     handles: structure describing the tags of the edit boxes and menus
    menus

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- mouse_down 'mouse_down': function activated when the mouse button is pressed on a figure (callback for 'WindowButtonDownFcn'
- series 'series': master function associated to the GUI series.m for analysis field series
- set_grid 'set_grid':produce grid for PIV with one or two images (stereo case)
- set_object 'set_object': GUI to edit a projection object

## SOURCE CODE

    0001 %'read_set_object': read the data on the 'set_object' interface
    0002 %--------------------------------------------------------
    0003 % data=read_set_object(handles)
    0004 %--------------------------------------------------------
    0005 %OUTPUT
    0006 %data: structure of data read on the set_object interface
    0007 %    .Style : style of projection object
    0008 %    .Coord(nbpos,3): set of coordinates defining the object position;
    0009 %    .ProjMode=type of projection ;
    0010 %    .Phi=angle of projection;
    0011 %    .DX,.DY,.DZ=increments;
    0012 %    .YMax,YMin: min and max Y
    0013 %INPUT:
    0014 % handles: structure describing the tags of the edit boxes and menus
    0015 function data=read_set_object(handles)
    0016 %menus
    0017 if isfield(handles,'ObjectStyle')%case of the set_object interface
    0018     menu=get(handles.ObjectStyle,'String');
    0019     value=get(handles.ObjectStyle,'Value');
    0020     data.Style=menu{value};
    0021     menu=get(handles.ProjMode,'String');
    0022     value=get(handles.ProjMode,'Value');
    0023     data.ProjMode=menu{value};
    0024     menu=get(handles.MenuCoord,'String');
    0025     value=get(handles.MenuCoord,'Value');
    0026     data.CoordType=menu{value};
    0027     testcalib=0;
    0028 else %default
    0029     data.Style='points';
    0030     testcalib=1;
    0031 end
    0032
    0033 %Euler angles and projection ranges
    0034 if ~testcalib
    0035     if isequal(get(handles.Phi,'Visible'),'on')
    0036         data.Phi=str2num(get(handles.Phi,'String'));
    0037     end
    0038     if isequal(get(handles.Theta,'Visible'),'on')
    0039         data.Theta=str2num(get(handles.Theta,'String'));
    0040     end
    0041     if isequal(get(handles.Psi,'Visible'),'on')
    0042         data.Psi=str2num(get(handles.Psi,'String'));
    0043     end
    0044     if isequal(get(handles.DX,'Visible'),'on')
    0045         data.DX=str2num(get(handles.DX,'String'));
    0046     end
    0047     if isequal(get(handles.DY,'Visible'),'on')
    0048         data.DY=str2num(get(handles.DY,'String'));
    0049     end
    0050     if isequal(get(handles.DZ,'Visible'),'on')
    0051         data.DZ=str2num(get(handles.DZ,'String'));
    0052     end
    0053     dimrange=[1 1];%default
    0054     if isequal(get(handles.ZMin,'Visible'),'on')
    0055         ZMin=str2num(get(handles.ZMin,'String'));
    0056         if ~isempty(ZMin)
    0057            data.RangeZ(1)=ZMin;
    0058            dimrange=[2 3];
    0059         end
    0060     end
    0061     if isequal(get(handles.ZMax,'Visible'),'on')
    0062         ZMax=str2num(get(handles.ZMax,'String'));
    0063         if isempty(ZMax)
    0064             if dimrange(1)>1
    0065 %                 set(handles.ZMax,'String',get(handles.ZMin,'String'))
    0066                 data.RangeZ(1)=ZMax;
    0067             end
    0068         else
    0069            data.RangeZ=ZMax;
    0070            dimrange=[dimrange(1) 3];
    0071         end
    0072     end
    0073     if isequal(get(handles.YMin,'Visible'),'on')
    0074         YMin=str2num(get(handles.YMin,'String'));
    0075         if isempty(YMin)
    0076 %             if dimrange(2)>2
    0077 % %                 set(handles.YMin,'String','0')
    0078 %                 data.RangeY(2)=0;
    0079 %             end
    0080         else
    0081             data.RangeY(2)=YMin;
    0082             dimrange=[2 max(dimrange(2),2)];
    0083         end
    0084     end
    0085     if isequal(get(handles.YMax,'Visible'),'on')
    0086 %         data.YMax=str2num(get(handles.YMax,'String'));
    0087         YMax=str2num(get(handles.YMax,'String'));
    0088         if isempty(YMax)
    0089 %             if dimrange(1)>1
    0090 % %                 set(handles.YMax,'String',get(handles.YMin,'String'))
    0091 %                 if ~isempty(YMin)
    0092 %                 data.RangeY(1)=YMin;
    0093 %                 end
    0094 %             elseif dimrange(2)>2
    0095 % %                 set(handles.YMax,'String',get(handles.ZMin,'String'))
    0096 %                 data.RangeY(2)=ZMin;
    0097 %             end
    0098         else
    0099             data.RangeY(1)=YMax;
    0100             dimrange=[dimrange(1) max(dimrange(2),2)];
    0101         end
    0102     end
    0103     if isequal(get(handles.XMin,'Visible'),'on')
    0104         XMin=str2num(get(handles.XMin,'String'));
    0105         if isempty(XMin)
    0106 %             if ~isempty(YMin)
    0107 %                 if dimrange(2)>1
    0108 % %                     set(handles.XMin,'String',get(handles.YMin,'String'))
    0109 %                     data.RangeX(2)=YMin;
    0110 %                     XMin=YMin;
    0111 %                 end
    0112 %             end
    0113         else
    0114             data.RangeX(2)=XMin;
    0115             %dimrange=[2 max(dimrange(2),1)];
    0116         end
    0117     end
    0118     if isequal(get(handles.XMax,'Visible'),'on')
    0119          XMax=str2num(get(handles.XMax,'String'));
    0120          if isempty(XMax)
    0121 %             if dimrange(1)>1
    0122 % %                 set(handles.XMax,'String',get(handles.XMin,'String'))
    0123 %                 if ~isempty(XMin)
    0124 %                 data.RangeX(2)=XMin;
    0125 %                 end
    0126 %             elseif dimrange(2)>1
    0127 % %                 set(handles.XMax,'String',get(handles.YMax,'String'))
    0128 %                 data.RangeX(1)=YMax;
    0129 %             end
    0130         else
    0131             data.RangeX(1)=XMax;
    0132          end
    0133     end
    0134 end
    0135
    0136
    0137 %positions x,y,z
    0138 Xcolumn=get(handles.XObject,'String');
    0139 Ycolumn=get(handles.YObject,'String');
    0140 if ischar(Xcolumn)
    0141     sizchar=size(Xcolumn);
    0142     for icol=1:sizchar(1)
    0143         Xcolumn_cell{icol}=Xcolumn(icol,:);
    0144     end
    0145     Xcolumn=Xcolumn_cell;
    0146 end
    0147 if ischar(Ycolumn)
    0148     sizchar=size(Ycolumn);
    0149     for icol=1:sizchar(1)
    0150         Ycolumn_cell{icol}=Ycolumn(icol,:);
    0151     end
    0152     Ycolumn=Ycolumn_cell;
    0153 end
    0154 Zcolumn={};%default
    0155 if isequal(get(handles.ZObject,'Visible'),'on')
    0156     data.NbDim=3; %test 3D object
    0157     Zcolumn=get(handles.ZObject,'String');
    0158     if ischar(Zcolumn)
    0159         Zcolumn={Zcolumn};
    0160     end
    0161 end
    0162 nb_points=min(length(Xcolumn),length(Ycolumn));%number of point positions needed to define the object position
    0163 if isequal (data.Style,'line');
    0164     nb_defining_points=2;
    0165 elseif isequal(data.Style,'plane')|isequal(data.Style,'rectangle')|isequal(data.Style,'ellipse')
    0166     nb_defining_points=1;
    0167 else
    0168     nb_defining_points=nb_points;
    0169 end
    0170 data_XObject=[];
    0171 data_YObject=[];
    0172 data_ZObject=[];
    0173 for i=1:nb_points
    0174     Xnumber=str2num(Xcolumn{i});
    0175     Ynumber=str2num(Ycolumn{i});
    0176     if isempty(Xnumber)|isempty(Ynumber)
    0177         break
    0178     else
    0179         data_XObject=[data_XObject; Xnumber(1)];
    0180         data_YObject=[data_YObject; Ynumber(1)];
    0181     end
    0182     if length(Zcolumn)<i | isempty(str2num(Zcolumn{i}))
    0183         data_ZObject=[data_ZObject; 0];
    0184     else
    0185         data_ZObject=[data_ZObject; str2num(Zcolumn{i})];
    0186     end
    0187 end
    0188 if nb_defining_points > nb_points
    0189     for i=nb_points+1:nb_defining_points
    0190         data_XObject=[0;data_XObject];
    0191         data_YObject=[0;data_YObject];
    0192         data_ZObject=[0;data_ZObject];
    0193     end
    0194 end
    0195 if isempty(data_XObject)
    0196     data_XObject=0;
    0197 end
    0198 if isempty(data_YObject)
    0199     data_YObject=0;
    0200 end
    0201 if isempty(data_ZObject)
    0202     data_ZObject=0;
    0203 end
    0204 data.Coord=[data_XObject data_YObject data_ZObject];
    0205
    0206 set(handles.XObject,'String',mat2cell(data_XObject,length(data_XObject)))%correct the interface display
    0207 set(handles.YObject,'String',mat2cell(data_YObject,length(data_XObject)))
    0208 set(handles.ZObject,'String',mat2cell(data_ZObject,length(data_XObject)))
    0209
    0210