ctkCorePythonQtDecorators.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 __ctkCorePythonQtDecorators_h
  15. #define __ctkCorePythonQtDecorators_h
  16. // PythonQt includes
  17. #include <PythonQt.h>
  18. // CTK includes
  19. #include <ctkWorkflowStep.h>
  20. #include <ctkWorkflowTransitions.h>
  21. // NOTE:
  22. //
  23. // For decorators it is assumed that the methods will never be called
  24. // with the self argument as NULL. The self argument is the first argument
  25. // for non-static methods.
  26. //
  27. /// \ingroup Core
  28. class ctkCorePythonQtDecorators : public QObject
  29. {
  30. Q_OBJECT
  31. public:
  32. ctkCorePythonQtDecorators()
  33. {
  34. PythonQt::self()->registerCPPClass("ctkWorkflowStep", 0, "CTKCore");
  35. PythonQt::self()->registerClass(&ctkWorkflowInterstepTransition::staticMetaObject, "CTKCore");
  36. }
  37. public Q_SLOTS:
  38. //
  39. // ctkWorkflowStep
  40. //
  41. ctkWorkflowStep* new_ctkWorkflowStep()
  42. {
  43. return new ctkWorkflowStep();
  44. }
  45. ctkWorkflowStep* new_ctkWorkflowStep(const QString& newId)
  46. {
  47. return new ctkWorkflowStep(newId);
  48. }
  49. void delete_ctkWorkflowStep(ctkWorkflowStep * step)
  50. {
  51. delete step;
  52. }
  53. ctkWorkflow* workflow(ctkWorkflowStep* step)const
  54. {
  55. return step->workflow();
  56. }
  57. QString id(ctkWorkflowStep* step)const
  58. {
  59. return step->id();
  60. }
  61. void setId(ctkWorkflowStep* step, const QString& newId)const
  62. {
  63. step->setId(newId);
  64. }
  65. QString name(ctkWorkflowStep* step)const
  66. {
  67. return step->name();
  68. }
  69. void setName(ctkWorkflowStep* step, const QString& newName)
  70. {
  71. step->setName(newName);
  72. }
  73. QString description(ctkWorkflowStep* step)const
  74. {
  75. return step->description();
  76. }
  77. void setDescription(ctkWorkflowStep* step, const QString& newDescription)
  78. {
  79. step->setDescription(newDescription);
  80. }
  81. QString statusText(ctkWorkflowStep* step)const
  82. {
  83. return step->statusText();
  84. }
  85. bool hasValidateCommand(ctkWorkflowStep* step)const
  86. {
  87. return step->hasValidateCommand();
  88. }
  89. void setHasValidateCommand(ctkWorkflowStep* step, bool newHasValidateCommand)
  90. {
  91. step->setHasValidateCommand(newHasValidateCommand);
  92. }
  93. bool hasOnEntryCommand(ctkWorkflowStep* step)const
  94. {
  95. return step->hasOnEntryCommand();
  96. }
  97. void setHasOnEntryCommand(ctkWorkflowStep* step, bool newHasOnEntryCommand)
  98. {
  99. step->setHasOnEntryCommand(newHasOnEntryCommand);
  100. }
  101. bool hasOnExitCommand(ctkWorkflowStep* step)const
  102. {
  103. return step->hasOnExitCommand();
  104. }
  105. void setHasOnExitCommand(ctkWorkflowStep* step, bool newHasOnExitCommand)
  106. {
  107. step->setHasOnExitCommand(newHasOnExitCommand);
  108. }
  109. QObject* ctkWorkflowStepQObject(ctkWorkflowStep* step)
  110. {
  111. return step->ctkWorkflowStepQObject();
  112. }
  113. //
  114. // ctkWorkflowInterstepTransition
  115. //
  116. ctkWorkflowInterstepTransition* new_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition::InterstepTransitionType newTransitionType)
  117. {
  118. return new ctkWorkflowInterstepTransition(newTransitionType);
  119. }
  120. ctkWorkflowInterstepTransition* new_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition::InterstepTransitionType newTransitionType, const QString& newId)
  121. {
  122. return new ctkWorkflowInterstepTransition(newTransitionType, newId);
  123. }
  124. void delete_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition * transition)
  125. {
  126. delete transition;
  127. }
  128. };
  129. //-----------------------------------------------------------------------------
  130. void initCTKCorePythonQtDecorators()
  131. {
  132. PythonQt::self()->addDecorators(new ctkCorePythonQtDecorators);
  133. }
  134. #endif