qwt_plot_picker.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
  2. * Qwt Widget Library
  3. * Copyright (C) 1997 Josef Wilgen
  4. * Copyright (C) 2002 Uwe Rathmann
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the Qwt License, Version 1.0
  8. *****************************************************************************/
  9. #ifndef QWT_PLOT_PICKER_H
  10. #define QWT_PLOT_PICKER_H
  11. #include "qwt_global.h"
  12. #include "qwt_picker.h"
  13. #include <qvector.h>
  14. class QwtPlot;
  15. /*!
  16. \brief QwtPlotPicker provides selections on a plot canvas
  17. QwtPlotPicker is a QwtPicker tailored for selections on
  18. a plot canvas. It is set to a x-Axis and y-Axis and
  19. translates all pixel coordinates into this coordinate system.
  20. */
  21. class QWT_EXPORT QwtPlotPicker: public QwtPicker
  22. {
  23. Q_OBJECT
  24. public:
  25. explicit QwtPlotPicker( QWidget *canvas );
  26. virtual ~QwtPlotPicker();
  27. explicit QwtPlotPicker( int xAxis, int yAxis, QWidget * );
  28. explicit QwtPlotPicker( int xAxis, int yAxis,
  29. RubberBand rubberBand, DisplayMode trackerMode, QWidget * );
  30. virtual void setAxis( int xAxis, int yAxis );
  31. int xAxis() const;
  32. int yAxis() const;
  33. QwtPlot *plot();
  34. const QwtPlot *plot() const;
  35. QWidget *canvas();
  36. const QWidget *canvas() const;
  37. Q_SIGNALS:
  38. /*!
  39. A signal emitted in case of QwtPickerMachine::PointSelection.
  40. \param pos Selected point
  41. */
  42. void selected( const QPointF &pos );
  43. /*!
  44. A signal emitted in case of QwtPickerMachine::RectSelection.
  45. \param rect Selected rectangle
  46. */
  47. void selected( const QRectF &rect );
  48. /*!
  49. A signal emitting the selected points,
  50. at the end of a selection.
  51. \param pa Selected points
  52. */
  53. void selected( const QVector<QPointF> &pa );
  54. /*!
  55. A signal emitted when a point has been appended to the selection
  56. \param pos Position of the appended point.
  57. \sa append(). moved()
  58. */
  59. void appended( const QPointF &pos );
  60. /*!
  61. A signal emitted whenever the last appended point of the
  62. selection has been moved.
  63. \param pos Position of the moved last point of the selection.
  64. \sa move(), appended()
  65. */
  66. void moved( const QPointF &pos );
  67. protected:
  68. QRectF scaleRect() const;
  69. QRectF invTransform( const QRect & ) const;
  70. QRect transform( const QRectF & ) const;
  71. QPointF invTransform( const QPoint & ) const;
  72. QPoint transform( const QPointF & ) const;
  73. virtual QwtText trackerText( const QPoint & ) const;
  74. virtual QwtText trackerTextF( const QPointF & ) const;
  75. virtual void move( const QPoint & );
  76. virtual void append( const QPoint & );
  77. virtual bool end( bool ok = true );
  78. private:
  79. int d_xAxis;
  80. int d_yAxis;
  81. };
  82. #endif