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