使用核心图,如何将接触点转换为图空间? [英] Using core-plot, how can you convert a touched point to the plot space?

查看:65
本文介绍了使用核心图,如何将接触点转换为图空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的图形,我想启用触摸功能,我的
第一部分正在工作:

I have a very simple graph that I want to enable touch on, I have the first part working:

plotSpace.delegate = self;

plotSpace.delegate = self;

以及方法:

-(BOOL)plotSpace:(CPPlotSpace *)space
shouldHandlePointingDeviceDownEvent:(id)event atPoint:(CGPoint)point
{
    NSLog(@"touched at: x: %f y: %f", point.x, point.y);
}

如何将点 point转换为图形的绘图空间?

How do I convert the point "point" to the plot space of my graph?

我可以看到这些方法,但是我不确定如何使用它们,doco,
虽然很大,但对它们的描述还不够好:)

I can see the methods, but Im unsure on how to use them, the doco, although large, doesnt really describe them well enough :)

非常感谢
标记

Thanks a lot Mark

推荐答案

承认,我忘记了这个问题,感谢史蒂夫的答复。

I have to admit, I forgot about this question, thanks for the reply Steve.

我也确实解决了它,这是我的实现(即扩展 CPXYGraph

I did get it solved too, here is my implementation (im extending CPXYGraph)

-(BOOL)plotSpace:(CPPlotSpace *)space shouldHandlePointingDeviceDownEvent:(id)event atPoint:(CGPoint)point {

    CPScatterPlot *plot = (CPScatterPlot*)[[self allPlots] objectAtIndex: 0];
    CGPoint pointInPlotArea = [plot convertPoint:point toLayer:plot];

    if ([plot containsPoint:pointInPlotArea]) {
        CPXYPlotSpace *plotSpace = (CPXYPlotSpace*)[self defaultPlotSpace];
        NSDecimal touchDataPoint[2];
        [plotSpace plotPoint:touchDataPoint forPlotAreaViewPoint:pointInPlotArea];
    }
}

touchDataPoint然后包含用户触摸过的坐标。

touchDataPoint then contains the coords that the user has touched.

这篇关于使用核心图,如何将接触点转换为图空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆