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);
259 m_uiForm.rfFileInput->setFileProblem(
error ?
"Could not load file. See log for details." :
"");
274 if (
m_uiForm.stackedDataSelect->currentIndex() > 0) {
276 QString filename =
m_uiForm.wsWorkspaceInput->currentText();
277 if (filename.isEmpty())
320 QFileInfo qfio(filepath);
321 QString baseName = qfio.completeBaseName();
324 if (
m_uiForm.rfFileInput->allowMultipleFiles() && filepath.count(
",") > 0) {
325 baseName +=
"_group";
344 QString filename(
"");
351 if (
m_uiForm.rfFileInput->isValid()) {
352 if (
m_uiForm.rfFileInput->allowMultipleFiles() && !autoLoad) {
363 filename =
m_uiForm.wsWorkspaceInput->currentText();
418 m_uiForm.pbLoadFile->setEnabled(load);
419 m_uiForm.pbLoadFile->setVisible(load);
428 const QMimeData *mimeData = de->mimeData();
429 auto before_action = de->dropAction();
431 auto const dragData = mimeData->text().toStdString();
433 if (de->mimeData() && ads.doesExist(dragData)) {
434 m_uiForm.wsWorkspaceInput->dropEvent(de);
435 if (de->dropAction() == before_action) {
437 m_uiForm.cbInputType->setCurrentIndex(1);
440 de->setDropAction(before_action);
443 m_uiForm.rfFileInput->dropEvent(de);
444 if (de->dropAction() == before_action) {
445 m_uiForm.cbInputType->setCurrentIndex(0);
448 auto const filepath =
m_uiForm.rfFileInput->getText().toStdString();
449 if (de->mimeData() && !ads.doesExist(dragData) && !filepath.empty()) {
450 auto const file = extractLastOf(filepath,
"/");
451 if (fileFound(file)) {
452 auto const workspaceName = cutLastOf(file,
".");
456 m_uiForm.cbInputType->setCurrentIndex(1);
467 auto const index =
m_uiForm.wsWorkspaceInput->findText(workspaceName);
476 const QMimeData *mimeData = de->mimeData();
477 if (mimeData->hasText() || mimeData->hasUrls())
478 de->acceptProposedAction();
double value
The value of the point.
IPeaksWorkspace_sptr workspace
std::map< DeltaEMode::Type, std::string > index
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)