本文整理汇总了C++中QwtPlotCurve::yAxis方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotCurve::yAxis方法的具体用法?C++ QwtPlotCurve::yAxis怎么用?C++ QwtPlotCurve::yAxis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotCurve
的用法示例。
在下文中一共展示了QwtPlotCurve::yAxis方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawCurve
/*!
\brief Draw a set of points of a curve.
When observing an measurement while it is running, new points have to be
added to an existing curve. drawCurve can be used to display them avoiding
a complete redraw of the canvas.
\param key curve key
\param from index of the first point to be painted
\param to index of the last point to be painted. If to < 0 the
curve will be painted to its last point.
\sa QwtCurve::draw
*/
void QwtPlot::drawCurve(long key, int from, int to)
{
QwtPlotCurve *curve = d_curves->find(key);
if ( !curve )
return;
QPainter p(canvas());
p.setClipping(TRUE);
p.setClipRect(canvas()->contentsRect());
curve->draw(&p,
canvasMap(curve->xAxis()), canvasMap(curve->yAxis()),
from, to);
if ( canvas()->cacheMode() && canvas()->cache())
{
QPainter cachePainter(canvas()->cache());
cachePainter.translate(-canvas()->contentsRect().x(),
-canvas()->contentsRect().y());
curve->draw(&cachePainter,
canvasMap(curve->xAxis()), canvasMap(curve->yAxis()),
from, to);
}
}
示例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: drawCanvas
//! Redraw grid, curves, and markers. The draw code
// does not clear clipRegion prior to painting.
// \param p painter used for drawing
void QwtPlot::drawCanvas(QPainter *p)
{
QwtDiMap map[axisCnt];
for ( int axis = 0; axis < axisCnt; axis++ )
map[axis] = canvasMap(axis);
QRect rect = d_canvas->contentsRect();
//
// draw grid
//
if ( d_grid.enabled() &&
axisEnabled( d_grid.xAxis() ) &&
axisEnabled( d_grid.yAxis() ) )
{
d_grid.draw(p, rect, map[d_grid.xAxis()], map[d_grid.yAxis()]);
}
//
// draw curves
//
QIntDictIterator<QwtPlotCurve> itc(*d_curves);
for (QwtPlotCurve *curve = itc.toFirst(); curve != 0; curve = ++itc )
{
if ( curve->enabled() &&
axisEnabled( curve->xAxis() ) &&
axisEnabled( curve->yAxis() ) )
{
curve->draw(p, map[curve->xAxis()], map[curve->yAxis()]);
}
}
//
// draw markers
//
QIntDictIterator<QwtPlotMarker> itm(*d_markers);
for (QwtPlotMarker *marker = itm.toFirst(); marker != 0; marker = ++itm )
{
if ( marker->enabled() && axisEnabled( marker->xAxis() ) &&
axisEnabled( marker->yAxis() ) )
{
marker->draw(p,
map[marker->xAxis()].transform(marker->xValue()),
map[marker->yAxis()].transform(marker->yValue()),
rect);
}
}
}
示例4: closestCurve
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 = 1.0e10;
int key = -1;
for (QMapIterator<int, QwtPlotCurve *> it = d_curves.begin(); it != d_curves.end(); ++it )
{
QwtPlotCurve *c = (QwtPlotCurve *)it.data();
if (!c)
continue;
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)
{
dmin = f;
key = it.key();
point = i;
}
}
}
dist = int(sqrt(dmin));
return key;
}
示例5: updateAxes
//! Rebuild the scales and maps
void QwtPlot::updateAxes()
{
int i;
bool resetDone[axisCnt];
for (i = 0; i < axisCnt; i++)
resetDone[i] = FALSE;
//
// Adjust autoscalers
//
QIntDictIterator<QwtPlotCurve> itc(*d_curves);
for (QwtPlotCurve *c = itc.toFirst(); c != 0; c = ++itc )
{
if (c->dataSize() > 0) // don't scale curves with no data
{ // (minXValue() et al. would return 0.0)
int axis = c->xAxis();
if ( !resetDone[axis] )
{
d_as[axis].reset();
resetDone[axis] = TRUE;
}
d_as[axis].adjust(c->minXValue(), c->maxXValue());
axis = c->yAxis();
if ( !resetDone[axis] )
{
d_as[axis].reset();
resetDone[axis] = TRUE;
}
d_as[axis].adjust(c->minYValue(), c->maxYValue());
}
}
//
// Adjust scales
//
for (i=0; i<axisCnt; i++)
{
d_sdiv[i] = d_as[i].scaleDiv();
d_scale[i]->setScaleDiv(d_sdiv[i]);
}
d_grid.setXDiv(d_sdiv[d_grid.xAxis()]);
d_grid.setYDiv(d_sdiv[d_grid.yAxis()]);
}
示例6: pen
void
MainWindow::sampleSeriesAdded(int index)
{
SampleSeries series = adapter->getSampleSeries(index);
QwtPlotCurve *curve = new QwtPlotCurve();
curve->setData(new SampleSeries(series));
curve->setTitle(SampleSeries::toString(series.unit()));
QPen pen(getColor(series.unit()));
pen.setWidth(3);
curve->setPen(pen);
ui->plot->enableAxis(curve->yAxis());
curve->attach(ui->plot);
}
示例7: drawCanvasItems
void QwtPlot::drawCanvasItems(QPainter *painter, const QRect &rect,
const QwtArray<QwtDiMap> &map, const QwtPlotPrintFilter &pfilter) const
{
//
// draw grid
//
if ( pfilter.options() & QwtPlotPrintFilter::PrintGrid )
{
if ( d_grid->enabled() )
{
d_grid->draw(painter, rect,
map[d_grid->xAxis()], map[d_grid->yAxis()]);
}
}
//
// draw curves
//
QwtPlotCurveIterator itc = curveIterator();
for (QwtPlotCurve *curve = itc.toFirst(); curve != 0; curve = ++itc )
{
if ( curve->enabled() )
{
curve->draw(painter,
map[curve->xAxis()], map[curve->yAxis()]);
}
}
//
// draw markers
//
QwtPlotMarkerIterator itm = markerIterator();
for (QwtPlotMarker *marker = itm.toFirst(); marker != 0; marker = ++itm )
{
if ( marker->enabled() )
{
marker->draw(painter,
map[marker->xAxis()].transform(marker->xValue()),
map[marker->yAxis()].transform(marker->yValue()),
rect);
}
}
}