Computer Assited Medical Intervention Tool Kit  version 4.1
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-2018 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 
26 #ifndef ACTION_H
27 #define ACTION_H
28 
29 // -- Core stuff
30 #include "CamiTKAPI.h"
31 #include <HistoryItem.h>
32 #include <Application.h>
33 
34 #include <QSet>
35 #include <QWidget>
36 #include <QString>
37 #include <QAction>
38 
39 
40 namespace camitk {
41 
42 class ActionExtension;
43 class Property;
44 
207 class CAMITK_API Action : public QObject {
208  Q_OBJECT
209 
210 public:
211 
214 
216  ~Action() override;
217 
218 #ifdef ERROR
219 #define CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD ERROR
220 #undef ERROR
221 #endif
222  enum ApplyStatus {
228  TRIGGERED
229  };
230 
231 #ifdef CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD
232 #define ERROR CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD
233 #endif
234 
236  static QString getStatusAsString(ApplyStatus);
237 
238 public slots:
244  ApplyStatus trigger(QWidget* parent = nullptr);
245 
255  virtual ApplyStatus apply() = 0;
256 
264  ApplyStatus applyAndRegister();
265 
266 public:
267 
270 
279  ApplyStatus applyInPipeline();
281 
285  void setInputComponents(ComponentList inputs);
286 
288  void setInputComponent(Component* input);
289 
291  ComponentList getOutputComponents();
292 
294  Component* getOutputComponent();
296 
300 
308  QAction* getQAction();
309 
311  QString getName() const {
312  return name;
313  };
314 
316  QString getDescription() const {
317  return description;
318  };
319 
321  QString getComponent() const {
322  return component;
323  };
324 
326  QString getFamily() const {
327  return family;
328  };
329 
331  QString getExtensionName() const;
332 
334  QStringList getTag() const {
335  return tags;
336  };
337 
339  bool getEmbedded() const {
340  return isEmbedded;
341  };
343 
346 
368  virtual QWidget* getWidget();
369 
371  virtual QPixmap getIcon();
372 
374  const ComponentList getTargets() const;
376 
380  bool getAutoUpdateProperties() const;
381 
383  void setAutoUpdateProperties(bool);
384 
391  Q_INVOKABLE virtual Property* getProperty(QString name);
392 
401  virtual bool addParameter(Property*);
403 
406 
411  void applyTargetPosition(Component* input, Component* target);
412 
419  void applyTargetPosition(Component* input, Component* target, Application::TargetPositionningPolicy policy);
421 
422 protected:
427  void setName(QString name);
430 
432  void setDescription(QString description);
433 
435  void setComponent(QString component);
436 
438  void setFamily(QString family);
439 
441  void addTag(QString tag);
442 
444  void setEmbedded(bool isEmbedded);
445 
447  void setIcon(QPixmap);
448 
450  QWidget* actionWidget;
451 
452 
454 
455 
456 
457 private:
459  QString name;
460 
462  QString description;
463 
465  QString component;
466 
468  QString family;
469 
471  QStringList tags;
472 
475 
478 
480  QPixmap icon;
481 
483  QAction* qAction;
484 
486  QMap<QString, Property*> parameterMap;
487 
498 
501 
504 
513 
518 
523  void preProcess();
524 
529  void postProcess();
531 
534 
544 
549 
550 
556  void preProcessInPipeline();
557 
562  void postProcessInPipeline();
563 
564 
565 
567 
568 
569 
570 };
571 
572 }
573 
574 // -------------------- declare the interface for QPluginLoader --------------------
575 Q_DECLARE_INTERFACE(camitk::Action, "TIMC-IMAG.Action/2.1") //TODO use svn version?
576 
577 #endif // ACTION_H
578 
579 
580 
581 
ComponentList aliveBeforeComponents
In case of a pipeline application of the Action (i.e.
Definition: Action.h:543
QString getName() const
get the name of the action
Definition: Action.h:311
QString name
the name of the action
Definition: Action.h:459
QString getDescription() const
the description of the action
Definition: Action.h:316
QPixmap icon
the Action pixmap icon
Definition: Action.h:480
bool getEmbedded() const
argument use to know if the widget is embedded or not
Definition: Action.h:339
const char * description
Definition: applications/cepgenerator/main.cpp:37
bool autoUpdateProperties
Should the properties/parameters of this action be automatically updated when the user change somethi...
Definition: Action.h:500
apply() failed : an error occured (usually it means that the apply() was interrupted) ...
Definition: Action.h:225
Action class is an abstract class that enables you to build a action (generally on a component)...
Definition: Action.h:207
TargetPositionningPolicy
: Policy to determine how a newly instanciated component&#39;s frame should be initialized regarding of i...
Definition: Application.h:69
everything went according to plan
Definition: Action.h:224
ActionExtension * extension
the extension in which this action is declared and registered
Definition: Action.h:477
Definition: Action.cpp:36
ComponentList topLevelSelectedComponents
The list of top level selected components before running the action This list is used to deduce the n...
Definition: Action.h:517
QAction * qAction
the corresponding QAction
Definition: Action.h:483
some (partial) error occured during the application of the algorithm
Definition: Action.h:226
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:298
#define CAMITK_API
Definition: CamiTKAPI.h:49
This class describes what is a generic Action extension.
Definition: ActionExtension.h:59
QStringList getTag() const
the name of the tag called this action
Definition: Action.h:334
QString component
the name of the component class that can be used by this action
Definition: Action.h:465
QString description
the descriptionof the action
Definition: Action.h:462
HistoryItem class describes the entry of an action used in a pipeline, in the history.
Definition: HistoryItem.h:61
QString getComponent() const
the name of the component class that can be used by this action
Definition: Action.h:321
ApplyStatus
describes what happened during the application of an algorithm (i.e. results of the apply method) ...
Definition: Action.h:223
HistoryItem * item
Definition: Action.h:512
ComponentList outputComponents
List returned by getOutputComponents()
Definition: Action.h:548
QWidget * actionWidget
the action widget
Definition: Action.h:450
ComponentList targetComponents
The list of valid (regarding the component property) components for which this action is called...
Definition: Action.h:497
QMap< QString, Property * > parameterMap
list of CamiTK property decorating the dynamic properties (action parameters)
Definition: Action.h:486
bool isEmbedded
is the widget embedded or not
Definition: Action.h:474
QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:89
QString family
the name of the family in which this action is associated
Definition: Action.h:468
QStringList tags
the name of the tag called this action
Definition: Action.h:471
the action was aborted before completion
Definition: Action.h:227
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:291
QString getFamily() const
the name of the family in which this action is associated
Definition: Action.h:326