本文整理汇总了C++中QwtPlotMarker::symbol方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotMarker::symbol方法的具体用法?C++ QwtPlotMarker::symbol怎么用?C++ QwtPlotMarker::symbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotMarker
的用法示例。
在下文中一共展示了QwtPlotMarker::symbol方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: markerSymbol
/*!
\return a marker's symbol
\param key Marker key
*/
QwtSymbol QwtPlot::markerSymbol(long key) const
{
QwtPlotMarker *m = d_markers->find(key);
if (m)
return m->symbol();
else
return QwtSymbol();
}
示例2: closestMarker
/*!
\brief Find the marker which is closest to a given point.
\param xpos
\param ypos coordinates of a point in the plotting region
\retval dist Distance in points between the marker and the specified point.
\return Key of the closest marker or 0 if no marker was found
*/
long QwtPlot::closestMarker(int xpos, int ypos, int &dist) const
{
QwtDiMap map[axisCnt];
for ( int axis = 0; axis < axisCnt; axis++ )
map[axis] = canvasMap(axis);
long rv = 0;
double dmin = 1.0e10;
QwtPlotMarkerIterator itm = markerIterator();
for (QwtPlotMarker *m = itm.toFirst(); m != 0; m = ++itm )
{
double cx = map[m->xAxis()].xTransform(m->xValue());
double cy = map[m->yAxis()].xTransform(m->yValue());
if (m->lineStyle() == QwtMarker::HLine)
{
if (m->symbol().style() == QwtSymbol::None)
cx = double(xpos);
}
else if (m->lineStyle() == QwtMarker::VLine)
{
if (m->symbol().style() == QwtSymbol::None)
cy = double(ypos);
}
double f = qwtSqr(cx - double(xpos)) + qwtSqr(cy - double(ypos));
if (f < dmin)
{
dmin = f;
rv = itm.currentKey();
}
}
dist = int(sqrt(dmin));
return rv;
}
示例3: reset
/*!
Reset color and fonts of a plot
\sa QwtPlotPrintFilter::apply
*/
void QwtPlotPrintFilter::reset(QwtPlot *plot) const
{
if ( d_cache == 0 )
return;
QFont *font;
QColor *color;
if ( plot->d_lblTitle )
{
QPalette palette = plot->d_lblTitle->palette();
palette.setColor(
QPalette::Active, QColorGroup::Foreground, d_cache->titleColor);
plot->d_lblTitle->setPalette(palette);
plot->d_lblTitle->setFont(d_cache->titleFont);
}
if ( plot->d_legend )
{
QIntDictIterator<QWidget> it = plot->d_legend->itemIterator();
for ( QWidget *w = it.toFirst(); w != 0; w = ++it)
{
const int key = it.currentKey();
font = d_cache->legendFonts.find(key);
if ( font )
w->setFont(*font);
if ( w->inherits("QwtLegendButton") )
{
QwtLegendButton *btn = (QwtLegendButton *)w;
QwtSymbol symbol = btn->symbol();
color = d_cache->curveSymbolPenColors.find(key);
if ( color )
{
QPen pen = symbol.pen();
pen.setColor(*color);
symbol.setPen(pen);
}
color = d_cache->curveSymbolBrushColors.find(key);
if ( color )
{
QBrush brush = symbol.brush();
brush.setColor(*color);
symbol.setBrush(brush);
}
btn->setSymbol(symbol);
color = d_cache->curveColors.find(key);
if ( color )
{
QPen pen = btn->curvePen();
pen.setColor(*color);
btn->setCurvePen(pen);
}
}
}
}
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
QwtScale *scale = plot->d_scale[axis];
if ( scale )
{
QPalette palette = scale->palette();
palette.setColor(QPalette::Active, QColorGroup::Foreground,
d_cache->scaleColor[axis]);
scale->setPalette(palette);
scale->setFont(d_cache->scaleFont[axis]);
scale->setTitleColor(d_cache->scaleTitleColor[axis]);
scale->setTitleFont(d_cache->scaleTitleFont[axis]);
int startDist, endDist;
scale->minBorderDist(startDist, endDist);
scale->setBorderDist(startDist, endDist);
}
}
plot->setBackgroundColor(d_cache->widgetBackground);
plot->setCanvasBackground(d_cache->canvasBackground);
QPen pen = plot->d_grid->majPen();
pen.setColor(d_cache->gridColors[0]);
plot->d_grid->setMajPen(pen);
pen = plot->d_grid->minPen();
pen.setColor(d_cache->gridColors[1]);
plot->d_grid->setMinPen(pen);
QIntDictIterator<QwtPlotCurve> itc(*plot->d_curves);
for (QwtPlotCurve *c = itc.toFirst(); c != 0; c = ++itc )
{
const int key = itc.currentKey();
//.........这里部分代码省略.........
示例4: apply
/*!
Change color and fonts of a plot
\sa QwtPlotPrintFilter::apply
*/
void QwtPlotPrintFilter::apply(QwtPlot *plot) const
{
QwtPlotPrintFilter *that = (QwtPlotPrintFilter *)this;
delete that->d_cache;
that->d_cache = new QwtPlotPrintFilterCache;
QwtPlotPrintFilterCache &cache = *that->d_cache;
if ( plot->d_lblTitle )
{
QPalette palette = plot->d_lblTitle->palette();
cache.titleColor = palette.color(
QPalette::Active, QColorGroup::Foreground);
palette.setColor(QPalette::Active, QColorGroup::Foreground,
color(cache.titleColor, Title));
plot->d_lblTitle->setPalette(palette);
cache.titleFont = plot->d_lblTitle->font();
plot->d_lblTitle->setFont(font(cache.titleFont, Title));
}
if ( plot->d_legend )
{
QIntDictIterator<QWidget> it = plot->d_legend->itemIterator();
for ( QWidget *w = it.toFirst(); w != 0; w = ++it)
{
const int key = it.currentKey();
cache.legendFonts.insert(it.currentKey(), new QFont(w->font()));
w->setFont(font(w->font(), Legend, key));
if ( w->inherits("QwtLegendButton") )
{
QwtLegendButton *btn = (QwtLegendButton *)w;
QwtSymbol symbol = btn->symbol();
QPen pen = symbol.pen();
QBrush brush = symbol.brush();
pen.setColor(color(pen.color(), CurveSymbol, key));
brush.setColor(color(brush.color(), CurveSymbol, key));
symbol.setPen(pen);
symbol.setBrush(brush);
btn->setSymbol(symbol);
pen = btn->curvePen();
pen.setColor(color(pen.color(), Curve, key));
btn->setCurvePen(pen);
}
}
}
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
QwtScale *scale = plot->d_scale[axis];
if ( scale )
{
cache.scaleColor[axis] = scale->palette().color(
QPalette::Active, QColorGroup::Foreground);
QPalette palette = scale->palette();
palette.setColor(QPalette::Active, QColorGroup::Foreground,
color(cache.scaleColor[axis], AxisScale, axis));
scale->setPalette(palette);
cache.scaleFont[axis] = scale->font();
scale->setFont(font(cache.scaleFont[axis], AxisScale, axis));
cache.scaleTitleColor[axis] = scale->titleColor();
scale->setTitleColor(
color(cache.scaleTitleColor[axis], AxisTitle, axis));
cache.scaleTitleFont[axis] = scale->titleFont();
scale->setTitleFont(
font(cache.scaleTitleFont[axis], AxisTitle, axis));
int startDist, endDist;
scale->minBorderDist(startDist, endDist);
scale->setBorderDist(startDist, endDist);
}
}
cache.widgetBackground = plot->backgroundColor();
plot->setBackgroundColor(color(cache.widgetBackground, WidgetBackground));
cache.canvasBackground = plot->canvasBackground();
plot->setCanvasBackground(color(cache.canvasBackground, CanvasBackground));
QPen pen = plot->d_grid->majPen();
cache.gridColors[0] = pen.color();
pen.setColor(color(pen.color(), MajorGrid));
plot->d_grid->setMajPen(pen);
pen = plot->d_grid->minPen();
cache.gridColors[1] = pen.color();
pen.setColor(color(pen.color(), MinorGrid));
plot->d_grid->setMinPen(pen);
//.........这里部分代码省略.........
示例5: 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;
}
}
示例6: apply
void QwtPlotPrintFilter::apply(QwtPlotItem *item) const
{
PrivateData::Cache &cache = *d_data->cache;
switch(item->rtti())
{
case QwtPlotItem::Rtti_PlotGrid:
{
QwtPlotGrid *grid = (QwtPlotGrid *)item;
QPen pen = grid->majPen();
cache.gridColors[0] = pen.color();
pen.setColor(color(pen.color(), MajorGrid));
grid->setMajPen(pen);
pen = grid->minPen();
cache.gridColors[1] = pen.color();
pen.setColor(color(pen.color(), MinorGrid));
grid->setMinPen(pen);
break;
}
case QwtPlotItem::Rtti_PlotCurve:
{
QwtPlotCurve *c = (QwtPlotCurve *)item;
QwtSymbol symbol = c->symbol();
QPen pen = symbol.pen();
cache.curveSymbolPenColors.insert(c, pen.color());
pen.setColor(color(pen.color(), CurveSymbol));
symbol.setPen(pen);
QBrush brush = symbol.brush();
cache.curveSymbolBrushColors.insert(c, brush.color());
brush.setColor(color(brush.color(), CurveSymbol));
symbol.setBrush(brush);
c->setSymbol(symbol);
pen = c->pen();
cache.curveColors.insert(c, pen.color());
pen.setColor(color(pen.color(), Curve));
c->setPen(pen);
break;
}
case QwtPlotItem::Rtti_PlotMarker:
{
QwtPlotMarker *m = (QwtPlotMarker *)item;
QwtText label = m->label();
cache.markerFonts.insert(m, label.font());
label.setFont(font(label.font(), Marker));
cache.markerLabelColors.insert(m, label.color());
label.setColor(color(label.color(), Marker));
m->setLabel(label);
QPen pen = m->linePen();
cache.markerLineColors.insert(m, pen.color());
pen.setColor(color(pen.color(), Marker));
m->setLinePen(pen);
QwtSymbol symbol = m->symbol();
pen = symbol.pen();
cache.markerSymbolPenColors.insert(m, pen.color());
pen.setColor(color(pen.color(), MarkerSymbol));
symbol.setPen(pen);
QBrush brush = symbol.brush();
cache.markerSymbolBrushColors.insert(m, brush.color());
brush.setColor(color(brush.color(), MarkerSymbol));
symbol.setBrush(brush);
m->setSymbol(symbol);
break;
}
default:
break;
}
}