Tulip  4.4.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
GlLines.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 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef _TLP_GLLINES
22 #define _TLP_GLLINES
23 #ifndef DOXYGEN_NOTFOR_DEVEL
24 #include <vector>
25 
26 #if defined(_MSC_VER)
27 #include <Windows.h>
28 #endif
29 
30 #if defined(__APPLE__)
31 #include <OpenGL/gl.h>
32 #else
33 #include <GL/gl.h>
34 #endif
35 
36 #include <tulip/Coord.h>
37 #include <tulip/Color.h>
38 
39 #include <tulip/tulipconf.h>
40 
41 namespace tlp {
42 
43 struct TLP_GL_SCOPE GlLines {
44  //Curves types: linear, bezier, spline order 3, spline order 4
45  enum InterpolationMethod {LINEAR=0, BEZIER, SPLINE3, SPLINE4};
46  enum StippleType {TLP_PLAIN=0, TLP_DOT, TLP_DASHED, TLP_ALTERNATE};
47 
48  static void glDrawPoint(const Coord &p);
49 
50  static void glDrawLine(const Coord &startPoint,const Coord &endPoint,const double width,const unsigned int stippleType,
51  const Color &startColor,const Color &endColor,const bool arrow=false,const double arrowWidth=1,
52  const double arrowHeight=1);
53  static void glDrawCurve(const Coord &startPoint,const std::vector<Coord> &bends,const Coord &endPoint,const double width,
54  const unsigned int stippleType,const Color &startColor,const Color &endColor,const bool arrow=false,
55  const double arrowWidth=1,const double arrowHeight=1);
56  static void glDrawBezierCurve(const Coord &startPoint,const std::vector<Coord> &bends,const Coord &endPoint,unsigned int steps,
57  const double width,const unsigned int stippleType,const Color &startColor,const Color &endColor,
58  const bool arrow=false,const double arrowWidth=1,const double arrowHeight=1);
59  static void glDrawSplineCurve(const Coord &startPoint,const std::vector<Coord> &bends,const Coord &endPoint,unsigned int steps,
60  const double width,const unsigned int stippleType,const Color &startColor,const Color &endColor,
61  const bool arrow=false,const double arrowWidth=1,const double arrowHeight=1);
62  static void glDrawSpline2Curve(const Coord &startPoint,const std::vector<Coord> &bends,const Coord &endPoint,unsigned int steps,
63  const double width,const unsigned int stippleType,const Color &startColor,const Color &endColor,
64  const bool arrow=false,const double arrowWidth=1,const double arrowHeight=1);
65 
66 private:
67  static void glDisableLineStipple(unsigned int stippleType);
68  static void glEnableLineStipple(unsigned int stippleType);
69  static GLfloat *buildCurvePoints(const Coord &startPoint,const std::vector<Coord> &bends,const Coord &endPoint);
70  static GLfloat *buildCurvePoints(const Coord &p0,const Coord &p1,const Coord &p2,const Coord &p3);
71 };
72 
73 }
74 #endif //DOXYGEN_NOTFOR_DEVEL
75 #endif
76 ///@endcond