#=============================================== # TkEllipsometrySi #=============================================== package TkEllipsometrySi; use TkPlotModule; @ISA = qw(TkPlotModule); #公開したいサブルーチン #@EXPORT = qw(DelSpace Reduce01 MakePath RegExpQuote); use strict; #use Tk::JPEG; use Utils; use IniFile; use CSV; use Tk; use Tk::Balloon; use MyTk::Dialog; use MyTk::MyFrame; use MyTk::MyLabFrame; use MyTk::MyLabel; use MyTk::MyEntry; use MyTk::MyListbox; use MyTk::MyBrowseEntry; use MyTk::MyText; use MyTk::MyButton; use MyTk::MyCheckbutton; use MyTk::MyMenubutton; use MyTk::MyCanvas; use MyTk::MyAdjuster; use MyTk::MyScale; use MyTk::GraphFrameArray; use GraphData; use Sci::Science; use Sci::Material; use Sci::Ellipsometry; use Sci::MultiLayer; use Sci::OpticalMaterial; my $pi = Sci::pi(); my $kB = Sci::kB(); my $c = Sci::c(); my $e = Sci::e(); my $e0 = Sci::e0(); my $me = Sci::me(); my $mp = Sci::mp(); my $mn = Sci::mn(); my $h = Sci::h(); my $hbar = Sci::hbar(); my $torad = Sci::torad(); my $todeg = Sci::todeg(); my $material = new Material; #============================================================ # 変数等取得関数 #============================================================ sub FileType { return shift->{FileType}; } sub SetFileType { my ($this,$t)=@_; return $this->{FileType} = $t; } sub FileName { my ($this)=@_; $this->{FileName} = '' if(!defined $this->{FileName}); return shift->{FileName}; } sub SetFileName { my ($this,$f)=@_; return $this->{FileName} = $f; } sub SetDataArray { my ($this, $da)=@_; return $this->{DataArray} = $da; } sub DataArray { return shift->{DataArray}; } sub GetColor { return shift->{Color}; } sub ColorMapImage { return shift->{ColorMapImage}; } sub SetColorMapImage { my ($this,$m)=@_; return shift->{ColorMapImage} = $m; } #============================================================ # コンストラクタ、デストラクタ #============================================================ sub new { my ($module, $app) = @_; # 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 CreateLeftFrame { my ($this, $ConfigSide, @args) = @_; # return $this->SUPER::CreateLeftFrame(); return undef; } sub CreateSelectFilePane { my ($this) = @_; # return $this->SUPER::CreateSelectFilePane(); return undef; } sub CreateFileContentPane { return undef; } sub CreateWidgets { my ($this) = @_; my $App = $this->App(); my $args = $App->Args(); my $mw = $this->mw(); $this->{ini} = new IniFile; $this->{Ellipsometry} = new Ellipsometry; $this->SUPER::CreateWidgets(); #=================================================== # ペインを作製 #=================================================== my $Frame = $mw->MyFrame()->pack(-anchor => 'nw', -fill => 'x'); &MakeChooseFileEntry($this, $Frame, 'Param', 'Param:', $this->{ini}->pVariable("ParameterFile", ""), '&Choose', sub { $this->ChooseFile(@_); }, "ChooseParameterFile"); $this->{SaveParamButton} = $Frame->MyButton( -text => '&Save', -takefocus => 1, -command => [\&ButtonPressed, $this, 'RButtonDown', 'SaveParam'], )->pack(-side => 'left'); $this->{EditParamButton} = $Frame->MyButton( -text => 'ed', -takefocus => 1, -command => [\&ButtonPressed, $this, 'RButtonDown', 'EditParam'], )->pack(-side => 'left'); $Frame = $mw->MyFrame()->pack(-anchor => 'nw', -fill => 'x'); &MakeChooseFileEntry($this, $Frame, 'SPE', 'SPE:', $this->{ini}->pVariable("DataFile", ""), '&Choose', sub { $this->ChooseFile(@_); }, "ChooseDataFile"); $this->{EditDataButton} = $Frame->MyButton( -text => 'ed', -takefocus => 1, -command => [\&ButtonPressed, $this, 'RButtonDown', 'EditData'], )->pack(-side => 'left'); $Frame = $mw->MyFrame()->pack(-anchor => 'nw', -fill => 'x'); my $lsb1 = $this->{ChooseXListBox} = $Frame->MyBrowseEntry( -label => "X:", -state => "readonly", -takefocus => 1, -width => 5, -Selections => [], -SelIndex => 0, )->pack(-side => 'left', -expand => 'yes', -fill => 'x'); $lsb1->configure(-browsecmd => [\&SelChangeListBox, $this, "X", $this->{ChooseXListBox}]); my $lsb2 = $this->{ChooseY1ListBox} = $Frame->MyBrowseEntry( -label => "Y1:", -state => "readonly", -takefocus => 1, -width => 5, -Selections => [], -SelIndex => 1, )->pack(-side => 'left', -expand => 'yes', -fill => 'x'); $lsb2->configure(-browsecmd => [\&SelChangeListBox, $this, "Y1", $this->{ChooseY1ListBox}]); my $lsb3 = $this->{ChooseY2ListBox} = $Frame->MyBrowseEntry( -label => "Y2:", -state => "readonly", -takefocus => 1, -width => 5, -Selections => [], -SelIndex => 2, )->pack(-side => 'left', -expand => 'yes', -fill => 'x'); $lsb3->configure(-browsecmd => [\&SelChangeListBox, $this, "Y2", $this->{ChooseY2ListBox}]); my $EntryWidth = 10; $Frame = $mw->MyFrame()->pack(-anchor => 'nw'); &MakeLabelEntry($this, $Frame, "Angle", "Angle:", $this->{ini}->pVariable('Angle', 70.0), "%8.4f", $EntryWidth, "deg", 0, 0); &MakeCheckEntry($this, $Frame, "dSiO2", "dSiO2:", $this->{ini}->pVariable('dSiO2check', 1) , $this->{ini}->pVariable('dSiO2', 0.3), "%12.6g", $EntryWidth, "nm", 1, 0); $this->UpdateParameters(); $Frame = $mw->MyFrame()->pack(-anchor => 'nw', -fill => 'x'); $this->{RecalcButton} = $Frame->MyButton( -text => 'Re&calc', -takefocus => 1, -command => [\&ButtonPressed, $this, 'RButtonDown', 'Recalc'], )->pack(-side => 'left'); $this->{SaveForSCOUTButton} = $Frame->MyButton( -text => 'Save for &SCOUT', -takefocus => 1, -command => [\&ButtonPressed, $this, 'RButtonDown', 'SaveForSCOUT'], )->pack(-side => 'left'); #ツールバーのOpenボタンをファイル読み込みにバインドする $mw->{OpenButton}->configure( -command => sub { $this->ChooseFile('SampleCSVFile', $this->{SPEFileFileEntry}); }, ) if($mw->{OpenButton}); } sub InsertToolBar { my ($this, $frame) = @_; #print "this=$this\n"; #ツールバーに追加 my $spb1 = $this->mw()->{ShowRecalcDataButton} = $frame->MyCheckbutton( -text => 'Show Recalc data', -takefocus => 1, -variable => $this->{ini}->pVariable('ShowRecalcData', 1), -indicatoron => 0, )->pack(-side => 'left', -fill => 'x'); my $spb2 = $this->mw()->{ShowCalcPlotButton} = $frame->MyCheckbutton( -text => 'Show CalcPlot', -takefocus => 1, -variable => $this->{ini}->pVariable('ShowCalcPlot', 1), -indicatoron => 0, )->pack(-side => 'left', -fill => 'x'); my $spb3 = $this->mw()->{AutoUpdateButton} = $frame->MyCheckbutton( -text => 'Auto Update', -takefocus => 1, -variable => $this->{ini}->pVariable('AutoUpdate', 0), -indicatoron => 0, )->pack(-side => 'left', -fill => 'x'); } sub MakeChooseFileEntry { my ($this, $Frame, $name, $Label, $pVariable, $ButtonLabel, $pFunction, $Option) = @_; $Frame->MyLabel(-text => $Label)->pack(-side => 'left'); $this->{"${name}FileEntry"} = $Frame->MyEntry(-takefocus => 1, -textvariable => $pVariable)->pack(-side => 'left', -expand => 'yes', -fill => 'x'); $this->{"${name}FileEntry"}->focus(); $this->{"${name}FilePathButton"} = $Frame->MyButton( -text => $ButtonLabel, -takefocus => 1, -command => [$pFunction, $this, $name, $this->{"${name}FileEntry"}, $Option], )->pack(-side => 'left'); return $this->{"${name}FileEntry"}; } sub MakeLabelEntry { my ($this, $Frame, $name, $label1, $pVariable, $format, $EntryWidth, $label2, $row, $column, $state) = @_; $state = 'normal' if(!defined $state); if(!$pVariable) { $this->{$name} = ''; $pVariable = \{$this->{$name}}; } #print "p=$pVariable,$$pVariable f=$format\n"; #print "Frame=$Frame name=$name,$label1,$format,$label2\n"; $$pVariable = Utils::DelSpace(sprintf($format, $$pVariable)); $Frame->MyLabel(-text => $label1)->grid(-row => $row, -column => 3*$column+0, -columnspan => 1, -sticky => 'e' ); my $ent = $Frame->MyEntry( -name => $name, -width => $EntryWidth, # -text => $val, -textvariable => $pVariable, -state => $state, -format => $format, )->grid(-row => $row, -column => 3*$column+1, -columnspan => 1, -sticky => 'e' ); $Frame->MyLabel(-text => $label2)->grid(-row => $row, -column => 3*$column+2, -columnspan => 1, -sticky => 'w' ); $ent->bind('', [\&EntryFocusedOut, $this, 'FocusOut', $name]); $this->{pEntryArray} = [] if(!$this->{pEntryArray}); push(@{$this->{pEntryArray}}, $ent); return $this->{"${name}Entry"} = $ent; } sub MakeCheckEntry { my ($this, $Frame, $name, $label1, $pCheckVariable, $pVariable, $format, $EntryWidth, $label2, $row, $column, $state) = @_; $state = 'normal' if(!defined $state); #print "name=$name p=$pVariable,$$pVariable check: $pCheckVariable, $$pCheckVariable f=$format\n"; $$pVariable = Utils::DelSpace(sprintf($format, $$pVariable)); my $button = $Frame->MyCheckbutton( -text => $label1, -variable => $pCheckVariable, -onvalue => 1, -offvalue => 0, -indicatoron => 'no', )->grid(-row => $row, -column => 3*$column+0, -columnspan => 1, -sticky => 'e' ); # $button->configure(-command => sub { print "$label1 is pressed [", $button->GetText(), "]\n"; }); my $ent = $Frame->MyEntry( -name => $name, -width => $EntryWidth, # -text => $val, -textvariable => $pVariable, -state => $state, -format => $format, )->grid(-row => $row, -column => 3*$column+1, -columnspan => 1, -sticky => 'e' ); $Frame->MyLabel(-text => $label2)->grid(-row => $row, -column => 3*$column+2, -columnspan => 1, -sticky => 'w' ); $ent->bind('', [\&EntryFocusedOut, $this, 'FocusOut', $name]); $this->{pEntryArray} = [] if(!$this->{pEntryArray}); push(@{$this->{pEntryArray}}, $ent); return $this->{"${name}Entry"} = $ent; } sub ButtonPressed { my ($this, $event, $type) = @_; my $App = $this->App(); if($type eq 'Recalc') { &Recalc($this); $this->CreateGraphFrame(); $this->AssignGraphData(1); $this->Draw(); } elsif($type eq 'SaveForSCOUT') { my $pE = $this->{Ellipsometry}->GetData('eV'); my $pPsi = $this->{Ellipsometry}->GetData('Psi'); my $pDelta = $this->{Ellipsometry}->GetData('Delta'); my $pn = $this->{Ellipsometry}->GetData('n'); my $pk = $this->{Ellipsometry}->GetData('k'); my $nData = $this->{Ellipsometry}->nData(); my $path = $this->ChooseSaveFile(); my $out = new JFile; if(!$out->Open($path, "w")) { $App->print("Error: Can not write to [$path].\n"); return undef; } $out->print("E(eV),wl(nm),Psi,Delta,tan(Psi),tan(Delta),n,k,e1,e2,alpha(cm-1),sigma(S/cm)\n"); for(my $i = 0 ; $i < $nData ; $i++) { my $E = $pE->[$i]; my $wl = Optics::eVTonm($E); my $Psi = $pPsi->[$i]; $Psi -= 360.0 if($Psi >= 180.0); my $tanPsi = Sci::tan($Psi*$torad); my $Delta = $pDelta->[$i]; $Delta -= 360.0 if($Delta >= 180.0); my $tanDelta = Sci::tan($Delta*$torad); my ($n, $k); if($pn) { $n = $pn->[$i]; $k = $pk->[$i]; } else { ($n, $k) = $this->{Ellipsometry}->PsiDeltaToNK($Psi, $Delta); } my ($e1, $e2) = $this->{Ellipsometry}->NKToEps($n, $k); my $alpha = Optics::KToAlpha($wl, $k); my $sigma = Optics::EpsToConductivity($E, $e2); $out->print("$E,$wl,$Psi,$Delta,$tanPsi,$tanDelta,$n,$k,$e1,$e2,$alpha,$sigma\n"); } $out->Close(); } elsif($type eq 'Fit') { &Fit($this); # $this->CreateGraphFrame(); $this->AssignGraphData(0); $this->Draw(); return; } elsif($type eq 'SaveParam') { # $this->{ini}->{Model} = $this->{ChooseModelListBox}->GetText(); $this->{ini}->{X} = $this->{ChooseXListBox}->GetText(); $this->{ini}->{Y1} = $this->{ChooseY1ListBox}->GetText(); $this->{ini}->{Y1} = $this->{ChooseY2ListBox}->GetText(); $this->{ini}->SetIniFile($this->{ini}->{ParameterFile}, undef, 1); if(!defined $this->{ini}->IniFile() or $this->{ini}->IniFile() eq '' or $this->{ini}->IniFile() eq '.') { my $path = $this->ChooseSaveFile('save.prm', '*.prm'); if($path) { $this->{ini}->SetIniFile($path, undef, 1); $this->{ini}->{ParameterFile} = $path; } else { return; } } $this->{ini}->WriteAll(); return; } elsif($type eq 'EditParam') { my $Editor = $this->App()->{EditorPath}; my $File = $this->{ini}->{ParameterFile}; my $command = "$Editor $File"; system($command); return; } elsif($type eq 'EditData') { my $Editor = $this->App()->{EditorPath}; my $File = $this->{ini}->{DataFile}; my $command = "$Editor $File"; system($command); return; } } sub UpdateParameters { my ($this) = @_; # $this->{Cox} = $material->CalCapacitance($this->{er}, 0.01*0.01, $this->{dgate}*1.0e-9); # F/cm2 my $pEA = $this->{pEntryArray}; for(my $i = 0 ; $i < @$pEA ; $i++) { $pEA->[$i]->Update(); } } sub EntryFocusedOut { my ($obj, $this, $event, $type) = @_; #print "type: $type\n"; if($event eq 'FocusOut') { if($type eq 'T') { } } if($this->{ini}->{AutoUpdate} and defined $this->{ini}->{"${type}check"}) { &Recalc($this); # $this->CreateGraphFrame(); $this->AssignGraphData(0); $this->Draw(); } else { &UpdateParameters($this); } } #=================================================== # データ処理 #=================================================== sub Recalc { my ($this) = @_; &UpdateParameters($this); my $SubstrateThickness = 0.5e-3; # m, Substrate thickness my $SiPath = 'D:/PerlPrograms/SI100.JEL'; # my $SiPath = 'D:/PerlPrograms/SI111025.SPE'; my $Angle = $this->{ini}->{Angle}; my $FilmThickness = $this->{ini}->{dSiO2} * 1.0e-9; # m #print "FilmThickness=$FilmThickness\n"; my $optics = new Optics; my $el = new Ellipsometry(); $el->SetIncidentAngle($Angle); my $Layers = new MultiLayer; my $Air = new OpticalMaterial("air"); my $SiO2 = new OpticalMaterial("Specify", "SiO2"); # my $aSi = new OpticalMaterial("a-Si:H"); my $Si = new OpticalMaterial("Specify", "Si"); $Layers->AddLayer($Air, -1.0, 0.0); $Layers->AddLayer($SiO2, $FilmThickness, 1.0); $Layers->AddLayer($Si, -1.0, 0.0); $Layers->SetIncidentAngle($Angle); $SiO2->AddDielectricModel( "Constant", "Constant", "e1inf", 2.25, "e2inf", 0.0, ); my @a = $Si->AddDielectricModel( "Si", "EFile", "Path", $SiPath, ); if(@a == 0) { print "Error in TkEllipsometry::Recalc: Can not read [$SiPath].\n"; exit; } my $Emin = 1.5; my $Estep = 0.05; my $Emax = 5.0; my $nData = int( ($Emax - $Emin) / $Estep + 1.001); my (@E, @e1, @e2); for(my $i = 0 ; $i < $nData ; $i++) { my $E = $Emin + $i * $Estep; my ($Psi, $Delta) = $Layers->CalPsiDelta($E); my ($e1c, $e2c) = $el->PsiDeltaToEps($Psi, $Delta, $Angle); $E[$i] = $E; $e1[$i] = $e1c; $e2[$i] = $e2c; } $this->{pEArray} = \@E; $this->{pEps1Array} = \@e1; $this->{pEps2Array} = \@e2; } sub Fit { my ($this) = @_; $this->UpdateParameters(); $this->UpdateParameters(); } sub CalS2 { my ($this, $pVars, $iPrintLevel) = @_; } sub ReadFile { my ($this, $filepath, $IsPrint) = @_; my $App = $this->App(); #print "type=$type\n"; $this->{Path} = $filepath; my ($nData, $pLabelArray, @pDataArray) = $this->{Ellipsometry}->Read($filepath); if(!defined $nData) { $App->print("Error: Can not read [$filepath].\n"); return $this->{Path} = undef; } my $nDataArray = $this->{Ellipsometry}->nDataArray(); #print "nDataArray: $nDataArray\n"; $this->{"ChooseXListBox"}->DeleteAllItem(); $this->{"ChooseY1ListBox"}->DeleteAllItem(); $this->{"ChooseY2ListBox"}->DeleteAllItem(); for(my $i = 0 ; $i < $nDataArray ; $i++) { #print "$i: $pLabelArray->[$i]\n"; $this->{"ChooseXListBox"}->AddItem($pLabelArray->[$i]); $this->{"ChooseY1ListBox"}->AddItem($pLabelArray->[$i]); $this->{"ChooseY2ListBox"}->AddItem($pLabelArray->[$i]); } $this->{"ChooseXListBox"}->SetCurSel('E', 'eV'); $this->{"ChooseY1ListBox"}->SetCurSel('e1', 'n', 'Psi'); $this->{"ChooseY2ListBox"}->SetCurSel('e2', 'k', 'Delta'); $this->CreateGraphFrame(); $this->AssignGraphData(); return $filepath; } sub CreateGraphFrame { my ($this, $canvas, $TargetData) = @_; $canvas = $this->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(); # return undef unless($FileType); # my $pDataArray = $this->DataArray(); # return unless($pDataArray); my $GraphFrameArray = $this->{'GraphFrameArray'} = new GraphFrameArray($this->mw()); $GraphFrameArray->SetCanvasSize($w, $h); $GraphFrameArray->AddGraphFrame(); my $GraphFrame0 = $GraphFrameArray->GetGraphFrame(0); my $FramePosStr0 = $App->{"GraphFrame0Position"}; my $XScale0 = $GraphFrame0->GetXScale(0); my $YScale0 = $GraphFrame0->GetYScale(0); $GraphFrame0->SetPositionByStr($FramePosStr0); $XScale0->SetScaleStringVisible(1); $XScale0->SetCaptionVisible(1); $GraphFrame0->SetViewRange(0, 0, 1, 1); } sub AssignGraphData { my ($this, $ResetViewRange) = @_; $ResetViewRange = 1 if(!defined $ResetViewRange); my $GraphFrameArray = $this->GetGraphFrameArray(); my $GraphFrame0 = $GraphFrameArray->GetGraphFrame(0); $GraphFrame0->ClearAllData(); # my $pDataArray = $this->DataArray(); # my $FileType = $this->FileType(); # my $TargetData = $pDataArray->{'TargetData'}; # return unless($pDataArray); # my $Data0 = $pDataArray->GetGraphData(0); # my $Data1 = $pDataArray->GetGraphData(1); # return unless($Data1); # my $nData = $Data0->nData(); # my $title = $Data0->Title(); my $XLabel = $this->{"ChooseXListBox"}->GetText(); $XLabel = 'X' if(!$XLabel); my $Y1Label = $this->{"ChooseY1ListBox"}->GetText(); $Y1Label = 'Y1' if(!$Y1Label); my $Y2Label = $this->{"ChooseY2ListBox"}->GetText(); $Y2Label = 'Y2' if(!$Y2Label); my $pX = $this->{Ellipsometry}->GetData($XLabel); my $pY1 = $this->{Ellipsometry}->GetData($Y1Label); my $pY2 = $this->{Ellipsometry}->GetData($Y2Label); my $nData = $this->{Ellipsometry}->nData(); $GraphFrame0->SetXCaption($XLabel); $GraphFrame0->SetYCaption("$Y1Label,$Y2Label"); if($pX and $pY1) { my $nData0 = $GraphFrame0->AddGraphData($pX, $pY1, 2, "black", "", 6, "red", 0, "red", "XAutoSkip", "Energy", "${Y1Label}(obs)"); my $nData1 = $GraphFrame0->AddGraphData($pX, $pY2, 2, "red", "", 6, "red", 0, "red", "XAutoSkip", "Energy", "${Y2Label}(obs)"); } my $pCalE = $this->{pEArray}; my $pCalEps1 = $this->{pEps1Array}; my $pCalEps2 = $this->{pEps2Array}; if($pCalE) { my $nData0 = $GraphFrame0->AddGraphData($pCalE, $pCalEps1, 1, "black", "", 6, "red", 0, "red", "XAutoSkip", "Energy", "${Y1Label}(cal)"); my $nData1 = $GraphFrame0->AddGraphData($pCalE, $pCalEps2, 1, "red", "", 6, "red", 0, "red", "XAutoSkip", "Energy", "${Y2Label}(cal)"); } $GraphFrame0->SetYScalePlotType('x'); if($ResetViewRange) { $GraphFrame0->CalMinMax(); $GraphFrame0->AdjustViewRange(0.05, 0.05, 0.05, 0.05); } } sub AdjustViewRange { my ($this) = @_; my $GraphFrameArray = $this->GetGraphFrameArray(); my $pGraphFrame = $GraphFrameArray->GetpGraphFrameArray(); my $FileType = $this->FileType(); if($FileType =~ /(Ids)/i) { } } sub Draw { my ($this, $canvas, $TargetData) = @_; my $mw = $this->mw(); $canvas = $this->Canvas() if(!$canvas); # my $FileType = $this->FileType(); my $App = $this->App(); my $font = $App->{'GraphFrameFont'}; my @font = split(/,/, $font) if($font); my $GraphFrameArray = $this->GetGraphFrameArray(); return unless($GraphFrameArray); $canvas->ClearAll(); $mw->RefleshCanvas(); if($font) { $canvas->SetFont(\@font); $GraphFrameArray->SetFont(\@font); } my $w = $canvas->width(); my $h = $canvas->height(); $GraphFrameArray->SetCanvasSize($w, $h); $this->mw()->WriteStatusBar("Drawing TFT..."); # $this->ReadFiles($this->FileName(), $TargetData); # $this->CreateGraphFrame($canvas, $TargetData); # $this->AssignGraphData(); $mw->Balloon()->detach($canvas); $GraphFrameArray->Draw($canvas); $this->mw()->WriteStatusBar("Finish TFT."); } sub DeleteWidget { my ($this, $Frame) = @_; return undef unless($Frame); return 1; } sub AddWidget { my ($this, $Frame) = @_; return undef unless($Frame); # 左枠3列目作成: ファイルの内容を表示するセクションリストボックス # $this->mw()->CreateSectionListBox(); # 左枠4列目作成: ファイルの内容を表示するテキストボックス # $this->mw()->CreateFileContentTextBox(); return 1; } sub SetFileInfo { my ($this, $ListBox, $TextBox) = @_; return undef unless($ListBox); return undef unless($TextBox); $ListBox->ClearAll(); $TextBox->ClearText(); my $App = $this->App(); my @Font = split(/,/, $App->{"FileContentFont"}); $TextBox->configure(-font => \@Font) if(@Font > 0); my $DataArray = $App->TkData(); return undef unless($DataArray); # $TextBox->AddText("$nData\n"); return 1; } sub SelTags { my ($canvas, $this, $command, $x, $y, $X, $Y) = @_; #print "command: $command Pos: ($x, $y)\n"; if($command =~ /LButtonDown/i) { } elsif($command =~ /Move/i) { my $s = "($x,$y)"; $this->mw()->WriteStatusBar($s); } elsif($command =~ /LButtonUp/i) { } } sub SelChangeListBox { my ($this, $type, $lb) = @_; #print "this:$this lb=$lb\n"; my $s = $lb->GetText(); # if($s =~ /Solar/i) { # } # $this->CreateGraphFrame(); $this->AssignGraphData(); $this->Draw(); } sub ChooseFile { my ($this, $type, $widget, $Option) = @_; my $App = $this->App(); my $canvas = $this->Canvas(); my $mw = $this->mw(); #print "Opt=$Option\n"; my $mode = 'open'; my $fmask = '*.spe;*.jel;*.asp;*.smo;*isa;*.ref;*.pal;*.bef;*.aft'; if($Option eq 'ChooseParameterFile') { # $mode = 'save'; $fmask = '*.prm'; } my $dir = ''; unless($widget) { $dir = $this->App()->{WorkDir}; chdir($dir); } my $defstr = ''; my $message = 'Choose file'; my $filepath = Dialog::OpenFileDialog($mw, 'open', $fmask, $defstr, $message, $dir); if($filepath) { my $DirPath = $this->SetWorkDir($filepath); if($widget) { $widget->SetText($filepath); } } else { return undef; } my $ret; if($Option eq 'ChooseParameterFile') { $this->{ini}->{DataFile} = ''; $this->{ini}->ReadAll($filepath); $this->{ini}->{ParameterFile} = $filepath; $this->{ChooseModelListBox}->SetText($this->{ini}->{Model}) if($this->{ChooseModelListBox} and $this->{ini}->{Model}); $this->{ChooseXListBox}->SetText($this->{ini}->{X}) if($this->{ChooseXListBox} and $this->{ini}->{X}); $this->{ChooseY1ListBox}->SetText($this->{ini}->{Y1}) if($this->{ChooseY1ListBox} and $this->{ini}->{Y1}); if($this->{ini}->{DataFile}) { $ret = $this->ReadFile($this->{ini}->{DataFile}, 1, 0); return undef unless($ret); $this->Draw(); } } elsif($Option eq 'ChooseDataFile') { $ret = $this->ReadFile($filepath); return undef unless($ret); $this->Draw(); } return $ret; } sub ChooseSaveFile { my ($this, $path, $fmask, $widget) = @_; $path = 'save.csv' if(!defined $path); $fmask = '*.csv' if(!defined $fmask); $path = $widget->GetText() if($widget); $path = 'out.csv' if(!$path); my $App = $this->App(); my $mw = $this->mw(); my $dir = $this->App()->{WorkDir}; chdir($dir) if($dir); my $defstr = $path; my $message = 'Choose file'; my $filepath = Dialog::OpenFileDialog($mw, 'save', $fmask, $defstr, $message, $dir); if($filepath) { my $DirPath = $this->SetWorkDir($filepath); if($widget) { $widget->SetText($filepath); } } return $filepath; } 1;