Computer Assited Medical Intervention Tool Kit  version 4.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-2016 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 
208 class CAMITK_API Action : public QObject {
209  Q_OBJECT
210 
211 public:
212 
215 
217  virtual ~Action();
218 
220  enum ApplyStatus {
225  TRIGGERED
226  };
227 
228 public slots:
234  ApplyStatus trigger(QWidget * parent = NULL);
235 
245  virtual ApplyStatus apply() = 0;
246 
254  ApplyStatus applyAndRegister();
255 
256 public:
257 
260 
269  ApplyStatus applyInPipeline();
271 
275  void setInputComponents(ComponentList inputs);
276 
278  void setInputComponent(Component * input);
279 
281  ComponentList getOutputComponents();
282 
284  Component * getOutputComponent();
286 
290 
298  QAction *getQAction();
299 
301  QString getName() const {
302  return name;
303  };
304 
306  QString getDescription() const {
307  return description;
308  };
309 
311  QString getComponent() const {
312  return component;
313  };
314 
316  QString getFamily() const {
317  return family;
318  };
319 
321  QString getExtensionName() const;
322 
324  QStringList getTag() const {
325  return tags;
326  };
327 
329  bool getEmbedded() const {
330  return isEmbedded;
331  };
333 
336 
358  virtual QWidget * getWidget();
359 
361  virtual QPixmap getIcon();
362 
364  const ComponentList getTargets() const;
366 
370  bool getAutoUpdateProperties() const;
371 
373  void setAutoUpdateProperties(bool);
374 
381  Q_INVOKABLE virtual Property* getProperty(QString name);
382 
391  virtual bool addParameter(Property*);
393 
396 
401  void applyTargetPosition(Component* input, Component* target);
402 
409  void applyTargetPosition(Component* input, Component* target, Application::TargetPositionningMethods policy);
411 
412 protected:
417  void setName(QString name);
420 
422  void setDescription(QString description);
423 
425  void setComponent(QString component);
426 
428  void setFamily(QString family);
429 
431  void addTag(QString tag);
432 
434  void setEmbedded(bool isEmbedded);
435 
437  void setIcon(QPixmap);
438 
440  QWidget *actionWidget;
441 
442 
444 
445 
446 
447 private:
449  QString name;
450 
452  QString description;
453 
455  QString component;
456 
458  QString family;
459 
461  QStringList tags;
462 
465 
468 
470  QPixmap icon;
471 
473  QAction *qAction;
474 
476  QMap<QString, Property*> parameterMap;
477 
488 
491 
494 
503 
508 
513  void preProcess();
514 
519  void postProcess();
521 
524 
534 
539 
540 
546  void preProcessInPipeline();
547 
552  void postProcessInPipeline();
553 
554 
555 
557 
558 
559 
560 };
561 
562 }
563 
564 // -------------------- declare the interface for QPluginLoader --------------------
565 Q_DECLARE_INTERFACE(camitk::Action, "TIMC-IMAG.Action/2.1") //TODO use svn version?
566 
567 #endif // ACTION_H
568 
569 
570 
571 
ComponentList aliveBeforeComponents
In case of a pipeline application of the Action (i.e.
Definition: Action.h:533
QString getName() const
get the name of the action
Definition: Action.h:301
QString name
the name of the action
Definition: Action.h:449
QString getDescription() const
the description of the action
Definition: Action.h:306
QPixmap icon
the Action pixmap icon
Definition: Action.h:470
bool getEmbedded() const
argument use to know if the widget is embedded or not
Definition: Action.h:329
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:490
apply() failed : an error occured (usually it means that the apply() was interrupted) ...
Definition: Action.h:222
Action class is an abstract class that enables you to build a action (generally on a component)...
Definition: Action.h:208
everything went according to plan
Definition: Action.h:221
ActionExtension * extension
the extension in which this action is declared and registered
Definition: Action.h:467
Definition: Action.cpp:40
ComponentList topLevelSelectedComponents
The list of top level selected components before running the action This list is used to deduce the n...
Definition: Action.h:507
QAction * qAction
the corresponding QAction
Definition: Action.h:473
some (partial) error occured during the application of the algorithm
Definition: Action.h:223
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:299
CAMITK_API QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:86
#define CAMITK_API
Definition: CamiTKAPI.h:49
This class describes what is a generic Action extension.
Definition: ActionExtension.h:61
QStringList getTag() const
the name of the tag called this action
Definition: Action.h:324
QString component
the name of the component class that can be used by this action
Definition: Action.h:455
QString description
the descriptionof the action
Definition: Action.h:452
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:311
ApplyStatus
describes what happened during the application of an algorithm (i.e. results of the apply method) ...
Definition: Action.h:220
HistoryItem * item
Definition: Action.h:502
ComponentList outputComponents
List returned by getOutputComponents()
Definition: Action.h:538
QWidget * actionWidget
the action widget
Definition: Action.h:440
ComponentList targetComponents
The list of valid (regarding the component property) components for which this action is called...
Definition: Action.h:487
QMap< QString, Property * > parameterMap
list of CamiTK property decorating the dynamic properties (action parameters)
Definition: Action.h:476
bool isEmbedded
is the widget embedded or not
Definition: Action.h:464
QString family
the name of the family in which this action is associated
Definition: Action.h:458
QStringList tags
the name of the tag called this action
Definition: Action.h:461
TargetPositionningMethods
Definition: Application.h:67
the action was aborted before completion
Definition: Action.h:224
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:260
QString getFamily() const
the name of the family in which this action is associated
Definition: Action.h:316