PageRenderTime 50ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/Base/QTCore/qSlicerBaseQTCorePythonQtDecorators.h

https://github.com/pieper/Slicer4
C Header | 129 lines | 68 code | 28 blank | 33 comment | 0 complexity | 79487a744d3cc507276011bacb3e19a3 MD5 | raw file
  1. /*=auto=========================================================================
  2. Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH)
  3. All Rights Reserved.
  4. See Doc/copyright/copyright.txt
  5. or http://www.slicer.org/copyright/copyright.txt for details.
  6. Program: 3D Slicer
  7. =========================================================================auto=*/
  8. #ifndef __qSlicerBaseQTCorePythonQtDecorators_h
  9. #define __qSlicerBaseQTCorePythonQtDecorators_h
  10. // Qt includes
  11. #include <QObject>
  12. // CTK includes
  13. #include <ctkAbstractPythonManager.h>
  14. // VTK includes
  15. #include <vtkInstantiator.h>
  16. #include <vtkPythonUtil.h>
  17. #include <vtkPython.h>
  18. // PythonQT includes
  19. #include <PythonQtObjectPtr.h>
  20. // SlicerQt includes
  21. #include "qSlicerCoreApplication.h"
  22. #include "qSlicerModuleManager.h"
  23. #include "qSlicerModuleFactoryManager.h"
  24. #include "qSlicerAbstractCoreModule.h"
  25. #include "qSlicerBaseQTCoreExport.h"
  26. // NOTE:
  27. //
  28. // For decorators it is assumed that the methods will never be called
  29. // with the self argument as NULL. The self argument is the first argument
  30. // for non-static methods.
  31. //
  32. class Q_SLICER_BASE_QTCORE_EXPORT qSlicerBaseQTBasePythonQtDecorators : public QObject
  33. {
  34. Q_OBJECT
  35. public:
  36. qSlicerBaseQTBasePythonQtDecorators(ctkAbstractPythonManager* pythonManager)
  37. {
  38. Q_ASSERT(pythonManager);
  39. pythonManager->registerClassForPythonQt(&qSlicerCoreApplication::staticMetaObject);
  40. pythonManager->registerClassForPythonQt(&qSlicerModuleManager::staticMetaObject);
  41. pythonManager->registerClassForPythonQt(&qSlicerAbstractCoreModule::staticMetaObject);
  42. pythonManager->registerCPPClassForPythonQt("qSlicerModuleFactoryManager");
  43. }
  44. public slots:
  45. // static methods
  46. QList<QWidget*> static_qSlicerCoreApplication_allWidgets()
  47. {
  48. return qSlicerCoreApplication::allWidgets();
  49. }
  50. //----------------------------------------------------------------------------
  51. // qSlicerCoreApplication
  52. qSlicerModuleManager* moduleManager(qSlicerCoreApplication* app)const
  53. {
  54. return app->moduleManager();
  55. }
  56. void sendEvent(qSlicerCoreApplication* app, QObject* _receiver, QEvent* _event)
  57. {
  58. app->sendEvent(_receiver, _event);
  59. }
  60. void processEvents(qSlicerCoreApplication* app)
  61. {
  62. app->processEvents();
  63. }
  64. //----------------------------------------------------------------------------
  65. // qSlicerModuleFactoryManager
  66. QStringList moduleNames(qSlicerModuleFactoryManager* _factoryManager)
  67. {
  68. return _factoryManager->moduleNames();
  69. }
  70. //----------------------------------------------------------------------------
  71. // qSlicerModuleManager
  72. qSlicerModuleFactoryManager* factoryManager(qSlicerModuleManager* _moduleManager)
  73. {
  74. return _moduleManager->factoryManager();
  75. }
  76. ///
  77. bool loadModule(qSlicerModuleManager* _moduleManager, const QString& name)
  78. {
  79. return _moduleManager->loadModule(name);
  80. }
  81. ///
  82. bool unLoadModule(qSlicerModuleManager* _moduleManager, const QString& name)
  83. {
  84. return _moduleManager->unLoadModule(name);
  85. }
  86. ///
  87. bool isLoaded(qSlicerModuleManager* _moduleManager, const QString& name)const
  88. {
  89. return _moduleManager->isLoaded(name);
  90. }
  91. ///
  92. qSlicerAbstractCoreModule* module(qSlicerModuleManager* _moduleManager, const QString& name)
  93. {
  94. return _moduleManager->module(name);
  95. }
  96. };
  97. #endif