CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkWidgetsPythonQtDecorators.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Library: CTK
4
5 Copyright (c) Kitware Inc.
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0.txt
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18
19=========================================================================*/
20
21#ifndef __ctkWidgetsPythonQtDecorators_h
22#define __ctkWidgetsPythonQtDecorators_h
23
24// PythonQt includes
25#include <PythonQt.h>
26
27// CTK includes
28#include <ctkErrorLogModel.h>
32#include <ctkWidgetsUtils.h>
34
35// NOTE:
36//
37// For decorators it is assumed that the methods will never be called
38// with the self argument as NULL. The self argument is the first argument
39// for non-static methods.
40//
41
43class ctkWidgetsPythonQtDecorators : public QObject
44{
45 Q_OBJECT
46public:
47
49 {
50 PythonQt::self()->addParentClass("ctkWorkflowWidgetStep", "ctkWorkflowStep",
51 PythonQtUpcastingOffset<ctkWorkflowWidgetStep,ctkWorkflowStep>());
52 }
53
54public Q_SLOTS:
55
56 // ctkWorkflowWidgetStep
57
59 {
60 return step->hasCreateUserInterfaceCommand();
61 }
62
64 ctkWorkflowWidgetStep* step, bool newHasCreateUserInterfaceCommand)
65 {
66 step->setHasCreateUserInterfaceCommand(newHasCreateUserInterfaceCommand);
67 }
68
70 {
71 return step->hasShowUserInterfaceCommand();
72 }
73
75 ctkWorkflowWidgetStep* step, bool newHasShowUserInterfaceCommand)
76 {
77 step->setHasShowUserInterfaceCommand(newHasShowUserInterfaceCommand);
78 }
79
80 // ctkErrorLogLevel
81
83 {
85 }
86
87 // ctkTransferFunctionBarsItem
88
90 {
91 return new ctkTransferFunctionBarsItem(parent);
92 }
93
95 ctkTransferFunction* transferFunc,
96 QGraphicsItem* parent = 0)
97 {
98 return new ctkTransferFunctionBarsItem(transferFunc, parent);
99 }
100
102 {
103 delete obj;
104 }
105
106 // ctkTransferFunctionControlPointsItem
107
109 QGraphicsItem* parent = 0)
110 {
111 return new ctkTransferFunctionControlPointsItem(parent);
112 }
113
115 ctkTransferFunction* transferFunc,
116 QGraphicsItem* parent = 0)
117 {
118 return new ctkTransferFunctionControlPointsItem(transferFunc, parent);
119 }
120
122 {
123 delete obj;
124 }
125
126 // ctkTransferFunctionGradientItem
127
129 QGraphicsItem* parent = 0)
130 {
131 return new ctkTransferFunctionGradientItem(parent);
132 }
133
135 ctkTransferFunction* transferFunc,
136 QGraphicsItem* parent = 0)
137 {
138 return new ctkTransferFunctionGradientItem(transferFunc, parent);
139 }
140
142 {
143 delete obj;
144 }
145
146};
147
148//-----------------------------------------------------------------------------
149class PythonQtWrapper_CTKWidgets : public QObject
150{
151 Q_OBJECT
152
153public Q_SLOTS:
154 QImage static_ctkWidgetsUtils_grabWidget(QWidget* widget, QRect rectangle = QRect())
155 {
156 return ctk::grabWidget(widget, rectangle);
157 }
158};
159
160//-----------------------------------------------------------------------------
163{
164 // HACK: Since the CMake based light wrapping only consider class name matching the
165 // filename where the class is defined, let's explicitly register ctkErrorLogLevel
166 // so that the log level QFlags are exposed to python.
167 PythonQt::self()->registerClass(&ctkErrorLogLevel::staticMetaObject, "CTKCore");
168
169 PythonQt::self()->registerClass(&ctkTransferFunctionBarsItem::staticMetaObject, "CTKWidgets");
170 PythonQt::self()->registerClass(&ctkTransferFunctionControlPointsItem::staticMetaObject, "CTKWidgets");
171 PythonQt::self()->registerClass(&ctkTransferFunctionGradientItem::staticMetaObject, "CTKWidgets");
172
173 PythonQt::self()->addDecorators(new ctkWidgetsPythonQtDecorators);
174
175 // NOTE: This exposes ctk.ctkWidgetsUtils.grabWidget(), for example. PythonQt
176 // doesn't support wrapping a static function and adding it to the top-level
177 // ctk module. Note that PythonQtWrapper_CTKDICOMCore installs itself as ctk.ctk,
178 // but using that same module here would replace PythonQtWrapper_CTKDICOMCore.
179 PythonQt::self()->registerCPPClass("ctkWidgetsUtils", "", "CTKWidgets", PythonQtCreateObject<PythonQtWrapper_CTKWidgets>);
180}
181
182#endif
QImage static_ctkWidgetsUtils_grabWidget(QWidget *widget, QRect rectangle=QRect())
static QString logLevelAsString(ctkErrorLogLevel::LogLevel logLevel)
ctkTransferFunctionGradientItem * new_ctkTransferFunctionGradientItem(ctkTransferFunction *transferFunc, QGraphicsItem *parent=0)
void delete_ctkTransferFunctionGradientItem(ctkTransferFunctionGradientItem *obj)
ctkTransferFunctionControlPointsItem * new_ctkTransferFunctionControlPointsItem(QGraphicsItem *parent=0)
bool hasShowUserInterfaceCommand(ctkWorkflowWidgetStep *step) const
ctkTransferFunctionGradientItem * new_ctkTransferFunctionGradientItem(QGraphicsItem *parent=0)
ctkTransferFunctionControlPointsItem * new_ctkTransferFunctionControlPointsItem(ctkTransferFunction *transferFunc, QGraphicsItem *parent=0)
QString static_ctkErrorLogLevel_logLevelAsString(ctkErrorLogLevel::LogLevel logLevel)
void delete_ctkTransferFunctionBarsItem(ctkTransferFunctionBarsItem *obj)
void setHasCreateUserInterfaceCommand(ctkWorkflowWidgetStep *step, bool newHasCreateUserInterfaceCommand)
void setHasShowUserInterfaceCommand(ctkWorkflowWidgetStep *step, bool newHasShowUserInterfaceCommand)
ctkTransferFunctionBarsItem * new_ctkTransferFunctionBarsItem(ctkTransferFunction *transferFunc, QGraphicsItem *parent=0)
void delete_ctkTransferFunctionControlPointsItem(ctkTransferFunctionControlPointsItem *obj)
bool hasCreateUserInterfaceCommand(ctkWorkflowWidgetStep *step) const
ctkTransferFunctionBarsItem * new_ctkTransferFunctionBarsItem(QGraphicsItem *parent=0)
ctkWorkflowWidgetStep is a convienience class to quickly construct a ctkWorkflowStep with a user inte...
virtual void setHasCreateUserInterfaceCommand(bool flag)
virtual bool hasCreateUserInterfaceCommand() const
virtual bool hasShowUserInterfaceCommand() const
virtual void setHasShowUserInterfaceCommand(bool flag)
void initCTKWidgetsPythonQtDecorators()
QImage CTK_WIDGETS_EXPORT grabWidget(QWidget *widget, QRect rectangle=QRect())