ctkVTKObjectEventsObserver.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. All rights reserved.
  5. Distributed under a BSD License. See LICENSE.txt file.
  6. This software is distributed "AS IS" WITHOUT ANY WARRANTY; without even
  7. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the above copyright notice for more information.
  9. =========================================================================*/
  10. #ifndef __ctkVTKObjectEventsObserver_h
  11. #define __ctkVTKObjectEventsObserver_h
  12. /// CTK includes
  13. #include <ctkPimpl.h>
  14. /// Qt includes
  15. #include <QObject>
  16. #include <QList>
  17. #include <QString>
  18. /// VTK includes
  19. #include <vtkCommand.h>
  20. #include "CTKVisualizationVTKCoreExport.h"
  21. class ctkVTKConnection;
  22. class vtkObject;
  23. class ctkVTKObjectEventsObserverPrivate;
  24. class CTK_VISUALIZATION_VTK_CORE_EXPORT ctkVTKObjectEventsObserver : public QObject
  25. {
  26. Q_OBJECT
  27. public:
  28. typedef QObject Superclass;
  29. explicit ctkVTKObjectEventsObserver(QObject* parent = 0);
  30. virtual ~ctkVTKObjectEventsObserver(){}
  31. virtual void printAdditionalInfo();
  32. ///
  33. /// Enable / Disable all ctkVTKConnections
  34. void setAllEnabled( bool enable );
  35. bool allEnabled()const;
  36. ///
  37. /// Add a connection, an Id allowing to uniquely identify the connection is also returned
  38. QString addConnection(vtkObject* vtk_obj, unsigned long vtk_event,
  39. const QObject* qt_obj, const char* qt_slot, float priority = 0.0);
  40. ///
  41. /// Utility function that remove a connection on old_vtk_obj and add a connection
  42. /// to vtk_obj (same event, object, slot, priority)
  43. QString addConnection(vtkObject* old_vtk_obj, vtkObject* vtk_obj, unsigned long vtk_event,
  44. const QObject* qt_obj, const char* qt_slot, float priority = 0.0);
  45. ///
  46. /// Utility function that remove a connection on old_vtk_obj and add a connection
  47. /// to vtk_obj (same event, object, slot, priority)
  48. QString reconnection(vtkObject* vtk_obj, unsigned long vtk_event,
  49. const QObject* qt_obj, const char* qt_slot,
  50. float priority = 0.0);
  51. ///
  52. /// Remove a connection
  53. int removeConnection(vtkObject* vtk_obj, unsigned long vtk_event = vtkCommand::NoEvent,
  54. const QObject* qt_obj = 0, const char* qt_slot = 0);
  55. ///
  56. /// Remove all the connections
  57. inline int removeAllConnections();
  58. ///
  59. /// Temporarilly block all the connection
  60. void blockAllConnections(bool block);
  61. ///
  62. /// Block/Unblock a connection.
  63. int blockConnection(bool block, vtkObject* vtk_obj,
  64. unsigned long vtk_event, const QObject* qt_obj);
  65. void blockConnection(const QString& id, bool blocked);
  66. private:
  67. CTK_DECLARE_PRIVATE(ctkVTKObjectEventsObserver);
  68. };
  69. int ctkVTKObjectEventsObserver::removeAllConnections()
  70. {
  71. return this->removeConnection(0);
  72. }
  73. #endif