【源码】MouseTracking:追踪鼠标指针位置的自动数据提示

在这里插入图片描述

主要特点:

•不需要参数传递。直接从绘图界面中提取所有值。

•鼠标点击或移动时直接产生反应。

•显示最接近鼠标指针的数据点,无距离限制。

•在曲线上与鼠标指针保持一定距离。

•为每条曲线显示一个单独的数据提示标题。

•将曲线的颜色复制为数据提示的方框颜色。

•也可以在GUIs中工作。

Features:

• No arguments to pass over. Retrieves all values out of the plot.

• Reaction on mouse click or mouse move.

• Displays the data point closest to the mouse pointer with no distance limit.

• Sticks on a curve by a certain distance to the mouse pointer.

• Displays for each curve an individual data tip title.

• Replicates the color of the curve as box color of data tip.

• Works also in GUIs.

局限性:

•二维绘图

•一个x轴,不反转,线性或对数。

•一个或两个y轴,不反转,线性或对数。

Limitations:

• 2D plot

• One x-axis, not reversed, linear or log.

• One or two y-axes, not reversed, linear or log.

Method:

• Get the mouse pointer location

• Retrieve all data out of the plot

• Translation of all data point to centimeters

• Translation of mouse pointer location to cm

• Set origin at mouse pointer location

• Translation to polar coordinates

• Determine closest point

• Translation of this point to normalized coordinates

• Display data tip

Manual:

Copy the principal of the examples for regular figure or GUI.

Note: Data tip title is stored in the plot UserData.

使用示例:

Short example:

hFig = figure;

plot(1:.1:2,2:.1:3,‘UserData’,‘My data tip title’);

%Track by mouse click:

set(hFig,‘windowbuttondownfcn’,@MouseTracking);

%Track by mouse move:

% set(h,‘windowbuttonmotionfcn’,@MouseTracking);

*) Remark to sticking:

The default value (delta) for sticking on a curve is 2 mm.

Example:

We work with polar coordinates. Only distances are relevant.

The origin is at the mouse pointer location.

With

dc: distance current curve point to mouse

dn: distance of next curve point to mouse

this holds:

dn < dc-delta, dn must be closer to the mouse pointer by delta.

Let us assume the two data points are 1 cm apart: dn-dc=1 cm

Then the next curve point dn must be closer than 0.4 cm to the mouse pointer in order to switch over to the next curve.

更多精彩文章请关注公众号:在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值