Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 #ifndef GLSCENEZOOMANDPAN_H_ 00020 #define GLSCENEZOOMANDPAN_H_ 00021 00022 #include <tulip/tulipconf.h> 00023 #include <tulip/Vector.h> 00024 #include <tulip/Coord.h> 00025 00026 namespace tlp { 00027 00028 class GlScene; 00029 struct BoundingBox; 00030 class Camera; 00031 00032 /** 00033 * \brief A class which encapsulate a Tulip OpenGL scene animation 00034 * This class aims to encapsulate a Tulip OpenGL scene animation. 00035 * Derive it if you want to add extra animations to the Tulip OpenGL scene while a Zoom and Pan is performed 00036 */ 00037 class TLP_GL_SCOPE AdditionalGlSceneAnimation { 00038 00039 public : 00040 00041 virtual ~AdditionalGlSceneAnimation() {} 00042 00043 /** 00044 * Method to set the total number of animation steps. No need to call it because the GlSceneZoomAndPan class do that task. 00045 * 00046 */ 00047 inline void setNbAnimationSteps(int nbAnimationSteps) { 00048 this->nbAnimationSteps = nbAnimationSteps; 00049 } 00050 00051 /** 00052 * Pure virtual method called at each step of the Zoom and Pan animation. 00053 * 00054 * Implement it in your derived class to perform any extra animation you want on the Tulip OpenGL scene. 00055 */ 00056 virtual void animationStep(int animationStep) = 0; 00057 00058 protected : 00059 00060 int nbAnimationSteps; 00061 }; 00062 00063 /** \brief A convenient class to perform Zoom and Pan animation on Tulip OpenGL scene 00064 * 00065 * This class allow to perform a smooth and efficient zooming and panning on Tulip OpenGL scene. 00066 * The algorithm used to perform this task is the one published in: Jarke J. van Wijk and Wim A.A. Nuij, "Smooth and efficient zooming and panning" 00067 * For more details, the paper can be downloaded at the following url: http://www.win.tue.nl/~vanwijk/zoompan.pdf 00068 * Even if this class contains the whole Zoom and Pan implementation, it is not aimed to be used directly because its role is only to compute new camera parameters. 00069 * Use the derived class QtGlSceneZoomAndPanAnimator in the tulip-gui library instead to perform the animation. 00070 */ 00071 class TLP_GL_SCOPE GlSceneZoomAndPan { 00072 00073 public : 00074 00075 virtual ~GlSceneZoomAndPan() {} 00076 00077 /** 00078 * GlSceneZoomAndPan constructor 00079 * 00080 * \param glScene the Tulip OpenGL scene on which to perform zooming and panning 00081 * \param boundingBox the bounding box in scene coordinates on which the Tulip OpenGL scene has to be zoomed and panned. 00082 * At the end of the animation, the viewport will be zoomed and centered on the content of that bounding box. 00083 * \param layerName The name of the layer animation should be done on 00084 * \param nbAnimationSteps the number of steps to perform during the animation 00085 * \param optimalPath if true zooming and panning will be combined at each step of the animation, if false the scene will be zoomed out/in, panned then zoomed in/out 00086 * \param p zoom/pan trade-off parameter, adjust it according to your needs 00087 */ 00088 GlSceneZoomAndPan(GlScene *glScene, const BoundingBox &boundingBox, const std::string &layerName="Main", const int nbAnimationSteps = 50, const bool optimalPath = true, const double p = sqrt(1.6)); 00089 00090 /** 00091 * Method to add an additional scene animation while zooming and panning 00092 * 00093 * \param additionalAnimation The animation to add 00094 */ 00095 void setAdditionalGlSceneAnimation(AdditionalGlSceneAnimation *additionalAnimation); 00096 00097 /** 00098 * Method which return the number of animation steps 00099 */ 00100 inline int getNbAnimationsStep() const { 00101 return nbAnimationSteps; 00102 } 00103 00104 /** 00105 * Method to set the number of animation steps 00106 */ 00107 inline void setNbAnimationSteps(const int nbAnimationSteps) { 00108 this->nbAnimationSteps = nbAnimationSteps; 00109 } 00110 00111 /** 00112 * Method which performs the zoom and pan animation. Its role is to compute new camera parameters at step animationStep. 00113 * The scene is not redrawn with this method, you have to call the draw method on the associated GlScene object 00114 */ 00115 void zoomAndPanAnimationStep(int animationStep); 00116 00117 protected : 00118 00119 Camera &camera; 00120 Vector<int, 4> viewport; 00121 int nbAnimationSteps; 00122 bool optimalPath; 00123 double p; 00124 Coord camCenterStart, camCenterEnd; 00125 double w0, w1, u0, u1, b0, b1, r0, r1, S, sA, sB, wm; 00126 AdditionalGlSceneAnimation *additionalAnimation; 00127 float zoomAreaWidth, zoomAreaHeight; 00128 bool doZoomAndPan; 00129 00130 }; 00131 00132 } 00133 00134 #endif /* GLSCENEZOOMANDPAN_H_ */