ctkWidgetsPythonQtDecorators.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 <ctkWorkflowWidgetStep.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 Widgets
  28. class ctkWidgetsPythonQtDecorators : public QObject
  29. {
  30. Q_OBJECT
  31. public:
  32. ctkWidgetsPythonQtDecorators()
  33. {
  34. PythonQt::self()->addParentClass("ctkWorkflowWidgetStep", "ctkWorkflowStep",
  35. PythonQtUpcastingOffset<ctkWorkflowWidgetStep,ctkWorkflowStep>());
  36. }
  37. public Q_SLOTS:
  38. bool hasCreateUserInterfaceCommand(ctkWorkflowWidgetStep* step)const
  39. {
  40. return step->hasCreateUserInterfaceCommand();
  41. }
  42. void setHasCreateUserInterfaceCommand(
  43. ctkWorkflowWidgetStep* step, bool newHasCreateUserInterfaceCommand)
  44. {
  45. step->setHasCreateUserInterfaceCommand(newHasCreateUserInterfaceCommand);
  46. }
  47. bool hasShowUserInterfaceCommand(ctkWorkflowWidgetStep* step)const
  48. {
  49. return step->hasShowUserInterfaceCommand();
  50. }
  51. void setHasShowUserInterfaceCommand(
  52. ctkWorkflowWidgetStep* step, bool newHasShowUserInterfaceCommand)
  53. {
  54. step->setHasShowUserInterfaceCommand(newHasShowUserInterfaceCommand);
  55. }
  56. // ctkErrorLogLevel
  57. QString static_ctkErrorLogLevel_logLevelAsString(ctkErrorLogLevel::LogLevel logLevel)
  58. {
  59. return ctkErrorLogLevel::logLevelAsString(logLevel);
  60. }
  61. };
  62. //-----------------------------------------------------------------------------
  63. /// \ingroup Widgets
  64. void initCTKWidgetsPythonQtDecorators()
  65. {
  66. // HACK: Since the CMake based light wrapping only consider class name matching the
  67. // filename where the class is defined, let's explicitly register ctkErrorLogLevel
  68. // so that the log level QFlags are exposed to python.
  69. PythonQt::self()->registerClass(&ctkErrorLogLevel::staticMetaObject, "CTKCore");
  70. PythonQt::self()->addDecorators(new ctkWidgetsPythonQtDecorators);
  71. }
  72. #endif