| 1 |
## -*- cperl -*- |
| 2 |
## |
| 3 |
## This file is part of Athena, copyright (c) 2001-2008 Bruce Ravel |
| 4 |
## |
| 5 |
## This section of the code contains the subroutine for dealing with |
| 6 |
## the Group list in the skinny frame |
| 7 |
|
| 8 |
|
| 9 |
sub fill_skinny { |
| 10 |
|
| 11 |
my ($list, $item, $is_file, $dont_set) = @_; |
| 12 |
my $list_canvas = ($list->children())[0]; |
| 13 |
#my ($group, $label) = group_name($item); |
| 14 |
my ($group, $label) = ($groups{$item}->{group}, $groups{$item}->{label}); |
| 15 |
my $vio = $config{colors}{marked}; |
| 16 |
|
| 17 |
## begin drawing widgets on the skinny canvas |
| 18 |
|
| 19 |
## the values for widget placement were determined by trial and error |
| 20 |
my $step = $config{list}{real_y}; # see delete_group in group_ops.pl |
| 21 |
my ($cx, $cy, $tx, $ty) = ($config{list}{real_x1}.'c', |
| 22 |
sprintf("%4.2fc",1.1+$step*$line_count), |
| 23 |
$config{list}{real_x2}.'c',, |
| 24 |
sprintf("%4.2fc",1.1+$step*$line_count)); |
| 25 |
|
| 26 |
($is_file) and ($marked{$group} = 0); |
| 27 |
++$group_count; |
| 28 |
my $tag = sprintf("line_%d", $group_count); # checkbutton for marking groups |
| 29 |
$groups{$item}->make(bindtag=>$tag); |
| 30 |
my $checkbutton; |
| 31 |
if ($is_file) { |
| 32 |
$checkbutton = $list -> Checkbutton(-selectcolor=>$vio, -variable => \$marked{$group},); |
| 33 |
} else { |
| 34 |
$checkbutton = $list -> Frame(qw/-width 18p -height 10p -borderwidth 0/); |
| 35 |
}; |
| 36 |
my $check = $list -> createWindow($cx, $cy, -anchor=>'e', -window => $checkbutton); |
| 37 |
## change text size/color unless passing over the current group |
| 38 |
## (this works because the text has only one tag associated with it, |
| 39 |
## which is the first item in the list returned by the itemcget method. |
| 40 |
## Take care not to undo the orange group. The rectangle is below the text. |
| 41 |
my @bold = (-fill => $config{colors}{activehighlightcolor}, ); |
| 42 |
my @normal = (-fill => $config{colors}{foreground}, ); |
| 43 |
my @rect_in = (-fill => $config{colors}{activebackground}, -outline=>$config{colors}{activebackground}); |
| 44 |
my @rect_out = (-fill => $config{colors}{background}, -outline=>$config{colors}{background}); |
| 45 |
$list -> bind($tag, '<Any-Enter>'=>sub{my $this = shift; |
| 46 |
return if not exists($groups{$current}->{bindtag}); |
| 47 |
$this->configure(-cursor => $mouse_over_cursor); |
| 48 |
if ($this->itemcget('current', '-tags')->[0] ne $groups{$current}->{bindtag}) { |
| 49 |
#$this->itemconfigure('current', @bold ); |
| 50 |
my $x = $this->find(below=>'current'); |
| 51 |
$this->itemconfigure($x, @rect_in,); |
| 52 |
} |
| 53 |
}); |
| 54 |
$list -> bind($tag, '<Any-Leave>'=>\&Leave); |
| 55 |
## sub{my $this = shift; |
| 56 |
## return if not exists($groups{$current}->{bindtag}); |
| 57 |
## if ($this->itemcget('current', '-tags')->[0] ne $groups{$current}->{bindtag}) { |
| 58 |
## my $x = $this->find(below=>'current'); |
| 59 |
## $this->itemconfigure($x, @rect_out,); |
| 60 |
## }; |
| 61 |
## } |
| 62 |
## this rectangle is colored to indicate the selected group |
| 63 |
## write the name of the group over the rectangle |
| 64 |
my $text = $list -> createText($tx, $ty, -anchor=>'w', -text=>$label, -tags=>$tag, |
| 65 |
-font => $config{fonts}{med}); |
| 66 |
## see set_properties for how this rectangle is managed |
| 67 |
my $rect = $list -> createRectangle($list->bbox($text), #$tx1, $ty1, $tx2, $ty2, |
| 68 |
-width=>5, |
| 69 |
-fill=>$config{colors}{background}, |
| 70 |
-outline=>$config{colors}{background}); |
| 71 |
$list_canvas->raise($text, $rect); |
| 72 |
|
| 73 |
## set a few features of the data object that Athena uses to display |
| 74 |
## the data |
| 75 |
$groups{$group} -> make(check=>$check, rect=>$rect, text=>$text, checkbutton=>$checkbutton); |
| 76 |
## deal with the element and edge symbols |
| 77 |
if (not $reading_project) { |
| 78 |
if ($groups{$group}->{is_pixel}) { |
| 79 |
$groups{$group} -> make(bkg_z=>'H', fft_edge=>'K',); |
| 80 |
} elsif ($groups{$group}->{not_data}) { |
| 81 |
1; |
| 82 |
} elsif (lc($groups{$group}->{bkg_z}) eq 'h') { |
| 83 |
my ($sym, $edg) = find_edge($groups{$group}->{bkg_e0}); |
| 84 |
$groups{$group} -> make(bkg_z=>$sym, fft_edge=>$edg,); |
| 85 |
}; |
| 86 |
## adjust e0 if configured for half-step, zero crossing, or atomic |
| 87 |
if ($config{bkg}{e0} eq 'fraction') { |
| 88 |
$groups{$group} -> dispatch_bkg($dmode); |
| 89 |
set_edge($group, 'fraction'); |
| 90 |
} elsif ($config{bkg}{e0} eq 'zero') { |
| 91 |
$groups{$group} -> dispatch_bkg($dmode); |
| 92 |
set_edge($group, 'zero'); |
| 93 |
} elsif ($config{bkg}{e0} eq 'atomic') { |
| 94 |
Echo("Cannot fetch atomic e0 values."), return unless $absorption_exists; |
| 95 |
$groups{$group} -> dispatch_bkg($dmode); |
| 96 |
set_edge($group, 'atomic'); |
| 97 |
}; |
| 98 |
set_edge_peak($group) if ( $config{bkg}{ledgepeak} |
| 99 |
and get_Z($config{bkg}{ledgepeak}) |
| 100 |
and (get_Z($groups{$group}->{bkg_z}) > get_Z($config{bkg}{ledgepeak})) |
| 101 |
and ($groups{$group}->{fft_edge} =~ m{l[23]}i) |
| 102 |
); |
| 103 |
}; |
| 104 |
$groups{$group} -> make(bkg_eshift=>0) unless ($groups{$group}->{bkg_eshift} =~ /-?(\d+\.?\d*|\.\d+)/); |
| 105 |
$groups{$group} -> make(bkg_nclamp => $config{bkg}{nclamp}, |
| 106 |
bkg_tie_e0 => 0, |
| 107 |
bkg_former_e0 => $groups{$group}->{bkg_e0}); |
| 108 |
|
| 109 |
## adjust view so this one is showing |
| 110 |
push @skinny_list, $check, $rect, $text; |
| 111 |
my $h = ($list->bbox(@skinny_list))[3] + 5; |
| 112 |
if ($h > 200) { |
| 113 |
$list -> configure(-scrollregion=>['0', '0', '200', $h]); |
| 114 |
$list -> yview('moveto', 1); |
| 115 |
}; |
| 116 |
|
| 117 |
## mouse bindings in the groups list |
| 118 |
#$list -> bind($tag, '<Double-Button-1>' => sub{set_properties($group, 0); &get_new_name;}); |
| 119 |
$list -> bind($tag, '<Double-Button-1>' => sub{set_properties(1, $group, 0); $list_canvas->focus; &get_new_name;}); |
| 120 |
$list -> bind($tag, '<1>' => [\&set_properties, $group, 0]); |
| 121 |
$list -> bind($tag, '<2>' => sub{$marked{$group} = !$marked{$group}}); |
| 122 |
($is_file) and |
| 123 |
$list -> bind($tag, '<3>' => [\&GroupsPopupMenu, $group, Ev('X'), Ev('Y')]); |
| 124 |
|
| 125 |
## finally, fill parameters into the fat canvas |
| 126 |
set_properties(1, $group, 0) unless $dont_set; |
| 127 |
project_state(0); |
| 128 |
}; |
| 129 |
|
| 130 |
|
| 131 |
## END OF GROUP LIST SUBSECTION |
| 132 |
########################################################################################## |