Skip to content

Commit

Permalink
RE 6901 MantidEV usability
Browse files Browse the repository at this point in the history
When the user selects an event file to load,
default names are now provided for the event, md
and peaks workspaces.

refs #6901
  • Loading branch information
DennisMikkelson committed Apr 25, 2013
1 parent d410c9c commit 9999ef7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ private slots:
/// Utility method to get a positive integer value from a QtLineEdit widget
bool getPositiveInt( QLineEdit *ledt, size_t & value );

/// Get base file name to form names for event, MD and peaks workspaces
std::string extractBaseFileName( std::string FullFileName) const;

/// Get name of file for saving peaks
void getSavePeaksFileName();

Expand Down
42 changes: 42 additions & 0 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MantidEV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,15 @@ void MantidEV::loadEventFile_slot()
{
last_event_file = Qfile_name.toStdString();
m_uiForm.EventFileName_ledt->setText( Qfile_name );

std::string base_name = extractBaseFileName( last_event_file );
std::string event_ws_name = base_name + "_event";
std::string md_ws_name = base_name + "_md";
std::string peaks_ws_name = base_name + "_peaks";

m_uiForm.SelectEventWorkspace_ledt->setText( QString::fromStdString( event_ws_name ));
m_uiForm.MDworkspace_ledt->setText( QString::fromStdString( md_ws_name ));
m_uiForm.PeaksWorkspace_ledt->setText( QString::fromStdString( peaks_ws_name ));
}
}

Expand Down Expand Up @@ -1662,6 +1671,39 @@ bool MantidEV::getPositiveInt( QLineEdit *ledt,
}


/**
* Get base file name to form names for event, MD and peaks workspaces
*
* @param full_file_name The full name of the file that is being loaded.
*
* @return The base file name, with the directory and extension removed.
*/
std::string MantidEV::extractBaseFileName( std::string full_file_name ) const
{
size_t dot_index = full_file_name.find_last_of(".");

if ( dot_index != std::string::npos )
{
full_file_name = full_file_name.substr( 0, dot_index );
}

size_t path_sep_index = full_file_name.find_last_of("/\\:");

if ( path_sep_index != std::string::npos )
{
full_file_name = full_file_name.substr( path_sep_index + 1 );
}

size_t ev_suffix_index = full_file_name.rfind( "_event", std::string::npos );
if ( ev_suffix_index != std::string::npos )
{
full_file_name = full_file_name.substr( 0, ev_suffix_index );
}

return full_file_name;
}


/**
* Utility to save the current state of all GUI components into the
* specified file name. If the filename has length zero, the settings
Expand Down

0 comments on commit 9999ef7

Please sign in to comment.