]> git.donarmstrong.com Git - biopieces.git/blob - www/index.cgi
cleaned BBrowser::Tracks.pm
[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     push @html, section_taxonomy_table( $cookie );
396     push @html, section_export( $cookie );
397
398     return wantarray ? @html : \@html;
399 }
400
401
402 sub page_browse
403 {
404     # Martin A. Hansen, November 2009.
405     
406     # Renders the browse page.
407
408     my ( $cookie,
409        ) = @_;
410
411     # Returns a list.
412
413     my ( @html );
414
415     push @html, section_taxonomy_table( $cookie );
416     push @html, section_navigate( $cookie );
417     push @html, section_browse( $cookie );
418
419     return wantarray ? @html : \@html;
420 }
421
422
423 sub page_taxonomy
424 {
425     # Martin A. Hansen, November 2009.
426     
427     # Renders the browse page.
428
429     my ( $cookie,   # cookie hash
430        ) = @_;
431
432     # Returns a list.
433
434     my ( @html );
435
436     push @html, section_taxonomy_table( $cookie );
437     push @html, section_taxonomy_select( $cookie );
438
439     return wantarray ? @html : \@html;
440 }
441
442
443 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SECTIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
444
445
446 sub section_taxonomy_table
447 {
448     # Martin A. Hansen, November 2009.
449
450     # Returns a HTML section with a taxonomy table
451     # showing the location in the taxonomy and with
452     # links to browse the taxonomy.
453
454     my ( $cookie,   # cookie hash
455        ) = @_;
456
457     # Returns a list.
458
459     my ( $page, @row, @html, $href, $txt );
460     
461     foreach $page ( @{ $cookie->{ 'LIST_PAGES' } } )
462     {
463         last if $page eq $cookie->{ 'PAGE' };
464
465         $href = cookie_href( $cookie, $page );
466
467         $txt = ": $cookie->{ uc $page }";
468
469         push @row, Maasha::XHTML::ln( txt => $page, href => $href, class => 'inline' );
470         push @row, Maasha::XHTML::p(  txt => $txt, class => 'inline' );
471     }
472
473     push @html, Maasha::XHTML::table_beg( summary => "Taxonomy table", align => 'center', cellpadding => '5px' );
474     push @html, Maasha::XHTML::table_row_simple( tr => [ join( " ", @row ) ], align => 'center' );
475     push @html, Maasha::XHTML::table_end;
476
477     return wantarray ? @html : \@html;
478 }
479
480
481 sub section_taxonomy_select
482 {
483     # Martin A. Hansen, November 2009.
484     
485     # Returns a HTML section with selection choices
486     # for navigating the taxonomy tree.
487
488     my ( $cookie,   # cookie hash
489        ) = @_;
490
491     # Returns a list.
492
493     my ( $list, @html, $item, $href );
494
495     $list = "LIST_" . uc $cookie->{ 'PAGE' };
496
497     push @html, Maasha::XHTML::h2( txt => "Select $cookie->{ 'PAGE' }", class => 'center' );
498
499     push @html, Maasha::XHTML::table_beg( summary => "Select table", align => 'center', cellpadding => '5px' );
500
501     foreach $item ( @{ $cookie->{ $list } } )
502     {
503         $cookie->{ uc $cookie->{ 'PAGE' } } = $item;
504
505         $href = cookie_href( $cookie, cookie_page_next( $cookie ) );
506
507         push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $item, href => $href ) ] );
508     }
509
510     push @html, Maasha::XHTML::table_end;
511
512     return wantarray ? @html : \@html;
513 }
514
515
516 sub section_navigate
517 {
518     # Martin A. Hansen, November 2009.
519
520     # Returns a HTML section for navigating in the browser window.
521
522     my ( $cookie,   # cookie hash
523        ) = @_;
524
525     # Returns a list.
526
527     my ( @html );
528
529     push @html, Maasha::XHTML::table_beg( summary => "Navigation table", align => 'center' );
530     push @html, Maasha::XHTML::table_row_simple( tr => [
531         "Start:",
532         Maasha::XHTML::text( name => "nav_start", value => Maasha::Calc::commify( $cookie->{ 'NAV_START' } ), size => 20 ),
533         "End:",
534         Maasha::XHTML::text( name => "nav_end",   value => Maasha::Calc::commify( $cookie->{ 'NAV_END' } ),   size => 20 ), 
535         Maasha::XHTML::submit( name => "nav_submit", value => "Submit" ),
536     ] );
537     push @html, Maasha::XHTML::table_end;
538
539     push @html, Maasha::XHTML::table_beg( summary => "Zoom table", align => 'center' );
540     push @html, Maasha::XHTML::table_row_simple( tr => [
541         Maasha::XHTML::p( txt => 'Move:' ),
542         Maasha::XHTML::submit( name => "move_left3",  value => "<<<", title => "move 95% to the left" ),
543         Maasha::XHTML::submit( name => "move_left2",  value => "<<",  title => "move 47.5% to the left" ),
544         Maasha::XHTML::submit( name => "move_left1",  value => "<",   title => "move 10% to the left" ),
545         Maasha::XHTML::submit( name => "move_right1", value => ">",   title => "move 10% to the rigth" ),
546         Maasha::XHTML::submit( name => "move_right2", value => ">>",  title => "move 47.5% to the rigth" ),
547         Maasha::XHTML::submit( name => "move_right3", value => ">>>", title => "move 95% to the right" ),
548         Maasha::XHTML::p( txt => 'Zoom in:' ),
549         Maasha::XHTML::submit( name => "zoom_in1", value => "1.5x" ),
550         Maasha::XHTML::submit( name => "zoom_in2", value => "3x" ),
551         Maasha::XHTML::submit( name => "zoom_in3", value => "10x" ),
552         Maasha::XHTML::p( txt => 'Zoom out:' ),
553         Maasha::XHTML::submit( name => "zoom_out1", value => "1.5x" ),
554         Maasha::XHTML::submit( name => "zoom_out2", value => "3x" ),
555         Maasha::XHTML::submit( name => "zoom_out3", value => "10x" ),
556     ] );
557     push @html, Maasha::XHTML::table_end;
558
559     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "page",     value => "browse" ) );
560     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "user",     value => "$cookie->{ 'USER' }" ) );
561     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "clade",    value => "$cookie->{ 'CLADE' }" ) );
562     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "genome",   value => "$cookie->{ 'GENOME' }" ) );
563     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "assembly", value => "$cookie->{ 'ASSEMBLY' }" ) );
564     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "contig",   value => "$cookie->{ 'CONTIG' }" ) );
565
566     return wantarray ? @html : \@html;
567 }
568
569
570 sub section_browse
571 {
572     my ( $cookie,
573        ) = @_;
574
575     # Returns a list.
576
577     my ( @tracks, $i, @features, $feat, $elem, $file, $surface, $cr, @html, @img );
578
579     push @features, [ Maasha::BBrowser::Track::track_ruler( $cookie ) ];
580     push @features, [ Maasha::BBrowser::Track::track_seq( $cookie ) ];
581
582     @tracks = Maasha::BBrowser::Track::path_tracks( $cookie );
583
584     for ( $i = 0; $i < @tracks; $i++ )
585     {
586         $cookie->{ 'FEAT_COLOR' } = Maasha::BBrowser::Draw::palette( $i );
587
588         push @features, [ Maasha::BBrowser::Track::track_feature( $tracks[ $i ], $cookie ) ];
589     }
590
591     $file = "fisk.png";   # FIXME
592
593     $surface = Cairo::ImageSurface->create( 'argb32', $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' } );
594     $cr      = Cairo::Context->create( $surface );
595
596     foreach $feat ( @features ) {
597         Maasha::BBrowser::Draw::draw_feature( $cr, $feat ) if $feat;
598     }
599
600     Maasha::BBrowser::Draw::file_png( $surface, $file );
601
602     push @img, Maasha::XHTML::img(
603         src    => $file,
604         alt    => "Browser Tracks",
605         height => $cookie->{ 'TRACK_OFFSET' },
606         width  => $cookie->{ 'IMG_WIDTH' },
607         id     => "browser_map",
608         usemap => "#browser_map"
609     );
610
611     push @img, Maasha::XHTML::map_beg( name => "browser_map", id => "browser_map" );
612
613     foreach $feat ( @features )
614     {
615         foreach $elem ( @{ $feat } )
616         {
617             next if $elem->{ 'type' } eq 'text';
618
619             push @img, Maasha::XHTML::area(
620                 href   => cookie_href( $cookie, "export" ) . "&Q_ID=$elem->{ 'id' }",
621                 shape  => "rect",
622                 coords => "$elem->{ x1 }, $elem->{ y1 }, $elem->{ x2 }, $elem->{ y2 }", title => "$elem->{ 'title' }",
623             );
624         }
625     }
626
627     push @img, Maasha::XHTML::map_end();
628
629     push @html, Maasha::XHTML::p( txt => join( "\n", @img ) );
630
631     @html = Maasha::XHTML::div( txt => join( "\n", @html ), class => 'browse' );
632
633     return wantarray ? @html : \@html;
634 }
635
636
637 sub section_export
638 {
639     # Martin A. Hansen, November 2009.
640
641     # Returns a HTML section with export table.
642
643     my ( $cookie,   # cookie hash
644        ) = @_;
645
646     # Returns a list.
647
648     my ( @html );
649
650     push @html, Maasha::XHTML::h2( txt => "Export", class => 'center' );   # TODO section_export!
651
652     return wantarray ? @html : \@html;
653 }
654
655
656 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
657
658
659 __END__