本文整理汇总了C++中QwtPlot::setAxisAutoScale方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlot::setAxisAutoScale方法的具体用法?C++ QwtPlot::setAxisAutoScale怎么用?C++ QwtPlot::setAxisAutoScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlot
的用法示例。
在下文中一共展示了QwtPlot::setAxisAutoScale方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paint
void PlotItem::paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget*)
{
const auto& rect = option->rect;
#else
void PlotItem::paint (QPainter *painter)
{
const auto& rect = contentsBoundingRect ().toRect ();
#endif
QwtPlot plot;
plot.setFrameShape (QFrame::NoFrame);
plot.enableAxis (QwtPlot::yLeft, LeftAxisEnabled_);
plot.enableAxis (QwtPlot::xBottom, BottomAxisEnabled_);
plot.setAxisTitle (QwtPlot::yLeft, LeftAxisTitle_);
plot.setAxisTitle (QwtPlot::xBottom, BottomAxisTitle_);
plot.resize (rect.size ());
auto setPaletteColor = [&plot] (const QColor& color, QPalette::ColorRole role) -> void
{
if (!color.isValid ())
return;
auto pal = plot.palette ();
pal.setColor (role, { color });
plot.setPalette (pal);
};
setPaletteColor (BackgroundColor_, QPalette::Window);
setPaletteColor (TextColor_, QPalette::WindowText);
setPaletteColor (TextColor_, QPalette::Text);
if (!PlotTitle_.isEmpty ())
plot.setTitle (QwtText { PlotTitle_ });
if (MinYValue_ < MaxYValue_)
{
plot.setAxisAutoScale (QwtPlot::yLeft, false);
plot.setAxisScale (QwtPlot::yLeft, MinYValue_, MaxYValue_);
}
plot.setAutoFillBackground (false);
plot.setCanvasBackground (Qt::transparent);
if (YGridEnabled_)
{
auto grid = new QwtPlotGrid;
grid->enableYMin (YMinorGridEnabled_);
grid->enableX (false);
#if QWT_VERSION >= 0x060100
grid->setMajorPen (QPen (GridLinesColor_, 1, Qt::SolidLine));
grid->setMinorPen (QPen (GridLinesColor_, 1, Qt::DashLine));
#else
grid->setMajPen (QPen (GridLinesColor_, 1, Qt::SolidLine));
grid->setMinPen (QPen (GridLinesColor_, 1, Qt::DashLine));
#endif
grid->attach (&plot);
}
auto items = Multipoints_;
if (items.isEmpty ())
items.push_back ({ Color_, Points_ });
if (MinXValue_ < MaxXValue_)
plot.setAxisScale (QwtPlot::xBottom, MinXValue_, MaxXValue_);
else if (const auto ptsCount = items.first ().Points_.size ())
plot.setAxisScale (QwtPlot::xBottom, 0, ptsCount - 1);
std::vector<std::unique_ptr<QwtPlotCurve>> curves;
for (const auto& item : items)
{
curves.emplace_back (new QwtPlotCurve);
const auto curve = curves.back ().get ();
curve->setPen (QPen (item.Color_));
auto transpColor = item.Color_;
transpColor.setAlphaF (Alpha_);
curve->setBrush (transpColor);
curve->setRenderHint (QwtPlotItem::RenderAntialiased);
curve->attach (&plot);
curve->setSamples (item.Points_.toVector ());
}
plot.replot ();
QwtPlotRenderer {}.render (&plot, painter, rect);
const auto xExtent = CalcXExtent (plot);
const auto yExtent = CalcYExtent (plot);
if (xExtent != XExtent_ || yExtent != YExtent_)
{
XExtent_ = xExtent;
YExtent_ = yExtent;
emit extentsChanged ();
}
}