Skip to content

Commit

Permalink
Fix various issues with egs_inprz
Browse files Browse the repository at this point in the history
Fixes included:
1. Elimination of segmentation fault when browsing density
   correction files in pegless media def.
2. Truncation of float values to int when saving no. of
   atoms in pegsless media def.
3. Proper enabling of energy table when dosrznrc .egsinp file
   specifies a pulse height distribution calculation
4. Ability to browse from EGS_HOME and HEN_HOUSE for
   density correction files in pegsless media def.
  • Loading branch information
blakewalters committed May 23, 2016
1 parent d53d3af commit edad0d7
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 244 deletions.
9 changes: 5 additions & 4 deletions HEN_HOUSE/gui/egs_inprz/include/tooltips.h
Expand Up @@ -568,10 +568,11 @@ static const char* sources[] = {
"\n be deleted from the list."

#define DENSITY_FILE "specify a density correction file which, when applied to calculated cross-sections,"\
"\nresults in agreement with stopping powers published in ICRU37. The browser"\
"\nstarts in the $HEN_HOUSE/pegs4/density_corrections parent directory and allows"\
"\nyou to enter either the 'compounds' or 'elements' subdirectory."\
"\nOmit the directory path and '.density' extension from the filename."
"\nresults in agreement with stopping powers published in ICRU37. You can start"\
"\nthe browser in $EGS_HOME/pegs4/density_corrections (the default) or in"\
"\n$HEN_HOUSE/pegs4/density_corrections from either of which you can"\
"\nenter either the 'compounds' or 'elements' subdirectory."\
"\nNote that the file name includes the full directory path."

#define STERNCID "The Sternheimer-Seltzer-Berger ID for the medium. If this matches the ID in"\
"\nan internal lookup table, pre-calculated density effect parameters are applied"\
Expand Down
7 changes: 4 additions & 3 deletions HEN_HOUSE/gui/egs_inprz/src/inputRZForm.cpp
Expand Up @@ -1114,6 +1114,8 @@ void inputRZImpl::update_MCInputs( const MMCInputs* EGSmc )
else {
openErrors += QString(WARNING_KERMA) + "\n";
}
if ( (ifullComboBox->currentText()).toLower() == "pulse height distribution")
phdGroupBox->setEnabled( true );
}
else if ( usercode != flurznrc ) {// PHOTON REGENERATION
if ( EGSmc->photreg.toLower() == "yes" ){
Expand Down Expand Up @@ -1360,6 +1362,7 @@ void inputRZImpl::update_PEGSLESSParam( const PEGSLESSInputs* EGSpgls)

//set some defaults in the input window for material specified in .egsinp file
pzRadioButton->setChecked(true);
df_egs_homeRadioButton->setChecked(true);
//qt3to4 -- BW
//pz_or_rhozTable->horizontalHeader()->setLabel(1,"no. of atoms");
pz_or_rhozTable->setHorizontalHeaderItem(1,new QTableWidgetItem("no. of atoms"));
Expand Down Expand Up @@ -1441,6 +1444,7 @@ void inputRZImpl::inpmediumSave( const QString& str)
{

int ind=inpmediumComboBox->currentIndex();
Ppgls->inpmedind=ind;
if(inpmediumComboBox->currentText()!="define new medium"){
//note: above allows blanks in medium name...probably not a good idea
if(ind==Ppgls->ninpmedia) {
Expand Down Expand Up @@ -2676,9 +2680,6 @@ void inputRZImpl::update_usercode()

outputTip->setTips( out_dos, sizeof out_dos / sizeof(char *));

if ( (ifullComboBox->currentText()).toLower() == "pulse height distribution")
phdGroupBox->setEnabled( true );

//Q3WhatsThis::add( CSEnhancementGroupBox, CS_ENHANCEMENT_DOSRZNRC );
CSEnhancementGroupBox->setWhatsThis(CS_ENHANCEMENT_DOSRZNRC );
CSEnhancementGroupBox->setToolTip(CS_ENHANCEMENT_DOSRZNRC );
Expand Down
10 changes: 8 additions & 2 deletions HEN_HOUSE/gui/egs_inprz/src/inputRZImpl.cpp
Expand Up @@ -773,7 +773,10 @@ void inputRZImpl::GetDFfile()
//char s = QDir::separator();
char s = QDir::separator().toAscii();
//browse from HEN_HOUSE/pegs4/density_corrections
if(df_hen_houseRadioButton->isChecked())
tmpDir = ironIt(HEN_HOUSE + s + "pegs4" + s + "density_corrections" + s);
else
tmpDir = ironIt(EGS_HOME + s + "pegs4" + s + "density_corrections" + s);
QDir d(tmpDir);
//qt3to4 -- BW
//QString f = Q3FileDialog::getOpenFileName( this,"",tmpDir, "density correction file (*.density);; all files (*)");
Expand All @@ -783,11 +786,14 @@ void inputRZImpl::GetDFfile()
//HEN_HOUSE/pegs4/data/compounds directories
if ( (f.indexOf(tmpDir + "elements",0) >=0 || f.indexOf(tmpDir + "compounds",0) >=0 ) &&
f.indexOf(".density",1)>=0) {
//keep entire filename
//remove directory name
f.remove( 0, f.lastIndexOf(s,-1)+1);
//f.remove( 0, f.lastIndexOf(s,-1)+1);
//remove ".density" extension
f.remove(f.indexOf(".density",1),8);
//f.remove(f.indexOf(".density",1),8);
}
int ind=inpmediumComboBox->currentIndex();
Ppgls->inpmedind=ind;
Ppgls->dffile[Ppgls->inpmedind] = f;
DFEdit->setText(Ppgls->dffile[Ppgls->inpmedind]);
}
Expand Down
22 changes: 19 additions & 3 deletions HEN_HOUSE/gui/egs_inprz/src/pegslessinputs.cpp
Expand Up @@ -40,6 +40,8 @@
//qt3to4 -- BW
#include <QTextStream>

#include <qmessagebox>

PEGSLESSInputs::PEGSLESSInputs()
{

Expand Down Expand Up @@ -142,7 +144,6 @@ std::ifstream & operator >> ( std::ifstream & in, PEGSLESSInputs* rPEGSLESS )
//define defaults

rPEGSLESS->elements[tempint].push_back("");
rPEGSLESS->pz_or_rhoz[tempint].push_back("");
rPEGSLESS->spec_by_pz[tempint]=true;
rPEGSLESS->isgas[tempint]=false;

Expand All @@ -151,13 +152,15 @@ std::ifstream & operator >> ( std::ifstream & in, PEGSLESSInputs* rPEGSLESS )
if(rPEGSLESS->elements[tempint][0]!="") {
//see if composition defined
rPEGSLESS->nelements[tempint]=rPEGSLESS->elements[tempint].size();
//initialize composition with blanks
for(int i=0; i<rPEGSLESS->nelements[tempint]; i++) rPEGSLESS->pz_or_rhoz[tempint].push_back("");
rPEGSLESS->pz_or_rhoz[tempint]=getThemAll( codes1[1] , rPEGSLESS->pz_or_rhoz[tempint], rPEGSLESS->errors, p1 );
if(rPEGSLESS->pz_or_rhoz[tempint][0]=="") {
rPEGSLESS->pz_or_rhoz[tempint]=getThemAll( codes1[2] , rPEGSLESS->pz_or_rhoz[tempint], rPEGSLESS->errors, p1 );
if(rPEGSLESS->pz_or_rhoz[tempint][0]!="") rPEGSLESS->spec_by_pz[tempint]=false;
}
}

rPEGSLESS->rho[tempint]=getIt( codes1[3] , "", rPEGSLESS->errors, p1 );
rPEGSLESS->spr[tempint]=getIt( codes1[4] , "restricted total", rPEGSLESS->errors, p1 );
rPEGSLESS->bc[tempint]=getIt( codes1[5] , "KM", rPEGSLESS->errors, p1 );
Expand Down Expand Up @@ -251,7 +254,20 @@ QTextStream & operator << ( QTextStream & t, PEGSLESSInputs * rPEGSLESS )
if(!rPEGSLESS->spec_by_pz[i]) t << "mass fractions= ";
else t << "no. of atoms= ";
}
t << rPEGSLESS->pz_or_rhoz[i][j];
QString qs_pz_or_rhoz=QString::fromStdString(rPEGSLESS->pz_or_rhoz[i][j]);
float fl_pz_or_rhoz=qs_pz_or_rhoz.toFloat();
int i_pz_or_rhoz=(int)fl_pz_or_rhoz;
if(rPEGSLESS->spec_by_pz[i]){
if (fl_pz_or_rhoz-i_pz_or_rhoz>0) {
QString error = "Composition of med " + QString::number(i+1) +
" specified by no. of atoms but" +
" non-integer no. input. Number will" +
" be truncated in .egsinp file.";
QMessageBox::warning(0,"Warning",error,1,0,0);
}
t << i_pz_or_rhoz;
}
else t << fl_pz_or_rhoz;
if(j<rPEGSLESS->nelements[i]-1) t << ",";
else t << "\n";
}
Expand Down

1 comment on commit edad0d7

@mainegra
Copy link
Contributor

@mainegra mainegra commented on edad0d7 May 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Blakey! I'll give it a try!

Please sign in to comment.