length 1 segments should be drawn as lines
[mussa.git] / alg / glseqbrowser.cpp
index e82cfe1f48fab2cd13fb3f82dba47e6d62bef5f9..79acb4068c64fd224def7b6f06dc93ee11bacdba 100644 (file)
@@ -695,24 +695,30 @@ void GlSeqBrowser::draw_segments() const
                         + track_container[path_index]->x();
       float seq_end_x = s.end.x
                       + track_container[path_index+1]->x();
-      // add in length
-      float seq_start_x_length = s.start.x 
+      if (s.length <= 1) {
+        // use lines for elements of length <=1.
+        // and try to center the line
+        const float offset = 0.5;
+        glBegin(GL_LINES);
+          glVertex3f(seq_start_x+offset, s.start.y, -1);
+          glVertex3f(seq_end_x  +offset, s.end.y, -1);
+        glEnd();
+      } else {
+        // otherwise use quads
+        // compute length
+        float seq_start_x_length = s.start.x 
+                                 + s.length
+                                 + track_container[path_index]->x();
+        float seq_end_x_length = s.end.x
                                + s.length
-                               + track_container[path_index]->x();
-      float seq_end_x_length = s.end.x
-                             + s.length
-                             + track_container[path_index+1]->x();
-      //glBegin(GL_LINES);
-      //  glVertex3f(seq_start_x, s.start.y, -1);
-      //  glVertex3f(seq_end_x  , s.end.y, -1);
-      //glEnd();
-      
-      glBegin(GL_QUADS);
-        glVertex3f(seq_start_x, s.start.y, zdepth);
-        glVertex3f(seq_end_x, s.end.y, zdepth);
-        glVertex3f(seq_end_x_length, s.end.y, zdepth);
-        glVertex3f(seq_start_x_length, s.start.y, zdepth);
-      glEnd();      
+                               + track_container[path_index+1]->x();
+        glBegin(GL_QUADS);
+          glVertex3f(seq_start_x, s.start.y, zdepth);
+          glVertex3f(seq_end_x, s.end.y, zdepth);
+          glVertex3f(seq_end_x_length, s.end.y, zdepth);
+          glVertex3f(seq_start_x_length, s.start.y, zdepth);
+        glEnd();
+      }      
       // clear the names
       glPopName(); glPopName(); glPopName();
     }