本文整理汇总了C++中QwtLegendItem::setSymbol方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtLegendItem::setSymbol方法的具体用法?C++ QwtLegendItem::setSymbol怎么用?C++ QwtLegendItem::setSymbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtLegendItem
的用法示例。
在下文中一共展示了QwtLegendItem::setSymbol方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateLegend
//! Update the widget that represents the curve on the legend
void QwtPlotCurve::updateLegend(QwtLegend *legend) const
{
if ( !legend )
return;
QwtPlotItem::updateLegend(legend);
QWidget *widget = legend->find(this);
if ( !widget || !widget->inherits("QwtLegendItem") )
return;
QwtLegendItem *legendItem = (QwtLegendItem *)widget;
#if QT_VERSION < 0x040000
const bool doUpdate = legendItem->isUpdatesEnabled();
#else
const bool doUpdate = legendItem->updatesEnabled();
#endif
legendItem->setUpdatesEnabled(false);
const int policy = legend->displayPolicy();
if (policy == QwtLegend::FixedIdentifier)
{
int mode = legend->identifierMode();
if (mode & QwtLegendItem::ShowLine)
legendItem->setCurvePen(pen());
if (mode & QwtLegendItem::ShowSymbol)
legendItem->setSymbol(symbol());
if (mode & QwtLegendItem::ShowText)
legendItem->setText(title());
else
legendItem->setText(QwtText());
legendItem->setIdentifierMode(mode);
}
else if (policy == QwtLegend::AutoIdentifier)
{
int mode = 0;
if (QwtPlotCurve::NoCurve != style())
{
legendItem->setCurvePen(pen());
mode |= QwtLegendItem::ShowLine;
}
if (QwtSymbol::NoSymbol != symbol().style())
{
legendItem->setSymbol(symbol());
mode |= QwtLegendItem::ShowSymbol;
}
if ( !title().isEmpty() )
{
legendItem->setText(title());
mode |= QwtLegendItem::ShowText;
}
else
{
legendItem->setText(QwtText());
}
legendItem->setIdentifierMode(mode);
}
legendItem->setUpdatesEnabled(doUpdate);
legendItem->update();
}
示例2: reset
/*!
Reset color and fonts of a plot
\sa apply()
*/
void QwtPlotPrintFilter::reset(QwtPlot *plot) const
{
if ( d_data->cache == 0 )
return;
const bool doAutoReplot = plot->autoReplot();
plot->setAutoReplot(false);
const PrivateData::Cache &cache = *d_data->cache;
if ( plot->titleLabel() )
{
QwtTextLabel* title = plot->titleLabel();
if ( title->text().testPaintAttribute(QwtText::PaintUsingTextFont) )
{
QwtText text = title->text();
text.setColor(cache.titleColor);
title->setText(text);
}
else
{
QPalette palette = title->palette();
palette.setColor(
QPalette::Active, Palette::Text, cache.titleColor);
title->setPalette(palette);
}
if ( title->text().testPaintAttribute(QwtText::PaintUsingTextFont) )
{
QwtText text = title->text();
text.setFont(cache.titleFont);
title->setText(text);
}
else
{
title->setFont(cache.titleFont);
}
}
if ( plot->legend() )
{
#if QT_VERSION < 0x040000
QValueList<QWidget *> list = plot->legend()->legendItems();
for ( QValueListIterator<QWidget *> it = list.begin();
it != list.end(); ++it )
#else
QList<QWidget *> list = plot->legend()->legendItems();
for ( QList<QWidget*>::iterator it = list.begin();
it != list.end(); ++it )
#endif
{
QWidget *w = *it;
if ( cache.legendFonts.contains(w) )
w->setFont(cache.legendFonts[w]);
if ( w->inherits("QwtLegendItem") )
{
QwtLegendItem *label = (QwtLegendItem *)w;
const QwtPlotItem *plotItem =
(const QwtPlotItem*)plot->legend()->find(label);
QwtSymbol symbol = label->symbol();
if ( cache.curveSymbolPenColors.contains(plotItem) )
{
QPen pen = symbol.pen();
pen.setColor(cache.curveSymbolPenColors[plotItem]);
symbol.setPen(pen);
}
if ( cache.curveSymbolBrushColors.contains(plotItem) )
{
QBrush brush = symbol.brush();
brush.setColor(cache.curveSymbolBrushColors[plotItem]);
symbol.setBrush(brush);
}
label->setSymbol(symbol);
if ( cache.curveColors.contains(plotItem) )
{
QPen pen = label->curvePen();
pen.setColor(cache.curveColors[plotItem]);
label->setCurvePen(pen);
}
}
}
}
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
QwtScaleWidget *scaleWidget = plot->axisWidget(axis);
if ( scaleWidget )
{
QPalette palette = scaleWidget->palette();
palette.setColor(QPalette::Active, Palette::Foreground,
cache.scaleColor[axis]);
scaleWidget->setPalette(palette);
//.........这里部分代码省略.........
示例3: apply
/*!
Change color and fonts of a plot
\sa apply()
*/
void QwtPlotPrintFilter::apply(QwtPlot *plot) const
{
const bool doAutoReplot = plot->autoReplot();
plot->setAutoReplot(false);
delete d_data->cache;
d_data->cache = new PrivateData::Cache;
PrivateData::Cache &cache = *d_data->cache;
if ( plot->titleLabel() )
{
QPalette palette = plot->titleLabel()->palette();
cache.titleColor = palette.color(
QPalette::Active, Palette::Text);
palette.setColor(QPalette::Active, Palette::Text,
color(cache.titleColor, Title));
plot->titleLabel()->setPalette(palette);
cache.titleFont = plot->titleLabel()->font();
plot->titleLabel()->setFont(font(cache.titleFont, Title));
}
if ( plot->legend() )
{
#if QT_VERSION < 0x040000
QValueList<QWidget *> list = plot->legend()->legendItems();
for ( QValueListIterator<QWidget *> it = list.begin();
it != list.end(); ++it )
#else
QList<QWidget *> list = plot->legend()->legendItems();
for ( QList<QWidget*>::iterator it = list.begin();
it != list.end(); ++it )
#endif
{
QWidget *w = *it;
cache.legendFonts.insert(w, w->font());
w->setFont(font(w->font(), Legend));
if ( w->inherits("QwtLegendItem") )
{
QwtLegendItem *label = (QwtLegendItem *)w;
QwtSymbol symbol = label->symbol();
QPen pen = symbol.pen();
QBrush brush = symbol.brush();
pen.setColor(color(pen.color(), CurveSymbol));
brush.setColor(color(brush.color(), CurveSymbol));
symbol.setPen(pen);
symbol.setBrush(brush);
label->setSymbol(symbol);
pen = label->curvePen();
pen.setColor(color(pen.color(), Curve));
label->setCurvePen(pen);
}
}
}
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
QwtScaleWidget *scaleWidget = plot->axisWidget(axis);
if ( scaleWidget )
{
cache.scaleColor[axis] = scaleWidget->palette().color(
QPalette::Active, Palette::Foreground);
QPalette palette = scaleWidget->palette();
palette.setColor(QPalette::Active, Palette::Foreground,
color(cache.scaleColor[axis], AxisScale));
scaleWidget->setPalette(palette);
cache.scaleFont[axis] = scaleWidget->font();
scaleWidget->setFont(font(cache.scaleFont[axis], AxisScale));
cache.scaleTitle[axis] = scaleWidget->title();
QwtText scaleTitle = scaleWidget->title();
if ( scaleTitle.testPaintAttribute(QwtText::PaintUsingTextColor) )
{
cache.scaleTitleColor[axis] = scaleTitle.color();
scaleTitle.setColor(
color(cache.scaleTitleColor[axis], AxisTitle));
}
if ( scaleTitle.testPaintAttribute(QwtText::PaintUsingTextFont) )
{
cache.scaleTitleFont[axis] = scaleTitle.font();
scaleTitle.setFont(
font(cache.scaleTitleFont[axis], AxisTitle));
}
scaleWidget->setTitle(scaleTitle);
int startDist, endDist;
scaleWidget->getBorderDistHint(startDist, endDist);
//.........这里部分代码省略.........