ctkVTKMagnifyWidget.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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.commontk.org/LICENSE
  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 __ctkVTKMagnifyWidget_h
  15. #define __ctkVTKMagnifyWidget_h
  16. // QT includes
  17. #include <QList>
  18. // CTK includes
  19. #include "ctkCursorPixmapWidget.h"
  20. #include "ctkVisualizationVTKWidgetsExport.h"
  21. // VTK includes
  22. class QVTKWidget;
  23. class ctkVTKMagnifyWidgetPrivate;
  24. /// Gives a magnified view of a QVTKWidget around the mouse position, with
  25. /// overlaid cursor (ex. cross-hair). You must specify the QVTKWidget(s) to be
  26. /// observed.
  27. /// \sa ctkCursorPixmapWidget
  28. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKMagnifyWidget
  29. : public ctkCursorPixmapWidget
  30. {
  31. Q_OBJECT
  32. Q_PROPERTY(double magnification READ magnification WRITE setMagnification);
  33. public:
  34. /// Constructors
  35. typedef ctkCursorPixmapWidget Superclass;
  36. explicit ctkVTKMagnifyWidget(QWidget* parent = 0);
  37. virtual ~ctkVTKMagnifyWidget();
  38. /// Set/get the magnification (zoom). Looks best when the magnification and
  39. /// the widget size are both either even or odd. Default 1.0.
  40. double magnification() const;
  41. void setMagnification(double newMagnification);
  42. /// Add a QVTKWidget to observe mouse events on. You can call this function
  43. /// multiple times to observe multiple QVTKWidgets.
  44. /// \sa observe
  45. void observe(QVTKWidget * widget);
  46. /// Add multiple QVTKWidgets at once to observe mouse events on. You can
  47. /// call this function multiple times to observe multiple QVTKWidgets.
  48. /// \sa observe
  49. void observe(QList<QVTKWidget *> widgets);
  50. /// Remove a QVTKWidget to observe mouse events on. You can call this
  51. /// function multiple times to remove multiple QVTKWidgets.
  52. /// \sa remove
  53. void remove(QVTKWidget * widget);
  54. /// Remove multiple QVTKWidgets at once to observe mouse events on. You can
  55. /// call this function multiple times to remove multiple QVTKWidgets.
  56. /// \sa unobserve
  57. void remove(QList<QVTKWidget *> widgets);
  58. /// Returns whether a QVTKWidget is observed
  59. bool isObserved(QVTKWidget * widget) const;
  60. /// Returns the number of observed QVTKWidgets
  61. int numberObserved()const;
  62. protected:
  63. QScopedPointer<ctkVTKMagnifyWidgetPrivate> d_ptr;
  64. /// Handles mouse events on the observed QVTKWidgets (specifically,
  65. /// enterEvent, leaveEvent and mouseMoveEvent).
  66. virtual bool eventFilter(QObject *obj, QEvent *event);
  67. signals:
  68. void enteredObservedWidget(QVTKWidget * widget);
  69. void leftObservedWidget(QVTKWidget * widget);
  70. private:
  71. Q_DECLARE_PRIVATE(ctkVTKMagnifyWidget);
  72. Q_DISABLE_COPY(ctkVTKMagnifyWidget);
  73. };
  74. #endif