Computer Assited Medical Intervention Tool Kit  version 5.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-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, TIMC, 38000 Grenoble, France
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"
48 class ActionState : public QState {
49 
50  Q_OBJECT
51 
52 public:
55  ActionState(QState* parent, QString name, QString description, QTextStream* logStream = nullptr);
56 
57  void setAction(camitk::Action* action,
58  QMap<QString, QVariant> parameters,
59  QMap<QString, QString> inputComponentNames,
60  QMap<QString, QString> outputComponentNames);
61 
63  QString getName();
64 
66  QString getDescription();
67 
69  void setAlternativeDesc(QString altDescText, QVector<camitk::Action::ApplyStatus> statusList);
70 
73 
75  ActionTransition* addActionTransition(QString transitionName, QAbstractState* nextState,
76  bool applyAction = true, QVector<camitk::Action::ApplyStatus> disableConditions = QVector<camitk::Action::ApplyStatus>());
77 
78  // get the whole action state widget (used by the ActionStateViewer)
80 
81  // set the status of previous action and modify description/possible action accordingly
83 
85  const QMap<QString, QString>& getInputComponents();
86 
88  const QMap<QString, QString>& getOutputComponents();
89 
91  void autoNextEntry();
92 
94  void autoNextExit();
95 
96 protected:
99  void onEntry(QEvent* event) override;
100 
101  void onExit(QEvent* event) override;
103 
105  QString name;
106 
110  QString description;
111 
114 
116  QMap<QString, QString> inputComponentNames;
117 
119  QMap<QString, QString> outputComponentNames;
120 
122  QMap<QString, QVariant> parameters;
123 
125  QMap<camitk::Action::ApplyStatus, QVector<QPushButton* > > conditionalButtons;
126 
128  QMap<camitk::Action::ApplyStatus, QString> conditionalDescriptions;
129 
138 
140  QTextStream* logStream;
141 
143  QTime* startTime;
144 
145 };
146 #endif // ACTIONSTATE_H
ActionState::setPreviousActionStatus
void setPreviousActionStatus(camitk::Action::ApplyStatus status)
Definition: ActionState.cpp:171
ActionState::setAction
void setAction(camitk::Action *action, QMap< QString, QVariant > parameters, QMap< QString, QString > inputComponentNames, QMap< QString, QString > outputComponentNames)
Definition: ActionState.cpp:53
ActionState::getWidget
ActionStateWidget * getWidget()
Definition: ActionState.cpp:76
ActionState.h
ActionState::applyAction
virtual camitk::Action::ApplyStatus applyAction()
apply the action encapsulated by this action state
Definition: ActionState.cpp:107
camitk::ActionWidget
Build a default widget for a given action using its Qt properties. It should be good enough in most o...
Definition: ActionWidget.h:96
camitk::Action::ApplyStatus
ApplyStatus
Definition: Action.h:247
ActionState
The state (in a state machine point of view) corresponding to the current processed action.
Definition: ActionState.h:48
ActionState::onEntry
void onEntry(QEvent *event) override
Reimplemented from QState.
Definition: ActionState.cpp:205
camitk::ActionWidget::setButtonVisibility
void setButtonVisibility(bool)
if false then the apply/revert buttons are shown
Definition: ActionWidget.cpp:156
camitk::Action::setAutoUpdateProperties
void setAutoUpdateProperties(bool)
are the properties to be udpated every time the user makes a change in the widget (default is false)?
Definition: Action.cpp:426
ActionStateWidget::addTransitionButton
QPushButton * addTransitionButton(QString text)
Definition: ActionStateWidget.cpp:38
ActionStateWidget
The action save state widget.
Definition: ActionStateWidget.h:41
ActionState::name
QString name
Name of the state action (may not be the same as the action's name)
Definition: ActionState.h:128
camitk::Component::setModified
virtual void setModified(bool modified=true)
set the modified flag
Definition: sdk/libraries/core/component/Component.h:943
ActionState::ActionState
ActionState(QState *parent, QString name, QString description, QTextStream *logStream=nullptr)
Definition: ActionState.cpp:43
camitk::Action::getName
QString getName() const
get the name of the action
Definition: Action.h:338
Action.h
ActionState::myStateWidget
ActionStateWidget * myStateWidget
Widget containing:
Definition: ActionState.h:160
camitk::Action::applyInPipeline
ApplyStatus applyInPipeline()
This method encapsulates the apply() method.
Definition: Action.cpp:285
camitk::Action::setInputComponents
void setInputComponents(ComponentList inputs)
Specify the input Component(s) Only applyInPipeline() should be called with this method (maybe apply)...
Definition: Action.cpp:307
ActionWidget.h
Log.h
ActionState::onExit
void onExit(QEvent *event) override
Definition: ActionState.cpp:321
camitk::Action
Action class is an abstract class that enables you to build a action (generally on a component)....
Definition: Action.h:231
ActionState::addActionTransition
ActionTransition * addActionTransition(QString transitionName, QAbstractState *nextState, bool applyAction=true, QVector< camitk::Action::ApplyStatus > disableConditions=QVector< camitk::Action::ApplyStatus >())
Adds a possible transition from this action.
Definition: ActionState.cpp:81
ActionState::inputComponentNames
QMap< QString, QString > inputComponentNames
names of all the input compenent, this is a map <name, type>
Definition: ActionState.h:139
ActionState::getInputComponents
const QMap< QString, QString > & getInputComponents()
get the names and type of all input components
Definition: ActionState.cpp:332
ActionState::startTime
QTime * startTime
Keep track of time...
Definition: ActionState.h:166
ActionState::getName
QString getName()
Returns the name of the action state (may be different from the name of the actual action)
Definition: ActionState.cpp:66
ActionState::parameters
QMap< QString, QVariant > parameters
name and value of preset parameters
Definition: ActionState.h:145
ActionState::logStream
QTextStream * logStream
Log stream to write report on logFile.
Definition: ActionState.h:163
description
const char * description
Definition: applications/cepgenerator/main.cpp:38
ActionState::autoNextEntry
void autoNextEntry()
programmatically call the onEntry() method (used during autonext)
Definition: ActionState.cpp:200
ActionStateWidget::setDescription
void setDescription(QString description)
Definition: ActionStateWidget.cpp:52
ActionState::autoNextExit
void autoNextExit()
programmatically call the onExit() method (used during autonext)
Definition: ActionState.cpp:316
camitk::ComponentList
QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:127
ActionStateWidget.h
ActionTransition.h
ActionTransition
This class handle a transition between two states (including previous/next buttons)....
Definition: ActionTransition.h:59
camitk::Action::name
QString name
the name of the action
Definition: Action.h:489
camitk::Action::getOutputComponents
ComponentList getOutputComponents()
Returns the output Component(s)
Definition: Action.cpp:332
ActionState::getDescription
QString getDescription()
Returns the description of the action state (may be different from the description of the actual acti...
Definition: ActionState.cpp:71
ActionState::myAction
camitk::Action * myAction
Actual CamiTK action.
Definition: ActionState.h:136
ActionState::conditionalDescriptions
QMap< camitk::Action::ApplyStatus, QString > conditionalDescriptions
Descriptions that should be displaied if the previous action state did not happen correctly.
Definition: ActionState.h:151
ActionState::description
QString description
Description of the state action may not be the same as the action's description but complementary.
Definition: ActionState.h:133
ActionState::getOutputComponents
const QMap< QString, QString > & getOutputComponents()
get the names and type of all output components
Definition: ActionState.cpp:337
camitk::Action::getWidget
virtual QWidget * getWidget()
This method has to be redefined in your Action only if:
Definition: Action.cpp:185
camitk::refresh
void refresh()
refresh the display
ActionState::setAlternativeDesc
void setAlternativeDesc(QString altDescText, QVector< camitk::Action::ApplyStatus > statusList)
May change its description according to the previous action result.
Definition: ActionState.cpp:161
ActionState::conditionalButtons
QMap< camitk::Action::ApplyStatus, QVector< QPushButton * > > conditionalButtons
Buttons that should be disabled if the previous aciton state did not happen correctly.
Definition: ActionState.h:148
ActionStateWidget::setActionWidget
void setActionWidget(QWidget *widget)
Definition: ActionStateWidget.cpp:45
camitk::Component
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:302
Application.h
ActionState::outputComponentNames
QMap< QString, QString > outputComponentNames
names of all the output compenent, this is a map <name, type>
Definition: ActionState.h:142
camitk
Definition: Action.cpp:35