aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/MTools/Comp/MAntiRecouvrement.pm1
-rw-r--r--src/MTools/Comp/MMover.pm6
-rw-r--r--src/MTools/Comp/MMultiSelection.pm1
-rw-r--r--src/MTools/Comp/MWritable.pm42
4 files changed, 46 insertions, 4 deletions
diff --git a/src/MTools/Comp/MAntiRecouvrement.pm b/src/MTools/Comp/MAntiRecouvrement.pm
index 04d7caa..b54f669 100644
--- a/src/MTools/Comp/MAntiRecouvrement.pm
+++ b/src/MTools/Comp/MAntiRecouvrement.pm
@@ -97,6 +97,7 @@ sub addObject {
sub removeObject {
my ($self, $target) = @_;
+ return if (!defined $self -> {__objects});
for (my $i = @{$self -> {__objects}} - 1; $i >= 0; $i --)
{
if (@{$self -> {__objects}} [$i] eq $target)
diff --git a/src/MTools/Comp/MMover.pm b/src/MTools/Comp/MMover.pm
index 0d2628c..6097bd9 100644
--- a/src/MTools/Comp/MMover.pm
+++ b/src/MTools/Comp/MMover.pm
@@ -55,6 +55,7 @@ sub new {
$self -> recordProperty ('y', 0);
$self -> recordProperty ('targets', $targets);
$self -> recordProperty ('allower', undef);
+ $self -> recordProperty ('translate', 'translate');
$self -> mconfigure (%options);
@@ -79,17 +80,18 @@ sub setPos {
my $dy = $y - $self -> mget ('y');
my $tgs = $self -> mget ('targets');
my @targets;
+ my $translate_cbk = $self -> mget ('translate');
if (ref ($tgs) eq 'ARRAY')
{
@targets = @{$tgs};
for (my $i = 0; $i < @targets; $i++)
{
- $targets [$i] -> translate ($dx, $dy);
+ $targets [$i] -> $translate_cbk ($dx, $dy);
}
}
else
{
- $tgs -> translate ($dx, $dy);
+ $tgs -> $translate_cbk ($dx, $dy);
}
$self -> mconfigure ('x', $x);
$self -> mconfigure ('y', $y);
diff --git a/src/MTools/Comp/MMultiSelection.pm b/src/MTools/Comp/MMultiSelection.pm
index 0697a73..14c0c26 100644
--- a/src/MTools/Comp/MMultiSelection.pm
+++ b/src/MTools/Comp/MMultiSelection.pm
@@ -253,6 +253,7 @@ sub addObject {
sub removeObject {
my ($self, $target, $plan) = @_;
if (!defined $plan) {$plan = 0;}
+ return if (!defined $self -> {__objects} [$plan]);
for (my $i = @{$self -> {__objects} [$plan]} - 1; $i >= 0; $i --)
{
if (@{$self -> {__objects} [$plan]} [$i] eq $target)
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);