ctkVTKMagnifyWidget.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKMagnifyWidget
  25. : public ctkCursorPixmapWidget
  26. {
  27. Q_OBJECT
  28. Q_PROPERTY(double magnification READ magnification WRITE setMagnification);
  29. public:
  30. /// Constructors
  31. typedef ctkCursorPixmapWidget Superclass;
  32. explicit ctkVTKMagnifyWidget(QWidget* parent = 0);
  33. virtual ~ctkVTKMagnifyWidget();
  34. /// Set/get the magnification (zoom). Default 1.0.
  35. double magnification() const;
  36. void setMagnification(double newMagnification);
  37. /// Add a QVTKWidget to observe mouse events on. You can call this function
  38. /// multiple times to observe multiple QVTKWidgets.
  39. /// \sa observe
  40. void observe(QVTKWidget * widget);
  41. /// Add multiple QVTKWidgets at once to observe mouse events on. You can
  42. /// call this function multiple times to observe multiple QVTKWidgets.
  43. /// \sa observe
  44. void observe(QList<QVTKWidget *> widgets);
  45. /// Remove a QVTKWidget to observe mouse events on. You can call this
  46. /// function multiple times to remove multiple QVTKWidgets.
  47. /// \sa remove
  48. void remove(QVTKWidget * widget);
  49. /// Remove multiple QVTKWidgets at once to observe mouse events on. You can
  50. /// call this function multiple times to remove multiple QVTKWidgets.
  51. /// \sa unobserve
  52. void remove(QList<QVTKWidget *> widgets);
  53. /// Returns whether a QVTKWidget is observed
  54. bool isObserved(QVTKWidget * widget) const;
  55. /// Returns the number of observed QVTKWidgets
  56. int numberObserved()const;
  57. protected:
  58. QScopedPointer<ctkVTKMagnifyWidgetPrivate> d_ptr;
  59. /// Handles mouse events on the observed QVTKWidgets (specifically,
  60. /// enterEvent, leaveEvent and mouseMoveEvent).
  61. virtual bool eventFilter(QObject *obj, QEvent *event);
  62. signals:
  63. void enteredObservedWidget(QVTKWidget * widget);
  64. void leftObservedWidget(QVTKWidget * widget);
  65. private:
  66. Q_DECLARE_PRIVATE(ctkVTKMagnifyWidget);
  67. Q_DISABLE_COPY(ctkVTKMagnifyWidget);
  68. };
  69. #endif