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>
31 #include <ctkWorkflowTransitions.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 
41 class ctkCorePythonQtDecorators : public QObject
42 {
43  Q_OBJECT
44 public:
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 
54 public 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  }
203  int line(ctkErrorLogContext* context)
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
ctkCorePythonQtDecorators::new_ctkWorkflowStep
ctkWorkflowStep * new_ctkWorkflowStep(const QString &newId)
Definition: ctkCorePythonQtDecorators.h:74
ctkCorePythonQtDecorators::setName
void setName(ctkWorkflowStep *step, const QString &newName)
Definition: ctkCorePythonQtDecorators.h:104
ctkErrorLogContext::Category
QString Category
Definition: ctkErrorLogContext.h:37
ctkCorePythonQtDecorators::category
QString category(ctkErrorLogContext *context)
Definition: ctkCorePythonQtDecorators.h:194
ctkCorePythonQtDecorators::setHasOnEntryCommand
void setHasOnEntryCommand(ctkWorkflowStep *step, bool newHasOnEntryCommand)
Definition: ctkCorePythonQtDecorators.h:139
ctkCorePythonQtDecorators::setFunction
void setFunction(ctkErrorLogContext *context, const QString &function)
Definition: ctkCorePythonQtDecorators.h:217
ctkCorePythonQtDecorators::delete_ctkWorkflowStep
void delete_ctkWorkflowStep(ctkWorkflowStep *step)
Definition: ctkCorePythonQtDecorators.h:79
ctkCorePythonQtDecorators::new_ctkWorkflowStep
ctkWorkflowStep * new_ctkWorkflowStep()
Definition: ctkCorePythonQtDecorators.h:69
ctkErrorLogContext::Function
QString Function
Definition: ctkErrorLogContext.h:40
ctkCorePythonQtDecorators::delete_ctkWorkflowInterstepTransition
void delete_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition *transition)
Definition: ctkCorePythonQtDecorators.h:172
ctkWorkflowStep
ctkWorkflowStep is the basis for a workflow step.
Definition: ctkWorkflowStep.h:46
ctkCorePythonQtDecorators::new_ctkBooleanMapper
ctkBooleanMapper * new_ctkBooleanMapper(QObject *targetObject, const QByteArray &propertyName, const QByteArray &signal)
Definition: ctkCorePythonQtDecorators.h:60
ctkCorePythonQtDecorators::setHasOnExitCommand
void setHasOnExitCommand(ctkWorkflowStep *step, bool newHasOnExitCommand)
Definition: ctkCorePythonQtDecorators.h:149
ctkCorePythonQtDecorators::workflow
ctkWorkflow * workflow(ctkWorkflowStep *step) const
Definition: ctkCorePythonQtDecorators.h:84
ctkCorePythonQtDecorators::new_ctkErrorLogContext
ctkErrorLogContext * new_ctkErrorLogContext()
Definition: ctkCorePythonQtDecorators.h:180
ctkCorePythonQtDecorators::description
QString description(ctkWorkflowStep *step) const
Definition: ctkCorePythonQtDecorators.h:109
ctkCorePythonQtDecorators::new_ctkWorkflowInterstepTransition
ctkWorkflowInterstepTransition * new_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition::InterstepTransitionType newTransitionType, const QString &newId)
Definition: ctkCorePythonQtDecorators.h:167
ctkWorkflowStep::setId
void setId(const QString &newStepId)
ctkErrorLogContext::Line
int Line
Definition: ctkErrorLogContext.h:38
ctkCorePythonQtDecorators::hasOnEntryCommand
bool hasOnEntryCommand(ctkWorkflowStep *step) const
Definition: ctkCorePythonQtDecorators.h:134
ctkWorkflowStep::setHasOnEntryCommand
void setHasOnEntryCommand(bool newHasOnEntryCommand)
ctkCorePythonQtDecorators::new_ctkWorkflowInterstepTransition
ctkWorkflowInterstepTransition * new_ctkWorkflowInterstepTransition(ctkWorkflowInterstepTransition::InterstepTransitionType newTransitionType)
Definition: ctkCorePythonQtDecorators.h:162
initCTKCorePythonQtDecorators
void initCTKCorePythonQtDecorators()
Definition: ctkCorePythonQtDecorators.h:238
ctkWorkflowStep::setHasOnExitCommand
void setHasOnExitCommand(bool newHasOnExitCommand)
ctkWorkflow
ctkWorkflow is the basis for a workflow engine, i.e. a state machine with enhancements to support ctk...
Definition: ctkWorkflow.h:40
ctkWorkflowStep::description
QString description() const
Set/get description.
ctkCorePythonQtDecorators::setLine
void setLine(ctkErrorLogContext *context, int line)
Definition: ctkCorePythonQtDecorators.h:199
ctkCorePythonQtDecorators::id
QString id(ctkWorkflowStep *step) const
Definition: ctkCorePythonQtDecorators.h:89
ctkCorePythonQtDecorators::setHasValidateCommand
void setHasValidateCommand(ctkWorkflowStep *step, bool newHasValidateCommand)
Definition: ctkCorePythonQtDecorators.h:129
ctkCorePythonQtDecorators::setDescription
void setDescription(ctkWorkflowStep *step, const QString &newDescription)
Definition: ctkCorePythonQtDecorators.h:114
ctkCorePythonQtDecorators::setFile
void setFile(ctkErrorLogContext *context, const QString &file)
Definition: ctkCorePythonQtDecorators.h:208
ctkWorkflowTransitions.h
ctkWorkflowStep::hasOnEntryCommand
bool hasOnEntryCommand() const
ctkWorkflowStep::ctkWorkflowStepQObject
QObject * ctkWorkflowStepQObject()
Get QObject associated with this step, to connect signals/slots.
ctkWorkflowStep::hasValidateCommand
bool hasValidateCommand() const
ctkWorkflowInterstepTransition
Definition: ctkWorkflowTransitions.h:133
ctkBooleanMapper.h
ctkCorePythonQtDecorators::hasValidateCommand
bool hasValidateCommand(ctkWorkflowStep *step) const
Definition: ctkCorePythonQtDecorators.h:124
ctkCorePythonQtDecorators::file
QString file(ctkErrorLogContext *context)
Definition: ctkCorePythonQtDecorators.h:212
ctkWorkflowStep::name
QString name() const
Set/get name.
ctkWorkflowStep::setHasValidateCommand
void setHasValidateCommand(bool newHasValidateCommand)
ctkErrorLogContext.h
ctkErrorLogContext::File
QString File
Definition: ctkErrorLogContext.h:39
ctkBooleanMapper
Definition: ctkBooleanMapper.h:52
ctkCorePythonQtDecorators::setMessage
void setMessage(ctkErrorLogContext *context, const QString &message)
Definition: ctkCorePythonQtDecorators.h:226
ctkCorePythonQtDecorators::line
int line(ctkErrorLogContext *context)
Definition: ctkCorePythonQtDecorators.h:203
ctkCorePythonQtDecorators::name
QString name(ctkWorkflowStep *step) const
Definition: ctkCorePythonQtDecorators.h:99
ctkWorkflowInterstepTransition::InterstepTransitionType
InterstepTransitionType
Definition: ctkWorkflowTransitions.h:140
ctkWorkflowStep::statusText
QString statusText() const
Get statusText.
ctkCorePythonQtDecorators::hasOnExitCommand
bool hasOnExitCommand(ctkWorkflowStep *step) const
Definition: ctkCorePythonQtDecorators.h:144
ctkCorePythonQtDecorators::setCategory
void setCategory(ctkErrorLogContext *context, const QString &category)
Definition: ctkCorePythonQtDecorators.h:190
ctkErrorLogContext
Definition: ctkErrorLogContext.h:33
ctkWorkflowStep::workflow
ctkWorkflow * workflow() const
Get the workflow associated with this step.
ctkCorePythonQtDecorators::message
QString message(ctkErrorLogContext *context)
Definition: ctkCorePythonQtDecorators.h:230
ctkCorePythonQtDecorators
Definition: ctkCorePythonQtDecorators.h:42
ctkCorePythonQtDecorators::ctkCorePythonQtDecorators
ctkCorePythonQtDecorators()
Definition: ctkCorePythonQtDecorators.h:46
ctkWorkflowStep::setDescription
void setDescription(const QString &newDescription)
ctkErrorLogContext::Message
QString Message
Definition: ctkErrorLogContext.h:41
ctkWorkflowStep::id
QString id() const
Get id.
ctkCorePythonQtDecorators::setId
void setId(ctkWorkflowStep *step, const QString &newId) const
Definition: ctkCorePythonQtDecorators.h:94
ctkCorePythonQtDecorators::ctkWorkflowStepQObject
QObject * ctkWorkflowStepQObject(ctkWorkflowStep *step)
Definition: ctkCorePythonQtDecorators.h:154
ctkCorePythonQtDecorators::new_ctkErrorLogContext
ctkErrorLogContext * new_ctkErrorLogContext(const QString &msg)
Definition: ctkCorePythonQtDecorators.h:185
ctkWorkflowStep::hasOnExitCommand
bool hasOnExitCommand() const
ctkWorkflowStep::setName
void setName(const QString &newName)
ctkCorePythonQtDecorators::statusText
QString statusText(ctkWorkflowStep *step) const
Definition: ctkCorePythonQtDecorators.h:119
ctkWorkflowStep.h