GlSequence::GlSequence(const Sequence &s)
: seq(s),
- seq_x(0),
- seq_y(0),
- seq_z(0),
+ seq_x(0.0),
+ seq_y(0.0),
+ seq_z(1.0),
seq_width(s.size()),
seq_height(gl_track_height)
{
<< std::endl;
glEnd();
// draw annotations
+ 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 != annots.end();
- ++annot_itor)
+ ++annot_itor, ++annotation_z)
{
glColor3f(0.0, 0.5, 0.0);
glBegin(GL_LINES);
- glVertex3f(annot_itor->start, seq_y, seq_z);
- glVertex3f(annot_itor->end , seq_y, seq_z);
+ glVertex3f(annot_itor->start, seq_y, annotation_z);
+ glVertex3f(annot_itor->end , seq_y, annotation_z);
glEnd();
}
}
void PathScene::initializeGL()
{
- glEnable(GL_DEPTH_TEST|GL_BLEND);
+ glEnable(GL_DEPTH_TEST);
glClearColor(1.0, 1.0, 1.0, 0.0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glShadeModel(GL_FLAT);
- glLoadIdentity();
- glPushMatrix();
}
void PathScene::resizeGL(int width, int height)
glOrtho(curOrtho2d.left(), curOrtho2d.right(),
curOrtho2d.top(), curOrtho2d.bottom(),
-50.0, clipZ);
- glMatrixMode(GL_MODELVIEW);
}
void PathScene::paintGL()
curOrtho2d.top(), curOrtho2d.bottom(),
-50.0, clipZ);
glMatrixMode(GL_MODELVIEW);
+ mussaesque();
+ glEnable(GL_BLEND);
+ glDepthMask(GL_FALSE);
if (debugBand && !drawingBand) {
glColor4f(0.4, 0.4, 0.4, 0.9);
glRectf(previousBand.x(), previousBand.y(),
previousBand.right(), previousBand.bottom());
}
- glTranslatef(-X*1000, 0.0, 0.0);
- mussaesque();
-
+ glDepthMask(GL_TRUE);
+ glDisable(GL_BLEND);
glPopMatrix();
glFlush();
}
void PathScene::draw_lines() const
{
GLfloat x;
- GLfloat y;
+ GLfloat y;
+ bool reversed = false;
+ bool prevReversed = false;
const Nway_Paths& nway = mussaAnalysis.paths();
- glLineWidth(0.1);
- glColor3f(0.9, 0.0, 0.0);
+ glLineWidth(0.5);
vector<GlSequence>::const_iterator track_itor;
- // To use the refined_pathz, change pathz to refined_pathz, and
- // change path_itor->begin() to path_itor->begin()+1
- for(list<vector<int> >::const_iterator path_itor = nway.pathz.begin();
- path_itor != nway.pathz.end();
+ for(list<vector<int> >::const_iterator path_itor = nway.refined_pathz.begin();
+ path_itor != nway.refined_pathz.end();
++path_itor)
{
track_itor = tracks.begin();
+ vector<int>::const_iterator sp_itor = path_itor->begin();
+ // since we were drawing to the start of a window, and opengl lines
+ // are centered around the two connecting points our lines were slightly
+ // offset. the idea of window_offset is to adjust them to the
+ // right for forward compliment or left for reverse compliment
+ // FIXME: figure out how to unit test these computations
+ GLfloat window_offset = (*sp_itor)/2.0;
+ sp_itor++;
+
glBegin(GL_LINE_STRIP);
- for (vector<int>::const_iterator sp_itor = path_itor->begin();
+ for (;
sp_itor != path_itor->end();
++sp_itor, ++track_itor)
{
y = track_itor->y();
// at some point when we modify the pathz data structure to keep
// track of the score we can put grab the depth here.
- if (x >= 0) {
- glColor3f(0.9, 0.0, 0.0);
+ //
+ // are we reverse complimented?
+ if ( x>=0) {
+ reversed = false;
} else {
- x *= -1;
- glColor3f(0.0, 0.0, 0.9);
+ reversed = true;
+ x = -x; // make positive
}
- glVertex3f(x, y, -1.0);
+ if (!reversed)
+ x += window_offset; // move right for forward compliment
+ else
+ x -= window_offset; // move left for reverse compliment
+ // the following boolean implements logical xor
+ if ( (reversed || prevReversed) && (!reversed || !prevReversed)) {
+ // we have a different orientation
+ glColor3f(0.0, 0.0, 0.8);
+ } else {
+ // both current and previous path have the same orientation
+ glColor3f(0.8, 0.0, 0.0);
+ }
+ prevReversed = reversed;
+ glVertex3f(x, y, 0.0);
}
glEnd();
}
void PathScene::mussaesque()
{
- //static GLuint theLines = make_line_list();
+ static GLuint theLines = make_line_list();
glInitNames();
- glPushName(0);
+ glPushName(10);
+ glCallList(theLines);
+ //draw_lines();
+ glLoadName(0);
draw_tracks();
- glLoadName(10);
- //glCallList(theLines);
- draw_lines();
glPopName();
}