Changed file checking scheme\.

This commit is contained in:
salman 2009-09-22 14:09:51 +00:00
parent 02334c8319
commit 857c744ee0
3 changed files with 252 additions and 224 deletions

View File

@ -1,6 +1,6 @@
# Form implementation generated from reading ui file 'MuSRFit.ui'
#
# Created: Tue Sep 22 11:42:50 2009
# Created: Tue Sep 22 16:07:47 2009
# by: The PerlQt User Interface Compiler (puic)
#
# WARNING! All changes made in this file will be lost!
@ -46,11 +46,11 @@ use Qt::attributes qw(
musrfit_tabs
RUNSPage
RUNSAuto
RunNumbers
YEAR
YEARLabel
BeamLine
BeamLineLabel
YEAR
RunNumbers
RUNSMan
RunFiles
Browse
@ -1588,16 +1588,6 @@ sub NEW
RUNSAuto->setSizePolicy( Qt::SizePolicy(5, 7, 0, 0, RUNSAuto->sizePolicy()->hasHeightForWidth()) );
RUNSAuto->setMargin( int(5) );
RunNumbers = Qt::LineEdit(RUNSAuto, "RunNumbers");
RunNumbers->setGeometry( Qt::Rect(15, 25, 505, 26) );
RunNumbers->setSizePolicy( Qt::SizePolicy(0, 0, 0, 0, RunNumbers->sizePolicy()->hasHeightForWidth()) );
RunNumbers->setMinimumSize( Qt::Size(0, 23) );
YEAR = Qt::ComboBox(0, RUNSAuto, "YEAR");
YEAR->setGeometry( Qt::Rect(420, 55, 100, 26) );
YEAR->setSizePolicy( Qt::SizePolicy(0, 0, 0, 0, YEAR->sizePolicy()->hasHeightForWidth()) );
YEAR->setMinimumSize( Qt::Size(0, 20) );
YEARLabel = Qt::Label(RUNSAuto, "YEARLabel");
YEARLabel->setGeometry( Qt::Rect(361, 55, 55, 26) );
YEARLabel->setMinimumSize( Qt::Size(0, 20) );
@ -1610,6 +1600,16 @@ sub NEW
BeamLineLabel = Qt::Label(RUNSAuto, "BeamLineLabel");
BeamLineLabel->setGeometry( Qt::Rect(127, 55, 99, 26) );
BeamLineLabel->setMinimumSize( Qt::Size(0, 20) );
YEAR = Qt::ComboBox(0, RUNSAuto, "YEAR");
YEAR->setGeometry( Qt::Rect(420, 55, 100, 26) );
YEAR->setSizePolicy( Qt::SizePolicy(0, 0, 0, 0, YEAR->sizePolicy()->hasHeightForWidth()) );
YEAR->setMinimumSize( Qt::Size(0, 20) );
RunNumbers = Qt::LineEdit(RUNSAuto, "RunNumbers");
RunNumbers->setGeometry( Qt::Rect(15, 25, 505, 26) );
RunNumbers->setSizePolicy( Qt::SizePolicy(0, 0, 0, 0, RunNumbers->sizePolicy()->hasHeightForWidth()) );
RunNumbers->setMinimumSize( Qt::Size(0, 23) );
$layout43->addWidget(RUNSAuto);
RUNSMan = Qt::GroupBox($LayoutWidget, "RUNSMan");
@ -2483,7 +2483,7 @@ sub NEW
separatorAction= Qt::Action(this, "separatorAction");
FileExistCheck= Qt::Action(this, "FileExistCheck");
FileExistCheck->setToggleAction( 1 );
FileExistCheck->setOn( 1 );
FileExistCheck->setOn( 0 );
ManualFile= Qt::Action(this, "ManualFile");
ManualFile->setToggleAction( 1 );
fileChangeDirAction= Qt::Action(this, "fileChangeDirAction");
@ -2684,15 +2684,6 @@ sub languageChange
setCaption(trUtf8("MuSRFit GUI") );
setIconText(trUtf8("MuSRFitGUI") );
RUNSAuto->setTitle( trUtf8("RUN Numbers") );
Qt::ToolTip::add(RunNumbers, trUtf8("Numbers of RUNs to fit. Multiple runs are comma separated."));
Qt::WhatsThis::add(RunNumbers, trUtf8("Numbers of RUNs to fit. Multiple runs are comma separated."));
YEAR->clear();
YEAR->insertItem( trUtf8("2009") );
YEAR->insertItem( trUtf8("2008") );
YEAR->insertItem( trUtf8("2007") );
YEAR->insertItem( trUtf8("2006") );
YEAR->insertItem( trUtf8("2005") );
YEAR->insertItem( trUtf8("2004") );
YEARLabel->setText( trUtf8("Year") );
BeamLine->clear();
BeamLine->insertItem( trUtf8("LEM") );
@ -2700,6 +2691,15 @@ sub languageChange
BeamLine->insertItem( trUtf8("Dolly") );
BeamLine->insertItem( trUtf8("LTF") );
BeamLineLabel->setText( trUtf8("On beam line") );
YEAR->clear();
YEAR->insertItem( trUtf8("2009") );
YEAR->insertItem( trUtf8("2008") );
YEAR->insertItem( trUtf8("2007") );
YEAR->insertItem( trUtf8("2006") );
YEAR->insertItem( trUtf8("2005") );
YEAR->insertItem( trUtf8("2004") );
Qt::ToolTip::add(RunNumbers, trUtf8("Numbers of RUNs to fit. Multiple runs are comma separated."));
Qt::WhatsThis::add(RunNumbers, trUtf8("Numbers of RUNs to fit. Multiple runs are comma separated."));
RUNSMan->setTitle( trUtf8("RUN Files") );
Qt::ToolTip::add(RunFiles, trUtf8("Names of data files to be fit. Multiple data files are comma separated."));
Qt::WhatsThis::add(RunFiles, trUtf8("Names of data files to be fit. Multiple data files are comma separated."));
@ -3145,7 +3145,7 @@ sub helpAbout
sub CreateAllInput
{
# TODO: Need to deliver shared parameters also
# TODO: Need to automatically generage years list depending on beamline
my %All=();
# From RUNS Tab
$All{"TITLE"}= TITLE->text;
@ -3347,7 +3347,27 @@ sub CallMSRCreate
use MSR;
my %All=CreateAllInput();
# Check if the option for checking for existing files is selected
my $FileExistCheck= FileExistCheck->isOn();
my $FILENAME=$All{"FILENAME"}.".msr";
my $Answer=0;
if ($All{"RunNumbers"} ne "" || $All{"RunFiles"} ne "") {
if ( $FileExistCheck==1 ) {
if (-e $FILENAME) {
# Warning: MSR file exists
# my $Warning = "Warning: MSR file $FILENAME Already exists!\nIf you continue it will overwriten.";
my $Warning = "Warning: MSR file $FILENAME Already exists!\nDo you want to overwrite it?";
# my $WarningWindow = Qt::MessageBox::information( this, "Warning",$Warning);
# $Answer =1,0 for yes and no
$Answer= Qt::MessageBox::warning( this, "Warning",$Warning, "&No", "&Yes", undef, 1,1);
}
} else {
# Just overwrite file
$Answer=1;
}
if ($Answer) {
if ( $All{"FitAsyType"} eq "Asymmetry" ) {
my ($Full_T_Block,$Paramcomp_ref)= MSR::CreateMSR(\%All);
}
@ -3356,6 +3376,8 @@ sub CallMSRCreate
}
UpdateMSRFileInitTable();
}
}
return $Answer;
}
@ -3556,24 +3578,8 @@ sub TabChanged
{
# TODO: First check if there are some runs given, otherwise disbale
# TODO: Check if the MSR file exists and decide whether to use it or not
my %All=CreateAllInput();
my $SlectedTab = musrfit_tabs->currentPageIndex;
# Check if the option for checking for existing files is selected
my $FileExistCheck= FileExistCheck->isOn();
my $FILENAME=$All{"FILENAME"}.".msr";
if ($All{"RunNumbers"} ne "" && $SlectedTab==4 && $FileExistCheck==1) {
if (-e $FILENAME) {
# Warning: MSR file exists
my $Warning = "Warning: MSR file $FILENAME Already exists!\nIf you continue it will overwriten.";
my $WarningWindow = Qt::MessageBox::information( this, "Warning",$Warning);
# my $Answer= Qt::MessageBox::warning( this, "Warning",$Warning, "&No", "&Yes", undef, 1,1);
# $Answer =1,0 for yes and no
# print "Answer=$Answer\n";
}
}
# First make sure we have sharing initialized
ActivateShComp();
InitializeTab();
@ -3588,14 +3594,14 @@ sub GoFit
my %All=CreateAllInput();
musrfit_tabs->setCurrentPage(1);
CallMSRCreate();
my $Answer=CallMSRCreate();
if ($Answer) {
my $FILENAME=$All{"FILENAME"}.".msr";
if (-e $FILENAME) {
my $cmd="musrfit -t $FILENAME";
my $pid = open(FTO,"$cmd 2>&1 |");
while (<FTO>) {
FitTextOutput->append("$_");
# print "line= ".$_;
}
close(FTO);
$cmd="musrview $FILENAME &";
@ -3606,6 +3612,8 @@ sub GoFit
FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------");
# update MSR File tab and initialization table
UpdateMSRFileInitTable();
}
return;
}
@ -3614,8 +3622,10 @@ sub GoPlot
{
my %All=CreateAllInput();
CallMSRCreate();
my $Answer=CallMSRCreate();
my $FILENAME=$All{"FILENAME"}.".msr";
if ($Answer) {
if (-e $FILENAME) {
my $cmd="musrview $FILENAME &";
my $pid = system($cmd);
@ -3623,6 +3633,7 @@ sub GoPlot
FitTextOutput->append("Cannot find MSR file!");
FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------");
}
}
return;
}
@ -3633,7 +3644,9 @@ sub ShowMuSRT0
my %All=CreateAllInput();
musrfit_tabs->setCurrentPage(6);
# Create MSR file and then run musrt0
CallMSRCreate();
my $Answer=CallMSRCreate();
if ($Answer) {
my $FILENAME=$All{"FILENAME"}.".msr";
if (-e $FILENAME) {
my $cmd="musrt0 $FILENAME &";
@ -3641,6 +3654,7 @@ sub ShowMuSRT0
} else {
print STDERR "Cannot find MSR file!\n";
}
}
return;
}

View File

@ -114,96 +114,6 @@
<property name="title">
<string>RUN Numbers</string>
</property>
<widget class="QLineEdit">
<property name="name">
<cstring>RunNumbers</cstring>
</property>
<property name="geometry">
<rect>
<x>15</x>
<y>25</y>
<width>505</width>
<height>26</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>23</height>
</size>
</property>
<property name="toolTip" stdset="0">
<string>Numbers of RUNs to fit. Multiple runs are comma separated.</string>
</property>
<property name="whatsThis" stdset="0">
<string>Numbers of RUNs to fit. Multiple runs are comma separated.</string>
</property>
</widget>
<widget class="QComboBox">
<item>
<property name="text">
<string>2009</string>
</property>
</item>
<item>
<property name="text">
<string>2008</string>
</property>
</item>
<item>
<property name="text">
<string>2007</string>
</property>
</item>
<item>
<property name="text">
<string>2006</string>
</property>
</item>
<item>
<property name="text">
<string>2005</string>
</property>
</item>
<item>
<property name="text">
<string>2004</string>
</property>
</item>
<property name="name">
<cstring>YEAR</cstring>
</property>
<property name="geometry">
<rect>
<x>420</x>
<y>55</y>
<width>100</width>
<height>26</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>YEARLabel</cstring>
@ -295,6 +205,96 @@
<string>On beam line</string>
</property>
</widget>
<widget class="QComboBox">
<item>
<property name="text">
<string>2009</string>
</property>
</item>
<item>
<property name="text">
<string>2008</string>
</property>
</item>
<item>
<property name="text">
<string>2007</string>
</property>
</item>
<item>
<property name="text">
<string>2006</string>
</property>
</item>
<item>
<property name="text">
<string>2005</string>
</property>
</item>
<item>
<property name="text">
<string>2004</string>
</property>
</item>
<property name="name">
<cstring>YEAR</cstring>
</property>
<property name="geometry">
<rect>
<x>420</x>
<y>55</y>
<width>100</width>
<height>26</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>RunNumbers</cstring>
</property>
<property name="geometry">
<rect>
<x>15</x>
<y>25</y>
<width>505</width>
<height>26</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>23</height>
</size>
</property>
<property name="toolTip" stdset="0">
<string>Numbers of RUNs to fit. Multiple runs are comma separated.</string>
</property>
<property name="whatsThis" stdset="0">
<string>Numbers of RUNs to fit. Multiple runs are comma separated.</string>
</property>
</widget>
</widget>
<widget class="QGroupBox">
<property name="name">
@ -4042,7 +4042,7 @@
<bool>true</bool>
</property>
<property name="on">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="text">
<string>Change name</string>

View File

@ -212,7 +212,7 @@ void Form1::helpAbout()
void MuSRFitform::CreateAllInput()
{
# TODO: Need to deliver shared parameters also
# TODO: Need to automatically generage years list depending on beamline
my %All=();
# From RUNS Tab
$All{"TITLE"}= TITLE->text;
@ -412,7 +412,27 @@ void MuSRFitform::CallMSRCreate()
{
use MSR;
my %All=CreateAllInput();
# Check if the option for checking for existing files is selected
my $FileExistCheck= FileExistCheck->isOn();
my $FILENAME=$All{"FILENAME"}.".msr";
my $Answer=0;
if ($All{"RunNumbers"} ne "" || $All{"RunFiles"} ne "") {
if ( $FileExistCheck==1 ) {
if (-e $FILENAME) {
# Warning: MSR file exists
# my $Warning = "Warning: MSR file $FILENAME Already exists!\nIf you continue it will overwriten.";
my $Warning = "Warning: MSR file $FILENAME Already exists!\nDo you want to overwrite it?";
# my $WarningWindow = Qt::MessageBox::information( this, "Warning",$Warning);
# $Answer =1,0 for yes and no
$Answer= Qt::MessageBox::warning( this, "Warning",$Warning, "&No", "&Yes", undef, 1,1);
}
} else {
# Just overwrite file
$Answer=1;
}
if ($Answer) {
if ( $All{"FitAsyType"} eq "Asymmetry" ) {
my ($Full_T_Block,$Paramcomp_ref)= MSR::CreateMSR(\%All);
}
@ -422,6 +442,8 @@ void MuSRFitform::CallMSRCreate()
UpdateMSRFileInitTable();
}
}
return $Answer;
}
void MuSRFitform::UpdateMSRFileInitTable()
{
@ -611,24 +633,8 @@ void MuSRFitform::InitializeTab()
void MuSRFitform::TabChanged()
{
# TODO: First check if there are some runs given, otherwise disbale
# TODO: Check if the MSR file exists and decide whether to use it or not
my %All=CreateAllInput();
my $SlectedTab = musrfit_tabs->currentPageIndex;
# Check if the option for checking for existing files is selected
my $FileExistCheck= FileExistCheck->isOn();
my $FILENAME=$All{"FILENAME"}.".msr";
if ($All{"RunNumbers"} ne "" && $SlectedTab==4 && $FileExistCheck==1) {
if (-e $FILENAME) {
# Warning: MSR file exists
my $Warning = "Warning: MSR file $FILENAME Already exists!\nIf you continue it will overwriten.";
my $WarningWindow = Qt::MessageBox::information( this, "Warning",$Warning);
# my $Answer= Qt::MessageBox::warning( this, "Warning",$Warning, "&No", "&Yes", undef, 1,1);
# $Answer =1,0 for yes and no
# print "Answer=$Answer\n";
}
}
# First make sure we have sharing initialized
ActivateShComp();
InitializeTab();
@ -642,14 +648,14 @@ void MuSRFitform::GoFit()
{
my %All=CreateAllInput();
musrfit_tabs->setCurrentPage(1);
CallMSRCreate();
my $Answer=CallMSRCreate();
if ($Answer) {
my $FILENAME=$All{"FILENAME"}.".msr";
if (-e $FILENAME) {
my $cmd="musrfit -t $FILENAME";
my $pid = open(FTO,"$cmd 2>&1 |");
while (<FTO>) {
FitTextOutput->append("$_");
# print "line= ".$_;
}
close(FTO);
$cmd="musrview $FILENAME &";
@ -660,14 +666,18 @@ void MuSRFitform::GoFit()
FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------");
# update MSR File tab and initialization table
UpdateMSRFileInitTable();
}
return;
}
void MuSRFitform::GoPlot()
{
my %All=CreateAllInput();
CallMSRCreate();
my $Answer=CallMSRCreate();
my $FILENAME=$All{"FILENAME"}.".msr";
if ($Answer) {
if (-e $FILENAME) {
my $cmd="musrview $FILENAME &";
my $pid = system($cmd);
@ -675,6 +685,7 @@ void MuSRFitform::GoPlot()
FitTextOutput->append("Cannot find MSR file!");
FitTextOutput->append("-----------------------------------------------------------------------------------------------------------------------------");
}
}
return;
}
@ -684,7 +695,9 @@ void MuSRFitform::ShowMuSRT0()
my %All=CreateAllInput();
musrfit_tabs->setCurrentPage(6);
# Create MSR file and then run musrt0
CallMSRCreate();
my $Answer=CallMSRCreate();
if ($Answer) {
my $FILENAME=$All{"FILENAME"}.".msr";
if (-e $FILENAME) {
my $cmd="musrt0 $FILENAME &";
@ -692,6 +705,7 @@ void MuSRFitform::ShowMuSRT0()
} else {
print STDERR "Cannot find MSR file!\n";
}
}
return;
}