Tulip  5.7.4
Large graphs analysis and drawing
GlLines.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 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef _TLP_GLLINES
22 #define _TLP_GLLINES
23 #ifndef DOXYGEN_NOTFOR_DEVEL
24 #include <vector>
25 
26 #include <tulip/OpenGlIncludes.h>
27 
28 #include <tulip/Coord.h>
29 #include <tulip/Color.h>
30 
31 #include <tulip/tulipconf.h>
32 
33 namespace tlp {
34 
35 struct TLP_GL_SCOPE GlLines {
36  // Curves types: linear, bezier, spline order 3, spline order 4
37  enum InterpolationMethod { LINEAR = 0, BEZIER, SPLINE3, SPLINE4 };
38  enum StippleType { TLP_PLAIN = 0, TLP_DOT, TLP_DASHED, TLP_ALTERNATE };
39 
40  static void glDrawPoint(const Coord &p);
41 
42  static void glDrawLine(const Coord &startPoint, const Coord &endPoint, const double width,
43  const unsigned int stippleType, const Color &startColor,
44  const Color &endColor, const bool arrow = false,
45  const double arrowWidth = 1, const double arrowHeight = 1);
46  static void glDrawCurve(const Coord &startPoint, const std::vector<Coord> &bends,
47  const Coord &endPoint, const double width, const unsigned int stippleType,
48  const Color &startColor, const Color &endColor, const bool arrow = false,
49  const double arrowWidth = 1, const double arrowHeight = 1);
50  static void glDrawBezierCurve(const Coord &startPoint, const std::vector<Coord> &bends,
51  const Coord &endPoint, unsigned int steps, const double width,
52  const unsigned int stippleType, const Color &startColor,
53  const Color &endColor, const bool arrow = false,
54  const double arrowWidth = 1, const double arrowHeight = 1);
55  static void glDrawSplineCurve(const Coord &startPoint, const std::vector<Coord> &bends,
56  const Coord &endPoint, unsigned int steps, const double width,
57  const unsigned int stippleType, const Color &startColor,
58  const Color &endColor, const bool arrow = false,
59  const double arrowWidth = 1, const double arrowHeight = 1);
60  static void glDrawSpline2Curve(const Coord &startPoint, const std::vector<Coord> &bends,
61  const Coord &endPoint, unsigned int steps, const double width,
62  const unsigned int stippleType, const Color &startColor,
63  const Color &endColor, const bool arrow = false,
64  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,
70  const Coord &endPoint);
71  static GLfloat *buildCurvePoints(const Coord &p0, const Coord &p1, const Coord &p2,
72  const Coord &p3);
73 };
74 } // namespace tlp
75 #endif // DOXYGEN_NOTFOR_DEVEL
76 #endif
77 ///@endcond