www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtools/@cglinedragger/cglinedragger.m

    function h = cglinedragger(varargin)
%CGLINEDRAGGER Construct a new cglinedragger instance
%
%  obj = cglinedragger(PROP, VAL, ...) constructs a new cglinedragger
%  object and specifies property-value pairs.

%  Copyright 2000-2013 The MathWorks, Inc. and Ford Global Technologies, Inc.


h = cgtools.cglinedragger;
if ~isempty(varargin)
    set(h, varargin{:});
end

% find parent
if isempty(h.Parent)
    h.Parent = gca;
end

% Construct line and picker line
h.LineHandle = line('Parent', h.Parent, ...
    'Visible', h.Visible, ...
    'Marker', 'o', ...
    'MarkerSize', 6, ...
    'Color', 'b', ...
    'ButtonDownFcn', {@i_ButtonDown, h});
h.LockMarkersHandle = line('Parent', h.Parent, ...
    'Visible', h.Visible, ...
    'Marker','.',...
    'MarkerSize',18,...
    'LineStyle','none',...
    'Color', 'k', ...
    'XLimInclude', 'off', ...
    'YLimInclude', 'off', ...
    'ZLimInclude', 'off');
mbcgui.hgclassesutil.setNotPickable(h.LockMarkersHandle);

h.PickerHandle = line('Parent', h.Parent, ...
    'Visible', 'off', ...
    'LineWidth', 3, ...
    'HitTest', 'off', ...
    'Marker', 'none', ...
    'Color', 'b', ...
    'XLimInclude', 'off', ...
    'YLimInclude', 'off', ...
    'ZLimInclude', 'off');
mbcgui.hgclassesutil.setNotPickable(h.PickerHandle);
SC = xregGui.SystemColorsDbl;
h.SelectedHandle = line('Parent', h.Parent, ...
    'LineStyle', 'none', ...
    'Marker', 'o', ...
    'MarkerEdgeColor', SC.WINDOW_BG, ...
    'MarkerFaceColor', SC.TITLE_ACTIVE_BG);
mbcgui.hgclassesutil.setNotPickable(h.SelectedHandle);


List.Delete = handle.listener(h,'ObjectBeingDestroyed', ...
    {@i_delete,[h.LineHandle h.LockMarkersHandle h.PickerHandle]});
List.HGDelete = mbcgui.hgclassesutil.listener([h.LineHandle h.LockMarkersHandle h.PickerHandle], ...
    'ObjectBeingDestroyed', mbcutils.callback(@i_deleteself, h));
List.VisSet = handle.listener(h,h.findprop('Visible'),'PropertyPostSet', ...
    {@i_visibleset,[h.LineHandle h.LockMarkersHandle]});

DataProps = [h.findprop('XData'), h.findprop('YData'), h.findprop('LockData')];
List.DataSet = handle.listener(h,DataProps,'PropertyPostSet',{@i_dataset,h});

h.Listeners = List;

h.pUpdateData;


function i_ButtonDown(src, evt, h)
h.pButtonDown;

function i_dataset(src, evt, h)
h.pUpdateData;

function i_delete(src, evt, hObjects)
ax = src.Parent;
if isgraphics(ax) && ~mbcgui.util.isBeingDestroyed(ax)
    delete(hObjects(isgraphics(hObjects)));
end

function i_deleteself(src, evt, h)
delete(h);

function i_visibleset(src,evt,hLines)
set(hLines, 'Visible', evt.NewValue);