Skip to content

Commit

Permalink
Added auto update on file load and prop change
Browse files Browse the repository at this point in the history
Refs #10300
  • Loading branch information
DanNixon committed Oct 2, 2014
1 parent 7c816cf commit 7340483
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Expand Up @@ -2285,6 +2285,9 @@ Later steps in the process (saving, renaming) will not be done.</string>
<string>_sqw.nxs</string>
</stringlist>
</property>
<property name="autoLoad" stdset="0">
<bool>true</bool>
</property>
<property name="showLoad" stdset="0">
<bool>false</bool>
</property>
Expand Down
Expand Up @@ -59,7 +59,7 @@ namespace CustomInterfaces
/// Slot to update the guides when the range properties change
void updateProperties(QtProperty* prop, double val);
/// Triggers an update of the preview plot
void updatePreviewPlot();
void updatePreviewPlot(QString workspaceName = "");
/// Called when the algorithm completes to update preview plot
void momentsAlgComplete(bool error);

Expand Down
25 changes: 17 additions & 8 deletions Code/Mantid/MantidQt/CustomInterfaces/src/IndirectMoments.cpp
Expand Up @@ -67,8 +67,13 @@ namespace CustomInterfaces
connect(m_rangeSelectors["MomentsRangeSelector"], SIGNAL(maxValueChanged(double)), this, SLOT(maxValueChanged(double)));
connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updateProperties(QtProperty*, double)));

// Update the preview plot when the algorithm completes
connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(momentsAlgComplete(bool)));

// Events that will update the preview plot
connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updatePreviewPlot()));
connect(m_uiForm.moment_dsInput, SIGNAL(dataReady(const QString&)), this, SLOT(updatePreviewPlot(const QString&)));

m_uiForm.moment_validScale->setStyleSheet("QLabel { color : #aa0000; }");
}

Expand All @@ -86,7 +91,7 @@ namespace CustomInterfaces
void IndirectMoments::run()
{
QString workspaceName = m_uiForm.moment_dsInput->getCurrentDataName();
QString outputName = workspaceName.left(workspaceName.length()-4);
QString outputName = workspaceName.left(workspaceName.length() - 4);
QString scaleString = m_uiForm.moment_leScale->text();
double scale = 1.0;
double eMin = m_dblManager->value(m_properties["EMin"]);
Expand All @@ -96,7 +101,7 @@ namespace CustomInterfaces
bool verbose = m_uiForm.moment_ckVerbose->isChecked();
bool save = m_uiForm.moment_ckSave->isChecked();

if (!scaleString.isEmpty())
if(!scaleString.isEmpty())
scale = scaleString.toDouble();

std::string outputWorkspaceName = outputName.toStdString() + "_Moments";
Expand Down Expand Up @@ -137,10 +142,14 @@ namespace CustomInterfaces

void IndirectMoments::handleSampleInputReady(const QString& filename)
{
disconnect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updatePreviewPlot()));

plotMiniPlot(filename, 0, "MomentsPlot", "MomentsPlotCurve");
std::pair<double,double> range = getCurveRange("MomentsPlotCurve");
setMiniPlotGuides("MomentsRangeSelector", m_properties["EMin"], m_properties["EMax"], range);
setPlotRange("MomentsRangeSelector", m_properties["EMin"], m_properties["EMax"], range);

connect(m_dblManager, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updatePreviewPlot()));
}

/**
Expand All @@ -163,7 +172,7 @@ namespace CustomInterfaces
m_dblManager->setValue(m_properties["EMax"], max);
}

/**
/**
* Handles when properties in the property manager are updated.
*
* @param prop :: The property being updated
Expand Down Expand Up @@ -200,9 +209,11 @@ namespace CustomInterfaces
/**
* Runs the moments algorithm with preview properties.
*/
void IndirectMoments::updatePreviewPlot()
void IndirectMoments::updatePreviewPlot(QString workspaceName)
{
QString workspaceName = m_uiForm.moment_dsInput->getCurrentDataName();
if(workspaceName.isEmpty())
workspaceName = m_uiForm.moment_dsInput->getCurrentDataName();

QString outputName = workspaceName.left(workspaceName.length() - 4);
QString scaleString = m_uiForm.moment_leScale->text();
double scale = 1.0;
Expand Down Expand Up @@ -256,13 +267,11 @@ namespace CustomInterfaces
plotMiniPlot(QString::fromStdString(resultWsNames[2]), 0, "MomentsPreviewPlot", "Moments_M2");
plotMiniPlot(QString::fromStdString(resultWsNames[3]), 0, "MomentsPreviewPlot", "Moments_M4");

// Colour plots as per plot option
// Colour plots as close to plot output as possible
m_curves["Moments_M0"]->setPen(QColor(Qt::green));
m_curves["Moments_M2"]->setPen(QColor(Qt::black));
m_curves["Moments_M4"]->setPen(QColor(Qt::red));

// Set X range to data range
/* setXAxisToCurve("PreviewPlot", ""); */
m_plots["MomentsPreviewPlot"]->replot();
}

Expand Down

0 comments on commit 7340483

Please sign in to comment.