qwt_point_mapper.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_POINT_MAPPER_H
  10. #define QWT_POINT_MAPPER_H
  11. #include "qwt_global.h"
  12. #include "qwt_series_data.h"
  13. #include <qimage.h>
  14. class QwtScaleMap;
  15. class QPolygonF;
  16. class QPolygon;
  17. /*!
  18. \brief A helper class for translating a series of points
  19. QwtPointMapper is a collection of methods and optimizations
  20. for translating a series of points into paint device coordinates.
  21. It is used by QwtPlotCurve but might also be useful for
  22. similar plot items displaying a QwtSeriesData<QPointF>.
  23. */
  24. class QWT_EXPORT QwtPointMapper
  25. {
  26. public:
  27. /*!
  28. \brief Flags affecting the transformation process
  29. \sa setFlag(), setFlags()
  30. */
  31. enum TransformationFlag
  32. {
  33. //! Round points to integer values
  34. RoundPoints = 0x01,
  35. /*!
  36. Try to remove points, that are translated to the
  37. same position.
  38. */
  39. WeedOutPoints = 0x02
  40. };
  41. /*!
  42. \brief Flags affecting the transformation process
  43. \sa setFlag(), setFlags()
  44. */
  45. typedef QFlags<TransformationFlag> TransformationFlags;
  46. QwtPointMapper();
  47. ~QwtPointMapper();
  48. void setFlags( TransformationFlags );
  49. TransformationFlags flags() const;
  50. void setFlag( TransformationFlag, bool on = true );
  51. bool testFlag( TransformationFlag ) const;
  52. void setBoundingRect( const QRectF & );
  53. QRectF boundingRect() const;
  54. QPolygonF toPolygonF( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  55. const QwtSeriesData<QPointF> *series, int from, int to ) const;
  56. QPolygon toPolygon( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  57. const QwtSeriesData<QPointF> *series, int from, int to ) const;
  58. QPolygon toPoints( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  59. const QwtSeriesData<QPointF> *series, int from, int to ) const;
  60. QPolygonF toPointsF( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  61. const QwtSeriesData<QPointF> *series, int from, int to ) const;
  62. QImage toImage( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  63. const QwtSeriesData<QPointF> *series, int from, int to,
  64. const QPen &, bool antialiased, uint numThreads ) const;
  65. private:
  66. class PrivateData;
  67. PrivateData *d_data;
  68. };
  69. Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPointMapper::TransformationFlags )
  70. #endif