#=============================================== # TkGeneralDataFile #=============================================== package TkGeneralDataFile; use Sci::GeneralDataFile; use MyTk::TkCommon; @ISA = qw(GeneralDataFile TkCommon); #公開したいサブルーチン #@EXPORT = qw(DelSpace Reduce01 MakePath RegExpQuote); use strict; use Utils; BEGIN { } sub new { my ($module, $app, $canvas) = @_; my $this = {}; bless $this; $this->SetApplication($app); $this->SetCanvas($canvas); return $this; } sub DESTROY { my $this = shift; $this->SUPER::DESTROY(@_); } sub SetCanvas { my($this,$can)=@_; return $this->{'Canvas'} = $can; } sub Canvas { return shift->{'Canvas'}; } sub GetGraphFrameArray { return shift->{'GraphFrameArray'}; } sub CreateGraphFrame { my ($this, $canvas) = @_; $this->SetCanvas($canvas) if($canvas); $canvas = $this->Canvas() unless($canvas); my $App = $this->App(); my $font = $App->{'GraphFrameFont'}; my @font = split(/,/, $font) if($font); my $w = $canvas->width(); my $h = $canvas->height(); my $FileType = $this->FileType(); # Canvas, GraphFrameの初期化 my $GraphFrameArray = $this->{'GraphFrameArray'} = new GraphFrameArray($this->mw(), $canvas); $GraphFrameArray->AddGraphFrame(); my $GraphFrame0 = $GraphFrameArray->GetGraphFrame(0); $GraphFrameArray->SetFont(\@font) if($font); $GraphFrameArray->SetXCaption('X'); $GraphFrameArray->SetYCaption('Y'); $GraphFrameArray->SetCanvasSize($w, $h); my $FramePosStr0 = $App->{"GraphFrame0Position"}; $GraphFrame0->SetPositionByStr($FramePosStr0); my $XScale0 = $GraphFrame0->GetXScale(0); my $YScale0 = $GraphFrame0->GetYScale(0); $GraphFrame0->SetViewRange(0, 0, 1, 1); } sub AssignGraphData { my ($this) = @_; my $GraphFrameArray = $this->GetGraphFrameArray(); my $GraphFrame0 = $GraphFrameArray->GetGraphFrame(0); my $pDataArray = $this->DataArray(); my $Data = $pDataArray->GetGraphData(0); my $nData = $Data->nData(); my $title = $Data->Title(); my $pX0 = $Data->GetDataArray('x0'); for(my $i = 0 ; ; $i++) { my $pY = $Data->GetDataArray("y$i"); last unless($pY); $GraphFrame0->AddGraphData($pX0, $pY, 1, "black", "", 6, "black", 0, "black", "XAutoSkip"); } $GraphFrame0->CalMinMax(); $GraphFrame0->AdjustViewRange(0.05, 0.05, 0.05, 0.05); $this->AdjustViewRange(); } sub AdjustViewRange { my ($this) = @_; my $GraphFrameArray = $this->GetGraphFrameArray(); my $pGraphFrame = $GraphFrameArray->GetpGraphFrameArray(); my ($xmin, $xmax) = $pGraphFrame->[0]->GetViewXRange(); my ($ymin, $ymax) = $pGraphFrame->[0]->GetViewYRange(); } sub Draw { my ($this, $canvas) = @_; my $mw = $this->mw(); my $GraphFrameArray = $this->GetGraphFrameArray(); my $pGraphFrame = $GraphFrameArray->GetpGraphFrameArray(); my @GraphFrame = @$pGraphFrame; $canvas = $this->Canvas() unless($canvas); my $App = $this->App(); my $font = $App->{'GraphFrameFont'}; my @font = split(/,/, $font) if($font); my $w = $canvas->width(); my $h = $canvas->height(); $canvas->SetFont(\@font) if($font);; $GraphFrameArray->SetCanvasSize($w, $h); $GraphFrameArray->Draw($canvas); } 1;