Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
GlSceneZoomAndPan.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
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
20///@cond DOXYGEN_HIDDEN
21
22#ifndef GLSCENEZOOMANDPAN_H_
23#define GLSCENEZOOMANDPAN_H_
24
25#include <tulip/tulipconf.h>
26#include <tulip/Vector.h>
27#include <tulip/Coord.h>
28
29namespace tlp {
30
31class GlScene;
32struct BoundingBox;
33class Camera;
34
35/**
36 * \brief A class which encapsulate a Tulip OpenGL scene animation
37 * This class aims to encapsulate a Tulip OpenGL scene animation.
38 * Derive it if you want to add extra animations to the Tulip OpenGL scene while a Zoom and Pan is
39 * performed
40 */
41class TLP_GL_SCOPE AdditionalGlSceneAnimation {
42
43public:
44 virtual ~AdditionalGlSceneAnimation() {}
45
46 /**
47 * Method to set the total number of animation steps. No need to call it because the
48 * GlSceneZoomAndPan class do that task.
49 *
50 */
51 inline void setNbAnimationSteps(int nbAnimationSteps) {
52 this->nbAnimationSteps = nbAnimationSteps;
53 }
54
55 /**
56 * Pure virtual method called at each step of the Zoom and Pan animation.
57 *
58 * Implement it in your derived class to perform any extra animation you want on the Tulip OpenGL
59 * scene.
60 */
61 virtual void animationStep(int animationStep) = 0;
62
63protected:
64 int nbAnimationSteps;
65};
66
67/** \brief A convenient class to perform Zoom and Pan animation on Tulip OpenGL scene
68 *
69 * This class allow to perform a smooth and efficient zooming and panning on Tulip OpenGL scene.
70 * The algorithm used to perform this task is the one published in: Jarke J. van Wijk and Wim A.A.
71 * Nuij, "Smooth and efficient zooming and panning"
72 * For more details, the paper can be downloaded at the following url:
73 * http://www.win.tue.nl/~vanwijk/zoompan.pdf
74 * Even if this class contains the whole Zoom and Pan implementation, it is not aimed to be used
75 * directly because its role is only to compute new camera parameters.
76 * Use the derived class QtGlSceneZoomAndPanAnimator in the tulip-gui library instead to perform
77 * the animation.
78 */
79class TLP_GL_SCOPE GlSceneZoomAndPan {
80
81public:
82 virtual ~GlSceneZoomAndPan() {}
83
84 /**
85 * GlSceneZoomAndPan constructor
86 *
87 * \param glScene the Tulip OpenGL scene on which to perform zooming and panning
88 * \param boundingBox the bounding box in scene coordinates on which the Tulip OpenGL scene has to
89 * be zoomed and panned.
90 * At the end of the animation, the viewport will be zoomed and centered on the content
91 * of that bounding box.
92 * \param layerName The name of the layer animation should be done on
93 * \param nbAnimationSteps the number of steps to perform during the animation
94 * \param optimalPath if true zooming and panning will be combined at each step of the animation,
95 * if false the scene will be zoomed out/in, panned then zoomed in/out
96 * \param p zoom/pan trade-off parameter, adjust it according to your needs
97 */
98 GlSceneZoomAndPan(GlScene *glScene, const BoundingBox &boundingBox,
99 const std::string &layerName = "Main", const int nbAnimationSteps = 50,
100 const bool optimalPath = true, const double p = sqrt(1.6));
101
102 /**
103 * Method to add an additional scene animation while zooming and panning
104 *
105 * \param additionalAnimation The animation to add
106 */
107 void setAdditionalGlSceneAnimation(AdditionalGlSceneAnimation *additionalAnimation);
108
109 /**
110 * Method which return the number of animation steps
111 */
112 inline int getNbAnimationsStep() const {
113 return nbAnimationSteps;
114 }
115
116 /**
117 * Method to set the number of animation steps
118 */
119 inline void setNbAnimationSteps(const int nbAnimationSteps) {
120 this->nbAnimationSteps = nbAnimationSteps;
121 }
122
123 /**
124 * Method which performs the zoom and pan animation. Its role is to compute new camera parameters
125 * at step animationStep.
126 * The scene is not redrawn with this method, you have to call the draw method on the associated
127 * GlScene object
128 */
129 void zoomAndPanAnimationStep(int animationStep);
130
131protected:
132 Camera &camera;
133 Vector<int, 4> viewport;
134 int nbAnimationSteps;
135 bool optimalPath;
136 double p;
137 Coord camCenterStart, camCenterEnd;
138 double w0, w1, u0, u1, b0, b1, r0, r1, S, sA, sB, wm;
139 AdditionalGlSceneAnimation *additionalAnimation;
140 float zoomAreaWidth, zoomAreaHeight;
141 bool doZoomAndPan;
142};
143} // namespace tlp
144
145#endif /* GLSCENEZOOMANDPAN_H_ */
146
147///@endcond