Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerBaseQTGUIPythonQtDecorators.h
Go to the documentation of this file.
1 /*=auto=========================================================================
2 
3  Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH)
4  All Rights Reserved.
5 
6  See COPYRIGHT.txt
7  or http://www.slicer.org/copyright/copyright.txt for details.
8 
9  Program: 3D Slicer
10 
11 =========================================================================auto=*/
12 
13 #ifndef __qSlicerBaseQTGUIPythonQtDecorators_h
14 #define __qSlicerBaseQTGUIPythonQtDecorators_h
15 
16 // PythonQt includes
17 #include <PythonQt.h>
18 
19 // CTK includes
20 #include <ctkErrorLogModel.h>
21 
22 #include "vtkSlicerConfigure.h" // For Slicer_USE_QtTesting
23 
24 // CTK includes
25 #ifdef Slicer_USE_QtTesting
26 # include <ctkQtTestingUtility.h>
27 #endif
28 
29 // Slicer includes
32 #include "qSlicerAbstractModule.h"
33 #include "qSlicerCommandOptions.h"
34 #include "qSlicerPythonManager.h"
35 
36 #include "qSlicerBaseQTGUIExport.h"
37 
38 
39 // NOTE:
40 //
41 // For decorators it is assumed that the methods will never be called
42 // with the self argument as NULL. The self argument is the first argument
43 // for non-static methods.
44 //
45 
46 class qSlicerBaseQTGUIPythonQtDecorators : public QObject
47 {
48  Q_OBJECT
49 
50 public:
51 
53  {
54  PythonQt::self()->registerClass(&qSlicerAbstractModuleWidget::staticMetaObject);
55  PythonQt::self()->registerClass(&qSlicerPythonManager::staticMetaObject);
56  PythonQt::self()->registerClass(&qSlicerCommandOptions::staticMetaObject);
57 #ifdef Slicer_USE_QtTesting
58  PythonQt::self()->registerClass(&ctkQtTestingUtility::staticMetaObject);
59 #endif
60  PythonQt::self()->registerClass(&ctkErrorLogModel::staticMetaObject);
61  PythonQt::self()->registerClass(&ctkErrorLogTerminalOutput::staticMetaObject);
62  // Note: Use registerCPPClassForPythonQt to register pure Cpp classes
63  }
64 
65 public slots:
66 
67  //----------------------------------------------------------------------------
68  // qSlicerAbstractModule
69 
70  //----------------------------------------------------------------------------
72  {
73  return dynamic_cast<qSlicerAbstractModuleWidget*>(_module->widgetRepresentation());
74  }
75 
76  //----------------------------------------------------------------------------
78  {
79  return dynamic_cast<qSlicerAbstractModuleWidget*>(_module->createNewWidgetRepresentation());
80  }
81 
82  //----------------------------------------------------------------------------
83  // qSlicerAbstractModule
84 
85  //----------------------------------------------------------------------------
87  {
88  return dynamic_cast<qSlicerAbstractModule*>(_moduleWidget->module());
89  }
90 };
91 
92 //-----------------------------------------------------------------------------
94 {
95  PythonQt::self()->addDecorators(new qSlicerBaseQTGUIPythonQtDecorators);
96 }
97 
98 #endif
qSlicerAbstractCoreModule * module() const
qSlicerAbstractModuleRepresentation * createNewWidgetRepresentation()
qSlicerAbstractModuleWidget * createNewWidgetRepresentation(qSlicerAbstractModule *_module)
void initqSlicerBaseQTGUIPythonQtDecorators()
qSlicerAbstractModule * module(qSlicerAbstractModuleWidget *_moduleWidget)
qSlicerAbstractModuleWidget * widgetRepresentation(qSlicerAbstractModule *_module)
qSlicerAbstractModuleRepresentation * widgetRepresentation()