ctkVTKObjectEventsObserver.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 2010 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 __ctkVTKObjectEventsObserver_h
  15. #define __ctkVTKObjectEventsObserver_h
  16. /// CTK includes
  17. #include <ctkPimpl.h>
  18. /// Qt includes
  19. #include <QObject>
  20. #include <QList>
  21. #include <QString>
  22. /// VTK includes
  23. #include <vtkCommand.h>
  24. #include "CTKVisualizationVTKCoreExport.h"
  25. class ctkVTKConnection;
  26. class vtkObject;
  27. class ctkVTKObjectEventsObserverPrivate;
  28. class CTK_VISUALIZATION_VTK_CORE_EXPORT ctkVTKObjectEventsObserver : public QObject
  29. {
  30. Q_OBJECT
  31. public:
  32. typedef QObject Superclass;
  33. explicit ctkVTKObjectEventsObserver(QObject* parent = 0);
  34. virtual ~ctkVTKObjectEventsObserver(){}
  35. virtual void printAdditionalInfo();
  36. ///
  37. /// Enable / Disable all ctkVTKConnections
  38. void setAllEnabled( bool enable );
  39. bool allEnabled()const;
  40. ///
  41. /// Add a connection, an Id allowing to uniquely identify the connection is also returned
  42. QString addConnection(vtkObject* vtk_obj, unsigned long vtk_event,
  43. const QObject* qt_obj, const char* qt_slot, float priority = 0.0);
  44. ///
  45. /// Utility function that remove a connection on old_vtk_obj and add a connection
  46. /// to vtk_obj (same event, object, slot, priority)
  47. QString addConnection(vtkObject* old_vtk_obj, vtkObject* vtk_obj, unsigned long vtk_event,
  48. const QObject* qt_obj, const char* qt_slot, float priority = 0.0);
  49. ///
  50. /// Utility function that remove a connection on old_vtk_obj and add a connection
  51. /// to vtk_obj (same event, object, slot, priority)
  52. QString reconnection(vtkObject* vtk_obj, unsigned long vtk_event,
  53. const QObject* qt_obj, const char* qt_slot,
  54. float priority = 0.0);
  55. ///
  56. /// Remove a connection
  57. int removeConnection(vtkObject* vtk_obj, unsigned long vtk_event = vtkCommand::NoEvent,
  58. const QObject* qt_obj = 0, const char* qt_slot = 0);
  59. ///
  60. /// Remove all the connections
  61. inline int removeAllConnections();
  62. ///
  63. /// Temporarilly block all the connection
  64. void blockAllConnections(bool block);
  65. ///
  66. /// Block/Unblock a connection.
  67. int blockConnection(bool block, vtkObject* vtk_obj,
  68. unsigned long vtk_event, const QObject* qt_obj);
  69. void blockConnection(const QString& id, bool blocked);
  70. private:
  71. CTK_DECLARE_PRIVATE(ctkVTKObjectEventsObserver);
  72. };
  73. //-----------------------------------------------------------------------------
  74. int ctkVTKObjectEventsObserver::removeAllConnections()
  75. {
  76. return this->removeConnection(0);
  77. }
  78. #endif