Computer Assisted Medical Intervention Tool Kit version 6.0
 
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-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, 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"
32
33#include <QSet>
34#include <QWidget>
35#include <QString>
36#include <QAction>
37#include <QEvent>
38
39
40namespace camitk {
41
42// This simplify the user vision of her/his code.
43// This can be used for future generative processing
44#define CamiTKActionDeclaration(X) extern "C"
45#define CamiTKActionImplementation(X) extern "C"
46
47class ActionExtension;
48class Property;
49class HistoryItem;
50class ImageComponent;
51class Component;
52
215class CAMITK_API Action : public QObject, public InterfacePersistence {
216 Q_OBJECT
217
218public:
219
222
224 ~Action() override;
225
226#ifdef ERROR
227#define CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD ERROR
228#undef ERROR
229#endif
238
239#ifdef CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD
240#define ERROR CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD
241#endif
242
244 static QString getStatusAsString(ApplyStatus);
245
246public slots:
252 camitk::Action::ApplyStatus trigger(QWidget* parent = nullptr);
253
264
272 camitk::Action::ApplyStatus applyAndRegister();
273
274public:
275
278
287 ApplyStatus applyInPipeline();
289
293 void setInputComponents(ComponentList inputs);
294
296 void setInputComponent(Component* input);
297
299 ComponentList getOutputComponents();
300
302 Component* getOutputComponent();
304
308
319 virtual QAction* getQAction(Component* target = nullptr);
320
322 QString getName() const {
323 return name;
324 };
325
327 QString getDescription() const {
328 return description;
329 };
330
332 QString getComponentClassName() const {
333 return componentClassName;
334 };
335
337 QString getFamily() const {
338 return family;
339 };
340
342 QString getExtensionName() const;
343
345 QStringList getTag() const {
346 return tags;
347 };
348
350 bool getEmbedded() const {
351 return isEmbedded;
352 };
354
357
379 virtual QWidget* getWidget();
380
382 void setDefaultWidgetButtonVisibility(bool);
383
385 void setDefaultWidgetApplyButtonText(QString);
386
388 virtual QPixmap getIcon();
389
391 const ComponentList getTargets() const;
392
394 void updateTargets();
396
400 bool getAutoUpdateProperties() const;
401
403 void setAutoUpdateProperties(bool);
404
411 Q_INVOKABLE virtual camitk::Property* getProperty(QString name);
412
416 virtual QVariant getParameterValue(const QString& name) const;
417
421 virtual bool setParameterValue(const QString& name, QVariant newValue);
422
425 virtual QString getParameterValueAsString(const QString& name) const;
426
435 virtual bool addParameter(Property*);
437
444 virtual QVariant toVariant() const override;
445
447 virtual void fromVariant(const QVariant&) override;
448
450 virtual QUuid getUuid() const override;
451
458 virtual bool setUuid(QUuid) override;
459
461
462protected:
469 void setName(QString name);
470
472 void setDescription(QString description);
473
475 void setComponentClassName(QString componentClassName);
476
478 void setFamily(QString family);
479
481 void addTag(QString tag);
482
484 void setEmbedded(bool isEmbedded);
485
487 void setIcon(QPixmap);
488
490 QWidget* actionWidget;
492
494 const ActionExtension* getExtension() const;
495
498 void refreshApplication();
499
500private:
502 QString name;
503
505 QString description;
506
507 // the unique id of the action
508 QUuid uuid;
509
511 QString componentClassName;
512
514 QString family;
515
517 QStringList tags;
518
520 bool isEmbedded;
521
523 bool defaultWidgetButtonVisibility;
524
526 QString defaultWidgetApplyButtonText;
527
529 ActionExtension* extension;
530
532 QPixmap icon;
533
535 QAction* qAction;
536
538 QMap<QString, Property*> parameterMap;
539
549 ComponentList targetComponents;
550
552 bool autoUpdateProperties;
553
556
564 HistoryItem* historyItem;
565
569 ComponentList topLevelSelectedComponents;
570
575 void preProcess();
576
581 void postProcess();
583
586
595 ComponentList aliveBeforeComponents;
596
600 ComponentList outputComponents;
601
602
608 void preProcessInPipeline();
609
614 void postProcessInPipeline();
616};
617
618}
619
620// -------------------- declare the interface for QPluginLoader --------------------
621Q_DECLARE_INTERFACE(camitk::Action, "TIMC-IMAG.Action/2.1")
622
623#endif // ACTION_H
624
625
626
627
#define CAMITK_API
Definition CamiTKAPI.h:66
const char * description
Definition applications/cepgenerator/main.cpp:38
A component is something that composed something and could also be a part of something.
Definition modeling/libraries/pml/Component.h:48
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 an algorithm that wor...
Definition Action.h:215
ApplyStatus
describes what happened during the application of an algorithm (i.e. results of the apply method)
Definition Action.h:231
@ ERROR
apply() failed : an error occurred (usually it means that the apply() was interrupted)
Definition Action.h:233
@ SUCCESS
everything went according to plan
Definition Action.h:232
@ ABORTED
the action was aborted before completion
Definition Action.h:235
@ WARNING
some (partial) error occurred during the application of the algorithm
Definition Action.h:234
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:337
QString getName() const
get the name of the action
Definition Action.h:322
QStringList getTag() const
the name of the tag called this action
Definition Action.h:345
bool getEmbedded() const
argument use to know if the widget is embedded or not
Definition Action.h:350
QWidget * actionWidget
the action widget
Definition Action.h:490
QString getDescription() const
the description of the action
Definition Action.h:327
QString getComponentClassName() const
the name of the component class that can be used by this action
Definition Action.h:332
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition sdk/libraries/core/component/Component.h:304
HistoryItem class describes the entry of an action used in a pipeline, in the history.
Definition HistoryItem.h:61
Interface for all objects that should be serialized by the PersistenceManager.
Definition InterfacePersistence.h:38
This class describes a property that can be used in components and actions or any class that needs to...
Definition Property.h:306
Definition Action.cpp:40