From 6b827782b93cc91117c5a515b8523b865054f334 Mon Sep 17 00:00:00 2001 From: William Johnson Date: Thu, 23 Nov 2023 16:27:06 -0800 Subject: [PATCH] A little cleanup around PeakSkew. --- InterSpec/PeakDef.h | 1 + src/InterSpec.cpp | 4 ++-- src/PeakDef.cpp | 18 ++++++++++++++++++ src/PeakEdit.cpp | 22 +--------------------- src/RelActAutoGui.cpp | 12 +----------- target/osx/CMakeLists.txt | 2 +- 6 files changed, 24 insertions(+), 35 deletions(-) diff --git a/InterSpec/PeakDef.h b/InterSpec/PeakDef.h index a9c9e118..72adcc1b 100644 --- a/InterSpec/PeakDef.h +++ b/InterSpec/PeakDef.h @@ -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. diff --git a/src/InterSpec.cpp b/src/InterSpec.cpp index 05d6e1d3..13c85904 100644 --- a/src/InterSpec.cpp +++ b/src/InterSpec.cpp @@ -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(type) ) ); }//for( loop over PeakContinuum::OffsetTypes ) @@ -2509,7 +2509,7 @@ void InterSpec::handleRightClick( double energy, double counts, // Disable current skew type, enable all others const vector 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: diff --git a/src/PeakDef.cpp b/src/PeakDef.cpp index 7d03ab2f..86ca7351 100644 --- a/src/PeakDef.cpp +++ b/src/PeakDef.cpp @@ -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") ) diff --git a/src/PeakEdit.cpp b/src/PeakEdit.cpp index a4e716ef..e0da4ee3 100644 --- a/src/PeakEdit.cpp +++ b/src/PeakEdit.cpp @@ -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 ); diff --git a/src/RelActAutoGui.cpp b/src/RelActAutoGui.cpp index 716137e7..e7a9bc15 100644 --- a/src/RelActAutoGui.cpp +++ b/src/RelActAutoGui.cpp @@ -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 ) diff --git a/target/osx/CMakeLists.txt b/target/osx/CMakeLists.txt index 1ee395d6..8e27e1d6 100644 --- a/target/osx/CMakeLists.txt +++ b/target/osx/CMakeLists.txt @@ -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" )