diff options
-rw-r--r-- | Perl/demos/Tk/demos/zinc_lib/items.pl | 56 | ||||
-rw-r--r-- | Perl/demos/Tk/demos/zinc_lib/labelformat.pl | 20 |
2 files changed, 48 insertions, 28 deletions
diff --git a/Perl/demos/Tk/demos/zinc_lib/items.pl b/Perl/demos/Tk/demos/zinc_lib/items.pl index a6cd5ff..f9a7d8e 100644 --- a/Perl/demos/Tk/demos/zinc_lib/items.pl +++ b/Perl/demos/Tk/demos/zinc_lib/items.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w # $Id$ # these simple samples have been developped by C. Mertz mertz@cena.fr @@ -17,12 +17,12 @@ my $zinc = $mw->Zinc(-width => 700, -height => 600, )->pack; $zinc->add('rectangle', 1, [10,10, 100, 50], -fillcolor => "green", -filled => 1, - -linewidth => 3); + -linewidth => 10, -relief => "roundridge", -linecolor => "darkgreen"); $zinc->add('text', 1, -font => $defaultfont, - -text => "A filled rectangle with a border of 3 pixels.", + -text => "A filled rectangle with a \"roundridge\" relief border of 10 pixels.", -anchor => 'nw', -position => [120, 20]); @@ -31,7 +31,7 @@ my $labelformat = "x82x60+0+0 x60a0^0^0 x32a0^0>1 a0a0>2>1 x32a0>3>1 a0a0^0>2"; my $x=20; my $y=120; -my $track=$zinc->add('track', 1, 6, # 6 is the number of field in the flightlabel +my $track=$zinc->add('track', 1, 6, # 6 is the number of fields in the flightlabel -labelformat => $labelformat, -position => [$x, $y], -speedvector => [40, -10], @@ -43,10 +43,10 @@ foreach my $i (0..5) { $zinc->coords("$track",[$x+$i*10,$y-$i*2]); } $zinc->add('text', 1, -font => $defaultfont, - -text => "A flight track for a radar display.\n". - "(A waypoint is very similar, but has no speed neither past positions)", + -text => "A flight track for a radar display. (A waypoint looks similar,\n". + "but has no speedvector neither past positions)", -anchor => 'nw', - -position => [120, 120], + -position => [200, 80], ); $zinc->itemconfigure($track, 0, @@ -79,23 +79,26 @@ $zinc->itemconfigure($track, 5, -$zinc->add('arc', 1, [90, 210, 390, 310], -fillcolor => "gray20", +$zinc->add('arc', 1, [150, 140, 450, 240], -fillcolor => "gray20", -filled => 0, -linewidth => 1, -startangle => 45, -extent => 270); -$zinc->add('arc', 1, [200, 220, 280, 300], -fillcolor => "gray20", +$zinc->add('arc', 1, [260, 150, 340, 230], -fillcolor => "gray20", -filled => 0, -linewidth => 1, -startangle => 45, -extent => 270, -pieslice => 1, -closed => 1, + -linestyle => 'mixed', -linewidth => 3, ); $zinc->add('text', 1, -font => $defaultfont, -text => "Two arcs, starting at 45° with an extent of 270°.", -anchor => 'nw', - -position => [250, 250]); + -position => [320, 180]); + $zinc->add('curve', 1, [10, 324, 24, 300, 45, 432, 247, 356, 128, 401], - -filled => 0, + -filled => 0, -relief => 'roundgroove', + # -linewidth => 10, ## BUG with zinc 3.2.3g ); $zinc->add('text', 1, -font => $defaultfont, @@ -104,14 +107,14 @@ $zinc->add('text', 1, -position => [50, 350]); # Bug: this bezier does not display with openGL (zinc-perl v3.2.3e) -$zinc->add('bezier', 1, [310, 324, 324, 300, 345, 432, 547, 356, 428, 401, 534, 407], +$zinc->add('bezier', 1, [210, 270, 264, 250, 285, 382, 487, 306, 368, 350, 474, 357], -filled => 0, ); $zinc->add('text', 1, -font => $defaultfont, -text => "An open bezier.", -anchor => 'nw', - -position => [450, 320]); + -position => [350, 280]); $zinc->add('text', 1, -font => $defaultfont, @@ -136,15 +139,14 @@ foreach my $fieldId (1..5) { $zinc->add('text', 1, -font => $defaultfont, - -text => "3 tabulars of 2 fields,\nattached together", + -text => "3 tabulars of 2 fields,\nattached together.", -anchor => 'nw', - -position => [310, 480], + -position => [510, 380], ); -#my $labelformat2 = "80x24 a7a1+0+0 f3f1+0+10"; my $labelformat2 = "x72x40 x72a0^0^0 x34a0^0>1"; -my $tabular1 = $zinc->add('tabular', 1, 6, -position => [490,420], +my $tabular1 = $zinc->add('tabular', 1, 6, -position => [570,250], -labelformat => $labelformat2, ); my $tabular2 = $zinc->add('tabular', 1, 6, -connecteditem => $tabular1, @@ -166,11 +168,27 @@ foreach my $tab ($tabular1, $tabular2, $tabular3) { $count++; } + +$zinc->add('reticle', 1, -position => [530,550], + -firstradius => 20, -numcircles => 6, + -period => 2, -stepsize => 20, + -brightlinestyle => 'dashed', -brightlinecolor => 'darkred', + ); + +$zinc->add('text', 1, + -font => $defaultfont, + -text => "a reticle of 6 circles.", + -anchor => 'nw', + -position => [530, 540]); + + + $zinc->add('text', 1, -font => $defaultfont, - -text => "Items not yet demonstrated are map, reticle, group...", + -text => "maps, triangles and groups items\nare not demonstrated here.", -anchor => 'nw', - -position => [50, 570]); + -position => [10, 550]); + MainLoop; diff --git a/Perl/demos/Tk/demos/zinc_lib/labelformat.pl b/Perl/demos/Tk/demos/zinc_lib/labelformat.pl index 5587a4e..9cb1fcb 100644 --- a/Perl/demos/Tk/demos/zinc_lib/labelformat.pl +++ b/Perl/demos/Tk/demos/zinc_lib/labelformat.pl @@ -21,8 +21,8 @@ $text->pack(qw/-expand yes -fill both/); $text->insert('0.0', 'This toy-appli demonstrates the use of labelformat for tabular items. The fieldPos (please, refer to the "labelformat type" description -in the "Zinc reference manual") of each fields as described in -the the labelformat is displayed inside the field.'); +in the "Zinc reference manual") of each field as described in +the labelformat is displayed inside the field.'); ########################################### @@ -56,23 +56,23 @@ are given in pixels"); my $labelformat2 = "300x300 x110x20+100+30 x80x20<0<0 x80x20<0>0 x80x20>0>0 x80x20>0<0"; my $tabular2 = $zinc->add('tabular',1, 5, - -position => [300,10], + -position => [270,10], -labelformat => $labelformat2, ); &setLabelContent ($tabular2,$labelformat2); -$zinc->add('text', 1, -position => [270,100], -text => +$zinc->add('text', 1, -position => [260,100], -text => "All fields positions are given relatively to field 0. -They are either on the left / -right and up/down the field 0."); +They are either on the left/right +and up/down the field 0."); ### third labelformat and tabular -my $labelformat3 = "300x300 x200x20+50+40 x80x20^0<0 x80x20^0>0 x80x20\$0>0 x80x20\$0<0 x90x20\$1<1 x90x20\$2>2 x90x20^4<4 x90x20^3>3"; +my $labelformat3 = "400x300 x200x70+100+70 x80x26^0<0 x80x26^0>0 x80x29\$0\$0 x80x32\$0^0 x90x20\<1^1 x90x20<2\$2 x90x20^4<4 x90x20^3>3"; my $tabular3 = $zinc->add('tabular',1, 9, - -position => [150,250], + -position => [150,180], -labelformat => $labelformat3, ); &setLabelContent ($tabular3,$labelformat3); @@ -84,6 +84,8 @@ Field 6 is positionned relatively to field 2..." ); +### this function displays in each field, the corresponding <fieldPos> +### part of the labelformat sub setLabelContent { my ($item,$labelformat) = @_; @@ -92,7 +94,7 @@ sub setLabelContent { my $i=0; foreach my $fieldSpec (@fieldsSpec) { - my ($posSpec) = $fieldSpec =~ /\d+.?\d+(.*)/ ; + my ($posSpec) = $fieldSpec =~ /^.\d+.\d+(.*)/ ; # print "$fieldSpec\t$i\t$posSpec\n"; $zinc->itemconfigure ($item,$i, -text => "$i: $posSpec", |