// virtual from QwtPlotItem
QwtGraphic PlotMarker::legendIcon (int index, // (ignore, only one)
const QSizeF& iconSize) const
{
// call base class method (don't).
//-- QwtGraphic graphic = QwtPlotMarker::legendIcon (index, iconSize);
//-- return graphic;
// The following is adapted from the QwtPlotMarker::legendIcon()
// implementation (from Qwt 6.1.2). We really don't want to attempt
// to draw "vertical" components of the marker appearance, i.e. the
// vertical line, if the marker has the "VLine" or "Cross" style.
// Those nuances have been left out of this adaptation.
Q_UNUSED (index);
if (iconSize.isEmpty())
return QwtGraphic();
QwtGraphic icon;
icon.setDefaultSize (iconSize);
icon.setRenderHint (QwtGraphic::RenderPensUnscaled, true);
painter.
setRenderHint (QPainter::Antialiasing,
const QPen& penRef = linePen();
{
painter.setPen (penRef);
const double y = 0.5 * iconSize.height();
QwtPainter::drawLine (&painter,
0.0, y, iconSize.
width(), y
);
}
if (symb)
{
const QRect rect
(0.0,
0.0, iconSize.
width(), iconSize.
height());
symb->drawSymbol (&painter, rect);
}
return icon;
}
// virtual from QwtPlotItem
QwtGraphic PlotMarker::legendIcon (int index, // (ignore, only one)
const QSizeF& iconSize) const
{
// call base class method (don't).
//-- QwtGraphic graphic = QwtPlotMarker::legendIcon (index, iconSize);
//-- return graphic;
// The following is adapted from the QwtPlotMarker::legendIcon()
// implementation (from Qwt 6.1.2). We really don't want to attempt
// to draw "vertical" components of the marker appearance, i.e. the
// vertical line, if the marker has the "VLine" or "Cross" style.
// Those nuances have been left out of this adaptation.
Q_UNUSED (index);
if (iconSize.isEmpty())
return QwtGraphic();
QwtGraphic icon;
icon.setDefaultSize (iconSize);
icon.setRenderHint (QwtGraphic::RenderPensUnscaled, true);
QPainter painter (&icon);
painter.setRenderHint (QPainter::Antialiasing,
testRenderHint(QwtPlotItem::RenderAntialiased));
const QwtPlotMarker::LineStyle markerStyle = lineStyle();
const QPen& penRef = linePen();
const QwtSymbol* symb = symbol();
if (markerStyle != QwtPlotMarker::NoLine)
{
painter.setPen (penRef);
const double y = 0.5 * iconSize.height();
QwtPainter::drawLine (&painter, 0.0, y, iconSize.width(), y);
}
if (symb)
{
const QRect rect (0.0, 0.0, iconSize.width(), iconSize.height());
symb->drawSymbol (&painter, rect);
}
return icon;
}
To copy to clipboard, switch view to plain text mode
Bookmarks