ctkVTKMagnifyView.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 __ctkVTKMagnifyView_h
  15. #define __ctkVTKMagnifyView_h
  16. // QT includes
  17. #include <QList>
  18. // CTK includes
  19. #include "ctkCrosshairLabel.h"
  20. #include "ctkVisualizationVTKWidgetsExport.h"
  21. // VTK includes
  22. class QVTKWidget;
  23. class ctkVTKMagnifyViewPrivate;
  24. /// \ingroup Visualization_VTK_Widgets
  25. /// Gives a magnified view of a QVTKWidget around the mouse position, with
  26. /// overlaid crosshair (ex. cross-hair). You must specify the QVTKWidget(s) to be
  27. /// observed.
  28. /// \sa ctkCrosshairLabel
  29. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKMagnifyView
  30. : public ctkCrosshairLabel
  31. {
  32. Q_OBJECT
  33. Q_PROPERTY(double magnification READ magnification WRITE setMagnification)
  34. Q_PROPERTY(bool observeRenderWindowEvents
  35. READ observeRenderWindowEvents WRITE setObserveRenderWindowEvents)
  36. Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval)
  37. public:
  38. /// Constructors
  39. typedef ctkCrosshairLabel Superclass;
  40. explicit ctkVTKMagnifyView(QWidget* parent = 0);
  41. virtual ~ctkVTKMagnifyView();
  42. /// Set/get the magnification (zoom). Looks best when the magnification and
  43. /// the widget size are both either even or odd. Default 1.0.
  44. double magnification() const;
  45. void setMagnification(double newMagnification);
  46. /// Set/get whether or not to observe EndEvents emitted by the observed
  47. /// QVTKWidgets' vtkRenderWindows after they have rendered. This triggers
  48. /// updates to the magnify widget whenever the vtkRenderWindow does a render,
  49. /// even if the mouse position does not move. Default true.
  50. bool observeRenderWindowEvents() const;
  51. void setObserveRenderWindowEvents(bool newObserve);
  52. /// Set/get a fixed interval, in milliseconds, at which this widget will update
  53. /// itself. Default 20. Specify an update interval of 0 to handle all events as
  54. /// they occur.
  55. int updateInterval() const;
  56. void setUpdateInterval(int newInterval);
  57. /// Add a QVTKWidget to observe mouse events on. You can call this function
  58. /// multiple times to observe multiple QVTKWidgets.
  59. /// \sa observe
  60. void observe(QVTKWidget * widget);
  61. /// Add multiple QVTKWidgets at once to observe mouse events on. You can
  62. /// call this function multiple times to observe multiple QVTKWidgets.
  63. /// \sa observe
  64. void observe(QList<QVTKWidget *> widgets);
  65. /// Remove a QVTKWidget to observe mouse events on. You can call this
  66. /// function multiple times to remove multiple QVTKWidgets.
  67. /// \sa remove
  68. void remove(QVTKWidget * widget);
  69. /// Remove multiple QVTKWidgets at once to observe mouse events on. You can
  70. /// call this function multiple times to remove multiple QVTKWidgets.
  71. /// \sa unobserve
  72. void remove(QList<QVTKWidget *> widgets);
  73. /// Returns whether a QVTKWidget is observed
  74. bool isObserved(QVTKWidget * widget) const;
  75. /// Returns the number of observed QVTKWidgets
  76. int numberObserved()const;
  77. /// Returns true if the mouse cursor is over an observed widget,
  78. /// false otherwise.
  79. bool hasCursorInObservedWidget()const;
  80. protected:
  81. QScopedPointer<ctkVTKMagnifyViewPrivate> d_ptr;
  82. /// Handles mouse events on the observed QVTKWidgets (specifically,
  83. /// enterEvent, leaveEvent and mouseMoveEvent).
  84. virtual bool eventFilter(QObject *obj, QEvent *event);
  85. Q_SIGNALS:
  86. void enteredObservedWidget(QVTKWidget * widget);
  87. void leftObservedWidget(QVTKWidget * widget);
  88. private:
  89. Q_DECLARE_PRIVATE(ctkVTKMagnifyView)
  90. Q_DISABLE_COPY(ctkVTKMagnifyView)
  91. };
  92. #endif