Computer Assited Medical Intervention Tool Kit  version 5.0
Action.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
26#ifndef ACTION_H
27#define ACTION_H
28
29// -- Core stuff
30#include "CamiTKAPI.h"
31#include <Application.h>
32#include <Component.h>
33
34#include <QSet>
35#include <QWidget>
36#include <QString>
37#include <QAction>
38
39
40namespace camitk {
41
42class ActionExtension;
43class Property;
44class HistoryItem;
45
208class CAMITK_API Action : public QObject {
209 Q_OBJECT
210
211public:
212
215
217 ~Action() override;
218
219#ifdef ERROR
220#define CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD ERROR
221#undef ERROR
222#endif
229 TRIGGERED
230 };
231
232#ifdef CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD
233#define ERROR CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD
234#endif
235
237 static QString getStatusAsString(ApplyStatus);
238
239public slots:
245 camitk::Action::ApplyStatus trigger(QWidget* parent = nullptr);
246
257
265 camitk::Action::ApplyStatus applyAndRegister();
266
267public:
268
271
280 ApplyStatus applyInPipeline();
282
286 void setInputComponents(ComponentList inputs);
287
289 void setInputComponent(Component* input);
290
292 ComponentList getOutputComponents();
293
295 Component* getOutputComponent();
297
301
312 virtual QAction* getQAction(Component* target = nullptr);
313
315 QString getName() const {
316 return name;
317 };
318
320 QString getDescription() const {
321 return description;
322 };
323
325 QString getComponent() const {
326 return component;
327 };
328
330 QString getFamily() const {
331 return family;
332 };
333
335 QString getExtensionName() const;
336
338 QStringList getTag() const {
339 return tags;
340 };
341
343 bool getEmbedded() const {
344 return isEmbedded;
345 };
347
350
372 virtual QWidget* getWidget();
373
375 virtual QPixmap getIcon();
376
378 const ComponentList getTargets() const;
379
381 void updateTargets();
383
387 bool getAutoUpdateProperties() const;
388
390 void setAutoUpdateProperties(bool);
391
398 Q_INVOKABLE virtual camitk::Property* getProperty(QString name);
399
408 virtual bool addParameter(Property*);
410
413
418 void applyTargetPosition(Component* input, Component* target);
419
426 void applyTargetPosition(Component* input, Component* target, Application::TargetPositionningPolicy policy);
428
429protected:
436 void setName(QString name);
437
439 void setDescription(QString description);
440
442 void setComponent(QString component);
443
445 void setFamily(QString family);
446
448 void addTag(QString tag);
449
451 void setEmbedded(bool isEmbedded);
452
454 void setIcon(QPixmap);
455
457 QWidget* actionWidget;
458
459
461
462
463
464private:
466 QString name;
467
469 QString description;
470
472 QString component;
473
475 QString family;
476
478 QStringList tags;
479
482
485
487 QPixmap icon;
488
490 QAction* qAction;
491
493 QMap<QString, Property*> parameterMap;
494
505
508
511
520
525
530 void preProcess();
531
536 void postProcess();
538
541
551
556
557
563 void preProcessInPipeline();
564
569 void postProcessInPipeline();
570
571
572
574
575
576
577};
578
579}
580
581// -------------------- declare the interface for QPluginLoader --------------------
582Q_DECLARE_INTERFACE(camitk::Action, "TIMC-IMAG.Action/2.1")
583
584#endif // ACTION_H
585
586
587
588
#define CAMITK_API
Definition: CamiTKAPI.h:49
const char * description
Definition: applications/cepgenerator/main.cpp:38
This class describes what is a generic Action extension.
Definition: ActionExtension.h:57
Action class is an abstract class that enables you to build a action (generally on a component).
Definition: Action.h:208
QStringList tags
the name of the tag called this action
Definition: Action.h:478
ApplyStatus
describes what happened during the application of an algorithm (i.e. results of the apply method)
Definition: Action.h:224
@ ERROR
apply() failed : an error occured (usually it means that the apply() was interrupted)
Definition: Action.h:226
@ SUCCESS
everything went according to plan
Definition: Action.h:225
@ ABORTED
the action was aborted before completion
Definition: Action.h:228
@ WARNING
some (partial) error occured during the application of the algorithm
Definition: Action.h:227
virtual camitk::Action::ApplyStatus apply()=0
This method is called when the action has to be applied on the target list (get the target lists usin...
QString getFamily() const
the name of the family in which this action is associated
Definition: Action.h:330
QString getName() const
get the name of the action
Definition: Action.h:315
QString description
the descriptionof the action
Definition: Action.h:469
ComponentList targetComponents
The list of valid (regarding the component property) components for which this action is called.
Definition: Action.h:504
QPixmap icon
the Action pixmap icon
Definition: Action.h:487
ComponentList topLevelSelectedComponents
The list of top level selected components before running the action This list is used to deduce the n...
Definition: Action.h:524
HistoryItem * item
Definition: Action.h:519
ComponentList outputComponents
List returned by getOutputComponents()
Definition: Action.h:555
QString getComponent() const
the name of the component class that can be used by this action
Definition: Action.h:325
QAction * qAction
the corresponding QAction
Definition: Action.h:490
QString component
the name of the component class that can be used by this action
Definition: Action.h:472
bool autoUpdateProperties
Should the properties/parameters of this action be automatically updated when the user change somethi...
Definition: Action.h:507
QString name
the name of the action
Definition: Action.h:466
QStringList getTag() const
the name of the tag called this action
Definition: Action.h:338
ComponentList aliveBeforeComponents
In case of a pipeline application of the Action (i.e.
Definition: Action.h:550
ActionExtension * extension
the extension in which this action is declared and registered
Definition: Action.h:484
bool getEmbedded() const
argument use to know if the widget is embedded or not
Definition: Action.h:343
QString family
the name of the family in which this action is associated
Definition: Action.h:475
QWidget * actionWidget
the action widget
Definition: Action.h:457
QMap< QString, Property * > parameterMap
list of CamiTK property decorating the dynamic properties (action parameters)
Definition: Action.h:493
QString getDescription() const
the description of the action
Definition: Action.h:320
bool isEmbedded
is the widget embedded or not
Definition: Action.h:481
TargetPositionningPolicy
: Policy to determine how a newly instantiated component's frame should be initialized regarding of i...
Definition: Application.h:88
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:302
HistoryItem class describes the entry of an action used in a pipeline, in the history.
Definition: HistoryItem.h:61
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:280
Definition: Action.cpp:35
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding)
QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:127