26auto &ads = AnalysisDataService::Instance();
28std::string cutLastOf(
const std::string &str,
const std::string &delimiter) {
29 const auto cutIndex = str.rfind(delimiter);
30 if (cutIndex != std::string::npos)
31 return str.substr(0, cutIndex);
35std::string extractLastOf(
const std::string &str,
const std::string &delimiter) {
36 const auto cutIndex = str.rfind(delimiter);
37 if (cutIndex != std::string::npos)
38 return str.substr(cutIndex + 1, str.size() - cutIndex);
42bool fileFound(std::string
const &file) {
return !FileFinder::Instance().getFullPath(file).empty(); }
44std::string loadAlgName(
const std::string &filePath) {
45 const auto suffix = extractLastOf(filePath,
".");
46 return suffix ==
"dave" ?
"LoadDaveGrp" :
"Load";
49void makeGroup(std::string
const &workspaceName) {
51 const auto groupAlg = AlgorithmManager::Instance().createUnmanaged(
"GroupWorkspaces");
52 groupAlg->initialize();
53 groupAlg->setProperty(
"InputWorkspaces", workspaceName);
54 groupAlg->setProperty(
"OutputWorkspace", workspaceName);
64 :
API::MantidWidget(parent), m_loadProperties(), m_algRunner(), m_showLoad(true), m_alwaysLoadAsGroup(false) {
75 this->setAcceptDrops(
true);
76 m_uiForm.rfFileInput->setAcceptDrops(
false);
102 QString filename =
m_uiForm.rfFileInput->getUserInput().toString();
104 if (filename.isEmpty()) {
160 if (
isValid && !ads.doesExist(wsName)) {
163 auto const filepath =
m_uiForm.rfFileInput->getUserInput().toString().toStdString();
164 if (!filepath.empty())
167 isValid = ads.doesExist(wsName);
170 m_uiForm.rfFileInput->setFileProblem(
"The specified workspace is "
171 "missing from the analysis data "
175 if (!ads.doesExist(wsName)) {
178 auto const workspaceTypes =
m_uiForm.wsWorkspaceInput->getWorkspaceTypes();
180 isValid = workspaceTypes.empty() || workspaceTypes.indexOf(QString::fromStdString(
workspace->id())) != -1;
182 m_uiForm.rfFileInput->setFileProblem(
"The specified workspace type (" +
183 QString::fromStdString(
workspace->id()) +
185 "not one of the allowed types: " +
186 workspaceTypes.join(
", "));
202 QString problem =
"";
204 problem =
m_uiForm.rfFileInput->getFileProblem();
205 if (problem.compare(
"") == 0) {
206 problem =
"Input field is empty";
209 problem =
"A valid workspace has not been selected";
237 const auto loadAlg = AlgorithmManager::Instance().createUnmanaged(loadAlgName(filename));
238 loadAlg->initialize();
240 loadAlg->setProperty(
"Filename", filename);
241 loadAlg->setProperty(
"OutputWorkspace", outputWorkspace);
242 }
catch (std::exception
const &ex) {
243 m_uiForm.rfFileInput->setFileProblem(ex.what());
278 m_uiForm.rfFileInput->setFileProblem(
error ?
"Could not load file. See log for details." :
"");
293 if (
m_uiForm.stackedDataSelect->currentIndex() > 0) {
295 QString filename =
m_uiForm.wsWorkspaceInput->currentText();
296 if (filename.isEmpty())
339 QFileInfo qfio(filepath);
340 QString baseName = qfio.completeBaseName();
343 if (
m_uiForm.rfFileInput->allowMultipleFiles() && filepath.count(
",") > 0) {
344 baseName +=
"_group";
363 QString filename(
"");
370 if (
m_uiForm.rfFileInput->isValid()) {
371 if (
m_uiForm.rfFileInput->allowMultipleFiles() && !autoLoad) {
382 filename =
m_uiForm.wsWorkspaceInput->currentText();
416 m_uiForm.rfFileInput->restoreSettings(settings);
422 m_uiForm.rfFileInput->saveSettings(settings, values);
439 m_uiForm.pbLoadFile->setEnabled(load);
440 m_uiForm.pbLoadFile->setVisible(load);
449 const QMimeData *mimeData = de->mimeData();
450 auto before_action = de->dropAction();
452 auto const dragData = mimeData->text().toStdString();
454 if (de->mimeData() && ads.doesExist(dragData)) {
455 m_uiForm.wsWorkspaceInput->dropEvent(de);
456 if (de->dropAction() == before_action) {
458 m_uiForm.cbInputType->setCurrentIndex(1);
461 de->setDropAction(before_action);
464 m_uiForm.rfFileInput->dropEvent(de);
465 if (de->dropAction() == before_action) {
466 m_uiForm.cbInputType->setCurrentIndex(0);
469 auto const filepath =
m_uiForm.rfFileInput->getText().toStdString();
470 if (de->mimeData() && !ads.doesExist(dragData) && !filepath.empty()) {
471 auto const file = extractLastOf(filepath,
"/");
472 if (fileFound(file)) {
473 auto const workspaceName = cutLastOf(file,
".");
477 m_uiForm.cbInputType->setCurrentIndex(1);
488 auto const index =
m_uiForm.wsWorkspaceInput->findText(workspaceName);
497 const QMimeData *mimeData = de->mimeData();
498 if (mimeData->hasText() || mimeData->hasUrls())
499 de->acceptProposedAction();
double value
The value of the point.
IPeaksWorkspace_sptr workspace
std::map< DeltaEMode::Type, std::string > index
Immutable snapshot of the persistent state used by FileFinderWidget.
virtual void startAlgorithm(Mantid::API::IAlgorithm_sptr alg)
Begin asynchronous execution of an algorithm and observe its execution.
Class to hold a set of workspaces.
Base Workspace Abstract Class.
void MANTID_API_DLL update(std::string const &property, std::string const &value, IAlgorithmRuntimeProps &properties)