diff options
author | bouyssou | 2008-01-09 14:32:04 +0000 |
---|---|---|
committer | bouyssou | 2008-01-09 14:32:04 +0000 |
commit | 937c7a8e097a6ef0af3989cfcc492b06d95b35ad (patch) | |
tree | ba14f2629b117027ce2eb4c27a2ff38b3f76b0b8 /src/SVG/SVG2zinc.pm | |
parent | d953cc5c6e5bca46dbbd0c290ff53734b5aba9a4 (diff) | |
download | mtc-937c7a8e097a6ef0af3989cfcc492b06d95b35ad.zip mtc-937c7a8e097a6ef0af3989cfcc492b06d95b35ad.tar.gz mtc-937c7a8e097a6ef0af3989cfcc492b06d95b35ad.tar.bz2 mtc-937c7a8e097a6ef0af3989cfcc492b06d95b35ad.tar.xz |
On peut désormais accéder aux objets zinc via une table de hash. Attention ! il est impératif de supprimer et regénérer vos fichiers contenu dans les répertoires AUTOGEN.
Diffstat (limited to 'src/SVG/SVG2zinc.pm')
-rw-r--r-- | src/SVG/SVG2zinc.pm | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/src/SVG/SVG2zinc.pm b/src/SVG/SVG2zinc.pm index 74638dd..753fff7 100644 --- a/src/SVG/SVG2zinc.pm +++ b/src/SVG/SVG2zinc.pm @@ -325,6 +325,14 @@ sub name { } } +sub printFindKey { + my ($name) = @_; + if ($name ne '') { + return "HASHKEY{$name}"; + } + return ""; +} + sub g { my ($parser, $elementname, %attrs) = @_; push (@nameStack, $attrs{id}); @@ -337,8 +345,8 @@ sub g { return; } %attrs = &expandAttributes ($elementname, %attrs); - my ($name,$natural) = &name ($elementname, $attrs {id}); - my $res = '$parent = $previous = '." -> add ('group', $current_group, -tags => [$name], -priority => 10"; + my ($name, $natural) = &name ($elementname, $attrs {id}); + my $res = printFindKey ($name).'$parent = $previous = '." -> add ('group', $current_group, -tags => [$name], -priority => 10"; unshift @prev_groups, $current_group; $current_group = '$parent'; unshift @prev_contexts, \%current_context; @@ -481,7 +489,7 @@ sub clipPath { %attrs = &expandAttributes ($elementname,%attrs); my ($name,$natural) = &name ($elementname, $attrs{id}); print "In clippath $name NYI\n"; - my $res = "->add('group',$current_group, -tags => [$name, '__clipPath'], -priority => 10, -atomic => 1, -visible => 0"; + my $res = "->add('group',$current_group, -tags => [$name], -priority => 10, -atomic => 1, -visible => 0"; unshift @prev_groups, $current_group; unshift @prev_contexts, \%current_context; my $prop; @@ -534,7 +542,7 @@ sub use { } $ref =~ s/\#//; my $cleanedId = &cleanName($ref); # to make the name zinc compliant - my $res = "-> clone ('$cleanedId', -visible => 1, -tags => [$name, 'cloned_$cleanedId']"; + my $res = "-> clone ('$cleanedId', -visible => 1, -tags => [$name]"; $res .= &analyze_style (\%attrs); $res .=");"; my ($x,$y,$width,$height) = ($attrs{x},$attrs{y},$attrs{width},$attrs{height}); @@ -975,7 +983,7 @@ sub image { $group .= ", -color => 'white;$opacity'"; } } - my $res = ""; + my $res = printFindKey ($name); my $ref = ""; if ($ref = $attrs {'xlink:href'}) { @@ -1015,7 +1023,7 @@ sub image { return; } - $res .= ", -tags => [$name, '$ref'], -composescale => 1, -composerotation => 1, -priority => 10);"; + $res .= ", -tags => [$name], -composescale => 1, -composerotation => 1, -priority => 10);"; push @RES, $res ; my ($x, $y, $width, $height) = &sizesConvert ( \%attrs , qw (x y width height)); @@ -1062,10 +1070,8 @@ sub line { } %attrs = &expandAttributes ($elementname,%attrs); my ($name,$natural) = &name ($elementname, $attrs{id}); - my $res = "->add ('curve', $current_group, [$attrs{x1}, $attrs{y1}, $attrs{x2}, $attrs{y2}], -priority => 10"; - $res .= ", -tags => ['line'"; - $res .= ", $name" if ($natural or $attrs{transform}); - $res .= "]"; + my $res = printFindKey ($name). "\$previous = ->add ('curve', $current_group, [$attrs{x1}, $attrs{y1}, $attrs{x2}, $attrs{y2}], -priority => 10"; + $res .= ", -tags => [$name]," if ($natural or $attrs{transform}); $res .= &analyze_style (\%attrs); $res .=");"; &attrs_implemented ( 'line', $name, [qw (x1 y1 x2 y2 style id transform )], %attrs ); @@ -1129,9 +1135,9 @@ my %save_current_context = (); %attrs = &expandAttributes ($elementname,%attrs); my ($name,$natural) = &name ($elementname, $attrs{id}); ($text_x, $text_y) = &sizesConvert( \%attrs , qw (x y)); - $res = "->add('text',$current_group, -composescale => 1, -composerotation => 1, -position => [0, 0], -tags => ['text'"; - $res .= ", $name" if ($natural or $attrs{transform}); - $res .= "], -anchor => 'nw'"; + $res = printFindKey ($name)."->add('text',$current_group, -composescale => 1, -composerotation => 1, -position => [0, 0]"; + $res .= ", -tags => [$name]" if ($natural or $attrs{transform}); + $res .= ", -anchor => 'nw'"; $res .= &analyze_text_style (\%attrs); @texts = (); @transforms = &transform('$previous', $attrs{transform}); @@ -1204,10 +1210,10 @@ sub polyline { } %attrs = &expandAttributes ($elementname,%attrs); my ($name,$natural) = &name ($elementname, $attrs{id}); - my $res = "->add('curve',$current_group,[" . &points(\%attrs); - $res .= "], -tags => ['polyline'"; - $res .= ", $name" if ($natural or $attrs{transform}); - $res .= "], -priority => 10"; + my $res = printFindKey ($name)."\$previous ->add('curve',$current_group,[" . &points(\%attrs); + $res .= "]"; + $res .= ", -tags => [$name]" if ($natural or $attrs{transform}); + $res .= ", -priority => 10"; $res .= &analyze_style (\%attrs); $res .=");"; &attrs_implemented ( 'polyline', $name, [qw (points style transform id )], %attrs ); @@ -1245,9 +1251,9 @@ sub rect { $add_stroke = 0; - my $res = "\$previous = -> add('$type',$current_group, [$path], -tags => ['rect'"; - $res .= ", $name" if ($natural or $attrs{transform}); - $res .= "], -priority => 10"; + my $res = printFindKey ($name)."\$previous = -> add('$type',$current_group, [$path]"; + $res .= ", -tags => [$name]" if ($natural or $attrs{transform}); + $res .= ", -priority => 10"; $res .= ", -filled => 1" unless defined $attrs{fill} and $attrs{fill} eq 'none'; $add_stroke = 1 if defined $attrs{stroke}; @@ -1313,10 +1319,10 @@ sub ellipse { %attrs = &expandAttributes ($elementname,%attrs); my ($name,$natural) = &name ($elementname, $attrs{id}); my ($cx,$cy,$rx,$ry)=&sizesConvert( \%attrs , qw (cx cy rx ry)); - my $res = "\$previous = ->add('arc', $current_group, [". ($cx-$rx) . ", ". ($cy-$ry) . - ", " . ($cx+$rx) . ", ". ($cy+$ry) . "], -tags => ['ellipse',"; - $res .= ", $name" if ($natural or $attrs{transform}); - $res .= "], -priority => 10"; + my $res = printFindKey ($name)."\$previous = ->add('arc', $current_group, [". ($cx-$rx) . ", ". ($cy-$ry) . + ", " . ($cx+$rx) . ", ". ($cy+$ry) . "]"; + $res .= ", -tags => [$name]" if ($natural or $attrs{transform}); + $res .= ", -priority => 10"; # by default, ellipses are filled # from svg specifs). The value is set here, and can be overidden later # in the &analyze_style @@ -1352,10 +1358,10 @@ sub circle { %attrs = &expandAttributes ($elementname,%attrs); my ($name,$natural) = &name ($elementname, $attrs{id}); my ($cx,$cy,$r)=&sizesConvert( \%attrs , qw (cx cy r)); - my $res = "\$previous = -> add('arc',$current_group,[". ($cx-$r) . ", ". ($cy-$r) . - ", " . ($cx+$r) . ", ". ($cy+$r) . "], -tags => ['circle'"; - $res .= ", $name" if ($natural or $attrs{transform}); - $res .= "], -priority => 10"; + my $res = printFindKey ($name)."\$previous = -> add('arc',$current_group,[". ($cx-$r) . ", ". ($cy-$r) . + ", " . ($cx+$r) . ", ". ($cy+$r) . "]"; + $res .= ", -tags => [$name]" if ($natural or $attrs{transform}); + $res .= ", -priority => 10"; # by default, circles are filled # from svg specifs). The value is set here, and can be overidden later # in the &analyze_style @@ -1390,10 +1396,10 @@ sub polygon { } %attrs = &expandAttributes ($elementname,%attrs); my ($name,$natural) = &name ($elementname, $attrs{id}); - my $res = "\$previous = -> add('curve',$current_group,[" . &points(\%attrs); - $res .= "], -closed => 1, -tags => ['polygon'"; - $res .= ", $name" if ($natural or $attrs{transform}); - $res .= "], -priority => 10"; + my $res = printFindKey ($name)."\$previous = -> add('curve',$current_group,[" . &points(\%attrs); + $res .= "], -closed => 1"; + $res .= ", -tags => [$name]" if ($natural or $attrs{transform}); + $res .= ", -priority => 10"; # by default, polygones are filled # from svg specifs). The value is set here, and can be overidden later # in the &analyze_style @@ -1458,7 +1464,7 @@ sub path { push @contours, $contour; } &attrs_implemented ( 'path', $name, [qw ( d style stroke-linejoin stroke-linecap transform id stroke-dasharray )], %attrs ); - $res = start_opacity_gp ($parser, $elementname)."\$previous = -> add('curve', $current_group, [".$res; + $res = start_opacity_gp ($parser, $elementname).printFindKey ($name)."\$previous = -> add('curve', $current_group, [".$res; &ddisplay ($res, @contours, &transform('$previous', $attrs{transform})); $res = close_opacity_gp ($parser, $elementname); |