Skip to content

Commit

Permalink
A little cleanup around PeakSkew.
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohns committed Nov 24, 2023
1 parent 0637040 commit 6b82778
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 35 deletions.
1 change: 1 addition & 0 deletions InterSpec/PeakDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ class PeakDef

static const char *to_string( const CoefficientType type );
static const char *to_string( const SkewType type );
static const char *to_label( const SkewType type );
static SkewType skew_from_string( const std::string &skew_str );

/** Gives reasonable range for skew parameter values, as well as a reasonable starting value.
Expand Down
4 changes: 2 additions & 2 deletions src/InterSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ InterSpec::InterSpec( WContainerWidget *parent )
for( auto type = PeakDef::SkewType(0);
type <= PeakDef::SkewType::DoubleSidedCrystalBall; type = PeakDef::SkewType(type+1) )
{
WMenuItem *item = m_rightClickChangeSkewMenu->addItem( PeakDef::to_string(type) );
WMenuItem *item = m_rightClickChangeSkewMenu->addItem( PeakDef::to_label(type) );
item->triggered().connect( boost::bind( &InterSpec::handleChangeSkewTypeFromRightClick,
this, static_cast<int>(type) ) );
}//for( loop over PeakContinuum::OffsetTypes )
Expand Down Expand Up @@ -2509,7 +2509,7 @@ void InterSpec::handleRightClick( double energy, double counts,

// Disable current skew type, enable all others
const vector<WMenuItem *> items = m_rightClickChangeSkewMenu->items();
const char *labelTxt = PeakDef::to_string( peak->skewType() );
const char *labelTxt = PeakDef::to_label( peak->skewType() );
for( WMenuItem *item : items )
item->setDisabled( item->text() == labelTxt );
}//case kChangeSkew:
Expand Down
18 changes: 18 additions & 0 deletions src/PeakDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,24 @@ const char *PeakDef::to_string( const SkewType type )
}//const char *to_string( const SkewType type )


const char *PeakDef::to_label( const SkewType type )
{
switch( type )
{
case PeakDef::NoSkew: return "None";
case PeakDef::Bortel: return "Exp*Gauss";
case PeakDef::GaussExp: return "GaussExp";
case PeakDef::CrystalBall: return "Crystal Ball";
case PeakDef::ExpGaussExp: return "ExpGaussExp";
case PeakDef::DoubleSidedCrystalBall: return "Double Crystal Ball";
}//switch( skew_type )

assert( 0 );
throw runtime_error( "PeakDef::to_string(SkewType): invalid SkewType" );
return "";
}//const char *to_label( const SkewType type );


PeakDef::SkewType PeakDef::skew_from_string( const string &skew_type_str )
{
if( SpecUtils::iequals_ascii(skew_type_str,"NoSkew") )
Expand Down
22 changes: 1 addition & 21 deletions src/PeakEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,27 +498,7 @@ void PeakEdit::init()
for( PeakDef::SkewType t = PeakDef::SkewType(0);
t <= PeakDef::DoubleSidedCrystalBall; t = PeakDef::SkewType(t+1) )
{
switch ( t )
{
case PeakDef::NoSkew:
m_skewType->addItem( "None" );
break;
case PeakDef::Bortel:
m_skewType->addItem( "Exp*Gauss" );
break;
case PeakDef::CrystalBall:
m_skewType->addItem( "Crystal Ball" );
break;
case PeakDef::DoubleSidedCrystalBall:
m_skewType->addItem( "Double Crystal Ball" );
break;
case PeakDef::GaussExp:
m_skewType->addItem( "GaussExp" );
break;
case PeakDef::ExpGaussExp:
m_skewType->addItem( "ExpGaussExp" );
break;
}//switch ( t )
m_skewType->addItem( PeakDef::to_label(t) );
}//for( loop over PeakDef::OffsetType )

row = m_valueTable->rowAt( PeakEdit::NumPeakPars+8 );
Expand Down
12 changes: 1 addition & 11 deletions src/RelActAutoGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1572,17 +1572,7 @@ RelActAutoGui::RelActAutoGui( InterSpec *viewer, Wt::WContainerWidget *parent )
for( auto st = PeakDef::SkewType(0); st <= PeakDef::SkewType::DoubleSidedCrystalBall;
st = PeakDef::SkewType(st + 1) )
{
const char *label = "";
switch( st )
{
case PeakDef::NoSkew: label = "None"; break;
case PeakDef::Bortel: label = "exGaussian"; break;
case PeakDef::GaussExp: label = "GaussExp"; break;
case PeakDef::CrystalBall: label = "Crystal Ball"; break;
case PeakDef::ExpGaussExp: label = "ExpGaussExp"; break;
case PeakDef::DoubleSidedCrystalBall: label = "Double Crystal Ball"; break;
}//switch( st )

const char *label = PeakDef::to_label(st);
m_skew_type->addItem( label );
}//for( loop over SkewTypes )

Expand Down
2 changes: 1 addition & 1 deletion target/osx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SET(MACOSX_BUNDLE_BUNDLE_VERSION "0" )
SET(MACOSX_BUNDLE_COPYRIGHT "Sandia National Labs, Will Johnson" )
SET(MACOSX_BUNDLE_GUI_IDENTIFIER "gov.sandia.macOS.InterSpec" )
#set MACOS_BUNDLE_VERSION_NUMBER for Info.plist.template to populate corresponding value in Xcode
set(MACOS_BUNDLE_VERSION_NUMBER 39)
set(MACOS_BUNDLE_VERSION_NUMBER 41)


SET( ${PRODUCT_NAME} "InterSpec" )
Expand Down

0 comments on commit 6b82778

Please sign in to comment.