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 <ctkWorkflowWidgetStep.h>
33 
34 // NOTE:
35 //
36 // For decorators it is assumed that the methods will never be called
37 // with the self argument as NULL. The self argument is the first argument
38 // for non-static methods.
39 //
40 
42 class ctkWidgetsPythonQtDecorators : public QObject
43 {
44  Q_OBJECT
45 public:
46 
48  {
49  PythonQt::self()->addParentClass("ctkWorkflowWidgetStep", "ctkWorkflowStep",
50  PythonQtUpcastingOffset<ctkWorkflowWidgetStep,ctkWorkflowStep>());
51  }
52 
53 public Q_SLOTS:
54 
55  // ctkWorkflowWidgetStep
56 
58  {
59  return step->hasCreateUserInterfaceCommand();
60  }
61 
63  ctkWorkflowWidgetStep* step, bool newHasCreateUserInterfaceCommand)
64  {
65  step->setHasCreateUserInterfaceCommand(newHasCreateUserInterfaceCommand);
66  }
67 
69  {
70  return step->hasShowUserInterfaceCommand();
71  }
72 
74  ctkWorkflowWidgetStep* step, bool newHasShowUserInterfaceCommand)
75  {
76  step->setHasShowUserInterfaceCommand(newHasShowUserInterfaceCommand);
77  }
78 
79  // ctkErrorLogLevel
80 
82  {
83  return ctkErrorLogLevel::logLevelAsString(logLevel);
84  }
85 
86  // ctkTransferFunctionBarsItem
87 
89  {
90  return new ctkTransferFunctionBarsItem(parent);
91  }
92 
94  ctkTransferFunction* transferFunc,
95  QGraphicsItem* parent = 0)
96  {
97  return new ctkTransferFunctionBarsItem(transferFunc, parent);
98  }
99 
101  {
102  delete obj;
103  }
104 
105  // ctkTransferFunctionControlPointsItem
106 
108  QGraphicsItem* parent = 0)
109  {
110  return new ctkTransferFunctionControlPointsItem(parent);
111  }
112 
114  ctkTransferFunction* transferFunc,
115  QGraphicsItem* parent = 0)
116  {
117  return new ctkTransferFunctionControlPointsItem(transferFunc, parent);
118  }
119 
121  {
122  delete obj;
123  }
124 
125  // ctkTransferFunctionGradientItem
126 
128  QGraphicsItem* parent = 0)
129  {
130  return new ctkTransferFunctionGradientItem(parent);
131  }
132 
134  ctkTransferFunction* transferFunc,
135  QGraphicsItem* parent = 0)
136  {
137  return new ctkTransferFunctionGradientItem(transferFunc, parent);
138  }
139 
141  {
142  delete obj;
143  }
144 
145 };
146 
147 //-----------------------------------------------------------------------------
150 {
151  // HACK: Since the CMake based light wrapping only consider class name matching the
152  // filename where the class is defined, let's explicitly register ctkErrorLogLevel
153  // so that the log level QFlags are exposed to python.
154  PythonQt::self()->registerClass(&ctkErrorLogLevel::staticMetaObject, "CTKCore");
155 
156  PythonQt::self()->registerClass(&ctkTransferFunctionBarsItem::staticMetaObject, "CTKWidgets");
157  PythonQt::self()->registerClass(&ctkTransferFunctionControlPointsItem::staticMetaObject, "CTKWidgets");
158  PythonQt::self()->registerClass(&ctkTransferFunctionGradientItem::staticMetaObject, "CTKWidgets");
159 
160  PythonQt::self()->addDecorators(new ctkWidgetsPythonQtDecorators);
161 }
162 
163 #endif
ctkWorkflowWidgetStep is a convienience class to quickly construct a ctkWorkflowStep with a user inte...
void delete_ctkTransferFunctionBarsItem(ctkTransferFunctionBarsItem *obj)
bool hasShowUserInterfaceCommand(ctkWorkflowWidgetStep *step) const
ctkTransferFunctionControlPointsItem * new_ctkTransferFunctionControlPointsItem(QGraphicsItem *parent=0)
void delete_ctkTransferFunctionGradientItem(ctkTransferFunctionGradientItem *obj)
QString static_ctkErrorLogLevel_logLevelAsString(ctkErrorLogLevel::LogLevel logLevel)
ctkTransferFunctionControlPointsItem * new_ctkTransferFunctionControlPointsItem(ctkTransferFunction *transferFunc, QGraphicsItem *parent=0)
static QString logLevelAsString(ctkErrorLogLevel::LogLevel logLevel)
ctkTransferFunctionGradientItem * new_ctkTransferFunctionGradientItem(QGraphicsItem *parent=0)
ctkTransferFunctionBarsItem * new_ctkTransferFunctionBarsItem(QGraphicsItem *parent=0)
void setHasShowUserInterfaceCommand(ctkWorkflowWidgetStep *step, bool newHasShowUserInterfaceCommand)
bool hasCreateUserInterfaceCommand(ctkWorkflowWidgetStep *step) const
virtual void setHasCreateUserInterfaceCommand(bool flag)
void setHasCreateUserInterfaceCommand(ctkWorkflowWidgetStep *step, bool newHasCreateUserInterfaceCommand)
void delete_ctkTransferFunctionControlPointsItem(ctkTransferFunctionControlPointsItem *obj)
virtual void setHasShowUserInterfaceCommand(bool flag)
void initCTKWidgetsPythonQtDecorators()
ctkTransferFunctionBarsItem * new_ctkTransferFunctionBarsItem(ctkTransferFunction *transferFunc, QGraphicsItem *parent=0)
virtual bool hasCreateUserInterfaceCommand() const
virtual bool hasShowUserInterfaceCommand() const
ctkTransferFunctionGradientItem * new_ctkTransferFunctionGradientItem(ctkTransferFunction *transferFunc, QGraphicsItem *parent=0)