]> git.donarmstrong.com Git - biopieces.git/blob - www/index.cgi
Cleaned BBrowser::Draw
[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
124     $path = "$cookie->{ 'DATA_DIR' }/Users";
125
126     $cookie->{ 'LIST_USER' }       = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
127
128     $path .= "/$cookie->{ 'USER' }";
129
130     $cookie->{ 'LIST_CLADE' }      = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
131
132     $path .= "/$cookie->{ 'CLADE' }";
133
134     $cookie->{ 'LIST_GENOME' }     = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
135
136     $path .= "/$cookie->{ 'GENOME' }";
137
138     $cookie->{ 'LIST_ASSEMBLY' }   = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
139
140     $path .= "/$cookie->{ 'ASSEMBLY' }";
141
142     $cookie->{ 'LIST_CONTIG' }     = Maasha::Filesys::ls_dirs_base( $path ) if -d $path;
143
144     if ( $cookie->{ 'CONTIG' } )
145     {
146         cookie_start( $cookie );
147         cookie_end( $cookie );
148         cookie_zoom( $cookie );
149         cookie_move( $cookie );
150     }
151
152     return wantarray ? %{ $cookie } : $cookie;
153 }
154
155
156 sub cookie_start
157 {
158     # Martin A. Hansen, November 2009.
159
160     # Decommify the cookie value for NAV_START and adjust it to
161     # to prevent negative values.
162
163     my ( $cookie,   # cookie hash
164        ) = @_;
165
166     # Returns nothing.
167
168     if ( defined $cookie->{ 'NAV_START' } )
169     {
170         $cookie->{ 'NAV_START' } =~ tr/,//d;
171         $cookie->{ 'NAV_START' } = 1 if $cookie->{ 'NAV_START' } <= 0;
172     }
173     else
174     {
175         $cookie->{ 'NAV_START' } = 1;
176     }
177 }
178
179
180 sub cookie_end
181 {
182     # Martin A. Hansen, November 2009.
183
184     # Decommify the cookie value for NAV_END and adjust it to prevent
185     # overshooting the max value for the contig size as determined
186     # from the cookie.
187
188     my ( $cookie,   # cookie hash
189        ) = @_;
190
191     # Returns nothing.
192
193     my ( $max );
194     
195     $max = Maasha::Filesys::file_size( Maasha::BBrowser::Track::path_seq( $cookie ) );
196
197     if ( defined $cookie->{ 'NAV_END' } )
198     {
199         $cookie->{ 'NAV_END' } =~ tr/,//d;
200         $cookie->{ 'NAV_END' } = $max if $cookie->{ 'NAV_END' } > $max;
201     }
202     else
203     {
204         $cookie->{ 'NAV_END' } = $max;
205     }
206 }
207
208
209 sub cookie_zoom
210 {
211     # Martin A. Hansen, November 2009.
212
213     # Adjust the cookie values for NAV_START and NAV_END based
214     # on cookie ZOOM values.
215
216     my ( $cookie,   # cookie hash
217        ) = @_;
218
219     # Returns nothing.
220
221     my ( $max, $dist, $new_dist, $dist_diff );
222
223     $max = Maasha::Filesys::file_size( Maasha::BBrowser::Track::path_seq( $cookie ) );
224
225     $dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' };
226
227     if ( defined $cookie->{ 'ZOOM_IN1' } ) {
228         $new_dist = $dist / 1.5;
229     } elsif ( defined $cookie->{ 'ZOOM_IN2' } ) {
230         $new_dist = $dist / 3;
231     } elsif ( defined $cookie->{ 'ZOOM_IN3' } ) {
232         $new_dist = $dist / 10;
233     } elsif ( defined $cookie->{ 'ZOOM_OUT1' } ) {
234         $new_dist = $dist * 1.5;
235     } elsif ( defined $cookie->{ 'ZOOM_OUT2' } ) {
236         $new_dist = $dist * 3;
237     } elsif ( defined $cookie->{ 'ZOOM_OUT3' } ) {
238         $new_dist = $dist * 10;
239     }
240
241     if ( $new_dist )
242     {
243         $dist_diff = $dist - $new_dist;
244
245         $cookie->{ 'NAV_START' } = int( $cookie->{ 'NAV_START' } + ( $dist_diff / 2 ) );
246         $cookie->{ 'NAV_END' }   = int( $cookie->{ 'NAV_END' }   - ( $dist_diff / 2 ) );
247
248         $cookie->{ 'NAV_START' } = 1     if $cookie->{ 'NAV_START' } <= 0;
249         $cookie->{ 'NAV_END' }   = $max if $cookie->{ 'NAV_END' } > $max;
250     }
251 }
252
253
254 sub cookie_move
255 {
256     # Martin A. Hansen, November 2009.
257
258     # Adjust the cookie values for NAV_START and NAV_END based
259     # on cookie MOVE values.
260
261     my ( $cookie,   # cookie hash
262        ) = @_;
263
264     my ( $max, $dist, $shift, $new_start, $new_end );
265
266     $max = Maasha::Filesys::file_size( Maasha::BBrowser::Track::path_seq( $cookie ) );
267
268     $dist = $cookie->{ 'NAV_END' } - $cookie->{ 'NAV_START' };
269
270     if ( defined $cookie->{ 'MOVE_LEFT1' } ) {
271         $shift = -1 * $dist * 0.10;
272     } elsif ( defined $cookie->{ 'MOVE_LEFT2' } ) {
273         $shift = -1 * $dist * 0.475;
274     } elsif ( defined $cookie->{ 'MOVE_LEFT3' } ) {
275         $shift = -1 * $dist * 0.95;
276     } elsif ( defined $cookie->{ 'MOVE_RIGHT1' } ) {
277         $shift = $dist * 0.10;
278     } elsif ( defined $cookie->{ 'MOVE_RIGHT2' } ) {
279         $shift = $dist * 0.475;
280     } elsif ( defined $cookie->{ 'MOVE_RIGHT3' } ) {
281         $shift = $dist * 0.95;
282     }
283
284     if ( $shift )
285     {
286         $new_start = int( $cookie->{ 'NAV_START' } + $shift );
287         $new_end   = int( $cookie->{ 'NAV_END' }   + $shift );
288
289         if ( $new_start > 0 and $new_end < $max )
290         {
291             $cookie->{ 'NAV_START' } = $new_start;
292             $cookie->{ 'NAV_END' }   = $new_end;
293         }
294     }
295 }
296
297
298 sub cookie_href
299 {
300     # Martin A. Hansen, November 2009.
301
302     # Returns the href for a taxonomy path terminated at a given
303     # page using information stored in a cookie.
304
305     my ( $cookie,   # cookie hash
306          $page,     # page
307        ) = @_;
308
309     # Returns a string.
310
311     my ( @href );
312
313     while ( 1 )
314     {
315         push @href, "$cookie->{ 'SCRIPT' }?page=$page";
316         push @href, "user=$cookie->{ 'USER' }"         if $cookie->{ 'USER' };
317         last if $page eq 'user';
318         push @href, "clade=$cookie->{ 'CLADE' }"       if $cookie->{ 'CLADE' };
319         last if $page eq 'clade';
320         push @href, "genome=$cookie->{ 'GENOME' }"     if $cookie->{ 'GENOME' };
321         last if $page eq 'genome';
322         push @href, "assembly=$cookie->{ 'ASSEMBLY' }" if $cookie->{ 'ASSEMBLY' };
323         last if $page eq 'assembly';
324         push @href, "contig=$cookie->{ 'CONTIG' }"     if $cookie->{ 'CONTIG' };
325         last if $page eq 'contig';
326         last;
327     }
328
329     return join "&", @href;
330 }
331
332
333 sub cookie_page_next
334 {
335     # Martin A. Hansen, November 2009.
336     
337     # Returns the next page in the taxonomy path.
338
339     my ( $cookie,   # cookie hash
340        ) = @_;
341
342     # Returns a string.
343
344     my ( $i );
345
346     for ( $i = 0; $i < @{ $cookie->{ 'LIST_PAGES' } }; $i++ ) {
347         last if $cookie->{ 'PAGE' } eq $cookie->{ 'LIST_PAGES' }->[ $i ];
348     }
349
350     return $cookie->{ 'LIST_PAGES' }->[ $i + 1 ];
351 }
352
353
354 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PAGES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
355
356
357 sub page
358 {
359     # Martin A. Hansen, November 2009.
360
361     # Determines what page to render based on
362     # the cookie's PAGE setting.
363
364     my ( $cookie,   # cookie hash
365        ) = @_;
366
367     # Returns a list.
368
369     my ( @html );
370
371     if ( $cookie->{ 'PAGE' } eq 'export' ) {
372         push @html, page_export( $cookie );
373     } elsif ( $cookie->{ 'PAGE' } eq 'browse' ) {
374         push @html, page_browse( $cookie );
375     } else {
376         push @html, page_taxonomy( $cookie );
377     }
378
379     return wantarray ? @html : \@html;
380 }
381
382
383 sub page_export
384 {
385     # Martin A. Hansen, November 2009.
386
387     # Renders the export page.
388
389     my ( $cookie,
390        ) = @_;
391
392     # Returns a list.
393
394     push @html, section_taxonomy_table( $cookie );
395     push @html, section_export( $cookie );
396
397     return wantarray ? @html : \@html;
398 }
399
400
401 sub page_browse
402 {
403     # Martin A. Hansen, November 2009.
404     
405     # Renders the browse page.
406
407     my ( $cookie,
408        ) = @_;
409
410     # Returns a list.
411
412     my ( @html );
413
414     push @html, section_taxonomy_table( $cookie );
415     push @html, section_navigate( $cookie );
416     push @html, section_browse( $cookie );
417
418     return wantarray ? @html : \@html;
419 }
420
421
422 sub page_taxonomy
423 {
424     # Martin A. Hansen, November 2009.
425     
426     # Renders the browse page.
427
428     my ( $cookie,   # cookie hash
429        ) = @_;
430
431     # Returns a list.
432
433     my ( @html );
434
435     push @html, section_taxonomy_table( $cookie );
436     push @html, section_taxonomy_select( $cookie );
437
438     return wantarray ? @html : \@html;
439 }
440
441
442 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SECTIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
443
444
445 sub section_taxonomy_table
446 {
447     # Martin A. Hansen, November 2009.
448
449     # Returns a HTML section with a taxonomy table
450     # showing the location in the taxonomy and with
451     # links to browse the taxonomy.
452
453     my ( $cookie,   # cookie hash
454        ) = @_;
455
456     # Returns a list.
457
458     my ( $page, @row, @html, $href, $txt );
459     
460     foreach $page ( @{ $cookie->{ 'LIST_PAGES' } } )
461     {
462         last if $page eq $cookie->{ 'PAGE' };
463
464         $href = cookie_href( $cookie, $page );
465
466         $txt = ": $cookie->{ uc $page }";
467
468         push @row, Maasha::XHTML::ln( txt => $page, href => $href, class => 'inline' );
469         push @row, Maasha::XHTML::p(  txt => $txt, class => 'inline' );
470     }
471
472     push @html, Maasha::XHTML::table_beg( summary => "Taxonomy table", align => 'center', cellpadding => '5px' );
473     push @html, Maasha::XHTML::table_row_simple( tr => [ join( " ", @row ) ], align => 'center' );
474     push @html, Maasha::XHTML::table_end;
475
476     return wantarray ? @html : \@html;
477 }
478
479
480 sub section_taxonomy_select
481 {
482     # Martin A. Hansen, November 2009.
483     
484     # Returns a HTML section with selection choices
485     # for navigating the taxonomy tree.
486
487     my ( $cookie,   # cookie hash
488        ) = @_;
489
490     # Returns a list.
491
492     my ( $list, @html, $item, $href );
493
494     $list = "LIST_" . uc $cookie->{ 'PAGE' };
495
496     push @html, Maasha::XHTML::h2( txt => "Select $cookie->{ 'PAGE' }", class => 'center' );
497
498     push @html, Maasha::XHTML::table_beg( summary => "Select table", align => 'center', cellpadding => '5px' );
499
500     foreach $item ( @{ $cookie->{ $list } } )
501     {
502         $cookie->{ uc $cookie->{ 'PAGE' } } = $item;
503
504         $href = cookie_href( $cookie, cookie_page_next( $cookie ) );
505
506         push @html, Maasha::XHTML::table_row_simple( tr => [ Maasha::XHTML::ln( txt => $item, href => $href ) ] );
507     }
508
509     push @html, Maasha::XHTML::table_end;
510
511     return wantarray ? @html : \@html;
512 }
513
514
515 sub section_navigate
516 {
517     # Martin A. Hansen, November 2009.
518
519     # Returns a HTML section for navigating in the browser window.
520
521     my ( $cookie,   # cookie hash
522        ) = @_;
523
524     # Returns a list.
525
526     my ( @html );
527
528     push @html, Maasha::XHTML::table_beg( summary => "Navigation table", align => 'center' );
529     push @html, Maasha::XHTML::table_row_simple( tr => [
530         "Start:",
531         Maasha::XHTML::text( name => "nav_start", value => Maasha::Calc::commify( $cookie->{ 'NAV_START' } ), size => 20 ),
532         "End:",
533         Maasha::XHTML::text( name => "nav_end",   value => Maasha::Calc::commify( $cookie->{ 'NAV_END' } ),   size => 20 ), 
534         Maasha::XHTML::submit( name => "nav_submit", value => "Submit" ),
535     ] );
536     push @html, Maasha::XHTML::table_end;
537
538     push @html, Maasha::XHTML::table_beg( summary => "Zoom table", align => 'center' );
539     push @html, Maasha::XHTML::table_row_simple( tr => [
540         Maasha::XHTML::p( txt => 'Move:' ),
541         Maasha::XHTML::submit( name => "move_left3",  value => "<<<", title => "move 95% to the left" ),
542         Maasha::XHTML::submit( name => "move_left2",  value => "<<",  title => "move 47.5% to the left" ),
543         Maasha::XHTML::submit( name => "move_left1",  value => "<",   title => "move 10% to the left" ),
544         Maasha::XHTML::submit( name => "move_right1", value => ">",   title => "move 10% to the rigth" ),
545         Maasha::XHTML::submit( name => "move_right2", value => ">>",  title => "move 47.5% to the rigth" ),
546         Maasha::XHTML::submit( name => "move_right3", value => ">>>", title => "move 95% to the right" ),
547         Maasha::XHTML::p( txt => 'Zoom in:' ),
548         Maasha::XHTML::submit( name => "zoom_in1", value => "1.5x" ),
549         Maasha::XHTML::submit( name => "zoom_in2", value => "3x" ),
550         Maasha::XHTML::submit( name => "zoom_in3", value => "10x" ),
551         Maasha::XHTML::p( txt => 'Zoom out:' ),
552         Maasha::XHTML::submit( name => "zoom_out1", value => "1.5x" ),
553         Maasha::XHTML::submit( name => "zoom_out2", value => "3x" ),
554         Maasha::XHTML::submit( name => "zoom_out3", value => "10x" ),
555     ] );
556     push @html, Maasha::XHTML::table_end;
557
558     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "page",     value => "browse" ) );
559     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "user",     value => "$cookie->{ 'USER' }" ) );
560     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "clade",    value => "$cookie->{ 'CLADE' }" ) );
561     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "genome",   value => "$cookie->{ 'GENOME' }" ) );
562     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "assembly", value => "$cookie->{ 'ASSEMBLY' }" ) );
563     push @html, Maasha::XHTML::p( txt => Maasha::XHTML::hidden( name => "contig",   value => "$cookie->{ 'CONTIG' }" ) );
564
565     return wantarray ? @html : \@html;
566 }
567
568
569 sub section_browse
570 {
571     my ( $cookie,
572        ) = @_;
573
574     # Returns a list.
575
576     my ( @tracks, $i, @features, $feat, $elem, $file, $surface, $cr, @html, @img );
577
578     push @features, [ Maasha::BBrowser::Track::track_ruler( $cookie ) ];
579     push @features, [ Maasha::BBrowser::Track::track_seq( $cookie ) ];
580
581     @tracks = Maasha::BBrowser::Track::path_tracks( $cookie );
582
583     for ( $i = 0; $i < @tracks; $i++ )
584     {
585         $cookie->{ 'FEAT_COLOR' } = Maasha::BBrowser::Draw::palette( $i );
586
587         push @features, [ Maasha::BBrowser::Track::track_feature( $tracks[ $i ], $cookie, $cookie ) ];
588     }
589
590     $file = "fisk.png";   # FIXME
591
592     $surface = Cairo::ImageSurface->create( 'argb32', $cookie->{ 'IMG_WIDTH' }, $cookie->{ 'TRACK_OFFSET' } );
593     $cr      = Cairo::Context->create( $surface );
594
595     foreach $feat ( @features ) {
596         Maasha::BBrowser::Draw::draw_feature( $cr, $feat ) if $feat;
597     }
598
599     Maasha::BBrowser::Draw::file_png( $surface, $file );
600
601     push @img, Maasha::XHTML::img(
602         src    => $file,
603         alt    => "Browser Tracks",
604         height => $cookie->{ 'TRACK_OFFSET' },
605         width  => $cookie->{ 'IMG_WIDTH' },
606         id     => "browser_map",
607         usemap => "#browser_map"
608     );
609
610     push @img, Maasha::XHTML::map_beg( name => "browser_map", id => "browser_map" );
611
612     foreach $feat ( @features )
613     {
614         foreach $elem ( @{ $feat } )
615         {
616             next if $elem->{ 'type' } eq 'text';
617
618             push @img, Maasha::XHTML::area(
619                 href   => cookie_href( $cookie, "export" ) . "&Q_ID=$elem->{ 'id' }",
620                 shape  => "rect",
621                 coords => "$elem->{ x1 }, $elem->{ y1 }, $elem->{ x2 }, $elem->{ y2 }", title => "$elem->{ 'title' }",
622             );
623         }
624     }
625
626     push @img, Maasha::XHTML::map_end();
627
628     push @html, Maasha::XHTML::p( txt => join( "\n", @img ) );
629
630     @html = Maasha::XHTML::div( txt => join( "\n", @html ), class => 'browse' );
631
632     return wantarray ? @html : \@html;
633 }
634
635
636 sub section_export
637 {
638     # Martin A. Hansen, November 2009.
639
640     # Returns a HTML section with export table.
641
642     my ( $cookie,   # cookie hash
643        ) = @_;
644
645     # Returns a list.
646
647     my ( @html );
648
649     push @html, Maasha::XHTML::h2( txt => "Export", class => 'center' );   # TODO section_export!
650
651     return wantarray ? @html : \@html;
652 }
653
654
655 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
656
657
658 __END__