ctkAxesWidget.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkAxesWidget_h
  15. #define __ctkAxesWidget_h
  16. // Qt includes
  17. #include <QMetaType>
  18. #include <QWidget>
  19. // CTK includes
  20. #include "ctkWidgetsExport.h"
  21. class ctkAxesWidgetPrivate;
  22. /// \ingroup Widgets
  23. class CTK_WIDGETS_EXPORT ctkAxesWidget : public QWidget
  24. {
  25. Q_OBJECT
  26. Q_ENUMS(Axis)
  27. Q_PROPERTY(Axis currentAxis READ currentAxis WRITE setCurrentAxis NOTIFY currentAxisChanged)
  28. Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
  29. public :
  30. enum Axis
  31. {
  32. None=0,
  33. Right,
  34. Left,
  35. Superior,
  36. Inferior,
  37. Anterior,
  38. Posterior,
  39. };
  40. ctkAxesWidget(QWidget *parent = 0);
  41. virtual ~ctkAxesWidget();
  42. ///
  43. /// Current selected axis. None by default.
  44. Axis currentAxis() const;
  45. ///
  46. /// If autoReset is true, anytime the current axis is changed, the current
  47. /// axis is automatically reset to None.
  48. /// False by default.
  49. bool autoReset() const;
  50. Q_SIGNALS:
  51. void currentAxisChanged(ctkAxesWidget::Axis axis);
  52. public slots :
  53. ///
  54. /// Select the current axis and emit the currentAxisChanged signal if it is
  55. /// a new one. Warning, if autoReset is true, the currentAxis will automatically
  56. /// be reset to None.
  57. void setCurrentAxis(Axis axis);
  58. ///
  59. /// Utility slot that set the current axis to none
  60. void setCurrentAxisToNone();
  61. ///
  62. /// Set the autoReset property to None anytime the currentAxis is changed.
  63. void setAutoReset(bool reset);
  64. /// Size hints
  65. virtual QSize minimumSizeHint()const;
  66. virtual QSize sizeHint()const;
  67. virtual bool hasHeightForWidth()const;
  68. virtual int heightForWidth(int width)const;
  69. protected:
  70. void paintEvent(QPaintEvent *);
  71. void mousePressEvent(QMouseEvent *mouseEvent);
  72. void mouseMoveEvent(QMouseEvent *mouseEvent);
  73. void mouseReleaseEvent(QMouseEvent *mouseEvent);
  74. QScopedPointer<ctkAxesWidgetPrivate> d_ptr;
  75. private :
  76. Q_DECLARE_PRIVATE(ctkAxesWidget);
  77. Q_DISABLE_COPY(ctkAxesWidget);
  78. };
  79. Q_DECLARE_METATYPE(ctkAxesWidget::Axis)
  80. #endif