seq_x(0.0),
seq_y(0.0),
seq_z(1.0),
- seq_height(gl_track_height),
+ seq_height(12.0),
drawColor(0.0, 0.0, 0.0),
char_pix_per_world_unit(5.0)
{
void GlSequence::draw(GLfloat left, GLfloat right) const
{
if ( not is_sequence_renderable(left, right) ) {
- draw_bar(left, right);
+ draw_track(left, right);
} else {
draw_sequence(left, right);
}
draw_annotations(left, right);
}
-void GlSequence::draw_bar(GLfloat left, GLfloat right) const
+void GlSequence::draw_box(GLfloat left, GLfloat right,
+ GLfloat height, GLfloat z) const
+{
+ GLfloat offset = height/2.0;
+ GLfloat top = seq_y + offset;
+ GLfloat bottom = seq_y - offset;
+
+ glBegin(GL_QUADS);
+ glVertex3f(left, top, z);
+ glVertex3f(left, bottom, z);
+ glVertex3f(right, bottom, z);
+ glVertex3f(right, top, z);
+ glEnd();
+}
+void GlSequence::draw_track(GLfloat left, GLfloat right) const
{
- glLineWidth(seq_height);
glColor3fv(drawColor.get());
// draw main sequence track
- glBegin(GL_LINES);
- glVertex3f(seq_x, seq_y, seq_z);
- glVertex3f(seq_x+seq.size(), seq_y, seq_z);
- //clog << "drawing " << seq_x << " " << seq_y << " " << seq.size()
- // << std::endl;
- glEnd();
+ draw_box(seq_x, seq_x+seq.size(), seq_height, 0.0);
}
void GlSequence::draw_annotations(GLfloat left, GLfloat right) const
{
// draw annotations
+ glLineWidth(seq_height);
GLfloat annotation_z = seq_z + 1.0;
std::list<annot> annots = seq.annotations();
for (std::list<annot>::const_iterator annot_itor = annots.begin();
++annot_itor, ++annotation_z)
{
glColor3f(0.0, 0.5, 0.0);
- glBegin(GL_LINES);
- glVertex3f(annot_itor->start, seq_y, annotation_z);
- glVertex3f(annot_itor->end , seq_y, annotation_z);
- glEnd();
+ draw_box(seq_x+annot_itor->start, seq_x+annot_itor->end,
+ seq_height, annotation_z);
}
}
} CP;
CP Adata[] = {
- {0, 0, PT}, {0, 9, PT}, {1, 10, PT}, {4, 10, PT},
- {5, 9, PT}, {5, 0, STROKE}, {0, 5, PT}, {5, 5, END}
+ {0, -5, PT}, {2.5, 5, PT}, {5, -5, STROKE},
+ {0.75, -2, PT}, {4.25, -2, END}
};
CP Tdata[] = {
- {2.5, 0, PT}, {2.5,10, STROKE}, {0, 10, PT}, {5,10, END}
+ {2.5, -5, PT}, {2.5,5, STROKE}, {0, 5, PT}, {5, 5, END}
};
CP Gdata[] = {
- {5, 9, PT}, {4, 10, PT}, {1, 10, PT}, {0, 9, PT}, {0, 1, PT},
- {1, 0, PT}, {5, 0, PT}, {5, 4, PT}, {3.5, 4, END}
+ {5, 3, PT}, {3, 5, PT}, {2, 5, PT}, {0, 3, PT}, {0, -3, PT},
+ {2, -5, PT}, {3, -5, PT}, {5, -3, STROKE},
+ {2.5, -1, PT}, {5, -1,PT}, {5, -5, END}
};
CP Cdata[] = {
- {5, 8, PT}, {3, 10, PT}, {2, 10, PT}, {0, 8, PT}, {0, 2, PT},
- {2, 0, PT}, {3, 0, PT}, {5, 2, END}
+ {4.9, 3, PT}, {3, 5, PT}, {2, 5, PT}, {0, 3, PT}, {0, -3, PT},
+ {2, -5, PT}, {3, -5, PT}, {5, -3, END}
};
-CP Xdata[] = {{ 0, 10, PT}, {5,0,STROKE},{0,0,PT},{5,10,END}};
-CP Ndata[] = {{ 0, 0, PT}, {0, 10, PT}, {5, 0, PT}, {5, 10, END}};
+CP Xdata[] = {{ 0, 5, PT}, {5, -5,STROKE},{0,-5,PT},{5, 5, END}};
+CP Ndata[] = {{ 0, -5, PT}, {0, 5, PT}, {5, -5, PT}, {5, 5, END}};
-static void drawLetter(CP *l)
+static void drawLetter(CP *l, GLfloat z)
{
glBegin(GL_LINE_STRIP);
while(1) {
switch (l->type) {
case PT:
- glVertex2fv(&l->x);
+ glVertex3f(l->x, l->y, z);
break;
case STROKE:
- glVertex2fv(&l->x);
+ glVertex3f(l->x, l->y, z);
glEnd();
glBegin(GL_LINE_STRIP);
break;
case END:
- glVertex2fv(&l->x);
+ glVertex3f(l->x, l->y, z);
glEnd();
return;
break;
void GlSequence::draw_sequence(GLfloat left, GLfloat right) const
{
- glLineWidth(0.1);
+ // FIXME: basically this needs to be greater than the number of annotations
+ const GLfloat z = 30;
+ glLineWidth(0.3);
glColor3fv(drawColor.get());
Sequence::const_iterator seq_itor = sequence_begin(left, right);
glScalef(0.1, 1.0, 1.0);
switch (*seq_itor) {
case 'A': case 'a':
- drawLetter(Adata);
+ drawLetter(Adata, z);
break;
case 'T': case 't':
- drawLetter(Tdata);
+ drawLetter(Tdata, z);
break;
case 'G': case 'g':
- drawLetter(Gdata);
+ drawLetter(Gdata, z);
break;
case 'C': case 'c':
- drawLetter(Cdata);
+ drawLetter(Cdata, z);
break;
case 'N': case 'n':
- drawLetter(Ndata);
+ drawLetter(Ndata, z);
break;
default:
- drawLetter(Xdata);
+ drawLetter(Xdata, z);
break;
}
glPopMatrix();