1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
#!/usr/bin/perl
########################################################################
# Copyright (c) 2002 by Philippe Midol-Monnet <philippe@midol-monnet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#########################################################################
use XML::Simple;
use PostScript::Simple;
use strict;
use Task;
use TaskList;
package Projet;
use vars qw(@ISA);
@ISA = qw( TaskList );
sub max {
my ($max) = shift (@_);
my $temp;
foreach $temp (@_) {
$max = $temp if $temp > $max;
}
return ($max);
}
sub min {
my ($min) = shift (@_);
my $temp;
foreach $temp (@_) {
$min = $temp if $temp < $min;
}
return ($min);
}
sub new {
my ( $class, $ref ) = @_;
my $projet = TaskList->new($ref);
$projet->{xml} = $ref;
bless $projet, $class;
return $projet;
}
sub extract_list_task {
my $self = shift;
# call the TaskList sub
$self->SUPER::extract_list_task($self->{xml});
}
sub process_tasks {
my $self = shift;
# add dependencies lists for all tasks
$self->add_depends_by_ref($self);
# place all task in the grid;
$self->put_in_grid($self);
$self->put_in_line;
$self->set_lin(0);
}
sub get_name {
my $self = shift;
return $self->{xml}{Name}
}
sub get_version {
my $self = shift;
return $self->{xml}{Version}
}
sub get_end {
my $self = shift;
return POSIX::strftime( "%x", localtime( $self->{xml}{end}{content} ) )
}
sub get_start {
my $self = shift;
return POSIX::strftime( "%x", localtime( $self->{xml}{start}{content} ) )
}
sub get_now {
my $self = shift;
return POSIX::strftime( "%x", localtime( $self->{xml}{now}{content} ) )
}
sub draw {
my $self = shift;
my $output_file = shift;
my $marginx = 1.0; # 1cm
my $marginy = 1.0; # 1cm
my $cartouchex = 7.0; # 10cm
my $cartouchey = 2.0; # 4cm
# calculate bouding box
my $bx =
( $self->get_max_col + 1 ) * Task->get_task_width() * Task->cell_coef + 2 * $marginx;
my $by = ( $self->get_height ) * Task->get_task_height() * Task->cell_coef + 2 * $marginy + $cartouchey;
# create postscript file
my $p =
new PostScript::Simple( units => "cm", xsize => $bx, ysize => $by,
eps => 1 );
$p->setfont( "Times-Roman-iso", 9 );
#draw cartouche
# $p->setlinewidth(0.1);
# $p->box( 0, 0, $bx, $by);
# $p->setlinewidth(0.025);
$p->box( $marginx , $marginy,
$bx - $marginx , $by - $marginy);
my $lineheight = $cartouchey / 4.0;
my $colwidth = $cartouchex / 4.0;
$p->box( $marginx , $marginy,
$marginx + $cartouchex , $marginy + $cartouchey);
# title + version
$p->line( $marginx, $marginy + $lineheight,
$marginx + $cartouchex, $marginy + $lineheight);
$p->text( $marginx + $cartouchex / 2.0, $marginy + $lineheight / 3.5,
$self->get_name()." ".$self->get_version(), 'centre'
);
# start, end , now
$p->line( $marginx, $marginy + 2.0 * $lineheight,
$marginx + $cartouchex, $marginy + 2.0 * $lineheight);
$p->line( $marginx, $marginy + 3.0 * $lineheight,
$marginx + $cartouchex, $marginy + 3.0 * $lineheight);
$p->line( $marginx + $colwidth, $marginy + $lineheight,
$marginx + $colwidth, $marginy + $cartouchey);
$p->text( $marginx + $colwidth / 2.0, $marginy + $lineheight / 3.5 + $lineheight, "End", 'centre');
$p->text( $marginx + $colwidth / 2.0, $marginy + $lineheight / 3.5 + 2 * $lineheight, "Start", 'centre');
$p->text( $marginx + $colwidth / 2.0, $marginy + $lineheight / 3.5 + 3 * $lineheight, "Now", 'centre');
$p->text( $marginx + 2.5 *$colwidth, $marginy + $lineheight / 3.5 + $lineheight, $self->get_end(), 'centre');
$p->text( $marginx + 2.5 *$colwidth, $marginy + $lineheight / 3.5 + 2 * $lineheight, $self->get_start(), 'centre');
$p->text( $marginx + 2.5 *$colwidth, $marginy + $lineheight / 3.5 + 3 * $lineheight, $self->get_now(), 'centre');
# a ajouter : nom du projet + info du projet voir dtd
# inverse y axis
$p->{pspages} .= "$marginx u $by $marginy sub u translate \n";
$self->SUPER::draw( $p, 0 , -by );
$p->output($output_file);
}
1;
|