Commit be63fb12 authored by Owen Arnold's avatar Owen Arnold
Browse files

refs #6222 Add and implement query method.

parent aa8478a6
......@@ -108,6 +108,12 @@ namespace API
*/
virtual IPeak* createPeak(Mantid::Kernel::V3D QLabFrame, double detectorDistance=1.0) const = 0;
//---------------------------------------------------------------------------------------------
/** Determine if the workspace has been integrated using a peaks integration algorithm.
* @return TRUE if the workspace has been integrated.
*/
virtual bool hasIntegratedPeaks() const = 0;
};
......
......@@ -107,7 +107,7 @@ namespace DataObjects
API::IPeak* createPeak(Kernel::V3D QLabFrame, double detectorDistance=1.0) const;
std::vector<Peak> & getPeaks();
const std::vector<Peak> & getPeaks() const;
virtual bool hasIntegratedPeaks() const;
virtual size_t getMemorySize() const;
// ====================================== ITableWorkspace Methods ==================================
......
......@@ -265,6 +265,20 @@ namespace DataObjects
return peaks;
}
/** Getter for the integration status.
@return TRUE if it has been integrated using a peak integration algorithm.
*/
bool PeaksWorkspace::hasIntegratedPeaks() const
{
bool ret = false;
const std::string peaksIntegrated = "PeaksIntegrated";
if(this->run().hasProperty(peaksIntegrated))
{
ret = boost::lexical_cast<bool>(this->run().getProperty(peaksIntegrated)->value());
}
return ret;
}
//---------------------------------------------------------------------------------------------
/// Return the memory used in bytes
size_t PeaksWorkspace::getMemorySize() const
......
......@@ -269,6 +269,28 @@ public:
TSM_ASSERT_THROWS_NOTHING("should clearly delete pw",delete pw);
}
void test_hasIntegratedPeaks_without_property()
{
PeaksWorkspace ws;
TSM_ASSERT("Should not indicate that there are integrated peaks without property.", !ws.hasIntegratedPeaks());
}
void test_hasIntegratedPeaks_with_property_when_false()
{
PeaksWorkspace ws;
bool hasIntegratedPeaks = false;
ws.mutableRun().addProperty("PeaksIntegrated", hasIntegratedPeaks);
TS_ASSERT_EQUALS(hasIntegratedPeaks, ws.hasIntegratedPeaks());
}
void test_hasIntegratedPeaks_with_property_when_true()
{
PeaksWorkspace ws;
bool hasIntegratedPeaks = true;
ws.mutableRun().addProperty("PeaksIntegrated", hasIntegratedPeaks);
TS_ASSERT_EQUALS(hasIntegratedPeaks, ws.hasIntegratedPeaks());
}
PeaksWorkspaceTest()
{
FrameworkManager::Instance();
......
......@@ -308,6 +308,9 @@ namespace MDEvents
<< std::endl;
}
// This flag is used by the PeaksWorkspace to evaluate whether it has been integrated.
peakWS->mutableRun().addProperty("PeaksIntegrated", true, true);
// These flags are specific to the algorithm.
peakWS->mutableRun().addProperty("PeakRadius", PeakRadius, true);
peakWS->mutableRun().addProperty("BackgroundInnerRadius", BackgroundInnerRadius, true);
peakWS->mutableRun().addProperty("BackgroundOuterRadius", BackgroundOuterRadius, true);
......
......@@ -293,6 +293,7 @@ public:
TS_ASSERT_EQUALS(peakRadius, actualPeakRadius);
TS_ASSERT_EQUALS(backgroundOutterRadius, actualBackgroundOutterRadius);
TS_ASSERT_EQUALS(backgroundInnerRadius, actualBackgroundInnerRadius);
TS_ASSERT(outWS->hasIntegratedPeaks());
}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment