ctkTestWrappedVTKQInvokable.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 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.apache.org/licenses/LICENSE-2.0.txt
  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 __ctkTestWrappedVTKQInvokable_h
  15. #define __ctkTestWrappedVTKQInvokable_h
  16. // Qt includes
  17. #include <QObject>
  18. // VTK includes
  19. #include <vtkSmartPointer.h>
  20. #include <vtkTable.h>
  21. class ctkTestWrappedVTKQInvokable : public QObject
  22. {
  23. Q_OBJECT
  24. public:
  25. ctkTestWrappedVTKQInvokable(QObject * newParent = 0) : QObject(newParent)
  26. {
  27. this->MyTable = vtkSmartPointer<vtkTable>::New();
  28. }
  29. virtual ~ctkTestWrappedVTKQInvokable()
  30. {
  31. }
  32. /// Example of 'invokable' returning a VTK object
  33. /// Declaring a method as invokable allows to add it to the MetaObject system
  34. /// \note When a method returns a value, we tend to use Q_INVOKABLE
  35. /// instead of declaring a slot.
  36. Q_INVOKABLE vtkTable * getTable() const
  37. {
  38. return this->MyTable;
  39. }
  40. /// Example of 'invokable' accepting a VTK object as parameter
  41. Q_INVOKABLE void setTable(vtkTable * newTable)
  42. {
  43. this->MyTable = newTable;
  44. }
  45. private:
  46. vtkSmartPointer<vtkTable> MyTable;
  47. };
  48. #endif