Tulip  4.3.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
GLInteractor.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 #ifndef GLINTERACTOR_H
20 #define GLINTERACTOR_H
21 
22 #include <tulip/InteractorComposite.h>
23 
24 #include <QIcon>
25 
26 namespace tlp {
27 
28 class GlMainWidget;
29 
30 /**
31  * @brief The GLInteractorComponent class is an InteractorComponent that can do OpenGL rendering on a GlMainWidget.
32  *
33  * @warning Only GLInteractorComponent that are stored into a GLInteractorComposite will be able to do OpenGL rendering. Storing them into an InteractorComposite will have no effect.
34  *
35  * GLInteractorComponent are meant to be stored into a GLInteractorComposite
36  * When installed on a GlMainWidget, this interactor will have two new methods getting called:
37  * @list
38  * @li draw: Draws a visual feedback into the OpenGL scene. This is called after the scene was rendered
39  * @li compute: Allows the interactor to do some pre-initialisation steps before the OpenGL scene is rendered.
40  * @endlist
41  */
42 class TLP_QT_SCOPE GLInteractorComponent: public tlp::InteractorComponent {
43  Q_OBJECT
44 public slots:
45 
46  /**
47  * @brief Draws an OpenGL visual feedback for the interactor into a given GlMainWidget.
48  * This method is called after the scene was rendered.
49  * @return true if the rendering completed sucessfully
50  */
51  virtual bool draw(tlp::GlMainWidget*) {
52  return false;
53  }
54 
55  /**
56  * @brief Initializes the interactor before the scene in the given GlMainWidget is rendered
57  */
58  virtual bool compute(tlp::GlMainWidget*) {
59  return false;
60  }
61 };
62 
63 /**
64  * @brief The GLInteractorComposite class behaves like a InteractorComposite but is meant to store GLInteractorComponent.
65  * @warning Only GLInteractorComponent that are stored into a GLInteractorComposite will be able to do OpenGL rendering. Storing them into an InteractorComposite will have no effect.
66  */
67 class TLP_QT_SCOPE GLInteractorComposite: public tlp::InteractorComposite {
68  Q_OBJECT
69 
70 public:
71  GLInteractorComposite(const QIcon& icon, const QString& text="");
72 
73 public slots:
74  /**
75  * @brief Calls the compute method on every sub-components
76  * @note You can subclass this method to add custom behavior before or after components are called.
77  */
78  virtual void compute(tlp::GlMainWidget*);
79 
80  /**
81  * @brief Calls the draw method on every sub-components
82  * @note You can subclass this method to add custom behavior before or after components are called.
83  */
84  virtual void draw(tlp::GlMainWidget*);
85 };
86 
87 }
88 
89 #endif // GLINTERACTOR_H