09437b54bbafa6dae1e4065b16112cf2c9dfb758
[mussa.git] / qui / GlSequence.cxx
1 #include "qui/GlSequence.h"
2
3 #include <iostream>
4 using namespace std;
5
6 GlSequence::GlSequence(const Sequence &s) 
7   : seq(s),
8     seq_x(0.0), 
9     seq_y(0.0), 
10     seq_z(1.0), 
11     seq_width(s.size()),
12     seq_height(gl_track_height) 
13 {
14 }
15
16 GlSequence::GlSequence(const GlSequence &s) 
17   : seq(s.seq),
18     seq_x(s.seq_x),
19     seq_y(s.seq_y),
20     seq_z(s.seq_z),
21     seq_width(s.seq_width),
22     seq_height(s.seq_height)
23 {
24 }
25
26 GlSequence &GlSequence::operator=(const GlSequence & s)
27 {
28   if (this != &s) {
29     const_cast<Sequence &>(seq) = s.seq;
30     seq_x = s.seq_x;
31     seq_y = s.seq_y;
32     seq_z = s.seq_z;
33     seq_width = s.seq_width;
34     seq_height = s.seq_height;
35   }
36   return *this;
37 }
38
39 const Sequence &GlSequence::sequence() const
40 {
41   return seq;
42 }
43
44 void GlSequence::setX(GLfloat value)
45 {
46   seq_x = value;
47 }
48
49 GLfloat GlSequence::x() const
50 {
51   return seq_x;
52 }
53
54 void GlSequence::setY(GLfloat value)
55 {
56   seq_y = value;
57 }
58
59 GLfloat GlSequence::y() const
60 {
61   return seq_y;
62 }
63
64 void GlSequence::setWidth(GLfloat value)
65 {
66   seq_width = value;
67 }
68
69 GLfloat GlSequence::width() const
70 {
71   return seq_width;
72 }
73
74
75 void GlSequence::draw() const
76 {
77   glLineWidth(seq_height);
78   glColor3f(0.0, 0.0, 0.0);
79   // draw main sequence track
80   glBegin(GL_LINES);
81     glVertex3f(seq_x,           seq_y, seq_z);
82     glVertex3f(seq_x+seq_width, seq_y, seq_z);
83     //clog << "drawing " << seq_x << " " << seq_y << " " << seq_width
84     //     << std::endl;
85   glEnd();
86   // draw annotations
87   GLfloat annotation_z = seq_z + 1.0;
88   std::list<annot> annots = seq.annotations();
89   for (std::list<annot>::const_iterator annot_itor = annots.begin();
90        annot_itor != annots.end();
91        ++annot_itor, ++annotation_z)
92   {
93     glColor3f(0.0, 0.5, 0.0);
94     glBegin(GL_LINES);
95       glVertex3f(annot_itor->start, seq_y, annotation_z);
96       glVertex3f(annot_itor->end  , seq_y, annotation_z);
97     glEnd();
98   }
99 }