CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Loading...
Searching...
No Matches
ctkWorkflowTransitions.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 __ctkWorkflowTransition_h
22#define __ctkWorkflowTransition_h
23
24// Qt includes
25#include <QEvent>
26#include <QAbstractTransition>
27#include <QString>
28
29// CTK includes
30#include "ctkCoreExport.h"
31
42
43//-----------------------------------------------------------------------------
44struct CTK_CORE_EXPORT ctkWorkflowIntrastepTransitionEvent : public QEvent
45{
46
49 : QEvent(QEvent::Type(getWorkflowIntrastepTransitionEventType())),
50 EventTransitionType(newTransitionType){}
51
55 {
56 static int workflowIntrastepTransitionEventType = QEvent::registerEventType(QEvent::User+1);
57 return workflowIntrastepTransitionEventType;
58 }
59
61};
62
63//-----------------------------------------------------------------------------
65class CTK_CORE_EXPORT ctkWorkflowIntrastepTransition : public QAbstractTransition
66{
67 Q_OBJECT
68
69public:
70
72 {
73 ValidationTransition = 0,
74 ValidationFailedTransition
75 };
76
78 : TransitionType(newTransitionType){}
79
80 IntrastepTransitionType transitionType() {return this->TransitionType;}
81
82protected:
83 virtual bool eventTest(QEvent* e)
84 {
85 // check the event type
87 {
88 return false;
89 }
90
91 // check the event value (i.e. the TransitionType)
93
94 return (this->TransitionType == workflowEvent->EventTransitionType);
95 }
96
97 void onTransition(QEvent*){}
98
99private:
100 IntrastepTransitionType TransitionType;
101
102};
103
104//-----------------------------------------------------------------------------
106struct CTK_CORE_EXPORT ctkWorkflowInterstepTransitionEvent : public QEvent
107{
108
111 : QEvent(QEvent::Type(getWorkflowInterstepTransitionEventType())),
112 EventTransitionType(newTransitionType){}
113 ctkWorkflowInterstepTransitionEvent(int newTransitionType, const QString& newId)
114 : QEvent(QEvent::Type(getWorkflowInterstepTransitionEventType())),
115 EventTransitionType(newTransitionType),
116 EventId(newId){}
117
121 {
122 static int workflowInterstepTransitionEventType = QEvent::registerEventType(QEvent::User+1);
123 return workflowInterstepTransitionEventType;
124 }
125
127 QString EventId;
128};
129
130//-----------------------------------------------------------------------------
132class CTK_CORE_EXPORT ctkWorkflowInterstepTransition : public QAbstractTransition
133{
134 Q_OBJECT
136
137public:
138
140 {
141 TransitionToNextStep = 0,
145 TransitionToPreviousStartingStepAfterSuccessfulGoToFinishStep
146 };
147
149 : TransitionType(newTransitionType){}
150 ctkWorkflowInterstepTransition(InterstepTransitionType newTransitionType, const QString& newId)
151 : TransitionType(newTransitionType),
152 Id(newId) {}
153
154 InterstepTransitionType transitionType() {return this->TransitionType;}
155 QString& id() {return this->Id;}
156
157protected:
158 virtual bool eventTest(QEvent* e)
159 {
160 // check the event type
162 {
163 return false;
164 }
165
166 // check the event value (i.e. the TransitionType)
168
169 return (this->TransitionType == workflowEvent->EventTransitionType
170 && this->Id == workflowEvent->EventId);
171 }
172
173 void onTransition(QEvent*){}
174
175private:
176 InterstepTransitionType TransitionType;
177 QString Id;
178
179};
180
181#endif
InterstepTransitionType transitionType()
ctkWorkflowInterstepTransition(InterstepTransitionType newTransitionType)
ctkWorkflowInterstepTransition(InterstepTransitionType newTransitionType, const QString &newId)
ctkWorkflowIntrastepTransition(IntrastepTransitionType newTransitionType)
IntrastepTransitionType transitionType()
ctkWorkflowInterstepTransitionEvent(int newTransitionType, const QString &newId)
ctkWorkflowInterstepTransitionEvent(int newTransitionType)
EventTransitionType is the value of a transition event, used to conditionally trigger transitions.
Custom transitions for use with ctkWorkflow.
ctkWorkflowIntrastepTransitionEvent(int newTransitionType)
EventTransitionType is the value of a transition event, used to conditionally trigger transitions.