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()) {
159 if (
isValid && !ads.doesExist(wsName)) {
162 auto const filepath =
m_uiForm.rfFileInput->getUserInput().toString().toStdString();
163 if (!filepath.empty())
166 isValid = ads.doesExist(wsName);
169 m_uiForm.rfFileInput->setFileProblem(
"The specified workspace is "
170 "missing from the analysis data "
174 if (!ads.doesExist(wsName)) {
177 auto const workspaceTypes =
m_uiForm.wsWorkspaceInput->getWorkspaceTypes();
179 isValid = workspaceTypes.empty() || workspaceTypes.indexOf(QString::fromStdString(
workspace->id())) != -1;
181 m_uiForm.rfFileInput->setFileProblem(
"The specified workspace type (" +
182 QString::fromStdString(
workspace->id()) +
184 "not one of the allowed types: " +
185 workspaceTypes.join(
", "));
201 QString problem =
"";
203 problem =
m_uiForm.rfFileInput->getFileProblem();
204 if (problem.compare(
"") == 0) {
205 problem =
"Input field is empty";
208 problem =
"A valid workspace has not been selected";
234 const auto loadAlg = AlgorithmManager::Instance().createUnmanaged(loadAlgName(filename));
235 loadAlg->initialize();
236 loadAlg->setProperty(
"Filename", filename);
237 loadAlg->setProperty(
"OutputWorkspace", outputWorkspace);
269 m_uiForm.rfFileInput->setFileProblem(
error ?
"Could not load file. See log for details." :
"");
284 if (
m_uiForm.stackedDataSelect->currentIndex() > 0) {
286 QString filename =
m_uiForm.wsWorkspaceInput->currentText();
287 if (filename.isEmpty())
330 QFileInfo qfio(filepath);
331 QString baseName = qfio.completeBaseName();
334 if (
m_uiForm.rfFileInput->allowMultipleFiles() && filepath.count(
",") > 0) {
335 baseName +=
"_group";
354 QString filename(
"");
361 if (
m_uiForm.rfFileInput->isValid()) {
362 if (
m_uiForm.rfFileInput->allowMultipleFiles() && !autoLoad) {
373 filename =
m_uiForm.wsWorkspaceInput->currentText();
407 m_uiForm.rfFileInput->restoreSettings(settings);
413 m_uiForm.rfFileInput->saveSettings(settings, values);
430 m_uiForm.pbLoadFile->setEnabled(load);
431 m_uiForm.pbLoadFile->setVisible(load);
440 const QMimeData *mimeData = de->mimeData();
441 auto before_action = de->dropAction();
443 auto const dragData = mimeData->text().toStdString();
445 if (de->mimeData() && ads.doesExist(dragData)) {
446 m_uiForm.wsWorkspaceInput->dropEvent(de);
447 if (de->dropAction() == before_action) {
449 m_uiForm.cbInputType->setCurrentIndex(1);
452 de->setDropAction(before_action);
455 m_uiForm.rfFileInput->dropEvent(de);
456 if (de->dropAction() == before_action) {
457 m_uiForm.cbInputType->setCurrentIndex(0);
460 auto const filepath =
m_uiForm.rfFileInput->getText().toStdString();
461 if (de->mimeData() && !ads.doesExist(dragData) && !filepath.empty()) {
462 auto const file = extractLastOf(filepath,
"/");
463 if (fileFound(file)) {
464 auto const workspaceName = cutLastOf(file,
".");
468 m_uiForm.cbInputType->setCurrentIndex(1);
479 auto const index =
m_uiForm.wsWorkspaceInput->findText(workspaceName);
488 const QMimeData *mimeData = de->mimeData();
489 if (mimeData->hasText() || mimeData->hasUrls())
490 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)