本文整理汇总了C++中QwtPlot::enableAxis方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlot::enableAxis方法的具体用法?C++ QwtPlot::enableAxis怎么用?C++ QwtPlot::enableAxis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlot
的用法示例。
在下文中一共展示了QwtPlot::enableAxis方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateLayout
void PlotMatrix::updateLayout()
{
for ( int row = 0; row < numRows(); row++ )
{
for ( int col = 0; col < numColumns(); col++ )
{
QwtPlot *p = plot( row, col );
if ( p )
{
bool showAxis[QwtPlot::axisCnt];
showAxis[QwtPlot::xBottom] =
axisEnabled( QwtPlot::xBottom ) && row == numRows() - 1;
showAxis[QwtPlot::xTop] =
axisEnabled( QwtPlot::xTop ) && row == 0;
showAxis[QwtPlot::yLeft] =
axisEnabled( QwtPlot::yLeft ) && col == 0;
showAxis[QwtPlot::yRight] =
axisEnabled( QwtPlot::yRight ) && col == numColumns() - 1;
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop )
p->enableAxis( axis, showAxis[axis] );
else
{
p->enableAxis( axis, true );
QwtScaleDraw *sd = p->axisScaleDraw( axis );
sd->enableComponent(
QwtScaleDraw::Backbone, showAxis[axis] );
sd->enableComponent(
QwtScaleDraw::Ticks, showAxis[axis] );
sd->enableComponent(
QwtScaleDraw::Labels, showAxis[axis] );
}
}
}
}
}
for ( int col = 0; col < numColumns(); col++ )
{
alignVAxes( col, QwtPlot::yLeft );
alignVAxes( col, QwtPlot::yRight );
}
for ( int row = 0; row < numRows(); row++ )
{
for ( int col = 0; col < numColumns(); col++ )
{
QwtPlot *p = plot( row, col );
if ( p )
p->replot();
}
}
}
示例2: main
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QwtPlot plot;
plot.setCanvasBackground(QColor(Qt::white));
plot.setTitle("Bar Chart");
QwtPlotGrid *grid = new QwtPlotGrid;
grid->enableX(false);
grid->enableYMin(true);
grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
grid->attach(&plot);
BarChartItem *item = new BarChartItem();
item->attach(&plot);
QList< QPair<int, QString> > barHeights;
barHeights.append(QPair<int, QString>(10, ""));
barHeights.append(QPair<int, QString>(100, ""));
barHeights.append(QPair<int, QString>(20, ""));
item->setData(barHeights);
plot.enableAxis(QwtPlot::xBottom, false);
plot.resize(600, 400);
plot.show();
return app.exec();
}
示例3: showColorScale
void Spectrogram::showColorScale(int axis, bool on)
{
if (hasColorScale() == on && color_axis == axis)
return;
QwtPlot *plot = this->plot();
if (!plot)
return;
QwtScaleWidget *colorAxis = plot->axisWidget(color_axis);
colorAxis->setColorBarEnabled(false);
color_axis = axis;
// We must switch main and the color scale axes and their respective scales
int xAxis = this->xAxis();
int yAxis = this->yAxis();
int oldMainAxis = yAxis;
if (axis == QwtPlot::xBottom || axis == QwtPlot::xTop)
{
oldMainAxis = xAxis;
xAxis = 5 - color_axis;
}
else if (axis == QwtPlot::yLeft || axis == QwtPlot::yRight)
{
oldMainAxis = yAxis;
yAxis = 1 - color_axis;
}
// First we switch axes
setAxis(xAxis, yAxis);
// Next we switch axes scales
QwtScaleDiv *scDiv = plot->axisScaleDiv(oldMainAxis);
if (axis == QwtPlot::xBottom || axis == QwtPlot::xTop)
plot->setAxisScale(xAxis, scDiv->lBound(), scDiv->hBound());
else if (axis == QwtPlot::yLeft || color_axis == QwtPlot::yRight)
plot->setAxisScale(yAxis, scDiv->lBound(), scDiv->hBound());
colorAxis = plot->axisWidget(color_axis);
plot->setAxisScale(color_axis, data().range().minValue(), data().range().maxValue());
colorAxis->setColorBarEnabled(on);
colorAxis->setColorMap(data().range(), colorMap());
if (!plot->axisEnabled(color_axis))
plot->enableAxis(color_axis);
colorAxis->show();
plot->updateLayout();
}
示例4: Plots_Create
//---------------------------------------------------------------------------
void Plots::Plots_Create(PlotType Type)
{
// Paddings
if (paddings[Type]==NULL)
{
paddings[Type]=new QWidget(this);
paddings[Type]->setVisible(false);
}
// General design of plot
QwtPlot* plot = new QwtPlot(this);
plot->setVisible(false);
plot->setMinimumHeight(1);
plot->enableAxis(QwtPlot::xBottom, Type==PlotType_Axis);
plot->setAxisMaxMajor(QwtPlot::yLeft, 0);
plot->setAxisMaxMinor(QwtPlot::yLeft, 0);
plot->setAxisScale(QwtPlot::xBottom, 0, FileInfoData->Videos[0]->x_Max[XAxis_Kind_index]);
if (PerPlotGroup[Type].Count>3)
plot->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// Plot grid
QwtPlotGrid *grid = new QwtPlotGrid();
grid->enableXMin(true);
grid->enableYMin(true);
grid->setMajorPen(Qt::darkGray, 0, Qt::DotLine );
grid->setMinorPen(Qt::gray, 0 , Qt::DotLine );
grid->attach(plot);
// Plot curves
for(unsigned j=0; j<PerPlotGroup[Type].Count; ++j)
{
plotsCurves[Type][j] = new QwtPlotCurve(PerPlotName[PerPlotGroup[Type].Start+j].Name);
QColor c;
switch (PerPlotGroup[Type].Count)
{
case 1 :
switch (Type)
{
case PlotType_YDiff: c=Qt::darkGreen; break;
case PlotType_UDiff: c=Qt::darkBlue; break;
case PlotType_VDiff: c=Qt::darkRed; break;
default: c=Qt::black;
}
break;
case 2 :
switch (j)
{
case 0: c=Qt::darkGreen; break;
case 1: c=Qt::darkRed; break;
default: c=Qt::black;
}
break;
case 3 :
switch (j)
{
case 0: c=Qt::darkRed; break;
case 1: c=Qt::darkBlue; break;
case 2: c=Qt::darkGreen; break;
default: c=Qt::black;
}
break;
case 5 :
switch (j)
{
case 0: c=Qt::red; break;
case 1: c=QColor::fromRgb(0x00, 0x66, 0x00); break; //Qt::green
case 2: c=Qt::black; break;
case 3: c=Qt::green; break;
case 4: c=Qt::red; break;
default: c=Qt::black;
}
break;
default: c=Qt::black;
}
plotsCurves[Type][j]->setPen(c);
plotsCurves[Type][j]->setRenderHint(QwtPlotItem::RenderAntialiased);
plotsCurves[Type][j]->setZ(plotsCurves[Type][j]->z()-j); //Invert data order (e.g. MAX before MIN)
plotsCurves[Type][j]->attach(plot);
}
// Legends
QwtLegend *legend = new QwtLegend(this);
legend->setVisible(false);
legend->setMinimumHeight(1);
legend->setMaxColumns(1);
QFont Font=legend->font();
#ifdef _WIN32
Font.setPointSize(6);
#else // _WIN32
Font.setPointSize(8);
#endif //_WIN32
legend->setFont(Font);
connect(plot, SIGNAL(legendDataChanged(const QVariant &, const QList<QwtLegendData> &)), legend, SLOT(updateLegend(const QVariant &, const QList<QwtLegendData> &)));
plot->updateLegend();
// Assignment
plots[Type]=plot;
//.........这里部分代码省略.........
示例5: 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 ();
}
}
示例6: main
int main(int argc, char *argv[])
{
// QGuiApplication a(argc, argv);
QApplication a(argc, argv);
QwtPlot *plot = new QwtPlot();
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setBorderRadius(10);
plot->setCanvas(canvas);
plot->setCanvasBackground(QColor("LIGHTGRAY"));
plot->enableAxis(QwtPlot::yRight);
plot->enableAxis(QwtPlot::xTop);
plot->setAxisTitle(QwtPlot::xBottom, "Xline");
plot->setAxisTitle(QwtPlot::xTop, "Xline");
plot->setAxisTitle(QwtPlot::yLeft, "Inline");
plot->setAxisTitle(QwtPlot::yRight, "Inline");
// float minx = srv->getStations().first().x();
// float maxx = srv->getStations().last().x();
plot->setAxisScale( QwtPlot::xBottom,3500,300);
// plot->setAxisScale( QwtPlot::xTop,minx,maxx );
// QwtScaleDraw *sd = axisScaleDraw( QwtPlot::yLeft );
// sd->setMinimumExtent( sd->extent( axisWidget( QwtPlot::yLeft )->font() ) );
plot->plotLayout()->setAlignCanvasToScales( true );
QFileDialog custDialog;
QStringList names = custDialog.getOpenFileNames(NULL, ("Open Files..."),QString(), ("UKOOA Files (*.p190 *.p90);;All Files (*)"));
// handle if the dialog was "Cancelled"
if(names.isEmpty())
{
return 0;
}
qSort(names.begin(), names.end());
QVector <QwtPlotCurve *> curves;
foreach (QString name, names)
{
QwtPlotCurve *vCurve = new QwtPlotCurve;
if(name.contains(QString( "NS1763")) || name.contains(QString("NS2029")))
{
QColor c = Qt::red;
vCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, Qt::red,c , QSize( 2, 2 ) ) );
}
else
{
QColor c = Qt::green;
vCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, Qt::green,c , QSize( 2, 2 ) ) );
}
vCurve->setStyle( QwtPlotCurve::NoCurve );
vCurve->setPen( Qt::gray );
cout << name.toStdString() << endl;
QVector<QPointF> curveData;
// m_nameLineLable->setText(m_names.at(0));
QFile *ukFile = new QFile(QString(name));
bool rt = ukFile->open(QIODevice::ReadOnly);
cout << "return " << rt << endl;
qint64 icount = 0;
qint64 fileSize = ukFile->size();
char *data = new char[fileSize];
ukFile->read(data,fileSize);
QString sData = data;
QString shot = "SNS";
while (true)
{
ukFile->seek(icount);
ukFile->read(data,fileSize);
sData = data;;
if(icount>=fileSize)
{
break;
}
auto sPos = sData.indexOf(shot,0,Qt::CaseInsensitive);
QString cr = sData.mid(sPos,19);
if(cr.contains("\n"))
{
sPos +=2;
}
// auto shotNo = sData.mid(sPos+20,sPos+5);
QString shotNo = sData.mid(sPos+19,6);
int shotNos;
if(shotNo.contains("\n") || shotNo.contains("\r"))
{
shotNo = sData.mid(sPos+19,8);
int shift1 = shotNo.indexOf("\r");
int shift = shotNo.indexOf("\n");
// cout << shift1 << " " << shift << endl;
QString tmp = shotNo.mid(0,shift1);
tmp.append(shotNo.mid(shift+1,3));
shotNos = tmp.toInt();
}
else
//.........这里部分代码省略.........