Changeset 156


Ignore:
Timestamp:
Dec 19, 2010, 10:11:04 PM (13 years ago)
Author:
sommeria
Message:

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

Location:
trunk/src
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field.m

    r124 r156  
    223223    siz=size(ValCell{1});
    224224    ValCell{1}=reshape(ValCell{1},siz(1),1);
     225    Role{1}='scalar';
    225226    if isfield(DataIn,'TimeUnit')
    226227        units={[DataIn.TimeUnit '-1']};
  • trunk/src/create_grid.m

    r109 r156  
    1212function varargout = create_grid(varargin)
    1313
    14 % Last Modified by GUIDE v2.5 05-Mar-2010 21:57:44
     14% Last Modified by GUIDE v2.5 16-Dec-2010 00:17:20
    1515
    1616% Begin initialization code - DO NOT EDIT
     
    4444if exist('name','var') && ischar(name)
    4545    set(hObject,'name',name)
     46    if strcmp(name,'detect_grid')
     47        set(handles.white,'Visible','on')
     48        set(handles.black,'Visible','on')
     49    end
    4650end
    4751% Update handles structure
     
    137141    varargout{1}=[xarray yarray zarray];
    138142    varargout{2}=T;
     143    varargout{3}=get(handles.white,'Value')
    139144end
    140145
     
    189194
    190195
    191 
    192 
    193 
     196% --- Executes on button press in white.
     197function white_Callback(hObject, eventdata, handles)
     198val=get(handles.white,'Value');
     199if val
     200    set(handles.black,'Value',0)
     201else
     202    set(handles.black,'Value',1)
     203end
     204% hObject    handle to white (see GCBO)
     205% eventdata  reserved - to be defined in a future version of MATLAB
     206% handles    structure with handles and user data (see GUIDATA)
     207
     208% Hint: get(hObject,'Value') returns toggle state of white
     209
     210
     211% --- Executes on button press in black.
     212function black_Callback(hObject, eventdata, handles)
     213val=get(handles.black,'Value');
     214if val
     215    set(handles.white,'Value',0)
     216else
     217    set(handles.white,'Value',1)
     218end
     219
  • trunk/src/dataview.m

    r152 r156  
    102102   set(handles.Cancel,'Visible','on')
    103103   set(handles.figure,'WindowStyle','modal')% Make% Make the GUI modal
     104   set(hObject,'Visible','on')
     105   drawnow
    104106   RootDirectory_Callback(hObject, eventdata, handles)
    105107   % UIWAIT makes translate_points wait for user response (see UIRESUME)
     
    144146function RootDirectory_Callback(hObject, eventdata, handles)
    145147%------------------------------------------------------------------------
     148set(handles.RootDirectory,'BackgroundColor',[1 1 0])
     149drawnow
    146150CampaignDir=get(handles.RootDirectory,'String');
    147151ExpName={''};
     
    167171    msgbox_uvmat('ERROR',['The input ' CampaignDir ' is not a directory'])
    168172end
     173set(handles.RootDirectory,'BackgroundColor',[1 1 1])
    169174
    170175%------------------------------------------------------------------------
  • trunk/src/delete_object.m

    r89 r156  
    1717if isequal(floor(hObject),hObject) %case of an index
    1818    if  ~isempty(UvData) & isfield(UvData, 'Object') & length(UvData.Object)>=hObject
    19         if isfield(UvData.Object{hObject},'HandlesDisplay')
    20             hdisplay=UvData.Object{hObject}.HandlesDisplay;
     19        if isfield(UvData.Object{hObject},'DisplayHandle_uvmat')
     20            hdisplay=UvData.Object{hObject}.DisplayHandle_uvmat;
    2121            for iview=1:length(hdisplay)
    2222                if ishandle(hdisplay(iview)) & ~isequal(hdisplay(iview),0)
     
    3434        end   
    3535        for iobj=hObject+1:length(UvData.Object)
    36             hdisplay=UvData.Object{iobj}.HandlesDisplay;
     36            hdisplay=UvData.Object{iobj}.DisplayHandle_uvmat;
    3737            for iview=1:length(hdisplay)
    3838                if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
  • trunk/src/geometry_calib.m

    r149 r156  
    7575%------------------------------------------------------------------------
    7676% Choose default command line output for geometry_calib
     77
    7778handles.output = hObject;
    7879
     
    8283
    8384%set the position of the interface
    84 if exist('pos','var')&& length(pos)>2
    85     pos_gui=get(hObject,'Position');
    86     pos_gui(1)=pos(1);
    87     pos_gui(2)=pos(2);
    88     set(hObject,'Position',pos_gui);
     85if exist('pos','var')&& length(pos)>=4
     86%     %pos_gui=get(hObject,'Position');
     87%     pos_gui(1)=pos(1);
     88%     pos_gui(2)=pos(2);
     89    set(hObject,'Position',pos);
    8990end
    9091
    9192%set menu of calibration options
    92 %set(handles.calib_type,'String',{'rescale';'linear';'perspective';'normal';'tsai';'bouguet';'extrinsic'})
    9393set(handles.calib_type,'String',{'rescale';'linear';'3D_linear';'3D_quadr';'3D_extrinsic'})
    9494inputxml='';
     
    9999        inputfile=[fullfile(Pathsub,RootFile) '.xml'];%xml file corresponding to the input file
    100100    end
    101 end
    102 set(handles.ListCoord,'String',{'......'})
    103 if exist(inputfile,'file')
    104     Heading=loadfile(handles,inputfile);% load the point coordiantes existing in the xml file
    105 end
    106 if isfield(Heading,'Campaign')&& ischar(Heading.Campaign)
    107     struct.Campaign=Heading.Campaign;
    108 end
    109 set(hObject,'UserData',struct)
     101    set(handles.ListCoord,'String',{'......'})
     102    if exist(inputfile,'file')
     103        Heading=loadfile(handles,inputfile);% load the point coordiantes existing in the xml file
     104        if isfield(Heading,'Campaign')&& ischar(Heading.Campaign)
     105            struct.Campaign=Heading.Campaign;
     106        end
     107    end   
     108    set(hObject,'UserData',struct)
     109end
     110
    110111set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function
    111112
     
    126127if ~isempty(huvmat)
    127128    handles=guidata(huvmat);
    128     set(handles.MenuMask,'enable','on')
    129     set(handles.MenuGrid,'enable','on')
    130     set(handles.MenuObject,'enable','on')
    131     set(handles.MenuEdit,'enable','on')
    132     set(handles.edit,'enable','on')
     129%     set(handles.MenuMask,'enable','on')
     130%     set(handles.MenuGrid,'enable','on')
     131%     set(handles.MenuObject,'enable','on')
     132%     set(handles.MenuEdit,'enable','on')
     133%     set(handles.edit,'enable','on')
    133134    hobject=findobj(handles.axes3,'tag','calib_points');
    134135    if ~isempty(hobject)
     
    11031104    grid_input=CalibData.grid;%retrieve the previously used grid
    11041105end
    1105 [T,CalibData.grid]=create_grid(grid_input,'detect_grid');%display the GUI create_grid, read the set of phys coordinates T
     1106[T,CalibData.grid,white_test]=create_grid(grid_input,'detect_grid');%display the GUI create_grid, read the set of phys coordinates T
    11061107
    11071108set(handles.geometry_calib,'UserData',CalibData)%store the phys grid parameters for later use
     
    12001201% [Amod,Rangx,Rangy]=phys_Ima(A-min(min(A)),GeometryCalib,0);
    12011202
    1202 
    1203 Amod=double(Amod);
     1203if white_test
     1204    Amod=double(Amod);%will look for image maxima
     1205else
     1206    Amod=-double(Amod);%will look for image minima
     1207end
    12041208% figure(12) %display corrected image
    12051209% Amax=max(max(Amod));
  • trunk/src/get_plot_handles.m

    r128 r156  
    6565%PlotHandles.cal=handles.cal;
    6666%PlotHandles.makemask=handles.makemask;
    67 PlotHandles.edit=handles.edit;
     67PlotHandles.edit_object=handles.edit_object;
    6868PlotHandles.text_display_1=handles.text_display_1;
    6969PlotHandles.text_display_2=handles.text_display_2;
  • trunk/src/imadoc2struct.m

    r116 r156  
    1616
    1717function [s,errormsg]=imadoc2struct(ImaDoc,option)
     18%% default input and output
    1819if ~exist('option','var')
    19     option='default';
     20    option='*';
    2021end
    2122errormsg=[];%default
     
    2627tsai=[];%default
    2728
     29%% opening the xml file
    2830if exist(ImaDoc,'file')~=2, errormsg=[ ImaDoc ' does not exist']; return;end;%input file does not exist
    2931try
     
    3436    return
    3537end
    36 
    3738uid_root=find(t,'/ImaDoc');
    3839if isempty(uid_root), errormsg=[ImaDoc ' is not an image documentation file ImaDoc']; return; end;%not an ImaDoc .xml file
    3940
    40 %Heading
     41
     42%% Heading
    4143uid_Heading=find(t,'/ImaDoc/Heading');
    4244if ~isempty(uid_Heading),
     
    5557end
    5658
    57 %Camera   
    58 uid_Camera=find(t,'/ImaDoc/Camera');
    59 if ~isempty(uid_Camera)
    60     uid_ImageSize=find(t,'/ImaDoc/Camera/ImageSize');
    61     if ~isempty(uid_ImageSize);
    62         ImageSize=get(t,children(t,uid_ImageSize),'value');
    63         xindex=findstr(ImageSize,'x');
    64         if length(xindex)>=2
    65              s.Npx=str2double(ImageSize(1:xindex(1)-1));
    66              s.Npy=str2double(ImageSize(xindex(1)+1:xindex(2)-1));
     59%% Camera  and timing
     60if strcmp(option,'*') || strcmp(option,'Camera')
     61    uid_Camera=find(t,'/ImaDoc/Camera');
     62    if ~isempty(uid_Camera)
     63        uid_ImageSize=find(t,'/ImaDoc/Camera/ImageSize');
     64        if ~isempty(uid_ImageSize);
     65            ImageSize=get(t,children(t,uid_ImageSize),'value');
     66            xindex=findstr(ImageSize,'x');
     67            if length(xindex)>=2
     68                s.Npx=str2double(ImageSize(1:xindex(1)-1));
     69                s.Npy=str2double(ImageSize(xindex(1)+1:xindex(2)-1));
     70            end
     71        end
     72        uid_TimeUnit=find(t,'/ImaDoc/Camera/TimeUnit');
     73        if ~isempty(uid_TimeUnit)
     74            s.TimeUnit=get(t,children(t,uid_TimeUnit),'value');
     75        end
     76        uid_BurstTiming=find(t,'/ImaDoc/Camera/BurstTiming');
     77        if ~isempty(uid_BurstTiming)
     78            for k=1:length(uid_BurstTiming)
     79                subt=branch(t,uid_BurstTiming(k));%subtree under BurstTiming
     80                % reading Dtk
     81                Frequency=get_value(subt,'/BurstTiming/FrameFrequency',1);
     82                Dtj=get_value(subt,'/BurstTiming/Dtj',[]);
     83                Dtj=Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')
     84                NbDtj=get_value(subt,'/BurstTiming/NbDtj',1);
     85                Dti=get_value(subt,'/BurstTiming/Dti',[]);
     86                Dti=Dti/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')
     87                NbDti=get_value(subt,'/BurstTiming/NbDti',1);
     88                Time_val=get_value(subt,'/BurstTiming/Time',0);%time in TimeUnit
     89                if ~isempty(Dti)
     90                    Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times
     91                    Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals  Dti
     92                end
     93                if ~isempty(Dtj)
     94                    Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dti vector NbDti times
     95                    Dtj=[0 Dtj];
     96                    Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj
     97                end
     98                % reading Dtk
     99                Dtk=get_value(subt,'/BurstTiming/Dtk',[]);
     100                NbDtk=get_value(subt,'/BurstTiming/NbDtk',1);
     101                if isempty(Dtk)
     102                    s.Time=[s.Time;Time_val];
     103                else
     104                    for kblock=1:NbDtk+1
     105                        Time_val=Time_val+(kblock-1)*Dtk;
     106                        s.Time=[s.Time;Time_val];
     107                    end
     108                end
     109            end
    67110        end
    68111    end
    69     uid_TimeUnit=find(t,'/ImaDoc/Camera/TimeUnit');
    70     if ~isempty(uid_TimeUnit)
    71         s.TimeUnit=get(t,children(t,uid_TimeUnit),'value');
     112end
     113
     114%%  geometric calibration
     115if strcmp(option,'*') || strcmp(option,'GeometryCalib')
     116    uid_GeometryCalib=find(t,'/ImaDoc/GeometryCalib');
     117    if ~isempty(uid_GeometryCalib)
     118        if length(uid_GeometryCalib)>1
     119            errormsg=['More than one GeometryCalib in ' filecivxml];
     120            return
     121        end
     122        subt=branch(t,uid_GeometryCalib);%subtree under GeometryCalib
     123        cont=get(subt,1,'contents');
     124        if ~isempty(cont)
     125            uid_CalibrationType=find(subt,'/GeometryCalib/CalibrationType');
     126            if isequal(length(uid_CalibrationType),1)
     127                tsai.CalibrationType=get(subt,children(subt,uid_CalibrationType),'value');
     128            end
     129            uid_CoordUnit=find(subt,'/GeometryCalib/CoordUnit');
     130            if isequal(length(uid_CoordUnit),1)
     131                tsai.CoordUnit=get(subt,children(subt,uid_CoordUnit),'value');
     132            end
     133            uid_fx_fy=find(subt,'/GeometryCalib/fx_fy');
     134            focal=[];%default fro old convention (Reg Wilson)
     135            if isequal(length(uid_fx_fy),1)
     136                tsai.fx_fy=str2num(get(subt,children(subt,uid_fx_fy),'value'));
     137            else %old convention (Reg Wilson)
     138                uid_focal=find(subt,'/GeometryCalib/focal');
     139                uid_dpx_dpy=find(subt,'/GeometryCalib/dpx_dpy');
     140                uid_sx=find(subt,'/GeometryCalib/sx');
     141                if ~isempty(uid_focal) && ~isempty(uid_dpx_dpy) && ~isempty(uid_sx)
     142                    dpx_dpy=str2num(get(subt,children(subt,uid_dpx_dpy),'value'));
     143                    sx=str2num(get(subt,children(subt,uid_sx),'value'));
     144                    focal=str2num(get(subt,children(subt,uid_focal),'value'));
     145                    tsai.fx_fy(1)=sx*focal/dpx_dpy(1);
     146                    tsai.fx_fy(2)=focal/dpx_dpy(2);
     147                end
     148            end
     149            uid_Cx_Cy=find(subt,'/GeometryCalib/Cx_Cy');
     150            if ~isempty(uid_Cx_Cy)
     151                tsai.Cx_Cy=str2num(get(subt,children(subt,uid_Cx_Cy),'value'));
     152            end
     153            uid_kc=find(subt,'/GeometryCalib/kc');
     154            if ~isempty(uid_kc)
     155                tsai.kc=str2double(get(subt,children(subt,uid_kc),'value'));
     156            else %old convention (Reg Wilson)
     157                uid_kappa1=find(subt,'/GeometryCalib/kappa1');
     158                if ~isempty(uid_kappa1)&& ~isempty(focal)
     159                    kappa1=str2double(get(subt,children(subt,uid_kappa1),'value'));
     160                    tsai.kc=-kappa1*focal*focal;
     161                end
     162            end
     163            uid_Tx_Ty_Tz=find(subt,'/GeometryCalib/Tx_Ty_Tz');
     164            if ~isempty(uid_Tx_Ty_Tz)
     165                tsai.Tx_Ty_Tz=str2num(get(subt,children(subt,uid_Tx_Ty_Tz),'value'));
     166            end
     167            uid_R=find(subt,'/GeometryCalib/R');
     168            if ~isempty(uid_R)
     169                RR=get(subt,children(subt,uid_R),'value');
     170                if length(RR)==3
     171                    tsai.R=[str2num(RR{1});str2num(RR{2});str2num(RR{3})];
     172                end
     173            end
     174           
     175            %look for laser plane definitions
     176            uid_Angle=find(subt,'/GeometryCalib/PlaneAngle');
     177            uid_Pos=find(subt,'/GeometryCalib/SliceCoord');
     178            if isempty(uid_Pos)
     179                uid_Pos=find(subt,'/GeometryCalib/PlanePos');%old convention
     180            end
     181            if ~isempty(uid_Angle)
     182                tsai.PlaneAngle=str2num(get(subt,children(subt,uid_Angle),'value'));
     183            end
     184            if ~isempty(uid_Pos)
     185                for j=1:length(uid_Pos)
     186                    tsai.SliceCoord(j,:)=str2num(get(subt,children(subt,uid_Pos(j)),'value'));
     187                end
     188                uid_DZ=find(subt,'/GeometryCalib/SliceDZ');
     189                uid_NbSlice=find(subt,'/GeometryCalib/NbSlice');
     190                if ~isempty(uid_DZ) && ~isempty(uid_NbSlice)
     191                    DZ=str2double(get(subt,children(subt,uid_DZ),'value'));
     192                    NbSlice=get(subt,children(subt,uid_NbSlice),'value');
     193                    if isequal(NbSlice,'volume')
     194                        tsai.NbSlice='volume';
     195                        NbSlice=NbDtj+1;
     196                    else
     197                        tsai.NbSlice=str2double(NbSlice);
     198                    end
     199                    tsai.SliceCoord=ones(NbSlice,1)*tsai.SliceCoord+DZ*(0:NbSlice-1)'*[0 0 1];
     200                end
     201            end
     202            if strcmp(option,'GeometryCalib')
     203                tsai.PointCoord=get_value(subt,'/GeometryCalib/SourceCalib/PointCoord',[0 0 0 0 0]);
     204            end
     205            s.GeometryCalib=tsai;
     206        end
    72207    end
    73     uid_BurstTiming=find(t,'/ImaDoc/Camera/BurstTiming');
    74     if ~isempty(uid_BurstTiming)
    75         for k=1:length(uid_BurstTiming)
    76             subt=branch(t,uid_BurstTiming(k));%subtree under BurstTiming
    77              % reading Dtk
    78             Frequency=get_value(subt,'/BurstTiming/FrameFrequency',1);
    79             Dtj=get_value(subt,'/BurstTiming/Dtj',[]);
    80             Dtj=Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')
    81             NbDtj=get_value(subt,'/BurstTiming/NbDtj',1);
    82             Dti=get_value(subt,'/BurstTiming/Dti',[]);
    83             Dti=Dti/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')
    84             NbDti=get_value(subt,'/BurstTiming/NbDti',1);
    85             Time_val=get_value(subt,'/BurstTiming/Time',0);%time in TimeUnit
    86             if ~isempty(Dti)
    87                 Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times
    88                 Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals  Dti
    89             end
    90             if ~isempty(Dtj)
    91                 Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dti vector NbDti times
    92                 Dtj=[0 Dtj];
    93                 Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj
    94             end
    95             % reading Dtk
    96             Dtk=get_value(subt,'/BurstTiming/Dtk',[]);
    97             NbDtk=get_value(subt,'/BurstTiming/NbDtk',1);
    98             if isempty(Dtk)
    99                 s.Time=[s.Time;Time_val];
    100             else
    101                 for kblock=1:NbDtk+1
    102                     Time_val=Time_val+(kblock-1)*Dtk;
    103                     s.Time=[s.Time;Time_val];
    104                 end
    105             end
    106         end
    107     end
    108 end
    109 
    110 %read calibration
    111 uid_GeometryCalib=find(t,'/ImaDoc/GeometryCalib');
    112 if ~isempty(uid_GeometryCalib)
    113     if length(uid_GeometryCalib)>1
    114         errormsg=['More than one GeometryCalib in ' filecivxml];
    115         return
    116     end
    117     subt=branch(t,uid_GeometryCalib);%subtree under GeometryCalib
    118     cont=get(subt,1,'contents');
    119     if ~isempty(cont)
    120 %         uid_pixcmx=find(subt,'/GeometryCalib/Pxcmx');
    121 %         uid_pixcmy=find(subt,'/GeometryCalib/Pxcmy');
    122 %         if ~isempty(uid_pixcmx) && ~isempty(uid_pixcmy)%NON UTILISE
    123 %            pixcmx=str2num(get(subt,children(subt,uid_pixcmx),'value'));
    124 %             if isempty(pixcmx),pixcmx=1;end; %default
    125 %             pixcmy=str2num(get(subt,children(subt,uid_pixcmy),'value'));
    126 %             if isempty(pixcmy),pixcmy=1;end; %default
    127 %             tsai.Pxcmx=pixcmx;
    128 %             tsai.Pxcmy=pixcmy;
    129 %         end
    130         %default values:
    131         %tsai.dpx_dpy=1;
    132         %tsai.dpy=1;
    133         %tsai.sx=1;
    134 %         tsai.Cx_Cy=[0 0];
    135        % tsai.Cy=0;
    136 %         tsai.Tx_Ty_Tz=[0 0 1];
    137 %         tsai.Tx=0;
    138 %         tsai.Ty=0;
    139 %         tsai.R=[1 0 0; 0 1 0; 0 0 0];
    140         uid_CalibrationType=find(subt,'/GeometryCalib/CalibrationType');
    141         if isequal(length(uid_CalibrationType),1)
    142             tsai.CalibrationType=get(subt,children(subt,uid_CalibrationType),'value');
    143         end
    144         uid_CoordUnit=find(subt,'/GeometryCalib/CoordUnit');
    145         if isequal(length(uid_CoordUnit),1)
    146             tsai.CoordUnit=get(subt,children(subt,uid_CoordUnit),'value');
    147         end
    148         uid_fx_fy=find(subt,'/GeometryCalib/fx_fy');
    149         focal=[];%default fro old convention (Reg Wilson)
    150         if isequal(length(uid_fx_fy),1)
    151             tsai.fx_fy=str2num(get(subt,children(subt,uid_fx_fy),'value'));
    152         else %old convention (Reg Wilson)
    153             uid_focal=find(subt,'/GeometryCalib/focal');
    154             uid_dpx_dpy=find(subt,'/GeometryCalib/dpx_dpy');
    155             uid_sx=find(subt,'/GeometryCalib/sx');
    156             if ~isempty(uid_focal) && ~isempty(uid_dpx_dpy) && ~isempty(uid_sx)
    157                 dpx_dpy=str2num(get(subt,children(subt,uid_dpx_dpy),'value'));
    158                 sx=str2num(get(subt,children(subt,uid_sx),'value'));
    159                 focal=str2num(get(subt,children(subt,uid_focal),'value'));
    160                 tsai.fx_fy(1)=sx*focal/dpx_dpy(1);
    161                 tsai.fx_fy(2)=focal/dpx_dpy(2);
    162             end
    163         end
    164         uid_Cx_Cy=find(subt,'/GeometryCalib/Cx_Cy');
    165         if ~isempty(uid_Cx_Cy)
    166             tsai.Cx_Cy=str2num(get(subt,children(subt,uid_Cx_Cy),'value'));
    167         end
    168         uid_kc=find(subt,'/GeometryCalib/kc');
    169         if ~isempty(uid_kc)
    170             tsai.kc=str2num(get(subt,children(subt,uid_kc),'value'));
    171         else %old convention (Reg Wilson)
    172             uid_kappa1=find(subt,'/GeometryCalib/kappa1');
    173             if ~isempty(uid_kappa1)&& ~isempty(focal)
    174                 kappa1=str2num(get(subt,children(subt,uid_kappa1),'value'));
    175                 tsai.kc=-kappa1*focal*focal;
    176             end
    177         end
    178         uid_Tx_Ty_Tz=find(subt,'/GeometryCalib/Tx_Ty_Tz');
    179         if ~isempty(uid_Tx_Ty_Tz)
    180             tsai.Tx_Ty_Tz=str2num(get(subt,children(subt,uid_Tx_Ty_Tz),'value'));
    181         end
    182         uid_R=find(subt,'/GeometryCalib/R');
    183         if ~isempty(uid_R)
    184             RR=get(subt,children(subt,uid_R),'value');
    185             if length(RR)==3
    186                 tsai.R=[str2num(RR{1});str2num(RR{2});str2num(RR{3})];
    187             end
    188         end
    189        
    190         %look for laser plane definitions   
    191         uid_Angle=find(subt,'/GeometryCalib/PlaneAngle');
    192         uid_Pos=find(subt,'/GeometryCalib/SliceCoord');
    193         if isempty(uid_Pos)
    194             uid_Pos=find(subt,'/GeometryCalib/PlanePos');%old convention
    195         end
    196         if ~isempty(uid_Angle)
    197             tsai.PlaneAngle=str2num(get(subt,children(subt,uid_Angle),'value'));
    198         end
    199         if ~isempty(uid_Pos)     
    200             for j=1:length(uid_Pos)
    201                 tsai.SliceCoord(j,:)=str2num(get(subt,children(subt,uid_Pos(j)),'value'));
    202             end
    203             uid_DZ=find(subt,'/GeometryCalib/SliceDZ');
    204             uid_NbSlice=find(subt,'/GeometryCalib/NbSlice');
    205             if ~isempty(uid_DZ) && ~isempty(uid_NbSlice)
    206                 DZ=str2double(get(subt,children(subt,uid_DZ),'value'));
    207                 NbSlice=get(subt,children(subt,uid_NbSlice),'value');
    208                 if isequal(NbSlice,'volume')
    209                     tsai.NbSlice='volume';
    210                     NbSlice=NbDtj+1;
    211                 else
    212                     tsai.NbSlice=str2double(NbSlice);
    213                 end
    214                 tsai.SliceCoord=ones(NbSlice,1)*tsai.SliceCoord+DZ*(0:NbSlice-1)'*[0 0 1];
    215             end         
    216         end
    217         if strcmp(option,'GeometryCalib')
    218             tsai.PointCoord=get_value(subt,'/GeometryCalib/SourceCalib/PointCoord',[0 0 0 0 0]);%time in TimeUnit
    219             size(tsai.PointCoord)
    220         end
    221         s.GeometryCalib=tsai;
    222     end
    223 end   
     208end
    224209
    225210%--------------------------------------------------
  • trunk/src/mouse_down.m

    r150 r156  
    2424function xy=mouse_down(hObject,eventdata)
    2525
    26 MouseAction='none'; %default
     26%MouseAction='none'; %default
    2727huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls theoption of  mouse action
    2828if isempty(huvmat)
     
    3030end
    3131hhuvmat=guidata(huvmat);%handles of elements in uvmat
    32 guihandles=guidata(hObject);
    3332UvData=get(huvmat,'UserData');
    34 MouseAction='none'; %default
     33%MouseAction='none'; %default
    3534currentfig=hObject;
    3635hhcurrentfig=guidata(currentfig);
    37 test_zoom=get(hhcurrentfig.zoom,'Value')
    38 %test_zoom=get(guihandles.zoom,'Value');% get the mouse action from the uvmat GUI: options:
    39 if isfield(UvData,'MouseAction')
    40     MouseAction=UvData.MouseAction;% get the mouse action from the uvmat GUI: options:
    41 end
    42 
    43 test_create=~test_zoom && (isequal(MouseAction,'create_object') || isequal(MouseAction,'create_mask'));
     36test_zoom=get(hhcurrentfig.zoom,'Value');%test for zoom action, first priority
     37% if isfield(UvData,'MouseAction')
     38%     MouseAction=UvData.MouseAction;% get the mouse action from the uvmat GUI: options:
     39% end
     40
    4441%test_cal=get(handles.cal,'Value');
    45 test_cal=strcmp(MouseAction,'calib');
    46 test_ruler=strcmp(MouseAction,'ruler');
    47 test_edit=strcmp(MouseAction,'edit_object');
    48 test_edit_vect=strcmp(MouseAction,'edit_vect');
     42% test_cal=strcmp(MouseAction,'calib');
     43test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler  action, second priority
     44%test_ruler=strcmp(MouseAction,'ruler');
     45%test_edit=strcmp(MouseAction,'edit_object');
     46test_edit=get(hhuvmat.edit_object,'Value');%test for object editing, third priority
     47%test_edit_vect=strcmp(MouseAction,'edit_vect');%test for vector editing,  priority 4
     48test_edit_vect=get(hhuvmat.edit_vect,'Value');%test for vector editing,  priority 4
     49test_create=isequal(get(hhuvmat.MenuObject,'checked'),'on');% test for object creation,  priority 5
     50if test_create
     51    hset_object=findobj(allchild(0),'tag','set_object');
     52    test_create=~isempty(hset_object)&&~test_edit;
     53end
     54test_cal=isequal(get(hhuvmat.MenuCalib,'checked'),'on');% test for calibration
     55if test_cal% test for calibration popints,  priority 6
     56    h_calib=findobj(allchild(0),'tag','geometry_calib');
     57    if isempty(h_calib)
     58        test_cal=0;
     59        set(hhuvmat.MenuCalib,'checked','off');% test for calibration off
     60    else
     61        hh_calib=guidata(h_calib);
     62        test_cal=get(hh_calib.edit_append,'Value');
     63    end
     64end
     65%test_create=~test_zoom && strcmp(MouseAction,'create_object')&&~test_edit && ~test_edit_vect ;% || isequal(MouseAction,'create_mask'));
    4966xdisplay=[];%default
    5067ydisplay=[];%default
    5168AxeData=[];%default
    5269
    53 %edit an existing point or line if found
     70%% edit an existing point or line if found
    5471hcurrentobject=gco;% current object handle (selected by the mouse)
    5572hcurrentfig=hObject;% current figure handle
     
    6077hchild=get(hcurrentfig,'Children');%handles of all objects in the current figure
    6178haxes=[];
    62 % loop on all the objects in the current figure (selected by the last mouse click)
     79
     80%% loop on all the objects in the current figure (selected by the last mouse click)
    6381for ichild=1:length(hchild)
    6482    obj_pos=get(hchild(ichild),'Position');%position of the object
     
    7492                AxeData=get(haxes,'UserData');% data attached to the axis
    7593                AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin
    76                 if ~isequal(tag_obj,'proj_object') & ~test_create
    77                     x_mouse=xy(1,1);%default
    78                     y_mouse=xy(1,2);%default
    79                     u_mouse=[];
    80                     v_mouse=[];
    81                     w_mouse=[];
    82                     A_mouse=[];
    83                     c_text=[];
    84                     f_text=[];
    85                     ff_text=[];     
    86                     ivec=[];   
    87                     if isfield(AxeData,'X') & isfield(AxeData,'Y') & isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis
    88                         flag_vec=(AxeData.X<(xy(1,1)+AxeData.Mesh/4) & AxeData.X>(xy(1,1)-AxeData.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
    89                           (AxeData.Y<(xy(1,2)+AxeData.Mesh/4) & AxeData.Y>(xy(1,2)-AxeData.Mesh/4));%f
    90                         ivec=find(flag_vec,1);% search the (first) selected vector index ivec
     94                if test_edit_vect && ~isequal(tag_obj,'proj_object') & ~test_create
     95                    ivec=[];
     96                    FigData=get(hcurrentfig,'UserData');
     97                    tagaxes=get(haxes,'tag');
     98                    if isfield(FigData,tagaxes)
     99                        eval(['Field=FigData.' tagaxes ';'])
     100                        [CellVarIndex,NbDim,VarType]=find_field_indices(Field);%analyse the physical fields contained in Field
     101                        for icell=1:numel(CellVarIndex)%look for all physical fields
     102                            if NbDim(icell)==2 % select 2D field
     103                                if  isfield(Field,'Mesh') && ~isempty(Field.Mesh)&& ~isempty(VarType{icell}.coord_x) && ~isempty(VarType{icell}.coord_y)%case of unstructured data
     104                                    eval(['X=Field.' Field.ListVarName{VarType{icell}.coord_x} ';'])
     105                                    eval(['Y=Field.' Field.ListVarName{VarType{icell}.coord_y} ';'])
     106                                    flag_vec=(X<(xy(1,1)+Field.Mesh/4) & X>(xy(1,1)-Field.Mesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
     107                                        (Y<(xy(1,2)+Field.Mesh/4) & Y>(xy(1,2)-Field.Mesh/4));%f
     108                                    ivec=find(flag_vec,1);% search the (first) selected vector index ivec
     109                                end
     110                            end
     111                        end
    91112                    end
    92113                end
     
    113134end   
    114135
    115 % zoom has first priority
     136%% zoom has first priority
    116137if test_zoom %&& ~test_create && ~test_edit && ~test_edit_vect && exist('xy','var')
    117138     AxeData.Drawing='zoom'; %initiate drawing mode
     
    120141     return
    121142end
    122 if isempty(huvmat)
    123     return
    124 end
    125 
    126 %ruler has second priority
     143if isempty(huvmat)%further options require the uvmat GUI
     144    return 
     145end
     146
     147%% ruler has second priority
    127148if test_ruler
    128     UvData.RulerCoord(1,1)=xy(1,1);
    129     UvData.RulerCoord(1,2)=xy(1,2);
    130     UvData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler');
    131     set(huvmat,'UserData',UvData)
     149    AxeData.RulerCoord(1,1)=xy(1,1);
     150    AxeData.RulerCoord(1,2)=xy(1,2);
     151    AxeData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler');
    132152    AxeData.Drawing='ruler';
    133153    set(haxes,'UserData',AxeData);
     
    135155end
    136156
    137 %selection of an existing projection object
     157%% selection of an existing projection object (third priority)
    138158if  test_edit && (isequal(tag_obj,'proj_object')||isequal(tag_obj,'DeformPoint'))
    139159    if ~(isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'create'))
     
    222242    end
    223243end
    224 %  create new projection  object
     244
     245%%  create new projection  object
    225246if  test_create && ~isempty(xy) && ~(isfield(AxeData,'Drawing')&& isequal(AxeData.Drawing,'create'))
    226         ObjectData=read_set_object(UvData.sethandles);
    227         ObjectData.Coord=[]; %reset previous object coordinates
    228         ObjectData.Coord(1,1)=xy(1,1);
    229         ObjectData.Coord(1,2)=xy(1,2);
    230         ObjectData.Coord(1,3)=0;
    231         if isfield(AxeData,'ObjectCoord') & size(AxeData.ObjectCoord,2)==3
    232              ObjectData.Coord(1,3)=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle
    233         end
    234         AxeData.CurrentObject=plot_object(ObjectData,[],haxes,'m');%draw the object and its handle becomes AxeData.CurrentObject
    235         if isfield(UvData,'Object')
    236             IndexObj=length(UvData.Object)+1;% add the object as index IndexObj on the list of the interface
    237         else
    238             IndexObj=2;
    239         end 
    240         UvData.Object{IndexObj}=ObjectData;
    241         UvData.Object{IndexObj}.HandlesDisplay(1)=AxeData.CurrentObject;
    242         set(huvmat,'UserData',UvData)
    243         list_str=get(hhuvmat.list_object_1,'String');
    244         object_name=get(UvData.sethandles.TITLE,'String')
    245         if isempty(object_name)|| strcmp(object_name,'')
    246             list_str{IndexObj}=[num2str(IndexObj) '-' ObjectData.Style];
    247             set(UvData.sethandles.TITLE,'String',list_str{IndexObj})
    248         else
    249            list_str{IndexObj}=object_name;
    250         end
    251         set(hhuvmat.list_object_1,'String',list_str)
    252         list_str{end+1}='...';
    253         set(hhuvmat.list_object_2,'String',list_str)
    254         if strcmp(fig_tag,'view_field')%we are in view_field plot
    255               set(hhuvmat.list_object_1,'Value',IndexObj)% the projection field will be plotted in uvmat frame
    256         else%we are in uvmat plot
    257             set(hhuvmat.list_object_2,'Value',IndexObj)
    258         end
    259         PlotData=get(AxeData.CurrentObject,'UserData');
    260         PlotData.IndexObj=IndexObj;
    261         set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph
    262         AxeData.Drawing='create';
     247        hset_object=findobj(allchild(0),'tag','set_object');
     248        if ~isempty(hset_object)
     249            sethandles=guidata(hset_object);
     250            ObjectData=read_set_object(sethandles);
     251            ObjectData.Coord=[]; %reset previous object coordinates
     252            ObjectData.Coord(1,1)=xy(1,1);
     253            ObjectData.Coord(1,2)=xy(1,2);
     254            ObjectData.Coord(1,3)=0;
     255            if isfield(AxeData,'ObjectCoord') & size(AxeData.ObjectCoord,2)==3
     256                 ObjectData.Coord(1,3)=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle
     257            end
     258            AxeData.CurrentObject=plot_object(ObjectData,[],haxes,'m');%draw the object and its handle becomes AxeData.CurrentObject
     259            if isfield(UvData,'Object')
     260                IndexObj=length(UvData.Object)+1;% add the object as index IndexObj on the list of the interface
     261            else
     262                IndexObj=2;
     263            end 
     264            UvData.Object{IndexObj}=ObjectData;       
     265            list_str=get(hhuvmat.list_object_1,'String');
     266            object_name=get(sethandles.TITLE,'String');
     267            if isempty(object_name)|| strcmp(object_name,'')
     268                list_str{IndexObj}=[num2str(IndexObj) '-' ObjectData.Style];
     269                set(sethandles.TITLE,'String',list_str{IndexObj})
     270            else
     271               list_str{IndexObj}=object_name;
     272            end
     273            set(hhuvmat.list_object_1,'String',list_str)
     274            list_str{end+1}='...';
     275            set(hhuvmat.list_object_2,'String',list_str)
     276            if strcmp(fig_tag,'view_field')%we are in view_field plot
     277                  set(hhuvmat.list_object_1,'Value',IndexObj)% the projection field will be plotted in uvmat frame
     278                  UvData.Object{IndexObj}.DisplayHandle_uvmat=[];
     279                  UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject;       
     280            else%we are in uvmat plot
     281                set(hhuvmat.list_object_2,'Value',IndexObj)
     282                UvData.Object{IndexObj}.DisplayHandle_uvmat=AxeData.CurrentObject;
     283                UvData.Object{IndexObj}.DisplayHandle_view_field=[];
     284            end
     285            set(huvmat,'UserData',UvData)
     286            PlotData=get(AxeData.CurrentObject,'UserData');
     287            PlotData.IndexObj=IndexObj;
     288            set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph
     289            AxeData.Drawing='create';
     290        end
    263291end
    264292
     
    267295    h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
    268296    hh_geometry_calib=guidata(h_geometry_calib);
    269     h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
    270297    h_edit_append=hh_geometry_calib.edit_append;%findobj(h_geometry_calib,'Tag','edit_append');
    271298    if isequal(get(h_edit_append,'Value'),1) && ~isempty(haxes)
     299        h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
    272300        coord_value=get(hhuvmat.transform_fct,'Value');% set uvmat to pixel coordinates, run it again if not
    273301        if ~(isequal(coord_value,1)||isequal(coord_value,3)); %active only with no transform or px (no phys)
     
    303331             Coord{val}=strline;
    304332             set(h_ListCoord,'String',Coord)
    305             % set(h_ListCoord,'Value',val+1)
    306333             data=read_geometry_calib(Coord);%transform char cell to numbers
    307334             XCoord=data.Coord(:,4);
     
    330357
    331358% edit vectors
    332 if test_edit_vect & ~isempty(ivec)
    333     if ~(isfield(AxeData,'FF')&& ~isempty(AxeData.FF))
    334         AxeData.FF=zeros(size(AxeData.X));
    335     end
    336     if isequal(AxeData.FF(ivec),0)
    337         AxeData.FF(ivec)=100; %mark vector #ivec as false
     359if test_edit_vect && ~isempty(ivec)
     360    %create the error flag FF if it does not exist
     361    if ~isfield(Field,'FF')
     362        Field.ListVarName=[Field.ListVarName 'FF'];
     363        Field.VarDimName=[Field.VarDimName Field.VarDimName{VarType{icell}.coord_x}];
     364        nbvar=length(Field.ListVarName);
     365        Field.VarAttribute{nbvar}.Role='errorflag';
     366        Field.FF=zeros(size(Field.X));
     367    end
     368    if isequal(Field.FF(ivec),0)
     369        Field.FF(ivec)=100 %mark vector #ivec as false
    338370    else
    339         AxeData.FF(ivec)=0;
    340     end
    341     PlotParam=read_plot_param(hhuvmat);
    342     [PlotType,ScalOut]= plot_field(AxeData,haxes,PlotParam,1);
     371        Field.FF(ivec)=0;
     372    end
     373    PlotParam=read_plot_param(hhcurrentfig);
     374    plot_field(Field,haxes,PlotParam);
     375    eval(['FigData.' tagaxes '=Field;'])%record the modified field in FigData
     376    set(hcurrentfig,'UserData',FigData);
    343377end   
    344378set(haxes,'UserData',AxeData);
  • trunk/src/mouse_motion.m

    r153 r156  
    3333test_draw=0;%test for mouse drawing of object, =0 by default
    3434test_object=0; %test for object editing or creation
    35 test_edit=isfield(handles,'edit') && get(handles.edit,'Value');% edit test for mouse shap: an arrow
     35test_edit_object=0;% edit test for mouse shap: an arrow
    3636test_zoom_draw=0; % test for zoom drawing
    3737test_ruler=0;%test for active ruler
     
    4040if ~isempty(huvmat)
    4141    hhuvmat=guidata(huvmat);
    42 end
    43 if ~isempty(huvmat)
    44     UvData=get(huvmat,'UserData');
    45     test_ruler=isfield(UvData,'MouseAction') && isequal(UvData.MouseAction,'ruler');
    46 end
    47 hciv=findobj(allchild(0),'tag','civ');%find the uvmat interface handle
     42    test_edit_object=get(hhuvmat.edit_object,'Value');
     43    test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');
     44end
     45hciv=findobj(allchild(0),'tag','civ');%find the civ interface handle
    4846if ~isempty(hciv) && strcmp(get(currentfig,'tag'),'view_field')
    4947    hhciv=guidata(hciv);
     
    8583            test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal');
    8684            test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject);
    87             if ~test_edit && ~test_zoom_draw && ~test_ruler
     85            if ~test_edit_object && ~test_zoom_draw && ~test_ruler
    8886                pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
    8987            end
     
    110108                                    if ~isempty(ivec)
    111109                                        % mark the vectors with a circle in the absence of other operations
    112                                         if ~test_object && ~test_edit && ~test_ruler
     110                                        if ~test_object && ~test_edit_object && ~test_ruler
    113111                                            pointershape='arrow'; %mouse indicates  the detection of a vector
    114112                                            if isempty(hhh)
     
    291289%%%%%%%%%%%%%%%%%
    292290%% create or modify an object
    293 
    294291if ~isempty(huvmat) && test_object
    295292    PlotData=get(AxeData.CurrentObject,'UserData');
     
    347344    pointershape='crosshair';%default for geometry_calib: ready to create new points
    348345    hh_geometry_calib=guidata(h_geometry_calib);
    349     if  ~isempty(xy)
     346    if  ~isempty(xy) && isfield(hh_geometry_calib,'ListCoord')
    350347        h_ListCoord=hh_geometry_calib.ListCoord; %findobj(h_geometry_calib,'Tag','ListCoord');
    351348        Coord=get(h_ListCoord,'String');
     
    368365                hh=findobj('Tag','calib_points');%look for handle of calibration points
    369366               if ~isempty(hh) && ~isempty(get(hh,'UserData')) && get(hh_geometry_calib.edit_append,'Value')
    370                     index_point=get(hh,'UserData');
     367                    index_point=get(hh,'UserData')
    371368                    XCoord(index_point)=xy(1,1);
    372369                    YCoord(index_point)=xy(1,2);
     
    387384
    388385%% draw ruler
    389 if test_ruler && isequal(AxeData.Drawing,'ruler')
    390            if isfield(UvData,'RulerHandle')
    391                pointershape='crosshair';
    392                 RulerCoord=[UvData.RulerCoord ;xy(1,1:2)];
    393                 set(UvData.RulerHandle,'XData',RulerCoord(:,1));
    394                 set(UvData.RulerHandle,'YData',RulerCoord(:,2));
    395            end
     386if test_ruler && isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'ruler')
     387    if isfield(AxeData,'RulerHandle')
     388        pointershape='crosshair'; %give  the mouse pointer a cross shape
     389        RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)]; %coordinates defining the ruler segment
     390        set(AxeData.RulerHandle,'XData',RulerCoord(:,1));% updtate the x coordinates for the ruler graphic object
     391        set(AxeData.RulerHandle,'YData',RulerCoord(:,2));% updtate the y coordinates for the ruler graphic object
     392    end
    396393end
    397394
  • trunk/src/mouse_up.m

    r154 r156  
    2323
    2424function mouse_up(hObject,eventdata,handles)
    25 MouseAction='none'; %default
     25%MouseAction='none'; %default
    2626test_zoom=0;%default
     27test_ruler=0;%default
    2728currentfig=hObject;
    2829tagfig=get(currentfig,'tag');
    2930hhcurrentfig=guidata(currentfig);
    3031test_zoom=get(hhcurrentfig.zoom,'Value');
    31 if ~exist('handles','var')
    32    handles=get(gcbo,'UserData');
    33 end
     32
     33% if ~exist('handles','var')
     34%    handles=get(gcbo,'UserData');
     35% end
    3436huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle
    3537if ~isempty(huvmat)
    3638    hhuvmat=guidata(huvmat);
    3739    UvData=get(huvmat,'UserData');
    38     if isfield(UvData,'MouseAction')
    39         MouseAction=UvData.MouseAction;% set the mouse action (edit, create objects...)
    40     end
    41 %     test_zoom=get(hhuvmat.zoom,'Value');
     40%     if isfield(UvData,'MouseAction')
     41%         MouseAction=UvData.MouseAction;% set the mouse action (edit, create objects...)
     42%     end
     43   test_ruler=~test_zoom && isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler  action, second priority
    4244end
    4345currentfig=hObject;
     
    4850
    4951%% finalize the fabrication or the translation/deformation of an object and plot the corresponding projected field
    50 if ~isempty(huvmat) & isfield(AxeData,'Drawing') & ~isequal(AxeData.Drawing,'off') & isfield(AxeData,'CurrentObject')...
    51            & ishandle(AxeData.CurrentObject)
     52if ~isempty(huvmat) && isfield(AxeData,'Drawing') && ~isequal(AxeData.Drawing,'off') && isfield(AxeData,'CurrentObject')...
     53           && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject)
    5254    xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    5355    PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object 
     
    131133%                  PlotHandles=[];%do not project data on the object during mask creation
    132134%              else
    133             PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
     135           % PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
    134136%              end
    135             UvData.Object=update_obj(UvData,IndexObj,ObjectData,PlotHandles);
    136             if strcmp(tagfig,'uvmat')% uvmat plot selected, projection plot seen on view_field
    137 %             if strcmp(projview,'view_field')
    138                 hview_field=findobj(allchild(0),'tag','view_field');
    139                 ViewFieldData=get(hview_field,'UserData');
    140                 ViewFieldData.axes3=ObjectData;
    141                 set(hview_field,'UserData',ViewFieldData)
    142             else
    143                 UvData.axes3=ObjectData;
    144             end
    145             if  isfield(UvData.Object{IndexObj},'PlotParam')
    146                 write_plot_param(PlotHandles,UvData.Object{IndexObj}.PlotParam); %update the display of plotting parameters for the current object
    147             end   
    148             set(hhuvmat.edit,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
    149             set(hhuvmat.edit,'Value',1);%
    150             set(hhuvmat.edit,'Enable','on');%
     137
     138            %% update the object representation
     139            ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj}.DisplayHandle_uvmat;
     140            ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj}.DisplayHandle_view_field;
     141            UvData.Object{IndexObj}=ObjectData;%update the current object properties
     142            hhuvmat=guidata(huvmat);
     143            IndexObj_1=get(hhuvmat.list_object_1,'Value');
     144            IndexObj_2=get(hhuvmat.list_object_2,'Value');
     145            UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2);
     146
     147            %% plot the field projected on the object and store it on the corresponding figure
     148            ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
     149            if ~isempty(ProjData)
     150                if strcmp(tagfig,'uvmat')% uvmat plot selected, projection plot seen on view_field
     151                    %             if strcmp(projview,'view_field')
     152                    hview_field=findobj(allchild(0),'tag','view_field');
     153                    if isempty(hview_field)
     154                        hview_field=view_field;
     155                    end
     156                    ViewFieldData=get(hview_field,'UserData');
     157                    ViewFieldData.axes3=ProjData;
     158                    set(hview_field,'UserData',ViewFieldData)
     159                    PlotHandles=guidata(hview_field);
     160                else
     161                    UvData.axes3=ProjData;
     162                    PlotHandles=hhuvmat;
     163                end
     164                [PlotType,PlotParam]=plot_field(ProjData,PlotHandles.axes3,PlotHandles);%update an existing field plot
     165                write_plot_param(PlotHandles,PlotParam); %update the display of plotting parameters for the current object
     166            end
     167            %             if  isfield(UvData.Object{IndexObj},'PlotParam')
     168            %                 write_plot_param(PlotHandles,UvData.Object{IndexObj}.PlotParam); %update the display of plotting parameters for the current object
     169            %             end
     170            set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
     171            set(hhuvmat.edit_object,'Value',1);%
     172            set(hhuvmat.edit_object,'Enable','on');%
    151173            set(hhuvmat.MenuEditObject,'Enable','on');%
    152174            set(hhuvmat.MenuEdit,'Enable','on');%
    153             UvData.MouseAction='edit_object'; % set the edit button to 'on'
    154175        end
    155176    else
     
    171192        %open or update a new zoom figure if a rectangle has been drawn
    172193        if ishandle(currentaxes);
    173             if isfield(AxeData,'CurrentRectZoom') & ishandle(AxeData.CurrentRectZoom)
     194            if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)
    174195                PosRect=get(AxeData.CurrentRectZoom,'Position');
    175                 if isfield(AxeData,'CurrentVec') & ishandle(AxeData.CurrentVec)
     196                if isfield(AxeData,'CurrentVec') && ~isempty(AxeData.CurrentVec) && ishandle(AxeData.CurrentVec)
    176197                    delete(AxeData.CurrentVec)
    177198                end
     
    182203                map=colormap(currentaxes);
    183204                colormap(map);%transmit the current colormap to the zoom fig
    184                 get(handles.RootFile,'String')
    185205                set(hfig2,'Position',[0.2 0.33 0.6 0.6]);
    186206                if test_replot==0
     
    288308
    289309%% editing calibration point
    290 if ~test_zoom && strcmp(MouseAction,'calib')
    291     h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
    292     hh_geometry_calib=guidata(h_geometry_calib);
    293     edit_test=get(hh_geometry_calib.edit_append,'Value');
    294     hh=findobj(currentaxes,'Tag','calib_points');%look for handle of calibration points
    295     if ~isempty(hh) && edit_test
    296         index_point=get(hh,'UserData');
    297         set(hh,'UserData',[])%remove edit mode
    298         h_ListCoord=hh_geometry_calib.ListCoord; %handles of the coordinate list
    299         Coord=get(h_ListCoord,'String');
    300         data=read_geometry_calib(Coord);
    301         %         val=get(h_ListCoord,'Value');
    302         xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    303         data.Coord(index_point,4)=xy(1,1);
    304         data.Coord(index_point,5)=xy(1,2);
    305         for ipoint=1:size(data.Coord,1)
    306             for jcoord=1:5
    307                 Coord_cell{ipoint,jcoord}=num2str(data.Coord(ipoint,jcoord),4);%display coordiantes with 4 digits
    308             end
     310if ~test_zoom && isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'calibration')
     311    h_geometry_calib=findobj(allchild(0),'tag','geometry_calib'); %find the geomterty_calib GUI
     312    if ~isempty(h_geometry_calib)
     313        hh_geometry_calib=guidata(h_geometry_calib);
     314        edit_test=get(hh_geometry_calib.edit_append,'Value');
     315        hh=findobj(currentaxes,'tag','calib_points');%look for handle of calibration points
     316        if ~isempty(hh) && edit_test
     317            index_point=get(hh,'UserData');
     318            set(hh,'UserData',[])%remove edit mode
     319            h_ListCoord=hh_geometry_calib.ListCoord; %handles of the coordinate list
     320            Coord=get(h_ListCoord,'String');
     321            data=read_geometry_calib(Coord);
     322            %         val=get(h_ListCoord,'Value');
     323            xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     324            data.Coord(index_point,4)=xy(1,1);
     325            data.Coord(index_point,5)=xy(1,2);
     326            for ipoint=1:size(data.Coord,1)
     327                for jcoord=1:5
     328                    Coord_cell{ipoint,jcoord}=num2str(data.Coord(ipoint,jcoord),4);%display coordiantes with 4 digits
     329                end
     330            end
     331            Tabchar=cell2tab(Coord_cell,' | ');
     332            Tabchar=[Tabchar ;{'......'}];
     333            set(h_ListCoord,'String',Tabchar)
     334            %         coord_str=Coord{index_point}; %current line (string)
     335            %         k=findstr('|',coord_str);%find separator indices on the string
     336            %         blanks=blank
     337            %         xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     338            %         if numel(k)>=3
     339            %             coord_str=[coord_str(1:k(3)-1) ' | ' num2str(xy(1,1),4) ' | ' num2str(xy(1,2),4)]; %update the pixel information while preserving phys coord
     340            %         else
     341            %             coord_str=[ '    |    '  '    |    '  '    |    ' num2str(xy(1,1),4) '    |    ' num2str(xy(1,2),4)];
     342            %         end
     343            %         Coord{index_point}=coord_str;
     344            %         set(h_ListCoord,'String',Coord)
     345            %         data=read_geometry_calib(Coord);%transform char cell to numbers
     346            set(hh,'XData',data.Coord(:,4))
     347            set(hh,'YData',data.Coord(:,5))
    309348        end
    310         Tabchar=cell2tab(Coord_cell,' | ');
    311         Tabchar=[Tabchar ;{'......'}];
    312         set(h_ListCoord,'String',Tabchar)
    313         %         coord_str=Coord{index_point}; %current line (string)
    314         %         k=findstr('|',coord_str);%find separator indices on the string
    315         %         blanks=blank
    316         %         xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    317         %         if numel(k)>=3
    318         %             coord_str=[coord_str(1:k(3)-1) ' | ' num2str(xy(1,1),4) ' | ' num2str(xy(1,2),4)]; %update the pixel information while preserving phys coord
    319         %         else
    320         %             coord_str=[ '    |    '  '    |    '  '    |    ' num2str(xy(1,1),4) '    |    ' num2str(xy(1,2),4)];
    321         %         end
    322         %         Coord{index_point}=coord_str;
    323         %         set(h_ListCoord,'String',Coord)
    324         %         data=read_geometry_calib(Coord);%transform char cell to numbers
    325         set(hh,'XData',data.Coord(:,4))
    326         set(hh,'YData',data.Coord(:,5))
    327349    end
    328350end
     
    330352
    331353%% finalising ruler
    332 if strcmp(MouseAction,'ruler')
    333     UvData.MouseAction='none';
    334     UvData=rmfield(UvData,'RulerHandle');
    335      xy=get(currentaxes,'CurrentPoint');
    336     RulerCoord=[UvData.RulerCoord ;xy(1,1:2)];
    337     set(huvmat,'UserData',UvData)
    338     RulerCoord=diff(RulerCoord,1);
     354if test_ruler
     355    set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat 
     356    xy=get(currentaxes,'CurrentPoint');% get the current mouse coordinates
     357    RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)];% append the recorded ruler origin to the current mouse coordinates
     358    RulerCoord=diff(RulerCoord,1);% coordiante difference between segment end and beginning
    339359    RulerCoord=RulerCoord(1)+i*RulerCoord(2);
    340360    distance=abs(RulerCoord);
    341361    azimuth=(180/pi)*angle(RulerCoord);
    342362    msgbox_uvmat('RULER','',['length: ' num2str(distance,3) ',  angle(degrees): ' num2str(azimuth,3)])
    343     hruler=findobj(currentaxes,'Tag','ruler');
    344     delete(hruler)
    345     AxeData.Drawing='off';%stop current drawing a
     363    delete(AxeData.RulerHandle)%delete the ruler graphic object
     364    AxeData=rmfield(AxeData,'RulerHandle');%remove the ruler handle in AxeData
     365    AxeData.Drawing='off';%exit the ruler drawing mode
    346366end
    347367
  • trunk/src/msgbox_uvmat.m

    r121 r156  
    5151icontype='quest';%default question icon (text input asked)
    5252if exist('title','var')
    53       set(hObject, 'Name', title);
    54       if isequal (title,'CONFIRMATION')
    55          icontype='';
    56          testCancel=0; %no cancel button
    57       elseif isequal (title,'ERROR')
    58          icontype='error';
    59          testCancel=0; %no cancel button
    60       elseif isequal (title,'WARNING')
    61          icontype='warn';
    62          testCancel=0; %no cancel button
    63       elseif isequal (title,'INPUT_Y-N')
    64          icontype='quest';
    65          testNo=1; % button No activated
    66       else
    67           testinputstring=1;
    68       end
     53    set(hObject, 'Name', title);
     54    switch title
     55        case {'CONFIRMATION'}
     56            icontype='';
     57            testCancel=0; %no cancel button
     58        case 'ERROR'
     59            icontype='error';
     60            testCancel=0; %no cancel button
     61        case 'WARNING'
     62            icontype='warn';
     63            testCancel=0; %no cancel button
     64        case 'INPUT_Y-N'
     65            icontype='quest';
     66            testNo=1; % button No activated
     67        case {'RULER'}
     68            icontype='';
     69            testCancel=0; %no cancel button
     70            testinputstring=1;
     71        otherwise
     72            testinputstring=1;
     73    end
    6974end
    7075if exist('display','var')
  • trunk/src/plot_field.m

    r153 r156  
    144144if testnewfig% create a new figure and axes if the plotting axes does not exist
    145145    hfig=figure;
    146 %     if isfield(Data,'IndexObj') && isfield(Data,'Style') && isfield(Data,'ProjMode')
    147 %         figname=[num2str(Data.IndexObj) '-' Data.Style];
    148 %         set(hfig,'Name',figname)
    149 %     end
    150 %     testhandle=0;
    151146    if isfield(PlotParam,'text_display_1') && ishandle(PlotParam.text_display_1)
    152147        set(hfig,'UserData',PlotParam)
    153 %         testhandle=1;
    154148    end
    155149    set(hfig,'Units','normalized')
    156150    set(hfig,'WindowButtonDownFcn','mouse_down')
    157     %set(hfig,'WindowButtonMotionFcn',{'mouse_motion',PlotParam})%set mouse action function
    158151    set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action function
    159152    set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse action function
     
    204197        if testzoomaxes && isempty(errormsg)
    205198            [AxeData,zoomaxes,PlotParamOut,xx,errormsg]=plot_plane(Data,CellVarIndex(ind_select),VarType(ind_select),zoomaxes,PlotParam,1,PosColorbar);
    206             %AxeData.ZoomAxes=zoomaxes;
    207199            Data.ZoomAxes=zoomaxes;
    208200        end
  • trunk/src/plot_object.m

    r38 r156  
    3737
    3838function [hh]=plot_object(ObjectDataIn,ProjObject,hplot,col)
     39%% default output
    3940hh=[];%default output
    4041if isequal(ProjObject,ObjectDataIn)% object representation does not appear in its own projection plot
     
    4849    return % no object representation yet available
    4950end
    50 if ~isfield(ObjectData,'Style')|isempty(ObjectData.Style)|~ischar(ObjectData.Style)
     51if ~isfield(ObjectData,'Style')||isempty(ObjectData.Style)||~ischar(ObjectData.Style)
    5152    msgbox_uvmat('ERROR','undefined ObjectData.Style in plot_object.m')
    5253    return
    5354end
    54 if ~isfield(ObjectData,'Style')|isempty(ObjectData.Style)|~ischar(ObjectData.Style)
     55if ~isfield(ObjectData,'Style')||isempty(ObjectData.Style)||~ischar(ObjectData.Style)
    5556    msgbox_uvmat('ERROR','undefined ObjectData.Style in plot_object.m')
    5657    return
     
    6364ZMax=0;
    6465
    65 %determine the plotting axes (with handle 'haxes')
     66%% determine the plotting axes (with handle 'haxes')
    6667test_newobj=1;
    6768if ishandle(hplot)
    68     if isequal(get(hplot,'Tag'),'proj_object') 
     69    if isequal(get(hplot,'Tag'),'proj_object')% hplot is the handle of an object representation 
    6970        test_newobj=0;
    7071        haxes=get(hplot,'parent');
    71     elseif isequal(get(hplot,'Type'),'axes')
    72         axes(hplot)
     72    elseif isequal(get(hplot,'Type'),'axes')% hplot is the handle of an axis
     73        currentfig=get(hplot,'parent');
     74        set(0,'CurrentFigure',currentfig)
    7375        haxes=hplot;
    74     elseif isequal(get(hplot,'Type'),'figure')
    75         figure(hplot);%set the input figure as the current one
     76        set(currentfig,'CurrentAxes',haxes);
     77    elseif isequal(get(hplot,'Type'),'figure')% hplot is the handle of a figure
     78        set(0,'CurrentFigure',hplot);%set the input figure as the current one
    7679        haxes=findobj(hplot,'Type','axes');%look for axes in the figure
    7780        haxes=haxes(1);
    78         axes(haxes); %set the first found axis as the current one
     81        set(hplot,'CurrentAxes',haxes);%set the first found axis as the current one
    7982    else
    8083        figure; %create new figure
     
    8891end
    8992
    90 %default input parameters
     93%% default input parameters
    9194if ~isfield(ObjectData,'ProjMode')|isempty(ObjectData.ProjMode)
    9295     ObjectData.ProjMode='projection';%default
     
    148151sizcoord=size(ObjectData.Coord);
    149152
    150 %determine the coordinates xline, yline,xsup,xinf, yinf,ysup determining the new object plot
     153%% determine the coordinates xline, yline,xsup,xinf, yinf,ysup determining the new object plot
    151154test_line= isequal(ObjectData.Style,'points')|isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')|...
    152155    isequal(ObjectData.Style,'polygon')| isequal(ObjectData.Style,'plane')| isequal(ObjectData.Style,'volume');
     
    206209end
    207210
    208 %shading image
     211%% shading image
    209212if test_patch
    210213    npMx=512;
     
    267270
    268271PlotData=[];%default
    269 %MODIFY AN EXISTING OBJECT PLOT
     272%% MODIFY AN EXISTING OBJECT PLOT
    270273if test_newobj==0;
    271274    hh=hplot;
     
    326329end
    327330
    328 %create the object
     331%% create the object
    329332if test_newobj
    330333    axes(haxes)
  • trunk/src/proj_field.m

    r150 r156  
    11%'proj_field': projects the field on a projection object
    22%--------------------------------------------------------------------------
    3 %  function [ProjData,errormsg]=proj_field(FieldData,ObjectData,IndexObj)
     3%  function [ProjData,errormsg]=proj_field(FieldData,ObjectData)
    44%
    55% OUTPUT:
     
    8080%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    8181
    82 function [ProjData,errormsg]=proj_field(FieldData,ObjectData,IndexObj)
     82function [ProjData,errormsg]=proj_field(FieldData,ObjectData)
    8383errormsg=[];%default
    8484if isfield(ObjectData,'ProjMode') && (isequal(ObjectData.ProjMode,'none')||isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'))
     
    138138        [ProjData,errormsg] = proj_volume(FieldData,ObjectData);
    139139end
    140 if exist('IndexObj','var')
    141     ProjData.IndexObj=IndexObj;%transfer object index
    142 end
     140% if exist('IndexObj','var')
     141%     ProjData.IndexObj=IndexObj;%transfer object index
     142% end
    143143
    144144%-----------------------------------------------------------------
  • trunk/src/read_civxdata.m

    r140 r156  
    8989    Field.ListVarName(end-2:end)=[];
    9090    Field.ListVarName{end}='DjUi';
    91     Field.VarDimIndex(end-2:end)=[];
     91    Field.VarDimName(end-2:end)=[];
    9292    Field.VarAttribute(end-2:end)=[];
    9393end
  • trunk/src/series.m

    r147 r156  
    6161guidata(hObject, handles);
    6262%default initial parameters
     63drawnow
    6364
    6465%load the list of previously browsed files in menus Open and Open_1
     
    656657if isequal(ext_imadoc,'.xml')
    657658        [XmlData,warntext]=imadoc2struct([FileBase '.xml']);
    658         if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName')
     659        if isfield(XmlData,'Heading') && isfield(XmlData.Heading,'ImageName') && ischar(XmlData.Heading.ImageName)
    659660            [PP,FF,ext_ima_read]=fileparts(XmlData.Heading.ImageName);
    660661        end
  • trunk/src/set_object.m

    r153 r156  
    721721function PLOT_Callback(hObject, eventdata, handles)
    722722
     723%% reading the object parameters on the GUI uvmat
    723724huvmat=findobj('tag','uvmat');%find the current uvmat interface handle
    724725UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat
     
    728729IndexObj_1=get(hhuvmat.list_object_1,'Value');
    729730IndexObj_2=get(hhuvmat.list_object_2,'Value');
    730 ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object
    731731testnew=0;
    732732PlotHandles=get_plot_handles(hhuvmat);
    733 projview='';
     733projview='view_field';%default
    734734if strcmp(ListObject{IndexObj_1},ObjectName)% we are editing the object whose projection is viewed in the uvmat frame
    735    ObjectData.HandlesDisplay=hhuvmat.axes3;
     735%    ObjectData.HandlesDisplay=hhuvmat.axes3;
     736%     Object_set{iobj}.DisplayHandle_view_field
    736737    IndexObj=IndexObj_1;
    737738    projview='uvmat';
     739     plotaxes=hhuvmat.axes3;%handle of axes3 in view_field
    738740elseif IndexObj_2<=numel(ListObject)&& strcmp(ListObject{IndexObj_2},ObjectName)% we are editing the object whose projection is viewed in view_field
     741   
     742    IndexObj=IndexObj_2;
     743%     projview='view_field';
     744else %new object
     745    testnew=1;
     746    IndexObj=numel(ListObject)+1;
    739747    hview_field=findobj(allchild(0),'tag','view_field');
    740748    if ~isempty(hview_field)
    741749        PlotHandles=guidata(hview_field);
    742         ObjectData.HandlesDisplay=PlotHandles.axes3;%handle of axes3 in view_field
    743     end
    744     IndexObj=IndexObj_2;
    745     projview='view_field';
    746 else %new object
    747     testnew=1; 
    748     IndexObj=numel(ListObject)+1;
    749 end
     750        plotaxes=PlotHandles.axes3;%handle of axes3 in view_field
     751%         ObjectData.HandlesDisplay=PlotHandles.axes3;%handle of axes3 in view_field
     752    end
     753end
     754if strcmp(projview,'view_field')
     755    hview_field=findobj(allchild(0),'tag','view_field')
     756    if isempty(hview_field)
     757        hview_field=view_field
     758    end
     759    PlotHandles=guidata(hview_field);
     760    plotaxes=PlotHandles.axes3;%handle of axes3 in view_field
     761end   
     762ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object
     763
     764%% naming the object
    750765if length(ObjectName)<1% name of object not defined in set_object
    751766    ObjectName=[num2str(IndexObj) '-' ObjectData.Style];%default name
    752 elseif ~get(hhuvmat.edit,'Value')%not in edit mode (new object created)
     767elseif ~get(hhuvmat.edit_object,'Value')%not in edit mode (new object created)
    753768    detectname=1;
    754769    ObjectNameNew=ObjectName;
    755770    vers=0;
    756     while detectname==1 %create a new subdir if the netcdf files already exist
    757         detectname=find(strcmp(ObjectNameNew,ListObject),1)%test the existence of the proposed name in the list
    758         if detectname% if athe object name already exists
    759             indstr=regexp(ObjectNameNew,'\D')
     771    while detectname==1
     772        detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
     773        if detectname% if the object name already exists
     774            indstr=regexp(ObjectNameNew,'\D');
    760775            if indstr(end)<length(ObjectNameNew) %object name ends by a number
    761776                vers=str2double(ObjectNameNew(indstr(end)+1:end))+1;
    762777                ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)];
    763778            else
    764                 vers=vers+1
    765                 ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)]     
     779                vers=vers+1;
     780                ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];     
    766781            end
    767782        end
     
    772787set(hhuvmat.list_object_1,'String',ListObject)
    773788set(hhuvmat.list_object_2,'String',[ListObject;{'...'}])
     789
     790%% update the object plot and projection field
    774791if testnew
    775792    set(hhuvmat.list_object_2,'Value',IndexObj)
    776 end
    777 
    778 % update the object plot and projection field
    779 UvData.Object{IndexObj}=update_obj(UvData,IndexObj,ObjectData,PlotHandles);
     793    ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;
     794    ObjectData.DisplayHandle_view_field=[];
     795else % save the previous object graph handles
     796    ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj}.DisplayHandle_uvmat;
     797    ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj}.DisplayHandle_view_field;
     798end
     799UvData.Object{IndexObj}=ObjectData;%update the current object properties
     800IndexObj
     801ObjectData
     802UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2);
     803
     804%% plot the field projected on the object and store it the corresponding figue
     805get(plotaxes,'tag')
     806ProjData= proj_field(UvData.Field,ObjectData)%project the current interface field on ObjectData
     807[PlotType,Object_out{IndexObj}.PlotParam,plotaxes]=plot_field(ProjData,plotaxes,PlotHandles);%update an existing field plot
    780808if strcmp(projview,'view_field')
    781809    ViewFieldData=get(hview_field,'UserData');
     
    786814end
    787815
    788 %set uvmat to object edit mode to allow further object update
     816%% update the GUI uvmat
    789817hhuvmat=guidata(huvmat);%handles of elements in the uvmat GUI
    790818set(hhuvmat.MenuEditObject,'enable','on')
    791 set(hhuvmat.edit,'Value',1)
    792 set(hhuvmat.edit,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
    793 UvData.MouseAction='edit_object'; % set the edit button to 'on'
     819set(hhuvmat.edit_object,'Value',1) % set uvmat to object edit mode to allow further object update
     820set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
     821%UvData.MouseAction='edit_object'; % set the edit button to 'on'
    794822set(huvmat,'UserData',UvData)
    795823%------------------------------------------------------------------------
  • trunk/src/update_imadoc.m

    r114 r156  
    88%-------------------------------------------------------------
    99function errormsg=update_imadoc(GeometryCalib,outputfile)
     10tic
    1011errormsg='';
    1112testappend=0;
     
    2122    [success,message]=copyfile(outputfile,backupfile);%make backup
    2223    if success==0
    23         errormsg=message
     24        errormsg=message;
    2425    end
    2526    uid=find(t,'ImaDoc');
     
    5657        [t,uid_camera]=add(t,1,'element','Camera');
    5758        Camera.TimeUnit='s';
    58 %         Camera.BurstTiming.FrameFrequency=info.FramesPerSecond;
    5959        Camera.BurstTiming.Time=0;
    6060        Camera.BurstTiming.Dti=1/info.FramesPerSecond;
    6161        Camera.BurstTiming.NbDti=info.NumFrames-1;
    62         t=struct2xml(Camera,t,uid_camera)
     62        t=struct2xml(Camera,t,uid_camera);
    6363    end
    6464   [t,uid_calib]=add(t,1,'element','GeometryCalib');
     
    6666t=struct2xml(GeometryCalib,t,uid_calib);
    6767save(t,outputfile);
     68toc
  • trunk/src/update_obj.m

    r102 r156  
    11%'update_obj': update the object graph representation and its projection field, record it in the uvmat interface
    22%-------------------------------------------------------------------
    3 %Object=update_obj(UvData,IndexObj,ObjectData,PlotHandles);
    4 %
     3%Object_out=update_obj(UvData,IndexObj,ObjectData,PlotHandles);
     4
    55%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     .
    97%
    108%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:
    1210%    .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
    1716%       .Style: style of the object: 'line', 'rectangle'...
    1817%PlotHandles: structure containing the handles of the plotting parameter buttons on the uvmat or view_field interface
    1918%-------------------------------------
    2019
    21 function Object_out=update_obj(UvData,IndexObj,ObjectData,PlotHandles)
     20function Object_out=update_obj(UvData,IndexObj_1,IndexObj_2)
    2221
    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
     29Object_out=UvData.Object;
    3030
    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
    6448
    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
    7473    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
    77117
    78118
    79119
     120
  • trunk/src/view_field.m

    r150 r156  
    7575    set(hhuvmat.list_object_2,'Visible','on')
    7676    % handles_mouse.create=hhuvmat.create;
    77     handles_mouse.edit=hhuvmat.edit;
     77    handles_mouse.edit=hhuvmat.edit_object;
    7878    pos_uvmat=get(huvmat,'Position');
    7979    pos_view_field(1)=pos_uvmat(1)+pos_uvmat(3)/2;
     
    8989set(hObject,'WindowButtonUpFcn',{'mouse_up',handles_mouse})
    9090set(hObject,'CloseRequestFcn',{@closefcn})%
     91if ~exist('Field','var')
     92    return
     93end
    9194
    9295[PlotType,PlotParamOut]= plot_field(Field,handles.axes3);%,PlotParam,KeepLim,PosColorbar)
    9396ViewFieldData.axes3=Field;
    9497set(handles.view_field,'UserData',ViewFieldData);%store the current field
    95 get(handles.view_field)
    9698if isfield(PlotParamOut,'Vectors')
    9799    set(handles.VECT_title,'Visible','on')
Note: See TracChangeset for help on using the changeset viewer.