Computer Assisted Medical Intervention Tool Kit  version 5.1
 
Loading...
Searching...
No Matches
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-2023 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
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
333 CAMITK_API_DEPRECATED("Please use getComponentClassName() instead")
334 QString getComponent() const {
335 return getComponentClassName();
336 };
338
340 QString getComponentClassName() const {
341 return componentClassName;
342 };
343
345 QString getFamily() const {
346 return family;
347 };
348
350 QString getExtensionName() const;
351
353 QStringList getTag() const {
354 return tags;
355 };
356
358 bool getEmbedded() const {
359 return isEmbedded;
360 };
362
365
387 virtual QWidget* getWidget();
388
390 virtual QPixmap getIcon();
391
393 const ComponentList getTargets() const;
394
396 void updateTargets();
398
402 bool getAutoUpdateProperties() const;
403
405 void setAutoUpdateProperties(bool);
406
413 Q_INVOKABLE virtual camitk::Property* getProperty(QString name);
414
423 virtual bool addParameter(Property*);
425
428
433 void applyTargetPosition(Component* input, Component* target);
434
441 void applyTargetPosition(Component* input, Component* target, Application::TargetPositionningPolicy policy);
443
444protected:
451 void setName(QString name);
452
454 void setDescription(QString description);
455
457
465 CAMITK_API_DEPRECATED("Please use setComponentClassName(QString componentClassName) instead")
466 void setComponent(QString component);
468
470 void setComponentClassName(QString componentClassName);
471
473 void setFamily(QString family);
474
476 void addTag(QString tag);
477
479 void setEmbedded(bool isEmbedded);
480
482 void setIcon(QPixmap);
483
485 QWidget* actionWidget;
487
488private:
490 QString name;
491
493 QString description;
494
496 QString componentClassName;
497
499 QString family;
500
502 QStringList tags;
503
505 bool isEmbedded;
506
508 ActionExtension* extension;
509
511 QPixmap icon;
512
514 QAction* qAction;
515
517 QMap<QString, Property*> parameterMap;
518
528 ComponentList targetComponents;
529
531 bool autoUpdateProperties;
532
535
543 HistoryItem* item;
544
548 ComponentList topLevelSelectedComponents;
549
554 void preProcess();
555
560 void postProcess();
562
565
574 ComponentList aliveBeforeComponents;
575
579 ComponentList outputComponents;
580
581
587 void preProcessInPipeline();
588
593 void postProcessInPipeline();
594
595
596
598
599
600
601};
602
603}
604
605// -------------------- declare the interface for QPluginLoader --------------------
606Q_DECLARE_INTERFACE(camitk::Action, "TIMC-IMAG.Action/2.1")
607
608#endif // ACTION_H
609
610
611
612
#define CAMITK_API_DEPRECATED(X)
Definition CamiTKAPI.h:94
#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
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 occurred (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 occurred 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:345
QString getName() const
get the name of the action
Definition Action.h:315
QStringList getTag() const
the name of the tag called this action
Definition Action.h:353
bool getEmbedded() const
argument use to know if the widget is embedded or not
Definition Action.h:358
QString getDescription() const
the description of the action
Definition Action.h:320
QString getComponentClassName() const
the name of the component class that can be used by this action
Definition Action.h:340
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
QList< Component * > ComponentList
A list of Component.
Definition CamiTKAPI.h:127