本文整理汇总了C++中QwtPlotMarker::setLabel方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotMarker::setLabel方法的具体用法?C++ QwtPlotMarker::setLabel怎么用?C++ QwtPlotMarker::setLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotMarker
的用法示例。
在下文中一共展示了QwtPlotMarker::setLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clear
void Plot::clear()
{
this->detachItems();
pointsArr.clear();
// ...a horizontal line at y = 1...
QwtPlotMarker *mY1 = new QwtPlotMarker();
mY1->setLabel( QString::fromLatin1( "y = 1" ) );
mY1->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
mY1->setLineStyle( QwtPlotMarker::HLine );
mY1->setYValue( 1.0 );
mY1->setLinePen(Qt::black, 1, Qt::DashLine);
mY1->attach( this );
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabel( QString::fromLatin1( "y = 0" ) );
mY->setLabelAlignment( Qt::AlignRight | Qt::AlignTop );
mY->setLineStyle( QwtPlotMarker::HLine );
mY->setYValue( 0.0 );
mY->attach( this );
// ...a vertical line at x = 0
QwtPlotMarker *mX = new QwtPlotMarker();
mX->setLabel( QString::fromLatin1( "x = 0" ) );
mX->setLabelAlignment( Qt::AlignLeft | Qt::AlignBottom );
mX->setLabelOrientation( Qt::Vertical );
mX->setLineStyle( QwtPlotMarker::VLine );
mX->setLinePen( Qt::black, 0, Qt::DashDotLine );
mX->setXValue( 0 );
mX->attach( this );
}
示例2: setTitle
Plot::Plot()
{
setTitle("A Simple QwtPlot Demonstration");
insertLegend(new QwtLegend(), QwtPlot::RightLegend);
// Set axis titles
setAxisTitle(xBottom, "x -->");
setAxisTitle(yLeft, "y -->");
// Insert new curves
QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)");
#if QT_VERSION >= 0x040000
cSin->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
cSin->setPen(QPen(Qt::red));
cSin->attach(this);
QwtPlotCurve *cCos = new QwtPlotCurve("y = cos(x)");
#if QT_VERSION >= 0x040000
cCos->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
cCos->setPen(QPen(Qt::blue));
cCos->attach(this);
// Create sin and cos data
const int nPoints = 100;
cSin->setData(SimpleData(::sin, nPoints));
cCos->setData(SimpleData(::cos, nPoints));
// Insert markers
// ...a horizontal line at y = 0...
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabel(QString::fromLatin1("y = 0"));
mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mY->setLineStyle(QwtPlotMarker::HLine);
mY->setYValue(0.0);
mY->attach(this);
// ...a vertical line at x = 2 * pi
QwtPlotMarker *mX = new QwtPlotMarker();
mX->setLabel(QString::fromLatin1("x = 2 pi"));
mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
mX->setLabelOrientation(Qt::Vertical);
mX->setLineStyle(QwtPlotMarker::VLine);
mX->setLinePen(QPen(Qt::black, 0, Qt::DashDotLine));
mX->setXValue(2.0 * M_PI);
mX->attach(this);
}
示例3: mouseReleaseEvent
void Variog_plot::mouseReleaseEvent(QMouseEvent * event)
{
std::cerr << "show_pairs_count() called " << std::endl;
if( event->button() != Qt::RightButton ) return;
const float offset=1.02;
QFont font;
font.setPointSize( 7 );
if( !pairs_shown_ ) {
for( unsigned int i=0; i < pairs_.size(); i++ ) {
QString label;
label.setNum( pairs_[i] );
QwtText T(label);
QwtPlotMarker * marker = new QwtPlotMarker();
marker->attach(this);
T.setFont(font);
marker->setValue(pairs_coord_x_[i], pairs_coord_y_[i]*offset);
marker->setLabel(T);
}
pairs_shown_ = true;
}
else {
detachItems(QwtPlotItem::Rtti_PlotMarker);
pairs_shown_ = false;
}
replot();
}
示例4: insertLineMarker
/*!
This function is a shortcut to insert a horizontal or vertical
line marker, dependent on the specified axis.
\param label Label
\param axis Axis to be attached
\return New key if the marker could be inserted, 0 if not.
*/
long QwtPlot::insertLineMarker(const QString &label, int axis)
{
QwtMarker::LineStyle lineStyle = QwtMarker::NoLine;
int xAxis = QwtPlot::xBottom;
int yAxis = QwtPlot::yLeft;
switch(axis)
{
case yLeft:
case yRight:
yAxis = axis;
lineStyle = QwtMarker::HLine;
break;
case xTop:
case xBottom:
xAxis = axis;
lineStyle = QwtMarker::VLine;
break;
}
QwtPlotMarker *marker = new QwtPlotMarker(this);
if ( marker == 0 )
return 0;
marker->setAxis(xAxis, yAxis);
marker->setLabel(label);
marker->setLineStyle(lineStyle);
marker->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
long key = insertMarker(marker);
if ( key == 0 )
delete marker;
return key;
}
示例5: loadSweep
void SweepInspector::loadSweep(int index) {
//load in new sweep values from data
if (data == NULL) return;
if ( (index < 0) || (index >= data->getNumSweeps())) return;
//remove old data and get new
if (d_curve) d_curve->attach(NULL);
detachItems();
fsweep sweep = data->getSweep(index);
d_curve = new QwtPlotCurve( data->timestampFromIndex(index) ); //Qwt will delete() this when its done with it
d_curve->setRenderHint( QwtPlotItem::RenderAntialiased );
d_curve->setStyle( QwtPlotCurve::Lines );
d_curve->setPen( QColor( Qt::yellow ), 2, Qt::SolidLine );
d_curve->setSamples( sweep );
d_curve->attach(this);
QwtInterval frange = data->limits(FREQ);
//setAxisScale(QwtPlot::xBottom, frange.minValue(), frange.maxValue(), (frange.maxValue() - frange.minValue())/ 5.0);
//setAxisScale(QwtPlot::yLeft, -135, 20, 10.0);
setTitle( QString("RF Sweep @ %1").arg(data->timestampFromIndex(index)) );
//set maximum zoom out
zoomer->setZoomBase(QRectF(QPointF(frange.minValue(), 40), QPointF(frange.maxValue(), -135)));
zoomer->zoomBase();
//find max, min, and average values and drop it on plot as well
double max = sweep.first().y(), min = sweep.first().y(), avg=0;
for(int i=0; i < sweep.size(); i++) {
max = std::max(max, sweep.at(i).y());
min = std::min(min, sweep.at(i).y());
avg += sweep.at(i).y();
} avg /= sweep.size();
//add markers onto the plot
QwtPlotMarker *one = new QwtPlotMarker(), *two = new QwtPlotMarker();
one->attach(this); one->setAxes(QwtPlot::xTop, QwtPlot::yRight);
two->attach(this); two->setAxes(QwtPlot::xTop, QwtPlot::yRight);
QwtText tone = QwtText(QString("Max: %1 dBm\nMin: %2 dBm\nAvg: %3 dBm").arg(max).arg(min).arg(avg));
tone.setFont( QFont( "Helvetica", 10, QFont::Bold ) );
tone.setColor( Qt::green );
tone.setRenderFlags(Qt::AlignTop | Qt::AlignLeft);
one->setLabel(tone);
one->setValue(0, 10);
one->setLabelAlignment(Qt::AlignBottom | Qt::AlignRight);
QwtText ttwo(data->plotText());
ttwo.setFont( QFont( "Helvetica", 10, QFont::Bold ) );
ttwo.setColor( Qt::white );
ttwo.setRenderFlags(Qt::AlignBottom | Qt::AlignRight);
two->setLabel(ttwo);
two->setValue(10, 10);
two->setLabelAlignment(Qt::AlignBottom | Qt::AlignLeft);
replot();
repaint();
}
示例6: dodaj_naj
void wykres::dodaj_naj(double d) {
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabel(QString::fromLatin1("Osobnik najlepszy = ")+QString::number(-d));
mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mY->setLineStyle(QwtPlotMarker::HLine);
mY->setYValue(-d);
mY->attach(this);
}
示例7: setMarkerLabel
/*!
\brief Set the marker label
\param key Marker key
\param text the label text
\param font the font of the label text
\param color the color of the label text
\param pen the pen of the bounding box of the label text
\param brush the brush of the bounding box of the label text
\return \c TRUE if the specified marker exists
*/
bool QwtPlot::setMarkerLabel(long key, const QString &text, const QFont &font,
const QColor &color, const QPen &pen, const QBrush &brush)
{
QwtPlotMarker *m;
if ((m = d_markers->find(key)))
{
m->setLabel(text, font, color, pen, brush);
return TRUE;
}
return FALSE;
}
示例8: setExtraCaption
/**
* Dodaje dodatkowy opis wykresu.
*
* @param caption opis wykresu
* @param x pozycja na wykresie w skali czasu
* @param y pozycja na wykresie w skali pionowej (np. częstotliwości)
*/
void SpectrogramPlot::setExtraCaption(QString caption, double x, double y)
{
QwtPlotMarker* marker = new QwtPlotMarker();
QwtText label(caption);
label.setColor(QColor::fromRgba(0x88FFFFFF));
label.setFont(QFont("Arial", 10, QFont::Bold));
marker->setLabel(label);
marker->setLineStyle(QwtPlotMarker::NoLine);
marker->setValue(x, y);
marker->setLabelAlignment(Qt::AlignRight | Qt::AlignBottom);
marker->attach(this);
}
示例9: populate
void Plot::populate()
{
// Insert new curves
QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)");
cSin->setRenderHint(QwtPlotItem::RenderAntialiased);
cSin->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
cSin->setPen(QPen(Qt::red));
cSin->attach(this);
QwtPlotCurve *cCos = new QwtPlotCurve("y = cos(x)");
cCos->setRenderHint(QwtPlotItem::RenderAntialiased);
cCos->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
cCos->setPen(QPen(Qt::blue));
cCos->attach(this);
// Create sin and cos data
cSin->setData(new FunctionData(::sin));
cCos->setData(new FunctionData(::cos));
// Insert markers
// ...a horizontal line at y = 0...
QwtPlotMarker *mY = new QwtPlotMarker();
mY->setLabel(QString::fromLatin1("y = 0"));
mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
mY->setLineStyle(QwtPlotMarker::HLine);
mY->setYValue(0.0);
mY->attach(this);
// ...a vertical line at x = 2 * pi
QwtPlotMarker *mX = new QwtPlotMarker();
mX->setLabel(QString::fromLatin1("x = 2 pi"));
mX->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
mX->setLabelOrientation(Qt::Vertical);
mX->setLineStyle(QwtPlotMarker::VLine);
mX->setLinePen(QPen(Qt::black, 0, Qt::DashDotLine));
mX->setXValue(2.0 * M_PI);
mX->attach(this);
}
示例10: addText
void caStripPlot::addText(double x, double y, char* text, QColor c, int fontsize)
{
QwtPlotMarker *mY = new QwtPlotMarker();
QwtText txt;
txt.setText(text);
txt.setFont(QFont("Helvetica",fontsize, QFont::Bold));
txt.setColor(c);
mY->setLabel(txt);
mY->setLabelAlignment(Qt::AlignRight | Qt::AlignTop);
mY->setXValue(x);
mY->setYValue(y);
mY->attach(this);
replot();
}
示例11: insertMarker
/*!
\brief Insert a new marker
\param label Label
\param xAxis X axis to be attached
\param yAxis Y axis to be attached
\return New key if the marker could be inserted, 0 if not.
*/
long QwtPlot::insertMarker(const QString &label, int xAxis, int yAxis)
{
QwtPlotMarker *marker = new QwtPlotMarker(this);
if ( marker == 0 )
return 0;
marker->setAxis(xAxis, yAxis);
marker->setLabel(label);
long key = insertMarker(marker);
if ( key == 0 )
delete marker;
return key;
}
示例12: setInitialTimeDisplay
void MainWindow::setInitialTimeDisplay(int start)
{
std::size_t ncols = _vm["file.ncols"].as<int>();
std::size_t nrows = _vm["file.nrows"].as<int>();
//TODO: move plotting to appropiate method
std::size_t numofplottedsamples = _vm["plot.num.samples"].as<int>();
_gridPlot->p->detachItems();
_gridPlot->setoffset(start);
double interrowoffset = _vm["inter.row.offset"].as<double>();
for (std::size_t row=0; row<nrows; ++row){
// for (std::size_t row=0; row<1; ++row){
std::vector<double> xs(numofplottedsamples);
std::vector<double> ys(numofplottedsamples);
std::stringstream strst;
std::string strTitle = "Row";
strst << strTitle << "-" << row;
strTitle = strst.str();
QwtPlotCurve *tscurve = new QwtPlotCurve((char *)strTitle.c_str());
for (std::size_t x = 0; x < numofplottedsamples; ++x)
{
if (x+start<ncols){
xs[x] = (x+start)/_gridPlot->gridXpixelsperunit; //position in seconds
if (_bf!=NULL) {
ys[x] = row*interrowoffset + (*_bf)(row,x+start)/_gridPlot->gridYpixelsperunit; //y value of that sample
} else if (_bfsi!=NULL) {
ys[x] = row*interrowoffset + (*_bfsi)(row,x+start)/_gridPlot->gridYpixelsperunit; //y value of that sample
}
}
}
tscurve->setSamples(&xs[0],&ys[0],xs.size());
tscurve->setPen(QPen(Qt::black));
QwtPlotMarker *rowNameText = new QwtPlotMarker();
rowNameText->setLabel(QString(strTitle.c_str()));
rowNameText->setXValue(xs[0]+0.25);
rowNameText->setYValue(row*interrowoffset-0.5);
rowNameText->attach(_gridPlot->p);
tscurve->attach(_gridPlot->p);
}
_gridPlot->resetzoom();
}
示例13: addMarker
void Graph::addMarker(double val, const QColor &color, int axis)
{
QwtPlotMarker *m = new QwtPlotMarker();
m->setLineStyle(axis == QwtPlot::xBottom ? QwtPlotMarker::VLine : QwtPlotMarker::HLine);
m->setLinePen(QPen(color));
m->setYAxis(axis);
m->setValue(val, val);
m->attach(this);
m->setLabel(QString::number(val));
if(axis == QwtPlot::xBottom)
m->setLabelAlignment(Qt::AlignLeft | Qt::AlignVCenter);
else
m->setLabelAlignment(Qt::AlignTop | Qt::AlignHCenter);
getMarkers(axis).push_back(m);
}
示例14: drawHistogram
//.........这里部分代码省略.........
grid->setPen( mGridPen );
grid->attach( mpPlot );
// make colors list
mHistoColors.clear();
foreach ( QgsRendererRangeV2 range, mRanges )
{
mHistoColors << ( range.symbol() ? range.symbol()->color() : Qt::black );
}
//draw histogram
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
QwtPlotHistogram * plotHistogram = 0;
plotHistogram = createPlotHistogram( mRanges.count() > 0 ? mRanges.at( 0 ).label() : QString(),
mRanges.count() > 0 ? QBrush( mHistoColors.at( 0 ) ) : mBrush,
mRanges.count() > 0 ? Qt::NoPen : mPen );
#else
HistogramItem *plotHistogramItem = 0;
plotHistogramItem = createHistoItem( mRanges.count() > 0 ? mRanges.at( 0 ).label() : QString(),
mRanges.count() > 0 ? QBrush( mHistoColors.at( 0 ) ) : mBrush,
mRanges.count() > 0 ? Qt::NoPen : mPen );
#endif
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
QVector<QwtIntervalSample> dataHisto;
#else
// we safely assume that QT>=4.0 (min version is 4.7), therefore QwtArray is a QVector, so don't set size here
QwtArray<QwtDoubleInterval> intervalsHisto;
QwtArray<double> valuesHisto;
#endif
int bins = mBinsSpinBox->value();
QList<double> edges = mHistogram.binEdges( bins );
QList<int> counts = mHistogram.counts( bins );
int rangeIndex = 0;
int lastValue = 0;
for ( int bin = 0; bin < bins; ++bin )
{
int binValue = counts.at( bin );
//current bin crosses two graduated ranges, so we split between
//two histogram items
if ( rangeIndex < mRanges.count() - 1 && edges.at( bin ) > mRanges.at( rangeIndex ).upperValue() )
{
rangeIndex++;
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
plotHistogram->setSamples( dataHisto );
plotHistogram->attach( mpPlot );
plotHistogram = createPlotHistogram( mRanges.at( rangeIndex ).label(), mHistoColors.at( rangeIndex ) );
dataHisto.clear();
dataHisto << QwtIntervalSample( lastValue, mRanges.at( rangeIndex - 1 ).upperValue(), edges.at( bin ) );
#else
plotHistogramItem->setData( QwtIntervalData( intervalsHisto, valuesHisto ) );
plotHistogramItem->attach( mpPlot );
plotHistogramItem = createHistoItem( mRanges.at( rangeIndex ).label(), mHistoColors.at( rangeIndex ) );
intervalsHisto.clear();
valuesHisto.clear();
intervalsHisto.append( QwtDoubleInterval( mRanges.at( rangeIndex - 1 ).upperValue(), edges.at( bin ) ) );
valuesHisto.append( lastValue );
#endif
}
double upperEdge = mRanges.count() > 0 ? qMin( edges.at( bin + 1 ), mRanges.at( rangeIndex ).upperValue() )
: edges.at( bin + 1 );
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
dataHisto << QwtIntervalSample( binValue, edges.at( bin ), upperEdge );
#else
intervalsHisto.append( QwtDoubleInterval( edges.at( bin ), upperEdge ) );
valuesHisto.append( double( binValue ) );
#endif
lastValue = binValue;
}
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
plotHistogram->setSamples( dataHisto );
plotHistogram->attach( mpPlot );
#else
plotHistogramItem->setData( QwtIntervalData( intervalsHisto, valuesHisto ) );
plotHistogramItem->attach( mpPlot );
#endif
mRangeMarkers.clear();
foreach ( QgsRendererRangeV2 range, mRanges )
{
QwtPlotMarker* rangeMarker = new QwtPlotMarker();
rangeMarker->attach( mpPlot );
rangeMarker->setLineStyle( QwtPlotMarker::VLine );
rangeMarker->setXValue( range.upperValue() );
rangeMarker->setLabel( QString::number( range.upperValue() ) );
rangeMarker->setLabelOrientation( Qt::Vertical );
rangeMarker->setLabelAlignment( Qt::AlignLeft | Qt::AlignTop );
rangeMarker->show();
mRangeMarkers << rangeMarker;
}
示例15: reset
void QwtPlotPrintFilter::reset(QwtPlotItem *item) const
{
if ( d_data->cache == 0 )
return;
const PrivateData::Cache &cache = *d_data->cache;
switch(item->rtti())
{
case QwtPlotItem::Rtti_PlotGrid:
{
QwtPlotGrid *grid = (QwtPlotGrid *)item;
QPen pen = grid->majPen();
pen.setColor(cache.gridColors[0]);
grid->setMajPen(pen);
pen = grid->minPen();
pen.setColor(cache.gridColors[1]);
grid->setMinPen(pen);
break;
}
case QwtPlotItem::Rtti_PlotCurve:
{
QwtPlotCurve *c = (QwtPlotCurve *)item;
QwtSymbol symbol = c->symbol();
if ( cache.curveSymbolPenColors.contains(c) )
{
symbol.setPen(cache.curveSymbolPenColors[c]);
}
if ( cache.curveSymbolBrushColors.contains(c) )
{
QBrush brush = symbol.brush();
brush.setColor(cache.curveSymbolBrushColors[c]);
symbol.setBrush(brush);
}
c->setSymbol(symbol);
if ( cache.curveColors.contains(c) )
{
QPen pen = c->pen();
pen.setColor(cache.curveColors[c]);
c->setPen(pen);
}
break;
}
case QwtPlotItem::Rtti_PlotMarker:
{
QwtPlotMarker *m = (QwtPlotMarker *)item;
if ( cache.markerFonts.contains(m) )
{
QwtText label = m->label();
label.setFont(cache.markerFonts[m]);
m->setLabel(label);
}
if ( cache.markerLabelColors.contains(m) )
{
QwtText label = m->label();
label.setColor(cache.markerLabelColors[m]);
m->setLabel(label);
}
if ( cache.markerLineColors.contains(m) )
{
QPen pen = m->linePen();
pen.setColor(cache.markerLineColors[m]);
m->setLinePen(pen);
}
QwtSymbol symbol = m->symbol();
if ( cache.markerSymbolPenColors.contains(m) )
{
QPen pen = symbol.pen();
pen.setColor(cache.markerSymbolPenColors[m]);
symbol.setPen(pen);
}
if ( cache.markerSymbolBrushColors.contains(m) )
{
QBrush brush = symbol.brush();
brush.setColor(cache.markerSymbolBrushColors[m]);
symbol.setBrush(brush);
}
m->setSymbol(symbol);
break;
}
default:
break;
}
}