App-SourcePlot
view release on metacpan or search on metacpan
lib/App/SourcePlot.pm view on Meta::CPAN
-text => 'Ok',
-command => sub {
$source->configure($nameEnt->get(), $raEnt->get(), $decEnt->get(), $epocEnt);
destroy $Top;
$RESPONSE = 1;
},
)->pack(-side => 'right');
$buttonF->Button(
-text => 'Cancel',
-command => sub {
destroy $Top;
$RESPONSE = -1;
},
)->pack(-side => 'right');
$Top->update;
$Top->grab;
}
=item B<editSource>
Edits the existing source list.
=cut
sub editSource {
my (@selected) = ();
my $udeb = 0; #debugger
$eBut->configure(-state => 'disabled');
my $Top = $MW->Toplevel();
$Top->geometry('+600+90');
$Top->title('Source Plot: Edit Window');
$Top->resizable(1, 1);
my $topFrame = $Top->Frame(
-relief => 'groove',
-borderwidth => 2,
-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(
-text => 'Done',
-width => 4,
-command => sub {
destroy $Top;
},
)->pack(-side => 'right');
$balloon->attach($doneBut, -balloonmsg => "Press to close the Edit Window");
# Closing the window should reset $eBut.
$Top->bind('<Destroy>', sub {
my $widget = shift;
return unless $widget == $Top;
$eBut->configure(-state => 'normal');
$EDIT_OPEN = 0;
});
# create the On / Off button
my $OOBut = $buttonF->Button(
-text => 'ON/Off',
-width => 5,
-command => sub {
my $source;
foreach $source (@selected) {
if ($source->active()) {
tagOnOff($source->name(), 0);
$source->active(0);
$T->tag(
'configure',
'd' . $source->index(),
-foreground => 'black'
);
}
else {
tagOnOff($source->name(), 1, $source->color(), 'yellow');
$source->active(1);
$T->tag(
'configure',
'd' . $source->index(),
-foreground => $source->color()
);
}
}
@selected = ();
},
)->pack(-side => 'left');
$balloon->attach($OOBut, -balloonmsg => "Press to turn the selected\nsources On/Off");
lib/App/SourcePlot.pm view on Meta::CPAN
$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,
lib/App/SourcePlot.pm view on Meta::CPAN
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);
}
( run in 1.374 second using v1.01-cache-2.11-cpan-0d23b851a93 )