#======================================================== # BandGraphFrame #======================================================== package BandGraphFrame; use MyTk::GraphFrame; @ISA = qw(GraphFrame); #公開したいサブルーチン #@EXPORT = qw(); use strict; #============================================================ # ローカル大局変数 #============================================================ my @PredefinedColors = ("black", "red", "blue", "brown", "purple", "violet", "cyan", "magenta", "green", "yellow", "pink", "orange1", "grey", "dark red", "dark blue", "brown4", "purple3", "dark violet", "dark cyan", "dark magenta", "dark green", "yellow4", "DeepPink1", "white"); my $nColors = @PredefinedColors; my $CurColor = 0; #============================================================ # 静的メンバー関数 #============================================================ #============================================================ # 変数等取得関数 #============================================================ #============================================================ # コンストラクタ、デストラクタ #============================================================ sub new($$) { my ($module, $mainwindow, $idx) = @_; my $this = {}; bless $this; # $this->SUPER::new($mainwindow, $idx); # $this->{'Canvas'} = $canvas; $this->{'MainWindow'} = $mainwindow; $idx = 0 unless($idx); my @DataArray; $this->{'DataArray'} = \@DataArray; my @array; $this->{'GraphScaleArray'} = \@array; my @SXArray; $this->{'XSynchronousGraphFrameArray'} = \@SXArray; my @SYArray; $this->{'YSynchronousGraphFrameArray'} = \@SYArray; $this->SetIndex($idx); $this->{'XCaption'} = "Energy / eV"; $this->{'YCaption'} = "Intensity / cps"; $this->AddXScale("xbottom", "x"); # $this->AddXScale("xtop", "x"); $this->AddYScale("yleft", "x"); # $this->AddYScale("yright", "x"); $this->SetLinesVisible(1, 1, 1, 1, 1, 1); $this->SetViewRange(0, 0, 1, 1); $CurColor = 0; return $this; } sub DESTROY { my $this = shift; # $this->SUPER::DESTROY(@_); } #============================================================ # 一般関数 #============================================================ sub Draw { my ($this, $canvas) = @_; $canvas = $this->Canvas() unless(defined $canvas); my $rect = $this->SUPER::Draw($canvas); my $pBandBoundaryDistances = $this->{'pBandBoundaryDistances'}; my $pBoundaryPositions = $this->{'pBandBoundaryPositions'}; return unless(defined $pBoundaryPositions); my $pKPointName = $this->{'KPointNameArray'}; if($pKPointName) { $this->SetScaleVisible('X', 0); $this->SetScaleStringVisible('X', 0); $this->SetXCaption(''); } else { $this->SetScaleVisible('X', 1); $this->SetScaleStringVisible('X', 1); $this->SetXCaption('k'); } my ($x0, $y0, $x1, $y1) = $this->GetPosition(); my ($vx0, $vx1) = $this->GetViewXRange(); my %TagHash; for(my $i = 0 ; $i < @$pBandBoundaryDistances ; $i++) { my $b = $pBandBoundaryDistances->[$i]; next if($b < $vx0 or $vx1 < $b); my ($x, $y) = $this->ValueToPosition($b, 0); my $str = $pBoundaryPositions->[$i]; my $tag = "Boundary$i"; $b = Utils::Round($b, 4); $TagHash{$tag} = "($str) x=$b"; $canvas->DrawLine($x, $y0, $x, $y1, 1, "black", $tag); if($pKPointName) { my $Name = $pKPointName->[$i]; #print "KPoint: $Name\n"; $this->DrawSymbolChar($canvas, $x, $y0+2, $Name); } } $this->mw()->Balloon()->attach($canvas, -balloonposition => 'mouse', -msg => \%TagHash); return $rect; } 1;