Customized Zoom function - Getting the clicked figure Tag
    1 view (last 30 days)
  
       Show older comments
    
Hi all
I'm quite new to MatLab programming and have encountered a problem...
I've written a script that collects data and presents these data to a GUI which contains different presentations of the same data. The GUI contains 8 figures.
What I want to do is to use the zoom function (by clicking the zoom icon in the meny bar), select a figure, drag to select the new X- and Y-axis limits and then update ALL 8 figures in the GUI based on the new axis limits. I cannot use linkaxes due to the necessity to do a lot of recalculations based on the limit selection for each figure.
When browsing around I found how to get the selected limits according to:
     % --------------------------------------------------------------------
    function uitoggletool1_ClickedCallback(hObject, eventdata, handles)
    % hObject    handle to uitoggletool1 (see GCBO)
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    disp('Zoom tool clicked');
    h = zoom;
    set(h,'ActionPreCallback',{@myprecallback,handles});
    set(h,'ActionPostCallback',{@mypostcallback,handles});
    set(h,'Enable','on');
    %
    function myprecallback(obj,evd, handles)
    disp('A zoom is about to occur.');
    %
    function mypostcallback(obj,evd, handles)
    NewXLim = get(evd.Axes,'XLim');
    %disp('X-limits '), NewXLim
    NewYLim = get(evd.Axes,'YLim');
    %disp('Y-limits '), NewYLim
    %Get the tag of the selected figure in the GUI
    h1 = gco;
    Update_All_Figures(h1, NewXLim, NewYLim, handles);
%  
  function Update_All_Figures(h1, xlim, ylim, handles)
  disp('Entering function Update_All-Figures...')
  disp('Figure tag '), h1
  disp('X-limits '), xlim
  disp('Y-limits '), ylim
    %Find out which figure was clicked...
    if h1 == handles.ScatterTag
        disp('Scatter plot zoomed...')
        %Update active data and replot all figures here...
    elseif h1 == handles.xHistoTag
        disp('X histogram was zoomed...')
        %Update active data and replot all figures here...
    elseif h1 == handles.yHistoTag
        disp('Y histogram was zoomed...')
        %Update active data and replot all figures here...
    elseif h1 == handles.thetaHistoTag
        disp('Theta histogram was zoomed...')
        %Update active data and replot all figures here...
    elseif h1 == handles.RegistrationTag
        disp('Registration plot was zoomed...')
        %Update active data and replot all figures here...
    elseif h1 == handles.MountScanOrderTag
        disp('Mount/Scan plot was zoomed...')
        %Update active data and replot all figures here...
    elseif h1 == handles.dXdYTag
        disp('dx/dy error was zoomed...')
        %Update active data and replot all figures here...
    elseif h1 == handles.dfiTag
        disp('dFi error was zoomed...')
        %Update active data and replot all figures here...
    else
        disp('Figure not recognized. Try again!')
    end
Note that the handles structure contains the tags to all 8 plots.
When I run the code I get different values of figure tag (h1 in the code). Sometimes the gco command returns the correct figure tag and sometimes not.
Anybody has any ideas?
TIA
Magnus
5 Comments
Answers (0)
See Also
Categories
				Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
