Skip to content

Commit

Permalink
Add option to show a modal-dialog for automatic external RID results.
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohns committed Dec 8, 2023
1 parent 58d8cfc commit 2de8d06
Show file tree
Hide file tree
Showing 5 changed files with 655 additions and 197 deletions.
14 changes: 14 additions & 0 deletions InterSpec/InterSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,10 @@ class InterSpec : public Wt::WContainerWidget
RemoteRid *remoteRid();
void createRemoteRidWindow();
void deleteRemoteRidWindow();

void setAutoRemoteRidResultDialog( SimpleDialog *dialog );
void handleAutoRemoteRidResultDialogClose();
void programaticallyCloseAutoRemoteRidResultDialog();
#endif


Expand Down Expand Up @@ -1455,6 +1459,16 @@ class InterSpec : public Wt::WContainerWidget
PopupDivMenuItem *m_featureMarkerMenuItem;

SimpleDialog *m_multimedia;

#if( USE_REMOTE_RID )
/** When the user has selected spectra to be sent off to external RID analysis, and results to
be displayed in a dialog, instead of a Toast message, this pointer will keep track of the dialog.
\sa getAutoRemoteRidResultDialog
\sa handleAutoRemoteRidResultDialogClose
*/
SimpleDialog *m_autoRemoteRidResultDialog;
#endif

GammaXsWindow *m_gammaXsToolWindow;
DoseCalcWindow *m_doseCalcWindow;
Expand Down
22 changes: 22 additions & 0 deletions InterSpec/RemoteRid.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,33 @@ namespace SpecUtils { class SpecFile; }

namespace RestRidImp { class ExternalRidWidget; }

/** An enum that represents the value of the integer "AlwaysCallExternalRid" preference.
```
const int always_call = InterSpecUser::preferenceValue<int>( "AlwaysCallExternalRid", m_interspec );
const auto pref = static_cast<ExternalRidAuotCallPref>( always_call );
```
*/
enum class ExternalRidAuotCallPref : int
{
DoNotCall = 0,
AlwaysUseRestWithToast = 1,
AlwaysUseExeWithToast = 2,
AlwaysUseRestWithDialog = 3,
AlwaysUseExeWithDialog = 4
};//enum class ExternalRidCallPrevValue : int



/** Interface to the Full-Spectrum nuclide ID algorithm, either to the REST web service, or to
the command line interface of the executable.
*/
class RemoteRid : public Wt::WContainerWidget
{
public:
/** Retrieves and returns users preference about calling external RID algorithm. */
static ExternalRidAuotCallPref external_rid_call_pref( InterSpec *viewer );

public:
/** Starts a remote RID dialog sequence.
Expand Down
11 changes: 10 additions & 1 deletion InterSpec_resources/RemoteRid.css
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,16 @@
}


.RemoteRid .AlwaysSubmitAna
.ExternalRidWidget .RidOptionCbRow
{
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
}

.RemoteRid .AlwaysSubmitAna, .RemoteRid .ShowDialogOpt
{
margin-left: 10px;
}
44 changes: 38 additions & 6 deletions src/InterSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ InterSpec::InterSpec( WContainerWidget *parent )
m_featureMarkers( nullptr ),
m_featureMarkerMenuItem( nullptr ),
m_multimedia( nullptr ),
#if( USE_REMOTE_RID )
m_autoRemoteRidResultDialog( nullptr ),
#endif
m_gammaXsToolWindow( nullptr ),
m_doseCalcWindow( nullptr ),
m_1overR2Calc( nullptr ),
Expand Down Expand Up @@ -8608,7 +8611,6 @@ void InterSpec::createRemoteRidWindow()

void InterSpec::deleteRemoteRidWindow()
{
assert( m_remoteRid );
if( !m_remoteRid )
return;

Expand Down Expand Up @@ -8637,6 +8639,30 @@ void InterSpec::deleteRemoteRidWindow()
m_undo->addUndoRedoStep( std::move(undo), std::move(redo), "Close remote RID tool" );
}
}//void handleRemoteRidClose()

void InterSpec::setAutoRemoteRidResultDialog( SimpleDialog *dialog )
{
programaticallyCloseAutoRemoteRidResultDialog();
m_autoRemoteRidResultDialog = dialog;
}//setAutoRemoteRidResultDialog()


void InterSpec::handleAutoRemoteRidResultDialogClose()
{
m_autoRemoteRidResultDialog = nullptr;
}//handleAutoRemoteRidResultDialogClose()


void InterSpec::programaticallyCloseAutoRemoteRidResultDialog()
{
SimpleDialog *dialog = m_autoRemoteRidResultDialog;

//Set m_multimedia to m_autoRemoteRidResultDialog so #handleAutoRemoteRidResultDialogClose
// wont add undo/redo step
m_autoRemoteRidResultDialog = nullptr;
if( dialog )
dialog->done( Wt::WDialog::DialogCode::Accepted );
}//programaticallyCloseAutoRemoteRidResultDialog()
#endif //#if( USE_REMOTE_RID )


Expand Down Expand Up @@ -10815,9 +10841,9 @@ void InterSpec::setSpectrum( std::shared_ptr<SpecMeas> meas,
const std::string type = SpecUtils::descriptionText(spec_type);
WStringStream js;
#if( USE_REMOTE_RID )
js << "File contained on-board RIID results: "
js << "File contained on-board RID results: "
#else
js << "File contained RIID analysis results: "
js << "File contained RID analysis results: "
#endif
<< riidAnaSummary(meas)
<< "<div onclick="
Expand All @@ -10835,8 +10861,9 @@ void InterSpec::setSpectrum( std::shared_ptr<SpecMeas> meas,
#if( USE_REMOTE_RID )
if( meas && !options.testFlag(SetSpectrumOptions::SkipExternalRid) )
{
const int call_ext_rid = InterSpecUser::preferenceValue<int>( "AlwaysCallExternalRid", this );
if( (call_ext_rid == 1) || (call_ext_rid == 2) )
const ExternalRidAuotCallPref pref = RemoteRid::external_rid_call_pref( this );

if( pref != ExternalRidAuotCallPref::DoNotCall )
{
Wt::WApplication *app = wApp;
auto callExternalRid = [app,this,sameSpecFile](){
Expand All @@ -10850,7 +10877,7 @@ void InterSpec::setSpectrum( std::shared_ptr<SpecMeas> meas,
if( sameSpecFile )
flags |= RemoteRid::AnaFileOptions::OnlyDisplayedSearchSamples;

RemoteRid::startAutomatedOnLoadAnalysis(this, flags );
RemoteRid::startAutomatedOnLoadAnalysis( this, flags );
}else
{
cerr << "Failed to get WApplication::UpdateLock to call external RID." << endl;
Expand Down Expand Up @@ -10914,6 +10941,11 @@ void InterSpec::setSpectrum( std::shared_ptr<SpecMeas> meas,
programmaticallyCloseMultimediaWindow();
assert( !m_multimedia );

#if( USE_REMOTE_RID )
if( m_autoRemoteRidResultDialog )
programaticallyCloseAutoRemoteRidResultDialog();
#endif

bool show_notification = false;
for( const shared_ptr<const SpecUtils::MultimediaData> &mmd : m_dataMeasurement->multimedia_data() )
{
Expand Down
Loading

0 comments on commit 2de8d06

Please sign in to comment.