App-SourcePlot
view release on metacpan or search on metacpan
lib/App/SourcePlot.pm view on Meta::CPAN
-width => 50,
)->grid(-column => 0, -row => 0, -padx => 3, -pady => 3, -sticky => 'nsew');
# create the header
my $head = $topFrame->Text(
-wrap => 'none',
-relief => 'flat',
-foreground => 'midnightblue',
-width => 50,
-height => 1,
-font => '-*-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*',
-takefocus => 0,
)->grid(-sticky => 'ew', -row => 0);
my $title = sprintf "%5s %-16s %-12s %-13s %-4s", 'Index', 'Name',
'Ra', 'Dec', 'Epoc';
$head->insert('end', $title);
$head->configure(-state => 'disabled');
# create the scollable text
my $T = $topFrame->Scrolled(
'Text',
-scrollbars => 'e',
-background => '#333333',
-wrap => 'none',
-width => 60,
-height => 15,
-font => '-*-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*',
-setgrid => 1,
)->grid(-sticky => 'nsew', -row => 1);
$T->bindtags(qw/widget_demo/); # remove all bindings but dummy "widget_demo"
$topFrame->gridRowconfigure(1, -weight => 1);
$topFrame->gridColumnconfigure(0, -weight => 1);
# create the done button
my $buttonF = $Top->Frame->grid(-column => 0, -row => 1, -padx => 3, -pady => 3, -sticky => 'nsew');
my $doneBut = $buttonF->Button(
lib/App/SourcePlot.pm view on Meta::CPAN
# air mass case
$special = 2;
}
print "axes is special\n" if $debug;
}
print " Setting the world coordinate system\n" if $locateBug;
$plotter->worldToPixRatio($xworldRatio, $yworldRatio);
$plotter->worldAtZero($minX, $minY);
# draw the grid lines - x axis
$plotter->fontColor('White');
$plotter->drawColor('dark green');
if (($special == 1) || ($special == 2)) {
# draw the angle grid lines
for (my $z = 0; $z < 360; $z += 15) {
my $tz = (90 - $z) * pi / 180;
my $x = 92 * cos $tz;
my $y = 92 * sin $tz;
$plotter->drawLine(0, 0, $x, $y, 'grid');
}
#label the angle grid lines
lib/App/SourcePlot.pm view on Meta::CPAN
my $east = $plotter->toWx($xplot + 10);
$plotter->drawColor('black');
$plotter->drawBox($west, $maxY, $east, $top, 'foblack');
$plotter->drawBox($west, $minY, $east, $bottom, 'foblack');
$plotter->drawBox($west, $bottom, $minX, $top, 'foblack');
$plotter->drawBox($maxX, $bottom, $east, $top, 'foblack');
# plot the axes and graphs - last to make look neat
print " Plotting the grid border and labels\n" if $locateBug;
$plotter->drawColor('White');
$plotter->fontColor('White');
$plotter->drawLine($minX, $minY, $minX, $maxY, 'lwhite');
$plotter->drawLine($minX, $minY, $maxX, $minY, 'lwhite');
$plotter->drawLine($maxX, $minY, $maxX, $maxY, 'lwhite');
$plotter->drawLine($minX, $maxY, $maxX, $maxY, 'lwhite');
$plotter->raiseAbove('lwhite', 'foblack');
$plotter->raiseAbove('twhite', 'foblack');
}
# label the axes
$plotter->usingWorld(0);
lib/App/SourcePlot.pm view on Meta::CPAN
}
if ($r > 60 && defined $prevr && $prevr < 60) {
my $time = $timeH - 12 + int($i / 2) * (24 / ($NUM_POINTS - 1));
$time += 24 if $time < 0;
$time -= 24 if $time > 24;
my ($h, $m) = split /\./, $time;
$m = ('.' . $m) * 60;
$m = '0' . $m if $m < 10;
$h = '0' . $h if $h < 10;
$time = sprintf "%2s:%2s", $h, $m;
$plotter->fontColor('#ffff00');
$plotter->drawText($x, $y + 3, "$time", 'time' . $source->name());
$plotter->drawFillOval($x - 1, $y - 1, $x + 1, $y + 1, 'fo' . $source->name());
}
elsif ($r < 60 && defined $prevr && $prevr > 60) {
my $time = $timeH - 12 + int($i / 2) * (24 / ($NUM_POINTS - 1));
my $di = 24 / ($NUM_POINTS - 1);
$time -= $di;
$time += 24 if $time < 0;
$time -= 24 if $time > 24;
my ($h, $m) = split /\./, $time;
$m = ('.' . $m) * 60;
$m = '0' . $m if $m < 10;
$h = '0' . $h if $h < 10;
$time = sprintf "%2s:%2s", $h, $m;
my $x2 = 90 + $prevr * cos $prevt;
my $y2 = 90 + $prevr * sin $prevt;
$plotter->fontColor('#ffff00');
$plotter->drawText($x2, $y2 + 3, "$time", 'time' . $source->name());
$plotter->drawFillOval($x2 - 1, $y2 - 1, $x2 + 1, $y2 + 1, 'fo' . $source->name());
}
$plotter->drawFillOval($x - .5, $y - .5, $x + .5, $y + .5, 'fo' . $source->name());
push @newpoints, $x;
push @newpoints, $y;
}
elsif ($len2 > 0 && defined $prevr && $prevr < 90) {
my $dr = $r - 90;
my $pdr = 90 - $prevr;
my $nt = $dr / ($dr + $pdr) * ($prevt - $theta) + $theta;
$x = 90 + 90 * cos $nt;
$y = 90 + 90 * sin $nt;
$plotter->fontColor($source->color());
$plotter->drawTextFromLeft($x + 5, $y, $source->name(), 't' . $source->name());
push @newpoints, $x;
push @newpoints, $y;
$plotter->drawSmoothLine(@newpoints, 'l' . $source->name());
@newpoints = ();
}
elsif (defined $len2 and $len2 >= 4) {
$plotter->drawSmoothLine(@newpoints, 'l' . $source->name());
@newpoints = ();
}
lib/App/SourcePlot.pm view on Meta::CPAN
for (my $i = 1; $i < $len; $i += 2) {
my $x = $points[$i - 1];
my $y = $points[$i];
$plotter->drawFillOval($x - $xw, $y - $yw, $x + $xw, $y + $yw, 'fo' . $source->name());
if ($points[$i] > $max) {
$max = $points[$i];
$xm = $points[$i - 1];
}
}
my $ya = $plotter->toWy(5) - $plotter->toWy(0);
$plotter->fontColor($source->color());
$plotter->drawTextFromLeft($xm, $max - $ya, $source->name(), 't' . $source->name());
my @second = ();
my $prevx = $points[0];
my $prevy = $points[1];
my $plotNow = 0;
for (my $i = 3; $i < $len; $i += 2) {
my $x = $points[$i - 1];
my $y = $points[$i];
my $plotx = $x;
lib/App/SourcePlot.pm view on Meta::CPAN
my $y2 = $source->timeDotY();
if ($x2 ne '' && $y2 ne '') {
$plotter->$plotstyle($x2 - $sX, $y2 - $sY, $x2 + $sX, $y2 + $sY, 'timeDot' . $source->name());
$plotter->bindTag(
'timeDot' . $source->name(),
'<Any-Enter>' => sub {
$plotter->drawColor($source->color());
$plotter->drawFillOval($x2 - $sX, $y2 - $sY, $x2 + $sX, $y2 + $sY, 'ltimeDot' . $source->name());
# draw AZ-EL pointers
$plotter->drawColor('red');
$plotter->fontColor('red');
$plotter->penWidth(2);
$plotter->drawLine($x2 - $elex, $y2 - $eley, $x2, $y2, 'ltimeDot' . $source->name());
$plotter->drawLine($x2 - $azx, $y2 - $azy, $x2, $y2, 'ltimeDot' . $source->name());
$plotter->penWidth(1);
my ($xoff, $yoff) = $plotter->toW(7, 7);
$xoff -= $plotter->toWx(0);
$yoff -= $plotter->toWy(0);
$plotter->drawText($x2 - $elex - $xoff, $y2 - $eley - $yoff, 'El', 'ltimeDot' . $source->name());
# and RA-Dec box
my $bx = 1.5 * sqrt($azx * $azx + $elex * $elex);
my $by = 1.5 * sqrt($azy * $azy + $eley * $eley);
$plotter->drawLine($x2 - $bx, $y2 - $by, $x2 - $bx, $y2 + $by, 'ltimeDot' . $source->name());
$plotter->drawLine($x2 - $bx, $y2 + $by, $x2 + $bx, $y2 + $by, 'ltimeDot' . $source->name());
$plotter->drawLine($x2 + $bx, $y2 + $by, $x2 + $bx, $y2 - $by, 'ltimeDot' . $source->name());
$plotter->drawLine($x2 + $bx, $y2 - $by, $x2 - $bx, $y2 - $by, 'ltimeDot' . $source->name());
$plotter->drawText($x2, $y2 - 1.2 * $by, 'R.A.', 'ltimeDot' . $source->name());
$plotter->drawText($x2 - 1.12 * $bx, $y2 + 0.2 * $by, 'D', 'ltimeDot' . $source->name());
$plotter->drawText($x2 - 1.1 * $bx, $y2, 'e', 'ltimeDot' . $source->name());
$plotter->drawText($x2 - 1.1 * $bx, $y2 - 0.2 * $by, 'c', 'ltimeDot' . $source->name());
$plotter->fontColor($source->color());
},
);
$plotter->bindTag(
'ltimeDot' . $source->name(),
'<Any-Leave>' => sub {
$plotter->delete('ltimeDot' . $source->name());
},
);
}
}
lib/App/SourcePlot/Plotter/Tk.pm view on Meta::CPAN
$plotter->setForeground('black');
=cut
sub setForeground {
my $self = shift;
my $color = shift;
$self->getCanvas()->configure(-foreground => $color);
}
=item font
Sets and returns the font currently being used.
$f = $plotter->font();
$plotter->font($f);
=cut
sub font {
my $self = shift;
if (@_) {
$self->{FONT} = shift;
}
return $self->{FONT};
}
=item fontColor
Sets and returns the font color.
$plotter->fontColor('black');
=cut
sub fontColor {
my $self = shift;
if (@_) {
$self->{FONT_COLOR} = shift;
}
return $self->{FONT_COLOR};
}
=item fontSize
Sets and returns the font size.
$plotter->fontSize(5);
$size = $plotter->fontSize();
=cut
sub fontSize {
my $self = shift;
my $font = $self->font();
$font =~ /\d+/;
my $before = $`;
my $num = $&;
my $end = $';
if (@_) {
my $size = shift;
$self->font($before . $size . '0' . $end);
$self->{FONTSIZE} = $size;
}
else {
$self->{FONT_SIZE} = $num / 10 if (!defined $self->{FONT_SIZE});
}
return $self->{FONT_SIZE};
}
=item drawColor
lib/App/SourcePlot/Plotter/Tk.pm view on Meta::CPAN
sub lowerBelow {
my $self = shift;
my $tag = shift;
my $tag2 = shift;
$self->getCanvas()->lower($tag, $tag2);
}
=item drawTextVert
Draws text on the canvas in the given (x, y) coordinates using
the current font, font size, and font Color. Returns the text item
number. Adds a tag name if one is given. Draws it vertically
$plotter->drawTextVert(5, 5, "hello");
$id = $plotter->drawTextVert(5, 5, "hello", 'text');
=cut
sub drawTextVert {
my $self = shift;
my $x = shift;
my $y = shift;
my $text = shift;
my $font = $self->font();
if ($self->usingWorld()) {
$font =~ /\d+/;
my $before = $`;
my $num = $&;
my $end = $';
$num = ($num / 10) / $self->worldToPixRatio();
$num = s/\..+//;
$font = $before . $num . '0' . $end;
}
my $t = $self->getCanvas()->create(
'text',
$self->toP($x, $y),
-text => $text,
-font => $font,
-width => 1,
-fill => $self->fontColor()
);
if (@_) {
my $tag = shift;
$self->getCanvas()->addtag($tag, 'withtag', $t);
}
return $t;
}
=item drawText
Draws text on the canvas in the given (x, y) coordinates using
the current font, font size, and font Color. Returns the text item
number. Adds a tag name if one is given.
$plotter->drawText(5, 5, "hello");
$id = $plotter->drawText(5, 5, "hello", 'text');
=cut
sub drawText {
my $self = shift;
my $x = shift;
my $y = shift;
my $text = shift;
my $font = $self->font();
if ($self->usingWorld()) {
$font =~ /\d+/;
my $before = $`;
my $num = $&;
my $end = $';
$num = ($num / 10) / $self->worldToPixRatio();
$num = s/\..+//;
$font = $before . $num . '0' . $end;
}
my $t = $self->getCanvas()->create(
'text',
$self->toP($x, $y),
-text => $text,
-font => $font,
-fill => $self->fontColor()
);
if (@_) {
my $tag = shift;
$self->getCanvas()->addtag($tag, 'withtag', $t);
}
return $t;
}
=item drawTextFromLeft
Draws text on the canvas in the given (x, y) coordinates using
the current font, font size, and font Color. Returns the text item
number. Adds a tag name if one is given.
$plotter->drawTextFromLeft(5, 5, "hello");
$id = $plotter->drawTextFromLeft(5, 5, "hello", 'text');
=cut
sub drawTextFromLeft {
my $self = shift;
my $x = shift;
my $y = shift;
my $text = shift;
my $font = $self->font();
if ($self->usingWorld()) {
$font =~ /\d+/;
my $before = $`;
my $num = $&;
my $end = $';
$num = ($num / 10) / $self->worldToPixRatio();
$num = s/\..+//;
$font = $before . $num . '0' . $end;
}
my $t = $self->getCanvas()->create(
'text',
$self->toP($x, $y),
-text => $text,
-font => $font,
-fill => $self->fontColor(),
-anchor => 'w'
);
if (@_) {
my $tag = shift;
$self->getCanvas()->addtag($tag, 'withtag', $t);
}
return $t;
}
=item drawTextFromRight
Draws text on the canvas in the given (x, y) coordinates using
the current font, font size, and font Color. Returns the text item
number. Adds a tag name if one is given.
$plotter->drawTextFromRight(5, 5, "hello");
$id = $plotter->drawTextFromRight(5, 5, "hello", 'text');
=cut
sub drawTextFromRight {
my $self = shift;
my $x = shift;
my $y = shift;
my $text = shift;
my $font = $self->font();
if ($self->usingWorld()) {
$font =~ /\d+/;
my $before = $`;
my $num = $&;
my $end = $';
$num = ($num / 10) / $self->worldToPixRatio();
$num = s/\..+//;
$font = $before . $num . '0' . $end;
}
my $t = $self->getCanvas()->create(
'text',
$self->toP($x, $y),
-text => $text,
-font => $font,
-fill => $self->fontColor(),
-anchor => 'e'
);
if (@_) {
my $tag = shift;
$self->getCanvas()->addtag($tag, 'withtag', $t);
}
return $t;
}
=item drawOval
( run in 3.203 seconds using v1.01-cache-2.11-cpan-ceb78f64989 )