App-SourcePlot
view release on metacpan or search on metacpan
lib/App/SourcePlot.pm view on Meta::CPAN
)->pack(-side => 'left');
$balloon->attach($newBut, -balloonmsg => "Press to manually\nadd a source");
# create the planet button
my $planBut = $manipF->Menubutton(
-text => 'Planets',
-width => 7,
-relief => 'raised',
);
{
my $k = 0;
foreach my $plan (@planets) {
my $c = $k;
$planBut->command(
-label => $plan,
-command => sub {
&addPlanetSource($plan, $c);
print "$TEL is tel \n" if $locateBug;
fillWithSourceList($EditWin, 'full');
plot();
}
);
$k ++;
}
}
$planBut->command(
-label => 'All',
-command => sub {
my $j = 0;
foreach (@planets) {
&addPlanetSource($_, $j);
$j ++;
}
fillWithSourceList($EditWin, 'full');
plot();
}
);
$planBut->pack(-side => 'left');
$balloon->attach($planBut, -balloonmsg => "Press to add a planet\nto the plot");
$Top->gridRowconfigure(0, -weight => 1);
$Top->gridColumnconfigure(0, -weight => 1);
$EditWin->{'Window'} = $Top;
$EditWin->{'Text'} = $T;
$EditWin->{'Selected'} = \@selected;
$EditWin->{'Sources'} = \@SOURCE_LIST;
fillWithSourceList($EditWin, 'full');
$MW->update;
}
=item B<fillWithSourceList>
Fills a Text box with the list of current sources.
=cut
sub fillWithSourceList {
my (@bold, @normal);
my $Window = shift;
my $T = $Window->{'Text'};
my $selected = $Window->{'Selected'};
my $arrayOfSources = $Window->{'Sources'};
my $task = shift;
my $sort = shift;
my $index = shift;
my (@sources);
my ($source);
my @entered = ();
my ($line, $itag);
@sources = @$arrayOfSources;
if (defined $sort) {
for ($sort) {
/unsorted/ and do {@sources = @$arrayOfSources; last;};
/name/ and do {@sources = sort by_name @$arrayOfSources; last;};
/ra/ and do {@sources = sort by_ra @$arrayOfSources; last;};
/dec/ and do {@sources = sort by_dec @$arrayOfSources; last;};
die "Unknown value for form variable \$sort \n";
}
}
# Enable infobox for access
$T->configure(-state => 'normal');
# Clear the existing widgets
if (defined $task && $task eq 'full') {
$T->delete('1.0', 'end');
foreach my $source (@sources) {
$T->tagDelete('d' . $source->index());
}
}
# Set up display styles
if ($T->depth > 1) {
@bold = ('-background' => '#eeeeee', '-relief' => 'raised', '-borderwidth' => 1);
@normal = ('-background' => undef, '-relief' => 'flat');
}
else {
@bold = ('-foreground' => 'white', '-background' => 'black');
@normal = ('-foreground' => undef, '-background' => undef);
}
$T->tag(configure => 'normal', '-foreground' => 'blue');
$T->tag(configure => 'inactive', '-foreground' => 'black');
$T->tag(configure => 'selected', '-foreground' => 'red');
foreach (@COLOR_LIST) {
$T->tag('configure', $_, '-foreground' => $_);
}
# Insert the current values
if (defined $task && $task eq 'full') {
my $len = @sources;
for ($index = 0; $index < $len; $index ++) {
$source = $sources[$index];
$source->index($index);
$line = $source->dispLine();
if (&isWithin($source, @$selected)) {
inswt($T, "$line\n", "d$index", 'selected');
}
else {
if ($source->active()) {
if ($source->color() ne '') {
inswt($T, "$line\n", "d$index", $source->color());
}
else {
inswt($T, "$line\n", "d$index", 'normal');
}
}
else {
inswt($T, "$line\n", "d$index", 'inactive');
}
}
}
$len = @sources;
for ($itag = 0; $itag < $len; $itag ++) {
my $dtag = "d$itag";
$T->tag(
'bind', $dtag,
'<Any-Enter>' => sub {
shift->tag('configure', $dtag, @bold);
if ($Window->{'Changeable'} && $sources[substr($dtag, 1, 99)]->active()) {
$plotter->configureTag(
'l' . $sources[substr($dtag, 1, 99)]->name(),
-width => 3);
}
},
);
$T->tag(
'bind', $dtag,
'<Any-Leave>' => sub {
shift->tag('configure', $dtag, @normal);
if ($Window->{'Changeable'} && $sources[substr($dtag, 1, 99)]->active()) {
$plotter->configureTag(
'l' . $sources[substr($dtag, 1, 99)]->name(),
-width => 1);
}
},
);
$T->tag(
'bind', $dtag,
'<ButtonRelease-1>' => sub {
if (! $BUSY) {
if (! &isWithin($sources[substr($dtag, 1, 99)], @$selected)) {
shift->tag('configure', $dtag,
-foreground => 'red');
push @$selected, $sources[substr($dtag, 1, 99)];
}
else {
if ($sources[substr($dtag, 1, 99)]->color() ne '') {
shift->tag('configure', $dtag,
-foreground => $sources[substr($dtag, 1, 99)]->color()
);
}
else {
shift->tag('configure', $dtag,
-foreground => 'blue');
}
&remove($sources[substr($dtag, 1, 99)], $selected);
}
}
},
);
if ($Window->{'Changeable'}) {
$T->tag(
'bind', $dtag,
'<Double-1>' => sub {
my $source = $sources[substr($dtag, 1, 99)];
$LAST_COMMAND = 'Change';
@UNDO_LIST = ($source->coords());
&getSource($source);
my $res = &waitForResponse();
if ($res) {
$undoBut->configure(-state => 'normal')
if $EDIT_OPEN;
}
else {
$undoBut->configure(-state => 'disabled')
if $EDIT_OPEN;
}
push @UNDO_LIST, $source;
lib/App/SourcePlot.pm view on Meta::CPAN
if ($prevy < 100 && $y > 260) {
my $len2 = @second;
if ($len2 > 0) {
$ploty = $y - 360;
$plotyn = $prevy + 360;
$plotNow = 1;
}
}
elsif ($y < 100 && $prevy > 260) {
my $len2 = @second;
if ($len2 > 0) {
$ploty = $y + 360;
$plotyn = $prevy - 360;
$plotNow = 1;
}
}
}
elsif ($X_AXIS =~ /azimuth/i) {
if ($prevx < 100 && $x > 260) {
my $len2 = @second;
if ($len2 > 0) {
$plotx = $x - 360;
$plotxn = $prevx + 360;
$plotNow = 1;
}
}
elsif ($x < 100 && $prevx > 260) {
my $len2 = @second;
if ($len2 > 0) {
$plotx = $x + 360;
$plotxn = $prevx - 360;
$plotNow = 1;
}
}
}
if ($plotNow) {
$plotNow = 0;
push @second, $plotx;
push @second, $ploty;
$plotter->drawSmoothLine(@second, 'l' . $source->name());
@second = ();
push @second, $plotxn;
push @second, $plotyn;
}
elsif ($i == $len - 1) {
push @second, $x;
push @second, $y;
}
$prevx = $x;
$prevy = $y;
}
@points = @second;
}
my $len2 = @points;
$plotter->drawSmoothLine(@points, 'l' . $source->name())
if ($len2 > 0);
my @bold = (
'-background' => "#bbbbbb",
'-foreground' => 'black',
'-relief' => 'raised',
'-borderwidth' => 1,
);
my @normal = (
'-background' => undef,
'-foreground' => $source->color(),
'-relief' => 'flat',
);
$plotter->bindTag(
'l' . $source->name(),
'<Any-Enter>' => sub {
my $s = $source;
if ($s->active()) {
$EditWin->{'Text'}->tag('configure', 'd' . $s->index(), @bold)
if $EDIT_OPEN;
$plotter->configureTag('l' . $s->name(), -width => 3);
}
},
);
$plotter->bindTag(
'l' . $source->name(),
'<Any-Leave>' => sub {
my $s = $source;
if ($s->active()) {
$EditWin->{'Text'}->tag('configure', 'd' . $s->index(), @normal)
if $EDIT_OPEN;
$plotter->configureTag('l' . $s->name(), -width => 1);
}
},
);
}
$plotter->penWidth(1);
#calculate where the time dots go.
calcTime($source);
if ($plotter->existTag('foblack')) {
if ($plotter->existTag('timeDot' . $source->name())) {
$plotter->raiseAbove('timeDot' . $source->name(), 'l' . $source->name());
$plotter->raiseAbove('foblack', 'timeDot' . $source->name());
}
elsif ($plotter->existTag('l' . $source->name())) {
$plotter->raiseAbove('foblack', 'l' . $source->name());
}
$plotter->raiseAbove('t' . $source->name(), 'foblack')
if $plotter->existTag('t' . $source->name());
$plotter->raiseAbove('lwhite', 'foblack');
$plotter->raiseAbove('twhite', 'foblack');
}
else {
$plotter->raiseAbove('lwhite', 'l' . $source->name())
if $plotter->existTag('l' . $source->name());
$plotter->raiseAbove('twhite', 'l' . $source->name())
if $plotter->existTag('l' . $source->name());
}
}
calcTime('TelescopePosition');
if (defined $Top) {
destroy $Top;
}
$plotter->penWidth(1);
}
print "Exit plot\n" if $locateBug;
}
=item B<am_to_deg>
Converts air mass to degrees.
=cut
( run in 1.083 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )