aboutsummaryrefslogtreecommitdiff
path: root/src/MTools/Comp/MWritable.pm
diff options
context:
space:
mode:
authorbouyssou2008-08-22 13:13:01 +0000
committerbouyssou2008-08-22 13:13:01 +0000
commitfbed78e8c1b992a886a20ec7e1dd2817c55a2cae (patch)
treec40ee66cf2d3ea31affd892b11b08d7ac0d9efc1 /src/MTools/Comp/MWritable.pm
parentaf277e7a5eb97227f63472ccd95e9ba11feb3422 (diff)
downloadmtc-fbed78e8c1b992a886a20ec7e1dd2817c55a2cae.zip
mtc-fbed78e8c1b992a886a20ec7e1dd2817c55a2cae.tar.gz
mtc-fbed78e8c1b992a886a20ec7e1dd2817c55a2cae.tar.bz2
mtc-fbed78e8c1b992a886a20ec7e1dd2817c55a2cae.tar.xz
Modif permettant de recuperer dans l ordre chronologique les coordonnees d un ensemble de curves contenu dans le MWritable. Ajout de l evenement MOVED_OUT_OF_BOUNDS dans le MMover permettant notifier que l on essaie de deplacer le MMover en dehors de ses frontieres.
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 {