本文整理汇总了C++中PlotCurve::y方法的典型用法代码示例。如果您正苦于以下问题:C++ PlotCurve::y方法的具体用法?C++ PlotCurve::y怎么用?C++ PlotCurve::y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlotCurve
的用法示例。
在下文中一共展示了PlotCurve::y方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: closestCurve
/**
* Returns the index of the closest curve to a point on the canvas.
* Also returns index of the nearest data point on that curve.
* @param xpos :: x coordinate of a point on the canvas in pixels.
* @param ypos :: y coordinate of a point on the canvas in pixels.
* @param dist :: ?
* @param point :: Output index of the nearest data point to the point with coordinates (xpos,ypos)
*/
int Plot::closestCurve(int xpos, int ypos, int &dist, int &point)
{
QwtScaleMap map[QwtPlot::axisCnt];
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
map[axis] = canvasMap(axis);
double dmin = std::numeric_limits<double>::max();
int key = -1;
for (QMap<int, QwtPlotItem *>::iterator iter = d_curves.begin(); iter != d_curves.end(); ++iter )
{
QwtPlotItem *item = (QwtPlotItem *)iter.data();
if (!item)
continue;
if(item->rtti() != QwtPlotItem::Rtti_PlotSpectrogram)
{
PlotCurve *c = (PlotCurve *)item;
DataCurve *dc = dynamic_cast<DataCurve *>(item);
if (dc)
{
if (c->type() != Graph::Function && dc->hasLabels() &&
dc->selectedLabels(QPoint(xpos, ypos))){
dist = 0;
return iter.key();
} else
dc->setLabelsSelected(false);
}
for (int i=0; i<c->dataSize(); i++)
{
double cx = map[c->xAxis()].xTransform(c->x(i)) - double(xpos);
double cy = map[c->yAxis()].xTransform(c->y(i)) - double(ypos);
double f = qwtSqr(cx) + qwtSqr(cy);
if (f < dmin && c->type() != Graph::ErrorBars)
{
dmin = f;
key = iter.key();
point = i;
}
}
}
}
dist = static_cast<int>(sqrt(dmin));
return key;
}