38 return QRectF(
geometry(canvas_rect).topRight() + QPoint(-s, -s) , QSize(s*2, s*2));
40 return QRectF(
geometry(canvas_rect).topLeft() + QPoint(-s, -s), QSize(s*2, s*2));
58 painter->setBrush(QBrush(Qt::white, Qt::SolidPattern));
59 painter->drawEllipse(iconRect);
62 iconRect -= QMarginsF(3,3,3,3);
63 painter->setBrush(QBrush(col, Qt::SolidPattern));
64 painter->drawEllipse(iconRect);
72 const QRectF& rect)
const 77 const QRectF r = rect.toRect().adjusted(m, m, -m, -m);
79 painter->setClipRect(r, Qt::IntersectClip);
86 QRectF iconRect(r.topLeft(), graphic.
defaultSize());
88 iconRect.moveCenter(QPoint(iconRect.center().x(), rect.center().y()));
92 graphic.
render(painter, iconRect, Qt::KeepAspectRatio);
95 titleOff += iconRect.width() +
spacing();
104 pen.setColor(QColor(122, 122, 122));
110 painter->setPen(pen);
111 painter->setFont(
font());
113 const QRectF textRect = r.adjusted(titleOff, 0, 0, 0);
114 text.
draw(painter, textRect);
125 painter->setPen(pen);
128 painter->drawRoundedRect(rect, radius, radius);
136 const QPoint press_point = mouse_event->pos();
138 if (
isVisible() && mouse_event->modifiers() == Qt::NoModifier)
140 if ( (
hideButtonRect() + QMargins(2,2,2,2) ).contains(press_point))
152 if (item_rect.contains(press_point))
void setSpacing(int)
Set the spacing between the legend items.
const QwtPlotItem * processMousePressEvent(QMouseEvent *mouse_event)
void setBackgroundMode(BackgroundMode)
Set the background mode.
void render(QPainter *) const
Replay all recorded painter commands.
void setFont(const QFont &)
QSizeF defaultSize() const
Default size.
virtual QRect geometry(const QRectF &canvasRect) const
virtual void replot()
Redraw the plot.
void draw(QPainter *painter, const QRectF &rect) const
Qt::Alignment alignmentInCanvas() const
virtual void drawBackground(QPainter *painter, const QRectF &rect) const override
void setMargin(int)
Set the margin around legend items.
void setAlignmentInCanvas(Qt::Alignment)
Set the alignmnet.
virtual void drawLegendData(QPainter *painter, const QwtPlotItem *, const QwtLegendData &, const QRectF &) const override
QList< const QwtPlotItem * > plotItems() const
QBrush backgroundBrush() const
A class representing a text.
virtual void draw(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const QWT_OVERRIDE
A paint device for scalable graphics.
void setBorderRadius(double)
double borderRadius() const
virtual void setVisible(bool)
QRectF hideButtonRect() const
void attach(QwtPlot *plot)
Attach the item to a plot.
PlotLegend(QwtPlot *parent)
virtual void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &rect) const override
void setRenderHint(RenderHint, bool on=true)
Base class for items on the plot canvas.
QList< QRect > legendGeometries(const QwtPlotItem *) const
Attributes of an entry on a legend.
void setMaxColumns(uint)
Limit the number of columns.