Revert "Use fabs() for floats, not abs()".
[agianapa.git] / socg / axis.h
blob59c26676772125ef42db793ae9f750e8ddcc8b21
1 #ifndef AXIS_H
2 #define AXIS_H
4 #include <QColor>
5 #include <QString>
6 #include <QtOpenGL>
8 class Axis {
9 public:
10 Axis(QString label = "axis", QColor color = QColor(0, 255, 0), bool hasLabel = false,
11 bool isVisible = true, bool isLocal = false)
13 m_color = color;
14 m_label = label;
15 m_hasLabel = hasLabel;
16 m_isVisible = isVisible;
17 m_isLocal = isLocal;
19 ~Axis() {};
21 // Setters
22 void setColor(QColor color) { m_color = color; }
23 void setLabel(QString label) { m_label = label; }
24 void setVisible(bool isVisible) { m_isVisible = isVisible; }
25 void setLocal(bool isLocal) { m_isLocal = isLocal; }
27 // Getters
28 const QColor *getColor(void) const { return &m_color; }
29 QString getLabel(void) const {return m_label; }
30 bool hasLabel(void) const { return m_hasLabel; }
31 bool isVisible(void) const { return m_isVisible; }
32 bool isLocal(void) const { return m_isLocal; }
34 // Draw
35 void draw(float x0, float y0, float z0, float x1, float y1, float z1) const
37 if (!m_isVisible)
38 return;
40 // XXX: should be tunable
41 glLineWidth(1);
42 glEnable(GL_LINE_SMOOTH);
44 glBegin(GL_LINES);
45 glColor3f(m_color.redF(), m_color.greenF(), m_color.blueF());
46 glVertex3f(x0, y0, z0);
47 glVertex3f(x1, y1, z1);
48 glEnd();
50 // Restore color and line width
51 glColor3f(1.0f, 1.0f, 1.0f);
52 glDisable(GL_LINE_SMOOTH);
53 glLineWidth(1);
55 private:
56 QColor m_color;
57 QString m_label;
58 bool m_hasLabel;
59 bool m_isVisible;
60 bool m_isLocal;
63 #endif // AXIS_H