ctkVTKConnection.h 3.0 KB

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