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 #include <signal.h>
39 
40 
41 namespace camitk {
42 
43 class ActionExtension;
44 class Property;
45 
209 class CAMITK_API Action : public QObject {
210  Q_OBJECT
211 
212 public:
213 
216 
218  virtual ~Action();
219 
221  enum ApplyStatus {
226  TRIGGERED
227  };
228 
229 public slots:
235  ApplyStatus trigger(QWidget * parent = NULL);
236 
246  virtual ApplyStatus apply() = 0;
247 
255  ApplyStatus applyAndRegister();
256 
257 public:
258 
261 
270  ApplyStatus applyInPipeline();
272 
276  void setInputComponents(ComponentList inputs);
277 
279  void setInputComponent(Component * input);
280 
282  ComponentList getOutputComponents();
283 
285  Component * getOutputComponent();
287 
291 
299  QAction *getQAction();
300 
302  QString getName() const {
303  return name;
304  };
305 
307  QString getDescription() const {
308  return description;
309  };
310 
312  QString getComponent() const {
313  return component;
314  };
315 
317  QString getFamily() const {
318  return family;
319  };
320 
322  QString getExtensionName() const;
323 
325  QStringList getTag() const {
326  return tags;
327  };
328 
330  bool getEmbedded() const {
331  return isEmbedded;
332  };
334 
337 
359  virtual QWidget * getWidget();
360 
362  virtual QPixmap getIcon();
363 
365  const ComponentList getTargets() const;
367 
371  bool getAutoUpdateProperties() const;
372 
374  void setAutoUpdateProperties(bool);
375 
382  Q_INVOKABLE virtual Property* getProperty(QString name);
383 
392  virtual bool addParameter(Property*);
394 
397 
402  void applyTargetPosition(Component* input, Component* target);
403 
410  void applyTargetPosition(Component* input, Component* target, Application::TargetPositionningMethods policy);
412 
413 protected:
418  void setName(QString name);
421 
423  void setDescription(QString description);
424 
426  void setComponent(QString component);
427 
429  void setFamily(QString family);
430 
432  void addTag(QString tag);
433 
435  void setEmbedded(bool isEmbedded);
436 
438  void setIcon(QPixmap);
439 
441  QWidget *actionWidget;
442 
443 
445 
446 
447 
448 private:
450  QString name;
451 
453  QString description;
454 
456  QString component;
457 
459  QString family;
460 
462  QStringList tags;
463 
466 
469 
471  QPixmap icon;
472 
474  QAction *qAction;
475 
477  QMap<QString, Property*> parameterMap;
478 
489 
492 
495 
504 
509 
514  void preProcess();
515 
520  void postProcess();
522 
525 
535 
540 
541 
547  void preProcessInPipeline();
548 
553  void postProcessInPipeline();
554 
555 
556 
558 
559 
560 
561 };
562 
563 }
564 
565 // -------------------- declare the interface for QPluginLoader --------------------
566 Q_DECLARE_INTERFACE(camitk::Action, "TIMC-IMAG.Action/2.1") //TODO use svn version?
567 
568 #endif // ACTION_H
569 
570 
571 
572 
ComponentList aliveBeforeComponents
In case of a pipeline application of the Action (i.e.
Definition: Action.h:534
QStringList getTag() const
the name of the tag called this action
Definition: Action.h:325
QString name
the name of the action
Definition: Action.h:450
QPixmap icon
the Action pixmap icon
Definition: Action.h:471
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:491
apply() failed : an error occured (usually it means that the apply() was interrupted) ...
Definition: Action.h:223
Action class is an abstract class that enables you to build a action (generally on a component)...
Definition: Action.h:209
bool getEmbedded() const
argument use to know if the widget is embedded or not
Definition: Action.h:330
everything went according to plan
Definition: Action.h:222
ActionExtension * extension
the extension in which this action is declared and registered
Definition: Action.h:468
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:508
QAction * qAction
the corresponding QAction
Definition: Action.h:474
some (partial) error occured during the application of the algorithm
Definition: Action.h:224
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:299
QString getName() const
get the name of the action
Definition: Action.h:302
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
QString component
the name of the component class that can be used by this action
Definition: Action.h:456
QString getFamily() const
the name of the family in which this action is associated
Definition: Action.h:317
QString description
the descriptionof the action
Definition: Action.h:453
HistoryItem class describes the entry of an action used in a pipeline, in the history.
Definition: HistoryItem.h:61
ApplyStatus
describes what happened during the application of an algorithm (i.e. results of the apply method) ...
Definition: Action.h:221
HistoryItem * item
Definition: Action.h:503
ComponentList outputComponents
List returned by getOutputComponents()
Definition: Action.h:539
QWidget * actionWidget
the action widget
Definition: Action.h:441
ComponentList targetComponents
The list of valid (regarding the component property) components for which this action is called...
Definition: Action.h:488
QMap< QString, Property * > parameterMap
list of CamiTK property decorating the dynamic properties (action parameters)
Definition: Action.h:477
bool isEmbedded
is the widget embedded or not
Definition: Action.h:465
QString getDescription() const
the description of the action
Definition: Action.h:307
QString getComponent() const
the name of the component class that can be used by this action
Definition: Action.h:312
QString family
the name of the family in which this action is associated
Definition: Action.h:459
QStringList tags
the name of the tag called this action
Definition: Action.h:462
TargetPositionningMethods
Definition: Application.h:67
the action was aborted before completion
Definition: Action.h:225
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:260