CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkCorePythonQtDecorators.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 __ctkCorePythonQtDecorators_h
22#define __ctkCorePythonQtDecorators_h
23
24// PythonQt includes
25#include <PythonQt.h>
26
27// CTK includes
28#include <ctkBooleanMapper.h>
29#include <ctkErrorLogContext.h>
30#include <ctkWorkflowStep.h>
32
33// NOTE:
34//
35// For decorators it is assumed that the methods will never be called
36// with the self argument as NULL. The self argument is the first argument
37// for non-static methods.
38//
39
41class ctkCorePythonQtDecorators : public QObject
42{
43 Q_OBJECT
44public:
45
47 {
48 PythonQt::self()->registerClass(&ctkBooleanMapper::staticMetaObject, "CTKCore");
49 PythonQt::self()->registerCPPClass("ctkErrorLogContext", 0, "CTKCore");
50 PythonQt::self()->registerCPPClass("ctkWorkflowStep", 0, "CTKCore");
51 PythonQt::self()->registerClass(&ctkWorkflowInterstepTransition::staticMetaObject, "CTKCore");
52 }
53
54public Q_SLOTS:
55
56 //
57 // ctkBooleanMapper
58 //
59
60 ctkBooleanMapper* new_ctkBooleanMapper(QObject* targetObject, const QByteArray& propertyName, const QByteArray& signal)
61 {
62 return new ctkBooleanMapper(targetObject, propertyName, signal);
63 }
64
65 //
66 // ctkWorkflowStep
67 //
68
70 {
71 return new ctkWorkflowStep();
72 }
73
74 ctkWorkflowStep* new_ctkWorkflowStep(const QString& newId)
75 {
76 return new ctkWorkflowStep(newId);
77 }
78
80 {
81 delete step;
82 }
83
85 {
86 return step->workflow();
87 }
88
89 QString id(ctkWorkflowStep* step)const
90 {
91 return step->id();
92 }
93
94 void setId(ctkWorkflowStep* step, const QString& newId)const
95 {
96 step->setId(newId);
97 }
98
99 QString name(ctkWorkflowStep* step)const
100 {
101 return step->name();
102 }
103
104 void setName(ctkWorkflowStep* step, const QString& newName)
105 {
106 step->setName(newName);
107 }
108
109 QString description(ctkWorkflowStep* step)const
110 {
111 return step->description();
112 }
113
114 void setDescription(ctkWorkflowStep* step, const QString& newDescription)
115 {
116 step->setDescription(newDescription);
117 }
118
119 QString statusText(ctkWorkflowStep* step)const
120 {
121 return step->statusText();
122 }
123
125 {
126 return step->hasValidateCommand();
127 }
128
129 void setHasValidateCommand(ctkWorkflowStep* step, bool newHasValidateCommand)
130 {
131 step->setHasValidateCommand(newHasValidateCommand);
132 }
133
135 {
136 return step->hasOnEntryCommand();
137 }
138
139 void setHasOnEntryCommand(ctkWorkflowStep* step, bool newHasOnEntryCommand)
140 {
141 step->setHasOnEntryCommand(newHasOnEntryCommand);
142 }
143
145 {
146 return step->hasOnExitCommand();
147 }
148
149 void setHasOnExitCommand(ctkWorkflowStep* step, bool newHasOnExitCommand)
150 {
151 step->setHasOnExitCommand(newHasOnExitCommand);
152 }
153
155 {
156 return step->ctkWorkflowStepQObject();
157 }
158
159 //
160 // ctkWorkflowInterstepTransition
161 //
163 {
164 return new ctkWorkflowInterstepTransition(newTransitionType);
165 }
166
168 {
169 return new ctkWorkflowInterstepTransition(newTransitionType, newId);
170 }
171
173 {
174 delete transition;
175 }
176
177 //
178 // ctkErrorLogContext
179 //
181 {
182 return new ctkErrorLogContext();
183 }
184
186 {
187 return new ctkErrorLogContext(msg);
188 }
189
190 void setCategory(ctkErrorLogContext* context, const QString& category)
191 {
192 context->Category = category;
193 }
194 QString category(ctkErrorLogContext* context)
195 {
196 return context->Category;
197 }
198
199 void setLine(ctkErrorLogContext* context, int line)
200 {
201 context->Line = line;
202 }
204 {
205 return context->Line;
206 }
207
208 void setFile(ctkErrorLogContext* context, const QString& file)
209 {
210 context->File = file;
211 }
212 QString file(ctkErrorLogContext* context)
213 {
214 return context->File;
215 }
216
217 void setFunction(ctkErrorLogContext* context, const QString& function)
218 {
219 context->Function = function;
220 }
221 QString function(ctkErrorLogContext* context)
222 {
223 return context->Function;
224 }
225
226 void setMessage(ctkErrorLogContext* context, const QString& message)
227 {
228 context->Message = message;
229 }
230 QString message(ctkErrorLogContext* context)
231 {
232 return context->Message;
233 }
234
235};
236
237//-----------------------------------------------------------------------------
239{
240 PythonQt::self()->addDecorators(new ctkCorePythonQtDecorators);
241}
242
243#endif
void setHasOnExitCommand(ctkWorkflowStep *step, bool newHasOnExitCommand)
bool hasOnEntryCommand(ctkWorkflowStep *step) const
ctkWorkflowStep * new_ctkWorkflowStep()
ctkBooleanMapper * new_ctkBooleanMapper(QObject *targetObject, const QByteArray &propertyName, const QByteArray &signal)
QString category(ctkErrorLogContext *context)
ctkErrorLogContext * new_ctkErrorLogContext(const QString &msg)
void setCategory(ctkErrorLogContext *context, const QString &category)
QString description(ctkWorkflowStep *step) const
int line(ctkErrorLogContext *context)
QString function(ctkErrorLogContext *context)
ctkErrorLogContext * new_ctkErrorLogContext()
ctkWorkflow * workflow(ctkWorkflowStep *step) const
void delete_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition *transition)
QString statusText(ctkWorkflowStep *step) const
void setHasOnEntryCommand(ctkWorkflowStep *step, bool newHasOnEntryCommand)
void setLine(ctkErrorLogContext *context, int line)
bool hasOnExitCommand(ctkWorkflowStep *step) const
ctkWorkflowInterstepTransition * new_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition::InterstepTransitionType newTransitionType)
void setHasValidateCommand(ctkWorkflowStep *step, bool newHasValidateCommand)
QObject * ctkWorkflowStepQObject(ctkWorkflowStep *step)
ctkWorkflowInterstepTransition * new_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition::InterstepTransitionType newTransitionType, const QString &newId)
void setDescription(ctkWorkflowStep *step, const QString &newDescription)
void setId(ctkWorkflowStep *step, const QString &newId) const
QString file(ctkErrorLogContext *context)
ctkWorkflowStep * new_ctkWorkflowStep(const QString &newId)
void setFile(ctkErrorLogContext *context, const QString &file)
void setFunction(ctkErrorLogContext *context, const QString &function)
void setName(ctkWorkflowStep *step, const QString &newName)
QString id(ctkWorkflowStep *step) const
void delete_ctkWorkflowStep(ctkWorkflowStep *step)
bool hasValidateCommand(ctkWorkflowStep *step) const
QString message(ctkErrorLogContext *context)
QString name(ctkWorkflowStep *step) const
void setMessage(ctkErrorLogContext *context, const QString &message)
ctkWorkflowStep is the basis for a workflow step.
QString statusText() const
Get statusText.
QString description() const
Set/get description.
bool hasValidateCommand() const
bool hasOnExitCommand() const
void setHasOnEntryCommand(bool newHasOnEntryCommand)
void setName(const QString &newName)
void setId(const QString &newStepId)
ctkWorkflow * workflow() const
Get the workflow associated with this step.
QObject * ctkWorkflowStepQObject()
Get QObject associated with this step, to connect signals/slots.
void setHasOnExitCommand(bool newHasOnExitCommand)
QString id() const
Get id.
QString name() const
Set/get name.
void setHasValidateCommand(bool newHasValidateCommand)
void setDescription(const QString &newDescription)
bool hasOnEntryCommand() const
ctkWorkflow is the basis for a workflow engine, i.e. a state machine with enhancements to support ctk...
Definition: ctkWorkflow.h:40
void initCTKCorePythonQtDecorators()