ctkWidgetsPythonQtDecorators.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 __ctkWidgetsPythonQtDecorators_h
  15. #define __ctkWidgetsPythonQtDecorators_h
  16. // PythonQt includes
  17. #include <PythonQt.h>
  18. // CTK includes
  19. #include <ctkErrorLogModel.h>
  20. #include <ctkTransferFunctionBarsItem.h>
  21. #include <ctkTransferFunctionControlPointsItem.h>
  22. #include <ctkTransferFunctionGradientItem.h>
  23. #include <ctkWorkflowWidgetStep.h>
  24. // NOTE:
  25. //
  26. // For decorators it is assumed that the methods will never be called
  27. // with the self argument as NULL. The self argument is the first argument
  28. // for non-static methods.
  29. //
  30. /// \ingroup Widgets
  31. class ctkWidgetsPythonQtDecorators : public QObject
  32. {
  33. Q_OBJECT
  34. public:
  35. ctkWidgetsPythonQtDecorators()
  36. {
  37. PythonQt::self()->addParentClass("ctkWorkflowWidgetStep", "ctkWorkflowStep",
  38. PythonQtUpcastingOffset<ctkWorkflowWidgetStep,ctkWorkflowStep>());
  39. }
  40. public Q_SLOTS:
  41. // ctkWorkflowWidgetStep
  42. bool hasCreateUserInterfaceCommand(ctkWorkflowWidgetStep* step)const
  43. {
  44. return step->hasCreateUserInterfaceCommand();
  45. }
  46. void setHasCreateUserInterfaceCommand(
  47. ctkWorkflowWidgetStep* step, bool newHasCreateUserInterfaceCommand)
  48. {
  49. step->setHasCreateUserInterfaceCommand(newHasCreateUserInterfaceCommand);
  50. }
  51. bool hasShowUserInterfaceCommand(ctkWorkflowWidgetStep* step)const
  52. {
  53. return step->hasShowUserInterfaceCommand();
  54. }
  55. void setHasShowUserInterfaceCommand(
  56. ctkWorkflowWidgetStep* step, bool newHasShowUserInterfaceCommand)
  57. {
  58. step->setHasShowUserInterfaceCommand(newHasShowUserInterfaceCommand);
  59. }
  60. // ctkErrorLogLevel
  61. QString static_ctkErrorLogLevel_logLevelAsString(ctkErrorLogLevel::LogLevel logLevel)
  62. {
  63. return ctkErrorLogLevel::logLevelAsString(logLevel);
  64. }
  65. // ctkTransferFunctionBarsItem
  66. ctkTransferFunctionBarsItem* new_ctkTransferFunctionBarsItem(QGraphicsItem* parent = 0)
  67. {
  68. return new ctkTransferFunctionBarsItem(parent);
  69. }
  70. ctkTransferFunctionBarsItem* new_ctkTransferFunctionBarsItem(
  71. ctkTransferFunction* transferFunc,
  72. QGraphicsItem* parent = 0)
  73. {
  74. return new ctkTransferFunctionBarsItem(transferFunc, parent);
  75. }
  76. void delete_ctkTransferFunctionBarsItem(ctkTransferFunctionBarsItem* obj)
  77. {
  78. delete obj;
  79. }
  80. // ctkTransferFunctionControlPointsItem
  81. ctkTransferFunctionControlPointsItem* new_ctkTransferFunctionControlPointsItem(
  82. QGraphicsItem* parent = 0)
  83. {
  84. return new ctkTransferFunctionControlPointsItem(parent);
  85. }
  86. ctkTransferFunctionControlPointsItem* new_ctkTransferFunctionControlPointsItem(
  87. ctkTransferFunction* transferFunc,
  88. QGraphicsItem* parent = 0)
  89. {
  90. return new ctkTransferFunctionControlPointsItem(transferFunc, parent);
  91. }
  92. void delete_ctkTransferFunctionControlPointsItem(ctkTransferFunctionControlPointsItem* obj)
  93. {
  94. delete obj;
  95. }
  96. // ctkTransferFunctionGradientItem
  97. ctkTransferFunctionGradientItem* new_ctkTransferFunctionGradientItem(
  98. QGraphicsItem* parent = 0)
  99. {
  100. return new ctkTransferFunctionGradientItem(parent);
  101. }
  102. ctkTransferFunctionGradientItem* new_ctkTransferFunctionGradientItem(
  103. ctkTransferFunction* transferFunc,
  104. QGraphicsItem* parent = 0)
  105. {
  106. return new ctkTransferFunctionGradientItem(transferFunc, parent);
  107. }
  108. void delete_ctkTransferFunctionGradientItem(ctkTransferFunctionGradientItem* obj)
  109. {
  110. delete obj;
  111. }
  112. };
  113. //-----------------------------------------------------------------------------
  114. /// \ingroup Widgets
  115. void initCTKWidgetsPythonQtDecorators()
  116. {
  117. // HACK: Since the CMake based light wrapping only consider class name matching the
  118. // filename where the class is defined, let's explicitly register ctkErrorLogLevel
  119. // so that the log level QFlags are exposed to python.
  120. PythonQt::self()->registerClass(&ctkErrorLogLevel::staticMetaObject, "CTKCore");
  121. PythonQt::self()->registerClass(&ctkTransferFunctionBarsItem::staticMetaObject, "CTKWidgets");
  122. PythonQt::self()->registerClass(&ctkTransferFunctionControlPointsItem::staticMetaObject, "CTKWidgets");
  123. PythonQt::self()->registerClass(&ctkTransferFunctionGradientItem::staticMetaObject, "CTKWidgets");
  124. PythonQt::self()->addDecorators(new ctkWidgetsPythonQtDecorators);
  125. }
  126. #endif