From 7565f230e66e363a32ed79ddced1f2647e2d3825 Mon Sep 17 00:00:00 2001 From: Gennady Pospelov <g.pospelov@fz-juelich.de> Date: Wed, 3 Feb 2016 17:23:20 +0100 Subject: [PATCH] IDetector now returns vector of allowed detector units --- Core/Algorithms/inc/IDetector2D.h | 4 +++- Core/Algorithms/inc/RectangularDetector.h | 3 +++ Core/Algorithms/inc/SphericalDetector.h | 3 +++ Core/Algorithms/src/IDetector2D.cpp | 6 ++++++ Core/Algorithms/src/Instrument.cpp | 10 ++++------ Core/Algorithms/src/RectangularDetector.cpp | 8 ++++++++ Core/Algorithms/src/SphericalDetector.cpp | 8 ++++++++ GUI/coregui/Models/IntensityDataItem.cpp | 4 ++-- GUI/coregui/Models/JobItem.cpp | 2 +- 9 files changed, 38 insertions(+), 10 deletions(-) diff --git a/Core/Algorithms/inc/IDetector2D.h b/Core/Algorithms/inc/IDetector2D.h index 4ac08c0f366..31358c7eb7d 100644 --- a/Core/Algorithms/inc/IDetector2D.h +++ b/Core/Algorithms/inc/IDetector2D.h @@ -119,6 +119,9 @@ public: //! Returns detector map in given axes units virtual OutputData<double> *createDetectorMap(const Beam& beam, EAxesUnits units_type) const; + //! returns vector of valid axes units + virtual std::vector<EAxesUnits> getValidAxesUnits() const; + protected: //! Create an IPixelMap for the given OutputData object and index virtual IPixelMap* createPixelMap(size_t index) const=0; @@ -152,7 +155,6 @@ protected: Eigen::Matrix2cd m_analyzer_operator; //!< polarization analyzer operator #endif DetectorMask m_detector_mask; - private: //! Verify if the given analyzer properties are physical bool checkAnalyzerProperties(const kvector_t &direction, double efficiency, diff --git a/Core/Algorithms/inc/RectangularDetector.h b/Core/Algorithms/inc/RectangularDetector.h index 728d6d75fcc..9060e4bcd3d 100644 --- a/Core/Algorithms/inc/RectangularDetector.h +++ b/Core/Algorithms/inc/RectangularDetector.h @@ -88,6 +88,9 @@ public: //! Returns detector map in given axes units virtual OutputData<double> *createDetectorMap(const Beam& beam, EAxesUnits units_type) const; + //! returns vector of valid axes units + virtual std::vector<EAxesUnits> getValidAxesUnits() const; + protected: //! Create an IPixelMap for the given OutputData object and index virtual IPixelMap* createPixelMap(size_t index) const; diff --git a/Core/Algorithms/inc/SphericalDetector.h b/Core/Algorithms/inc/SphericalDetector.h index 0f74d21aaa0..74335cc6da4 100644 --- a/Core/Algorithms/inc/SphericalDetector.h +++ b/Core/Algorithms/inc/SphericalDetector.h @@ -60,6 +60,9 @@ public: //! Returns detector map in given axes units virtual OutputData<double> *createDetectorMap(const Beam& beam, EAxesUnits units_type) const; + //! returns vector of valid axes units + virtual std::vector<EAxesUnits> getValidAxesUnits() const; + protected: //! Create an IPixelMap for the given OutputData object and index virtual IPixelMap* createPixelMap(size_t index) const; diff --git a/Core/Algorithms/src/IDetector2D.cpp b/Core/Algorithms/src/IDetector2D.cpp index fe18ffb9bf7..3dc6496b9fd 100644 --- a/Core/Algorithms/src/IDetector2D.cpp +++ b/Core/Algorithms/src/IDetector2D.cpp @@ -125,6 +125,12 @@ OutputData<double> *IDetector2D::createDetectorMap(const Beam& /* beam */, EAxes return 0; } +std::vector<IDetector2D::EAxesUnits> IDetector2D::getValidAxesUnits() const +{ + std::vector<EAxesUnits> result = {DEFAULT, NBINS}; + return result; +} + void IDetector2D::removeMasks() { m_detector_mask.removeMasks(); diff --git a/Core/Algorithms/src/Instrument.cpp b/Core/Algorithms/src/Instrument.cpp index 8f5139561d6..780505c6614 100644 --- a/Core/Algorithms/src/Instrument.cpp +++ b/Core/Algorithms/src/Instrument.cpp @@ -17,8 +17,7 @@ #include "SphericalDetector.h" #include "ConvolutionDetectorResolution.h" #include "BornAgainNamespace.h" -#include "CustomBinAxis.h" -#include "ConstKBinAxis.h" +#include <memory> Instrument::Instrument() : IParameterized("Instrument") @@ -110,11 +109,11 @@ void Instrument::applyDetectorResolution(OutputData<double> *p_intensity_map) co OutputData<double> *Instrument::getDetectorIntensity(const OutputData<double> &data, IDetector2D::EAxesUnits units_type) const { - OutputData<double> *result = data.clone(); - applyDetectorResolution(result); + std::unique_ptr<OutputData<double> > result (data.clone()); + applyDetectorResolution(result.get()); if(units_type == IDetector2D::DEFAULT) { - return result; + return result.release(); } else { OutputData<double> *detectorMap = mP_detector->createDetectorMap(m_beam, units_type); if(!detectorMap) { @@ -122,7 +121,6 @@ OutputData<double> *Instrument::getDetectorIntensity(const OutputData<double> &d "Can't create detector map."); } detectorMap->setRawDataVector(result->getRawDataVector()); - delete result; return detectorMap; } } diff --git a/Core/Algorithms/src/RectangularDetector.cpp b/Core/Algorithms/src/RectangularDetector.cpp index c12bc18285e..cfd47e0dc9d 100644 --- a/Core/Algorithms/src/RectangularDetector.cpp +++ b/Core/Algorithms/src/RectangularDetector.cpp @@ -273,6 +273,14 @@ OutputData<double> *RectangularDetector::createDetectorMap(const Beam &beam, } +std::vector<IDetector2D::EAxesUnits> RectangularDetector::getValidAxesUnits() const +{ + std::vector<IDetector2D::EAxesUnits> result = IDetector2D::getValidAxesUnits(); + std::vector<IDetector2D::EAxesUnits> addon = {RADIANS, DEGREES, MM, QYQZ}; + result.insert(result.end(), addon.begin(), addon.end()); + return result; +} + void RectangularDetector::print(std::ostream &ostr) const { ostr << "RectangularDetector: '" << getName() << "' " << m_parameters; diff --git a/Core/Algorithms/src/SphericalDetector.cpp b/Core/Algorithms/src/SphericalDetector.cpp index 3945412d1b8..e703099adc5 100644 --- a/Core/Algorithms/src/SphericalDetector.cpp +++ b/Core/Algorithms/src/SphericalDetector.cpp @@ -159,6 +159,14 @@ OutputData<double> *SphericalDetector::createDetectorMap(const Beam &beam, IDete } +std::vector<IDetector2D::EAxesUnits> SphericalDetector::getValidAxesUnits() const +{ + std::vector<IDetector2D::EAxesUnits> result = IDetector2D::getValidAxesUnits(); + std::vector<IDetector2D::EAxesUnits> addon = {RADIANS, DEGREES, QYQZ}; + result.insert(result.end(), addon.begin(), addon.end()); + return result; +} + IPixelMap *SphericalDetector::createPixelMap(size_t index) const { const IAxis &phi_axis = getAxis(BornAgain::X_AXIS_INDEX); diff --git a/GUI/coregui/Models/IntensityDataItem.cpp b/GUI/coregui/Models/IntensityDataItem.cpp index 75408bae6ae..f00b192138a 100644 --- a/GUI/coregui/Models/IntensityDataItem.cpp +++ b/GUI/coregui/Models/IntensityDataItem.cpp @@ -53,7 +53,7 @@ QMap<QString, IDetector2D::EAxesUnits> IntensityDataItem::m_description_to_units IntensityDataItem::IntensityDataItem(ParameterizedItem *parent) : ParameterizedItem(Constants::IntensityDataType, parent) { - registerProperty(P_NAME, Constants::IntensityDataType); + registerProperty(P_NAME, Constants::IntensityDataType).setHidden(); ComboProperty units; units << Constants::UnitsNbins << Constants::UnitsRadians << Constants::UnitsDegrees @@ -61,7 +61,7 @@ IntensityDataItem::IntensityDataItem(ParameterizedItem *parent) registerProperty(P_AXES_UNITS, units.getVariant()).setHidden(); - registerProperty(P_PROJECTIONS_FLAG, false); + registerProperty(P_PROJECTIONS_FLAG, false).setHidden(); registerProperty(P_IS_INTERPOLATED, true); ComboProperty gradient; diff --git a/GUI/coregui/Models/JobItem.cpp b/GUI/coregui/Models/JobItem.cpp index 2f1e9609df5..3f075a91017 100644 --- a/GUI/coregui/Models/JobItem.cpp +++ b/GUI/coregui/Models/JobItem.cpp @@ -239,7 +239,7 @@ MultiLayerItem *JobItem::getMultiLayerItem(bool from_backup) } //! Returns InstrumentItem of this JobItem, if from_backup=true, then backup'ed version of -//! the instruyment will be used +//! the instrument will be used InstrumentItem *JobItem::getInstrumentItem(bool from_backup) { foreach(ParameterizedItem *item, childItems()) { -- GitLab