Changeset 625


Ignore:
Timestamp:
May 2, 2013, 7:51:42 PM (8 years ago)
Author:
sommeria
Message:

system of object creation by mouse ilmproved

Location:
trunk/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/check_files.m

    r623 r625  
    4343    'civ_3D.fig';...
    4444    'civ_matlab';...% civ programs, Matlab version (called by civ.m, option Civprogram/Matlab in the upper menu bar)
    45     'close_fig';...% function  activated when a figure is closed
    4645    'copyfields';...% copy fields between two matlab structures
    4746    'create_grid';...% called by the GUI geometry_calib to create a physical grid
  • trunk/src/keyboard_callback.m

    r622 r625  
    33function keyboard_callback(hObject,eventdata,handleshaxes)
    44cur_axes=get(hObject,'CurrentAxes');%current plotting axes of the figure with handle hObject
    5 if ~isempty(eventdata) && isnumeric(eventdata)
    6     xx=eventdata; % keyboard_callback called by mouse_down
    7 else
    85xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
    9 end
    106switch xx
    117    case {29,28,30,31}    %arrows for displacement
     8        AxeData=get(cur_axes,'UserData');
     9        if isfield(AxeData,'ZoomAxes')&&ishandle(AxeData.ZoomAxes)
     10           cur_axes=AxeData.ZoomAxes;% move the field of the zoom sub-plot instead of the main axes  if it exsits
     11           axes(cur_axes)
     12        end
    1213        if ~isempty(cur_axes)
    1314            xlimit=get(cur_axes,'XLim');
     
    3334                rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)];
    3435                set(hparentrect,'Position',rect)
    35                 hfig=get(hparentrect,'parent');
    36                 hfig=get(hfig,'parent');
    3736            elseif isfield(AxeData,'LimEditBox')&& isequal(AxeData.LimEditBox,1)% update display of the GUI containing the axis (uvmat or view_field)
    3837                hh=guidata(hfig);
  • trunk/src/mouse_down.m

    r623 r625  
    2828FigData=get(hObject,'UserData'); %default data stored on the current object
    2929if 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
    30     hcurrentfig=get(get(FigData,'parent'),'parent');%handle of the current GUI: zoom plot
     30    hCurrentGUI=get(get(FigData,'parent'),'parent');%handle of the current GUI: zoom plot
    3131else
    32     hcurrentfig=hObject; % handle of the current GUI: usual plot
    33 end
    34 hhcurrentfig=guidata(hcurrentfig);% tags of the children of the current GUI
     32    hCurrentGUI=hObject; % handle of the current GUI: usual plot
     33end
     34hhCurrentGUI=guidata(hCurrentGUI);% tags of the children of the current GUI
    3535CheckZoom=0;
    36 if isfield(hhcurrentfig,'CheckZoom') && get(hhcurrentfig.CheckZoom,'Value');%test for zoom action, first priority
     36if isfield(hhCurrentGUI,'CheckZoom') && get(hhCurrentGUI.CheckZoom,'Value');%test for zoom action, first priority
    3737    CheckZoom=1;
    3838end
    3939test_piv=isfield(FigData,'CivHandle');
    40 set(hcurrentfig,'Units','pixels')
    41 GUI_pos=get(hcurrentfig,'Position');%position of the GUI series on the screen (in pixels), used to position message boxes
    42 set(hcurrentfig,'Units','normalized')% back to current unit for fig position
     40set(hCurrentGUI,'Units','pixels')
     41GUI_pos=get(hCurrentGUI,'Position');%position of the GUI series on the screen (in pixels), used to position message boxes
     42set(hCurrentGUI,'Units','normalized')% back to current unit for fig position
    4343
    4444%% determine the currently selected items
    4545hcurrentobject=gco;% current object handle (selected by the mouse)
    46 fig_tag=get(hcurrentfig,'Tag');
     46CurrentGUI_tag=get(hCurrentGUI,'Tag');
    4747obj_tag=get(gco,'Tag');%tag of the currently selected object
    4848xy=[];%default
     
    6363    if ~isempty(hset_object)
    6464        hPLOT=findobj(hset_object,'tag','PLOT');
    65         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'
     65        test_create=strcmp(get(hPLOT,'enable'),'on') &&~get(hhuvmat.edit_object,'Value');% create new object if set_object is in mode enable and uvmat not in mode 'edit_object'
    6666    end
    6767    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
     
    8181%% loop on all the objects in the current figure (selected by the last mouse click)
    8282hchildren=get(hObject,'Children');%handles of all objects in the current figure
    83 check_visible=strcmp(get(hchildren,'Visible'),'on');% if visible='on', =0 otherwise
    84 hchildren=hchildren(check_visible); %kkep only the visible children
     83check_visible=strcmp(get(hchildren,'Visible'),'on')& ~strcmp(get(hchildren,'Type'),'uimenu');% if visible='on', =0 otherwise
     84hchildren=hchildren(check_visible); %keep only the visible children
     85set(hchildren,'Units','normalized');
    8586PosChildren=get(hchildren,'Position');% set of object positions
    8687if iscell(PosChildren)% only one child
     
    9697ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse
    9798hchild=hchildren(ind_object);% corresponding object handle
    98 if 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
    114 else
     99if ~isempty(hchild)
    115100    htype=get(hchild,'Type');%type of object child of the current figure
    116101    switch htype
     
    129114            if test_edit_vect
    130115                ivec=[];
    131                 FigData=get(hcurrentfig,'UserData');
     116                FigData=get(hCurrentGUI,'UserData');
    132117                tagaxes=get(hchild,'tag');
    133118                if isfield(FigData,tagaxes)
     
    200185
    201186%% creation of a zoom subfig
    202 if isfield(hhcurrentfig,'CheckZoomFig') && get(hhcurrentfig.CheckZoomFig,'Value')
     187if isfield(hhCurrentGUI,'CheckZoomFig') && get(hhCurrentGUI.CheckZoomFig,'Value')
    203188    AxeData.Drawing='zoom'; %initiate drawing mode
    204189    AxeData.CurrentObject=[];%unselect objects
     
    212197
    213198%% ruler has second priority
    214 if test_ruler
     199if test_ruler && ~isempty(xy)
    215200    AxeData.RulerCoord(1,1:2)=xy(1,1:2);
    216201    AxeData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler');
     
    287272            IndexObj=ObjectData.IndexObj;
    288273                    %indicate on the list of the GUI uvmat which object has been selected
    289             if strcmp(get(hcurrentfig,'tag'),'uvmat') %if the uvmat graph has been selected, object projection is on the other frame view_field
     274            if strcmp(get(hCurrentGUI,'tag'),'uvmat') %if the uvmat graph has been selected, object projection is on the other frame view_field
    290275%                 IndexObj=get(hhuvmat.ListObject,'Value');
    291276%                 if IndexObj>IndexObj_old(1)
     
    331316
    332317%%  create  projection  object
    333 if  test_create && ~isempty(xy)
     318if  test_create && ~isempty(xy) && ~strcmp(get(hCurrentGUI,'SelectionType'),'alt')
    334319    % activate this option if the GUI set_object is opened
    335     if ~isempty(hset_object) && ~strcmp(get(hcurrentfig,'SelectionType'),'alt')
    336         sethandles=guidata(hset_object);% handles of the elements in the GUI set_object
    337         ObjectData=read_GUI(hset_object); %read object parameters in the GUI set_object
    338         IndexObj=length(UvData.ProjObject);
    339         %initiate a new object (no data .Coord yet recorded)
    340         if ~isfield(UvData.ProjObject{IndexObj},'Coord');
    341             ObjectData.Coord=[];
    342             ObjectNameNew=ObjectData.Name;
    343             if isempty(ObjectNameNew)
    344                 ObjectNameNew=ObjectData.Type;
    345             end
    346             % add an index to the object name if the proposed name already exists
    347             vers=0;% index of the name
    348             ListObject=get(hhuvmat.ListObject,'String');
    349             detectname=1;
    350             while ~isempty(detectname)
    351                 detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
    352                 if detectname% if the object name already exists
    353                     indstr=regexp(ObjectNameNew,'\D');
    354                     if indstr(end)<length(ObjectNameNew) %object name ends by a number
    355                         vers=str2double(ObjectNameNew(indstr(end)+1:end))+1;
    356                         ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)];
    357                     else
    358                         vers=vers+1;
    359                         ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];
    360                     end
     320    sethandles=guidata(hset_object);% handles of the elements in the GUI set_object
     321    ObjectData=read_GUI(hset_object); %read object parameters in the GUI set_object
     322    IndexObj=length(UvData.ProjObject);
     323    % if the currently selected object is already finished, a new object is initiated
     324    if ~isfield(UvData.ProjObject{IndexObj},'CreateMode')
     325        IndexObj=IndexObj+1;%start new object
     326        ObjectData.Coord=[];
     327        ObjectNameNew=ObjectData.Name;
     328        if isempty(ObjectNameNew)
     329            ObjectNameNew=ObjectData.Type;
     330        end
     331        % add an index to the object name if the proposed name already exists
     332        vers=0;% index of the name
     333        ListObject=get(hhuvmat.ListObject,'String');
     334        detectname=1;
     335        while ~isempty(detectname)
     336            detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
     337            if detectname% if the object name already exists
     338                indstr=regexp(ObjectNameNew,'\D');
     339                if indstr(end)<length(ObjectNameNew) %object name ends by a number
     340                    vers=str2double(ObjectNameNew(indstr(end)+1:end))+1;
     341                    ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)];
     342                else
     343                    vers=vers+1;
     344                    ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];
    361345                end
    362346            end
    363             ObjectName=ObjectNameNew;
    364             set(sethandles.Name,'String',ObjectName)% display the default name in set_object
    365             if isempty(ListObject)
    366                 ListObject={ObjectName};
    367             else
    368                 ListObject{end}=ObjectName;
    369             end
    370             set(hhuvmat.ListObject,'String',ListObject);%complement the object list
    371             set(hhuvmat.ListObject_1,'String',ListObject);%complement the object list
     347        end
     348        ObjectName=ObjectNameNew;
     349        set(sethandles.Name,'String',ObjectName)% display the default name in set_object
     350        ListObject=[ListObject;{ObjectName}];
     351        set(hhuvmat.ListObject,'String',ListObject);%complement the object list
     352        set(hhuvmat.ListObject_1,'String',ListObject);%complement the object list
     353        if strcmp(CurrentGUI_tag,'uvmat')
    372354            set(hhuvmat.ListObject,'Value',IndexObj)
    373             set(hhuvmat.ViewObject,'Value',1)
    374         end
    375         ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the coordinates marked by the mouse to the object
    376                                                          %TODO replace 0 by z coord for 3D       
    377         hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(fig_tag);
    378         if isempty(hobject)
    379             hobject=haxes;
    380         end
     355        else
     356            set(hhuvmat.ListObject_1,'Value',IndexObj)
     357        end
     358        UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; % axes for plot_object
     359        UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
     360        set(hhuvmat.ViewObject,'Value',1)
     361    end
     362    ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the coordinates marked by the mouse to the object
     363    %TODO replace 0 by z coord for 3D
     364    hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(CurrentGUI_tag);
     365    if isempty(hobject)
     366        hobject=haxes;
     367    end
     368    if strcmp(CurrentGUI_tag,'uvmat')
    381369        ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')};
    382         AxeData.CurrentObject=plot_object(ObjectData,ProjObject,hobject,'m');%draw the object and its handle becomes 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
    385         set(huvmat,'UserData',UvData)
    386         PlotData=get(AxeData.CurrentObject,'UserData');
    387         PlotData.IndexObj=IndexObj;
    388         set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph (memory used for mouse motion)
    389         AxeData.Drawing='create';% flag for mouse motion
    390         %show object coordinates in the GUI set_object
    391         h_set_object=findobj(allchild(0),'Tag','set_object');
    392         hh_set_object=guidata(h_set_object);
    393         set(hh_set_object.Coord,'Data',ObjectData.Coord);
    394     end
     370    else
     371        ProjObject=UvData.ProjObject{get(hhuvmat.ListObject,'Value')};
     372    end
     373    AxeData.CurrentObject=plot_object(ObjectData,ProjObject,hobject,'m');%draw the object and its handle becomes AxeData.CurrentObject
     374    UvData.ProjObject{IndexObj}=ObjectData;
     375    UvData.ProjObject{IndexObj}.DisplayHandle.(CurrentGUI_tag)=AxeData.CurrentObject;% attribute the current plot object handle to the Object
     376    UvData.ProjObject{IndexObj}.CreateMode='on';% mark the object as in the course of creation
     377    set(huvmat,'UserData',UvData)
     378    PlotData=get(AxeData.CurrentObject,'UserData');
     379    PlotData.IndexObj=IndexObj;
     380    set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph (memory used for mouse motion)
     381    AxeData.Drawing='create';% flag for mouse motion
     382   
     383   
     384    %initiate a new object (no data .Coord yet recorded)
     385    %if ~isfield(UvData.ProjObject{IndexObj},'Coord');
     386    %     ObjectData.Coord=[];
     387   
     388    %             if isempty(ListObject)
     389    %                 ListObject={ObjectName};
     390    %             else
     391    %                 ListObject{end}=ObjectName;
     392    %             end
     393    %                 UvData.ProjObject{IndexObj}=[]; %create a new empty object
     394    %     UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; % axes for plot_object
     395    %     UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
     396   
     397    %         PlotData=get(AxeData.CurrentObject,'UserData');
     398    %         PlotData.IndexObj=IndexObj;
     399    %         set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph (memory used for mouse motion)
     400    %         AxeData.Drawing='create';% flag for mouse motion
     401    %show object coordinates in the GUI set_object
     402    h_set_object=findobj(allchild(0),'Tag','set_object');
     403    hh_set_object=guidata(h_set_object);
     404    set(hh_set_object.Coord,'Data',ObjectData.Coord);
    395405end
    396406
     
    475485        Field.FF(ivec)=0;
    476486    end
    477     PlotParam=read_GUI(hcurrentfig);
     487    PlotParam=read_GUI(hCurrentGUI);
    478488    plot_field(Field,haxes,PlotParam);
    479489    eval(['FigData.' tagaxes '=Field;'])%record the modified field in FigData
    480     set(hcurrentfig,'UserData',FigData);
     490    set(hCurrentGUI,'UserData',FigData);
    481491end 
    482492set(haxes,'UserData',AxeData);
  • trunk/src/mouse_motion.m

    r622 r625  
    3030FigData=get(hObject,'UserData');
    3131if 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
    32     CurrentFig=get(get(FigData,'parent'),'parent');
     32    hCurrentFig=get(get(FigData,'parent'),'parent');
    3333else
    34     CurrentFig=hObject;%usual plot
    35 end
    36 hhCurrentFig=guidata(CurrentFig);%handles of the elements in the GUI containing the current figure (uvmat or view_field)
     34    hCurrentFig=hObject;%usual plot
     35end
     36hhCurrentFig=guidata(hCurrentFig);%handles of the elements in the GUI containing the current figure (uvmat or view_field)
    3737CheckZoom=get(hhCurrentFig.CheckZoom,'Value');% check for zoom on mode
    3838CheckZoomFig=get(hhCurrentFig.CheckZoomFig,'Value');% check for zoom sub fig creation mode
     39hPlotAxes=hhCurrentFig.PlotAxes';% handles of the main plot axes
     40AxeData=get(hPlotAxes,'UserData');% data attached to the axis
     41test_draw=0;%test for mouse drawing of object, =0 by default
     42if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing)
     43    test_draw=~isequal(AxeData.Drawing,'off');%=1 if mouse drawing of object is active
     44end
    3945test_zoom_draw=0;
    40 test_draw=0;%test for mouse drawing of object, =0 by default
    4146test_object=0; %test for object editing or creation
    4247test_edit_object=0;% edit test for mouse shap: an arrow
     
    6469text_displ_4='';
    6570
    66 AxeData=[];%default
     71% AxeData=[];%default
    6772xy=[];%default
    6873xy_fig=get(hObject,'CurrentPoint');% current point of the current figure (gcbo)
     
    9297    CurrentAxes=hchild;
    9398    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
    9899    test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal');
    99100    test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject);
    100     %if ~test_edit_object && ~test_zoom_draw && ~test_ruler
    101101    if ~test_edit_object  && ~test_ruler && ~CheckZoom
    102102        pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
    103103    end
    104     FigData=get(CurrentFig,'UserData');
     104    FigData=get(hCurrentFig,'UserData');
    105105    tagaxes=get(CurrentAxes,'tag');
    106106    if isfield(FigData,tagaxes)
     
    130130                                pointershape='arrow'; %mouse indicates  the detection of a vector
    131131                                if isempty(hhh)
    132                                     set(0,'CurrentFigure',CurrentFig)
    133                                     set(CurrentFig,'CurrentAxes',CurrentAxes)
     132                                    set(0,'CurrentFigure',hCurrentFig)
     133                                    set(hCurrentFig,'CurrentAxes',CurrentAxes)
    134134                                    rectangle('Curvature',[1 1],...
    135135                                        'Position',[X(ivec)-Field.CoordMesh/2 Y(ivec)-Field.CoordMesh/2 Field.CoordMesh Field.CoordMesh],'EdgeColor','m',...
     
    232232                hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker');
    233233                if isempty(hhh)
    234                     set(0,'CurrentFigure',CurrentFig)
    235                     set(CurrentFig,'CurrentAxes',CurrentAxes)
     234                    set(0,'CurrentFigure',hCurrentFig)
     235                    set(hCurrentFig,'CurrentAxes',CurrentAxes)
    236236                    rectangle('Curvature',[0 0],...
    237237                        'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',...
     
    420420
    421421%% update the mouse pointer
    422 set(CurrentFig,'Pointer',pointershape);
     422set(hCurrentFig,'Pointer',pointershape);
  • trunk/src/mouse_up.m

    r623 r625  
    2525
    2626test_ruler=0;%default
    27 hcurrentfig=hObject;
    28 fig_tag=get(hcurrentfig,'tag');
    29 currentaxes=gca; %store the current axes handle
    30 AxeData=get(currentaxes,'UserData');
     27AxeData=get(gca,'UserData');
     28if isfield(AxeData,'ParentAxes')% case of a zoom plot as current axis
     29    hcurrentaxes=AxeData.ParentAxes;
     30    AxeData=get(hcurrentaxes,'UserData');
     31    hcurrentfig=get(hcurrentaxes,'parent');%handles of the GUI parent of the zoom plot
     32    testsubplot=1;% mouse selection is on a zoom subplot
     33else
     34    hcurrentfig=hObject;
     35    hcurrentaxes=gca; %store the current axes handle
     36    testsubplot=0;
     37end
    3138CurrentOrigin=[];
    3239if isfield(AxeData,'CurrentOrigin')
    3340    CurrentOrigin=AxeData.CurrentOrigin;
    3441end
    35 if isfield(AxeData,'ParentRect')% case of a zoom plot as current axis
    36     parentaxes=get(AxeData.ParentRect,'parent');
    37     AxeData=get(parentaxes,'UserData');
    38     controlGUI=get(parentaxes,'parent');%handles of the GUI parent of the zoom plot
    39     hhcurrentfig=guidata(controlGUI);
    40     testsubplot=1;
    41 else
    42     hhcurrentfig=guidata(hcurrentfig);%the current figure is a GUI (uvmat or view_field)
    43     testsubplot=0;
    44 end
    45 test_zoom=get(hhcurrentfig.CheckZoom,'Value');
    46 
     42FigTag=get(hcurrentfig,'tag');
     43hhcurrentfig=guidata(hcurrentfig);%the current figure is a GUI (uvmat or view_field)
     44CheckZoom=get(hhcurrentfig.CheckZoom,'Value');
     45CheckZoomFig=get(hhcurrentfig.CheckZoomFig,'Value');%exclusive to CheckZoom
    4746huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle
    4847if ~isempty(huvmat)
    4948    hhuvmat=guidata(huvmat);
    5049    UvData=get(huvmat,'UserData');
    51    test_ruler=~test_zoom && isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler  action, second priority
    52 end
    53 test_drawing=0;%default
    54 
    55 %% finalize the fabrication or the translation/deformation of an object and plot the corresponding projected field
     50   test_ruler=~CheckZoom && isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler  action, second priority
     51end
     52test_drawing=0;%default, =1 to allow drawing by further mouse action
     53xy=get(gca,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     54
     55
     56%% proceed with the creation or editing (translation/deformation) of an object
    5657if ~isempty(huvmat) && isfield(AxeData,'Drawing') && ~isequal(AxeData.Drawing,'off') && isfield(AxeData,'CurrentObject')...
    5758        && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject)
    58     xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     59    %     xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    5960    PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object
    6061    IndexObj=PlotData.IndexObj;
    6162    ObjectData=UvData.ProjObject{IndexObj};
    6263    check_multiple=0;
     64   
     65    h_set_object=findobj(allchild(0),'Tag','set_object');
     66    hh_set_object=guidata(h_set_object);
     67    ObjectData.Coord=get(hh_set_object.Coord,'Data');
     68   
    6369    % ending translation
    6470    if isequal(AxeData.Drawing,'translate')
     
    6975        ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
    7076       
    71     %ending object deformation
     77        %ending object deformation
    7278    elseif isequal(AxeData.Drawing,'deform')
    7379        ind_move=AxeData.CurrentIndex;
     
    7581        ObjectData.Coord(ind_move,2)=xy(1,2);
    7682       
    77     %creating object
     83        %creating object
    7884    else
    7985        switch ObjectData.Type
     
    8591                end
    8692            case {'rectangle','ellipse','volume'}
    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     
     93                %                  if size(ObjectData.Coord,1)==1 % this is the mouse up for the first point, continue until next click
     94                %                     check_multiple=1;
     95                %                  else
     96                ObjectData.Coord=(CurrentOrigin+xy(1,1:2))/2;% keep only the first point coordinate
    9197                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   
     98                ObjectData.RangeY=abs(ObjectData.Coord(1,2)-xy(1,2));%rectangle height
    9399                if isequal(ObjectData.RangeX,0)||isequal(ObjectData.RangeY,0)
    94100                    check_multiple=1;% pass to next mous up if width of height=0
    95101                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
     102                %                 ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
     103                %                 ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
     104                %                 ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
     105                %                 ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
     106                %                  end
    101107            case 'plane' %case of 'plane'
    102108                DX=(xy(1,1)-ObjectData.Coord(1,1));
     
    110116                end
    111117            otherwise
    112                 check_multiple=1; 
     118                check_multiple=1;
    113119        end
    114120    end
    115121   
    116122    %show object coordinates in the GUI set_object
    117     h_set_object=findobj(allchild(0),'Tag','set_object');
    118     hh_set_object=guidata(h_set_object);
    119     set(hh_set_object.Coord,'Data',ObjectData.Coord);
     123    %     h_set_object=findobj(allchild(0),'Tag','set_object');
     124    %     hh_set_object=guidata(h_set_object);
     125    %     set(hh_set_object.Coord,'Data',ObjectData.Coord);
    120126    if strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')
    121127        set(hh_set_object.num_RangeX_2,'String',num2str(ObjectData.RangeX,4));
    122128        set(hh_set_object.num_RangeY_2,'String',num2str(ObjectData.RangeY,4));
    123129    end
    124 
    125     %stop drawing and plot projected field if the object manipulation is finished
     130   
     131    %% stop drawing and plot the projected field if the object manipulation is finished
    126132    if check_multiple==0  || isequal(get(hcurrentfig,'SelectionType'),'alt')
    127133        AxeData.CurrentOrigin=[]; %suppress the current origin
    128         hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(fig_tag);
     134        hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(FigTag);
    129135        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
     136            ProjObject=UvData.ProjObject{get(hhuvmat.ListObject_1,'Value')};
     137            AxeData.CurrentObject=plot_object(ObjectData,ProjObject,hobject,'m');%draw the object and its handle becomes AxeData.CurrentObject
    132138        end
    133139        %%
     
    136142            ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
    137143            if ~isempty(ProjData)
    138                 if strcmp(fig_tag,'uvmat')% uvmat plot selected, projection plot seen in view_field
     144                if strcmp(FigTag,'uvmat')% uvmat plot selected, projection plot seen in view_field
    139145                    hview_field=findobj(allchild(0),'tag','view_field');
    140146                    if isempty(hview_field)
     
    159165                else
    160166                    UvData.PlotAxes=ProjData;
    161                     [PlotType,PlotParam]=plot_field(ProjData,hhuvmat.PlotAxes,read_GUI(hhuvmat));%update an existing field plot
     167                    [PlotType,PlotParam]=plot_field(ProjData,hhuvmat.PlotAxes,read_GUI(huvmat));%update an existing field plot
    162168                    errormsg=fill_GUI(PlotParam,huvmat);
    163169                end
    164170            end
    165171            set(hhuvmat.ViewField,'Value',1);%
    166             set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
    167             set(hhuvmat.edit_object,'Value',1);%
     172            set(hhuvmat.edit_object,'Value',1);%           
    168173            set(hhuvmat.edit_object,'Enable','on');%
    169174            set(hhuvmat.MenuEditObject,'Enable','on');%
    170175            set(hhuvmat.MenuEdit,'Enable','on');%
     176            set(get(h_set_object,'children'),'Enable','on')
     177        end
     178        UvData.ProjObject{IndexObj}=ObjectData;
     179        if isfield(UvData.ProjObject{IndexObj},'CreateMode')
     180            UvData.ProjObject{IndexObj}=rmfield(UvData.ProjObject{IndexObj},'CreateMode');%remove createMode to mark the object as finished
    171181        end
    172182    else
    173 %         test_drawing=1;%allow continuation of drawing object
    174         AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the next current origin
    175     end
    176     UvData.ProjObject{IndexObj}=ObjectData;
     183        test_drawing=1;%allow continuation of drawing object
     184        AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the next current origin
     185    end
     186    %     UvData.ProjObject{IndexObj}=ObjectData;
    177187    hother=findobj('Tag','deformpoint');%find all the deformpoints
    178188    set(hother,'Color','b');%reset all the deformpoints in 'blue'
    179189end
    180190
    181 %% creation of a new zoom plot
    182 if isequal(get(hcurrentfig,'SelectionType'),'normal');%if left button has been pressed
     191%% creation or update of a  zoom sub-plot
     192if CheckZoomFig && isequal(get(hcurrentfig,'SelectionType'),'normal')&&...%if left button has been pressed
     193     ~isempty(CurrentOrigin) && ~isequal(CurrentOrigin(1),xy(1,1)) && ~isequal(CurrentOrigin(2),xy(1,2))%if mouse moved in x and y since presed down
    183194    hparentfig=hcurrentfig;
    184195    %open or update a new zoom figure if a rectangle has been drawn
    185     if ishandle(currentaxes);
     196    if ishandle(hcurrentaxes);
    186197        if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)
    187             PosRect=get(AxeData.CurrentRectZoom,'Position');
     198            %PosRect=get(AxeData.CurrentRectZoom,'Position');
    188199            if isfield(AxeData,'CurrentVec') && ~isempty(AxeData.CurrentVec) && ishandle(AxeData.CurrentVec)
    189200                delete(AxeData.CurrentVec)
    190201            end
    191             if ~testsubplot
    192                 hfig2=figure;%create new figure
    193                 set(hfig2,'name','zoom')
    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);
    202                 map=colormap(currentaxes);
    203                 colormap(map);%transmit the current colormap to the zoom fig
    204                 set(hfig2,'KeyPressFcn',{@keyboard_callback,handles})%set keyboard action function
    205                 set(hfig2,'WindowButtonMotionFcn',{@mouse_motion,handles})%set mouse action function
    206                 set(hfig2,'WindowButtonDownFcn',{@mouse_down})%set mouse click action function
    207                 set(hfig2,'WindowButtonUpFcn',{@mouse_up,handles})
    208                 set(hfig2,'DeleteFcn',{@close_fig,AxeData.CurrentRectZoom,'zoom'})
    209                 set(hfig2,'UserData',AxeData.CurrentRectZoom)% record the parent object (zoom rectangle) in the new fig
    210                 AxeData.ZoomAxes=copyobj(currentaxes,hfig2); %copy the current graph axes to the zoom figure
     202            if ~testsubplot% if we are not already on a zoom plot
     203                hfig2=findobj(allchild(0),'Tag','zoom_fig');
     204                if isempty(hfig2)% create zoom sub plot if absent
     205                    hfig2=figure('name',['zoom_' FigTag],'tag','zoom_fig');%create new figure (unit='pixels' by default)
     206                    set(0,'Unit','pixels')
     207                    FigPos=get(hfig2,'Position');%get the standard width and height of the fig
     208                    ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
     209                    Left=ScreenSize(3)- FigPos(3)-40; %right edge close to the right, with margin=40
     210                    Bottom=ScreenSize(4)-FigPos(4)-40; %put fig at top right
     211                    FigPos(1:2)=[Left Bottom];
     212                    set(hfig2,'Position',FigPos);% put the zoom fig close to the upper right of the screen
     213                    map=colormap(hcurrentaxes);
     214                    colormap(map);%transmit the current colormap to the zoom fig
     215                    set(hfig2,'KeyPressFcn',{@keyboard_callback,handles})%set keyboard action function
     216                    set(hfig2,'WindowButtonMotionFcn',{@mouse_motion,handles})%set mouse action function
     217                    set(hfig2,'WindowButtonDownFcn',{@mouse_down})%set mouse click action function
     218                    set(hfig2,'WindowButtonUpFcn',{@mouse_up,handles})
     219                else
     220                    zoom_axes=findobj(hfig2,'Type','axes');%delete existing axes
     221                    axes(zoom_axes);%make the zoom axes apparent
     222                    delete(zoom_axes)
     223                end
     224                set(hfig2,'DeleteFcn',{@close_fig,AxeData.CurrentRectZoom})
     225                set(hfig2,'UserData',AxeData.CurrentRectZoom)% record the parent object (zoom rectangle) in the new fig   
     226                AxeData.ZoomAxes=copyobj(hcurrentaxes,hfig2); %copy the current graph axes to the zoom figure
    211227                hrect_zoom=findobj(AxeData.ZoomAxes,'Tag','rect_zoom');%find and delete the copy of the rect_zoom rectangle
    212228                delete(hrect_zoom)
    213                 ChildAxeData=get(AxeData.ZoomAxes,'UserData');
    214                 if isfield(ChildAxeData,'ParentGUI')
    215                     ChildAxeData=rmfield(ChildAxeData,'ParentGUI');%no parent GUI, e.g. uvmat,  for the new plot
    216                 end
    217                 set(AxeData.ZoomAxes,'Position',[0.1300    0.1100    0.7750    0.8150])% standard axes position on a figure
    218229                hcol=findobj(hparentfig,'Tag','Colorbar'); %look for colorbar axes
    219230                if ~isempty(hcol)
     
    228239                    set(hcol_new,'Yticklabel',YTicklabel);
    229240                end
    230             end         
     241                ChildAxeData=get(AxeData.ZoomAxes,'UserData');
     242            end 
     243            ChildAxeData.CurrentOrigin=[];% forget the current origin
    231244            ChildAxeData.CurrentRectZoom=[]; % no rect zoom in the new window
    232245            ChildAxeData.Drawing='off';
    233             ChildAxeData.ParentRect=AxeData.CurrentRectZoom;%set the rectangle as a 'parent' associated to the new axe
    234             PosRect=CurrentOrigin;
    235             xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    236             set(AxeData.ZoomAxes,'Xlim',[PosRect(1) xy(1,1)])
    237             set(AxeData.ZoomAxes,'Ylim',[PosRect(2) xy(1,2)])
     246            ChildAxeData.ParentAxes=hcurrentaxes;
     247            ChildAxeData.ParentRect=AxeData.CurrentRectZoom;%set the rectangle drawing as a 'parent' associated to the new axe
     248            %PosRect=CurrentOrigin;
     249           % xy=get(hcurrentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     250            if xy(1,1)>CurrentOrigin(1)
     251            set(AxeData.ZoomAxes,'Xlim',[CurrentOrigin(1) xy(1,1)])
     252            else
     253                set(AxeData.ZoomAxes,'Xlim',[xy(1,1) CurrentOrigin(1)])
     254            end
     255            if xy(1,2)>CurrentOrigin(2)
     256            set(AxeData.ZoomAxes,'Ylim',[CurrentOrigin(2) xy(1,2)])
     257            else
     258                set(AxeData.ZoomAxes,'Ylim',[xy(1,2) CurrentOrigin(2)])
     259            end
    238260            set(AxeData.ZoomAxes,'UserData',ChildAxeData);%update the AxeData of the new axes
    239261        end
     
    242264
    243265%% zoom in or out by a factor 2 if no new figure is created
    244 if test_zoom
    245     xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    246     xlim=get(currentaxes,'XLim');
    247     ylim=get(currentaxes,'YLim');
     266if CheckZoom
     267    if testsubplot
     268        haxes=gca;% zoom on a zoom sub-plot
     269    else
     270        haxes=hcurrentaxes;% zoom on the main plot
     271    end
     272   % xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     273    xlim=get(haxes,'XLim');
     274    ylim=get(haxes,'YLim');
    248275    % if left mouse 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
    250         PlotBoxAspectRatio=get(currentaxes,'PlotBoxAspectRatio');
     276    if  isequal(get(gcf,'SelectionType'),'normal');%if left button has been pressed, zoom in by a factor of 2
     277        PlotBoxAspectRatio=get(haxes,'PlotBoxAspectRatio');
    251278        yoverx=PlotBoxAspectRatio(2)/PlotBoxAspectRatio(1);
    252279        if yoverx <2
    253280            xlim(1)=0.5*xy(1,1)+0.5*xlim(1);
    254281            xlim(2)=0.5*xy(1,1)+0.5*xlim(2);%double the field whith the middle at the selected points
    255             set(currentaxes,'XLim',xlim)
     282            set(haxes,'XLim',xlim)
    256283        end
    257284        if yoverx >0.5
    258285            ylim(2)=0.5*xy(1,2)+0.5*ylim(2);
    259286            ylim(1)=0.5*xy(1,2)+0.5*ylim(1);
    260             set(currentaxes,'YLim',ylim)
     287            set(haxes,'YLim',ylim)
    261288        end
    262289       
     
    267294        ylim(1)=2*ylim(1)-xy(1,2);
    268295        ylim(2)=2*ylim(2)-xy(1,2);
    269         if isfield(AxeData,'RangeX')&& isfield(AxeData,'RangeY')
     296        % adjust the zoom out to the available field
     297        if ~testsubplot && isfield(AxeData,'RangeX')&& isfield(AxeData,'RangeY')
    270298            xlim(1)=max(AxeData.RangeX(1),xlim(1));
    271299            xlim(2)=min(AxeData.RangeX(2),xlim(2));
     
    279307            if isequal(xlim,AxeData.RangeX) && isequal(ylim,AxeData.RangeY)
    280308                set(hhuvmat.CheckZoom,'Value',0)
    281                 set(hhuvmat.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
     309               % set(hhuvmat.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
    282310                set(hhuvmat.CheckFixLimits,'Value',0)
    283                 set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
    284             end
    285         end
    286         set(currentaxes,'XLim',xlim)
    287         set(currentaxes,'YLim',ylim)
     311              %  set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
     312            end
     313        end
     314        set(haxes,'XLim',xlim)
     315        set(haxes,'YLim',ylim)
    288316        %test whther zoom out is operating (to inactivate AxedAta
    289317        if ~isfield(AxeData,'CurrentXLim')|| ~isequal(xlim,AxeData.CurrentXLim)
     
    291319        end
    292320    end
    293     if isfield(AxeData,'LimEditBox')&& AxeData.LimEditBox% update display of the GUI containing the axis (uvmat or view_field)
     321    %if isfield(AxeData,'LimEditBox')&& AxeData.LimEditBox% update display of the GUI containing the axis (uvmat or view_field)
     322    if testsubplot
     323        set(AxeData.CurrentRectZoom,'Position',[xlim(1) ylim(1) xlim(2)-xlim(1) ylim(2)-ylim(1)])
     324    else
    294325        set(hhcurrentfig.num_MinX,'String',num2str(xlim(1)))
    295326        set(hhcurrentfig.num_MaxX,'String',num2str(xlim(2)))
     
    300331
    301332%% editing calibration point
    302 if ~test_zoom && isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'calibration')
     333if ~CheckZoom && isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'calibration')
    303334    h_geometry_calib=findobj(allchild(0),'tag','geometry_calib'); %find the geomterty_calib GUI
    304335    if ~isempty(h_geometry_calib)
    305336        hh_geometry_calib=guidata(h_geometry_calib);
    306337        edit_test=get(hh_geometry_calib.edit_append,'Value');
    307         hh=findobj(currentaxes,'tag','calib_points');%look for handle of calibration points
     338        hh=findobj(hcurrentaxes,'tag','calib_points');%look for handle of calibration points
    308339        if ~isempty(hh) && edit_test
    309340            index_point=get(hh,'UserData');
     
    313344            data=read_geometry_calib(Coord);
    314345            %         val=get(h_ListCoord,'Value');
    315             xy=get(currentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     346          %  xy=get(hcurrentaxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    316347            data.Coord(index_point,4)=xy(1,1);
    317348            data.Coord(index_point,5)=xy(1,2);
     
    331362
    332363%% finalising ruler
    333 if test_ruler
     364if test_ruler && ~isempty(xy)
    334365    set(hhuvmat.MenuRuler,'checked','off')%desable the ruler option in uvmat
    335     xy=get(currentaxes,'CurrentPoint');% get the current mouse coordinates
     366    xy=get(hcurrentaxes,'CurrentPoint');% get the current mouse coordinates
    336367    RulerCoord=[AxeData.RulerCoord ;xy(1,1:2)];% append the recorded ruler origin to the current mouse coordinates
    337368    RulerCoord=diff(RulerCoord,1);% coordiante difference between segment end and beginning
     
    346377
    347378%% display the data of the current object selected with the mouse right click
    348 if isequal(get(hcurrentfig,'SelectionType'),'alt') && ~test_zoom && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create'))
     379if isequal(get(hcurrentfig,'SelectionType'),'alt') && ~CheckZoom && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create'))
    349380    hother=findobj('Tag','proj_object');%find all the proj objects
    350381    nbselect=0;
     
    384415        AxeData.Drawing='off';%stop current drawing action
    385416end
    386 set(currentaxes,'UserData',AxeData);
     417set(hcurrentaxes,'UserData',AxeData);
    387418if ~isempty(huvmat)
    388419    set(huvmat,'UserData',UvData);
    389420end
    390421
    391    
    392 
     422%------------------------------------------------------------------------   
     423% --- 'close_fig': function  activated when a zoom figure is closed
     424%------------------------------------------------------------------------
     425function close_fig(ggg,eventdata,hparent)
     426
     427hfig=get(get(hparent,'parent'),'parent');
     428hbutton=findobj(hfig,'Tag','CheckZoomFig');
     429if ~isempty(hbutton)
     430    set(hbutton,'Value',0)% desactivate the zoom fig option
     431end
     432delete(hparent)  % delete the rectangle showing the zoom graph in the parent fig
     433
  • trunk/src/plot_field.m

    r609 r625  
    1212%  dimension variables (case of matrices).
    1313%
    14 % function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,htext,PosColorbar)
     14% function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,PosColorbar)
    1515%
    1616% OUPUT:
  • trunk/src/plot_object.m

    r622 r625  
    5454    return
    5555end
    56 XMin=0;%default
     56XMin=0;%default range for the graph
    5757XMax=0;
    5858YMin=0;
     
    6060ZMin=0;
    6161ZMax=0;
     62XMinRange=[];%default range set by input
     63XMaxRange=[];
     64YMinRange=[];
     65YMaxRange=[];
     66ZMinRange=[];
     67ZMaxRange=[];
    6268
    6369%% determine the plotting axes (with handle 'haxes')
     
    99105    XMax=max(ObjectData.RangeX);
    100106    XMin=min(ObjectData.RangeX);
     107        XMaxRange=max(ObjectData.RangeX);
     108        if numel(ObjectData.RangeX)==2
     109    XMinRange=min(ObjectData.RangeX);
     110        end
    101111end
    102112if isfield(ObjectData,'RangeY')&&~isempty(ObjectData.RangeY)
    103113    YMax=max(ObjectData.RangeY);
    104114    YMin=min(ObjectData.RangeY);
     115        YMaxRange=max(ObjectData.RangeY);
     116        if numel(ObjectData.RangeY)==2
     117    YMinRange=min(ObjectData.RangeY);
     118        end
    105119end
    106120if isfield(ObjectData,'RangeZ')&&~isempty(ObjectData.RangeZ)
    107121    ZMax=max(ObjectData.RangeZ);
    108122    ZMin=min(ObjectData.RangeZ);
    109 end
    110 switch ObjectData.Type
    111     case 'points'
    112         if strcmp(ObjectData.ProjMode,'projection')
    113             YMax=max(XMax,YMax);
    114             YMax=max(YMax,ZMax);
    115         end
    116     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
    124     case 'plane'
    125         if  isequal(XMax,0)
    126             xlim=get(haxes,'XLim');
    127             XMax=xlim(2);
    128         end
    129         if  isequal(YMax,0)
    130             ylim=get(haxes,'YLim');
    131             YMax=ylim(2);
    132         end
     123    ZMaxRange=max(ObjectData.RangeZ);
     124    ZMinRange=min(ObjectData.RangeZ);
     125end
     126if strcmp(ObjectData.Type,'points') && strcmp(ObjectData.ProjMode,'projection')
     127    YMax=max(XMax,YMax);
     128    YMax=max(YMax,ZMax);
    133129end
    134130sizcoord=size(ObjectData.Coord);
     
    147143        yline=[yline; ObjectData.Coord(1,2)];
    148144    elseif isequal(ObjectData.Type,'plane')|| isequal(ObjectData.Type,'volume')
     145        if ~isfield(ObjectData,'Angle')
     146            ObjectData.Angle=[0 0 0];
     147        end
    149148        phi=ObjectData.Angle(3)*pi/180;%angle in radians
    150         Xend_x=xline(1)+XMax*cos(phi);
    151         Xend_y=yline(1)+XMax*sin(phi);
    152         Xbeg_x=xline(1)+XMin*cos(phi);
    153         Xbeg_y=yline(1)+XMin*sin(phi);
    154         Yend_x=xline(1)-YMax*sin(phi);
    155         Yend_y=yline(1)+YMax*cos(phi);
    156         Ybeg_x=xline(1)-YMin*sin(phi);
    157         Ybeg_y=yline(1)+YMin*cos(phi);
    158         xline=[Xbeg_x Xend_x NaN Ybeg_x Yend_x];
    159         yline=[Xbeg_y Xend_y NaN Ybeg_y Yend_y];
     149        x0=xline(1); y0=yline(1);
     150        xlim=get(haxes,'XLim');
     151        ylim=get(haxes,'YLim');
     152        graph_scale=max(abs(xlim(2)-xlim(1)),abs(ylim(2)-ylim(1)))/2;% estimate the length of axes plots
     153        XMax=graph_scale;
     154        YMax=graph_scale;
     155        XMin=-graph_scale;
     156        YMin=-graph_scale;
     157        if  ~isempty(XMaxRange)
     158            XMax=XMaxRange;
     159        end
     160        if  ~isempty(XMinRange)
     161            XMin=XMinRange;
     162        end
     163        if  ~isempty(YMaxRange)
     164            YMax=YMaxRange;
     165        end
     166        if  ~isempty(YMinRange)
     167            YMin=YMinRange;
     168        end   
     169        % axes lines
     170        xline=NaN(1,13);
     171        xline(1)=x0+min(0,XMin)*cos(phi); % min end of the x axes
     172        yline(1)=y0+min(0,XMin)*sin(phi);
     173        xline(2)=x0+XMax*cos(phi);% max end of the x axes
     174        yline(2)=y0+XMax*sin(phi);
     175        xline(8)=x0-min(0,YMin)*sin(phi);% min end of the y axes
     176        yline(8)=y0+min(0,YMin)*cos(phi);
     177        xline(9)=x0-YMax*sin(phi);% max end of the y axes
     178        yline(9)=y0+YMax*cos(phi);
     179
     180        %arrows on x axis
     181        arrow_scale=graph_scale/20;
     182        xline(3)=xline(2)-arrow_scale*cos(phi-pi/8);
     183        yline(3)=yline(2)-arrow_scale*sin(phi-pi/8);
     184        xline(5)=xline(2);
     185        yline(5)=yline(2);
     186        xline(6)=xline(2)-arrow_scale*cos(phi+pi/8);
     187        yline(6)=yline(2)-arrow_scale*sin(phi+pi/8);
     188       
     189        %arrows on y axis
     190        xline(10)=xline(9)-arrow_scale*cos(phi+pi/2-pi/8);
     191        yline(10)=yline(9)-arrow_scale*sin(phi+pi/2-pi/8);
     192        xline(12)=xline(9);
     193        yline(12)=yline(9);
     194        xline(13)=xline(9)-arrow_scale*cos(phi+pi/2+pi/8);
     195        yline(13)=yline(9)-arrow_scale*sin(phi+pi/2+pi/8);     
     196        %xline=[Xbeg_x Xend_x NaN Ybeg_x Yend_x];
     197        %yline=[Xbeg_y Xend_y NaN Ybeg_y Yend_y];
     198        %  dashed lines indicating bounds
     199        xsup=NaN(1,5);
     200        ysup=NaN(1,5);
     201        if ~isempty(XMaxRange)
     202            xsup(1)=xline(2)-YMin*sin(phi);
     203            ysup(1)=yline(2)+YMin*cos(phi);
     204            xsup(2)=xline(2)-YMax*sin(phi);
     205            ysup(2)=yline(2)+YMax*cos(phi);
     206        end
     207        if ~isempty(YMaxRange)
     208            xsup(2)=xline(2)-YMax*sin(phi);
     209            ysup(2)=yline(2)+YMax*cos(phi);
     210            xsup(3)=xline(9)+XMin*cos(phi);
     211            ysup(3)=yline(9)+XMin*sin(phi);
     212        end   
     213        if ~isempty(XMinRange)
     214            xsup(3)=xline(9)+XMin*cos(phi);
     215            ysup(3)=yline(9)+XMin*sin(phi);
     216            xsup(4)=x0+XMin*cos(phi)-YMin*sin(phi);
     217            ysup(4)=y0+XMin*sin(phi)+YMin*cos(phi);
     218        end 
     219        if ~isempty(YMinRange)
     220           xsup(4)=x0+XMin*cos(phi)-YMin*sin(phi);
     221            ysup(4)=y0+XMin*sin(phi)+YMin*cos(phi);
     222            xsup(5)=xline(8)-YMin*sin(phi);
     223            ysup(5)=yline(8)+YMin*cos(phi);
     224        end
    160225    end
    161226    SubLineStyle='none';%default
     
    258323if test_newobj==0;
    259324    hh=hplot;
    260     PlotData=get(hplot,'UserData');           
     325    PlotData=get(hplot,'UserData');
    261326    if test_line
    262327        set(hplot,'XData',xline)
    263328        set(hplot,'YData',yline)
    264     %modify subobjects
    265         if isfield(PlotData,'SubObject')
    266            if length(PlotData.SubObject)==2 && ~isequal(ObjectData.Type,'points')&& ~isequal(ObjectData.Type,'plane');
     329        %modify subobjects
     330        if isfield(PlotData,'SubObject')
     331            if isequal(ObjectData.Type,'points')
     332                if ~isequal(YMax,0)
     333                    for ipt=1:min(length(PlotData.SubObject),size(ObjectData.Coord,1))
     334                        set(PlotData.SubObject(ipt),'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax])
     335                    end
     336                    %complement missing points
     337                    if length(PlotData.SubObject)>nbpoints% fpoints in excess on the graph
     338                        for ii=nbpoints+1: length(PlotData.SubObject);
     339                            if ishandle(PlotData.SubObject(ii))
     340                                delete(PlotData.SubObject(ii))
     341                            end
     342                        end
     343                    end
     344                    %                NbDeformPoint=nbpoints;
     345                   
     346                    if nbpoints>length(PlotData.SubObject)
     347                        for ipt=length(PlotData.SubObject)+1:nbpoints
     348                            PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],...
     349                                'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,...
     350                                'LineStyle',SubLineStyle,'Tag','proj_object');
     351                        end
     352                    end
     353                end
     354            elseif length(PlotData.SubObject)==2
    267355                set(PlotData.SubObject(1),'XData',xinf);
    268356                set(PlotData.SubObject(1),'YData',yinf);
    269357                set(PlotData.SubObject(2),'XData',xsup);
    270358                set(PlotData.SubObject(2),'YData',ysup);
    271            elseif isequal(ObjectData.Type,'points')&& ~isequal(YMax,0)
    272                for ipt=1:min(length(PlotData.SubObject),size(ObjectData.Coord,1))
    273                     set(PlotData.SubObject(ipt),'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax])
    274                end
    275                %complement missing points
    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
    286                      PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],...
    287                   'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,...
    288                   'LineStyle',SubLineStyle,'Tag','proj_object');
    289                    end
    290                end                                         
    291            end
     359            elseif length(PlotData.SubObject)==1
     360                set(PlotData.SubObject(1),'XData',xsup);
     361                set(PlotData.SubObject(1),'YData',ysup);
     362            end
    292363        end
    293364        if isfield(PlotData,'DeformPoint')
    294365            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))
     366            if NbDeformPoint>nbpoints% fpoints in excess on the graph
     367                for ii=nbpoints+1:NbDeformPoint;
     368                    if ishandle(PlotData.DeformPoint(ii))
    298369                        delete(PlotData.DeformPoint(ii))
    299                    end
    300                end
    301                NbDeformPoint=nbpoints;
    302            end
    303            for ipt=1:NbDeformPoint
    304                if ishandle(PlotData.DeformPoint(ipt))
    305                    if nbpoints>=ipt 
     370                    end
     371                end
     372                NbDeformPoint=nbpoints;
     373            end
     374            for ipt=1:NbDeformPoint
     375                if ishandle(PlotData.DeformPoint(ipt))
     376                    if nbpoints>=ipt
    306377                        set(PlotData.DeformPoint(ipt),'XData',xline(ipt),'YData',yline(ipt));
    307378                    end
    308                end
    309            end
    310            if nbpoints>length(PlotData.DeformPoint)
    311                for ipt=length(PlotData.DeformPoint)+1:nbpoints
     379                end
     380            end
     381            if nbpoints>length(PlotData.DeformPoint)
     382                for ipt=length(PlotData.DeformPoint)+1:nbpoints
    312383                    PlotData.DeformPoint(ipt)=line(xline(ipt),yline(ipt),'Color',col,'LineStyle','.','Tag','DeformPoint',...
    313384                        'SelectionHighlight','off','UserData',hplot);
    314                end
    315                set(hplot,'UserData',PlotData)
    316            end
     385                end
     386                set(hplot,'UserData',PlotData)
     387            end
    317388        end
    318389    elseif (isequal(ObjectData.Type,'rectangle')||isequal(ObjectData.Type,'ellipse'))&&XMax>0 && YMax>0
    319         set(hplot,'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax])         
    320     end
    321     if test_patch 
     390        set(hplot,'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax])
     391    end
     392    if test_patch
    322393        for iobj=1:length(PlotData.SubObject)
    323394            objtype=get(PlotData.SubObject(iobj),'Type');
     
    353424    set(hother,'Color','b');
    354425    set(hother,'Selected','off') 
    355     if isequal(ObjectData.Type,'points')
    356         hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color',col,'LineStyle','.','Marker','+');
    357         for ipt=1:length(xline)
    358               PlotData.DeformPoint(ipt)=line(ObjectData.Coord(ipt,1),ObjectData.Coord(ipt,2),'Color',...
    359                   col,'LineStyle','.','SelectionHighlight','off','UserData',hh,'Tag','DeformPoint');
    360               %create circle around each point
    361               if ~isequal(YMax,0)
    362                  PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],...
    363                   'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,...
    364                   'LineStyle',SubLineStyle,'Tag','proj_object');
    365               end
    366         end
    367     elseif  strcmp(ObjectData.Type,'line')||strcmp(ObjectData.Type,'polyline')||...       
    368           strcmp(ObjectData.Type,'polygon') ||strcmp(ObjectData.Type,'plane')||strcmp(ObjectData.Type,'volume')%  (isequal(ObjectData.Type,'polygon') & ~test_patch) |isequal(ObjectData.Type,'plane')
    369         hh=line(xline,yline,'Color',col);
    370         if ~strcmp(ObjectData.Type,'plane') && ~strcmp(ObjectData.Type,'volume')
    371             PlotData.SubObject(1)=line(xinf,yinf,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');%draw sub-lines
    372             PlotData.SubObject(2)=line(xsup,ysup,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');
    373             for ipt=1:sizcoord(1)
     426    switch ObjectData.Type
     427        case 'points'
     428            hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color',col,'LineStyle','.','Marker','+');
     429            for ipt=1:length(xline)
    374430                PlotData.DeformPoint(ipt)=line(ObjectData.Coord(ipt,1),ObjectData.Coord(ipt,2),'Color',...
    375                       col,'LineStyle','none','Marker','.','Tag','DeformPoint','SelectionHighlight','off','UserData',hh);
    376             end
    377         end
    378    
    379     elseif strcmp(ObjectData.Type,'rectangle')
    380         hh=rectangle('Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax],'EdgeColor',col);   
    381     elseif strcmp(ObjectData.Type,'ellipse')
    382         hh=rectangle('Curvature',[1 1],'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax],'EdgeColor',col);
    383     else
    384         msgbox_uvmat('ERROR','unknown ObjectData.Type in plot_object.m')
    385         return
     431                    col,'LineStyle','.','SelectionHighlight','off','UserData',hh,'Tag','DeformPoint');
     432                %create circle around each point
     433                if ~isequal(YMax,0)
     434                    PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],...
     435                        'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,...
     436                        'LineStyle',SubLineStyle,'Tag','proj_object');
     437                end
     438            end
     439        case {'line','polyline','polygon'}
     440            hh=line(xline,yline,'Color',col);
     441                PlotData.SubObject(1)=line(xinf,yinf,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');%draw sub-lines
     442                PlotData.SubObject(2)=line(xsup,ysup,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');
     443                for ipt=1:sizcoord(1)
     444                    PlotData.DeformPoint(ipt)=line(ObjectData.Coord(ipt,1),ObjectData.Coord(ipt,2),'Color',...
     445                        col,'LineStyle','none','Marker','.','Tag','DeformPoint','SelectionHighlight','off','UserData',hh);
     446                end
     447        case {'plane','volume'}
     448            hh=line(xline,yline,'Color',col);
     449            PlotData.SubObject(1)=line(xsup,ysup,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');
     450        case 'rectangle'
     451            hh=rectangle('Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax],'LineWidth',2,'EdgeColor',col);
     452        case 'ellipse'
     453            hh=rectangle('Curvature',[1 1],'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax],'EdgeColor',col);
     454        otherwise
     455            msgbox_uvmat('ERROR','unknown ObjectData.Type in plot_object.m')
     456            return
    386457    end
    387458    set(hh,'Tag','proj_object')
  • trunk/src/proj_field.m

    r603 r625  
    22032203
    22042204%% store the properties of the projection object
    2205 ListObject={'Type','ProjMode','RangeX','RangeY','RangeZ','Phi','Theta','Psi','Coord'};
     2205ListObject={'Name','Type','ProjMode','angle','RangeX','RangeY','RangeZ','DX','DY','DZ','Coord'};
    22062206for ilist=1:length(ListObject)
    22072207    if isfield(ObjectData,ListObject{ilist})
    22082208        val=ObjectData.(ListObject{ilist});
    22092209        if ~isempty(val)
    2210             ProjData.(['Object' ListObject{ilist}])=val;
    2211             ProjData.ListGlobalAttribute=[ProjData.ListGlobalAttribute {['Object' ListObject{ilist}]}];
     2210            ProjData.(['ProjObject' ListObject{ilist}])=val;
     2211            ProjData.ListGlobalAttribute=[ProjData.ListGlobalAttribute {['ProjObject' ListObject{ilist}]}];
    22122212        end
    22132213    end   
  • trunk/src/set_object.m

    r622 r625  
    153153        end
    154154    end 
    155     if isfield(data,'Angle') && isequal(numel(data.Angle),3)
     155    if ~isfield(data,'Angle')
     156        data.Angle=[0 0 0];
     157    end
     158%     if isfield(data,'Angle') && isequal(numel(data.Angle),3)
    156159         set(handles.num_Angle_1,'String',num2str(data.Angle(1)))
    157160         set(handles.num_Angle_2,'String',num2str(data.Angle(2)))
    158161         set(handles.num_Angle_3,'String',num2str(data.Angle(3)))
    159     end
    160 end
    161 % if enable_plot
    162 %    set(handles.PLOT,'enable','on')
    163 % else
    164 % enable the PLOT (REFRESH) button by default
    165 %defaul settings
    166 set(get(handles.set_object,'children'),'enable','on')
    167 set(handles.PLOT,'enable','off')
    168 % end
    169 % huvmat=findobj(allchild(0),'tag','uvmat');
    170 % UvData=get(huvmat,'UserData');
    171 % pos_uvmat=get(huvmat,'Position');
    172 % %position the set_object GUI with respect to uvmat
    173 % if isfield(UvData,'SetObjectOrigin')
    174 %     pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
    175 %     pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
    176 %     set(hObject,'Position',pos_set_object)
    177 % end
     162%     end
     163end
     164set(get(handles.set_object,'children'),'enable','off')
     165set(handles.SAVE,'enable','on')
     166% set(handles.PLOT,'enable','off')
     167
    178168
    179169%------------------------------------------------------------------------
     
    195185    set(hhuvmat.ViewObject,'value',0)%
    196186    set(hhuvmat.edit_object,'Value',0)% desactivate the edit option
    197     set(hhuvmat.edit_object,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree
     187%    set(hhuvmat.edit_object,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree
    198188    % deselect the object in ListObject when view_field is closed
    199189    if isempty(findobj(allchild(0),'Tag','view_field'))
     
    450440hhuvmat=guidata(huvmat);%handles of the objects children of the  GUI uvmat
    451441ListObject=get(hhuvmat.ListObject,'String');% list of objects displayed in uvmat
    452 IndexObj=get(hhuvmat.ListObject,'Value');% index of the selected object for display in uvmat
     442
     443if isequal(get(hhuvmat.edit_object,'Value'),0) %we append a new object
     444    ListObject=[ListObject;{''}];
     445    IndexObj=length(ListObject);
     446    set(hhuvmat.ListObject,'String',ListObject)
     447    set(hhuvmat.ListObject,'Value',IndexObj)
     448    UvData.ProjObject{IndexObj}=[]; %create a new empty object
     449    UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; % axes for plot_object
     450    UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
     451else
     452    % if ~strcmp(ListObject{end},'')
     453    %     ListObject=[ListObject;{''}]; %append a blank to the list (if nort already done) to indicate the creation of a new object
     454    %     set(handles.ListObject,'String',ListObject)
     455    % end
     456    % IndexObj=length(ListObject); 
     457    % set(handles.uvmat,'UserData',UvData)   
     458    IndexObj=get(hhuvmat.ListObject,'Value');% index of the selected object for display in uvmat
     459end
     460
    453461%set or modify(edit mode) the nameof the currently selected object
    454462detectname=1;
     
    474482ListObject{IndexObj}=ObjectName;
    475483set(hhuvmat.ListObject,'String',ListObject);%complement the object list
     484set(hhuvmat.ListObject_1,'String',ListObject);%complement the object list
    476485set(hhuvmat.ViewObject,'Value',1)% indicate that the currently selected objected is viewed on set_object
    477486check_handle=isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat')...
     
    572581set(hhuvmat.MenuEditObject,'enable','on')
    573582set(hhuvmat.edit_object,'Value',1) % set uvmat to object edit mode to allow further object update
    574 set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
     583%set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
    575584set(hhuvmat.ViewField,'Value',1)
    576585% set(handles.PLOT,'enable','on')
  • trunk/src/uvmat.m

    r623 r625  
    25512551        UvData.ProjObject{1}.Type='plane';%main plotting plane
    25522552        UvData.ProjObject{1}.ProjMode='projection';%main plotting plane
     2553        UvData.ProjObject{1}.Coord=[0 0 0];
    25532554        UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
    25542555        UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
     
    41684169list_str=get(handles.ListObject,'String');
    41694170IndexObj=get(handles.ListObject,'Value');%present object selection
    4170 
    4171 %% The object  is displayed in set_object if this GUI is already opened
    41724171UvData=get(handles.uvmat,'UserData');
    41734172ObjectData=UvData.ProjObject{IndexObj};
    4174 hset_object=findobj(allchild(0),'tag','set_object');
    4175 if ~isempty(hset_object)
    41764173    ZBounds=0; % default
    41774174    if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
     
    41794176        ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
    41804177    end
    4181     ObjectData.Name=list_str{IndexObj};
     4178
     4179%% show object features if view_object isselected
     4180if get(handles.ViewObject,'value')
    41824181    set_object(ObjectData,[],ZBounds);
    4183     set(handles.ViewField,'Value',1)% show that the selected object in ListObject is currently visualised
    4184 end
    4185 
    4186 %%  desactivate the edit object mode
     4182end
     4183
     4184%% The object  is displayed in set_object if this GUI is already opened
     4185%
     4186% hset_object=findobj(allchild(0),'tag','set_object');
     4187% if ~isempty(hset_object)
     4188%
     4189%     ObjectData.Name=list_str{IndexObj};
     4190%     set_object(ObjectData,[],ZBounds);
     4191%     set(handles.ViewField,'Value',1)% show that the selected object in ListObject is currently visualised
     4192% end
     4193
     4194%%  desactivate the edit object mode for security
    41874195set(handles.edit_object,'Value',0)
     4196
    41884197% set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
    41894198
     
    42744283%-------------------------------------------------------------------
    42754284hset_object=findobj(allchild(0),'Tag','set_object');
    4276 if get(handles.edit_object,'Value')
    4277 %     set(handles.edit_object,'BackgroundColor',[1,1,0]) 
     4285if get(handles.edit_object,'Value')
    42784286    %suppress the other options
    42794287    set(handles.CheckZoom,'Value',0)
     
    42834291        hhgeometry_calib=guidata(hgeometry_calib);
    42844292        set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
    4285         set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
    42864293    end
    42874294    set(handles.ViewObject,'value',1)
    42884295    ViewObject_Callback(hObject, eventdata, handles)
    4289 else % desctivate object edit mode
    4290 %     set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
     4296else % desactivate object edit mode
    42914297    if ~isempty(hset_object)% open the
    4292         hhset_object=guidata(hset_object);
    4293         set(hhset_object.PLOT,'enable','off');
    4294         set(get(hset_object,'children'),'enable','inactive')
     4298        set(get(hset_object,'children'),'Enable','off')
     4299        hSAVE=findobj(hset_object,'Tag','SAVE');
     4300        set(hSAVE,'Enable','on')
    42954301    end
    42964302end
     
    43174323        ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
    43184324    end
    4319 %     set(handles.ListObject_1,'Value',IndexObj);%restore ListObject selection after set_object deletion
    43204325    data=UvData.ProjObject{IndexObj};
    43214326    if ~isfield(data,'Type')% default plane
    43224327        data.Type='plane';
    43234328    end
    4324 %     if isfield(UvData,'Field')
    4325 %         Field=UvData.Field;
    4326 %         if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh)
    4327 %             data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
    4328 %             if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')
    4329 %                 data.RangeY=UvData.Field.Mesh;
    4330 %             else
    4331 %                 data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
    4332 %             end
    4333 %             data.DX=UvData.Field.Mesh;
    4334 %             data.DY=UvData.Field.Mesh;
    4335 %         end
    4336 %         if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
    4337 %             data.Coord=[0 0 0]; %default
    4338 %         end
    4339 %         if isfield(Field,'CoordUnit')
    4340 %             data.CoordUnit=Field.CoordUnit;
    4341 %         end
    4342 %     end
    43434329    hset_object=set_object(data,[],ZBounds);
    43444330    hhset_object=guidata(hset_object);
    43454331    if get(handles.edit_object,'Value')% edit mode
    4346         set(hhset_object.PLOT,'Enable','on')
    4347         set(get(hset_object,'children'),'enable','on')
     4332        set(get(hset_object,'children'),'Enable','on')
    43484333    else
    4349         set(hhset_object.PLOT,'Enable','off')
    4350         set(get(hset_object,'children'),'enable','inactive')% deactivate the GUI except SAVE
     4334        set(get(hset_object,'children'),'Enable','off')% deactivate the GUI except SAVE
    43514335        set(hhset_object.SAVE,'Enable','on')
    43524336    end
     
    47714755end
    47724756set(handles.edit_object,'Value',0)  %desactivate the object edit mode
     4757edit_object_Callback([],[],handles)
     4758set(handles.ViewObject,'Value',0) % desactivate view_object (new object created)
    47734759set(handles.CheckZoomFig,'Value',0) %desactivate zoom sub fig
    47744760set(handles.CheckZoom,'Value',0)    %desactivate the zoom action
     
    47774763end
    47784764
    4779 %% append a new line to the list of projection objects
    4780 ListObject=get(handles.ListObject,'String');
    4781 if isempty(ListObject)
    4782     ListObject={''};
    4783 end
    4784 if ~strcmp(ListObject{end},'')
    4785     ListObject=[ListObject;{''}]; %append a blank to the list (if nort already done) to indicate the creation of a new object
    4786     set(handles.ListObject,'String',ListObject)
    4787 end
    4788 IndexObj=length(ListObject);
    4789 set(handles.ListObject,'Value',IndexObj)
     4765%% append a new line to the list of projection objects A METTRE PLUS TARD
     4766% ListObject=get(handles.ListObject,'String');
     4767% if isempty(ListObject)
     4768%     ListObject={''};
     4769% end
     4770% if ~strcmp(ListObject{end},'')
     4771%     ListObject=[ListObject;{''}]; %append a blank to the list (if nort already done) to indicate the creation of a new object
     4772%     set(handles.ListObject,'String',ListObject)
     4773% end
     4774% IndexObj=length(ListObject);
     4775% set(handles.ListObject,'Value',IndexObj)
    47904776UvData=get(handles.uvmat,'UserData');
    4791 UvData.ProjObject{IndexObj}=[]; %create a new empty object
    4792 UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object
    4793 UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
    4794 set(handles.uvmat,'UserData',UvData)
     4777% UvData.ProjObject{IndexObj}=[]; %create a new empty object
     4778% UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object
     4779% UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
     4780% set(handles.uvmat,'UserData',UvData)
    47954781
    47964782%% initiate the new projection object
     
    48624848set(get(hset_object,'children'),'enable','on')% enable edit action on elements on GUI set_object
    48634849set(handles.edit_object,'Value',0); %suppress the object edit mode
     4850edit_object_Callback([],[],handles)
    48644851% set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
    48654852set(handles.delete_object,'Visible','on')
  • trunk/src/view_field.m

    r622 r625  
    9090        set(handles.Scalar,'Visible','off')
    9191    end
     92   
    9293    errormsg=fill_GUI(PlotParamOut,hObject);
    9394    if ~isempty(errormsg)
     
    394395function CheckFixLimits_Callback(hObject, eventdata, handles)
    395396test=get(handles.CheckFixLimits,'Value');
    396 if test
    397     set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
    398 else
    399     set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
    400 end
     397% if test
     398%     set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
     399% else
     400%     set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
     401% end
    401402update_plot(handles)
    402403 
     
    406407%-------------------------------------------------------------------
    407408if get(handles.CheckFixAspectRatio,'Value')
    408     set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0])
    409409    update_plot(handles);
    410410else
    411     set(handles.CheckFixAspectRatio,'BackgroundColor',[0.7 0.7 0.7])
    412411    update_plot(handles);
    413412end
     
    417416%-------------------------------------------------------------------
    418417set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button
    419 set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0])% mark in yellow
    420418update_plot(handles);
    421419
     
    600598%------------------------------------------------------------------------
    601599set(handles.CheckFixLimits,'Value',1) %suppress auto mode
    602 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
     600% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
    603601update_plot(handles);
    604602
     
    607605%------------------------------------------------------------------------
    608606set(handles.CheckFixLimits,'Value',1) %suppress auto mode
    609 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
     607% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
    610608update_plot(handles);
    611609
     
    614612%------------------------------------------
    615613set(handles.CheckFixLimits,'Value',1) %suppress auto mode
    616 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
     614% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
    617615update_plot(handles);
    618616
     
    621619%------------------------------------------------------------------------
    622620set(handles.CheckFixLimits,'Value',1) %suppress auto mode
    623 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
     621% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
    624622update_plot(handles);
    625623
     
    635633%--------------------------------------------
    636634set(handles.CheckFixScalar,'Value',1) %suppress auto mode
    637 set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
     635% set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
    638636update_plot(handles)
    639637
     
    642640%--------------------------------------------
    643641test=get(handles.CheckFixScalar,'Value');
    644 if test
    645     set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
    646 else
    647     set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
    648     update_plot(handles);
    649 %     set(handles.MinA,'String',num2str(ScalOut.MinA,3))
    650 %     set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
    651 end
     642% if test
     643%     set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
     644% else
     645%     set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
     646%     update_plot(handles);
     647% %     set(handles.MinA,'String',num2str(ScalOut.MinA,3))
     648% %     set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
     649% end
    652650
    653651%-------------------------------------------------------------------
     
    699697    update_plot(handles);
    700698    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
    701     set(handles.FixVec,'BackgroundColor',[0.7 0.7 0.7])
     699%     set(handles.FixVec,'BackgroundColor',[0.7 0.7 0.7])
    702700end
    703701
Note: See TracChangeset for help on using the changeset viewer.