qwt_plot_glcanvas.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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_GLCANVAS_H
  10. #define QWT_PLOT_GLCANVAS_H
  11. #include "qwt_global.h"
  12. #include <qframe.h>
  13. #include <qgl.h>
  14. #include <qpainterpath.h>
  15. class QwtPlot;
  16. /*!
  17. \brief An alternative canvas for a QwtPlot derived from QGLWidget
  18. QwtPlotGLCanvas implements the very basics to act as canvas
  19. inside of a QwtPlot widget. It might be extended to a full
  20. featured alternative to QwtPlotCanvas in a future version of Qwt.
  21. Even if QwtPlotGLCanvas is not derived from QFrame it imitates
  22. its API. When using style sheets it supports the box model - beside
  23. backgrounds with rounded borders.
  24. \sa QwtPlot::setCanvas(), QwtPlotCanvas
  25. \note With Qt4 you might want to use the QPaintEngine::OpenGL paint engine
  26. ( see QGL::setPreferredPaintEngine() ). On a Linux test system
  27. QPaintEngine::OpenGL2 shows very basic problems like translated
  28. geometries.
  29. */
  30. class QWT_EXPORT QwtPlotGLCanvas: public QGLWidget
  31. {
  32. Q_OBJECT
  33. Q_ENUMS( Shape Shadow )
  34. Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow )
  35. Q_PROPERTY( Shape frameShape READ frameShape WRITE setFrameShape )
  36. Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth )
  37. Q_PROPERTY( int midLineWidth READ midLineWidth WRITE setMidLineWidth )
  38. Q_PROPERTY( int frameWidth READ frameWidth )
  39. Q_PROPERTY( QRect frameRect READ frameRect DESIGNABLE false )
  40. public:
  41. /*!
  42. \brief Frame shadow
  43. Unfortunately it is not possible to use QFrame::Shadow
  44. as a property of a widget that is not derived from QFrame.
  45. The following enum is made for the designer only. It is safe
  46. to use QFrame::Shadow instead.
  47. */
  48. enum Shadow
  49. {
  50. //! QFrame::Plain
  51. Plain = QFrame::Plain,
  52. //! QFrame::Raised
  53. Raised = QFrame::Raised,
  54. //! QFrame::Sunken
  55. Sunken = QFrame::Sunken
  56. };
  57. /*!
  58. \brief Frame shape
  59. Unfortunately it is not possible to use QFrame::Shape
  60. as a property of a widget that is not derived from QFrame.
  61. The following enum is made for the designer only. It is safe
  62. to use QFrame::Shadow instead.
  63. \note QFrame::StyledPanel and QFrame::WinPanel are unsupported
  64. and will be displayed as QFrame::Panel.
  65. */
  66. enum Shape
  67. {
  68. NoFrame = QFrame::NoFrame,
  69. Box = QFrame::Box,
  70. Panel = QFrame::Panel
  71. };
  72. explicit QwtPlotGLCanvas( QwtPlot * = NULL );
  73. virtual ~QwtPlotGLCanvas();
  74. void setFrameStyle( int style );
  75. int frameStyle() const;
  76. void setFrameShadow( Shadow );
  77. Shadow frameShadow() const;
  78. void setFrameShape( Shape );
  79. Shape frameShape() const;
  80. void setLineWidth( int );
  81. int lineWidth() const;
  82. void setMidLineWidth( int );
  83. int midLineWidth() const;
  84. int frameWidth() const;
  85. QRect frameRect() const;
  86. Q_INVOKABLE QPainterPath borderPath( const QRect & ) const;
  87. virtual bool event( QEvent * );
  88. public Q_SLOTS:
  89. void replot();
  90. protected:
  91. virtual void paintEvent( QPaintEvent * );
  92. virtual void drawBackground( QPainter * );
  93. virtual void drawBorder( QPainter * );
  94. virtual void drawItems( QPainter * );
  95. private:
  96. class PrivateData;
  97. PrivateData *d_data;
  98. };
  99. #endif