www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtools/@cgsurfacedragger/cgsurfacedragger.m
function h = cgsurfacedragger(varargin) %CGSURFACEDRAGGER Construct a new cgsurfacedragger instance % % obj = cgsurfacedragger(PROP, VAL, ...) constructs a new cgsurfacedragger % object and specifies property-value pairs. % Copyright 2000-2013 The MathWorks, Inc. and Ford Global Technologies, Inc. h = cgtools.cgsurfacedragger; if ~isempty(varargin) set(h, varargin{:}); end % find parent if isempty(h.Parent) h.Parent = gca; end % Create the line that marks locked points h.LockMarkersHandle = line(... 'Parent', h.Parent, ... 'Visible', h.Visible, ... 'Marker','.',... 'MarkerSize',15,... 'LineStyle','none',... 'Color', 'k', ... 'XLimInclude', 'off', ... 'YLimInclude', 'off', ... 'ZLimInclude', 'off'); mbcgui.hgclassesutil.setNotPickable(h.LockMarkersHandle); % Create the main surface h.SurfaceHandle = surface('Parent', h.Parent, ... 'FaceColor','interp',... 'Visible', h.Visible); % Create the line that is shown during drag-editing 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.SurfaceHandle h.LockMarkersHandle h.PickerHandle]}); List.HGDelete = mbcgui.hgclassesutil.listener([h.SurfaceHandle h.LockMarkersHandle h.PickerHandle], ... 'ObjectBeingDestroyed', mbcutils.callback(@i_deleteself, h)); List.VisSet = handle.listener(h,h.findprop('Visible'),'PropertyPostSet', ... {@i_visibleset,[h.SurfaceHandle h.LockMarkersHandle]}); DataProps = [h.findprop('XData'), h.findprop('YData'), h.findprop('ZData'), h.findprop('LockData')]; List.DataSet = handle.listener(h,DataProps,'PropertyPostSet',{@i_dataset,h}); h.Listeners = List; h.pUpdateData; function i_dataset(src, evt, h) h.pUpdateData; function i_deleteself(src, evt, h) delete(h); function i_delete(src, evt, hObjects) ax = src.Parent; if isgraphics(ax) && ~mbcgui.util.isBeingDestroyed(ax) delete(hObjects(isgraphics(hObjects))); end function i_visibleset(src, evt, hObjects) set(hObjects, 'Visible', evt.NewValue);