diff options
Diffstat (limited to 'src/MTools/Comp/MWritable.pm')
-rw-r--r-- | src/MTools/Comp/MWritable.pm | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/MTools/Comp/MWritable.pm b/src/MTools/Comp/MWritable.pm index 764e384..ec7fbd8 100644 --- a/src/MTools/Comp/MWritable.pm +++ b/src/MTools/Comp/MWritable.pm @@ -37,6 +37,7 @@ package MTools::Comp::MWritable; # * write : force l'ecriture # * end_write : force une fin d'ecriture # * erase : force un effacement +# * getArrayFromCurves : renvoie les coordonnees des curves sous forme de tableau use strict; @@ -101,8 +102,8 @@ sub __endWrite { ($x, $y) = $zinc -> transform ('device', minstance ($self), [$x, $y]); $self -> writing ($x, $y); $self -> notify ('WRITE', $x, $y); - $self -> notify ('END_WRITE'); $self -> endWrite (); + $self -> notify ('END_WRITE'); } else { @@ -247,7 +248,44 @@ sub erase { } } } - +sub getArrayFromCurves { + my ($self,$format) = @_; + my @tab = (); + if (defined $self -> {__curves}) + { + my @curves = @{$self -> {__curves}}; + for (my $i = $#curves; $i >= 0 ; $i --) + { + my $single = ""; + my @points = $zinc -> coords ($curves [$i]); + for (my $j = 0; $j <= $#points; $j ++) + { + if (defined $format && $format eq "RECO") + { + $single .= sprintf" %d %d,",$points[$j]-> [0],$points[$j] -> [1]; + if ($j == $#points) + { + $single .=" break"; + } + } + else + { + $single .= sprintf"\[%d,%d",$points[$j]-> [0],$points[$j] -> [1]; + if (defined $points[$j] -> [2]) + { + $single .= sprintf",%s\]-",$points[$j] -> [2]; + } + else + { + $single .= sprintf"\]-"; + } + } + } + push (@tab,$single); + } + } + return \@tab; +} sub __deleteCurve { my ($self, $index) = @_; $self -> notify ('ERASE', $index); |