Skip to content

Commit

Permalink
Added output as tree widget
Browse files Browse the repository at this point in the history
Refs #11072
  • Loading branch information
DanNixon committed Feb 16, 2015
1 parent 4adc1e9 commit 98ffcab
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 15 deletions.
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>275</height>
<width>550</width>
<height>450</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -214,17 +214,47 @@
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<widget class="QGroupBox" name="gbOutput">
<property name="title">
<string>Output</string>
</property>
</spacer>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QWidget" name="ppTransmission" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="canvasColor" stdset="0">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="showLegend" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="twResults">
<column>
<property name="text">
<string>Property</string>
</property>
</column>
<column>
<property name="text">
<string>Value</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="loActionButtons">
Expand Down
40 changes: 39 additions & 1 deletion Code/Mantid/MantidQt/CustomInterfaces/src/SampleTransmission.cpp
Expand Up @@ -4,6 +4,7 @@
#include "MantidQtCustomInterfaces/SampleTransmission.h"

#include "MantidAPI/AlgorithmManager.h"
#include "MantidKernel/Statistics.h"
#include "MantidQtCustomInterfaces/UserInputValidator.h"


Expand Down Expand Up @@ -154,9 +155,46 @@ void SampleTransmission::calculate()
*/
void SampleTransmission::algorithmComplete(bool error)
{
using namespace Mantid::Kernel;

// Ignore errors
if(error)
return;

//TODO
MatrixWorkspace_sptr ws =
AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("CalculatedSampleTransmission");

// Fill the output table
m_uiForm.twResults->clear();

double scattering = ws->dataY(1)[0];
QTreeWidgetItem *scatteringItem = new QTreeWidgetItem();
scatteringItem->setText(0, "Scattering");
scatteringItem->setText(1, QString::number(scattering));
m_uiForm.twResults->addTopLevelItem(scatteringItem);

QTreeWidgetItem *transmissionItem = new QTreeWidgetItem();
transmissionItem->setText(0, "Transmission");
m_uiForm.twResults->addTopLevelItem(transmissionItem);
transmissionItem->setExpanded(true);

std::vector<double> transmissionData = ws->dataY(0);
Statistics stats = getStatistics(transmissionData);

QMap<QString, double> transmissionStats;
transmissionStats["Min"] = stats.minimum;
transmissionStats["Max"] = stats.maximum;
transmissionStats["Mean"] = stats.mean;
transmissionStats["Median"] = stats.median;
transmissionStats["Std. Dev."] = stats.standard_deviation;

for(auto it = transmissionStats.begin(); it != transmissionStats.end(); ++it)
{
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, it.key());
item->setText(1, QString::number(it.value()));
transmissionItem->addChild(item);
}

//TODO: plot
}
Expand Up @@ -21,8 +21,6 @@ namespace // anonymous
pair.second = temp;
}
}

Mantid::Kernel::Logger g_log("UserInputValidator");
} // anonymous namespace

namespace MantidQt
Expand Down

0 comments on commit 98ffcab

Please sign in to comment.