]> git.donarmstrong.com Git - biopieces.git/blob - www/index.cgi
38957c3761bd51aba0e3dc4cf186cb64d1dc2a66
[biopieces.git] / www / index.cgi
1 #!/usr/bin/env perl
2
3 # Copyright (C) 2006-2009 Martin A. Hansen.
4
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 # http://www.gnu.org/copyleft/gpl.html
20
21 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
22
23 use strict;
24 use warnings;
25
26 use lib $ENV{ 'BP_PERL' };
27
28 use CGI;
29 use Data::Dumper;
30 use Maasha::Common;
31 use Maasha::Filesys;
32 use Maasha::Calc;
33 use Maasha::XHTML;
34 use Maasha::KISS;
35 use Maasha::BBrowser::Track;
36 use Maasha::BBrowser::Draw;
37
38 my ( $cgi, $cookie, @html );
39
40 $cgi    = new CGI;
41 $cookie = cookie_default( $cgi );;
42
43 push @html, Maasha::XHTML::html_header(
44     cgi_header  => 1,
45     title       => "Biopieces Genome Browser",
46     css_file    => "bgb.css",
47     author      => "Martin A. Hansen, mail\@maasha.dk",
48     description => "Biopieces Genome Browser",
49     keywords    => [ qw( Biopieces biopiece genome browser viewer bacterium bacteria prokaryote prokaryotes ) ],
50     no_cache    => 1,
51 );
52
53 push @html, Maasha::XHTML::h1( txt => "Biopieces Genome Browser", class => 'center' );
54 push @html, Maasha::XHTML::form_beg( action => $cookie->{ 'SCRIPT' }, method => "get", enctype => "multipart/form-data" );
55
56 push @html, page( $cookie );
57
58 push @html, Maasha::XHTML::form_end;
59 push @html, Maasha::XHTML::body_end;
60 push @html, Maasha::XHTML::html_end;
61
62 # push @html, Maasha::XHTML::hdump( $cgi->param );  # DEBUG
63 # push @html, Maasha::XHTML::hdump( $cookie );      # DEBUG
64
65 print "$_\n" foreach @html;
66
67
68 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SUBROUTINES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
69
70
71 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> COOKIE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
72
73
74 sub cookie_default
75 {
76     # Martin A. Hansen, November 2009.
77
78     # Set a cookie with values from the CGI object or defaults.
79
80     my ( $cgi,   # CGI object
81        ) = @_;
82
83     # Returns a hash.
84
85     my ( $cookie, $path );
86
87     $cookie = {};
88
89     $cookie->{ 'SCRIPT' }          = Maasha::Common::get_scriptname();
90     $cookie->{ 'DATA_DIR' }        = "Data";
91     $cookie->{ 'LIST_PAGES' }      = [ qw( user clade genome assembly contig browse ) ];
92     $cookie->{ 'PAGE' }            = $cgi->param( 'page' )     || 'user';
93     $cookie->{ 'USER' }            = $cgi->param( 'user' )     || '';
94     $cookie->{ 'CLADE' }           = $cgi->param( 'clade' )    || '';
95     $cookie->{ 'GENOME' }          = $cgi->param( 'genome' )   || '';
96     $cookie->{ 'ASSEMBLY' }        = $cgi->param( 'assembly' ) || '';
97     $cookie->{ 'CONTIG' }          = $cgi->param( 'contig' )   || '';
98     $cookie->{ 'NAV_START' }       = $cgi->param( 'nav_start' );
99     $cookie->{ 'NAV_END' }         = $cgi->param( 'nav_end' );
100     $cookie->{ 'ZOOM_IN1' }        = $cgi->param( 'zoom_in1' );
101     $cookie->{ 'ZOOM_IN2' }        = $cgi->param( 'zoom_in2' );
102     $cookie->{ 'ZOOM_IN3' }        = $cgi->param( 'zoom_in3' );
103     $cookie->{ 'ZOOM_OUT1' }       = $cgi->param( 'zoom_out1' );
104     $cookie->{ 'ZOOM_OUT2' }       = $cgi->param( 'zoom_out2' );
105     $cookie->{ 'ZOOM_OUT3' }       = $cgi->param( 'zoom_out3' );
106     $cookie->{ 'MOVE_LEFT1' }      = $cgi->param( 'move_left1' );
107     $cookie->{ 'MOVE_LEFT2' }      = $cgi->param( 'move_left2' );
108     $cookie->{ 'MOVE_LEFT3' }      = $cgi->param( 'move_left3' );
109     $cookie->{ 'MOVE_RIGHT1' }     = $cgi->param( 'move_right1' );
110     $cookie->{ 'MOVE_RIGHT2' }     = $cgi->param( 'move_right2' );
111     $cookie->{ 'MOVE_RIGHT3' }     = $cgi->param( 'move_right3' );
112
113     $cookie->{ 'IMG_WIDTH' }       = 1200;
114     $cookie->{ 'IMG_HEIGHT' }      = 800;
115     $cookie->{ 'TRACK_OFFSET' }    = 20;
116     $cookie->{ 'TRACK_SPACE' }     = 20;
117     $cookie->{ 'RULER_FONT_SIZE' } = 10;
118     $cookie->{ 'RULER_COLOR' }     = [ 0, 0, 0 ];
119     $cookie->{ 'SEQ_FONT_SIZE' }   = 10;
120     $cookie->{ 'SEQ_COLOR' }       = [ 0, 0, 0, ];
121     $cookie->{ 'FEAT_WIDTH' }      = 5;
122     $cookie->{ 'FEAT_COLOR' }      = [ 0, 0, 0 ];
123     $cookie->{ 'FEAT_MAX' }        = 5000;
124
125     $path = "$cookie->{ 'DATA_DIR' }/Users";
126
127     $cookie->{ 'LIST_USER' }       = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
128
129     $path .= "/$cookie->{ 'USER' }";
130
131     $cookie->{ 'LIST_CLADE' }      = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
132
133     $path .= "/$cookie->{ 'CLADE' }";
134
135     $cookie->{ 'LIST_GENOME' }     = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
136
137     $path .= "/$cookie->{ 'GENOME' }";
138
139     $cookie->{ 'LIST_ASSEMBLY' }   = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
140
141     $path .= "/$cookie->{ 'ASSEMBLY' }";
142
143     $cookie->{ 'LIST_CONTIG' }     = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
144
145     if ( $cookie->{ 'CONTIG' } )
146     {
147         cookie_start( $cookie );
148         cookie_end( $cookie );
149         cookie_zoom( $cookie );
150         cookie_move( $cookie );
151     }
152
153     return wantarray ? %{ $cookie } : $cookie;
154 }
155
156
157 sub cookie_start
158 {
159     # Martin A. Hansen, November 2009.
160
161     # Decommify the cookie value for NAV_START and adjust it to
162     # to prevent negative values.
163
164     my ( $cookie,   # cookie hash
165        ) = @_;
166
167     # Returns nothing.
168
169     if ( defined $cookie->{ 'NAV_START' } )
170     {
171         $cookie->{ 'NAV_START' } =~ tr/,//d;
172         $cookie->{ 'NAV_START' } = 1 if $cookie->{ 'NAV_START' } <= 0;
173     }
174     else
175     {
176         $cookie->{ 'NAV_START' } = 1;
177     }
178 }
179
180
181 sub cookie_end
182 {
183     # Martin A. Hansen, November 2009.
184
185     # Decommify the cookie value for NAV_END and adjust it to prevent
186     # overshooting the max value for the contig size as determined
187     # from the cookie.
188
189     my ( $cookie,   # cookie hash
190        ) = @_;
191
192     # Returns nothing.
193
194     my ( $max );
195     
196     $max = Maasha::Filesys::file_size( Maasha::BBrowser::Track::path_seq( $cookie ) );
197
198     if ( defined $cookie->{ 'NAV_END' } )
199     {
200         $cookie->{ 'NAV_END' } =~ tr/,//d;
201         $cookie->{ 'NAV_END' } = $max if $cookie->{ 'NAV_END' } > $max;
202     }
203     else
204     {
205         $cookie->{ 'NAV_END' } = $max;
206     }
207 }
208
209
210 sub cookie_zoom
211 {
212     # Martin A. Hansen, November 2009.
213
214     # Adjust the cookie values for NAV_START and NAV_END based
215     # on cookie ZOOM values.
216
217     my ( $cookie,   # cookie hash
218        ) = @_;
219
220     # Returns nothing.
221
222     my ( $max, $dist, $new_dist, $dist_diff );
223
224     $max = Maasha::Filesys::file_size( Maasha::BBrowser::Track::path_seq( $cookie ) );
225
226     $dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' };
227
228     if ( defined $cookie->{ 'ZOOM_IN1' } ) {
229         $new_dist = $dist / 1.5;
230     } elsif ( defined $cookie->{ 'ZOOM_IN2' } ) {
231         $new_dist = $dist / 3;
232     } elsif ( defined $cookie->{ 'ZOOM_IN3' } ) {
233         $new_dist = $dist / 10;
234     } elsif ( defined $cookie->{ 'ZOOM_OUT1' } ) {
235         $new_dist = $dist * 1.5;
236     } elsif ( defined $cookie->{ 'ZOOM_OUT2' } ) {
237         $new_dist = $dist * 3;
238     } elsif ( defined $cookie->{ 'ZOOM_OUT3' } ) {
239         $new_dist = $dist * 10;
240     }
241
242     if ( $new_dist )
243     {
244         $dist_diff = $dist - $new_dist;
245
246         $cookie->{ 'NAV_START' } = int( $cookie->{ 'NAV_START' } + ( $dist_diff / 2 ) );
247         $cookie->{ 'NAV_END' }   = int( $cookie->{ 'NAV_END' }   - ( $dist_diff / 2 ) );
248
249         $cookie->{ 'NAV_START' } = 1     if $cookie->{ 'NAV_START' } <= 0;
250         $cookie->{ 'NAV_END' }   = $max if $cookie->{ 'NAV_END' } > $max;
251     }
252 }
253
254
255 sub cookie_move
256 {
257     # Martin A. Hansen, November 2009.
258
259     # Adjust the cookie values for NAV_START and NAV_END based
260     # on cookie MOVE values.
261
262     my ( $cookie,   # cookie hash
263        ) = @_;
264
265     my ( $max, $dist, $shift, $new_start, $new_end );
266
267     $max = Maasha::Filesys::file_size( Maasha::BBrowser::Track::path_seq( $cookie ) );
268
269     $dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' };
270
271     if ( defined $cookie->{ 'MOVE_LEFT1' } ) {
272         $shift = -1 * $dist * 0.10;
273     } elsif ( defined $cookie->{ 'MOVE_LEFT2' } ) {
274         $shift = -1 * $dist * 0.475;
275     } elsif ( defined $cookie->{ 'MOVE_LEFT3' } ) {
276         $shift = -1 * $dist * 0.95;
277     } elsif ( defined $cookie->{ 'MOVE_RIGHT1' } ) {
278         $shift = $dist * 0.10;
279     } elsif ( defined $cookie->{ 'MOVE_RIGHT2' } ) {
280         $shift = $dist * 0.475;
281     } elsif ( defined $cookie->{ 'MOVE_RIGHT3' } ) {
282         $shift = $dist * 0.95;
283     }
284
285     if ( $shift )
286     {
287         $new_start = int( $cookie->{ 'NAV_START' } + $shift );
288         $new_end   = int( $cookie->{ 'NAV_END' }   + $shift );
289
290         if ( $new_start > 0 and $new_end < $max )
291         {
292             $cookie->{ 'NAV_START' } = $new_start;
293             $cookie->{ 'NAV_END' }   = $new_end;
294         }
295     }
296 }
297
298
299 sub cookie_href
300 {
301     # Martin A. Hansen, November 2009.
302
303     # Returns the href for a taxonomy path terminated at a given
304     # page using information stored in a cookie.
305
306     my ( $cookie,   # cookie hash
307          $page,     # page
308        ) = @_;
309
310     # Returns a string.
311
312     my ( @href );
313
314     while ( 1 )
315     {
316         push @href, "$cookie->{ 'SCRIPT' }?page=$page";
317         push @href, "user=$cookie->{ 'USER' }"         if $cookie->{ 'USER' };
318         last if $page eq 'user';
319         push @href, "clade=$cookie->{ 'CLADE' }"       if $cookie->{ 'CLADE' };
320         last if $page eq 'clade';
321         push @href, "genome=$cookie->{ 'GENOME' }"     if $cookie->{ 'GENOME' };
322         last if $page eq 'genome';
323         push @href, "assembly=$cookie->{ 'ASSEMBLY' }" if $cookie->{ 'ASSEMBLY' };
324         last if $page eq 'assembly';
325         push @href, "contig=$cookie->{ 'CONTIG' }"     if $cookie->{ 'CONTIG' };
326         last if $page eq 'contig';
327         last;
328     }
329
330     return join "&", @href;
331 }
332
333
334 sub cookie_page_next
335 {
336     # Martin A. Hansen, November 2009.
337     
338     # Returns the next page in the taxonomy path.
339
340     my ( $cookie,   # cookie hash
341        ) = @_;
342
343     # Returns a string.
344
345     my ( $i );
346
347     for ( $i = 0; $i < @{ $cookie->{ 'LIST_PAGES' } }; $i++ ) {
348         last if $cookie->{ 'PAGE' } eq $cookie->{ 'LIST_PAGES' }->[ $i ];
349     }
350
351     return $cookie->{ 'LIST_PAGES' }->[ $i + 1 ];
352 }
353
354
355 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PAGES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
356
357
358 sub page
359 {
360     # Martin A. Hansen, November 2009.
361
362     # Determines what page to render based on
363     # the cookie's PAGE setting.
364
365     my ( $cookie,   # cookie hash
366        ) = @_;
367
368     # Returns a list.
369
370     my ( @html );
371
372     if ( $cookie->{ 'PAGE' } eq 'export' ) {
373         push @html, page_export( $cookie );
374     } elsif ( $cookie->{ 'PAGE' } eq 'browse' ) {
375         push @html, page_browse( $cookie );
376     } else {
377         push @html, page_taxonomy( $cookie );
378     }
379
380     return wantarray ? @html : \@html;
381 }
382
383
384 sub page_export
385 {
386     # Martin A. Hansen, November 2009.
387
388     # Renders the export page.
389
390     my ( $cookie,
391        ) = @_;
392
393     # Returns a list.
394
395     my ( @html );
396
397     push @html, section_taxonomy_table( $cookie );
398     push @html, section_export( $cookie );
399
400     return wantarray ? @html : \@html;
401 }
402
403
404 sub page_browse
405 {
406     # Martin A. Hansen, November 2009.
407     
408     # Renders the browse page.
409
410     my ( $cookie,
411        ) = @_;
412
413     # Returns a list.
414
415     my ( @html );
416
417     push @html, section_taxonomy_table( $cookie );
418     push @html, section_navigate( $cookie );
419     push @html, section_browse( $cookie );
420
421     return wantarray ? @html : \@html;
422 }
423
424
425 sub page_taxonomy
426 {
427     # Martin A. Hansen, November 2009.
428     
429     # Renders the browse page.
430
431     my ( $cookie,   # cookie hash
432        ) = @_;
433
434     # Returns a list.
435
436     my ( @html );
437
438     push @html, section_taxonomy_table( $cookie );
439     push @html, section_taxonomy_select( $cookie );
440
441     return wantarray ? @html : \@html;
442 }
443
444
445 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SECTIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
446
447
448 sub section_taxonomy_table
449 {
450     # Martin A. Hansen, November 2009.
451
452     # Returns a HTML section with a taxonomy table
453     # showing the location in the taxonomy and with
454     # links to browse the taxonomy.
455
456     my ( $cookie,   # cookie hash
457        ) = @_;
458
459     # Returns a list.
460
461     my ( $page, @row, @html, $href, $txt );
462     
463     foreach $page ( @{ $cookie->{ 'LIST_PAGES' } } )
464     {
465         last if $page eq $cookie->{ 'PAGE' } or $page eq 'browse';
466
467         $href = cookie_href( $cookie, $page );
468
469         $txt = ": $cookie->{ uc $page }";
470
471         push @row, Maasha::XHTML::ln( txt => $page, href => $href, class => 'inline' );
472         push @row, Maasha::XHTML::p(  txt => $txt, class => 'inline' );
473     }
474
475     push @html, Maasha::XHTML::table_beg( summary => "Taxonomy table", align => 'center', cellpadding => '5px' );
476     push @html, Maasha::XHTML::table_row_simple( tr => [ join( " ", @row ) ], align => 'center' );
477     push @html, Maasha::XHTML::table_end;
478
479     return wantarray ? @html : \@html;
480 }
481
482
483 sub section_taxonomy_select
484 {
485     # Martin A. Hansen, November 2009.
486     
487     # Returns a HTML section with selection choices
488     # for navigating the taxonomy tree.
489
490     my ( $cookie,   # cookie hash
491        ) = @_;
492
493     # Returns a list.
494
495     my ( $list, @html, $item, $href );
496
497     $list = "LIST_" . uc $cookie->{ 'PAGE' };
498
499     push @html, Maasha::XHTML::h2( txt => "Select $cookie->{ 'PAGE' }", class => 'center' );
500
501     push @html, Maasha::XHTML::table_beg( summary => "Select table", align => 'center', cellpadding => '5px' );
502
503     foreach $item ( @{ $cookie->{ $list } } )
504     {
505         $cookie->{ uc $cookie->{ 'PAGE' } } = $item;
506
507         $href = cookie_href( $cookie, cookie_page_next( $cookie ) );
508
509         push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $item, href => $href ) ] );
510     }
511
512     push @html, Maasha::XHTML::table_end;
513
514     return wantarray ? @html : \@html;
515 }
516
517
518 sub section_navigate
519 {
520     # Martin A. Hansen, November 2009.
521
522     # Returns a HTML section for navigating in the browser window.
523
524     my ( $cookie,   # cookie hash
525        ) = @_;
526
527     # Returns a list.
528
529     my ( @html );
530
531     push @html, Maasha::XHTML::table_beg( summary => "Navigation table", align => 'center' );
532     push @html, Maasha::XHTML::table_row_simple( tr => [
533         "Start:",
534         Maasha::XHTML::text( name => "nav_start", value => Maasha::Calc::commify( $cookie->{ 'NAV_START' } ), size => 20 ),
535         "End:",
536         Maasha::XHTML::text( name => "nav_end",   value => Maasha::Calc::commify( $cookie->{ 'NAV_END' } ),   size => 20 ), 
537         Maasha::XHTML::submit( name => "nav_submit", value => "Submit" ),
538     ] );
539     push @html, Maasha::XHTML::table_end;
540
541     push @html, Maasha::XHTML::table_beg( summary => "Zoom table", align => 'center' );
542     push @html, Maasha::XHTML::table_row_simple( tr => [
543         Maasha::XHTML::p( txt => 'Move:' ),
544         Maasha::XHTML::submit( name => "move_left3",  value => "<<<", title => "move 95% to the left" ),
545         Maasha::XHTML::submit( name => "move_left2",  value => "<<",  title => "move 47.5% to the left" ),
546         Maasha::XHTML::submit( name => "move_left1",  value => "<",   title => "move 10% to the left" ),
547         Maasha::XHTML::submit( name => "move_right1", value => ">",   title => "move 10% to the rigth" ),
548         Maasha::XHTML::submit( name => "move_right2", value => ">>",  title => "move 47.5% to the rigth" ),
549         Maasha::XHTML::submit( name => "move_right3", value => ">>>", title => "move 95% to the right" ),
550         Maasha::XHTML::p( txt => 'Zoom in:' ),
551         Maasha::XHTML::submit( name => "zoom_in1", value => "1.5x" ),
552         Maasha::XHTML::submit( name => "zoom_in2", value => "3x" ),
553         Maasha::XHTML::submit( name => "zoom_in3", value => "10x" ),
554         Maasha::XHTML::p( txt => 'Zoom out:' ),
555         Maasha::XHTML::submit( name => "zoom_out1", value => "1.5x" ),
556         Maasha::XHTML::submit( name => "zoom_out2", value => "3x" ),
557         Maasha::XHTML::submit( name => "zoom_out3", value => "10x" ),
558     ] );
559     push @html, Maasha::XHTML::table_end;
560
561     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "page",     value => "browse" ) );
562     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "user",     value => "$cookie->{ 'USER' }" ) );
563     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "clade",    value => "$cookie->{ 'CLADE' }" ) );
564     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "genome",   value => "$cookie->{ 'GENOME' }" ) );
565     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "assembly", value => "$cookie->{ 'ASSEMBLY' }" ) );
566     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "contig",   value => "$cookie->{ 'CONTIG' }" ) );
567
568     return wantarray ? @html : \@html;
569 }
570
571
572 sub section_browse
573 {
574     my ( $cookie,
575        ) = @_;
576
577     # Returns a list.
578
579     my ( @tracks, $i, @features, $feat, $elem, $file, $surface, $cr, @html, @img );
580
581     push @features, [ Maasha::BBrowser::Track::track_ruler( $cookie ) ];
582     push @features, [ Maasha::BBrowser::Track::track_seq( $cookie ) ];
583
584     @tracks = Maasha::BBrowser::Track::path_tracks( $cookie );
585
586     for ( $i = 0; $i < @tracks; $i++ )
587     {
588         $cookie->{ 'FEAT_COLOR' } = Maasha::BBrowser::Draw::palette( $i );
589
590         push @features, [ Maasha::BBrowser::Track::track_feature( $tracks[ $i ], $cookie ) ];
591     }
592
593     $file = "fisk.png";   # FIXME
594
595     $surface = Cairo::ImageSurface->create( 'argb32', $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' } );
596     $cr      = Cairo::Context->create( $surface );
597
598     $cr->rectangle (0, 0, $cookie->{ 'IMG_WIDTH' },  $cookie->{ 'TRACK_OFFSET' } );
599     $cr->set_source_rgb (1, 1, 1);
600     $cr->fill;
601
602     foreach $feat ( @features ) {
603         Maasha::BBrowser::Draw::draw_feature( $cr, $feat ) if $feat;
604     }
605
606     Maasha::BBrowser::Draw::file_png( $surface, $file );
607
608     push @img, Maasha::XHTML::img(
609         src    => $file,
610         alt    => "Browser Tracks",
611         height => $cookie->{ 'TRACK_OFFSET' },
612         width  => $cookie->{ 'IMG_WIDTH' },
613         id     => "browser_map",
614         usemap => "#browser_map"
615     );
616
617     push @img, Maasha::XHTML::map_beg( name => "browser_map", id => "browser_map" );
618
619     foreach $feat ( @features )
620     {
621         foreach $elem ( @{ $feat } )
622         {
623             next if $elem->{ 'type' } eq 'text';
624
625             push @img, Maasha::XHTML::area(
626                 href   => cookie_href( $cookie, "export" ) . "&Q_ID=$elem->{ 'id' }",
627                 shape  => "rect",
628                 coords => "$elem->{ x1 }, $elem->{ y1 }, $elem->{ x2 }, $elem->{ y2 }", title => "$elem->{ 'title' }",
629             );
630         }
631     }
632
633     push @img, Maasha::XHTML::map_end();
634
635     push @html, Maasha::XHTML::p( txt => join( "\n", @img ) );
636
637     @html = Maasha::XHTML::div( txt => join( "\n", @html ), class => 'browse' );
638
639     return wantarray ? @html : \@html;
640 }
641
642
643 sub section_export
644 {
645     # Martin A. Hansen, November 2009.
646
647     # Returns a HTML section with export table.
648
649     my ( $cookie,   # cookie hash
650        ) = @_;
651
652     # Returns a list.
653
654     my ( @html );
655
656     push @html, Maasha::XHTML::h2( txt => "Export", class => 'center' );   # TODO section_export!
657
658     return wantarray ? @html : \@html;
659 }
660
661
662 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
663
664
665 __END__