qwt_plot_marker.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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_MARKER_H
  10. #define QWT_PLOT_MARKER_H
  11. #include <qpen.h>
  12. #include <qfont.h>
  13. #include <qstring.h>
  14. #include <qbrush.h>
  15. #include "qwt_global.h"
  16. #include "qwt_plot_item.h"
  17. class QRectF;
  18. class QwtText;
  19. class QwtSymbol;
  20. /*!
  21. \brief A class for drawing markers
  22. A marker can be a horizontal line, a vertical line,
  23. a symbol, a label or any combination of them, which can
  24. be drawn around a center point inside a bounding rectangle.
  25. The setSymbol() member assigns a symbol to the marker.
  26. The symbol is drawn at the specified point.
  27. With setLabel(), a label can be assigned to the marker.
  28. The setLabelAlignment() member specifies where the label is
  29. drawn. All the Align*-constants in Qt::AlignmentFlags (see Qt documentation)
  30. are valid. The interpretation of the alignment depends on the marker's
  31. line style. The alignment refers to the center point of
  32. the marker, which means, for example, that the label would be printed
  33. left above the center point if the alignment was set to
  34. Qt::AlignLeft | Qt::AlignTop.
  35. \note QwtPlotTextLabel is intended to align a text label
  36. according to the geometry of canvas
  37. ( unrelated to plot coordinates )
  38. */
  39. class QWT_EXPORT QwtPlotMarker: public QwtPlotItem
  40. {
  41. public:
  42. /*!
  43. Line styles.
  44. \sa setLineStyle(), lineStyle()
  45. */
  46. enum LineStyle
  47. {
  48. //! No line
  49. NoLine,
  50. //! A horizontal line
  51. HLine,
  52. //! A vertical line
  53. VLine,
  54. //! A crosshair
  55. Cross
  56. };
  57. explicit QwtPlotMarker( const QString &title = QString() );
  58. explicit QwtPlotMarker( const QwtText &title );
  59. virtual ~QwtPlotMarker();
  60. virtual int rtti() const;
  61. double xValue() const;
  62. double yValue() const;
  63. QPointF value() const;
  64. void setXValue( double );
  65. void setYValue( double );
  66. void setValue( double, double );
  67. void setValue( const QPointF & );
  68. void setLineStyle( LineStyle );
  69. LineStyle lineStyle() const;
  70. void setLinePen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
  71. void setLinePen( const QPen & );
  72. const QPen &linePen() const;
  73. void setSymbol( const QwtSymbol * );
  74. const QwtSymbol *symbol() const;
  75. void setLabel( const QwtText& );
  76. QwtText label() const;
  77. void setLabelAlignment( Qt::Alignment );
  78. Qt::Alignment labelAlignment() const;
  79. void setLabelOrientation( Qt::Orientation );
  80. Qt::Orientation labelOrientation() const;
  81. void setSpacing( int );
  82. int spacing() const;
  83. virtual void draw( QPainter *,
  84. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
  85. const QRectF & ) const;
  86. virtual QRectF boundingRect() const;
  87. virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
  88. protected:
  89. virtual void drawLines( QPainter *,
  90. const QRectF &, const QPointF & ) const;
  91. virtual void drawLabel( QPainter *,
  92. const QRectF &, const QPointF & ) const;
  93. private:
  94. class PrivateData;
  95. PrivateData *d_data;
  96. };
  97. #endif