diff --git a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/Load.h b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/Load.h index fb4a2d669a56d802db0a60b3476d4f5578192eee..5f77d3055f66a71654ec13da2ffa214300878bf4 100644 --- a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/Load.h +++ b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/Load.h @@ -74,7 +74,8 @@ namespace Mantid /// Set the output workspace(s) void setOutputWorkspace(const API::IDataFileChecker_sptr loader); /// Retrieve a pointer to the output workspace from the sub algorithm - API::Workspace_sptr getOutputWorkspace(const API::IDataFileChecker_sptr loader) const; + API::Workspace_sptr getOutputWorkspace(const std::string & propName, + const API::IDataFileChecker_sptr loader) const; private: diff --git a/Code/Mantid/Framework/DataHandling/src/Load.cpp b/Code/Mantid/Framework/DataHandling/src/Load.cpp index d96e14f6deae74a46d190bcc067473956523a698..b2228f32ceea58660a6e66477df134469871418c 100644 --- a/Code/Mantid/Framework/DataHandling/src/Load.cpp +++ b/Code/Mantid/Framework/DataHandling/src/Load.cpp @@ -4,6 +4,7 @@ #include "MantidDataHandling/Load.h" #include "MantidAPI/FileProperty.h" #include "MantidAPI/IEventWorkspace.h" +#include "MantidAPI/IWorkspaceProperty.h" #include "MantidKernel/ArrayProperty.h" #include "MantidAPI/LoadAlgorithmFactory.h" #include "MantidAPI/AlgorithmManager.h" @@ -302,39 +303,44 @@ namespace Mantid /** * Set the output workspace(s) if the load's return workspace has type API::Workspace - * @param load :: Shared pointer to load algorithm + * @param loader :: Shared pointer to load algorithm */ - void Load::setOutputWorkspace(const API::IDataFileChecker_sptr load) + void Load::setOutputWorkspace(const API::IDataFileChecker_sptr loader) { - Workspace_sptr childWS = getOutputWorkspace(load); - if( WorkspaceGroup_sptr wsGroup = boost::dynamic_pointer_cast<WorkspaceGroup>(childWS) ) + // Go through each OutputWorkspace property and check whether we need to make a counterpart here + const std::vector<Property*> loaderProps = loader->getProperties(); + const size_t count = loader->propertyCount(); + for( size_t i = 0; i < count; ++i ) { - std::vector<std::string> names = wsGroup->getNames(); - const size_t numMembers(names.size()); - const std::string baseName("OutputWorkspace_"); - for( size_t i = 0; i < numMembers; ++i ) + Property *prop = loaderProps[i]; + if( dynamic_cast<IWorkspaceProperty*>(prop) && prop->direction() == Direction::Output ) { - std::ostringstream propName; - propName << baseName << (i+1); - declareProperty(new WorkspaceProperty<Workspace>(propName.str(), load->getPropertyValue(propName.str()), - Direction::Output)); - Workspace_sptr memberWS = load->getProperty(propName.str()); - setProperty(propName.str(), memberWS); + const std::string & name = prop->name(); + if( !this->existsProperty(name) ) + { + declareProperty(new WorkspaceProperty<Workspace>(name, loader->getPropertyValue(name), + Direction::Output)); + } + Workspace_sptr wkspace = getOutputWorkspace(name, loader); + setProperty(name, wkspace); } } - setProperty("OutputWorkspace", childWS); } /** - * Return the top-level workspace property + * Return an output workspace property dealing with the lack of connection between of + * WorkspaceProperty types + * @param propName :: The name of the property + * @param loader :: The loader algorithm * @returns A pointer to the OutputWorkspace property of the sub algorithm */ - API::Workspace_sptr Load::getOutputWorkspace(const API::IDataFileChecker_sptr loader) const + API::Workspace_sptr Load::getOutputWorkspace(const std::string & propName, + const API::IDataFileChecker_sptr loader) const { // @todo Need to try and find a better way using the getValue methods try { - return loader->getProperty("OutputWorkspace"); + return loader->getProperty(propName); } catch(std::runtime_error&) { @@ -342,7 +348,7 @@ namespace Mantid // Try a MatrixWorkspace try { - MatrixWorkspace_sptr childWS = loader->getProperty("OutputWorkspace"); + MatrixWorkspace_sptr childWS = loader->getProperty(propName); return childWS; } catch(std::runtime_error&) @@ -351,7 +357,7 @@ namespace Mantid // EventWorkspace try { - IEventWorkspace_sptr childWS = loader->getProperty("OutputWorkspace"); + IEventWorkspace_sptr childWS = loader->getProperty(propName); return childWS; } catch(std::runtime_error&) diff --git a/Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp b/Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp index 769a97ada8181194cacbadff87c8e4e341c175db..de7e4932af42a1c35f74f638bc70f9aa0d06897e 100644 --- a/Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp +++ b/Code/Mantid/MantidQt/API/src/AlgorithmDialog.cpp @@ -201,7 +201,7 @@ QLabel* AlgorithmDialog::getValidatorMarker(const QString & propname) const QLabel *validLbl(NULL); if( !m_validators.contains(propname) ) { - validLbl = new QLabel("*", const_cast<AlgorithmDialog*>(this)); + validLbl = new QLabel("*"); QPalette pal = validLbl->palette(); pal.setColor(QPalette::WindowText, Qt::darkRed); validLbl->setPalette(pal); @@ -253,7 +253,11 @@ bool AlgorithmDialog::setPropertyValues() { validator->setToolTip(QString::fromStdString(error)); if( error.empty() ) validator->hide(); - else validator->show(); + else + { + validator->show(); + allValid = false; + } } } return allValid;