ctkCorePythonQtDecorators.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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 <ctkBooleanMapper.h>
  20. #include <ctkErrorLogContext.h>
  21. #include <ctkWorkflowStep.h>
  22. #include <ctkWorkflowTransitions.h>
  23. // NOTE:
  24. //
  25. // For decorators it is assumed that the methods will never be called
  26. // with the self argument as NULL. The self argument is the first argument
  27. // for non-static methods.
  28. //
  29. /// \ingroup Core
  30. class ctkCorePythonQtDecorators : public QObject
  31. {
  32. Q_OBJECT
  33. public:
  34. ctkCorePythonQtDecorators()
  35. {
  36. PythonQt::self()->registerClass(&ctkBooleanMapper::staticMetaObject, "CTKCore");
  37. PythonQt::self()->registerCPPClass("ctkErrorLogContext", 0, "CTKCore");
  38. PythonQt::self()->registerCPPClass("ctkWorkflowStep", 0, "CTKCore");
  39. PythonQt::self()->registerClass(&ctkWorkflowInterstepTransition::staticMetaObject, "CTKCore");
  40. }
  41. public Q_SLOTS:
  42. //
  43. // ctkBooleanMapper
  44. //
  45. ctkBooleanMapper* new_ctkBooleanMapper(QObject* targetObject, const QByteArray& propertyName, const QByteArray& signal)
  46. {
  47. return new ctkBooleanMapper(targetObject, propertyName, signal);
  48. }
  49. //
  50. // ctkWorkflowStep
  51. //
  52. ctkWorkflowStep* new_ctkWorkflowStep()
  53. {
  54. return new ctkWorkflowStep();
  55. }
  56. ctkWorkflowStep* new_ctkWorkflowStep(const QString& newId)
  57. {
  58. return new ctkWorkflowStep(newId);
  59. }
  60. void delete_ctkWorkflowStep(ctkWorkflowStep * step)
  61. {
  62. delete step;
  63. }
  64. ctkWorkflow* workflow(ctkWorkflowStep* step)const
  65. {
  66. return step->workflow();
  67. }
  68. QString id(ctkWorkflowStep* step)const
  69. {
  70. return step->id();
  71. }
  72. void setId(ctkWorkflowStep* step, const QString& newId)const
  73. {
  74. step->setId(newId);
  75. }
  76. QString name(ctkWorkflowStep* step)const
  77. {
  78. return step->name();
  79. }
  80. void setName(ctkWorkflowStep* step, const QString& newName)
  81. {
  82. step->setName(newName);
  83. }
  84. QString description(ctkWorkflowStep* step)const
  85. {
  86. return step->description();
  87. }
  88. void setDescription(ctkWorkflowStep* step, const QString& newDescription)
  89. {
  90. step->setDescription(newDescription);
  91. }
  92. QString statusText(ctkWorkflowStep* step)const
  93. {
  94. return step->statusText();
  95. }
  96. bool hasValidateCommand(ctkWorkflowStep* step)const
  97. {
  98. return step->hasValidateCommand();
  99. }
  100. void setHasValidateCommand(ctkWorkflowStep* step, bool newHasValidateCommand)
  101. {
  102. step->setHasValidateCommand(newHasValidateCommand);
  103. }
  104. bool hasOnEntryCommand(ctkWorkflowStep* step)const
  105. {
  106. return step->hasOnEntryCommand();
  107. }
  108. void setHasOnEntryCommand(ctkWorkflowStep* step, bool newHasOnEntryCommand)
  109. {
  110. step->setHasOnEntryCommand(newHasOnEntryCommand);
  111. }
  112. bool hasOnExitCommand(ctkWorkflowStep* step)const
  113. {
  114. return step->hasOnExitCommand();
  115. }
  116. void setHasOnExitCommand(ctkWorkflowStep* step, bool newHasOnExitCommand)
  117. {
  118. step->setHasOnExitCommand(newHasOnExitCommand);
  119. }
  120. QObject* ctkWorkflowStepQObject(ctkWorkflowStep* step)
  121. {
  122. return step->ctkWorkflowStepQObject();
  123. }
  124. //
  125. // ctkWorkflowInterstepTransition
  126. //
  127. ctkWorkflowInterstepTransition* new_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition::InterstepTransitionType newTransitionType)
  128. {
  129. return new ctkWorkflowInterstepTransition(newTransitionType);
  130. }
  131. ctkWorkflowInterstepTransition* new_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition::InterstepTransitionType newTransitionType, const QString& newId)
  132. {
  133. return new ctkWorkflowInterstepTransition(newTransitionType, newId);
  134. }
  135. void delete_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition * transition)
  136. {
  137. delete transition;
  138. }
  139. //
  140. // ctkErrorLogContext
  141. //
  142. ctkErrorLogContext* new_ctkErrorLogContext()
  143. {
  144. return new ctkErrorLogContext();
  145. }
  146. ctkErrorLogContext* new_ctkErrorLogContext(const QString& msg)
  147. {
  148. return new ctkErrorLogContext(msg);
  149. }
  150. void setCategory(ctkErrorLogContext* context, const QString& category)
  151. {
  152. context->Category = category;
  153. }
  154. QString category(ctkErrorLogContext* context)
  155. {
  156. return context->Category;
  157. }
  158. void setLine(ctkErrorLogContext* context, int line)
  159. {
  160. context->Line = line;
  161. }
  162. int line(ctkErrorLogContext* context)
  163. {
  164. return context->Line;
  165. }
  166. void setFile(ctkErrorLogContext* context, const QString& file)
  167. {
  168. context->File = file;
  169. }
  170. QString file(ctkErrorLogContext* context)
  171. {
  172. return context->File;
  173. }
  174. void setFunction(ctkErrorLogContext* context, const QString& function)
  175. {
  176. context->Function = function;
  177. }
  178. QString function(ctkErrorLogContext* context)
  179. {
  180. return context->Function;
  181. }
  182. void setMessage(ctkErrorLogContext* context, const QString& message)
  183. {
  184. context->Message = message;
  185. }
  186. QString message(ctkErrorLogContext* context)
  187. {
  188. return context->Message;
  189. }
  190. };
  191. //-----------------------------------------------------------------------------
  192. void initCTKCorePythonQtDecorators()
  193. {
  194. PythonQt::self()->addDecorators(new ctkCorePythonQtDecorators);
  195. }
  196. #endif