Computer Assited Medical Intervention Tool Kit  version 4.0
ActionState.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2016 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 #ifndef ACTIONSTATE_H
26 #define ACTIONSTATE_H
27 
28 // Qt stuff
29 #include <QTime>
30 #include <QState>
31 #include <QVector>
32 #include <QTextStream>
33 
34 //CamiTK stuff
35 #include <Action.h>
36 
37 // Local stuff
38 #include "ActionStateWidget.h"
39 #include "ActionTransition.h"
47 class ActionState : public QState {
48 
49 public:
52  ActionState(QState * parent, QString name, QString description, QTextStream * logStream = NULL);
53 
54  void setAction(camitk::Action * action,
55  QMap<QString, QVariant> parameters,
56  QMap<QString, QString> inputComponentNames,
57  QMap<QString, QString> outputComponentNames);
58 
60  QString getName();
61 
63  QString getDescription();
64 
66  void setAlternativeDesc(QString altDescText, QVector<camitk::Action::ApplyStatus> statusList);
67 
70 
72  ActionTransition * addActionTransition(QString buttonText, QAbstractState * nextState,
73  bool applyAction = true, QVector<camitk::Action::ApplyStatus> disableConditions = QVector<camitk::Action::ApplyStatus>());
74 
76 
78 
79  void setFinal();
80 
82  const QMap<QString, QString> & getInputComponents();
83 
85  const QMap<QString, QString> & getOutputComponents();
86 
87 protected:
90  virtual void onEntry ( QEvent * event );
91 
92  virtual void onExit ( QEvent * event );
94 
96  QString name;
97 
101  QString description;
102 
105 
107  QMap<QString, QString> inputComponentNames;
108 
110  QMap<QString, QString> outputComponentNames;
111 
113  QMap<QString, QVariant> parameters;
114 
116  QMap<camitk::Action::ApplyStatus, QVector<QPushButton * > > conditionalButtons;
117 
119  QMap<camitk::Action::ApplyStatus, QString> conditionalDescriptions;
120 
129 
131  QTextStream * logStream;
132 
134  QTime * startTime;
135 
136 
137 };
138 #endif // ACTIONSTATE_H
void setAction(camitk::Action *action, QMap< QString, QVariant > parameters, QMap< QString, QString > inputComponentNames, QMap< QString, QString > outputComponentNames)
Definition: ActionState.cpp:51
void setAlternativeDesc(QString altDescText, QVector< camitk::Action::ApplyStatus > statusList)
May change its description according to the previous action result.
Definition: ActionState.cpp:165
QMap< QString, QString > outputComponentNames
names of all the output compenent, this is a map <name, type>
Definition: ActionState.h:110
Action class is an abstract class that enables you to build a action (generally on a component)...
Definition: Action.h:208
ActionState(QState *parent, QString name, QString description, QTextStream *logStream=NULL)
Definition: ActionState.cpp:41
virtual void onEntry(QEvent *event)
Reimplemented from QState.
Definition: ActionState.cpp:199
virtual camitk::Action::ApplyStatus applyAction()
apply the action encapsulated by this action state
Definition: ActionState.cpp:102
QMap< QString, QString > inputComponentNames
names of all the input compenent, this is a map <name, type>
Definition: ActionState.h:107
QString getName()
Returns the name of the action state (may be different from the name of the actual action) ...
Definition: ActionState.cpp:63
QTextStream * logStream
Log stream to write report on logFile.
Definition: ActionState.h:131
QString name
Name of the state action (may not be the same as the action&#39;s name)
Definition: ActionState.h:96
ActionStateWidget * myStateWidget
Widget containing:
Definition: ActionState.h:128
QTime * startTime
Keep track of time...
Definition: ActionState.h:134
The state (in a state machine point of view) corresponding to the current processed action...
Definition: ActionState.h:47
const QMap< QString, QString > & getInputComponents()
get the names and type of all input components
Definition: ActionState.cpp:306
QMap< camitk::Action::ApplyStatus, QVector< QPushButton *> > conditionalButtons
Buttons that should be disabled if the previous aciton state did not happen correctly.
Definition: ActionState.h:116
ApplyStatus
describes what happened during the application of an algorithm (i.e. results of the apply method) ...
Definition: Action.h:220
QMap< QString, QVariant > parameters
name and value of preset parameters
Definition: ActionState.h:113
QString getDescription()
Returns the description of the action state (may be different from the description of the actual acti...
Definition: ActionState.cpp:68
camitk::Action * myAction
Actual CamiTK action.
Definition: ActionState.h:104
const QMap< QString, QString > & getOutputComponents()
get the names and type of all output components
Definition: ActionState.cpp:311
void setFinal()
QMap< camitk::Action::ApplyStatus, QString > conditionalDescriptions
Descriptions that should be displaied if the previous action state did not happen correctly...
Definition: ActionState.h:119
The action save state widget.
Definition: ActionStateWidget.h:41
QString description
Description of the state action may not be the same as the action&#39;s description but complementary...
Definition: ActionState.h:101
ActionTransition * addActionTransition(QString buttonText, QAbstractState *nextState, bool applyAction=true, QVector< camitk::Action::ApplyStatus > disableConditions=QVector< camitk::Action::ApplyStatus >())
Adds a possible transition from this action.
Definition: ActionState.cpp:78
This class handle a transition between two states (including previous/next buttons).
Definition: ActionTransition.h:56
virtual void onExit(QEvent *event)
Definition: ActionState.cpp:294
void setPreviousActionStatus(camitk::Action::ApplyStatus status)
Definition: ActionState.cpp:175
ActionStateWidget * getWidget()
Definition: ActionState.cpp:73