本文整理汇总了C++中QwtPlotCurve::closestPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotCurve::closestPoint方法的具体用法?C++ QwtPlotCurve::closestPoint怎么用?C++ QwtPlotCurve::closestPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotCurve
的用法示例。
在下文中一共展示了QwtPlotCurve::closestPoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectClosestCurve
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuSummaryQwtPlot::selectClosestCurve(const QPoint& pos)
{
QwtPlotCurve* closestCurve = NULL;
double distMin = DBL_MAX;
const QwtPlotItemList& itmList = itemList();
for(QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++)
{
if((*it)->rtti() == QwtPlotItem::Rtti_PlotCurve)
{
QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>(*it);
double dist = DBL_MAX;
candidateCurve->closestPoint(pos, &dist);
if(dist < distMin)
{
closestCurve = candidateCurve;
distMin = dist;
}
}
}
if(closestCurve && distMin < 20)
{
RimSummaryCurve* selectedCurve = m_plotDefinition->findRimCurveFromQwtCurve(closestCurve);
if(selectedCurve)
{
RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(selectedCurve);
}
}
}
示例2: closestCurvePoint
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QPointF RiuSummaryQwtPlot::closestCurvePoint(const QPoint& cursorPosition, QString* valueString, QString* timeString, int* yAxis) const
{
QPointF samplePoint;
QwtPlotCurve* closestCurve = nullptr;
double distMin = DBL_MAX;
int closestPointSampleIndex = -1;
const QwtPlotItemList& itmList = itemList();
for (QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++)
{
if ((*it)->rtti() == QwtPlotItem::Rtti_PlotCurve)
{
QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>(*it);
double dist = DBL_MAX;
int candidateSampleIndex = candidateCurve->closestPoint(cursorPosition, &dist);
if (dist < distMin)
{
closestCurve = candidateCurve;
distMin = dist;
closestPointSampleIndex = candidateSampleIndex;
}
}
}
if (closestCurve && distMin < 50)
{
samplePoint = closestCurve->sample(closestPointSampleIndex);
if (yAxis) *yAxis = closestCurve->yAxis();
}
if (timeString)
{
const QwtScaleDraw* timeAxisScaleDraw = axisScaleDraw(QwtPlot::xBottom);
if (timeAxisScaleDraw)
{
*timeString = timeAxisScaleDraw->label(samplePoint.x()).text();
}
}
if (valueString && closestCurve)
{
const QwtScaleDraw* yAxisScaleDraw = axisScaleDraw(closestCurve->yAxis());
if (yAxisScaleDraw)
{
*valueString = yAxisScaleDraw->label(samplePoint.y()).text();
}
}
return samplePoint;
}
示例3: select
void CanvasPicker::select( const QPoint &pos )
{
QwtPlotCurve *curve = NULL;
double dist = 10e10;
int index = -1;
const QwtPlotItemList& itmList = plot()->itemList();
for ( QwtPlotItemIterator it = itmList.begin();
it != itmList.end(); ++it )
{
if ( ( *it )->rtti() == QwtPlotItem::Rtti_PlotCurve )
{
QwtPlotCurve *c = static_cast<QwtPlotCurve *>( *it );
double d;
int idx = c->closestPoint( pos, &d );
if ( d < dist )
{
curve = c;
index = idx;
dist = d;
}
}
}
showCursor( false );
d_selectedCurve = NULL;
d_selectedPoint = -1;
if ( curve && dist < 10 ) // 10 pixels tolerance
{
d_selectedCurve = curve;
d_selectedPoint = index;
showCursor( true );
}
}