ctkVTKConnection.h 2.3 KB

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