-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented hiding of unrelevant parameter group in the dialog.
Refs #7441
- Loading branch information
1 parent
097b57e
commit b5158e0
Showing
2 changed files
with
93 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 72 additions & 13 deletions
85
Code/Mantid/MantidQt/CustomDialogs/src/SmoothNeighboursDialog.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,89 @@ | ||
#include "MantidQtCustomDialogs/SmoothNeighboursDialog.h" | ||
|
||
using Mantid::Geometry::Instrument; | ||
using Mantid::API::MatrixWorkspace_sptr; | ||
|
||
//Register the class with the factory | ||
DECLARE_DIALOG(SmoothNeighboursDialog) | ||
|
||
|
||
// As defined in algorithm. Make sure you change them in SmoothNeighbours.cpp as well. | ||
const QString SmoothNeighboursDialog::NON_UNIFORM_GROUP = "NonUniform Detectors"; | ||
const QString SmoothNeighboursDialog::RECTANGULAR_GROUP = "Rectangular Detectors"; | ||
const QString SmoothNeighboursDialog::INPUT_WORKSPACE = "InputWorkspace"; | ||
|
||
SmoothNeighboursDialog::SmoothNeighboursDialog(QWidget* parent) | ||
: AlgorithmDialog(parent) | ||
{ | ||
} | ||
|
||
void SmoothNeighboursDialog::initLayout() | ||
{ | ||
// Set main layout | ||
QVBoxLayout *dialog_layout = new QVBoxLayout(); | ||
setLayout(dialog_layout); | ||
// Create main layout | ||
m_dialogLayout = new QVBoxLayout(); | ||
|
||
this->setLayout(m_dialogLayout); | ||
|
||
// Set to size which fits all the possible widget changes | ||
this->resize(475, 545); | ||
|
||
// Create yellow information box | ||
this->addOptionalMessage(m_dialogLayout); | ||
|
||
m_propertiesWidget = new AlgorithmPropertiesWidget(this); | ||
|
||
m_propertiesWidget->setAlgorithm(this->getAlgorithm()); | ||
|
||
// Tie all the widgets to properties | ||
for (auto it = m_propertiesWidget->m_propWidgets.begin(); it != m_propertiesWidget->m_propWidgets.end(); it++) | ||
this->tie(it.value(), it.key()); | ||
|
||
m_propertiesWidget->hideOrDisableProperties(); | ||
|
||
PropertyWidget* inputWorkspaceWidget = m_propertiesWidget->m_propWidgets[INPUT_WORKSPACE]; | ||
|
||
connect(inputWorkspaceWidget, SIGNAL(valueChanged(const QString&)), | ||
this, SLOT(inputWorkspaceChanged(const QString&))); | ||
|
||
// Create and add widget with all the properties | ||
m_algPropertiesWidget = new AlgorithmPropertiesWidget(this); | ||
m_algPropertiesWidget->setAlgorithm(this->getAlgorithm()); | ||
m_algPropertiesWidget->hideOrDisableProperties(); | ||
dialog_layout->addWidget(m_algPropertiesWidget, 1); | ||
m_dialogLayout->addWidget(m_propertiesWidget); | ||
|
||
// Create and add the OK/Cancel/Help. buttons | ||
dialog_layout->addLayout(this->createDefaultButtonLayout(), 0); | ||
m_dialogLayout->addLayout(this->createDefaultButtonLayout()); | ||
|
||
// Explicitly call, to hide/show property group from the beginning | ||
inputWorkspaceWidget->valueChangedSlot(); | ||
} | ||
|
||
void SmoothNeighboursDialog::parseInput() | ||
void SmoothNeighboursDialog::inputWorkspaceChanged(const QString& pName) | ||
{ | ||
// TODO: implement | ||
} | ||
UNUSED_ARG(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(); | ||
|
||
QString groupToShow; | ||
|
||
if(containsRectDetectors == Instrument::ContainsState::Full) | ||
groupToShow = RECTANGULAR_GROUP; | ||
else | ||
groupToShow = NON_UNIFORM_GROUP; | ||
|
||
m_propertiesWidget->m_groupWidgets[groupToShow]->setVisible(true); | ||
} | ||
|
||
void SmoothNeighboursDialog::accept() | ||
{ | ||
AlgorithmDialog::accept(); | ||
|
||
// If got there, there were errors | ||
for(auto it = m_errors.begin(); it != m_errors.end(); it++) | ||
m_propertiesWidget->m_propWidgets[it.key()]->setError(it.value()); | ||
} |