Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sandialabs/InterSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohns committed Apr 24, 2023
2 parents 94c0491 + 2a277df commit c119bf5
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 11 deletions.
8 changes: 8 additions & 0 deletions InterSpec/InterSpecServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ namespace InterSpecServer
The file path must either be a file-system path to a spectrum file, or it can be a App URL with
the schema "interspec://..."
Call #clear_file_to_open_on_load after you have succesfully handled the file to remove this request
and not accidentally request to load it later.
Throws exception if an invalid session token, or the session has already been loaded.
*/
void set_file_to_open_on_load( const char *session_token, const std::string file_path );
Expand All @@ -227,6 +230,11 @@ namespace InterSpecServer
Returns empty string if none.
*/
std::string file_to_open_on_load( const std::string &session_token );

/** Once you have loaded the file/url from #file_to_open_on_load, call this function to avoid
loading the file/url again later
*/
void clear_file_to_open_on_load( const std::string &session_token );


#if( BUILD_AS_ELECTRON_APP || BUILD_AS_OSX_APP || BUILD_AS_WX_WIDGETS_APP )
Expand Down
2 changes: 1 addition & 1 deletion data/more_nuclide_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ TODO: Need to incorporate the following from FRMAC Spectroscopists guide:

<Ref key="FRMAC">
<desc>FRMAC Gamma Spectroscopist Knowledge Guide. Revision 0., by Michael Enghauser. Sandia National Lab. (SNL-NM), Albuquerque, NM (United States).</desc>
<url>https://www.hamamatsu.com/content/dam/hamamatsu-photonics/sites/documents/99_SALES_LIBRARY/etd/PMT_handbook_v3aE.pdf</url>
<url>https://www.osti.gov/servlets/purl/1763003</url>
<date>20230311</date>
</Ref>

Expand Down
19 changes: 17 additions & 2 deletions src/GammaCountDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@
#include <Wt/WLabel>
#include <Wt/WImage>
#include <Wt/WGridLayout>
#include <Wt/WPushButton>
#include <Wt/WEnvironment>
#include <Wt/WApplication>
#include <Wt/WSelectionBox>
#include <Wt/WDoubleSpinBox>
#include <Wt/WPushButton>
#include <Wt/WContainerWidget>


#include "SpecUtils/SpecFile.h"
#include "SpecUtils/StringAlgo.h"

#include "InterSpec/SpecMeas.h"
#include "InterSpec/AuxWindow.h"
#include "InterSpec/InterSpec.h"
Expand Down Expand Up @@ -196,8 +199,20 @@ void GammaCountDialog::init()

if( m_specViewer && !m_specViewer->isMobile() )
{
WLabel* temp = new WLabel("<center><i><small>You can also <b>Shift-Alt-Drag</b> on the chart"
string key_sequence = "Shift-Alt-Drag"; // Linux / Windows
const string &user_agent = wApp->environment().userAgent();
if( SpecUtils::icontains( user_agent, "macos")
|| SpecUtils::icontains( user_agent, "macintel")
|| SpecUtils::icontains( user_agent, "macintosh")
|| SpecUtils::icontains( user_agent, "iphone")
|| SpecUtils::icontains( user_agent, "ipad") )
{
key_sequence = "Shift-Option-Drag"; //Apple
}

WLabel* temp = new WLabel("<center><i><small>You can also <b>" + key_sequence + "</b> on the chart"
" to select the energy range</small></i></center>");

temp->setWordWrap(true);
layout->addWidget(temp,++row, 0 , 1 ,3,AlignCenter);
temp->setStyleClass("line-below");
Expand Down
7 changes: 5 additions & 2 deletions src/InterSpecApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,13 @@ void InterSpecApp::setupWidgets( const bool attemptStateLoad )
const Http::ParameterMap &parmap = environment().getParameterMap();

#if( !BUILD_FOR_WEB_DEPLOYMENT )
if( !m_externalToken.empty() )
// The check of `attemptStateLoad` isnt strickly needed, as #file_to_open_on_load contents
// will be cleared
if( attemptStateLoad && !m_externalToken.empty() )
{
const string initial_file = InterSpecServer::file_to_open_on_load( m_externalToken );
if( !initial_file.empty() )
{

if( SpecUtils::istarts_with(initial_file, "interspec://")
|| SpecUtils::istarts_with(initial_file, "RADDATA://G0/") )
{
Expand All @@ -556,6 +557,8 @@ void InterSpecApp::setupWidgets( const bool attemptStateLoad )
{
loadedSpecFile = m_viewer->userOpenFileFromFilesystem( initial_file );
}//if( SpecUtils::istarts_with(foregroundPath, "interspec://") )

InterSpecServer::clear_file_to_open_on_load( m_externalToken );

if( loadedSpecFile )
{
Expand Down
9 changes: 9 additions & 0 deletions src/InterSpecServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,15 @@ std::string file_to_open_on_load( const std::string &session_token )
}//file_to_open_on_load(...)


void clear_file_to_open_on_load( const std::string &session_token )
{
lock_guard<mutex> lock( ns_sessions_mutex );
auto pos = ns_sessions.find( session_token );
if( pos != end(ns_sessions) )
ns_sessions.erase( pos );
}//void clear_file_to_open_on_load( const std::string &session_token )


#if( BUILD_AS_ELECTRON_APP || BUILD_AS_OSX_APP || BUILD_AS_WX_WIDGETS_APP )


Expand Down
17 changes: 11 additions & 6 deletions src/ReferencePhotopeakDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,6 @@ void ReferencePhotopeakDisplay::handleIsotopeChange( const bool useCurrentAge )

try
{

if( nuc && !nuc->isStable() && !nuc->decaysToChildren.empty() && !useCurrentAge )
{
if( nuc->decaysToStableChildren() )
Expand All @@ -1370,8 +1369,8 @@ void ReferencePhotopeakDisplay::handleIsotopeChange( const bool useCurrentAge )
m_ageEdit->setText( hlstr );
}else if( m_currentlyShowingNuclide.m_input.m_input_txt != nuc->symbol )
{
string agestr;
PeakDef::defaultDecayTime( nuc, &agestr );
string defagestr;
PeakDef::defaultDecayTime( nuc, &defagestr );
m_ageEdit->setText( agestr );
}else
{
Expand All @@ -1382,9 +1381,15 @@ void ReferencePhotopeakDisplay::handleIsotopeChange( const bool useCurrentAge )
}//if( nuc->decaysToStableChildren() ) / else
}else if( nuc && useCurrentAge )
{
double age = PhysicalUnits::stringToTimeDurationPossibleHalfLife( agestr, nuc->halfLife );
if( age > 100.0*nuc->halfLife || age < 0.0 )
throw std::runtime_error( "" );
if( agestr.empty() && nuc->decaysToStableChildren() )
{
// We dont need an age - we will set to zero - so dont throw exception from empty string
}else
{
double age = PhysicalUnits::stringToTimeDurationPossibleHalfLife( agestr, nuc->halfLife );
if( age > 100.0*nuc->halfLife || age < 0.0 )
throw std::runtime_error( "" );
}
}
}catch(...)
{
Expand Down

0 comments on commit c119bf5

Please sign in to comment.