www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtradeoffgui/@tradeoffGraphView/pPerformClick.m
function pPerformClick(obj) %PPERFORMCLICK React to a mouse click on the object % % PPERFORMCLICK(OBJ) is called in response to a mouse click on the object. % Copyright 2000-2013 The MathWorks, Inc. and Ford Global Technologies, Inc. hFig = ancestor(obj.Parent, 'figure'); % Get point of click in figure pt = get(hFig, 'CurrentPoint'); pt = mbcgui.util.convertLocation(pt, obj.Display); cellindex = obj.hGraphTable.getCellAt(pt(1), pt(2)); if all(cellindex>0) && ~obj.hDataModel.IsBlank(cellindex(1), cellindex(2)); % Only accepts clicks that happen in the main cell area of the table seltype = get(hFig, 'SelectionType'); R = cellindex(1); C = cellindex(2); if ~strcmp(seltype, 'open') % Prevent current graph selection on the second click of an open % action oldR = obj.hDataModel.SelectedRow; oldC = obj.hDataModel.SelectedColumn; if oldR~=R || oldC~=C obj.pUpdateSelection(R, C); % Repaint the old and new cells and corresponding headers obj.hGraphTable.paintCell(oldR, oldC); obj.hGraphTable.paintCell(0, oldC); obj.hGraphTable.paintCell(oldR, 0); obj.hGraphTable.paintCell(R, C); obj.hGraphTable.paintCell(0, C); obj.hGraphTable.paintCell(R, 0); end end if strcmp(seltype, 'extend') % User draws a selection box and this is used to zoom the current % graph. Note that we are using rbbox here, which assumes the % correct figure is current. pt = get(hFig,'CurrentPoint'); drawn_rect = rbbox([pt(1),pt(2),0,0]); hDisplay = obj.hGraphTable.getObjectAt(R, C); if ~isempty(hDisplay) fract = hDisplay.getZoomFractions(drawn_rect); obj.hDataModel.zoom(R, C, fract{1}, fract{2}); obj.hGraphTable.paintColumns(C); if obj.ShowCommonYAxis obj.hGraphTable.paintRows(R); end end elseif strcmp(seltype, 'open') % Reset the zoom for the current graph obj.hDataModel.resetZoom(R, C); obj.hGraphTable.paintColumns(C); if obj.ShowCommonYAxis obj.hGraphTable.paintRows(R); end end end