Changeset 622


Ignore:
Timestamp:
Apr 29, 2013, 11:35:27 AM (11 years ago)
Author:
sommeria
Message:

mouse system for uvmat imrpoved

Location:
trunk/src
Files:
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/keyboard_callback.m

    r342 r622  
    33function keyboard_callback(hObject,eventdata,handleshaxes)
    44cur_axes=get(hObject,'CurrentAxes');%current plotting axes of the figure with handle hObject
     5if ~isempty(eventdata) && isnumeric(eventdata)
     6    xx=eventdata; % keyboard_callback called by mouse_down
     7else
    58xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
     9end
    610switch xx
    711    case {29,28,30,31}    %arrows for displacement
  • trunk/src/mouse_down.m

    r594 r622  
    2323
    2424function xy=mouse_down(hObject,eventdata)
    25 AxeData=[];%default
    26 FigData=get(hObject,'UserData');
     25
     26%% look for parameters set by the current figure (handle=input parameter hObject)
     27AxeData=[];%default data stored on the current axes
     28FigData=get(hObject,'UserData'); %default data stored on the current object
    2729if ishandle(FigData)% case of a zoom plot, the handle of the parent rectangle is stored in UserData, its parent is the plotting axes of the rectangle
    28     hcurrentfig=get(get(FigData,'parent'),'parent');
     30    hcurrentfig=get(get(FigData,'parent'),'parent');%handle of the current GUI: zoom plot
    2931else
    30     hcurrentfig=hObject;%usual plot
    31 end
     32    hcurrentfig=hObject; % handle of the current GUI: usual plot
     33end
     34hhcurrentfig=guidata(hcurrentfig);% tags of the children of the current GUI
     35CheckZoom=0;
     36if isfield(hhcurrentfig,'CheckZoom') && get(hhcurrentfig.CheckZoom,'Value');%test for zoom action, first priority
     37    CheckZoom=1;
     38end
     39test_piv=isfield(FigData,'CivHandle');
    3240set(hcurrentfig,'Units','pixels')
    33 GUI_pos=get(hcurrentfig,'Position');%position of the GUI series (in pixels)
    34 set(hcurrentfig,'Units','normalized')
    35 hhcurrentfig=guidata(hcurrentfig);
    36 if isfield(hhcurrentfig,'CheckZoom')
    37     test_zoom=get(hhcurrentfig.CheckZoom,'Value');%test for zoom action, first priority
    38 else
    39     test_zoom=0;
    40 end
    41 test_piv=isfield(FigData,'CivHandle');
     41GUI_pos=get(hcurrentfig,'Position');%position of the GUI series on the screen (in pixels), used to position message boxes
     42set(hcurrentfig,'Units','normalized')% back to current unit for fig position
     43
     44%% determine the currently selected items
     45hcurrentobject=gco;% current object handle (selected by the mouse)
     46fig_tag=get(hcurrentfig,'Tag');
     47obj_tag=get(gco,'Tag');%tag of the currently selected object
     48xy=[];%default
     49xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
     50haxes=[];
    4251
    4352%% look for parameters set by the GUI uvmat
     
    4554test_edit=0;
    4655test_create=0;
    47 huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls theoption of  mouse action
     56huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls the option of  mouse action
    4857if ~isempty(huvmat)
    4958    hhuvmat=guidata(huvmat);%handles of elements in uvmat
    5059    UvData=get(huvmat,'UserData');
    5160    test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler  action, second priority;
    52     test_edit=get(hhuvmat.edit_object,'Value');%test for object editing, third priority
    53     test_edit_vect=get(hhuvmat.edit_vect,'Value');%test for vector editing,  priority 4
    54     %     test_create=isequal(get(hhuvmat.MenuObject,'checked'),'on');% test for object creation,  priority 5
    55     %     if test_create
    56     test_create=0;
     61    test_edit=get(hhuvmat.edit_object,'Value')&& (isequal(obj_tag,'proj_object')||isequal(obj_tag,'DeformPoint'));%test for object editing, third priority
    5762    hset_object=findobj(allchild(0),'tag','set_object');
    58 
    5963    if ~isempty(hset_object)
    6064        hPLOT=findobj(hset_object,'tag','PLOT');
    6165        test_create=strcmp(get(hPLOT,'enable'),'on') &&~test_edit;% create new object if set_object is in mode enable and uvmat not in mode 'edit_object'
    6266    end
    63    
     67    test_edit_vect=get(hhuvmat.edit_vect,'Value') && ~test_create && ~(isequal(obj_tag,'proj_object')||isequal(obj_tag,'DeformPoint')) ;%test for vector editing,  priority 4
    6468    test_cal=isequal(get(hhuvmat.MenuCalib,'checked'),'on');% test for calibration
    6569    if test_cal% test for calibration popints,  priority 6
     
    7579end
    7680
    77 %% determine the currently selected items
    78 hcurrentobject=gco;% current object handle (selected by the mouse)
    79 %hcurrentfig=hObject;% current figure handle
    80 fig_tag=get(hcurrentfig,'Tag');
    81 tag_obj=get(gco,'Tag');%tag of the currently selected object
    82 xy=[];%default
    83 xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
     81%% loop on all the objects in the current figure (selected by the last mouse click)
    8482hchildren=get(hObject,'Children');%handles of all objects in the current figure
    85 haxes=[];
    86 
    87 %% loop on all the objects in the current figure (selected by the last mouse click)
    88 output_str='';
    89 state_visible=get(hchildren,'Visible');
    90 check_visible=strcmp('on',state_visible);%=1 if visible='on', =0 otherwise
    91 hchildren=hchildren(find(check_visible)); %kkep only the visible children
    92 for ichild=1:length(hchildren)
    93     hchild=hchildren(ichild); %handle of the current obj
    94     obj_pos=get(hchild,'Position');%position of the object
    95     if xy_fig(1) >=obj_pos(1) & xy_fig(2) >= obj_pos(2)& xy_fig(1) <=obj_pos(1)+obj_pos(3) & xy_fig(2) <= obj_pos(2)+obj_pos(4);
    96         htype=get(hchild,'Type');%type of object child of the current figure
    97         switch htype
    98             %if the mouse is over an axis, look at the data
    99             case 'axes'
    100                 y_lim=get(hchild,'YLim');
    101                 x_lim=get(hchild,'XLim');
    102                 haxes=hchild;
    103                 xy=get(hchild,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    104 %                 if xy(1,1)>x_lim(1) && xy(1,1)<x_lim(2) && xy(1,2)>y_lim(1) && xy(1,2)<y_lim(2)
    105                     AxeData=get(hchild,'UserData');% data attached to the axis
    106                     AxeData.CurrentOrigin=[xy(1,1) xy(1,2)];% The current point set by the mouse becomes the current origin
    107                     if test_edit_vect && ~isequal(tag_obj,'proj_object') & ~test_create
    108                         ivec=[];
    109                         FigData=get(hcurrentfig,'UserData');
    110                         tagaxes=get(hchild,'tag');
    111                         if isfield(FigData,tagaxes)
    112                             Field=FigData.(tagaxes);
    113                             [CellVarIndex,NbDim,VarType]=find_field_cells(Field);%analyse the physical fields contained in Field
    114                             for icell=1:numel(CellVarIndex)%look for all physical fields
    115                                 if NbDim(icell)==2 % select 2D field
    116                                     if  isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& ~isempty(VarType{icell}.coord_x) && ~isempty(VarType{icell}.coord_y)%case of unstructured data
    117                                         eval(['X=Field.' Field.ListVarName{VarType{icell}.coord_x} ';'])
    118                                         eval(['Y=Field.' Field.ListVarName{VarType{icell}.coord_y} ';'])
    119                                         flag_vec=(X<(xy(1,1)+Field.CoordMesh/4) & X>(xy(1,1)-Field.CoordMesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
    120                                             (Y<(xy(1,2)+Field.CoordMesh/4) & Y>(xy(1,2)-Field.CoordMesh/4));%f
    121                                         ivec=find(flag_vec,1);% search the (first) selected vector index ivec
    122                                     end
    123                                 end
     83check_visible=strcmp(get(hchildren,'Visible'),'on');% if visible='on', =0 otherwise
     84hchildren=hchildren(check_visible); %kkep only the visible children
     85PosChildren=get(hchildren,'Position');% set of object positions
     86if iscell(PosChildren)% only one child
     87    PosLength=cellfun('length',PosChildren);% set of vector lengths for object positions
     88    hchildren=hchildren(PosLength==4);% keep only objects with position defined by a 4 element vector
     89    PosChildren=cell2mat(PosChildren(PosLength==4));% convert cells to matrix of positions
     90end
     91if size(PosChildren,2)~=4
     92    return
     93end
     94xy_fig_mat=ones(size(PosChildren,1),1)*xy_fig;% mouse position set to a matrix
     95check_pos=xy_fig_mat >= PosChildren(:,1:2) & xy_fig_mat <= PosChildren(:,1:2)+PosChildren(:,3:4);% compare object to mouse position
     96ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse
     97hchild=hchildren(ind_object);% corresponding object handle
     98if isempty(hchild)
     99%     if test_edit||test_create
     100%         hPlotAxes=findobj(hcurrentfig,'Tag','PlotAxes');
     101%         if ~isempty( hPlotAxes)
     102%             PosPlotAxes=get(hPlotAxes,'Position');
     103%             PosDiff(1)=xy_fig(1)-PosPlotAxes(1)-PosPlotAxes(3);% distance to the right axes edge
     104%             PosDiff(2)=PosPlotAxes(1)-xy_fig(1);% distance to the left axes edge
     105%             PosDiff(3)=xy_fig(2)-PosPlotAxes(1)-PosPlotAxes(3);% distance to the top axes edge
     106%             PosDiff(4)=PosPlotAxes(2)-xy_fig(2);% distance to the low axes edge
     107%             [tild,ind_sel]=max(PosDiff);
     108%             list_arrow=[29 28 30 31];
     109%             arrow_option=list_arrow(ind_sel);
     110%             keyboard_callback(hcurrentfig,arrow_option)
     111%             return
     112%         end
     113%     end
     114else
     115    htype=get(hchild,'Type');%type of object child of the current figure
     116    switch htype
     117        %if the mouse is over an axis, look at the data
     118        case 'axes'
     119            haxes=hchild;
     120            xy=get(hchild,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     121            AxeData=get(hchild,'UserData');% data attached to the axis
     122%             if isfield(AxeData,'ObjectCoord') && size(AxeData.ProjObjectCoord,2)==3
     123%                 xy(1,3)=AxeData.ProjObjectCoord(1,3); % z coordinate of the mouse: to generalise ...
     124%             else
     125%                 xy(1,3)=0; % z coordinate set to 0 by default
     126%             end
     127            AxeData.CurrentOrigin=xy(1,1:2);% The current point set by the mouse becomes the current origin
     128           
     129            if test_edit_vect
     130                ivec=[];
     131                FigData=get(hcurrentfig,'UserData');
     132                tagaxes=get(hchild,'tag');
     133                if isfield(FigData,tagaxes)
     134                    Field=FigData.(tagaxes);
     135                    [CellVarIndex,NbDim,VarType]=find_field_cells(Field);%analyse the physical fields contained in Field
     136                    for icell=1:numel(CellVarIndex)%look for all physical fields
     137                        if NbDim(icell)==2 % select 2D field
     138                            if  isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& ~isempty(VarType{icell}.coord_x) && ~isempty(VarType{icell}.coord_y)%case of unstructured data
     139                                X=Field.(Field.ListVarName{VarType{icell}.coord_x});
     140                                Y=Field.(Field.ListVarName{VarType{icell}.coord_y});
     141                                flag_vec=(X<(xy(1,1)+Field.CoordMesh/4) & X>(xy(1,1)-Field.CoordMesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse
     142                                    (Y<(xy(1,2)+Field.CoordMesh/4) & Y>(xy(1,2)-Field.CoordMesh/4));%f
     143                                ivec=find(flag_vec,1);% search the (first) selected vector index ivec
    124144                            end
    125145                        end
    126146                    end
    127 %                 else
    128 %                     hchild=[];%mouse out of axes
    129 %                 end
    130                 break
     147                end
     148            end
     149            %break% leave the loop once an axes has been selected
     150           
     151            %if the mouse is over a uicontrol, with right mouse button activated, duplicate the display in an editable  zoom window
     152        case 'uicontrol'
     153            if isequal(get(hObject,'SelectionType'),'alt') %% && ~isequal(get(hchild,'tag'),'frame_object')
     154                obj_pos=PosChildren(ind_object,:);
     155                msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
     156                display_str=get(hchild,'TooltipString');
     157                msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],display_str,get(hchild,'String'),msg_pos);
     158                return %leave the function once a uicontrol has been selected
     159            end
     160           
     161            %if the mouse is over a uipanel, look at the children of the uipanel
     162        case 'uipanel'
     163            if isequal(get(hObject,'SelectionType'),'alt')
     164                panel_pos=PosChildren(ind_object,:);%position of the panel
     165                hhchildren=get(hchild,'Children');%handles of all objects in the selected panel
     166                check_visible=strcmp(get(hhchildren,'Visible'),'on');%=1 if visible='on', =0 otherwise
     167                hhchildren=hhchildren(check_visible); %keep only the visible children
    131168               
    132             %if the mouse is over a uicontrol, duplicate the display  in an editable  zoom window
    133             case 'uicontrol'
    134                 if isequal(get(hObject,'SelectionType'),'alt')  && isequal(get(hchild,'Visible'),'on') && ~isequal(get(hchild,'tag'),'frame_object')&&...
    135                         ~isequal(get(hchild,'tag'),'ListObject')
    136                     if ~strcmp(get(hchild,'Style'),'frame')%do not visualisaze frames
    137                         msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
    138                         display_str=get(hchild,'TooltipString');
    139                         output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],display_str,get(hchild,'String'),msg_pos);
    140                         break
     169                PosChildren=get(hhchildren,'Position');
     170                PosLength=cellfun('length',PosChildren);
     171                hhchildren=hhchildren(PosLength==4);% keep only object with position defined by a 4 element vector
     172                PosChildren=cell2mat(PosChildren(PosLength==4));% transform cell array to a matrix of positions
     173                xy_panel=(xy_fig-panel_pos(1:2))./panel_pos(3:4);% mouse position relative to the panel
     174                xy_panel_mat=ones(size(PosChildren,1),1)*xy_panel;% mouse position on the figure transformed to a matrix
     175                check_pos=xy_panel_mat >= PosChildren(:,1:2) & xy_panel_mat <= PosChildren(:,1:2)+PosChildren(:,3:4);% compare object to mouse position
     176                ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse
     177                if ~isempty(ind_object)
     178                    hhchild=hhchildren(ind_object);% corresponding object handle
     179                    if strcmp(get(hhchild,'Type'),'uicontrol')
     180                        msg_pos=GUI_pos(1:2)+panel_pos(1:2).*GUI_pos(3:4)+PosChildren(ind_object,1:2).*panel_pos(3:4).*GUI_pos(3:4);
     181                        display_str=get(hhchild,'TooltipString');
     182                        msgbox_uvmat(['uicontrol: ' get(hhchild,'Tag')],display_str,get(hhchild,'String'),msg_pos);
    141183                    end
    142184                end
    143             case 'uipanel'
    144                 panel_pos=obj_pos;%position of the panel
    145                 hhchildren=get(hchild,'Children');%handles of all objects in the current GUI
    146                 %% loop on all the objects in the current figure (selected by the last mouse click)
    147                 for iichild=1:length(hhchildren)
    148                     hchild=hhchildren(iichild);
    149                     rel_pos=get(hchild,'Position');%position of the object relative to the uipanel
    150                     obj_pos(1:2)=panel_pos(1:2)+rel_pos(1:2).*panel_pos(3:4);
    151                     obj_pos(3:4)=panel_pos(3:4).*rel_pos(3:4);
    152                     if numel(obj_pos)>=4 && xy_fig(1) >=obj_pos(1) && xy_fig(2) >= obj_pos(2)&& xy_fig(1) <=obj_pos(1)+obj_pos(3) && xy_fig(2) <= obj_pos(2)+obj_pos(4);
    153                         htype=get(hchild,'Type');%type of object child of the current figure
    154                         %if the mouse is over a uicontrol, look at the data
    155                         if strcmp(htype,'uicontrol') && strcmp(get(hchild,'Visible'),'on')
    156                             msg_pos(1:2)=GUI_pos(1:2)+obj_pos(1:2).*GUI_pos(3:4);
    157                             display_str=get(hchild,'TooltipString');
    158                             output_str=msgbox_uvmat(['uicontrol: ' get(hchild,'Tag')],display_str,get(hchild,'String'),msg_pos);
    159                             break
    160                         end
    161                     end
    162                 end
    163         end
    164         if ~isempty(output_str)
    165             break   %leave the current loop if a uicontrol has been selected
    166         end
    167     end
    168 end
    169 if ~isempty(output_str)               
    170     set(hObject,'Units','pixels')
    171     if strcmp(get(hchild,'enable'),'on')
    172     set(hchild,'String',output_str)% fill the parent uicontrol with the sttring edited in the msgbox
    173     end
    174 end
    175    
    176 %% desable  object creation and vector editing if NbDim different from 2
    177 if ~(isfield(AxeData,'NbDim') && isequal(AxeData.NbDim,2))
    178     test_create=0;
    179     test_edit_vect=0;   
     185            end
     186            %   return %leave the function once a uicontrol has been selected
     187    end
    180188end
    181189
    182190%% delete the current zoom rectangle
    183 if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)
    184     delete(AxeData.CurrentRectZoom)
    185     AxeData.CurrentRectZoom=[];
    186 end   
    187 
    188 %% zoom has first priority
    189 if test_zoom %&& ~test_create && ~test_edit && ~test_edit_vect && exist('xy','var')
    190      AxeData.Drawing='zoom'; %initiate drawing mode
    191      AxeData.CurrentObject=[];%unselect objects
    192      set(hchild,'UserData',AxeData);
    193      return
    194 end
     191% if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)
     192%     delete(AxeData.CurrentRectZoom)
     193%     AxeData.CurrentRectZoom=[];
     194% end
     195
     196%% zoom has first priority, stop here
     197if CheckZoom
     198    return
     199end
     200
     201%% creation of a zoom subfig
     202if get(hhcurrentfig.CheckZoomFig,'Value')
     203    AxeData.Drawing='zoom'; %initiate drawing mode
     204    AxeData.CurrentObject=[];%unselect objects
     205    set(hchild,'UserData',AxeData);
     206    return
     207end
     208
    195209if isempty(huvmat)%further options require the uvmat GUI
    196210    return
     
    199213%% ruler has second priority
    200214if test_ruler
    201     AxeData.RulerCoord(1,1)=xy(1,1);
    202     AxeData.RulerCoord(1,2)=xy(1,2);
     215    AxeData.RulerCoord(1,1:2)=xy(1,1:2);
    203216    AxeData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler');
    204217    AxeData.Drawing='ruler';
     
    218231end
    219232
     233%% desable  object creation and vector editing if NbDim different from 2
     234if ~(isfield(AxeData,'NbDim') && isequal(AxeData.NbDim,2))
     235    test_create=0;
     236    test_edit_vect=0;
     237end
     238
    220239%% selection of an existing projection object (third priority)
    221 if  test_edit && (isequal(tag_obj,'proj_object')||isequal(tag_obj,'DeformPoint'))
     240if  test_edit
    222241    if ~(isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'create'))
    223242        userdata=get(hcurrentobject,'UserData');
     
    228247        end
    229248        ObjectData=get(AxeData.CurrentObject,'UserData');
    230         if test_edit && isfield(ObjectData,'IndexObj')
     249        if isfield(ObjectData,'IndexObj')
    231250            hother=findobj('Tag','proj_object','Type','line');%find all the proj objects
    232251            set(hother,'Color','b');%reset all the proj objects in 'blue' by default
     
    263282                end
    264283            end
    265             if isequal(tag_obj,'DeformPoint')
     284            if isequal(obj_tag,'DeformPoint')
    266285                 set(hcurrentobject,'Color','m'); %set the selected DeformPoint to magenta color
    267286            end
     
    280299                set(hhuvmat.ListObject_1,'Value',IndexObj);
    281300                list_str=get(hhuvmat.ListObject_1,'String');
    282                 UvData.Object{IndexObj}.Name=list_str{IndexObj};
     301                UvData.ProjObject{IndexObj}.Name=list_str{IndexObj};
    283302            end
    284303%             h_set_object=findobj(allchild(0),'Tag','set_object');
     
    286305%                 delete(h_set_object)
    287306%             end
    288             set_object(UvData.Object{IndexObj})
     307            set_object(UvData.ProjObject{IndexObj})
    289308            axes(hchild);%set back the current axes haxes
    290309            testdeform=0;
    291310            set(gcbo,'Pointer','circle');
    292311            AxeData.Drawing='deform';
    293             if isequal(tag_obj,'DeformPoint')       
     312            if isequal(obj_tag,'DeformPoint')       
    294313               if isfield(ObjectData,'DeformPoint')
    295314                   set(hcurrentobject,'Selected','on')
     
    312331
    313332%%  create  projection  object
    314 if  test_create && ~isempty(xy) %&& ~(isfield(AxeData,'Drawing')&& isequal(AxeData.Drawing,'create'))
    315     hset_object=findobj(allchild(0),'tag','set_object');
     333if  test_create && ~isempty(xy)
    316334    % activate this option if the GUI set_object is opened
    317     if ~isempty(hset_object)
     335    if ~isempty(hset_object) && ~strcmp(get(hcurrentfig,'SelectionType'),'alt')
    318336        sethandles=guidata(hset_object);% handles of the elements in the GUI set_object
    319337        ObjectData=read_GUI(hset_object); %read object parameters in the GUI set_object
    320         IndexObj=length(UvData.Object);
     338        IndexObj=length(UvData.ProjObject);
    321339        %initiate a new object (no data .Coord yet recorded)
    322         if ~isfield(UvData.Object{IndexObj},'Coord');
     340        if ~isfield(UvData.ProjObject{IndexObj},'Coord');
    323341            ObjectData.Coord=[];
    324342            ObjectNameNew=ObjectData.Name;
     
    326344                ObjectNameNew=ObjectData.Type;
    327345            end
    328             % add an index to the object name if the proposed name already exists         
     346            % add an index to the object name if the proposed name already exists
    329347            vers=0;% index of the name
    330348            ListObject=get(hhuvmat.ListObject,'String');
     
    348366                ListObject={ObjectName};
    349367            else
    350             ListObject{end}=ObjectName;
     368                ListObject{end}=ObjectName;
    351369            end
    352370            set(hhuvmat.ListObject,'String',ListObject);%complement the object list
     
    356374        end
    357375        ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the coordinates marked by the mouse to the object
    358         hobject=UvData.Object{IndexObj}.DisplayHandle.(fig_tag);
     376                                                         %TODO replace 0 by z coord for 3D       
     377        hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(fig_tag);
    359378        if isempty(hobject)
    360379            hobject=haxes;
    361380        end
    362         ProjObject=UvData.Object{get(hhuvmat.ListObject_1,'Value')};
     381        ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')};
    363382        AxeData.CurrentObject=plot_object(ObjectData,ProjObject,hobject,'m');%draw the object and its handle becomes AxeData.CurrentObject
    364         UvData.Object{IndexObj}=ObjectData;     
    365         UvData.Object{IndexObj}.DisplayHandle.(fig_tag)=AxeData.CurrentObject;% attribute the current plot object handle to the Object     
    366         %UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject;
     383        UvData.ProjObject{IndexObj}=ObjectData;
     384        UvData.ProjObject{IndexObj}.DisplayHandle.(fig_tag)=AxeData.CurrentObject;% attribute the current plot object handle to the Object
    367385        set(huvmat,'UserData',UvData)
    368386        PlotData=get(AxeData.CurrentObject,'UserData');
     
    378396
    379397%% create calibration points if the GUI geometry_calib is opened, if the main axes PlotAxes of uvmat has ben selected
    380 if ~test_zoom && test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'PlotAxes')
     398if test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'PlotAxes')
    381399    h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
    382400    hh_geometry_calib=guidata(h_geometry_calib);
  • trunk/src/mouse_motion.m

    r575 r622  
    3535end
    3636hhCurrentFig=guidata(CurrentFig);%handles of the elements in the GUI containing the current figure (uvmat or view_field)
    37 test_zoom=get(hhCurrentFig.CheckZoom,'Value');%test for zoom activated on the current figure
     37CheckZoom=get(hhCurrentFig.CheckZoom,'Value');% check for zoom on mode
     38CheckZoomFig=get(hhCurrentFig.CheckZoomFig,'Value');% check for zoom sub fig creation mode
     39test_zoom_draw=0;
    3840test_draw=0;%test for mouse drawing of object, =0 by default
    3941test_object=0; %test for object editing or creation
    4042test_edit_object=0;% edit test for mouse shap: an arrow
    41 test_zoom_draw=0; % test for zoom drawing
    4243test_ruler=0;%test for active ruler
    4344huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle
     
    6465
    6566AxeData=[];%default
    66 mouse=[];
    6767xy=[];%default
    68 
     68xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
    6969pointershape='arrow';% default pointer is an arrow
    7070
    71 xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
    72 hchild=get(hObject,'Children');%handles of all objects in the current figure
    73 
    7471%% loop on all the objects in the current figure, detect whether the mouse is over a plot  axes
     72hchildren=get(hObject,'Children');%handles of all objects in the current figure
     73check_visible=strcmp(get(hchildren,'Visible'),'on');% if visible='on', =0 otherwise
     74hchildren=hchildren(check_visible); %kkep only the visible children
     75PosChildren=get(hchildren,'Position');% set of object positions
     76if iscell(PosChildren)% only one child
     77    PosLength=cellfun('length',PosChildren);% set of vector lengths for object positions
     78    hchildren=hchildren(PosLength==4);% keep only objects with position defined by a 4 element vector
     79    PosChildren=cell2mat(PosChildren(PosLength==4));% convert cells to matrix of positions
     80end
     81if size(PosChildren,2)~=4
     82    return
     83end
     84xy_fig_mat=ones(size(PosChildren,1),1)*xy_fig;% mouse position set to a matrix
     85check_pos=xy_fig_mat >= PosChildren(:,1:2) & xy_fig_mat <= PosChildren(:,1:2)+PosChildren(:,3:4);% compare object to mouse position
     86ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse
     87hchild=hchildren(ind_object);% corresponding object handle
    7588CurrentAxes=[];
    76 for ichild=1:length(hchild)
    77     obj_pos=get(hchild(ichild),'Position');
    78     if numel(obj_pos)~=4% for some versions of matlab a uicontextmenu appears
    79         continue
    80     end%position of the object
    81     if xy_fig(1) >=obj_pos(1) && xy_fig(2) >= obj_pos(2)&& xy_fig(1) <=obj_pos(1)+obj_pos(3) && xy_fig(2) <= obj_pos(2)+obj_pos(4);
    82         htype=get(hchild(ichild),'Type');%type of the crrent child
    83         %if the mouse is over an axis, look at the data
    84         if strcmp(htype,'axes')
    85             CurrentAxes=hchild(ichild);
    86             xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    87             AxeData=get(CurrentAxes,'UserData');% data attached to the axis
    88             if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing)
    89                 test_draw=~isequal(AxeData.Drawing,'off');%=1 if mouse drawing of object is active
    90             end
    91             test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal');
    92             test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject);
    93             if ~test_edit_object && ~test_zoom_draw && ~test_ruler
    94                 pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
    95             end
    96             FigData=get(CurrentFig,'UserData');
    97             tagaxes=get(CurrentAxes,'tag');
    98             if isfield(FigData,tagaxes)
    99                 Field=FigData.(tagaxes);
    100                 if isfield(Field,'ListVarName')
    101                     [CellInfo,NbDimArray]=find_field_cells(Field);%analyse the physical fields contained in Field
    102                     text_displ_1='';
    103                     text_displ_2='';
    104                     text_displ_3='';
    105                     text_displ_4='';
    106                     text_displ_5='';
    107                     ivec=[];
    108                     xName='';
    109                     z=[];
    110                     for icell=1:numel(CellInfo)%look for all physical fields
    111                         if NbDimArray(icell)>=2 % select 2D field
    112                             if  isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured data
    113                                 X=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end)});
    114                                 Y=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end-1)});
    115                                 flag_vec=(X<(xy(1,1)+Field.CoordMesh/3) & X>(xy(1,1)-Field.CoordMesh/3)) & ...%flagx=1 for the vectors with x position selected by the mouse
    116                                     (Y<(xy(1,2)+Field.CoordMesh/3) & Y>(xy(1,2)-Field.CoordMesh/3));%f
    117                                 ivec=find(flag_vec,1);% search the (first) selected vector index ivec
    118                                 hhh=findobj(CurrentAxes,'Tag','vector_marker');
    119                                 if ~isempty(ivec)
    120                                     % mark the vectors with a circle in the absence of other operations
    121                                     if ~test_object && ~test_edit_object && ~test_ruler
    122                                         pointershape='arrow'; %mouse indicates  the detection of a vector
    123                                         if isempty(hhh)
    124                                             set(0,'CurrentFigure',CurrentFig)
    125                                             set(CurrentFig,'CurrentAxes',CurrentAxes)
    126                                             rectangle('Curvature',[1 1],...
    127                                                 'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh],'EdgeColor','m',...
    128                                                 'LineStyle','-','Tag','vector_marker');
    129                                         else
    130                                             set(hhh,'Visible','on')
    131                                             set(hhh,'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh])
    132                                         end
    133                                     end
    134                                     %display the field values
    135                                     for ivar=1:numel(CellInfo{icell}.VarIndex)
    136                                         VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)};
    137                                         VarVal=Field.(VarName)(ivec);
    138                                         var_text=[VarName '=' num2str(VarVal,4) ','];
    139                                         if isequal(ivar,CellInfo{icell}.CoordIndex(end))||isequal(ivar,CellInfo{icell}.CoordIndex(end-1))||isequal(ivar,CellInfo{icell}.CoordIndex(1))
    140                                             text_displ_1=[text_displ_1 var_text];
    141                                         elseif (isfield(CellInfo{icell},'VarIndex_vector_x') && isequal(ivar,CellInfo{icell}.VarIndex_vector_x))||isequal(ivar,CellInfo{icell}.VarIndex_vector_y)||...
    142                                                 (isfield(CellInfo{icell},'VarIndex_vector_z') && isequal(ivar,CellInfo{icell}.VarIndex_vector_z))
    143                                             text_displ_4=[text_displ_4 var_text];
    144                                         else
    145                                             text_displ_5=[text_displ_5 var_text];
    146                                         end
    147                                     end
     89
     90%if the mouse is over an axis, look at the data
     91if strcmp(get(hchild,'Type'),'axes')
     92    CurrentAxes=hchild;
     93    xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     94    AxeData=get(CurrentAxes,'UserData');% data attached to the axis
     95    if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing)
     96        test_draw=~isequal(AxeData.Drawing,'off');%=1 if mouse drawing of object is active
     97    end
     98    test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal');
     99    test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject);
     100    %if ~test_edit_object && ~test_zoom_draw && ~test_ruler
     101    if ~test_edit_object  && ~test_ruler && ~CheckZoom
     102        pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
     103    end
     104    FigData=get(CurrentFig,'UserData');
     105    tagaxes=get(CurrentAxes,'tag');
     106    if isfield(FigData,tagaxes)
     107        Field=FigData.(tagaxes);
     108        if isfield(Field,'ListVarName')
     109            [CellInfo,NbDimArray]=find_field_cells(Field);%analyse the physical fields contained in Field
     110            text_displ_1='';
     111            text_displ_2='';
     112            text_displ_3='';
     113            text_displ_4='';
     114            text_displ_5='';
     115            ivec=[];
     116            xName='';
     117            z=[];
     118            for icell=1:numel(CellInfo)%look for all physical fields
     119                if NbDimArray(icell)>=2 % select 2D field
     120                    if  isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured data
     121                        X=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end)});
     122                        Y=Field.(Field.ListVarName{CellInfo{icell}.CoordIndex(end-1)});
     123                        flag_vec=(X<(xy(1,1)+Field.CoordMesh/3) & X>(xy(1,1)-Field.CoordMesh/3)) & ...%flagx=1 for the vectors with x position selected by the mouse
     124                            (Y<(xy(1,2)+Field.CoordMesh/3) & Y>(xy(1,2)-Field.CoordMesh/3));%f
     125                        ivec=find(flag_vec,1);% search the (first) selected vector index ivec
     126                        hhh=findobj(CurrentAxes,'Tag','vector_marker');
     127                        if ~isempty(ivec)
     128                            % mark the vectors with a circle in the absence of other operations
     129                            if ~test_object && ~test_edit_object && ~test_ruler && ~CheckZoomFig
     130                                pointershape='arrow'; %mouse indicates  the detection of a vector
     131                                if isempty(hhh)
     132                                    set(0,'CurrentFigure',CurrentFig)
     133                                    set(CurrentFig,'CurrentAxes',CurrentAxes)
     134                                    rectangle('Curvature',[1 1],...
     135                                        'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh],'EdgeColor','m',...
     136                                        'LineStyle','-','Tag','vector_marker');
    148137                                else
    149                                     if ~isempty(hhh)
    150                                         set(hhh,'Visible','off')
    151                                     end
     138                                    set(hhh,'Visible','on')
     139                                    set(hhh,'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh])
    152140                                end
    153                             elseif strcmp(CellInfo{icell}.CoordType,'grid') %structured coordinates
    154                                 yName=Field.ListVarName{CellInfo{icell}.CoordIndex(1)};
    155                                 xName=Field.ListVarName{CellInfo{icell}.CoordIndex(2)};
    156                                 y=Field.(yName);
    157                                 x=Field.(xName);
    158                                 VarName=Field.ListVarName{CellInfo{icell}.VarIndex(1)};
    159                                 nxy=size(Field.(VarName));
    160                                 MaxAY=max(y(1),y(end)); %#ok<COLND>
    161                                 MinAY=min(y(1),y(end)); %#ok<COLND>
    162                                 if (xy(1,1)>x(1))&(xy(1,1)<x(end))&(xy(1,2)<MaxAY)&(xy(1,2)>MinAY) %#ok<COLND>
    163                                     indx0=1+round((nxy(2)-1)*(xy(1,1)-x(1))/(x(end)-x(1)));%#ok<COLND> % index x of pixel
    164                                     indy0=1+round((nxy(1)-1)*(xy(1,2)-y(1))/(y(end)-y(1)));%#ok<COLND> % index y of pixel
    165                                     if indx0>=1 & indx0<=nxy(2) & indy0>=1 & indy0<=nxy(1)
    166                                         text_displ_2=['i='  num2str(indx0) ',j=' num2str(indy0) ','];
    167                                         for ivar=1:numel(CellInfo{icell}.VarIndex)
    168                                             VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)};
    169                                             VarVal=Field.(VarName)(indy0,indx0,:);
    170                                             var_text=[VarName '=' num2str(VarVal) ','];
    171                                             text_displ_4=[text_displ_4 var_text];
    172                                         end
    173                                     end
     141                            end
     142                            %display the field values
     143                            for ivar=1:numel(CellInfo{icell}.VarIndex)
     144                                VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)};
     145                                VarVal=Field.(VarName)(ivec);
     146                                var_text=[VarName '=' num2str(VarVal,4) ','];
     147                                if isequal(ivar,CellInfo{icell}.CoordIndex(end))||isequal(ivar,CellInfo{icell}.CoordIndex(end-1))||isequal(ivar,CellInfo{icell}.CoordIndex(1))
     148                                    text_displ_1=[text_displ_1 var_text];
     149                                elseif (isfield(CellInfo{icell},'VarIndex_vector_x') && isequal(ivar,CellInfo{icell}.VarIndex_vector_x))||isequal(ivar,CellInfo{icell}.VarIndex_vector_y)||...
     150                                        (isfield(CellInfo{icell},'VarIndex_vector_z') && isequal(ivar,CellInfo{icell}.VarIndex_vector_z))
     151                                    text_displ_4=[text_displ_4 var_text];
     152                                else
     153                                    text_displ_5=[text_displ_5 var_text];
     154                                end
     155                            end
     156                        else
     157                            if ~isempty(hhh)
     158                                set(hhh,'Visible','off')
     159                            end
     160                        end
     161                    elseif strcmp(CellInfo{icell}.CoordType,'grid') %structured coordinates
     162                        yName=Field.ListVarName{CellInfo{icell}.CoordIndex(1)};
     163                        xName=Field.ListVarName{CellInfo{icell}.CoordIndex(2)};
     164                        y=Field.(yName);
     165                        x=Field.(xName);
     166                        VarName=Field.ListVarName{CellInfo{icell}.VarIndex(1)};
     167                        nxy=size(Field.(VarName));
     168                        MaxAY=max(y(1),y(end));
     169                        MinAY=min(y(1),y(end));
     170                        if (xy(1,1)>x(1))&(xy(1,1)<x(end))&(xy(1,2)<MaxAY)&(xy(1,2)>MinAY)
     171                            indx0=1+round((nxy(2)-1)*(xy(1,1)-x(1))/(x(end)-x(1))); % index x of pixel
     172                            indy0=1+round((nxy(1)-1)*(xy(1,2)-y(1))/(y(end)-y(1))); % index y of pixel
     173                            if indx0>=1 & indx0<=nxy(2) & indy0>=1 & indy0<=nxy(1)
     174                                text_displ_2=['i='  num2str(indx0) ',j=' num2str(indy0) ','];
     175                                for ivar=1:numel(CellInfo{icell}.VarIndex)
     176                                    VarName=Field.ListVarName{CellInfo{icell}.VarIndex(ivar)};
     177                                    VarVal=Field.(VarName)(indy0,indx0,:);
     178                                    var_text=[VarName '=' num2str(VarVal) ','];
     179                                    text_displ_4=[text_displ_4 var_text];
    174180                                end
    175181                            end
    176182                        end
    177183                    end
    178               % display the current x,y plot coordinates in the absence of detected vector
    179                     if isempty(ivec)
    180                         if isempty(xName)
    181                             xName='x';
    182                             yName='y';
     184                end
     185            end
     186            % display the current x,y plot coordinates in the absence of detected vector
     187            if isempty(ivec)
     188                if isempty(xName)
     189                    xName='x';
     190                    yName='y';
     191                end
     192                text_displ_1=[xName '=' num2str(xy(1,1),4) ', ' yName '=' num2str(xy(1,2),4) ','];
     193            end
     194            %display the z coordinate if defined by the projection plane
     195            if isfield(Field,'ObjectType') && strcmp(Field.ObjectType,'plane') && isfield(Field,'ObjectCoord') && length(Field.ObjectCoord)>=3
     196                pos=[xy(1,1) xy(1,2) 0];
     197                if isfield(Field,'ObjectAngle')&&~isequal(Field.ObjectAngle,[0 0 0])
     198                    om=norm(Field.ObjectAngle);%norm of rotation angle in radians
     199                    OmAxis=Field.ObjectAngle/om; %unit vector marking the rotation axis
     200                    cos_om=cos(pi*om/180);
     201                    sin_om=sin(pi*om/180);
     202                    pos=[xy(1,1) xy(1,2) 0];
     203                    pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
     204                end
     205                pos=pos+[Field.ObjectCoord 0];
     206                text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)];
     207            end
     208            %                     if ~isempty(z)
     209            %                         text_displ_1=[text_displ_1 ' z=' num2str(z,4)];
     210            %                     end
     211            % case of PIV correlation display
     212            if test_piv
     213                par=read_GUI(hhciv.Civ1);
     214                [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2)));
     215                xround=Field.X(ind_pt);
     216                yround=Field.Y(ind_pt);
     217                %                         par.Grid=[xround size(Field.A,1)-yround+1];
     218                par.Grid=[xround yround];
     219                % mark the correlation box with a rectangle
     220                par.ImageA=Field.A;
     221                par.ImageB=Field.B;
     222                par.ImageHeight=size(par.ImageA,1);
     223                par.ImageWidth=size(par.ImageA,2);
     224                Param.Civ1=par;
     225                ibx2=floor((par.CorrBoxSize(1)-1)/2);
     226                iby2=floor((par.CorrBoxSize(2)-1)/2);
     227                isx2=floor((par.SearchBoxSize(1)-1)/2);
     228                isy2=floor((par.SearchBoxSize(2)-1)/2);
     229                shiftx=par.SearchBoxShift(1);
     230                shifty=par.SearchBoxShift(2);
     231                hhh=findobj(CurrentAxes,'Tag','PIV_box_marker');
     232                hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker');
     233                if isempty(hhh)
     234                    set(0,'CurrentFigure',CurrentFig)
     235                    set(CurrentFig,'CurrentAxes',CurrentAxes)
     236                    rectangle('Curvature',[0 0],...
     237                        'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',...
     238                        'LineStyle','-','Tag','PIV_box_marker');
     239                    rectangle('Curvature',[0 0],...
     240                        'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2],'EdgeColor','m',...
     241                        'LineStyle','- -','Tag','PIV_search_marker');
     242                else
     243                    set(hhh,'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2])
     244                    set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2])
     245                end
     246                [Data,errormsg,result_conv]= civ_matlab(Param);
     247                if ~isempty(errormsg)
     248                    text_displ_5=errormsg;
     249                else
     250                    rangx(1)=-(isx2-ibx2)+shiftx;
     251                    rangx(2)=isx2-ibx2+shiftx;
     252                    rangy(1)=-(isy2-iby2)-shifty;
     253                    rangy(2)=(isy2-iby2)-shifty;
     254                    hcorr=[];
     255                    if isfield(AxeData,'CurrentCorrImage')
     256                        hcorr=AxeData.CurrentCorrImage;
     257                        if ~ishandle(hcorr)
     258                            hcorr=[];
    183259                        end
    184                         text_displ_1=[xName '=' num2str(xy(1,1),4) ', ' yName '=' num2str(xy(1,2),4) ','];
    185260                    end
    186                     %display the z coordinate if defined by the projection plane
    187                     if isfield(Field,'ObjectCoord') && length(Field.ObjectCoord)>=3
    188                         pos=[xy(1,1) xy(1,2) 0];
    189                         if isfield(Field,'ObjectAngle')&&~isequal(Field.ObjectAngle,[0 0 0])
    190                             om=norm(Field.ObjectAngle);%norm of rotation angle in radians
    191                             OmAxis=Field.ObjectAngle/om; %unit vector marking the rotation axis
    192                             cos_om=cos(pi*om/180);
    193                             sin_om=sin(pi*om/180);
    194                             pos=[xy(1,1) xy(1,2) 0];
    195                             pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
     261                    if isempty(hcorr)
     262                        corrfig=findobj(allchild(0),'tag','corrfig');
     263                        if ~isempty(corrfig)
     264                            set(0,'CurrentFigure',corrfig(1))
     265                            AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]);
     266                            AxeData.CurrentVector=line([0 Data.Civ1_U],[0 Data.Civ1_V],'Tag','vector');
     267                            AxeData.TitleHandle=title(num2str(par.Grid));
     268                            colorbar
     269                            set(CurrentAxes,'UserData',AxeData)
     270                            set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal')
    196271                        end
    197                         pos=pos+Field.ObjectCoord;
    198                         text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)];
    199                     end
    200 %                     if ~isempty(z)
    201 %                         text_displ_1=[text_displ_1 ' z=' num2str(z,4)];
    202 %                     end
    203                % case of PIV correlation display
    204                     if test_piv
    205                         par=read_GUI(hhciv.Civ1);
    206                         [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2)));
    207                         xround=Field.X(ind_pt);
    208                         yround=Field.Y(ind_pt);
    209 %                         par.Grid=[xround size(Field.A,1)-yround+1];
    210                         par.Grid=[xround yround];
    211                         % mark the correlation box with a rectangle
    212                         par.ImageA=Field.A;
    213                         par.ImageB=Field.B;
    214                         par.ImageHeight=size(par.ImageA,1);
    215                         par.ImageWidth=size(par.ImageA,2);
    216                         Param.Civ1=par;
    217                         ibx2=floor((par.CorrBoxSize(1)-1)/2);
    218                         iby2=floor((par.CorrBoxSize(2)-1)/2);
    219                         isx2=floor((par.SearchBoxSize(1)-1)/2);
    220                         isy2=floor((par.SearchBoxSize(2)-1)/2);
    221                         shiftx=par.SearchBoxShift(1);
    222                         shifty=par.SearchBoxShift(2);     
    223                         hhh=findobj(CurrentAxes,'Tag','PIV_box_marker');
    224                         hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker');
    225                         if isempty(hhh)
    226                             set(0,'CurrentFigure',CurrentFig)
    227                             set(CurrentFig,'CurrentAxes',CurrentAxes)
    228                             rectangle('Curvature',[0 0],...
    229                                 'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',...
    230                                 'LineStyle','-','Tag','PIV_box_marker');
    231                             rectangle('Curvature',[0 0],...
    232                                 'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2],'EdgeColor','m',...
    233                                 'LineStyle','- -','Tag','PIV_search_marker');
    234                         else
    235                             set(hhh,'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2])
    236                             set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2])
    237                         end
    238                         [Data,errormsg,result_conv]= civ_matlab(Param);
    239                         if ~isempty(errormsg)
    240                             text_displ_5=errormsg;
    241                         else
    242                             rangx(1)=-(isx2-ibx2)+shiftx;
    243                             rangx(2)=isx2-ibx2+shiftx;
    244                             rangy(1)=-(isy2-iby2)-shifty;
    245                             rangy(2)=(isy2-iby2)-shifty;
    246                             hcorr=[];
    247                             if isfield(AxeData,'CurrentCorrImage')
    248                                 hcorr=AxeData.CurrentCorrImage;
    249                                 if ~ishandle(hcorr)
    250                                     hcorr=[];
    251                                 end
    252                             end
    253                             if isempty(hcorr)
    254                                 corrfig=findobj(allchild(0),'tag','corrfig');
    255                                 if ~isempty(corrfig)
    256                                     set(0,'CurrentFigure',corrfig(1))         
    257                                     AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]);
    258                                     AxeData.CurrentVector=line([0 Data.Civ1_U],[0 Data.Civ1_V],'Tag','vector');
    259                                    AxeData.TitleHandle=title(num2str(par.Grid));
    260                                     colorbar
    261                                     set(CurrentAxes,'UserData',AxeData)
    262                                     set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal')
    263                                 end
    264                             else
    265                                 set(AxeData.CurrentCorrImage,'CData',result_conv)
    266                                 set(AxeData.CurrentCorrImage,'XData',rangx)
    267                                 set(AxeData.CurrentCorrImage,'YData',-rangy)
    268                                 set(AxeData.CurrentVector,'XData',[0 Data.Civ1_U],'YData',[0 Data.Civ1_V])
    269                                 set(AxeData.TitleHandle,'String',num2str(par.Grid))
    270                             end
    271                         end
     272                    else
     273                        set(AxeData.CurrentCorrImage,'CData',result_conv)
     274                        set(AxeData.CurrentCorrImage,'XData',rangx)
     275                        set(AxeData.CurrentCorrImage,'YData',-rangy)
     276                        set(AxeData.CurrentVector,'XData',[0 Data.Civ1_U],'YData',[0 Data.Civ1_V])
     277                        set(AxeData.TitleHandle,'String',num2str(par.Grid))
    272278                    end
    273279                end
     
    288294
    289295%%%%%%%%%%%%%
    290 %% draw a zoom rectangle if no object creation is selected
     296%% draw a zoom rectangle if checkZoomFig has been selected
    291297if test_zoom_draw
    292    xy_rect=AxeData.CurrentOrigin;
     298   xy_rect=AxeData.CurrentOrigin;% mark the previous position from mouse down
    293299   if ~isempty(xy_rect)
    294300        rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate
     
    296302        rect(3)=abs(xy(1,1)-xy_rect(1));%rectangle width
    297303        rect(4)=abs(xy(1,2)-xy_rect(2));%rectangle height
    298         if rect(3)>0 & rect(4)>0
    299             if isfield(AxeData,'CurrentRectZoom')& ishandle(AxeData.CurrentRectZoom)
     304        if rect(3)>0 && rect(4)>0
     305            if isfield(AxeData,'CurrentRectZoom')&& ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)
    300306                set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position
    301307            else
    302                 AxeData.CurrentRectZoom=rectangle('Position',rect,'LineStyle',':','Tag','rect_zoom');
     308                AxeData.CurrentRectZoom=rectangle('Position',rect,'Tag','rect_zoom','EdgeColor','b');
    303309                set(CurrentAxes,'UserData',AxeData)
    304310            end
    305311        end
    306312   end
    307     pointershape='arrow';
    308313end
    309314
     
    316321        return
    317322    end
    318     ObjectData=UvData.Object{PlotData.IndexObj};
    319     ProjObject=[];% object (plane) whose projection is represented on the current axes
     323    ObjectData=UvData.ProjObject{PlotData.IndexObj};
    320324    if isequal(hObject,huvmat)% if the mouse ifs over the GUI uvmat
    321         ProjObject=UvData.Object{get(hhuvmat.ListObject_1,'Value')};
     325        ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')};
    322326    else
    323         ProjObject=UvData.Object{get(hhuvmat.ListObject,'Value')};
     327        ProjObject=UvData.ProjObject{get(hhuvmat.ListObject,'Value')};
    324328    end
    325329    XYData=AxeData.CurrentOrigin;
     
    329333            % ObjectData.Coord(end,:)=xy(1,:);
    330334        elseif strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')||strcmp(ObjectData.Type,'volume')
    331             ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
    332             ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
    333             ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
    334             ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
     335                ObjectData.Coord=(AxeData.CurrentOrigin+xy(1,1:2))/2;% keep only the first point coordinate     
     336                ObjectData.RangeX=abs(ObjectData.Coord(1,1)-xy(1,1));%rectangle width
     337                ObjectData.RangeY=abs(ObjectData.Coord(1,2)-xy(1,2));%rectangle height
    335338        elseif isequal(ObjectData.Type,'plane') %case of 'plane'
    336339            DX=(xy(1,1)-ObjectData.Coord(1,1));
     
    364367%% detect calibration points if the GUI geometry_calib is opened
    365368h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
    366 if ~test_zoom && ~isempty(h_geometry_calib)
     369if ~CheckZoom && ~isempty(h_geometry_calib)
    367370    pointershape='crosshair';%default for geometry_calib: ready to create new points
    368371    hh_geometry_calib=guidata(h_geometry_calib);
  • trunk/src/mouse_up.m

    r608 r622  
    2323
    2424function mouse_up(hObject,eventdata,handles)
    25 %MouseAction='none'; %default
    26 test_zoom=0;%default
     25
    2726test_ruler=0;%default
    28 currentfig=hObject;
    29 tagfig=get(currentfig,'tag');
     27hcurrentfig=hObject;
     28fig_tag=get(hcurrentfig,'tag');
    3029currentaxes=gca; %store the current axes handle
    3130AxeData=get(currentaxes,'UserData');
     31CurrentOrigin=[];
    3232if isfield(AxeData,'CurrentOrigin')
    3333    CurrentOrigin=AxeData.CurrentOrigin;
     
    4040    testsubplot=1;
    4141else
    42     hhcurrentfig=guidata(currentfig);%the current figure is a GUI (uvmat or view_field)
     42    hhcurrentfig=guidata(hcurrentfig);%the current figure is a GUI (uvmat or view_field)
    4343    testsubplot=0;
    4444end
     
    5959    PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object
    6060    IndexObj=PlotData.IndexObj;
    61     ObjectData=UvData.Object{IndexObj};
     61    ObjectData=UvData.ProjObject{IndexObj};
    6262    check_multiple=0;
    6363    % ending translation
     
    7979        switch ObjectData.Type
    8080            case {'line'}
    81                 if isfield(AxeData,'ObjectCoord') && size(AxeData.ObjectCoord,2)==3
    82                     xy(1,3)=AxeData.ObjectCoord(1,3); % z coordinate of the mouse: to generalise ...
     81                if size(ObjectData.Coord,1)==1 % this is the mouse up for the first point, continue until next click
     82                    check_multiple=1;
    8383                else
    84                     xy(1,3)=0; % z coordinate set to 0 by default
    85                 end
    86                 %                 if ~isequal(ObjectData.Coord,xy(1,:))
    87                 if ~isequal(ObjectData.Coord(end,1:2),xy(1,1:2))
    88                     ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the second point of the line if different from the first one
    89                 end
    90                 %                 end
     84                    %ObjectData.Coord=[ObjectData.Coord ;CurrentOrigin];% append the second point of the line (the last pointed position during mouse down)
     85                end
    9186            case {'rectangle','ellipse','volume'}
    92                 XYData=AxeData.CurrentOrigin;
    93                 ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
    94                 ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
    95                 ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
    96                 ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
     87%                  if size(ObjectData.Coord,1)==1 % this is the mouse up for the first point, continue until next click
     88%                     check_multiple=1;
     89%                  else
     90                ObjectData.Coord=(CurrentOrigin+xy(1,1:2))/2;% keep only the first point coordinate     
     91                ObjectData.RangeX=abs(ObjectData.Coord(1,1)-xy(1,1));%rectangle width
     92                ObjectData.RangeY=abs(ObjectData.Coord(1,2)-xy(1,2));%rectangle height   
     93                if isequal(ObjectData.RangeX,0)||isequal(ObjectData.RangeY,0)
     94                    check_multiple=1;% pass to next mous up if width of height=0
     95                end
     96%                 ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
     97%                 ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
     98%                 ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
     99%                 ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
     100%                  end
    97101            case 'plane' %case of 'plane'
    98102                DX=(xy(1,1)-ObjectData.Coord(1,1));
     
    106110                end
    107111            otherwise
    108                 check_multiple=1;
     112                check_multiple=1; 
    109113        end
    110114    end
     
    120124
    121125    %stop drawing and plot projected field if the object manipulation is finished
    122     if check_multiple==0  || isequal(get(currentfig,'SelectionType'),'alt')
     126    if check_multiple==0  || isequal(get(hcurrentfig,'SelectionType'),'alt')
    123127        AxeData.CurrentOrigin=[]; %suppress the current origin
    124 %         if isequal(ObjectData.Type,'line') && size(ObjectData.Coord,1)>=2
    125 % %             AxeData.Drawing='off';
    126 % %             set(currentaxes,'UserData',AxeData);
    127 %             
    128 %         end
     128        hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(fig_tag);
     129        if ~isempty(hObject)
     130         ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')};
     131        AxeData.CurrentObject=plot_object(ObjectData,ProjObject,hobject,'m');%draw the object and its handle becomes AxeData.CurrentObject
     132        end
     133        %%
    129134        if  ~isempty(ObjectData)
    130             %              testmask=0;
    131             %              hmask=findobj(huvmat,'Tag','makemask');
    132             %              if ~isempty(hmask)
    133             %                 testmask=get(hmask,'Value');
    134             %              end
    135            
    136135            % plot the field projected on the object
    137136            ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
    138137            if ~isempty(ProjData)
    139                 if strcmp(tagfig,'uvmat')% uvmat plot selected, projection plot seen in view_field
     138                if strcmp(fig_tag,'uvmat')% uvmat plot selected, projection plot seen in view_field
    140139                    hview_field=findobj(allchild(0),'tag','view_field');
    141140                    if isempty(hview_field)
     
    144143                        hhview_field=guidata(hview_field);
    145144                        [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%update an existing  plot in view_field
    146                         %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object
    147145                        errormsg=fill_GUI(PlotParam,hview_field);
    148146                    end
    149147                    ViewFieldData=get(hview_field,'UserData');
    150                     %                     ViewFieldData.PlotAxes=ProjData;
    151148                    haxes=findobj(hview_field,'tag','axes3');
    152149                    if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table)
     
    164161                    [PlotType,PlotParam]=plot_field(ProjData,hhuvmat.PlotAxes,read_GUI(hhuvmat));%update an existing field plot
    165162                    errormsg=fill_GUI(PlotParam,huvmat);
    166                    % write_plot_param(hhuvmat,PlotParam); %update the display of plotting parameters for the current object
    167163                end
    168164            end
     
    176172    else
    177173        test_drawing=1;%allow continuation of drawing object
    178         AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the next current origin
    179     end
    180     UvData.Object{IndexObj}=ObjectData;
     174         AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the next current origin
     175    end
     176    UvData.ProjObject{IndexObj}=ObjectData;
    181177    hother=findobj('Tag','deformpoint');%find all the deformpoints
    182178    set(hother,'Color','b');%reset all the deformpoints in 'blue'
     
    184180
    185181%% creation of a new zoom plot
    186 if isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed
    187     hparentfig=currentfig;
     182if isequal(get(hcurrentfig,'SelectionType'),'normal');%if left button has been pressed
     183    hparentfig=hcurrentfig;
    188184    %open or update a new zoom figure if a rectangle has been drawn
    189185    if ishandle(currentaxes);
     
    196192                hfig2=figure;%create new figure
    197193                set(hfig2,'name','zoom')
    198                 set(hfig2,'Units','normalized')
    199                 set(hfig2,'Position',[0.2 0.33 0.6 0.6]);
     194                set(0,'Unit','pixels')
     195                set(hfig2,'Unit','pixels')
     196                FigPos=get(hfig2,'Position');
     197                ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
     198                Left=ScreenSize(3)- FigPos(3)-40; %right edge close to the right, with margin=40
     199                Bottom=ScreenSize(4)-FigPos(4)-40; %put fig at top right
     200                FigPos(1:2)=[Left Bottom];
     201                set(hfig2,'Position',FigPos);
    200202                map=colormap(currentaxes);
    201203                colormap(map);%transmit the current colormap to the zoom fig
    202                 set(hfig2,'Position',[0.2 0.33 0.6 0.6]);
    203                 set(hfig2,'Unit','normalized')
    204204                set(hfig2,'KeyPressFcn',{@keyboard_callback,handles})%set keyboard action function
    205205                set(hfig2,'WindowButtonMotionFcn',{@mouse_motion,handles})%set mouse action function
     
    209209                set(hfig2,'UserData',AxeData.CurrentRectZoom)% record the parent object (zoom rectangle) in the new fig
    210210                AxeData.ZoomAxes=copyobj(currentaxes,hfig2); %copy the current graph axes to the zoom figure
     211                hrect_zoom=findobj(AxeData.ZoomAxes,'Tag','rect_zoom');%find and delete the copy of the rect_zoom rectangle
     212                delete(hrect_zoom)
    211213                ChildAxeData=get(AxeData.ZoomAxes,'UserData');
    212214                if isfield(ChildAxeData,'ParentGUI')
    213215                    ChildAxeData=rmfield(ChildAxeData,'ParentGUI');%no parent GUI, e.g. uvmat,  for the new plot
    214216                end
    215                 %figure(hfig2)
    216                 %set(0,'CurrentFigure',hfig2)% the zoom figure becomes the current figure
    217217                set(AxeData.ZoomAxes,'Position',[0.1300    0.1100    0.7750    0.8150])% standard axes position on a figure
    218218                hcol=findobj(hparentfig,'Tag','Colorbar'); %look for colorbar axes
     
    247247    ylim=get(currentaxes,'YLim');
    248248    % if left mouse button has been pressed, zoom in by a factor of 2
    249     if  isequal(get(currentfig,'SelectionType'),'normal');%if left button has been pressed, zoom in by a factor of 2
     249    if  isequal(get(hcurrentfig,'SelectionType'),'normal');%if left button has been pressed, zoom in by a factor of 2
    250250        PlotBoxAspectRatio=get(currentaxes,'PlotBoxAspectRatio');
    251251        yoverx=PlotBoxAspectRatio(2)/PlotBoxAspectRatio(1);
     
    346346
    347347%% display the data of the current object selected with the mouse right click
    348 if isequal(get(currentfig,'SelectionType'),'alt') && ~test_zoom && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create'))
     348if isequal(get(hcurrentfig,'SelectionType'),'alt') && ~test_zoom && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create'))
    349349    hother=findobj('Tag','proj_object');%find all the proj objects
    350350    nbselect=0;
     
    368368    end
    369369%     if ((nbselect==0) && isequal(get(currentobj,'Type'),'axes')) || isequal(currentobj,huvmat)
    370 %         currentfig=get(currentobj,'parent');
    371 %         figname=get(currentfig,'name');
     370%         hcurrentfig=get(currentobj,'parent');
     371%         figname=get(hcurrentfig,'name');
    372372%         eval(['global Data_' figname])
    373373%         eval(['Data_' figname '=get(currentobj,''UserData'')']);
  • trunk/src/plot_object.m

    r534 r622  
    115115        end
    116116    case {'rectangle','ellipse','volume'}
    117         if  isequal(YMax,0)
    118             ylim=get(haxes,'YLim');
    119             YMax=(ylim(2)-ylim(1))/100;
    120         end
    121         if isequal(XMax,0)
    122             XMax=YMax;%default
    123         end
     117%         if  isequal(YMax,0)
     118%             ylim=get(haxes,'YLim');
     119%             YMax=(ylim(2)-ylim(1))/100;
     120%         end
     121%         if isequal(XMax,0)
     122%             XMax=YMax;%default
     123%         end
    124124    case 'plane'
    125125        if  isequal(XMax,0)
     
    274274               end
    275275               %complement missing points
    276                if size(ObjectData.Coord,1)>length(PlotData.SubObject)
    277                    for ipt=length(PlotData.SubObject)+1:size(ObjectData.Coord,1)
     276                if length(PlotData.SubObject)>nbpoints% fpoints in excess on the graph
     277               for ii=nbpoints+1: length(PlotData.SubObject);
     278                   if ishandle(PlotData.SubObject(ii))
     279                        delete(PlotData.SubObject(ii))
     280                   end
     281               end
     282%                NbDeformPoint=nbpoints;
     283           end
     284               if nbpoints>length(PlotData.SubObject)
     285                   for ipt=length(PlotData.SubObject)+1:nbpoints
    278286                     PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],...
    279287                  'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,...
     
    284292        end
    285293        if isfield(PlotData,'DeformPoint')
    286            for ipt=1:length(PlotData.DeformPoint)
     294            NbDeformPoint=length(PlotData.DeformPoint);
     295           if NbDeformPoint>nbpoints% fpoints in excess on the graph
     296               for ii=nbpoints+1:NbDeformPoint;
     297                   if ishandle(PlotData.DeformPoint(ii))
     298                        delete(PlotData.DeformPoint(ii))
     299                   end
     300               end
     301               NbDeformPoint=nbpoints;
     302           end
     303           for ipt=1:NbDeformPoint
    287304               if ishandle(PlotData.DeformPoint(ipt))
    288305                   if nbpoints>=ipt 
     
    299316           end
    300317        end
    301     elseif isequal(ObjectData.Type,'rectangle')||isequal(ObjectData.Type,'ellipse')
     318    elseif (isequal(ObjectData.Type,'rectangle')||isequal(ObjectData.Type,'ellipse'))&&XMax>0 && YMax>0
    302319        set(hplot,'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax])         
    303320    end
  • trunk/src/set_grid.m

    r591 r622  
    170170    set(handles.TxtWarning,'visible','on')
    171171end
    172 
    173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    174 % --- Executes on button press in delete.
    175 function delete_Callback(hObject, eventdata, handles)
    176 
    177 %SetData=get(gcbf,'UserData');%get the interface data
    178 %IndexObj=SetData.IndexObj;
    179 huvmat=findobj('Name','uvmat');%find the current uvmat interface handle
    180 UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
    181 if isfield(UvData,'CurrentObjectIndex')
    182     IndexObj=UvData.CurrentObjectIndex;
    183 else
    184     IndexObj=[];
    185 end
    186 delete_object(IndexObj);
    187 
    188172
    189173% ------------------------------------------------------
  • trunk/src/set_object.m

    r613 r622  
    475475set(hhuvmat.ListObject,'String',ListObject);%complement the object list
    476476set(hhuvmat.ViewObject,'Value',1)% indicate that the currently selected objected is viewed on set_object
    477 check_handle=isfield(UvData.Object{IndexObj},'DisplayHandle') && isfield(UvData.Object{IndexObj}.DisplayHandle,'uvmat')...
    478     && ~isempty(UvData.Object{IndexObj}.DisplayHandle.uvmat) && ishandle(UvData.Object{IndexObj}.DisplayHandle.uvmat);
     477check_handle=isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat')...
     478    && ~isempty(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat) && ishandle(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat);
    479479if check_handle
    480     obj_handle=UvData.Object{IndexObj}.DisplayHandle.uvmat;
    481 end
    482 UvData.Object{IndexObj}=ObjectData;%record the current object properties in uvmat
     480    obj_handle=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat;
     481end
     482UvData.ProjObject{IndexObj}=ObjectData;%record the current object properties in uvmat
    483483if check_handle
    484     UvData.Object{IndexObj}.DisplayHandle.uvmat=obj_handle; %preserve the object plot handle if valid
    485 else
    486     UvData.Object{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; %axes taken as object display handle by defualt
     484    UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=obj_handle; %preserve the object plot handle if valid
     485else
     486    UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; %axes taken as object display handle by defualt
    487487end
    488488%set(hhuvmat.edit_object,'Value',1)% set the current object to edit mode
     
    543543
    544544%% update the object plot
    545 hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat;
     545hobject=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat;
    546546% if we are editing the object used for projection in uvmat
    547547if isequal(IndexObj_1,IndexObj)
    548548    %update the representation of the current object for projection field represented in view_field
    549     for iobj=1:numel(UvData.Object)
    550         UvData.Object{iobj}.DisplayHandle.uvmat=...
    551             plot_object(UvData.Object{iobj},UvData.Object{IndexObj_1},UvData.Object{iobj}.DisplayHandle.uvmat,'b');
     549    for iobj=1:numel(UvData.ProjObject)
     550        UvData.ProjObject{iobj}.DisplayHandle.uvmat=...
     551            plot_object(UvData.ProjObject{iobj},UvData.ProjObject{IndexObj_1},UvData.ProjObject{iobj}.DisplayHandle.uvmat,'b');
    552552    end
    553553else %  we are editing the object used for projection field represented in view_field
    554554    %update the representation of the current object in uvmat
    555     UvData.Object{IndexObj}.DisplayHandle.uvmat=...
    556              plot_object(UvData.Object{IndexObj},UvData.Object{IndexObj_1},UvData.Object{IndexObj}.DisplayHandle.uvmat,'m');
     555    UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=...
     556             plot_object(UvData.ProjObject{IndexObj},UvData.ProjObject{IndexObj_1},UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'m');
    557557    %indicate the object index in the user data of the object plot (needed for further mouse editing)
    558     ObjectInfo=get(UvData.Object{IndexObj}.DisplayHandle.uvmat,'UserData');
     558    ObjectInfo=get(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'UserData');
    559559    ObjectInfo.IndexObj=IndexObj;
    560     set(UvData.Object{IndexObj}.DisplayHandle.uvmat,'UserData',ObjectInfo)
     560    set(UvData.ProjObject{IndexObj}.DisplayHandle.uvmat,'UserData',ObjectInfo)
    561561    % update the representation of all objects in view_field
    562     for iobj=1:numel(UvData.Object)
    563         if isfield(UvData.Object{iobj}.DisplayHandle,'view_field')
    564             UvData.Object{iobj}.DisplayHandle.view_field=...
    565                 plot_object(UvData.Object{iobj},UvData.Object{iobj},UvData.Object{iobj}.DisplayHandle.view_field,'b');
     562    for iobj=1:numel(UvData.ProjObject)
     563        if isfield(UvData.ProjObject{iobj}.DisplayHandle,'view_field')
     564            UvData.ProjObject{iobj}.DisplayHandle.view_field=...
     565                plot_object(UvData.ProjObject{iobj},UvData.ProjObject{iobj},UvData.ProjObject{iobj}.DisplayHandle.view_field,'b');
    566566        end
    567567    end
  • trunk/src/uvmat.m

    r620 r622  
    3434%                       .PosGeometryCalib: size of set_object
    3535%                       .NbBuiltin: nbre of functions always displayed in TransformName menu
    36 %          .Object: cell array of structures representing the current projection objects, as produced by 'set_object.m'={[]} by default
     36%          .ProjObject: cell array of structures representing the current projection objects, as produced by 'set_object.m'={[]} by default
    3737%          .NewSeries: =0/1 flag telling whether a new field series has been opened
    3838%          .FileName_1: name of the current second field (used to detect a  constant field during file scanning)
     
    126126%              .Phi, .Theta, .Psi : Euler angles
    127127%              .X,.Y,.U,.V.... : field data projected on the object
    128 %              .IndexObj: index in the list of UvData.Object
     128%              .IndexObj: index in the list of UvData.ProjObject
    129129           %during plotting
    130130%               .plotaxes: handles of the current axes used to plot the  result of field projection on the object
     
    214214set(handles.FieldName,'Value',1)
    215215set(handles.FieldName,'string',{''})
    216 UvData.Object={[]};
     216UvData.ProjObject={[]};
    217217
    218218%% TRANSFORM menu: builtin fcts
     
    18091809function movie_pair_Callback(hObject, eventdata, handles)
    18101810%------------------------------------------------------------------------
     1811
    18111812%% stop movie action if the movie_pair button is off
    18121813if ~get(handles.movie_pair,'value')
     
    20652066check_proj_tps=0;
    20662067if  (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))
    2067     for iobj=1:numel(UvData.Object)
    2068         if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'interp_tps')
     2068    for iobj=1:numel(UvData.ProjObject)
     2069        if isfield(UvData.ProjObject{iobj},'ProjMode')&& strcmp(UvData.ProjObject{iobj}.ProjMode,'interp_tps')
    20692070            check_proj_tps=1;
    20702071            break
     
    25472548    end
    25482549    % default projection plane
    2549     if isempty(UvData.Object{1})
    2550         UvData.Object{1}.Type='plane';%main plotting plane
    2551         UvData.Object{1}.ProjMode='projection';%main plotting plane
    2552         UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
    2553         UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
     2550    if isempty(UvData.ProjObject{1})
     2551        UvData.ProjObject{1}.Type='plane';%main plotting plane
     2552        UvData.ProjObject{1}.ProjMode='projection';%main plotting plane
     2553        UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
     2554        UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
    25542555    end
    25552556    %% 3D case (menuvolume)
     
    25632564        end
    25642565        if test_set_object% reinitiate the GUI set_object
    2565             delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2
    2566             UvData.Object{1}.NbDim=NbDim;%test for 3D objects
    2567             UvData.Object{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane
    2568             UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
    2569             UvData.Object{1}.Angle=[0 0 0];
    2570             UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
    2571             UvData.Object{1}.Name='1-PLANE';
    2572             UvData.Object{1}.enable_plot=1;
    2573             set_object(UvData.Object{1},handles,ZBounds);
     2566            delete_object(1);% delete the current projection object in the list UvData.ProjObject, delete its graphic representations and update the list displayed in handles.ListObject and 2
     2567            UvData.ProjObject{1}.NbDim=NbDim;%test for 3D objects
     2568            UvData.ProjObject{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane
     2569            UvData.ProjObject{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
     2570            UvData.ProjObject{1}.Angle=[0 0 0];
     2571            UvData.ProjObject{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
     2572            UvData.ProjObject{1}.Name='1-PLANE';
     2573            UvData.ProjObject{1}.enable_plot=1;
     2574            set_object(UvData.ProjObject{1},handles,ZBounds);
    25742575            set(handles.ListObject,'Value',1);
    25752576            set(handles.ListObject,'String',{'1-PLANE'});
     
    25822583            XmlData=UvData.XmlData{1};
    25832584            if isfield(XmlData,'PlanePos')
    2584                 UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
     2585                UvData.ProjObject{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
    25852586            end
    25862587            if isfield(XmlData,'PlaneAngle')
    25872588                siz=size(XmlData.PlaneAngle);
    25882589                indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
    2589                 UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
     2590                UvData.ProjObject{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
    25902591            end
    25912592        elseif isfield(UvData,'ZIndex')
    2592             UvData.Object{1}.ZObject=UvData.ZIndex;
     2593            UvData.ProjObject{1}.ZObject=UvData.ZIndex;
    25932594        end
    25942595    end
     
    26312632        set(handles.ListObject,'Value',1)
    26322633        set(handles.ListObject,'String',{'plane'})
    2633         UvData.Object{1}.Type='plane';%main plotting plane
    2634         UvData.Object{1}.ProjMode='projection';%main plotting plane
    2635         UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
    2636         UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
     2634        UvData.ProjObject{1}.Type='plane';%main plotting plane
     2635        UvData.ProjObject{1}.ProjMode='projection';%main plotting plane
     2636        UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
     2637        UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
    26372638        set(handles.ListObject_1,'Value',1)
    26382639        set(handles.ListObject_1,'String',{'plane'})
    26392640    end
    26402641    IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view
    2641     if IndexObj(1)> numel(UvData.Object)
     2642    if IndexObj(1)> numel(UvData.ProjObject)
    26422643        IndexObj(1)=1;%select the first object if the selected one does not exist
    26432644        set(handles.ListObject_1,'Value',1)
     
    26822683    for imap=1:numel(IndexObj)
    26832684        iobj=IndexObj(imap);
    2684         if numel(UvData.Object)<iobj
     2685        if numel(UvData.ProjObject)<iobj
    26852686            break
    26862687        end
    2687         [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
     2688        [ObjectData,errormsg]=proj_field(UvData.Field,UvData.ProjObject{iobj});% project field on the object
    26882689        if ~isempty(errormsg)
    26892690            return
     
    28792880end
    28802881
    2881 %-------------------------------------------------------------------
     2882%------------------------------------------------------------------------
    28822883% --- translate coordinate to matrix index
    2883 %-------------------------------------------------------------------
     2884%------------------------------------------------------------------------
    28842885function [indx,indy]=pos2ind(x0,rangx0,nxy)
    28852886indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel 
    28862887indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
    28872888
    2888 
    2889 %-------------------------------------------------------------------
     2889%------------------------------------------------------------------------
    28902890% --- Executes on button press in 'CheckZoom'.
    2891 %-------------------------------------------------------------------
     2891%------------------------------------------------------------------------
    28922892function CheckZoom_Callback(hObject, eventdata, handles)
    28932893
    2894 if (get(handles.CheckZoom,'Value') == 1);
    2895     set(handles.CheckZoom,'BackgroundColor',[1 1 0])
     2894if get(handles.CheckZoom,'Value')
    28962895    set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes
    2897     set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
    2898 else
    2899     set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
    2900 end
    2901 
    2902 %-------------------------------------------------------------------
     2896    set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig
     2897end
     2898
     2899%------------------------------------------------------------------------
     2900% --- Executes on button press in CheckZoomFig.
     2901%------------------------------------------------------------------------
     2902function CheckZoomFig_Callback(hObject, eventdata, handles)
     2903
     2904if get(handles.CheckZoomFig,'Value')
     2905    set(handles.CheckZoom,'value',0)
     2906end
     2907
     2908%------------------------------------------------------------------------
    29032909% --- Executes on button press in 'CheckFixLimits'.
    2904 %-------------------------------------------------------------------
     2910%------------------------------------------------------------------------
    29052911function CheckFixLimits_Callback(hObject, eventdata, handles)
    2906 test=get(handles.CheckFixLimits,'Value');
    2907 if test
    2908     set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
    2909 else
    2910     set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
     2912
     2913if ~get(handles.CheckFixLimits,'Value')
    29112914    update_plot(handles);
    29122915end
    29132916
    2914 %-------------------------------------------------------------------
     2917%------------------------------------------------------------------------
    29152918% --- Executes on button press in CheckFixAspectRatio.
    29162919function CheckFixAspectRatio_Callback(hObject, eventdata, handles)
    2917 %-------------------------------------------------------------------
     2920%------------------------------------------------------------------------
     2921
    29182922if get(handles.CheckFixAspectRatio,'Value')
    2919 %     set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0])
    29202923    update_plot(handles);
    29212924else
    2922 %     set(handles.CheckFixAspectRatio,'BackgroundColor',[0.7 0.7 0.7])
    29232925    update_plot(handles);
    29242926end
    29252927
    2926 %-------------------------------------------------------------------
     2928%------------------------------------------------------------------------
    29272929function num_AspectRatio_Callback(hObject, eventdata, handles)
    2928 %-------------------------------------------------------------------
     2930%------------------------------------------------------------------------
    29292931set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button
    2930 % set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0])% mark in yellow
    29312932update_plot(handles);
    2932 %-------------------------------------------------------------------
    2933 
    2934 %-------------------------------------------------------------------
    2935 
    2936 
    2937 
    2938 %-------------------------------------------------------------------
     2933
     2934%------------------------------------------------------------------------
    29392935%----Executes on button press in 'record': records the current flags of manual correction.
    2940 %-------------------------------------------------------------------
     2936%------------------------------------------------------------------------
    29412937function record_Callback(hObject, eventdata, handles)
    2942 % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
     2938
    29432939[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    29442940FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    2945 %FileName=read_file_boxes(handles);
    29462941[erread,message]=fileattrib(FileName);
    29472942if ~isempty(message) && ~isequal(message.UserWrite,1)
     
    32333228end
    32343229
    3235 %---------------------------------------------------
     3230%----------------------------------------------------------------
    32363231% --- Executes on menu selection FieldName
    32373232function FieldName_1_Callback(hObject, eventdata, handles)
     
    34523447
    34533448
    3454 %-----------------------------------------------------------------------
     3449%------------------------------------------------------------------------
    34553450% --- reset civ buttons
    34563451function reset_vel_type(handles_civ0,handle1)
    3457 %-----------------------------------------------------------------------
     3452%------------------------------------------------------------------------
    34583453for ibutton=1:length(handles_civ0)
    34593454    set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
     
    35463541yi=0.5:npy-0.5;
    35473542[Xi,Yi]=meshgrid(xi,yi);
    3548 if isfield(UvData,'Object')
    3549     for iobj=1:length(UvData.Object)
    3550         ObjectData=UvData.Object{iobj};
     3543if isfield(UvData,'ProjObject')
     3544    for iobj=1:length(UvData.ProjObject)
     3545        ObjectData=UvData.ProjObject{iobj};
    35513546        if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
    35523547            flagobj=1;
     
    36183613image(imflag);
    36193614
    3620 %-------------------------------------------------------------------
    3621 %-------------------------------------------------------------------
     3615%------------------------------------------------------------------------
     3616%------------------------------------------------------------------------
    36223617%  - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
    36233618
    3624 %------------------------------------------------------------------
    3625 %-------------------------------------------------------------
     3619%------------------------------------------------------------------------
     3620%------------------------------------------------------------------------
    36263621% --- Executes on selection change in TransformName.
    36273622
    36283623function TransformName_Callback(hObject, eventdata, handles)
    3629 %-------------------------------------------------------------
     3624%------------------------------------------------------------------------
    36303625UvData=get(handles.uvmat,'UserData');
    36313626menu=get(handles.TransformName,'String');refresh
     
    37493744        delete(hhh)
    37503745    end
    3751 %     if isfield(UvData,'Object')
    3752 %         UvData.Object=UvData.Object(1);
    3753 %     end
    37543746    set(handles.ListObject,'Value',1)
    37553747    set(handles.ListObject,'String',{''})
     
    37623754    set(handles.edit_object,'Value',0)
    37633755    edit_object_Callback(hObject, eventdata, handles)
    3764     UvData.Object={[]};
     3756    UvData.ProjObject={[]};
    37653757end
    37663758set(handles.uvmat,'UserData',UvData)
     
    39173909%------------------------------------------------------------------------
    39183910% --- Executes on selection change in CheckDecimate4 (nb_vec/4).
     3911%------------------------------------------------------------------------
    39193912function CheckDecimate4_Callback(hObject, eventdata, handles)
    3920 %------------------------------------------------------------------------
     3913
    39213914if isequal(get(handles.CheckDecimate4,'Value'),1)
    39223915    set(handles.CheckDecimate16,'Value',0)
     
    39263919%------------------------------------------------------------------------
    39273920% --- Executes on selection change in CheckDecimate16 (nb_vec/16).
     3921%------------------------------------------------------------------------
    39283922function CheckDecimate16_Callback(hObject, eventdata, handles)
    3929 %------------------------------------------------------------------------
     3923
    39303924if isequal(get(handles.CheckDecimate16,'Value'),1)
    39313925    set(handles.CheckDecimate4,'Value',0)
     
    41324126list_str=get(handles.ListObject,'String');
    41334127UvData=get(handles.uvmat,'UserData');
    4134 ObjectData=UvData.Object{get(handles.ListObject_1,'Value')};
     4128ObjectData=UvData.ProjObject{get(handles.ListObject_1,'Value')};
    41354129
    41364130%% update the projection plot on uvmat
     
    41394133%replot all the objects within the new projected field
    41404134for IndexObj=1:numel(list_str)
    4141         hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat;
     4135        hobject=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat;
    41424136        if isempty(hobject) || ~ishandle(hobject)
    41434137            hobject=handles.PlotAxes;
     
    41484142            objectcolor='b';
    41494143        end
    4150         UvData.Object{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.Object{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat     
     4144        UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.ProjObject{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat     
    41514145end
    41524146set(handles.uvmat,'UserData',UvData)
     
    41774171%% The object  is displayed in set_object if this GUI is already opened
    41784172UvData=get(handles.uvmat,'UserData');
    4179 ObjectData=UvData.Object{IndexObj};
     4173ObjectData=UvData.ProjObject{IndexObj};
    41804174hset_object=findobj(allchild(0),'tag','set_object');
    41814175if ~isempty(hset_object)
     
    42194213
    42204214%% update the color of the graphic object representation: the selected object in magenta, others in blue
    4221 update_object_color(handles.PlotAxes,hhview_field.PlotAxes,UvData.Object{IndexObj}.DisplayHandle.uvmat)
     4215update_object_color(handles.PlotAxes,hhview_field.PlotAxes,UvData.ProjObject{IndexObj}.DisplayHandle.uvmat)
    42224216
    42234217%------------------------------------------------------------------------
     
    43134307    list_object=get(handles.ListObject,'String');
    43144308    UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    4315     UvData.Object{IndexObj}.Name=list_object{IndexObj};
    4316     if numel(UvData.Object)<IndexObj;% error in UvData
     4309    UvData.ProjObject{IndexObj}.Name=list_object{IndexObj};
     4310    if numel(UvData.ProjObject)<IndexObj;% error in UvData
    43174311        msgbox_uvmat('ERROR','invalid object list')
    43184312        return
     
    43244318    end
    43254319%     set(handles.ListObject_1,'Value',IndexObj);%restore ListObject selection after set_object deletion
    4326     data=UvData.Object{IndexObj};
     4320    data=UvData.ProjObject{IndexObj};
    43274321    if ~isfield(data,'Type')% default plane
    43284322        data.Type='plane';
     
    43744368    IndexObj=get(handles.ListObject,'Value');
    43754369    UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    4376     if numel(UvData.Object)<IndexObj(end);% error in UvData
     4370    if numel(UvData.ProjObject)<IndexObj(end);% error in UvData
    43774371        msgbox_uvmat('ERROR','invalid object list')
    43784372        return
     
    43844378    end
    43854379    set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion
    4386     if ~isfield(UvData.Object{IndexObj(1)},'Type')% default plane
    4387         UvData.Object{IndexObj(1)}.Type='plane';
     4380    if ~isfield(UvData.ProjObject{IndexObj(1)},'Type')% default plane
     4381        UvData.ProjObject{IndexObj(1)}.Type='plane';
    43884382    end
    43894383    list_object=get(handles.ListObject,'String');
    4390     UvData.Object{IndexObj(end)}.Name=list_object{IndexObj(end)};
     4384    UvData.ProjObject{IndexObj(end)}.Name=list_object{IndexObj(end)};
    43914385   
    43924386    %% show the projection of the selected object on view_field
    4393     ProjData= proj_field(UvData.Field,UvData.Object{IndexObj});%project the current field on ObjectData
     4387    ProjData= proj_field(UvData.Field,UvData.ProjObject{IndexObj});%project the current field on ObjectData
    43944388    hview_field=findobj(allchild(0),'tag','view_field');
    43954389    if isempty(hview_field)
     
    44254419%------------------------------------------------------------------------
    44264420% --- Executes on button press in delete_object.
     4421%------------------------------------------------------------------------
    44274422function delete_object_Callback(hObject, eventdata, handles)
    4428 %------------------------------------------------------------------------
     4423
    44294424IndexObj=get(handles.ListObject,'Value');%projection object selected for view_field
    44304425IndexObj_1=get(handles.ListObject_1,'Value');%projection object selected for uvmat plot
    44314426if IndexObj>1 && ~isequal(IndexObj,IndexObj_1) % do not delete the object used for the uvmat plot
    44324427    delete_object(IndexObj)
     4428end
     4429
     4430%'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle
     4431%------------------------------------------------------------------------
     4432% function delete_object(hObject)
     4433%
     4434% INPUT:
     4435% hObject: object index (if integer) or handle of the graphic object. If
     4436%          hObject is a subobject, the parent object is detected and deleted.
     4437
     4438function delete_object(IndexObj)
     4439
     4440huvmat=findobj('tag','uvmat');%handles of the uvmat interface
     4441UvData=get(huvmat,'UserData');
     4442hlist_object=findobj(huvmat,'Tag','ListObject');%handles of the object list in the uvmat interface
     4443list_str=get(hlist_object,'String');%objet list
     4444% if isequal(floor(hObject),hObject) %case of an index
     4445    if  ~isempty(UvData) && isfield(UvData, 'ProjObject') && length(UvData.ProjObject)>=IndexObj
     4446        if isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat')
     4447            hdisplay=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat;
     4448            for iview=1:length(hdisplay)
     4449                if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
     4450                    ObjectData=get(hdisplay(iview),'UserData');
     4451                    if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject)
     4452                        delete(ObjectData.SubObject);
     4453                    end
     4454                    if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint)
     4455                        delete(ObjectData.DeformPoint);
     4456                    end
     4457                    delete(hdisplay(iview))
     4458                end
     4459                ishandle(hdisplay(iview))
     4460            end
     4461            for iobj=IndexObj+1:length(UvData.ProjObject)
     4462                hdisplay=UvData.ProjObject{iobj}.DisplayHandle.uvmat;
     4463                for iview=1:length(hdisplay)
     4464                    if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
     4465                        PlotData=get(hdisplay(iview),'UserData');
     4466                        PlotData.IndexObj=iobj-1;
     4467                        set(hdisplay(iview),'UserData',PlotData);
     4468                    end
     4469                end
     4470            end
     4471        end
     4472        UvData.ProjObject(IndexObj)=[]; 
     4473        if ~isempty(list_str)
     4474            list_str(IndexObj)=[];
     4475        end
     4476    end
     4477% elseif ishandle(hObject)%object handle
     4478%     userdata=get(hObject,'UserData');
     4479%     if ishandle(userdata)%the selected line depends on a parent line
     4480%         hdisplay=userdata;% the parent object becomes the current one
     4481%     else
     4482%         hdisplay=hObject;% the selected object becomes the current one
     4483%     end
     4484%     PlotData=get(hdisplay,'UserData');
     4485%     if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject)
     4486%             delete(PlotData.SubObject);
     4487%     end
     4488%     if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint)
     4489%            delete(PlotData.DeformPoint);
     4490%     end
     4491%     delete(hdisplay);
     4492%     if isfield(PlotData,'IndexObj')
     4493%         IndexObj=PlotData.IndexObj;
     4494%         if  isequal(round(IndexObj),IndexObj) & IndexObj>=1 & length(list_str) > IndexObj
     4495%             if isfield(UvData,'ProjObject')& length(UvData.ProjObject) > IndexObj
     4496%                UvData.ProjObject(IndexObj)=[];
     4497%             end
     4498%             list_str(IndexObj)=[];
     4499%         end
     4500%     end
     4501% end
     4502set(huvmat,'UserData',UvData);
     4503set(hlist_object,'String',list_str)
     4504set(hlist_object,'Value',length(list_str))
     4505hlist_object_1=findobj(huvmat,'Tag','ListObject_1');%handles of the first object list in the uvmat interface
     4506old_index=get(hlist_object_1,'Value');
     4507set(hlist_object_1,'String',list_str)
     4508if IndexObj<=old_index
     4509    set(hlist_object_1,'Value',old_index-1)
    44334510end
    44344511
     
    45994676aviobj=close(aviobj);
    46004677UvData=rmfield(UvData,'plotaxes');
    4601 %UvData.Object{1}.plotaxes=handles.PlotAxes;
    46024678set(huvmat,'UserData',UvData);
    46034679msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
     
    46884764function create_object(data,handles)
    46894765%------------------------------------------------------------------------
    4690 % desactivate geometric calibration if opened
    4691 hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
     4766%% desactivate concurrent tools
     4767hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');% search the GUI geometric calibration
    46924768if ishandle(hgeometry_calib)
    46934769    hhgeometry_calib=guidata(hgeometry_calib);
    46944770    set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
    4695     set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
    4696 end
    4697 set(handles.edit_object,'Value',0); %suppress the object edit mode
    4698 set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
     4771end
     4772set(handles.edit_object,'Value',0)  %desactivate the object edit mode
     4773set(handles.CheckZoomFig,'Value',0) %desactivate zoom sub fig
     4774set(handles.CheckZoom,'Value',0)    %desactivate the zoom action
     4775if ishandle(handles.UVMAT_title)
     4776    delete(handles.UVMAT_title)     %delete the initial display of uvmat if no field has been entered yet
     4777end
     4778
     4779%% append a new line to the list of projection objects
    46994780ListObject=get(handles.ListObject,'String');
    47004781if isempty(ListObject)
     
    47084789set(handles.ListObject,'Value',IndexObj)
    47094790UvData=get(handles.uvmat,'UserData');
    4710 UvData.Object{IndexObj}=[]; %create a new empty object
    4711 UvData.Object{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object
    4712 UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
     4791UvData.ProjObject{IndexObj}=[]; %create a new empty object
     4792UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object
     4793UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
     4794set(handles.uvmat,'UserData',UvData)
     4795
     4796%% initiate the new projection object
    47134797data.Name=data.Type;% default name=type
    47144798data.Coord=[0 0]; %default
     
    47244808        data.DX=UvData.Field.CoordMesh;
    47254809        data.DY=UvData.Field.CoordMesh;
     4810        if strcmp(data.Type,'rectangle')||strcmp(data.Type,'ellipse')
     4811            data.RangeX=UvData.Field.CoordMesh;
     4812            data.RangeY=UvData.Field.CoordMesh;
     4813        end
    47264814    end
    47274815    if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
     
    47324820    end
    47334821end
    4734 if ishandle(handles.UVMAT_title)
    4735     delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
    4736 end
    4737 hset_object=set_object(data,handles);% call the set_object interface
    4738 hhset_object=guidata(hset_object);
     4822hset_object=set_object(data,handles);% call the GUI set_object
    47394823hchild=get(hset_object,'children');
    47404824set(hchild,'enable','on')
    4741 set(handles.uvmat,'UserData',UvData)
    4742 set(handles.CheckZoom,'Value',0) %desactivate the zoom for object creation by the mouse
    4743 CheckZoom_Callback(handles.uvmat, [], handles)
     4825
     4826
    47444827set(handles.delete_object,'Visible','on')
    47454828
     
    47714854
    47724855UvData=get(handles.uvmat,'UserData');
    4773 UvData.Object{IndexObj}=[]; %create a new empty object
    4774 UvData.Object{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation
    4775 UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
     4856UvData.ProjObject{IndexObj}=[]; %create a new empty object
     4857UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation
     4858UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
    47764859set(handles.uvmat,'UserData',UvData)
    47774860set(handles.ListObject,'Value',IndexObj)
     
    48424925
    48434926%% read lines currently drawn
    4844 ListObj=UvData.Object;
     4927ListObj=UvData.ProjObject;
    48454928select=zeros(1,numel(ListObj));
    48464929for iobj=1:numel(ListObj);
     
    48554938else
    48564939    set(handles.ListObject,'Value',val);% show the selected lines on the list
    4857     ObjectData=UvData.Object(val);
     4940    ObjectData=UvData.ProjObject(val);
    48584941    for iobj=1:length(ObjectData)
    48594942%         if isfield(ObjectData{iobj},'Coord')
     
    49625045%------------------------------------------------------------------------
    49635046UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    4964 ListObj=UvData.Object;
     5047ListObj=UvData.ProjObject;
    49655048select=zeros(1,numel(ListObj));
    49665049for iobj=1:numel(ListObj);
     
    49815064    yi=0.5:npy-0.5;
    49825065    [Xi,Yi]=meshgrid(xi,yi);
    4983 %     if isfield(UvData,'Object')
    4984         for iobj=1:length(UvData.Object)
    4985             ObjectData=UvData.Object{iobj};
     5066        for iobj=1:length(UvData.ProjObject)
     5067            ObjectData=UvData.ProjObject{iobj};
    49865068            if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
    49875069                flagobj=1;
     
    53075389
    53085390
    5309 % --- Executes on button press in CheckZoomFig.
    5310 function CheckZoomFig_Callback(hObject, eventdata, handles)
    5311 % hObject    handle to CheckZoomFig (see GCBO)
    5312 % eventdata  reserved - to be defined in a future version of MATLAB
    5313 % handles    structure with handles and user data (see GUIDATA)
    5314 
    5315 % Hint: get(hObject,'Value') returns toggle state of CheckZoomFig
  • trunk/src/view_field.m

    r612 r622  
    363363% set(handles.RunMovie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
    364364
    365 
    366 %-------------------------------------------------------------------
     365%------------------------------------------------------------------------
    367366% --- translate coordinate to matrix index
    368 %-------------------------------------------------------------------
     367%------------------------------------------------------------------------
    369368function [indx,indy]=pos2ind(x0,rangx0,nxy)
    370369indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel 
    371370indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
    372371
    373 %-------------------------------------------------------------------
    374 % --- Executes on button press in 'zoom'.
    375 %-------------------------------------------------------------------
     372%------------------------------------------------------------------------
     373% --- Executes on button press in 'CheckZoom'.
     374%------------------------------------------------------------------------
    376375function CheckZoom_Callback(hObject, eventdata, handles)
    377 if (get(handles.CheckZoom,'Value') == 1);
    378     set(handles.CheckZoom,'BackgroundColor',[1 1 0])
     376
     377if get(handles.CheckZoom,'Value')
    379378    set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes
    380     set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
    381 else
    382     set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
     379    set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig
     380end
     381
     382%------------------------------------------------------------------------
     383% --- Executes on button press in CheckZoomFig.
     384%------------------------------------------------------------------------
     385function CheckZoomFig_Callback(hObject, eventdata, handles)
     386
     387if get(handles.CheckZoomFig,'Value')
     388    set(handles.CheckZoom,'value',0)
    383389end
    384390
     
    839845% % eventdata  reserved - to be defined in a future version of MATLAB
    840846% % handles    structure with handles and user data (see GUIDATA)
     847
     848
     849
     850
Note: See TracChangeset for help on using the changeset viewer.