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

    function obj = mmSiteGraphView(varargin)
%MMSITEGRAPHVIEW Constructor for mmSiteGraphView objects
%
%  OBJ = MMSITEGRAPHVIEW(PROP, VAL, ...) constructs a new mmSiteGraphView
%  with the given property values.

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


if nargin && isa(varargin{1}, 'cgtradeoffgui.mmSiteGraphView')
   obj = varargin{1};
   varargin(1) = [];
else
   obj = cgtradeoffgui.mmSiteGraphView;
end

% Call the inherited constructor
obj.View(varargin{:});

% Create axes
obj.hAxesPanel = mbcgui.widget.AxesPanel(...
    'Parent', obj.Parent, ...
    'Visible', obj.Visible, ...
    'Border', [45 10 15 30]);
obj.hAxes = obj.hAxesPanel.AxesHandle;
set(obj.hAxes, ...
    'Box', 'on', ...
    'Units', 'pixels', ...
    'YDir', 'reverse', ...
    'XAxisLocation', 'top');

% Make tolerance patch first so it is underneath the lines
obj.hTolerancePatch = patch('Parent', obj.hAxes, ...
    'FaceColor', [.7 .7 1], ...
    'XData', [], ...
    'YData', []);

% Lines that display the breakpoints
obj.hXBPLine = line('Parent', obj.hAxes, ...
    'LineWidth', 2, ...
    'LineStyle', ':', ...
    'Color', [.4 .4 .6], ...
    'XData', [], ...
    'YData', []);
obj.hYBPLine = line('Parent', obj.hAxes, ...
    'LineWidth', 2, ...
    'LineStyle', ':', ...
    'Color', [.4 .4 .6], ...
    'XData', [], ...
    'YData', []);

% Context menus used to add/remove points
hAddSiteContext = uicontextmenu('Parent', obj.Parent);
uimenu(hAddSiteContext, ...
    'Label', '&Include Model Site', ...
    'Callback', {@i_addmodel, obj});
hRemoveSiteContext = uicontextmenu('Parent', obj.Parent);
uimenu(hRemoveSiteContext, ...
    'Label', '&Exclude Model Site', ...
    'Callback', {@i_removemodel, obj});

% Markers for the model sites
obj.hSiteHitLine = line('Parent', obj.hAxes, ...
    'LineStyle', 'none', ...
    'LineWidth', 2, ...
    'Marker', 'o', ...
    'MarkerEdgeColor', [0 0 1], ...
    'XData', [], ...
    'YData', [], ...
    'ButtonDownFcn', {@i_recordhit, obj}, ...
    'UIContextMenu', hRemoveSiteContext);
obj.hSiteMissedLine = line('Parent', obj.hAxes, ...
    'LineStyle', 'none', ...
    'LineWidth', 2, ...
    'Marker', 'x', ...
    'MarkerSize', 8, ...
    'MarkerEdgeColor', [1 0 0], ...
    'XData', [], ...
    'YData', [], ...
    'ButtonDownFcn', {@i_recordhit, obj}, ...
    'UIContextMenu', hRemoveSiteContext);
obj.hSiteExcludedLine = line('Parent', obj.hAxes, ...
    'LineStyle', 'none', ...
    'LineWidth', 2, ...
    'Marker', 'o', ...
    'MarkerEdgeColor', [.7 .7 .7], ...
    'XData', [], ...
    'YData', [], ...
    'ButtonDownFcn', {@i_recordhit, obj}, ...
    'UIContextMenu', hAddSiteContext);

% Hook up to the message service if it exists
if ~isempty(obj.MessageService)
    obj.pPostSetMessageService;
end


% Callbacks
function i_recordhit(src, evt, obj)
obj.pGetHitPoint;

function i_addmodel(src, evt, obj)
% Find model site that is closest to last hit point
idx = obj.pFindModelSite;
obj.MessageService.addSite(idx);

function i_removemodel(src, evt, obj)
idx = obj.pFindModelSite;
obj.MessageService.removeSite(idx);