aboutsummaryrefslogtreecommitdiff
path: root/src/MTools/Comp/MWritable.pm
diff options
context:
space:
mode:
Diffstat (limited to 'src/MTools/Comp/MWritable.pm')
-rw-r--r--src/MTools/Comp/MWritable.pm61
1 files changed, 38 insertions, 23 deletions
diff --git a/src/MTools/Comp/MWritable.pm b/src/MTools/Comp/MWritable.pm
index f4826b3..bdbfe0d 100644
--- a/src/MTools/Comp/MWritable.pm
+++ b/src/MTools/Comp/MWritable.pm
@@ -251,47 +251,62 @@ sub erase {
}
}
sub getArrayFromCurves {
- my ($self,$format) = @_;
+ my ($self, $format, $firstCurveIndex, $lastCurveIndex) = @_;
my @tab = ();
if (defined $self -> {__curves})
{
my @curves = @{$self -> {__curves}};
- for (my $i = $#curves; $i >= 0 ; $i --)
+ if (defined $format && $format eq "RECO")
{
- my $single = "";
- my @points = $zinc -> coords ($curves [$i]);
- for (my $j = 0; $j <= $#points; $j ++)
+ for (my $i = 0 ; $i <= $#curves; $i ++)
{
- if (defined $format && $format eq "RECO")
+ next if defined $firstCurveIndex && $i < $firstCurveIndex;
+ last if defined $lastCurveIndex && $i > $lastCurveIndex;
+ my $single = "";
+ my @points = $zinc -> coords ($curves [$i]);
+ for (my $j = 0; $j <= $#points; $j ++)
{
- $single .= sprintf" %d %d,",$points[$j]-> [0],$points[$j] -> [1];
- if ($j == $#points)
- {
- $single .=" break";
- }
+ if($points[$j]-> [0] != $points[$j-1]-> [0] || $points[$j] -> [1] != $points[$j-1] -> [1]) {
+ $single .= sprintf" %d %d,",$points[$j]-> [0],$points[$j] -> [1];
+ }
+
+ if ($j == $#points)
+ {
+ $single .=" break";
+ }
}
- else
+ push (@tab,$single);
+ }
+ }
+ else {
+ for (my $i = 0 ; $i <= $#curves; $i ++)
+ {
+ next if defined $firstCurveIndex && $i < $firstCurveIndex;
+ last if defined $lastCurveIndex && $i > $lastCurveIndex;
+ my $single = "";
+ my @points = $zinc -> coords ($curves [$i]);
+ for (my $j = 0; $j <= $#points; $j ++)
{
- $single .= sprintf"\[%d,%d",$points[$j]-> [0],$points[$j] -> [1];
- if (defined $points[$j] -> [2])
- {
- $single .= sprintf",%s\]-",$points[$j] -> [2];
- }
- else
- {
- $single .= sprintf"\]-";
- }
+ $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);
}
- push (@tab,$single);
}
}
return \@tab;
}
sub __deleteCurve {
my ($self, $index) = @_;
- $self -> notify ('ERASE', $index);
$self -> deleteCurve ($index);
+ $self -> notify ('ERASE', $index);
}
sub deleteCurve {