00001 #ifndef PLOTLEGEND_H 00002 #define PLOTLEGEND_H 00003 00004 #include <QObject> 00005 #include "qwt_plot_legenditem.h" 00006 #include "qwt_plot.h" 00007 00008 class PlotLegend: public QObject, public QwtPlotLegendItem 00009 { 00010 Q_OBJECT 00011 public: 00012 PlotLegend(QwtPlot* parent): 00013 _parent_plot(parent), 00014 _collapsed(false) 00015 { 00016 this->attach(parent); 00017 } 00018 00019 QRectF hideButtonRect() const; 00020 00021 bool processWheelEvent(QWheelEvent* ev); 00022 00023 const QwtPlotItem *processMousePressEvent(QMouseEvent* mouse_event); 00024 00025 private: 00026 00027 virtual void draw( QPainter *p, 00028 const QwtScaleMap &xMap, const QwtScaleMap &yMap, 00029 const QRectF &rect ) const override; 00030 00031 virtual void drawLegendData( QPainter *painter, 00032 const QwtPlotItem *, const QwtLegendData &, 00033 const QRectF & ) const override; 00034 00035 QwtPlot* _parent_plot; 00036 bool _collapsed; 00037 00038 signals: 00039 void legendSizeChanged(int point_size); 00040 }; 00041 00042 #endif // PLOTLEGEND_H