27 #ifndef QPCANVASHELPERS_QO_H_
28 #define QPCANVASHELPERS_QO_H_
38 #include <qwt_legend.h>
39 #if QWT_VERSION >= 0x060000
40 #include <qwt_plot_legenditem.h>
43 #include <qwt_plot_grid.h>
44 #include <qwt_scale_draw.h>
47 #include <QMouseEvent>
48 #include <QSpacerItem>
60 class QPMouseFilter :
public QObject {
65 QPMouseFilter(QwtPlotCanvas* canvas);
66 QPMouseFilter(QWidget* widget);
72 void turnTracking(
bool on);
77 void mouseMoveEvent(QMouseEvent*
e);
82 bool eventFilter(QObject* obj, QEvent* ev);
86 QwtPlotCanvas* m_canvas;
96 class QPScaleDraw :
public QwtScaleDraw {
99 QPScaleDraw(QwtPlot* parent, QwtPlot::Axis axis);
125 bool referenceValueSet()
const;
126 double referenceValue()
const;
127 void setReferenceValue(
bool on,
double value = 0);
135 QwtText label(
double value)
const;
137 virtual void draw(QPainter* painter,
const QPalette& palette)
const;
139 #if QWT_VERSION < 0x060000
140 virtual int extent(
const QPen& pen,
const QFont& font )
const;
145 int getTickPrecision()
const;
151 QwtPlot::Axis m_axis;
165 double m_referenceValue;
178 class QPLegend :
public QwtLegend {
181 QPLegend(QWidget* parent = NULL);
188 QSize sizeHint()
const;
192 const QPLine& line()
const;
193 const QPen& pen()
const;
194 void setLine(
const PlotLine& line);
195 void setLine(
const QPen& pen) { setLine(QPLine(pen)); }
200 const QPAreaFill& areaFill()
const;
201 const QBrush& brush()
const;
204 void setAreaFill(
const PlotAreaFill& fill,
bool update=
true);
205 void setAreaFill(
const QBrush& brush) { setAreaFill(QPAreaFill(brush)); }
211 void drawOutlineAndBackground(QPainter* painter,
const QRect& rect,
212 bool useQwtPainter =
false);
217 void paintEvent(QPaintEvent* event);
224 QPAreaFill m_areaFill;
229 class QPLegendHolder :
public QWidget {
234 static const int DEFAULT_INTERNAL_PADDING;
237 static QwtPlot::LegendPosition legendPosition(
243 int padding = DEFAULT_INTERNAL_PADDING);
248 QPLegend* legend() {
return m_legend; }
251 bool legendShown()
const;
252 void showLegend(
bool show =
true);
257 bool isInternal()
const;
264 const QPLine& line()
const {
return m_legend->line(); }
265 const QPen& pen()
const {
return m_legend->pen(); }
266 void setLine(
const PlotLine& line) { m_legend->setLine(line); }
267 void setLine(
const QPen& pen) { m_legend->setLine(pen); }
272 const QPAreaFill& areaFill()
const {
return m_legend->areaFill(); }
273 const QBrush& brush()
const {
return m_legend->brush(); }
276 void setAreaFill(
const PlotAreaFill& fill,
bool update =
true ) {
277 if (m_legend) m_legend->setAreaFill(fill, update); }
278 void setAreaFill(
const QBrush& brush) {
279 if (m_legend) m_legend->setAreaFill(brush); }
283 QRect internalLegendRect(
const QRect& canvasRect)
const;
286 void drawOutlineAndBackground(QPainter* painter,
const QRect& rect,
287 bool useQwtPainter =
false) {
288 m_legend->drawOutlineAndBackground(painter, rect, useQwtPainter); }
297 #if QWT_VERSION >= 0x060000
298 QwtPlotLegendItem* m_legendItem;
299 void setupLegendItem();
307 QSpacerItem* m_spaceTop, *m_spaceLeft, *m_spaceRight, *m_spaceBottom;
314 void updateSpacers();
323 class QPBaseItem :
public QPLayerItem {
324 friend class QPLayeredCanvas;
329 static const double BASE_Z_CARTAXIS;
330 static const double BASE_Z_GRID;
338 virtual ~QPBaseItem();
342 virtual void itemChanged() { QwtPlotItem::itemChanged(); }
345 virtual unsigned int itemDrawCount()
const {
return 1; }
353 void qpAttach(QPCanvas* canvas);
362 class QPGrid :
public QPBaseItem,
public QwtPlotGrid {
372 void itemChanged() { QPBaseItem::itemChanged(); }
375 bool shouldDraw()
const;
381 QwtDoubleRect boundingRect()
const {
return QwtPlotGrid::boundingRect(); }
384 void updateScaleDiv(
const QwtScaleDiv& xDiv,
const QwtScaleDiv& yDiv) {
385 QwtPlotGrid::updateScaleDiv(xDiv, yDiv); }
389 #if QWT_VERSION >= 0x060000
390 void draw_(QPainter* p,
const QwtScaleMap& xMap,
391 const QwtScaleMap& yMap,
const QRectF& drawRect,
392 unsigned int drawIndex,
unsigned int drawCount)
const
394 void draw_(QPainter* p,
const QwtScaleMap& xMap,
395 const QwtScaleMap& yMap,
const QRect& drawRect,
396 unsigned int drawIndex,
unsigned int drawCount)
const
399 (void)drawIndex; (void)drawCount;
400 QwtPlotGrid::draw(p, xMap, yMap, drawRect); }
406 class QPCartesianAxis :
public QPBaseItem {
410 QPCartesianAxis(QwtPlot::Axis master, QwtPlot::Axis slave);
417 bool shouldDraw()
const {
return true; }
424 #if QWT_VERSION >= 0x060000
425 void draw_(QPainter* p,
const QwtScaleMap& xMap,
426 const QwtScaleMap& yMap,
const QRectF& drawRect,
427 unsigned int drawIndex,
unsigned int drawCount)
const;
429 void draw_(QPainter* p,
const QwtScaleMap& xMap,
430 const QwtScaleMap& yMap,
const QRect& drawRect,
431 unsigned int drawIndex,
unsigned int drawCount)
const;
436 QwtPlot::Axis m_axis;
439 QwtScaleDraw m_scaleDraw;
void show(const variant &v)
AngleFormat
Enum for angle formats.
const Double e
e and functions thereof:
String: the storage and methods of handling collections of characters.
PlotAxisScale
Enum for possible axis scales.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.