Computer Assited Medical Intervention Tool Kit  version 3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-2014 UJF-Grenoble 1, 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 
33 #include <QSet>
34 #include <QWidget>
35 #include <QString>
36 #include <QAction>
37 #include <signal.h>
38 
39 
40 namespace camitk {
41 
42 class ActionExtension;
43 class Property;
44 
184 class CAMITK_API Action : public QObject {
185  Q_OBJECT
186 
187 public:
188 
191 
193  virtual ~Action();
194 
196  enum ApplyStatus {
201  TRIGGERED
202  };
203 
204 public slots:
210  ApplyStatus trigger(QWidget * parent = NULL);
211 
221  virtual ApplyStatus apply() = 0;
222 
230  ApplyStatus applyAndRegister();
231 
232 public:
233 
236 
245  ApplyStatus applyInPipeline();
247 
251  void setInputComponents(ComponentList inputs);
252 
254  void setInputComponent(Component * input);
255 
257  ComponentList getOutputComponents();
258 
260  Component * getOutputComponent();
262 
266 
274  QAction *getQAction();
275 
277  QString getName() const {
278  return name;
279  };
280 
282  QString getDescription() const {
283  return description;
284  };
285 
287  QString getComponent() const {
288  return component;
289  };
290 
292  QString getFamily() const {
293  return family;
294  };
295 
297  QString getExtensionName() const;
298 
300  QStringList getTag() const {
301  return tags;
302  };
303 
305  bool getEmbedded() const {
306  return isEmbedded;
307  };
309 
312 
334  virtual QWidget * getWidget();
335 
337  virtual QPixmap getIcon();
338 
340  const ComponentList getTargets() const;
342 
344  bool getAutoUpdateProperties() const;
345 
347  void setAutoUpdateProperties(bool);
348 
355  Q_INVOKABLE virtual Property* getProperty(QString name);
356 
365  virtual bool addParameter(Property*);
366 
367 protected:
372  void setName(QString name);
375 
377  void setDescription(QString description);
378 
380  void setComponent(QString component);
381 
383  void setFamily(QString family);
384 
386  void addTag(QString tag);
387 
389  void setEmbedded(bool isEmbedded);
390 
392  void setIcon(QPixmap);
393 
395  QWidget *actionWidget;
396 
397 
399 
400 
401 
402 private:
404  QString name;
405 
407  QString description;
408 
410  QString component;
411 
413  QString family;
414 
416  QStringList tags;
417 
420 
423 
425  QPixmap icon;
426 
428  QAction *qAction;
429 
431  QMap<QString, Property*> parameterMap;
432 
443 
446 
449 
458 
463 
468  void preProcess();
469 
474  void postProcess();
476 
479 
489 
494 
495 
501  void preProcessInPipeline();
502 
507  void postProcessInPipeline();
508 
509 
510 
512 
513 
514 
515 };
516 
517 }
518 
519 // -------------------- declare the interface for QPluginLoader --------------------
520 Q_DECLARE_INTERFACE(camitk::Action, "TIMC-IMAG.Action/2.1") //TODO use svn version?
521 
522 #endif // ACTION_H
523 
524 
525 
526 
the action was aborted before completion
Definition: Action.h:200
ComponentList aliveBeforeComponents
In case of a pipeline application of the Action (i.e.
Definition: Action.h:488
QStringList getTag() const
the name of the tag called this action
Definition: Action.h:300
QString name
the name of the action
Definition: Action.h:404
QPixmap icon
the Action pixmap icon
Definition: Action.h:425
bool autoUpdateProperties
Should the properties/parameters of this action be automatically updated when the user change somethi...
Definition: Action.h:445
Action class is an abstract class that enables you to build a action (generally on a component)...
Definition: Action.h:184
some (partial) error occured during the application of the algorithm
Definition: Action.h:199
bool getEmbedded() const
argument use to know if the widget is embedded or not
Definition: Action.h:305
ActionExtension * extension
the extension in which this action is declared and registered
Definition: Action.h:422
Definition: Action.h: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:462
QAction * qAction
the corresponding QAction
Definition: Action.h:428
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:292
QString getName() const
get the name of the action
Definition: Action.h:277
CAMITK_API QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:87
#define CAMITK_API
Definition: CamiTKAPI.h:49
This class describes what is a generic Action extension.
Definition: ActionExtension.h:61
QString component
the name of the component class that can be used by this action
Definition: Action.h:410
QString getFamily() const
the name of the family in which this action is associated
Definition: Action.h:292
QString description
the descriptionof the action
Definition: Action.h:407
HistoryItem class describes the entry of an action used in a pipeline, in the history.
Definition: HistoryItem.h:61
HistoryItem * item
Definition: Action.h:457
ComponentList outputComponents
List returned by getOutputComponents()
Definition: Action.h:493
QWidget * actionWidget
the action widget
Definition: Action.h:395
ComponentList targetComponents
The list of valid (regarding the component property) components for which this action is called...
Definition: Action.h:442
QMap< QString, Property * > parameterMap
list of CamiTK property decorating the dynamic properties (action parameters)
Definition: Action.h:431
everything went according to plan
Definition: Action.h:197
bool isEmbedded
is the widget embedded or not
Definition: Action.h:419
QString getDescription() const
the description of the action
Definition: Action.h:282
QString getComponent() const
the name of the component class that can be used by this action
Definition: Action.h:287
ApplyStatus
describes what happened during the application of an algorithm (i.e. results of the apply method) ...
Definition: Action.h:196
QString family
the name of the family in which this action is associated
Definition: Action.h:413
QStringList tags
the name of the tag called this action
Definition: Action.h:416
apply() failed : an error occured (usually it means that the apply() was interrupted) ...
Definition: Action.h:198
Definition: ExtensionWindow.h:39
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:188