ctkVTKConnection.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 __ctkVTKConnection_h
  11. #define __ctkVTKConnection_h
  12. // Qt includes
  13. #include <QObject>
  14. #include <QVector>
  15. // CTK includes
  16. #include <ctkPimpl.h>
  17. #include "CTKVisualizationVTKCoreExport.h"
  18. class vtkObject;
  19. class ctkVTKConnectionPrivate;
  20. class CTK_VISUALIZATION_VTK_CORE_EXPORT ctkVTKConnection : public QObject
  21. {
  22. Q_OBJECT
  23. public:
  24. typedef QObject Superclass;
  25. explicit ctkVTKConnection(QObject* parent);
  26. ///
  27. virtual void printAdditionalInfo();
  28. QString shortDescription();
  29. static QString shortDescription(vtkObject* vtk_obj, unsigned long vtk_event,
  30. const QObject* qt_obj, QString qt_slot = "");
  31. ///
  32. void SetParameters(vtkObject* vtk_obj, unsigned long vtk_event,
  33. const QObject* qt_obj, QString qt_slot, float priority);
  34. ///
  35. /// Check the validity of the parameters. Parameters must be valid to add
  36. /// a connection
  37. static bool ValidateParameters(vtkObject* vtk_obj, unsigned long vtk_event,
  38. const QObject* qt_obj, QString qt_slot);
  39. ///
  40. /// Actually do the connection. Parameters must have been set prior to it
  41. /// Disconnecting (enable = false) removes the connection.
  42. void setEnabled(bool enable);
  43. bool isEnabled()const;
  44. ///
  45. /// Temporarilly block any signals/slots. If the event is fired, the slot
  46. /// won't be called. You can restore the connection by calling SetBlocked
  47. /// with block = false.
  48. void setBlocked(bool block);
  49. bool isBlocked()const;
  50. ///
  51. bool isEqual(vtkObject* vtk_obj, unsigned long vtk_event,
  52. const QObject* qt_obj, QString qt_slot)const;
  53. ///
  54. /// Return a string uniquely identifying the connection within the current process
  55. QString id()const;
  56. public slots:
  57. ///
  58. /// Safe deletion
  59. void deleteConnection();
  60. signals:
  61. ///
  62. /// The qt signal emited by the VTK Callback
  63. /// The signal corresponding to the slot will be emited
  64. void emitExecute(vtkObject* caller, vtkObject* call_data);
  65. /// Note: even if the signal has a signature with 4 args, you can
  66. /// connect it to a slot with less arguments as long as the types of the
  67. /// argument are matching:
  68. /// connect(obj1,SIGNAL(signalFunc(A,B,C,D)),obj2,SLOT(slotFunc(A)));
  69. void emitExecute(vtkObject* caller, void* call_data, unsigned long vtk_event, void* client_data);
  70. protected:
  71. virtual ~ctkVTKConnection();
  72. private:
  73. CTK_DECLARE_PRIVATE(ctkVTKConnection);
  74. };
  75. #endif