]> git.donarmstrong.com Git - biopieces.git/commitdiff
added grid to BGB
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 19 Mar 2010 08:48:07 +0000 (08:48 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 19 Mar 2010 08:48:07 +0000 (08:48 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@934 74ccb610-7750-0410-82ae-013aeee3265d

code_perl/Maasha/BGB/Draw.pm
code_perl/Maasha/BGB/Track.pm
www/index.cgi

index 7cfe938ce3ac5f814ca2bd78c050ff91fedb2ff8..1a76cd5620c8a8f4a0d5dada62e7f8309dfa6466 100644 (file)
@@ -71,6 +71,12 @@ sub draw_feature
             $cr->move_to( $feature->{ 'x1' }, $feature->{ 'y1' } );
             $cr->line_to( $feature->{ 'x2' }, $feature->{ 'y2' } );
         }
+        elsif ( $feature->{ 'type' } eq 'grid' )
+        {
+            $cr->set_line_width( $feature->{ 'line_width' } );
+            $cr->move_to( $feature->{ 'x1' }, $feature->{ 'y1' } );
+            $cr->line_to( $feature->{ 'x2' }, $feature->{ 'y2' } );
+        }
         elsif ( $feature->{ 'type' } eq 'wiggle' )
         {
             $cr->set_line_width( $feature->{ 'line_width' } );
index e007f68c1d8a43f86d28199161a4a090743c0faf..75ba5526fcff1e0769e3d11a3783120117660654 100644 (file)
@@ -61,6 +61,36 @@ use constant {
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
+sub track_grid
+{
+    # Martin A. Hansen, March 2010.
+    # Create a grid of vertical lines for the browser image.
+
+    my ( $cookie,   # browser cookie
+       ) = @_;
+
+    # Returns a list.
+
+    my ( @grid, $i );
+
+    for ( $i = 0; $i < $cookie->{ 'IMG_WIDTH' }; $i += 20 )
+    {
+        push @grid, {
+            type       => 'grid',
+            line_width => 0.1,
+            color      => [ 0, 0, 0 ],
+            x1         => $i,
+            y1         => 0,
+            x2         => $i,
+            y2         => $cookie->{ 'TRACK_OFFSET' },
+        };
+    }
+
+    return wantarray ? @grid : \@grid;
+}
+
+
 sub track_ruler
 {
     # Martin A. Hansen, November 2009.
index 85fed675115605e54c0fb8079670cc938fd8bfaf..38b1988af96addb41c9096f340b102c7874d6bc5 100755 (executable)
@@ -165,7 +165,7 @@ sub cookie_default
     $cookie->{ 'MOVE_RIGHT3' }     = $cgi->param( 'move_right3' );
 
     $cookie->{ 'IMG_WIDTH' }       = 1200;   # Width of browser image in pixels
-    $cookie->{ 'IMG_HEIGHT' }      = 800;    # Height of browser image in pixels
+    $cookie->{ 'IMG_HEIGHT' }      = 800;    # Height of browser image in pixels  # TODO: Redundant?
     $cookie->{ 'WIGGLE_HEIGHT' }   = 75;     # Height of Wiggle tracks in pixels
     $cookie->{ 'TRACK_OFFSET' }    = 20;
     $cookie->{ 'TRACK_SPACE' }     = 20;
@@ -1123,6 +1123,8 @@ sub section_browse
         push @tracks, [ Maasha::BGB::Track::track_feature( $track_list[ $i ], $cookie ) ];
     }
 
+    unshift @tracks, [ Maasha::BGB::Track::track_grid( $cookie ) ];
+
     $surface = Cairo::ImageSurface->create( 'argb32', $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' } );
     $cr      = Cairo::Context->create( $surface );
 
@@ -1180,7 +1182,7 @@ sub section_browse
     {
         foreach $elem ( @{ $track } )
         {
-            next if $elem->{ 'type' } =~ /text|wiggle/;
+            next if $elem->{ 'type' } =~ /grid|text|wiggle/;
 
             if ( $elem->{ 'type' } eq 'track_name' )
             {