MATLAB:画笔集'启用'到'关闭'在ActionPostCallback中

时间:2015-08-17 16:46:27

标签: matlab callback brush

我有一个回调函数(参见下面的function annotateSelectedRegion),它将获取刷新数据并保存以供日后参考。我使用GUIDE开发了一个GUI,并创建了一个处理大部分功能和数据存储的类。我目前有一个刷子对象(在类中创建),我可以在函数中成功启用它并将回调设置为类中的另一个函数(参见下面的function startAnnotating)。

我现在希望在保存数据后刷子自动关闭(set(brushHandle, 'Enable', off'))。我已经看过各种示例,其中回调本身(http://www.mathworks.com/matlabcentral/answers/79531-create-a-callback-that-waits-for-the-brush-to-include-some-data-and-then-display-them)中禁用了画笔。

但是,当我在回调中尝试类似的方法时,我收到回调错误。 值得注意的是,当我删除该行 set(obj.regionSelector, 'Enable', 'off'); 时,回调功能正常运行。 我不完全确定我做错了什么,因为我已经在其他例子中看到了它。我引用的示例是使用编程 GUI完成的。这可能与我的错误有关吗?指南与程序化?

刷回调

    % Input: 
    %        eventdata variable provides the axes being brushed...
    %        ...NOTE: The call back automatically provides...
    %        ...eventdata. You do NOT need to pass it along explicitly.
    %        
    % Output: 
    %        None 
    function annotateSelectedRegion(obj, ~, eventdata)

        currentSelection = eventdata.Axes; 

        selectedData = currentSelection.Children; 

        if isempty(selectedData) || ~any(selectedData.BrushData(:))
            % Do nothing 
            disp('please select data or load data');

        elseif ~isempty(selectedData.BrushData)           
            brushedIdx = logical(selectedData.BrushData);
            brushedXData = selectedData.XData(brushedIdx);
            brushedYData = selectedData.YData(brushedIdx);

            obj.t1 = brushedXData(1); 
            obj.t2 = brushedXData(end); 

            fillRecPairInfo(obj); 
            fillAnnotIDInfo(obj); 
            fillUniqueIDInfo(obj); 
            fillAnnotRangeInfo(obj, currentSelection);

            annotationPopUp;

        end

        set(obj.regionSelector, 'Enable', 'off'); 

    end

此功能中启用了画笔。画笔开始只是一个空的"在课堂上的财产。

    function startAnnotating(obj)

        switch obj.annotationMode 
            case 1 
                obj.regionSelector = brush; 
                set(obj.regionSelector, 'Enable', 'on', 'ActionPostCallback', {@obj.annotateSelectedRegion})
            case 2
                % Bring up window 
            case 3 
                % Bring up window 
            case 4 
                % Bring up window 
        end 

    end 

0 个答案:

没有答案
相关问题