Skip to content

Commit

Permalink
Made the dialog work properly for workspace groups.
Browse files Browse the repository at this point in the history
Refs #7441
  • Loading branch information
arturbekasov committed Jul 24, 2013
1 parent a0d672d commit d8a3a29
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions Code/Mantid/MantidQt/CustomDialogs/src/SmoothNeighboursDialog.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidQtCustomDialogs/SmoothNeighboursDialog.h"

using Mantid::Geometry::Instrument;
using Mantid::API::MatrixWorkspace_sptr;
using namespace Mantid::API;
using namespace Mantid::Geometry;

//Register the class with the factory
DECLARE_DIALOG(SmoothNeighboursDialog)
Expand Down Expand Up @@ -60,23 +61,32 @@ void SmoothNeighboursDialog::inputWorkspaceChanged(const QString& pName)
m_propertiesWidget->m_groupWidgets[RECTANGULAR_GROUP]->setVisible(false);
m_propertiesWidget->m_groupWidgets[NON_UNIFORM_GROUP]->setVisible(false);

// Workspace should have been set by PropertyWidget before emitting valueChanged
MatrixWorkspace_sptr workspace = this->getAlgorithm()->getProperty(INPUT_WORKSPACE.toStdString());

// If invalid workspace, do nothing
if(!workspace)
return;

Instrument::ContainsState containsRectDetectors = workspace->getInstrument()->containsRectDetectors();
std::string inWsName = INPUT_WORKSPACE.toStdString();

QString groupToShow;
// Workspace should have been set by PropertyWidget before emitting valueChanged
MatrixWorkspace_sptr inWs = this->getAlgorithm()->getProperty(inWsName);

if(!inWs)
{
// Workspace groups are NOT returned by IWP->getWorkspace(), as they are not MatrixWorkspace,
// so check the ADS for the GroupWorkspace with the same name
std::string inWsValue = this->getAlgorithm()->getPointerToProperty(inWsName)->value();
WorkspaceGroup_sptr inGroupWs = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(inWsValue);

if(inGroupWs)
// If is a group workspace, use the first workspace to determine the instrument type,
// as most of the times it will be the same for all the workspaces
inWs = boost::dynamic_pointer_cast<MatrixWorkspace>(inGroupWs->getItem(0));
else
// If is not a GroupWorkspace as well, do nothing
return;
}
Instrument::ContainsState containsRectDetectors = inWs->getInstrument()->containsRectDetectors();

if(containsRectDetectors == Instrument::ContainsState::Full)
groupToShow = RECTANGULAR_GROUP;
m_propertiesWidget->m_groupWidgets[RECTANGULAR_GROUP]->setVisible(true);
else
groupToShow = NON_UNIFORM_GROUP;

m_propertiesWidget->m_groupWidgets[groupToShow]->setVisible(true);
m_propertiesWidget->m_groupWidgets[NON_UNIFORM_GROUP]->setVisible(true);
}

void SmoothNeighboursDialog::accept()
Expand Down

0 comments on commit d8a3a29

Please sign in to comment.